diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index ea9a29c..40a340d 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -1543,6 +1543,37 @@ HRESULT STDMETHODCALLTYPE DebugEngine::ChangeEngineState( /////////////////////////////////////////////////////////////////////////////// +HRESULT STDMETHODCALLTYPE DebugEngine::StartInput( + __in ULONG BufferSize ) +{ + std::string s = ""; + + { + PyThread_StateSave pyThreadSave( g_dbgEng->pystate ); + + python::object ret = python::eval( "raw_input(\"input>\")" ); + + s = python::extract( ret ); + } + + g_dbgEng->control->ReturnInput ( s.c_str() ); + + //python::object sys = python::import( "sys" ); + //python::object sysstdin = sys.attr("stdin"); + //sys.attr("stdin") = python::object( DbgIn() ); + return S_OK; +} + +/////////////////////////////////////////////////////////////////////////////// + +HRESULT STDMETHODCALLTYPE DebugEngine::EndInput() +{ + return S_OK; +} + +/////////////////////////////////////////////////////////////////////////////// + + DebugEngine::DbgEngBind* DebugEngine::operator->() { if ( m_bind.get() != NULL ) @@ -1564,6 +1595,8 @@ DebugEngine::DbgEngBind* DebugEngine::operator->() main_namespace["globalEventHandler"] = EventHandlerPtr( new EventHandlerImpl() ); + client->SetInputCallbacks( this ); + return m_bind.get(); } diff --git a/pykd/win/dbgeng.h b/pykd/win/dbgeng.h index eadd1fa..4f55fd6 100644 --- a/pykd/win/dbgeng.h +++ b/pykd/win/dbgeng.h @@ -12,7 +12,7 @@ namespace pykd { /////////////////////////////////////////////////////////////////////////////////// -class DebugEngine : private DebugBaseEventCallbacks +class DebugEngine : private DebugBaseEventCallbacks, private IDebugInputCallbacks { public: @@ -43,6 +43,28 @@ public: }; // IUnknown impls + // IUnknown. + STDMETHOD(QueryInterface)( + __in REFIID InterfaceId, + __out PVOID* Interface + ) + { + *Interface = NULL; + if (IsEqualIID(InterfaceId, __uuidof(IUnknown)) || + IsEqualIID(InterfaceId, __uuidof(IDebugEventCallbacks)) || + IsEqualIID(InterfaceId,__uuidof(IDebugInputCallbacks)) + ) + { + *Interface = this; + return S_OK; + } + else + { + return E_NOINTERFACE; + } + } + + STDMETHOD_(ULONG, AddRef)() { return 1; } STDMETHOD_(ULONG, Release)() { return 1; } @@ -84,6 +106,12 @@ public: __in ULONG Flags, __in ULONG64 Argument ); + + STDMETHOD(StartInput)( + __in ULONG BufferSize ); + + STDMETHOD(EndInput)(); + DbgEngBind* operator->(); void registerCallbacks( const DEBUG_EVENT_CALLBACK *callbacks );