From ab231883b00950f20d8014e17ad7a27a94c8373a Mon Sep 17 00:00:00 2001 From: Matthew Montera Date: Mon, 31 Jul 2017 17:02:12 -0700 Subject: Moved Components to Extension INFs Removed DefaultDestDirs Added COM Registration example --- general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln | 18 - .../osrfx2_DCHU_base/osrfx2_DCHU_base.inx | Bin 7490 -> 6664 bytes .../osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj | 17 - .../osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h | 2 +- .../osrfx2_DCHU_usersvc/CppWindowsService.cpp | 74 -- .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp | 320 --------- .../osrfx2_DCHU_base/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_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 3172 -> 0 bytes .../osrfx2_DCHU_usersvc.vcxproj | 206 ------ .../osrfx2_DCHU_component.inx | 2 +- .../osrfx2_DCHU_componentsoftware.vcxproj | 11 +- .../osrfx2_DCHU_extension.sln | 25 + .../osrfx2_DCHU_extension.inx | 35 +- .../osrfx2_DCHU_extension.vcxproj | 23 +- .../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 0 -> 3190 bytes .../osrfx2_DCHU_usersvc.vcxproj | 206 ++++++ 35 files changed, 2994 insertions(+), 2953 deletions(-) delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx delete mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln index bcb87f32..ce0593e1 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln @@ -10,17 +10,12 @@ 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}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_filter", "osrfx2_DCHU_filter", "{1665ED66-7966-4FE2-9BA5-B5843511E325}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc", "{97E38EBE-CA24-4E71-9EB1-E2792ABBF622}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc\osrfx2_DCHU_usersvc.vcxproj", "{DE70E2D1-6A4D-4984-BD82-CE750889F0D3}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_filter", "osrfx2_DCHU_filter\osrfx2_DCHU_filter.vcxproj", "{3CC42473-D121-41F4-AE26-1F2F0AC65E82}" EndProject Global @@ -61,18 +56,6 @@ Global {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|Win32.Build.0 = Release|Win32 {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|x64.ActiveCfg = Release|x64 {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|x64.Build.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 {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|ARM.ActiveCfg = Debug|Win32 {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|ARM64.ActiveCfg = Debug|Win32 {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -96,7 +79,6 @@ Global GlobalSection(NestedProjects) = preSolution {5B711254-3F53-4E1D-A1AD-CC81E34588B7} = {3B268182-F450-4AB8-B350-A2CF6495F756} {6EED5CDD-5526-40DC-97F9-582857E10187} = {52ABC41E-9AAA-4DA8-8986-F6298E32C8A3} - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {97E38EBE-CA24-4E71-9EB1-E2792ABBF622} {3CC42473-D121-41F4-AE26-1F2F0AC65E82} = {1665ED66-7966-4FE2-9BA5-B5843511E325} 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 807337f8..c4cead6a 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 838add16..4a34c9dc 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 @@ -234,23 +234,6 @@ - - - - - - - - - - - - - - - - - diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h index 1452aebf..d35086de 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h @@ -37,7 +37,7 @@ typedef struct _IO_STACK_LOCATION *PIO_STACK_LOCATION; #include #include #include -#include +#include "trace.h" #include "public.h" diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp deleted file mode 100644 index 98a3975c..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp deleted file mode 100644 index 157a6cb9..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/Main.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h deleted file mode 100644 index dcbd950e..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp deleted file mode 100644 index c39e4838..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/SampleService.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h deleted file mode 100644 index eee8a609..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/ServiceBase.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp deleted file mode 100644 index 4c20af2e..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/ServiceBase.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h deleted file mode 100644 index 106597e1..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/ThreadPool.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h deleted file mode 100644 index 3d851537..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/Utils.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp deleted file mode 100644 index e8fc87ee..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/Utils.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h deleted file mode 100644 index b619f461..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters deleted file mode 100644 index 7f12a302..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx deleted file mode 100644 index 68f1f4fd..00000000 Binary files a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx and /dev/null 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 deleted file mode 100644 index eab4b251..00000000 --- a/general/DCHU/osrfx2_DCHU_base/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 - v140 - - - Application - Unicode - v140 - - - Application - Unicode - true - 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 - - - - - - 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_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx index 2d9bb813..8baab1a0 100644 --- 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 @@ -38,7 +38,7 @@ osrfx2_DCHU_componentsoftware.exe = 1 1 = %DiskName% [DestinationDirs] -DefaultDestDir = 13 ; copy to driverstore +OsrFx2Component_CopyFiles = 13 ; copy to driverstore [OsrFx2Component_Install.NT] CopyFiles = OsrFx2Component_CopyFiles 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 index c9f4e88b..2bb8b05d 100644 --- 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 @@ -1,5 +1,5 @@  - + Debug @@ -29,26 +29,26 @@ Application true - v140 + v141 Unicode Application false - v140 + v141 true Unicode Application true - v140 + v141 Unicode Application false - v140 + v141 true Unicode @@ -138,6 +138,7 @@ true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded Console diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln index 517da9dd..386ba436 100644 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln @@ -3,7 +3,16 @@ 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 @@ -41,8 +50,24 @@ Global {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.inx b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx index bc81fc7f..d90c39f7 100644 --- 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 @@ -34,15 +34,46 @@ DriverVer = 05/16/2017,15.14.36.721 %OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 [OsrFx2Extension_Install.NT] -; empty +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" \ No newline at end of file +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 index 84cc35c5..232cfa89 100644 --- 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 @@ -1,5 +1,5 @@  - + Debug @@ -35,12 +35,31 @@ + + + + + + + + + + + + + + + + + + + {0588DF70-3923-42E6-8DC9-13C2C0186F20} {4605da2c-74a5-4865-98e1-152ef136825f} - v4.5 + v4.6.1 12.0 Debug Win32 diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp new file mode 100644 index 00000000..98a3975c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp new file mode 100644 index 00000000..157a6cb9 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp @@ -0,0 +1,320 @@ +/*++ + +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 new file mode 100644 index 00000000..dcbd950e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h @@ -0,0 +1,261 @@ +/*++ + +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 new file mode 100644 index 00000000..c39e4838 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp @@ -0,0 +1,254 @@ +/*++ + +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 new file mode 100644 index 00000000..eee8a609 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp new file mode 100644 index 00000000..4c20af2e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/ServiceBase.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h new file mode 100644 index 00000000..106597e1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/ThreadPool.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h new file mode 100644 index 00000000..3d851537 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/Utils.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp new file mode 100644 index 00000000..e8fc87ee --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/Utils.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h new file mode 100644 index 00000000..b619f461 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters new file mode 100644 index 00000000..7f12a302 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx new file mode 100644 index 00000000..61e1e958 Binary files /dev/null and b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx 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 new file mode 100644 index 00000000..111fd2bf --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/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 + 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 -- cgit v1.3.1