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 


fast call CELua function?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
nvz
Newbie cheater
Reputation: 0

Joined: 02 Jul 2016
Posts: 21

PostPosted: Fri Jun 09, 2017 3:21 am    Post subject: fast call CELua function? Reply with quote

hi, i wanted to know if there some efficient way to call Lua function from
assembler? last time i tried it would load every time the string and
convert it to bytecode, at least this is what i remember. Is it possible
to load the string only one time? so then you could just run the bytecode.
Loading the string everytime was very slow on my computer, but maybe
i made some mistake.
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 Jun 09, 2017 3:52 am    Post subject: Reply with quote

you can use CELUA_ExecuteFunctionByReference and pass it a referenceid to the function. it's a lot faster and no text parsing needed

e.g this code creates a reference if it isn't created yet, and then uses that
Code:

loadlibrary(luaclient-i386.dll)
luacall(openLuaServer('CELUASERVER'))

...


mov eax,[addresswithluafunctionidstored]
test eax,eax
jne short hasrefid

push addresswithluafunctionname  //string with the name of the function
call CELUA_GetFunctionReferenceFromName  //Basically calls createRef(functionname) and returns the value
mov [addresswithluafunctionidstored],eax
hasrefid:
mov [addresswithparameterlist],param1
mov [addresswithparameterlist+4],param2
mov [addresswithparameterlist+8],param3
//...
push 0 //0=no async, 1=async.  Use async if you do not wish to update the GUI. Faster
push addresswithparameterlist
push numberofparameterstopass
push eax //push the reference ID of the function
call CELUA_ExecuteFunctionByReference


When done EAX will contain the result of the lua function
And as per common 32-bit calling convention, EDX and ECX could have been altered. So save/restore them beforehand

_________________
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
nvz
Newbie cheater
Reputation: 0

Joined: 02 Jul 2016
Posts: 21

PostPosted: Fri Jun 09, 2017 6:25 am    Post subject: Reply with quote

ty boss, will be very useful
Back to top
View user's profile Send private message
Schnitzelmaker
Advanced Cheater
Reputation: 6

Joined: 27 Jan 2012
Posts: 64

PostPosted: Sun Jun 11, 2017 2:56 am    Post subject: Reply with quote

I think an easy way is using CELUA_ExecuteFunction and use a label having the name of the lua method. Disadvantage is that it can only have one parameter.

I think 32-Bit was: (Not 100% sure about syntax, have only used 64-bit version)
Code:

loadlibrary(luaclient-i386.dll)
luacall(openLuaServer('CELUASERVER'))

CELUA_ServerName:
db 'CELUASERVER',0

[Enable]
...
alloc(myluascript, 1000)
...

myluascript:
  db 'yourluamethodname(parameter)',0


newmem:
...
push integervariableyouwishtopasstolua
push myluascript
call CELUA_ExecuteFunction
...


And 64-Bit:
Code:

loadlibrary(luaclient-x86_64.dll)
luacall(openLuaServer('CELUASERVER'))

CELUA_ServerName:
db 'CELUASERVER',0

[Enable]
...
alloc(myluascript, 1000)
...

myluascript:
  db 'yourluamethodname(parameter)',0


newmem:
...
  mov rcx, myluascript
  mov rdx, [yourparamtervalue]
  sub rsp,28
  call CELUA_ExecuteFunction
  add rsp,28
...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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