From a89854a04557609e5ea925d1e8bc0b1753a37d84 Mon Sep 17 00:00:00 2001 From: Clement Rouault Date: Wed, 24 May 2017 17:45:27 +0200 Subject: [PATCH] PrintBP now accept a pre-format fonction to forge new format parameters --- windows/debug/breakpoints.py | 9 +++++++-- windows/debug/debugger.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/windows/debug/breakpoints.py b/windows/debug/breakpoints.py index b007d15..5ca1247 100644 --- a/windows/debug/breakpoints.py +++ b/windows/debug/breakpoints.py @@ -160,9 +160,14 @@ class FunctionBP(FunctionCallBP, FunctionParamDumpBP): """ class PrintBP(Breakpoint): - def __init__(self, addr, format): + def __init__(self, addr, format, func=None): super(PrintBP, self).__init__(addr) self.format = format + self.func = func def trigger(self, dbg, exc): - print(self.format.format(dbg=dbg, exc=exc, ctx=dbg.current_thread.context)) \ No newline at end of file + thread = dbg.current_thread + format_dict = {"dbg": dbg, "exc": exc, "proc": dbg.current_process, "thread": thread, "ctx": thread.context} + if self.func: + format_dict.update(self.func(**format_dict)) + print(self.format.format(**format_dict)) \ No newline at end of file diff --git a/windows/debug/debugger.py b/windows/debug/debugger.py index 955662e..31f13dd 100644 --- a/windows/debug/debugger.py +++ b/windows/debug/debugger.py @@ -930,6 +930,7 @@ class Debugger(object): The default behaviour is to return ``DBG_CONTINUE`` for the known exception code and ``DBG_EXCEPTION_NOT_HANDLED`` else """ + dbgprint("Exception: {0} at ".format(exception.ExceptionRecord.ExceptionCode, exception.ExceptionRecord.ExceptionAddress), "DBG") if not exception.ExceptionRecord.ExceptionCode in winexception.exception_name_by_value: return DBG_EXCEPTION_NOT_HANDLED return DBG_CONTINUE