Advertisement
MMMonster

Godmode Source (Skid Edition)

Jun 2nd, 2018
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string>
  4. #include <Windows.h>
  5. #include <TlHelp32.h>
  6. using namespace std;
  7. __int64 GetModuleBaseAddress(LPCSTR szProcessName, LPCSTR szModuleName) {
  8.     HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  9.     PROCESSENTRY32 pe32;
  10.     if (hSnap == INVALID_HANDLE_VALUE) {
  11.         return 0;
  12.     }
  13.     pe32.dwSize = sizeof(PROCESSENTRY32);
  14.     if (Process32First(hSnap, &pe32) == 0) {
  15.         CloseHandle(hSnap);
  16.         return 0;
  17.     }
  18.     do {
  19.         if (lstrcmp(pe32.szExeFile, szProcessName) == 0) {
  20.             int PID;
  21.             PID = pe32.th32ProcessID;
  22.             HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
  23.             MODULEENTRY32 xModule;
  24.             if (hSnap == INVALID_HANDLE_VALUE) {
  25.                 return 0;
  26.             }
  27.             xModule.dwSize = sizeof(MODULEENTRY32);
  28.             if (Module32First(hSnap, &xModule) == 0) {
  29.                 CloseHandle(hSnap);
  30.                 return 0;
  31.             }
  32.             do {
  33.                 if (lstrcmp(xModule.szModule, szModuleName) == 0) {
  34.                     CloseHandle(hSnap);
  35.                     return (__int64)xModule.modBaseAddr;
  36.                 }
  37.             } while (Module32Next(hSnap, &xModule));
  38.             CloseHandle(hSnap);
  39.             return 0;
  40.         }
  41.     } while (Process32Next(hSnap, &pe32));
  42.     CloseHandle(hSnap);
  43.     return 0;
  44. }
  45. LPCSTR GameWindow;
  46. LPCSTR GameID;
  47. HWND WindowID;
  48. __int64 BaseAddress;
  49. DWORD PID;
  50. HANDLE pHandle;
  51. byte EnableGod = 9;
  52. byte DisableGod = 0;
  53. DWORD GodOffset = 0x189;
  54. DWORD HealthOffset = 0x280;
  55. DWORD MaxHealthOffset = 0x2A0;
  56. DWORD ArmorOffset = 0x14B8;
  57. DWORD PlayerOffset = 0x8;
  58. DWORD WorldOffset_SocialClub = 0x23DE120; // Update on when new dlc come out
  59. DWORD WorldOffset_Steam = 0x23E2130; // Update on when new dlc come out
  60. __int64 GodAddress;
  61. __int64 PedAddress;
  62. __int64 PlayerPedAddress;
  63. __int64 HealthAddress;
  64. __int64 MaxHealthAddress;
  65. __int64 ArmorAddress;
  66. __int64 WantedAddress;
  67. float MaxHealth;
  68. float MaxArmor = 50;
  69. void console() {
  70.     HWND console = GetConsoleWindow();
  71.     SetWindowLong(console, GWL_STYLE, GetWindowLong(console, GWL_STYLE) & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX);
  72.     RECT r;
  73.     GetWindowRect(console, &r);
  74.     MoveWindow(console, r.left, r.top, 500, 500, TRUE);
  75.     system("color d");
  76. }
  77. void load() {
  78.     GameWindow = "Grand Theft Auto V";
  79.     GameID = "GTA5.exe";
  80.     WindowID = FindWindow(NULL, GameWindow);
  81.     BaseAddress = GetModuleBaseAddress(GameID, GameID);
  82.     GetWindowThreadProcessId(WindowID, &PID);
  83.     pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, PID);
  84. }
  85. void address() {
  86.     ReadProcessMemory(pHandle, (void*)(BaseAddress + WorldOffset_Steam), &PedAddress, sizeof(PedAddress), NULL);
  87.     ReadProcessMemory(pHandle, (void*)(PedAddress + PlayerOffset), &PlayerPedAddress, sizeof(PlayerPedAddress), NULL);
  88.     GodAddress = (PlayerPedAddress + GodOffset);
  89.     HealthAddress = (PlayerPedAddress + HealthOffset);
  90.     MaxHealthAddress = (PlayerPedAddress + MaxHealthOffset);
  91.     ArmorAddress = (PlayerPedAddress + ArmorOffset);
  92. }
  93. int main() {
  94.     load();
  95.     address();
  96.     console();
  97.     while (1)
  98.     {
  99.         if (BaseAddress == 0) {
  100.             MessageBox(NULL, "GTA5 is not running", "Error", MB_OK);
  101.             return -1;
  102.         }
  103.         int choice = 0;
  104.         cout << "1 = Toggle Godmode" << endl;
  105.         byte CheckGod = 0;
  106.         ReadProcessMemory(pHandle, (void*)(GodAddress), &CheckGod, sizeof(CheckGod), NULL);
  107.         if (CheckGod == 0) {
  108.             cout << "Godmode = Disabled" << endl;
  109.         }
  110.         if (CheckGod == 9) {
  111.             cout << "Godmode = Enabled" << endl;
  112.         }
  113.         cin >> choice;
  114.         if (choice == 1) {
  115.             if (CheckGod == 0)
  116.                 WriteProcessMemory(pHandle, (void*)GodAddress, &EnableGod, sizeof(EnableGod), NULL);
  117.             if (CheckGod == 9)
  118.                 WriteProcessMemory(pHandle, (void*)GodAddress, &DisableGod, sizeof(DisableGod), NULL);
  119.         }
  120.         system("CLS");
  121.     }
  122.     return 0;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement