# The &khexedit; Handbook

## Introduction

&khexedit; is an editor for the raw data of binary files. It includes find/replace functions, bookmarks, many configuration options, drag and drop support and other powerful features.

## Starting &khexedit;

Type ``khexedit`` at a command prompt or select Binary Editor from the Utilities group in the KDE start menu.

The standard &Qt; and &kde; command line options are available, and can be listed by entering ``khexedit` `--help``.

Other command line options are:

``<file>`` - open the specified file

`--offset` `<offset>` jump to position `<offset>` in the opened file.

## &khexedit; In A Nutshell

The main &khexedit; window has the following components: menu bar, toolbar, offset column, data editor window, text field, search bar, conversion field and status bar.

&khexedit; Screen &khexedit; Screen

When a document is opened, the bytes are displayed in hexadecimal format in the data editor window. The data can be edited, cut, copied, pasted, dragged and dropped much as text is in an text editor or word processor. A cursor marks the current position. Pressing the Insert key toggles between overwrite and insert text entry modes. The data can also be displayed as octal, binary or decimal values, by choosing the desired format in the View menu.

The offset column on the left indicates the position of a particular byte in the file. The text field on the right displays the ASCII encoding of the file. The cursor position and edits in the data editor window are reflected in the text field. The text field can also be edited, and those changes are reflected in the data editor window.

The search bar allows the user to search for a specific value -- hexadecimal, octal, binary, decimal or text.

The conversion field displays the value of the byte at the cursor position in a variety of bases. It also displays the value of all standard data types starting at the cursor.

Multiple documents can be open at the same time but only one can be active. Use the Documents menu to select which document will be active.

## Menu Commands

Note that most menu commands also have a keyboard shortcut.

### File Menu

&Ctrl;N File New

- Open a new file.

&Ctrl;O File Open...

- Open an existing file.

&Ctrl;I File Insert...

- Insert an exiting file in the current document.

File Open Recent

- Choose from a list of the last opened files.

File Revert

- Return edited document to the last saved state.

&Ctrl;S File Save

- Save document.

File Save As...

- Save document with a new name.

&Ctrl;W File Close

- Close the current document.

&Ctrl;P File Print...

- Print the current document.

File Export...

- Export the selected document or a portion of it.

  Opens a dialog box with these options:

  Format

- Plain text, HTML table, rich text format, C array. Use the Options tab to select details for a C array or an HTML table.

Destination

- The file to which the data will be exported

Export Range

- Selects which data will be exported -- the entire document, the selected portion or the range between two specified offsets.

File Cancel Operation

- Stop the current operation

File Permissions

- Set write privileges:

  Read only

- When set, changes may not be made to the displayed file.

Allow Resize

- When off, individual bytes may be edited but the total number of bytes may not be changed.

File New Window

- Open an additional &khexedit; window

File Close Window

- Close the current &khexedit; window

&Ctrl;Q File Quit

- Close all &khexedit; windows

### Edit Menu

&Ctrl;Z Edit Undo

- Undo the last action.

&Ctrl;&Shift;Z Edit Redo

- Redo the last undone action.

&Ctrl;X Edit Cut

- Delete the selected bytes and copy them to the clipboard.

&Ctrl;C Edit Copy

- Copy the selected bytes to the clipboard.

&Ctrl;V Edit Paste

- Insert the cut or copied bytes in the clipboard.

Edit Special

- Variations on Copy and Paste:

  - Copy as Text: Copies the selected bytes as ASCII characters.

  - Paste into New File.

  - Paste into new window.

&Ctrl;A Edit Select All

- Select entire document.

Edit Unselect

- Unselect entire document.

&Ctrl;F Edit Find...

- Find a specified pattern in the document. Hexadecimal,decimal, octal, binary or text patterns can be searched for.

  Options in the dialog box allow you to specify the starting point, direction and range of the search.

F3 Edit Find Next

- Find the next instance of the Find pattern.

&Shift;F3 Edit Find Previous

- Find the previous instance of the Find pattern.

&Ctrl;R Edit Replace...

- Replace the find pattern with a different pattern.

&Ctrl;G Edit Goto Offset...

- Move the cursor to a specified offset.

&Ctrl;Ins Edit Insert Pattern...

- Insert a specified string of bytes.

  Options in the dialog box allow you to specify the length of the pattern, its format (hexadecimal, decimal, octal, binary or text) and the insertion point.

  If Repeat pattern is checked, the specified pattern will be inserted repeatedly to reach the length set in Size.

### View Menu

View Hexadecimal View Decimal View Octal View Binary View Text

- The first five choices select the format displayed in the data editor window: hexadecimal, decimal, octal, binary or text. When text display is selected, the extra text field is not displayed.

View Show Offset Column

- Toggles display of offset column on and off.

View Show Text Field

- Toggles display of text field on and off.

View Offset as Decimal

- When set, all offsets are displayed and interpreted as decimal numbers rather than as hexadecimals.

View Upper Case (Data)

- When set, hexadecimal digits in the data are displayed in upper case.

View Upper Case (Offset)

- When set, hexadecimal digits in the offset value are displayed in upper case.

View Document Encoding

- Select the encoding used for display in the text field. Alternative encodings like EBCDIC and 7-bit ASCII can be used. Additional encodings can be added by the user (not implemented yet.)

### Bookmarks Menu

&Ctrl;B Bookmarks Add Bookmark

- Bookmark a location within the document.

  Multiple bookmarks can be set for a single document. Each document has its own set of bookmarks and the appropriate set is displayed at the bottom of the Bookmarks menu when a document is selected. Choose a bookmark from the menu to go to it.

&Ctrl;E Bookmarks Replace Bookmark

- Reset an existing bookmark to the current cursor location. A dialog will be opened with the list of available bookmarks; select the one you wish to change.

&Ctrl;U Bookmarks Remove Bookmark

- Remove an existing bookmark. A dialog will be opened with a list of available bookmarks; select the one you wish to remove.

Bookmarks Remove All

- Clear the bookmark list.

&Alt;Down Bookmarks Goto Next Bookmark

- Move the cursor to the next bookmark.

&Alt;Up Bookmarks Goto Previous Bookmark

- Move the cursor to the previous bookmark.

### Tools Menu

Tools Extract Strings...

- Locate ASCII strings in the data. Minimum string length, case sensitivity and a pattern to match can be specified.

Tools Binary Filter...

- Perform a binary operation on the data. The operation (AND, OR, ROTATE..) and an operand can be specified in the dialog box. Check boxes in the dialog allow the operation to be limited to selected bytes or the region before or after the cursor.

Tools Character Table

- Open a list of values and their ASCII equivalents and insert the selected value at the cursor.

Tools Converter

- Enter a value in any of the fields and see its equivalent in hexadecimal, decimal, octal, binary or text. A check box allows viewing of the value at the cursor instead.

Tools Statistics

- Display the frequency of occurrence of values in the document.

### Documents Menu

Provides a list of the open documents. Selecting one makes it active.

### Settings Menu

Settings Show Toolbar

- Toggle display of the toolbar below the menu bar.

Settings Show Statusbar

- Toggle display of the status bar

Settings Show Full Path

- Toggle display of the full file path in the titlebar

Settings Document Tabs

- Change display of tabs for all current documents. The tab can be displayed above or below the editor window, or hidden. You may find the tabs more convenient than the document menu for switching documents.

Settings Conversion Field

- Change display of the value conversion field. It can be embedded in the main window, made a floating window or hidden.

Settings Searchbar

- Change display of the value search bar. It can be displayed above or below the editor window, or hidden.

Settings Save Options

- Save the current state of the options.

Settings Preferences...

- Change these settings:

  Layout

- Line and column size (in bytes). These can be set separately for different modes. Fixed number of bytes per line. Lock column at end of line. Grid lines between rows and columns. Width of field separators, spacing and margins.

Cursor

- Blink rate and shape of the cursor. Behavior of the cursor when the window loses focus.

Font

- Font name, style and size. Character used to display non printing characters in the text field.

Colors

- All colors in &khexedit; can be customized, including odd and even lines and columns, bookmarks, separators and grid lines. The one exception is the selection color, which uses the setting chosen in the KDE Control Center.

Files

- Opening of the last, or all recent documents on startup. Restoration of cursor position. Write protection enabled by default. Make a backup upon saving files. Saving of Recent Documents list on exit. The Recent Documents list can also be cleared in this dialog.

Miscellaneous

- Automatic copy to clipboard upon selection. Startup in insert mode, rather than overwrite. Confirmation required for wrapping to the beginning or end during searches. Cursor jumps to nearest byte when moved in binary mode. Sound on typing input or fatal failure. Display of bookmarks in the offset column and editor fields. Warning when number of printable pages exceeds a settable limit. Maximum number of undos.

### Help Menu

&help.menu.documentation;

### Toolbar

The toolbar contains icons for the following commands:

(Except for Drag document and Toggle write protection, all behave identically to the menu command.)

- Drag document -- Click this button and drag to a text editor or a new &khexedit; window.

- New

- Open

- Revert

- Save

- Print

- Find

- Find Next

- Find Previous

- Cut

- Copy

- Paste

- Undo

- Redo

- Cancel Operation

- Help

..and at the right of the toolbar..

Toggle write protection - switch between read-only and read/write modes.

#### Search bar

The search bar is used to locate a specific value in the document. Enter a value in the box, select the desired representation (hexadecimal, octal, binary, decimal or text) and hit the Find button. Check the Backwards box to search backwards from the cursor point or check Ignore case for a case-insensitive text search. Click the button on the right of the bar (X) to hide the search bar; go to Searchbar in the Settings menu to restore it.

#### Conversion field

The conversion field displays the values of various data types at the selected byte. For 8 bit types, it displays the value of the byte under the cursor; for larger types, it displays the value starting at that byte. The rightmost column displays various encodings of the current byte. Options in the conversion field are:

Show little endian decoding

- When checked, causes multibyte types to be calculated using the little-endian method used by x86 and Alpha processors. In this scheme, the first byte represents the least significant part of the value. (0a 4e = 0x4e0a = 19978) When unchecked, causes multibyte types to be calculated using the big-endian method used by PowerPC and Sparc processors. (0a 4e = 0x0a4e = 2638)

Show unsigned as hexadecimal

- When checked, causes unsigned types to be displayed in hexadecimal, rather than decimal format.

Stream length

- Determines the number of bits used to calculate the values in the fields above it.

#### Status Bar

The status bar displays the following information:

Encoding/Selection

- When there is no selection, this field shows the encoding option used. (See View Document Encoding for more information on encoding.) The start point and the length of the selection are shown.

File Modified

- A `!` in this box indicates the current file was modified.

Insert/Overwrite

- Indicates whether values entered at the keyboard are inserted at the cursor point (INS) or overwrite the existing data starting at the cursor(OVR). Use the Insert key to toggle between the two modes.

Size

- Displays the total size of the current document.

Offset

- Indicates the position of the cursor within the document.

Display mode

- Indicates whether data editor window is displaying values in hexadecimal, octal, binary, decimal or text mode. Switch between modes with the View menu.

Write Protection

- Indicates whether the document can be edited (RW) or is being viewed read-only (R). Switch between modes with the button on the far-right of the toolbar or the Permissions command in the File menu.

## Credits and License

&khexedit;

Program copyright 1999-2000 Espen Sand espensa@online.no

Contributors:

- Leon Lessing leon@irlabs.com

- Craig Graham c_graham@hinge.mistral.co.uk

- Dima Rogozin dima@mercury.co.il

- Edward Livingstone-Blade sbcs@bigfoot.com

Documentation copyright 2000 Jonathan Singer jsinger@leeta.net

&underFDL; &underGPL;

## Compilation and Installation

&install.intro.documentation; &install.compile.documentation;
&documentation.index;