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 


Different byte generation

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

Joined: 06 Sep 2016
Posts: 2

PostPosted: Tue Sep 06, 2016 12:22 pm    Post subject: Different byte generation Reply with quote

While I was looking to freeze a time for a game I found something weird.
Since I can't post urls yet I'll add the screenshots as an attachment.
See "Before activation.png"
When I tried to edit the line:
State of War.exe+26ED1 A3 94727000 mov ["State of War.exe"+307294],eax (eax contains the seconds of the time)
and saved it without making a change it would give me the message:

"The generated code is 6 byte(s) long, but the selected opcode is 5 byte(s) long! Do you want to replace the incomplete opcode(s) with NOP's?"

Why would it change the bytes of an unchanged code?

Anyway, I did a code injection and make the following script:
Code:

[ENABLE]
alloc(seconds,100)
label(returnhere)
label(exit)

seconds:
mov ["State of War.exe"+307294],3B //Set seconds to 59 so minutes never gets changed
jmp exit

exit:
jmp returnhere

"State of War.exe"+26ED1:
jmp seconds
returnhere:

[DISABLE]
dealloc(seconds)

"State of War.exe"+26ED1:
mov ["State of War.exe"+307294],eax


When enabled it would show this:
See "Enabled.png"

The problem occurs when I disable it again, the previous code gets replaced back but the byte length changes from 5 to 6:
See "Disabled.png"

The bytes changed from A3 94 72 70 00 to 89 05 94 72 70 00 for some reason, thus changing other code and crashing the game.

I fixed the problem by editing the last line of the script to:
db A3 94 72 70 00

But I'm still wondering what's causing this? Am I missing something?



Before activation.png
 Description:
 Filesize:  13.1 KB
 Viewed:  3850 Time(s)

Before activation.png



Enabled.png
 Description:
 Filesize:  12.13 KB
 Viewed:  3850 Time(s)

Enabled.png



Disabled.png
 Description:
 Filesize:  11.29 KB
 Viewed:  3850 Time(s)

Disabled.png


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

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

PostPosted: Tue Sep 06, 2016 12:42 pm    Post subject: Reply with quote

they are both valid lines.
tbat's why the template adds the db line as secondary option

_________________
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
kuntz
Cheater
Reputation: 0

Joined: 29 Aug 2016
Posts: 44
Location: Canada

PostPosted: Tue Sep 06, 2016 4:19 pm    Post subject: Reply with quote

MOV [M32], EAX has multiple encodings and in this case CE's assembler is choosing the longer 6-byte encoding over the smaller 5-byte variant:

www-felixcloutier-com/x86/MOV-html

CE has no way of knowing what the original code is, so if you provide it a script with an ambiguous statement such as "mov [m32], EAX" there's no telling what it's going to do. Always use db's when replacing existing code since it is the only way to guarantee compatibility.
Back to top
View user's profile Send private message
Iamhere55
How do I cheat?
Reputation: 0

Joined: 06 Sep 2016
Posts: 2

PostPosted: Tue Sep 06, 2016 4:40 pm    Post subject: Reply with quote

I understand it now, thank you for your answers.
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