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 


How can I avoid ACCESS_DENIED exception from Windows?

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

Joined: 28 May 2020
Posts: 8

PostPosted: Tue Apr 13, 2021 12:14 am    Post subject: How can I avoid ACCESS_DENIED exception from Windows? Reply with quote

Let's say that in a script I wanna access what's on [eax-100], how can I know beforehand that I can access that memory? Can I somehow check that that memory belongs to the process/game attached?

I have a script that accesses thousands of different addresses and what's happening is that every once in a while, a value comes and crashes my game with the Windows exception 5 (ACCESS_DENIED).

It would also help if I could know the size of the structure that's on [eax] (which I know I can access), I know there's a tool for it in CE but didn't see a way to do that on a script (with lua or something else).

Any help will be appreciated, thanks!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Tue Apr 13, 2021 10:06 am    Post subject: Reply with quote

Sp4rt wrote:
how can I know beforehand that I can access that memory?
You can't. IsBadReadPtr tries to solve this, but it's obviously a race condition between the call and the access. If the access could sometimes be bad, the safest way is to establish an exception handler. (a test for null pointers can quickly handle some cases)
Sp4rt wrote:
It would also help if I could know the size of the structure that's on [eax]
Again, you can't know that for certain. As far as I'm aware CE doesn't have a tool that can find the structure size in the general case.
Sometimes, there's debugging information available that CE can use to gather information about the semantics of data- e.g. mono. There's a Lua interface for accessing this information.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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: Tue Apr 13, 2021 11:07 am    Post subject: Reply with quote

you can use the AA exception handler

Code:

{$try}
mov ebx,[eax-100]
jmp ok

{$except}
jmp notok

ok:
//use ebx and do stuff

notok:
//error, skip it


_________________
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
Sp4rt
How do I cheat?
Reputation: 0

Joined: 28 May 2020
Posts: 8

PostPosted: Tue Apr 13, 2021 11:20 am    Post subject: Reply with quote

Thank you both, I'll try this out asap.

Also ParkourPenguin, this is what I meant by knowing the size of the structure of an address (I might have gotten this all wrong, sorry if so).



a.png
 Description:
 Filesize:  7.79 KB
 Viewed:  1448 Time(s)

a.png


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 Lua Scripting 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