Application "BinPatch.exe" INTRODUCTION BinPatch is a versatile file reading and patching program. Using it, you can inspect and modify the contents of any file, extract segments from the file, and splice files together. The primary display is in hexadecimal format, with an ASCII display as well. Not all ASCII byte values have printable characters. For most of these, other characters have been substituted in the ASCII display column. MENU File Open Close Exit Edit... Copy page Copy Selected Text RevByteOrder Ascii Integer Long Read Address Single Double Copy a Snip Start Address End Address Make Snip File Splice Loaded + File2 > Splice NAVIGATION BUTTONS: Select Start Back Fwd TEXT ENTRY AND DISPLAY WINDOWS: Main Display Detail Display and Data Entry (Above main window) Window for entry of address for patch data DATA TYPE OPTION BUTTONS: Byte Integer [2 bytes] Long [4 bytes] Short [4 bytes] Double [8 bytes] DISPLAY FORMAT DESCRIPTION: The hexadecimal numbering system is base 16 (decimal is base ten) and has the number sequence 0 through 10, followed by A through F. Since each character is 4 binary bits long, it takes two characters to represent a byte value. A line of display of integer numbers looks like this: 00019020 80E4 480B 391C 5CE5 E00B 491B 4CE6 C80C €äH^9\åà^ILæÈF The first group of 8 characters, represents the offset address of the starting point of the line, in bytes from the start of the file. In this example "00019020" is hexadecimal for decimal "102432". Following the offset address are 8 groups of 4 hexadecimal characters each. The first two characters of a group are the hexadecimal value of a byte, and so are the second. A line of display represents a total of 16 bytes of data on the file. The next group of 16 characters are an attempt to represent the value of each byte with printable Ascii characters. To interpret the contents of a binary file, one must know the format of the file, i.e., what type of data was written (byte, integer, short, etc.), where the boundary lines between data values are, and in what order the byte values representing a number are written to the file. One would natually expect to find the most significant byte value to appear first, followed by the bytes of lesser significance. This is the case for main frame computers, and this format is called "Big Endian". However, Intel-based processors write the least significant byte first ("Little Endian"). All PC's use Little Endian, and BinPatch.exe assumes this. One may, however, encounter data files written in Big Endian, which is the reason for the "RevByteOrder" command in the Edit menu. The integer number "12345" is hex "3039", but displays as "3930" in a PC file. HOW TO READ A STORED NUMERICAL VALUE: 1. Use the mouse to highlight the group of hex characters you want to interpret. 2. Click on "Copy Sel Text" button. The selected text will appear in the I/O window. 3. Click on "Edit.." and on the data type. If you do everything right, a decimal number will appear in the I/O window. 4. If you want interpret a byte value, copy just two characters to the I/O window, append 2 zeroes to it and select "Integer" data type to convert. HOW TO READ A LINE OFFSET ADDRESS: 1. Use the mouse to select the hexadecimal address at the left end of the line. (8 charaters). 2. Click on "Copy Sel Text" button. The selected text will appear in the I/O window. 3. Click on "Edit.." and on "Read Address". The decimal offset value will appear. HOW TO CHANGE A STORED NUMERICAL VALUE: 1. Be sure to make a BACKUP COPY of the file first! 2. Type in the new number in the I/O window. 3. Type the offset address in the patch address window, in hexadecimal. 4. Select the data type, using the option buttons. 5. Click "Paste" while watching the area of the display window where you expect to see the change. If you do not see the change, or if it not what you intended, immediately click on "Undo", and reconfirm what you had originally entered. Otherwise, you may have corrupted the file. ***Note*** When pasting in a double precision number, you may not get exactly the bit pattern you might want. The precision of the decimal number is probably not enough to exactly define the least significant bits of the hexadecimal representation. Suppose that you want to paste exactly the same double precision number from one location in the file to another. First, do this as well as you can by reading the number and pasting it. Then, compare the hex display of the pasted number with the source display. If they do not exactly match, then repatch by reading and pasting byte or integer pieces of the original number into the new number. HOW TO COPY A SEGMENT OF THE FILE TO A NEW FILE: 1. Click on "Copy a snip". 2. Select "Start Address". Enter the start offset (in hex) in the dialog box. 3. Click on "Copy a snip". 4. Select "End Address". Enter the end offset (in hex) in the dialog box. 5. Click on "Copy a snip". 6. Select "Make Snip File" Enter the file name in the Save Dialog Box, with the desired extension, if any. HOW TO SPLICE TWO FILES TOGETHER: (The first file is the one loaded into BinPatch) 1. Click on "Splice" and "Loaded + File2 > Splice". 2. Select the file to be attached in the Open Dialog Box. 3. Enter the name of the spliced file in the Save Dialog Box, with the desired extension, if any. ------------------ Thise progam is written in Visual Basic 6.0, and may not run on your machine. It may be necessary to download the file "VBRun60sp4.exe" from http://support.microsoft.com. This is a self-extracting Exe File, which installs the run-time files necessary for Visual Basic applications. ------------------ Bob McClure January, 2005 =====