Go to file
gutmet 69114e6782 make sure set bytes are not longer than byte field
* also little formatting issues
2020-04-27 17:58:34 +02:00
laymanshex.go make sure set bytes are not longer than byte field 2020-04-27 17:58:34 +02:00
LICENSE Initial commit 2020-04-26 22:57:19 +02:00
README link to laymanshex-files 2020-04-27 15:29:48 +02:00

LaymansHex
==========

LaymansHex takes a (partial) file description and allows tinkering with
the values in a binary file. It thus serves as a sort of layman's
hex editor.


File description format
-----------------------

In EBNF:
```
description =
  { comment }
  endianness
  definition
  { definition }
.

comment = '#' { LETTER | DIGIT } '\n'.

endianness = ("little endian" | "big endian") '\n'.

definition = name ':' type '\n'.

name = { LETTER | DIGIT }.

type = ( "byte[" INTEGER "]" )
  | int8    | int16  | int32  | int64
  | uint8   | uint16 | uint32 | uint64
  | float32 | float64  
```

The name of a definition line can be left empty to ignore that particular value.
Portions of the binary file not covered be the file description are ignored.


Usage
-----

To get values: laymanshex FORMATFILE BINARY

To set values: laymanshex -set "key1=value1,key2=value2" FORMATFILE BINARY

Examples of format descriptions can be found in the [laymanshex-files repo](/laymanshex-files/).

TODO
----

There is no way to express offset values inside a file yet. Since this is
relatively common, I will add it at some point. Also: Repeated data limited by
marker or size field.