|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
aitboss Newbie cheater Reputation: 0
Joined: 30 Sep 2017 Posts: 17
|
Posted: Tue May 15, 2018 6:32 am Post subject: Restore original OAB values |
|
|
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 |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Tue May 15, 2018 7:06 am Post subject: |
|
|
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)
_________________
|
|
Back to top |
|
|
aitboss Newbie cheater Reputation: 0
Joined: 30 Sep 2017 Posts: 17
|
Posted: Wed May 16, 2018 2:57 am Post subject: |
|
|
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 |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Wed May 16, 2018 5:20 am Post subject: |
|
|
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 |
_________________
|
|
Back to top |
|
|
aitboss Newbie cheater Reputation: 0
Joined: 30 Sep 2017 Posts: 17
|
Posted: Tue May 22, 2018 9:32 pm Post subject: |
|
|
Many thanks for your time FreeER.
|
|
Back to top |
|
|
aitboss Newbie cheater Reputation: 0
Joined: 30 Sep 2017 Posts: 17
|
Posted: Tue Feb 12, 2019 4:04 am Post subject: |
|
|
FreeER wrote: | Code: |
-- whenever you want to restore them loop over saved addresses
for k,v in pairs(someTableToStoreAddresses) do
FunctionToWriteAOBStringToAddress(k,v)
end |
|
How can I iterate through the table named "someTableToStoreAddresses" and restore the values?
I tried:
Code: |
for k,v in pairs(someTableToStoreAddresses) do
writeBytes(someTableToStoreAddresses[v], v)
end |
but it is not working.
How can I iterate through the table and print the values?
I am not expert in lua and hope if somebody kindly help me.
Thanks!
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Tue Feb 12, 2019 4:25 am Post subject: |
|
|
Maybe this will help.
aitboss wrote: | ...
How can I iterate through the table and print the values?
... |
Code: | local myTable = {
[0xDEADBEEF] = "80 BF 58010000 00",
[0xADABEEF0] = "F3 0F10 40 1C",
}
for key, value in pairs(myTable) do
print("key: ", string.format("%016X", key), " : ", key)
print("value: ", value)
print("")
end |
Quote: | key: 00000000ADABEEF0 : 2913726192
value: F3 0F10 40 1C
key: 00000000DEADBEEF : 3735928559
value: 80 BF 58010000 00
|
_________________
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
Posted: Tue Feb 12, 2019 7:42 pm Post subject: |
|
|
Define the change scenario above.
Leave the remaining job: checkbox control.
If scripts and codes are good; Enable and Disable will work correctly.
(or worst of all: It's me, I'm misunderstanding the question! )
Code: | function CECheckbox1Change(sender)
if UDF1.CECheckbox1.Checked==true then
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'
}
replace(aobs, {01,00,00,00,00,00,00,00,01,00})
else
local aobs = {
'01 01 00 00 D0 07 00 00 F4 01',
'00 03 00 00 F4 01 00 00 20 03',
'00 03 00 00 DC 05 00 00 20 03',
'00 00 00 00 00 00 00 00 26 02',
'00 05 00 00 00 00 00 00 58 02',
'00 00 00 00 00 00 00 00 78 05',
'00 00 00 00 00 00 00 00 08 07',
'00 01 00 00 00 00 00 00 F4 01',
'01 03 00 00 E8 03 00 00 20 03',
'00 00 00 E8 03 00 00 20 03',
'20 03 00 00 00 00 00 00 20 03'
}
replace(aobs, {F4,20,E8,FA,78,C8,C8,F4,20,03})
--end
end |
_________________
|
|
Back to top |
|
|
aitboss Newbie cheater Reputation: 0
Joined: 30 Sep 2017 Posts: 17
|
Posted: Wed Feb 13, 2019 2:19 pm Post subject: |
|
|
What I am trying to do is:
search for each AOB in the list and replace it with:
"01 00 00 00 00 00 00 00 01 00"
01,00,00,00,00,00,00,00,01,00 (in hexadecimal)
and storing the original value in a table for each address.
Then when, for example a key is pressed, I want to restore the original values to each address (in hexadecimal).
I am stuck at making the function that will loop and write the bytes back.
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Feb 13, 2019 7:20 pm Post subject: |
|
|
Quote: | How can I iterate through the table and print the values? |
--- for AOB not in a table
Code: | function getByteString(address, bytecount)
local bytes = readBytes(address, bytecount, true)
if bytes then
local result = ""
for i = 1, #bytes do
if #result > 0 then
result = result .. " "
end
result = result .. string.format("%02X", bytes[i])
end
return result
end
end
aobresult=AOBScan("F4 01 00 00 D0 07 00 00 F4 01")
j = 0
cnt = 1
if (aobresult~=nil) then
print("Results found: "..aobresult.Count)
while j < aobresult.Count do
a = getByteString(aobresult[j], 12)
print("Address "..cnt.." = "..aobresult[j].." --> AOB : "..a)
j=j+1
cnt = cnt+1
end
aobresult.destroy()
aobresult=nil
else
print("No results found")
end |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
|
|
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
|
|