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 


Auto Assembler Memory in Lua

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

Joined: 25 Aug 2014
Posts: 46

PostPosted: Mon Aug 25, 2014 3:24 pm    Post subject: Auto Assembler Memory in Lua Reply with quote

I have some data I'd like to back up on [ENABLE] and restore later.
For that I allocate a block in the auto assembler and try to have a Lua function copy the data to my memory. However the symbol apparently isn't registered by the time the Lua function runs (or maybe the memory isn't even allocated yet?) so this test code fails:

Code:
[ENABLE]

alloc(backup, $600)
registersymbol(backup)

LuaCall(copybackup())

[DISABLE]

dealloc(backup)


with "copybackup" being something like:

Code:
function copybackup()
  local address = getAddress("backup")
  local bytes = readBytes(0xDEADBEEF, 0x600, true)
  writeBytes(address, bytes, 0x600)
end


Questions:

  • Is "backup" even allocated by the time "copybackup" is called?
  • If so, how do I get an address for "backup"?
  • If that is impossible how else could I get the job done? Do I have to write my whole script in Lua?
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Mon Aug 25, 2014 3:29 pm    Post subject: Reply with quote

Lua calls are executed before the script is.
You may achieve this by write your whole script in lua, or 2 auto assembler functions.
I'd go for whole script in lua (more options, ordered, can add/update table entries).

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Aug 25, 2014 3:53 pm    Post subject: Reply with quote

You can use readmem to backup the original bytes

Code:

[enable]
alloc(backup,$600)
registersymbol(backup)

backup:
readmem(someaddress,$600)

someaddress:
nop
nop
nop
...

[disable]

someaddress:
readmem(backup,16)

...


dealloc(backup)
unregistersymbol(backup)

_________________
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
Haizan
Cheater
Reputation: 1

Joined: 25 Aug 2014
Posts: 46

PostPosted: Mon Aug 25, 2014 4:05 pm    Post subject: Reply with quote

Oh, that works!

For now I'm gonna go with the readmem method.

Thanks, you two.
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