Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include <iostream>
  2. #include "proc.h"
  3.  
  4. int main()
  5. {
  6. //Get ProcID of the game eg: AC_Client;
  7. DWORD procId = GetProcID(L"ac_client.exe");
  8. //Get Module base address
  9. uintptr_t modBase = GetModBaseAddress(procId, L"ac_client.exe");
  10. //Get handle process
  11. HANDLE hProc = 0;
  12. hProc = OpenProcess(PROCESS_ALL_ACCESS, NULL, procId);
  13. //Resolve base address of the pointer chain
  14. uintptr_t dynamicPtrAddress = modBase + 0x50F4F4;
  15. std::cout << "Dynamic Ptr = " << std::dec << dynamicPtrAddress << std::endl;
  16. //Ammo value
  17. int ammoValue = 0;
  18. //DWORD primaryAmmoAddress = 0x0281A4E0;
  19. std::vector<unsigned int>ammoOffset = { 0x374, 0x14, 0x0 };
  20. uintptr_t ammoAddr = FindDMAAddy(hProc, dynamicPtrAddress, ammoOffset);
  21. //Read the primary ammo address
  22. ReadProcessMemory(hProc, (BYTE*)ammoAddr, &ammoValue, sizeof(ammoValue), nullptr);
  23. std::cout << "Current Ammo = " << std::dec << ammoValue << std::endl;
  24. //Write to the new address
  25. int newAmmoValue = 9999;
  26. WriteProcessMemory(hProc, (BYTE*)ammoAddr, &newAmmoValue, sizeof(newAmmoValue), nullptr);
  27. //Read the modified address
  28. ReadProcessMemory(hProc, (BYTE*)ammoAddr, &ammoValue, sizeof(ammoValue), nullptr);
  29. std::cout << "New Ammo = " << std::dec << ammoValue << std::endl;
  30.  
  31. int healthValue = 0;
  32. std::vector<unsigned int>healthOffset = { 0xF8 };
  33. uintptr_t healthAddr = FindDMAAddy(hProc, dynamicPtrAddress, healthOffset);
  34. std::cout << "Health address = " << std::hex << healthAddr << std::endl;
  35.  
  36. ReadProcessMemory(hProc, (BYTE*)healthAddr, &healthValue, sizeof(healthValue), nullptr);
  37. std::cout << "Current Health = " << std::dec << healthValue << std::endl;
  38.  
  39. //Write to our health address the new value which in this case will be LEET
  40. int newHealthValue = 1337;
  41. WriteProcessMemory(hProc, (BYTE*)healthAddr, &newHealthValue, sizeof(newHealthValue), nullptr);
  42.  
  43. //Then read it again
  44. ReadProcessMemory(hProc, (BYTE*)healthAddr, &healthValue, sizeof(healthValue), nullptr);
  45. std::cout << "New Health = " << std::dec << healthValue << std::endl;
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement