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_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))
def prepare_directory(self):
curr_pos = self.header_size
for streamtype in self.streams:
self.streams[streamtype].to_bytes(self.data_buffer)
directory = MINIDUMP_DIRECTORY()
directory.StreamType = streamtype
directory.Location = curr_pos
self.header_buffer.write(directory.to_bytes())
def parse(buff):
raw_stream_type_value = MINIDUMP_DIRECTORY.get_stream_type_value(buff)
# StreamType value that are over 0xffff are considered MINIDUMP_USER_STREAM streams
# and their format depends on the client used to create the minidump.
# As per the documentation, this stream should be ignored : https://docs.microsoft.com/en-us/windows/win32/api/minidumpapiset/ne-minidumpapiset-minidumminidump_dirp_stream_type#remarks
is_user_stream = raw_stream_type_value > MINIDUMP_STREAM_TYPE.LastReservedStream.value
is_stream_supported = raw_stream_type_value in MINIDUMP_STREAM_TYPE._value2member_map_
if is_user_stream and not is_stream_supported:
return None
md = MINIDUMP_DIRECTORY()
md.StreamType = MINIDUMP_STREAM_TYPE(raw_stream_type_value)
md.Location = MINIDUMP_LOCATION_DESCRIPTOR.parse(buff)
return md