Recently I have found an interesting project called Kaitai, they are collaborating with construct developers to enable import of python struct code to their format, but it's not available yet.
I have been trying to port it myself, so the formats would not be tied to python, but I have run into some issues trying to understand the format.
not_packed_stream = Struct(
"data_start_offset" / Tell,
"filename_table_offset" / Int32ul,
"files_count" / Int32ul,
Seek(8, 1),
"filedata_table_offset" / Int32ul,
"filename_table" / filename_table,
"file_data_table" / file_data_table,
)
Here is what the file looks like:

I have to read the values after the file has been parsed and discovered that :
data_start_offset is equal to 0
filename_table_offset is equal to 32
files_count is equal to 23
filedata_table_offsed is equal to 672
I don't understand why Tell is returning 0 in this case, since the pointer would have moved, after reading the header.
I also don't understand where the 32 is coming from.
I'm assuming the 00 00 00 is the tail from zstd_stream, then there is 17 00 which translated to 23, but I would expect a 4 byte integer, not just 2 bytes
After this 23, there is a0 02 it translates to 672, which also fits the number I need, but it's 2 bytes wide again.
It also contradicts the Seek(8,1) line
I have tried searching entire file for a a 32 bit, unsigned, little-endian integer equal to 672 and found nothing.
The section after after_obfs does not seem to contain any of those numbers.

I have also tried to look for a "visualizer" for python's construct, to better understand the relation between the structure description and file contents location, but was unable to find any.
Could you please explain at least some of those issues?
I would really appreciate it.
I could translate this to Russian if it's necessary.
Recently I have found an interesting project called Kaitai, they are collaborating with construct developers to enable import of python struct code to their format, but it's not available yet.
I have been trying to port it myself, so the formats would not be tied to python, but I have run into some issues trying to understand the format.
Here is what the file looks like:

I have to read the values after the file has been parsed and discovered that :
data_start_offsetis equal to0filename_table_offsetis equal to32files_countis equal to23filedata_table_offsedis equal to672I don't understand why Tell is returning 0 in this case, since the pointer would have moved, after reading the header.
I also don't understand where the 32 is coming from.
I'm assuming the
00 00 00is the tail fromzstd_stream, then there is17 00which translated to23, but I would expect a 4 byte integer, not just 2 bytesAfter this 23, there is
a0 02it translates to672, which also fits the number I need, but it's 2 bytes wide again.It also contradicts the
Seek(8,1)lineI have tried searching entire file for a a 32 bit, unsigned, little-endian integer equal to 672 and found nothing.
The section after

after_obfsdoes not seem to contain any of those numbers.I have also tried to look for a "visualizer" for python's construct, to better understand the relation between the structure description and file contents location, but was unable to find any.
Could you please explain at least some of those issues?
I would really appreciate it.
I could translate this to Russian if it's necessary.