Hexed is a command line Hexadecimal File Editor.

The source code is written to use an ANSI C99 compatible compiler for portability between Operating Systems.

Hexed is released under the BSD license

Latest Updates
May 6, 2014
hexed help screen now shows the version number.

May 6, 2014
Bugfix: #1 - Added bfcntl to set _fmode to _O_BINARY in MinGW as 'r+b' in fopen was

January 23, 2014
Modified the Makefile. It now has fewer options and should be a cleaner build process.

November 18, 2010

hexed – commands insert & remove

A small update with 2 new commands, insert and remove, having been added to hexed. Insert first moves any data at the end of the file then inserts the bytes from a buffer and removes deletes bytes from the buffer.

The Command List

Insert: -i

Inserts bytes in the file at the destination, repeating the bytes for a number of times.

-i 100 10 01 02 03

This will insert the bytes 0x01 0x02 0x03 at 0x100 16 times.

Remove: -r

Removes a number of bytes from the file starting at the source.

-r 10 100

Removes 0x100 bytes from the file at 0x10 to 0x110.

November 6, 2010

hexed – commands help, dump & enter

Command control has been added to hexed and the first 3 commands are help, dump and enter. Command control is handled by a Command struct and a Cmdoptions struct. Each command is set with an ID, flags and any options in the Cmdoptions area. Cmdoptions is general purpose and shares common names for values between all the commands. Any extra data is stored in a buffer before being copied to the file. Multiple commands can be set on the command line and these are performed in the order they are found.

hexed -d 0 100 -e 40 10 20 30 40 -d 0 100 test.hex

This will display the file test.hex, enter 4 values at 0x40, display the file again then save the file and quit.

The Command List

Help: -?

Help simply displays the command list and how to use each command:

hexed - Hexadecimal File Editor

  hexed [options] [file]

  -?                            Shows this help screen
  -d [src] [len]                Display hex values from [src] for [len] bytes
  -e [dest] [...]               Enter hex values [...] at [dest]

Dump: -d

The dump command displays a range of values and their ascii symbols:

-d 0 100

Displays values starting from 0x0 for 0x100 (256) bytes, all options to commands are set in hex values.

Enter: -e

Enter adds new values to a file, overwriting any values that were already at the address:

-e 100 10 20 30 40

Enters the values 0x10, 0x20, 0x30 and 0x40 starting at 0x100. If a file name is set then the values will be automatically saved to the file.

October 23, 2010

Buffered file access – Bfile

There may already be a method or library for handling files in memory but I wrote this to easily add and remove bytes without constantly reading or writing to a file. Bfile reads the whole file into memory before working on it by using the bfread, bfwrite, bfclip and bfinsert functions.

bfopen() opens a file and sets the initial values in the Bfile struct.
bfclose() flushes the buffer to the file and closes the file.
bfflush() flushes the buffer to the file.
bfread() reads the entire file into a Bfile buffer.
bfwrite() writes from memory to the Bfile buffer, but not to the file.
bfclip() removes data from the Bfile and adjusts the file size.
bfinsert() inserts data from memory into the Bfile and adjusts the file size.

Writing to the file needs to end with a bfflush and this is done automatically when the file is closed with bfclose.


Source: bfile.hbfile.c