diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index 5ab11b4..ea9a29c 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -6,6 +6,7 @@ #include "win/dbgeng.h" #include "win/dbgio.h" #include "dbgexcept.h" +#include "eventhandler.h" namespace pykd { @@ -1542,6 +1543,32 @@ HRESULT STDMETHODCALLTYPE DebugEngine::ChangeEngineState( /////////////////////////////////////////////////////////////////////////////// +DebugEngine::DbgEngBind* DebugEngine::operator->() +{ + if ( m_bind.get() != NULL ) + return m_bind.get(); + + CComPtr client = NULL; + + HRESULT hres = DebugCreate( __uuidof(IDebugClient4), (void **)&client ); + if ( FAILED( hres ) ) + throw DbgException("DebugCreate failed"); + + m_bind.reset(new DbgEngBind(client, this) ); + + python::object main = boost::python::import("__main__"); + + python::object main_namespace = main.attr("__dict__"); + + python::object pykd = boost::python::import( "pykd" ); + + main_namespace["globalEventHandler"] = EventHandlerPtr( new EventHandlerImpl() ); + + return m_bind.get(); +} + +/////////////////////////////////////////////////////////////////////////////// + ULONG64 getCurrentProcess() { diff --git a/pykd/win/dbgeng.h b/pykd/win/dbgeng.h index eba1e61..d10c0a0 100644 --- a/pykd/win/dbgeng.h +++ b/pykd/win/dbgeng.h @@ -84,22 +84,21 @@ public: __in ULONG Flags, __in ULONG64 Argument ); - DbgEngBind* - operator->() - { - if ( m_bind.get() != NULL ) - return m_bind.get(); + DbgEngBind* operator->(); + //{ + // if ( m_bind.get() != NULL ) + // return m_bind.get(); - CComPtr client = NULL; + // CComPtr client = NULL; - HRESULT hres = DebugCreate( __uuidof(IDebugClient4), (void **)&client ); - if ( FAILED( hres ) ) - throw DbgException("DebugCreate failed"); + // HRESULT hres = DebugCreate( __uuidof(IDebugClient4), (void **)&client ); + // if ( FAILED( hres ) ) + // throw DbgException("DebugCreate failed"); - m_bind.reset(new DbgEngBind(client, this) ); + // m_bind.reset(new DbgEngBind(client, this) ); - return m_bind.get(); - } + // return m_bind.get(); + //} void registerCallbacks( const DEBUG_EVENT_CALLBACK *callbacks ); void removeCallbacks( const DEBUG_EVENT_CALLBACK *callbacks );