Mahlet-Inc / hobbits

A multi-platform GUI for bit-based analysis, processing, and visualization
https://mahlet-inc.github.io
MIT License
660 stars 45 forks source link

Instance set by value does not appear in Kaitai Struct output #145

Closed jakecrowley closed 2 years ago

jakecrowley commented 2 years ago

In the Kaitai Struct plugin, if you have an instance set by a value, it fails to appear in the "Parsed" tab.

for example:

instances:
  test1:
    pos: 0
    size: 1
  test2:
    value: 0xff

should result in something like this (from kaitai struct visualizer): image

however, in Hobbits, it appears like this: image

hello-adam commented 2 years ago

thanks for the heads up, I will look into this.

hello-adam commented 2 years ago

I'm not sure how to get the appropriate information about test2 from the information that Kaitai provides. It isn't in the _debug dictionary, so I guess I would need to analyze the core object and determine its position from there? I'm open to ideas from anyone more familiar with kaitai.

I noticed that the produced byte length is inaccurate in the example you gave, and I fixed that in fdc2b10c373a66c110488026e3b130ee47e5d65e

jakecrowley commented 2 years ago

Instances set by value aren't going to be in the _debug dict, since they don't have a start or end because they are set directly, not in the stream. You could fix this by looping over all attributes of the object and not just the attributes in _debug.

I wrote an example implementation of this method - jakecrowley/hobbits@1c49116 image

hello-adam commented 2 years ago

ok, cool, I might just steal that because I don't have a better idea. Feel free to do pull request into develop if you think it's a reasonable solution - as you have seen, the whole script is pretty hacky.

jakecrowley commented 2 years ago

It hasn't been tested very extensively, but it seems to work in my short testing. I've gone ahead and created a PR if you are okay with merging.