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 to use executeCodeEx?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
yazigegeda
Expert Cheater
Reputation: 0

Joined: 22 Jan 2019
Posts: 159

PostPosted: Wed Apr 03, 2019 3:08 am    Post subject: How to use executeCodeEx? Reply with quote

I want to use executeCodeEx to call setwindowstext, how to write code?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Apr 03, 2019 3:59 am    Post subject: Reply with quote

example on the tutorial first window:
Code:

if hwnd==nil then hwnd=findWindow(nil,"Cheat Engine Tutorial v3.4") end

executeCodeEx(0, nil,'setwindowtexta',{0,hwnd},{3,"Some text"})


it uses the stdcall calling convention, waits until return or target crash, and calls setwindowtexta
it provides 2 parameters: a window handle, and a text
the window handle is an integer, so type 0
the text is a pointer to a string, so type 3 (CE allocates and injects the string into the target and then passes that address as parameters, afterwards CE will clean it up)

Note that there is currently an issue with functions with more than 4 parameters, but is fixed in the next version

_________________
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
yazigegeda
Expert Cheater
Reputation: 0

Joined: 22 Jan 2019
Posts: 159

PostPosted: Wed Apr 03, 2019 5:00 pm    Post subject: help Reply with quote

For example, mouse_event can't be used? These 5 parameters? He said up to 4 parameters?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Apr 03, 2019 11:01 pm    Post subject: Reply with quote

correct, but then again, most of the common functions already have a celua implementation (like mouse_event)
_________________
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
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Fri Jan 15, 2021 8:47 am    Post subject: Reply with quote

I used your code

Code:

if hwnd==nil then hwnd=findWindow(nil,"Cheat Engine 7.2") end

executeCodeEx(0, nil,'setwindowtexta',{0,hwnd},{3,"Some text"})

but i got an error "Error:Failure allocating memory near 00010000".
am i doing something wrong?

_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri Jan 15, 2021 4:00 pm    Post subject: Reply with quote

Try a different process not CE
_________________
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
wulfcare
Advanced Cheater
Reputation: 0

Joined: 27 Feb 2023
Posts: 59

PostPosted: Thu Mar 02, 2023 1:32 pm    Post subject: Reply with quote

What if we need to use __fastcall calling convention? It seems that executeCodeEx can only use stdcall or cdecl calling conventions.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Mar 02, 2023 3:16 pm    Post subject: Reply with quote

for custom types of calling conventions you'll have to write a wrapper using auto assembler or C that converts the provided parameters to the required calling mechanism

e.g: call for a 2 param __fastcall call it like a 2 param stdcall
Code:

alloc(caller2param,,256)
caller2param:
mov ecx,[esp+4]
mov edx,[esp+8]
call hardcodedfunctionaddress
ret 8


And are you sure it's fastcall and not just a method call ? (both use ecx for instance)

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

Joined: 27 Feb 2023
Posts: 59

PostPosted: Thu Mar 02, 2023 3:22 pm    Post subject: Reply with quote

IDA disassembler determined it to be a fastcall function, it uses the registers ECX, EDX, R8, R9.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Thu Mar 02, 2023 3:56 pm    Post subject: Reply with quote

r8 and r9? So it's 64-bit?

In that case it's normal 64-bit calling abi. You can pick whatever calling convention, it won't affect the result

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

Joined: 27 Feb 2023
Posts: 59

PostPosted: Fri Mar 03, 2023 12:28 am    Post subject: Reply with quote

Thank you so much Dark Byte, this is saving me so much time now that I can call functions for testing within cheat engine. <3
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