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 


Restore original OAB values

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

Joined: 30 Sep 2017
Posts: 12

PostPosted: Tue May 15, 2018 6:32 am    Post subject: Restore original OAB values Reply with quote

Hello!

I have a code that searchs for and replaces some AOBs:

Code:

function replace(searchV, replaceV)
  if type(searchV) ~= "table" then
    searchV = {(assert(tonumber(searchV),"Could not convert first argument to number"))}
  end
 
  for i,v in ipairs(searchV) do
    local res = AOBScan(v, "+W-C", 1, 4)
    if res then
      for j=0, res.Count-1, 1 do
        writeBytes(res[j], replaceV)
      end
      res.destroy()
    end
  end
end

local aobs = {
'F4 01 00 00 D0 07 00 00 F4 01',
'20 03 00 00 F4 01 00 00 20 03',
'E8 03 00 00 DC 05 00 00 20 03',
'FA 00 00 00 00 00 00 00 26 02',
'78 05 00 00 00 00 00 00 58 02',
'C8 00 00 00 00 00 00 00 78 05',
'C8 00 00 00 00 00 00 00 08 07',
'F4 01 00 00 00 00 00 00 F4 01',
'20 03 00 00 E8 03 00 00 20 03',
'03 00 00 E8 03 00 00 20 03',
'20 03 00 00 00 00 00 00 20 03'
}

-- pass a table of bytes rather than a string that are parsed into bytes
replace(aobs, {01,00,00,00,00,00,00,00,01,00})


Is there a way to restore the values to its original values after they have been replaced.

Thank you!
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 34

Joined: 09 Aug 2013
Posts: 893

PostPosted: Tue May 15, 2018 7:06 am    Post subject: Reply with quote

Keep track of the addresses you found and when you want to change them back loop through and write bytes from the original AOB that found it back (if you had wildcards you'd also need to keep track of the original bytes before overwriting them)
_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
aitboss
Newbie cheater
Reputation: 0

Joined: 30 Sep 2017
Posts: 12

PostPosted: Wed May 16, 2018 2:57 am    Post subject: Reply with quote

Thanks FreeER.
May you kindly give me an example of how to do it please. I can't figure a correct way to do keep track of found addresses and restore them without errors.

Thank you!
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 34

Joined: 09 Aug 2013
Posts: 893

PostPosted: Wed May 16, 2018 5:20 am    Post subject: Reply with quote

Code:
someTableToStoreAddresses = {}
function replace(searchV, replaceV)
  if type(searchV) ~= "table" then
    searchV = {(assert(tonumber(searchV),"Could not convert first argument to number"))}
  end
 
  for i,v in ipairs(searchV) do
    local res = AOBScan(v, "+W-C", 1, 4)
    if res then
      for j=0, res.Count-1, 1 do
        someTableToStoreAddresses[res[j]] = v -- save address and aob
        writeBytes(res[j], replaceV)
      end
      res.destroy()
    end
  end
end

local aobs = {
'F4 01 00 00 D0 07 00 00 F4 01',
'20 03 00 00 F4 01 00 00 20 03',
'E8 03 00 00 DC 05 00 00 20 03',
'FA 00 00 00 00 00 00 00 26 02',
'78 05 00 00 00 00 00 00 58 02',
'C8 00 00 00 00 00 00 00 78 05',
'C8 00 00 00 00 00 00 00 08 07',
'F4 01 00 00 00 00 00 00 F4 01',
'20 03 00 00 E8 03 00 00 20 03',
'03 00 00 E8 03 00 00 20 03',
'20 03 00 00 00 00 00 00 20 03'
}

-- pass a table of bytes rather than a string that are parsed into bytes
replace(aobs, {01,00,00,00,00,00,00,00,01,00})

-- whenever you want to restore them loop over saved addresses
for k,v in pairs(someTableToStoreAddresses) do
    FunctionToWriteAOBStringToAddress(k,v)
end

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
aitboss
Newbie cheater
Reputation: 0

Joined: 30 Sep 2017
Posts: 12

PostPosted: Tue May 22, 2018 9:32 pm    Post subject: Reply with quote

Many thanks for your time FreeER.
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