Difference between revisions of "HOWTO-Reverse Engineering"

Jump to navigation Jump to search
no edit summary
(Added Practical Examples section to Reverse Engineering HOWTO)
(4 intermediate revisions by 3 users not shown)
Line 17: Line 17:
[http://en.wikipedia.org/wiki/X86_assembly_language 8086 Assembly Language]
[http://en.wikipedia.org/wiki/X86_assembly_language 8086 Assembly Language]
For those new to 8086 assembly language, you'll need a handy reference to learn the syntax. The Wikipedia is a good starting point, but you can also simply Google for an introduction as well.
For those new to 8086 assembly language, you'll need a handy reference to learn the syntax. The Wikipedia is a good starting point, but you can also simply Google for an introduction as well.
[http://beginners.re/ "Reverse Engineering for Beginners" free book]
This site has a free ebook that may be useful as a gentle introduction to reverse engineering techniques in general.
[http://godbolt.org/ Compiler Explorer]
A pretty cool online tool that lets you paste in C code and shows you the compiled assembly under various different compilers. Useful if you're familiar with C, and what see what kinds of assembly are produced for various different code fragments.
[https://www.frida.re/ FRIDA - Dynamic Instrumentation Framework]
Nice tool for a easy writing and injecting hooks to game binaries. Useful for watching how code executes, when are internal functions called, for dumping structures from memory of target process and for changing data in memory on the fly. Works for newer binaries of games (32bit and windows xp)


== Using the DosBox Debugger ==
== Using the DosBox Debugger ==
Line 53: Line 62:
=== Naming Methods ===
=== Naming Methods ===
Methods can be renamed using the general 'N' hotkey (as well as via the menus), and the 'Y' can be used to specify a C-like prototype for a method. This is particularly useful when some of the parameters for a method are passed using registers. By explicitly documenting what the method expects, it makes it easier to remember later on when you're reversing methods that call it. Standard methods where parameters are passed via the stack are easy, since IDA can automatically set up the function prototype for you. If a method does have parameters passed in registers, prototypes like the below can be used:
Methods can be renamed using the general 'N' hotkey (as well as via the menus), and the 'Y' can be used to specify a C-like prototype for a method. This is particularly useful when some of the parameters for a method are passed using registers. By explicitly documenting what the method expects, it makes it easier to remember later on when you're reversing methods that call it. Standard methods where parameters are passed via the stack are easy, since IDA can automatically set up the function prototype for you. If a method does have parameters passed in registers, prototypes like the below can be used:
<syntax type="C">
<source lang="c">
int __usercall sub_100FB<ax>(__int8 param1<al>, int param2<bx>)
int __usercall sub_100FB<ax>(__int8 param1<al>, int param2<bx>)
</syntax>
</source>


In this case, the method takes an 8-bit parameter in the al register, and another 16-bit value in bx, then returns a result in ax
In this case, the method takes an 8-bit parameter in the al register, and another 16-bit value in bx, then returns a result in ax
Line 63: Line 72:


When dealing with data, you'll frequently see cases like
When dealing with data, you'll frequently see cases like
<syntax type="asm">
<source lang="asm">
mov bx, 30h
mov bx, 30h
mul bx
mul bx
mov ax, [bx+2D00h]
mov ax, [bx+2D00h]
</syntax>
</source>


In this case, an initial index in the ax register is multiplied by 30h (30 hexadecimal = 48 decimal). So from this we can determine that the given structure is 48 bytes in size, and can create a new structure accordingly. For smaller sized structures, you may want to create as many 2 byte word fields as needed to make up the correct size for the structure. For larger sizes, the easiest way is to simply declare an array of the needed structure size - 1, and follow it with a single byte field. You can then delete/undefine the array. The remaining byte will keep the structure at the correct size, and you can then later fill in the fields as you find references to them.
In this case, an initial index in the ax register is multiplied by 30h (30 hexadecimal = 48 decimal). So from this we can determine that the given structure is 48 bytes in size, and can create a new structure accordingly. For smaller sized structures, you may want to create as many 2 byte word fields as needed to make up the correct size for the structure. For larger sizes, the easiest way is to simply declare an array of the needed structure size - 1, and follow it with a single byte field. You can then delete/undefine the array. The remaining byte will keep the structure at the correct size, and you can then later fill in the fields as you find references to them.
47

edits

Navigation menu