SHARE
TWEET

Untitled

a guest Jun 25th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <Windows.h>
  3. #include <iostream>
  4. #include <TlHelp32.h>
  5. #include <string>
  6. #include <time.h>
  7.  
  8. const uintptr_t retOffset       = 0x2CD80;
  9. const uintptr_t shAllowedOffset = 0x68140;
  10.  
  11. uintptr_t getModuleBase(DWORD pid, const char *name)
  12. {
  13.     HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
  14.     if (snapshot != INVALID_HANDLE_VALUE)
  15.     {
  16.         MODULEENTRY32 me;
  17.         me.dwSize = sizeof(MODULEENTRY32);
  18.         if (Module32First(snapshot, &me))
  19.         {
  20.             do
  21.             {
  22.                 if (strcmp(me.szModule, name) == 0)
  23.                 {
  24.                     CloseHandle(snapshot);
  25.                     return reinterpret_cast<uintptr_t>(me.modBaseAddr);
  26.                 }
  27.             } while (Module32Next(snapshot, &me));
  28.         }
  29.     }
  30.  
  31.     return 0;
  32. }
  33.  
  34. char *getWindowTitle(HWND hwnd)
  35. {
  36.     char *windowTitle = new char[GetWindowTextLength(hwnd)];
  37.     GetWindowText(hwnd, windowTitle, sizeof(windowTitle));
  38.     return windowTitle;
  39. }
  40.  
  41. int main()
  42. {
  43.     SetConsoleTitleA("FiveM ScriptHook Bypass - Created by Desudo @ https://unknowncheats.me");
  44.  
  45.     std::cout << "Waiting for window..." << std::endl;;
  46.  
  47.     HWND hwnd = NULL;
  48.     do
  49.     {
  50.         hwnd = FindWindowEx(NULL, NULL, "grcWindow", NULL);
  51.         Sleep(1000);
  52.     } while (!hwnd);
  53.  
  54.     std::wcout << "Found window (name = " << getWindowTitle(hwnd) << "), patching..." << std::endl;
  55.  
  56.     DWORD pid;
  57.     GetWindowThreadProcessId(hwnd, &pid);
  58.  
  59.     HANDLE hndl = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
  60.     if (hndl != INVALID_HANDLE_VALUE)
  61.     {
  62.         uintptr_t startAddress;
  63.         for (int i = 0; i < 5; i++)
  64.         {
  65.             startAddress = getModuleBase(pid, "adhesive.dll");
  66.             if (startAddress)
  67.                 break;
  68.  
  69.             Sleep(1000);
  70.         }
  71.  
  72.         if (startAddress)
  73.         {
  74.             void *retAddress        = reinterpret_cast<void *>(startAddress + retOffset);
  75.             void *shAllowedAddress  = reinterpret_cast<void *>(startAddress + shAllowedOffset);
  76.  
  77.             BYTE patchRet[]{
  78.                 0xC3
  79.             };
  80.  
  81.             bool patchShAllowed = true;
  82.  
  83.             DWORD oldProt;
  84.             if (VirtualProtectEx(hndl, retAddress, 1, PAGE_EXECUTE_READWRITE, &oldProt))
  85.             {
  86.                 if (!WriteProcessMemory(hndl, retAddress, &patchRet, sizeof(patchRet), NULL))
  87.                 {
  88.                     std::cout << "WriteProcessMemory failed at retAddress, try turning off your antivirus." << std::endl;
  89.                 }
  90.  
  91.                 if (!VirtualProtectEx(hndl, retAddress, 1, oldProt, &oldProt))
  92.                 {
  93.                     std::cout << "VirtualProtectEx (2) failed at retAddress, try turning off your antivirus." << std::endl;
  94.                 }
  95.             }
  96.             else
  97.             {
  98.                 std::cout << "VirtualProtectEx (2) failed at retAddress, try turning off your antivirus." << std::endl;
  99.             }
  100.  
  101.             if (!WriteProcessMemory(hndl, shAllowedAddress, &patchShAllowed, sizeof(patchShAllowed), NULL))
  102.             {
  103.                 std::cout << "WriteProcessMemory failed at shAllowedAddress, try turning off your antivirus." << std::endl;
  104.             }
  105.  
  106.             std::cout << "Patched." << std::endl;
  107.         }
  108.         else
  109.         {
  110.             std::cout << "startAddress was invalid, try closing the window with the title listed above." << std::endl;
  111.         }
  112.     }
  113.     else
  114.     {
  115.         std::cout << "OpenProcess failed, try turning off your antivirus." << std::endl;
  116.     }
  117.    
  118.     CloseHandle(hndl);
  119.  
  120.     getchar();
  121.     return 0;
  122. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top