Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jakecrowley opened this issue May 19, 2022 · 5 comments
Closed

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

jakecrowley opened this issue May 19, 2022 · 5 comments

Comments

@jakecrowley
Copy link

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
Copy link
Member

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

@hello-adam
Copy link
Member

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 fdc2b10

@jakecrowley
Copy link
Author

jakecrowley commented Jun 7, 2022

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
Copy link
Member

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
Copy link
Author

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.

hello-adam added a commit that referenced this issue Jun 8, 2022
fix KaitaiStruct value instances not appearing
hello-adam pushed a commit that referenced this issue Jun 8, 2022
## [0.53.2](v0.53.1...v0.53.2) (2022-06-08)

### Bug Fixes

* correctly display kaitai value instances for [#145](#145) ([556514b](556514b))
* fix kaitai plugin byte and string array sizes ([fdc2b10](fdc2b10))
goldest-star added a commit to goldest-star/binary-analysis-tool that referenced this issue Jun 4, 2023
## [0.53.2](Mahlet-Inc/hobbits@v0.53.1...v0.53.2) (2022-06-08)

### Bug Fixes

* correctly display kaitai value instances for [#145](Mahlet-Inc/hobbits#145) ([556514b](Mahlet-Inc/hobbits@556514b))
* fix kaitai plugin byte and string array sizes ([fdc2b10](Mahlet-Inc/hobbits@fdc2b10))
antoniovazquezblanco pushed a commit to antoniovazquezblanco/hobbits that referenced this issue Mar 25, 2024
## [0.53.2](Mahlet-Inc/hobbits@v0.53.1...v0.53.2) (2022-06-08)

### Bug Fixes

* correctly display kaitai value instances for [Mahlet-Inc#145](Mahlet-Inc#145) ([556514b](Mahlet-Inc@556514b))
* fix kaitai plugin byte and string array sizes ([fdc2b10](Mahlet-Inc@fdc2b10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants