From bd19263aede052f5d8e3c923f62df9a409313b91 Mon Sep 17 00:00:00 2001
From: "SND\\kernelnet_cp"
 <SND\kernelnet_cp@9b283d60-5439-405e-af05-b73fd8c4d996>
Date: Mon, 28 Apr 2014 08:41:43 +0000
Subject: [PATCH] [0.3.x] fixed : issue #12956 ( setCurrentThread not actually
 switch current thread )

git-svn-id: https://pykd.svn.codeplex.com/svn@88124 9b283d60-5439-405e-af05-b73fd8c4d996
---
 pykd-0.3-2012.sln     | 122 +++++++++++++++++++----
 pykd/pycpucontext.cpp | 200 +++++++++++++++++++++++++++++++++----
 pykd/pycpucontext.h   | 225 +++++++++++++++++++++++++++---------------
 pykd/pymod.cpp        |  38 ++++---
 4 files changed, 445 insertions(+), 140 deletions(-)

diff --git a/pykd-0.3-2012.sln b/pykd-0.3-2012.sln
index 1dde291..11895bd 100644
--- a/pykd-0.3-2012.sln
+++ b/pykd-0.3-2012.sln
@@ -9,27 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{A7AF
 	EndProjectSection
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "snippets", "snippets", "{AAB21DD2-B0EE-493E-8415-5195F18879EB}"
-	ProjectSection(SolutionItems) = preProject
-		snippets\accessmask.py = snippets\accessmask.py
-		snippets\avl.py = snippets\avl.py
-		snippets\cr0.py = snippets\cr0.py
-		snippets\cr4.py = snippets\cr4.py
-		snippets\ctlcode.py = snippets\ctlcode.py
-		snippets\export.py = snippets\export.py
-		snippets\findhandle.py = snippets\findhandle.py
-		snippets\findtag.py = snippets\findtag.py
-		snippets\gdt.py = snippets\gdt.py
-		snippets\help.py = snippets\help.py
-		snippets\iat.py = snippets\iat.py
-		snippets\nbl.py = snippets\nbl.py
-		snippets\ndis.py = snippets\ndis.py
-		snippets\ntobj.py = snippets\ntobj.py
-		snippets\pytowiki.py = snippets\pytowiki.py
-		snippets\ssdt.py = snippets\ssdt.py
-		snippets\stkdelta.py = snippets\stkdelta.py
-		snippets\stkwalk.py = snippets\stkwalk.py
-		snippets\wfp.py = snippets\wfp.py
-	EndProjectSection
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "um", "um", "{EEFC9510-DFA7-439E-801E-48FCE72766AD}"
 	ProjectSection(SolutionItems) = preProject
@@ -48,16 +27,26 @@ Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "pykdtest", "test\scripts\py
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5} = {C4C45791-0201-4406-BC5C-A384B01E3BF5}
 	EndProjectSection
 EndProject
+Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "snippets", "snippets\snippets.pyproj", "{6471FEDC-3129-410F-BFFC-4BC89707E5EC}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug_2.7|Any CPU = Debug_2.7|Any CPU
 		Debug_2.7|Mixed Platforms = Debug_2.7|Mixed Platforms
 		Debug_2.7|Win32 = Debug_2.7|Win32
 		Debug_2.7|x64 = Debug_2.7|x64
+		Debug|Any CPU = Debug|Any CPU
+		Debug|Mixed Platforms = Debug|Mixed Platforms
+		Debug|Win32 = Debug|Win32
+		Debug|x64 = Debug|x64
 		Release_2.7|Any CPU = Release_2.7|Any CPU
 		Release_2.7|Mixed Platforms = Release_2.7|Mixed Platforms
 		Release_2.7|Win32 = Release_2.7|Win32
 		Release_2.7|x64 = Release_2.7|x64
+		Release|Any CPU = Release|Any CPU
+		Release|Mixed Platforms = Release|Mixed Platforms
+		Release|Win32 = Release|Win32
+		Release|x64 = Release|x64
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug_2.7|Any CPU.ActiveCfg = Debug|Win32
@@ -70,6 +59,15 @@ Global
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug_2.7|x64.ActiveCfg = Debug|x64
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug_2.7|x64.Build.0 = Debug|x64
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug_2.7|x64.Deploy.0 = Debug|x64
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|Mixed Platforms.Deploy.0 = Debug|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|Win32.ActiveCfg = Debug|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|Win32.Build.0 = Debug|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|Win32.Deploy.0 = Debug|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|x64.ActiveCfg = Debug|x64
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Debug|x64.Build.0 = Debug|x64
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release_2.7|Any CPU.ActiveCfg = Release|Win32
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release_2.7|Mixed Platforms.ActiveCfg = Release|Win32
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release_2.7|Mixed Platforms.Build.0 = Release|Win32
@@ -80,6 +78,15 @@ Global
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release_2.7|x64.ActiveCfg = Release|x64
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release_2.7|x64.Build.0 = Release|x64
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release_2.7|x64.Deploy.0 = Release|x64
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Any CPU.ActiveCfg = Release|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Mixed Platforms.Deploy.0 = Release|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Win32.ActiveCfg = Release|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Win32.Build.0 = Release|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|Win32.Deploy.0 = Release|Win32
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|x64.ActiveCfg = Release|x64
+		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF}.Release|x64.Build.0 = Release|x64
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug_2.7|Any CPU.ActiveCfg = Debug|Win32
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug_2.7|Mixed Platforms.ActiveCfg = Debug|Win32
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug_2.7|Mixed Platforms.Build.0 = Debug|Win32
@@ -90,6 +97,15 @@ Global
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug_2.7|x64.ActiveCfg = Debug|x64
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug_2.7|x64.Build.0 = Debug|x64
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug_2.7|x64.Deploy.0 = Debug|x64
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|Mixed Platforms.Deploy.0 = Debug|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|Win32.ActiveCfg = Debug|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|Win32.Build.0 = Debug|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|Win32.Deploy.0 = Debug|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|x64.ActiveCfg = Debug|x64
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Debug|x64.Build.0 = Debug|x64
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release_2.7|Any CPU.ActiveCfg = Release|Win32
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release_2.7|Mixed Platforms.ActiveCfg = Release|Win32
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release_2.7|Mixed Platforms.Build.0 = Release|Win32
@@ -100,6 +116,15 @@ Global
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release_2.7|x64.ActiveCfg = Release|x64
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release_2.7|x64.Build.0 = Release|x64
 		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release_2.7|x64.Deploy.0 = Release|x64
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|Any CPU.ActiveCfg = Release|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|Mixed Platforms.Deploy.0 = Release|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|Win32.ActiveCfg = Release|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|Win32.Build.0 = Release|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|Win32.Deploy.0 = Release|Win32
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|x64.ActiveCfg = Release|x64
+		{3E9C538F-F060-4E86-AB7D-D44439615B63}.Release|x64.Build.0 = Release|x64
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug_2.7|Any CPU.ActiveCfg = Debug_2.7|Win32
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug_2.7|Mixed Platforms.ActiveCfg = Debug_2.7|Win32
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug_2.7|Mixed Platforms.Build.0 = Debug_2.7|Win32
@@ -110,6 +135,15 @@ Global
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug_2.7|x64.ActiveCfg = Debug_2.7|x64
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug_2.7|x64.Build.0 = Debug_2.7|x64
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug_2.7|x64.Deploy.0 = Debug_2.7|x64
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|Any CPU.ActiveCfg = Debug_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|Mixed Platforms.ActiveCfg = Debug_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|Mixed Platforms.Build.0 = Debug_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|Mixed Platforms.Deploy.0 = Debug_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|Win32.ActiveCfg = Debug_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|Win32.Build.0 = Debug_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|Win32.Deploy.0 = Debug_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|x64.ActiveCfg = Debug_2.7|x64
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Debug|x64.Build.0 = Debug_2.7|x64
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release_2.7|Any CPU.ActiveCfg = Release_2.7|Win32
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release_2.7|Mixed Platforms.ActiveCfg = Release_2.7|Win32
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release_2.7|Mixed Platforms.Build.0 = Release_2.7|Win32
@@ -120,6 +154,15 @@ Global
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release_2.7|x64.ActiveCfg = Release_2.7|x64
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release_2.7|x64.Build.0 = Release_2.7|x64
 		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release_2.7|x64.Deploy.0 = Release_2.7|x64
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|Any CPU.ActiveCfg = Release_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|Mixed Platforms.ActiveCfg = Release_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|Mixed Platforms.Build.0 = Release_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|Mixed Platforms.Deploy.0 = Release_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|Win32.ActiveCfg = Release_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|Win32.Build.0 = Release_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|Win32.Deploy.0 = Release_2.7|Win32
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|x64.ActiveCfg = Release_2.7|x64
+		{C4C45791-0201-4406-BC5C-A384B01E3BF5}.Release|x64.Build.0 = Release_2.7|x64
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug_2.7|Any CPU.ActiveCfg = Debug|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug_2.7|Any CPU.Build.0 = Debug|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug_2.7|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -127,12 +170,48 @@ Global
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug_2.7|Win32.ActiveCfg = Debug|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug_2.7|Win32.Build.0 = Debug|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug_2.7|x64.ActiveCfg = Debug|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Debug|x64.ActiveCfg = Debug|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release_2.7|Any CPU.ActiveCfg = Release|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release_2.7|Any CPU.Build.0 = Release|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release_2.7|Mixed Platforms.ActiveCfg = Release|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release_2.7|Mixed Platforms.Build.0 = Release|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release_2.7|Win32.ActiveCfg = Release|Any CPU
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release_2.7|x64.ActiveCfg = Release|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release|Any CPU.Build.0 = Release|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release|Win32.ActiveCfg = Release|Any CPU
+		{3F0BE77E-19B0-4192-B432-44A25805BCB8}.Release|x64.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug_2.7|Any CPU.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug_2.7|Any CPU.Build.0 = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug_2.7|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug_2.7|Mixed Platforms.Build.0 = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug_2.7|Win32.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug_2.7|x64.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release_2.7|Any CPU.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release_2.7|Any CPU.Build.0 = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release_2.7|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release_2.7|Mixed Platforms.Build.0 = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release_2.7|Win32.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release_2.7|x64.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release|Win32.ActiveCfg = Release|Any CPU
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC}.Release|x64.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -141,5 +220,6 @@ Global
 		{0E4CC688-F2F5-499F-9C07-0F2CAEE0D3EF} = {5A3C2DA6-AE91-4025-AC03-A58BD03CEBCD}
 		{3F0BE77E-19B0-4192-B432-44A25805BCB8} = {5A3C2DA6-AE91-4025-AC03-A58BD03CEBCD}
 		{EEFC9510-DFA7-439E-801E-48FCE72766AD} = {A7AF87D2-983B-4B3A-823F-5A2C6989672E}
+		{6471FEDC-3129-410F-BFFC-4BC89707E5EC} = {AAB21DD2-B0EE-493E-8415-5195F18879EB}
 	EndGlobalSection
 EndGlobal
diff --git a/pykd/pycpucontext.cpp b/pykd/pycpucontext.cpp
index 5ec7f1b..6c26bac 100644
--- a/pykd/pycpucontext.cpp
+++ b/pykd/pycpucontext.cpp
@@ -9,13 +9,16 @@ namespace pykd {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-python::object CPUContextAdapter::getRegisterByName( kdlib::CPUContextPtr& cpu, const std::wstring &name )
+python::object getRegisterByName( const std::wstring &name )
 {
     kdlib::NumVariant var;
 
     do {
+
         AutoRestorePyState  pystate;
-        var = cpu->getRegisterByName(name);
+
+        var = kdlib::getRegisterByName(name);
+    
     } while(false);
 
     return NumVariantAdaptor::convertToPython( var );
@@ -23,30 +26,14 @@ python::object CPUContextAdapter::getRegisterByName( kdlib::CPUContextPtr& cpu,
 
 ///////////////////////////////////////////////////////////////////////////////
 
-python::object CPUContextAdapter::getRegisterByIndex( kdlib::CPUContextPtr& cpu, unsigned long  index )
-{
-    kdlib::NumVariant var;
-    std::wstring name;
-
-    do {
-        AutoRestorePyState  pystate;
-        var = cpu->getRegisterByIndex(index);
-        name = cpu->getRegisterName(index);
-    }while(false);
-
-    return python::make_tuple( name, NumVariantAdaptor::convertToPython( var ) );
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-python::list  CPUContextAdapter::getStack( kdlib::CPUContextPtr& cpu )
+python::list getCurrentStack()
 {
     kdlib::StackPtr  stack;
     unsigned long  numberFrames;
 
     do {
         AutoRestorePyState  pystate;
-        stack = kdlib::getStack(cpu);
+        stack = kdlib::getStack();
         numberFrames = stack->getFrameCount();
     } while(false);
 
@@ -72,7 +59,6 @@ std::wstring StackFrameAdapter::print( kdlib::StackFramePtr& frame )
 
     return sstr.str();
 }
-
 ///////////////////////////////////////////////////////////////////////////////
 
 python::list StackFrameAdapter::getParamsList( kdlib::StackFramePtr&  frame)
@@ -191,4 +177,176 @@ python::dict StackFrameAdapter::getLocalsDict(kdlib::StackFramePtr& frame)
 
 ///////////////////////////////////////////////////////////////////////////////
 
+
+
+
+
+//python::object CPUContextAdapter::getRegisterByIndex( kdlib::CPUContextPtr& cpu, unsigned long  index )
+//{
+//    kdlib::NumVariant var;
+//    std::wstring name;
+//
+//    do {
+//        AutoRestorePyState  pystate;
+//        var = cpu->getRegisterByIndex(index);
+//        name = cpu->getRegisterName(index);
+//    }while(false);
+//
+//    return python::make_tuple( name, NumVariantAdaptor::convertToPython( var ) );
+//}
+//
+/////////////////////////////////////////////////////////////////////////////////
+//
+//python::list  CPUContextAdapter::getStack( kdlib::CPUContextPtr& cpu )
+//{
+//    kdlib::StackPtr  stack;
+//    unsigned long  numberFrames;
+//
+//    do {
+//        AutoRestorePyState  pystate;
+//        stack = kdlib::getStack(cpu);
+//        numberFrames = stack->getFrameCount();
+//    } while(false);
+//
+//    python::list  lst;
+//    for ( unsigned long  i = 0; i < numberFrames; ++i )
+//        lst.append( stack->getFrame(i) );
+//
+//    return lst;
+//}
+//
+/////////////////////////////////////////////////////////////////////////////////
+//
+//std::wstring StackFrameAdapter::print( kdlib::StackFramePtr& frame )
+//{
+//    AutoRestorePyState  pystate;
+//
+//    std::wstringstream sstr;
+//    sstr << L"Frame: ";
+//    sstr << L"IP=" << std::hex << frame->getIP() << L"  ";
+//    sstr << L"Return=" << std::hex << frame->getRET() << L"  ";
+//    sstr << L"Frame Offset=" << std::hex << frame->getFP() << L"  ";
+//    sstr << L"Stack Offset=" << std::hex << frame->getSP();
+//
+//    return sstr.str();
+//}
+//
+/////////////////////////////////////////////////////////////////////////////////
+//
+//python::list StackFrameAdapter::getParamsList( kdlib::StackFramePtr&  frame)
+//{
+//    typedef std::vector< std::pair< std::wstring, kdlib::TypedVarPtr> >  FuncParamList;
+//
+//    FuncParamList  paramLst;
+//    unsigned long  paramCount;
+//
+//    do {
+//        AutoRestorePyState  pystate;
+//        paramCount = frame->getTypedParamCount();
+//        for ( unsigned long i = 0; i < paramCount; ++i )
+//        {
+//            kdlib::TypedVarPtr  param = frame->getTypedParam(i);
+//            std::wstring  paramName =   frame->getTypedParamName(i);
+//
+//            paramLst.push_back( std::make_pair( paramName, param) );
+//        }
+//    } while(false);
+//
+//    python::list  pyLst;
+//
+//    for ( unsigned long i = 0; i < paramCount; ++i )
+//        pyLst.append( python::make_tuple( paramLst[i].first, paramLst[i].second ) );
+//
+//    return pyLst;
+//}
+//
+/////////////////////////////////////////////////////////////////////////////////
+//
+//python::dict StackFrameAdapter::getParamsDict( kdlib::StackFramePtr&  frame)
+//{
+//    typedef std::vector< std::pair< std::wstring, kdlib::TypedVarPtr> >  FuncParamList;
+//
+//    FuncParamList  paramLst;
+//    unsigned long  paramCount;
+//
+//    do {
+//        AutoRestorePyState  pystate;
+//        paramCount = frame->getTypedParamCount();
+//        for ( unsigned long i = 0; i < paramCount; ++i )
+//        {
+//            kdlib::TypedVarPtr  param = frame->getTypedParam(i);
+//            std::wstring  paramName =   frame->getTypedParamName(i);
+//
+//            paramLst.push_back( std::make_pair( paramName, param) );
+//        }
+//    } while(false);
+//
+//    python::dict  pyLst;
+//
+//    for ( unsigned long i = 0; i < paramCount; ++i )
+//        pyLst[paramLst[i].first] = paramLst[i].second;
+//
+//    return pyLst;
+//}
+//
+/////////////////////////////////////////////////////////////////////////////////
+//
+//python::list StackFrameAdapter::getLocalsList(kdlib::StackFramePtr& frame)
+//{
+//    typedef std::vector< std::pair< std::wstring, kdlib::TypedVarPtr> >  LocalVarList;
+//
+//    LocalVarList  localLst;
+//    unsigned long  localCount;
+//
+//    do {
+//        AutoRestorePyState  pystate;
+//        localCount = frame->getLocalVarCount();
+//        for ( unsigned long i = 0; i < localCount; ++i )
+//        {
+//            kdlib::TypedVarPtr  param = frame->getLocalVar(i);
+//            std::wstring  paramName =  frame->getLocalVarName(i);
+//
+//            localLst.push_back( std::make_pair( paramName, param) );
+//        }
+//    } while(false);
+//
+//    python::list  pyLst;
+//
+//    for ( unsigned long i = 0; i < localCount; ++i )
+//        pyLst.append( python::make_tuple( localLst[i].first, localLst[i].second ) );
+//
+//    return pyLst;
+//}
+//
+/////////////////////////////////////////////////////////////////////////////////
+//
+//python::dict StackFrameAdapter::getLocalsDict(kdlib::StackFramePtr& frame)
+//{
+//    typedef std::vector< std::pair< std::wstring, kdlib::TypedVarPtr> >  LocalVarList;
+//
+//    LocalVarList  localLst;
+//    unsigned long  localCount;
+//
+//    do {
+//        AutoRestorePyState  pystate;
+//        localCount = frame->getLocalVarCount();
+//        for ( unsigned long i = 0; i < localCount; ++i )
+//        {
+//            kdlib::TypedVarPtr  param = frame->getLocalVar(i);
+//            std::wstring  paramName =  frame->getLocalVarName(i);
+//
+//            localLst.push_back( std::make_pair( paramName, param) );
+//        }
+//    } while(false);
+//
+//    python::dict  pyLst;
+//
+//    for ( unsigned long i = 0; i < localCount; ++i )
+//        pyLst[localLst[i].first] = localLst[i].second;
+//
+//    return pyLst;
+//}
+
+///////////////////////////////////////////////////////////////////////////////
+
 } // end namespace pykd
diff --git a/pykd/pycpucontext.h b/pykd/pycpucontext.h
index a8ab3a5..c9d115b 100644
--- a/pykd/pycpucontext.h
+++ b/pykd/pycpucontext.h
@@ -64,51 +64,45 @@ public:
     }
 };
 
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
 
-
-inline kdlib::CPUContextPtr loadCPUCurrentContext() {
-    AutoRestorePyState  pystate;
-    return kdlib::loadCPUCurrentContext();
-}
-
-inline kdlib::CPUContextPtr loadCPUContextByIndex( unsigned long index ) {
-    AutoRestorePyState  pystate;
-    return kdlib::loadCPUContextByIndex(index);
-}
+python::object getRegisterByName( const std::wstring &name );
 
 inline unsigned long long loadMSR( unsigned long  msrIndex ) 
 {
     AutoRestorePyState  pystate;
-    return kdlib::loadCPUCurrentContext()->loadMSR( msrIndex );
+    return kdlib::loadMSR(msrIndex);
 }
 
 inline void setMSR( unsigned long  msrIndex, unsigned long long value )
 {  
     AutoRestorePyState  pystate;
-    return kdlib::loadCPUCurrentContext()->setMSR( msrIndex, value );
+    return kdlib::setMSR( msrIndex, value );
 }
 
 inline kdlib::CPUType getProcessorMode() {
     AutoRestorePyState  pystate;
-    return kdlib::loadCPUCurrentContext()->getCPUMode();
+    return kdlib::getCPUMode();
 }
 
 inline kdlib::CPUType getProcessorType() {
     AutoRestorePyState  pystate;
-    return kdlib::loadCPUCurrentContext()->getCPUType();
+    return kdlib::getCPUType();
 }
 
 inline void setProcessorMode( kdlib::CPUType mode ) {
     AutoRestorePyState  pystate;
-    kdlib::loadCPUCurrentContext()->setCPUMode(mode);
+    kdlib::setCPUMode(mode);
 }
 
+
 inline void switchProcessorMode() {
     AutoRestorePyState  pystate;
-    kdlib::loadCPUCurrentContext()->switchCPUMode();
+    kdlib::switchCPUMode();
 }
 
+python::list getCurrentStack();
+
 inline kdlib::StackFramePtr getCurrentFrame() {
     AutoRestorePyState  pystate;
     return kdlib::getStack()->getFrame(0);
@@ -122,73 +116,148 @@ inline kdlib::TypedVarPtr getParam( const std::wstring &name ) {
     return StackFrameAdapter::getParam( getCurrentFrame(), name );
 }
 
-inline python::list getLocals() {
-    return StackFrameAdapter::getLocalsList( getCurrentFrame() );
-}
-
 inline kdlib::TypedVarPtr getLocal( const std::wstring &name ) {
     return StackFrameAdapter::getLocal( getCurrentFrame(), name );
 }
 
-
-class CPUContextAdapter
-{
-public:
-    static python::object getRegisterByName( kdlib::CPUContextPtr& cpu, const std::wstring &name );
-    static python::object getRegisterByIndex( kdlib::CPUContextPtr& cpu, unsigned long index );
-    static python::list getStack( kdlib::CPUContextPtr& cpu );
-    
-    static kdlib::MEMOFFSET_64 getIP( kdlib::CPUContextPtr& cpu ) 
-    {
-        AutoRestorePyState  pystate;
-        return cpu->getIP();
-    }
-    
-    static kdlib::MEMOFFSET_64 getSP( kdlib::CPUContextPtr& cpu )
-    {
-        AutoRestorePyState  pystate;
-        return cpu->getSP();
-    }
-
-    static kdlib::MEMOFFSET_64 getFP( kdlib::CPUContextPtr& cpu )
-    {
-        AutoRestorePyState  pystate;
-        return cpu->getFP();
-    }
-
-    static kdlib::CPUType getCPUType( kdlib::CPUContextPtr& cpu )
-    {
-        AutoRestorePyState  pystate;
-        return cpu->getCPUType();
-    }
-
-    static kdlib::CPUType getCPUMode( kdlib::CPUContextPtr& cpu )
-    {
-        AutoRestorePyState  pystate;
-        return cpu->getCPUMode();
-    }
-
-    static void setCPUMode( kdlib::CPUContextPtr& cpu, kdlib::CPUType mode )
-    {
-        AutoRestorePyState  pystate;
-        cpu->setCPUMode(mode);
-    }
-
-    static void switchCPUMode( kdlib::CPUContextPtr& cpu )
-    {
-        AutoRestorePyState  pystate;
-        cpu->switchCPUMode();
-    }
-};
-
-inline python::object getRegisterByName( const std::wstring &name )
-{
-    return CPUContextAdapter::getRegisterByName( kdlib::loadCPUCurrentContext(), name );
+inline python::list getLocals() {
+    return StackFrameAdapter::getLocalsList( getCurrentFrame() );
 }
 
-inline python::list getCurrentStack() {
-    return CPUContextAdapter::getStack( kdlib::loadCPUCurrentContext() );
-}
+
+
+
+
+
+
+
+
+
+
+//
+//
+//inline kdlib::CPUContextPtr loadCPUCurrentContext() {
+//    AutoRestorePyState  pystate;
+//    return kdlib::loadCPUCurrentContext();
+//}
+//
+//inline kdlib::CPUContextPtr loadCPUContextByIndex( unsigned long index ) {
+//    AutoRestorePyState  pystate;
+//    return kdlib::loadCPUContextByIndex(index);
+//}
+//
+//inline unsigned long long loadMSR( unsigned long  msrIndex ) 
+//{
+//    AutoRestorePyState  pystate;
+//    return kdlib::loadCPUCurrentContext()->loadMSR( msrIndex );
+//}
+//
+//inline void setMSR( unsigned long  msrIndex, unsigned long long value )
+//{  
+//    AutoRestorePyState  pystate;
+//    return kdlib::loadCPUCurrentContext()->setMSR( msrIndex, value );
+//}
+//
+//inline kdlib::CPUType getProcessorMode() {
+//    AutoRestorePyState  pystate;
+//    return kdlib::loadCPUCurrentContext()->getCPUMode();
+//}
+//
+//inline kdlib::CPUType getProcessorType() {
+//    AutoRestorePyState  pystate;
+//    return kdlib::loadCPUCurrentContext()->getCPUType();
+//}
+//
+//inline void setProcessorMode( kdlib::CPUType mode ) {
+//    AutoRestorePyState  pystate;
+//    kdlib::loadCPUCurrentContext()->setCPUMode(mode);
+//}
+//
+//inline void switchProcessorMode() {
+//    AutoRestorePyState  pystate;
+//    kdlib::loadCPUCurrentContext()->switchCPUMode();
+//}
+//
+//inline kdlib::StackFramePtr getCurrentFrame() {
+//    AutoRestorePyState  pystate;
+//    return kdlib::getStack()->getFrame(0);
+//}
+//
+//inline python::list getParams() {
+//    return StackFrameAdapter::getParamsList( getCurrentFrame() );
+//}
+//
+//inline kdlib::TypedVarPtr getParam( const std::wstring &name ) {
+//    return StackFrameAdapter::getParam( getCurrentFrame(), name );
+//}
+//
+//inline python::list getLocals() {
+//    return StackFrameAdapter::getLocalsList( getCurrentFrame() );
+//}
+//
+//inline kdlib::TypedVarPtr getLocal( const std::wstring &name ) {
+//    return StackFrameAdapter::getLocal( getCurrentFrame(), name );
+//}
+//
+//
+//class CPUContextAdapter
+//{
+//public:
+//    static python::object getRegisterByName( kdlib::CPUContextPtr& cpu, const std::wstring &name );
+//    static python::object getRegisterByIndex( kdlib::CPUContextPtr& cpu, unsigned long index );
+//    static python::list getStack( kdlib::CPUContextPtr& cpu );
+//    
+//    static kdlib::MEMOFFSET_64 getIP( kdlib::CPUContextPtr& cpu ) 
+//    {
+//        AutoRestorePyState  pystate;
+//        return cpu->getIP();
+//    }
+//    
+//    static kdlib::MEMOFFSET_64 getSP( kdlib::CPUContextPtr& cpu )
+//    {
+//        AutoRestorePyState  pystate;
+//        return cpu->getSP();
+//    }
+//
+//    static kdlib::MEMOFFSET_64 getFP( kdlib::CPUContextPtr& cpu )
+//    {
+//        AutoRestorePyState  pystate;
+//        return cpu->getFP();
+//    }
+//
+//    static kdlib::CPUType getCPUType( kdlib::CPUContextPtr& cpu )
+//    {
+//        AutoRestorePyState  pystate;
+//        return cpu->getCPUType();
+//    }
+//
+//    static kdlib::CPUType getCPUMode( kdlib::CPUContextPtr& cpu )
+//    {
+//        AutoRestorePyState  pystate;
+//        return cpu->getCPUMode();
+//    }
+//
+//    static void setCPUMode( kdlib::CPUContextPtr& cpu, kdlib::CPUType mode )
+//    {
+//        AutoRestorePyState  pystate;
+//        cpu->setCPUMode(mode);
+//    }
+//
+//    static void switchCPUMode( kdlib::CPUContextPtr& cpu )
+//    {
+//        AutoRestorePyState  pystate;
+//        cpu->switchCPUMode();
+//    }
+//};
+//
+//inline python::object getRegisterByName( const std::wstring &name )
+//{
+//    return CPUContextAdapter::getRegisterByName( kdlib::loadCPUCurrentContext(), name );
+//}
+//
+//inline python::list getCurrentStack() {
+//    return CPUContextAdapter::getStack( kdlib::loadCPUCurrentContext() );
+//}
 
 ///////////////////////////////////////////////////////////////////////////////
 
diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp
index 4598d7c..ca94b43 100644
--- a/pykd/pymod.cpp
+++ b/pykd/pymod.cpp
@@ -328,13 +328,13 @@ BOOST_PYTHON_MODULE( pykd )
         "Return MSR value" );
     python::def( "wrmsr", pykd::setMSR,
         "Set MSR value" );
-    python::def( "getProcessorMode", pykd::getProcessorMode, 
+    python::def( "getCPUMode", pykd::getProcessorMode, 
         "Return current processor mode: CPUType" );
-    python::def( "getProcessorType", pykd::getProcessorType,
+    python::def( "getCPUType", pykd::getProcessorType,
         "Return type of physical processor: CPUType" );
-    python::def( "setProcessorMode",pykd::setProcessorMode,
+    python::def( "setCPUMode",pykd::setProcessorMode,
         "Set current processor mode (CPUType)" );
-    python::def( "switchProcessorMode", pykd::switchProcessorMode,
+    python::def( "switchCPUMode", pykd::switchProcessorMode,
         "Switch processor mode ( X86 <-> X64 )" );
 
    // stack and local variables
@@ -342,8 +342,6 @@ BOOST_PYTHON_MODULE( pykd )
         "Return a current stack as a list of stackFrame objects" );
     python::def( "getFrame", pykd::getCurrentFrame,
         "Return a current stack frame" );
-   // python::def( "getStackWow64", &getCurrentStackWow64,
-   //     "Return a stack for wow64 context as a list of stackFrame objects" );
     python::def( "getLocals", pykd::getLocals, 
         "Get list of local variables" );
     python::def( "getLocal", pykd::getLocal,
@@ -671,20 +669,20 @@ BOOST_PYTHON_MODULE( pykd )
             "return the function's local variable  by it's name")
         .def( "__str__", StackFrameAdapter::print );
 
-    python::class_<kdlib::CPUContext, kdlib::CPUContextPtr, boost::noncopyable>( "cpu",
-        "class for CPU context representation", python::no_init  )
-         .def("__init__", python::make_constructor(pykd::loadCPUCurrentContext) )
-         .def("__init__", python::make_constructor(pykd::loadCPUContextByIndex) )
-         .add_property("ip", CPUContextAdapter::getIP )
-         .add_property("sp", CPUContextAdapter::getSP )
-         .add_property("fp", CPUContextAdapter::getSP )
-         .def("getCPUType", CPUContextAdapter::getCPUType )
-         .def("getCPUMode",  CPUContextAdapter::getCPUMode )
-         .def("setCPUMode", CPUContextAdapter::setCPUMode )
-         .def("switchCPUMode", CPUContextAdapter::switchCPUMode )
-         .def("getStack",  CPUContextAdapter::getStack )
-         .def("__getattr__",  CPUContextAdapter::getRegisterByName )
-         .def("__getitem__",  CPUContextAdapter::getRegisterByIndex );
+    //python::class_<kdlib::CPUContext, kdlib::CPUContextPtr, boost::noncopyable>( "cpu",
+    //    "class for CPU context representation", python::no_init  )
+    //     .def("__init__", python::make_constructor(pykd::loadCPUCurrentContext) )
+    //     .def("__init__", python::make_constructor(pykd::loadCPUContextByIndex) )
+    //     .add_property("ip", CPUContextAdapter::getIP )
+    //     .add_property("sp", CPUContextAdapter::getSP )
+    //     .add_property("fp", CPUContextAdapter::getSP )
+    //     .def("getCPUType", CPUContextAdapter::getCPUType )
+    //     .def("getCPUMode",  CPUContextAdapter::getCPUMode )
+    //     .def("setCPUMode", CPUContextAdapter::setCPUMode )
+    //     .def("switchCPUMode", CPUContextAdapter::switchCPUMode )
+    //     .def("getStack",  CPUContextAdapter::getStack )
+    //     .def("__getattr__",  CPUContextAdapter::getRegisterByName )
+    //     .def("__getitem__",  CPUContextAdapter::getRegisterByIndex );
 
     python::class_<kdlib::SystemInfo>(
         "systemVersion", "Operation system version", python::no_init)