diff --git a/pykd/pykd_2008.vcproj b/pykd/pykd_2008.vcproj
index 9fa6662..1c2a032 100644
--- a/pykd/pykd_2008.vcproj
+++ b/pykd/pykd_2008.vcproj
@@ -1,7 +1,7 @@
diff --git a/pykd_2008.sln b/pykd_2008.sln
index e8ecace..f135593 100644
--- a/pykd_2008.sln
+++ b/pykd_2008.sln
@@ -2,17 +2,13 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pykd", "pykd\pykd_2008.vcproj", "{FE961905-666F-4908-A212-961465F46F13}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C6254E16-AB8E-41EE-887D-31458E93FC68} = {C6254E16-AB8E-41EE-887D-31458E93FC68}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "targetapp", "test\targetapp\targetapp.vcproj", "{C6254E16-AB8E-41EE-887D-31458E93FC68}"
EndProject
Global
- GlobalSection(TeamFoundationVersionControl) = preSolution
- SccNumberOfProjects = 2
- SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
- SccTeamFoundationServer = https://tfs.codeplex.com/tfs/TFS08
- SccLocalPath0 = .
- SccProjectUniqueName1 = pykd\\pykd_2008.vcproj
- SccProjectName1 = pykd
- SccLocalPath1 = pykd
- EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
@@ -28,8 +24,25 @@ Global
{FE961905-666F-4908-A212-961465F46F13}.Release|Win32.Build.0 = Release|Win32
{FE961905-666F-4908-A212-961465F46F13}.Release|x64.ActiveCfg = Release|x64
{FE961905-666F-4908-A212-961465F46F13}.Release|x64.Build.0 = Release|x64
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Debug|Win32.Build.0 = Debug|Win32
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Debug|x64.ActiveCfg = Debug|x64
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Debug|x64.Build.0 = Debug|x64
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Release|Win32.ActiveCfg = Release|Win32
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Release|Win32.Build.0 = Release|Win32
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Release|x64.ActiveCfg = Release|x64
+ {C6254E16-AB8E-41EE-887D-31458E93FC68}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(TeamFoundationVersionControl) = preSolution
+ SccNumberOfProjects = 2
+ SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
+ SccTeamFoundationServer = https://tfs.codeplex.com/tfs/TFS08
+ SccLocalPath0 = .
+ SccProjectUniqueName1 = pykd\\pykd_2008.vcproj
+ SccProjectName1 = pykd
+ SccLocalPath1 = pykd
+ EndGlobalSection
EndGlobal
diff --git a/test/scripts/_run_pykdtest.cmd b/test/scripts/_run_pykdtest.cmd
new file mode 100644
index 0000000..220ed32
--- /dev/null
+++ b/test/scripts/_run_pykdtest.cmd
@@ -0,0 +1,23 @@
+:: Pass $(TargetDir)\ from Visual Studio
+set TestAppPath=%1
+
+:: Pass $(PlatformName) from Visual Studio
+set TestAppPlatform=%2
+
+set Arch=x64
+if "%PROCESSOR_ARCHITECTURE%" == "x86" (
+ if not defined PROCESSOR_ARCHITEW6432 set Arch=x86
+)
+
+:: Select appropriate python.exe path
+set PythonRegKey=HKLM\Software\Python\PythonCore\2.6\InstallPath
+if "%Arch%" == "x64" (
+ if "%TestAppPlatform%" == "Win32" set PythonRegKey=HKLM\Software\Wow6432Node\Python\PythonCore\2.6\InstallPath
+)
+
+for /F "tokens=3*" %%A in ('reg.exe query %PythonRegKey% /ve 2^>NUL ^| FIND "REG_SZ"') do set PythonInstallPath=%%B
+::echo %PythonInstallPath%
+
+%PythonInstallPath%python.exe "%~dp0pykdtest.py" %TestAppPath%
+
+::pause
diff --git a/test/scripts/pykdtest.py b/test/scripts/pykdtest.py
new file mode 100644
index 0000000..0688453
--- /dev/null
+++ b/test/scripts/pykdtest.py
@@ -0,0 +1,37 @@
+import sys
+import os
+import unittest
+
+# Append current pykd.pyd path to PYTHONPATH
+sys.path.append(os.path.dirname(sys.argv[1]))
+import pykd
+
+class TestPykd(unittest.TestCase):
+
+ def setUp(self):
+ self.targetAppPath = sys.argv[1]
+ self.targetModuleName = os.path.splitext(os.path.basename(self.targetAppPath))[0]
+ self.targetModule = None
+ self.gVerInfoOffset = 0L
+ self.verInfo = None
+
+ def testPykd(self):
+ print self.targetAppPath
+
+ self.assertTrue(pykd.startProcess(self.targetAppPath))
+
+ self.targetModule = pykd.loadModule(self.targetModuleName)
+ self.assertNotEqual(self.targetModule, None)
+ pykd.go()
+
+ self.gVerInfoOffset = pykd.getOffset(self.targetModuleName, "gVerInfo")
+ self.assertNotEqual(self.gVerInfoOffset, 0L)
+
+ self.verInfo = pykd.typedVar(self.targetModuleName, "_OSVERSIONINFOA", self.gVerInfoOffset)
+ self.assertNotEqual(self.verInfo, None)
+ pykd.go()
+
+if __name__ == '__main__':
+ #unittest.main(argv=[])
+ suite = unittest.TestLoader().loadTestsFromTestCase(TestPykd)
+ unittest.TextTestRunner().run(suite)
diff --git a/test/targetapp/stdafx.cpp b/test/targetapp/stdafx.cpp
new file mode 100644
index 0000000..7709cdc
--- /dev/null
+++ b/test/targetapp/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// targetapp.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/test/targetapp/stdafx.h b/test/targetapp/stdafx.h
new file mode 100644
index 0000000..6795c57
--- /dev/null
+++ b/test/targetapp/stdafx.h
@@ -0,0 +1,14 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include
+#include
+
+#define WIN32_LEAN_AND_MEAN
+#include
\ No newline at end of file
diff --git a/test/targetapp/targetapp.cpp b/test/targetapp/targetapp.cpp
new file mode 100644
index 0000000..d9866aa
--- /dev/null
+++ b/test/targetapp/targetapp.cpp
@@ -0,0 +1,37 @@
+#include "stdafx.h"
+
+#include
+
+#include
+
+#include "utils.h"
+
+OSVERSIONINFOA gVerInfo = {0};
+
+void test_getOffset_typedVar()
+{
+ gVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
+ if (!::GetVersionExA(&gVerInfo))
+ throw std::runtime_error("Can't get OS version: " + utils::GetLastErrorStr());
+ __debugbreak();
+}
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ try
+ {
+ test_getOffset_typedVar();
+ }
+ catch(std::exception & ex)
+ {
+ std::cout << ex.what() << std::endl;
+ return 1;
+ }
+ catch (...)
+ {
+ std::cout << "Unknown error" << std::endl;
+ return 1;
+ }
+ return 0;
+}
+
diff --git a/test/targetapp/targetapp.vcproj b/test/targetapp/targetapp.vcproj
new file mode 100644
index 0000000..c5731f9
--- /dev/null
+++ b/test/targetapp/targetapp.vcproj
@@ -0,0 +1,395 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/targetapp/targetver.h b/test/targetapp/targetver.h
new file mode 100644
index 0000000..956cad8
--- /dev/null
+++ b/test/targetapp/targetver.h
@@ -0,0 +1,13 @@
+#pragma once
+
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
diff --git a/test/targetapp/utils.cpp b/test/targetapp/utils.cpp
new file mode 100644
index 0000000..220606e
--- /dev/null
+++ b/test/targetapp/utils.cpp
@@ -0,0 +1,44 @@
+#include "stdafx.h"
+
+#include
+#include
+
+namespace utils
+{
+
+std::string GetWinErrorText(DWORD dwError)
+{
+ HLOCAL hLocal = NULL; // Buffer that gets the error message string
+
+ // Get the error code's textual description
+ DWORD strSize = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL, dwError, 0 /* Default language */, (LPSTR) &hLocal, 0, NULL);
+
+ if (!strSize)
+ {
+ // Is it a network-related error?
+ HMODULE hDll = LoadLibraryEx(TEXT("netmsg.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
+ if (hDll == INVALID_HANDLE_VALUE)
+ return std::string("Can't load netmsg.dll");
+ std::tr1::shared_ptr guard1(hDll, ::FreeLibrary);
+ strSize = FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM,
+ hDll, dwError, 0 /* Default language */, (LPSTR) &hLocal, 0, NULL);
+ }
+
+ if (strSize != NULL)
+ {
+ std::tr1::shared_ptr guard2(hLocal, ::LocalFree);
+ std::string str;
+ str += reinterpret_cast(::LocalLock(hLocal));
+ return str;
+ }
+
+ return std::string("Unknown error.");
+}
+
+std::string GetLastErrorStr()
+{
+ return GetWinErrorText(::GetLastError());
+}
+
+} // namespace utils
\ No newline at end of file
diff --git a/test/targetapp/utils.h b/test/targetapp/utils.h
new file mode 100644
index 0000000..07d2222
--- /dev/null
+++ b/test/targetapp/utils.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include
+
+namespace utils
+{
+
+std::string GetWinErrorText(DWORD dwError);
+
+std::string GetLastErrorStr();
+
+} // namespace utils
\ No newline at end of file