Live data from Hacker News

Visualizing binary files with ImHex's DSL, the "pattern language"

xy2i.blogspot.com

11–17 of 17 posts

Re: Visualizing binary files with ImHex's DSL, the "pattern language"

#11
post #9

Wow, I've never thought of it, but "syntax"-highlighting for binary files would be awesome.. e.g. "these bytes indicate the beginning of the next frame" (when talking about MP3/video files), maybe with mouseover support where it says e.g. "this value at this location indicates it's a $FOO variant of the file". Anyone know of such a tool?

I deal with a lot of cryptographic documents (e.g. public keys) and https://lapo.it/asn1js/ is a godsend for making sense of them. You just paste in hex or pem, and it shows the full deconstructed format along with two-way 'syntax highlighting' where if you hover over part of the deconstruction it highlights the equivalent part of the binary data. Hit the 'load' button for a representative example.

Re: Visualizing binary files with ImHex's DSL, the "pattern language"

#12
post #9

Wow, I've never thought of it, but "syntax"-highlighting for binary files would be awesome.. e.g. "these bytes indicate the beginning of the next frame" (when talking about MP3/video files), maybe with mouseover support where it says e.g. "this value at this location indicates it's a $FOO variant of the file". Anyone know of such a tool?

Kaitai Struct has an online demo which basically does this; https://ide.kaitai.io/

Re: Visualizing binary files with ImHex's DSL, the "pattern language"

#14
Whoa, a flashback! Many, many years ago I worked on online presentation software that dynamically assembled Flash clips from clip-arts / user-provided graphics and text. There was a lot of parsing and reassembling of SWF involved. There used to be Swfmill library, but it didn't have enough stuff in it to deal with animations / transformations. Sigh that was a fun project.

My approach at the time was to have Org-mode tables detailing the meaning and composition of chunks of binary data. That wasn't nearly as comfortable as this editor seems to be, but I was told that it looked very impressive to people looking over my shoulder. Just like in those "hackers movies" where the screen is filled with gibberish sequences of digits and other random characters :)

Re: Visualizing binary files with ImHex's DSL, the "pattern language"

#16
post #10
post #9

Wow, I've never thought of it, but "syntax"-highlighting for binary files would be awesome.. e.g. "these bytes indicate the beginning of the next frame" (when talking about MP3/video files), maybe with mouseover support where it says e.g. "this value at this location indicates it's a $FOO variant of the file". Anyone know of such a tool?

010 editor has something like this. Okteta too. They both use DSLs to represent formats

+1 for the 010 editor. It comes with a number of pre-built binary templates, I use the sqlite one all the time. A recent upgrade got syntax coding by the tree-sitter environment, which is a great upgrade. Highly recommended.https://www.sweetscape.com/010editor/

Re: Visualizing binary files with ImHex's DSL, the "pattern language"

#17
post #3

Great write up! I looked at ImHex a good while back and I think I had some runtime issues or maybe even compilation issues and didn't dig deeper. Even though the definition language piqued my curiosity. These days I tend to just use xxd, bless, ghex, or seldom wxHexEditor, depending on what I need. But ImHex looks really powerful, like it could replace all the GUI ones. I'm looking forward to giving it another go tom…

I got to try it a while back and same problem, it uses very recent versions of C++ which my distro didn't support. I finally got the AppImage, but I had a few breaking bugs, making it too unreliable for actual work. But I also noticed that the project is quite active, so maybe most of the issues are fixed now. Maybe I should give it a try.

For now, my hex editor of choice is 010editor. Not free software, but the best for my application. Like ImHex, it supports huge files and block devices, and it has a powerful definition language.

Post reply on HN