I cannot find the length of the previous block, nor the offset of the beginning of this "block" from the beginning of the raw data section. Anyone got a clue here?
Modifié par Tierrie, 24 décembre 2009 - 02:22 .
Modifié par Tierrie, 24 décembre 2009 - 02:22 .
For the top-most "struct" i.e. the one which is placed first in the Struct Array part of the file the offset of data in the Raw Data block is going to be 0. So to read the data for a field in this 'primary' struct you'll use offset of (0 + value of "index" part of the field description) into the Raw Data block.Tierrie wrote...
I cannot find the length of the previous block, nor the offset of the beginning of this "block" from the beginning of the raw data section. Anyone got a clue here?
Modifié par tmp7704, 24 décembre 2009 - 07:25 .
Modifié par Tierrie, 24 décembre 2009 - 10:03 .
def parseString( filehandle, header, field, position ):
# Make sure we are at the correct position
filehandle.seek( position + field["INDEX"], os.SEEK_SET)
# Determine the position of the list
reference = struct.unpack("I", filehandle.read(4))
# Confirm the list isn't empty
if reference == 0xFFFFFFFF:
return
# Advance to the position of the list
filehandle.seek( reference + header["RAW_DATA_OFFSET"], os.SEEK_SET)
# Extract the size of the list
size = struct.unpack("I", filehandle.read(4))
# Get the string
result = []
for i in range(0, size):
result.append( struct.unpack("2c", filehandle.read(2)) )
return result
Modifié par Werefox009, 24 décembre 2009 - 10:20 .
If it's specifically for ECStrings then from what i experienced you can just treat value specified by field as a reference i.e. straight offset from beginning of Raw Data block to the point where the string data begins (length of string followed by series of wide chars)Tierrie wrote...
My situation is specifically ECStrings. The FieldIndex is 0, 4, 8, 16, 44, and so forth. And since its ECStrings, the value in at these locations are pointers to a List of wide chars.
However, in the Fields, I cannot find the offset of the "child structures" from the beginning of the raw data block.
Modifié par tmp7704, 24 décembre 2009 - 10:43 .
tmp7704 wrote...
If it's specifically for ECStrings then from what i experienced you can just treat value specified by field as a reference i.e. straight offset from beginning of Raw Data block to the point where the string data begins (length of string followed by series of wide chars)
Yes, this is correct for the fields which are part of the "child struct". Their index values are supposed to be added to the starting point of this "child struct" rather than the very beginning of the Raw Data block.Tierrie wrote...
The FieldIndex is an offset from the beginning of the "child struct". And the "child struct"s are some offset from the beginning of the Raw Data block.
Modifié par tmp7704, 25 décembre 2009 - 04:26 .
A field in this structure states it is a link to a list of structs of type "plot". The list has following data: length of the list, and then the offset for 1st "child struct" and then optionally for the 2nd one etc.
From what seems to work for me now (also with the *.plo files) is the following:Tierrie wrote...
Here's what happened when I checked the list - the first struct has flags "list" and "struct" and "index=3". So I go to the 3rd struct and recur. Where's the list that contains the length of the list and the offset of the 1st "child struct" etc?
Modifié par tmp7704, 25 décembre 2009 - 05:54 .
Tierrie wrote...
@tmp7704, @Werefox009, do either of you mind sharing your code? Particular the part that traverses the structures?
Modifié par Werefox009, 25 décembre 2009 - 07:33 .
Modifié par tmp7704, 25 décembre 2009 - 07:57 .
Modifié par tmp7704, 26 décembre 2009 - 02:38 .
Modifié par Werefox009, 26 décembre 2009 - 03:27 .
Modifié par Werefox009, 26 décembre 2009 - 03:32 .