Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Check if the memory address is valid in AA?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Jamboz
How do I cheat?
Reputation: 0

Joined: 12 Jan 2011
Posts: 9
Location: Finland

PostPosted: Thu Jan 20, 2011 8:59 am    Post subject: Check if the memory address is valid in AA? Reply with quote

I've been searching for a valid pointer for my address for hours now, but can't find one that always points to the correct address.

Is there a way to check in AA if this code can retrieve the address or not:
Code:
mov ebx, dword ptr[xxxxx.dll+0090C9E0]
mov ebx, dword ptr[ebx+30]
mov ebx, dword ptr[ebx+18]
mov ebx, dword ptr[ebx+30]
mov ebx, dword ptr[ebx+10]
mov ebx, dword ptr[ebx+B8]
lea ebx, dword ptr[ebx]
add ebx, 00A0
mov [carbase], ebx
retn


Whenever I crash my car in the game, the address does not change but the pointer gives an invalid address which makes this code crash the game. After crashing the car the pointer points to the correct address again.
If I put this same pointer on the CE address list, it shows "???????" as the address but it still retrieves the value of the address. How is that possible?

But the question is, is there a way to check in AA if e.g ebx+B8 is a valid memory address without crashing the game? And how can I do the same in C++ if I can't do it in inline assembly?

I'd appreciate any help, I've been struggling with this for hours.

EDIT:

I tried to google for help multiple times, but now I searched from the Cheat Engine's own forums and I found excatly what I needed. I didn't really believe that I'd find it from here.
viewtopic.php?t=511049
Anyways, I have another question about this.
This is the code checks if the address is valid:
Code:
pushfd //save flags
pushad //not sure which registers get messed with with this api call
push 4  //size in bytes of pointer
lea eax,[addresstocheck]
push eax
call isbadreadptr
cmp eax,0
jne invalidmemory

//valid memory
//do stuff

invalidmemory:
popad
popfd
//done

But do I really have to do this check for every single pointer (ebx+18, ebx+30, ebx+10, ebx+BCool or is there a shorter way?


Last edited by Jamboz on Thu Jan 20, 2011 9:11 am; edited 2 times in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Jan 20, 2011 9:04 am    Post subject: Reply with quote

isbadreadptr: http://forum.cheatengine.org/viewtopic.php?t=511049

and then there's always the exception handling method ( example of it's usage: http://forum.cheatengine.org/viewtopic.php?t=488611 )

also, if the address turns 0 when it's invalid you can test for that
mov ebx, dword ptr[xxxxx.dll+0090C9E0]
test ebx,ebx
je invalid
mov ebx, dword ptr[ebx+30]
test ebx,ebx
je invalid
mov ebx, dword ptr[ebx+18]
test ebx,ebx
je invalid
mov ebx, dword ptr[ebx+30]
test ebx,ebx
je invalid
mov ebx, dword ptr[ebx+10]
test ebx,ebx
je invalid
mov ebx, dword ptr[ebx+B8]
test ebx,ebx
je invalid
lea ebx, dword ptr[ebx]

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Jamboz
How do I cheat?
Reputation: 0

Joined: 12 Jan 2011
Posts: 9
Location: Finland

PostPosted: Thu Jan 20, 2011 9:15 am    Post subject: Reply with quote

damn you were fast! I was editing my post while you posted this.
the address doesn't turn 0, instead it's invalid, so I'm gonna go with the isbadreadptr method.

thanks a lot you're awesome!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Thu Jan 20, 2011 9:18 am    Post subject: Reply with quote

with address to 0 I mean one of the paths the pointer goes through turns 0 (a NULL/nil pointer) causing all subsequent path entries to be invalid

as for isbadreadptr, that is the shortest way

alternatively you could look at http://forum.cheatengine.org/viewtopic.php?t=488611 where I had the same problem

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Jamboz
How do I cheat?
Reputation: 0

Joined: 12 Jan 2011
Posts: 9
Location: Finland

PostPosted: Thu Jan 20, 2011 10:07 am    Post subject: Reply with quote

thanks a lot it works like charm! I ended up using test ebx, ebx
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites