View previous topic :: View next topic |
Author |
Message |
Nemexia55 Expert Cheater Reputation: 0
Joined: 28 Jan 2014 Posts: 160
|
Posted: Tue Sep 06, 2016 1:46 pm Post subject: how to work with lua |
|
|
hi, i'm sure there is Lua tut in this forum but i couldn't find one which explains about where to write Lua scripts and how to use them and call them in AA.
but i see everyone knows how to do it...
i would appreciate a good help,
thanks
P.S.: something like this:
http://forum.cheatengine.org/viewtopic.php?p=886483#886483
but for lua
_________________
|
|
Back to top |
|
|
Smellyhobo101 Newbie cheater Reputation: 0
Joined: 21 Sep 2014 Posts: 23
|
Posted: Tue Sep 06, 2016 2:39 pm Post subject: |
|
|
To write lua scripts go to table > show cheat table lua script.
The wiki is a good place to start but has a lot of missing information. Look at main.lua in your cheat engine folder for a complete reference.
http://wiki.cheatengine.org/index.php?title=Lua
Take a look at using timers to set up an execution loop.
You can write lua in auto assembler scripts with the {$lua} tag. Like this:
Code: |
[ENABLE]
{$lua}
-- everything below here is LUA
{$asm}
// everything below here is ASM
|
If you want your assembly code to call a lua function directly it's a bit different. First make a new auto assembler script and use the template "Call CE Lua function". Leave that script as it is and run it. Now you can call your CE lua functions from ASM like so:
Code: |
alloc(NAME, 64)
NAME:
db 'functionName()',0
code:
pushad
push eax
push NAME
call LuaFunctionCall
popad
|
pushad and popad are probably not necessary but I had an issue with registers getting messed up once so I always do it.
|
|
Back to top |
|
|
Nemexia55 Expert Cheater Reputation: 0
Joined: 28 Jan 2014 Posts: 160
|
Posted: Sat Sep 10, 2016 1:52 pm Post subject: |
|
|
thanks for your useful info!
but i still have problem with this part:
Quote: |
Code:
alloc(NAME, 64)
NAME:
db 'functionName()',0
code:
pushad
push eax
push NAME
call LuaFunctionCall
popad
pushad and popad are probably not necessary but I had an issue with registers getting messed up once so I always do it. |
_________________
|
|
Back to top |
|
|
Smellyhobo101 Newbie cheater Reputation: 0
Joined: 21 Sep 2014 Posts: 23
|
Posted: Sat Sep 10, 2016 3:32 pm Post subject: |
|
|
You need to learn how to do code injection first. Plenty of tutorials on the forums on that. Then once you have your injection set up you add that code to call your LUA function.
Here's my full template for LUA hooks:
Code: | aobScanModule(NAME_inject_point,lethalleague.exe,BYTES)
registersymbol(NAME_inject_point)
alloc(code,1024)
alloc(NAME, 64)
label(NAME_code)
label(NAME_return)
NAME:
db 'functionName()',0
code:
NAME_code:
//ORIGINAL CODE
pushad
push eax
push NAME
call LuaFunctionCall
popad
jmp NAME_return
NAME_inject_point:
jmp NAME_code
//nops here
NAME_return:
[DISABLE]
NAME_inject_point:
//ORIGINAL CODE
unregistersymbol(NAME_inject_point)
dealloc(code)
|
To use:
1. Replace NAME with a name of your choice
2. Replace BYTES with the AOB (array of bytes) of your injection point.
3. Replace //ORIGINAL CODE with the code your jump will overwrite.
4. Make sure you have the correct amount of nops at //nops here. This depends on the amount of instructions you are overwriting. Jumps are 5 bytes, so if you overwrite 8 bytes of instructions you need 3 extra nops to overwrite the left over junk.
5. Replace functionName() with the name of the function you want to call.
|
|
Back to top |
|
|
|