Help with base addresses and pointers.
Hello mpgh, I started am trying to make an external mod with my limited C++ knowledge and the help of the internet, but I am struggling with memory addresses/pointers. Here is my code so far:
Code:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
int gravValue = 200;
HWND hwnd = FindWindowA(NULL, "Grand Theft Auto V");
if (hwnd == NULL)
{
cout << "Could not find game window" << endl;
Sleep(3000);
exit(-1);
}
else
{
static DWORD procID;
GetWindowThreadProcessId(hwnd, &procID);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
if (procID == NULL)
{
cout << "Couldnt get PID" << endl;
Sleep(3000);
exit(-1);
}
else
{
for (;;)
{
if (GetAsyncKeyState(VK_SPACE))
{
WriteProcessMemory(handle, (LPVOID)0x0, &gravValue, sizeof(gravValue), 0);
cout << "it worked" << endl;
Sleep(4000);
exit(-1);
}
}
}
}
return 0;
}
I want to be able to change the gravity by pressing the spacebar, and later create different gravity functions triggered by different keys. However I cant figure out how to change the gravity value since the address for gravity changes when the game is restarted. I have the offsets I need (0x08, 0xD28,0xBCC), but I don't know how to implement them. Thanks in advance.