tibit.org – hacks

This section contains small hacks and tools which make my life easier. These programms are written because I had the need for them and did not find a usuable tool already available.

edhex – a mmap based, simple hex editor

edhex is a very simple line orientated, mmap(2) based hex file editor It is written in the spirit of ed; one letter commands and it can read commands from stdin. edhex does not include stdio.h so it can be statically linked (using dietlibc for example) to a very small executable size for use on rescue discs.

All other hex-based editors I looked at were either to bloated or unsuitable for my purposes. I needed a quick way to replace respectivly overwrite stuff in files at a certain position and this is where edhex is really good at.

This editor contains no safety net! There is no undo command, whenever you write something either with the 'w' or 'W' commands or via search and replace with 's' and 'S' it will be written immediatly to the file.

The following commands are supported (accessible via h in edhex)
pN print current(+N) lines
/S search ascii string S (cancel with ^C)
fD find hex data D (cancel with ^C)
F find next not 0 byte (cancel with ^C)
N find next 0 byte (cancel with ^C)
gN goto byte offset N (prefix N with + or - for relative seek)
!S execute S as shell command
wS write ascii string S at current position
WD write hex data D at position
mX save position as bookmark X (0-63)
'X restore position from bookmark X (0-63)
s/x/y/ replace all occurrences of x with y
S/x/y/ replace all HEX occurrences of x with y
r reset (same as g0)
i print status
n next line
h print this help
q quit the program
v print version banner
\n repeat last command

Notes: Do not seperate command and argument by whitespace, the commandline parser is way too stupid for that. A command and its argument can only be 255 chars long. Any s or S command must be terminated. When dealing with hex strings, the parser is quite good, these strings may contain as much whitepace as you like (easy for copy&paste).

Compile with:

gcc -Wall -Os -o edhex edhex.c

or

make CFLAGS="-Os -Wall -pedantic" LDFLAGS="-s" CC=gcc edhex

Example: Write HELLO at offset 0x260 in file filename

$ edhex filename <<EOT > g0x260 > wHELLO > q > EOT

Download edhex here (5kb)

edhex is (c) 2004-2005 Tilmann Bitterberg <transcode at tibit dot org>, Sat Mar 13 23:52:43 GMT 2004

xvid4conf – A configuration tool for xvid

A long, long time ago I wrote a configuration file generator for xvid for use in transcode. It is not necessarily linked to transcode and I recently found it to be include in nearly all linux distributions. I don't provide binaries but some kind soul probably already prepared a package for your favourite linux distribution. If you want to compile source, you can find it here: xvid4conf-1.12.tar.gz (131k)

xvid4conf is free software, you can use it and distribute it under the terms of the Gnu Public License v2. I do not actively maintain xvid4conf anymore for the sole reason I consider it finished. If you do have any patches, please feel free to contact me and I'll include them.