Olly Debug
The latest craze in reverse engineering technology

Now that you've downloaded all the programs you're going to need, start up OllyDbg. Go to File > Open and select the Cavestory executable that you want to hack. WORD OF WARNING: It is possible to permanently ruin a Cave Story mod by using assembly hacking. Please use a new, fresh copy of Doukutsu for testing purposes. If you want to implement assembly hacks into your mod, please BACK UP your mod somewhere safe. When backing up your mod, make sure that you create multiple copies later on. I cannot stress this enough. (Backing up your mod is simple. First, make a copy of your mod folder and rename it something else. For example, the new folder could be "My Mod Backup 1". After a while, make another copy. As time progresses, you can delete the old backups and keep the newest ones.) By the way, ASM is short for Assembly, so whenever you see "ASM hacking", that just means Assembly Hacking. After opening up your Cavestory exe, you should see something like this: Err... confusing much? Don't worry about the right panel and the bottom panel. The main screen is your primary concern. Let's look at what all this data means. OllyDbg Explained Blue Box: Addresses Here is a long list of addresses. Each assembly instruction will start at a certain address. When you run the Doukutsu.exe program, the instructions will be executed one by one, from top to bottom[1]. You can use the JMP instruction to jump to a certain address and continue the code from there, similar to how the <EVE command in TSC will take you to a certain event in a script. Imagine ASM instructions like being a series of houses on a street: Many instructions are so large that they take up multiple addresses, similar to the mansion you see on the street. Notice that every address will start with the number 4. Also, every address will be 6 digits in length[2]. (Example: 402055 is a possible address) If you prefer to count the leading zeroes as digits, then each address starts with 004, and so every address must be 8 digits long, which includes those zeroes. Of course, it is your option whether to count the leading zeroes or not. To go to a certain address so that you can edit the instruction at that address, press Ctrl+G and type in the address you want. Each address is worth 1 byte. So, if I move forward in the code by 1 address, I actually move forward 1 byte. Going from address 459000 to 459006 means I have moved forward 6 bytes in the code. Red Box: Hex Dump The raw, hexadecimal version of the code. Don't worry about this too much, we're going to ignore it most of the time. We will learn what hexadecimal numbers are in the next lesson. Green Box: Instructions Remember that instructions are the commands that tell your computer what to do. Here are some example instructions: JMP = Jump to an address. MOV = Store a value into a memory location or register. CALL = Calls a procedure or function. PUSH = Pushes a number onto the stack. POP = Pops a number off the stack and stores it somewhere. Don't worry about understanding the different kinds of instructions right now. We will go over these instructions in detail later. Orange Box: Comments Possibly the most important part of ASM, commenting your code is an absolute necessity. Notice that OllyDbg already has some "comments" that explain parts of the ASM code. You can put in your own comments by double-clicking the orange box. Comments are like notes to help you understand what's going on with the instructions and whatnot. Other useful little things: Use Ctrl+F to find a certain instruction in the code. Select a chunk of code and press Ctrl+C to copy it. Now you can paste the code into Notepad or a similar plain text editor. Right click an instruction, go to Search for > Sequence of Commands... to type in a list of instructions and search for them. Also: Sometimes, if you modify your game .exe with a program that is not OllyDbg, such as CaveEditor, you may lose the comments you made previously. This is why it's a good idea to use the Ctrl+C shortcut to copy large blocks of code and save that code in a text file. The comments will be copied along with the instructions themselves. Navigation Previous Lesson: Defining A Program Next Lesson: Hexadecimal Numbers Table of Contents [1]Sort of. In reality, the first instruction executed is somewhere in the middle of the .exe file, not the beginning. However - what I mean is that the ORDER in which instructions are executed is always top to bottom, unless you change the current address using special instructions called jumps. We will learn about jumps later. [2]In some cases, addresses can start with the number 5 instead of 4. But 99% of the time, you use addresses that start with the number 4.