Reading float value from multilevel pointer with injected DLL
Hi, i have been searching google for a long time and can't really find a viable solution to my problem.
I want to access a game's health value stored as float, to listen to it and make a function that fires when it's < than a specific number.
I'm using (credits to Guided Hacking youtube channel) this to get the address for the health value
Then for debug i run this code to see if it returns the right address that cheat engine is currently pointing to through the pointers
But the value of these is not the same.
So my question is why exactly are those different, and once i find the right address, how can i read a float value from it and compare it to another number.
I hope this is easy for someone more experienced in c++ since i have just recently started learning.
I want to access a game's health value stored as float, to listen to it and make a function that fires when it's < than a specific number.
I'm using (credits to Guided Hacking youtube channel) this to get the address for the health value
Code:
DWORD HealthBaseGet = (DWORD)GetModuleHandle(L"DLLname.dll");
DWORD HealthOffsets[] = {0x00,0x00,0x00,0x00,0x00,0x00};
DWORD FindDmaAddy(int PointerLevel, DWORD Offsets[], DWORD BaseAddress)
{
DWORD Ptr = *(DWORD*)(BaseAddress); //Base Address
if (Ptr == 0) return NULL;//prevent crash
for (int i = 0; i < PointerLevel; i++)
{
if (i == PointerLevel - 1)
{
Ptr = (DWORD)(Ptr + Offsets[i]); /
if (Ptr == 0) return NULL;//prevent crash
return Ptr;
}
else
{
Ptr = *(DWORD*)(Ptr + Offsets[i]);
if (Ptr == 0) return NULL;//prevent crash
}
}
return Ptr;
}
Then for debug i run this code to see if it returns the right address that cheat engine is currently pointing to through the pointers
Code:
DWORD hpaddress = FindDmaAddy(6, HealthOffsets, HealthBaseGet);
DWORD comparison = 0x88CF6AA8;
if (comparison == hpaddress) {
label3->Text = "ON";
}
So my question is why exactly are those different, and once i find the right address, how can i read a float value from it and compare it to another number.
I hope this is easy for someone more experienced in c++ since i have just recently started learning.
