MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / handle_exception

Method handle_exception

windows/debug/localdbg.py:116–140  ·  view source on GitHub ↗
(self, exc)

Source from the content-addressed store, hash-verified

114 return self.handle_exception(exc)
115
116 def handle_exception(self, exc):
117 exp_code = self.get_exception_code()
118 context = self.get_exception_context()
119 exp_addr = context.pc
120 if exp_code == EXCEPTION_BREAKPOINT and exp_addr in self.breakpoints:
121 res = self.breakpoints[exp_addr].trigger(self, exc)
122 single_step = self.get_exception_context().EEFlags.TF # single step activated by breakpoint
123 if exp_addr in self.breakpoints: # Breakpoint deleted itself ?
124 return self._pass_breakpoint(exp_addr, single_step)
125 return EXCEPTION_CONTINUE_EXECUTION
126
127 if exp_code == EXCEPTION_SINGLE_STEP and windows.current_thread.tid in self._reput_breakpoint:
128 bp, single_step = self._reput_breakpoint[windows.current_thread.tid]
129 self._memory_save[bp._addr] = windows.current_process.read_memory(bp._addr, 1)
130 with windows.utils.VirtualProtected(bp._addr, 1, PAGE_EXECUTE_READWRITE):
131 windows.current_process.write_memory(bp._addr, b"\xcc")
132 del self._reput_breakpoint[windows.current_thread.tid]
133 if single_step:
134 return self.on_exception(exc)
135 return windef.EXCEPTION_CONTINUE_EXECUTION
136 elif exp_code == EXCEPTION_SINGLE_STEP and exp_addr in self._hxbp_breakpoint[windows.current_thread.tid]:
137 res = self._hxbp_breakpoint[windows.current_thread.tid][exp_addr].trigger(self, exc)
138 context.EEFlags.RF = 1
139 return EXCEPTION_CONTINUE_EXECUTION
140 return self.on_exception(exc)
141
142 def on_exception(self, exc):
143 """Called on exception"""

Callers 1

callbackMethod · 0.95

Calls 7

get_exception_codeMethod · 0.95
get_exception_contextMethod · 0.95
_pass_breakpointMethod · 0.95
on_exceptionMethod · 0.95
triggerMethod · 0.45
read_memoryMethod · 0.45
write_memoryMethod · 0.45

Tested by

no test coverage detected