improve error handling
This commit is contained in:
parent
42c69867b8
commit
fec96b92a7
@ -341,7 +341,7 @@ class Process(metaclass=ABCMeta):
|
||||
self.read_memory(start, region_buffer)
|
||||
found += [offset + start for offset in search(needle_buffer, region_buffer)]
|
||||
except OSError:
|
||||
logger.error('Failed to read in range 0x{} - 0x{}'.format(start, stop))
|
||||
logger.exception(f'Failed to read in range 0x{start} - 0x{stop}')
|
||||
return found
|
||||
|
||||
@classmethod
|
||||
|
@ -161,8 +161,8 @@ class Process(AbstractProcess):
|
||||
ctypes.sizeof(write_buffer),
|
||||
None
|
||||
)
|
||||
except (BufferError, ValueError, TypeError):
|
||||
raise MemEditError(f'Error with handle {self.process_handle}: {self._get_last_error()}')
|
||||
except (BufferError, ValueError, TypeError) as err:
|
||||
raise MemEditError(f'Error with handle {self.process_handle}: {self._get_last_error()}') from err
|
||||
|
||||
def read_memory(self, base_address: int, read_buffer: ctypes_buffer_t) -> ctypes_buffer_t:
|
||||
try:
|
||||
@ -173,8 +173,8 @@ class Process(AbstractProcess):
|
||||
ctypes.sizeof(read_buffer),
|
||||
None
|
||||
)
|
||||
except (BufferError, ValueError, TypeError):
|
||||
raise MemEditError(f'Error with handle {self.process_handle}: {self._get_last_error()}')
|
||||
except (BufferError, ValueError, TypeError) as err:
|
||||
raise MemEditError(f'Error with handle {self.process_handle}: {self._get_last_error()}') from err
|
||||
|
||||
return read_buffer
|
||||
|
||||
@ -274,8 +274,7 @@ class Process(AbstractProcess):
|
||||
if success == 0:
|
||||
raise MemEditError('Failed VirtualQueryEx with handle '
|
||||
+ f'{self.process_handle}: {self._get_last_error()}')
|
||||
else:
|
||||
raise MemEditError('VirtualQueryEx output too short!')
|
||||
raise MemEditError('VirtualQueryEx output too short!')
|
||||
|
||||
return mbi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user