mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.2.x] added : removeExt routine ( Unload a WinDBg extension. Parameters: extension path )
git-svn-id: https://pykd.svn.codeplex.com/svn@87278 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
9e84715b22
commit
70cc46f8bb
@ -234,8 +234,10 @@ void appendSymbolPath(const std::string &symPath);
|
||||
// Extensions
|
||||
std::wstring getExtensionSearchPath();
|
||||
ULONG64 loadExtension(const std::wstring &extPath );
|
||||
ULONG64 addExtension(const std::wstring &extPath );
|
||||
ULONG64 getExtension(const std::wstring &extPath );
|
||||
void removeExtension( ULONG64 extHandle );
|
||||
void removeExtension(const std::wstring &extPath );
|
||||
std::wstring callExtension( ULONG64 extHandle, const std::wstring command, const std::wstring ¶ms );
|
||||
|
||||
};
|
||||
|
@ -89,8 +89,10 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Load a WinDBG extension. Return handle of the loaded extension" );
|
||||
python::def( "getExt", &getExtension,
|
||||
"Return handle of the loaded extension" );
|
||||
python::def( "removeExt", &removeExtension,
|
||||
python::def( "removeExt", (void(*)(ULONG64))&removeExtension,
|
||||
"Unload a WinDBG extension. Parameters: handle returned by loadExt" );
|
||||
python::def( "removeExt", (void(*)(const std::wstring&))&removeExtension,
|
||||
"Unload a WinDBg extension. Parameters: extension path" );
|
||||
python::def( "callExt", &callExtension,
|
||||
"Call a WinDBG extension's routine. Parameters: handle returned by loadExt; string command line" );
|
||||
|
||||
|
@ -1333,10 +1333,11 @@ std::wstring getExtensionSearchPath()
|
||||
|
||||
ULONG64 loadExtension(const std::wstring &extPath )
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||
|
||||
HRESULT hres;
|
||||
ULONG64 handle = 0;
|
||||
ULONG64 handle = 0;
|
||||
|
||||
std::vector< wchar_t > rawPath(MAX_PATH + 1, L'\0');
|
||||
DWORD ret =
|
||||
@ -1357,7 +1358,11 @@ ULONG64 loadExtension(const std::wstring &extPath )
|
||||
HMODULE m_hmod;
|
||||
} scoped_lib(&rawPath[0]);
|
||||
if (!scoped_lib.m_hmod)
|
||||
throw DbgException( "extension not found" );
|
||||
{
|
||||
std::stringstream sstr;
|
||||
sstr << "failed to load extension with error " << std::dec << GetLastError();
|
||||
throw DbgException( sstr.str() );
|
||||
}
|
||||
|
||||
hres = g_dbgEng->control->AddExtensionWide( extPath.c_str(), 0, &handle );
|
||||
if ( FAILED( hres ) )
|
||||
@ -1370,6 +1375,24 @@ ULONG64 loadExtension(const std::wstring &extPath )
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64 addExtension(const std::wstring &extPath )
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||
|
||||
ULONG64 handle = 0;
|
||||
|
||||
hres = g_dbgEng->control->AddExtensionWide( extPath.c_str(), 0, &handle );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugControl::AddExtension", hres );
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG64 getExtension(const std::wstring &extPath )
|
||||
@ -1388,6 +1411,23 @@ ULONG64 getExtension(const std::wstring &extPath )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void removeExtension(const std::wstring &extPath )
|
||||
{
|
||||
HRESULT hres;
|
||||
|
||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||
|
||||
ULONG64 handle = 0;
|
||||
|
||||
hres = g_dbgEng->control->GetExtensionByPathWide( extPath.c_str(), &handle );
|
||||
if ( FAILED( hres ) )
|
||||
throw DbgException( "IDebugControl::GetExtensionByPath", hres );
|
||||
|
||||
g_dbgEng->control->RemoveExtension( handle );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void removeExtension( ULONG64 extHandle )
|
||||
{
|
||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||
|
Loading…
Reference in New Issue
Block a user