Example #1
0
 def createFields(self):
     # This stupid shit gets the LSB, not the MSB...
     self.info(
         "Note info: 0x%02X" %
         self.stream.readBits(self.absolute_address, 8, LITTLE_ENDIAN))
     yield RealBit(self, "is_extended")
     if self["is_extended"].value:
         info = NoteInfo(self, "info")
         yield info
         if info["has_note"].value:
             yield Enum(UInt8(self, "note"), NOTE_NAME)
         if info["has_instrument"].value:
             yield UInt8(self, "instrument")
         if info["has_volume"].value:
             yield textHandler(UInt8(self, "volume"), parseVolume)
         if info["has_type"].value:
             yield Effect(self, "effect_type")
         if info["has_parameter"].value:
             yield textHandler(UInt8(self, "effect_parameter"), hexadecimal)
     else:
         yield Enum(Bits(self, "note", 7), NOTE_NAME)
         yield UInt8(self, "instrument")
         yield textHandler(UInt8(self, "volume"), parseVolume)
         yield Effect(self, "effect_type")
         yield textHandler(UInt8(self, "effect_parameter"), hexadecimal)
Example #2
0
 def createFields(self):
     yield Bit(self, "sync[]")  # =True
     yield Bits(self, "ext_length", 7)
     yield NullBits(self, "reserved[]", 8)
     size = self["ext_length"].value
     if size:
         yield RawBytes(self, "ext_bytes", size)
Example #3
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")
Example #4
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
Example #5
0
def parseDefineSound(parent, size):
    yield UInt16(parent, "sound_id")

    yield Bit(parent, "is_stereo")
    yield Bit(parent, "is_16bit")
    yield textHandler(Bits(parent, "rate", 2), bit2hertz)
    yield Enum(Bits(parent, "codec", 4), SOUND_CODEC)

    yield UInt32(parent, "sample_count")

    if parent["codec"].value == SOUND_CODEC_MP3:
        yield UInt16(parent, "len")

    size = (parent.size - parent.current_size) // 8
    if size:
        yield RawBytes(parent, "music_data", size)
Example #6
0
 def createFields(self):
     for name in ['arctime', 'atime', 'ctime', 'mtime']:
         yield Bits(self, "%s_count" % name, 2, "Number of %s bytes" % name)
         yield Bit(self, "%s_onesec" % name,
                   "Add one second to the timestamp?")
         yield Bit(self, "%s_present" % name,
                   "Is %s extra time present?" % name)
Example #7
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)")
Example #8
0
 def createFields(self):
     yield Bits(self, "quantizer_scale", 5)
     start = self.absolute_address + self.current_size + 3
     pos = self.stream.searchBytes(
         '\0\0\1', start,
         start + 1024 * 1024 * 8)  # seek forward by at most 1MB
     if pos is None: pos = self.root.size
     yield RawBits(self, "data", pos - start + 3)
Example #9
0
 def createFields(self):
     yield textHandler(UInt8(self, "sync", 8), hexadecimal)
     if self["sync"].value != 0x47:
         raise ParserError("MPEG-2 TS: Invalid synchronization byte")
     yield Bit(self, "has_error")
     yield Bit(self, "payload_unit_start")
     yield Bit(self, "priority")
     yield Enum(
         textHandler(Bits(self, "pid", 13, "Program identifier"),
                     hexadecimal), self.PID)
     yield Bits(self, "scrambling_control", 2)
     yield Bit(self, "has_adaptation")
     yield Bit(self, "has_payload")
     yield Bits(self, "counter", 4)
     yield RawBytes(self, "payload", 184)
     if self["has_error"].value:
         yield RawBytes(self, "error_correction", 16)
Example #10
0
 def createFields(self):
     yield UInt16(self, "width", "Width")
     yield UInt16(self, "height", "Height")
     yield Bits(self, "size_global_map", 3,
                "log2(size of global map) minus one")
     yield Bit(self, "sort_flag",
               "Is the global map sorted by decreasing importance?")
     yield Bits(self, "color_res", 3, "Color resolution minus one")
     yield Bit(self, "global_map", "Has global map?")
     yield UInt8(self, "background", "Background color")
     field = UInt8(self, "pixel_aspect_ratio")
     if field.value:
         field._description = "Pixel aspect ratio: %f (stored as %i)" % (
             (field.value + 15) / 64., field.value)
     else:
         field._description = "Pixel aspect ratio: not specified"
     yield field
    def createFields(self):
        # Header
        yield PaddingBits(self,
                          "sync",
                          11,
                          "Synchronize bits (set to 1)",
                          pattern=1)
        yield Enum(Bits(self, "version", 2, "MPEG audio version"),
                   self.VERSION_NAME)
        yield Enum(Bits(self, "layer", 2, "MPEG audio layer"), self.LAYER_NAME)
        yield Bit(self, "crc16", "No CRC16 protection?")

        # Rates and padding
        yield Bits(self, "bit_rate", 4, "Bit rate")
        yield Bits(self, "sampling_rate", 2, "Sampling rate")
        yield Bit(self, "use_padding", "Stream field use padding?")
        yield Bit(self, "extension", "Extension")

        # Channel mode, mode extension, copyright, ...
        yield Enum(Bits(self, "channel_mode", 2, "Channel mode"),
                   self.CHANNEL_MODE_NAME)
        yield Bits(self, "mode_ext", 2, "Mode extension")
        yield Bit(self, "copyright", "Is copyrighted?")
        yield Bit(self, "original", "Is original?")
        yield Enum(Bits(self, "emphasis", 2, "Emphasis"), self.EMPHASIS_NAME)

        size = (self.size - self.current_size) / 8
        if size:
            yield RawBytes(self, "data", size)
Example #12
0
 def createFields(self):
     yield UInt8(self, "size",
                 "Total length of this FFN in bytes, minus 1")
     self._size = self["size"].value * 8 + 8
     yield Bits(self, "prq", 2, "Pitch request")
     yield Bit(self, "fTrueType", "Is font a TrueType font?")
     yield Bits(self, "reserved[]", 1)
     yield Bits(self, "ff", 3, "Font Family ID")
     yield Bits(self, "reserved[]", 1)
     yield UInt16(self, "wWeight", "Base weight of font")
     yield UInt8(self, "chs", "Character set identifier")
     yield UInt8(self, "ixchSzAlt",
                 "Index into name to the name of the alternate font")
     yield RawBytes(self, "panose", 10)
     yield RawBytes(self, "fs", 24, "Font Signature")
     yield CString(self, "name", charset="UTF-16-LE")
     if self["ixchSzAlt"].value != 0:
         yield CString(self, "nameAlt", charset="UTF-16-LE")
Example #13
0
 def createFields(self):
     yield UInt8(self, "version", "Version")
     yield Bits(self, "flags", 24, "Flags (=1)")
     graphics = UInt16(self, "graphicsmode")
     graphics.createDisplay = lambda: self.graphicsDisplay(graphics)
     graphics.createDescription = lambda: self.graphicsDescription(graphics)
     yield graphics
     yield UInt16(self, "op_red", "Red value for graphics mode")
     yield UInt16(self, "op_green", "Green value for graphics mode")
     yield UInt16(self, "op_blue", "Blue value for graphics mode")
Example #14
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")
Example #15
0
 def createFields(self):
     # http://www.w3.org/Graphics/JPEG/itu-t81.pdf, page 40-41
     yield Enum(Bits(self, "table_class", 4, "Table class"), {
         0:"DC or Lossless Table",
         1:"AC Table"})
     yield Bits(self, "index", 4, "Huffman table destination identifier")
     for i in xrange(1, 17):
         yield UInt8(self, "count[%i]" % i, "Number of codes of length %i" % i)
     lengths = []
     remap = {}
     for i in xrange(1, 17):
         for j in xrange(self["count[%i]" % i].value):
             field = UInt8(self, "value[%i][%i]" % (i, j), "Value of code #%i of length %i" % (j, i))
             yield field
             remap[len(lengths)] = field.value
             lengths.append(i)
     self.tree = {}
     for i,j in build_tree(lengths).iteritems():
         self.tree[i] = remap[j]
Example #16
0
 def createFields(self):
     yield UInt8(self, "size")
     self._size = (self['size'].value+1)*8
     yield Enum(UInt8(self, "type"), self.STREAMTYPE)
     if self['type'].display.startswith('V'): # Video
         yield Enum(Bits(self, "resolution", 4), {1:'480i', 2:'576i', 3:'480p', 4:'1080i', 5:'720p', 6:'1080p', 7:'576p'})
         yield Enum(Bits(self, "fps", 4), {1:'24/1.001', 2:'24', 3:'25', 4:'30/1.001', 6:'50', 7:'60/1.001'})
         yield Enum(UInt8(self, "aspect_ratio"), {0x20:'4:3', 0x30:'16:9'})
     elif self['type'].display.startswith('A'): # Audio
         yield Enum(Bits(self, "channel_layout", 4), {1:'Mono', 3:'Stereo', 6:'Multi', 12:'Combi'})
         yield Enum(Bits(self, "sample_rate", 4), {1:'48KHz', 4:'96KHz', 5:'192KHz', 12:'48-192KHz', 14:'48-96KHz'})
         yield Enum(String(self, "language", 3), ISO639_2)
     elif self['type'].display.startswith('T'): # Text subtitle
         yield UInt8(self, "unknown[]")
         yield Enum(String(self, "language", 3), ISO639_2)
     elif self['type'].display.startswith('S'): # Graphics
         yield Enum(String(self, "language", 3), ISO639_2)
     else:
         pass
Example #17
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)
Example #18
0
    def createFields(self):
        yield displayHandler(UInt32(self, "res_space", "Reserved space"), humanFilesize)
        yield displayHandler(UInt32(self, "used_space", "Used space"), humanFilesize)
        yield Bits(self, "file_flags", 8, "(=4)")

        yield textHandler(UInt16(self, "magic"), hexadecimal)
        yield Bits(self, "flags", 16)
        yield displayHandler(UInt16(self, "page_size", "Page size in bytes"), humanFilesize)
        yield String(self, "structure", 16, strip="\0", charset="ASCII")
        yield NullBytes(self, "zero", 2)
        yield UInt16(self, "nb_page_splits", "Number of page splits B+ tree has suffered")
        yield UInt16(self, "root_page", "Page number of B+ tree root page")
        yield PaddingBytes(self, "one", 2, pattern="\xFF")
        yield UInt16(self, "nb_page", "Number of B+ tree pages")
        yield UInt16(self, "nb_level", "Number of levels of B+ tree")
        yield UInt16(self, "nb_entry", "Number of entries in B+ tree")

        size = (self.size - self.current_size)//8
        if size:
            yield PaddingBytes(self, "reserved_space", size)
Example #19
0
    def createFields(self):
        yield IntVbe(self, "lat_diff")
        yield IntVbe(self, "lon_diff")
        yield Bits(self, "layer", 4)
        yield Bits(self, "num_tags", 4)

        for i in range(self["num_tags"].value):
            yield UIntVbe(self, "tag_id[]")

        yield Bit(self, "have_name")
        yield Bit(self, "have_house_number")
        yield Bit(self, "have_ele")
        yield PaddingBits(self, "pad[]", 5)

        if self["have_name"].value:
            yield VbeString(self, "name")
        if self["have_house_number"].value:
            yield VbeString(self, "house_number")
        if self["have_ele"].value:
            yield IntVbe(self, "ele")
Example #20
0
    def createFields(self):
        yield Bits(self, "sync[]", 2)  # =2
        if self["sync[0]"].value != 2:
            raise ParserError("Unknown video elementary data")
        yield Bits(self, "is_scrambled", 2)
        yield Bits(self, "priority", 1)
        yield Bit(self, "alignment")
        yield Bit(self, "is_copyrighted")
        yield Bit(self, "is_original")
        yield Bit(self, "has_pts", "Presentation Time Stamp")
        yield Bit(self, "has_dts", "Decode Time Stamp")
        yield Bit(self, "has_escr", "Elementary Stream Clock Reference")
        yield Bit(self, "has_es_rate", "Elementary Stream rate")
        yield Bit(self, "dsm_trick_mode")
        yield Bit(self, "has_copy_info")
        yield Bit(self, "has_prev_crc",
                  "If True, previous PES packet CRC follows")
        yield Bit(self, "has_extension")
        yield UInt8(self, "size")

        # Time stamps
        if self["has_pts"].value:
            yield Bits(self, "sync[]", 4)  # =2, or 3 if has_dts=True
            yield Timestamp(self, "pts")
        if self["has_dts"].value:
            if not (self["has_pts"].value):
                raise ParserError("Invalid PTS/DTS values")
            yield Bits(self, "sync[]", 4)  # =1
            yield Timestamp(self, "dts")

        if self["has_escr"].value:
            yield Bits(self, "sync[]", 2)  # =0
            yield SCR(self, "escr")

        if self["has_es_rate"].value:
            yield Bit(self, "sync[]")  # =True
            yield Bits(self, "es_rate", 14)  # in units of 50 bytes/second
            yield Bit(self, "sync[]")  # =True

        if self["has_copy_info"].value:
            yield Bit(self, "sync[]")  # =True
            yield Bits(self, "copy_info", 7)

        if self["has_prev_crc"].value:
            yield textHandler(UInt16(self, "prev_crc"), hexadecimal)

        # --- Extension ---
        if self["has_extension"].value:
            yield VideoExtension1(self, "extension")
            if self["extension/has_extension2"].value:
                yield VideoExtension2(self, "extension2")
Example #21
0
 def createFields(self):
     yield UInt8(self, "bootable", "Bootable flag (true if equals to 0x80)")
     if self["bootable"].value not in (0x00, 0x80):
         self.warning(
             "Stream doesn't look like master boot record (partition bootable error)!"
         )
     yield UInt8(self, "start_head",
                 "Starting head number of the partition")
     yield Bits(self, "start_sector", 6,
                "Starting sector number of the partition")
     yield CylinderNumber(self, "start_cylinder",
                          "Starting cylinder number of the partition")
     yield Enum(UInt8(self, "system", "System indicator"), self.system_name)
     yield UInt8(self, "end_head", "Ending head number of the partition")
     yield Bits(self, "end_sector", 6,
                "Ending sector number of the partition")
     yield CylinderNumber(self, "end_cylinder",
                          "Ending cylinder number of the partition")
     yield UInt32(self, "LBA",
                  "LBA (number of sectors before this partition)")
     yield UInt32(self, "size", "Size (block count)")
Example #22
0
 def createFields(self):
     yield ExtTimeFlags(self, "time_flags")
     for name in ['mtime', 'ctime', 'atime', 'arctime']:
         if self['time_flags/%s_present' % name].value:
             if name != 'mtime':
                 yield TimeDateMSDOS32(self, "%s" % name,
                                       "%s DOS timestamp" % name)
             count = self['time_flags/%s_count' % name].value
             if count:
                 yield Bits(
                     self, "%s_remainder" % name, 8 * count,
                     "%s extra precision time (in 100ns increments)" % name)
Example #23
0
 def createFields(self):
     yield GUID(self, "type")
     yield GUID(self, "error_correction")
     yield UInt64(self, "time_offset")
     yield UInt32(self, "data_len")
     yield UInt32(self, "error_correct_len")
     yield Bits(self, "stream_index", 7)
     yield Bits(self, "reserved[]", 8)
     yield Bit(self, "encrypted", "Content is encrypted?")
     yield UInt32(self, "reserved[]")
     size = self["data_len"].value
     if size:
         tag = self["type"].value
         if tag in Object.TAG_INFO:
             name, parser = Object.TAG_INFO[tag][0:2]
             yield parser(self, name, size=size * 8)
         else:
             yield RawBytes(self, "data", size)
     size = self["error_correct_len"].value
     if size:
         yield RawBytes(self, "error_correct", size)
Example #24
0
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)")
Example #25
0
 def createFields(self):
     yield UInt8(self, "version")
     yield NullBits(self, "flags", 24)
     yield NullBits(self, "reserved[]", 24)
     yield UInt8(self, "field_size",
                 "Size of each entry in this table, in bits")
     yield UInt32(self, "count", description="Number of samples")
     bitsize = self['field_size'].value
     for i in xrange(self['count'].value):
         yield Bits(self, "sample_size[]", bitsize)
     if self.current_size % 8 != 0:
         yield NullBits(self, "padding[]", 8 - (self.current_size % 8))
Example #26
0
 def createFields(self):
     # This tag has too many variant forms.
     if '/tags/' in self.path:
         yield UInt32(self, "count")
         for i in xrange(self['count'].value):
             yield METATAG(self, "tag[]")
     elif self.stream.readBits(self.absolute_address, 32, self.endian) == 0:
         yield UInt8(self, "version")
         yield Bits(self, "flags", 24)
         yield AtomList(self, "tags")
     else:
         yield AtomList(self, "tags")
Example #27
0
 def createFields(self):
     yield Bits(self, "day", 5)
     yield Bits(self, "month", 4)
     yield Bits(self, "year", 7, "Number of year after 1980")
     yield Bits(self, "second", 5, "Second/2")
     yield Bits(self, "minute", 6)
     yield Bits(self, "hour", 5)
Example #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)
    def createFields(self):
        # File mode
        yield Bit(self, "other_exec")
        yield Bit(self, "other_write")
        yield Bit(self, "other_read")
        yield Bit(self, "group_exec")
        yield Bit(self, "group_write")
        yield Bit(self, "group_read")
        yield Bit(self, "owner_exec")
        yield Bit(self, "owner_write")
        yield Bit(self, "owner_read")
        yield Bit(self, "sticky")
        yield Bit(self, "setgid")
        yield Bit(self, "setuid")
        yield Enum(Bits(self, "file_type", 4), self.file_type)

        yield UInt16(self, "uid", "User ID")
        yield UInt32(self, "size", "File size (in bytes)")
        yield TimestampUnix32(self, "atime", "Last access time")
        yield TimestampUnix32(self, "ctime", "Creation time")
        yield TimestampUnix32(self, "mtime", "Last modification time")
        yield TimestampUnix32(self, "dtime", "Delete time")
        yield UInt16(self, "gid", "Group ID")
        yield UInt16(self, "links_count", "Links count")
        yield UInt32(self, "blocks", "Number of blocks")
        yield UInt32(self, "flags", "Flags")
        yield NullBytes(self, "reserved[]", 4, "Reserved")
        for index in xrange(15):
            yield UInt32(self, "block[]")
        yield UInt32(self, "version", "Version")
        yield UInt32(self, "file_acl", "File ACL")
        yield UInt32(self, "dir_acl", "Directory ACL")
        yield UInt32(self, "faddr",
                     "Block where the fragment of the file resides")

        os = self["/superblock/creator_os"].value
        if os == SuperBlock.OS_LINUX:
            yield UInt8(self, "frag", "Number of fragments in the block")
            yield UInt8(self, "fsize", "Fragment size")
            yield UInt16(self, "padding", "Padding")
            yield UInt16(self, "uid_high", "High 16 bits of user ID")
            yield UInt16(self, "gid_high", "High 16 bits of group ID")
            yield NullBytes(self, "reserved[]", 4, "Reserved")
        elif os == SuperBlock.OS_HURD:
            yield UInt8(self, "frag", "Number of fragments in the block")
            yield UInt8(self, "fsize", "Fragment size")
            yield UInt16(self, "mode_high", "High 16 bits of mode")
            yield UInt16(self, "uid_high", "High 16 bits of user ID")
            yield UInt16(self, "gid_high", "High 16 bits of group ID")
            yield UInt32(self, "author", "Author ID (?)")
        else:
            yield RawBytes(self, "raw", 12, "Reserved")
Example #30
0
 def createFields(self):
     yield Bits(self, "action_id", 8)
     if not (self["action_id"].value & 128):
         return
     yield UInt16(self, "action_length")
     size = self["action_length"].value
     if not size:
         return
     if self.parser:
         for field in self.parser(self, size):
             yield field
     else:
         yield RawBytes(self, "action_data", size)