本文整理匯總了Python中kaitaistruct.BytesIO方法的典型用法代碼示例。如果您正苦於以下問題:Python kaitaistruct.BytesIO方法的具體用法?Python kaitaistruct.BytesIO怎麽用?Python kaitaistruct.BytesIO使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kaitaistruct
的用法示例。
在下文中一共展示了kaitaistruct.BytesIO方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _read
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def _read(self):
self.hdr = self._root.Header(self._io, self, self._root)
self.logical_screen_descriptor = self._root.LogicalScreenDescriptorStruct(self._io, self, self._root)
if self.logical_screen_descriptor.has_color_table:
self._raw_global_color_table = self._io.read_bytes((self.logical_screen_descriptor.color_table_size * 3))
io = KaitaiStream(BytesIO(self._raw_global_color_table))
self.global_color_table = self._root.ColorTable(io, self, self._root)
self.blocks = []
i = 0
while True:
_ = self._root.Block(self._io, self, self._root)
self.blocks.append(_)
if ((self._io.is_eof()) or (_.block_type == self._root.BlockType.end_of_file)) :
break
i += 1
示例2: program_headers
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def program_headers(self):
if hasattr(self, '_m_program_headers'):
return self._m_program_headers if hasattr(self, '_m_program_headers') else None
_pos = self._io.pos()
self._io.seek(self.program_header_offset)
if self._is_le:
self._raw__m_program_headers = [None] * (self.qty_program_header)
self._m_program_headers = [None] * (self.qty_program_header)
for i in range(self.qty_program_header):
self._raw__m_program_headers[i] = self._io.read_bytes(self.program_header_entry_size)
io = KaitaiStream(BytesIO(self._raw__m_program_headers[i]))
self._m_program_headers[i] = self._root.EndianElf.ProgramHeader(io, self, self._root, self._is_le)
else:
self._raw__m_program_headers = [None] * (self.qty_program_header)
self._m_program_headers = [None] * (self.qty_program_header)
for i in range(self.qty_program_header):
self._raw__m_program_headers[i] = self._io.read_bytes(self.program_header_entry_size)
io = KaitaiStream(BytesIO(self._raw__m_program_headers[i]))
self._m_program_headers[i] = self._root.EndianElf.ProgramHeader(io, self, self._root, self._is_le)
self._io.seek(_pos)
return self._m_program_headers if hasattr(self, '_m_program_headers') else None
示例3: section_headers
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def section_headers(self):
if hasattr(self, '_m_section_headers'):
return self._m_section_headers if hasattr(self, '_m_section_headers') else None
_pos = self._io.pos()
self._io.seek(self.section_header_offset)
if self._is_le:
self._raw__m_section_headers = [None] * (self.qty_section_header)
self._m_section_headers = [None] * (self.qty_section_header)
for i in range(self.qty_section_header):
self._raw__m_section_headers[i] = self._io.read_bytes(self.section_header_entry_size)
io = KaitaiStream(BytesIO(self._raw__m_section_headers[i]))
self._m_section_headers[i] = self._root.EndianElf.SectionHeader(io, self, self._root, self._is_le)
else:
self._raw__m_section_headers = [None] * (self.qty_section_header)
self._m_section_headers = [None] * (self.qty_section_header)
for i in range(self.qty_section_header):
self._raw__m_section_headers[i] = self._io.read_bytes(self.section_header_entry_size)
io = KaitaiStream(BytesIO(self._raw__m_section_headers[i]))
self._m_section_headers[i] = self._root.EndianElf.SectionHeader(io, self, self._root, self._is_le)
self._io.seek(_pos)
return self._m_section_headers if hasattr(self, '_m_section_headers') else None
示例4: strings
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def strings(self):
if hasattr(self, '_m_strings'):
return self._m_strings if hasattr(self, '_m_strings') else None
_pos = self._io.pos()
self._io.seek(self.section_headers[self.section_names_idx].offset)
if self._is_le:
self._raw__m_strings = self._io.read_bytes(self.section_headers[self.section_names_idx].size)
io = KaitaiStream(BytesIO(self._raw__m_strings))
self._m_strings = self._root.EndianElf.StringsStruct(io, self, self._root, self._is_le)
else:
self._raw__m_strings = self._io.read_bytes(self.section_headers[self.section_names_idx].size)
io = KaitaiStream(BytesIO(self._raw__m_strings))
self._m_strings = self._root.EndianElf.StringsStruct(io, self, self._root, self._is_le)
self._io.seek(_pos)
return self._m_strings if hasattr(self, '_m_strings') else None
示例5: __init__
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self.length = self._io.read_u4le()
if self.length == 4294967295:
self.length64 = self._io.read_u8le()
self.id = self._io.read_u4le()
if self.length > 0:
_on = self.id
if _on == 0:
self._raw_body = self._io.read_bytes((self.length - 4))
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.SegmentCommand64.Section64.EhFrameItem.Cie(io, self, self._root)
else:
self.body = self._io.read_bytes((self.length - 4))
示例6: _read
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def _read(self):
self.crc16 = self._io.read_u2le()
self.block_type = self._root.BlockTypes(self._io.read_u1())
self.flags = self._io.read_u2le()
self.block_size = self._io.read_u2le()
if self.has_add:
self.add_size = self._io.read_u4le()
_on = self.block_type
if _on == self._root.BlockTypes.file_header:
self._raw_body = self._io.read_bytes(self.body_size)
io = KaitaiStream(BytesIO(self._raw_body))
self.body = self._root.BlockFileHeader(io, self, self._root)
else:
self.body = self._io.read_bytes(self.body_size)
if self.has_add:
self.add_body = self._io.read_bytes(self.add_size)
示例7: __init__
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self.mz1 = self._root.MzPlaceholder(self._io, self, self._root)
self.mz2 = self._io.read_bytes((self.mz1.header_size - 64))
self.pe_signature = self._io.ensure_fixed_contents(struct.pack('4b', 80, 69, 0, 0))
self.coff_hdr = self._root.CoffHeader(self._io, self, self._root)
self._raw_optional_hdr = self._io.read_bytes(self.coff_hdr.size_of_optional_header)
io = KaitaiStream(BytesIO(self._raw_optional_hdr))
self.optional_hdr = self._root.OptionalHeader(io, self, self._root)
self.sections = [None] * (self.coff_hdr.number_of_sections)
for i in range(self.coff_hdr.number_of_sections):
self.sections[i] = self._root.Section(self._io, self, self._root)
示例8: code_signature
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def code_signature(self):
if hasattr(self, '_m_code_signature'):
return self._m_code_signature if hasattr(self, '_m_code_signature') else None
io = self._root._io
_pos = io.pos()
io.seek(self.data_off)
self._raw__m_code_signature = io.read_bytes(self.data_size)
io = KaitaiStream(BytesIO(self._raw__m_code_signature))
self._m_code_signature = self._root.CsBlob(io, self, self._root)
io.seek(_pos)
return self._m_code_signature if hasattr(self, '_m_code_signature') else None
示例9: rebase
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def rebase(self):
if hasattr(self, '_m_rebase'):
return self._m_rebase if hasattr(self, '_m_rebase') else None
io = self._root._io
_pos = io.pos()
io.seek(self.rebase_off)
self._raw__m_rebase = io.read_bytes(self.rebase_size)
io = KaitaiStream(BytesIO(self._raw__m_rebase))
self._m_rebase = self._root.DyldInfoCommand.RebaseData(io, self, self._root)
io.seek(_pos)
return self._m_rebase if hasattr(self, '_m_rebase') else None
示例10: bind
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def bind(self):
if hasattr(self, '_m_bind'):
return self._m_bind if hasattr(self, '_m_bind') else None
io = self._root._io
_pos = io.pos()
io.seek(self.bind_off)
self._raw__m_bind = io.read_bytes(self.bind_size)
io = KaitaiStream(BytesIO(self._raw__m_bind))
self._m_bind = self._root.DyldInfoCommand.BindData(io, self, self._root)
io.seek(_pos)
return self._m_bind if hasattr(self, '_m_bind') else None
示例11: lazy_bind
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def lazy_bind(self):
if hasattr(self, '_m_lazy_bind'):
return self._m_lazy_bind if hasattr(self, '_m_lazy_bind') else None
io = self._root._io
_pos = io.pos()
io.seek(self.lazy_bind_off)
self._raw__m_lazy_bind = io.read_bytes(self.lazy_bind_size)
io = KaitaiStream(BytesIO(self._raw__m_lazy_bind))
self._m_lazy_bind = self._root.DyldInfoCommand.LazyBindData(io, self, self._root)
io.seek(_pos)
return self._m_lazy_bind if hasattr(self, '_m_lazy_bind') else None
示例12: strs
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def strs(self):
if hasattr(self, '_m_strs'):
return self._m_strs if hasattr(self, '_m_strs') else None
io = self._root._io
_pos = io.pos()
io.seek(self.str_off)
self._raw__m_strs = io.read_bytes(self.str_size)
io = KaitaiStream(BytesIO(self._raw__m_strs))
self._m_strs = self._root.SymtabCommand.StrTable(io, self, self._root)
io.seek(_pos)
return self._m_strs if hasattr(self, '_m_strs') else None
示例13: _read
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def _read(self):
self.total_length = self._io.read_u4le()
self.install_paths_length = self._io.read_u4le()
self._raw_install_paths = self._io.read_bytes(self.install_paths_length)
io = KaitaiStream(BytesIO(self._raw_install_paths))
self.install_paths = self._root.InstallPathsStruct(io, self, self._root)
self.binaries_length = self._io.read_u4le()
self._raw_binaries = self._io.read_bytes(self.binaries_length)
io = KaitaiStream(BytesIO(self._raw_binaries))
self.binaries = self._root.BinariesStruct(io, self, self._root)
self.persistence_length = self._io.read_u4le()
self._raw_persistence_strings = self._io.read_bytes(self.persistence_length)
io = KaitaiStream(BytesIO(self._raw_persistence_strings))
self.persistence_strings = self._root.PersistenceStruct(io, self, self._root)
示例14: parse_vek_keybag
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def parse_vek_keybag(unwrapped_keybag):
"""
Returns a kaitai struct structure of the unwrapped keybag
param: unwrappped_keybag: The bytes like keybag that will be parsed
return: keybag: The structured keybag
"""
stream = KaitaiStream(BytesIO(unwrapped_keybag))
keybag = media_keybag_t_vek(stream)
return keybag
示例15: parse_volume_keybag
# 需要導入模塊: import kaitaistruct [as 別名]
# 或者: from kaitaistruct import BytesIO [as 別名]
def parse_volume_keybag(unwrapped_keybag):
"""
Returns a kaitai struct structure of the unwrapped keybag
param: unwrappped_keybag: The bytes like keybag that will be parsed
return: keybag: The structured keybag
"""
stream = KaitaiStream(BytesIO(unwrapped_keybag))
keybag = media_keybag_t_kek(stream)
return keybag