[0.2.x] added : getCurrentProcess, setCurrentProcess, getImplicitThread, getImplicitThread

git-svn-id: https://pykd.svn.codeplex.com/svn@80000 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2012-10-04 05:57:48 +00:00 committed by Mikhail I. Izmestev
parent 3a4a5400b8
commit 8e13e35311
3 changed files with 79 additions and 0 deletions

View File

@ -84,5 +84,12 @@ ULONG breakPointSet( ULONG64 offset, bool hardware = false, ULONG size = 0, ULON
void breakPointRemove( ULONG id ); void breakPointRemove( ULONG id );
void breakPointRemoveAll(); void breakPointRemoveAll();
// processes end threads
ULONG64 getCurrentProcess();
ULONG64 getImplicitThread();
void setCurrentProcess( ULONG64 processAddr );
void setImplicitThread( ULONG64 threadAddr );
}; };

View File

@ -235,6 +235,16 @@ BOOST_PYTHON_MODULE( pykd )
python::def( "removeAllBp", &removeAllBp, python::def( "removeAllBp", &removeAllBp,
"Remove all breapoints" ); "Remove all breapoints" );
// processes and threads
python::def( "getCurrentProcess", &getCurrentProcess,
"Return pointer to current process's block" );
python::def( "getImplicitThread", &getImplicitThread,
"Return implicit thread for current process" );
python::def( "setCurrentProcess", &setCurrentProcess,
"Set current process by address" );
python::def( "setImplicitThread", &setImplicitThread,
"Set implicit thread for current process" );
// custom types // custom types
python::def( "createStruct", &CustomStruct::create, CustomStruct_create( python::args( "name", "align" ), python::def( "createStruct", &CustomStruct::create, CustomStruct_create( python::args( "name", "align" ),
"Create empty structure. Use append() method for building" ) ); "Create empty structure. Use append() method for building" ) );

View File

@ -943,6 +943,68 @@ HRESULT STDMETHODCALLTYPE DebugEngine::Breakpoint(
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
ULONG64
getCurrentProcess()
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
ULONG64 processAddr = 0;
hres = g_dbgEng->system->GetImplicitProcessDataOffset( &processAddr );
if ( FAILED( hres ) )
throw DbgException( "IDebugSystemObjects2::GetImplicitProcessDataOffset failed" );
return processAddr;
}
///////////////////////////////////////////////////////////////////////////////
ULONG64
getImplicitThread()
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
ULONG64 threadOffset = -1;
hres = g_dbgEng->system->GetImplicitThreadDataOffset( &threadOffset );
if ( FAILED( hres ) )
throw DbgException( "IDebugSystemObjects2::GetImplicitThreadDataOffset failed" );
return threadOffset;
}
///////////////////////////////////////////////////////////////////////////////
void setCurrentProcess( ULONG64 processAddr )
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
processAddr = addr64(processAddr);
hres = g_dbgEng->system->SetImplicitProcessDataOffset( processAddr );
if ( FAILED( hres ) )
throw DbgException( "IDebugSystemObjects2::SetImplicitProcessDataOffset failed" );
}
///////////////////////////////////////////////////////////////////////////////
void setImplicitThread( ULONG64 threadAddr )
{
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
HRESULT hres;
threadAddr = addr64(threadAddr);
hres = g_dbgEng->system->SetImplicitThreadDataOffset( threadAddr );
if ( FAILED( hres ) )
throw DbgException( "IDebugSystemObjects2::SetImplicitThreadDataOffset failed" );
}
///////////////////////////////////////////////////////////////////////////////
} // end pykd namespace } // end pykd namespace