Posted: Mon May 20, 2019 6:22 pm Post subject: Need help with readmem
Need help figuring out why this doesn't work:
define(gameSequenceAddress,"SonicMania.exe"+55B90)
define(gameSequenceBytes,readmem("SonicMania.exe"+55B90,10))
readmem returns an aob in that instance, I thought? So that should be able to pull back a changing byte array on script run, I would think.
The main line that's throwing the error is the assert command later on.
assert(gameSequenceAddress,gameSequenceBytes)
It might be the way CE intriprits the script and then deals with it.
My first question is what are you doing with the "assert" in this context. "assert" is to check that the bytes are a known value. If you read an unknown value then "assert" on what every you read, it kinda defeats the purpose of the "assert". I think you just need to rethink your code and what it's actually doing.
It's pretty much like an if statement like this:
Code:
if X == X then
-- do stuff
else
-- don't do stuff
end
It would always be true. But in this case, I think it's that "define" was never meant to be used with "readMem", so it fails. You'll need to allocate some memory and store the read bytes there. _________________
define works more like C preprocessor macros - it just copies readmem(...) wherever gameSequenceBytes appears.
The assert runs before readmem.
The easiest way to solve this would be to delete the assert. Even if it did work like the way you're writing it out, it wouldn't be doing anything anyways.
If you needed to verify two different memory locations had the same values, you could use a {$lua} block. _________________
I don't know where I'm going, but I'll figure it out when I get there.
Cool thanks. I was mostly just trying to keep my code conforming to the auto inject structures I'd been using for all my ASM functions. I honestly didn't know all of what assert was doing under the hood. Sounds like I don't even need it for what I'm trying to do. I have a memory address in static memory but the pointer on the address call shifts on game startup which changes the last two bytes and I just want to make sure that the code I'm overwriting is able to be properly returned to the original code when I unfreeze. Sounds like I don't really need assert for that though, so I'll just remove that.
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