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 


Setting a BP and pulling thread context

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Burningmace
Grandmaster Cheater
Reputation: 5

Joined: 17 Feb 2008
Posts: 520
Location: Inside the Intel CET shadow stack

PostPosted: Sun Oct 14, 2018 6:14 am    Post subject: Setting a BP and pulling thread context Reply with quote

I've got a case where it'd be very useful to have the Lua script set a BP on a particular instruction found via aobscan, then pull the thread context and extract a particular register value. Is this possible, or do I need to go the route of injecting a code cave and copying the register value to a known memory address that can be read back out?
_________________
It's not fun unless every exploit mitigation is enabled.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sun Oct 14, 2018 7:00 am    Post subject: Reply with quote

Not sure about the thread context, but you can use "debug_setBreakpoint" and "debugger_onBreakpoint", and there is "debug_setContext" but I have never used it.
https://wiki.cheatengine.org/index.php?title=Lua#Debugger

https://wiki.cheatengine.org/index.php?title=Lua:debug_setBreakpoint
https://wiki.cheatengine.org/index.php?title=Lua:debugger_onBreakpoint

_________________
Back to top
View user's profile Send private message Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Sun Oct 14, 2018 12:52 pm    Post subject: This post has 1 review(s) Reply with quote

The 'context' is set to globals when debugger_onBreakpoint is called.

Code:

 When a breaking breakpoint hits (that includes single stepping) and the lua function debugger_onBreakpoint() is defined it will be called and the global variables EAX, EBX, .... will be filled in
 Return 0 if you want the userinterface to be updated and anything else if not (e.g You continued from the breakpoint in your script)


So you can directly access the registers as globals in Lua.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Burningmace
Grandmaster Cheater
Reputation: 5

Joined: 17 Feb 2008
Posts: 520
Location: Inside the Intel CET shadow stack

PostPosted: Sun Oct 14, 2018 5:36 pm    Post subject: Reply with quote

Oh, perfect, thanks!
_________________
It's not fun unless every exploit mitigation is enabled.
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