Memory Question

05/09/2011 09:06 Shortpants#1
Hey epvp,


I have been doing a for loop in C from 0 to 769 and my loop has been "crashing" due to an exception.

It took me a while to figure out, but I started to realize that every mob ptr requires you to do the index * 0x4

Code:
0x00AE9944 + 0x1C + 0x1C + 0x24 + 0x50 + i * 0x4 + 0x11C
Now, I figured out that some i * 0x4 simply return ?? in CheatEngine, so I was wondering how to fix this problem, because not every i * 0x4 returns 0 therefore it causes my code to crash.

Does anyone know how this pointer exactly works? The range of the index? The incorrect indexs that return ?? Or simply know a way to fix this.

Am I doing something wrong? Because i * 0x4 would be 0,4,8,12,16,20,24,28,32, and so on, which doesnt seem too reliable to me.

Thanks in advance, I would really like some help on this one since I got everything else to work!
05/09/2011 10:48 Shareen#2
Cheat Engine returns ?? for nil (null) pointer. What you need to do in your code is check return values for nil (null) pointer, before trying to use it as a valid pointer (or valid piece of data, whatever it may be).

I haven't been following the latest offsets, but assuming that this:
Code:
0x00AE9944 + 0x1C + 0x1C + 0x24 + 0x50 + i * 0x4
returns pointer to an object's struct, pseudo code would be something like:
Code:
somePointer = 0x00AE9944 + 0x1C + 0x1C + 0x24 + 0x50 + i * 0x4
if somePointer is not nill then
  someObject = read data at somePointer address
05/09/2011 10:58 Shortpants#3
Well, I know its a NULL ptr, but I don't see how I could check whether a ptr has a NULL value before reading it since I'm working at memory level (this is done in a DLL which is injected).
05/09/2011 12:04 Sᴡoosh#4
In delphi :

if @somevalue = nil then exit_or_do_whatever_you_wanna_do;

@ is an operator that gives pointer to the variable its applied on. Maybe its simular in your language.
05/09/2011 13:37 Shortpants#5
Fixed with SEH, thanks all.