Posted: Mon Jun 13, 2016 9:22 am Post subject: Figure out bytes from opcode?
Hey everyone, im wondering if theres a way to calculate the bytes in an opcode that involves calling a function or address in a game. For example, the opcode call 3EEFF240 gives the bytes E8 33F28F3D. I know E8 is for the call function but how does cheat engine calculate the address 3EEFF240 into the bytes 33F28F3D? I've been looking for quite a while now but havent found much results, if anyone has any suggestions or knows how the bytes are calculated i would gladly appreciate it!
Terminology: an instruction is the thing that's executed. It encompasses both the operation to be performed and the information used to perform said operation. The bytes it's composed of is called machine code. The opcode is the bytes used to represent the operation to be performed (i.e. the byte E8). The operands are the information used to perform the operation (i.e. the dword 3D8FF233).
That particular addressing mode of the call instruction uses a rel32 displacement from the address of the next instruction. This means that the instruction call 3EEFF240 must have been located at the address 01600008: 3EEFF240 (end address) - 3D8FF233 (rel32) - 5 (call instruction).
Let's say you want to jump to address B via a call instruction located at address A. The opcode would be E8, and the dword operand would be B - A - 5.
2 notes: the dword operand is stored in little endian, and you can't do this in a 64-bit process if the address you're jumping to is greater than 2GB away. _________________
I don't know where I'm going, but I'll figure it out when I get there.
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