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 


Narrowing AOBScan search area

 
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 Jan 08, 2018 11:10 am    Post subject: Narrowing AOBScan search area Reply with quote

First I'll give a quick glimpse of what I'm looking for
Code:

function zAOBAddr( FIND, ADDSUB )
   local T = AOBScan( FIND )
   if ( (T == nil ) or (T.Count == 0) ) then
        return nil
   end
   return ('' .. T[0] .. '' .. ADDSUB)
end
...
local pFoes = zAOBAddr( "A0 A0 00 00 A1 2F", '+544' )

This is for LRFF13.exe of steam for reference, I've done this multiple times now when I start it up and always find that the address is between DD000000 to DDFFFFFF for me so I'd like to speed things up and set the search range, I tried looking via google for this information but to no avail. Any help here would be appreciated.

_________________
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
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jan 08, 2018 12:09 pm    Post subject: This post has 1 review(s) Reply with quote

I know this has come up before, not sure if there was a simple solution mentioned at the time however...

AA has aobscanregion so you might be able to use autoassemble to do the job

(disclaimer, untested code)
Code:
-- returns first result or nil
function AOBScanRegion(aob, start, end)
  -- temporary symbol name to register (should be unique of course)
  local aobscanregionSymbol = 'aobscanregionSymbol'
  local script = [[aobscanregion(%s, %s, %s, %s)
  registerSymbol(%s)]]

  if type(start) == 'number' then start = ('%X'):format(start) end
  if type(end) == 'number' then end = ('%X'):format(end) end
  script = script:format(aobscanregionSymbol, start, end, aob)

  local result = autoAssemble(script)

  if not result return nil end

  local address = getAddress(aobscanregionSymbol)
  unregisterSymbol(aobscanregionSymbol)

  return address
end


otherwise you'd probably need to make use of the memscan class

Code:
-- returns stringlist of results or nil
function AOBScanRegion(aob, start, end)
  local ms = createMemscan()
  ms.firstScan(soExactValue, vtByteArray, '', aob, '', start,end,'',fsmNotAligned,
    '' ,true,true, false, false)
  local sl
  ms.OnScanDone(function(ms)
    local fl = createFoundList(ms)
    fl.initialize()
    if fl.Count > 0 then
      sl = createStringList()
      for i=0, fl.Count-1 do
        sl.add(fl.Address[i])
      end
    end
    fl.deinitialize()
    fl.destroy()
    ms.destroy()
  end)
  ms.WaitTillDone()
  return sl
end
Back to top
View user's profile Send private message
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Mon Jan 08, 2018 12:56 pm    Post subject: Reply with quote

Was busy identifying what bits showed what data in my bestiary so didn't notice until just now, attempted with 1st one (after fixing the glaring issue with "end") and got an error back twice, the 1st I could easily fix (lack of then by final if) but the 2nd one was about a missing parameter in the :format() call, is that lua or cheat engine related?

Edit: Meant to post the changes I made also:
Code:

-- http://forum.cheatengine.org/viewtopic.php?p=5734498#5734498
function AOBScanRegion(AOB, START, END)
  -- temporary symbol name to register (should be unique of course)
  local aobscanregionSymbol = 'aobscanregionSymbol'
  local CODE = [[aobscanregion(%s, %s, %s, %s)
  registerSymbol(%s)]]

  if type(START) == 'number' then
     START = ('%X'):format(START) end
  if type(END) == 'number' then
     END = ('%X'):format(END) end
  CODE = CODE:format(aobscanregionSymbol, START, END, AOB)

  local result = autoAssemble(CODE)
  if not result then return nil end

  local ADDR = getAddress(aobscanregionSymbol)
  unregisterSymbol(aobscanregionSymbol)
  return ADDR
end

_________________
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
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jan 08, 2018 1:29 pm    Post subject: Reply with quote

ah, the format needs 5 arguments because the symbol is used in both the scan and the registersymbol

Code:
-- http://forum.cheatengine.org/viewtopic.php?p=5734498#5734498
function AOBScanRegion(AOB, START, END)
  -- temporary symbol name to register (should be unique of course)
  local aobscanregionSymbol = 'aobscanregionSymbol'
  local CODE = [[aobscanregion(%s, %s, %s, %s)
  registerSymbol(%s)]]

  if type(START) == 'number' then
     START = ('%X'):format(START) end
  if type(END) == 'number' then
     END = ('%X'):format(END) end
  CODE = CODE:format(aobscanregionSymbol, START, END, AOB, aobscanregionSymbol)

  local result = autoAssemble(CODE)
  if not result then return nil end

  local ADDR = getAddress(aobscanregionSymbol)
  unregisterSymbol(aobscanregionSymbol)
  return ADDR
end


as for the second memscan one.... this _should_ work but for some reason waitTillDone isn't waiting for the scan to finish.......(CE 6.7)
Code:
-- returns stringlist of results or nil
function AOBScanRegion(aob, start, ending)
  local ms = createMemScan()
  ms.firstScan(soExactValue, vtByteArray, '', aob, '', start,ending,'',fsmNotAligned,
    '' ,true,true, false, false)
  local sl
  ms.OnScanDone = function(ms)
    print('scan done')
    local fl = createFoundList(ms)
    fl.initialize()
    if fl.Count > 0 then
      sl = createStringlist()
      for i=0, fl.Count-1 do
        sl.add(fl.Address[i])
      end
    end
    fl.deinitialize()
    fl.destroy()
    ms.destroy()
  end
  ms.WaitTillDone() -- not working?
  print('returning')
  return sl
end
return AOBScanRegion('8B 83 80 04 00 00', 0x00423000, 0x00424000)

output (various methods, lua engine, table lua script, "AA" script both execute and assigned)
Code:
returning
:nil
scan done
returning
scan done
returning
scan done
returning
scan done
returning
scan done
Back to top
View user's profile Send private message
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Mon Jan 08, 2018 2:17 pm    Post subject: Reply with quote

Thanks, I applied the fix (and fixed a few of my own mistakes) and seems to be executing fine, I'll test whether it works properly a little later (had shut down the game while waiting to do some reading)

Edit: Just booted the game, executed the script before loading my save and doing manual search to compare, the addresses both showed as the same so BIG thanks from my side :)

_________________
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