Reverse Engineering Games - Intro and Tools

Sure, you beat your favorite game, but can you mod it?

Instead of exploring level one, looking for that last special item so you have all the concept art, what if you took a game apart?

Modding has become popular enough that some publishers even encourage it. Communities form to extend games, improve graphics, or shape games into something new. People publish tools and post their custom creations. It’s great, but what if you’re looking at a game where no such community exists yet? Well, someone has to start digging, so why not you?

Think of it as the hardest puzzle you’ll ever try to solve. You have 100s of megabytes, maybe gigabytes of information that’s written for a machine, and you have to make sense of it. It’s codebreaking in a sense. Better yet, it’s a chance to pull back the curtain, and peer into the minds of the people who made the games you love. For the amateur game programmers out there, I can promise you will be better at your craft once you peer into the assets of a big box title.

Personally, I started reverse engineering game files because I wanted to play with the 3d models. The chance to view the game worlds of my childhood from the sky, and maybe even tweak them to my liking, was too cool to pass up. I’ve learned two things since then:

  1. This stuff is hard.
  2. Learning how things work is a lot of fun, even when you don’t have an immediate use for the information.

So what do we need to get started? Just a few free tools fortunately:

  1. Text Editor: If you’re lucky, the game you want to reverse engineer will have a few nice, human readable text files for you to soak up. Get a good text editor for this. My favorite on Windows is Notepad++.
  2. Hex Editor: Every file on your computer is stored as an on-off binary sequence. Some of these represent the nice text files I talked about above. Most don’t. A hex editor takes binary and converts it into a series of base-16 numbers. It’s not an intuitive way to look at something, but it can let you view ANYTHING on you hard drive and begin to understand it. I am currently using HxD, which is stable and polished, but I am honestly still looking for an editor with a few more features that would be useful for making reverse engineering easier.
  3. Compiler for your language of choice: You’re gonna need to do some programming.

The prior entries deal with reading/editing the game’s assets (sounds, meshes, stats in an outside file, etc). If you want to change hardcoded behavior of the game you will need the following:

  1. Debugger/Disassembler: If you want to edit the executable itself (maybe for infinite life or a no-cd patch), you will need a tool to take the compiled game executable and show it as assembly code. For those not familiar, assembly language is an extremely low level programming language where each line corresponds to a processor instruction. Any .exe file can be converted back into assembly mnemonics, but you won’t have the advantage of variable or function names. Reverse engineering parts of the executable takes a tremendous amount of knowledge, skill and time, but presents boundless opportunity for modding. OllyDbg is a great free tool that will not only disassemble code, but let you set break points and step through it.
  2. Memory Editor: I’ll explain this one with an example. Say you’re playing a tycoon game and you want more money. You know you currently have $52,973. A memory editor can scan RAM for a specific value and change it. You can simply search for 52,973 in memory and set it to something else. Often times it is more complicated than this, but a memory editor is a good first step, as it is much easier than using a tool like OllyDbg. Check out CheatEngine for this one.

Those are the tools of the trade. In coming posts I’ll talk about extracting the assets from a few of my favorite titles.

Obligatory legal disclaimer: Reverse engineering itself is not against the law. Often times this stuff will violate a game’s EULA, however. Additionally, bypassing encryption or other copyright restrictions can fall afoul of the DMCA. This article from the Electronic Frontier Foundation will help you know more. When in doubt, consult a lawyer, and don’t look to dopes on the internet like me for legal advice.