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 


Trying to call LUA from ASM (runtime)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Gi@nnis
Cheater
Reputation: 1

Joined: 26 Oct 2013
Posts: 32
Location: Greece

PostPosted: Sat Nov 28, 2015 1:58 pm    Post subject: Trying to call LUA from ASM (runtime) Reply with quote

Trying to call LUA from ASM. But I'm failing miserably.

Nothing happens (no print message). Can someone give me a hand, I can't see what I am doing wrong. The "integervariableyouwishtopasstolua" is a bit unclear to me.

Please, be gentle with me I am not a pro programmer. Thanks in advance.

Code:
[ENABLE]
{$lua}
function testFunc(param)
  print("Hello world!")
  print("Calling LUA from ASM!!!:)")
  print(param)
end

{$asm}
///#region untouched - Call CE lua function
loadlibrary(luaclient-i386.dll)
luacall(openLuaServer('CELUASERVER'))
globalalloc(luainit, 128)
globalalloc(LuaFunctionCall, 128)
label(luainit_exit)
globalalloc(luaserverinitialized, 4)
globalalloc(luaservername, 12)

luaservername:
  db 'CELUASERVER',0

luainit:
  cmp [luaserverinitialized],0
  jne luainit_exit
  push luaservername
  call CELUA_Initialize //this function is defined in the luaclient dll
  mov [luaserverinitialized],eax
  luainit_exit:
  ret

LuaFunctionCall:
  push ebp
  mov ebp,esp
  call luainit

  push [ebp+c]
  push [ebp+8]
  call CELUA_ExecuteFunction
  pop ebp
  ret 8

//luacall call example:
//push integervariableyouwishtopasstolua
//push addresstostringwithfunction  //(The lua function will have access to the variable passed by name "parameter")
//call LuaFunctionCall
//When done EAX will contain the result of the lua function
///#endregion


globalalloc(myVar,4)
myVar:
  dd 0

alloc(luaCallExample, $200)
label(funcName)
createThread(luaCallExample)

luaCallExample:
  push 1
  push funcName
  call LuaFunctionCall
  mov [myVar],eax
  inc [myVar]
  ret

funcName:
  db 'testFunc',0

[DISABLE]
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Nov 28, 2015 4:39 pm    Post subject: Reply with quote

Run the game explicitly with admin rights
_________________
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 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