The KHexEdit Handbook

The KHexEdit Handbook

The KHexEdit Handbook

Jonathan Singer

Developer: Espen Sand

Reviewer: Lauri Watts

Revision 0.08.05

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

KHexEdit is a hexadecimal editor for the KDE environment.


Chapter 1. Introduction

Introduction

Chapter 1. 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.

KDE Logo
Chapter 2. Starting KHexEdit

Starting KHexEdit

Chapter 2. 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 specfied file

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

KDE Logo
Chapter 3. KHexEdit In A Nutshell

KHexEdit In A Nutshell

Chapter 3. KHexEdit In A Nutshell

The main KHexEdit window has the following components: menubar, toolbar, offset column, data editor window, text field, searchbar, conversion field and status bar.

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 searchbar 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.

KDE Logo
Chapter 4. Menu Commands

Menu Commands

Chapter 4. Menu Commands

Note that most menu commands also have a keyboard shortcut.

File Menu

File->New (Ctrl+N)

Open a new file.

File->Open... (Ctrl+O)

Open an existing file.

File->Insert... (Ctrl+I)

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.

File->Save (Ctrl+S)

Save document.

File->Save As...

Save document with a new name.

File->Close (Ctrl+W)

Close the current document.

File->Print... (Ctrl+P)

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

File->Quit (Ctrl+Q)

Close all KHexEdit windows

Edit Menu

Edit Menu

Edit Menu

Edit->Undo (Ctrl+Z)

Undo the last action.

Edit->Redo (Ctrl+Shift+Z)

Redo the last undone action.

Edit->Cut (Ctrl+X)

Delete the selected bytes and copy them to the clipboard.

Edit->Copy (Ctrl+C)

Copy the selected bytes to the clipboard.

Edit->Paste (Ctrl+V)

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.

Edit->Select All (Ctrl+A)

Select entire document.

Edit->Unselect

Unselect entire document.

Edit->Find... (Ctrl+F)

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.

Edit->Find Next (F3)

Find the next instance of the Find pattern.

Edit->Find Previous (Shift+F3)

Find the previous instance of the Find pattern.

Edit->Replace... (Ctrl+R)

Replace the find pattern with a different pattern.

Edit->Goto Offset... (Ctrl+G)

Move the cursor to a specified offset.

Edit->Insert Pattern... (Ctrl+Ins)

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.

KDE Logo
View Menu

View Menu

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.)

KDE Logo
Bookmarks Menu

Bookmarks Menu

Bookmarks Menu

Bookmarks->Add Bookmark (Ctrl+B)

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.

Bookmarks->Replace Bookmark (Ctrl+E)

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.

Bookmarks->Remove Bookmark (Ctrl+U)

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.

Bookmarks->Goto Next Bookmark (Alt+Down)

Move the cursor to the next bookmark.

Bookmarks->Goto Previous Bookmark (Alt+Up)

Move the cursor to the previous bookmark.

KDE Logo
Tools Menu

Tools Menu

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. Checkboxes 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.

KDE Logo
Documents Menu

Documents Menu

Documents Menu

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

KDE Logo
Settings Menu

Settings Menu

Settings Menu

Settings->Show Toolbar

Toggle display of the toolbar below the menubar.

Settings->Show Statusbar

Toggle display of the statusbar

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 searchbar. 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. Gridlines 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 nonprinting 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.

KDE Logo
Help Menu

Help Menu

Help Menu

Help->Contents... (F1)

Invokes the KDE Help system starting at the KHexEdit help pages. (this document).

Help->What's This? (Shift+F1)

Changes the mouse cursor to a combination arrow and question mark. Clicking on items within KHexEdit will open a help window (if one exists for the particular item) explaining the item's function.

Help->Report Bug...

Opens the Bug report dialog where you can report a bug or request a ‘wishlist’ feature.

Help->About KHexEdit

This will display version and author information.

Help->About KDE

This displays the KDE version and other basic information.

KDE Logo
Toolbar

Toolbar

Toolbar

The toolbar contains icons for the following commands:

Note

(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.

Searchbar

The searchbar 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 searchbar; go to Searchbar in the Settings menu to restore it.

Conversion field

The conversion field displays the values of various datatypes 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 betwen 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 diplaying 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.

KDE Logo
KDE Logo
Chapter 5. Credits and License

Credits and License

Chapter 5. Credits and License

KHexEdit

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

Contributors:

Documentation copyright 2000 Jonathan Singer <jsinger@leeta.net>

This documentation is licensed under the terms of the GNU Free Documentation License.

This program is licensed under the terms of the GNU General Public License.

KDE Logo
Appendix A. Compilation and Installation

Compilation and Installation

Appendix A. Compilation and Installation

KHexEdit is part of the KDE project http://www.kde.org/.

KHexEdit can be found in the kdeutils package on ftp://ftp.kde.org/pub/kde/, the main FTP site of the KDE project.

In order to compile and install KHexEdit on your system, type the following in the base directory of the KHexEdit distribution:

% ./configure
% make
% make install

Since KHexEdit uses autoconf and automake you should have no trouble compiling it. Should you run into problems please report them to the KDE mailing lists.

KDE Logo
KDE Logo