Hey guys! I am trying to make a program that reads the ammo, i think something is wrong with the offsets and base address. It would be insanely helpful if someone could help me
Code:
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
HWND hwnd = FindWindow(NULL, "AssaultCube");
if (!hwnd)
{
cout << "Window could not be found.\n";
system("PAUSE");
}
else
{
cout << "Window found\n";
DWORD pId;
GetWindowThreadProcessId(hwnd, &pId);
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);
if (!hProc)
{
cout << "Process could not be opened\n";
system("PAUSE");
}
else
{
cout << "Process opened, all access.\n";
DWORD address = 0x004DF73C;
DWORD pointed1, pointed2, pointed3;
WORD offset1 = 0x0;
WORD offset2 = 0x14;
WORD offset3 = 0x378;
int currentAmmo;
while (1) {
ReadProcessMemory(hProc, (LPCVOID)(address), &pointed1, 4, NULL);
ReadProcessMemory(hProc, (LPCVOID)(pointed1 + offset1), &pointed2, 4, NULL);
ReadProcessMemory(hProc, (LPCVOID)(pointed2 + offset2), &pointed3, 4, NULL);
ReadProcessMemory(hProc, (LPCVOID)(pointed3 + offset3), ¤tAmmo, 4, NULL);
cout << "Your current ammo is " << currentAmmo << endl;
Sleep(9999);
}
}
}
cin.get();
return 0;
}