pinigin

GTA SA writing memory example

Feb 21st, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char **argv)
  7. {
  8.     DWORD proc_id;
  9.     HWND window = FindWindow(0, "GTA:SA:MP");
  10.     if (window == NULL) {
  11.         cout << "A big problems, gta_sa.exe not found!" << endl;
  12.         return 1;
  13.     }
  14.     GetWindowThreadProcessId(window, &proc_id);
  15.     cout << "Process id: " << proc_id << endl;
  16.     HANDLE handler = OpenProcess(PROCESS_ALL_ACCESS, true, proc_id);
  17.     BYTE buffer = 0x0;
  18.     SIZE_T bytes;
  19.     int result = WriteProcessMemory(handler, (LPVOID)0xBA6794, &buffer, sizeof(buffer), &bytes);
  20.     cout << "Result: " << result << " Writted bytes: " << bytes << endl;
  21.     if (CloseHandle(handler)) cout << "Process handle closed" << endl;
  22.     else cout << "Process handle not closed" << endl;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment