Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------------------------------
- // Data declarations
- extern _UNKNOWN loc_401A87; // weak
- extern _UNKNOWN loc_406E89; // weak
- extern char aGetprocesswind[]; // idb
- extern char aGetuserobjecti[]; // idb
- extern char aGetlastactivep[]; // idb
- extern char aGetactivewindo[]; // idb
- extern char aMessageboxw[]; // idb
- extern const WCHAR aUser32_dll[]; // idb
- extern char buf[8]; // idb
- extern int dword_40AA24; // weak
- extern int dword_40AA28; // weak
- extern __int16 word_40AA2C; // weak
- extern char byte_40AA2E; // weak
- extern int dword_40AA30; // weak
- extern int dword_40AA34; // weak
- extern int dword_40AA38; // weak
- extern __int16 word_40AA3C; // weak
- extern char byte_40AA3E; // weak
- extern _WORD aPLd[36]; // idb
- extern const WCHAR LibFileName[]; // idb
- extern char ProcName[]; // idb
- extern wchar_t aMemoryWritingE[25]; // weak
- extern wchar_t aThreadSuspendE[25]; // weak
- extern wchar_t aThreadResumeEr[24]; // weak
- extern wchar_t aMemoryProtecti[28]; // weak
- extern wchar_t aMemoryReadingE[25]; // weak
- extern wchar_t aFunctionNotFou[22]; // weak
- extern wchar_t aErrorOpeningPr[25]; // weak
- extern char aConnect[]; // idb
- extern wchar_t aAllWritesSuces[26]; // weak
- extern wchar_t aMemoryAllocati[28]; // weak
- extern wchar_t aUnableToGetPro[32]; // weak
- extern char cp[]; // idb
- extern wchar_t aAuthenticating[24]; // weak
- extern wchar_t asc_40AD04[2]; // weak
- extern wchar_t asc_40AD08[2]; // weak
- extern wchar_t aAcceptFailedD[17]; // weak
- extern wchar_t aListenFailedD[17]; // weak
- extern wchar_t aBindsocketFail[21]; // weak
- extern wchar_t aSocketCreation[26]; // weak
- extern wchar_t aMemoryAlloca_0[28]; // weak
- extern wchar_t a_ini[5]; // weak
- extern const WCHAR KeyName[]; // idb
- extern const WCHAR AppName[]; // idb
- extern wchar_t aExecutableFile[25]; // weak
- extern wchar_t aSelectApplicat[30]; // weak
- extern char a83_222_115_46[]; // idb
- extern wchar_t aCreatingProces[24]; // weak
- extern wchar_t aOk[4]; // weak
- extern wchar_t aPatchOk___[13]; // weak
- extern wchar_t aResumethreadEr[23]; // weak
- extern wchar_t aPatchFailed___[17]; // weak
- extern wchar_t aInitialization[26]; // weak
- extern wchar_t aCreateProcessE[25]; // weak
- extern _UNKNOWN unk_40B040; // weak
- extern _UNKNOWN unk_40B048; // weak
- extern int __security_cookie; // weak
- extern void *off_40C180; // weak
- extern HANDLE hConsoleOutput; // idb
- extern PVOID dword_40D754; // idb
- extern PVOID dword_40D768; // idb
- extern PVOID dword_40DAEC; // idb
- extern int dword_40DAFC; // weak
- extern PVOID dword_40DB00; // idb
- extern PVOID dword_40DB04; // idb
- extern PVOID dword_40DB08; // idb
- extern PVOID dword_40DB0C; // idb
- extern PVOID dword_40DB10; // idb
- extern int dword_40DB44; // weak
- extern int dword_40DB48; // weak
- extern UINT uNumber; // idb
- extern int dword_40DB60[]; // weak
- //-------------------------------------------------------------------------
- // Function declarations
- // bool __usercall sub_401000<al>(DWORD a1<eax>, void *hThread);
- bool __fastcall sub_4011C0(HANDLE hThread, DWORD dwProcessId, DWORD dwProcessIda, int a4);
- int __cdecl sub_401430();
- // bool __usercall sub_401610<al>(void *a1<ebx>, void *a2);
- int __cdecl main(int argc, const char **argv, const char **envp);
- // void *__cdecl malloc(size_t);
- // wchar_t *__cdecl wcsncpy(wchar_t *, const wchar_t *, size_t);
- signed int __cdecl sub_4019F3(int a1, char a2);
- // int *__cdecl _errno();
- // unsigned __int32 *__cdecl __doserrno();
- void *__cdecl sub_4022D6(void *a1);
- void **__cdecl sub_40230D();
- // _DWORD __cdecl _lock_file2(_DWORD, _DWORD); weak
- // _DWORD __cdecl _unlock_file2(_DWORD, _DWORD); weak
- // int __cdecl _stbuf(FILE *); idb
- // _DWORD __cdecl _ftbuf(_DWORD, FILE *); weak
- // _DWORD __cdecl _woutput_l(_DWORD, _DWORD, _DWORD, _DWORD); weak
- void *__cdecl sub_403285(void *a1);
- // int _invalid_parameter_noinfo(void); weak
- int (*__cdecl sub_403D26())(void);
- int (*__cdecl sub_403D4C())(void);
- // int _encoded_null(void); weak
- void __cdecl sub_404281();
- PVOID __cdecl sub_4044D5();
- int __cdecl sub_404694(int a1);
- int __cdecl sub_4049DB(int a1, int a2, int a3);
- // _DWORD __cdecl flsall(_DWORD); weak
- int __cdecl sub_405086();
- // void *__cdecl memset(void *, int, size_t);
- // int __cdecl _write_nolock(int, int, DWORD nNumberOfBytesToWrite); idb
- int __cdecl sub_406DBD(int, int, DWORD nNumberOfBytesToWrite); // idb
- int __cdecl sub_407CA0();
- // _DWORD __cdecl __lock_fhandle(_DWORD); weak
- // _DWORD __cdecl _unlock_fhandle(_DWORD); weak
- BOOL __cdecl sub_4084A8();
- // BOOL __stdcall GetOpenFileNameW(LPOPENFILENAMEW);
- // DWORD __stdcall GetPrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName);
- // HANDLE __stdcall OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId);
- // HMODULE __stdcall LoadLibraryW(LPCWSTR lpLibFileName);
- // void __stdcall Sleep(DWORD dwMilliseconds);
- // BOOL __stdcall ReadProcessMemory(HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead);
- // BOOL __stdcall TerminateProcess(HANDLE hProcess, UINT uExitCode);
- // DWORD __stdcall GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize);
- // HANDLE __stdcall CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
- // HMODULE __stdcall GetModuleHandleW(LPCWSTR lpModuleName);
- // DWORD __stdcall GetLastError();
- // FARPROC __stdcall GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
- // BOOL __stdcall VirtualProtectEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
- // LPVOID __stdcall VirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
- // BOOL __stdcall CloseHandle(HANDLE hObject);
- // BOOL __stdcall WriteProcessMemory(HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesWritten);
- // DWORD __stdcall SuspendThread(HANDLE hThread);
- // DWORD __stdcall ResumeThread(HANDLE hThread);
- // BOOL __stdcall WritePrivateProfileStringW(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpString, LPCWSTR lpFileName);
- // BOOL __stdcall CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
- // BOOL __stdcall IsProcessorFeaturePresent(DWORD ProcessorFeature);
- // PVOID __stdcall DecodePointer(PVOID Ptr);
- // PVOID __stdcall EncodePointer(PVOID Ptr);
- // int __stdcall WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData);
- // unsigned __int32 __stdcall inet_addr(const char *cp);
- // int __stdcall WSAGetLastError();
- // u_short __stdcall htons(u_short hostshort);
- // int __stdcall recv(SOCKET s, char *buf, int len, int flags);
- // int __stdcall bind(SOCKET s, const struct sockaddr *name, int namelen);
- // SOCKET __stdcall socket(int af, int type, int protocol);
- // int __stdcall closesocket(SOCKET s);
- // int __stdcall send(SOCKET s, const char *buf, int len, int flags);
- // int __stdcall listen(SOCKET s, int backlog);
- // SOCKET __stdcall accept(SOCKET s, struct sockaddr *addr, int *addrlen);
- //----- (00401000) --------------------------------------------------------
- bool __usercall sub_401000<al>(DWORD a1<eax>, void *hThread)
- {
- HANDLE v2; // edi@1
- HMODULE v3; // eax@2
- FARPROC v4; // esi@2
- int v5; // eax@3
- char v7; // al@19
- int v8; // [sp-Ch] [bp-28h]@12
- char v9; // [sp-8h] [bp-24h]@12
- int v10; // [sp+8h] [bp-14h]@1
- int v11; // [sp+Ch] [bp-10h]@1
- DWORD flOldProtect; // [sp+10h] [bp-Ch]@6
- SIZE_T NumberOfBytesWritten; // [sp+14h] [bp-8h]@4
- int Buffer; // [sp+18h] [bp-4h]@3
- v10 = 65259;
- v11 = 0;
- v2 = OpenProcess(0x38u, 0, a1);
- if ( v2 )
- {
- LoadLibraryW(L"ws2_32.dll");
- v3 = GetModuleHandleW(L"ws2_32.dll");
- v4 = GetProcAddress(v3, "WSAStartup");
- if ( !v4 )
- {
- v9 = GetLastError();
- v8 = (int)L"Function not found:%d";
- goto LABEL_18;
- }
- Buffer = 0;
- ResumeThread(hThread);
- v5 = 0;
- if ( 0 != *(_WORD *)v4 )
- {
- do
- {
- ReadProcessMemory(v2, v4, &Buffer, 2u, &NumberOfBytesWritten);
- v5 = Buffer;
- }
- while ( Buffer != *(_WORD *)v4 );
- }
- if ( v5 != *(_WORD *)v4 )
- {
- v9 = GetLastError();
- v8 = (int)L"Memory reading error:%d\n";
- goto LABEL_18;
- }
- if ( !VirtualProtectEx(v2, v4, 2u, 0x40u, &flOldProtect) )
- {
- v9 = GetLastError();
- v8 = (int)L"Memory protection error:%d\n";
- goto LABEL_18;
- }
- if ( WriteProcessMemory(v2, v4, &v10, 2u, &NumberOfBytesWritten) )
- {
- if ( ResumeThread(hThread) == -1 )
- {
- v9 = GetLastError();
- v8 = (int)L"Thread resume error:%d\n";
- goto LABEL_18;
- }
- Sleep(0x1388u);
- if ( SuspendThread(hThread) == -1 )
- {
- v9 = GetLastError();
- v8 = (int)L"Thread suspend error:%d\n";
- goto LABEL_18;
- }
- if ( WriteProcessMemory(v2, v4, v4, 2u, &NumberOfBytesWritten) )
- {
- VirtualProtectEx(v2, v4, 2u, flOldProtect, &flOldProtect);
- v11 = 1;
- CloseHandle(v2);
- return v11 != 0;
- }
- }
- v9 = GetLastError();
- v8 = (int)L"Memory writing error:%d\n";
- LABEL_18:
- sub_4019F3(v8, v9);
- CloseHandle(v2);
- return v11 != 0;
- }
- v7 = GetLastError();
- sub_4019F3((int)L"Error opening process:%d", v7);
- return v11 != 0;
- }
- // 40AAAC: using guessed type wchar_t aMemoryWritingE[25];
- // 40AAE0: using guessed type wchar_t aThreadSuspendE[25];
- // 40AB14: using guessed type wchar_t aThreadResumeEr[24];
- // 40AB44: using guessed type wchar_t aMemoryProtecti[28];
- // 40AB7C: using guessed type wchar_t aMemoryReadingE[25];
- // 40ABB0: using guessed type wchar_t aFunctionNotFou[22];
- // 40ABDC: using guessed type wchar_t aErrorOpeningPr[25];
- //----- (004011C0) --------------------------------------------------------
- bool __fastcall sub_4011C0(HANDLE hThread, DWORD dwProcessId, DWORD dwProcessIda, int a4)
- {
- HANDLE v4; // esi@1
- HANDLE v5; // ebx@1
- HMODULE v6; // eax@2
- void *v7; // eax@3
- void *v8; // esi@4
- char *v9; // edx@4
- int v11; // [sp-8h] [bp-B4h]@11
- char v12; // [sp-4h] [bp-B0h]@11
- char v13; // [sp+0h] [bp-ACh]@0
- DWORD flOldProtect; // [sp+Ch] [bp-A0h]@4
- char v15; // [sp+10h] [bp-9Ch]@5
- LPVOID lpBaseAddress; // [sp+14h] [bp-98h]@3
- HANDLE hThreada; // [sp+18h] [bp-94h]@1
- void *v18; // [sp+1Ch] [bp-90h]@3
- char v19; // [sp+20h] [bp-8Ch]@4
- char *v20; // [sp+21h] [bp-8Bh]@4
- int v21; // [sp+28h] [bp-84h]@1
- LPVOID Buffer; // [sp+2Ch] [bp-80h]@2
- SIZE_T NumberOfBytesWritten; // [sp+34h] [bp-78h]@2
- char v24; // [sp+38h] [bp-74h]@4
- __int16 v25; // [sp+7Ch] [bp-30h]@4
- int v26; // [sp+7Eh] [bp-2Eh]@4
- int v27; // [sp+84h] [bp-28h]@4
- int v28; // [sp+88h] [bp-24h]@4
- __int16 v29; // [sp+8Ch] [bp-20h]@4
- char v30; // [sp+8Eh] [bp-1Eh]@4
- int v31; // [sp+8Fh] [bp-1Dh]@4
- int v32; // [sp+93h] [bp-19h]@4
- int v33; // [sp+97h] [bp-15h]@4
- int v34; // [sp+9Bh] [bp-11h]@4
- __int16 v35; // [sp+9Fh] [bp-Dh]@4
- char v36; // [sp+A1h] [bp-Bh]@4
- char *v37; // [sp+A2h] [bp-Ah]@4
- unsigned int v38; // [sp+A8h] [bp-4h]@1
- int v39; // [sp+ACh] [bp+0h]@1
- v38 = (unsigned int)&v39 ^ __security_cookie;
- v4 = hThread;
- hThreada = hThread;
- v21 = 0;
- v5 = OpenProcess(0x38u, 0, dwProcessIda);
- if ( !v5 )
- {
- v12 = GetLastError();
- v11 = (int)L"Error opening process:%d";
- goto LABEL_12;
- }
- SuspendThread(v4);
- NumberOfBytesWritten = 0;
- LoadLibraryW(L"ws2_32.dll");
- v6 = GetModuleHandleW(L"ws2_32.dll");
- Buffer = GetProcAddress(v6, "connect");
- if ( !Buffer )
- {
- sub_4019F3((int)L"Unable to get procedure address", v13);
- goto LABEL_13;
- }
- v7 = VirtualAllocEx(v5, 0, 0x6Cu, 0x1000u, 0x40u);
- lpBaseAddress = v7;
- v18 = (char *)v7 + 34;
- if ( !v7 )
- {
- v12 = GetLastError();
- v11 = (int)L"Memory allocation error:%d\n";
- goto LABEL_12;
- }
- memcpy(&v24, "P>‹D$ Æ", 0x44u);
- v20 = (char *)v7 - 10179175;
- v27 = dword_40AA24;
- v28 = dword_40AA28;
- v29 = word_40AA2C;
- v30 = byte_40AA2E;
- v32 = dword_40AA30;
- v33 = dword_40AA34;
- v34 = dword_40AA38;
- v35 = word_40AA3C;
- v36 = byte_40AA3E;
- v25 = aPLd[34];
- v8 = Buffer;
- v31 = a4;
- v9 = (char *)(Buffer - v7);
- *(LPVOID *)((char *)&Buffer + 1) = (LPVOID)(v7 - Buffer - 5);
- v26 = 10179135 - (_DWORD)((char *)v7 + 34);
- v19 = -23;
- v37 = v9 - 29;
- LOBYTE(Buffer) = -23;
- if ( !VirtualProtectEx(v5, v8, 5u, 0x40u, &flOldProtect)
- || !VirtualProtectEx(v5, (LPVOID)0x9B5284, 5u, 0x40u, (PDWORD)&v15) )
- {
- v12 = GetLastError();
- v11 = (int)L"Memory protection error:%d\n";
- goto LABEL_12;
- }
- if ( !WriteProcessMemory(v5, v8, &Buffer, 5u, &NumberOfBytesWritten)
- || !WriteProcessMemory(v5, lpBaseAddress, &v27, 0x22u, &NumberOfBytesWritten)
- || !WriteProcessMemory(v5, (LPVOID)0x9B5284, &v19, 5u, &NumberOfBytesWritten)
- || !WriteProcessMemory(v5, v18, &v24, 0x4Au, &NumberOfBytesWritten) )
- {
- v12 = GetLastError();
- v11 = (int)L"Memory writing error:%d\n";
- LABEL_12:
- sub_4019F3(v11, v12);
- LABEL_13:
- TerminateProcess(v5, 0);
- return v21 != 0;
- }
- sub_4019F3((int)L"All writes sucessfull...\n", v13);
- v21 = 1;
- ResumeThread(hThreada);
- return v21 != 0;
- }
- // 40AA24: using guessed type int dword_40AA24;
- // 40AA28: using guessed type int dword_40AA28;
- // 40AA2C: using guessed type __int16 word_40AA2C;
- // 40AA2E: using guessed type char byte_40AA2E;
- // 40AA30: using guessed type int dword_40AA30;
- // 40AA34: using guessed type int dword_40AA34;
- // 40AA38: using guessed type int dword_40AA38;
- // 40AA3C: using guessed type __int16 word_40AA3C;
- // 40AA3E: using guessed type char byte_40AA3E;
- // 40AAAC: using guessed type wchar_t aMemoryWritingE[25];
- // 40AB44: using guessed type wchar_t aMemoryProtecti[28];
- // 40ABDC: using guessed type wchar_t aErrorOpeningPr[25];
- // 40AC18: using guessed type wchar_t aAllWritesSuces[26];
- // 40AC4C: using guessed type wchar_t aMemoryAllocati[28];
- // 40AC88: using guessed type wchar_t aUnableToGetPro[32];
- // 40C004: using guessed type int __security_cookie;
- //----- (00401430) --------------------------------------------------------
- int __cdecl sub_401430()
- {
- SOCKET v0; // edi@2
- SOCKET v1; // esi@6
- int v2; // edi@7
- int v3; // eax@8
- char v4; // al@11
- int result; // eax@12
- int v6; // [sp-8h] [bp-1D8h]@14
- char v7; // [sp-4h] [bp-1D4h]@14
- char v8; // [sp+0h] [bp-1D0h]@0
- char v9; // [sp+0h] [bp-1D0h]@5
- void *buf; // [sp+Ch] [bp-1C4h]@1
- int addrlen; // [sp+10h] [bp-1C0h]@4
- SOCKET v13; // [sp+14h] [bp-1BCh]@2
- struct WSAData WSAData; // [sp+18h] [bp-1B8h]@2
- struct sockaddr addr; // [sp+1ACh] [bp-24h]@6
- struct sockaddr name; // [sp+1BCh] [bp-14h]@3
- unsigned int v17; // [sp+1CCh] [bp-4h]@1
- int v18; // [sp+1D0h] [bp+0h]@1
- v17 = (unsigned int)&v18 ^ __security_cookie;
- buf = malloc(0x112u);
- if ( !buf )
- {
- v7 = GetLastError();
- v6 = (int)L"Memory allocation failed:%d";
- return sub_4019F3(v6, v7);
- }
- memset(&WSAData, 0, 0x190u);
- WSAStartup(0x202u, &WSAData);
- v0 = socket(2, 1, 6);
- v13 = v0;
- if ( v0 == -1 )
- {
- v7 = WSAGetLastError();
- v6 = (int)L"Socket creation failed:%d";
- return sub_4019F3(v6, v7);
- }
- *(_DWORD *)&name.sa_family = 0;
- *(_DWORD *)&name.sa_data[2] = 0;
- *(_DWORD *)&name.sa_data[6] = 0;
- *(_DWORD *)&name.sa_data[10] = 0;
- name.sa_family = 2;
- *(_DWORD *)&name.sa_data[2] = inet_addr("127.0.0.1");
- *(_WORD *)&name.sa_data[0] = htons(0x1446u);
- if ( bind(v0, &name, 16) == -1 )
- {
- v7 = WSAGetLastError();
- v6 = (int)L"Bindsocket failed:%d";
- return sub_4019F3(v6, v7);
- }
- addrlen = 16;
- if ( listen(v0, 10) == -1 )
- {
- v7 = WSAGetLastError();
- v6 = (int)L"Listen failed:%d";
- return sub_4019F3(v6, v7);
- }
- sub_4019F3((int)L"Authenticating keys...\n", v8);
- do
- {
- v1 = accept(v0, &addr, &addrlen);
- if ( v1 == -1 )
- {
- v4 = WSAGetLastError();
- sub_4019F3((int)L"Accept failed:%d", v4);
- }
- else
- {
- sub_4019F3((int)L"<", v9);
- v2 = 274;
- do
- {
- v3 = recv(v1, (char *)buf, v2, 0);
- if ( v3 == -1 )
- break;
- v2 -= v3;
- }
- while ( v2 );
- sub_4019F3((int)L">", v9);
- send(v1, "KlëºÐh¼3", 26, 0);
- v0 = v13;
- }
- result = closesocket(v1);
- }
- while ( v1 != -1 );
- return result;
- }
- // 40ACD4: using guessed type wchar_t aAuthenticating[24];
- // 40AD04: using guessed type wchar_t asc_40AD04[2];
- // 40AD08: using guessed type wchar_t asc_40AD08[2];
- // 40AD0C: using guessed type wchar_t aAcceptFailedD[17];
- // 40AD30: using guessed type wchar_t aListenFailedD[17];
- // 40AD54: using guessed type wchar_t aBindsocketFail[21];
- // 40AD80: using guessed type wchar_t aSocketCreation[26];
- // 40ADB4: using guessed type wchar_t aMemoryAlloca_0[28];
- // 40C004: using guessed type int __security_cookie;
- //----- (00401610) --------------------------------------------------------
- bool __usercall sub_401610<al>(void *a1<ebx>, void *a2)
- {
- void *v2; // edi@1
- DWORD v3; // esi@1
- bool v4; // zf@1
- int v5; // eax@6
- __int16 v6; // cx@7
- void *v7; // eax@8
- __int16 v8; // cx@9
- HANDLE v9; // eax@12
- void *v10; // esi@14
- __int16 v11; // ax@15
- bool v12; // zf@16
- struct tagOFNW v14; // [sp+8h] [bp-64h]@11
- int v15; // [sp+64h] [bp-8h]@1
- v15 = 0;
- memset(a1, 0, 0x208u);
- memset(a2, 0, 0x208u);
- v2 = malloc(0x410u);
- v3 = GetModuleFileNameW(0, (LPWSTR)v2, 0x104u);
- v4 = v3 == 0;
- if ( (signed int)v3 > 0 )
- {
- do
- {
- if ( *((_WORD *)v2 + v3) == 46 )
- break;
- --v3;
- }
- while ( (signed int)v3 > 0 );
- v4 = v3 == 0;
- }
- if ( !v4 )
- {
- v5 = (int)L".ini";
- do
- {
- v6 = *(_WORD *)v5;
- *(_WORD *)((char *)v2 + 2 * v3 - (_DWORD)L".ini" + v5) = *(_WORD *)v5;
- v5 += 2;
- }
- while ( v6 );
- }
- GetPrivateProfileStringW(L"cfg", L"Exec", 0, (LPWSTR)a1, 0x104u, (LPCWSTR)v2);
- v7 = a1;
- do
- {
- v8 = *(_WORD *)v7;
- v7 = (char *)v7 + 2;
- }
- while ( v8 );
- if ( !((signed int)(v7 - ((char *)a1 + 2)) >> 1) )
- {
- memset(&v14, 0, 0x58u);
- v14.lpstrFilter = L"Executable files (*.exe)";
- v14.nMaxFile = 260;
- v14.lpstrFile = (LPWSTR)a1;
- v14.lpstrTitle = L"Select application executable";
- v14.lStructSize = 88;
- if ( !GetOpenFileNameW(&v14) || (v9 = CreateFileW((LPCWSTR)v2, 0x40000000u, 2u, 0, 2u, 0, 0)) == 0 )
- {
- LABEL_19:
- v12 = v3 == 0;
- goto LABEL_20;
- }
- CloseHandle(v9);
- WritePrivateProfileStringW(L"cfg", L"Exec", (LPCWSTR)a1, (LPCWSTR)v2);
- }
- v10 = a1;
- v15 = 1;
- do
- {
- v11 = *(_WORD *)v10;
- v10 = (char *)v10 + 2;
- }
- while ( v11 );
- v3 = (signed int)(v10 - ((char *)a1 + 2)) >> 1;
- v12 = v3 == 0;
- if ( (signed int)v3 > 0 )
- {
- do
- {
- if ( *((_WORD *)a1 + v3) == 92 )
- break;
- --v3;
- }
- while ( (signed int)v3 > 0 );
- goto LABEL_19;
- }
- LABEL_20:
- if ( !v12 )
- {
- wcsncpy((wchar_t *)a2, (const wchar_t *)a1, v3 + 1);
- *((_WORD *)a2 + v3 + 1) = 0;
- }
- return v15 != 0;
- }
- // 40ADEC: using guessed type wchar_t a_ini[5];
- // 40AE10: using guessed type wchar_t aExecutableFile[25];
- // 40AE54: using guessed type wchar_t aSelectApplicat[30];
- //----- (00401790) --------------------------------------------------------
- int __cdecl main(int argc, const char **argv, const char **envp)
- {
- void *v3; // ebx@1
- void *v4; // esi@1
- int v5; // eax@4
- DWORD v6; // edx@4
- int result; // eax@6
- char v8; // al@7
- char v9; // al@11
- int v10; // [sp-4h] [bp-64h]@8
- char v11; // [sp+0h] [bp-60h]@0
- char v12; // [sp+0h] [bp-60h]@3
- struct _PROCESS_INFORMATION ProcessInformation; // [sp+8h] [bp-58h]@2
- struct _STARTUPINFOW StartupInfo; // [sp+18h] [bp-48h]@2
- v3 = malloc(0x208u);
- v4 = malloc(0x208u);
- if ( !sub_401610(v3, v4) )
- return 0;
- memset(&StartupInfo, 0, 0x44u);
- StartupInfo.cb = 68;
- ProcessInformation.hProcess = 0;
- ProcessInformation.hThread = 0;
- ProcessInformation.dwProcessId = 0;
- ProcessInformation.dwThreadId = 0;
- sub_4019F3((int)L"Creating process %ws...", (char)v3);
- if ( !CreateProcessW((LPCWSTR)v3, 0, 0, 0, 0, 4u, 0, (LPCWSTR)v4, &StartupInfo, &ProcessInformation) )
- {
- v9 = GetLastError();
- sub_4019F3((int)L"Create process error %d\n", v9);
- return 0;
- }
- sub_4019F3((int)L"OK\n", v11);
- if ( !sub_401000(ProcessInformation.dwProcessId, ProcessInformation.hThread) )
- {
- v10 = (int)L"Initialization Failed...\n";
- goto LABEL_10;
- }
- v5 = inet_addr("83.222.115.46");
- if ( !sub_4011C0(ProcessInformation.hThread, v6, ProcessInformation.dwProcessId, v5) )
- {
- v10 = (int)L"Patch Failed...\n";
- LABEL_10:
- sub_4019F3(v10, v12);
- TerminateProcess(ProcessInformation.hProcess, 0);
- return 0;
- }
- sub_4019F3((int)L"Patch OK...\n", v12);
- if ( ResumeThread(ProcessInformation.hThread) == -1 )
- {
- v8 = GetLastError();
- sub_4019F3((int)L"ResumeThread error %d\n", v8);
- TerminateProcess(ProcessInformation.hProcess, 0);
- result = 0;
- }
- else
- {
- sub_401430();
- result = 0;
- }
- return result;
- }
- // 40AEA0: using guessed type wchar_t aCreatingProces[24];
- // 40AED0: using guessed type wchar_t aOk[4];
- // 40AED8: using guessed type wchar_t aPatchOk___[13];
- // 40AEF4: using guessed type wchar_t aResumethreadEr[23];
- // 40AF24: using guessed type wchar_t aPatchFailed___[17];
- // 40AF48: using guessed type wchar_t aInitialization[26];
- // 40AF7C: using guessed type wchar_t aCreateProcessE[25];
- //----- (004019F3) --------------------------------------------------------
- signed int __cdecl sub_4019F3(int a1, char a2)
- {
- signed int result; // eax@2
- void **v3; // eax@3
- void **v4; // eax@3
- int v5; // edi@3
- void **v6; // eax@3
- void **v7; // eax@3
- void **v8; // eax@3
- if ( a1 != 0 )
- {
- v3 = sub_40230D();
- _lock_file2(1, v3 + 8);
- v4 = sub_40230D();
- v5 = _stbuf((FILE *)v4 + 1);
- v6 = sub_40230D();
- _woutput_l(v6 + 8, a1, 0, &a2);
- v7 = sub_40230D();
- _ftbuf(v5, (FILE *)v7 + 1);
- v8 = sub_40230D();
- result = _unlock_file2(1, v8 + 8);
- }
- else
- {
- *_errno() = 22;
- _invalid_parameter_noinfo();
- result = -1;
- }
- return result;
- }
- // 402425: using guessed type _DWORD __cdecl _lock_file2(_DWORD, _DWORD);
- // 402493: using guessed type _DWORD __cdecl _unlock_file2(_DWORD, _DWORD);
- // 40255E: using guessed type _DWORD __cdecl _ftbuf(_DWORD, FILE *);
- // 4026C1: using guessed type _DWORD __cdecl _woutput_l(_DWORD, _DWORD, _DWORD, _DWORD);
- // 40340F: using guessed type int _invalid_parameter_noinfo(void);
- //----- (004022D6) --------------------------------------------------------
- void *__cdecl sub_4022D6(void *a1)
- {
- void *result; // eax@1
- result = a1;
- dword_40D754 = a1;
- return result;
- }
- //----- (0040230D) --------------------------------------------------------
- void **__cdecl sub_40230D()
- {
- return &off_40C180;
- }
- // 40C180: using guessed type void *off_40C180;
- //----- (00403285) --------------------------------------------------------
- void *__cdecl sub_403285(void *a1)
- {
- void *result; // eax@1
- result = a1;
- dword_40D768 = a1;
- return result;
- }
- //----- (00403D26) --------------------------------------------------------
- int (*__cdecl sub_403D26())(void)
- {
- int (*result)(void); // eax@1
- unsigned int v1; // edi@1
- result = (int (*)(void))&unk_40B040;
- v1 = (unsigned int)&unk_40B040;
- if ( &unk_40B040 < &unk_40B040 )
- {
- do
- {
- result = *(int (**)(void))v1;
- if ( *(_DWORD *)v1 )
- result = (int (*)(void))result();
- v1 += 4;
- }
- while ( v1 < (unsigned int)&unk_40B040 );
- }
- return result;
- }
- //----- (00403D4C) --------------------------------------------------------
- int (*__cdecl sub_403D4C())(void)
- {
- int (*result)(void); // eax@1
- unsigned int v1; // edi@1
- result = (int (*)(void))&unk_40B048;
- v1 = (unsigned int)&unk_40B048;
- if ( &unk_40B048 < &unk_40B048 )
- {
- do
- {
- result = *(int (**)(void))v1;
- if ( *(_DWORD *)v1 )
- result = (int (*)(void))result();
- v1 += 4;
- }
- while ( v1 < (unsigned int)&unk_40B048 );
- }
- return result;
- }
- //----- (00404281) --------------------------------------------------------
- void __cdecl sub_404281()
- {
- dword_40DB48 = 0;
- }
- // 40DB48: using guessed type int dword_40DB48;
- //----- (004044D5) --------------------------------------------------------
- PVOID __cdecl sub_4044D5()
- {
- return DecodePointer(dword_40DAEC);
- }
- //----- (00404694) --------------------------------------------------------
- int __cdecl sub_404694(int a1)
- {
- int result; // eax@1
- result = a1;
- dword_40DAFC = a1;
- return result;
- }
- // 40DAFC: using guessed type int dword_40DAFC;
- //----- (004049DB) --------------------------------------------------------
- int __cdecl sub_4049DB(int a1, int a2, int a3)
- {
- HMODULE v3; // eax@2
- HMODULE v4; // ebx@2
- FARPROC v5; // eax@3
- FARPROC v6; // eax@4
- FARPROC v7; // eax@4
- FARPROC v8; // eax@4
- FARPROC v9; // eax@5
- int (*v10)(void); // edi@8
- PVOID v11; // eax@8
- PVOID v12; // ebx@8
- int v13; // eax@10
- int (*v14)(void); // eax@15
- PVOID v15; // eax@18
- PVOID v16; // eax@20
- char v18; // [sp+Ch] [bp-24h]@11
- int v19; // [sp+10h] [bp-20h]@1
- int v20; // [sp+14h] [bp-1Ch]@1
- void *v21; // [sp+18h] [bp-18h]@1
- int v22; // [sp+1Ch] [bp-14h]@1
- char v23; // [sp+20h] [bp-10h]@11
- char v24; // [sp+28h] [bp-8h]@12
- unsigned int v25; // [sp+2Ch] [bp-4h]@1
- int v26; // [sp+30h] [bp+0h]@1
- v25 = (unsigned int)&v26 ^ __security_cookie;
- v19 = a1;
- v20 = a2;
- v22 = 0;
- v21 = (void *)_encoded_null();
- if ( !dword_40DB00 )
- {
- v3 = LoadLibraryW(L"USER32.DLL");
- v4 = v3;
- if ( !v3 || (v5 = GetProcAddress(v3, "MessageBoxW")) == 0 )
- return 0;
- dword_40DB00 = EncodePointer(v5);
- v6 = GetProcAddress(v4, "GetActiveWindow");
- dword_40DB04 = EncodePointer(v6);
- v7 = GetProcAddress(v4, "GetLastActivePopup");
- dword_40DB08 = EncodePointer(v7);
- v8 = GetProcAddress(v4, "GetUserObjectInformationW");
- dword_40DB10 = EncodePointer(v8);
- if ( dword_40DB10 )
- {
- v9 = GetProcAddress(v4, "GetProcessWindowStation");
- dword_40DB0C = EncodePointer(v9);
- }
- }
- if ( dword_40DB0C == v21
- || dword_40DB10 == v21
- || (v10 = (int (*)(void))DecodePointer(dword_40DB0C), v11 = DecodePointer(dword_40DB10), v12 = v11, !v10)
- || !v11
- || (v13 = v10()) != 0
- && ((int (__stdcall *)(int, signed int, char *, signed int, char *))v12)(v13, 1, &v23, 12, &v18)
- && v24 & 1 )
- {
- if ( dword_40DB04 != v21 )
- {
- v14 = (int (*)(void))DecodePointer(dword_40DB04);
- if ( v14 )
- {
- v22 = v14();
- if ( v22 )
- {
- if ( dword_40DB08 != v21 )
- {
- v15 = DecodePointer(dword_40DB08);
- if ( v15 )
- v22 = ((int (__stdcall *)(int))v15)(v22);
- }
- }
- }
- }
- }
- else
- {
- a3 |= 0x200000u;
- }
- v16 = DecodePointer(dword_40DB00);
- if ( v16 )
- return ((int (__stdcall *)(int, int, int, int))v16)(v22, v19, v20, a3);
- return 0;
- }
- // 403D72: using guessed type int _encoded_null(void);
- // 40C004: using guessed type int __security_cookie;
- //----- (00405086) --------------------------------------------------------
- int __cdecl sub_405086()
- {
- return flsall(1);
- }
- // 404FAC: using guessed type _DWORD __cdecl flsall(_DWORD);
- //----- (00406DBD) --------------------------------------------------------
- signed int __cdecl sub_406DBD(int a1, int a2, DWORD nNumberOfBytesToWrite)
- {
- int *v4; // edi@7
- int v5; // esi@7
- if ( a1 == -2 )
- {
- *__doserrno() = 0;
- *_errno() = 9;
- return -1;
- }
- if ( a1 < 0 || a1 >= uNumber || (v4 = &dword_40DB60[a1 >> 5], v5 = (a1 & 0x1F) << 6, !(*(_BYTE *)(*v4 + v5 + 4) & 1)) )
- {
- *__doserrno() = 0;
- *_errno() = 9;
- _invalid_parameter_noinfo();
- return -1;
- }
- __lock_fhandle(a1);
- if ( *(_BYTE *)(*v4 + v5 + 4) & 1 )
- {
- _write_nolock(a1, a2, nNumberOfBytesToWrite);
- }
- else
- {
- *_errno() = 9;
- *__doserrno() = 0;
- }
- return _unlock_fhandle(a1);
- }
- // 40340F: using guessed type int _invalid_parameter_noinfo(void);
- // 40837A: using guessed type _DWORD __cdecl __lock_fhandle(_DWORD);
- // 408419: using guessed type _DWORD __cdecl _unlock_fhandle(_DWORD);
- // 40DB60: using guessed type int dword_40DB60[];
- //----- (00407CA0) --------------------------------------------------------
- int __cdecl sub_407CA0()
- {
- dword_40DB44 = IsProcessorFeaturePresent(0xAu);
- return 0;
- }
- // 40DB44: using guessed type int dword_40DB44;
- //----- (004084A8) --------------------------------------------------------
- BOOL __cdecl sub_4084A8()
- {
- BOOL result; // eax@1
- result = (BOOL)hConsoleOutput;
- if ( hConsoleOutput != (HANDLE)-1 )
- {
- if ( hConsoleOutput != (HANDLE)-2 )
- result = CloseHandle(hConsoleOutput);
- }
- return result;
- }
- // ALL OK, 19 function(s) have been successfully decompiled
Advertisement
Add Comment
Please, Sign In to add comment