Skip to content

Commit ccd01f3

Browse files
committed
fix: track section offsets in kaitai parsing for #93
1 parent 4a567b0 commit ccd01f3

File tree

1 file changed

+6
-5
lines changed
  • src/hobbits-plugins/analyzers/KaitaiStruct/scripts

1 file changed

+6
-5
lines changed

src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from kaitaistruct import KaitaiStruct
99

10-
def dump_struct(s, sections, prefix=""):
10+
def dump_struct(s, sections, prefix="", offset=0):
1111
if isinstance(s, list):
1212
#print("list")
1313
for i, item in enumerate(s):
@@ -16,7 +16,7 @@ def dump_struct(s, sections, prefix=""):
1616
"label": label,
1717
"parent": prefix
1818
})
19-
dump_struct(item, sections, label)
19+
dump_struct(item, sections, label, offset)
2020
elif isinstance(s, KaitaiStruct):
2121
#print(vars(s))
2222
if hasattr(s, "_debug"):
@@ -28,13 +28,14 @@ def dump_struct(s, sections, prefix=""):
2828
# print(vars(prop))
2929
#print("")
3030
label = prefix + "." + name if prefix else name
31+
section_offset = descr["start"] + offset
3132
sections.append({
32-
"start": descr["start"],
33-
"end": descr["end"],
33+
"start": descr["start"] + offset,
34+
"end": descr["end"] + offset,
3435
"label": label,
3536
"parent": prefix
3637
})
37-
dump_struct(prop, sections, label)
38+
dump_struct(prop, sections, label, section_offset)
3839

3940
def parse_data(input_filename, output_filename, action_progress):
4041
# locate the compiled struct module

0 commit comments

Comments
 (0)