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 


Is it possible to execute game code through Cheat Engine?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Mon Jul 15, 2024 3:03 am    Post subject: Is it possible to execute game code through Cheat Engine? Reply with quote

I have used cheat engine code filter to find addresses which show that they are executed every time for a certain action done in game.

how can I use the addresses in cheat engine LUA scripting or AA to have them executed at my demand on the press of a hotkey

Something like this:

Code:
function executeAddresses()
    executeAddress(getAddress("game.exe+6ADC00"))
    executeAddress(getAddress("game.exe+28CE6F"))
    executeAddress(getAddress("game.exe+5C0C90"))
end

createHotkey(executeAddresses, VK_Z


"executeAddress" is not a special keyword like "getAddress"
So an example script of how to get code execution working will help

Thanks
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 462

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

PostPosted: Mon Jul 15, 2024 8:02 am    Post subject: Reply with quote

executeCode(address) works. But are you sure you can just call it like that or do those funcrions need specific parameters?
_________________
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
Csimbi
I post too much
Reputation: 96

Joined: 14 Jul 2007
Posts: 3179

PostPosted: Mon Jul 15, 2024 8:35 am    Post subject: Reply with quote

Interesting.
Would this be executed in context of the game (as if it was executed internally, with access to all code and memory), or, would be executed in context of CE?

Thank you!
Back to top
View user's profile Send private message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Mon Jul 15, 2024 8:43 am    Post subject: Reply with quote

Thank you for your answer @Dark Byte
I learned a new thing "executeCode(address)"

Well now the attached image shows how it is, filtered out 3 addresses being executed for a certain in game button click. Showing one of them opcodes in memory viewer

I just want to simulate that same thing at the press of a keyboard button.
Kinda like say power up when ever I want at will pressing Z key.

Would executeCode work or do I need to do it differently?
Where can I read up on this or can I get examples.

Thanks



Power Press Z.JPG
 Description:
 Filesize:  66.4 KB
 Viewed:  1561 Time(s)

Power Press Z.JPG


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 462

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

PostPosted: Mon Jul 15, 2024 9:24 am    Post subject: Reply with quote

it executes inside the game

You do need to call the code from the function start, so likely a bit higher. And most functions have parameters. (usually in rcx,rdx,r8 and r9 but can be anything else as well if it's an internal function)

You can pass those parameters as well with executeCode but the main issue is figuring out what the parameters are. e.g. for object oriented code the first parameter (rcx) is often the instance of the object (base address of the object) so you'd first have to find that before you can call the function

_________________
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
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Mon Jul 15, 2024 2:42 pm    Post subject: Reply with quote

Ok I did a bit more investigating afterwards

Of the 3 addresses that I got from code filtering, I found which one executes first using breakpoints.

Then I right clicked on that address in memory view and clicked the "select current function" which I believe highlights the whole function from start to end.

So from what I saw it seems like it starts from where the first found address is.
I attached image.

what should I do next?



Power Press Z2.JPG
 Description:
 Filesize:  103.77 KB
 Viewed:  1525 Time(s)

Power Press Z2.JPG


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 146

Joined: 06 Jul 2014
Posts: 4462

PostPosted: Mon Jul 15, 2024 5:49 pm    Post subject: Reply with quote

Figure out what the only parameter, rcx, is and how to find or make it yourself. In that image it seems like it's in the stack, so you'll probably need to look at the caller to figure that out.

Then call the function with the right argument and it might work. It also might require some other setup- e.g. games using mono need to do something to a thread before it can call code IIRC

_________________
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
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