Пример #1
0
def parseAudio(parent, size):
    yield Enum(Bits(parent, "codec", 4, "Audio codec"), AUDIO_CODEC_NAME)
    yield Enum(Bits(parent, "sampling_rate", 2, "Sampling rate"), SAMPLING_RATE_TEXT)
    yield Bit(parent, "is_16bit", "16-bit or 8-bit per sample")
    yield Bit(parent, "is_stereo", "Stereo or mono channel")

    size -= 1
    if 0 < size:
        if parent["codec"].value == AUDIO_CODEC_MP3 :
            yield Frame(parent, "music_data", size=size*8)
        else:
            yield RawBytes(parent, "music_data", size)
def parseFontHeader(self):
    yield UInt16(self, "maj_ver", "Major version")
    yield UInt16(self, "min_ver", "Minor version")
    yield UInt16(self, "font_maj_ver", "Font major version")
    yield UInt16(self, "font_min_ver", "Font minor version")
    yield textHandler(UInt32(self, "checksum"), hexadecimal)
    yield Bytes(self, "magic", 4, r"Magic string (\x5F\x0F\x3C\xF5)")
    if self["magic"].value != "\x5F\x0F\x3C\xF5":
        raise ParserError("TTF: invalid magic of font header")

    # Flags
    yield Bit(self, "y0", "Baseline at y=0")
    yield Bit(self, "x0", "Left sidebearing point at x=0")
    yield Bit(self, "instr_point", "Instructions may depend on point size")
    yield Bit(self, "ppem", "Force PPEM to integer values for all")
    yield Bit(self, "instr_width", "Instructions may alter advance width")
    yield Bit(self, "vertical", "e laid out vertically?")
    yield PaddingBits(self, "reserved[]", 1)
    yield Bit(self, "linguistic", "Requires layout for correct linguistic rendering?")
    yield Bit(self, "gx", "Metamorphosis effects?")
    yield Bit(self, "strong", "Contains strong right-to-left glyphs?")
    yield Bit(self, "indic", "contains Indic-style rearrangement effects?")
    yield Bit(self, "lossless", "Data is lossless (Agfa MicroType compression)")
    yield Bit(self, "converted", "Font converted (produce compatible metrics)")
    yield Bit(self, "cleartype", "Optimised for ClearType")
    yield Bits(self, "adobe", 2, "(used by Adobe)")

    yield UInt16(self, "unit_per_em", "Units per em")
    if not(16 <= self["unit_per_em"].value <= 16384):
        raise ParserError("TTF: Invalid unit/em value")
    yield UInt32(self, "created_high")
    yield TimestampMac32(self, "created")
    yield UInt32(self, "modified_high")
    yield TimestampMac32(self, "modified")
    yield UInt16(self, "xmin")
    yield UInt16(self, "ymin")
    yield UInt16(self, "xmax")
    yield UInt16(self, "ymax")

    # Mac style
    yield Bit(self, "bold")
    yield Bit(self, "italic")
    yield Bit(self, "underline")
    yield Bit(self, "outline")
    yield Bit(self, "shadow")
    yield Bit(self, "condensed", "(narrow)")
    yield Bit(self, "expanded")
    yield PaddingBits(self, "reserved[]", 9)

    yield UInt16(self, "lowest", "Smallest readable size in pixels")
    yield Enum(UInt16(self, "font_dir", "Font direction hint"), DIRECTION_NAME)
    yield Enum(UInt16(self, "ofst_format"), {0: "short offsets", 1: "long"})
    yield UInt16(self, "glyph_format", "(=0)")
Пример #3
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)
Пример #4
0
 def createFields(self):
     yield String(self,
                  "header_id",
                  4,
                  "Data Object Header Markup (\"mhod\")",
                  charset="ISO-8859-1")
     yield UInt32(self, "header_length", "Header Length")
     yield UInt32(self, "entry_length", "Entry Length")
     yield Enum(UInt32(self, "type", "type"), self.type_name)
     if (self["type"].value < 15):
         yield UInt32(self, "unknown[]")
         yield UInt32(self, "unknown[]")
         yield UInt32(self, "position", "Position")
         yield UInt32(self, "length", "String Length in bytes")
         yield UInt32(self, "unknown[]")
         yield UInt32(self, "unknown[]")
         yield String(self,
                      "string",
                      self["length"].value,
                      "String Data",
                      charset="UTF-16-LE")
     elif (self["type"].value < 17):
         yield UInt32(self, "unknown[]")
         yield UInt32(self, "unknown[]")
         yield String(self,
                      "string",
                      self._size / 8 - self["header_length"].value,
                      "String Data",
                      charset="UTF-8")
     elif (self["type"].value == 52):
         yield UInt32(self, "unknown[]", "unk1")
         yield UInt32(self, "unknown[]", "unk2")
         yield Enum(UInt32(self, "sort_index_type", "Sort Index Type"),
                    self.mhod52_sort_index_type_name)
         yield UInt32(self, "entry_count", "Entry Count")
         indexes_size = self["entry_count"].value * 4
         padding_offset = self["entry_length"].value - indexes_size
         padding = self.seekByte(padding_offset, "header padding")
         if padding:
             yield padding
         for i in xrange(self["entry_count"].value):
             yield UInt32(self, "index[" + str(i) + "]",
                          "Index of the " + str(i) + "nth mhit")
     else:
         padding = self.seekByte(self["header_length"].value,
                                 "header padding")
         if padding:
             yield padding
     padding = self.seekBit(self._size, "entry padding")
     if padding:
         yield padding
 def createFields(self):
     if self.stream.readBytes(self.absolute_address, 5) != "Adobe":
         yield RawBytes(self, "raw", self.size // 8, "Raw data")
         return
     yield String(self, "adobe", 5, "\"Adobe\" string", charset="ASCII")
     yield UInt16(self, "version", "DCT encoder version")
     yield Enum(Bit(self, "flag00"), {
         False: "Chop down or subsampling",
         True: "Blend"
     })
     yield NullBits(self, "flags0_reserved", 15)
     yield NullBytes(self, "flags1", 2)
     yield Enum(
         UInt8(self, "color_transform", "Colorspace transformation code"),
         self.COLORSPACE_TRANSFORMATION)
Пример #6
0
 def createFields(self):
     yield Enum(Bits(self, "class", 2), self.CLASS_DESC)
     yield Enum(Bit(self, "form"), self.FORM_DESC)
     if self['class'].value == 0:
         yield Enum(Bits(self, "type", 5), self.TYPE_DESC)
     else:
         yield Bits(self, "type", 5)
     yield ASNInteger(self, "size", "Size in bytes")
     size = self["size"].value
     if size:
         if self._handler:
             for field in self._handler(self, size):
                 yield field
         else:
             yield RawBytes(self, "raw", size)
Пример #7
0
 def createFields(self):
     yield UInt32(self, "hdr_size", "Header size (in bytes) (=40)")
     yield UInt32(self, "width", "Width")
     yield UInt32(self, "height", "Height")
     yield UInt16(self, "nb_planes", "Color planes")
     yield UInt16(self, "bpp", "Bits/pixel")
     if self._use_fourcc:
         yield Enum(String(self, "codec", 4, charset="ASCII"), video_fourcc_name)
     else:
         yield Enum(UInt32(self, "codec", "Compression"), self.COMPRESSION_NAME)
     yield UInt32(self, "size", "Image size (in bytes)")
     yield UInt32(self, "xres", "X pixels per meter")
     yield UInt32(self, "yres", "Y pixels per meter")
     yield UInt32(self, "color_used", "Number of used colors")
     yield UInt32(self, "color_important", "Number of important colors")
 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")
Пример #9
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)
Пример #10
0
    def createFields(self):
        yield String(self,
                     "signature",
                     4,
                     'Format signature (".snd")',
                     charset="ASCII")
        yield UInt32(self, "data_ofs", "Data offset")
        yield filesizeHandler(UInt32(self, "data_size", "Data size"))
        yield Enum(UInt32(self, "codec", "Audio codec"), self.CODEC_NAME)
        yield displayHandler(
            UInt32(self, "sample_rate", "Number of samples/second"),
            humanFrequency)
        yield UInt32(self, "channels", "Number of interleaved channels")

        size = self["data_ofs"].value - self.current_size // 8
        if 0 < size:
            yield String(self,
                         "info",
                         size,
                         "Information",
                         strip=" \0",
                         charset="ISO-8859-1")

        size = min(self["data_size"].value,
                   (self.size - self.current_size) // 8)
        yield RawBytes(self, "audio_data", size, "Audio data")
Пример #11
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, "Unknown field data")
Пример #12
0
    def createFields(self):
        # Header
        yield String(self, "magic", 3, "File magic code", charset="ASCII")
        yield String(self, "version", 3, "GIF version", charset="ASCII")

        yield ScreenDescriptor(self, "screen")
        if self["screen/global_map"].value:
            bpp = (self["screen/bpp"].value + 1)
            yield PaletteRGB(self, "color_map", 1 << bpp, "Color map")
            self.color_map = self["color_map"]
        else:
            self.color_map = None

        self.images = []
        while True:
            code = Enum(Character(self, "separator[]", "Separator code"),
                        self.separator_name)
            yield code
            code = code.value
            if code == "!":
                yield Extension(self, "extensions[]")
            elif code == ",":
                yield Image(self, "image[]")
            elif code == ";":
                # GIF Terminator
                break
            else:
                raise ParserError("Wrong GIF image separator: 0x%02X" %
                                  ord(code))
Пример #13
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")
Пример #14
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)
Пример #15
0
    def createFields(self):
        yield Bit(self, "has_private")
        yield Bit(self, "has_pack_lgth")
        yield Bit(self, "has_pack_seq")
        yield Bit(self, "has_pstd_buffer")
        yield Bits(self, "sync[]", 3)  # =7
        yield Bit(self, "has_extension2")

        if self["has_private"].value:
            yield RawBytes(self, "private", 16)

        if self["has_pack_lgth"].value:
            yield UInt8(self, "pack_lgth")

        if self["has_pack_seq"].value:
            yield Bit(self, "sync[]")  # =True
            yield Bits(self, "pack_seq_counter", 7)
            yield Bit(self, "sync[]")  # =True
            yield Bit(self, "mpeg12_id")
            yield Bits(self, "orig_stuffing_length", 6)

        if self["has_pstd_buffer"].value:
            yield Bits(self, "sync[]", 2)  # =1
            yield Enum(Bit(self, "pstd_buffer_scale"), {
                True: "128 bytes",
                False: "1024 bytes"
            })
            yield Bits(self, "pstd_size", 13)
Пример #16
0
    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)
Пример #17
0
 def createFields(self):
     if self["../.."].name.startswith("doc_summary"):
         enum = self.DOCUMENT_PROPERTY
     else:
         enum = self.COMPONENT_PROPERTY
     yield Enum(UInt32(self, "id"), enum)
     yield UInt32(self, "offset")
Пример #18
0
 def createFields(self):
     yield Bits(self, "unused", 2)
     yield Bit(self, "is_tonable")
     yield Bit(self, "16bits")
     yield Bit(self, "loop_bidir")
     yield Bit(self, "loop")
     yield Enum(Bits(self, "origin", 2), self.TYPES)
Пример #19
0
    def createFields(self):
        yield UInt16(self, "length", "Length of Item ID Entry")
        if not self["length"].value:
            return

        yield Enum(UInt8(self, "type"),self.ITEM_TYPE)
        entrytype=self["type"].value
        if entrytype in (0x1F, 0x2E, 0x70):
            # GUID
            yield RawBytes(self, "dummy", 1, "should be 0x50")
            yield GUID(self, "guid")

        elif entrytype in (0x23, 0x25, 0x29, 0x2F):
            # Drive
            yield String(self, "drive", self["length"].value-3, strip="\0")

        elif entrytype in (0x30, 0x31, 0x32):
            yield RawBytes(self, "dummy", 1, "should be 0x00")
            yield UInt32(self, "size", "size of file; 0 for folders")
            yield DateTimeMSDOS32(self, "date_time", "File/folder date and time")
            yield MSDOSFileAttr16(self, "attribs", "File/folder attributes")
            yield CString(self, "name", "File/folder name")
            if self.root.hasUnicodeNames():
                # Align to 2-bytes
                n = paddingSize(self.current_size//8, 2)
                if n:
                    yield PaddingBytes(self, "pad", n)

                yield UInt16(self, "length_w", "Length of wide struct member")
                yield RawBytes(self, "unknown[]", 6)
                yield DateTimeMSDOS32(self, "creation_date_time", "File/folder creation date and time")
                yield DateTimeMSDOS32(self, "access_date_time", "File/folder last access date and time")
                yield RawBytes(self, "unknown[]", 4)
                yield CString(self, "unicode_name", "File/folder name", charset="UTF-16-LE")
                yield RawBytes(self, "unknown[]", 2)
            else:
                yield CString(self, "name_short", "File/folder short name")

        elif entrytype in (0x41, 0x42, 0x46):
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")
            yield CString(self, "protocol")
            yield RawBytes(self, "unknown[]", 2)

        elif entrytype == 0x47:
            # Whole Network
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")

        elif entrytype == 0xC3:
            # Network Share
            yield RawBytes(self, "unknown[]", 2)
            yield CString(self, "name")
            yield CString(self, "protocol")
            yield CString(self, "description")
            yield RawBytes(self, "unknown[]", 2)

        else:
            yield RawBytes(self, "raw", self["length"].value-3)
Пример #20
0
    def createFields(self):
        yield Enum(UInt8(self, "type"), self.TYPE_DESC)
        yield UInt8(self, "code")
        yield textHandler(UInt16(self, "checksum"), hexadecimal)

        if self['type'].value in (self.ECHO_REQUEST, self.ECHO_REPLY):
            yield UInt16(self, "id")
            yield UInt16(self, "sequence")
 def createFields(self):
     yield Enum(UInt16(self, "type"), self.BLOCK_TYPE)
     if self["type"].value == 0:
         return
     yield UInt16(self, "size")
     size = self["size"].value
     if size:
         yield RawBytes(self, "data", size)
Пример #22
0
 def createFields(self):
     yield Enum(UInt8(self, "id"), ID_INFO)
     while not self.eof:
         addr = self.absolute_address+self.current_size
         uid = self.stream.readBits(addr, 8, LITTLE_ENDIAN)
         if uid == ID_END:
             yield Enum(UInt8(self, "end_marker"), ID_INFO)
             break
         elif uid == ID_PACK_INFO:
             yield PackInfo(self, "pack_info", ID_INFO[ID_PACK_INFO])
         elif uid == ID_UNPACK_INFO:
             yield UnpackInfo(self, "unpack_info", ID_INFO[ID_UNPACK_INFO])
         elif uid == ID_SUBSTREAMS_INFO:
             yield SubStreamInfo(self, "substreams_info", ID_INFO[ID_SUBSTREAMS_INFO])
         else:
             self.info("Unexpected ID (%i)" % uid)
             break
Пример #23
0
    def createFields(self):
        yield String(self, "magic", 4, "Signature (BLP1)")
        yield Enum(UInt32(self, "compression"), {
            0:"JPEG Compression",
            1:"Uncompressed"})
        yield UInt32(self, "flags")
        yield UInt32(self, "width")
        yield UInt32(self, "height")
        yield Enum(UInt32(self, "type"), {
            3:"Uncompressed Index List + Alpha List",
            4:"Uncompressed Index List + Alpha List",
            5:"Uncompressed Index List"})
        yield UInt32(self, "subtype")
        for i in xrange(16):
            yield UInt32(self, "mipmap_offset[]")
        for i in xrange(16):
            yield UInt32(self, "mipmap_size[]")

        compression = self["compression"].value
        image_type = self["type"].value
        width = self["width"].value
        height = self["height"].value

        if compression == 0: # JPEG Compression
            yield UInt32(self, "jpeg_header_len")
            yield RawBytes(self, "jpeg_header", self["jpeg_header_len"].value, "Shared JPEG Header")
        else:
            yield PaletteRGBA(self, "palette", 256)

        offsets = self.array("mipmap_offset")
        sizes = self.array("mipmap_size")
        for i in xrange(16):
            if not offsets[i].value or not sizes[i].value:
                continue
            padding = self.seekByte(offsets[i].value)
            if padding:
                yield padding
            if compression == 0:
                yield RawBytes(self, "mipmap[%i]" % i, sizes[i].value, "JPEG data, append to header to recover complete image")
            elif compression == 1:
                yield Generic2DArray(self, "mipmap_indexes[%i]" % i, width, height, PaletteIndex, "row", "index", "Indexes into the palette")
                if image_type in (3, 4):
                    yield Generic2DArray(self, "mipmap_alphas[%i]" % i, width, height, UInt8, "row", "alpha", "Alpha values")
            width /= 2
            height /= 2
Пример #24
0
 def createFields(self):
     yield String(self, "magic", len(self.MAGIC), 'Magic string (%r)' % self.MAGIC, charset="ASCII")
     yield UInt8(self, "major_version")
     yield UInt8(self, "minor_version")
     yield Enum(UInt8(self, "crypto"), self.CRYPTO_NAMES)
     yield Enum(UInt8(self, "hash"), self.HASH_NAMES)
     yield KeyringString(self, "keyring_name")
     yield TimestampUnix64(self, "mtime")
     yield TimestampUnix64(self, "ctime")
     yield Bit(self, "lock_on_idle")
     yield NullBits(self, "reserved[]", 31, "Reserved for future flags")
     yield UInt32(self, "lock_timeout")
     yield UInt32(self, "hash_iterations")
     yield RawBytes(self, "salt", 8)
     yield NullBytes(self, "reserved[]", 16)
     yield Items(self, "items")
     yield UInt32(self, "encrypted_size")
     yield Deflate(SubFile(self, "encrypted", self["encrypted_size"].value, "AES128 CBC", parser_class=EncryptedData))
Пример #25
0
 def createFields(self):
     yield UInt32(self, "inode", "Inode")
     yield UInt16(self, "rec_len", "Record length")
     yield UInt8(self, "name_len", "Name length")
     yield Enum(UInt8(self, "file_type", "File type"), self.file_type)
     yield String(self, "name", self["name_len"].value, "File name")
     size = (self._size - self.current_size)//8
     if size:
         yield NullBytes(self, "padding", size)
Пример #26
0
 def createFields(self):
     yield Enum(UInt8(self, "id"), ID_INFO)
     bytes = self.stream.readBytes(self.absolute_address, self.num_digests)
     if self.num_digests > 0:
         yield GenericVector(self, "defined[]", self.num_digests, UInt8, "bool")
         for index in xrange(self.num_digests):
             if bytes[index]:
                 yield textHandler(UInt32(self, "hash[]",
                     "Hash for digest %u" % index), hexadecimal)
 def createFields(self):
     if self.version == 1:
         yield TimestampUUID60(self, "time")
         yield Enum(Bits(self, "version", 4), self.VERSION_NAME)
         yield Enum(Bits(self, "variant", 3), self.VARIANT_NAME)
         yield textHandler(Bits(self, "clock", 13), hexadecimal)
         #            yield textHandler(Bits(self, "clock", 16), hexadecimal)
         if self.version == 1:
             yield MAC48_Address(self, "mac", "IEEE 802 MAC address")
         else:
             yield Bytes(self, "node", 6)
     else:
         namea, nameb = self.FIELD_NAMES.get(self.version,
                                             ("data_a", "data_b"))
         yield textHandler(Bits(self, namea, 60), hexadecimal)
         yield Enum(Bits(self, "version", 4), self.VERSION_NAME)
         yield Enum(Bits(self, "variant", 3), self.VARIANT_NAME)
         yield textHandler(Bits(self, nameb, 61), hexadecimal)
Пример #28
0
 def createFields(self):
     yield Bits(self, "width", 12)
     yield Bits(self, "height", 12)
     yield Enum(Bits(self, "aspect", 4), self.ASPECT)
     yield Enum(Bits(self, "frame_rate", 4), self.FRAMERATE)
     yield Bits(self, "bit_rate", 18, "Bit rate in units of 50 bytes")
     yield Bits(self, "sync[]", 1)  # =1
     yield Bits(self, "vbv_size", 10,
                "Video buffer verifier size, in units of 16768")
     yield Bit(self, "constrained_params_flag")
     yield Bit(self, "has_intra_quantizer")
     if self["has_intra_quantizer"].value:
         for i in range(64):
             yield Bits(self, "intra_quantizer[]", 8)
     yield Bit(self, "has_non_intra_quantizer")
     if self["has_non_intra_quantizer"].value:
         for i in range(64):
             yield Bits(self, "non_intra_quantizer[]", 8)
Пример #29
0
 def createFields(self):
     yield Bits(self, "sync", 14, "Sync code: 11111111111110")
     yield Bit(self, "reserved[]")
     yield Bit(self, "blocking_strategy")
     yield Bits(self, "block_size", 4)
     yield Enum(Bits(self, "sample_rate", 4), self.SAMPLE_RATES)
     yield Bits(self, "channel_assign", 4)
     yield Bits(self, "sample_size", 3)
     yield Bit(self, "reserved[]")
Пример #30
0
 def createFields(self):
     yield UInt32(self, "inodes_count", "Inodes count")
     yield UInt32(self, "blocks_count", "Blocks count")
     yield UInt32(self, "r_blocks_count", "Reserved blocks count")
     yield UInt32(self, "free_blocks_count", "Free blocks count")
     yield UInt32(self, "free_inodes_count", "Free inodes count")
     yield UInt32(self, "first_data_block", "First data block")
     yield UInt32(self, "log_block_size", "Block size")
     yield UInt32(self, "log_frag_size", "Fragment size")
     yield UInt32(self, "blocks_per_group", "Blocks per group")
     yield UInt32(self, "frags_per_group", "Fragments per group")
     yield UInt32(self, "inodes_per_group", "Inodes per group")
     yield TimestampUnix32(self, "mtime", "Mount time")
     yield TimestampUnix32(self, "wtime", "Write time")
     yield UInt16(self, "mnt_count", "Mount count")
     yield UInt16(self, "max_mnt_count", "Max mount count")
     yield String(self, "magic", 2, "Magic number (0x53EF)")
     yield Enum(UInt16(self, "state", "File system state"), self.state_desc)
     yield Enum(UInt16(self, "errors", "Behaviour when detecting errors"), self.error_handling_desc)
     yield UInt16(self, "minor_rev_level", "Minor revision level")
     yield TimestampUnix32(self, "last_check", "Time of last check")
     yield textHandler(UInt32(self, "check_interval", "Maximum time between checks"), self.postMaxTime)
     yield Enum(UInt32(self, "creator_os", "Creator OS"), self.os_name)
     yield UInt32(self, "rev_level", "Revision level")
     yield UInt16(self, "def_resuid", "Default uid for reserved blocks")
     yield UInt16(self, "def_resgid", "Default gid for reserved blocks")
     yield UInt32(self, "first_ino", "First non-reserved inode")
     yield UInt16(self, "inode_size", "Size of inode structure")
     yield UInt16(self, "block_group_nr", "Block group # of this superblock")
     yield UInt32(self, "feature_compat", "Compatible feature set")
     yield UInt32(self, "feature_incompat", "Incompatible feature set")
     yield UInt32(self, "feature_ro_compat", "Read-only compatible feature set")
     yield RawBytes(self, "uuid", 16, "128-bit uuid for volume")
     yield String(self, "volume_name", 16, "Volume name", strip="\0")
     yield String(self, "last_mounted", 64, "Directory where last mounted", strip="\0")
     yield UInt32(self, "compression", "For compression (algorithm usage bitmap)")
     yield UInt8(self, "prealloc_blocks", "Number of blocks to try to preallocate")
     yield UInt8(self, "prealloc_dir_blocks", "Number to preallocate for directories")
     yield UInt16(self, "padding", "Padding")
     yield String(self, "journal_uuid", 16, "uuid of journal superblock")
     yield UInt32(self, "journal_inum", "inode number of journal file")
     yield UInt32(self, "journal_dev", "device number of journal file")
     yield UInt32(self, "last_orphan", "start of list of inodes to delete")
     yield RawBytes(self, "reserved", 197, "Reserved")