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 


Need help with readmem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
junglechief87
How do I cheat?
Reputation: 0

Joined: 20 May 2019
Posts: 2

PostPosted: Mon May 20, 2019 6:22 pm    Post subject: Need help with readmem Reply with quote

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)
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Mon May 20, 2019 7:17 pm    Post subject: Reply with quote

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.

_________________
Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4297

PostPosted: Tue May 21, 2019 8:26 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
junglechief87
How do I cheat?
Reputation: 0

Joined: 20 May 2019
Posts: 2

PostPosted: Wed May 22, 2019 11:26 am    Post subject: Reply with quote

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.
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 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