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 


Learning AOBScan, Need help with adding offset.

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

Joined: 15 Dec 2016
Posts: 31

PostPosted: Thu Sep 27, 2018 11:12 pm    Post subject: Learning AOBScan, Need help with adding offset. Reply with quote

Code:
AWOKChapter1Items=AOBScan("07 00 4? 01 00 00 00 00 ?? 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ?? ?? ?? 44 ?? ?? ?? 44")
AWOKChapter1ItemsTotal=AWOKChapter1Items.getCount()
AWOKChapter1ItemsCount=0
print("Found " .. AWOKChapter1ItemsTotal .. " Address Locations!")
print(" ")


AWOKChapter1=createTimer()
AWOKChapter1.Interval=1000
AWOKChapter1.OnTimer=function(AWOKChapter1)
  if AWOKChapter1ItemsTotal == 0 then
    AWOKChapter1.Enabled=false
  else
    print("Address " .. AWOKChapter1ItemsCount .. " Is " .. AWOKChapter1Items[AWOKChapter1ItemsCount] .. " With A Value Of " .. readBytes(AWOKChapter1Items[AWOKChapter1ItemsCount]))
    AWOKChapter1ItemsCount=AWOKChapter1ItemsCount+1
    AWOKChapter1ItemsTotal=AWOKChapter1ItemsTotal-1
  end
end

AWOKChapter1.Enabled=true


I'm new to learning AOBScan and trying to learn it. Been searching for hours trying to figure this out with no luck. The code about is just to help me understand how it functions. I know the AOBSan your searching for should start with the address/value you want. But it was returning too many results. I so started the scan before the actual address/value I need. Which returns the 6 results I need. But now I need to offset all the found addresses by the same amount. So for example the first result returns 152FDE42. But I really need 152FDE4A. Thanks for any help given!
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Thu Sep 27, 2018 11:56 pm    Post subject: Reply with quote

"aobScan" and "aobScanModule" returns addresses as numbers, so you can just add the offset to it.
Code:
AWOKChapter1Items[AWOKChapter1ItemsCount] + 0x1F

Code:
AWOKChapter1Items[AWOKChapter1ItemsCount] - 0xF

And based off the addresses you mentioned, the "readBytes" call would be like this.
Code:
readBytes(AWOKChapter1Items[AWOKChapter1ItemsCount] + 8)


You can also use "getAddress" or "getAddressSafe" to get the address of any symbol so you can add offsets to them.

_________________
Back to top
View user's profile Send private message Visit poster's website
AmyGrrl
Cheater
Reputation: 0

Joined: 15 Dec 2016
Posts: 31

PostPosted: Fri Sep 28, 2018 12:02 am    Post subject: Reply with quote

I did find a solution on my own that works. I just converted the hex address to a number added 8 then converted back to hex. Works perfectly.

Code:
print("Address " .. AWOKChapter1ItemsCount .. " Is " .. string.format('%X', tonumber(AWOKChapter1Items[AWOKChapter1ItemsCount], 16) + 8) .. " With A Value Of " .. readBytes(string.format('%X', tonumber(AWOKChapter1Items[AWOKChapter1ItemsCount], 16) + 8)))


But I will give your solution a try. Seems a little cleaner. Thanks!
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Sep 28, 2018 12:11 am    Post subject: Reply with quote

No, you're right. I was thinking wrong. "aobScan" returns a string, so yeah "tonumber(..., 16)" to convert it to a number or the "getAddress" and "getAddressSafe" will also return a number.
Code:
readBytes(getAddress(AWOKChapter1Items[AWOKChapter1ItemsCount]) + 8)


EDIT:
But, I'm willing to bet that "tonumber" will be faster.

_________________
Back to top
View user's profile Send private message Visit poster's website
AmyGrrl
Cheater
Reputation: 0

Joined: 15 Dec 2016
Posts: 31

PostPosted: Fri Sep 28, 2018 12:25 am    Post subject: Reply with quote

I did try the same thing before you posted that. It works as well.

Code:
print("Address " .. AWOKChapter1ItemsCount .. " Is " .. string.format('%X', getAddress(AWOKChapter1Items[AWOKChapter1ItemsCount]) + 8) .. " With A Value Of " .. readBytes(getAddress(AWOKChapter1Items[AWOKChapter1ItemsCount]) + 8))


So I can use both. How can I test which solution is faster? Would it really make a big difference over the other. But I do get that converting to a number and back might be faster than looking up an address.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Fri Sep 28, 2018 1:22 am    Post subject: Reply with quote

you can, read the time and store it then run a loop of say 100; with "getAddress" being called. Then read the time again a see what the difference is, then do the same thing with "tonumber".
But this will only really matter if you have this in a loop or something, if it's just called every now and again I wouldn't worry about it.

_________________
Back to top
View user's profile Send private message Visit poster's website
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