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 


Lua Within Auto Assembler Script

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

Joined: 09 Dec 2010
Posts: 140

PostPosted: Fri Jan 09, 2015 12:33 pm    Post subject: Lua Within Auto Assembler Script Reply with quote

Is it possible? Say eax is the address to a structure in memory, that structure is 2000 bytes long, and I want to log this structure (and any other structure passed through this routine) to a file. I get a compile error using the following:

Code:
originalcode:
writeRegionToFile("whatever.txt", eax, 2000)
mov [ebx+00000480],eax

exit:
jmp returnhere


Just wondering if it is even possible call Lua functions within the auto assembler script.

_________________
Hitler are you bored? Watch some of my hacks here. Want 2 gb of online storage space for free? Get Dropbox for computer, phone, etc...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Jan 09, 2015 1:13 pm    Post subject: Reply with quote

yes, look at the lua template in the auto assembler
it creates a function you can pass the address of a lua script to and an optional variable (i can't write a complex script right now, especially when case sensitivity like lua is a thing, but hopefully you'll figure it out or someone gives else gives an example)

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

Joined: 09 Dec 2010
Posts: 140

PostPosted: Fri Jan 09, 2015 1:29 pm    Post subject: Reply with quote

Thanks for the quick reply. I guess I was under the assumption that you had wrappers setup for these calls instead of inserted templates. All good, thanks again.
_________________
Hitler are you bored? Watch some of my hacks here. Want 2 gb of online storage space for free? Get Dropbox for computer, phone, etc...
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Fri Jan 09, 2015 1:40 pm    Post subject: Reply with quote

Suppose the lua function called from AA do a scan, result is failed.
How to notify the AA the failure, so that, for example, it won't activate its children cheat entry?
(I know the lua function can notify the _user_ the scan failed by message box, for example)
Thank you~
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Jan 09, 2015 1:54 pm    Post subject: Reply with quote

the called lua script can return an integer. after the call, eax/rax contains that return value

there are of course other ways like passing it the address of a memoryblock and let the luascript read and write to that

_________________
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
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Fri Jan 09, 2015 2:27 pm    Post subject: Reply with quote

Dark Byte wrote:
the called lua script can return an integer. after the call, eax/rax contains that return value

there are of course other ways like passing it the address of a memoryblock and let the luascript read and write to that


I means, is there a way for AA to be failed like AA cmd AOBScan failed, but according to the value returned by lua call?

May be some assembler version of AA Script ASSERT?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Jan 09, 2015 2:34 pm    Post subject: Reply with quote

just return a value indicating failure (e. g. 0)
it's up to you on how to decide if something is a failure or not. A lua aobscan returns 0 results? you return that it was a failure by returning 0, or if you wanted it to return 0 results return what you decide is success

these lua scripts are not 1 line long, they can be as complex as you like(e.g. calling other functions)

just remember that the lua script gets executed by cheat engine, so it has access to everything yourua window has access to as well

-
if the script you pass has a syntax error it will return 0

_________________
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
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Fri Jan 09, 2015 4:13 pm    Post subject: Reply with quote

I rethink my question, it is actually not related to the lua call directly.

The eax return from lua can also be any value.

I'm asking if there is a way to make the cheat entry activated/deactivated or success/failure within assembler code, eg.

test eax,eax // 0 for fail
jne @f
call assert (0) // this should stop the activating of this MR, or may stop executing the AA script at once too
ret
@@:
// do stuff


It is related to lua called, for I'm finding a way to propagate(or stop to propagte in failure case) the failure/success result of the lua to the children MemoryRecord under calling MemoryRecord.

ie. deactivating the calling MR from lua may not work, at least not convenient. It may not work, for example, the calling MR is under a group, so the calling MR may not be the selected MR @ addressList.

added:hmm.. setting registersymbol and check the symbol from children MR should propagate the result... but it is not convenient and user cannot know if it fail or not.


Last edited by panraven on Fri Jan 09, 2015 4:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Jan 09, 2015 4:24 pm    Post subject: Reply with quote

no, activating memoryrecords are never affected by runtime code (unless the runtime code disables it with lua callbacks)

you may want to check this post for an example to use preprocessor $lua in aa instead where it's used to disable some entries before activating: http://forum.cheatengine.org/viewtopic.php?t=578677
if lua errors out (e. g error() ) scripts will also refuse to activate

_________________
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
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Fri Jan 09, 2015 4:56 pm    Post subject: Reply with quote

Dark Byte wrote:
no, activating memoryrecords are never affected by runtime code (unless the runtime code disables it with lua callbacks)

you may want to check this post for an example to use preprocessor $lua in aa instead where it's used to disable some entries before activating: http://forum.cheatengine.org/viewtopic.php?t=578677
if lua errors out (e. g error() ) scripts will also refuse to activate


Thank you~

I've made this as the 1st child of the group, 'failed' is the registersymbol that signal failure/success. It work now.

Code:
[ENABLE]
{$lua}
if readInteger('failed') == 1 then
  getAddressList().getMemoryRecordByDescription('Test Parent').Active = false
end
local t = createTimer()
t.Interval = 1000
t.OnTimer = function(sender)
  getAddressList().getMemoryRecordByDescription('Test guard').Active = false  -- reset/deactivate THIS MR
  sender.Enabled = false
  sender.destroy()
end
t.Enabled = true
{$asm}
[DISABLE]
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 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