From 13f231d6ade19b850937a60ba417c30044f9731c Mon Sep 17 00:00:00 2001 From: Clement Rouault Date: Mon, 18 Jul 2016 16:30:17 +0200 Subject: [PATCH] debugger disable memory breakpoint before calling membp.trigger() --- windows/debug/debugger.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/windows/debug/debugger.py b/windows/debug/debugger.py index 79f102f..269c908 100644 --- a/windows/debug/debugger.py +++ b/windows/debug/debugger.py @@ -461,7 +461,8 @@ class Debugger(object): self._pass_memory_breakpoint(bp, original_prot, fault_page) return DBG_CONTINUE - continue_flag = mem_bp.trigger(self, exception) + with self.DisabledMemoryBreakpoint() + continue_flag = mem_bp.trigger(self, exception) self._explicit_single_step[self.current_thread.tid] = self.current_thread.context.EEFlags.TF # If BP has not been removed in trigger, pas it if fault_page in cp_watch_page and mem_bp in cp_watch_page[fault_page].bps: @@ -716,6 +717,14 @@ class Debugger(object): target.virtual_protect(page_addr, PAGE_SIZE, protection, None) return + @contextmanager + def DisabledMemoryBreakpoint(self, target=None): + data = self.disable_all_memory_breakpoints(target) + try: + yield + finally: + self.restore_all_memory_breakpoints(data, target) + # Public callback def on_exception(self, exception): """Called on exception event other that known breakpoint or requested single step. ``exception`` is one of the following type: