Hi, so I have a pointer that points to the game's location data:
Code:
DWORD *pLocationData = (DWORD*)((*(DWORD*)(g_dwBaseAddress + 0x14459E4)) + 0x18);
And I have another pointer that points to the local player's X axis:
Code:
DWORD *pPlayerX = (DWORD*)(*(DWORD*)(pLocationData)+0x1C);
I'm not sure why, but the first pointer always points to the address 0x0000000018 unless I put the code in a new thread.
For example,
Code:
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)FlyHack, 0, 0, 0);
Code:
void FlyHack() //main.cpp
{
g_dwBaseAddress = GetModuleHandle(0);
while(true)
{
DWORD *pLocationData = (DWORD*)((*(DWORD*)(g_dwBaseAddress + 0x14459E4)) + 0x18);
cheat_state->player.flyHack ^= 1; // I'm assuming this crashes my program because I'm accessing a struct value from a new thread.
}
}
If I use the code above it will always point to the right address and not 0x00000018. However, if I code it like this:
Code:
HRESULT IDirect3DDevice9Proxy::Present(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion) //IDirect3DDevice9Proxy.cpp
{
renderHandler();
}
void renderHandler() //IDirect3DDevice9Proxy.cpp
{
// Draw some overlay stuff and call our cheat_hook function..
cheat_hook(pPresentParam.hDeviceWindow);
}
Code:
void cheat_hook(HWND wnd) //cheat.cpp
{
keyhook_maybe_install(wnd);
keyhook_run();
// Here is where we call our flyhack function
if(g_dwBaseAddress != NULL)
cheat_flyhack();
}
Code:
void cheat_flyhack() // flyhack.cpp
{
DWORD *pLocationData = (DWORD*)((*(DWORD*)(g_dwBaseAddress + 0x14459E4)) + 0x18);
if (pLocationData && (DWORD)pLocationData != 0x00000018)
{
// Code never makes it this far because pLocationData always points to 0x00000018
}
}
Take a look at the cheat_flyhack function. How come the pointer pLocationData always points to 0x00000018? If I put that same code in void Flyhack (a new thread) it works just fine. It will point to the local player's x coordinate like I programmed it to do. Could this be happening because the game I am playing has 2 processes with the same name? If so, how do I fix my code so it points to the right address? Both game processes have the same base address..
Edit: Yeah, my program is trying to access the pointer in the wrong process. If I attach cheat engine to the first game process it will point to the right address.
But if I attach to the second process (the one that has exactly the same name and baseaddress of the first) it will point to the wrong address.
So how do I get my code to point to the right address? I've been doing a lot of research on google and I don't think anyone has encountered this problem before.