Advertisement
Guest User

masterlist_fix.dl

a guest
Jun 5th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. unsigned int __cdecl load_config()
  2. {
  3.   char v0; // bl@1
  4.   unsigned int result; // eax@7
  5.   FILE *File; // [sp+8h] [bp-88h]@1
  6.   char path[128]; // [sp+Ch] [bp-84h]@3
  7.   unsigned int v4; // [sp+8Ch] [bp-4h]@1
  8.   int v5; // [sp+90h] [bp+0h]@1
  9.  
  10.   v4 = (unsigned int)&v5 ^ __security_cookie;
  11.   v0 = 0;
  12.   if ( fopen_s(&File, "masterlist_fix.cfg", "r") )
  13.     goto LABEL_10;
  14.   if ( fgets(&host, 128, File) )
  15.   {
  16.     if ( fgets(path, 128, File) )
  17.     {
  18.       *(&host + strcspn(&host, "\r\n")) = 0;
  19.       path[strcspn(path, "\r\n")] = 0;
  20.       v0 = 1;
  21.     }
  22.   }
  23.   fclose(File);
  24.   if ( !v0 )
  25.   {
  26. LABEL_10:
  27.     strcpy_s(&host, 128u, "masterlist.freeho.st");
  28.     strcpy_s(path, 0x80u, "/sa-mp_masterlist/masterlist.txt");
  29.   }
  30.   sprintf_s(
  31.     servers_buf,
  32.     0x1C8u,
  33.     "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",
  34.     path,
  35.     &host);
  36.   result = strlen(servers_buf);
  37.   servers_len = result;
  38.   return result;
  39. }
  40.  
  41. int __stdcall api_send(SOCKET s, const char *buf, int len, int flags)
  42. {
  43.   int retval; // eax@2
  44.  
  45.   if ( strstr(buf, "GET /0.3.7/servers") )
  46.     retval = pfn_send(s, servers_buf, servers_len, flags);
  47.   else
  48.     retval = pfn_send(s, buf, len, flags);
  49.   return retval;
  50. }
  51.  
  52. BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  53. {
  54.   HANDLE v4; // eax@3
  55.   HANDLE v5; // eax@3
  56.   HANDLE v6; // eax@5
  57.   HANDLE v7; // eax@5
  58.  
  59.   if ( !is_samp_exe() )
  60.   {
  61.     if ( fdwReason == 1 )
  62.     {
  63.       load_config();
  64.       DetourTransactionBegin();
  65.       v4 = GetCurrentThread();
  66.       DetourUpdateThread(v4);
  67.       DetourAttach(&pfn_send, api_send);
  68.       DetourTransactionCommit();
  69.       DetourTransactionBegin();
  70.       v5 = GetCurrentThread();
  71.       DetourUpdateThread(v5);
  72.       DetourAttach(&pfn_gethostbyname, sub_10001000);
  73.       DetourTransactionCommit();
  74.       return 1;
  75.     }
  76.     if ( !fdwReason )
  77.     {
  78.       DetourTransactionBegin();
  79.       v6 = GetCurrentThread();
  80.       DetourUpdateThread(v6);
  81.       DetourDetach(&pfn_send, api_send);
  82.       DetourTransactionCommit();
  83.       DetourTransactionBegin();
  84.       v7 = GetCurrentThread();
  85.       DetourUpdateThread(v7);
  86.       DetourDetach(&pfn_gethostbyname, sub_10001000);
  87.       DetourTransactionCommit();
  88.     }
  89.   }
  90.   return 1;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement