Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int __cdecl load_config()
- {
- char v0; // bl@1
- unsigned int result; // eax@7
- FILE *File; // [sp+8h] [bp-88h]@1
- char path[128]; // [sp+Ch] [bp-84h]@3
- unsigned int v4; // [sp+8Ch] [bp-4h]@1
- int v5; // [sp+90h] [bp+0h]@1
- v4 = (unsigned int)&v5 ^ __security_cookie;
- v0 = 0;
- if ( fopen_s(&File, "masterlist_fix.cfg", "r") )
- goto LABEL_10;
- if ( fgets(&host, 128, File) )
- {
- if ( fgets(path, 128, File) )
- {
- *(&host + strcspn(&host, "\r\n")) = 0;
- path[strcspn(path, "\r\n")] = 0;
- v0 = 1;
- }
- }
- fclose(File);
- if ( !v0 )
- {
- LABEL_10:
- strcpy_s(&host, 128u, "masterlist.freeho.st");
- strcpy_s(path, 0x80u, "/sa-mp_masterlist/masterlist.txt");
- }
- sprintf_s(
- servers_buf,
- 0x1C8u,
- "GET %s HTTP/1.1\r\nContent-Type: text/html\r\nHost: %s\r\nAccept: text/html, */*\r\nUser-Agent: Mozilla/3.0 (compatible; SA:MP v0.3.7)\r\n\r\n",
- path,
- &host);
- result = strlen(servers_buf);
- servers_len = result;
- return result;
- }
- int __stdcall api_send(SOCKET s, const char *buf, int len, int flags)
- {
- int retval; // eax@2
- if ( strstr(buf, "GET /0.3.7/servers") )
- retval = pfn_send(s, servers_buf, servers_len, flags);
- else
- retval = pfn_send(s, buf, len, flags);
- return retval;
- }
- BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
- {
- HANDLE v4; // eax@3
- HANDLE v5; // eax@3
- HANDLE v6; // eax@5
- HANDLE v7; // eax@5
- if ( !is_samp_exe() )
- {
- if ( fdwReason == 1 )
- {
- load_config();
- DetourTransactionBegin();
- v4 = GetCurrentThread();
- DetourUpdateThread(v4);
- DetourAttach(&pfn_send, api_send);
- DetourTransactionCommit();
- DetourTransactionBegin();
- v5 = GetCurrentThread();
- DetourUpdateThread(v5);
- DetourAttach(&pfn_gethostbyname, sub_10001000);
- DetourTransactionCommit();
- return 1;
- }
- if ( !fdwReason )
- {
- DetourTransactionBegin();
- v6 = GetCurrentThread();
- DetourUpdateThread(v6);
- DetourDetach(&pfn_send, api_send);
- DetourTransactionCommit();
- DetourTransactionBegin();
- v7 = GetCurrentThread();
- DetourUpdateThread(v7);
- DetourDetach(&pfn_gethostbyname, sub_10001000);
- DetourTransactionCommit();
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement