Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse(buff):
mh = MinidumpHeader()
mh.Signature = buff.read(4).decode()[::-1]
if mh.Signature != 'PMDM':
raise MinidumpHeaderSignatureMismatchException(mh.Signature)
mh.Version = int.from_bytes(buff.read(2), byteorder = 'little', signed = False)
mh.ImplementationVersion = int.from_bytes(buff.read(2), byteorder = 'little', signed = False)
mh.NumberOfStreams = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
mh.StreamDirectoryRva = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
mh.CheckSum = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
mh.Reserved = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
mh.TimeDateStamp = int.from_bytes(buff.read(4), byteorder = 'little', signed = False)
try:
mh.Flags = MINIDUMP_TYPE(int.from_bytes(buff.read(4), byteorder = 'little', signed = False))
except Exception as e:
raise MinidumpHeaderFlagsException('Could not parse header flags!')
return mh
def prepare_header(self):
self.header = MinidumpHeader()
self.header.Version = 1
self.header.ImplementationVersion = 1
self.header.NumberOfStreams = len(self.streams) +1 # +1 is fot he memory info stream
self.header.StreamDirectoryRva = self.directory_rva
#self.header.CheckSum = None
#self.header.Reserved = None
#self.header.TimeDateStamp = None
self.header.Flags = MINIDUMP_TYPE.MiniDumpWithFullMemory
self.header_buffer.write(self.header.to_bytes())
def __parse_header(self):
self.header = MinidumpHeader.parse(self.file_handle)
for i in range(0, self.header.NumberOfStreams):
self.file_handle.seek(self.header.StreamDirectoryRva + i * 12, 0 )
minidump_dir = MINIDUMP_DIRECTORY.parse(self.file_handle)
if minidump_dir:
self.directories.append(minidump_dir)
else:
self.file_handle.seek(self.header.StreamDirectoryRva + i * 12, 0 )
user_stream_type_value = MINIDUMP_DIRECTORY.get_stream_type_value(self.file_handle)
logging.debug('Found Unknown UserStream directory Type: %x' % (user_stream_type_value))