Exemplo n.º 1
0
    def createFields(self):
        yield SpectrumHeader(self, "header")
        yield RawBytes(self, "uknown area 1", 16)
        for index in range(1, 2 + 1):
            yield UInt32(self, "unknown index[%s]" % index)
        yield TimestampUnix32(self, "start")
        yield TimestampUnix32(self, "end")
        yield UInt32(self, "unknown long[%s]" % 1)
        yield RawBytes(self, "uknown area 2", 16)
        for index in range(2, 6 + 1):
            yield UInt32(self, "unknown long[%s]" % index)
        yield Float64(self, "unknown double")
        yield StructTwo(self, "unknown 52-byte structure")

        yield Struct100(self, "unknown 100-byte structure[1]")
        for index in range(1, 4 + 1):
            yield UInt16(self, "short[%s]" % index)
        yield Struct100(self, "unknown 100-byte structure[2]")
        for index in range(5, 6 + 1):
            yield UInt16(self, "short[%s]" % index)
        yield Struct100(self, "unknown 100-byte structure[3]")
        for index in range(7, 10 + 1):
            yield UInt16(self, "short[%s]" % index)
        yield Struct100(self, "unknown 100-byte structure[4]")
        for index in range(11, 14 + 1):
            yield UInt16(self, "short[%s]" % index)
Exemplo n.º 2
0
 def createFields(self):
     yield RawBytes(self, "unknown string", 24,
                    "detritus from a previous write?")
     yield UInt32(self, "unknown long 1")
     yield UInt32(self, "trailer addr")
     for index in range(2, 7 + 1):
         yield UInt32(self, "unknown long[%s]" % index)
     yield TimestampUnix32(self, "start time[1]")
     yield TimestampUnix32(self, "end time[1]")
     yield TimestampUnix32(self, "start time[2]")
     yield TimestampUnix32(self, "end time[2]")
     yield RawBytes(self, "unknown area 1", 16)
     yield UInt16(self, "unknown short 1")
     yield UInt16(self, "unknown short 2")
     yield RawBytes(self, "unknown area 2", 8)
     yield UInt16(self, "unknown short 3")
     yield RawBytes(self, "unknown area 3", 6)
     yield UInt16(self, "unknown short 4")
     yield UInt16(self, "unknown short 5")
     yield RawBytes(self, "unknown area 4", 0x2c)
     yield UInt32(self, "unknown long[%s]" % 8)
     yield RawBytes(self, "unknown string or buffer", 76,
                    "detritus from a previous write?")
     yield PascalStringWin32(self, "file path",
                             "The full filesystem path to this file")
     yield RawBytes(self, "uknown area 5", 16)
     yield PascalStringWin32(self, "method file",
                             "The filesystem path to method file")
     yield PascalStringWin32(self, "tune file",
                             "The filesystem path to tune file")
     yield StructOne(self, "unknown structure")
Exemplo n.º 3
0
    def createFields(self):
        yield UInt16(self, "left", "Left")
        yield UInt16(self, "top", "Top")
        yield UInt16(self, "width", "Width")
        yield UInt16(self, "height", "Height")

        yield Bits(self, "size_local_map", 3,
                   "log2(size of local map) minus one")
        yield NullBits(self, "reserved", 2)
        yield Bit(self, "sort_flag",
                  "Is the local map sorted by decreasing importance?")
        yield Bit(self, "interlaced", "Interlaced?")
        yield Bit(self, "has_local_map", "Use local color map?")

        if self["has_local_map"].value:
            nb_color = 1 << (1 + self["size_local_map"].value)
            yield PaletteRGB(self, "local_map", nb_color, "Local color map")

        yield UInt8(self, "lzw_min_code_size", "LZW Minimum Code Size")
        group = None
        while True:
            size = UInt8(self, "block_size")
            if size.value == 0:
                break
            block = CustomFragment(self, "image_block[]", None, GifImageBlock,
                                   "GIF Image Block", group)
            group = block.group
            yield block
        yield NullBytes(self, "terminator", 1, "Terminator (0)")
Exemplo n.º 4
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")
Exemplo n.º 5
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")
Exemplo n.º 6
0
def parseDeclareFunction(parent, size):
    yield CString(parent, "name")
    argCount = UInt16(parent, "arg_count")
    yield argCount
    for i in range(argCount.value):
        yield CString(parent, "arg[]")
    yield UInt16(parent, "function_length")
    def createFields(self):
        yield Bytes(self, "endian", 2, "Endian (0xFF 0xFE for Intel)")
        yield UInt16(self, "format", "Format (0)")
        yield UInt8(self, "os_version")
        yield UInt8(self, "os_revision")
        yield Enum(UInt16(self, "os_type"), OS_NAME)
        yield GUID(self, "format_id")
        yield UInt32(self, "section_count")
        if MAX_SECTION_COUNT < self["section_count"].value:
            raise ParserError("OLE2: Too much sections (%s)" %
                              self["section_count"].value)

        section_indexes = []
        for index in xrange(self["section_count"].value):
            section_index = SummaryIndex(self, "section_index[]")
            yield section_index
            section_indexes.append(section_index)

        for section_index in section_indexes:
            self.seekByte(section_index["offset"].value)
            yield SummarySection(self, "section[]")

        size = (self.size - self.current_size) // 8
        if 0 < size:
            yield NullBytes(self, "end_padding", size)
Exemplo n.º 8
0
    def createFields(self):
        yield String(self,
                     "signature",
                     4,
                     "PSD signature (8BPS)",
                     charset="ASCII")
        yield UInt16(self, "version")
        yield NullBytes(self, "reserved[]", 6)
        yield UInt16(self, "nb_channels")
        yield UInt32(self, "width")
        yield UInt32(self, "height")
        yield UInt16(self, "depth")
        yield Enum(UInt16(self, "color_mode"), self.COLOR_MODE)

        # Mode data
        yield UInt32(self, "mode_data_size")
        size = self["mode_data_size"].value
        if size:
            yield RawBytes(self, "mode_data", size)

        # Resources
        yield Config(self, "config")

        # Reserved
        yield UInt32(self, "reserved_data_size")
        size = self["reserved_data_size"].value
        if size:
            yield RawBytes(self, "reserved_data", size)

        yield Enum(UInt16(self, "compression"), self.COMPRESSION_NAME)

        size = (self.size - self.current_size) // 8
        if size:
            yield RawBytes(self, "end", size)
Exemplo n.º 9
0
    def createFields(self):
        yield ZipVersion(self, "version_made_by", "Version made by")
        for field in ZipStartCommonFields(self):
            yield field

        # 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)
Exemplo n.º 10
0
    def createFields(self):
        yield Enum(UInt16(self, "src"), self.port_name)
        yield Enum(UInt16(self, "dst"), self.port_name)
        yield UInt32(self, "seq_num")
        yield UInt32(self, "ack_num")

        yield Bits(self, "hdrlen", 6, "Header lenght")
        yield NullBits(self, "reserved", 2, "Reserved")

        yield Bit(self, "cgst", "Congestion Window Reduced")
        yield Bit(self, "ecn-echo", "ECN-echo")
        yield Bit(self, "urg", "Urgent")
        yield Bit(self, "ack", "Acknowledge")
        yield Bit(self, "psh", "Push mmode")
        yield Bit(self, "rst", "Reset connection")
        yield Bit(self, "syn", "Synchronize")
        yield Bit(self, "fin", "Stop the connection")

        yield UInt16(self, "winsize", "Windows size")
        yield textHandler(UInt16(self, "checksum"), hexadecimal)
        yield UInt16(self, "urgent")

        size = self["hdrlen"].value * 8 - self.current_size
        while 0 < size:
            option = TCP_Option(self, "option[]")
            yield option
            size -= option.size
Exemplo n.º 11
0
    def createFields(self):
        yield textHandler(UInt32(self, "magic", "File information magic (0xFEEF04BD)"), hexadecimal)
        if self["magic"].value != 0xFEEF04BD:
            raise ParserError("EXE resource: invalid file info magic")
        yield Version(self, "struct_ver", "Structure version (1.0)")
        yield Version(self, "file_ver_ms", "File version MS")
        yield Version(self, "file_ver_ls", "File version LS")
        yield Version(self, "product_ver_ms", "Product version MS")
        yield Version(self, "product_ver_ls", "Product version LS")
        yield textHandler(UInt32(self, "file_flags_mask"), hexadecimal)

        yield Bit(self, "debug")
        yield Bit(self, "prerelease")
        yield Bit(self, "patched")
        yield Bit(self, "private_build")
        yield Bit(self, "info_inferred")
        yield Bit(self, "special_build")
        yield NullBits(self, "reserved", 26)

        yield Enum(textHandler(UInt16(self, "file_os_major"), hexadecimal), MAJOR_OS_NAME)
        yield Enum(textHandler(UInt16(self, "file_os_minor"), hexadecimal), MINOR_OS_NAME)
        yield Enum(textHandler(UInt32(self, "file_type"), hexadecimal), FILETYPE_NAME)
        field = textHandler(UInt32(self, "file_subfile"), hexadecimal)
        if field.value == FILETYPE_DRIVER:
            field = Enum(field, DRIVER_SUBTYPE_NAME)
        elif field.value == FILETYPE_FONT:
            field = Enum(field, FONT_SUBTYPE_NAME)
        yield field
        yield TimestampUnix32(self, "date_ms")
        yield TimestampUnix32(self, "date_ls")
Exemplo n.º 12
0
 def createFields(self):
     yield NullBytes(self, "options", 4)
     yield TimestampUnix32(self, "creation_date")
     yield UInt16(self, "maj_ver", "Major version")
     yield UInt16(self, "min_ver", "Minor version")
     yield UInt16(self, "nb_name", "Number of named entries")
     yield UInt16(self, "nb_index", "Number of indexed entries")
Exemplo n.º 13
0
    def createFields(self):
        yield UInt16(self, "size", "Node size (in bytes)")
        yield UInt16(self, "data_size")
        yield Enum(UInt16(self, "type"), self.TYPE_NAME)
        yield CString(self, "name", charset="UTF-16-LE")

        size = paddingSize(self.current_size//8, 4)
        if size:
            yield NullBytes(self, "padding[]", size)
        size = self["data_size"].value
        if size:
            if self["type"].value == self.TYPE_STRING:
                if self.is_32bit:
                    size *= 2
                yield String(self, "value", size, charset="UTF-16-LE", truncate="\0")
            elif self["name"].value == "VS_VERSION_INFO":
                yield VersionInfoBinary(self, "value", size=size*8)
                if self["value/file_flags_mask"].value == 0:
                    self.is_32bit = False
            else:
                yield RawBytes(self, "value", size)
        while 12 <= (self.size - self.current_size) // 8:
            yield VersionInfoNode(self, "node[]", self.is_32bit)
        size = (self.size - self.current_size) // 8
        if size:
            yield NullBytes(self, "padding[]", size)
Exemplo n.º 14
0
    def createFields(self):
        yield String(self, "header_id", 4, "Playlist List Header Markup (\"mhyp\")", charset="ISO-8859-1")
        yield UInt32(self, "header_length", "Header Length")
        yield UInt32(self, "entry_length", "Entry Length")
        yield UInt32(self, "data_object_child_count", "Number of Child Data Objects")
        yield UInt32(self, "playlist_count", "Number of Playlist Items")
        yield Enum(UInt8(self, "type", "Normal or master playlist?"), self.is_master_pl_name)
        yield UInt8(self, "XXX1", "XXX1")
        yield UInt8(self, "XXX2", "XXX2")
        yield UInt8(self, "XXX3", "XXX3")
        yield TimestampMac32(self, "creation_date", "Date when the playlist was created")
        yield UInt64(self, "playlistid", "Persistent Playlist ID")
        yield UInt32(self, "unk3", "unk3")
        yield UInt16(self, "string_mhod_count", "Number of string MHODs for this playlist")
        yield Enum(UInt16(self, "is_podcast", "Playlist or Podcast List?"), self.is_podcast_name)
        yield Enum(UInt32(self, "sort_order", "Playlist Sort Order"), self.list_sort_order_name)

        padding = self.seekByte(self["header_length"].value, "entry padding")
        if padding:
            yield padding

        for i in xrange(self["data_object_child_count"].value):
            yield DataObject(self, "mhod[]")

        for i in xrange(self["playlist_count"].value):
            yield PlaylistItem(self, "playlist_item[]")
Exemplo n.º 15
0
    def createFields(self):
        yield Bits(self, "version", 4, "Version")
        yield Bits(self, "hdr_size", 4, "Header size divided by 5")

        # Type of service
        yield Enum(Bits(self, "precedence", 3, "Precedence"),
                   self.precedence_name)
        yield Bit(self, "low_delay", "If set, low delay, else normal delay")
        yield Bit(self, "high_throu",
                  "If set, high throughput, else normal throughput")
        yield Bit(self, "high_rel", "If set, high relibility, else normal")
        yield NullBits(self, "reserved[]", 2, "(reserved for future use)")

        yield UInt16(self, "length")
        yield UInt16(self, "id")

        yield NullBits(self, "reserved[]", 1)
        yield Bit(self, "df", "Don't fragment")
        yield Bit(self, "more_frag",
                  "There are more fragments? if not set, it's the last one")
        yield Bits(self, "frag_ofst_lo", 5)
        yield UInt8(self, "frag_ofst_hi")
        yield UInt8(self, "ttl", "Type to live")
        yield Enum(UInt8(self, "protocol"), self.PROTOCOL_NAME)
        yield textHandler(UInt16(self, "checksum"), hexadecimal)
        yield IPv4_Address(self, "src")
        yield IPv4_Address(self, "dst")

        size = (self.size - self.current_size) // 8
        if size:
            yield RawBytes(self, "options", size)
Exemplo n.º 16
0
    def createFields(self):
        yield Bytes(self, "header", 4, r"PE header signature (PE\0\0)")
        if self["header"].value != "PE\0\0":
            raise ParserError("Invalid PE header signature")
        yield Enum(UInt16(self, "cpu", "CPU type"), self.cpu_name)
        yield UInt16(self, "nb_section", "Number of sections")
        yield TimestampUnix32(self, "creation_date", "Creation date")
        yield UInt32(self, "ptr_to_sym", "Pointer to symbol table")
        yield UInt32(self, "nb_symbols", "Number of symbols")
        yield UInt16(self, "opt_hdr_size", "Optional header size")

        yield Bit(self, "reloc_stripped",
                  "If true, don't contain base relocations.")
        yield Bit(self, "exec_image", "Executable image?")
        yield Bit(self, "line_nb_stripped", "COFF line numbers stripped?")
        yield Bit(self, "local_sym_stripped",
                  "COFF symbol table entries stripped?")
        yield Bit(self, "aggr_ws", "Aggressively trim working set")
        yield Bit(self, "large_addr",
                  "Application can handle addresses greater than 2 GB")
        yield NullBits(self, "reserved", 1)
        yield Bit(self, "reverse_lo",
                  "Little endian: LSB precedes MSB in memory")
        yield Bit(self, "32bit", "Machine based on 32-bit-word architecture")
        yield Bit(self, "is_stripped", "Debugging information removed?")
        yield Bit(
            self, "swap",
            "If image is on removable media, copy and run from swap file")
        yield PaddingBits(self, "reserved2", 1)
        yield Bit(self, "is_system", "It's a system file")
        yield Bit(self, "is_dll", "It's a dynamic-link library (DLL)")
        yield Bit(self, "up", "File should be run only on a UP machine")
        yield Bit(self, "reverse_hi", "Big endian: MSB precedes LSB in memory")
Exemplo n.º 17
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)
Exemplo n.º 18
0
 def createFields(self):
     yield textHandler(UInt32(self, "signature", "Placeable Metafiles signature (0x9AC6CDD7)"), hexadecimal)
     yield UInt16(self, "handle")
     yield RECT16(self, "rect")
     yield UInt16(self, "inch")
     yield NullBytes(self, "reserved", 4)
     yield textHandler(UInt16(self, "checksum"), hexadecimal)
Exemplo n.º 19
0
 def createFields(self):
     if self.stream.readBytes(self.absolute_address, 2) == "\xff\xff":
         yield Int16(
             self, "utf16_marker",
             "If this field is present, the Sttbf contains UTF-16 data."
         )
         self.is_utf16 = True
     else:
         self.is_utf16 = False
     yield UInt16(self, "count", "Number of strings in this Sttbf")
     extra_data_field = UInt16(
         self, "extra_data_len",
         "Size of optional extra data after each string")
     yield extra_data_field
     extra_data_len = extra_data_field.value
     for i in xrange(self["count"].value):
         if self.name == "SttbfAssoc":
             desc = self.SttbfAssocDESC.get(i, None)
         else:
             desc = None
         if self.name == "Sttbfffn":
             yield TableParsers.Ffn(self, "string[]", desc)
         elif self.is_utf16:
             yield WidePascalString16(self, "string[]", desc)
         else:
             yield PascalString8(self, "string[]", desc)
         if extra_data_len:
             yield RawBytes(self, "extra[]", extra_data_len)
Exemplo n.º 20
0
def parseCommon(self):
    yield UInt16(self, "nb_channel")
    yield UInt32(self, "nb_sample")
    yield UInt16(self, "sample_size")
    yield Float80(self, "sample_rate")
    yield Enum(String(self, "codec", 4, strip="\0", charset="ASCII"),
               CODEC_NAME)
Exemplo n.º 21
0
 def createFields(self):
     yield String(self, "name", 22, strip='\0')
     yield UInt16(self, "sample_count")
     yield textHandler(UInt8(self, "fine_tune"), getFineTune)
     yield textHandler(UInt8(self, "volume"), getVolume)
     yield UInt16(self, "loop_start", "Loop start offset in samples")
     yield UInt16(self, "loop_len", "Loop length in samples")
Exemplo n.º 22
0
 def createFields(self):
     yield textHandler(UInt32(self, "crc32"), hexadecimal)
     yield UInt16(self, "size")
     yield UInt16(
         self, "uncompressed_size",
         "If this is 0, this block is continued in a subsequent cabinet")
     if self["/flags/has_reserved"].value and self[
             "/reserved_data_size"].value:
         yield RawBytes(self, "reserved_data",
                        self["/reserved_data_size"].value,
                        "Per-datablock reserved area")
     compr_method = self.parent.folder["compr_method"].value
     if compr_method == 0:  # Uncompressed
         yield RawBytes(self, "data", self["size"].value, "Folder Data")
         self.parent.uncompressed_data += self["data"].value
     elif compr_method == 1:  # MSZIP
         yield String(self, "mszip_signature", 2, "MSZIP Signature (CK)")
         yield DeflateBlock(self, "deflate_block",
                            self.parent.uncompressed_data)
         padding = paddingSize(self.current_size, 8)
         if padding:
             yield PaddingBits(self, "padding[]", padding)
         self.parent.uncompressed_data = self["deflate_block"].uncomp_data
     elif compr_method == 2:  # Quantum
         yield RawBytes(self, "compr_data", self["size"].value,
                        "Compressed Folder Data")
     elif compr_method == 3:  # LZX
         group = getattr(self.parent.folder, "lzx_group", None)
         field = CustomFragment(self, "data", self["size"].value * 8,
                                LZXStream, "LZX data fragment", group)
         self.parent.folder.lzx_group = field.group
         yield field
Exemplo n.º 23
0
    def createUnpaddedFields(self):
        yield String(self, "title", 28, strip='\0')
        yield textHandler(UInt8(self, "marker[]"), hexadecimal)
        for field in self.getFileVersionField():
            yield field

        yield UInt16(self, "num_orders")
        yield UInt16(self, "num_instruments")
        yield UInt16(self, "num_patterns")

        for field in self.getFirstProperties():
            yield field
        yield String(self, "marker[]", 4)
        for field in self.getLastProperties():
            yield field

        yield GenericVector(self, "channel_settings", 32, ChannelSettings,
                            "channel")

        # Orders
        yield GenericVector(self, "orders", self.getNumOrders(), UInt8,
                            "order")

        for field in self.getHeaderEndFields():
            yield field
Exemplo n.º 24
0
def parseCode(parent):
    if 0x3000000 <= parent.root.getVersion():
        yield UInt32(parent, "arg_count", "Argument count")
        yield UInt32(parent, "kwonlyargcount", "Keyword only argument count")
        yield UInt32(parent, "nb_locals", "Number of local variables")
        yield UInt32(parent, "stack_size", "Stack size")
        yield UInt32(parent, "flags")
    elif 0x2030000 <= parent.root.getVersion():
        yield UInt32(parent, "arg_count", "Argument count")
        yield UInt32(parent, "nb_locals", "Number of local variables")
        yield UInt32(parent, "stack_size", "Stack size")
        yield UInt32(parent, "flags")
    else:
        yield UInt16(parent, "arg_count", "Argument count")
        yield UInt16(parent, "nb_locals", "Number of local variables")
        yield UInt16(parent, "stack_size", "Stack size")
        yield UInt16(parent, "flags")
    yield Object(parent, "compiled_code")
    yield Object(parent, "consts")
    yield Object(parent, "names")
    yield Object(parent, "varnames")
    if 0x2000000 <= parent.root.getVersion():
        yield Object(parent, "freevars")
        yield Object(parent, "cellvars")
    yield Object(parent, "filename")
    yield Object(parent, "name")
    if 0x2030000 <= parent.root.getVersion():
        yield UInt32(parent, "firstlineno", "First line number")
    else:
        yield UInt16(parent, "firstlineno", "First line number")
    yield Object(parent, "lnotab")
Exemplo n.º 25
0
 def createFields(self):
     yield String(self,
                  "header_id",
                  4,
                  "DataBase Header Markup (\"mhbd\")",
                  charset="ISO-8859-1")
     yield UInt32(self, "header_length", "Header Length")
     yield UInt32(self, "entry_length", "Entry Length")
     yield UInt32(self, "unknown[]")
     yield UInt32(self, "version_number", "Version Number")
     yield UInt32(self, "child_number", "Number of Children")
     yield UInt64(self, "id", "ID for this database")
     yield UInt16(self, "unknown[]")
     yield UInt32(self, "unknown[]")
     yield UInt64(self, "unknown[]")
     yield UInt16(self, "unknown[]")
     yield UInt16(self, "hashing_scheme[]",
                  "Algorithm used to calculate the database hash")
     yield NullBytes(self, "unknown[]", 20)
     yield String(self, "language_id", 2, "Language ID")
     yield UInt64(self, "persistent_id", "Library Persistent ID")
     yield UInt32(self, "unknown[]")
     yield UInt32(self, "unknown[]")
     yield RawBytes(self, "hash[]", 20)
     yield Int32(self, "timezone_offset[]", "Timezone offset in seconds")
     yield UInt16(self, "unknown[]")
     yield RawBytes(self, "iphone_hash[]", 45)
     size = self["header_length"].value - self.current_size / 8
     if size > 0:
         yield NullBytes(self, "padding", size)
     for i in xrange(self["child_number"].value):
         yield DataSet(self, "dataset[]")
     padding = self.seekByte(self["entry_length"].value, "entry padding")
     if padding:
         yield padding
Exemplo n.º 26
0
 def createFields(self):
     yield Enum(UInt16(self, "field_id", "Extra field ID"),
                self.EXTRA_FIELD_ID)
     size = UInt16(self, "field_data_size", "Extra field data size")
     yield size
     if size.value > 0:
         yield RawBytes(self, "field_data", size.value, "Unknown field data")
Exemplo n.º 27
0
 def createFields(self):
     yield Enum(UInt16(self, "type"), self.CHUNK_DESC)
     yield UInt16(self, "header_size")
     yield UInt32(self, "chunk_size")
     if self.parse_func:
         for field in self.parse_func(self):
             yield field
Exemplo n.º 28
0
    def createFields(self):
        # Header
        yield NullBytes(self, "zero_vector", 16)
        yield GUID(self, "fs_guid")
        yield UInt64(self, "volume_len")
        yield String(self, "signature", 4)
        yield UInt32(self, "attributes")
        yield UInt16(self, "header_len")
        yield UInt16(self, "checksum")
        yield UInt16(self, "ext_header_offset")
        yield UInt8(self, "reserved")
        yield UInt8(self, "revision")
        while True:
            bm = BlockMap(self, "block_map[]")
            yield bm
            if bm['num_blocks'].value == 0 and bm['len'].value == 0:
                break
        # TODO must handle extended header

        # Content
        while not self.eof:
            padding = paddingSize(self.current_size // 8, 8)
            if padding:
                yield PaddingBytes(self, "padding[]", padding)
            yield File(self, "file[]")
Exemplo n.º 29
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")
Exemplo n.º 30
0
 def createFields(self):
     yield UInt8(self, "version", "Version")
     yield NullBits(self, "flags", 24)
     yield UInt16(self, "max_pdu_size")
     yield UInt16(self, "avg_pdu_size")
     yield UInt32(self, "max_bit_rate")
     yield UInt32(self, "avg_bit_rate")
     yield UInt32(self, "reserved[]")
Exemplo n.º 31
0
 def __init__(self, parent, name, description=None, target_types=None,
             target_text_handler=(lambda x: x), allow_zero=False):
     """
     Initialize a CPIndex.
     - target_type is the tuple of expected type for the target CPInfo
       (if None, then there will be no type check)
     - target_text_handler is a string transformation function used for
       pretty printing the target str() result
     - allow_zero states whether null index is allowed (sometimes, constant
       pool index is optionnal)
     """
     UInt16.__init__(self, parent, name, description)
     if isinstance(target_types, str):
         self.target_types = (target_types,)
     else:
         self.target_types = target_types
     self.allow_zero = allow_zero
     self.target_text_handler = target_text_handler
     self.getOriginalDisplay = lambda: self.value
Exemplo n.º 32
0
 def __init__(self, parent, name, targetBytes):
     UInt16.__init__(self, parent, name)
     self.targetBytes = targetBytes