Suggestion for HxD:User templates for data inspector

Wishlists for new functionality and features.
Post Reply
asmix
Posts: 10
Joined: 02 Dec 2008 02:40

Suggestion for HxD:User templates for data inspector

Post by asmix » 20 Jun 2017 08:30

It would be great if we have an ability to make user templates for different data, it will greatly simplify data interpretation.
Probably simple script language should be enough. E.g.

Code: Select all

Struct         32              ;Size of structure
Offset         128             ;Offset in current block (disk sector) or repetitive 
Magic          4D 41 47 49 43  ;Optional
Uint16         Some data
Uint32         Some other data
Color          #ff3333
String19       Some string
Bit16b         Some bits       ;Wide big-endian bit field
End
Also it would be nice to have an option to change Data inspector font and colors

But anyway, it's good to see the progress is moving
Great work Maël

akrutsinger
Posts: 3
Joined: 01 Jun 2016 20:03

Re: Suggestion for HxD:User templates for data inspector

Post by akrutsinger » 27 Jun 2017 18:39

Agreed! No need re-inventing a method though, take advantage of a format/structure that is already available -- http://kaitai.io/

Maël
Site Admin
Posts: 1137
Joined: 12 Mar 2005 14:15

Re: Suggestion for HxD:User templates for data inspector

Post by Maël » 28 Jun 2017 20:11

Thanks for this reference, it's nice to see new development in this area.
I like the language agnostic approach and the format seems to cater for many key concepts. It's also nice that it automatically creates parsers out of a specification.
Kaitai Struct seems to be a bit low level, though, probably to make it more machine readable.

Let's take their example for a GIF file format:

Code: Select all

meta:
  id: gif
  file-extension: gif
  endian: le
seq:
  - id: header
    type: header
  - id: logical_screen
    type: logical_screen
types:
  header:
    seq:
      - id: magic
        contents: 'GIF'
      - id: version
        size: 3
  logical_screen:
    seq:
      - id: image_width
        type: u2
      - id: image_height
        type: u2
      - id: flags
        type: u1
      - id: bg_color_index
        type: u1
      - id: pixel_aspect_ratio
        type: u1
In more common format specification languages, which are based on programming language datatype definitions, this would become something similar to this (when keeping the meta-info as is):

Code: Select all

meta:
  id: gif
  file-extension: gif
  endian: le
  
struct header
  ascii_char[3] magic = 'GIF'
  uint_8[3] version
  
struct logical_screen
  uint16_t image_width
  uint16_t image_height
  uint8_t flags
  uint8_t bg_color_index
  uint8_t pixel_aspect_ratio
I think it's easier to understand what the intent is, if it's written in ways similar to the one shown last. This is because datatypes are always explicit (magic and version are not in Kaitai Struct), and the visual structure of the text already suggests the structure of the file/file format.

If you want to express a hierarchy, you could do so as well, using indentation:

Code: Select all

struct header
  ascii_char[3] magic = 'GIF'
  uint_8[3] version
  
  struct logical_screen
    uint16_t image_width
    uint16_t image_height
    uint8_t flags
    uint8_t bg_color_index
    uint8_t pixel_aspect_ratio
Here you have a top-level structure header, that has a sub-structure logical_screen. (Katai Struct calls this type and sub-type.)

Alternatively, you could add a structure member named logical_screen with the structure type logical_screen_t like this:

Code: Select all

struct header
  ascii_char[3] magic = 'GIF'
  uint_8[3] version
  
  struct logical_screen_t logical_screen
    uint16_t image_width
    uint16_t image_height
    uint8_t flags
    uint8_t bg_color_index
    uint8_t pixel_aspect_ratio
There are many binary file specification formats, one of the most complete is this (while some of its syntax is a bit hard to parse "mentally"):
http://hmelnov.icc.ru/FlexT/index.eng.html

Its documentation is not complete and its main description in Russian. Some documentation can be found here:
http://hmelnov.icc.ru/FlexT/FLEXT_CSCC99.htm

But especially when you look through the format specifications, you see the breadths of concepts that are supported:
http://geos.icc.ru:8080/scripts/WWWBinV.dll/Cat
Link above seems to be dead, but this one seems to be the current link (15.9.2019):
http://hmelnov.icc.ru/geos/scripts/WWWBinV.dll/Cat

akrutsinger
Posts: 3
Joined: 01 Jun 2016 20:03

Re: Suggestion for HxD:User templates for data inspector

Post by akrutsinger » 17 Jul 2017 03:04

I agree that using explicit types makes the most sense and I personally prefer it to alleviate any potential ambiguity. Most of all I hope you are interested in adding this capability to HxD :D :D

DMan
Posts: 1
Joined: 28 Aug 2017 15:02

Re: Suggestion for HxD:User templates for data inspector

Post by DMan » 28 Aug 2017 15:05

Would love to see this feature too. For reference, the commercial "010 Editor" has this feature, which it calls "binary templates":

https://www.sweetscape.com/010editor/#templates

Example of a template:
https://gist.github.com/mattifestation/ ... 45ae02eccb

n8d06
Posts: 1
Joined: 22 Aug 2019 16:08

Re: Suggestion for HxD:User templates for data inspector

Post by n8d06 » 22 Aug 2019 16:11

I would also like to vote for this feature! Very helpful when looking at image files, or any "standard" files. Having a simple definition language would be very useful when reverse engineering files or when creating custom file types. Let me know if you need any help implementing this. HxD rocks!

Post Reply