DHEX(1)
okay so bestie, this is dhex(1) โ hex editor with a diff mode โ and she is genuinely iconic. ๐
โจ
๐ธ NAME ๐ธ
dhex โ hex editor with a diff mode. periodt. ๐ซถ
โจ SYNOPSIS โจ
dhex [-x]
dhex [-h] [-v] [-g] [-k] [-ab -ad -ah -ao base address] [-f config-file]
[-m marker-file] [-ob -od -oh -oo offset] [-r searchlog]
[-sa -sab string (ascii)] [-sh -shb string (hex)] [-w searchlog]
[file]
dhex [-h] [-v] [-g] [-k] [-a1b -a1d -a1h -a1o base address 1]
[-a2b -a2d -a2h -a2o base address 2] [-cb] [-cd upper-limit] [-cl]
[-f config-file] [-m marker-file] [-o1b -o1d -o1h -o1o offset1]
[-o2b -o2d -o2h -o2o offset2] [-r1 searchlog1] [-r2 searchlog2]
[-s1a -s1ab -s1h -s1hb string (ascii/hex)]
[-s2a -s2ab -s2h -s2hb string (ascii/hex)] [-w1 searchlog1]
[-w2 searchlog2] [file1 file2]
๐ฆ DESCRIPTION ๐ฆ
dhex is a hex editor. It can be used to alter individual bytes in large files. Since it is a text-mode program based on ncurses, it can run in numerous scenarios. Its special feature is the diff mode: with it, the user has a visual tool for file comparison. This mode is invoked when dhex is called with two instead of one file as parameters.
so yeah โ pass her two files instead of one and boom, you're in diff mode, getting that visual file-comparison moment. very demure, very mindful, very main character. ๐
๐ OPTIONS ๐
All the options are case-insensitive โ you can give them as either upper- or lowercase characters, bestie. ๐
-ab,-ad,-ah,-aobase address โ after loading a file, every address gets a base address other than0. This makes it easier to work on partial memory dumps. You can give the base address as a binary one with-ab, as a decimal one with-ad, as a hexadecimal one with-ah, or an octal with-ao. ๐-a1b,-a1d,-a1h,-a1obase address 1-a2b,-a2d,-a2h,-a2obase address 2 โ for the diff mode, you can set two different base addresses. Again, a binary address can be given as-a1b -a2b, decimal one with-a1d -a2d, hexadecimal one with-a1h -a2h, or an octal one with-a1o -a2o.
This base address is calculated into the marker files as well as the searchlogs. โจ
-cb,-clโ diff mode only, bestie: the input files can be correlated from the command line with the best-cbor longest-clmatch. This is very slow. ๐ญ-cdupper-limit โ diff mode only: the input files can be correlated from the command line with the minimum difference. To improve the correlation speed, an upper limit can be provided. ๐ฆ-fconfigfile โ usually,.dhexrcis being read from the invoker's home directory. With this parameter, any other config file can be loaded. Seedhexrc(5)for a description of its file format. ๐-gโ shows the license. ๐-xโ starts the hexcal. ๐ฅ-hโ shows the help screen. ๐ซถ-kโ starts the keyboard setup manually before any file is being loaded. This is very helpful when callingdhexfrom an exotic terminal. โจ๏ธ-mmarkerfile โ it is possible indhexto set bookmarks and store them in a markerfile for later use. With this parameter, the markerfile is being read at start time, making it unnecessary to read them later through the gui. Their file format is described indhex_markers(5). ๐-ob,-od,-oh,-oooffset โ after loading a file, the cursor is set to0, and the first page of bytes is being shown on the screen. With one of those parameters it is possible to start at any other location in the file. The cursorposition could be given as a binary number with-ob, as a decimal one with-od, as a hexadecimal one with-oh, or an octal with-oo. ๐-o1b,-o1d,-o1h,-o1ooffset1-o2b,-o2d,-o2h,-o2ooffset2 โ for the diff mode, it is possible to set two different cursorpositions at start time. Again, the cursorpositions can be given as a binary number with-o1b -o2b, as decimal one with-o1d -o2d, as hexadecimal one with-o1h -o2h, or an octal one with-o1o -o2o.
This way, the first few bytes in a file can be skipped, and just the rest can be compared. ๐
-rsearchlog โ when searching from the command line, the offsets are being read from this searchlog. Its format is being described indhex_searchlog(5). ๐-r1searchlog1-r2searchlog2 โ when searching in two files simultaneously, the offsets can be read from two different searchlogs. ๐-sa,-sab,-sh,-shbstring โ instead of setting the cursor offset to an absolute value, it is possible to search for a specific string from the command line. If there is an additional-ob -od -oh -oo offsetpresent, the search will start there. It is possible to read and write search logs with-r searchlogand-w searchlogrespectively. With-sa stringis being interpreted as ASCII.-sh stringinterprets it as hex. For backwards search,-sab stringor-shb stringcan be applied. ๐ง-s1a,-s1ab,-s1h,-s1hbstring1-s2a,-s2ab,-s2h,-s2hbstring2 โ in the diff mode, it is possible to search for two strings in two files simultaneously. ๐-vโ prints out the version ofdhex. โญ-wsearchlog โ when searching from the command line, write the results into this searchlog and quit. It is being written in the format described indhex_searchlog(5.). ๐-w1searchlog1-w2searchlog2 โ when searching in two files simultaneously, write the results from both searches into those log files. ๐ธ
๐ USER INTERFACE ๐
๐ General ๐
- Menus have hotkeys, and those show up in a different color. To jump from one menu item to the next, use the cursor keys or the TAB key.
- Input fields can be closed by pressing ESC, ENTER, or any cursor key. But only pressing ESC will not save the changes made in there.
โจ๏ธ The keyboard setup โจ๏ธ
When you run dhex for the first time, when there's no configfile present, or when you pass the -k parameter, the first screen you see is the keyboard setup screen. In this screen, the program asks you to press certain keys. Which are, in order: ESCAPE, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, BACKSPACE, DEL, ENTER, TAB, UP, DOWN, RIGHT, LEFT, PG UP, PG DOWN, HOME, END. It also tells you what it intends to do with those keys later, so you can decide on any alternative you choose. If you do not want to bind a specific function to a certain key, you can simply press ESCAPE and skip to the next question.
After pressing all the keys, you can choose whether or not to write those keys into the config file.
๐ The main screen ๐
The main screen is broken down into three columns: the first column contains the offset within the file for the current line. The second column contains the bytes in the file in hex format. Finally, the third column contains the same bytes, but this time in ascii format. If a byte is not printable, it is being substituted with a '.'. How many bytes are shown in a line depends on the width of the terminal. For example, if the terminal is 80 characters wide, 16 bytes are being shown in each line.
If no other [-o] or [-a] parameter was given at start time, the cursor is being set to offset 0. It is also being shown in the hex column. Here, it can be moved with the cursor keys. When entering a hexadecimal number, the file is being edited. The file can be edited in the ascii column as well, simply by pressing the TAB key (or whichever key was substituted for it in the keyboard setup). Pressing TAB again will return the cursor to the hex column. Pressing F9 (or its substitute) will undo the last of the changes. Changes are being shown in a different color.
Editing is not possible in the diff mode. Here, pressing the cursor keys will move both files synchronously.
๐ The goto screen ๐
Pressing F1 (or its substitute) will open the Goto... screen. Here, it is possible to jump to a specific address directly, without needing to scroll there with the cursor keys. The address can be entered in the 'To' field, either absolute or relative (to leap over a specified amount of bytes). An absolute address is being chosen by pressing '=', and a relative one by pressing '+' or '-', for a positive or negative leap respectively. Regardless of the addressing mode, it has to be entered as a hexadecimal number.
It is also possible to set up to ten bookmarks in this screen: pressing '0'...'9' will select one of them. Moving the cursor to "Set" and pressing ENTER will alter one of those bookmarks. The "Diff:" fields are showing the difference between the actual cursor position and the bookmark.
Bookmarks can be stored and loaded โ for this there are the "Save Markers" and "Load Markers" items on the bottom. Upon selecting one of them, the user is being prompted for a filename. It is possible to load a marker file at start time by providing the [-m markerfile] parameter. dhex_markers(5) describes the format of the marker files.
๐ Searching ๐
Pressing F2 (or its substitute) will open the Search... screen. Here, a short string can be entered (either in hex or in ascii). If no logfiles are being selected, the cursor will jump to the next occurrence of this search string upon selection of "Go". It can be chosen if the search is supposed to be conducted forward or backwards.
To jump to the next occurrence, F3 (or its substitute) has to be pressed. To jump to the previous one, F4 has to be pressed. The search itself wraps at the edges of the file, meaning that when it reaches the end, it will start from the beginning and vice versa.
Searchlogs are an advanced way of searching: writing to the searchlog does not jump the cursor from one occurrence to the next. Instead, it will write the offsets of all of them into the logfile. Their format is described in dhex_searchlog(5).
Reading from this searchlog means that the search does not cover the whole file: only the addresses which have been provided in this file are being searched. Thus it is possible to search for specific changes โ like, for example, the number of lives stored in the save file of a game. dhex_searchlog(5) describes the format of the searchlog.
๐งฎ HexCal ๐งฎ
Pressing F5 (or its substitute) will open a small 64 bit calculator. This calculator is capable of not only performing arithmetic operations (+, -, *, /, modulo), but also logic ones (and, or, xor, shift). There are three columns to enter numbers as hexadecimals, decimals, or in binary format. Pressing 'x' will close this screen. Using the command line argument [-x] will start it from the commandline.
๐งฌ Correlation ๐งฌ
When dhex(1) is running in diff mode, pressing F6 (or its substitute) will open the dialog for file correlation. This will try to find the optimal offset between the two files. There are three algorithms available for finding this offset: searching for the best match (as many bytes as possible are the same), the longest match (as many consecutive bytes match as possible), or the minimum difference (as little differences between the bytes as possible).
Even though it seems like the same at first, looking for the minimum difference is in fact faster. This can be improved even more if the user sets an upper difference limit.
Upon selecting Go, the program will search for the optimal offset. This will take some time.
๐พ Saving and quitting ๐พ
Pressing F10 (or its substitute) will close dhex. In case there have been changes made to the file, a save dialog opens up. Here, it is possible to select whether or not to write the changes back into the file.
๐ FILES ๐
$HOME/.dhexrcโ the default location of the config file. If the$HOME-variable is not set, its location has to be provided manually.
๐ BUGS ๐
Report bugs to <dettus@dettus.net>. Make sure to include DHEX somewhere in the subject.
๐ AUTHOR ๐
Written by Thomas Dettbarn.
๐ SEE ALSO ๐
dhexrc(5), dhex_markers(5), dhex_searchlog(5)
This page is from Debian, dated Jan 19, 2019, for DHEX(1) โ mwah, bestie ๐๐
๐ฆ where this page comes from
- alpine 3.24: dhex-doc 0.69-r3 ยท GPL-2.0-or-later
- arch rolling: dhex 0.69-5 ยท GPL-2.0-only
- fedora 43: dhex 0.69-17.fc43 ยท GPL-2.0-or-later
- fedora 44: dhex 0.69-19.fc44 ยท GPL-2.0-or-later
- nixos 26.05: dhex 0.69
- nixpkgs unstable: dhex 0.69
- opensuse-leap 16.0: dhex 0.69-bp160.1.13 ยท GPL-2.0-or-later
- opensuse-leap 16.0: dhex 0.69-bp160.1.13 ยท GPL-2.0-or-later
- opensuse-leap 16.0: dhex 0.69-bp160.1.13 ยท GPL-2.0-or-later
- opensuse-leap 16.0: dhex 0.69-bp160.1.13 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms