diff --git a/pykd/dbgengine.h b/pykd/dbgengine.h index 188717e..e0360ab 100644 --- a/pykd/dbgengine.h +++ b/pykd/dbgengine.h @@ -12,6 +12,7 @@ void detachProcess( ULONG processId = -1); void terminateProcess( ULONG processId = -1); void loadDump( const std::wstring &fileName ); +void writeDump( const std::wstring &fileNamem, bool smallDump ); bool isDumpAnalyzing(); bool isKernelDebugging(); diff --git a/pykd/pykdver.h b/pykd/pykdver.h index 262c7fe..2fbe79d 100644 --- a/pykd/pykdver.h +++ b/pykd/pykdver.h @@ -2,7 +2,7 @@ #define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MINOR 2 #define PYKD_VERSION_SUBVERSION 0 -#define PYKD_VERSION_BUILDNO 11 +#define PYKD_VERSION_BUILDNO 12 #define __VER_STR2__(x) #x diff --git a/pykd/python/pymod.cpp b/pykd/python/pymod.cpp index 028109f..c1e8b9c 100644 --- a/pykd/python/pymod.cpp +++ b/pykd/python/pymod.cpp @@ -104,6 +104,8 @@ BOOST_PYTHON_MODULE( pykd ) "Check if kernel dubugging is running" ); python::def( "isWindbgExt", &WindbgGlobalSession::isInit, "Check if script works in windbg context" ); + python::def( "writeDump", &writeDump, + "Write memory dump" ); python::def( "breakin", &debugBreak, "Break into debugger" ); diff --git a/pykd/win/dbgeng.cpp b/pykd/win/dbgeng.cpp index 580a948..316f3b0 100644 --- a/pykd/win/dbgeng.cpp +++ b/pykd/win/dbgeng.cpp @@ -144,6 +144,32 @@ void loadDump( const std::wstring &fileName ) /////////////////////////////////////////////////////////////////////////////////// +void writeDump( const std::wstring &fileName, bool smallDump ) +{ + PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate ); + + HRESULT hres; + + ULONG debugClass, debugQualifier; + + hres = g_dbgEng->control->GetDebuggeeType( &debugClass, &debugQualifier ); + + if ( FAILED( hres ) ) + throw DbgException( "IDebugControl::GetDebuggeeType failed" ); + + hres = g_dbgEng->client->WriteDumpFileWide( + fileName.c_str(), + NULL, + smallDump ? DEBUG_DUMP_SMALL : ( debugClass == DEBUG_CLASS_KERNEL ? DEBUG_DUMP_FULL : DEBUG_DUMP_DEFAULT ), + DEBUG_FORMAT_DEFAULT, + NULL ); + + if ( FAILED(hres) ) + throw DbgException( "IDebugClient4::WriteDumpFileWide failed" ); +} + +/////////////////////////////////////////////////////////////////////////////////// + bool isDumpAnalyzing() { PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );