[HELP] Pointer calculation halts process when path is lost

Posts 12 of 2 · Page 1 of 1
[HELP] Pointer calculation halts process when path is lost
So I have a function that calculates a pointer offset path called every so often. The problem is, the path gets lost at times (and is shown as ??????) in CE. When this happens while a calculation is happening it freezes.

And no, I cannot find a more reliable pointer or call the funtion only once.

How can I make it so the function knows when to stop before adding the next offset?

Code:
DWORD WINAPI adr1() {
	//cout << "initializing adr3 calc\n";
	pdwAddress = *(DWORD *)(gameBase + 0x01665308);
	pdwAddress = *(DWORD*)(pdwAddress + 0x2c);
	pdwAddress = *(DWORD*)(pdwAddress + 0x6c);
	pdwAddress = *(DWORD*)(pdwAddress + 0x4);
	pdwAddress = *(DWORD*)(pdwAddress + 0x8);
	pdwAddress = *(DWORD*)(pdwAddress + 0x8);
	pdwAddress = *(DWORD*)(pdwAddress + 0x24);
	pdwAddress = *(DWORD*)(pdwAddress + 0x20);
	pdwAddress = *(DWORD*)(pdwAddress + 0x0);
	pdwAddress = *(DWORD*)(pdwAddress + 0x0);
	//pdwAddress = *(DWORD*)(pdwAddress + 0xDC);
	return 0;
}
First, I'd recommend re-writing the function to take in a vector of offsets. Then during the loop have it check the value on each iteration to determine if it's a valid pointer (Pointing to an address less than the game base is a good example of this).

Here's an example of what you could do. This is external, you'd have to re-write it since you're writing internal.
Code:
DWORD getPointer(HANDLE pHandle, DWORD pID, char name[], std::vector<DWORD> offsets) {
	DWORD gameBase = GetModuleBaseAddress(pID, name);
	DWORD address = gameBase;

	if (offsets.empty()) {
		return NULL;
	}
	address += offsets[0];

	for (std::vector<DWORD>::iterator it = offsets.begin() + 1; it != offsets.end(); ++it) {
		ReadProcessMemory(pHandle, (LPVOID)address, &address, 4, 0);
		address = address + *it;
		if (address <= gameBase) {
			return NULL;
		}
	}


	return address;
}
Posts 12 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?