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 


Why doesn't AA readmem() work here?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Profound_Darkness
Newbie cheater
Reputation: 0

Joined: 21 May 2015
Posts: 23

PostPosted: Mon Dec 04, 2017 2:05 pm    Post subject: Why doesn't AA readmem() work here? Reply with quote

I've been poking at this for a bit, since discovering readmem(). I didn't find anything seeming related when searching.
readmem() worked fine when I wanted to copy the first bytes of a method found with findmonomethod() but stopped working when I was using an aobscan() with an offset label.

At first I thought this was an issue with aobscan() but when putting together some example code to illustrate my confusion, for this post, I ended up narrowing down the point of my confusion to the following example code. I thought aobscan() was the issue because of how fast the cheat enable failure was relative to how long it took to succeed without the readmem().

Code:

// This is attached to the Cheat Engine process since that's easy to get.
[Enable]
alloc(temp, 16)

label(source)
registersymbol(source)

label(dest)
registersymbol(dest)

cheatengine-x86_64.exe+4:
source:
// just defining a memory point.

temp:
dest:
readmem(source, 4) //this fails if not remarked and I don't know why
readmem(cheatengine-x86_64.exe+4, 4) //this works if the above is remarked

[Disable]

unregistersymbol(source)
unregistersymbol(dest)

dealloc(temp)


When encountering this in the future I can basically just copy the offset from where the offset label is defined (in this case source) and paste that in the readmem(), as in the second readmem() example above.

In the code where I first encountered this I've ended up doing a Lua implementation of AA's aobscanregion(), adding my offset, and storing that in a Lua global that I then reference in the ASM section, which works fine. (And I didn't know how to do that like 3 days ago Smile so thanks Dark Byte and CE community).
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Dec 04, 2017 4:45 pm    Post subject: Reply with quote

Comment the readmem, add the script, execute the script, uncomment, save.
Anyway, why bother creating the label?
Why not just use the second version of readmem you have?
Back to top
View user's profile Send private message
Profound_Darkness
Newbie cheater
Reputation: 0

Joined: 21 May 2015
Posts: 23

PostPosted: Mon Dec 04, 2017 6:21 pm    Post subject: Reply with quote

The code above is an extreme simplification out of something far more complex (originally > a couple hundred lines) and the result of quite a while of debugging.

I rather stumbled on the solution WHILE building the post asking for help. So my post turns from "help, I'm stuck" to "I'd love to know why this didn't work so I can avoid making a similar mistake... also something useful for anyone reading around."

... while posting this reply I think I answered my own question... again... I'm thinking that CE, when putting together AA, it does label->address conversion in 2 passes. The first pass (top to bottom) converts pre-defined symbols (lua globals, registered symbols) and output from AA commands (like aobscan, alloc) into addresses. Then later, after assembly, it converts relative labels into addresses as there would be no way for CE to know where a relative label is given the typical use case, something like returnhere.

Seems simple now. In context it makes sense that readmem() would happen on first pass labels as at that time none of the byte code has changed (before assembler), it's after the second pass of label -> address that byte code would have been changed and by then the target of readmem() is no apt to be copied (for the purpose of backing up). Also seems I can simplify some code I was working on Smile .

Thanks.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Dec 04, 2017 6:23 pm    Post subject: Reply with quote

I;m not really clear on your issue, but if you're having trouble with instructions that need to be changed because they are RIP relative offsets, then use the reassemble(address) command instead. It deals with that
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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