diff --git a/pykd/dllmain.cpp b/pykd/dllmain.cpp
index 8a4edd3..93034ff 100644
--- a/pykd/dllmain.cpp
+++ b/pykd/dllmain.cpp
@@ -1,6 +1,8 @@
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
+#include "kdlib/kdlib.h"
+
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
@@ -8,10 +10,16 @@ BOOL APIENTRY DllMain( HMODULE hModule,
{
switch (ul_reason_for_call)
{
- case DLL_PROCESS_ATTACH:
+ case DLL_PROCESS_ATTACH:
+ kdlib::initialize();
+ break;
+
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
+ break;
+
case DLL_PROCESS_DETACH:
+ kdlib::uninitialize();
break;
}
return TRUE;
diff --git a/pykd/pykd.vcxproj b/pykd/pykd.vcxproj
index 842d8f6..58b0b19 100644
--- a/pykd/pykd.vcxproj
+++ b/pykd/pykd.vcxproj
@@ -55,6 +55,7 @@
true
.pyd
+ true
false
@@ -72,6 +73,14 @@
true
pykd.def
+
+
+
+
+
+
+
+
@@ -88,8 +97,12 @@
$(PYTHON_27_X86_ROOT)\libs;$(BOOST_ROOT)\stage_2.7\lib;%(AdditionalLibraryDirectories)
- "$(ProjectDir)..\test\scripts\_run_pykdtest.cmd" "$(TargetDir)targetapp.exe" $(PlatformName)
+ copy $(ProjectDir)..\Debug\targetapp.exe $(OutDir)targetapp.exe
+
+
+
+
@@ -112,6 +125,7 @@
+
diff --git a/pykd/pykd.vcxproj.filters b/pykd/pykd.vcxproj.filters
index 0e70538..5147b86 100644
--- a/pykd/pykd.vcxproj.filters
+++ b/pykd/pykd.vcxproj.filters
@@ -21,6 +21,9 @@
Header Files
+
+ Header Files
+
diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp
index a85b29d..d3b7dbc 100644
--- a/pykd/pymod.cpp
+++ b/pykd/pymod.cpp
@@ -2,7 +2,7 @@
#include "stdafx.h"
-#include "kdlib/dbgio.h"
+#include "kdlib/kdlib.h"
using namespace kdlib;
@@ -95,26 +95,26 @@ BOOST_PYTHON_MODULE( pykd )
// "Call a WinDBG extension's routine. Parameters: handle returned by loadExt; string command line" );
- // // Manage debug target
+ // Manage debug target
- // python::def( "startProcess", &startProcess,
- // "Start process for debugging" );
- // python::def( "attachProcess", &attachProcess,
- // "Attach debugger to a exsisting process" );
- // python::def( "detachProcess", &detachProcess, detachProcess_( boost::python::args( "pid" ),
- // "Stop process debugging") );
- // python::def( "killProcess", &terminateProcess,
- // "Stop debugging and terminate current process" );
- // python::def( "loadDump", &loadDump,
- // "Load crash dump");
- // python::def( "isDumpAnalyzing", &isDumpAnalyzing,
- // "Check if it is a dump analyzing ( not living debuggee )" );
- // python::def( "isKernelDebugging", &isKernelDebugging,
- // "Check if kernel dubugging is running" );
- // python::def( "isWindbgExt", &WindbgGlobalSession::isInit,
- // "Check if script works in windbg context" );
- // python::def( "writeDump", &writeDump,
- // "Create memory dump file" );
+ python::def( "startProcess", &startProcess,
+ "Start process for debugging" );
+ python::def( "attachProcess", &attachProcess,
+ "Attach debugger to a exsisting process" );
+ //python::def( "detachProcess", &detachProcess, detachProcess_( boost::python::args( "pid" ),
+ // "Stop process debugging") );
+ python::def( "killProcess", &terminateProcess,
+ "Stop debugging and terminate current process" );
+ python::def( "loadDump", &loadDump,
+ "Load crash dump");
+ python::def( "isDumpAnalyzing", &isDumpAnalyzing,
+ "Check if it is a dump analyzing ( not living debuggee )" );
+ python::def( "isKernelDebugging", &isKernelDebugging,
+ "Check if kernel dubugging is running" );
+ //python::def( "isWindbgExt", &WindbgGlobalSession::isInit,
+ // "Check if script works in windbg context" );
+ python::def( "writeDump", &writeDump,
+ "Create memory dump file" );
// python::def( "breakin", &debugBreak,
// "Break into debugger" );
diff --git a/pykd/windbgext.cpp b/pykd/windbgext.cpp
index 08717cd..1a3c6cc 100644
--- a/pykd/windbgext.cpp
+++ b/pykd/windbgext.cpp
@@ -3,50 +3,46 @@
#include "kdlib/kdlib.h"
#include "kdlib/windbg.h"
+#include "windbgext.h"
+
using namespace kdlib;
using namespace kdlib::windbg;
+///////////////////////////////////////////////////////////////////////////////
+
+KDLIB_WINDBG_EXTENSION_INIT( PykdExt );
+
+
///////////////////////////////////////////////////////////////////////////////
extern "C" void initpykd();
-class PykdExt : public WindbgExtension
+void PykdExt::setUp()
{
-public:
- KDLIB_EXT_COMMAND_METHOD(py);
+ WindbgExtension::setUp();
-private:
+ PyImport_AppendInittab("pykd", initpykd );
- void startConsole();
+ Py_Initialize();
- virtual void setUp()
- {
- WindbgExtension::setUp();
+ boost::python::import( "pykd" );
- PyImport_AppendInittab("pykd", initpykd );
+ // перенаправление стандартных потоков ВВ
+ python::object sys = python::import("sys");
- Py_Initialize();
+ sys.attr("stdout") = python::ptr( dbgout );
+ sys.attr("stderr") = python::ptr( dbgout );
+ sys.attr("stdin") = python::ptr( dbgin );
+}
- boost::python::import( "pykd" );
+///////////////////////////////////////////////////////////////////////////////
- // перенаправление стандартных потоков ВВ
- python::object sys = python::import("sys");
+void PykdExt::tearDown()
+{
+ Py_Finalize();
- sys.attr("stdout") = python::ptr( dbgout );
- sys.attr("stderr") = python::ptr( dbgout );
- sys.attr("stdin") = python::ptr( dbgin );
- }
-
- virtual void tearDown()
- {
- Py_Finalize();
-
- WindbgExtension::tearDown();
- }
-
-};
-
-KDLIB_WINDBG_EXTENSION_INIT( PykdExt );
+ WindbgExtension::tearDown();
+}
///////////////////////////////////////////////////////////////////////////////
diff --git a/pykd/windbgext.h b/pykd/windbgext.h
new file mode 100644
index 0000000..cd57ac8
--- /dev/null
+++ b/pykd/windbgext.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "kdlib/windbg.h"
+
+///////////////////////////////////////////////////////////////////////////////
+
+class PykdExt : public kdlib::windbg::WindbgExtension
+{
+public:
+
+ KDLIB_EXT_COMMAND_METHOD(py);
+
+private:
+
+ void startConsole();
+
+ virtual void setUp();
+
+ virtual void tearDown();
+
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
diff --git a/test/scripts/pykdtest.py b/test/scripts/pykdtest.py
index 1c20f3a..c4f5a92 100644
--- a/test/scripts/pykdtest.py
+++ b/test/scripts/pykdtest.py
@@ -28,16 +28,16 @@ import target
class StartProcessWithoutParamsTest(unittest.TestCase):
def testStart(self):
- target.processId = pykd.startProcess( target.appPath )
- target.module = pykd.module( target.moduleName )
- target.module.reload();
- print "\n" + str( pykd.getSystemVersion() )
- pykd.go()
+ target.processId = pykd.startProcess( target.appPath )
+ # target.module = pykd.module( target.moduleName )
+ # target.module.reload();
+ # print "\n" + str( pykd.getSystemVersion() )
+ # pykd.go()
class TerminateProcessTest(unittest.TestCase):
def testKill(self):
pykd.killProcess( target.processId )
- pykd.detachProcess( target.processId )
+ #pykd.detachProcess( target.processId )
def getTestSuite( singleName = "" ):
if singleName == "":
@@ -76,6 +76,4 @@ if __name__ == "__main__":
target.appPath = sys.argv[1]
target.moduleName = os.path.splitext(os.path.basename(target.appPath))[0]
- unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getTestSuite() )
-
-
+ unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getTestSuite() )\