Advertisement
Krampus1025

Tutorial Code

Oct 20th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.47 KB | None | 0 0
  1. #include <Windows.h>
  2.  
  3. // Grabs a handle to the specified window
  4. HANDLE GrabHandle(char * windowName) {
  5.     // Get a handle to the window
  6.     HWND windHandle = FindWindowA(NULL, windowName);
  7.  
  8.     // Get the process identifier
  9.     DWORD pid;
  10.     GetWindowThreadProcessId(windHandle, &pid);
  11.  
  12.     // Open a handle to the process
  13.     HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, false, pid);
  14.  
  15.     return handle;
  16. }
  17.  
  18. int main() {
  19.     HANDLE handle = GrabHandle("AssaultCube");
  20.     bool healthToggleOn = false;
  21.     bool ammoToggleOn = false;
  22.     bool stillHacking = true;
  23.  
  24.     while (stillHacking) {
  25.         // Toggle the health hack feature
  26.         if (GetAsyncKeyState(VK_NUMPAD1) & 1) {
  27.             healthToggleOn = !healthToggleOn;
  28.         }
  29.  
  30.         // Toggle the ammo hack feature
  31.         if (GetAsyncKeyState(VK_NUMPAD2) & 1) {
  32.             ammoToggleOn = !ammoToggleOn;
  33.         }
  34.  
  35.         // Allow the user to close the hack
  36.         if (GetAsyncKeyState(VK_NUMPAD9) & 1) {
  37.             stillHacking = false;
  38.         }
  39.  
  40.         // Set our health to 1337 if the health toggle is currently on
  41.         if (healthToggleOn) {
  42.             // The value we're setting the health to
  43.             int newValue = 1337;
  44.             // The pointer to the player object
  45.             DWORD playerObjectPointer = 0x50F4F4;
  46.  
  47.             // Read into the player object pointer to get the dynamic address of the player object
  48.             DWORD playerObject;
  49.             ReadProcessMemory(handle, (LPCVOID)playerObjectPointer, &playerObject, sizeof(playerObject), NULL);
  50.  
  51.             // Write to the health
  52.             DWORD healthOffset = 0xF8;
  53.             DWORD healthAddress = playerObject + healthOffset;
  54.             WriteProcessMemory(handle, (LPVOID)healthAddress, &newValue, sizeof(newValue), NULL);
  55.         }
  56.  
  57.         // Set the ammo for our assault rifle and pistol to 1337
  58.         if (ammoToggleOn) {
  59.             // The value we're setting the ammos to
  60.             int newValue = 1337;
  61.             // The pointer to the player object
  62.             DWORD playerObjectPointer = 0x50F4F4;
  63.  
  64.             // Read into the player object pointer to get the dynamic address of the player object
  65.             DWORD playerObject;
  66.             ReadProcessMemory(handle, (LPCVOID)playerObjectPointer, &playerObject, sizeof(playerObject), NULL);
  67.  
  68.             // Write to the assault rifle ammo
  69.             DWORD arOffset = 0x150;
  70.             DWORD arAddress = playerObject + arOffset;
  71.             WriteProcessMemory(handle, (LPVOID)arAddress, &newValue, sizeof(newValue), NULL);
  72.  
  73.             // Write to the pistol offset
  74.             DWORD pistolOffset = 0x13C;
  75.             DWORD pistolAddress = playerObject + pistolOffset;
  76.             WriteProcessMemory(handle, (LPVOID)pistolAddress, &newValue, sizeof(newValue), NULL);
  77.         }
  78.     }
  79.  
  80.     CloseHandle(handle);
  81.     return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement