Skip to content

Commit

Permalink
fix: show type for array, byte, and string in kaitai display
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-adam committed Aug 24, 2021
1 parent fb81d4d commit cc54677
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py
Expand Up @@ -22,11 +22,13 @@ def process_value(value, section):
else:
value = f"0x{binascii.hexlify(value).decode()}"
section['value'] = value
section['type'] = f"bytes[{len(value)}]"

elif isinstance(value, str):
if len(value) > 15:
value = f"{value[:12]}..."
section['value'] = value
section['type'] = f"str[{len(value)}]"

elif isinstance(value, float):
section['value'] = value
Expand Down Expand Up @@ -121,6 +123,7 @@ def parse_struct(struct, sections, prefix="", parent_offset = 0, base_io=None, b
idx_offset = struct._debug[name]['arr'][idx]['start'] + base_offset

if isinstance(value_item, KaitaiStruct):
section['type'] = f"{type(value_item).__name__}[{len(value)}]"
sections.append(idx_section)
parse_struct(value_item, sections, idx_label, idx_offset, base_io, base_offset)
else:
Expand All @@ -131,6 +134,7 @@ def parse_struct(struct, sections, prefix="", parent_offset = 0, base_io=None, b
"parent": idx_section["parent"],
}
if process_value(value_item, value_item_section):
section['type'] = f"{value_item_section.get('type', 'array')}[{len(value)}]"
sections.append(value_item_section)

elif process_value(value, section):
Expand Down

0 comments on commit cc54677

Please sign in to comment.