From 47282c86ceae6ebf779687737ea8ea38a0f3f2fa Mon Sep 17 00:00:00 2001 From: Matthew Montera Date: Fri, 18 Aug 2017 17:10:41 -0700 Subject: AddComponent to Extension Put the Win32 Service into the base, and created two separate extensions that create the component in a loose and tight manner. --- general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln | 19 + .../osrfx2_DCHU_base/osrfx2_DCHU_base.inx | Bin 6664 -> 10398 bytes .../osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj | 36 +- .../osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj | 12 +- .../osrfx2_DCHU_testapp/osrusbfx2.vcxproj | 8 +- .../osrfx2_DCHU_usersvc/CppWindowsService.cpp | 74 ++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp | 1152 ++++++++++++++++++++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h | 342 ++++++ .../osrfx2_DCHU_usersvc/SampleService.cpp | 287 +++++ .../osrfx2_DCHU_usersvc/SampleService.h | 174 +++ .../osrfx2_DCHU_usersvc/ServiceBase.cpp | 794 ++++++++++++++ .../osrfx2_DCHU_usersvc/ServiceBase.h | 423 +++++++ .../osrfx2_DCHU_usersvc/ThreadPool.h | 80 ++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp | 156 +++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h | 111 ++ .../osrfx2_DCHU_usersvc.filters | 54 + .../osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx | Bin 0 -> 3190 bytes .../osrfx2_DCHU_usersvc.vcxproj | 206 ++++ .../osrfx2_DCHU_component.sln | 73 -- .../osrfx2_DCHU_component.filters | 14 - .../osrfx2_DCHU_component.inx | 64 -- .../osrfx2_DCHU_component.vcxproj | 272 ----- .../osrfx2_DCHU_componentsoftware.cpp | 489 --------- .../osrfx2_DCHU_componentsoftware.filters | 33 - .../osrfx2_DCHU_componentsoftware.vcxproj | 169 --- .../osrfx2_DCHU_componentsoftware/stdafx.cpp | 8 - .../osrfx2_DCHU_componentsoftware/stdafx.h | 18 - .../osrfx2_DCHU_componentsoftware/targetver.h | 8 - .../osrfx2_DCHU_extension.sln | 73 -- .../osrfx2_DCHU_extension.filters | 14 - .../osrfx2_DCHU_extension.inx | 79 -- .../osrfx2_DCHU_extension.vcxproj | 281 ----- .../osrfx2_DCHU_usersvc/CppWindowsService.cpp | 74 -- .../osrfx2_DCHU_usersvc/Main.cpp | 320 ------ .../osrfx2_DCHU_usersvc/Main.h | 261 ----- .../osrfx2_DCHU_usersvc/SampleService.cpp | 254 ----- .../osrfx2_DCHU_usersvc/SampleService.h | 174 --- .../osrfx2_DCHU_usersvc/ServiceBase.cpp | 794 -------------- .../osrfx2_DCHU_usersvc/ServiceBase.h | 423 ------- .../osrfx2_DCHU_usersvc/ThreadPool.h | 80 -- .../osrfx2_DCHU_usersvc/Utils.cpp | 156 --- .../osrfx2_DCHU_usersvc/Utils.h | 111 -- .../osrfx2_DCHU_usersvc.filters | 54 - .../osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx | Bin 3190 -> 0 bytes .../osrfx2_DCHU_usersvc.vcxproj | 206 ---- .../osrfx2_DCHU_component.filters | 14 + .../osrfx2_DCHU_component.inx | 64 ++ .../osrfx2_DCHU_component.vcxproj | 276 +++++ .../osrfx2_DCHU_componentsoftware.cpp | 489 +++++++++ .../osrfx2_DCHU_componentsoftware.filters | 33 + .../osrfx2_DCHU_componentsoftware.vcxproj | 169 +++ .../osrfx2_DCHU_componentsoftware/stdafx.cpp | 8 + .../osrfx2_DCHU_componentsoftware/stdafx.h | 18 + .../osrfx2_DCHU_componentsoftware/targetver.h | 8 + .../osrfx2_DCHU_extension.sln | 102 ++ .../osrfx2_DCHU_extension.filters | 14 + .../osrfx2_DCHU_extension.inx | 54 + .../osrfx2_DCHU_extension.vcxproj | 266 +++++ .../osrfx2_DCHU_component.inx | 64 ++ .../osrfx2_DCHU_componentsoftware.cpp | 489 +++++++++ .../osrfx2_DCHU_componentsoftware.filters | 33 + .../osrfx2_DCHU_componentsoftware.vcxproj | 169 +++ .../osrfx2_DCHU_componentsoftware/stdafx.cpp | 8 + .../osrfx2_DCHU_componentsoftware/stdafx.h | 18 + .../osrfx2_DCHU_componentsoftware/targetver.h | 8 + .../osrfx2_DCHU_extension.sln | 73 ++ .../osrfx2_DCHU_extension.filters | 14 + .../osrfx2_DCHU_extension.inx | 55 + .../osrfx2_DCHU_extension.vcxproj | 273 +++++ 69 files changed, 6629 insertions(+), 4520 deletions(-) create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln index ce0593e1..dfa90dbd 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln @@ -10,6 +10,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_base", "osrfx2_DCHU_base\osrfx2_DCHU_base.vcxproj", "{5B711254-3F53-4E1D-A1AD-CC81E34588B7}" ProjectSection(ProjectDependencies) = postProject {3CC42473-D121-41F4-AE26-1F2F0AC65E82} = {3CC42473-D121-41F4-AE26-1F2F0AC65E82} + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_testapp", "osrfx2_DCHU_testapp\osrusbfx2.vcxproj", "{6EED5CDD-5526-40DC-97F9-582857E10187}" @@ -18,6 +19,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_filter", "osrfx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_filter", "osrfx2_DCHU_filter\osrfx2_DCHU_filter.vcxproj", "{3CC42473-D121-41F4-AE26-1F2F0AC65E82}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc", "{DA04929E-1AFF-4EB7-935F-E9485C0316DB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc\osrfx2_DCHU_usersvc.vcxproj", "{DE70E2D1-6A4D-4984-BD82-CE750889F0D3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -42,6 +47,7 @@ Global {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|ARM64.ActiveCfg = Release|Win32 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.ActiveCfg = Release|Win32 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.Build.0 = Release|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.Deploy.0 = Release|Win32 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|x64.ActiveCfg = Release|x64 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|x64.Build.0 = Release|x64 {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|ARM.ActiveCfg = Debug|Win32 @@ -72,6 +78,18 @@ Global {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.ActiveCfg = Release|x64 {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.Build.0 = Release|x64 {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.Deploy.0 = Release|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM.ActiveCfg = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM64.ActiveCfg = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|Win32.Build.0 = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.ActiveCfg = Debug|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.Build.0 = Debug|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM.ActiveCfg = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM64.ActiveCfg = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|Win32.ActiveCfg = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|Win32.Build.0 = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.ActiveCfg = Release|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -80,5 +98,6 @@ Global {5B711254-3F53-4E1D-A1AD-CC81E34588B7} = {3B268182-F450-4AB8-B350-A2CF6495F756} {6EED5CDD-5526-40DC-97F9-582857E10187} = {52ABC41E-9AAA-4DA8-8986-F6298E32C8A3} {3CC42473-D121-41F4-AE26-1F2F0AC65E82} = {1665ED66-7966-4FE2-9BA5-B5843511E325} + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {DA04929E-1AFF-4EB7-935F-E9485C0316DB} EndGlobalSection EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx index c4cead6a..4b37e644 100644 Binary files a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx and b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx differ diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj index 4a34c9dc..4cfeed87 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj @@ -26,7 +26,7 @@ Win32 {F915ED95-7BE9-4CDB-B09A-0D3F4C9657FE} osrfx2_DCHU_base - $(LatestTargetPlatformVersion) + 10.0.15063.0 @@ -42,7 +42,7 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -50,7 +50,7 @@ False Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -58,12 +58,12 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary - $(IntDir) + $(SolutionDir)$(Platform)\$(ConfigurationName)\ @@ -137,6 +137,7 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 @@ -162,6 +163,7 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 @@ -187,6 +189,7 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 @@ -212,21 +215,30 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 + + + + + + + + - + @@ -234,11 +246,19 @@ - - + + + + + + + + + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj index 0ef42141..5e015f80 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj @@ -27,7 +27,7 @@ Debug Win32 {1A4A32BA-1596-4F52-BC48-B85A6D8D5D12} - $(LatestTargetPlatformVersion) + 10.0.15063.0 osrfx2_DCHU_filter @@ -44,7 +44,7 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -52,7 +52,7 @@ False Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -60,7 +60,7 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -101,7 +101,7 @@ - %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib + %(AdditionalDependencies);$(SDK_LIB_PATH)onecore.lib %(AdditionalIncludeDirectories);..\..\inc @@ -137,7 +137,7 @@ - %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib + %(AdditionalDependencies);$(SDK_LIB_PATH)onecore.lib %(AdditionalIncludeDirectories);..\..\inc diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj index e1450faf..9ac1e4f3 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj @@ -25,7 +25,7 @@ Win32 {F19E45AF-8B05-4204-A66B-9BDBFE333233} osrfx2_DCHU_testapp - $(LatestTargetPlatformVersion) + 10.0.15063.0 @@ -41,7 +41,7 @@ True Universal - WindowsApplicationForDrivers10.0 + v140 Application @@ -49,7 +49,7 @@ False Universal - WindowsApplicationForDrivers10.0 + v140 Application @@ -57,7 +57,7 @@ True Universal - WindowsApplicationForDrivers10.0 + v140 Application diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp new file mode 100644 index 00000000..98a3975c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + CppWindowsService.cpp + +Abstract: + + The file defines the entry point of the application. According to the + arguments in the command line, the function installs or uninstalls or + starts the service by calling into different routines. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include +#include +#include "ServiceBase.h" +#include "SampleService.h" +#pragma endregion + +// +// Settings of the service +// + +// +// Internal name of the service +// +#define SERVICE_NAME L"OsrUsbFx2UmUserSvc" + + +/*++ + +Routine Description: + + Entry point for the service. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +INT +wmain( + INT Argc, + WCHAR *Argv[] + ) +{ + CSampleService service(SERVICE_NAME); + + if (!CServiceBase::Run(service)) + { + wprintf(L"Service failed to run w/err 0x%08lx\n", GetLastError()); + } + + return 0; +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp new file mode 100644 index 00000000..e9d24c1b --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp @@ -0,0 +1,1152 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Main.cpp + +Abstract: + + Implements the functions to control the OSR USB FX2 device. + +Environment: + + User mode + +--*/ + +#include "Main.h" +#include "Utils.h" + +// +// Keep track of where the OSRFX2 device's bar graph currently is. +// +INT CurrentBar; +BAR_GRAPH_STATE BarGraphState; + +/*++ + +Routine Description: + + Sets the variables in this service to their default values. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +SetVariables() +{ + CurrentBar = 0; +} + + +/*++ + +Routine Description: + + Retrieves the device path of a given interface. + +Arguments: + + InterfaceGuid - The GUID of the interface to search for + + DevicePath - The resulting device path + + DevicePathLength - The length of DevicePath + +Return Value: + + TRUE if the function succeeded and FALSE otherwise. Errors + are logged in the Application event log. + +--*/ +_Success_(return) +BOOL +GetDevicePath( + _In_ LPGUID InterfaceGuid, + _Out_writes_z_(DevicePathLength) PWCHAR DevicePath, + _In_ size_t DevicePathLength + ) +{ + HRESULT hr = E_FAIL; + BOOL Return = FALSE; + CONFIGRET Status = CR_SUCCESS; + PWSTR DeviceInterfaceList = NULL; + ULONG DeviceInterfaceListLength = 0; + PWSTR NextInterface; + + // + // Determine if there are any interfaces that match the OSRFX2 device. + // + Status = CM_Get_Device_Interface_List_Size(&DeviceInterfaceListLength, + InterfaceGuid, + NULL, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); + + if (Status != CR_SUCCESS) + { + WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", + CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); + goto clean0; + } + + if (DeviceInterfaceListLength < 1) + { + WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", + CM_MapCrToWin32Err(Status, ERROR_EMPTY)); + goto clean0; + } + + DeviceInterfaceList = (PWSTR)malloc(DeviceInterfaceListLength * sizeof(WCHAR)); + + if (DeviceInterfaceList == NULL) + { + WriteToEventLog(L"Failed to allocate memory for the device interface list", + TRACE_LEVEL_ERROR); + goto clean0; + } + + ZeroMemory(DeviceInterfaceList, DeviceInterfaceListLength * sizeof(WCHAR)); + + Status = CM_Get_Device_Interface_List(InterfaceGuid, + NULL, + DeviceInterfaceList, + DeviceInterfaceListLength, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); + + if (Status != CR_SUCCESS) + { + WriteToErrorLog(L"CM_Get_Device_Interface_List", + CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); + goto clean0; + } + + if (*DeviceInterfaceList == UNICODE_NULL) + { + WriteToEventLog(L"CM_Get_Device_Interface_List returned an empty list", + TRACE_LEVEL_ERROR); + } + + // + // This sample only expects one interface for the OSRFX2 device. For other + // devices, though, it maybe necessary to sift through the interfaces + // from CM_Get_Device_Interface_List in order to find the correct device. + // + NextInterface = DeviceInterfaceList + wcslen(DeviceInterfaceList) + 1; + + if (*NextInterface != UNICODE_NULL) + { + WriteToEventLog(L"More than one device interface instance found. " + "Selecting first matching device.", + TRACE_LEVEL_WARNING); + } + + hr = StringCchCopy(DevicePath, DevicePathLength, DeviceInterfaceList); + + if (FAILED(hr)) + { + WriteToErrorLog(L"StringCchCopy", HRESULT_CODE(hr)); + goto clean0; + } + +clean0: + + if (DeviceInterfaceList != NULL) + { + free(DeviceInterfaceList); + } + + if (Status == CR_SUCCESS) + { + Return = TRUE; + } + + return Return; +} + + +/*++ + +Routine Description: + + Opens up the OSR USB FX2 device handle. + +Arguments: + + Synchronous - Whether or not this device should be opened for syncrhonous + access + +Return Value: + + The handle to the OSR USB FX2 device. + +--*/ +_Check_return_ +_Ret_notnull_ +_Success_(return != INVALID_HANDLE_VALUE) +HANDLE +OpenDevice( + _In_ BOOL Synchronous +) +{ + HANDLE DeviceHandle; + WCHAR DeviceName[MAX_DEVPATH_LENGTH]; + + if (!GetDevicePath((LPGUID)&GUID_DEVINTERFACE_OSRUSBFX2, + DeviceName, + sizeof(DeviceName) / sizeof(DeviceName[0]))) + { + return INVALID_HANDLE_VALUE; + } + + // + // Open a handle to the interface. + // + if (Synchronous) + { + DeviceHandle = CreateFile(DeviceName, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, // default security + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + } + else + { + DeviceHandle = CreateFile(DeviceName, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, // default security + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, + NULL); + } + + if (DeviceHandle == INVALID_HANDLE_VALUE) + { + WriteToErrorLog(L"CreateFile", GetLastError()); + } + else + { + WriteToEventLog(L"Opened Device Successfully", TRACE_LEVEL_INFORMATION); + } + + return DeviceHandle; +} + + +/*++ + +Routine Description: + + Handles an interface arrival notification. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +InterfaceArrivalAction( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + // + // Now that the interface has arrived, open a handle to it, and then + // register that handle for device events. + // + EnterCriticalSection(&Context->Lock); + + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + // + // The handle was already retrieved. + // + Err = ERROR_SUCCESS; + goto cleanup; + } + + Context->DeviceInterfaceHandle = OpenDevice(FALSE); + + if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + Err = GetLastError(); + WriteToErrorLog(L"Could not open device interface", Err); + goto cleanup; + } + + Err = RegisterDeviceNotifications(Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not register device notifications", Err); + goto cleanup; + } + +cleanup: + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles an interface arrival notification. + +Arguments: + + hNotify - The notification that fired the callback + + hContext - The callback context + + Action - The type of notification + + EventData - Additional information about the callback + + EventDataSize - The size of EventData + +Return Value: + + A Win32 error code. + +--*/ +DWORD +InterfaceCallback( + _In_ HCMNOTIFICATION hNotify, + _In_ PVOID hContext, + _In_ CM_NOTIFY_ACTION Action, + _In_ PCM_NOTIFY_EVENT_DATA EventData, + _In_ DWORD EventDataSize + ) +{ + DWORD Err = ERROR_SUCCESS; + PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + + // + // Validate Context. + // + if (Context == NULL) + { + goto cleanup; + } + + if (Action == CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL) + { + Err = InterfaceArrivalAction(Context); + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Registers the service for notifications using the notification handle in + Context. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +RegisterInterfaceNotifications( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + CONFIGRET cr; + CM_NOTIFY_FILTER NotifyFilter = {0}; + + if (Context == NULL) + { + goto cleanup; + } + + ZeroMemory(&NotifyFilter, sizeof(NotifyFilter)); + NotifyFilter.cbSize = sizeof(NotifyFilter); + NotifyFilter.FilterType = CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE; + NotifyFilter.u.DeviceInterface.ClassGuid = GUID_DEVINTERFACE_OSRUSBFX2; + + cr = CM_Register_Notification(&NotifyFilter, + (PVOID)Context, + (PCM_NOTIFY_CALLBACK)InterfaceCallback, + &Context->InterfaceNotificationHandle); + + if (cr != CR_SUCCESS) + { + Err = CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); + WriteToErrorLog(L"CM_Register_Notification", Err); + goto cleanup; + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Unregister for interface notifications. Note, this routine deadlocks + when called from an interface callback. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +UnregisterInterfaceNotifications( + PHANDLE_CONTEXT Context + ) +{ + CONFIGRET cr; + + if (Context->InterfaceNotificationHandle != NULL) + { + cr = CM_Unregister_Notification(Context->InterfaceNotificationHandle); + + Context->InterfaceNotificationHandle = NULL; + } + + return CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); +} + + +/*++ + +Routine Description: + + Callback for when a device is being query removed. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceQueryRemoveAction( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + // + // Close open handles to allow the device to exit + // + CloseHandle(Context->DeviceInterfaceHandle); + + Context->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + This callback avoids a deadlock when unregistering device notifications. + Rather than calling CM_Unregister_Notification from the callback, the + callback gives that work to a separate thread to avoid deadlock. + +Arguments: + + Instance - The thread's callback instance + + hContext - The callback context + + pWork - The thread handle + +Return Value: + + VOID + +--*/ +VOID +CALLBACK +UnregisterWorkerThreadCallback( + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _Inout_opt_ PVOID hContext, + _Inout_ PTP_WORK pWork + ) +{ + PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + + EnterCriticalSection(&Context->Lock); + + UnregisterDeviceNotifications(Context); + + // + // Close the device handle. + // + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + CloseHandle(Context->DeviceInterfaceHandle); + + Context->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + } + + LeaveCriticalSection(&Context->Lock); +} + + +/*++ + +Routine Description: + + Handles a device query remove failed notification. + +Arguments: + + hNotify - The notification that spurred this callback + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceQueryRemoveFailedAction( + HCMNOTIFICATION hNotify, + PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + // + // In case this callback fires before the registration call returns, make + // sure the notification handle is properly set. + // + Context->InterfaceNotificationHandle = hNotify; + + // + // Unregister the device callback, and then close the handle + // + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } + + LeaveCriticalSection(&Context->Lock); + + // + // Wait for the callback and then re-register the device + // + WaitForThreadpoolWorkCallbacks(Context->Work, FALSE); + + EnterCriticalSection(&Context->Lock); + + if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + Context->DeviceInterfaceHandle = OpenDevice(FALSE); + } + + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + RegisterDeviceNotifications(Context); + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles a device remove pending notification. + +Arguments: + + hNotify - The notification that spurred this callback + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceRemovePendingAction( + HCMNOTIFICATION hNotify, + PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + // + // In case this callback fires before the registration call returns, make + // sure the notification handle is properly set. + // + Context->InterfaceNotificationHandle = hNotify; + + // + // Unregister the device callback, and then close the handle + // + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles a device remove complete notification. + +Arguments: + + hNotify - The notification that spurred this callback + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceRemoveCompleteAction( + HCMNOTIFICATION hNotify, + PHANDLE_CONTEXT Context + ) +{ + __debugbreak(); + + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + // + // In case this callback fires before the registration call returns, make + // sure the notification handle is properly set. + // + Context->InterfaceNotificationHandle = hNotify; + + // + // Unregister the device callback, and then close the handle + // + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles device notifications. + +Arguments: + + hNotify - The notification that spurred this callback + + hContext - The callback context + + Action - The type of callback + + EventData - Additional information about this callback + + EventDataSize - The size of EventData + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceCallback( + _In_ HCMNOTIFICATION hNotify, + _In_ PVOID hContext, + _In_ CM_NOTIFY_ACTION Action, + _In_ PCM_NOTIFY_EVENT_DATA EventData, + _In_ DWORD EventDataSize +) +{ + DWORD Err = ERROR_SUCCESS; + PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + + // + // Validate Context. + // + if (Context == NULL) + { + goto cleanup; + } + + switch (Action) + { + + case CM_NOTIFY_ACTION_DEVICEQUERYREMOVE: + DeviceQueryRemoveAction(Context); + break; + + case CM_NOTIFY_ACTION_DEVICEQUERYREMOVEFAILED: + DeviceQueryRemoveFailedAction(hNotify, Context); + break; + + case CM_NOTIFY_ACTION_DEVICEREMOVEPENDING: + DeviceRemovePendingAction(hNotify, Context); + break; + + case CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE: + DeviceRemoveCompleteAction(hNotify, Context); + break; + + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Register for device notifications. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +RegisterDeviceNotifications( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + CONFIGRET cr; + CM_NOTIFY_FILTER NotifyFilter = {0}; + + NotifyFilter.cbSize = sizeof(NotifyFilter); + NotifyFilter.FilterType = CM_NOTIFY_FILTER_TYPE_DEVICEHANDLE; + NotifyFilter.u.DeviceHandle.hTarget = Context->DeviceInterfaceHandle; + + cr = CM_Register_Notification(&NotifyFilter, + (PVOID)Context, + (PCM_NOTIFY_CALLBACK)DeviceCallback, + &Context->DeviceNotificationHandle); + + if (cr != CR_SUCCESS) + { + Err = CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); + WriteToEventLog(L"Could not register for notifications", TRACE_LEVEL_WARNING); + goto cleanup; + } + + Context->Unregister = FALSE; + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Unregister for device notifications. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +UnregisterDeviceNotifications( + PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + CONFIGRET cr; + + if (Context->DeviceNotificationHandle != NULL) + { + cr = CM_Unregister_Notification(Context->DeviceNotificationHandle); + + if (cr != CR_SUCCESS) + { + Err = CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); + WriteToEventLog(L"Could not unregister notifications", TRACE_LEVEL_WARNING); + } + + Context->DeviceNotificationHandle = NULL; + } + + return Err; +} + + +/*++ + +Routine Description: + + Initialize the given PHANDLE_CONTEXT. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +InitializeContext( + _Out_ PHANDLE_CONTEXT* Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + *Context = (PHANDLE_CONTEXT)malloc(sizeof(HANDLE_CONTEXT)); + + if (*Context == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + (*Context)->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + + InitializeCriticalSection(&(*Context)->Lock); + + (*Context)->Work = CreateThreadpoolWork(UnregisterWorkerThreadCallback, (PVOID)(*Context), NULL); + + if ((*Context)->Work == NULL) + { + WriteToErrorLog(L"Could not create worker thread callback", ERROR_OUTOFMEMORY); + goto cleanup; + } + + (*Context)->DeviceNotificationHandle = NULL; + (*Context)->InterfaceNotificationHandle = NULL; + + // + // Register for device interface events to open and close the handle to + // the interface. + // + Err = RegisterInterfaceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not register notifications", Err); + goto cleanup; + } + + EnterCriticalSection(&(*Context)->Lock); + + // + // The interface may already have arrived while registering for + // notifications. + // + if ((*Context)->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + (*Context)->DeviceInterfaceHandle = OpenDevice(FALSE); + } + + if ((*Context)->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + Err = RegisterDeviceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not register device notifications", Err); + goto cleanup; + } + } + + // + // If OpenDevice ends up returning INVALID_HANDLE_VALUE, that's fine + // since a notification for the interface will arrive later. + // + +cleanup: + + LeaveCriticalSection(&(*Context)->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Clean up the given PHANDLE_CONTEXT. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +CloseContext( + _In_ PHANDLE_CONTEXT* Context + ) +{ + DWORD Err = ERROR_SUCCESS; + BOOL Unregister = FALSE; + + if ((Context == NULL) || + (*Context == NULL)) + { + // + // Nothing to remove. + // + goto cleanup; + } + + EnterCriticalSection(&(*Context)->Lock); + + if (!(*Context)->Unregister) + { + // + // Unregister from the callback here. + // + Unregister = TRUE; + (*Context)->Unregister = TRUE; + } + + LeaveCriticalSection(&(*Context)->Lock); + + // + // Unregister from the interface first, so that re-appearance of the interface + // doesn't cause us to register device events again. + // + Err = UnregisterInterfaceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not unregister interface notifications", Err); + } + + if (Unregister) + { + Err = UnregisterDeviceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not unregister device notifications", Err); + } + } + else + { + WaitForThreadpoolWorkCallbacks((*Context)->Work, FALSE); + } + + // + // No need to lock here, UnregisterDeviceNotifications will wait for all + // outstanding callbacks before returning. + // + if ((*Context)->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + CloseHandle((*Context)->DeviceInterfaceHandle); + + (*Context)->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + } + + if ((*Context)->Work != NULL) + { + CloseThreadpoolWork((*Context)->Work); + } + + DeleteCriticalSection(&(*Context)->Lock); + + free(*Context); + + *Context = NULL; + +cleanup: + + return Err; +} + +/*++ + +Routine Description: + + Turns off all of the bar graph lights on the OSR USB FX2 device. + +Arguments: + + Context - The callback context + +Return Value: + + VOID + +--*/ +DWORD +ClearAllBars( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + ULONG BytesReturned; + + BarGraphState.BarsAsUChar = 0; + + if (!DeviceIoControl(Context->DeviceInterfaceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &BarGraphState, // Pointer to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Pointer to OutBuffer + 0, // Length of OutBuffer + &BytesReturned, // BytesReturned + 0)) // Pointer to Overlapped structure + { + Err = GetLastError(); + WriteToErrorLog(L"DeviceIOControl", Err); + goto cleanup; + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Lights the next bar on the OSR USB FX2 device. + +Arguments: + + Context - The callback context + +Return Value: + + VOID + +--*/ +DWORD +LightNextBar( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + ULONG BytesReturned; + + // + // Normalize to 0-7 + // + CurrentBar += 1; + + if (CurrentBar > 7) + { + CurrentBar = 0; + } + + BarGraphState.BarsAsUChar = 1 << (UCHAR)CurrentBar; + + if (!DeviceIoControl(Context->DeviceInterfaceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &BarGraphState, // Pointer to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Pointer to OutBuffer + 0, // Length of OutBuffer + &BytesReturned, // BytesReturned + 0)) // Pointer to Overlapped structure + { + Err = GetLastError(); + WriteToErrorLog(L"DeviceIOControl", Err); + goto cleanup; + } + +cleanup: + + return Err; +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h new file mode 100644 index 00000000..ecdfa4ad --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h @@ -0,0 +1,342 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Main.h + +Abstract: + + Implements the functions to control the OSR USB FX2 device. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +// {573E8C73-0CB4-4471-A1BF-FAB26C31D384} +DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, + 0x573e8c73, 0xcb4, 0x4471, 0xa1, 0xbf, 0xfa, 0xb2, 0x6c, 0x31, 0xd3, 0x84); + +// +// Most device interface paths will fit into a buffer of this size. +// However, some could be longer, and a larger buffer or dynamically +// allocated buffer may be needed for robust code. +// +#define MAX_DEVPATH_LENGTH 1024 + +#pragma warning(push) +#pragma warning(disable:4201) // nameless struct/union +#pragma warning(disable:4214) // bit field types other than int + +typedef struct _HANDLE_CONTEXT { + HANDLE DeviceInterfaceHandle; + CRITICAL_SECTION Lock; + PTP_WORK Work; + BOOL Unregister; + HCMNOTIFICATION InterfaceNotificationHandle; + HCMNOTIFICATION DeviceNotificationHandle; +} HANDLE_CONTEXT, *PHANDLE_CONTEXT; + +// +// Define the structures that will be used by the IOCTL +// interface to the driver +// + +// +// BAR_GRAPH_STATE +// +// BAR_GRAPH_STATE is a bit field structure with each +// bit corresponding to one of the bar graph on the +// OSRFX2 Development Board +// +#include +typedef struct _BAR_GRAPH_STATE { + + union { + + struct { + // + // Individual bars starting from the + // top of the stack of bars + // + // NOTE: There are actually 10 bars, + // but the very top two do not light + // and are not counted here + // + UCHAR Bar1 : 1; + UCHAR Bar2 : 1; + UCHAR Bar3 : 1; + UCHAR Bar4 : 1; + UCHAR Bar5 : 1; + UCHAR Bar6 : 1; + UCHAR Bar7 : 1; + UCHAR Bar8 : 1; + }; + + // + // The state of all the bar graph as a single + // UCHAR + // + UCHAR BarsAsUChar; + + }; + +}BAR_GRAPH_STATE, *PBAR_GRAPH_STATE; + +// +// SWITCH_STATE +// +// SWITCH_STATE is a bit field structure with each +// bit corresponding to one of the switches on the +// OSRFX2 Development Board +// +typedef struct _SWITCH_STATE { + + union { + struct { + // + // Individual switches starting from the + // left of the set of switches + // + UCHAR Switch1 : 1; + UCHAR Switch2 : 1; + UCHAR Switch3 : 1; + UCHAR Switch4 : 1; + UCHAR Switch5 : 1; + UCHAR Switch6 : 1; + UCHAR Switch7 : 1; + UCHAR Switch8 : 1; + }; + + // + // The state of all the switches as a single + // UCHAR + // + UCHAR SwitchesAsUChar; + + }; + + +}SWITCH_STATE, *PSWITCH_STATE; + +#include + +#pragma warning(pop) + +#define IOCTL_INDEX 0x800 +#define FILE_DEVICE_OSRUSBFX2 65500U + +#define IOCTL_OSRUSBFX2_GET_CONFIG_DESCRIPTOR CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + +#define IOCTL_OSRUSBFX2_RESET_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 1, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + +#define IOCTL_OSRUSBFX2_REENUMERATE_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 3, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + +#define IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 4, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + + +#define IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 5, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + + +#define IOCTL_OSRUSBFX2_READ_SWITCHES CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 6, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + + +#define IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 7, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + + +#define IOCTL_OSRUSBFX2_SET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 8, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + +#define IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE CTL_CODE(FILE_DEVICE_OSRUSBFX2,\ + IOCTL_INDEX + 9, \ + METHOD_OUT_DIRECT, \ + FILE_READ_ACCESS) + +/*++ + +Routine Description: + + Sets the variables in this service to their default values. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID SetVariables(VOID); + + +/*++ + +Routine Description: + + Opens up the OSR USB FX2 device handle. + +Arguments: + + Synchronous - Whether or not this device should be + opened for synchronous access + +Return Value: + + The handle to the OSR USB FX2 device. + +--*/ +HANDLE OpenDevice(_In_ BOOL Synchronous); + + +/*++ + +Routine Description: + + Turns off all of the bar graph lights on the OSR USB FX2 device. + +Arguments: + + DeviceHandle - The handle to the OSR USB FX2 device. + +Return Value: + + VOID + +--*/ +DWORD ClearAllBars(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + + Lights the next bar on the OSR USB FX2 device. + +Arguments: + + DeviceHandle - The handle to the OSR USB FX2 device. + +Return Value: + +VOID + +--*/ +DWORD LightNextBar(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + +Register for device notifications. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD RegisterDeviceNotifications(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + +Unregister for device notifications. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD UnregisterDeviceNotifications(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + +Initialize the given PHANDLE_CONTEXT. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD InitializeContext(PHANDLE_CONTEXT* Context); + + +/*++ + +Routine Description: + +Clean up the given PHANDLE_CONTEXT. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD CloseContext(PHANDLE_CONTEXT* Context); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp new file mode 100644 index 00000000..0a246eb4 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp @@ -0,0 +1,287 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + SampleService.cpp + +Abstract: + + Provides a sample service class that derives from the service base class - + CServiceBase. The sample service logs the service start and stop + information to the Application event log, and shows how to run the main + function of the service in a thread pool worker thread. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include "SampleService.h" +#include "ThreadPool.h" +#pragma endregion + +// +// Variables used for device notifications should normally be local. However, +// we must use a global variable here since there is a potential race condition +// when the service needs to restart during device installation that could +// cause the service to prevent the device from being restarted as well. So, +// this variable is global so that the services OnStart and OnStart method can +// handle its creation and destruction. +// +PHANDLE_CONTEXT Context; + +/*++ + +Routine Description: + + The constructor of CSampleService. It initializes a new instance + of the CSampleService class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. Inherits properties from the class CServiceBase. + +Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + +Return Value: + + VOID + +--*/ +CSampleService::CSampleService( + PWSTR ServiceName, + BOOL CanStop, + BOOL CanShutdown, + BOOL CanPauseContinue + ) +: CServiceBase(ServiceName, CanStop, CanShutdown, CanPauseContinue) +{ + m_fStopping = FALSE; + + // + // Create a manual-reset event that is not signaled at first to indicate + // the stopped signal of the service. + // + m_hStoppedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + if (m_hStoppedEvent == NULL) + { + throw GetLastError(); + } +} + + +/*++ + +Routine Description: + + The virtual destructor of CSampleService. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +CSampleService::~CSampleService() +{ + if (m_hStoppedEvent) + { + CloseHandle(m_hStoppedEvent); + m_hStoppedEvent = NULL; + } +} + + +/*++ + +Routine Description: + + This function is executed when a Start command is sent to the + service by the SCM or when the operating system starts (for a service + that starts automatically). It specifies actions to take when the + service starts. In this code sample, OnStart logs a service-start + message to the Application log, and queues the main service function for + execution in a thread pool worker thread. + + NOTE: A service application is designed to be long running. Therefore, + it usually polls or monitors something in the system. The monitoring is + set up in the OnStart method. However, OnStart does not actually do the + monitoring. The OnStart method must return to the operating system after + the service's operation has begun. It must not loop forever or block. To + set up a simple monitoring mechanism, one general solution is to create + a timer in OnStart. The timer would then raise events in your code + periodically, at which time your service could do its monitoring. The + other solution is to spawn a new thread to perform the main service + functions, which is demonstrated in this code sample. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CSampleService::OnStart( + DWORD Argc, + PWSTR *Argv + ) +{ + // + // Log a service start message to the Application log. + // + WriteToEventLog(L"SampleService in OnStart", + EVENTLOG_INFORMATION_TYPE); + + // + // Set up any variables the service needs. + // + SetVariables(); + + // + // Set up the context, and register for notifications. + // + InitializeContext(&Context); + + // + // Queue the main service function for execution in a worker thread. + // + CThreadPool::QueueUserWorkItem(&CSampleService::ServiceWorkerThread, this); +} + + +/*++ + +Routine Description: + + This method performs the main function of the service. It runs + on a thread pool worker thread. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CSampleService::ServiceWorkerThread() +{ + DWORD Err = ERROR_SUCCESS; + + // + // Periodically check if the service is stopping. + // + while (!m_fStopping) + { + // + // Perform main service function here... + // + + // + // Wait for the device to arrive. + // + if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + ::Sleep(2000); + continue; + } + + Err = ClearAllBars(Context); + + if (Err != ERROR_SUCCESS) + { + continue; + } + + Err = LightNextBar(Context); + + if (Err != ERROR_SUCCESS) + { + continue; + } + + ::Sleep(2000); // Simulate some lengthy operations. + } + + // + // Signal the stopped event. + // + SetEvent(m_hStoppedEvent); +} + + +/*++ + +Routine Description: + + This function is executed when a Stop command is sent to the service by SCM. + It specifies actions to take when a service stops running. In this code + sample, OnStop logs a service-stop message to the Application log, and + waits for the finish of the main service function. + + Be sure to periodically call ReportServiceStatus() with + SERVICE_STOP_PENDING if the procedure is going to take a long time. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CSampleService::OnStop() +{ + __debugbreak(); + + // + // Log a service stop message to the Application log. + // + WriteToEventLog(L"SampleService in OnStop", + EVENTLOG_INFORMATION_TYPE); + + // + // Indicate that the service is stopping and wait for the finish of the + // main service function (ServiceWorkerThread). + // + m_fStopping = TRUE; + + if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0) + { + throw GetLastError(); + } + + // + // Clean up the context after the worker thread has finished. + // + CloseContext(&Context); +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h new file mode 100644 index 00000000..eee8a609 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h @@ -0,0 +1,174 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + SampleService.h + +Abstract: + + Provides a sample service class that derives from the service base class - + CServiceBase. The sample service logs the service start and stop + information to the Application event log, and shows how to run the main + function of the service in a thread pool worker thread. + +Environment: + + User mode + +--*/ + +#pragma once + +#include "ServiceBase.h" +#include "Main.h" + +class CSampleService : public CServiceBase +{ +public: + + /*++ + + Routine Description: + + The constructor of CSampleService. It initializes a new instance + of the CSampleService class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. Inherits properties from the class CServiceBase. + + Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + + Return Value: + + VOID + + --*/ + CSampleService(PWSTR ServiceName, + BOOL CanStop = TRUE, + BOOL CanShutdown = TRUE, + BOOL CanPauseContinue = FALSE); + + /*++ + + Routine Description: + + The virtual destructor of CSampleService. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual ~CSampleService(); + +protected: + + /*++ + + Routine Description: + + This function is executed when a Start command is sent to the + service by the SCM or when the operating system starts (for a service + that starts automatically). It specifies actions to take when the + service starts. In this code sample, OnStart logs a service-start + message to the Application log, and queues the main service function for + execution in a thread pool worker thread. + + NOTE: A service application is designed to be long running. Therefore, + it usually polls or monitors something in the system. The monitoring is + set up in the OnStart method. However, OnStart does not actually do the + monitoring. The OnStart method must return to the operating system after + the service's operation has begun. It must not loop forever or block. To + set up a simple monitoring mechanism, one general solution is to create + a timer in OnStart. The timer would then raise events in your code + periodically, at which time your service could do its monitoring. The + other solution is to spawn a new thread to perform the main service + functions, which is demonstrated in this code sample. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + virtual VOID OnStart(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + This function is executed when a Stop command is sent to the service by SCM. + It specifies actions to take when a service stops running. In this code + sample, OnStop logs a service-stop message to the Application log, and + waits for the finish of the main service function. + + Be sure to periodically call ReportServiceStatus() with + SERVICE_STOP_PENDING if the procedure is going to take a long time. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnStop(); + + + /*++ + + Routine Description: + + This method performs the main function of the service. It runs + on a thread pool worker thread. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID ServiceWorkerThread(); + +private: + + // + // Determines if the service is currently stopping. + // + BOOL m_fStopping; + + // + // The handle to wait for a stop event. + // + HANDLE m_hStoppedEvent; +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp new file mode 100644 index 00000000..4c20af2e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp @@ -0,0 +1,794 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + ServiceBase.cpp + +Abstract: + + Provides a base class for a service that will exist as part of a service + application. CServiceBase must be derived from when creating a new service + class. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include "ServiceBase.h" +#include "Main.h" +#include "Utils.h" +#include +#include +#pragma endregion + + +#pragma region Static Members + +// +// Initialize the singleton service instance. +// +CServiceBase *CServiceBase::s_service = NULL; + + +/*++ + +Routine Description: + + Register the executable for a service with the Service Control + Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start + command, which results in a call to the OnStart method in the service. + This method blocks until the service has stopped. + +Arguments: + + Service - The reference to a CServiceBase object. It will become the + singleton service instance of this service application. + +Return Value: + + If the function succeeds, the return value is TRUE. If the function + fails, the return value is FALSE. To get extended error information, + call GetLastError. + +--*/ +BOOL +CServiceBase::Run( + CServiceBase &Service + ) +{ + s_service = &Service; + + SERVICE_TABLE_ENTRY serviceTable[] = + { + { Service.m_name, ServiceMain }, + { NULL, NULL } + }; + + // + // Connects the main thread of a service process to the service control + // manager, which causes the thread to be the service control dispatcher + // thread for the calling process. This call returns when the service has + // stopped. The process should simply terminate when the call returns. + // + return StartServiceCtrlDispatcher(serviceTable); +} + + +/*++ + +Routine Description: + + The entry point for the service. It registers the handler function + for the service and starts the service. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +WINAPI +CServiceBase::ServiceMain( + DWORD Argc, + PWSTR *Argv + ) +{ + assert(s_service != NULL); + + // + // Register the handler function for the service. + // + s_service->m_statusHandle = RegisterServiceCtrlHandler(s_service->m_name, + ServiceCtrlHandler); + + if (s_service->m_statusHandle == NULL) + { + throw GetLastError(); + } + + // + // Start the service. + // + s_service->Start(Argc, Argv); +} + + +/*++ + +Routine Description: + + Called by the SCM whenever a control code is sent to the service. + +Arguments: + + CtrlCode - The control code. This parameter can be one of + the following values: + + SERVICE_CONTROL_CONTINUE + SERVICE_CONTROL_INTERROGATE + SERVICE_CONTROL_NETBINDADD + SERVICE_CONTROL_NETBINDDISABLE + SERVICE_CONTROL_NETBINDREMOVE + SERVICE_CONTROL_PARAMCHANGE + SERVICE_CONTROL_PAUSE + SERVICE_CONTROL_SHUTDOWN + SERVICE_CONTROL_STOP + + This parameter can also be a user-defined control + code ranging from 128 to 255. + +Return Value: + + VOID + +--*/ +VOID +WINAPI +CServiceBase::ServiceCtrlHandler( + DWORD Ctrl + ) +{ + switch (Ctrl) + { + case SERVICE_CONTROL_STOP: + s_service->Stop(); + break; + case SERVICE_CONTROL_PAUSE: + s_service->Pause(); + break; + case SERVICE_CONTROL_CONTINUE: + s_service->Continue(); + break; + case SERVICE_CONTROL_SHUTDOWN: + s_service->Shutdown(); + break; + case SERVICE_CONTROL_INTERROGATE: + break; + default: + break; + } +} + +#pragma endregion + + +#pragma region Service Constructor and Destructor + +/*++ + +Routine Description: + + The constructor of CServiceBase. It initializes a new instance + of the CServiceBase class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. + +Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + +Return Value: + + VOID + +--*/ +CServiceBase::CServiceBase( + PWSTR ServiceName, + BOOL CanStop, + BOOL CanShutdown, + BOOL CanPauseContinue + ) +{ + // + // Service name must be a valid string and cannot be NULL. + // + m_name = (ServiceName == NULL) ? L"" : ServiceName; + + m_statusHandle = NULL; + + // + // The service runs in its own process. + // + m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + + // + // The service is starting. + // + m_status.dwCurrentState = SERVICE_START_PENDING; + + // + // The accepted commands of the service. + // + DWORD dwControlsAccepted = 0; + + if (CanStop) + { + dwControlsAccepted |= SERVICE_ACCEPT_STOP; + } + + if (CanShutdown) + { + dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN; + } + + if (CanPauseContinue) + { + dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE; + } + + m_status.dwControlsAccepted = dwControlsAccepted; + + m_status.dwWin32ExitCode = NO_ERROR; + m_status.dwServiceSpecificExitCode = 0; + m_status.dwCheckPoint = 0; + m_status.dwWaitHint = 0; + + SetupEvents(); +} + + +/*++ + +Routine Description: + + The virtual destructor of CServiceBase. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +CServiceBase::~CServiceBase() +{ + DestroyEvents(); +} + +#pragma endregion + + +#pragma region Service Start, Stop, Pause, Continue, and Shutdown + +/*++ + +Routine Description: + + This function starts the service. It calls the OnStart virtual function + in which you can specify the actions to take when the service starts. If + an error occurs during the startup, the error will be logged in the + Application event log, and the service will be stopped. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Start( + DWORD Argc, + PWSTR *Argv +) +{ + try + { + // + // Tell SCM that the service is starting. + // + SetServiceStatus(SERVICE_START_PENDING); + + // + // Perform service-specific initialization. + // + OnStart(Argc, Argv); + + // + // Tell SCM that the service is started. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Start", Error); + + // + // Set the service status to be stopped. + // + SetServiceStatus(SERVICE_STOPPED, Error); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to start.", EVENTLOG_ERROR_TYPE); + + // + // Set the service status to be stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Start + command is sent to the service by the SCM or when the operating system + starts (for a service that starts automatically). Specifies actions to + take when the service starts. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the + procedure is going to take long time. You may also consider spawning a + new thread in OnStart to perform time-consuming initialization tasks. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnStart( + DWORD Argc, + PWSTR *Argv +) +{ + SetVariables(); +} + + +/*++ + +Routine Description: + + This function stops the service. It calls the OnStop virtual + function in which you can specify the actions to take when the service + stops. If an error occurs, the error will be logged in the Application + event log, and the service will be restored to the original state. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Stop() +{ + DWORD OriginalState = m_status.dwCurrentState; + + try + { + // + // Tell SCM that the service is stopping. + // + SetServiceStatus(SERVICE_STOP_PENDING); + + // + // Perform service-specific stop operations. + // + OnStop(); + + // + // Tell SCM that the service is stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Stop", Error); + + // + // Set the orginal service status. + // + SetServiceStatus(OriginalState); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to stop.", EVENTLOG_ERROR_TYPE); + + // + // Set the orginal service status. + // + SetServiceStatus(OriginalState); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Stop + command is sent to the service by the SCM. Specifies actions to take + when a service stops running. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the + procedure is going to take long time. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnStop() +{ +} + + +/*++ + +Routine Description: + + The function pauses the service if the service supports pause + and continue. It calls the OnPause virtual function in which you can + specify the actions to take when the service pauses. If an error occurs, + the error will be logged in the Application event log, and the service + will become running. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Pause() +{ + try + { + // + // Tell SCM that the service is pausing. + // + SetServiceStatus(SERVICE_PAUSE_PENDING); + + // + // Perform service-specific pause operations. + // + OnPause(); + + // + // Tell SCM that the service is paused. + // + SetServiceStatus(SERVICE_PAUSED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Pause", Error); + + // + // Tell SCM that the service is still running. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to pause.", EVENTLOG_ERROR_TYPE); + + // + // Tell SCM that the service is still running. + // + SetServiceStatus(SERVICE_RUNNING); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Pause + command is sent to the service by the SCM. Specifies actions to take + when a service pauses. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnPause() +{ +} + + +/*++ + +Routine Description: + + The function resumes normal functioning after being paused if + the service supports pause and continue. It calls the OnContinue virtual + function in which you can specify the actions to take when the service + continues. If an error occurs, the error will be logged in the + Application event log, and the service will still be paused. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Continue() +{ + try + { + // + // Tell SCM that the service is resuming. + // + SetServiceStatus(SERVICE_CONTINUE_PENDING); + + // + // Perform service-specific continue operations. + // + OnContinue(); + + // + // Tell SCM that the service is running. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Continue", Error); + + // + // Tell SCM that the service is still paused. + // + SetServiceStatus(SERVICE_PAUSED); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to resume.", EVENTLOG_ERROR_TYPE); + + // + // Tell SCM that the service is still paused. + // + SetServiceStatus(SERVICE_PAUSED); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, OnContinue runs when a + Continue command is sent to the service by the SCM. Specifies actions to + take when a service resumes normal functioning after being paused. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnContinue() +{ +} + + +/*++ + +Routine Description: + + The function executes when the system is shutting down. It + calls the OnShutdown virtual function in which you can specify what + should occur immediately prior to the system shutting down. If an error + occurs, the error will be logged in the Application event log. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Shutdown() +{ + try + { + // + // Perform service-specific shutdown operations. + // + OnShutdown(); + + // + // Tell SCM that the service is stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Shutdown", Error); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to shut down.", EVENTLOG_ERROR_TYPE); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when the system + is shutting down. Specifies what should occur immediately prior to the + system shutting down. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnShutdown() +{ +} + +#pragma endregion + + +#pragma region Helper Functions + +/*++ + +Routine Description: + + The function sets the service status and reports the status to the SCM. + +Arguments: + + CurrentState - The current state of the service + + Win32ExitCode - The error code to report + + WaitHint - The estimated time for pending operation, in milliseconds + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::SetServiceStatus( + DWORD CurrentState, + DWORD Win32ExitCode, + DWORD WaitHint + ) +{ + static DWORD CheckPoint = 1; + + // + // Fill in the SERVICE_STATUS structure of the service. + // + + m_status.dwCurrentState = CurrentState; + m_status.dwWin32ExitCode = Win32ExitCode; + m_status.dwWaitHint = WaitHint; + + m_status.dwCheckPoint = ((CurrentState == SERVICE_RUNNING) || + (CurrentState == SERVICE_STOPPED)) ? 0 : + CheckPoint++; + + // + // Report the status of the service to the SCM. + // + ::SetServiceStatus(m_statusHandle, &m_status); +} + +#pragma endregion \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h new file mode 100644 index 00000000..106597e1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h @@ -0,0 +1,423 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + ServiceBase.cpp + +Abstract: + + Provides a base class for a service that will exist as part of a service + application. CServiceBase must be derived from when creating a new service + class. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include "Utils.h" + +class CServiceBase +{ +public: + + /*++ + + Routine Description: + + Register the executable for a service with the Service Control + Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start + command, which results in a call to the OnStart method in the service. + This method blocks until the service has stopped. + + Arguments: + + Service - The reference to a CServiceBase object. It will become the + singleton service instance of this service application. + + Return Value: + + If the function succeeds, the return value is TRUE. If the function + fails, the return value is FALSE. To get extended error information, + call GetLastError. + + --*/ + static BOOL Run(CServiceBase &service); + + + /*++ + + Routine Description: + + The constructor of CServiceBase. It initializes a new instance + of the CServiceBase class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. + + Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + + Return Value: + + VOID + + --*/ + CServiceBase(PWSTR ServiceName, + BOOL CanStop = TRUE, + BOOL CanShutdown = TRUE, + BOOL CanPauseContinue = FALSE); + + + /*++ + + Routine Description: + + The virtual destructor of CServiceBase. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual ~CServiceBase(); + + + /*++ + + Routine Description: + + This function stops the service. It calls the OnStop virtual + function in which you can specify the actions to take when the service + stops. If an error occurs, the error will be logged in the Application + event log, and the service will be restored to the original state. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Stop(); + +protected: + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Start + command is sent to the service by the SCM or when the operating system + starts (for a service that starts automatically). Specifies actions to + take when the service starts. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the + procedure is going to take long time. You may also consider spawning a + new thread in OnStart to perform time-consuming initialization tasks. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + virtual VOID OnStart(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Stop + command is sent to the service by the SCM. Specifies actions to take + when a service stops running. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the + procedure is going to take long time. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnStop(); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Pause + command is sent to the service by the SCM. Specifies actions to take + when a service pauses. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnPause(); + + + /*++ + + Routine Description: + + When implemented in a derived class, OnContinue runs when a + Continue command is sent to the service by the SCM. Specifies actions to + take when a service resumes normal functioning after being paused. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnContinue(); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when the system + is shutting down. Specifies what should occur immediately prior to the + system shutting down. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnShutdown(); + + + /*++ + + Routine Description: + + The function sets the service status and reports the status to the SCM. + + Arguments: + + CurrentState - The current state of the service + + Win32ExitCode - The error code to report + + WaitHint - The estimated time for pending operation, in milliseconds + + Return Value: + + VOID + + --*/ + VOID SetServiceStatus(DWORD CurrentState, + DWORD Win32ExitCode = NO_ERROR, + DWORD WaitHint = 0); + +private: + + /*++ + + Routine Description: + + The entry point for the service. It registers the handler function + for the service and starts the service. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + static VOID WINAPI ServiceMain(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + Called by the SCM whenever a control code is sent to the service. + + Arguments: + + CtrlCode - The control code. This parameter can be one of + the following values: + + SERVICE_CONTROL_CONTINUE + SERVICE_CONTROL_INTERROGATE + SERVICE_CONTROL_NETBINDADD + SERVICE_CONTROL_NETBINDDISABLE + SERVICE_CONTROL_NETBINDREMOVE + SERVICE_CONTROL_PARAMCHANGE + SERVICE_CONTROL_PAUSE + SERVICE_CONTROL_SHUTDOWN + SERVICE_CONTROL_STOP + + This parameter can also be a user-defined control + code ranging from 128 to 255. + + Return Value: + + VOID + + --*/ + static VOID WINAPI ServiceCtrlHandler(DWORD Ctrl); + + + /*++ + + Routine Description: + + This function starts the service. It calls the OnStart virtual function + in which you can specify the actions to take when the service starts. If + an error occurs during the startup, the error will be logged in the + Application event log, and the service will be stopped. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + VOID Start(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + The function pauses the service if the service supports pause + and continue. It calls the OnPause virtual function in which you can + specify the actions to take when the service pauses. If an error occurs, + the error will be logged in the Application event log, and the service + will become running. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Pause(); + + + /*++ + + Routine Description: + + The function resumes normal functioning after being paused if + the service supports pause and continue. It calls the OnContinue virtual + function in which you can specify the actions to take when the service + continues. If an error occurs, the error will be logged in the + Application event log, and the service will still be paused. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Continue(); + + + /*++ + + Routine Description: + + The function executes when the system is shutting down. It + calls the OnShutdown virtual function in which you can specify what + should occur immediately prior to the system shutting down. If an error + occurs, the error will be logged in the Application event log. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Shutdown(); + + + // + // The singleton service instance. + // + static CServiceBase *s_service; + + // + // The name of the service. + // + PWSTR m_name; + + // + // The status of the service. + // + SERVICE_STATUS m_status; + + // + // The service status handle. + // + SERVICE_STATUS_HANDLE m_statusHandle; +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h new file mode 100644 index 00000000..3d851537 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h @@ -0,0 +1,80 @@ +/****************************** Module Header ******************************\ +* Module Name: ThreadPool.h +* Project: CppWindowsService +* Copyright (c) Microsoft Corporation. +* +* The class was designed by Kenny Kerr. It provides the ability to queue +* simple member functions of a class to the Windows thread pool. +* +* Using the thread pool is simple and feels natural in C++. +* +* class CSampleService +* { +* public: +* +* void AsyncRun() +* { +* CThreadPool::QueueUserWorkItem(&Service::Run, this); +* } +* +* void Run() +* { +* // Some lengthy operation +* } +* }; +* +* Kenny Kerr spends most of his time designing and building distributed +* applications for the Microsoft Windows platform. He also has a particular +* passion for C++ and security programming. Reach Kenny at +* http://weblogs.asp.net/kennykerr/ or visit his Web site: +* http://www.kennyandkarin.com/Kenny/. +* +* This source is subject to the Microsoft Public License. +* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL. +* All other rights reserved. +* +* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +\***************************************************************************/ + +#pragma once + +#include + + +class CThreadPool +{ +public: + + template + static void QueueUserWorkItem(void (T::*function)(void), + T *object, ULONG flags = WT_EXECUTELONGFUNCTION) + { + typedef std::pair CallbackType; + std::auto_ptr p(new CallbackType(function, object)); + + if (::QueueUserWorkItem(ThreadProc, p.get(), flags)) + { + // The ThreadProc now has the responsibility of deleting the pair. + p.release(); + } + else + { + throw GetLastError(); + } + } + +private: + + template + static DWORD WINAPI ThreadProc(PVOID context) + { + typedef std::pair CallbackType; + + std::auto_ptr p(static_cast(context)); + + (p->second->*p->first)(); + return 0; + } +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp new file mode 100644 index 00000000..e8fc87ee --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp @@ -0,0 +1,156 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Utils.cpp + +Abstract: + + Provides utility function to SampleApp.cpp. + +Environment: + + User mode + +--*/ + +#include "Utils.h" + +// +// Service trace event provider +// {54a25c42-cd91-4210-98cc-c3447b56e447} +// +EXTERN_C __declspec(selectany) const GUID SERVICE_PROVIDER_GUID = { 0x54a25c42, 0xcd91, 0x4210,{ 0x98, 0xcc, 0xc3, 0x44, 0x7b, 0x56, 0xe4, 0x47 } }; + +REGHANDLE m_etwRegHandle; + + +/*++ + +Routine Description: + + Sets up logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +SetupEvents() +{ + NTSTATUS status = EventRegister(&SERVICE_PROVIDER_GUID, + nullptr, + nullptr, + &m_etwRegHandle); + + if (status != ERROR_SUCCESS) + { + wprintf(L"Provider not registered. EventRegister failed with error: 0x%08X\n", status); + } +} + + +/*++ + +Routine Description: + + Destroys logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +DestroyEvents() +{ + if (m_etwRegHandle != NULL) + { + EventUnregister(m_etwRegHandle); + } +} + + +/*++ + +Routine Description: + + Log a message. + +Arguments: + + Message - The string message to be logged + + Level - The type of event to be logged. This parameter can + be one of the following values: + + TRACE_LEVEL_CRITICAL + TRACE_LEVEL_ERROR + TRACE_LEVEL_WARNING + TRACE_LEVEL_INFORMATION + TRACE_LEVEL_VERBOSE + +Return Value: + + VOID + +--*/ +VOID +WriteToEventLog( + PWSTR Message, + BYTE Level + ) +{ + if (m_etwRegHandle != NULL) + { + EventWriteString(m_etwRegHandle, Level, 0, Message); + } +} + + +/*++ + +Routine Description: + + Log an error message. + +Arguments: + + Function - The function that gives the error + + Error - The error code + +Return Value: + + VOID + +--*/ +VOID +WriteToErrorLog( + PWSTR Function, + DWORD Error + ) +{ + WCHAR Message[260]; + + StringCchPrintf(Message, ARRAYSIZE(Message), + L"%ws failed with error: 0x%08x", Function, Error); + + WriteToEventLog(Message, TRACE_LEVEL_ERROR); +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h new file mode 100644 index 00000000..b619f461 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Utils.cpp + +Abstract: + + Provides utility function to SampleApp.cpp. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include +#include +#include + +/*++ + +Routine Description: + + Sets up logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID SetupEvents(); + + +/*++ + +Routine Description: + + Destroys logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID DestroyEvents(); + + +/*++ + +Routine Description: + + Log a message. + +Arguments: + + Message - The string message to be logged + + Level - The type of event to be logged. This parameter can + be one of the following values: + + TRACE_LEVEL_CRITICAL + TRACE_LEVEL_ERROR + TRACE_LEVEL_WARNING + TRACE_LEVEL_INFORMATION + TRACE_LEVEL_VERBOSE + +Return Value: + + VOID + +--*/ +VOID WriteToEventLog(PWSTR Message, BYTE Level); + + +/*++ + +Routine Description: + + Log an error message. + +Arguments: + + Function - The function that gives the error + + Error - The error code + +Return Value: + + VOID + +--*/ +VOID WriteToErrorLog(PWSTR Function, DWORD Error); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters new file mode 100644 index 00000000..7f12a302 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters @@ -0,0 +1,54 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx new file mode 100644 index 00000000..61e1e958 Binary files /dev/null and b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx differ diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj new file mode 100644 index 00000000..8547d303 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj @@ -0,0 +1,206 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} + osrfx2_DCHU_usersvc + Win32Proj + osrfx2_DCHU_usersvc + 10.0.15063.0 + + + + Application + Unicode + true + v140 + + + Application + Unicode + v140 + + + Application + Unicode + false + v140 + + + Application + Unicode + v140 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Full + WIN32;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreaded + + + Level3 + EditAndContinue + + + true + Console + MachineX86 + onecoreuap.lib;%(AdditionalDependencies); + + + + + Full + true + WIN32;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + true + + + Level3 + ProgramDatabase + + + true + Console + true + true + MachineX86 + onecoreuap.lib;%(AdditionalDependencies); + + + + + X64 + + + Full + WIN32;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreaded + + + Level3 + ProgramDatabase + + + true + Console + MachineX64 + onecoreuap.lib;%(AdditionalDependencies); + + + + + + + + + X64 + + + Full + true + WIN32;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + true + + + Level3 + ProgramDatabase + + + true + Console + true + true + MachineX64 + onecoreuap.lib;%(AdditionalDependencies); + + + + + + + + + + + + + + + + + + + true + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln deleted file mode 100644 index e09b5650..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln +++ /dev/null @@ -1,73 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component", "{E498C537-BA1A-4E9D-8F1E-9DC7646D2E1A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware", "{E50E958C-B5D0-43E0-9D81-87F484F11E9F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component\osrfx2_DCHU_component.vcxproj", "{F90EFA96-B075-4531-B4E1-F406362D16BF}" - ProjectSection(ProjectDependencies) = postProject - {26D91630-B8FF-4102-A258-32F7D1C84E20} = {26D91630-B8FF-4102-A258-32F7D1C84E20} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware\osrfx2_DCHU_componentsoftware.vcxproj", "{26D91630-B8FF-4102-A258-32F7D1C84E20}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.ActiveCfg = Debug|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Build.0 = Debug|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Deploy.0 = Debug|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Build.0 = Debug|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.ActiveCfg = Debug|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Build.0 = Debug|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Deploy.0 = Debug|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.ActiveCfg = Debug|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Build.0 = Debug|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Deploy.0 = Debug|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.ActiveCfg = Release|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Build.0 = Release|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Deploy.0 = Release|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.ActiveCfg = Release|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Build.0 = Release|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Deploy.0 = Release|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.ActiveCfg = Release|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Build.0 = Release|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Deploy.0 = Release|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.ActiveCfg = Release|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Build.0 = Release|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Deploy.0 = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM.ActiveCfg = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM64.ActiveCfg = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.ActiveCfg = Debug|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.Build.0 = Debug|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.ActiveCfg = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.Build.0 = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM.ActiveCfg = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM64.ActiveCfg = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.ActiveCfg = Release|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.Build.0 = Release|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.ActiveCfg = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {F90EFA96-B075-4531-B4E1-F406362D16BF} = {E498C537-BA1A-4E9D-8F1E-9DC7646D2E1A} - {26D91630-B8FF-4102-A258-32F7D1C84E20} = {E50E958C-B5D0-43E0-9D81-87F484F11E9F} - EndGlobalSection -EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters deleted file mode 100644 index fa953f4c..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {8E41214B-6785-4CFE-B992-037D68949A14} - inf;inv;inx;mof;mc; - - - - - Driver Files - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx deleted file mode 100644 index 8baab1a0..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx +++ /dev/null @@ -1,64 +0,0 @@ -;/*++ -; -;Copyright (c) Microsoft Corporation. All rights reserved. -; -; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR -; PURPOSE. -; -;Module Name: -; -; osrfx2_DCHU_component.INF -; -;Abstract: -; -; Installation inf for one of the OSR FX2 Learning Kit's -; AddComponent directives -; -;--*/ - -[Version] -Signature = "$Windows NT$" -Class = SoftwareComponent -ClassGuid = {5c4c3332-344d-483c-8739-259e934c9cc8} -Provider = %ManufacturerName% -CatalogFile = osrfx2_DCHU_component.cat - -[Manufacturer] -%ManufacturerName% = OsrFx2Component, NT$ARCH$ - -[OsrFx2Component.NT$ARCH$] -%DeviceName% = OsrFx2Component_Install, SWC\VID_045e&PID_94ab - -[SourceDisksFiles] -osrfx2_DCHU_componentsoftware.exe = 1 - -[SourceDisksNames] -1 = %DiskName% - -[DestinationDirs] -OsrFx2Component_CopyFiles = 13 ; copy to driverstore - -[OsrFx2Component_Install.NT] -CopyFiles = OsrFx2Component_CopyFiles - -[OsrFx2Component_Install.NT.Services] -AddService = , 0x00000002 - -[OsrFx2Component_Install.NT.Software] -AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall - -[OsrFx2Component_SoftwareInstall] -SoftwareType = 1 -SoftwareBinary = osrfx2_DCHU_componentsoftware.exe -SoftwareArguments = <> -SoftwareVersion = 1.0.0.0 - -[OsrFx2Component_CopyFiles] -osrfx2_DCHU_componentsoftware.exe - -[Strings] -ManufacturerName = "Contoso" -DiskName = "OsrFx2 DCHU Component Installation Disk" -DeviceName = "OsrFx2 DCHU Component Device" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj deleted file mode 100644 index fed7ddf4..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj +++ /dev/null @@ -1,272 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM - - - Release - ARM - - - Debug - ARM64 - - - Release - ARM64 - - - - - - - - - - - - - - - - - - - - - - - - - {F90EFA96-B075-4531-B4E1-F406362D16BF} - {4605da2c-74a5-4865-98e1-152ef136825f} - v4.5 - 12.0 - Debug - Win32 - osrfx2_DCHU_component - osrfx2_DCHU_component - - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - - - - - - - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp deleted file mode 100644 index c14e66d1..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - osrfx2_DCHU_componentsoftware.cpp - -Abstract: - - An example .exe to run using the AddSoftware directive within an INF. - Contains an example on how to obtain a handle to the primary device using - SoftwareArguments within an AddSoftware directive's section. - -Environment: - - User mode - ---*/ - -#include "stdafx.h" - -#define BUFFER_SIZE (128 * sizeof(WCHAR)) -#define DEVICE_REG_SUBKEY L"OSR" -#define DEVICE_VALUE_OP_MODE L"OperatingMode" -#define DEVICE_VALUE_OP_PARAMS L"OperatingParams" -#define DEVICE_VALUE_OP_EXCEPTIONS L"OperatingExceptions" -#define CONTOSO_FILEPATH L"C:\\Program Files\\Contoso" -#define OSRFX2_DCHU_FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU" -#define FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU\\AddSoftwareInstallationFile.txt" -#define FILE_CONTENT L"Operating Mode: %ws\r\nOperating Params: %ws\r\nOperating Exceptions: %ws" - - -/*++ - -Routine Description: - -Arguments: - -Return Value: - - ---*/ -DWORD -WriteToFile( - _In_ PWSTR MessageText, - _In_ DWORD MessageTextLength - ) -{ - DWORD Err = ERROR_SUCCESS; - BOOL ErrorFlag = FALSE; - HANDLE hFile = INVALID_HANDLE_VALUE; - DWORD BytesToWrite; - DWORD BytesWritten; - - if (!CreateDirectory(CONTOSO_FILEPATH, NULL)) - { - Err = GetLastError(); - - if (Err == ERROR_ALREADY_EXISTS) - { - Err = ERROR_SUCCESS; - } - else - { - goto cleanup; - } - } - - if (!CreateDirectory(OSRFX2_DCHU_FILEPATH, NULL)) - { - Err = GetLastError(); - - if (Err == ERROR_ALREADY_EXISTS) - { - Err = ERROR_SUCCESS; - } - else - { - goto cleanup; - } - } - - hFile = CreateFile(FILEPATH, - GENERIC_WRITE, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Err = ERROR_INVALID_PARAMETER; - goto cleanup; - } - - BytesToWrite = MessageTextLength * sizeof(WCHAR); - - ErrorFlag = WriteFile(hFile, - MessageText, - BytesToWrite, - &BytesWritten, - NULL); - - if ((!ErrorFlag) || - (BytesToWrite != BytesWritten)) - { - Err = GetLastError(); - goto cleanup; - } - -cleanup: - - if (hFile != INVALID_HANDLE_VALUE) - { - CloseHandle(hFile); - } - - return Err; -} - - -/*++ - -Routine Description: - - Obtains the handle to the device that used a separate Software Component - INF to install software. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -__cdecl -_tmain( - INT Argc, - TCHAR *Argv[]) -{ - DWORD Err = ERROR_SUCCESS; - HRESULT hr = S_OK; - BOOL ErrorFlag = FALSE; - DWORD BytesToWrite = 0; - DWORD BytesWritten = 0; - PTSTR DeviceInstanceId; - HDEVINFO DevInfoList = INVALID_HANDLE_VALUE; - SP_DEVINFO_DATA DevInfoData; - WCHAR ParentDeviceInstanceId[MAX_DEVICE_ID_LEN]; - DWORD RequiredSize; - DEVPROPTYPE DevPropType; - SP_DEVINFO_DATA ParentDevInfoData; - HKEY DevRegKey = NULL; - PWSTR OperatingMode = NULL; - PWSTR OperatingParams = NULL; - PWSTR OperatingExceptions = NULL; - DWORD ValueType; - DWORD ValueSize = BUFFER_SIZE; - HKEY DevOsrRegKey = NULL; - PWSTR FileText = NULL; - DWORD FileTextLength; - - // - // Validate arguments. - // - if (Argc != 2) - { - Err = ERROR_INVALID_PARAMETER; - goto cleanup; - } - - OperatingMode = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); - - if (OperatingMode == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - OperatingParams = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); - - if (OperatingParams == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - OperatingExceptions = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); - - if (OperatingExceptions == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - // - // Argv[1] should be the device instance ID. - // - DeviceInstanceId = Argv[1]; - - // - // Create a device info list to store queried device handles. - // - DevInfoList = SetupDiCreateDeviceInfoList(NULL, NULL); - - if (DevInfoList == INVALID_HANDLE_VALUE) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - - // - // Add the Software Component device that called AddSoftware to the - // device info list, which will be used to find the primary device that - // called AddComponent in the first place. - // - if (!SetupDiOpenDeviceInfo(DevInfoList, - DeviceInstanceId, - NULL, - 0, - &DevInfoData)) - { - Err = GetLastError(); - goto cleanup; - } - - // - // Get the device instance id of the opened device's parent. - // - if (!SetupDiGetDeviceProperty(DevInfoList, - &DevInfoData, - &DEVPKEY_Device_Parent, - &DevPropType, - (PBYTE)ParentDeviceInstanceId, - sizeof(ParentDeviceInstanceId), - &RequiredSize, - 0)) - { - Err = GetLastError(); - goto cleanup; - } - - if ((DevPropType != DEVPROP_TYPE_STRING) || - (RequiredSize < sizeof(WCHAR))) - { - Err = ERROR_INVALID_PARAMETER; - goto cleanup; - } - - ParentDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - - // - // Get the parent of the device we retrieved first, which is the device - // that called AddComponent in its INF. - // - if (!SetupDiOpenDeviceInfoW(DevInfoList, - ParentDeviceInstanceId, - NULL, - 0, - &ParentDevInfoData)) - { - Err = GetLastError(); - goto cleanup; - } - - // - // Open up the HW registry keys of the primary device. - // - DevRegKey = SetupDiOpenDevRegKey(DevInfoList, - &ParentDevInfoData, - DICS_FLAG_GLOBAL, - 0, - DIREG_DEV, - KEY_READ); - - if (DevRegKey == INVALID_HANDLE_VALUE) - { - Err = GetLastError(); - DevRegKey = NULL; - goto cleanup; - } - - Err = RegOpenKeyEx(DevRegKey, - DEVICE_REG_SUBKEY, - 0, - KEY_QUERY_VALUE, - &DevOsrRegKey); - - if (Err != ERROR_SUCCESS) - { - goto cleanup; - } - - // - // Retrieve the registry values defined in the primary device's INF. - // Note that if the extension INF was applied, the extension INF would - // overwrite OperatingParams and create OperatingExceptions. - // - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_MODE, - NULL, - &ValueType, - (LPBYTE)OperatingMode, - &ValueSize); - - while (Err == ERROR_MORE_DATA) - { - // - // Create a larger buffer. - // - OperatingMode = (PTSTR)realloc(OperatingMode, ValueSize); - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_MODE, - NULL, - &ValueType, - (LPBYTE)OperatingMode, - &ValueSize); - } - - if (Err != ERROR_SUCCESS) - { - OperatingMode[0] = TEXT('\0'); - } - else if ((ValueType != REG_SZ) || - (ValueSize < sizeof(TCHAR))) - { - Err = ERROR_REGISTRY_CORRUPT; - OperatingMode[0] = TEXT('\0'); - } - - ValueSize = BUFFER_SIZE; - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_PARAMS, - NULL, - &ValueType, - (LPBYTE)OperatingParams, - &ValueSize); - - while (Err == ERROR_MORE_DATA) - { - // - // Create a larger buffer. - // - OperatingParams = (PTSTR)realloc(OperatingParams, ValueSize); - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_MODE, - NULL, - &ValueType, - (LPBYTE)OperatingParams, - &ValueSize); - } - - if (Err != ERROR_SUCCESS) - { - OperatingParams[0] = TEXT('\0'); - } - else if ((ValueType != REG_SZ) || - (ValueSize < sizeof(TCHAR))) - { - Err = ERROR_REGISTRY_CORRUPT; - OperatingParams[0] = TEXT('\0'); - } - - ValueSize = BUFFER_SIZE; - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_EXCEPTIONS, - NULL, - &ValueType, - (LPBYTE)OperatingExceptions, - &ValueSize); - - while (Err == ERROR_MORE_DATA) - { - // - // Create a larger buffer. - // - OperatingExceptions = (PTSTR)realloc(OperatingExceptions, ValueSize); - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_EXCEPTIONS, - NULL, - &ValueType, - (LPBYTE)OperatingExceptions, - &ValueSize); - } - - if (Err != ERROR_SUCCESS) - { - OperatingExceptions[0] = TEXT('\0'); - } - else if ((ValueType != REG_SZ) || - (ValueSize < sizeof(TCHAR))) - { - Err = ERROR_REGISTRY_CORRUPT; - OperatingExceptions[0] = TEXT('\0'); - } - - FileTextLength = (DWORD)wcslen(OperatingMode) + - (DWORD)wcslen(OperatingParams) + - (DWORD)wcslen(OperatingExceptions) + - (DWORD)wcslen(FILE_CONTENT) - - 9; // Subtract the 3 %ws - - FileText = (PWSTR)malloc((FileTextLength + 1) * sizeof(WCHAR)); - - if (FileText == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - hr = StringCchPrintf(FileText, - FileTextLength + 1, - FILE_CONTENT, - OperatingMode, - OperatingParams, - OperatingExceptions); - - if (FAILED(hr)) - { - Err = HRESULT_CODE(hr); - goto cleanup; - } - - Err = WriteToFile(FileText, FileTextLength); - - if (Err != ERROR_SUCCESS) - { - goto cleanup; - } - -cleanup: - - if (FileText != NULL) - { - free(FileText); - } - - if (OperatingExceptions != NULL) - { - free(OperatingExceptions); - } - - if (OperatingParams != NULL) - { - free(OperatingParams); - } - - if (OperatingMode != NULL) - { - free(OperatingMode); - } - - if (DevOsrRegKey != NULL) - { - RegCloseKey(DevOsrRegKey); - } - - if (DevRegKey != NULL) - { - RegCloseKey(DevRegKey); - } - - if (DevInfoList != INVALID_HANDLE_VALUE) - { - SetupDiDestroyDeviceInfoList(DevInfoList); - } - - return; -} - diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters deleted file mode 100644 index 395438fa..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj deleted file mode 100644 index 2bb8b05d..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj +++ /dev/null @@ -1,169 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {26D91630-B8FF-4102-A258-32F7D1C84E20} - Win32Proj - osrfx2_DCHU_componentsoftware - 10.0.15063.0 - osrfx2_DCHU_componentsoftware - - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - true - $(ProjectName) - - - false - - - false - $(ProjectName) - .exe - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Console - true - onecoreuap.lib;setupapi.lib; - - - - - Use - Level3 - Disabled - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Console - true - onecoreuap.lib;setupapi.lib; - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - Console - true - true - true - onecoreuap.lib;setupapi.lib; - - - - - Level3 - Use - MaxSpeed - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Console - true - true - true - onecoreuap.lib;setupapi.lib; - - - - - - - - - - - - Create - Create - Create - Create - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp deleted file mode 100644 index 79325e21..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// osrusbfx2umsoftware.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/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h deleted file mode 100644 index edb61924..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h +++ /dev/null @@ -1,18 +0,0 @@ -// 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 -#include -#include -#include -#include -#include -#include -#include -#include - -// TODO: reference additional headers your program requires here diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h deleted file mode 100644 index 87c0086d..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln deleted file mode 100644 index 386ba436..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln +++ /dev/null @@ -1,73 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DHCU_extension", "osrfx2_DHCU_extension", "{4577857A-CCAE-42EB-BDE2-16C1E3DC7B14}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc", "{D10B02D6-7E48-4F78-8AAE-20C93E77FA52}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension\osrfx2_DCHU_extension.vcxproj", "{0588DF70-3923-42E6-8DC9-13C2C0186F20}" - ProjectSection(ProjectDependencies) = postProject - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc\osrfx2_DCHU_usersvc.vcxproj", "{DE70E2D1-6A4D-4984-BD82-CE750889F0D3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.ActiveCfg = Debug|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Build.0 = Debug|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Deploy.0 = Debug|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Build.0 = Debug|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.ActiveCfg = Debug|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Build.0 = Debug|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Deploy.0 = Debug|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.ActiveCfg = Debug|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Build.0 = Debug|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Deploy.0 = Debug|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.ActiveCfg = Release|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Build.0 = Release|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Deploy.0 = Release|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.ActiveCfg = Release|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Build.0 = Release|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Deploy.0 = Release|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.ActiveCfg = Release|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Build.0 = Release|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Deploy.0 = Release|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.ActiveCfg = Release|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Build.0 = Release|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Deploy.0 = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM.ActiveCfg = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM64.ActiveCfg = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.ActiveCfg = Debug|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.Build.0 = Debug|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x86.ActiveCfg = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x86.Build.0 = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM.ActiveCfg = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM64.ActiveCfg = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.ActiveCfg = Release|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.Build.0 = Release|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x86.ActiveCfg = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {0588DF70-3923-42E6-8DC9-13C2C0186F20} = {4577857A-CCAE-42EB-BDE2-16C1E3DC7B14} - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {D10B02D6-7E48-4F78-8AAE-20C93E77FA52} - EndGlobalSection -EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters deleted file mode 100644 index 0ba1a59c..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {8E41214B-6785-4CFE-B992-037D68949A14} - inf;inv;inx;mof;mc; - - - - - Driver Files - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx deleted file mode 100644 index d90c39f7..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx +++ /dev/null @@ -1,79 +0,0 @@ -;/*++ -; -;Copyright (c) Microsoft Corporation. All rights reserved. -; -; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR -; PURPOSE. -; -;Module Name: -; -; osrfx2_DCHU_extension.INF -; -;Abstract: -; -; Extension inf for the OSR FX2 Learning Kit -; -;--*/ - -[Version] -Signature = "$WINDOWS NT$" -Class = Extension -ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} -Provider = %ManufacturerName% -ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} -CatalogFile = osrfx2_DCHU_extension.cat -DriverVer = 05/16/2017,15.14.36.721 - -[Manufacturer] -%ManufacturerName% = OsrFx2Extension, NT$ARCH$ - -[OsrFx2Extension.NT$ARCH$] -%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_045e&Pid_94aa&mi_00 -%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 - -[OsrFx2Extension_Install.NT] -CopyInf=osrfx2_DCHU_usersvc.inf - -[OsrFx2Extension_Install.NT.HW] -AddReg = OsrFx2Extension_AddReg -AddReg = OsrFx2Extension_COMAddReg - -[OsrFx2Extension_AddReg] -HKR, OSR, "OperatingParams",, "-Extended" -HKR, OSR, "OperatingExceptions",, "x86" - -; Add all registry keys to successfully register the -; In-Process ATL COM Server MSFT Sample. -[OsrFx2Extension_COMAddReg] -HKCR,AppID\ATLDllCOMServer.DLL,AppID,,"{9DD18FED-55F6-4741-AF25-798B90C4AED5}" -HKCR,AppID\{9DD18FED-55F6-4741-AF25-798B90C4AED5},,,"ATLDllCOMServer" -HKCR,ATLDllCOMServer.SimpleObject,,,"SimpleObject Class" -HKCR,ATLDllCOMServer.SimpleObject\CLSID,,,"{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}" -HKCR,ATLDllCOMServer.SimpleObject\CurVer,,,"ATLDllCOMServer.SimpleObject.1" -HKCR,ATLDllCOMServer.SimpleObject.1,,,"SimpleObject Class" -HKCR,ATLDllCOMServer.SimpleObject.1\CLSID,,,"{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084},,,"SimpleObject Class" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\InprocServer32,,%REG_EXPAND_SZ%,"%%SystemRoot%%\System32\ATLDllCOMServer.dll" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\InprocServer32,ThreadingModel,,"Apartment" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\ProgID,,,"ATLDllCOMServer.SimpleObject.1" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\Programmable,,%FLG_ADDREG_KEYONLY% -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\TypeLib,,,"{9B23EFED-A0C1-46B6-A903-218206447F3E}" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\VersionIndependentProgID,,,"ATLDllCOMServer.SimpleObject" - -[OsrFx2Extension_Install.NT.Components] -AddComponent = osrfx2_DCHU_component,,OsrFx2Extension_ComponentInstall -AddComponent = osrfx2_DCHU_usersvc,,OsrFx2Extension_ComponentInstall_UserSvc - -[OsrFx2Extension_ComponentInstall] -ComponentIds=VID_045e&PID_94ab - -[OsrFx2Extension_ComponentInstall_UserSvc] -ComponentIds=VID_045e&PID_94ac - -[Strings] -ManufacturerName = "Contoso" -OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" -REG_EXPAND_SZ = 0x00020000 -FLG_ADDREG_KEYONLY = 0x00000010 \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj deleted file mode 100644 index 232cfa89..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj +++ /dev/null @@ -1,281 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM - - - Release - ARM - - - Debug - ARM64 - - - Release - ARM64 - - - - - - - - - - - - - - - - - - - - - - - - - - {0588DF70-3923-42E6-8DC9-13C2C0186F20} - {4605da2c-74a5-4865-98e1-152ef136825f} - v4.6.1 - 12.0 - Debug - Win32 - osrfx2_DCHU_extension - osrfx2_DCHU_extension - - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - - - - - - - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp deleted file mode 100644 index 98a3975c..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - CppWindowsService.cpp - -Abstract: - - The file defines the entry point of the application. According to the - arguments in the command line, the function installs or uninstalls or - starts the service by calling into different routines. - -Environment: - - User mode - ---*/ - -#pragma region Includes -#include -#include -#include "ServiceBase.h" -#include "SampleService.h" -#pragma endregion - -// -// Settings of the service -// - -// -// Internal name of the service -// -#define SERVICE_NAME L"OsrUsbFx2UmUserSvc" - - -/*++ - -Routine Description: - - Entry point for the service. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -INT -wmain( - INT Argc, - WCHAR *Argv[] - ) -{ - CSampleService service(SERVICE_NAME); - - if (!CServiceBase::Run(service)) - { - wprintf(L"Service failed to run w/err 0x%08lx\n", GetLastError()); - } - - return 0; -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp deleted file mode 100644 index 157a6cb9..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Main.cpp - -Abstract: - - Implements the functions to control the OSR USB FX2 device. - -Environment: - - User mode - ---*/ - -#include "Main.h" -#include "Utils.h" - -INT CurrentBar; -BAR_GRAPH_STATE BarGraphState; - -/*++ - -Routine Description: - - Sets the variables in this service to their default values. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -SetVariables() -{ - CurrentBar = 0; -} - - -/*++ - -Routine Description: - - Retrieves the device path of a given interface. - -Arguments: - - InterfaceGuid - The GUID of the interface to search for - - DevicePath - The resulting device path - - DevicePathLength - The length of DevicePath - -Return Value: - - TRUE if the function succeeded and FALSE otherwise. Errors - are logged in the Application event log. - ---*/ -_Success_(return) -BOOL -GetDevicePath( - _In_ LPGUID InterfaceGuid, - _Out_writes_z_(DevicePathLength) PWCHAR DevicePath, - _In_ size_t DevicePathLength - ) -{ - HRESULT hr = E_FAIL; - BOOL Return = FALSE; - CONFIGRET Status = CR_SUCCESS; - PWSTR DeviceInterfaceList = NULL; - ULONG DeviceInterfaceListLength = 0; - PWSTR NextInterface; - - Status = CM_Get_Device_Interface_List_Size(&DeviceInterfaceListLength, - InterfaceGuid, - NULL, - CM_GET_DEVICE_INTERFACE_LIST_PRESENT); - - if (Status != CR_SUCCESS) - { - WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", - CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); - goto clean0; - } - - if (DeviceInterfaceListLength < 1) - { - WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", - CM_MapCrToWin32Err(Status, ERROR_EMPTY)); - goto clean0; - } - - DeviceInterfaceList = (PWSTR)malloc(DeviceInterfaceListLength * sizeof(WCHAR)); - - if (DeviceInterfaceList == NULL) - { - WriteToEventLog(L"Failed to allocate memory for the device interface list", - TRACE_LEVEL_ERROR); - goto clean0; - } - - ZeroMemory(DeviceInterfaceList, DeviceInterfaceListLength * sizeof(WCHAR)); - - Status = CM_Get_Device_Interface_List(InterfaceGuid, - NULL, - DeviceInterfaceList, - DeviceInterfaceListLength, - CM_GET_DEVICE_INTERFACE_LIST_PRESENT); - - if (Status != CR_SUCCESS) - { - WriteToErrorLog(L"CM_Get_Device_Interface_List", - CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); - goto clean0; - } - - if (*DeviceInterfaceList == UNICODE_NULL) - { - WriteToEventLog(L"CM_Get_Device_Interface_List returned an empty list", - TRACE_LEVEL_ERROR); - } - - NextInterface = DeviceInterfaceList + wcslen(DeviceInterfaceList) + 1; - - if (*NextInterface != UNICODE_NULL) - { - WriteToEventLog(L"More than one device interface instance found. " - "Selecting first matching device.", - TRACE_LEVEL_WARNING); - } - - hr = StringCchCopy(DevicePath, DevicePathLength, DeviceInterfaceList); - - if (FAILED(hr)) - { - WriteToErrorLog(L"StringCchCopy", HRESULT_CODE(hr)); - goto clean0; - } - -clean0: - - if (DeviceInterfaceList != NULL) - { - free(DeviceInterfaceList); - } - - if (Status == CR_SUCCESS) - { - Return = TRUE; - } - - return Return; -} - - -/*++ - -Routine Description: - - Opens up the OSR USB FX2 device handle. - -Arguments: - - Synchronous - Whether or not this device should be - opened for synchronous access - -Return Value: - - The handle to the OSR USB FX2 device. - ---*/ -_Check_return_ -_Ret_notnull_ -_Success_(return != INVALID_HANDLE_VALUE) -HANDLE -OpenDevice( - _In_ BOOL Synchronous - ) -{ - HANDLE DeviceHandle; - WCHAR DeviceName[MAX_DEVPATH_LENGTH]; - - if (!GetDevicePath((LPGUID)&GUID_DEVINTERFACE_OSRUSBFX2, - DeviceName, - sizeof(DeviceName) / sizeof(DeviceName[0]))) - { - return INVALID_HANDLE_VALUE; - } - - if (Synchronous) - { - DeviceHandle = CreateFile(DeviceName, - GENERIC_WRITE | GENERIC_READ, - FILE_SHARE_WRITE | FILE_SHARE_READ, - NULL, // default security - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - } - else - { - DeviceHandle = CreateFile(DeviceName, - GENERIC_WRITE | GENERIC_READ, - FILE_SHARE_WRITE | FILE_SHARE_READ, - NULL, // default security - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, - NULL); - } - - if (DeviceHandle == INVALID_HANDLE_VALUE) - { - WriteToErrorLog(L"CreateFile", GetLastError()); - } - else - { - WriteToEventLog(L"Opened Device Successfully", TRACE_LEVEL_INFORMATION); - } - - return DeviceHandle; -} - - -/*++ - -Routine Description: - - Turns off all of the bar graph lights on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device - -Return Value: - - VOID - ---*/ -VOID -ClearAllBars( - _In_ HANDLE DeviceHandle - ) -{ - ULONG BytesReturned; - - BarGraphState.BarsAsUChar = 0; - - if (!DeviceIoControl(DeviceHandle, - IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, - &BarGraphState, // Pointer to InBuffer - sizeof(BAR_GRAPH_STATE), // Length of InBuffer - NULL, // Pointer to OutBuffer - 0, // Length of OutBuffer - &BytesReturned, // BytesReturned - 0)) // Pointer to Overlapped structure - { - WriteToErrorLog(L"DeviceIOControl", GetLastError()); - } -} - - -/*++ - -Routine Description: - - Lights the next bar on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device - -Return Value: - - VOID - ---*/ -VOID -LightNextBar( - _In_ HANDLE DeviceHandle - ) -{ - ULONG BytesReturned; - - // - // Normalize to 0-7 - // - CurrentBar += 1; - - if (CurrentBar > 7) - { - CurrentBar = 0; - } - - BarGraphState.BarsAsUChar = 1 << (UCHAR)CurrentBar; - - if (!DeviceIoControl(DeviceHandle, - IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, - &BarGraphState, // Pointer to InBuffer - sizeof(BAR_GRAPH_STATE), // Length of InBuffer - NULL, // Pointer to OutBuffer - 0, // Length of OutBuffer - &BytesReturned, // BytesReturned - 0)) // Pointer to Overlapped structure - { - WriteToErrorLog(L"DeviceIOControl", GetLastError()); - } -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h deleted file mode 100644 index dcbd950e..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h +++ /dev/null @@ -1,261 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Main.h - -Abstract: - - Implements the functions to control the OSR USB FX2 device. - -Environment: - - User mode - ---*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -// {573E8C73-0CB4-4471-A1BF-FAB26C31D384} -DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, - 0x573e8c73, 0xcb4, 0x4471, 0xa1, 0xbf, 0xfa, 0xb2, 0x6c, 0x31, 0xd3, 0x84); - -// -// Most device interface paths will fit into a buffer of this size. -// However, some could be longer, and a larger buffer or dynamically -// allocated buffer may be needed for robust code. -// -#define MAX_DEVPATH_LENGTH 1024 - -#pragma warning(push) -#pragma warning(disable:4201) // nameless struct/union -#pragma warning(disable:4214) // bit field types other than int - -// -// Define the structures that will be used by the IOCTL -// interface to the driver -// - -// -// BAR_GRAPH_STATE -// -// BAR_GRAPH_STATE is a bit field structure with each -// bit corresponding to one of the bar graph on the -// OSRFX2 Development Board -// -#include -typedef struct _BAR_GRAPH_STATE { - - union { - - struct { - // - // Individual bars starting from the - // top of the stack of bars - // - // NOTE: There are actually 10 bars, - // but the very top two do not light - // and are not counted here - // - UCHAR Bar1 : 1; - UCHAR Bar2 : 1; - UCHAR Bar3 : 1; - UCHAR Bar4 : 1; - UCHAR Bar5 : 1; - UCHAR Bar6 : 1; - UCHAR Bar7 : 1; - UCHAR Bar8 : 1; - }; - - // - // The state of all the bar graph as a single - // UCHAR - // - UCHAR BarsAsUChar; - - }; - -}BAR_GRAPH_STATE, *PBAR_GRAPH_STATE; - -// -// SWITCH_STATE -// -// SWITCH_STATE is a bit field structure with each -// bit corresponding to one of the switches on the -// OSRFX2 Development Board -// -typedef struct _SWITCH_STATE { - - union { - struct { - // - // Individual switches starting from the - // left of the set of switches - // - UCHAR Switch1 : 1; - UCHAR Switch2 : 1; - UCHAR Switch3 : 1; - UCHAR Switch4 : 1; - UCHAR Switch5 : 1; - UCHAR Switch6 : 1; - UCHAR Switch7 : 1; - UCHAR Switch8 : 1; - }; - - // - // The state of all the switches as a single - // UCHAR - // - UCHAR SwitchesAsUChar; - - }; - - -}SWITCH_STATE, *PSWITCH_STATE; - -#include - -#pragma warning(pop) - -#define IOCTL_INDEX 0x800 -#define FILE_DEVICE_OSRUSBFX2 65500U - -#define IOCTL_OSRUSBFX2_GET_CONFIG_DESCRIPTOR CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - -#define IOCTL_OSRUSBFX2_RESET_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 1, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - -#define IOCTL_OSRUSBFX2_REENUMERATE_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 3, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - -#define IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 4, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - - -#define IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 5, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - - -#define IOCTL_OSRUSBFX2_READ_SWITCHES CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 6, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - - -#define IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 7, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - - -#define IOCTL_OSRUSBFX2_SET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 8, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - -#define IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE CTL_CODE(FILE_DEVICE_OSRUSBFX2,\ - IOCTL_INDEX + 9, \ - METHOD_OUT_DIRECT, \ - FILE_READ_ACCESS) - -/*++ - -Routine Description: - - Sets the variables in this service to their default values. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID SetVariables(); - - -/*++ - -Routine Description: - - Opens up the OSR USB FX2 device handle. - -Arguments: - - Synchronous - Whether or not this device should be - opened for synchronous access - -Return Value: - - The handle to the OSR USB FX2 device. - ---*/ -HANDLE OpenDevice(_In_ BOOL Synchronous); - - -/*++ - -Routine Description: - - Turns off all of the bar graph lights on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device. - -Return Value: - - VOID - ---*/ -VOID ClearAllBars(HANDLE deviceHandle); - - -/*++ - -Routine Description: - - Lights the next bar on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device. - -Return Value: - -VOID - ---*/ -VOID LightNextBar(HANDLE deviceHandle); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp deleted file mode 100644 index c39e4838..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - SampleService.cpp - -Abstract: - - Provides a sample service class that derives from the service base class - - CServiceBase. The sample service logs the service start and stop - information to the Application event log, and shows how to run the main - function of the service in a thread pool worker thread. - -Environment: - - User mode - ---*/ - -#pragma region Includes -#include "SampleService.h" -#include "ThreadPool.h" -#pragma endregion - -HANDLE DeviceHandle; - -/*++ - -Routine Description: - - The constructor of CSampleService. It initializes a new instance - of the CSampleService class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. Inherits properties from the class CServiceBase. - -Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - -Return Value: - - VOID - ---*/ -CSampleService::CSampleService( - PWSTR ServiceName, - BOOL CanStop, - BOOL CanShutdown, - BOOL CanPauseContinue - ) -: CServiceBase(ServiceName, CanStop, CanShutdown, CanPauseContinue) -{ - m_fStopping = FALSE; - - // - // Create a manual-reset event that is not signaled at first to indicate - // the stopped signal of the service. - // - m_hStoppedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (m_hStoppedEvent == NULL) - { - throw GetLastError(); - } -} - - -/*++ - -Routine Description: - - The virtual destructor of CSampleService. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -CSampleService::~CSampleService() -{ - if (m_hStoppedEvent) - { - CloseHandle(m_hStoppedEvent); - m_hStoppedEvent = NULL; - } -} - - -/*++ - -Routine Description: - - This function is executed when a Start command is sent to the - service by the SCM or when the operating system starts (for a service - that starts automatically). It specifies actions to take when the - service starts. In this code sample, OnStart logs a service-start - message to the Application log, and queues the main service function for - execution in a thread pool worker thread. - - NOTE: A service application is designed to be long running. Therefore, - it usually polls or monitors something in the system. The monitoring is - set up in the OnStart method. However, OnStart does not actually do the - monitoring. The OnStart method must return to the operating system after - the service's operation has begun. It must not loop forever or block. To - set up a simple monitoring mechanism, one general solution is to create - a timer in OnStart. The timer would then raise events in your code - periodically, at which time your service could do its monitoring. The - other solution is to spawn a new thread to perform the main service - functions, which is demonstrated in this code sample. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -CSampleService::OnStart( - DWORD Argc, - PWSTR *Argv - ) -{ - // - // Log a service start message to the Application log. - // - WriteToEventLog(L"SampleService in OnStart", - EVENTLOG_INFORMATION_TYPE); - - // - // Set variables in the base class - // - - // - // Open the device - // - DeviceHandle = OpenDevice(FALSE); - - if (DeviceHandle == INVALID_HANDLE_VALUE) - { - return; - } - - // - // Queue the main service function for execution in a worker thread. - // - CThreadPool::QueueUserWorkItem(&CSampleService::ServiceWorkerThread, this); -} - - -/*++ - -Routine Description: - - This method performs the main function of the service. It runs - on a thread pool worker thread. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CSampleService::ServiceWorkerThread() -{ - // - // Periodically check if the service is stopping. - // - while (!m_fStopping) - { - // - // Perform main service function here... - // - - ClearAllBars(DeviceHandle); - LightNextBar(DeviceHandle); - - ::Sleep(2000); // Simulate some lengthy operations. - } - - // - // Signal the stopped event. - // - SetEvent(m_hStoppedEvent); -} - - -/*++ - -Routine Description: - - This function is executed when a Stop command is sent to the service by SCM. - It specifies actions to take when a service stops running. In this code - sample, OnStop logs a service-stop message to the Application log, and - waits for the finish of the main service function. - - Be sure to periodically call ReportServiceStatus() with - SERVICE_STOP_PENDING if the procedure is going to take a long time. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CSampleService::OnStop() -{ - // - // Log a service stop message to the Application log. - // - WriteToEventLog(L"SampleService in OnStop", - EVENTLOG_INFORMATION_TYPE); - - // - // Indicate that the service is stopping and wait for the finish of the - // main service function (ServiceWorkerThread). - // - m_fStopping = TRUE; - - if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0) - { - throw GetLastError(); - } -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h deleted file mode 100644 index eee8a609..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h +++ /dev/null @@ -1,174 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - SampleService.h - -Abstract: - - Provides a sample service class that derives from the service base class - - CServiceBase. The sample service logs the service start and stop - information to the Application event log, and shows how to run the main - function of the service in a thread pool worker thread. - -Environment: - - User mode - ---*/ - -#pragma once - -#include "ServiceBase.h" -#include "Main.h" - -class CSampleService : public CServiceBase -{ -public: - - /*++ - - Routine Description: - - The constructor of CSampleService. It initializes a new instance - of the CSampleService class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. Inherits properties from the class CServiceBase. - - Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - - Return Value: - - VOID - - --*/ - CSampleService(PWSTR ServiceName, - BOOL CanStop = TRUE, - BOOL CanShutdown = TRUE, - BOOL CanPauseContinue = FALSE); - - /*++ - - Routine Description: - - The virtual destructor of CSampleService. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual ~CSampleService(); - -protected: - - /*++ - - Routine Description: - - This function is executed when a Start command is sent to the - service by the SCM or when the operating system starts (for a service - that starts automatically). It specifies actions to take when the - service starts. In this code sample, OnStart logs a service-start - message to the Application log, and queues the main service function for - execution in a thread pool worker thread. - - NOTE: A service application is designed to be long running. Therefore, - it usually polls or monitors something in the system. The monitoring is - set up in the OnStart method. However, OnStart does not actually do the - monitoring. The OnStart method must return to the operating system after - the service's operation has begun. It must not loop forever or block. To - set up a simple monitoring mechanism, one general solution is to create - a timer in OnStart. The timer would then raise events in your code - periodically, at which time your service could do its monitoring. The - other solution is to spawn a new thread to perform the main service - functions, which is demonstrated in this code sample. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - virtual VOID OnStart(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - This function is executed when a Stop command is sent to the service by SCM. - It specifies actions to take when a service stops running. In this code - sample, OnStop logs a service-stop message to the Application log, and - waits for the finish of the main service function. - - Be sure to periodically call ReportServiceStatus() with - SERVICE_STOP_PENDING if the procedure is going to take a long time. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnStop(); - - - /*++ - - Routine Description: - - This method performs the main function of the service. It runs - on a thread pool worker thread. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID ServiceWorkerThread(); - -private: - - // - // Determines if the service is currently stopping. - // - BOOL m_fStopping; - - // - // The handle to wait for a stop event. - // - HANDLE m_hStoppedEvent; -}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp deleted file mode 100644 index 4c20af2e..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp +++ /dev/null @@ -1,794 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - ServiceBase.cpp - -Abstract: - - Provides a base class for a service that will exist as part of a service - application. CServiceBase must be derived from when creating a new service - class. - -Environment: - - User mode - ---*/ - -#pragma region Includes -#include "ServiceBase.h" -#include "Main.h" -#include "Utils.h" -#include -#include -#pragma endregion - - -#pragma region Static Members - -// -// Initialize the singleton service instance. -// -CServiceBase *CServiceBase::s_service = NULL; - - -/*++ - -Routine Description: - - Register the executable for a service with the Service Control - Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start - command, which results in a call to the OnStart method in the service. - This method blocks until the service has stopped. - -Arguments: - - Service - The reference to a CServiceBase object. It will become the - singleton service instance of this service application. - -Return Value: - - If the function succeeds, the return value is TRUE. If the function - fails, the return value is FALSE. To get extended error information, - call GetLastError. - ---*/ -BOOL -CServiceBase::Run( - CServiceBase &Service - ) -{ - s_service = &Service; - - SERVICE_TABLE_ENTRY serviceTable[] = - { - { Service.m_name, ServiceMain }, - { NULL, NULL } - }; - - // - // Connects the main thread of a service process to the service control - // manager, which causes the thread to be the service control dispatcher - // thread for the calling process. This call returns when the service has - // stopped. The process should simply terminate when the call returns. - // - return StartServiceCtrlDispatcher(serviceTable); -} - - -/*++ - -Routine Description: - - The entry point for the service. It registers the handler function - for the service and starts the service. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -WINAPI -CServiceBase::ServiceMain( - DWORD Argc, - PWSTR *Argv - ) -{ - assert(s_service != NULL); - - // - // Register the handler function for the service. - // - s_service->m_statusHandle = RegisterServiceCtrlHandler(s_service->m_name, - ServiceCtrlHandler); - - if (s_service->m_statusHandle == NULL) - { - throw GetLastError(); - } - - // - // Start the service. - // - s_service->Start(Argc, Argv); -} - - -/*++ - -Routine Description: - - Called by the SCM whenever a control code is sent to the service. - -Arguments: - - CtrlCode - The control code. This parameter can be one of - the following values: - - SERVICE_CONTROL_CONTINUE - SERVICE_CONTROL_INTERROGATE - SERVICE_CONTROL_NETBINDADD - SERVICE_CONTROL_NETBINDDISABLE - SERVICE_CONTROL_NETBINDREMOVE - SERVICE_CONTROL_PARAMCHANGE - SERVICE_CONTROL_PAUSE - SERVICE_CONTROL_SHUTDOWN - SERVICE_CONTROL_STOP - - This parameter can also be a user-defined control - code ranging from 128 to 255. - -Return Value: - - VOID - ---*/ -VOID -WINAPI -CServiceBase::ServiceCtrlHandler( - DWORD Ctrl - ) -{ - switch (Ctrl) - { - case SERVICE_CONTROL_STOP: - s_service->Stop(); - break; - case SERVICE_CONTROL_PAUSE: - s_service->Pause(); - break; - case SERVICE_CONTROL_CONTINUE: - s_service->Continue(); - break; - case SERVICE_CONTROL_SHUTDOWN: - s_service->Shutdown(); - break; - case SERVICE_CONTROL_INTERROGATE: - break; - default: - break; - } -} - -#pragma endregion - - -#pragma region Service Constructor and Destructor - -/*++ - -Routine Description: - - The constructor of CServiceBase. It initializes a new instance - of the CServiceBase class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. - -Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - -Return Value: - - VOID - ---*/ -CServiceBase::CServiceBase( - PWSTR ServiceName, - BOOL CanStop, - BOOL CanShutdown, - BOOL CanPauseContinue - ) -{ - // - // Service name must be a valid string and cannot be NULL. - // - m_name = (ServiceName == NULL) ? L"" : ServiceName; - - m_statusHandle = NULL; - - // - // The service runs in its own process. - // - m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; - - // - // The service is starting. - // - m_status.dwCurrentState = SERVICE_START_PENDING; - - // - // The accepted commands of the service. - // - DWORD dwControlsAccepted = 0; - - if (CanStop) - { - dwControlsAccepted |= SERVICE_ACCEPT_STOP; - } - - if (CanShutdown) - { - dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN; - } - - if (CanPauseContinue) - { - dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE; - } - - m_status.dwControlsAccepted = dwControlsAccepted; - - m_status.dwWin32ExitCode = NO_ERROR; - m_status.dwServiceSpecificExitCode = 0; - m_status.dwCheckPoint = 0; - m_status.dwWaitHint = 0; - - SetupEvents(); -} - - -/*++ - -Routine Description: - - The virtual destructor of CServiceBase. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -CServiceBase::~CServiceBase() -{ - DestroyEvents(); -} - -#pragma endregion - - -#pragma region Service Start, Stop, Pause, Continue, and Shutdown - -/*++ - -Routine Description: - - This function starts the service. It calls the OnStart virtual function - in which you can specify the actions to take when the service starts. If - an error occurs during the startup, the error will be logged in the - Application event log, and the service will be stopped. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Start( - DWORD Argc, - PWSTR *Argv -) -{ - try - { - // - // Tell SCM that the service is starting. - // - SetServiceStatus(SERVICE_START_PENDING); - - // - // Perform service-specific initialization. - // - OnStart(Argc, Argv); - - // - // Tell SCM that the service is started. - // - SetServiceStatus(SERVICE_RUNNING); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Start", Error); - - // - // Set the service status to be stopped. - // - SetServiceStatus(SERVICE_STOPPED, Error); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to start.", EVENTLOG_ERROR_TYPE); - - // - // Set the service status to be stopped. - // - SetServiceStatus(SERVICE_STOPPED); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when a Start - command is sent to the service by the SCM or when the operating system - starts (for a service that starts automatically). Specifies actions to - take when the service starts. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the - procedure is going to take long time. You may also consider spawning a - new thread in OnStart to perform time-consuming initialization tasks. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnStart( - DWORD Argc, - PWSTR *Argv -) -{ - SetVariables(); -} - - -/*++ - -Routine Description: - - This function stops the service. It calls the OnStop virtual - function in which you can specify the actions to take when the service - stops. If an error occurs, the error will be logged in the Application - event log, and the service will be restored to the original state. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Stop() -{ - DWORD OriginalState = m_status.dwCurrentState; - - try - { - // - // Tell SCM that the service is stopping. - // - SetServiceStatus(SERVICE_STOP_PENDING); - - // - // Perform service-specific stop operations. - // - OnStop(); - - // - // Tell SCM that the service is stopped. - // - SetServiceStatus(SERVICE_STOPPED); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Stop", Error); - - // - // Set the orginal service status. - // - SetServiceStatus(OriginalState); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to stop.", EVENTLOG_ERROR_TYPE); - - // - // Set the orginal service status. - // - SetServiceStatus(OriginalState); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when a Stop - command is sent to the service by the SCM. Specifies actions to take - when a service stops running. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the - procedure is going to take long time. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnStop() -{ -} - - -/*++ - -Routine Description: - - The function pauses the service if the service supports pause - and continue. It calls the OnPause virtual function in which you can - specify the actions to take when the service pauses. If an error occurs, - the error will be logged in the Application event log, and the service - will become running. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Pause() -{ - try - { - // - // Tell SCM that the service is pausing. - // - SetServiceStatus(SERVICE_PAUSE_PENDING); - - // - // Perform service-specific pause operations. - // - OnPause(); - - // - // Tell SCM that the service is paused. - // - SetServiceStatus(SERVICE_PAUSED); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Pause", Error); - - // - // Tell SCM that the service is still running. - // - SetServiceStatus(SERVICE_RUNNING); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to pause.", EVENTLOG_ERROR_TYPE); - - // - // Tell SCM that the service is still running. - // - SetServiceStatus(SERVICE_RUNNING); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when a Pause - command is sent to the service by the SCM. Specifies actions to take - when a service pauses. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnPause() -{ -} - - -/*++ - -Routine Description: - - The function resumes normal functioning after being paused if - the service supports pause and continue. It calls the OnContinue virtual - function in which you can specify the actions to take when the service - continues. If an error occurs, the error will be logged in the - Application event log, and the service will still be paused. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Continue() -{ - try - { - // - // Tell SCM that the service is resuming. - // - SetServiceStatus(SERVICE_CONTINUE_PENDING); - - // - // Perform service-specific continue operations. - // - OnContinue(); - - // - // Tell SCM that the service is running. - // - SetServiceStatus(SERVICE_RUNNING); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Continue", Error); - - // - // Tell SCM that the service is still paused. - // - SetServiceStatus(SERVICE_PAUSED); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to resume.", EVENTLOG_ERROR_TYPE); - - // - // Tell SCM that the service is still paused. - // - SetServiceStatus(SERVICE_PAUSED); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, OnContinue runs when a - Continue command is sent to the service by the SCM. Specifies actions to - take when a service resumes normal functioning after being paused. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnContinue() -{ -} - - -/*++ - -Routine Description: - - The function executes when the system is shutting down. It - calls the OnShutdown virtual function in which you can specify what - should occur immediately prior to the system shutting down. If an error - occurs, the error will be logged in the Application event log. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Shutdown() -{ - try - { - // - // Perform service-specific shutdown operations. - // - OnShutdown(); - - // - // Tell SCM that the service is stopped. - // - SetServiceStatus(SERVICE_STOPPED); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Shutdown", Error); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to shut down.", EVENTLOG_ERROR_TYPE); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when the system - is shutting down. Specifies what should occur immediately prior to the - system shutting down. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnShutdown() -{ -} - -#pragma endregion - - -#pragma region Helper Functions - -/*++ - -Routine Description: - - The function sets the service status and reports the status to the SCM. - -Arguments: - - CurrentState - The current state of the service - - Win32ExitCode - The error code to report - - WaitHint - The estimated time for pending operation, in milliseconds - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::SetServiceStatus( - DWORD CurrentState, - DWORD Win32ExitCode, - DWORD WaitHint - ) -{ - static DWORD CheckPoint = 1; - - // - // Fill in the SERVICE_STATUS structure of the service. - // - - m_status.dwCurrentState = CurrentState; - m_status.dwWin32ExitCode = Win32ExitCode; - m_status.dwWaitHint = WaitHint; - - m_status.dwCheckPoint = ((CurrentState == SERVICE_RUNNING) || - (CurrentState == SERVICE_STOPPED)) ? 0 : - CheckPoint++; - - // - // Report the status of the service to the SCM. - // - ::SetServiceStatus(m_statusHandle, &m_status); -} - -#pragma endregion \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h deleted file mode 100644 index 106597e1..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h +++ /dev/null @@ -1,423 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - ServiceBase.cpp - -Abstract: - - Provides a base class for a service that will exist as part of a service - application. CServiceBase must be derived from when creating a new service - class. - -Environment: - - User mode - ---*/ - -#pragma once - -#include -#include "Utils.h" - -class CServiceBase -{ -public: - - /*++ - - Routine Description: - - Register the executable for a service with the Service Control - Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start - command, which results in a call to the OnStart method in the service. - This method blocks until the service has stopped. - - Arguments: - - Service - The reference to a CServiceBase object. It will become the - singleton service instance of this service application. - - Return Value: - - If the function succeeds, the return value is TRUE. If the function - fails, the return value is FALSE. To get extended error information, - call GetLastError. - - --*/ - static BOOL Run(CServiceBase &service); - - - /*++ - - Routine Description: - - The constructor of CServiceBase. It initializes a new instance - of the CServiceBase class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. - - Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - - Return Value: - - VOID - - --*/ - CServiceBase(PWSTR ServiceName, - BOOL CanStop = TRUE, - BOOL CanShutdown = TRUE, - BOOL CanPauseContinue = FALSE); - - - /*++ - - Routine Description: - - The virtual destructor of CServiceBase. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual ~CServiceBase(); - - - /*++ - - Routine Description: - - This function stops the service. It calls the OnStop virtual - function in which you can specify the actions to take when the service - stops. If an error occurs, the error will be logged in the Application - event log, and the service will be restored to the original state. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Stop(); - -protected: - - /*++ - - Routine Description: - - When implemented in a derived class, executes when a Start - command is sent to the service by the SCM or when the operating system - starts (for a service that starts automatically). Specifies actions to - take when the service starts. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the - procedure is going to take long time. You may also consider spawning a - new thread in OnStart to perform time-consuming initialization tasks. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - virtual VOID OnStart(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - When implemented in a derived class, executes when a Stop - command is sent to the service by the SCM. Specifies actions to take - when a service stops running. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the - procedure is going to take long time. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnStop(); - - - /*++ - - Routine Description: - - When implemented in a derived class, executes when a Pause - command is sent to the service by the SCM. Specifies actions to take - when a service pauses. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnPause(); - - - /*++ - - Routine Description: - - When implemented in a derived class, OnContinue runs when a - Continue command is sent to the service by the SCM. Specifies actions to - take when a service resumes normal functioning after being paused. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnContinue(); - - - /*++ - - Routine Description: - - When implemented in a derived class, executes when the system - is shutting down. Specifies what should occur immediately prior to the - system shutting down. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnShutdown(); - - - /*++ - - Routine Description: - - The function sets the service status and reports the status to the SCM. - - Arguments: - - CurrentState - The current state of the service - - Win32ExitCode - The error code to report - - WaitHint - The estimated time for pending operation, in milliseconds - - Return Value: - - VOID - - --*/ - VOID SetServiceStatus(DWORD CurrentState, - DWORD Win32ExitCode = NO_ERROR, - DWORD WaitHint = 0); - -private: - - /*++ - - Routine Description: - - The entry point for the service. It registers the handler function - for the service and starts the service. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - static VOID WINAPI ServiceMain(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - Called by the SCM whenever a control code is sent to the service. - - Arguments: - - CtrlCode - The control code. This parameter can be one of - the following values: - - SERVICE_CONTROL_CONTINUE - SERVICE_CONTROL_INTERROGATE - SERVICE_CONTROL_NETBINDADD - SERVICE_CONTROL_NETBINDDISABLE - SERVICE_CONTROL_NETBINDREMOVE - SERVICE_CONTROL_PARAMCHANGE - SERVICE_CONTROL_PAUSE - SERVICE_CONTROL_SHUTDOWN - SERVICE_CONTROL_STOP - - This parameter can also be a user-defined control - code ranging from 128 to 255. - - Return Value: - - VOID - - --*/ - static VOID WINAPI ServiceCtrlHandler(DWORD Ctrl); - - - /*++ - - Routine Description: - - This function starts the service. It calls the OnStart virtual function - in which you can specify the actions to take when the service starts. If - an error occurs during the startup, the error will be logged in the - Application event log, and the service will be stopped. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - VOID Start(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - The function pauses the service if the service supports pause - and continue. It calls the OnPause virtual function in which you can - specify the actions to take when the service pauses. If an error occurs, - the error will be logged in the Application event log, and the service - will become running. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Pause(); - - - /*++ - - Routine Description: - - The function resumes normal functioning after being paused if - the service supports pause and continue. It calls the OnContinue virtual - function in which you can specify the actions to take when the service - continues. If an error occurs, the error will be logged in the - Application event log, and the service will still be paused. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Continue(); - - - /*++ - - Routine Description: - - The function executes when the system is shutting down. It - calls the OnShutdown virtual function in which you can specify what - should occur immediately prior to the system shutting down. If an error - occurs, the error will be logged in the Application event log. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Shutdown(); - - - // - // The singleton service instance. - // - static CServiceBase *s_service; - - // - // The name of the service. - // - PWSTR m_name; - - // - // The status of the service. - // - SERVICE_STATUS m_status; - - // - // The service status handle. - // - SERVICE_STATUS_HANDLE m_statusHandle; -}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h deleted file mode 100644 index 3d851537..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h +++ /dev/null @@ -1,80 +0,0 @@ -/****************************** Module Header ******************************\ -* Module Name: ThreadPool.h -* Project: CppWindowsService -* Copyright (c) Microsoft Corporation. -* -* The class was designed by Kenny Kerr. It provides the ability to queue -* simple member functions of a class to the Windows thread pool. -* -* Using the thread pool is simple and feels natural in C++. -* -* class CSampleService -* { -* public: -* -* void AsyncRun() -* { -* CThreadPool::QueueUserWorkItem(&Service::Run, this); -* } -* -* void Run() -* { -* // Some lengthy operation -* } -* }; -* -* Kenny Kerr spends most of his time designing and building distributed -* applications for the Microsoft Windows platform. He also has a particular -* passion for C++ and security programming. Reach Kenny at -* http://weblogs.asp.net/kennykerr/ or visit his Web site: -* http://www.kennyandkarin.com/Kenny/. -* -* This source is subject to the Microsoft Public License. -* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL. -* All other rights reserved. -* -* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, -* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. -\***************************************************************************/ - -#pragma once - -#include - - -class CThreadPool -{ -public: - - template - static void QueueUserWorkItem(void (T::*function)(void), - T *object, ULONG flags = WT_EXECUTELONGFUNCTION) - { - typedef std::pair CallbackType; - std::auto_ptr p(new CallbackType(function, object)); - - if (::QueueUserWorkItem(ThreadProc, p.get(), flags)) - { - // The ThreadProc now has the responsibility of deleting the pair. - p.release(); - } - else - { - throw GetLastError(); - } - } - -private: - - template - static DWORD WINAPI ThreadProc(PVOID context) - { - typedef std::pair CallbackType; - - std::auto_ptr p(static_cast(context)); - - (p->second->*p->first)(); - return 0; - } -}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp deleted file mode 100644 index e8fc87ee..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Utils.cpp - -Abstract: - - Provides utility function to SampleApp.cpp. - -Environment: - - User mode - ---*/ - -#include "Utils.h" - -// -// Service trace event provider -// {54a25c42-cd91-4210-98cc-c3447b56e447} -// -EXTERN_C __declspec(selectany) const GUID SERVICE_PROVIDER_GUID = { 0x54a25c42, 0xcd91, 0x4210,{ 0x98, 0xcc, 0xc3, 0x44, 0x7b, 0x56, 0xe4, 0x47 } }; - -REGHANDLE m_etwRegHandle; - - -/*++ - -Routine Description: - - Sets up logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -SetupEvents() -{ - NTSTATUS status = EventRegister(&SERVICE_PROVIDER_GUID, - nullptr, - nullptr, - &m_etwRegHandle); - - if (status != ERROR_SUCCESS) - { - wprintf(L"Provider not registered. EventRegister failed with error: 0x%08X\n", status); - } -} - - -/*++ - -Routine Description: - - Destroys logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -DestroyEvents() -{ - if (m_etwRegHandle != NULL) - { - EventUnregister(m_etwRegHandle); - } -} - - -/*++ - -Routine Description: - - Log a message. - -Arguments: - - Message - The string message to be logged - - Level - The type of event to be logged. This parameter can - be one of the following values: - - TRACE_LEVEL_CRITICAL - TRACE_LEVEL_ERROR - TRACE_LEVEL_WARNING - TRACE_LEVEL_INFORMATION - TRACE_LEVEL_VERBOSE - -Return Value: - - VOID - ---*/ -VOID -WriteToEventLog( - PWSTR Message, - BYTE Level - ) -{ - if (m_etwRegHandle != NULL) - { - EventWriteString(m_etwRegHandle, Level, 0, Message); - } -} - - -/*++ - -Routine Description: - - Log an error message. - -Arguments: - - Function - The function that gives the error - - Error - The error code - -Return Value: - - VOID - ---*/ -VOID -WriteToErrorLog( - PWSTR Function, - DWORD Error - ) -{ - WCHAR Message[260]; - - StringCchPrintf(Message, ARRAYSIZE(Message), - L"%ws failed with error: 0x%08x", Function, Error); - - WriteToEventLog(Message, TRACE_LEVEL_ERROR); -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h deleted file mode 100644 index b619f461..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h +++ /dev/null @@ -1,111 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Utils.cpp - -Abstract: - - Provides utility function to SampleApp.cpp. - -Environment: - - User mode - ---*/ - -#pragma once - -#include -#include -#include -#include - -/*++ - -Routine Description: - - Sets up logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID SetupEvents(); - - -/*++ - -Routine Description: - - Destroys logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID DestroyEvents(); - - -/*++ - -Routine Description: - - Log a message. - -Arguments: - - Message - The string message to be logged - - Level - The type of event to be logged. This parameter can - be one of the following values: - - TRACE_LEVEL_CRITICAL - TRACE_LEVEL_ERROR - TRACE_LEVEL_WARNING - TRACE_LEVEL_INFORMATION - TRACE_LEVEL_VERBOSE - -Return Value: - - VOID - ---*/ -VOID WriteToEventLog(PWSTR Message, BYTE Level); - - -/*++ - -Routine Description: - - Log an error message. - -Arguments: - - Function - The function that gives the error - - Error - The error code - -Return Value: - - VOID - ---*/ -VOID WriteToErrorLog(PWSTR Function, DWORD Error); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters deleted file mode 100644 index 7f12a302..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx deleted file mode 100644 index 61e1e958..00000000 Binary files a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx and /dev/null differ diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj deleted file mode 100644 index 111fd2bf..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} - osrfx2_DCHU_usersvc - Win32Proj - osrfx2_DCHU_usersvc - 10.0.15063.0 - - - - Application - Unicode - true - v141 - - - Application - Unicode - v141 - - - Application - Unicode - true - v141 - - - Application - Unicode - v141 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreaded - - - Level3 - EditAndContinue - - - true - Console - MachineX86 - onecoreuap.lib;%(AdditionalDependencies); - - - - - MaxSpeed - true - WIN32;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - true - - - Level3 - ProgramDatabase - - - true - Console - true - true - MachineX86 - onecoreuap.lib;%(AdditionalDependencies); - - - - - X64 - - - Disabled - WIN32;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreaded - - - Level3 - ProgramDatabase - - - true - Console - MachineX64 - onecoreuap.lib;%(AdditionalDependencies); - - - - - - - - - X64 - - - MaxSpeed - true - WIN32;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - true - Console - true - true - MachineX64 - onecoreuap.lib;%(AdditionalDependencies); - - - - - - - - - - - - - - - - - - - true - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters new file mode 100644 index 00000000..fa953f4c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx new file mode 100644 index 00000000..8baab1a0 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx @@ -0,0 +1,64 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_component.INF +; +;Abstract: +; +; Installation inf for one of the OSR FX2 Learning Kit's +; AddComponent directives +; +;--*/ + +[Version] +Signature = "$Windows NT$" +Class = SoftwareComponent +ClassGuid = {5c4c3332-344d-483c-8739-259e934c9cc8} +Provider = %ManufacturerName% +CatalogFile = osrfx2_DCHU_component.cat + +[Manufacturer] +%ManufacturerName% = OsrFx2Component, NT$ARCH$ + +[OsrFx2Component.NT$ARCH$] +%DeviceName% = OsrFx2Component_Install, SWC\VID_045e&PID_94ab + +[SourceDisksFiles] +osrfx2_DCHU_componentsoftware.exe = 1 + +[SourceDisksNames] +1 = %DiskName% + +[DestinationDirs] +OsrFx2Component_CopyFiles = 13 ; copy to driverstore + +[OsrFx2Component_Install.NT] +CopyFiles = OsrFx2Component_CopyFiles + +[OsrFx2Component_Install.NT.Services] +AddService = , 0x00000002 + +[OsrFx2Component_Install.NT.Software] +AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall + +[OsrFx2Component_SoftwareInstall] +SoftwareType = 1 +SoftwareBinary = osrfx2_DCHU_componentsoftware.exe +SoftwareArguments = <> +SoftwareVersion = 1.0.0.0 + +[OsrFx2Component_CopyFiles] +osrfx2_DCHU_componentsoftware.exe + +[Strings] +ManufacturerName = "Contoso" +DiskName = "OsrFx2 DCHU Component Installation Disk" +DeviceName = "OsrFx2 DCHU Component Device" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj new file mode 100644 index 00000000..bc19d287 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj @@ -0,0 +1,276 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + + + + + + + + + + + + + + + + + + + {F90EFA96-B075-4531-B4E1-F406362D16BF} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.5 + 12.0 + Debug + Win32 + osrfx2_DCHU_component + osrfx2_DCHU_component + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp new file mode 100644 index 00000000..c14e66d1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp @@ -0,0 +1,489 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + osrfx2_DCHU_componentsoftware.cpp + +Abstract: + + An example .exe to run using the AddSoftware directive within an INF. + Contains an example on how to obtain a handle to the primary device using + SoftwareArguments within an AddSoftware directive's section. + +Environment: + + User mode + +--*/ + +#include "stdafx.h" + +#define BUFFER_SIZE (128 * sizeof(WCHAR)) +#define DEVICE_REG_SUBKEY L"OSR" +#define DEVICE_VALUE_OP_MODE L"OperatingMode" +#define DEVICE_VALUE_OP_PARAMS L"OperatingParams" +#define DEVICE_VALUE_OP_EXCEPTIONS L"OperatingExceptions" +#define CONTOSO_FILEPATH L"C:\\Program Files\\Contoso" +#define OSRFX2_DCHU_FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU" +#define FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU\\AddSoftwareInstallationFile.txt" +#define FILE_CONTENT L"Operating Mode: %ws\r\nOperating Params: %ws\r\nOperating Exceptions: %ws" + + +/*++ + +Routine Description: + +Arguments: + +Return Value: + + +--*/ +DWORD +WriteToFile( + _In_ PWSTR MessageText, + _In_ DWORD MessageTextLength + ) +{ + DWORD Err = ERROR_SUCCESS; + BOOL ErrorFlag = FALSE; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD BytesToWrite; + DWORD BytesWritten; + + if (!CreateDirectory(CONTOSO_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + if (!CreateDirectory(OSRFX2_DCHU_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + hFile = CreateFile(FILEPATH, + GENERIC_WRITE, + 0, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + BytesToWrite = MessageTextLength * sizeof(WCHAR); + + ErrorFlag = WriteFile(hFile, + MessageText, + BytesToWrite, + &BytesWritten, + NULL); + + if ((!ErrorFlag) || + (BytesToWrite != BytesWritten)) + { + Err = GetLastError(); + goto cleanup; + } + +cleanup: + + if (hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile); + } + + return Err; +} + + +/*++ + +Routine Description: + + Obtains the handle to the device that used a separate Software Component + INF to install software. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +__cdecl +_tmain( + INT Argc, + TCHAR *Argv[]) +{ + DWORD Err = ERROR_SUCCESS; + HRESULT hr = S_OK; + BOOL ErrorFlag = FALSE; + DWORD BytesToWrite = 0; + DWORD BytesWritten = 0; + PTSTR DeviceInstanceId; + HDEVINFO DevInfoList = INVALID_HANDLE_VALUE; + SP_DEVINFO_DATA DevInfoData; + WCHAR ParentDeviceInstanceId[MAX_DEVICE_ID_LEN]; + DWORD RequiredSize; + DEVPROPTYPE DevPropType; + SP_DEVINFO_DATA ParentDevInfoData; + HKEY DevRegKey = NULL; + PWSTR OperatingMode = NULL; + PWSTR OperatingParams = NULL; + PWSTR OperatingExceptions = NULL; + DWORD ValueType; + DWORD ValueSize = BUFFER_SIZE; + HKEY DevOsrRegKey = NULL; + PWSTR FileText = NULL; + DWORD FileTextLength; + + // + // Validate arguments. + // + if (Argc != 2) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + OperatingMode = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingMode == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingParams = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingParams == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingExceptions = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingExceptions == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + // + // Argv[1] should be the device instance ID. + // + DeviceInstanceId = Argv[1]; + + // + // Create a device info list to store queried device handles. + // + DevInfoList = SetupDiCreateDeviceInfoList(NULL, NULL); + + if (DevInfoList == INVALID_HANDLE_VALUE) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Add the Software Component device that called AddSoftware to the + // device info list, which will be used to find the primary device that + // called AddComponent in the first place. + // + if (!SetupDiOpenDeviceInfo(DevInfoList, + DeviceInstanceId, + NULL, + 0, + &DevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Get the device instance id of the opened device's parent. + // + if (!SetupDiGetDeviceProperty(DevInfoList, + &DevInfoData, + &DEVPKEY_Device_Parent, + &DevPropType, + (PBYTE)ParentDeviceInstanceId, + sizeof(ParentDeviceInstanceId), + &RequiredSize, + 0)) + { + Err = GetLastError(); + goto cleanup; + } + + if ((DevPropType != DEVPROP_TYPE_STRING) || + (RequiredSize < sizeof(WCHAR))) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + ParentDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Get the parent of the device we retrieved first, which is the device + // that called AddComponent in its INF. + // + if (!SetupDiOpenDeviceInfoW(DevInfoList, + ParentDeviceInstanceId, + NULL, + 0, + &ParentDevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Open up the HW registry keys of the primary device. + // + DevRegKey = SetupDiOpenDevRegKey(DevInfoList, + &ParentDevInfoData, + DICS_FLAG_GLOBAL, + 0, + DIREG_DEV, + KEY_READ); + + if (DevRegKey == INVALID_HANDLE_VALUE) + { + Err = GetLastError(); + DevRegKey = NULL; + goto cleanup; + } + + Err = RegOpenKeyEx(DevRegKey, + DEVICE_REG_SUBKEY, + 0, + KEY_QUERY_VALUE, + &DevOsrRegKey); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + + // + // Retrieve the registry values defined in the primary device's INF. + // Note that if the extension INF was applied, the extension INF would + // overwrite OperatingParams and create OperatingExceptions. + // + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingMode = (PTSTR)realloc(OperatingMode, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingMode[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingMode[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_PARAMS, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingParams = (PTSTR)realloc(OperatingParams, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingParams[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingParams[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingExceptions = (PTSTR)realloc(OperatingExceptions, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingExceptions[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingExceptions[0] = TEXT('\0'); + } + + FileTextLength = (DWORD)wcslen(OperatingMode) + + (DWORD)wcslen(OperatingParams) + + (DWORD)wcslen(OperatingExceptions) + + (DWORD)wcslen(FILE_CONTENT) - + 9; // Subtract the 3 %ws + + FileText = (PWSTR)malloc((FileTextLength + 1) * sizeof(WCHAR)); + + if (FileText == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + hr = StringCchPrintf(FileText, + FileTextLength + 1, + FILE_CONTENT, + OperatingMode, + OperatingParams, + OperatingExceptions); + + if (FAILED(hr)) + { + Err = HRESULT_CODE(hr); + goto cleanup; + } + + Err = WriteToFile(FileText, FileTextLength); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + +cleanup: + + if (FileText != NULL) + { + free(FileText); + } + + if (OperatingExceptions != NULL) + { + free(OperatingExceptions); + } + + if (OperatingParams != NULL) + { + free(OperatingParams); + } + + if (OperatingMode != NULL) + { + free(OperatingMode); + } + + if (DevOsrRegKey != NULL) + { + RegCloseKey(DevOsrRegKey); + } + + if (DevRegKey != NULL) + { + RegCloseKey(DevRegKey); + } + + if (DevInfoList != INVALID_HANDLE_VALUE) + { + SetupDiDestroyDeviceInfoList(DevInfoList); + } + + return; +} + diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters new file mode 100644 index 00000000..395438fa --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj new file mode 100644 index 00000000..32ebdebe --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {26D91630-B8FF-4102-A258-32F7D1C84E20} + Win32Proj + osrfx2_DCHU_componentsoftware + 10.0.16245.0 + osrfx2_DCHU_componentsoftware + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + $(ProjectName) + + + false + + + false + $(ProjectName) + .exe + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp new file mode 100644 index 00000000..79325e21 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// osrusbfx2umsoftware.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/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h new file mode 100644 index 00000000..edb61924 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h @@ -0,0 +1,18 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: reference additional headers your program requires here diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h new file mode 100644 index 00000000..87c0086d --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln new file mode 100644 index 00000000..6cc1d6b0 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln @@ -0,0 +1,102 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension", "{4577857A-CCAE-42EB-BDE2-16C1E3DC7B14}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension\osrfx2_DCHU_extension.vcxproj", "{0588DF70-3923-42E6-8DC9-13C2C0186F20}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component", "{E148C50E-31A6-423E-A867-526FD51DA164}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component\osrfx2_DCHU_component.vcxproj", "{F90EFA96-B075-4531-B4E1-F406362D16BF}" + ProjectSection(ProjectDependencies) = postProject + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {26D91630-B8FF-4102-A258-32F7D1C84E20} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware", "{272BE7AA-9011-46FA-96C9-2051C9526476}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware\osrfx2_DCHU_componentsoftware.vcxproj", "{26D91630-B8FF-4102-A258-32F7D1C84E20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.ActiveCfg = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Build.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Deploy.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Build.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.ActiveCfg = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Build.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Deploy.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.ActiveCfg = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Build.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Deploy.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.ActiveCfg = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Build.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Deploy.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.ActiveCfg = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Build.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Deploy.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.ActiveCfg = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Build.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Deploy.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.ActiveCfg = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Build.0 = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Deploy.0 = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.ActiveCfg = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Build.0 = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Deploy.0 = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Build.0 = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.ActiveCfg = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Build.0 = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Deploy.0 = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.ActiveCfg = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Build.0 = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Deploy.0 = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.ActiveCfg = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Build.0 = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Deploy.0 = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.ActiveCfg = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Build.0 = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Deploy.0 = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.ActiveCfg = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Build.0 = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Deploy.0 = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.ActiveCfg = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Build.0 = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Deploy.0 = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM64.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.ActiveCfg = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.Build.0 = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.Build.0 = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM64.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.ActiveCfg = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.Build.0 = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20} = {4577857A-CCAE-42EB-BDE2-16C1E3DC7B14} + {F90EFA96-B075-4531-B4E1-F406362D16BF} = {E148C50E-31A6-423E-A867-526FD51DA164} + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {272BE7AA-9011-46FA-96C9-2051C9526476} + EndGlobalSection +EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters new file mode 100644 index 00000000..0ba1a59c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx new file mode 100644 index 00000000..660e5049 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx @@ -0,0 +1,54 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_extension.INF +; +;Abstract: +; +; Extension inf for the OSR FX2 Learning Kit +; +;--*/ + +[Version] +Signature = "$WINDOWS NT$" +Class = Extension +ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} +Provider = %ManufacturerName% +ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} +CatalogFile = osrfx2_DCHU_extension.cat +DriverVer = 05/16/2017,15.14.36.721 + +[Manufacturer] +%ManufacturerName% = OsrFx2Extension, NT$ARCH$ + +[OsrFx2Extension.NT$ARCH$] +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_045e&Pid_94aa&mi_00 +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 + +[OsrFx2Extension_Install.NT] +; Empty + +[OsrFx2Extension_Install.NT.HW] +AddReg = OsrFx2Extension_AddReg + +[OsrFx2Extension_AddReg] +HKR, OSR, "OperatingParams",, "-Extended" +HKR, OSR, "OperatingExceptions",, "x86" + +[OsrFx2Extension_Install.NT.Components] +AddComponent = osrfx2_DCHU_component,,OsrFx2Extension_ComponentInstall + +[OsrFx2Extension_ComponentInstall] +ComponentIds=VID_045e&PID_94ab + +[Strings] +ManufacturerName = "Contoso" +OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj new file mode 100644 index 00000000..bfc7ded6 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj @@ -0,0 +1,266 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + {0588DF70-3923-42E6-8DC9-13C2C0186F20} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.6.1 + 12.0 + Debug + Win32 + osrfx2_DCHU_extension + osrfx2_DCHU_extension + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx new file mode 100644 index 00000000..8baab1a0 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx @@ -0,0 +1,64 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_component.INF +; +;Abstract: +; +; Installation inf for one of the OSR FX2 Learning Kit's +; AddComponent directives +; +;--*/ + +[Version] +Signature = "$Windows NT$" +Class = SoftwareComponent +ClassGuid = {5c4c3332-344d-483c-8739-259e934c9cc8} +Provider = %ManufacturerName% +CatalogFile = osrfx2_DCHU_component.cat + +[Manufacturer] +%ManufacturerName% = OsrFx2Component, NT$ARCH$ + +[OsrFx2Component.NT$ARCH$] +%DeviceName% = OsrFx2Component_Install, SWC\VID_045e&PID_94ab + +[SourceDisksFiles] +osrfx2_DCHU_componentsoftware.exe = 1 + +[SourceDisksNames] +1 = %DiskName% + +[DestinationDirs] +OsrFx2Component_CopyFiles = 13 ; copy to driverstore + +[OsrFx2Component_Install.NT] +CopyFiles = OsrFx2Component_CopyFiles + +[OsrFx2Component_Install.NT.Services] +AddService = , 0x00000002 + +[OsrFx2Component_Install.NT.Software] +AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall + +[OsrFx2Component_SoftwareInstall] +SoftwareType = 1 +SoftwareBinary = osrfx2_DCHU_componentsoftware.exe +SoftwareArguments = <> +SoftwareVersion = 1.0.0.0 + +[OsrFx2Component_CopyFiles] +osrfx2_DCHU_componentsoftware.exe + +[Strings] +ManufacturerName = "Contoso" +DiskName = "OsrFx2 DCHU Component Installation Disk" +DeviceName = "OsrFx2 DCHU Component Device" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp new file mode 100644 index 00000000..c14e66d1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp @@ -0,0 +1,489 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + osrfx2_DCHU_componentsoftware.cpp + +Abstract: + + An example .exe to run using the AddSoftware directive within an INF. + Contains an example on how to obtain a handle to the primary device using + SoftwareArguments within an AddSoftware directive's section. + +Environment: + + User mode + +--*/ + +#include "stdafx.h" + +#define BUFFER_SIZE (128 * sizeof(WCHAR)) +#define DEVICE_REG_SUBKEY L"OSR" +#define DEVICE_VALUE_OP_MODE L"OperatingMode" +#define DEVICE_VALUE_OP_PARAMS L"OperatingParams" +#define DEVICE_VALUE_OP_EXCEPTIONS L"OperatingExceptions" +#define CONTOSO_FILEPATH L"C:\\Program Files\\Contoso" +#define OSRFX2_DCHU_FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU" +#define FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU\\AddSoftwareInstallationFile.txt" +#define FILE_CONTENT L"Operating Mode: %ws\r\nOperating Params: %ws\r\nOperating Exceptions: %ws" + + +/*++ + +Routine Description: + +Arguments: + +Return Value: + + +--*/ +DWORD +WriteToFile( + _In_ PWSTR MessageText, + _In_ DWORD MessageTextLength + ) +{ + DWORD Err = ERROR_SUCCESS; + BOOL ErrorFlag = FALSE; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD BytesToWrite; + DWORD BytesWritten; + + if (!CreateDirectory(CONTOSO_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + if (!CreateDirectory(OSRFX2_DCHU_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + hFile = CreateFile(FILEPATH, + GENERIC_WRITE, + 0, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + BytesToWrite = MessageTextLength * sizeof(WCHAR); + + ErrorFlag = WriteFile(hFile, + MessageText, + BytesToWrite, + &BytesWritten, + NULL); + + if ((!ErrorFlag) || + (BytesToWrite != BytesWritten)) + { + Err = GetLastError(); + goto cleanup; + } + +cleanup: + + if (hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile); + } + + return Err; +} + + +/*++ + +Routine Description: + + Obtains the handle to the device that used a separate Software Component + INF to install software. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +__cdecl +_tmain( + INT Argc, + TCHAR *Argv[]) +{ + DWORD Err = ERROR_SUCCESS; + HRESULT hr = S_OK; + BOOL ErrorFlag = FALSE; + DWORD BytesToWrite = 0; + DWORD BytesWritten = 0; + PTSTR DeviceInstanceId; + HDEVINFO DevInfoList = INVALID_HANDLE_VALUE; + SP_DEVINFO_DATA DevInfoData; + WCHAR ParentDeviceInstanceId[MAX_DEVICE_ID_LEN]; + DWORD RequiredSize; + DEVPROPTYPE DevPropType; + SP_DEVINFO_DATA ParentDevInfoData; + HKEY DevRegKey = NULL; + PWSTR OperatingMode = NULL; + PWSTR OperatingParams = NULL; + PWSTR OperatingExceptions = NULL; + DWORD ValueType; + DWORD ValueSize = BUFFER_SIZE; + HKEY DevOsrRegKey = NULL; + PWSTR FileText = NULL; + DWORD FileTextLength; + + // + // Validate arguments. + // + if (Argc != 2) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + OperatingMode = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingMode == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingParams = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingParams == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingExceptions = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingExceptions == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + // + // Argv[1] should be the device instance ID. + // + DeviceInstanceId = Argv[1]; + + // + // Create a device info list to store queried device handles. + // + DevInfoList = SetupDiCreateDeviceInfoList(NULL, NULL); + + if (DevInfoList == INVALID_HANDLE_VALUE) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Add the Software Component device that called AddSoftware to the + // device info list, which will be used to find the primary device that + // called AddComponent in the first place. + // + if (!SetupDiOpenDeviceInfo(DevInfoList, + DeviceInstanceId, + NULL, + 0, + &DevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Get the device instance id of the opened device's parent. + // + if (!SetupDiGetDeviceProperty(DevInfoList, + &DevInfoData, + &DEVPKEY_Device_Parent, + &DevPropType, + (PBYTE)ParentDeviceInstanceId, + sizeof(ParentDeviceInstanceId), + &RequiredSize, + 0)) + { + Err = GetLastError(); + goto cleanup; + } + + if ((DevPropType != DEVPROP_TYPE_STRING) || + (RequiredSize < sizeof(WCHAR))) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + ParentDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Get the parent of the device we retrieved first, which is the device + // that called AddComponent in its INF. + // + if (!SetupDiOpenDeviceInfoW(DevInfoList, + ParentDeviceInstanceId, + NULL, + 0, + &ParentDevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Open up the HW registry keys of the primary device. + // + DevRegKey = SetupDiOpenDevRegKey(DevInfoList, + &ParentDevInfoData, + DICS_FLAG_GLOBAL, + 0, + DIREG_DEV, + KEY_READ); + + if (DevRegKey == INVALID_HANDLE_VALUE) + { + Err = GetLastError(); + DevRegKey = NULL; + goto cleanup; + } + + Err = RegOpenKeyEx(DevRegKey, + DEVICE_REG_SUBKEY, + 0, + KEY_QUERY_VALUE, + &DevOsrRegKey); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + + // + // Retrieve the registry values defined in the primary device's INF. + // Note that if the extension INF was applied, the extension INF would + // overwrite OperatingParams and create OperatingExceptions. + // + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingMode = (PTSTR)realloc(OperatingMode, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingMode[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingMode[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_PARAMS, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingParams = (PTSTR)realloc(OperatingParams, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingParams[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingParams[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingExceptions = (PTSTR)realloc(OperatingExceptions, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingExceptions[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingExceptions[0] = TEXT('\0'); + } + + FileTextLength = (DWORD)wcslen(OperatingMode) + + (DWORD)wcslen(OperatingParams) + + (DWORD)wcslen(OperatingExceptions) + + (DWORD)wcslen(FILE_CONTENT) - + 9; // Subtract the 3 %ws + + FileText = (PWSTR)malloc((FileTextLength + 1) * sizeof(WCHAR)); + + if (FileText == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + hr = StringCchPrintf(FileText, + FileTextLength + 1, + FILE_CONTENT, + OperatingMode, + OperatingParams, + OperatingExceptions); + + if (FAILED(hr)) + { + Err = HRESULT_CODE(hr); + goto cleanup; + } + + Err = WriteToFile(FileText, FileTextLength); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + +cleanup: + + if (FileText != NULL) + { + free(FileText); + } + + if (OperatingExceptions != NULL) + { + free(OperatingExceptions); + } + + if (OperatingParams != NULL) + { + free(OperatingParams); + } + + if (OperatingMode != NULL) + { + free(OperatingMode); + } + + if (DevOsrRegKey != NULL) + { + RegCloseKey(DevOsrRegKey); + } + + if (DevRegKey != NULL) + { + RegCloseKey(DevRegKey); + } + + if (DevInfoList != INVALID_HANDLE_VALUE) + { + SetupDiDestroyDeviceInfoList(DevInfoList); + } + + return; +} + diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters new file mode 100644 index 00000000..395438fa --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj new file mode 100644 index 00000000..32ebdebe --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {26D91630-B8FF-4102-A258-32F7D1C84E20} + Win32Proj + osrfx2_DCHU_componentsoftware + 10.0.16245.0 + osrfx2_DCHU_componentsoftware + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + $(ProjectName) + + + false + + + false + $(ProjectName) + .exe + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp new file mode 100644 index 00000000..79325e21 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// osrusbfx2umsoftware.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/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h new file mode 100644 index 00000000..edb61924 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h @@ -0,0 +1,18 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: reference additional headers your program requires here diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h new file mode 100644 index 00000000..87c0086d --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln new file mode 100644 index 00000000..40b15034 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln @@ -0,0 +1,73 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension", "{4577857A-CCAE-42EB-BDE2-16C1E3DC7B14}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension\osrfx2_DCHU_extension.vcxproj", "{0588DF70-3923-42E6-8DC9-13C2C0186F20}" + ProjectSection(ProjectDependencies) = postProject + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {26D91630-B8FF-4102-A258-32F7D1C84E20} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware", "{B327FC27-5816-4F28-959F-4C35F1D22678}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware\osrfx2_DCHU_componentsoftware.vcxproj", "{26D91630-B8FF-4102-A258-32F7D1C84E20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.ActiveCfg = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Build.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Deploy.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Build.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.ActiveCfg = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Build.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Deploy.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.ActiveCfg = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Build.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Deploy.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.ActiveCfg = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Build.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Deploy.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.ActiveCfg = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Build.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Deploy.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.ActiveCfg = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Build.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Deploy.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.ActiveCfg = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Build.0 = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Deploy.0 = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM64.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.ActiveCfg = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.Build.0 = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.Build.0 = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM64.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.ActiveCfg = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.Build.0 = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20} = {4577857A-CCAE-42EB-BDE2-16C1E3DC7B14} + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {B327FC27-5816-4F28-959F-4C35F1D22678} + EndGlobalSection +EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters new file mode 100644 index 00000000..0ba1a59c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx new file mode 100644 index 00000000..d6bc7e00 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx @@ -0,0 +1,55 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_extension.INF +; +;Abstract: +; +; Extension inf for the OSR FX2 Learning Kit +; +;--*/ + +[Version] +Signature = "$WINDOWS NT$" +Class = Extension +ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} +Provider = %ManufacturerName% +ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} +CatalogFile = osrfx2_DCHU_extension.cat +DriverVer = 05/16/2017,15.14.36.721 + +[Manufacturer] +%ManufacturerName% = OsrFx2Extension, NT$ARCH$ + +[OsrFx2Extension.NT$ARCH$] +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_045e&Pid_94aa&mi_00 +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 + +[OsrFx2Extension_Install.NT] +CopyInf=osrfx2_DCHU_component.inf + +[OsrFx2Extension_Install.NT.HW] +AddReg = OsrFx2Extension_AddReg +AddReg = OsrFx2Extension_COMAddReg + +[OsrFx2Extension_AddReg] +HKR, OSR, "OperatingParams",, "-Extended" +HKR, OSR, "OperatingExceptions",, "x86" + +[OsrFx2Extension_Install.NT.Components] +AddComponent = osrfx2_DCHU_component,,OsrFx2Extension_ComponentInstall + +[OsrFx2Extension_ComponentInstall] +ComponentIds=VID_045e&PID_94ab + +[Strings] +ManufacturerName = "Contoso" +OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj new file mode 100644 index 00000000..4542c3a7 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj @@ -0,0 +1,273 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + + + + + + + + {0588DF70-3923-42E6-8DC9-13C2C0186F20} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.6.1 + 12.0 + Debug + Win32 + osrfx2_DCHU_extension + osrfx2_DCHU_extension + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + + \ No newline at end of file -- cgit v1.3.1