[0.3.x] added : onModuleLoad/onModuleUnload methods

git-svn-id: https://pykd.svn.codeplex.com/svn@87486 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2014-03-07 07:16:10 +00:00 committed by Mikhail I. Izmestev
parent 0e0d147888
commit 33761324e3
4 changed files with 111 additions and 7 deletions

View File

@ -249,5 +249,107 @@ kdlib::DebugCallbackResult EventHandler::onException( const kdlib::ExceptionInfo
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
kdlib::DebugCallbackResult EventHandler::onModuleLoad( kdlib::MEMOFFSET_64 offset, const std::wstring &name )
{
kdlib::DebugCallbackResult result = kdlib::DebugCallbackNoChange;
PyEval_RestoreThread( m_pystate );
try {
do {
python::override pythonHandler = get_override( "onModuleLoad" );
if ( !pythonHandler )
{
result = kdlib::EventHandler::onModuleLoad( offset, name );
break;
}
python::object resObj = pythonHandler( offset, name );
if ( resObj.is_none() )
{
result = kdlib::DebugCallbackNoChange;
break;
}
int retVal = python::extract<int>( resObj );
if ( retVal >= kdlib::DebugCallbackMax )
{
result = kdlib::DebugCallbackBreak;
break;
}
result = kdlib::DebugCallbackResult(retVal);
} while( FALSE );
}
catch (const python::error_already_set &)
{
printException();
result = kdlib::DebugCallbackBreak;
}
m_pystate = PyEval_SaveThread();
return result;
}
///////////////////////////////////////////////////////////////////////////////
kdlib::DebugCallbackResult EventHandler::onModuleUnload( kdlib::MEMOFFSET_64 offset, const std::wstring &name )
{
kdlib::DebugCallbackResult result = kdlib::DebugCallbackNoChange;
PyEval_RestoreThread( m_pystate );
try {
do {
python::override pythonHandler = get_override( "onModuleUnload" );
if ( !pythonHandler )
{
result = kdlib::EventHandler::onModuleUnload( offset, name );
break;
}
python::object resObj = pythonHandler( offset, name );
if ( resObj.is_none() )
{
result = kdlib::DebugCallbackNoChange;
break;
}
int retVal = python::extract<int>( resObj );
if ( retVal >= kdlib::DebugCallbackMax )
{
result = kdlib::DebugCallbackBreak;
break;
}
result = kdlib::DebugCallbackResult(retVal);
} while( FALSE );
}
catch (const python::error_already_set &)
{
printException();
result = kdlib::DebugCallbackBreak;
}
m_pystate = PyEval_SaveThread();
return result;
}
///////////////////////////////////////////////////////////////////////////////
} // end namespace pykd } // end namespace pykd

View File

@ -75,6 +75,8 @@ public:
virtual kdlib::DebugCallbackResult onBreakpoint( kdlib::BREAKPOINT_ID bpId ); virtual kdlib::DebugCallbackResult onBreakpoint( kdlib::BREAKPOINT_ID bpId );
virtual void onExecutionStatusChange( kdlib::ExecutionStatus executionStatus ); virtual void onExecutionStatusChange( kdlib::ExecutionStatus executionStatus );
virtual kdlib::DebugCallbackResult onException( const kdlib::ExceptionInfo &exceptionInfo ); virtual kdlib::DebugCallbackResult onException( const kdlib::ExceptionInfo &exceptionInfo );
virtual kdlib::DebugCallbackResult onModuleLoad( kdlib::MEMOFFSET_64 offset, const std::wstring &name );
virtual kdlib::DebugCallbackResult onModuleUnload( kdlib::MEMOFFSET_64 offset, const std::wstring &name );
private: private:

View File

@ -2,7 +2,7 @@
#define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MAJOR 0
#define PYKD_VERSION_MINOR 3 #define PYKD_VERSION_MINOR 3
#define PYKD_VERSION_SUBVERSION 0 #define PYKD_VERSION_SUBVERSION 0
#define PYKD_VERSION_BUILDNO 1 #define PYKD_VERSION_BUILDNO 2
#define __VER_STR2__(x) #x #define __VER_STR2__(x) #x
#define __VER_STR1__(x) __VER_STR2__(x) #define __VER_STR1__(x) __VER_STR2__(x)

View File

@ -840,12 +840,12 @@ BOOST_PYTHON_MODULE( pykd )
.def( "onBreakpoint", &EventHandler::onBreakpoint, .def( "onBreakpoint", &EventHandler::onBreakpoint,
"Triggered breakpoint event. Parameter is int: ID of breakpoint\n" "Triggered breakpoint event. Parameter is int: ID of breakpoint\n"
"For ignore event method must return eventResult.noChange" ) "For ignore event method must return eventResult.noChange" )
// .def( "onModuleLoad", &EventHandlerWrap::OnModuleLoad, .def( "onModuleLoad", &EventHandler::onModuleLoad,
// "Triggered module load event. Parameter are long: module base, string: module name\n" "Triggered module load event. Parameter are long: module base, string: module name\n"
// "For ignore event method must return eventResult.noChange" ) "For ignore event method must return eventResult.noChange" )
// .def( "onModuleUnload", &EventHandlerWrap::OnModuleUnload, .def( "onModuleUnload", &EventHandler::onModuleUnload,
// "Triggered module unload event. Parameter are long: module base, string: module name\n" "Triggered module unload event. Parameter are long: module base, string: module name\n"
// "For ignore event method must return eventResult.noChange" ) "For ignore event method must return eventResult.noChange" )
.def( "onException", &EventHandler::onException, .def( "onException", &EventHandler::onException,
"Triggered exception event. Parameter - exceptionInfo\n" "Triggered exception event. Parameter - exceptionInfo\n"
"For ignore event method must return eventResult.noChange" ) "For ignore event method must return eventResult.noChange" )