def __init__(self, *args): FieldSet.__init__(self, *args) self._size = self["size"].value * 8 type = self["type"].value if type in self.ATTR_INFO: self._name = self.ATTR_INFO[type][0] self._parser = self.ATTR_INFO[type][2]
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) value = 0 for field in self: value <<= 15 value += (field.value & 0x7fff) self.createValue = lambda: value
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) key = self["type"].value & 31 if self['class'].value == 0: # universal object if key in self.TYPE_INFO: self._name, self._handler, self._description, create_desc = self.TYPE_INFO[key] if create_desc: self.createDescription = lambda: "%s: %s" % (self.TYPE_INFO[key][2], create_desc(self)) self._description = None elif key == 31: raise ParserError("ASN.1 Object: tag bigger than 30 are not supported") else: self._handler = None elif self['form'].value: # constructed: treat as sequence self._name = 'seq[]' self._handler = readSequence self._description = 'constructed object type %i' % key else: # primitive, context/private self._name = 'raw[]' self._handler = readASCIIString self._description = '%s object type %i' % (self['class'].display, key) field = self["size"] self._size = field.address + field.size + field.value*8
def __init__(self, *args): FieldSet.__init__(self, *args) tag = self["tag"].value if tag in self.TAG_INFO: self._name, self._description = self.TAG_INFO[tag] else: self._parser = None
def __init__(self, parent, name, desc=None): FieldSet.__init__(self, parent, name, desc) pos = self.stream.searchBytesLength(CrossReferenceTable.MAGIC, False) if pos == None: raise ParserError("Can't find xref starting at %u" % (self.absolute_address // 8)) self._size = 8 * pos - self.absolute_address
def __init__(self, parent, name, desc=None): FieldSet.__init__(self, parent, name, description=desc) pos = self.stream.searchBytesLength(Trailer.MAGIC, False) if pos == None: raise ParserError("Can't find '%s' starting at %u" \ (Trailer.MAGIC, self.absolute_address//8)) self._size = 8 * pos - self.absolute_address
def __init__(self, parent, name, **kw): FieldSet.__init__(self, parent, name, **kw) code = self["bytecode"].value if code not in self.bytecode_info: raise ParserError('Unknown bytecode: "%s"' % code) self.code_info = self.bytecode_info[code] if not name: self._name = self.code_info[0] if code == "l": self.createValue = self.createValueLong elif code in ("i", "I", "f", "g"): self.createValue = lambda: self["value"].value elif code == "T": self.createValue = lambda: True elif code == "F": self.createValue = lambda: False elif code in ("x", "y"): self.createValue = self.createValueComplex elif code in ("s", "t", "u"): self.createValue = self.createValueString self.createDisplay = self.createDisplayString if code == 't': if not hasattr(self.root,'string_table'): self.root.string_table=[] self.root.string_table.append(self) elif code == 'R': if hasattr(self.root,'string_table'): self.createValue = self.createValueStringRef
def __init__(self, parent, name, width, height, item_class, row_name="row", item_name="item", *args, **kwargs): FieldSet.__init__(self, parent, name, *args, **kwargs) self.width = width self.height = height self.item_class = item_class self.row_name = row_name self.item_name = item_name
def __init__(self, parent, name, toc, description, size=None): FieldSet.__init__(self, parent, name, description, size=size) self.toc = toc if self["format/byte_big_endian"].value: self.endian = BIG_ENDIAN else: self.endian = LITTLE_ENDIAN
def __init__(self, *args): FieldSet.__init__(self, *args) code = self["code"].value if code in self.ext_code: self._name, self.parser, self._description = self.ext_code[code] else: self.parser = defaultExtensionParser
def __init__(self, parent, ids): FieldSet.__init__(self, parent, "?[]") # Set name id = self['id'].value self.val = ids.get(id) if not self.val: if id == 0xBF: self.val = 'CRC-32[]', Binary elif id == 0xEC: self.val = 'Void[]', Binary elif id == 0x1B538667: self.val = 'SignatureSlot[]', signature else: self.val = 'Unknown[]', Binary self._name = self.val[0] # Compute size size = self['size'] if size.value is not None: self._size = size.address + size.size + size.value * 8 elif self._parent._parent: raise ParserError("Unknown length (only allowed for the last Level 0 element)") elif self._parent._size is not None: self._size = self._parent._size - self.address
def __init__(self, *args): FieldSet.__init__(self, *args) if not hasattr(self.root,'streamgroups'): self.root.streamgroups={} for tag in range(0xBC, 0x100): self.root.streamgroups[tag]=None tag = self["tag"].value if tag in self.tag_info: self._name, self.parser, self._description = self.tag_info[tag] elif 0xBC <= tag <= 0xFF: if 0xC0 <= tag < 0xE0: # audio streamid = tag-0xC0 self._name, self.parser, self._description = ("audio[%i][]"%streamid, Stream, "Audio Stream %i Packet"%streamid) elif 0xE0 <= tag < 0xF0: # video streamid = tag-0xE0 self._name, self.parser, self._description = ("video[%i][]"%streamid, Stream, "Video Stream %i Packet"%streamid) else: self._name, self.parser, self._description = ("stream[]", Stream, "Data Stream Packet") else: self.parser = defaultParser if not self.parser: self.parser = defaultParser elif self.parser != PackHeader and "length" in self: self._size = (6 + self["length"].value) * 8
def __init__(self, parent, name, desc=None): FieldSet.__init__(self, parent, name, desc) pos = self.stream.searchBytesLength(CrossReferenceTable.MAGIC, False) if pos == None: raise ParserError("Can't find xref starting at %u" % (self.absolute_address//8)) self._size = 8*pos-self.absolute_address
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) if not self._size: frame_size = self.getFrameSize() if not frame_size: raise ParserError("MPEG audio: Invalid frame %s" % self.path) self._size = min(frame_size * 8, self.parent.size - self.address)
def __init__(self, parent, name, desc=None): FieldSet.__init__(self, parent, name, description=desc) pos = self.stream.searchBytesLength(Trailer.MAGIC, False) if pos == None: raise ParserError("Can't find '%s' starting at %u" \ (Trailer.MAGIC, self.absolute_address//8)) self._size = 8*pos-self.absolute_address
def __init__(self, *args): FieldSet.__init__(self, *args) self._size = self["size"].value * 8 type = self["type"].value if type in self.ATTR_INFO: self._name = self.ATTR_INFO[type][0] self._parser = self.ATTR_INFO[type][2]
def __init__(self, parent, name, toc, description, size=None): FieldSet.__init__(self, parent, name, description, size=size) self.toc = toc if self["format/byte_big_endian"].value: self.endian = BIG_ENDIAN else: self.endian = LITTLE_ENDIAN
def __init__(self, *args): FieldSet.__init__(self, *args) code = self["code"].value if code in self.ext_code: self._name, self.parser, self._description = self.ext_code[code] else: self.parser = defaultExtensionParser
def __init__(self, *args): FieldSet.__init__(self, *args) tag = self["tag"].value if tag in self.TAG_INFO: self._name, self._description = self.TAG_INFO[tag] else: self._parser = None
def __init__(self, parent, name, description=None, size=None): FieldSet.__init__(self, parent, name, description=description, size=size) BaseSummary.__init__(self)
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) key = self["type"].value & 31 if self['class'].value == 0: # universal object if key in self.TYPE_INFO: self._name, self._handler, self._description, create_desc = self.TYPE_INFO[ key] if create_desc: self.createDescription = lambda: "%s: %s" % ( self.TYPE_INFO[key][2], create_desc(self)) self._description = None elif key == 31: raise ParserError( "ASN.1 Object: tag bigger than 30 are not supported") else: self._handler = None elif self['form'].value: # constructed: treat as sequence self._name = 'seq[]' self._handler = readSequence self._description = 'constructed object type %i' % key else: # primitive, context/private self._name = 'raw[]' self._handler = readASCIIString self._description = '%s object type %i' % (self['class'].display, key) field = self["size"] self._size = field.address + field.size + field.value * 8
def __init__(self, *args): FieldSet.__init__(self, *args) if not hasattr(self.root, 'streamgroups'): self.root.streamgroups = {} for tag in range(0xBC, 0x100): self.root.streamgroups[tag] = None tag = self["tag"].value if tag in self.tag_info: self._name, self.parser, self._description = self.tag_info[tag] elif 0xBC <= tag <= 0xFF: if 0xC0 <= tag < 0xE0: # audio streamid = tag - 0xC0 self._name, self.parser, self._description = ( "audio[%i][]" % streamid, Stream, "Audio Stream %i Packet" % streamid) elif 0xE0 <= tag < 0xF0: # video streamid = tag - 0xE0 self._name, self.parser, self._description = ( "video[%i][]" % streamid, Stream, "Video Stream %i Packet" % streamid) else: self._name, self.parser, self._description = ( "stream[]", Stream, "Data Stream Packet") else: self.parser = defaultParser if not self.parser: self.parser = defaultParser elif self.parser != PackHeader and "length" in self: self._size = (6 + self["length"].value) * 8
def __init__(self, *args): FieldSet.__init__(self, *args) self._size = (8 + alignValue(self["size"].value, 2)) * 8 tag = self["type"].value if tag in self.TAG_INFO: self._name, self._description, self._parser = self.TAG_INFO[tag] else: self._parser = None
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) self._size = 32 + self["metadata_length"].value * 8 try: key = self["block_type"].value self._name, self._description, self.handler = self.BLOCK_TYPES[key] except KeyError: self.handler = None
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) self._size = (11 + self["size"].value) * 8 tag = self["tag"].value if tag in self.tag_info: self._name, self.parser, self._description = self.tag_info[tag] else: self.parser = None
def __init__(self, parent, name, table, **kw): FieldSet.__init__(self, parent, name, **kw) self.table = table tag = table["tag"].value if tag in self.TAG_INFO: self._name, self._description, self.parser = self.TAG_INFO[tag] else: self.parser = None
def __init__(self, *args): FieldSet.__init__(self, *args) self._size = (8 + alignValue(self["size"].value, 2)) * 8 tag = self["type"].value if tag in self.TAG_INFO: self._name, self._description, self._parser = self.TAG_INFO[tag] else: self._parser = None
def __init__(self, parent, name, table, **kw): FieldSet.__init__(self, parent, name, **kw) self.table = table tag = table["tag"].value if tag in self.TAG_INFO: self._name, self._description, self.parser = self.TAG_INFO[tag] else: self.parser = None
def __init__(self, parent, name, entry, size=None): FieldSet.__init__(self, parent, name, size=entry["size"].value*8) self.entry = entry res_type = self.getResType() if res_type in RESOURCE_TYPE: self._name, description, self._parser = RESOURCE_TYPE[res_type] else: self._parser = None
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) try: self._name, self.handler, self._description = self.TAG_INFO[self["tag"].value] except KeyError: self.handler = None size = self["size"] self._size = size.address + size.size + alignValue(size.value, 2) * 8
def __init__(self, parent, name, size=None, desc=None): FieldSet.__init__(self, parent, name, description=desc) if size != None: self._size = 8*size # object catalogs are ended with "obj" elif self["object"].value == "obj": size = self.stream.searchBytesLength("endobj", False) if size != None: self._size = 8*(size+2)
def __init__(self, parent, name, size=None, desc=None): FieldSet.__init__(self, parent, name, description=desc) if size != None: self._size = 8 * size # object catalogs are ended with "obj" elif self["object"].value == "obj": size = self.stream.searchBytesLength("endobj", False) if size != None: self._size = 8 * (size + 2)
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) code = self["type"].value try: self.parser, desc = self.tag_info[code] if code == self.CODE_DATE: self.createValue = self.createValueDate except KeyError: raise ParserError("AMF: Unable to parse type %s" % code)
def __init__(self, *args): FieldSet.__init__(self, *args) self._size = self["length"].value * 8 fourcc = self["fourcc"].value if fourcc in self.tag_info: self._name, self._parser, self._description = self.tag_info[fourcc] else: self._parser = None self._description = "Unknown chunk: fourcc %s" % self["fourcc"].display
def __init__(self, *args): FieldSet.__init__(self, *args) # TODO: Remove this because it's not lazy? key = self["key"] if not key.hasValue(): return key = key.value self._name = str(key).replace(" ", "_")
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) try: self._name, self.handler, self._description = self.TAG_INFO[ self["tag"].value] except KeyError: self.handler = None size = self["size"] self._size = size.address + size.size + alignValue(size.value, 2) * 8
def __init__(self, parent, name, description=None): FieldSet.__init__(self, parent, name, description) self._size = (self["size"].value) * 8 tag = self["tag"].value if tag in self.tag_info: self._name, self.parse_func = self.tag_info[tag] else: self._description = "" self.parse_func = None
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) code = self["type"].value try: self.parser, desc = self.tag_info[code] if code == self.CODE_DATE: self.createValue = self.createValueDate except KeyError: raise ParserError("AMF: Unable to parse type %s" % code)
def __init__(self, *args): FieldSet.__init__(self, *args) size = 27 self.lacing_size = self['lacing_size'].value if self.lacing_size: size += self.lacing_size lacing = self['lacing'] self.segment_size = [ field.value for field in lacing ] size += sum(self.segment_size) self._size = size * 8
def __init__(self, parent, name, description=None): assert parent.endian in (BIG_ENDIAN, LITTLE_ENDIAN) FieldSet.__init__(self, parent, name, description, size) if format: if self._parent.endian == BIG_ENDIAN: self.struct_format = ">"+format else: self.struct_format = "<"+format else: self.struct_format = None
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) tag = self["guid"].value if tag not in self.TAG_INFO: self.handler = None return info = self.TAG_INFO[tag] self._name = info[0] self.handler = info[1]
def __init__(self, parent, name, description=None): assert parent.endian in (BIG_ENDIAN, LITTLE_ENDIAN) FieldSet.__init__(self, parent, name, description, size) if format: if self._parent.endian == BIG_ENDIAN: self.struct_format = ">" + format else: self.struct_format = "<" + format else: self.struct_format = None
def __init__(self, *args): FieldSet.__init__(self, *args) size = (188-4)*8 if self["parent_offset"].value != 0: size += 32 if self["first_child_offset"].value != 0: size += 32 if self["next_sibling_offset"].value != 0: size += 32 self._size = size
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) tag = self["guid"].value if tag not in self.TAG_INFO: self.handler = None return info = self.TAG_INFO[tag] self._name = info[0] self.handler = info[1]
def __init__(self, *args): FieldSet.__init__(self, *args) size = (188 - 4) * 8 if self["parent_offset"].value != 0: size += 32 if self["first_child_offset"].value != 0: size += 32 if self["next_sibling_offset"].value != 0: size += 32 self._size = size
def __init__(self, *args): FieldSet.__init__(self, *args) self._size = self["length"].value * 8 fourcc = self["fourcc"].value if fourcc in self.tag_info: self._name, self._parser, self._description = self.tag_info[fourcc] else: self._parser = None self._description = "Unknown chunk: fourcc %s" % self[ "fourcc"].display
def __init__(self, *args): FieldSet.__init__(self, *args) self.status = self.stream.readBits(self.absolute_address, 8, LITTLE_ENDIAN) if self.status in (0, 0xE5): return magic = self.stream.readBits(self.absolute_address+11*8, 8, LITTLE_ENDIAN) if magic & 0x3F == 0x0F: self.LFN = True elif self.getFilename() not in (".", ".."): self.process = True
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) self._size = self["size"].value * 8 section_type = self["type"].value if section_type in (EFI_SECTION_DXE_DEPEX, EFI_SECTION_PEI_DEPEX): # These sections can sometimes be longer than what their size # claims! It's so nice to have so detailled specs and not follow # them ... if self.stream.readBytes(self.absolute_address + self._size, 1) == '\0': self._size = self._size + 16
def __init__(self, *args): FieldSet.__init__(self, *args) code = self["action_id"].value if code & 128: self._size = (3 + self["action_length"].value) * 8 else: self._size = 8 if code in self.ACTION_INFO: self._name, self._description, self.parser = self.ACTION_INFO[code] else: self.parser = None
def __init__(self, parent, name, description=None, strip=None, charset="UTF-16-LE"): FieldSet.__init__(self, parent, name, description) length = self["length"].value self._size = 32 + length * 16 self.strip = strip self.charset = charset
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) self._size = self["size"].value * 8 section_type = self["type"].value if section_type in (EFI_SECTION_DXE_DEPEX, EFI_SECTION_PEI_DEPEX): # These sections can sometimes be longer than what their size # claims! It's so nice to have so detailled specs and not follow # them ... if self.stream.readBytes(self.absolute_address + self._size, 1) == '\0': self._size = self._size + 16
def __init__(self, *args): FieldSet.__init__(self, *args) tag = self["tag"].value if tag in self.tag_info: self._name, self.parser, self._description = self.tag_info[tag] if not self.parser: self.parser = defaultParser elif 0x01 <= tag <= 0xaf: self._name, self.parser, self._description = ('slice[]', VideoSlice, 'Picture slice') else: self.parser = defaultParser
def __init__(self, *args): FieldSet.__init__(self, *args) size = self["length"].value if self[0].name == "length_ext": self._size = (6+size) * 8 else: self._size = (2+size) * 8 code = self["code"].value if code in self.TAG_INFO: self._name, self._description, self.parser = self.TAG_INFO[code] else: self.parser = None
def __init__(self, *args, **kw): FieldSet.__init__(self, *args, **kw) number = self["dataset_nb"].value self.dataset_info = None if number in datasets: tag = self["tag"].value if tag in datasets[number]: self.dataset_info = datasets[number][tag] self._name = self.dataset_info[0] self._description = self.dataset_info[1] size_chunk = self["size"] self._size = 3*8 + size_chunk.size + size_chunk.value*8
def __init__(self, parent, name, nb_items, item_class, item_name="item", description=None): # Sanity checks assert issubclass(item_class, Field) assert isinstance(item_class.static_size, (int, long)) if not(0 < nb_items): raise ParserError('Unable to create empty vector "%s" in %s' \ % (name, parent.path)) size = nb_items * item_class.static_size self.__nb_items = nb_items self._item_class = item_class self._item_name = item_name FieldSet.__init__(self, parent, name, description, size=size)