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 


Please help me. I dont know what to do about this

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
rog9001
Expert Cheater
Reputation: 2

Joined: 22 Dec 2015
Posts: 214
Location: Jupiter

PostPosted: Fri Apr 22, 2016 11:38 am    Post subject: Please help me. I dont know what to do about this Reply with quote

Ok so I found this funny cheat which lets cars spin rapidly and then fly up in Asphalt 8 but I am having issues with this stuff... I am trying to make a read and then write trainer where it reads whats in the address and then it writes to it. Here is the code:

Code:
function CEButton1Click(sender)
setProperty(CETrainer.CEEdit1,"Text", readInteger("00D1FD6C"))
end
function CEButton2Click(sender)
writeInteger("00D1FD6C", getProperty(CETrainer.CEEdit1,"Text"))
end


now... if you look at the photo you wont understand anything but the number "17842375" is "mov [eax+10],00000001" and the number "1065159" is "mov [eax+10],00000000". now I thought that's strange because I want it to just read instead of "1065159" read "0" and instead of writing "17842375" to change the stuff just type in "1" but it seams instead of reading the 0/1 it reads the bytes in a "4 bytes" version. How do I make it read 0 instead of 1065159 and write 1 instead of 17842375???????



Problem.png
 Description:
 Filesize:  303.74 KB
 Viewed:  3519 Time(s)

Problem.png


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

Joined: 06 Jul 2014
Posts: 4302

PostPosted: Fri Apr 22, 2016 12:47 pm    Post subject: Reply with quote

You can't just read and write from the start of an instruction and expect to get a coherent value for the immediate operand.

An instruction's machine code is broken up into two parts: the opcode and the operand(s). The opcode specifies what it's suppose to do (i.e. move data), and the operands specify the data it's working with (i.e. the r/m32 and the imm32). So, target the address of the immediate operand instead.

If you look at the bytes, you'll see C7 40 10 01 00 00 00 for the instruction mov [eax+10],00000001. It should be clear from looking at this that the immediate starts 3 bytes after the start of the instruction. So, instead of reading/writing from/to 00D1FD6C, use 00D1FD6F.

As for an explanation of those numbers you're getting:
17842375 (decimal) = 011040C7 (hex) = C7 40 10 01 (AoB)
1065159 (decimal) = 001040C7 (hex) = C7 40 10 00 (AoB)

_________________
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
rog9001
Expert Cheater
Reputation: 2

Joined: 22 Dec 2015
Posts: 214
Location: Jupiter

PostPosted: Fri Apr 22, 2016 2:30 pm    Post subject: Reply with quote

ParkourPenguin Thanks for the help but could you explain what you mean by this

Quote:

If you look at the bytes, you'll see C7 40 10 01 00 00 00 for the instruction mov [eax+10],00000001. It should be clear from looking at this that the immediate starts 3 bytes after the start of the instruction. So, instead of reading/writing from/to 00D1FD6C, use 00D1FD6F.


"It should be clear from looking at this that the immediate starts 3 bytes after the start of the instruction" how is it meant to be clear? I really don't get it Confused
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4302

PostPosted: Fri Apr 22, 2016 2:51 pm    Post subject: Reply with quote

It's how data is stored. A 4-byte integer decimal number is stored into bits in the form of powers of 2, or the binary number system (e.g. 138 = 2^7 + 2^3 + 2^1). These bits are grouped together into bytes to form hexadecimal numbers (e.g. 138 = 10001010 (binary) = 8A (hex)). Sequences of multiple bytes are usually stored in the little endian format, where the least significant byte comes first.

If you understand that and you look at the mnemonic mov [eax+10],00000001, then it should be clear that the immediate 1 will be represented as 01 00 00 00 in the machine code. After you get some experience in asm, you can look at machine code and be able to tell what's what without even needing to think about it. For example, I know that the byte C7 is the opcode of the mov instruction, the byte 40 represents [eax+offs8], 10 is the offs8, and the rest is the imm32.

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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