Program Doesnt Work on Restart
Hi, I am learning C++ and have some code that works fine, except when I restart pc, heres the code
Code:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
DWORD address = 0x0292A670;
int value = 0;
DWORD pid;
HWND hwnd;
hwnd = FindWindow(NULL, L"AssaultCube");
if (!hwnd)
{
cout << "Window not found!\n";
cin.get();
}
else
{
GetWindowThreadProcessId(hwnd, &pid);
HANDLE phandle = OpenProcess(PROCESS_VM_READ, 0, pid);
if (!phandle)
{
cout << "Could not get handle!\n";
cin.get();
}
else
{
ReadProcessMemory(phandle, (void*)address, &value, sizeof(value), 0);
cout << value << "\n";
cin.get();
}
return 0;
}
}
How can I work make this code so its usable across restarts? I've been told i need to get base address but cant seem to acheive this
Thanks