From 39ca17dd9a613db2f8ac89f59e706b3c5d0ebf6f Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Thu, 23 Jan 2014 13:05:49 +0000 Subject: [PATCH] [0.2.x] add function getExt git-svn-id: https://pykd.svn.codeplex.com/svn@87117 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgengine.h | 1 + pykd/python/pymod.cpp | 2 ++ pykd/win/dbgeng.cpp | 22 +++++++++++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) 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() ); }