[0.2.x] added : loadExt, removeExt, callExt routines

git-svn-id: https://pykd.svn.codeplex.com/svn@80241 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-10-16 06:39:42 +00:00 committed by Mikhail I. Izmestev
parent b8a6996906
commit 6c582490ee
3 changed files with 63 additions and 6 deletions

View File

@ -101,5 +101,10 @@ std::string getSymbolPath();
void setSymbolPath(const std::string &symPath); void setSymbolPath(const std::string &symPath);
void appendSymbolPath(const std::string &symPath); void appendSymbolPath(const std::string &symPath);
// Extensions
ULONG64 loadExtension(const std::wstring &extPath );
void removeExtension( ULONG64 extHandle );
std::string callExtension( ULONG64 extHandle, const std::wstring command, const std::wstring &params );
}; };

View File

@ -66,6 +66,17 @@ BOOST_PYTHON_MODULE( pykd )
{ {
python::scope().attr("version") = pykdVersion; python::scope().attr("version") = pykdVersion;
// DbgEng services
python::def( "setSymSrvDir", &setSymSrvDir,
"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( "removeExt", &removeExtension,
"Unload a WinDBG extension. Parameters: handle returned by loadExt" );
python::def( "callExt", &callExtension,
"Call a WinDBG extension's routine. Parameters: handle returned by loadExt; string command line" );
// Manage debug target // Manage debug target
python::def( "startProcess", &startProcess, python::def( "startProcess", &startProcess,
@ -248,10 +259,7 @@ BOOST_PYTHON_MODULE( pykd )
"Set current process by address" ); "Set current process by address" );
python::def( "setImplicitThread", &setImplicitThread, python::def( "setImplicitThread", &setImplicitThread,
"Set implicit thread for current process" ); "Set implicit thread for current process" );
python::def( "setSymSrvDir", &setSymSrvDir,
"Set directory of SYMSRV.dll library.\nUsually this is a directory of WinDbg");
// symbol path // symbol path
python::def( "getSymbolPath", &getSymbolPath, "Returns current symbol path"); python::def( "getSymbolPath", &getSymbolPath, "Returns current symbol path");
python::def( "setSymbolPath", &setSymbolPath, "Set current symbol path"); python::def( "setSymbolPath", &setSymbolPath, "Set current symbol path");

View File

@ -1126,16 +1126,60 @@ void setImplicitThread( ULONG64 threadAddr )
{ {
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres; HRESULT hres;
threadAddr = addr64(threadAddr); threadAddr = addr64(threadAddr);
hres = g_dbgEng->system->SetImplicitThreadDataOffset( threadAddr ); hres = g_dbgEng->system->SetImplicitThreadDataOffset( threadAddr );
if ( FAILED( hres ) ) if ( FAILED( hres ) )
throw DbgException( "IDebugSystemObjects2::SetImplicitThreadDataOffset failed" ); throw DbgException( "IDebugSystemObjects2::SetImplicitThreadDataOffset failed" );
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
ULONG64 loadExtension(const std::wstring &extPath )
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
ULONG64 handle = 0;
hres = g_dbgEng->control->AddExtensionWide( extPath.c_str(), 0, &handle );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::AddExtension failed" );
return handle;
}
///////////////////////////////////////////////////////////////////////////////
void removeExtension( ULONG64 extHandle )
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
g_dbgEng->control->RemoveExtension( extHandle );
}
///////////////////////////////////////////////////////////////////////////////
std::string callExtension( ULONG64 extHandle, const std::wstring command, const std::wstring &params )
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
OutputReader outReader( g_dbgEng->client );
hres = g_dbgEng->control->CallExtensionWide( extHandle, command.c_str(), params.c_str() );
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::CallExtension failed" );
return std::string( outReader.Line() );
}
///////////////////////////////////////////////////////////////////////////////
} // end pykd namespace } // end pykd namespace