Calculating Offset Manually
Introduction This tutorial is more of a tip than a tutorial. It just explains how to calculate offsets for jumps and calls within the program you are patching. Types of Jumps/Calls Here I will just describe the different types of jumps and calls which you will come across: Short Jumps Short jumps be they conditional or unconditional jumps are 2 bytes long (or 1 nibble if your Californian ;-). These are relative jumps taken from the first byte after the two bytes of the jump. Using short jumps you can jump a maximum of 127 bytes forward and 128 bytes backwards. Long Jumps Long jumps if they are relative are 6 bytes long for conditional jumps and are 5 bytes long for unconditional jumps. For conditional jumps 2 bytes are used to identify that it is a long jump and what type of jump (je, jg, jns etc) it is. The other 4 bytes are used to show how far away the target location is relative to the first byte after the jump. In an unconditional jump only 1 byte is used to identify it as a long