LawyerMorty

AssaultCube Cheat Program Source

Dec 6th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.85 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. HWND hook(char* process) {
  6.     HWND hWnd = FindWindowA(NULL, process);
  7.  
  8.     return hWnd;
  9. }
  10.  
  11. int base = 0x400000; // Base Address
  12. int offset_lp = 0x10F4F4; // Local Player Offset
  13. int lp = 0; // Local Player
  14.  
  15. int ammoAddr = 0x0150; // Ammo Address Offset
  16. int fragAddr = 0x0158; // Frag Grenade Address Offset
  17. int armrAddr = 0x0128; // Armor Address Offset
  18.  
  19. void GetLocalPlayer(HANDLE handle) {
  20.     ReadProcessMemory(handle, (LPVOID)(base + offset_lp), &lp, sizeof(int), 0);
  21. }
  22.  
  23. int GetAddress(int fromOffset) {
  24.     return (lp + fromOffset);
  25. }
  26.  
  27. // Ammunition
  28. int GetAmmo(HANDLE handle) {
  29.     int current = 0;
  30.  
  31.     ReadProcessMemory(handle, (LPVOID)GetAddress(ammoAddr), &current, sizeof(int), 0);
  32.  
  33.     return current;
  34. }
  35.  
  36. void SetAmmo(HANDLE handle, int value) {
  37.     WriteProcessMemory(handle, (LPVOID)GetAddress(ammoAddr), &value, sizeof(int), 0);
  38. }
  39.  
  40. void AddAmmo(HANDLE handle, int value) {
  41.     int current = GetAmmo(handle);
  42.     int new_val = current + value;
  43.     printf("Setting ammo from %d to %d\n", current, new_val);
  44.  
  45.     SetAmmo(handle, new_val);
  46. }
  47.  
  48. // Frag Grenades
  49. int GetFrags(HANDLE handle) {
  50.     int current = 0;
  51.  
  52.     ReadProcessMemory(handle, (LPVOID)GetAddress(fragAddr), &current, sizeof(0), 0);
  53.  
  54.     return current;
  55. }
  56.  
  57. void SetFrags(HANDLE handle, int value) {
  58.     WriteProcessMemory(handle, (LPVOID)GetAddress(fragAddr), &value, sizeof(int), 0);
  59. }
  60.  
  61. void AddFrags(HANDLE handle, int value) {
  62.     int current = GetFrags(handle);
  63.     int new_val = current + value;
  64.     printf("Setting frag from %d to %d\n", current, new_val);
  65.  
  66.     SetFrags(handle, new_val);
  67. }
  68.  
  69. // Armor
  70. int GetArmor(HANDLE handle) {
  71.     int current = 0;
  72.  
  73.     ReadProcessMemory(handle, (LPVOID)GetAddress(armrAddr), &current, sizeof(0), 0);
  74.  
  75.     return current;
  76. }
  77.  
  78. void SetArmor(HANDLE handle, int value) {
  79.     WriteProcessMemory(handle, (LPVOID)GetAddress(armrAddr), &value, sizeof(int), 0);
  80. }
  81.  
  82. void AddArmor(HANDLE handle, int value) {
  83.     int current = GetArmor(handle);
  84.     int new_val = current + value;
  85.     printf("Setting armor from %d to %d\n", current, new_val);
  86.  
  87.     SetArmor(handle, new_val);
  88. }
  89.  
  90. int main()
  91. {
  92.     char process_name[] = "AssaultCube";
  93.  
  94.     int ammo_val = 99;
  95.     HWND hWnd = hook(process_name);
  96.  
  97.     if (hWnd == NULL) {
  98.         printf("Failed to hook into %s\n", process_name);
  99.         return -1;
  100.     }
  101.  
  102.     printf("Hooked into '%s'!\n", process_name);
  103.  
  104.     DWORD process_id;
  105.     GetWindowThreadProcessId(hWnd, &process_id);
  106.     HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);
  107.  
  108.     GetLocalPlayer(handle);
  109.  
  110.     int currentAmmo = GetAmmo(handle);
  111.     int currentFrag = GetFrags(handle);
  112.     int currentArmr = GetArmor(handle);
  113.  
  114.     printf("Current Ammo: %d.\n", currentAmmo);
  115.  
  116.     printf("Current Frags: %d.\n", currentFrag);
  117.  
  118.     printf("Current Armor: %d.\n", currentArmr);
  119.  
  120.     AddFrags(handle, 2);
  121.     AddAmmo(handle, 1000);
  122.     AddArmor(handle, 200);
  123.  
  124.     return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment