Using a Hex Editor

WinHex & X-Ways

Using a Hex Editor

 

A hex editor is capable of completely displaying the contents of each file type. Unlike a text editor, a  hex editor even displays control codes (e. g. linefeed and carriage-return characters) and executable code, using a two-digit number based on the hexadecimal system.

 

Consider one byte to be a sequence of 8 bits. Each bit is either 0 or 1, it assumes one of two possible states. Therefore one byte can have one of 2•2•2•2•2•2•2•2 = 2^8 = 256 different values. Since 256 is the square of 16, a byte value can be defined by a two-digit number based on the hexadecimal system, where each digit represents a tetrade or nibble of a byte, i. e. 4 bits. The sixteen digits used in the hexadecimal system are 0-9, A-F.

 

You can change the value of a byte by changing these digits in the hexadecimal mode. It is also possible to enter the character that is assigned to a certain byte value by a character set. All kinds of characters are allowed (e.g. letters and punctuation marks). Example: A byte whose decimal value is 65 is displayed as 41 in hexadecimal notation (4•16+1=65) and as the letter A in text mode. The ASCII character set defines the capital letter A to have the decimal value of 65.

 

When editing files of a certain type (for instance executable files), it is essential not to change the file size. Moving the addresses of executable code and included data results in severely damaging such files. Please note that changing the contents of a file generally may be the reason for the corresponding application to behave anomalously. It is quite safe to edit text passages in a file. At any rate, it is recommendable to create backup files before editing.

 

The command "Combined Search" was especially designed for editing files created by computer games to save the game state. If you know the value of a variable in two of such files, you can find out the offset, i. e. the position, at which this data is saved. Example: If two files hold the information that you have 5 resp. 7 points/lives/..., search simultaneously for the hex value 05 in the first and 07 in the second file.