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 


loading a lua created symbol in asm

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

Joined: 26 Sep 2016
Posts: 70

PostPosted: Mon Feb 19, 2018 2:13 am    Post subject: loading a lua created symbol in asm Reply with quote

I know this doesn't belong in this forum but I couldn't find any related forums in the main forum index/table/whatever you call it, basically I've copied some aobscans from someone else's existing scripts into my lua script in the hopes that I can put all the table scripts into one script making it less confusing for others when I finally upload the completed table that includes my own additions and the converted originals. The addresses they give are fine (and apparently consistently spaced providing room for the more faster calculated addresses) and the registering of the symbols goes fine too but I don't know how to make the existing ASM scripts load them instead so that I can test their behavior remains the same
_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Mon Feb 19, 2018 11:13 am    Post subject: Reply with quote

You can memoize the result of an AOBScan like this:
Code:
local AOBScanMemo = setmetatable({},{__mode = 'kv'})
function AOBScanMemoized(...)
  local aobstr = (...)
  local t = AOBScanMemo[aobstr]
  if t then return t end

  local aobres = AOBScan(...)
  t = {}

  if aobres then
    for i = 1, aobres.Count do
      t[i] = getAddress(aobres[i-1])
    end
    aobres.destroy()
  end

  AOBScanMemo[aobstr] = t
  return t
end

The return value from a {$lua} block is inserted into the script, so you can do something like this:
Code:
{$lua}
return ('define(aobresult,%08X)'):format(AOBScanMemoized('12 34 AB CD','+X-C-W')[1])
{$asm}

aobresult:
  db 56 78

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Feb 19, 2018 12:03 pm    Post subject: Reply with quote

If you have this variable in Lua:
Code:
justAnExample = 0x41424344



You can use it in AA script like this:
Code:
mov eax,$justAnExample



It will be assembled as:
Code:
mov eax,41424344



Of course, if you change justAnExample variable to newer value, you'll have to re-enable the script.



It can also be an address. In Lua:
Code:
justAnExample = 0x400500


AA script
Code:
$justAnExample:
nop
nop
nop
returnhere:


or
Code:
$justAnExample:
dd 01 02 03 04

_________________
Back to top
View user's profile Send private message MSN Messenger
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Mon Feb 19, 2018 4:45 pm    Post subject: Reply with quote

Thanks, I'll give mgr.inz.Player's suggestion a try first tomorrow sometime, only just got back from work so can't be bothered tonight

Edit: Whoops forgot to pop back and mention that it didn't work out, despite the unedited asm working perfectly fine when I activate it CE reports some error further down in the script when I only add the line for copying the value of the symbol I wanted to try using and comment out the original line. No matter how many variations of asm_value = $lua_value or define(asm_value,$lua_value) or some other such variation CE reports an error in the pre-existing asm so now I'm just gonna examine each of the blocks pulled up and decide what I can use to replicate original behavior via lua (minus the asm modifications)

_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
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