Ejemplo n.º 1
0
def fileHeader(self):
    yield filesizeHandler(
        UInt32(self, "compressed_size", "Size of the compressed file"))
    yield filesizeHandler(
        UInt32(self, "uncompressed_size", "Uncompressed file size"))
    yield TimeDateMSDOS32(self, "ftime", "Date and time (MS DOS format)")
    if self["/header/host_os"].value in (OS_MSDOS, OS_WIN32):
        yield MSDOSFileAttr32(self, "file_attr", "File attributes")
    else:
        yield textHandler(UInt32(self, "file_attr", "File attributes"),
                          hexadecimal)
    yield textHandler(
        UInt32(self, "file_crc32", "CRC32 checksum over the compressed file)"),
        hexadecimal)
    yield Enum(UInt8(self, "compression_type", "Type of compression"),
               COMPRESSION_TYPE)
    yield Enum(UInt8(self, "compression_mode", "Quality of compression"),
               COMPRESSION_MODE)
    yield textHandler(UInt16(self, "parameters", "Compression parameters"),
                      hexadecimal)
    yield textHandler(UInt16(self, "reserved", "Reserved data"), hexadecimal)
    # Filename
    yield PascalString16(self, "filename", "Filename")
    # Comment
    if self["flags/has_comment"].value:
        yield filesizeHandler(
            UInt16(self, "comment_size", "Size of the compressed comment"))
        if self["comment_size"].value > 0:
            yield RawBytes(self, "comment_data", self["comment_size"].value,
                           "Comment data")
Ejemplo n.º 2
0
 def createFields(self):
     bytes = self.stream.readBytes(self.absolute_address, 4)
     if bytes == b"\0R\0\0":
         charset = "UTF-16-BE"
     else:
         charset = "UTF-16-LE"
     yield String(self, "name", 64, charset=charset, truncate="\0")
     yield UInt16(self, "namelen", "Length of the name")
     yield Enum(UInt8(self, "type", "Property type"), self.TYPE_NAME)
     yield Enum(UInt8(self, "decorator", "Decorator"), self.DECORATOR_NAME)
     yield SECT(self, "left")
     yield SECT(self, "right")
     yield SECT(self, "child",
                "Child node (valid for storage and root types)")
     yield GUID(self, "clsid",
                "CLSID of this storage (valid for storage and root types)")
     yield NullBytes(self, "flags", 4, "User flags")
     yield TimestampWin64(
         self, "creation",
         "Creation timestamp(valid for storage and root types)")
     yield TimestampWin64(
         self, "lastmod",
         "Modify timestamp (valid for storage and root types)")
     yield SECT(
         self, "start",
         "Starting SECT of the stream (valid for stream and root types)")
     if self["/header/bb_shift"].value == 9:
         yield filesizeHandler(
             UInt32(self, "size",
                    "Size in bytes (valid for stream and root types)"))
         yield NullBytes(self, "padding", 4)
     else:
         yield filesizeHandler(
             UInt64(self, "size",
                    "Size in bytes (valid for stream and root types)"))
Ejemplo n.º 3
0
 def createFields(self):
     yield textHandler(UInt32(self, "file_crc32",
                              "Checksum (CRC32)"), hexadecimal)
     yield filesizeHandler(UInt32(self, "file_compressed_size",
                                  "Compressed size (bytes)"))
     yield filesizeHandler(UInt32(self, "file_uncompressed_size",
                                  "Uncompressed size (bytes)"))
Ejemplo n.º 4
0
def commentHeader(s):
    yield filesizeHandler(
        UInt16(s, "total_size", "Comment header size + comment size"))
    yield filesizeHandler(
        UInt16(s, "uncompressed_size", "Uncompressed comment size"))
    yield UInt8(s, "required_version", "RAR version needed to extract comment")
    yield UInt8(s, "packing_method", "Comment packing method")
    yield UInt16(s, "comment_crc16", "Comment CRC")
Ejemplo n.º 5
0
 def createFields(self):
     if self.stream.readBits(self.absolute_address, 6, self.endian) == 63:
         yield Bits(self, "length_ext", 6)
         yield Bits(self, "code", 10)
         yield filesizeHandler(UInt32(self, "length"))
     else:
         yield filesizeHandler(Bits(self, "length", 6))
         yield Bits(self, "code", 10)
     size = self["length"].value
     if 0 < size:
         if self.parser:
             yield from self.parser(self, size)
         else:
             yield RawBytes(self, "data", size)
Ejemplo n.º 6
0
 def createFields(self):
     yield GUID(self, "guid")
     yield filesizeHandler(UInt64(self, "file_size"))
     yield TimestampWin64(self, "creation_date")
     yield UInt64(self, "pckt_count")
     yield TimedeltaWin64(self, "play_duration")
     yield TimedeltaWin64(self, "send_duration")
     yield TimedeltaMillisWin64(self, "preroll")
     yield Bit(self, "broadcast", "Is broadcast?")
     yield Bit(self, "seekable", "Seekable stream?")
     yield PaddingBits(self, "reserved[]", 30)
     yield filesizeHandler(UInt32(self, "min_pckt_size"))
     yield filesizeHandler(UInt32(self, "max_pckt_size"))
     yield displayHandler(UInt32(self, "max_bitrate"), humanBitRate)
Ejemplo n.º 7
0
 def createFields(self):
     yield String(self, "magic", 4, "ITSF", charset="ASCII")
     yield UInt32(self, "version")
     yield UInt32(self, "header_size", "Total header length (in bytes)")
     yield UInt32(self, "one")
     yield UInt32(self, "last_modified", "Lower 32 bits of the time expressed in units of 0.1 us")
     yield Enum(UInt32(self, "lang_id", "Windows Language ID"), LANGUAGE_ID)
     yield GUID(self, "dir_uuid", "{7C01FD10-7BAA-11D0-9E0C-00A0-C922-E6EC}")
     yield GUID(self, "stream_uuid", "{7C01FD11-7BAA-11D0-9E0C-00A0-C922-E6EC}")
     yield UInt64(self, "filesize_offset")
     yield filesizeHandler(UInt64(self, "filesize_len"))
     yield UInt64(self, "dir_offset")
     yield filesizeHandler(UInt64(self, "dir_len"))
     if 3 <= self["version"].value:
         yield UInt64(self, "data_offset")
Ejemplo n.º 8
0
    def createFields(self):
        # Header
        yield String(self, "magic", 4, "PMGL", charset="ASCII")
        yield filesizeHandler(Int32(self, "free_space",
                                    "Length of free space and/or quickref area at end of directory chunk"))
        yield Int32(self, "unknown")
        yield Int32(self, "previous", "Chunk number of previous listing chunk")
        yield Int32(self, "next", "Chunk number of previous listing chunk")

        # Entries
        stop = self.size - self["free_space"].value * 8
        entry_count = 0
        while self.current_size < stop:
            yield PMGL_Entry(self, "entry[]")
            entry_count += 1

        # Padding
        quickref_frequency = 1 + (1 << self["/dir/itsp/density"].value)
        num_quickref = (entry_count // quickref_frequency)
        if entry_count % quickref_frequency == 0:
            num_quickref -= 1
        print(self.current_size // 8, quickref_frequency, num_quickref)
        padding = (self["free_space"].value - (num_quickref * 2 + 2))
        if padding:
            yield PaddingBytes(self, "padding", padding)
        for i in range(num_quickref * quickref_frequency, 0, -quickref_frequency):
            yield UInt16(self, "quickref[%i]" % i)
        yield UInt16(self, "entry_count")
Ejemplo n.º 9
0
    def createFields(self):
        yield String(self, "signature", 3, "SWF format signature", charset="ASCII")
        yield UInt8(self, "version")
        yield filesizeHandler(UInt32(self, "filesize"))
        if self["signature"].value != "CWS":
            yield RECT(self, "rect")
            yield FixedFloat16(self, "frame_rate")
            yield UInt16(self, "frame_count")

            while not self.eof:
                yield Tag(self, "tag[]")
        else:
            size = (self.size - self.current_size) // 8
            if has_deflate:
                data = Deflate(Bytes(self, "compressed_data", size), False)

                def createInputStream(cis, source=None, **args):
                    stream = cis(source=source)
                    header = StringInputStream(
                        b"FWS" + self.stream.readBytes(3 * 8, 5))
                    args.setdefault("tags", []).append(("class", SwfFile))
                    return ConcatStream((header, stream), source=stream.source, **args)
                data.setSubIStream(createInputStream)
                yield data
            else:
                yield Bytes(self, "compressed_data", size)
Ejemplo n.º 10
0
 def createFields(self):
     yield String(self, "signature", 17, "XM signature", charset="ASCII")
     yield String(self, "title", 20, "XM title", charset="ASCII", strip=' ')
     yield UInt8(self, "marker", "Marker (0x1A)")
     yield String(self,
                  "tracker_name",
                  20,
                  "XM tracker name",
                  charset="ASCII",
                  strip=' ')
     yield UInt8(self, "format_minor")
     yield UInt8(self, "format_major")
     yield filesizeHandler(UInt32(self, "header_size", "Header size (276)"))
     yield UInt16(self, "song_length", "Length in patten order table")
     yield UInt16(self, "restart", "Restart position")
     yield UInt16(self, "channels",
                  "Number of channels (2,4,6,8,10,...,32)")
     yield UInt16(self, "patterns", "Number of patterns (max 256)")
     yield UInt16(self, "instruments", "Number of instruments (max 128)")
     yield Bit(self, "amiga_ftable", "Amiga frequency table")
     yield Bit(self, "linear_ftable", "Linear frequency table")
     yield Bits(self, "unused", 14)
     yield UInt16(self, "tempo", "Default tempo")
     yield UInt16(self, "bpm", "Default BPM")
     yield GenericVector(self, "pattern_order", 256, UInt8, "order")
Ejemplo n.º 11
0
 def createFields(self):
     yield String(self, "filename", 56, truncate="\0")
     yield filesizeHandler(UInt32(self, "size"))
     yield SubFile(self,
                   "data",
                   self["size"].value,
                   filename=self["filename"].value)
Ejemplo n.º 12
0
    def createFields(self):
        yield String(self,
                     "signature",
                     4,
                     "AVI header (RIFF)",
                     charset="ASCII")
        yield filesizeHandler(UInt32(self, "filesize", "File size"))
        yield String(self,
                     "type",
                     4,
                     "Content type (\"AVI \", \"WAVE\", ...)",
                     charset="ASCII")

        # Choose chunk type depending on file type
        try:
            chunk_cls = self.VALID_TYPES[self["type"].value][0]
        except KeyError:
            chunk_cls = Chunk

        # Parse all chunks up to filesize
        while self.current_size < self["filesize"].value * 8 + 8:
            yield chunk_cls(self, "chunk[]")
        if not self.eof:
            yield RawBytes(self, "padding[]",
                           (self.size - self.current_size) // 8)
Ejemplo n.º 13
0
 def parseFilename(self):
     yield UInt64(self, "ref", "File reference to the parent directory")
     yield TimestampWin64(self, "ctime", "File Creation")
     yield TimestampWin64(self, "atime", "File Altered")
     yield TimestampWin64(self, "mtime", "MFT Changed")
     yield TimestampWin64(self, "rtime", "File Read")
     yield filesizeHandler(
         UInt64(self, "alloc_size", "Allocated size of the file"))
     yield filesizeHandler(
         UInt64(self, "real_size", "Real size of the file"))
     yield UInt32(self, "file_flags")
     yield UInt32(self, "file_flags2", "Used by EAs and Reparse")
     yield UInt8(self, "filename_length", "Filename length in characters")
     yield Enum(UInt8(self, "filename_namespace"), self.FILENAME_NAMESPACE)
     size = self["filename_length"].value * 2
     if size:
         yield String(self, "filename", size, charset="UTF-16-LE")
Ejemplo n.º 14
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.º 15
0
    def createFields(self):
        # Gzip header
        yield Bytes(self, "signature", 2, r"GZip file signature (\x1F\x8B)")
        yield Enum(UInt8(self, "compression", "Compression method"),
                   self.COMPRESSION_NAME)

        # Flags
        yield Bit(self, "is_text", "File content is probably ASCII text")
        yield Bit(self, "has_crc16", "Header CRC16")
        yield Bit(self, "has_extra", "Extra informations (variable size)")
        yield Bit(self, "has_filename", "Contains filename?")
        yield Bit(self, "has_comment", "Contains comment?")
        yield NullBits(self, "reserved[]", 3)
        yield TimestampUnix32(self, "mtime", "Modification time")

        # Extra flags
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "slowest",
                  "Compressor used maximum compression (slowest)")
        yield Bit(self, "fastest", "Compressor used the fastest compression")
        yield NullBits(self, "reserved[]", 5)
        yield Enum(UInt8(self, "os", "Operating system"), self.os_name)

        # Optional fields
        if self["has_extra"].value:
            yield UInt16(self, "extra_length", "Extra length")
            yield RawBytes(self, "extra", self["extra_length"].value, "Extra")
        if self["has_filename"].value:
            yield CString(self, "filename", "Filename", charset="ISO-8859-1")
        if self["has_comment"].value:
            yield CString(self, "comment", "Comment")
        if self["has_crc16"].value:
            yield textHandler(UInt16(self, "hdr_crc16", "CRC16 of the header"),
                              hexadecimal)

        if self._size is None:  # TODO: is it possible to handle piped input?
            raise NotImplementedError()

        # Read file
        size = (self._size - self.current_size) // 8 - 8  # -8: crc32+size
        if 0 < size:
            if self["has_filename"].value:
                filename = self["filename"].value
            else:
                for tag, filename in self.stream.tags:
                    if tag == "filename" and filename.endswith(".gz"):
                        filename = filename[:-3]
                        break
                else:
                    filename = None
            yield Deflate(SubFile(self, "file", size, filename=filename))

        # Footer
        yield textHandler(
            UInt32(self, "crc32", "Uncompressed data content CRC32"),
            hexadecimal)
        yield filesizeHandler(UInt32(self, "size", "Uncompressed size"))
Ejemplo n.º 16
0
 def createFields(self):
     yield String(self, "magic", 4, "ITSP", charset="ASCII")
     yield UInt32(self, "version", "Version (=1)")
     yield filesizeHandler(UInt32(self, "size", "Length (in bytes) of the directory header (84)"))
     yield UInt32(self, "unknown[]", "(=10)")
     yield filesizeHandler(UInt32(self, "block_size", "Directory block size"))
     yield UInt32(self, "density", "Density of quickref section, usually 2")
     yield UInt32(self, "index_depth", "Depth of the index tree")
     yield Int32(self, "nb_dir", "Chunk number of root index chunk")
     yield UInt32(self, "first_pmgl", "Chunk number of first PMGL (listing) chunk")
     yield UInt32(self, "last_pmgl", "Chunk number of last PMGL (listing) chunk")
     yield Int32(self, "unknown[]", "-1")
     yield UInt32(self, "nb_dir_chunk", "Number of directory chunks (total)")
     yield Enum(UInt32(self, "lang_id", "Windows language ID"), LANGUAGE_ID)
     yield GUID(self, "system_uuid", "{5D02926A-212E-11D0-9DF9-00A0C922E6EC}")
     yield filesizeHandler(UInt32(self, "size2", "Same value than size"))
     yield Int32(self, "unknown[]", "-1")
     yield Int32(self, "unknown[]", "-1")
     yield Int32(self, "unknown[]", "-1")
Ejemplo n.º 17
0
    def createFields(self):
        yield GUID(self, "guid")
        yield filesizeHandler(UInt64(self, "size"))

        size = self["size"].value - self.current_size // 8
        if 0 < size:
            if self.handler:
                yield self.handler(self, "content", size=size * 8)
            else:
                yield RawBytes(self, "content", size)
Ejemplo n.º 18
0
 def createFields(self):
     yield String(self, "signature", 4, "Signature (FORM)", charset="ASCII")
     yield filesizeHandler(UInt32(self, "filesize"))
     yield String(self,
                  "type",
                  4,
                  "Form type (AIFF or AIFC)",
                  charset="ASCII")
     while not self.eof:
         yield Chunk(self, "chunk[]")
Ejemplo n.º 19
0
 def createFields(self):
     yield String(self, "type", 4, "Signature (FORM)", charset="ASCII")
     yield filesizeHandler(UInt32(self, "size"))
     size = self["size"].value
     if size:
         if self._parser:
             yield from self._parser(self)
             if size % 2:
                 yield NullBytes(self, "padding", 1)
         else:
             yield RawBytes(self, "data", size)
Ejemplo n.º 20
0
    def createFields(self):
        yield String(self, "magic", 4, "PMGI", charset="ASCII")
        yield filesizeHandler(UInt32(self, "free_space",
                                     "Length of free space and/or quickref area at end of directory chunk"))

        stop = self.size - self["free_space"].value * 8
        while self.current_size < stop:
            yield PMGI_Entry(self, "entry[]")

        padding = (self.size - self.current_size) // 8
        if padding:
            yield PaddingBytes(self, "padding", padding)
Ejemplo n.º 21
0
 def createFields(self):
     yield filesizeHandler(UInt32(self, "size"))
     yield Enum(Int32(self, "format"), self.FORMAT_NAME)
     if self["format"].value == self.FORMAT_CLIPBOARD:
         yield Enum(UInt32(self, "dib_format"), self.DIB_FORMAT)
         if self["dib_format"].value == self.DIB_BMP:
             yield BmpHeader(self, "bmp_header")
             size = (self.size - self.current_size) // 8
             yield parseImageData(self, "pixels", size, self["bmp_header"])
             return
     size = (self.size - self.current_size) // 8
     if size:
         yield RawBytes(self, "data", size)
Ejemplo n.º 22
0
 def parseStandardInfo(self):
     yield TimestampWin64(self, "ctime", "File Creation")
     yield TimestampWin64(self, "atime", "File Altered")
     yield TimestampWin64(self, "mtime", "MFT Changed")
     yield TimestampWin64(self, "rtime", "File Read")
     yield MSDOSFileAttr32(self, "file_attr", "DOS File Permissions")
     yield UInt32(self, "max_version", "Maximum Number of Versions")
     yield UInt32(self, "version", "Version Number")
     yield UInt32(self, "class_id")
     yield UInt32(self, "owner_id")
     yield UInt32(self, "security_id")
     yield filesizeHandler(UInt64(self, "quota_charged", "Quota Charged"))
     yield UInt64(self, "usn", "Update Sequence Number (USN)")
Ejemplo n.º 23
0
 def createFields(self):
     yield filesizeHandler(UInt32(self, "filesize", "Uncompressed file size"))
     yield UInt32(self, "folder_offset", "File offset in uncompressed folder")
     yield Enum(UInt16(self, "folder_index", "Containing folder ID (index)"), {
         0xFFFD: "Folder continued from previous cabinet (real folder ID = 0)",
         0xFFFE: "Folder continued to next cabinet (real folder ID = %i)" % (self["../nb_folder"].value - 1),
         0xFFFF: "Folder spanning previous, current and next cabinets (real folder ID = 0)"})
     yield DateTimeMSDOS32(self, "timestamp")
     yield CabFileAttributes(self, "attributes")
     if self["attributes/name_is_utf"].value:
         yield CString(self, "filename", charset="UTF-8")
     else:
         yield CString(self, "filename", charset="ASCII")
Ejemplo n.º 24
0
    def createFields(self):
        yield String(self, "name", 8, charset="ASCII", strip="\0 ")
        yield filesizeHandler(UInt32(self, "mem_size", "Size in memory"))
        yield textHandler(UInt32(self, "rva", "RVA (location) in memory"), hexadecimal)
        yield filesizeHandler(UInt32(self, "phys_size", "Physical size (on disk)"))
        yield filesizeHandler(UInt32(self, "phys_off", "Physical location (on disk)"))
        yield PaddingBytes(self, "reserved", 12)

        # 0x0000000#
        yield NullBits(self, "reserved[]", 4)
        # 0x000000#0
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "has_code", "Contains code")
        yield Bit(self, "has_init_data", "Contains initialized data")
        yield Bit(self, "has_uninit_data", "Contains uninitialized data")
        # 0x00000#00
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "has_comment", "Contains comments?")
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "remove", "Contents will not become part of image")
        # 0x0000#000
        yield Bit(self, "has_comdata", "Contains comdat?")
        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "no_defer_spec_exc", "Reset speculative exceptions handling bits in the TLB entries")
        yield Bit(self, "gp_rel", "Content can be accessed relative to GP")
        # 0x000#0000
        yield NullBits(self, "reserved[]", 4)
        # 0x00#00000
        yield NullBits(self, "reserved[]", 4)
        # 0x0#000000
        yield Bit(self, "ext_reloc", "Contains extended relocations?")
        yield Bit(self, "discarded", "Can be discarded?")
        yield Bit(self, "is_not_cached", "Is not cachable?")
        yield Bit(self, "is_not_paged", "Is not pageable?")
        # 0x#0000000
        yield Bit(self, "is_shareable", "Is shareable?")
        yield Bit(self, "is_executable", "Is executable?")
        yield Bit(self, "is_readable", "Is readable?")
        yield Bit(self, "is_writable", "Is writable?")
Ejemplo n.º 25
0
def specialHeader(s, is_file):
    yield filesizeHandler(
        UInt32(s, "compressed_size", "Compressed size (bytes)"))
    yield filesizeHandler(
        UInt32(s, "uncompressed_size", "Uncompressed size (bytes)"))
    yield Enum(UInt8(s, "host_os", "Operating system used for archiving"),
               OS_NAME)
    yield textHandler(UInt32(s, "crc32", "File CRC32"), hexadecimal)
    yield TimeDateMSDOS32(s, "ftime", "Date and time (MS DOS format)")
    yield textHandler(
        UInt8(s, "version", "RAR version needed to extract file"),
        formatRARVersion)
    yield Enum(UInt8(s, "method", "Packing method"), COMPRESSION_NAME)
    yield filesizeHandler(UInt16(s, "filename_length", "File name size"))
    if s["host_os"].value in (OS_MSDOS, OS_WIN32):
        yield MSDOSFileAttr32(s, "file_attr", "File attributes")
    else:
        yield textHandler(UInt32(s, "file_attr", "File attributes"),
                          hexadecimal)

    # Start additional field from unrar
    if s["flags/is_large"].value:
        yield filesizeHandler(
            UInt64(s, "large_size", "Extended 64bits filesize"))

    # End additional field
    size = s["filename_length"].value
    if size > 0:
        if s["flags/is_unicode"].value:
            charset = "UTF-8"
        else:
            charset = "ISO-8859-15"
        yield String(s, "filename", size, "Filename", charset=charset)
    # Start additional fields from unrar - file only
    if is_file:
        if s["flags/has_salt"].value:
            yield textHandler(UInt8(s, "salt", "Salt"), hexadecimal)
        if s["flags/has_ext_time"].value:
            yield ExtTime(s, "extra_time", "Extra time info")
Ejemplo n.º 26
0
def newRecoveryHeader(self):
    """
    This header is described nowhere
    """
    if self["flags/extend"].value:
        yield filesizeHandler(
            UInt32(self, "body_size", "Size of the unknown body following"))
        self.body_size = self["body_size"].value
    yield textHandler(UInt32(self, "unknown[]", "Unknown field, probably 0"),
                      hexadecimal)
    yield String(self, "signature", 7, "Signature, normally '**ACE**'")
    yield textHandler(
        UInt32(self, "relative_start",
               "Offset (=crc16's) of this block in the file"), hexadecimal)
    yield textHandler(UInt32(self, "unknown[]", "Unknown field, probably 0"),
                      hexadecimal)
Ejemplo n.º 27
0
def markerHeader(self):
    yield String(self, "signature", 7, "Signature")
    yield UInt8(self, "ver_extract", "Version needed to extract archive")
    yield UInt8(self, "ver_created", "Version used to create archive")
    yield Enum(UInt8(self, "host_os", "OS where the files were compressed"),
               HOST_OS)
    yield UInt8(self, "vol_num", "Volume number")
    yield TimeDateMSDOS32(self, "time", "Date and time (MS DOS format)")
    yield Bits(self, "reserved", 64, "Reserved size for future extensions")
    flags = self["flags"]
    if flags["has_av_string"].value:
        yield PascalString8(self, "av_string", "AV String")
    if flags["has_comment"].value:
        size = filesizeHandler(UInt16(self, "comment_size", "Comment size"))
        yield size
        if size.value > 0:
            yield RawBytes(self, "compressed_comment", size.value,
                           "Compressed comment")
Ejemplo n.º 28
0
def recoveryHeader(self):
    yield filesizeHandler(UInt32(self, "rec_blk_size",
                                 "Size of recovery data"))
    self.body_size = self["rec_blk_size"].size
    yield String(self, "signature", 7, "Signature, normally '**ACE**'")
    yield textHandler(
        UInt32(
            self, "relative_start",
            "Relative start (to this block) of the data this block is mode of"
        ), hexadecimal)
    yield UInt32(self, "num_blocks", "Number of blocks the data is split into")
    yield UInt32(self, "size_blocks", "Size of these blocks")
    yield UInt16(self, "crc16_blocks", "CRC16 over recovery data")
    # size_blocks blocks of size size_blocks follow
    # The ultimate data is the xor data of all those blocks
    size = self["size_blocks"].value
    for index in range(self["num_blocks"].value):
        yield RawBytes(self, "data[]", size, "Recovery block %i" % index)
    yield RawBytes(self, "xor_data", size,
                   "The XOR value of the above data blocks")
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 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()