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 


Execute C function in Lua

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

Joined: 01 Feb 2019
Posts: 9

PostPosted: Mon Jul 01, 2019 10:18 am    Post subject: Execute C function in Lua Reply with quote

Hello, I have a function in C:

Code:
#define CALL_6(return_type, call_type, address, a1, a2, a3, a4, a5, a6) ((return_type(call_type *)(int, int, int, int, int, int))(address))((int)(a1), (int)(a2), (int)(a3), (int)(a4), (int)(a5), (int)(a6))

void SaveGame(char* save_name) { CALL_6(void, __thiscall, 0x4BEB60, *(int*)0x699538, save_name, 1, 1, 1, 0); }


how to execute this code in LUA/CE?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Jul 01, 2019 12:43 pm    Post subject: Reply with quote

Normally I'd say:
Code:

function SaveGame(save_name)
  executeCodeEx(0,nil,0x4beb60,{type=0,value=0x688538},{type=3,value=save_name},{type=0,value=1},{type=0,value=1},{type=0,value=1},{type=0,value=0})
end


but there's a bug with more than 4 parameters, so you have to wait till next version
(and there you can do:
Code:

function SaveGame(save_name)
  executeCodeEx(0,nil,0x4beb60,0x688538, save_name, 1, 1, 1,0)
end

)

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

Joined: 01 Feb 2019
Posts: 9

PostPosted: Mon Jul 01, 2019 2:04 pm    Post subject: Reply with quote

Thanks for answer Dark Byte.

So I have two question now.

1. Do u know when u done new version of CE?
2. If is not time-consuming can u write this function in ASM (maybe then it will work)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Mon Jul 01, 2019 3:21 pm    Post subject: Reply with quote

is the target 64 or 32 bit ?
_________________
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
catshy
How do I cheat?
Reputation: 0

Joined: 01 Feb 2019
Posts: 9

PostPosted: Mon Jul 01, 2019 3:41 pm    Post subject: Reply with quote

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

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

PostPosted: Mon Jul 01, 2019 4:32 pm    Post subject: Reply with quote

something like this
Code:

save_name:
db 'save_name text',0

...
sub rsp,#56 //or sub rsp,#48 if already aligned
mov rcx,699538 
//mov [rsp],rcx

mov rdx,save_name
//mov [rsp+8],rdx

mov r8,1
//mov [rsp+10],r8

mov r9,1
//mov [rsp+18],r9

mov [rsp+20],1
mov [rsp+28],0

call 4BEB60

add rsp,#56 //or 48 (see sub rsp)

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

Joined: 01 Feb 2019
Posts: 9

PostPosted: Tue Jul 02, 2019 1:27 am    Post subject: Reply with quote

Thanks for your code. Im trying to use it, but I have this (attachment).

Can u help me to fix it?



screen.png
 Description:
 Filesize:  23.22 KB
 Viewed:  4260 Time(s)

screen.png


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

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

PostPosted: Tue Jul 02, 2019 5:15 am    Post subject: Reply with quote

have you targeted a 64 bit process?

also you havn't allocated or designated an address to write to

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