diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index e880f5c..6dfb0f9 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -204,6 +204,7 @@ void appendSymbolPath(const std::string &symPath); // Extensions ULONG64 loadExtension(const std::wstring &extPath ); +ULONG64 getExtension(const std::wstring &extPath ); void removeExtension( ULONG64 extHandle ); std::wstring callExtension( ULONG64 extHandle, const std::wstring command, const std::wstring ¶ms ); diff --git a/pykd/python/pymod.cpp b/pykd/python/pymod.cpp index e9e613a..c13ba26 100644 --- a/pykd/python/pymod.cpp +++ b/pykd/python/pymod.cpp @@ -84,6 +84,8 @@ BOOST_PYTHON_MODULE( pykd ) "Set directory of SYMSRV.dll library.\nUsually this is a directory of WinDbg"); python::def( "loadExt", &loadExtension, "Load a WinDBG extension. Return handle of the loaded extension" ); + python::def( "getExt", &getExtension, + "Return handle of the loaded extension" ); python::def( "removeExt", &removeExtension, "Unload a WinDBG extension. Parameters: handle returned by loadExt" ); python::def( "callExt", &callExtension, diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index 17bb778..3b0f175 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -1298,7 +1298,23 @@ ULONG64 loadExtension(const std::wstring &extPath ) hres = g_dbgEng->control->AddExtensionWide( extPath.c_str(), 0, &handle ); if ( FAILED( hres ) ) - throw DbgException( "IDebugControl::AddExtension failed" ); + throw DbgException( "IDebugControl::AddExtension", hres ); + + return handle; +} + +/////////////////////////////////////////////////////////////////////////////// + +ULONG64 getExtension(const std::wstring &extPath ) +{ + PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); + + HRESULT hres; + ULONG64 handle = 0; + + hres = g_dbgEng->control->GetExtensionByPathWide( extPath.c_str(), &handle ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugControl::GetExtensionByPath", hres ); return handle; } @@ -1325,8 +1341,8 @@ std::wstring callExtension( ULONG64 extHandle, const std::wstring command, const hres = g_dbgEng->control->CallExtensionWide( extHandle, command.c_str(), params.c_str() ); if ( FAILED( hres ) ) - throw DbgException( "IDebugControl::CallExtension failed" ); - + throw DbgException( "IDebugControl::CallExtension", hres ); + return std::wstring( outReader.Line() ); }