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 


[Bug] AA - jmp requires 'long' if two labels share address?

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

Joined: 02 Oct 2019
Posts: 5

PostPosted: Wed Oct 02, 2019 10:25 pm    Post subject: [Bug] AA - jmp requires 'long' if two labels share address? Reply with quote

I think I may have run into a bug in the AutoAssembler. Luckily I found a simple workaround that appears to work.

I'm using Cheat Engine 7.0.

If I do something like this:


Code:


[enable]
aobScanModule( AOB_TestAddr, test.exe, 80 7c 24 20 00 74 1e )
label( patchRet )

alloc( newmem, 4096, "test.exe" )

AOB_TestAddr:
jmp newmem
patchRet:

newmem:
jmp patchRet



then, as expected, the bytes at AOB_TestAddr has a 5-byte 'jmp' instruction written to it.

However, if I have multiple labels for the same address and jump to the second label, bad things happen:

Code:

[enable]
aobScanModule( AOB_TestAddr, test.exe, 80 7c 24 20 00 74 1e )
label( patchRet )
label( patchFuncA )

alloc( newmem, 4096, "test.exe" )

AOB_TestAddr:
jmp patchFuncA
patchRet:

newmem:
patchFuncA:
jmp patchRet


Here, I tried to allocate a block of memory, and then label my first function I was writing in this block.

Now, instead of just having a 5-byte jmp instruction (plus whatever nops to match instructions) written to AOB_TestAddr, the jmp instruction is written *and* an additional 9 bytes are written.

In my current test case:
Code:

Expected: E9 25 13 50 FE 90 90 90
Actual:   E9 25 13 50 FE 66 0F 1F 84 00 00 00 00 00 90 90 90




Simply adding 'long' to my jump instruction fixes it:
Code:

[enable]
aobScanModule( AOB_TestAddr, test.exe, 80 7c 24 20 00 74 1e )
label( patchRet )
label( patchFuncA )

alloc( newmem, 4096, "test.exe" )

AOB_TestAddr:
jmp long patchFuncA
patchRet:

newmem:
patchFuncA:
jmp patchRet



Not sure what's going on, but it doesn't seem like expected behavior Smile


(side note: 'Spawn Diagram' is awesome! Did that just show up in 7.0? Awesome work!)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Oct 02, 2019 11:48 pm    Post subject: Reply with quote

That's by design. Forward jumps are unknown at the time of assembly and if no size specifier is provided it will reserve 14 bytes to fill in the jmp later

It shouldn't affect the functionality of the script though

_________________
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
chis101
How do I cheat?
Reputation: 0

Joined: 02 Oct 2019
Posts: 5

PostPosted: Thu Oct 03, 2019 2:32 pm    Post subject: Reply with quote

Ah okay, I thought I may have been doing something silly, but figured since both jump points were the same address they would act the same. Thanks for the quick reply!
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