Ejemplo n.º 1
0
 def createFields(self):
     yield Bytes(self, "sync", 3)
     yield textHandler(UInt8(self, "tag"), hexadecimal)
     if self.parser:
         if self.parser != PackHeader:
             yield UInt16(self, "length")
             if not self["length"].value:
                 return
         yield self.parser(self, "content")
Ejemplo n.º 2
0
def avInfoHeader(s):
    yield filesizeHandler(UInt16(s, "total_size", "Total block size"))
    yield UInt8(s,
                "version",
                "Version needed to decompress",
                handler=hexadecimal)
    yield UInt8(s, "method", "Compression method", handler=hexadecimal)
    yield UInt8(s, "av_version", "Version for AV", handler=hexadecimal)
    yield UInt32(s, "av_crc", "AV info CRC32", handler=hexadecimal)
Ejemplo n.º 3
0
 def createFields(self):
     yield UInt16(self, "length", "Length in widechar characters")
     size = self["length"].value
     if size:
         yield String(self,
                      "text",
                      size * 2,
                      charset=self.charset,
                      strip=self.strip)
Ejemplo n.º 4
0
def parseStartSound(parent, size):
    yield UInt16(parent, "sound_id")
    yield Bit(parent, "has_in_point")
    yield Bit(parent, "has_out_point")
    yield Bit(parent, "has_loops")
    yield Bit(parent, "has_envelope")
    yield Bit(parent, "no_multiple")
    yield Bit(parent, "stop_playback")
    yield NullBits(parent, "reserved", 2)

    if parent["has_in_point"].value:
        yield UInt32(parent, "in_point")
    if parent["has_out_point"].value:
        yield UInt32(parent, "out_point")
    if parent["has_loops"].value:
        yield UInt16(parent, "loop_count")
    if parent["has_envelope"].value:
        yield SoundEnvelope(parent, "envelope")
Ejemplo n.º 5
0
 def createFields(self):
     yield Bytes(self, "filetype", 4, "File type (MOBJ)")
     yield Bytes(self, "fileversion", 4, "File version (0?00)")
     yield RawBytes(self, "unknown[]", 32)
     yield UInt32(self, "size")
     yield UInt32(self, "unknown[]")
     yield UInt16(self, "count")
     yield textHandler(UInt32(self, "unknown_id"), hexadecimal)
     for i in xrange(1, self['count'].value):
         yield AVCHDMOBJ_Chunk(self, "movie_object[]")
Ejemplo n.º 6
0
    def createFields(self):
        yield UInt8(self, "version", "Version")
        yield NullBits(self, "flags", 24)
        yield UInt32(self, "track_id")
        yield NullBits(self, "reserved", 26)
        yield Bits(self, "length_size_of_traf_num", 2)
        yield Bits(self, "length_size_of_trun_num", 2)
        yield Bits(self, "length_size_of_sample_num", 2)
        yield UInt32(self, "number_of_entry")
        for i in xrange(self['number_of_entry'].value):
            if self['version'].value == 1:
                yield UInt64(self, "time[%i]" % i)
                yield UInt64(self, "moof_offset[%i]" % i)
            else:
                yield UInt32(self, "time[%i]" % i)
                yield UInt32(self, "moof_offset[%i]" % i)

            if self['length_size_of_traf_num'].value == 3:
                yield UInt64(self, "traf_number[%i]" % i)
            elif self['length_size_of_traf_num'].value == 2:
                yield UInt32(self, "traf_number[%i]" % i)
            elif self['length_size_of_traf_num'].value == 1:
                yield UInt16(self, "traf_number[%i]" % i)
            else:
                yield UInt8(self, "traf_number[%i]" % i)

            if self['length_size_of_trun_num'].value == 3:
                yield UInt64(self, "trun_number[%i]" % i)
            elif self['length_size_of_trun_num'].value == 2:
                yield UInt32(self, "trun_number[%i]" % i)
            elif self['length_size_of_trun_num'].value == 1:
                yield UInt16(self, "trun_number[%i]" % i)
            else:
                yield UInt8(self, "trun_number[%i]" % i)

            if self['length_size_of_sample_num'].value == 3:
                yield UInt64(self, "sample_number[%i]" % i)
            elif self['length_size_of_sample_num'].value == 2:
                yield UInt32(self, "sample_number[%i]" % i)
            elif self['length_size_of_sample_num'].value == 1:
                yield UInt16(self, "sample_number[%i]" % i)
            else:
                yield UInt8(self, "sample_number[%i]" % i)
Ejemplo n.º 7
0
def parseDeclareFunctionV7(parent, size):
    yield CString(parent, "name")
    argCount = UInt16(parent, "arg_count")
    yield argCount
    yield UInt8(parent, "reg_count")
    yield Bits(parent, "reserved", 7)
    yield Bit(parent, "preload_global")
    yield Bit(parent, "preload_parent")
    yield Bit(parent, "preload_root")
    yield Bit(parent, "suppress_super")
    yield Bit(parent, "preload_super")
    yield Bit(parent, "suppress_arguments")
    yield Bit(parent, "preload_arguments")
    yield Bit(parent, "suppress_this")
    yield Bit(parent, "preload_this")
    for i in range(argCount.value):
        yield UInt8(parent, "register[]")
        yield CString(parent, "arg[]")
    yield UInt16(parent, "function_length")
Ejemplo n.º 8
0
 def createFields(self):
     yield PascalString16(self,
                          "name",
                          "Name",
                          charset="UTF-16-LE",
                          strip="\0")
     yield Enum(UInt16(self, "type"), self.TYPE_NAME)
     yield UInt16(self, "value_length")
     type = self["type"].value
     size = self["value_length"].value
     name = "value"
     if type == 0 and (size % 2) == 0:
         yield String(self, name, size, charset="UTF-16-LE", strip="\0")
     elif type in (2, 3):
         yield UInt32(self, name)
     elif type == 4:
         yield UInt64(self, name)
     else:
         yield RawBytes(self, name, size)
Ejemplo n.º 9
0
 def createFields(self):
     yield UInt32(self, "size")
     yield UInt32(self, "index")
     yield Bits(self, "flags", 8)
     yield RawBytes(self, "unknown[]", 5)
     yield UInt16(self, "unknown[]")
     yield CString(self, "name", charset="UTF-16-LE")
     if self.current_size // 8 != self['size'].value:
         yield RawBytes(self, "padding",
                        self['size'].value - self.current_size // 8)
Ejemplo n.º 10
0
 def createFields(self):
     yield FixedFloat32(self, "horiz_res")
     yield Enum(UInt16(self, "horiz_res_unit"), {1: 'px/in', 2: 'px/cm'})
     yield Enum(UInt16(self, "width_unit"), {
         1: 'inches',
         2: 'cm',
         3: 'points',
         4: 'picas',
         5: 'columns'
     })
     yield FixedFloat32(self, "vert_res")
     yield Enum(UInt16(self, "vert_res_unit"), {1: 'px/in', 2: 'px/cm'})
     yield Enum(UInt16(self, "height_unit"), {
         1: 'inches',
         2: 'cm',
         3: 'points',
         4: 'picas',
         5: 'columns'
     })
Ejemplo n.º 11
0
 def createFields(self):
     for index in range(5):
         yield UInt16(self, "size[]")
     for name, size in zip(self.names, self.array("size")):
         if size.value:
             yield String(self,
                          name,
                          size.value,
                          charset="UTF-16-LE",
                          strip=" \0")
Ejemplo n.º 12
0
    def createFields(self):
        yield UInt16(self, "size", "Node size (in bytes)")
        yield UInt16(self, "data_size")
        yield CString(self, "name", charset="ISO-8859-1")

        size = paddingSize(self.current_size // 8, 4)
        if size:
            yield NullBytes(self, "padding[]", size)
        size = self["data_size"].value
        if size:
            if self["name"].value == "VS_VERSION_INFO":
                yield VersionInfoBinary(self, "value", size=size * 8)
            else:
                yield String(self, "value", size, charset="ISO-8859-1")
        while 12 <= (self.size - self.current_size) // 8:
            yield NE_VersionInfoNode(self, "node[]")
        size = (self.size - self.current_size) // 8
        if size:
            yield NullBytes(self, "padding[]", size)
Ejemplo n.º 13
0
 def createFields(self):
     yield UInt16(self, "signature",
                  "PE optional header signature (0x010b)")
     # TODO: Support PE32+ (signature=0x020b)
     if self["signature"].value != 0x010b:
         raise ParserError("Invalid PE optional header signature")
     yield UInt8(self, "maj_lnk_ver", "Major linker version")
     yield UInt8(self, "min_lnk_ver", "Minor linker version")
     yield filesizeHandler(UInt32(self, "size_code", "Size of code"))
     yield filesizeHandler(
         UInt32(self, "size_init_data", "Size of initialized data"))
     yield filesizeHandler(
         UInt32(self, "size_uninit_data", "Size of uninitialized data"))
     yield textHandler(
         UInt32(self, "entry_point",
                "Address (RVA) of the code entry point"), hexadecimal)
     yield textHandler(UInt32(self, "base_code", "Base (RVA) of code"),
                       hexadecimal)
     yield textHandler(UInt32(self, "base_data", "Base (RVA) of data"),
                       hexadecimal)
     yield textHandler(UInt32(self, "image_base", "Image base (RVA)"),
                       hexadecimal)
     yield filesizeHandler(UInt32(self, "sect_align", "Section alignment"))
     yield filesizeHandler(UInt32(self, "file_align", "File alignment"))
     yield UInt16(self, "maj_os_ver", "Major OS version")
     yield UInt16(self, "min_os_ver", "Minor OS version")
     yield UInt16(self, "maj_img_ver", "Major image version")
     yield UInt16(self, "min_img_ver", "Minor image version")
     yield UInt16(self, "maj_subsys_ver", "Major subsystem version")
     yield UInt16(self, "min_subsys_ver", "Minor subsystem version")
     yield NullBytes(self, "reserved", 4)
     yield filesizeHandler(UInt32(self, "size_img", "Size of image"))
     yield filesizeHandler(UInt32(self, "size_hdr", "Size of headers"))
     yield textHandler(UInt32(self, "checksum"), hexadecimal)
     yield Enum(UInt16(self, "subsystem"), self.SUBSYSTEM_NAME)
     yield UInt16(self, "dll_flags")
     yield filesizeHandler(UInt32(self, "size_stack_reserve"))
     yield filesizeHandler(UInt32(self, "size_stack_commit"))
     yield filesizeHandler(UInt32(self, "size_heap_reserve"))
     yield filesizeHandler(UInt32(self, "size_heap_commit"))
     yield UInt32(self, "loader_flags")
     yield UInt32(self, "nb_directory", "Number of RVA and sizes")
     for index in range(self["nb_directory"].value):
         try:
             name = self.DIRECTORY_NAME[index]
         except KeyError:
             name = "data_dir[%u]" % index
         yield DataDirectory(self, name)
Ejemplo n.º 14
0
    def createFields(self):
        LONG = Int32
        yield UInt32(self, "type", "Record type (always 1)")
        yield UInt32(self, "size", "Size of the header in bytes")
        yield RECT32(self, "Bounds", "Inclusive bounds")
        yield RECT32(self, "Frame", "Inclusive picture frame")
        yield textHandler(
            UInt32(self, "signature", "Signature ID (always 0x464D4520)"),
            hexadecimal)
        yield UInt16(self, "min_ver", "Minor version")
        yield UInt16(self, "maj_ver", "Major version")
        yield UInt32(self, "file_size", "Size of the file in bytes")
        yield UInt32(self, "NumOfRecords", "Number of records in the metafile")
        yield UInt16(self, "NumOfHandles",
                     "Number of handles in the handle table")
        yield NullBytes(self, "reserved", 2)
        yield UInt32(self, "desc_size", "Size of description in 16-bit words")
        yield UInt32(self, "desc_ofst",
                     "Offset of description string in metafile")
        yield UInt32(self, "nb_colors", "Number of color palette entries")
        yield LONG(self, "width_px", "Width of reference device in pixels")
        yield LONG(self, "height_px", "Height of reference device in pixels")
        yield LONG(self, "width_mm",
                   "Width of reference device in millimeters")
        yield LONG(self, "height_mm",
                   "Height of reference device in millimeters")

        # Read description (if any)
        offset = self["desc_ofst"].value
        current = (self.absolute_address + self.current_size) // 8
        size = self["desc_size"].value * 2
        if offset == current and size:
            yield String(self,
                         "description",
                         size,
                         charset="UTF-16-LE",
                         strip="\0 ")

        # Read padding (if any)
        size = self["size"].value - self.current_size // 8
        if size:
            yield RawBytes(self, "padding", size)
Ejemplo n.º 15
0
    def createFields(self):
        yield UInt32(self, "size")
        yield RawBytes(self, "format", 4, "Data Format (codec)")
        yield NullBytes(self, "reserved[]", 6, "Reserved")
        yield UInt16(self, "data_reference_index")
        handler = findHandler(self)
        if not handler:
            raise ParserError("stsd couldn't find track handler")
        if handler['subtype'].value == 'soun':
            # Audio sample entry
            yield NullBytes(self, "reserved[]", 8)
            yield UInt16(self, "channels", "Number of audio channels")
            yield UInt16(self, "samplesize", "Sample size in bits")
            yield UInt16(self, "unknown")
            yield NullBytes(self, "reserved[]", 2)
            yield QTFloat32(self, "samplerate", "Sample rate in Hz")
        elif handler['subtype'].value == 'vide':
            # Video sample entry
            yield UInt16(self, "version")
            yield UInt16(self, "revision_level")
            yield RawBytes(self, "vendor_id", 4)
            yield UInt32(self, "temporal_quality")
            yield UInt32(self, "spatial_quality")
            yield UInt16(self, "width", "Width (pixels)")
            yield UInt16(self, "height", "Height (pixels)")
            yield QTFloat32(self, "horizontal_resolution",
                            "Horizontal resolution in DPI")
            yield QTFloat32(self, "vertical resolution",
                            "Vertical resolution in DPI")
            yield UInt32(self, "data_size")
            yield UInt16(self, "frame_count")
            yield UInt8(self, "compressor_name_length")
            yield String(self, "compressor_name", 31, strip='\0')
            yield UInt16(self, "depth", "Bit depth of image")
            yield Int16(self, "unknown")
        elif handler['subtype'].value == 'hint':
            # Hint sample entry
            pass

        size = self['size'].value - self.current_size // 8
        if size > 0:
            yield RawBytes(self, "extra_data", size)
Ejemplo n.º 16
0
 def createFields(self):
     yield UInt16(self, "size")
     self._size = (self['size'].value + 2) * 8
     yield Bytes(self, "clip_id", 5)
     yield Bytes(self, "clip_type", 4)
     yield RawBytes(self, "unknown[]", 3)
     yield UInt32(self, "clip_start_time[]",
                  "clip start time (units unknown)")
     yield UInt32(self, "clip_end_time[]", "clip end time (units unknown)")
     yield RawBytes(self, "unknown[]", 10)
     yield AVCHDMPLS_PlayItem(self, "playitem")
Ejemplo n.º 17
0
    def createFields(self):
        # Type
        yield Enum(UInt8(self, "type"), self.type_desc)
        type = self["type"].value

        # Code
        field = UInt8(self, "code")
        if type == 3:
            field = Enum(field, self.reject_reason)
        yield field

        # Options
        yield textHandler(UInt16(self, "checksum"), hexadecimal)
        if type in (self.PING, self.PONG):  # and self["code"].value == 0:
            yield UInt16(self, "id")
            yield UInt16(self, "seq_num")
            # follow: ping data
        elif type == self.REJECT:
            yield NullBytes(self, "empty", 2)
            yield UInt16(self, "hop_mtu", "Next-Hop MTU")
Ejemplo n.º 18
0
 def createFields(self):
     yield textHandler(Int32(self, "ns"), stringIndex)
     yield textHandler(Int32(self, "name"), stringIndex)
     yield textHandler(Int32(self, "value_string"), stringIndex)
     yield UInt16(self, "unk[]")
     yield UInt8(self, "unk[]")
     yield Enum(UInt8(self, "value_type"), self.TYPE_NAME)
     func = self.TYPE_FUNC.get(self['value_type'].value, None)
     if not func:
         func = UInt32
     yield func(self, "value_data")
Ejemplo n.º 19
0
 def createFields(self):
     yield String(self, "jfif", 5, "JFIF string", charset="ASCII")
     if self["jfif"].value != "JFIF\0":
         raise ParserError(
             "Stream doesn't look like JPEG chunk (wrong JFIF signature)")
     yield UInt8(self, "ver_maj", "Major version")
     yield UInt8(self, "ver_min", "Minor version")
     yield Enum(UInt8(self, "units", "Units"), self.UNIT_NAME)
     if self["units"].value == 0:
         yield UInt16(self, "aspect_x", "Aspect ratio (X)")
         yield UInt16(self, "aspect_y", "Aspect ratio (Y)")
     else:
         yield UInt16(self, "x_density", "X density")
         yield UInt16(self, "y_density", "Y density")
     yield UInt8(self, "thumb_w", "Thumbnail width")
     yield UInt8(self, "thumb_h", "Thumbnail height")
     thumb_size = self["thumb_w"].value * self["thumb_h"].value
     if thumb_size != 0:
         yield PaletteRGB(self, "thumb_palette", 256)
         yield RawBytes(self, "thumb_data", thumb_size, "Thumbnail data")
Ejemplo n.º 20
0
 def createFields(self):
     if False:
         yield UInt32(self, "width0")
         yield UInt32(self, "height0")
         yield PaddingBytes(self, "reserved[]", 7)
         yield UInt32(self, "width")
         yield UInt32(self, "height")
         yield PaddingBytes(self, "reserved[]", 2)
         yield UInt16(self, "depth")
         yield Enum(String(self, "codec", 4, charset="ASCII"),
                    video_fourcc_name)
         yield NullBytes(self, "padding", 20)
     else:
         yield UInt32(self, "width")
         yield UInt32(self, "height")
         yield PaddingBytes(self, "reserved[]", 1)
         yield UInt16(self, "format_data_size")
         if self["format_data_size"].value < 40:
             raise ParserError("Unknown format data size")
         yield BitmapInfoHeader(self, "bmp_info", use_fourcc=True)
Ejemplo n.º 21
0
    def createFields(self):
        yield String(self, "tag", 4, "Chunk FourCC", charset="ASCII")
        yield UInt32(self, "size", "Chunk Size")
        yield UInt16(self, "version", "Chunk Version")

        if self.parse_func:
            yield from self.parse_func(self)
        else:
            size = (self.size - self.current_size) // 8
            if size:
                yield RawBytes(self, "raw", size)
Ejemplo n.º 22
0
 def createFields(self):
     yield UInt32(self, "size")
     yield textHandler(
         UInt32(
             self, "magic",
             "0xe391c05f for normal PPT, 0xf3d1c4df for encrypted PPT"),
         hexadecimal)
     yield UInt32(self, "offsetToCurrentEdit",
                  "Offset in main stream to current edit field")
     yield UInt16(self, "lenUserName", "Length of user name")
     yield UInt16(self, "docFileVersion", "1012 for PP97+")
     yield UInt8(self, "majorVersion", "3 for PP97+")
     yield UInt8(self, "minorVersion", "0 for PP97+")
     yield UInt16(self, "unknown")
     yield String(self, "userName", self["lenUserName"].value,
                  "ANSI version of the username")
     yield UInt32(
         self, "relVersion",
         "Release version: 8 for regular PPT file, 9 for multiple-master PPT file"
     )
Ejemplo n.º 23
0
    def createFields(self):
        yield ZipVersion(self, "version_made_by", "Version made by")
        yield from ZipStartCommonFields(self)

        # Check unicode status
        charset = zipGetCharset(self)

        yield UInt16(self, "comment_length", "Comment length")
        yield UInt16(self, "disk_number_start", "Disk number start")
        yield UInt16(self, "internal_attr", "Internal file attributes")
        yield UInt32(self, "external_attr", "External file attributes")
        yield UInt32(self, "offset_header", "Relative offset of local header")
        yield String(self, "filename", self["filename_length"].value,
                     "Filename", charset=charset)
        if 0 < self["extra_length"].value:
            yield ExtraFields(self, "extra", size=self["extra_length"].value * 8,
                              description="Extra fields")
        if 0 < self["comment_length"].value:
            yield String(self, "comment", self["comment_length"].value,
                         "Comment", charset=charset)
Ejemplo n.º 24
0
    def createFields(self):
        # Header
        yield UInt24(self, "size")
        yield Enum(UInt8(self, "type"), EFI_SECTION_TYPE)
        section_type = self["type"].value

        if section_type == EFI_SECTION_COMPRESSION:
            yield UInt32(self, "uncomp_len")
            yield Enum(UInt8(self, "comp_type"), self.COMPRESSION_TYPE)
        elif section_type == EFI_SECTION_FREEFORM_SUBTYPE_GUID:
            yield GUID(self, "sub_type_guid")
        elif section_type == EFI_SECTION_GUID_DEFINED:
            yield GUID(self, "section_definition_guid")
            yield UInt16(self, "data_offset")
            yield UInt16(self, "attributes")
        elif section_type == EFI_SECTION_USER_INTERFACE:
            yield CString(self, "file_name", charset="UTF-16-LE")
        elif section_type == EFI_SECTION_VERSION:
            yield UInt16(self, "build_number")
            yield CString(self, "version", charset="UTF-16-LE")

        # Content
        content_size = (self.size - self.current_size) // 8
        if content_size == 0:
            return

        if section_type == EFI_SECTION_COMPRESSION:
            compression_type = self["comp_type"].value
            if compression_type == 1:
                while not self.eof:
                    yield RawBytes(self, "compressed_content", content_size)
            else:
                while not self.eof:
                    yield FileSection(self, "section[]")
        elif section_type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
            yield FirmwareVolume(self, "firmware_volume")
        else:
            yield RawBytes(
                self, "content", content_size,
                EFI_SECTION_TYPE.get(self["type"].value,
                                     "Unknown Section Type"))
Ejemplo n.º 25
0
    def createFields(self):
        # Header
        yield GUID(self, "name")
        yield UInt16(self, "integrity_check")
        yield Enum(UInt8(self, "type"), EFI_FV_FILETYPE)
        yield UInt8(self, "attributes")
        yield UInt24(self, "size")
        yield UInt8(self, "state")

        # Content
        while not self.eof:
            yield FileSection(self, "section[]")
Ejemplo n.º 26
0
    def createFields(self):
        yield textHandler(UInt16(self, "crc16", "Block CRC16"), hexadecimal)
        yield textHandler(UInt8(self, "block_type", "Block type"), hexadecimal)

        # Parse flags
        yield from self.parseFlags()

        # Get block size
        yield filesizeHandler(UInt16(self, "block_size", "Block size"))

        # Parse remaining header
        yield from self.parseHeader()

        # Finish header with stuff of unknow size
        size = self["block_size"].value - (self.current_size // 8)
        if size > 0:
            yield RawBytes(self, "unknown", size,
                           "Unknow data (UInt32 probably)")

        # Parse body
        yield from self.parseBody()
Ejemplo n.º 27
0
 def createFields(self):
     yield textHandler(
         UInt16(self, "time_flags", "Flags for extended time"), hexadecimal)
     flags = self["time_flags"].value
     for index in range(4):
         rmode = flags >> ((3 - index) * 4)
         if rmode & 8:
             if index:
                 yield TimeDateMSDOS32(self, "dos_time[]", "DOS Time")
             if rmode & 3:
                 yield RawBytes(self, "remainder[]", rmode & 3,
                                "Time remainder")
Ejemplo n.º 28
0
 def createFields(self):
     yield GUID(self, "clsid", "16 bytes GUID used by some apps")
     yield UInt16(self, "ver_min", "Minor version")
     yield UInt16(self, "ver_maj", "Major version")
     yield Bytes(self, "endian", 2, "Endian (\\xfe\\xff for little endian)")
     yield UInt16(self, "bb_shift", "Log, base 2, of the big block size")
     yield UInt16(self, "sb_shift", "Log, base 2, of the small block size")
     yield NullBytes(self, "reserved[]", 6, "(reserved)")
     yield UInt32(
         self, "csectdir",
         "Number of SECTs in directory chain for 4 KB sectors (version 4)")
     yield UInt32(self, "bb_count", "Number of Big Block Depot blocks")
     yield SECT(self, "bb_start", "Root start block")
     yield NullBytes(self, "transaction", 4,
                     "Signature used for transactions (must be zero)")
     yield UInt32(self, "threshold",
                  "Maximum size for a mini stream (typically 4096 bytes)")
     yield SECT(self, "sb_start", "Small Block Depot start block")
     yield UInt32(self, "sb_count")
     yield SECT(self, "db_start", "First block of DIFAT")
     yield UInt32(self, "db_count", "Number of SECTs in DIFAT")
Ejemplo n.º 29
0
    def createFields(self):
        yield textHandler(
            UInt16(self, "crc16", "Archive CRC16 (from byte 4 on)"),
            hexadecimal)
        yield filesizeHandler(
            UInt16(self, "head_size", "Block size (from byte 4 on)"))
        yield UInt8(self, "block_type", "Block type")

        # Flags
        yield from self.parseFlags(self)

        # Rest of the header
        yield from self.parseHeader(self)

        size = self["head_size"].value - (self.current_size // 8) + (2 + 2)
        if size > 0:
            yield RawBytes(self, "extra_data", size,
                           "Extra header data, unhandled")

        # Body in itself
        yield from self.parseBody(self)
Ejemplo n.º 30
0
 def createFields(self):
     yield UInt32(self, "offset", "Offset to data (from file start)")
     yield UInt16(self, "data_blocks", "Number of data blocks which are in this cabinet")
     yield Enum(Bits(self, "compr_method", 4, "Compression method"), COMPRESSION_NAME)
     if self["compr_method"].value in [2, 3]:  # Quantum or LZX use compression level
         yield PaddingBits(self, "padding[]", 4)
         yield Bits(self, "compr_level", 5, "Compression level")
         yield PaddingBits(self, "padding[]", 3)
     else:
         yield PaddingBits(self, "padding[]", 12)
     if self["../flags/has_reserved"].value and self["../reserved_folder_size"].value:
         yield RawBytes(self, "reserved_folder", self["../reserved_folder_size"].value, "Per-folder reserved area")