One of my favorite hobbies is Reverse Engineering.
It requires a solid knowledge of assembly and the use of disassemblers/debuggers to walk through compiled code. This allows you to alter, understand and reverse compiled programs. Each new program is like a puzzle waiting to be solved!
For example, a lot of people reverse games like Minesweeper when they are first starting out.
Here is a screenshot of a key section of code in Minesweeper I reversed awhile back (comments on right-hand side):
This was located by placing a breakpoint on calls to the rand()
function and stepping backwards in the callstack. After some digging it becomes obvious that:
- Minefield Height is located in 0x1005338
- Minefield Width is located in 0x1005334
- Minefield Baseaddress is located at 0x1005340
With this knowledge it becomes easy to determine the location of any given mine in the minefield by:
cellAddress = mapBaseAddress + (32 * (y+1)) + (x+1);
Then, with a simple loop and some calls to ReadProcessMemory()
you’ve got the ultimate Minesweeper hack!
Reading hand-written assembly is far easier than reading machine generated assembly. Modern compilers do some magical and crazy things to the code for optimization that can sometimes be difficult to follow. So, this will definitely push your assembly knowledge!
There are tons of activities that can branch off from this:
- Reverse hidden API’s in libraries
- Write advanced game hacks using DLL Injection, Code Caves, Function Hooking and more!
- Understand the limitations of various protection schemes employed by software
- Reverse a fileformat that isn’t published or known and write code to read this format for interoperability purposes.
- Write emulators for various systems (including older game systems!)
- Understand how a well-known program does a particular task.
- Reverse malware and viruses to see how and what they do.
And more!
If you are interested, I highly suggest the book: Reversing: Secrets of Reverse Engineering