From 6f7c574b6b8c1e6ba6671d589904936253b79644 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Tue, 5 Nov 2013 06:08:27 +0000 Subject: [PATCH] [0.2.x] added : detachAllProcesses ( detach from all process and resume all their threads ) [0.2.x] added : killAllProcesses ( detach from all process then terminate them ) git-svn-id: https://pykd.svn.codeplex.com/svn@86269 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgengine.h | 2 ++ pykd/python/pymod.cpp | 4 ++++ pykd/win/dbgps.cpp | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index 806e783..e880f5c 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -12,6 +12,8 @@ void attachKernel( const std::string &connectOptions = "" ); bool isLocalKernelDebuggerEnabled(); void detachProcess( ULONG processId = -1); void terminateProcess( ULONG processId = -1); +void detachAllProcesses(); +void terminateAllProcesses(); void loadDump( const std::wstring &fileName ); void writeDump( const std::wstring &fileNamem, bool smallDump ); diff --git a/pykd/python/pymod.cpp b/pykd/python/pymod.cpp index 412a4a8..1a63a3b 100644 --- a/pykd/python/pymod.cpp +++ b/pykd/python/pymod.cpp @@ -102,8 +102,12 @@ BOOST_PYTHON_MODULE( pykd ) "Check whether kernel debugging is enabled for the local kernel" ); python::def( "detachProcess", &detachProcess, detachProcess_( boost::python::args( "pid" ), "Stop process debugging") ); + python::def( "detachAllProcesses", &detachAllProcesses, + "Detach from all process and resume all their threads" ); python::def( "killProcess", &terminateProcess, "Stop debugging and terminate current process" ); + python::def( "killAllProcesses", &terminateAllProcesses, + "Detach from all process then terminate them"); python::def( "loadDump", &loadDump, "Load crash dump"); python::def( "isDumpAnalyzing", &isDumpAnalyzing, diff --git a/pykd/win/dbgps.cpp b/pykd/win/dbgps.cpp index 745ebed..2644aad 100644 --- a/pykd/win/dbgps.cpp +++ b/pykd/win/dbgps.cpp @@ -166,7 +166,39 @@ void terminateProcess( ULONG processId ) hres = g_dbgEng->client->DetachCurrentProcess(); if ( FAILED( hres ) ) - throw DbgException( "IDebugClient::DetachCurrentProcess failed" ); + throw DbgException( "IDebugClient::DetachCurrentProcess", hres ); + +} + +/////////////////////////////////////////////////////////////////////////////// + +void detachAllProcesses() +{ + PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); + + HRESULT hres; + + hres = g_dbgEng->client->DetachProcesses(); + + if ( FAILED(hres) ) + throw DbgException( "IDebugClient::DetachProcesses", hres ); +} + +/////////////////////////////////////////////////////////////////////////////// + +void terminateAllProcesses() +{ + PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); + + HRESULT hres; + + hres = g_dbgEng->client->TerminateProcesses(); + if ( FAILED(hres) ) + throw DbgException( "IDebugClient::TerminateProcesses", hres ); + + hres = g_dbgEng->client->DetachProcesses(); + if ( FAILED(hres) ) + throw DbgException( "IDebugClient::DetachProcesses", hres ); }