Program Doesnt Work on Restart

Posts 1–7 of 7 · Page 1 of 1
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
You'd need to make your program start with windows.. which is kinda malicious tho
Quote Originally Posted by Biesi View Post
You'd need to make your program start with windows.. which is kinda malicious tho
is that the only way?

i have found a static pointer, 0x51E20C + offsets of {0,14,384} how would i adapt the code to read from that address + offsets, which should return the same value, accross restarts right?

Thanks for your time
Do you mean it doesn't work when you restart your PC or when you restart the game? Because you are using a hex address to read from.

I'm guessing you mean your game... If what it's reading isn't correct after a restart it means you have a dynamic pointer and you need a static pointer + the offset. If you searched for your address in cheat engine the address will be green.
Quote Originally Posted by InunoTaishou View Post
Do you mean it doesn't work when you restart your PC or when you restart the game? Because you are using a hex address to read from.

I'm guessing you mean your game... If what it's reading isn't correct after a restart it means you have a dynamic pointer and you need a static pointer + the offset. If you searched for your address in cheat engine the address will be green.
yeah, i found the static pointer + offsets, offsets are declared as DWORD, and i am trying to use address+offsets, which doesnt work.
Any idea how i would add 0051E20C + offsets of 0,14,384 in the above code?

Thanks for your time
Create an array of DWORD and loop through
You found the static address and offsets make sure again that they all point to the same value of ammo or hp. I'll put my code for the same game you can change it up

Code:
//Ammo here
bool AmmoStatus;
BYTE AmmoValue[] = {0xA3, 0x1C, 0x0, 0x0}; //These are the values that will be written into the memory
DWORD AmmoBaseAddress = {0x(YOUR STATIC AMMO ADDRESS HERE)}; //On this address the trainer will write your changes
DWORD AmmoOffsets = {0x(your last offset here), 0x(2nd offset), 0x(1st offset}}; //This pinpoints the address for sure so the program doesn't get confused
Let me know if i helped!
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Need help?