mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:53:23 +08:00
[0.1.x] added : detachProcess
[0.1.x] added : killProcess git-svn-id: https://pykd.svn.codeplex.com/svn@72653 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
5b45c22301
commit
da56036fee
@ -226,6 +226,21 @@ void attachProcess( ULONG processId ) {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void DebugClient::detachProcess()
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = m_client->DetachCurrentProcess();
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugClient::DetachCurrentProcess failed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void detachProcess() {
|
||||||
|
g_dbgClient->detachProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DebugClient::attachKernel( const std::wstring ¶m )
|
void DebugClient::attachKernel( const std::wstring ¶m )
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
@ -383,4 +398,20 @@ ULONG ptrSize()
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void DebugClient::terminateProcess()
|
||||||
|
{
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = m_client->TerminateCurrentProcess();
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugClient::TerminateCurrentProcess failed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void terminateProcess()
|
||||||
|
{
|
||||||
|
g_dbgClient->terminateProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}; // end of namespace pykd
|
}; // end of namespace pykd
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
|
|
||||||
bool compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, bool phyAddr = FALSE );
|
bool compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, bool phyAddr = FALSE );
|
||||||
|
|
||||||
|
void detachProcess();
|
||||||
|
|
||||||
DbgOut dout() {
|
DbgOut dout() {
|
||||||
return DbgOut( m_client );
|
return DbgOut( m_client );
|
||||||
}
|
}
|
||||||
@ -190,6 +192,8 @@ public:
|
|||||||
|
|
||||||
void setExecutionStatus( ULONG status );
|
void setExecutionStatus( ULONG status );
|
||||||
|
|
||||||
|
void terminateProcess();
|
||||||
|
|
||||||
void waitForEvent();
|
void waitForEvent();
|
||||||
|
|
||||||
|
|
||||||
@ -278,6 +282,8 @@ void attachProcess( ULONG processId );
|
|||||||
|
|
||||||
void attachKernel( const std::wstring ¶m );
|
void attachKernel( const std::wstring ¶m );
|
||||||
|
|
||||||
|
void detachProcess();
|
||||||
|
|
||||||
std::string findSymbol( ULONG64 offset );
|
std::string findSymbol( ULONG64 offset );
|
||||||
|
|
||||||
python::tuple getDebuggeeType();
|
python::tuple getDebuggeeType();
|
||||||
@ -298,6 +304,8 @@ ULONG ptrSize();
|
|||||||
|
|
||||||
void setExecutionStatus( ULONG status );
|
void setExecutionStatus( ULONG status );
|
||||||
|
|
||||||
|
void terminateProcess();
|
||||||
|
|
||||||
void waitForEvent();
|
void waitForEvent();
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -370,62 +378,3 @@ void changeDebuggerStatus()
|
|||||||
}; // namespace pykd
|
}; // namespace pykd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#include "dbgext.h"
|
|
||||||
//#include "dbgeventcb.h"
|
|
||||||
//
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
//class dbgClient {
|
|
||||||
//
|
|
||||||
//public:
|
|
||||||
//
|
|
||||||
// dbgClient()
|
|
||||||
// {
|
|
||||||
// m_callbacks = NULL;
|
|
||||||
//
|
|
||||||
// IDebugClient4 *client = NULL;
|
|
||||||
// DebugCreate( __uuidof(IDebugClient4), (void **)&client );
|
|
||||||
//
|
|
||||||
// m_ext = new DbgExt( client );
|
|
||||||
//
|
|
||||||
// client->Release();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ~dbgClient()
|
|
||||||
// {
|
|
||||||
// removeEventsMgr();
|
|
||||||
//
|
|
||||||
// delete m_ext;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void startEventsMgr() {
|
|
||||||
//
|
|
||||||
// m_callbacks = new DbgEventCallbacksManager( m_ext->client );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void removeEventsMgr() {
|
|
||||||
//
|
|
||||||
// if ( m_callbacks )
|
|
||||||
// {
|
|
||||||
// delete m_callbacks;
|
|
||||||
// m_callbacks = NULL;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//private:
|
|
||||||
//
|
|
||||||
// DbgExt *m_ext;
|
|
||||||
// DbgEventCallbacksManager *m_callbacks;
|
|
||||||
//};
|
|
||||||
//
|
|
||||||
//extern dbgClient g_dbgClient;
|
|
||||||
//
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
@ -149,6 +149,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Attach debugger to a exsisting process" )
|
"Attach debugger to a exsisting process" )
|
||||||
.def( "attachKernel", &DebugClient::attachKernel,
|
.def( "attachKernel", &DebugClient::attachKernel,
|
||||||
"Attach debugger to a target's kernel" )
|
"Attach debugger to a target's kernel" )
|
||||||
|
.def( "detachProcess", &DebugClient::detachProcess,
|
||||||
|
"Detach debugger from the current process" )
|
||||||
.def( "expr", &DebugClient::evaluate,
|
.def( "expr", &DebugClient::evaluate,
|
||||||
"Evaluate windbg expression" )
|
"Evaluate windbg expression" )
|
||||||
.def( "findSymbol", &DebugClient::findSymbol,
|
.def( "findSymbol", &DebugClient::findSymbol,
|
||||||
@ -183,6 +185,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Check if kernel dubugging is running" )
|
"Check if kernel dubugging is running" )
|
||||||
.def( "isValid", &DebugClient::isVaValid,
|
.def( "isValid", &DebugClient::isVaValid,
|
||||||
"Check if the virtual address is valid" )
|
"Check if the virtual address is valid" )
|
||||||
|
.def( "killProcess", &DebugClient::terminateProcess,
|
||||||
|
"Stop debugging and terminate current process" )
|
||||||
.def( "loadBytes", &DebugClient::loadBytes, DebugClient_loadBytes( python::args( "offset", "count", "phyAddr" ),
|
.def( "loadBytes", &DebugClient::loadBytes, DebugClient_loadBytes( python::args( "offset", "count", "phyAddr" ),
|
||||||
"Read the block of the target's memory and return it as list of unsigned bytes" ) )
|
"Read the block of the target's memory and return it as list of unsigned bytes" ) )
|
||||||
.def( "loadWords", &DebugClient::loadWords, DebugClient_loadWords( python::args( "offset", "count", "phyAddr" ),
|
.def( "loadWords", &DebugClient::loadWords, DebugClient_loadWords( python::args( "offset", "count", "phyAddr" ),
|
||||||
@ -255,21 +259,21 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Return a CPU regsiter value by the register's name" )
|
"Return a CPU regsiter value by the register's name" )
|
||||||
.def( "reg", &DebugClient::getRegByIndex,
|
.def( "reg", &DebugClient::getRegByIndex,
|
||||||
"Return a CPU regsiter value by the register's value" )
|
"Return a CPU regsiter value by the register's value" )
|
||||||
.def( "setExecutionStatus", &pykd::DebugClient::setExecutionStatus,
|
.def( "setExecutionStatus", &DebugClient::setExecutionStatus,
|
||||||
"Requests that the debugger engine enter an executable state" )
|
"Requests that the debugger engine enter an executable state" )
|
||||||
.def( "step", &pykd::DebugClient::changeDebuggerStatus<DEBUG_STATUS_STEP_OVER>,
|
.def( "step", &DebugClient::changeDebuggerStatus<DEBUG_STATUS_STEP_OVER>,
|
||||||
"Change debugger status to DEBUG_STATUS_STEP_OVER" )
|
"Change debugger status to DEBUG_STATUS_STEP_OVER" )
|
||||||
.def( "trace", &pykd::DebugClient::changeDebuggerStatus<DEBUG_STATUS_STEP_INTO>,
|
.def( "trace", &DebugClient::changeDebuggerStatus<DEBUG_STATUS_STEP_INTO>,
|
||||||
"Change debugger status to DEBUG_STATUS_STEP_INTO" )
|
"Change debugger status to DEBUG_STATUS_STEP_INTO" )
|
||||||
.def( "waitForEvent", &pykd::DebugClient::waitForEvent,
|
.def( "waitForEvent", &DebugClient::waitForEvent,
|
||||||
"Wait for events that breaks into the debugger" )
|
"Wait for events that breaks into the debugger" )
|
||||||
.def( "addSynSymbol", &pykd::DebugClient::addSyntheticSymbol,
|
.def( "addSynSymbol", &DebugClient::addSyntheticSymbol,
|
||||||
"Add new synthetic symbol for virtual address" )
|
"Add new synthetic symbol for virtual address" )
|
||||||
.def( "delAllSynSymbols", &pykd::DebugClient::delAllSyntheticSymbols,
|
.def( "delAllSynSymbols", &DebugClient::delAllSyntheticSymbols,
|
||||||
"Delete all synthetic symbol for all modules")
|
"Delete all synthetic symbol for all modules")
|
||||||
.def( "delSynSymbol", &pykd::DebugClient::delSyntheticSymbol,
|
.def( "delSynSymbol", &DebugClient::delSyntheticSymbol,
|
||||||
"Delete synthetic symbols by virtual address" )
|
"Delete synthetic symbols by virtual address" )
|
||||||
.def( "delSynSymbolsMask", &pykd::DebugClient::delSyntheticSymbolsMask,
|
.def( "delSynSymbolsMask", &DebugClient::delSyntheticSymbolsMask,
|
||||||
"Delete synthetic symbols by mask of module and symbol name");
|
"Delete synthetic symbols by mask of module and symbol name");
|
||||||
|
|
||||||
python::def( "addr64", &addr64,
|
python::def( "addr64", &addr64,
|
||||||
@ -288,6 +292,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Attach debugger to a exsisting process" );
|
"Attach debugger to a exsisting process" );
|
||||||
python::def( "attachKernel", &attachKernel,
|
python::def( "attachKernel", &attachKernel,
|
||||||
"Attach debugger to a kernel target" );
|
"Attach debugger to a kernel target" );
|
||||||
|
python::def( "detachProcess", &detachProcess,
|
||||||
|
"Detach denugger from the current process" );
|
||||||
python::def( "expr", &evaluate,
|
python::def( "expr", &evaluate,
|
||||||
"Evaluate windbg expression" );
|
"Evaluate windbg expression" );
|
||||||
python::def( "findSymbol", &findSymbol,
|
python::def( "findSymbol", &findSymbol,
|
||||||
@ -326,6 +332,8 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Check if script works in windbg context" );
|
"Check if script works in windbg context" );
|
||||||
python::def( "isValid", &isVaValid,
|
python::def( "isValid", &isVaValid,
|
||||||
"Check if the virtual address is valid" );
|
"Check if the virtual address is valid" );
|
||||||
|
python::def( "killProcess", &terminateProcess,
|
||||||
|
"Stop debugging and terminate current process" );
|
||||||
python::def( "loadBytes", &loadBytes, loadBytes_( python::args( "offset", "count", "phyAddr" ),
|
python::def( "loadBytes", &loadBytes, loadBytes_( python::args( "offset", "count", "phyAddr" ),
|
||||||
"Read the block of the target's memory and return it as liat of unsigned bytes" ) );
|
"Read the block of the target's memory and return it as liat of unsigned bytes" ) );
|
||||||
python::def( "loadWords", &loadWords, loadWords_( python::args( "offset", "count", "phyAddr" ),
|
python::def( "loadWords", &loadWords, loadWords_( python::args( "offset", "count", "phyAddr" ),
|
||||||
@ -388,7 +396,6 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Delete synthetic symbols by virtual address" );
|
"Delete synthetic symbols by virtual address" );
|
||||||
boost::python::def( "delSynSymbolsMask", &delSyntheticSymbolsMask,
|
boost::python::def( "delSynSymbolsMask", &delSyntheticSymbolsMask,
|
||||||
"Delete synthetic symbols by mask of module and symbol name");
|
"Delete synthetic symbols by mask of module and symbol name");
|
||||||
|
|
||||||
python::def( "loadExt", &pykd::loadExtension,
|
python::def( "loadExt", &pykd::loadExtension,
|
||||||
"Load a debuger extension" );
|
"Load a debuger extension" );
|
||||||
python::def( "loadModule", &loadModuleByName,
|
python::def( "loadModule", &loadModuleByName,
|
||||||
|
@ -56,7 +56,7 @@ class BaseTest( unittest.TestCase ):
|
|||||||
self.assertTrue( hasattr(pykd, 'loadWChars') )
|
self.assertTrue( hasattr(pykd, 'loadWChars') )
|
||||||
self.assertTrue( hasattr(pykd, 'loadWStr') )
|
self.assertTrue( hasattr(pykd, 'loadWStr') )
|
||||||
self.assertTrue( hasattr(pykd, 'loadWords') )
|
self.assertTrue( hasattr(pykd, 'loadWords') )
|
||||||
self.assertTrue( hasattr(pykd, 'locals') )
|
#self.assertTrue( hasattr(pykd, 'locals') )
|
||||||
self.assertTrue( hasattr(pykd, 'ptrByte') )
|
self.assertTrue( hasattr(pykd, 'ptrByte') )
|
||||||
self.assertTrue( hasattr(pykd, 'ptrDWord') )
|
self.assertTrue( hasattr(pykd, 'ptrDWord') )
|
||||||
self.assertTrue( hasattr(pykd, 'ptrMWord') )
|
self.assertTrue( hasattr(pykd, 'ptrMWord') )
|
||||||
@ -114,9 +114,11 @@ class BaseTest( unittest.TestCase ):
|
|||||||
def testNewAddededApi( self ):
|
def testNewAddededApi( self ):
|
||||||
""" Branch test: new API 0.1.x what must be available """
|
""" Branch test: new API 0.1.x what must be available """
|
||||||
self.assertTrue( hasattr(pykd, 'createDbgClient') )
|
self.assertTrue( hasattr(pykd, 'createDbgClient') )
|
||||||
|
self.asseerTrue( hasattr(pykd, 'detachProcess') )
|
||||||
self.assertTrue( hasattr(pykd, 'diaLoadPdb') )
|
self.assertTrue( hasattr(pykd, 'diaLoadPdb') )
|
||||||
self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) )
|
self.assertTrue( hasattr(pykd, 'getDebuggeeType' ) )
|
||||||
self.assertTrue( hasattr(pykd, 'getExecutionStatus' ) )
|
self.assertTrue( hasattr(pykd, 'getExecutionStatus' ) )
|
||||||
|
self.asseerTrue( hasattr(pykd, 'killProcess') )
|
||||||
self.assertTrue( hasattr(pykd, 'loadExt') )
|
self.assertTrue( hasattr(pykd, 'loadExt') )
|
||||||
self.assertTrue( hasattr(pykd, 'loadPtrList') )
|
self.assertTrue( hasattr(pykd, 'loadPtrList') )
|
||||||
self.assertTrue( hasattr(pykd, 'loadPtrArray') )
|
self.assertTrue( hasattr(pykd, 'loadPtrArray') )
|
||||||
|
Loading…
Reference in New Issue
Block a user