HelpReading float value from multilevel pointer with injected DLL

Posts 1–9 of 9 · Page 1 of 1
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

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";
		}
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.
Could you show your pointer chain you have in Cheat Engine please?
Address
Cheat engine pointer chain:



Since this needs approval and i cant post images im just gonna write this here:

48 -> 3ADAF18
0 -> 3ADA3ED0
390 -> 6E912588
144 -> 15C6CF48
440 -> 02C028B0
"game_shared.dll"+00614F8C -> 14351BA0
Quote Originally Posted by rassuk View Post
Cheat engine pointer chain:



Since this needs approval and i cant post images im just gonna write this here:

48 -> 3ADAF18
0 -> 3ADA3ED0
390 -> 6E912588
144 -> 15C6CF48
440 -> 02C028B0
"game_shared.dll"+00614F8C -> 14351BA0
Then that is wrong:

Code:
DWORD HealthOffsets[] = {0x00,0x00,0x00,0x00,0x00,0x00};
yeah i just wrote 0x00 for the example here, sorry, in the program its DWORD HealthOffsets[] = {0x00614F8C,0x440,0x144,0x390,0x0,0x48};
Quote Originally Posted by rassuk View Post
yeah i just wrote 0x00 for the example here, sorry, in the program its DWORD HealthOffsets[] = {0x00614F8C,0x440,0x144,0x390,0x0,0x48};
Try DWORD hpaddress = FindDmaAddy(6, HealthOffsets, &HealthBaseGet);

The function is dereferencing HealthBaseGet, which means your function would dereference the base address which would end up with the dos header bytes of the module being dereferenced.
That gives the error "function cannot be called with the given argument list (int, DWORD[6], DWORD *)
Quote Originally Posted by rassuk View Post
That gives the error "function cannot be called with the given argument list (int, DWORD[6], DWORD *)
You could cast it to a DWORD

Code:
DWORD hpaddress = FindDmaAddy(6, HealthOffsets, (DWORD)&HealthBaseGet);
or change the function prototype

Code:
DWORD FindDmaAddy(int PointerLevel, DWORD Offsets[], DWORD* BaseAddress)
Thank you so much, this works perfectly. +rep
Posts 1–9 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us