 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Drivium Expert Cheater
Reputation: 0
Joined: 16 Apr 2013 Posts: 100
|
Posted: Thu Apr 30, 2020 5:04 pm Post subject: Idea For A LUA Script to copy bytes. Is This Possible? |
|
|
I do a lot with AoB and the memory browser and I just had the idea for a script that would make my life so much easier. The script would prompt me to enter a target address, then prompt me to enter how many bytes above and below the target address I want copied. It would either spit the bytes into an output window that I could then copy OR it would put it directly into the windows clipboard. This would be awesome! This combined with my AoB tool would make the whole process of finding valid aob's pretty painless.
Thanks in advance.
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4725
|
Posted: Thu Apr 30, 2020 6:02 pm Post subject: |
|
|
You could use CE's builtin unique aob pattern finding algorithm through the AA "aob injection" template. If that isn't suitable, you probably shouldn't be scanning for aobs in the first place (e.g. if you're scanning for data, not code).
anyway...
| Code: | function memClipboard(address, b, a)
a = a or b
if a + b < 1 then return end
address = getAddress(address)
local t = readBytes(address - b, a+b, true)
for i,v in ipairs(t) do
t[i] = ('%02X'):format(v)
end
writeToClipboard(table.concat(t, ' '))
end
-- usage:
-- memClipboard('1234ABC',3,5) - copies 8 bytes from 1234AB9 to 1234AC0 (inclusive)
-- memClipboard('1234ABC',10) - copies 20 bytes from 1234AA8 to 1234ACF (inclusive)
|
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Drivium Expert Cheater
Reputation: 0
Joined: 16 Apr 2013 Posts: 100
|
Posted: Thu Apr 30, 2020 6:40 pm Post subject: |
|
|
Hmmm. I'm aware of the AOB injection template and I've used it, but I didn't realize "unique" meant even between restarts it'd remain unique (or even exist). I'm sincerely seeking to understand... So my question becomes, if that's the case, why would there ever be a need to do multiple scan byte comparisons to find consistent aob's between restarts if the aob template does this in a single scan? It's possible my knowledge of this method is old and maybe CE has some advances I should be taking advantage of.
The script you shared, if I'm understanding correctly, begins at the target address as opposed to starting above and going below putting the target in the middle of the range, correct? If I wanted to modify this to begin a certain number of bytes BEFORE the target and end a certain number AFTER the target, what would that look like....?
*Edit 1: NM. Your script does exactly what I need. THANK YOU!
I appreciate your help. Going to test your aob injection template suggestion right now.
*Edit 2: Just tried it and the unique aob it returns was the exact memory value I want to modify (in this case, money), so as soon as I or the game modifies the value, the aob is no longer valid. To be sure I'm using the method you're referring to... I find my money value, right click and choose disassemble, go to tools, auto assemble, template, then aob injection.
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4725
|
Posted: Thu Apr 30, 2020 10:35 pm Post subject: |
|
|
| Drivium wrote: | | I didn't realize "unique" meant even between restarts it'd remain unique (or even exist). | It doesn't, and I didn't mean to imply that.
Sometimes there will be problems - e.g. if a JIT compiler spits out assembly that directly accesses dynamically allocated memory (mov [416A54C8],3), as the bytes that compromise the address will likely change the next time the game is restarted and it gets compiled again.
But most of the time, this doesn't happen with code and it works fine.
| Drivium wrote: | | if that's the case, why would there ever be a need to do multiple scan byte comparisons to find consistent aob's between restarts if the aob template does this in a single scan? | As far as I'm aware people have never done that when scanning for code. However, reading your post further on, it seems like you're scanning for data.
This is just my opinion, but the vast majority of the time, doing a single aobscan to uniquely find data is entirely unreliable, a waste of time and resources, and generally stupid compared to other methods (i.e. pointers and/or code injection). Reflecting critically, I recognize my stance is more sentimental than it is pragmatic; regardless, I don't think I can be of great help to you in more precise regards to this topic.
| Drivium wrote: | | The script you shared, if I'm understanding correctly, begins at the target address as opposed to starting above and going below putting the target in the middle of the range, correct? | It starts at the address minus the second argument. e.g. if you passed 0x1234ABC as the address and 10 as the second argument, it would start reading bytes at 0x1234AA8. (10 = 0xA; 0x1234ABC - 0xA = 0x1234AA8)
The parameters could've had better semantics. If you'd like to change it to work some other way, e.g. second parameter = number of "after" bytes and third parameter = number of "before" bytes or 0 if unspecified, the function shouldn't be too hard to change even for someone with little knowledge of Lua.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Drivium Expert Cheater
Reputation: 0
Joined: 16 Apr 2013 Posts: 100
|
Posted: Tue May 05, 2020 10:57 am Post subject: |
|
|
| I corrected my previous response. Your script did EXACTLY what I needed. I'm grateful. It's already cut my efforts in finding aob's in half. Thank you!
|
|
| 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
|
|