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 


Some Autoassemble and Lua questions

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

Joined: 27 Aug 2014
Posts: 36

PostPosted: Wed Feb 08, 2017 5:30 pm    Post subject: Some Autoassemble and Lua questions Reply with quote

I apologize if these are poor questions, i dont want to come off as lazy but i am thoroughly confused on how to correctly integrate AA with lua. I am comfortable with using AA but i dont have much experience using lua for memory editing. Im now mainly stuck on trying to get lua and AA to communicate.

Q1. I would like to use lua to remember things like opcodes and addresses and then inside my AA script call on them, is this possible?

eg:
in lua:
local ad1 = 12345 or op1 = eb 75
and in AA:
ad1: db 90 or 66666: op1

2. How do i put atuo assemble code in a lua script and vice versa?

3. is it possible to have an AA script in your cheat table read from your lua script and vice versa, or should they be together?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Feb 08, 2017 6:02 pm    Post subject: Reply with quote

you can let your AA script read/write a registered symbol, and let a Lua script read/write that

e.g:
Code:

alloc(bla,4)
registersymbol(bla)
...
cmp [bla],1
jne skipcheat
..cheatstuff...

and then use a menu in Lua, or a timer/thread, to set the bra variable
e.g:
Code:

if myform.cbEnableCheat.Checked then
  writeInteger('bla',1)
else
  writeInteger('bla',0)
end



---
You can also combine Lua with AA using the {$lua} tag, but understand that this is mainly a pre-processor. (It runs BEFORE the aa script gets executed)
The result of the Lua function will be part of the auto assembler script which will get executed/injected

e.g:
Code:

... aa script...
label(something)
...

{$lua}
if readInteger(0x00400500)==0 then
  return [[
something:
dd 0
]]
else
  return [[
something:
dd 1
]]
end
...
cmp [something],1
je dosomething
...



---

putting AA script inside Lua is done using the autoAssemble() command
e.g:
Code:

  x=12
  s='something'
  autoAssemble(string.format([[
alloc(xxx,4)
registersymbol(xxx)
alloc(mystring,255)
registersymbol(mystring)
xxx:
dd %x

mystring:
db '%s'
]],x,s)


---
and for more advanced things like calling Lua functions from the target process in an injected piece of code check out the Lua inject template

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

Joined: 27 Aug 2014
Posts: 36

PostPosted: Wed Feb 08, 2017 6:14 pm    Post subject: Reply with quote

Fantastic, thank you :)

Something i would like to do is use lua to record variable wildcard bytes before they are overwritten so that i can restore them in the [disable] section of my AOBScan script. Should i use lua inside the AA script for this?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Feb 08, 2017 6:26 pm    Post subject: Reply with quote

You can of course use Lua to store the original bytes in a byteTable and on disable write them back.
But keep in mind that the Lua section executes before the AA script, so things like AOBscan and stuff will not have been executed. So your Lua script would then have to do the aobscan itself to get to the address and store the original bytes.
Of course if it's an exact address, then it's easy enough. (readBytes/writeBytes)

BUT, you can also do all this without Lua
Code:

[enable]
aobscan(xxx,11 22 33 * 55 * 77 88)
registersymbol(xxx)

alloc(originalbytes,8)
registersymbol(originalbytes)

originalbytes:
readmem(xxx,8)

....

xxx:
db 90 90 90 90 90 90 90 90
...

[disable]
...
xxx:
readmem(originalbytes,8)
dealloc(originalbytes)

unregistersymbol(originalbytes)
unregistersymbol(xxx)
...

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

Joined: 27 Aug 2014
Posts: 36

PostPosted: Wed Feb 08, 2017 6:42 pm    Post subject: Reply with quote

Oh ok, that looks good. I figured it would be more difficult to do with just AA alone.

Thanks :)

Edit:

Are there any performance issues with using readmem to read and overwrite a lot of bytes, eg readmem(base1,2048)?
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 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