mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:24:52 +08:00
[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:
parent
b8a6996906
commit
6c582490ee
@ -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 ¶ms );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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,
|
||||||
@ -249,9 +260,6 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
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");
|
||||||
|
@ -1136,6 +1136,50 @@ void setImplicitThread( ULONG64 threadAddr )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
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 ¶ms )
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user