From 040444db8fc48cd4012bc7ec4568f6a9b6143cb3 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 28 Apr 2017 17:48:44 +0300 Subject: nt_path_converter -> nt_namespace --- .../wdk8.1update/special/nt_namespace/.gitignore | 2 + .../special/nt_namespace/nt_namespace.vs12.sln | 64 ++++++ .../special/nt_namespace/nt_namespace.vs12.vcxproj | 232 +++++++++++++++++++++ .../special/nt_path_converter/.gitignore | 2 - .../nt_path_converter/nt_path_converter.vs12.sln | 64 ------ .../nt_path_converter.vs12.vcxproj | 232 --------------------- km/src/special/dirs | 2 +- km/src/special/nt_namespace/control_codes.h | 12 ++ km/src/special/nt_namespace/device.c | 203 ++++++++++++++++++ km/src/special/nt_namespace/device.h | 13 ++ km/src/special/nt_namespace/main.c | 27 +++ km/src/special/nt_namespace/makefile | 1 + km/src/special/nt_namespace/nt2dos.c | 151 ++++++++++++++ km/src/special/nt_namespace/nt2dos.h | 12 ++ km/src/special/nt_namespace/sources | 3 + km/src/special/nt_path_converter/control_codes.h | 12 -- km/src/special/nt_path_converter/device.c | 203 ------------------ km/src/special/nt_path_converter/device.h | 13 -- km/src/special/nt_path_converter/main.c | 27 --- km/src/special/nt_path_converter/makefile | 1 - km/src/special/nt_path_converter/nt2dos.c | 151 -------------- km/src/special/nt_path_converter/nt2dos.h | 12 -- km/src/special/nt_path_converter/sources | 3 - um/README.md | 6 +- um/wrappers/special/CMakeLists.txt | 2 +- um/wrappers/special/nt_namespace/CMakeLists.txt | 10 + um/wrappers/special/nt_namespace/README.md | 31 +++ .../nt_namespace/include/libnt_namespace/all.hpp | 8 + .../include/libnt_namespace/device.hpp | 21 ++ um/wrappers/special/nt_namespace/src/device.cpp | 48 +++++ .../special/nt_namespace/utils/CMakeLists.txt | 6 + .../special/nt_namespace/utils/convert_nt_path.cpp | 26 +++ .../special/nt_path_converter/CMakeLists.txt | 10 - um/wrappers/special/nt_path_converter/README.md | 31 --- .../include/libnt_path_converter/all.hpp | 8 - .../include/libnt_path_converter/device.hpp | 21 -- .../special/nt_path_converter/src/device.cpp | 48 ----- .../special/nt_path_converter/utils/CMakeLists.txt | 6 - .../nt_path_converter/utils/convert_nt_path.cpp | 26 --- 39 files changed, 875 insertions(+), 875 deletions(-) create mode 100644 km/build/wdk8.1update/special/nt_namespace/.gitignore create mode 100644 km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.sln create mode 100644 km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.vcxproj delete mode 100644 km/build/wdk8.1update/special/nt_path_converter/.gitignore delete mode 100644 km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.sln delete mode 100644 km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.vcxproj create mode 100644 km/src/special/nt_namespace/control_codes.h create mode 100644 km/src/special/nt_namespace/device.c create mode 100644 km/src/special/nt_namespace/device.h create mode 100644 km/src/special/nt_namespace/main.c create mode 100644 km/src/special/nt_namespace/makefile create mode 100644 km/src/special/nt_namespace/nt2dos.c create mode 100644 km/src/special/nt_namespace/nt2dos.h create mode 100644 km/src/special/nt_namespace/sources delete mode 100644 km/src/special/nt_path_converter/control_codes.h delete mode 100644 km/src/special/nt_path_converter/device.c delete mode 100644 km/src/special/nt_path_converter/device.h delete mode 100644 km/src/special/nt_path_converter/main.c delete mode 100644 km/src/special/nt_path_converter/makefile delete mode 100644 km/src/special/nt_path_converter/nt2dos.c delete mode 100644 km/src/special/nt_path_converter/nt2dos.h delete mode 100644 km/src/special/nt_path_converter/sources create mode 100644 um/wrappers/special/nt_namespace/CMakeLists.txt create mode 100644 um/wrappers/special/nt_namespace/README.md create mode 100644 um/wrappers/special/nt_namespace/include/libnt_namespace/all.hpp create mode 100644 um/wrappers/special/nt_namespace/include/libnt_namespace/device.hpp create mode 100644 um/wrappers/special/nt_namespace/src/device.cpp create mode 100644 um/wrappers/special/nt_namespace/utils/CMakeLists.txt create mode 100644 um/wrappers/special/nt_namespace/utils/convert_nt_path.cpp delete mode 100644 um/wrappers/special/nt_path_converter/CMakeLists.txt delete mode 100644 um/wrappers/special/nt_path_converter/README.md delete mode 100644 um/wrappers/special/nt_path_converter/include/libnt_path_converter/all.hpp delete mode 100644 um/wrappers/special/nt_path_converter/include/libnt_path_converter/device.hpp delete mode 100644 um/wrappers/special/nt_path_converter/src/device.cpp delete mode 100644 um/wrappers/special/nt_path_converter/utils/CMakeLists.txt delete mode 100644 um/wrappers/special/nt_path_converter/utils/convert_nt_path.cpp diff --git a/km/build/wdk8.1update/special/nt_namespace/.gitignore b/km/build/wdk8.1update/special/nt_namespace/.gitignore new file mode 100644 index 0000000..4ded7c4 --- /dev/null +++ b/km/build/wdk8.1update/special/nt_namespace/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/obj/ diff --git a/km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.sln b/km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.sln new file mode 100644 index 0000000..7b06101 --- /dev/null +++ b/km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.sln @@ -0,0 +1,64 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nt_namespace.vs12", "nt_namespace.vs12.vcxproj", "{6B611107-4492-46B1-A233-12BAB1FF0FC2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Win7 Debug|Win32 = Win7 Debug|Win32 + Win7 Debug|x64 = Win7 Debug|x64 + Win7 Release|Win32 = Win7 Release|Win32 + Win7 Release|x64 = Win7 Release|x64 + Win8 Debug|Win32 = Win8 Debug|Win32 + Win8 Debug|x64 = Win8 Debug|x64 + Win8 Release|Win32 = Win8 Release|Win32 + Win8 Release|x64 = Win8 Release|x64 + Win8.1 Debug|Win32 = Win8.1 Debug|Win32 + Win8.1 Debug|x64 = Win8.1 Debug|x64 + Win8.1 Release|Win32 = Win8.1 Release|Win32 + Win8.1 Release|x64 = Win8.1 Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.Deploy.0 = Win7 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.Deploy.0 = Win7 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.Deploy.0 = Win8 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.Deploy.0 = Win8 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.Deploy.0 = Win8 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.Deploy.0 = Win8 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.Deploy.0 = Win8.1 Debug|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.Deploy.0 = Win8.1 Debug|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.Deploy.0 = Win8.1 Release|Win32 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.Deploy.0 = Win8.1 Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.vcxproj b/km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.vcxproj new file mode 100644 index 0000000..9b33bb0 --- /dev/null +++ b/km/build/wdk8.1update/special/nt_namespace/nt_namespace.vs12.vcxproj @@ -0,0 +1,232 @@ + + + + + Win8.1 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Debug + Win32 + + + Win8 Release + Win32 + + + Win7 Debug + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Debug + x64 + + + Win8 Release + x64 + + + Win7 Debug + x64 + + + Win7 Release + x64 + + + + {6B611107-4492-46B1-A233-12BAB1FF0FC2} + {dd38f7fc-d7bd-488b-9242-7d8754cde80d} + v4.5 + 11.0 + Win8.1 Debug + Win32 + nt_namespace_vs12 + + + + WindowsV6.3 + true + WindowsKernelModeDriver8.1 + Driver + WDM + + + WindowsV6.3 + false + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows8 + true + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows8 + false + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows7 + true + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows7 + false + WindowsKernelModeDriver8.1 + Driver + WDM + + + WindowsV6.3 + true + WindowsKernelModeDriver8.1 + Driver + WDM + + + WindowsV6.3 + false + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows8 + true + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows8 + false + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows7 + true + WindowsKernelModeDriver8.1 + Driver + WDM + + + Windows7 + false + WindowsKernelModeDriver8.1 + Driver + WDM + + + + + + + + + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\debug\ + obj\$(TargetVersion)\$(PlatformShortName)\debug\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\release\ + obj\$(TargetVersion)\$(PlatformShortName)\release\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\debug\ + obj\$(TargetVersion)\$(PlatformShortName)\debug\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\release\ + obj\$(TargetVersion)\$(PlatformShortName)\release\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\debug\ + obj\$(TargetVersion)\$(PlatformShortName)\debug\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\release\ + obj\$(TargetVersion)\$(PlatformShortName)\release\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\debug\ + obj\$(TargetVersion)\$(PlatformShortName)\debug\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\release\ + obj\$(TargetVersion)\$(PlatformShortName)\release\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\debug\ + obj\$(TargetVersion)\$(PlatformShortName)\debug\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\release\ + obj\$(TargetVersion)\$(PlatformShortName)\release\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\debug\ + obj\$(TargetVersion)\$(PlatformShortName)\debug\ + + + DbgengKernelDebugger + bin\$(TargetVersion)\$(PlatformShortName)\release\ + obj\$(TargetVersion)\$(PlatformShortName)\release\ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/km/build/wdk8.1update/special/nt_path_converter/.gitignore b/km/build/wdk8.1update/special/nt_path_converter/.gitignore deleted file mode 100644 index 4ded7c4..0000000 --- a/km/build/wdk8.1update/special/nt_path_converter/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin/ -/obj/ diff --git a/km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.sln b/km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.sln deleted file mode 100644 index 45cf003..0000000 --- a/km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.sln +++ /dev/null @@ -1,64 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nt_path_converter.vs12", "nt_path_converter.vs12.vcxproj", "{6B611107-4492-46B1-A233-12BAB1FF0FC2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Win7 Debug|Win32 = Win7 Debug|Win32 - Win7 Debug|x64 = Win7 Debug|x64 - Win7 Release|Win32 = Win7 Release|Win32 - Win7 Release|x64 = Win7 Release|x64 - Win8 Debug|Win32 = Win8 Debug|Win32 - Win8 Debug|x64 = Win8 Debug|x64 - Win8 Release|Win32 = Win8 Release|Win32 - Win8 Release|x64 = Win8 Release|x64 - Win8.1 Debug|Win32 = Win8.1 Debug|Win32 - Win8.1 Debug|x64 = Win8.1 Debug|x64 - Win8.1 Release|Win32 = Win8.1 Release|Win32 - Win8.1 Release|x64 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|Win32.Deploy.0 = Win7 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Debug|x64.Deploy.0 = Win7 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|Win32.Deploy.0 = Win7 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.Build.0 = Win7 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win7 Release|x64.Deploy.0 = Win7 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|Win32.Deploy.0 = Win8 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Debug|x64.Deploy.0 = Win8 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|Win32.Deploy.0 = Win8 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.Build.0 = Win8 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8 Release|x64.Deploy.0 = Win8 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|Win32.Deploy.0 = Win8.1 Debug|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Debug|x64.Deploy.0 = Win8.1 Debug|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|Win32.Deploy.0 = Win8.1 Release|Win32 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 - {6B611107-4492-46B1-A233-12BAB1FF0FC2}.Win8.1 Release|x64.Deploy.0 = Win8.1 Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.vcxproj b/km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.vcxproj deleted file mode 100644 index f87134e..0000000 --- a/km/build/wdk8.1update/special/nt_path_converter/nt_path_converter.vs12.vcxproj +++ /dev/null @@ -1,232 +0,0 @@ - - - - - Win8.1 Debug - Win32 - - - Win8.1 Release - Win32 - - - Win8 Debug - Win32 - - - Win8 Release - Win32 - - - Win7 Debug - Win32 - - - Win7 Release - Win32 - - - Win8.1 Debug - x64 - - - Win8.1 Release - x64 - - - Win8 Debug - x64 - - - Win8 Release - x64 - - - Win7 Debug - x64 - - - Win7 Release - x64 - - - - {6B611107-4492-46B1-A233-12BAB1FF0FC2} - {dd38f7fc-d7bd-488b-9242-7d8754cde80d} - v4.5 - 11.0 - Win8.1 Debug - Win32 - nt_path_converter_vs12 - - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - WindowsV6.3 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows8 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - true - WindowsKernelModeDriver8.1 - Driver - WDM - - - Windows7 - false - WindowsKernelModeDriver8.1 - Driver - WDM - - - - - - - - - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\debug\ - obj\$(TargetVersion)\$(PlatformShortName)\debug\ - - - DbgengKernelDebugger - bin\$(TargetVersion)\$(PlatformShortName)\release\ - obj\$(TargetVersion)\$(PlatformShortName)\release\ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/km/src/special/dirs b/km/src/special/dirs index 479f4db..6492e74 100644 --- a/km/src/special/dirs +++ b/km/src/special/dirs @@ -1 +1 @@ -DIRS = nt_path_converter sysenter +DIRS = nt_namespace sysenter diff --git a/km/src/special/nt_namespace/control_codes.h b/km/src/special/nt_namespace/control_codes.h new file mode 100644 index 0000000..3fb2aff --- /dev/null +++ b/km/src/special/nt_namespace/control_codes.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2015 Egor Tensin + * This file is part of the "Windows 7 drivers" project. + * For details, see https://github.com/egor-tensin/windows7-drivers. + * Distributed under the MIT License. + */ + +#pragma once + +#include + +#define CONVERT_NT_PATH CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) diff --git a/km/src/special/nt_namespace/device.c b/km/src/special/nt_namespace/device.c new file mode 100644 index 0000000..6d88dc4 --- /dev/null +++ b/km/src/special/nt_namespace/device.c @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2015 Egor Tensin + * This file is part of the "Windows 7 drivers" project. + * For details, see https://github.com/egor-tensin/windows7-drivers. + * Distributed under the MIT License. + */ + +#include "control_codes.h" +#include "device.h" +#include "nt2dos.h" + +#include + +static NTSTATUS device_open(DEVICE_OBJECT *device_object, IRP *irp) +{ + NTSTATUS status = STATUS_SUCCESS; + + UNREFERENCED_PARAMETER(device_object); + + irp->IoStatus.Status = status; + irp->IoStatus.Information = 0; + IoCompleteRequest(irp, IO_NO_INCREMENT); + return status; +} + +typedef NTSTATUS (*ioctl_handler)( + void *, unsigned long, + void *, unsigned long, + ULONG_PTR *); + +static NTSTATUS handle_convert_nt_path( + void *in_buf, + unsigned long in_buf_size, + void *out_buf, + unsigned long out_buf_size, + ULONG_PTR *nbwritten) +{ + UNICODE_STRING uUnresolved, uResolved; + NTSTATUS status = STATUS_SUCCESS; + + DbgPrint("nt_namespace: unresolved path: %ws\n", (WCHAR *) in_buf); + DbgPrint("nt_namespace: unresolved size: %lu\n", in_buf_size); + + RtlInitUnicodeString(&uUnresolved, (WCHAR *) in_buf); + status = nt2dos(&uResolved, &uUnresolved); + + if (!NT_SUCCESS(status)) + return status; + + *nbwritten = uResolved.Length + sizeof(WCHAR); + + DbgPrint("nt_namespace: resolved path: %wZ\n", &uResolved); + DbgPrint("nt_namespace: resolved size: %Iu\n", *nbwritten); + + if (out_buf_size < *nbwritten) + { + status = STATUS_BUFFER_OVERFLOW; + goto free_resolved; + } + + RtlFillMemory(out_buf, *nbwritten, L'\0'); + RtlCopyMemory(out_buf, uResolved.Buffer, uResolved.Length); + +free_resolved: + ExFreePool(uResolved.Buffer); + + return status; +} + +static NTSTATUS device_ioctl(DEVICE_OBJECT *device_object, IRP *irp) +{ + IO_STACK_LOCATION *io_stack_loc; + void* in_buf, *out_buf; + unsigned long in_buf_size, out_buf_size; + ioctl_handler handler; + NTSTATUS status = STATUS_UNSUCCESSFUL; + + UNREFERENCED_PARAMETER(device_object); + + irp->IoStatus.Status = status; + irp->IoStatus.Information = 0; + io_stack_loc = IoGetCurrentIrpStackLocation(irp); + + in_buf = out_buf = irp->AssociatedIrp.SystemBuffer; + in_buf_size = io_stack_loc->Parameters.DeviceIoControl.InputBufferLength; + out_buf_size = io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength; + + switch (io_stack_loc->Parameters.DeviceIoControl.IoControlCode) + { + case CONVERT_NT_PATH: + handler = handle_convert_nt_path; + break; + + default: + status = irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + goto complete_request; + } + + status = irp->IoStatus.Status = handler( + in_buf, in_buf_size, + out_buf, out_buf_size, + &irp->IoStatus.Information); + +complete_request: + IoCompleteRequest(irp, IO_NO_INCREMENT); + + return status; +} + +typedef struct +{ + const wchar_t *path; + const wchar_t *symlink; +} +DeviceInfo; + +typedef struct +{ + DEVICE_OBJECT *object; + UNICODE_STRING path; + UNICODE_STRING symlink; +} +Device; + +#define NUMOF_DEVICES 1 + +static DeviceInfo devices_info[NUMOF_DEVICES] = +{ + { + L"\\Device\\nt_namespace", + L"\\DosDevices\\nt_namespace", + }, +}; + +static Device devices[NUMOF_DEVICES]; + +static void destroy_device(int i) +{ + IoDeleteSymbolicLink(&devices[i].symlink); + IoDeleteDevice(devices[i].object); +} + +void destroy_devices() +{ + int i; + for (i = 0; i < NUMOF_DEVICES; ++i) + destroy_device(i); +} + +static NTSTATUS set_up_device(DRIVER_OBJECT *driver_object, int i) +{ + NTSTATUS status = STATUS_SUCCESS; + + RtlInitUnicodeString(&devices[i].path, devices_info[i].path); + RtlInitUnicodeString(&devices[i].symlink, devices_info[i].symlink); + + status = IoCreateDevice( + driver_object, + 0, + &devices[i].path, + FILE_DEVICE_UNKNOWN, + FILE_DEVICE_SECURE_OPEN, + FALSE, + &devices[i].object); + + if (!NT_SUCCESS(status)) + return status; + + devices[i].object->Flags |= DO_BUFFERED_IO; + devices[i].object->Flags &= ~DO_DEVICE_INITIALIZING; + + if (!NT_SUCCESS(status = IoCreateSymbolicLink( + &devices[i].symlink, &devices[i].path))) + goto delete_device; + + return status; + +delete_device: + IoDeleteDevice(devices[i].object); + + return status; +} + +NTSTATUS set_up_devices(DRIVER_OBJECT *driver_object) +{ + int i, j; + NTSTATUS status = STATUS_SUCCESS; + + for (i = 0; i < NUMOF_DEVICES; ++i) + if (!NT_SUCCESS(status = set_up_device(driver_object, i))) + goto destroy_devices; + + driver_object->MajorFunction[IRP_MJ_CREATE] = device_open; + driver_object->MajorFunction[IRP_MJ_DEVICE_CONTROL] = device_ioctl; + + return status; + +destroy_devices: + for (j = 0; j < i; ++j) + destroy_device(j); + + return status; +} diff --git a/km/src/special/nt_namespace/device.h b/km/src/special/nt_namespace/device.h new file mode 100644 index 0000000..4f117e9 --- /dev/null +++ b/km/src/special/nt_namespace/device.h @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2015 Egor Tensin + * This file is part of the "Windows 7 drivers" project. + * For details, see https://github.com/egor-tensin/windows7-drivers. + * Distributed under the MIT License. + */ + +#pragma once + +#include + +NTSTATUS set_up_devices(DRIVER_OBJECT *); +void destroy_devices(); diff --git a/km/src/special/nt_namespace/main.c b/km/src/special/nt_namespace/main.c new file mode 100644 index 0000000..a1c08e8 --- /dev/null +++ b/km/src/special/nt_namespace/main.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 Egor Tensin + * This file is part of the "Windows 7 drivers" project. + * For details, see https://github.com/egor-tensin/windows7-drivers. + * Distributed under the MIT License. + */ + +#include "device.h" + +#include + +static void on_driver_unload(DRIVER_OBJECT *driver_object) +{ + UNREFERENCED_PARAMETER(driver_object); + + destroy_devices(); +} + +NTSTATUS DriverEntry( + DRIVER_OBJECT *driver_object, + UNICODE_STRING *registry_path) +{ + UNREFERENCED_PARAMETER(registry_path); + + driver_object->DriverUnload = on_driver_unload; + return set_up_devices(driver_object); +} diff --git a/km/src/special/nt_namespace/makefile b/km/src/special/nt_namespace/makefile new file mode 100644 index 0000000..5acbbd2 --- /dev/null +++ b/km/src/special/nt_namespace/makefile @@ -0,0 +1 @@ +!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/km/src/special/nt_namespace/nt2dos.c b/km/src/special/nt_namespace/nt2dos.c new file mode 100644 index 0000000..d1bdb3d --- /dev/null +++ b/km/src/special/nt_namespace/nt2dos.c @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2015 Egor Tensin + * This file is part of the "Windows 7 drivers" project. + * For details, see https://github.com/egor-tensin/windows7-drivers. + * Distributed under the MIT License. + */ + +#include + +#include "nt2dos.h" + +static NTSTATUS get_object_name_info( + void *object, + OBJECT_NAME_INFORMATION **object_name_info) +{ + unsigned long nbneeded; + NTSTATUS status = STATUS_SUCCESS; + + status = ObQueryNameString(object, NULL, 0, &nbneeded); + + if (status != STATUS_INFO_LENGTH_MISMATCH) + return status; + + *object_name_info = ExAllocatePoolWithTag(PagedPool, nbneeded, '1l'); + + if (*object_name_info == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + status = ObQueryNameString(object, *object_name_info, nbneeded, &nbneeded); + + if (!NT_SUCCESS(status)) + goto free_object_name_info; + + return status; + +free_object_name_info: + ExFreePool(*object_name_info); + + return status; +} + +NTSTATUS nt2dos(UNICODE_STRING *u_resolved, UNICODE_STRING *u_unresolved) +{ + IO_STATUS_BLOCK io_status_block; + DEVICE_OBJECT *volume_object; + FILE_OBJECT *file_object; + HANDLE file; + OBJECT_ATTRIBUTES file_attrs; + OBJECT_NAME_INFORMATION *file_name_info, *volume_name_info; + UNICODE_STRING u_dos_name; + USHORT u_resolved_size; + NTSTATUS status = STATUS_SUCCESS; + + InitializeObjectAttributes( + &file_attrs, + u_unresolved, + OBJ_CASE_INSENSITIVE | OBJ_OPENIF, + NULL, + NULL); + + status = ZwCreateFile( + &file, + FILE_READ_ATTRIBUTES, + &file_attrs, + &io_status_block, + NULL, + FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_OPEN, + FILE_SYNCHRONOUS_IO_NONALERT, + NULL, + 0); + + if (!NT_SUCCESS(status)) + return status; + + status = ObReferenceObjectByHandle( + file, + FILE_READ_ATTRIBUTES, + *IoFileObjectType, + KernelMode, + &file_object, + NULL); + + if (!NT_SUCCESS(status)) + goto close_file; + + status = get_object_name_info(file_object, &file_name_info); + + if (!NT_SUCCESS(status)) + goto close_file; + + if (file_object->Vpb == NULL) + { + u_resolved->Buffer = ExAllocatePoolWithTag( + PagedPool, file_name_info->Name.Length, '1l'); + + if (u_resolved->Buffer == NULL) + { + status = STATUS_INSUFFICIENT_RESOURCES; + goto free_file_name_info; + } + + RtlInitEmptyUnicodeString( + u_resolved, u_resolved->Buffer, file_name_info->Name.Length); + RtlCopyUnicodeString(u_resolved, &file_name_info->Name); + goto free_file_name_info; + } + + volume_object = file_object->Vpb->RealDevice; + status = get_object_name_info(volume_object, &volume_name_info); + + if (!NT_SUCCESS(status)) + goto free_file_name_info; + + status = IoVolumeDeviceToDosName(volume_object, &u_dos_name); + + if (!NT_SUCCESS(status)) + goto free_volume_name_info; + + u_resolved_size = file_name_info->Name.Length - volume_name_info->Name.Length + u_dos_name.Length; + + u_resolved->Buffer = ExAllocatePoolWithTag(PagedPool, u_resolved_size, '1l'); + + if (u_resolved->Buffer == NULL) + { + status = STATUS_INSUFFICIENT_RESOURCES; + goto free_dos_name; + } + + RtlInitEmptyUnicodeString(u_resolved, u_resolved->Buffer, u_resolved_size); + + RtlCopyUnicodeString(u_resolved, &u_dos_name); + file_name_info->Name.Buffer += volume_name_info->Name.Length / sizeof(wchar_t); + file_name_info->Name.Length -= volume_name_info->Name.Length; + RtlUnicodeStringCat(u_resolved, &file_name_info->Name); + +free_dos_name: + ExFreePool(u_dos_name.Buffer); + +free_volume_name_info: + ExFreePool(volume_name_info); + +free_file_name_info: + ExFreePool(file_name_info); + +close_file: + ZwClose(file); + + return status; +} diff --git a/km/src/special/nt_namespace/nt2dos.h b/km/src/special/nt_namespace/nt2dos.h new file mode 100644 index 0000000..ce0b690 --- /dev/null +++ b/km/src/special/nt_namespace/nt2dos.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2015 Egor Tensin + * This file is part of the "Windows 7 drivers" project. + * For details, see https://github.com/egor-tensin/windows7-drivers. + * Distributed under the MIT License. + */ + +#pragma once + +#include + +NTSTATUS nt2dos(UNICODE_STRING *resolved, UNICODE_STRING *unresolved); diff --git a/km/src/special/nt_namespace/sources b/km/src/special/nt_namespace/sources new file mode 100644 index 0000000..7629a23 --- /dev/null +++ b/km/src/special/nt_namespace/sources @@ -0,0 +1,3 @@ +TARGETTYPE = DRIVER +TARGETNAME = nt_namespace +SOURCES = device.c main.c nt2dos.c diff --git a/km/src/special/nt_path_converter/control_codes.h b/km/src/special/nt_path_converter/control_codes.h deleted file mode 100644 index 3fb2aff..0000000 --- a/km/src/special/nt_path_converter/control_codes.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#pragma once - -#include - -#define CONVERT_NT_PATH CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) diff --git a/km/src/special/nt_path_converter/device.c b/km/src/special/nt_path_converter/device.c deleted file mode 100644 index a179984..0000000 --- a/km/src/special/nt_path_converter/device.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include "control_codes.h" -#include "device.h" -#include "nt2dos.h" - -#include - -static NTSTATUS device_open(DEVICE_OBJECT *device_object, IRP *irp) -{ - NTSTATUS status = STATUS_SUCCESS; - - UNREFERENCED_PARAMETER(device_object); - - irp->IoStatus.Status = status; - irp->IoStatus.Information = 0; - IoCompleteRequest(irp, IO_NO_INCREMENT); - return status; -} - -typedef NTSTATUS (*ioctl_handler)( - void *, unsigned long, - void *, unsigned long, - ULONG_PTR *); - -static NTSTATUS handle_convert_nt_path( - void *in_buf, - unsigned long in_buf_size, - void *out_buf, - unsigned long out_buf_size, - ULONG_PTR *nbwritten) -{ - UNICODE_STRING uUnresolved, uResolved; - NTSTATUS status = STATUS_SUCCESS; - - DbgPrint("nt_path_converter: unresolved path: %ws\n", (WCHAR *) in_buf); - DbgPrint("nt_path_converter: unresolved size: %lu\n", in_buf_size); - - RtlInitUnicodeString(&uUnresolved, (WCHAR *) in_buf); - status = nt2dos(&uResolved, &uUnresolved); - - if (!NT_SUCCESS(status)) - return status; - - *nbwritten = uResolved.Length + sizeof(WCHAR); - - DbgPrint("nt_path_converter: resolved path: %wZ\n", &uResolved); - DbgPrint("nt_path_converter: resolved size: %Iu\n", *nbwritten); - - if (out_buf_size < *nbwritten) - { - status = STATUS_BUFFER_OVERFLOW; - goto free_resolved; - } - - RtlFillMemory(out_buf, *nbwritten, L'\0'); - RtlCopyMemory(out_buf, uResolved.Buffer, uResolved.Length); - -free_resolved: - ExFreePool(uResolved.Buffer); - - return status; -} - -static NTSTATUS device_ioctl(DEVICE_OBJECT *device_object, IRP *irp) -{ - IO_STACK_LOCATION *io_stack_loc; - void* in_buf, *out_buf; - unsigned long in_buf_size, out_buf_size; - ioctl_handler handler; - NTSTATUS status = STATUS_UNSUCCESSFUL; - - UNREFERENCED_PARAMETER(device_object); - - irp->IoStatus.Status = status; - irp->IoStatus.Information = 0; - io_stack_loc = IoGetCurrentIrpStackLocation(irp); - - in_buf = out_buf = irp->AssociatedIrp.SystemBuffer; - in_buf_size = io_stack_loc->Parameters.DeviceIoControl.InputBufferLength; - out_buf_size = io_stack_loc->Parameters.DeviceIoControl.OutputBufferLength; - - switch (io_stack_loc->Parameters.DeviceIoControl.IoControlCode) - { - case CONVERT_NT_PATH: - handler = handle_convert_nt_path; - break; - - default: - status = irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - goto complete_request; - } - - status = irp->IoStatus.Status = handler( - in_buf, in_buf_size, - out_buf, out_buf_size, - &irp->IoStatus.Information); - -complete_request: - IoCompleteRequest(irp, IO_NO_INCREMENT); - - return status; -} - -typedef struct -{ - const wchar_t *path; - const wchar_t *symlink; -} -DeviceInfo; - -typedef struct -{ - DEVICE_OBJECT *object; - UNICODE_STRING path; - UNICODE_STRING symlink; -} -Device; - -#define NUMOF_DEVICES 1 - -static DeviceInfo devices_info[NUMOF_DEVICES] = -{ - { - L"\\Device\\nt_path_converter", - L"\\DosDevices\\nt_path_converter", - }, -}; - -static Device devices[NUMOF_DEVICES]; - -static void destroy_device(int i) -{ - IoDeleteSymbolicLink(&devices[i].symlink); - IoDeleteDevice(devices[i].object); -} - -void destroy_devices() -{ - int i; - for (i = 0; i < NUMOF_DEVICES; ++i) - destroy_device(i); -} - -static NTSTATUS set_up_device(DRIVER_OBJECT *driver_object, int i) -{ - NTSTATUS status = STATUS_SUCCESS; - - RtlInitUnicodeString(&devices[i].path, devices_info[i].path); - RtlInitUnicodeString(&devices[i].symlink, devices_info[i].symlink); - - status = IoCreateDevice( - driver_object, - 0, - &devices[i].path, - FILE_DEVICE_UNKNOWN, - FILE_DEVICE_SECURE_OPEN, - FALSE, - &devices[i].object); - - if (!NT_SUCCESS(status)) - return status; - - devices[i].object->Flags |= DO_BUFFERED_IO; - devices[i].object->Flags &= ~DO_DEVICE_INITIALIZING; - - if (!NT_SUCCESS(status = IoCreateSymbolicLink( - &devices[i].symlink, &devices[i].path))) - goto delete_device; - - return status; - -delete_device: - IoDeleteDevice(devices[i].object); - - return status; -} - -NTSTATUS set_up_devices(DRIVER_OBJECT *driver_object) -{ - int i, j; - NTSTATUS status = STATUS_SUCCESS; - - for (i = 0; i < NUMOF_DEVICES; ++i) - if (!NT_SUCCESS(status = set_up_device(driver_object, i))) - goto destroy_devices; - - driver_object->MajorFunction[IRP_MJ_CREATE] = device_open; - driver_object->MajorFunction[IRP_MJ_DEVICE_CONTROL] = device_ioctl; - - return status; - -destroy_devices: - for (j = 0; j < i; ++j) - destroy_device(j); - - return status; -} diff --git a/km/src/special/nt_path_converter/device.h b/km/src/special/nt_path_converter/device.h deleted file mode 100644 index 4f117e9..0000000 --- a/km/src/special/nt_path_converter/device.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#pragma once - -#include - -NTSTATUS set_up_devices(DRIVER_OBJECT *); -void destroy_devices(); diff --git a/km/src/special/nt_path_converter/main.c b/km/src/special/nt_path_converter/main.c deleted file mode 100644 index a1c08e8..0000000 --- a/km/src/special/nt_path_converter/main.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include "device.h" - -#include - -static void on_driver_unload(DRIVER_OBJECT *driver_object) -{ - UNREFERENCED_PARAMETER(driver_object); - - destroy_devices(); -} - -NTSTATUS DriverEntry( - DRIVER_OBJECT *driver_object, - UNICODE_STRING *registry_path) -{ - UNREFERENCED_PARAMETER(registry_path); - - driver_object->DriverUnload = on_driver_unload; - return set_up_devices(driver_object); -} diff --git a/km/src/special/nt_path_converter/makefile b/km/src/special/nt_path_converter/makefile deleted file mode 100644 index 5acbbd2..0000000 --- a/km/src/special/nt_path_converter/makefile +++ /dev/null @@ -1 +0,0 @@ -!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/km/src/special/nt_path_converter/nt2dos.c b/km/src/special/nt_path_converter/nt2dos.c deleted file mode 100644 index d1bdb3d..0000000 --- a/km/src/special/nt_path_converter/nt2dos.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#include - -#include "nt2dos.h" - -static NTSTATUS get_object_name_info( - void *object, - OBJECT_NAME_INFORMATION **object_name_info) -{ - unsigned long nbneeded; - NTSTATUS status = STATUS_SUCCESS; - - status = ObQueryNameString(object, NULL, 0, &nbneeded); - - if (status != STATUS_INFO_LENGTH_MISMATCH) - return status; - - *object_name_info = ExAllocatePoolWithTag(PagedPool, nbneeded, '1l'); - - if (*object_name_info == NULL) - return STATUS_INSUFFICIENT_RESOURCES; - - status = ObQueryNameString(object, *object_name_info, nbneeded, &nbneeded); - - if (!NT_SUCCESS(status)) - goto free_object_name_info; - - return status; - -free_object_name_info: - ExFreePool(*object_name_info); - - return status; -} - -NTSTATUS nt2dos(UNICODE_STRING *u_resolved, UNICODE_STRING *u_unresolved) -{ - IO_STATUS_BLOCK io_status_block; - DEVICE_OBJECT *volume_object; - FILE_OBJECT *file_object; - HANDLE file; - OBJECT_ATTRIBUTES file_attrs; - OBJECT_NAME_INFORMATION *file_name_info, *volume_name_info; - UNICODE_STRING u_dos_name; - USHORT u_resolved_size; - NTSTATUS status = STATUS_SUCCESS; - - InitializeObjectAttributes( - &file_attrs, - u_unresolved, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - NULL, - NULL); - - status = ZwCreateFile( - &file, - FILE_READ_ATTRIBUTES, - &file_attrs, - &io_status_block, - NULL, - FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_OPEN, - FILE_SYNCHRONOUS_IO_NONALERT, - NULL, - 0); - - if (!NT_SUCCESS(status)) - return status; - - status = ObReferenceObjectByHandle( - file, - FILE_READ_ATTRIBUTES, - *IoFileObjectType, - KernelMode, - &file_object, - NULL); - - if (!NT_SUCCESS(status)) - goto close_file; - - status = get_object_name_info(file_object, &file_name_info); - - if (!NT_SUCCESS(status)) - goto close_file; - - if (file_object->Vpb == NULL) - { - u_resolved->Buffer = ExAllocatePoolWithTag( - PagedPool, file_name_info->Name.Length, '1l'); - - if (u_resolved->Buffer == NULL) - { - status = STATUS_INSUFFICIENT_RESOURCES; - goto free_file_name_info; - } - - RtlInitEmptyUnicodeString( - u_resolved, u_resolved->Buffer, file_name_info->Name.Length); - RtlCopyUnicodeString(u_resolved, &file_name_info->Name); - goto free_file_name_info; - } - - volume_object = file_object->Vpb->RealDevice; - status = get_object_name_info(volume_object, &volume_name_info); - - if (!NT_SUCCESS(status)) - goto free_file_name_info; - - status = IoVolumeDeviceToDosName(volume_object, &u_dos_name); - - if (!NT_SUCCESS(status)) - goto free_volume_name_info; - - u_resolved_size = file_name_info->Name.Length - volume_name_info->Name.Length + u_dos_name.Length; - - u_resolved->Buffer = ExAllocatePoolWithTag(PagedPool, u_resolved_size, '1l'); - - if (u_resolved->Buffer == NULL) - { - status = STATUS_INSUFFICIENT_RESOURCES; - goto free_dos_name; - } - - RtlInitEmptyUnicodeString(u_resolved, u_resolved->Buffer, u_resolved_size); - - RtlCopyUnicodeString(u_resolved, &u_dos_name); - file_name_info->Name.Buffer += volume_name_info->Name.Length / sizeof(wchar_t); - file_name_info->Name.Length -= volume_name_info->Name.Length; - RtlUnicodeStringCat(u_resolved, &file_name_info->Name); - -free_dos_name: - ExFreePool(u_dos_name.Buffer); - -free_volume_name_info: - ExFreePool(volume_name_info); - -free_file_name_info: - ExFreePool(file_name_info); - -close_file: - ZwClose(file); - - return status; -} diff --git a/km/src/special/nt_path_converter/nt2dos.h b/km/src/special/nt_path_converter/nt2dos.h deleted file mode 100644 index ce0b690..0000000 --- a/km/src/special/nt_path_converter/nt2dos.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2015 Egor Tensin - * This file is part of the "Windows 7 drivers" project. - * For details, see https://github.com/egor-tensin/windows7-drivers. - * Distributed under the MIT License. - */ - -#pragma once - -#include - -NTSTATUS nt2dos(UNICODE_STRING *resolved, UNICODE_STRING *unresolved); diff --git a/km/src/special/nt_path_converter/sources b/km/src/special/nt_path_converter/sources deleted file mode 100644 index 02a42cd..0000000 --- a/km/src/special/nt_path_converter/sources +++ /dev/null @@ -1,3 +0,0 @@ -TARGETTYPE = DRIVER -TARGETNAME = nt_path_converter -SOURCES = device.c main.c nt2dos.c diff --git a/um/README.md b/um/README.md index 4a30be2..7601f25 100644 --- a/um/README.md +++ b/um/README.md @@ -5,13 +5,13 @@ A couple of usage examples are included along with the drivers. * [libservice]: Utilities to load/unload the drivers. * [libsimple]: [simple] driver usage examples. -* [libnt_path_converter]: [nt_path_converter] driver usage examples. +* [libnt_namespace]: [nt_namespace] driver usage examples. [libservice]: service/README.md [libsimple]: wrappers/simple/README.md [simple]: ../km/src/simple -[libnt_path_converter]: wrappers/special/nt_path_converter/README.md -[nt_path_converter]: ../km/src/special/nt_path_converter +[libnt_namespace]: wrappers/special/nt_namespace/README.md +[nt_namespace]: ../km/src/special/nt_namespace Building -------- diff --git a/um/wrappers/special/CMakeLists.txt b/um/wrappers/special/CMakeLists.txt index ed48e00..40b32f6 100644 --- a/um/wrappers/special/CMakeLists.txt +++ b/um/wrappers/special/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(nt_path_converter) +add_subdirectory(nt_namespace) diff --git a/um/wrappers/special/nt_namespace/CMakeLists.txt b/um/wrappers/special/nt_namespace/CMakeLists.txt new file mode 100644 index 0000000..ede2673 --- /dev/null +++ b/um/wrappers/special/nt_namespace/CMakeLists.txt @@ -0,0 +1,10 @@ +project(libnt_namespace) +file(GLOB libnt_namespace_sources "src/*.cpp") +file(GLOB_RECURSE libnt_namespace_headers "include/*.hpp") +add_library(libnt_namespace + ${libnt_namespace_sources} + ${libnt_namespace_headers}) +target_link_libraries(libnt_namespace libservice) +target_include_directories(libnt_namespace PUBLIC include/) + +add_subdirectory(utils) diff --git a/um/wrappers/special/nt_namespace/README.md b/um/wrappers/special/nt_namespace/README.md new file mode 100644 index 0000000..22a74ee --- /dev/null +++ b/um/wrappers/special/nt_namespace/README.md @@ -0,0 +1,31 @@ +nt_namespace driver utilities +================================== + +[nt_namespace] driver usage examples. + +[nt_namespace]: ../../../../km/src/special/nt_namespace + +Usage +----- + +### convert_nt_path.exe + + Usage: convert_nt_path.exe [NT_PATH...] + +Converts a NT-style path to a DOS-style path. +The NT namespace can be explored using the [WinObj] utility. +For example: + + > convert_nt_path.exe \Device\HarddiskVolume2\Windows + C:\Windows + +[WinObj]: https://technet.microsoft.com/en-us/library/bb896657.aspx + +See also +-------- + +* [Building] +* [License] + +[Building]: ../../../README.md#building +[License]: ../../../../README.md#license diff --git a/um/wrappers/special/nt_namespace/include/libnt_namespace/all.hpp b/um/wrappers/special/nt_namespace/include/libnt_namespace/all.hpp new file mode 100644 index 0000000..474b802 --- /dev/null +++ b/um/wrappers/special/nt_namespace/include/libnt_namespace/all.hpp @@ -0,0 +1,8 @@ +// Copyright (c) 2015 Egor Tensin +// This file is part of the "Windows 7 drivers" project. +// For details, see https://github.com/egor-tensin/windows7-drivers. +// Distributed under the MIT License. + +#pragma once + +#include "device.hpp" diff --git a/um/wrappers/special/nt_namespace/include/libnt_namespace/device.hpp b/um/wrappers/special/nt_namespace/include/libnt_namespace/device.hpp new file mode 100644 index 0000000..775b707 --- /dev/null +++ b/um/wrappers/special/nt_namespace/include/libnt_namespace/device.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2015 Egor Tensin +// This file is part of the "Windows 7 drivers" project. +// For details, see https://github.com/egor-tensin/windows7-drivers. +// Distributed under the MIT License. + +#pragma once + +#include "libservice/all.hpp" + +#include + +namespace libnt_namespace +{ + class Device : libservice::Device + { + public: + Device(); + + std::wstring convert_nt_path(const std::wstring&); + }; +} diff --git a/um/wrappers/special/nt_namespace/src/device.cpp b/um/wrappers/special/nt_namespace/src/device.cpp new file mode 100644 index 0000000..1187b1c --- /dev/null +++ b/um/wrappers/special/nt_namespace/src/device.cpp @@ -0,0 +1,48 @@ +// Copyright (c) 2015 Egor Tensin +// This file is part of the "Windows 7 drivers" project. +// For details, see https://github.com/egor-tensin/windows7-drivers. +// Distributed under the MIT License. + +#include "libnt_namespace/device.hpp" + +#include "libservice/all.hpp" + +#include + +#include +#include + +namespace libnt_namespace +{ + namespace + { + const auto device_path = "\\\\.\\nt_namespace"; + const auto control_code = CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS); + } + + Device::Device() + : libservice::Device(libservice::Device::open(device_path)) + { } + + std::wstring Device::convert_nt_path(const std::wstring& src) + { + const auto in_buf = src.c_str(); + const auto in_buf_size = (src.size() + 1) * sizeof(wchar_t); + + const auto nbreq = get_required_output_size( + control_code, + in_buf, + in_buf_size); + + std::vector output(nbreq); + + send_control_code( + control_code, + in_buf, + in_buf_size, + output.data(), + nbreq); + + return reinterpret_cast(output.data()); + } +} diff --git a/um/wrappers/special/nt_namespace/utils/CMakeLists.txt b/um/wrappers/special/nt_namespace/utils/CMakeLists.txt new file mode 100644 index 0000000..294a713 --- /dev/null +++ b/um/wrappers/special/nt_namespace/utils/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable(convert_nt_path convert_nt_path.cpp) +target_link_libraries(convert_nt_path PRIVATE libnt_namespace) +if(MINGW) + target_compile_options(convert_nt_path PRIVATE -municode) + target_link_libraries(convert_nt_path PRIVATE -municode) +endif() diff --git a/um/wrappers/special/nt_namespace/utils/convert_nt_path.cpp b/um/wrappers/special/nt_namespace/utils/convert_nt_path.cpp new file mode 100644 index 0000000..5a77fed --- /dev/null +++ b/um/wrappers/special/nt_namespace/utils/convert_nt_path.cpp @@ -0,0 +1,26 @@ +// Copyright (c) 2015 Egor Tensin +// This file is part of the "Windows 7 drivers" project. +// For details, see https://github.com/egor-tensin/windows7-drivers. +// Distributed under the MIT License. + +#include "libnt_namespace/all.hpp" + +#include +#include + +int wmain(int argc, wchar_t* argv[]) +{ + try + { + libnt_namespace::Device dev; + for (int i = 1; i < argc; ++i) + std::wcout << dev.convert_nt_path(argv[i]) << L"\n"; + } + catch (const std::exception& e) + { + std::cerr << e.what() << "\n"; + return 1; + } + + return 0; +} diff --git a/um/wrappers/special/nt_path_converter/CMakeLists.txt b/um/wrappers/special/nt_path_converter/CMakeLists.txt deleted file mode 100644 index 69f85d0..0000000 --- a/um/wrappers/special/nt_path_converter/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(libnt_path_converter) -file(GLOB libnt_path_converter_sources "src/*.cpp") -file(GLOB_RECURSE libnt_path_converter_headers "include/*.hpp") -add_library(libnt_path_converter - ${libnt_path_converter_sources} - ${libnt_path_converter_headers}) -target_link_libraries(libnt_path_converter libservice) -target_include_directories(libnt_path_converter PUBLIC include/) - -add_subdirectory(utils) diff --git a/um/wrappers/special/nt_path_converter/README.md b/um/wrappers/special/nt_path_converter/README.md deleted file mode 100644 index b295a80..0000000 --- a/um/wrappers/special/nt_path_converter/README.md +++ /dev/null @@ -1,31 +0,0 @@ -nt_path_converter driver utilities -================================== - -[nt_path_converter] driver usage examples. - -[nt_path_converter]: ../../../../km/src/special/nt_path_converter - -Usage ------ - -### convert_nt_path.exe - - Usage: convert_nt_path.exe [NT_PATH...] - -Converts a NT-style path to a DOS-style path. -The NT namespace can be explored using the [WinObj] utility. -For example: - - > convert_nt_path.exe \Device\HarddiskVolume2\Windows - C:\Windows - -[WinObj]: https://technet.microsoft.com/en-us/library/bb896657.aspx - -See also --------- - -* [Building] -* [License] - -[Building]: ../../../README.md#building -[License]: ../../../../README.md#license diff --git a/um/wrappers/special/nt_path_converter/include/libnt_path_converter/all.hpp b/um/wrappers/special/nt_path_converter/include/libnt_path_converter/all.hpp deleted file mode 100644 index 474b802..0000000 --- a/um/wrappers/special/nt_path_converter/include/libnt_path_converter/all.hpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "device.hpp" diff --git a/um/wrappers/special/nt_path_converter/include/libnt_path_converter/device.hpp b/um/wrappers/special/nt_path_converter/include/libnt_path_converter/device.hpp deleted file mode 100644 index e1d75fb..0000000 --- a/um/wrappers/special/nt_path_converter/include/libnt_path_converter/device.hpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#pragma once - -#include "libservice/all.hpp" - -#include - -namespace libnt_path_converter -{ - class Device : libservice::Device - { - public: - Device(); - - std::wstring convert_nt_path(const std::wstring&); - }; -} diff --git a/um/wrappers/special/nt_path_converter/src/device.cpp b/um/wrappers/special/nt_path_converter/src/device.cpp deleted file mode 100644 index 2b5b89a..0000000 --- a/um/wrappers/special/nt_path_converter/src/device.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#include "libnt_path_converter/device.hpp" - -#include "libservice/all.hpp" - -#include - -#include -#include - -namespace libnt_path_converter -{ - namespace - { - const auto device_path = "\\\\.\\nt_path_converter"; - const auto control_code = CTL_CODE(0x8000, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS); - } - - Device::Device() - : libservice::Device(libservice::Device::open(device_path)) - { } - - std::wstring Device::convert_nt_path(const std::wstring& src) - { - const auto in_buf = src.c_str(); - const auto in_buf_size = (src.size() + 1) * sizeof(wchar_t); - - const auto nbreq = get_required_output_size( - control_code, - in_buf, - in_buf_size); - - std::vector output(nbreq); - - send_control_code( - control_code, - in_buf, - in_buf_size, - output.data(), - nbreq); - - return reinterpret_cast(output.data()); - } -} diff --git a/um/wrappers/special/nt_path_converter/utils/CMakeLists.txt b/um/wrappers/special/nt_path_converter/utils/CMakeLists.txt deleted file mode 100644 index 9c5254b..0000000 --- a/um/wrappers/special/nt_path_converter/utils/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_executable(convert_nt_path convert_nt_path.cpp) -target_link_libraries(convert_nt_path PRIVATE libnt_path_converter) -if(MINGW) - target_compile_options(convert_nt_path PRIVATE -municode) - target_link_libraries(convert_nt_path PRIVATE -municode) -endif() diff --git a/um/wrappers/special/nt_path_converter/utils/convert_nt_path.cpp b/um/wrappers/special/nt_path_converter/utils/convert_nt_path.cpp deleted file mode 100644 index 9d25242..0000000 --- a/um/wrappers/special/nt_path_converter/utils/convert_nt_path.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2015 Egor Tensin -// This file is part of the "Windows 7 drivers" project. -// For details, see https://github.com/egor-tensin/windows7-drivers. -// Distributed under the MIT License. - -#include "libnt_path_converter/all.hpp" - -#include -#include - -int wmain(int argc, wchar_t* argv[]) -{ - try - { - libnt_path_converter::Device dev; - for (int i = 1; i < argc; ++i) - std::wcout << dev.convert_nt_path(argv[i]) << L"\n"; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } - - return 0; -} -- cgit v1.2.3