From e98bf3e1c2e8ccd391386646785036454aa5efd5 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Wed, 12 Oct 2011 07:11:54 +0000 Subject: [PATCH] [0.0 -> 0.1 ] integrated : dbgevent.h git-svn-id: https://pykd.svn.codeplex.com/svn@70330 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgevent.h | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 pykd/dbgevent.h diff --git a/pykd/dbgevent.h b/pykd/dbgevent.h new file mode 100644 index 0000000..5a577b9 --- /dev/null +++ b/pykd/dbgevent.h @@ -0,0 +1,129 @@ +///////////////////////////////////////////////////////////////////////////////// +// user-customizing debug event handler +///////////////////////////////////////////////////////////////////////////////// + +#include "dbgeventcb.h" +#include "dbgmodule.h" +#include "pyaux.h" + +///////////////////////////////////////////////////////////////////////////////// + +class debugEvent : public DebugBaseEventCallbacks +{ +public: + + debugEvent(); + + virtual ~debugEvent(); + + virtual ULONG onBreakpoint(boost::python::dict &/*bpParameters*/) = 0; + + virtual ULONG onException(boost::python::dict &/*exceptData*/) = 0; + + virtual ULONG onLoadModule(const dbgModuleClass &/* module */) = 0; + + virtual ULONG onUnloadModule(const dbgModuleClass &/* module */) = 0; + + virtual ULONG onChangeSessionStatus( ULONG status ) = 0; + + virtual ULONG onChangeDebugeeState() = 0; + +private: + + STDMETHOD_(ULONG, AddRef)() { return 1; } + STDMETHOD_(ULONG, Release)() { return 1; } + + STDMETHOD(GetInterestMask)( + __out PULONG Mask + ); + + STDMETHOD(Breakpoint)( + __in PDEBUG_BREAKPOINT Bp + ); + + + STDMETHOD(Exception)( + __in PEXCEPTION_RECORD64 Exception, + __in ULONG FirstChance + ); + + STDMETHOD(LoadModule)( + __in ULONG64 ImageFileHandle, + __in ULONG64 BaseOffset, + __in ULONG ModuleSize, + __in PCSTR ModuleName, + __in PCSTR ImageName, + __in ULONG CheckSum, + __in ULONG TimeDateStamp + ); + + STDMETHOD(UnloadModule)( + __in PCSTR ImageBaseName, + __in ULONG64 BaseOffset + ); + + STDMETHOD(SessionStatus)( + __in ULONG Status + ); + + STDMETHOD(ChangeDebuggeeState)( + __in ULONG Flags, + __in ULONG64 Argument ); + +private: + + IDebugClient *m_debugClient; +}; + +///////////////////////////////////////////////////////////////////////////////// + +class debugEventWrap : public boost::python::wrapper, public debugEvent +{ + +public: + + ULONG onBreakpoint(boost::python::dict &bpParameters) { + return handler("onBreakpoint", bpParameters); + } + + ULONG onException(boost::python::dict &exceptData) { + return handler("onException", exceptData); + } + + ULONG onLoadModule(const dbgModuleClass &module) { + return handler("onLoadModule", module ); + } + + ULONG onUnloadModule(const dbgModuleClass &module) { + return handler("onUnloadModule", module ); + } + + ULONG onChangeSessionStatus( ULONG status ) { + return handler( "onChangeSessionStatus", status ); + } + + ULONG onChangeDebugeeState() { + return handler( "onChangeDebugeeState" ); + } + +private: + + template + ULONG handler( const char* handlerName, Arg1Type arg1 ) + { + if (boost::python::override pythonHandler = get_override( handlerName )) + return pythonHandler(arg1); + + return DEBUG_STATUS_NO_CHANGE; + } + + ULONG handler( const char* handlerName ) + { + if (boost::python::override pythonHandler = get_override( handlerName )) + return pythonHandler(); + + return DEBUG_STATUS_NO_CHANGE; + } +}; + +/////////////////////////////////////////////////////////////////////////////////