View previous topic :: View next topic |
Author |
Message |
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Wed Oct 07, 2015 6:30 pm Post subject: Array of Bytes (AOB) Scan and Replace All |
|
|
The following script will scan for the provided array of bytes.
Once found, the script will overwrite the bytes with the ones provided.
You can use '??' as a wildcard within the search and replace to ignore those bytes.
For the replace, this means the original bytes in those locations will not change.
The script will replace the bytes at each address in which the pattern matched.
Simply give the cheat a unique name and provide it with the pattern and replacement bytes.
Code: | {$lua}
if syntaxcheck then return end
cheat_name = "MyCheat"
[ENABLE]
local pattern = "48 83 EC 28 E8 ?? ?? ?? ?? 48 83 C4 28"
local replace = "?? ?? ?? ?? 90 90 90 90 90 ?? ?? ?? ??"
-- edit the name of the cheat
-- edit the pattern to search
-- edit the replacement bytes
-- use ?? to ignore the bytes
-- do not edit the code below
local scans = AOBScan(pattern)
if scans == nil then
showMessage("Unable to find pattern:\n"..pattern)
else
local saved = {}
local length = (#replace + 1) / 3
for i = 0, scans.Count - 1 do
local backup = readBytes(scans[i], length, true)
local bytes = {}
for hex in string.gmatch(replace, "%S+") do
local size = #bytes + 1
if hex == "??" then
bytes[size] = backup[size]
else
bytes[size] = tonumber(hex, 16)
end
end
saved[i] = backup
writeBytes(scans[i], bytes)
end
_G[cheat_name] = {
["scans"] = scans,
["saved"] = saved
}
end
[DISABLE]
local vars = _G[cheat_name]
if vars ~= nil then
local scans = vars.scans
local saved = vars.saved
for i = 0, scans.Count - 1 do
writeBytes(scans[i], saved[i])
end
scans.Destroy()
vars.scans = nil
vars.saved = nil
vars = nil
_G[cheat_name] = nil
end |
Last edited by Zanzer on Tue Jul 12, 2016 7:08 pm; edited 1 time in total |
|
Back to top |
|
|
mausi125 Advanced Cheater Reputation: 1
Joined: 05 Jun 2014 Posts: 86
|
Posted: Thu Oct 08, 2015 2:17 am Post subject: |
|
|
Thank you for your best script zanzer.
Last edited by mausi125 on Thu Oct 08, 2015 9:03 am; edited 1 time in total |
|
Back to top |
|
|
ta_trainer Advanced Cheater Reputation: 0
Joined: 24 Dec 2006 Posts: 76
|
Posted: Thu Oct 08, 2015 7:25 am Post subject: |
|
|
Thank you. can have some good use for it.
|
|
Back to top |
|
|
sulo0625 How do I cheat? Reputation: 0
Joined: 19 Apr 2018 Posts: 1
|
Posted: Thu Apr 19, 2018 6:28 am Post subject: |
|
|
thank you for your script zanzer. But i have a question. how to use this script for multiple pattern only one replace?
|
|
Back to top |
|
|
aitboss Newbie cheater Reputation: 0
Joined: 30 Sep 2017 Posts: 17
|
Posted: Fri Nov 02, 2018 4:46 am Post subject: |
|
|
Can we update this so it can scan for local pattern as array of values instead of only one value?
For example:
Code: |
local pattern = {
"A0 A1 00 A3",
"B4 56 00 9C",
"4B 00 34 9A"
}
local replace = { "00 00 00 01" }
|
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
|
Back to top |
|
|
aitboss Newbie cheater Reputation: 0
Joined: 30 Sep 2017 Posts: 17
|
Posted: Fri Nov 02, 2018 8:58 am Post subject: |
|
|
Yes I know this part but I could do the part of restoring the AOB to its original state after the trainer is deactivated.
I know how to replace an array of values, but the problem is in restoring their values again. That;s why I ask for some coding help
|
|
Back to top |
|
|
|