Multilayer Point C++

09/13/2012 02:43 Pwno_#1
Can anyone tell me why this crashes my game? Or perhaps a better way to do this.

Code:
	DWORD thefirst = (*(DWORD*)Base + 0x1343794);
	DWORD thesecond = (*(DWORD*)thefirst + 0);
	DWORD thethird = (*(DWORD*)thesecond + 0x11c);
	DWORD theresult = (*(DWORD*)thethird + 0x228);
	
	
	char msg[12];
	sprintf (msg, "%i", theresult);
	MessageBox(NULL, msg, NULL, MB_OK);
09/13/2012 09:02 Medix#2
attach a debugger and then you see where it crashes.

maybe you are reading from a memory space without the reading rights. check out virtualprotectex
09/13/2012 13:56 Omdi#3
Use VirtualProtectEx and IsBadCodePtr ;-)
09/14/2012 03:56 Pwno_#4
Quote:
Originally Posted by Neeya Nanaa View Post
Use VirtualProtectEx and IsBadCodePtr ;-)
Haha, I have little experience in coding, is there a superior way to code multi-level pointers?
09/14/2012 06:17 .Infinite#5
In a loop?
09/14/2012 13:51 -PinkiWinki-#6
Quote:
Originally Posted by Neeya Nanaa View Post
Use VirtualProtectEx and IsBadCodePtr ;-)
Never use IsBadCodePtr ...
09/14/2012 15:25 Dr. Coxxy#7
Quote:
Originally Posted by -PinkiWinki- View Post
Never use IsBadCodePtr ...
using it is better than using nothing.
and pls dont tell about page-faults etc. its a fucking hack, who cares anyway?

@topic
you may short the pointer deref'ing:

Code:
DWORD thefirst = (*(DWORD*)Base + 0x1343794); // i guess you forgot a () here... that may cause your crash. casting and deref is executed before the addition look here: http://www.cplusplus.com/doc/tutorial/operators/
// correct would be: DWORD thefirst = *(DWORD*) (Base + 0x1343794);
// same could be for the others, dunno how it originally was...
DWORD thesecond = (*(DWORD*)thefirst + 0);
DWORD thethird = (*(DWORD*)thesecond + 0x11c);
DWORD theresult = (*(DWORD*)thethird + 0x228);
is the same as:
Code:
DWORD theresult = *(DWORD*) ((*(DWORD*) ((**(DWORD**) (Base + 0x1343794)) + 0x11C)) + 0x228);
EDIT:
you may show us a screenshot of the cheatengine/whatever program you found this multilevel pointer, and we may assist you with creating correct code.
09/17/2012 02:35 Pwno_#8
Its a ID pointer for mouse over in Firefall.