From 77b0c8dd72a319af4c34a92b71d80985377e99c2 Mon Sep 17 00:00:00 2001 From: Nabil Fates Date: Tue, 6 Jun 2017 12:57:25 -0700 Subject: Adding DCHU sample to the WDK sample repo. --- general/DCHU/README.txt | 43 + ...5-1C56-4807-ACCD-B28C09D37FF0.devicemetadata-ms | Bin 0 -> 105893 bytes general/DCHU/osrfx2_DCHU_base/inc/prototypes.h | 14 + general/DCHU/osrfx2_DCHU_base/inc/public.h | 173 +++ general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln | 102 ++ .../osrfx2_DCHU_base/osrfx2_DCHU_base/Interrupt.c | 206 ++++ .../osrfx2_DCHU_base/osrfx2_DCHU_base/bulkrwr.c | 476 ++++++++ .../osrfx2_DCHU_base/osrfx2_DCHU_base/device.c | 1014 ++++++++++++++++ .../osrfx2_DCHU_base/osrfx2_DCHU_base/driver.c | 281 +++++ .../DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/ioctl.c | 1151 +++++++++++++++++++ .../osrfx2_DCHU_base/osrfx2_DCHU_base.Filters | 302 +++++ .../osrfx2_DCHU_base/osrfx2_DCHU_base.inx | Bin 0 -> 7490 bytes .../osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj | 269 +++++ .../osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h | 312 +++++ .../osrfx2_DCHU_base/osrusbfx2.man | 309 +++++ .../osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.rc | 13 + .../DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/trace.h | 115 ++ .../osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.c | 421 +++++++ .../osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.h | 85 ++ .../osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.rc | 12 + .../osrfx2_DCHU_filter/osrfx2_DCHU_filter.Filters | 31 + .../osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj | 186 +++ .../osrfx2_DCHU_base/osrfx2_DCHU_testapp/dump.c | 444 +++++++ .../osrfx2_DCHU_testapp.Filters | 30 + .../osrfx2_DCHU_testapp.vcxproj | 193 ++++ .../osrfx2_DCHU_testapp/osrusbfx2.vcxproj | 194 ++++ .../osrfx2_DCHU_base/osrfx2_DCHU_testapp/test.cmd | 6 + .../osrfx2_DCHU_base/osrfx2_DCHU_testapp/testapp.c | 1214 ++++++++++++++++++++ .../osrfx2_DCHU_testapp/testapp.rc | 12 + .../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 0 -> 3172 bytes .../osrfx2_DCHU_usersvc.vcxproj | 206 ++++ .../osrfx2_DCHU_component.sln | 73 ++ .../osrfx2_DCHU_component.filters | 14 + .../osrfx2_DCHU_component.inx | 64 ++ .../osrfx2_DCHU_component.vcxproj | 272 +++++ .../osrfx2_DCHU_componentsoftware.cpp | 489 ++++++++ .../osrfx2_DCHU_componentsoftware.filters | 33 + .../osrfx2_DCHU_componentsoftware.vcxproj | 168 +++ .../osrfx2_DCHU_componentsoftware/stdafx.cpp | 8 + .../osrfx2_DCHU_componentsoftware/stdafx.h | 18 + .../osrfx2_DCHU_componentsoftware/targetver.h | 8 + .../osrfx2_DCHU_extension.sln | 48 + .../osrfx2_DCHU_extension.filters | 14 + .../osrfx2_DCHU_extension.inx | 48 + .../osrfx2_DCHU_extension.vcxproj | 262 +++++ 56 files changed, 12034 insertions(+) create mode 100644 general/DCHU/README.txt create mode 100644 general/DCHU/osrfx2_DCHU_base/deviceMetadata/B4D697F5-1C56-4807-ACCD-B28C09D37FF0.devicemetadata-ms create mode 100644 general/DCHU/osrfx2_DCHU_base/inc/prototypes.h create mode 100644 general/DCHU/osrfx2_DCHU_base/inc/public.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/Interrupt.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/bulkrwr.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/device.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/driver.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/ioctl.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.Filters create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.man create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.rc create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/trace.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.rc create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.Filters create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/dump.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.Filters create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/test.cmd create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/testapp.c create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/testapp.rc create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h create mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj diff --git a/general/DCHU/README.txt b/general/DCHU/README.txt new file mode 100644 index 00000000..a63bed27 --- /dev/null +++ b/general/DCHU/README.txt @@ -0,0 +1,43 @@ +Driver package installation toolkit for universal drivers + +Directions: + +Each portion of the sample is separated by driver package: + +osrfx2_DCHU_base : The driver for the Osr Fx2 Learning Kit. This includes the device driver, + an upper filter driver for the device (a no-op), a Win32 User Service that + controls lights on the device, and a console app that can control the device. + +osrfx2_DCHU_extension: An extension driver for the Osr Fx2 device. This extension modifies + some registry settings laid down by the base driver (osrfx2_DCHU_base). + +osrfx2_DCHU_component: A Software Component that installs on a device that the base driver + package's INF (osrfx2_DCHU_base.inf) creates using AddComponent. + This Software Component executes a legacy .exe to install a file + in the C:\Program Files\... directory that reads the Osr Fx2 device's + registry settings applied in the base driver package's INF (osrfx2_DCHU_base.inf) + +Each of these solutions can be built with the latest WDK on Visual Studio 2015. Additionally, +an HSA that can also control the Osr Fx2 Learning Kit's device is available here: + +https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomCapability + +The HSA and the contents of this sample can coexist, but currently the HSA can only be built +with Visual Studio 2017 on a machine *WITHOUT* the WDK. This limitation is reportedly fixed +in RS3. + +To install these driver packages, make sure that the target machine is in Test Mode, using: + + bcdedit /set testsigning on + +And then use pnputil /i /a to install each of the three driver packages. They should +be installed in this order: + + osrfx2_DCHU_base + osrfx2_DCHU_extension + osrfx2_DCHU_component + +Technically the order of osrfx2_DCHU_extension and ...component doesn't matter, but the software +within osrfx2_DCHU_component will read the regisry set by the extension to show that an extension +INF's settings are applied *after* the base INF's. + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/deviceMetadata/B4D697F5-1C56-4807-ACCD-B28C09D37FF0.devicemetadata-ms b/general/DCHU/osrfx2_DCHU_base/deviceMetadata/B4D697F5-1C56-4807-ACCD-B28C09D37FF0.devicemetadata-ms new file mode 100644 index 00000000..5f8e82ee Binary files /dev/null and b/general/DCHU/osrfx2_DCHU_base/deviceMetadata/B4D697F5-1C56-4807-ACCD-B28C09D37FF0.devicemetadata-ms differ diff --git a/general/DCHU/osrfx2_DCHU_base/inc/prototypes.h b/general/DCHU/osrfx2_DCHU_base/inc/prototypes.h new file mode 100644 index 00000000..cc99cdfe --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/inc/prototypes.h @@ -0,0 +1,14 @@ +DRIVER_INITIALIZE DriverEntry; + +EVT_WDF_DRIVER_DEVICE_ADD EvtDeviceAdd; + +EVT_WDF_DEVICE_CONTEXT_CLEANUP EvtDriverContextCleanup; +EVT_WDF_DEVICE_PREPARE_HARDWARE EvtDevicePrepareHardware; + +EVT_WDF_IO_QUEUE_IO_READ EvtIoRead; +EVT_WDF_IO_QUEUE_IO_WRITE EvtIoWrite; +EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL EvtIoDeviceControl; + +EVT_WDF_REQUEST_COMPLETION_ROUTINE EvtRequestReadCompletionRoutine; +EVT_WDF_REQUEST_COMPLETION_ROUTINE EvtRequestWriteCompletionRoutine; + diff --git a/general/DCHU/osrfx2_DCHU_base/inc/public.h b/general/DCHU/osrfx2_DCHU_base/inc/public.h new file mode 100644 index 00000000..f1fc6be3 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/inc/public.h @@ -0,0 +1,173 @@ +/*++ + +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: + + public.h + +Abstract: + +Environment: + + User & Kernel mode + +--*/ + +#ifndef _PUBLIC_H +#define _PUBLIC_H + +#include + +// {573E8C73-0CB4-4471-A1BF-FAB26C31D384} +DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, + 0x573e8c73, 0xcb4, 0x4471, 0xa1, 0xbf, 0xfa, 0xb2, 0x6c, 0x31, 0xd3, 0x84); + +#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) + +#endif diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln new file mode 100644 index 00000000..bcb87f32 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln @@ -0,0 +1,102 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 12.0 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_base", "osrfx2_DCHU_base", "{3B268182-F450-4AB8-B350-A2CF6495F756}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_testapp", "osrfx2_DCHU_testapp", "{52ABC41E-9AAA-4DA8-8986-F6298E32C8A3}" +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 + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|ARM.ActiveCfg = Debug|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|ARM64.ActiveCfg = Debug|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|Win32.ActiveCfg = Debug|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|Win32.Build.0 = Debug|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|Win32.Deploy.0 = Debug|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|x64.ActiveCfg = Debug|x64 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|x64.Build.0 = Debug|x64 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Debug|x64.Deploy.0 = Debug|x64 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|ARM.ActiveCfg = Release|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|ARM64.ActiveCfg = Release|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.ActiveCfg = Release|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.Build.0 = Release|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|x64.ActiveCfg = Release|x64 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|x64.Build.0 = Release|x64 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|ARM.ActiveCfg = Debug|Win32 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|ARM64.ActiveCfg = Debug|Win32 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|Win32.ActiveCfg = Debug|Win32 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|Win32.Build.0 = Debug|Win32 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|x64.ActiveCfg = Debug|x64 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|x64.Build.0 = Debug|x64 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|ARM.ActiveCfg = Release|Win32 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|ARM64.ActiveCfg = Release|Win32 + {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|Win32.ActiveCfg = Release|Win32 + {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 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|Win32.Build.0 = Debug|Win32 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|Win32.Deploy.0 = Debug|Win32 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|x64.ActiveCfg = Debug|x64 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|x64.Build.0 = Debug|x64 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Debug|x64.Deploy.0 = Debug|x64 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|ARM.ActiveCfg = Release|Win32 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|ARM64.ActiveCfg = Release|Win32 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|Win32.ActiveCfg = Release|Win32 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|Win32.Build.0 = Release|Win32 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|Win32.Deploy.0 = Release|Win32 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.ActiveCfg = Release|x64 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.Build.0 = Release|x64 + {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.Deploy.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + 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/Interrupt.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/Interrupt.c new file mode 100644 index 00000000..5573ef6e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/Interrupt.c @@ -0,0 +1,206 @@ +/*++ + +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: + + Interrupt.c + +Abstract: + + This modules has routines configure a continuous reader on an + interrupt pipe to asynchronously read toggle switch states. + +Environment: + + User mode + +--*/ + +#include "osrusbfx2.h" + +#if defined(EVENT_TRACING) +#include "interrupt.tmh" +#endif + + +/*++ + +Routine Description: + + This routine configures a continuous reader on the + interrupt endpoint. It's called from the PrepareHarware event. + +Arguments: + + DeviceContext - The device context to use for configuration + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +OsrFxConfigContReaderForInterruptEndPoint( + _In_ PDEVICE_CONTEXT DeviceContext + ) +{ + WDF_USB_CONTINUOUS_READER_CONFIG ReaderConfig; + NTSTATUS Status; + + WDF_USB_CONTINUOUS_READER_CONFIG_INIT(&ReaderConfig, + OsrFxEvtUsbInterruptPipeReadComplete, + DeviceContext, + sizeof(UCHAR)); + + ReaderConfig.EvtUsbTargetPipeReadersFailed = OsrFxEvtUsbInterruptReadersFailed; + + // + // Reader requests are not posted to the target automatically. + // The driver must explictly call WdfIoTargetStart to kick start the + // reader. In this sample, it's done in D0Entry. + // By defaut, framework queues two requests to the target + // endpoint. Driver can configure up to 10 requests with CONFIG macro. + // + Status = WdfUsbTargetPipeConfigContinuousReader(DeviceContext->InterruptPipe, + &ReaderConfig); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "OsrFxConfigContReaderForInterruptEndPoint failed %x\n", + Status); + return Status; + } + + return Status; +} + + +/*++ + +Routine Description: + + This is the completion routine of the continuous reader. This can be called + concurrently on a multiprocessor system if there are multiple readers + configured, so make sure to protect access to global resources. + +Arguments: + + Buffer - This buffer is freed when this call returns. + If the driver wants to delay processing of the buffer, it + can take an additional referrence + + Context - Provided in the WDF_USB_CONTINUOUS_READER_CONFIG_INIT macro + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +VOID +OsrFxEvtUsbInterruptPipeReadComplete( + _In_ WDFUSBPIPE Pipe, + _In_ WDFMEMORY Buffer, + _In_ size_t NumBytesTransferred, + _In_ WDFCONTEXT Context + ) +{ + PUCHAR SwitchState = NULL; + WDFDEVICE Device; + PDEVICE_CONTEXT DeviceContext = Context; + + UNREFERENCED_PARAMETER(Pipe); + + Device = WdfObjectContextGetObject(DeviceContext); + + // + // Make sure that there is data in the read packet. Depending on the device + // specification, it is possible for it to return a 0 length read in + // certain conditions. + // + if (NumBytesTransferred == 0) + { + TraceEvents(TRACE_LEVEL_WARNING, DBG_INIT, + "OsrFxEvtUsbInterruptPipeReadComplete Zero length read " + "occured on the Interrupt Pipe's Continuous Reader\n"); + return; + } + + assert(NumBytesTransferred == sizeof(UCHAR)); + + SwitchState = WdfMemoryGetBuffer(Buffer, NULL); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, + "OsrFxEvtUsbInterruptPipeReadComplete SwitchState %x\n", + *SwitchState); + + DeviceContext->CurrentSwitchState = *SwitchState; + + // + // Handle any pending Interrupt Message IOCTLs. Note that the OSR USB device + // will generate an interrupt message when the the device resumes from a low + // power state. So if the Interrupt Message IOCTL was sent after the device + // has gone to a low power state, the pending Interrupt Message IOCTL will + // get completed in the function call below, before the user twiddles the + // dip switches on the OSR USB device. If this is not the desired behavior + // for your driver, then you could handle this condition by maintaining a + // state variable on D0Entry to track interrupt messages caused by power up. + // + OsrUsbIoctlGetInterruptMessage(Device, STATUS_SUCCESS); + +} + + +/*++ + +Routine Description: + + This the failure routine of the continous reader. + +Arguments: + + Pipe - The pipe that failed creation + + Status - The failure NTSTATUS + + UsbdStatus - A USB specific error code + +Return Value: + + TRUE + +--*/ +BOOLEAN +OsrFxEvtUsbInterruptReadersFailed( + _In_ WDFUSBPIPE Pipe, + _In_ NTSTATUS Status, + _In_ USBD_STATUS UsbdStatus + ) +{ + WDFDEVICE Device = WdfIoTargetGetDevice(WdfUsbTargetPipeGetIoTarget(Pipe)); + PDEVICE_CONTEXT DeviceContext = GetDeviceContext(Device); + + UNREFERENCED_PARAMETER(UsbdStatus); + + // + // Clear the current switch state. + // + DeviceContext->CurrentSwitchState = 0; + + // + // Service the pending interrupt switch change request + // + OsrUsbIoctlGetInterruptMessage(Device, Status); + + return TRUE; +} + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/bulkrwr.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/bulkrwr.c new file mode 100644 index 00000000..d29dea0b --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/bulkrwr.c @@ -0,0 +1,476 @@ +/*++ + +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: + + bulkrwr.c + +Abstract: + + This file has routines to perform reads and writes. + The read and writes are targeted bulk to endpoints. + +Environment: + + User mode + +--*/ + +#include "osrusbfx2.h" + + +#if defined(EVENT_TRACING) +#include "bulkrwr.tmh" +#endif + +#pragma warning(disable:4267) + + +/*++ + +Routine Description: + + Called by the framework when it receives Read or Write requests. + +Arguments: + + Queue - Default queue handle + + Request - Handle to the read/write request + + Length - Length of the data buffer associated with the request. + The default property of the queue is to not dispatch + zero lenght read & write requests to the driver and + complete is with status success. So we will never get + a zero length request + +Return Value: + + VOID + +--*/ +VOID +OsrFxEvtIoRead( + _In_ WDFQUEUE Queue, + _In_ WDFREQUEST Request, + _In_ size_t Length + ) +{ + WDFUSBPIPE Pipe; + NTSTATUS Status; + WDFMEMORY RequiredMemory; + PDEVICE_CONTEXT DeviceContext; + + UNREFERENCED_PARAMETER(Queue); + + // + // Log read start event, using IRP activity ID if available or request + // handle otherwise. + // + EventWriteReadStart(WdfIoQueueGetDevice(Queue), (ULONG)Length); + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_READ, "-->OsrFxEvtIoRead\n"); + + // + // First validate input parameters. + // + if (Length > TEST_BOARD_TRANSFER_BUFFER_SIZE) { + TraceEvents(TRACE_LEVEL_ERROR, DBG_READ, "Transfer exceeds %d\n", + TEST_BOARD_TRANSFER_BUFFER_SIZE); + Status = STATUS_INVALID_PARAMETER; + goto Exit; + } + + DeviceContext = GetDeviceContext(WdfIoQueueGetDevice(Queue)); + + Pipe = DeviceContext->BulkReadPipe; + + Status = WdfRequestRetrieveOutputMemory(Request, &RequiredMemory); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_READ, + "WdfRequestRetrieveOutputMemory failed %!STATUS!\n", Status); + goto Exit; + } + + // + // The format call validates to make sure that you are reading or + // writing to the right Pipe type, sets the appropriate transfer flags, + // creates an URB and initializes the request. + // + Status = WdfUsbTargetPipeFormatRequestForRead(Pipe, + Request, + RequiredMemory, + NULL // Offsets + ); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_READ, + "WdfUsbTargetPipeFormatRequestForRead failed 0x%x\n", Status); + goto Exit; + } + + WdfRequestSetCompletionRoutine(Request, + EvtRequestReadCompletionRoutine, + Pipe); + // + // Send the request asynchronously. + // + if (WdfRequestSend(Request, + WdfUsbTargetPipeGetIoTarget(Pipe), + WDF_NO_SEND_OPTIONS) == FALSE) + { + // + // Framework couldn't send the request for some reason. + // + TraceEvents(TRACE_LEVEL_ERROR, DBG_READ, "WdfRequestSend failed\n"); + Status = WdfRequestGetStatus(Request); + goto Exit; + } + +Exit: + + if (!NT_SUCCESS(Status)) + { + // + // Log event read failed. + // + EventWriteReadFail(WdfIoQueueGetDevice(Queue), Status); + WdfRequestCompleteWithInformation(Request, Status, 0); + } + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_READ, "<-- OsrFxEvtIoRead\n"); + + return; +} + + +/*++ + +Routine Description: + + This is the completion routine for reads + If the irp completes with success, we check if we + need to recirculate this irp for another stage of + transfer. + +Arguments: + + Context - Driver supplied context + + Device - Device handle + + Request - Request handle + + Params - request completion params + +Return Value: + + VOID + +--*/ +VOID +EvtRequestReadCompletionRoutine( + _In_ WDFREQUEST Request, + _In_ WDFIOTARGET Target, + _In_ PWDF_REQUEST_COMPLETION_PARAMS CompletionParams, + _In_ WDFCONTEXT Context + ) +{ + NTSTATUS Status; + size_t BytesRead = 0; + PWDF_USB_REQUEST_COMPLETION_PARAMS UsbCompletionParams; + + UNREFERENCED_PARAMETER(Target); + UNREFERENCED_PARAMETER(Context); + + Status = CompletionParams->IoStatus.Status; + + UsbCompletionParams = CompletionParams->Parameters.Usb.Completion; + + BytesRead = UsbCompletionParams->Parameters.PipeRead.Length; + + if (NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_READ, + "Number of bytes read: %I64d\n", (INT64)BytesRead); + } + else + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_READ, + "Read failed - request status 0x%x UsbdStatus 0x%x\n", + Status, UsbCompletionParams->UsbdStatus); + + } + + // + // Log read stop event, using IRP activity ID if available or request + // handle otherwise. + // + EventWriteReadStop(WdfIoQueueGetDevice(WdfRequestGetIoQueue(Request)), + BytesRead, + Status, + UsbCompletionParams->UsbdStatus); + + WdfRequestCompleteWithInformation(Request, Status, BytesRead); + + return; +} + + +/*++ + +Routine Description: + + Called by the framework when it receives Read or Write requests. + +Arguments: + + Queue - Default queue handle + + Request - Handle to the read/write request + + Lenght - Length of the data buffer associated with the request. + The default property of the queue is to not dispatch + zero lenght read & write requests to the driver and + complete is with status success. So we will never get + a zero length request + +Return Value: + + VOID + +--*/ +VOID +OsrFxEvtIoWrite( + _In_ WDFQUEUE Queue, + _In_ WDFREQUEST Request, + _In_ size_t Length + ) +{ + NTSTATUS Status; + WDFUSBPIPE Pipe; + WDFMEMORY RequiredMemory; + PDEVICE_CONTEXT DeviceContext; + + UNREFERENCED_PARAMETER(Queue); + + + // + // Log write start event, using IRP activity ID if available or request + // handle otherwise. + // + EventWriteWriteStart(WdfIoQueueGetDevice(Queue), (ULONG)Length); + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_WRITE, "-->OsrFxEvtIoWrite\n"); + + // + // First validate input parameters. + // + if (Length > TEST_BOARD_TRANSFER_BUFFER_SIZE) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_READ, + "Transfer exceeds %d\n", + TEST_BOARD_TRANSFER_BUFFER_SIZE); + Status = STATUS_INVALID_PARAMETER; + goto Exit; + } + + DeviceContext = GetDeviceContext(WdfIoQueueGetDevice(Queue)); + + Pipe = DeviceContext->BulkWritePipe; + + Status = WdfRequestRetrieveInputMemory(Request, &RequiredMemory); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_WRITE, + "WdfRequestRetrieveInputBuffer failed\n"); + goto Exit; + } + + Status = WdfUsbTargetPipeFormatRequestForWrite(Pipe, + Request, + RequiredMemory, + NULL // Offset + ); + + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_WRITE, + "WdfUsbTargetPipeFormatRequestForWrite failed 0x%x\n", Status); + goto Exit; + } + + WdfRequestSetCompletionRoutine(Request, + EvtRequestWriteCompletionRoutine, + Pipe); + + // + // Send the request asynchronously. + // + if (WdfRequestSend(Request, + WdfUsbTargetPipeGetIoTarget(Pipe), + WDF_NO_SEND_OPTIONS) == FALSE) + { + // + // Framework couldn't send the request for some reason. + // + TraceEvents(TRACE_LEVEL_ERROR, DBG_WRITE, "WdfRequestSend failed\n"); + Status = WdfRequestGetStatus(Request); + goto Exit; + } + +Exit: + + if (!NT_SUCCESS(Status)) + { + // + // log event write failed. + // + EventWriteWriteFail(WdfIoQueueGetDevice(Queue), Status); + WdfRequestCompleteWithInformation(Request, Status, 0); + } + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_WRITE, "<-- OsrFxEvtIoWrite\n"); + + return; +} + + +/*++ + +Routine Description: + + This is the completion routine for writes + If the irp completes with success, we check if we + need to recirculate this irp for another stage of + transfer. + +Arguments: + + Context - Driver supplied context + + Device - Device handle + + Request - Request handle + + Params - request completion params + +Return Value: + + VOID + +--*/ +VOID +EvtRequestWriteCompletionRoutine( + _In_ WDFREQUEST Request, + _In_ WDFIOTARGET Target, + _In_ PWDF_REQUEST_COMPLETION_PARAMS CompletionParams, + _In_ WDFCONTEXT Context + ) +{ + NTSTATUS Status; + size_t BytesWritten = 0; + PWDF_USB_REQUEST_COMPLETION_PARAMS UsbCompletionParams; + + UNREFERENCED_PARAMETER(Target); + UNREFERENCED_PARAMETER(Context); + + Status = CompletionParams->IoStatus.Status; + + // + // For usb devices, we should look at the Usb.Completion param. + // + UsbCompletionParams = CompletionParams->Parameters.Usb.Completion; + + BytesWritten = UsbCompletionParams->Parameters.PipeWrite.Length; + + if (NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_WRITE, + "Number of bytes written: %I64d\n", + (INT64)BytesWritten); + } + else + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_WRITE, + "Write failed: request status 0x%x UsbdStatus 0x%x\n", + Status, + UsbCompletionParams->UsbdStatus); + } + + // + // Log write stop event, using IRP activtiy ID if available or request + // handle otherwise. + // + EventWriteWriteStop(WdfIoQueueGetDevice(WdfRequestGetIoQueue(Request)), + BytesWritten, + Status, + UsbCompletionParams->UsbdStatus); + + WdfRequestCompleteWithInformation(Request, Status, BytesWritten); + + return; +} + + +/*++ + +Routine Description: + + This callback is invoked on every inflight request when the device + is suspended or removed. Since our inflight read and write requests + are actually pending in the target device, we will just acknowledge + its presence. Until we acknowledge, complete, or requeue the requests + framework will wait before allowing the device suspend or remove to + proceeed. When the underlying USB stack gets the request to suspend or + remove, it will fail all the pending requests. + +Arguments: + + Queue - Handle to queue object that is associated with the I/O request + + Request - Handle to a request object + + ActionFlags - Bitwise OR of one or more WDF_REQUEST_STOP_ACTION_FLAGS flags + +Return Value: + + VOID + +--*/ +VOID +OsrFxEvtIoStop( + _In_ WDFQUEUE Queue, + _In_ WDFREQUEST Request, + _In_ ULONG ActionFlags + ) +{ + UNREFERENCED_PARAMETER(Queue); + UNREFERENCED_PARAMETER(ActionFlags); + + if (ActionFlags & WdfRequestStopActionSuspend) + { + // + // Don't requeue. + // + WdfRequestStopAcknowledge(Request, FALSE); + } + else if(ActionFlags & WdfRequestStopActionPurge) + { + WdfRequestCancelSentRequest(Request); + } + return; +} + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/device.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/device.c new file mode 100644 index 00000000..a32ab79e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/device.c @@ -0,0 +1,1014 @@ +/*++ + +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: + + Device.c + +Abstract: + + USB device driver for OSR USB-FX2 Learning Kit + +Environment: + + User mode only + +--*/ + +#include "osrusbfx2.h" +#include + +#if defined(EVENT_TRACING) +#include "Device.tmh" +#endif + +#ifdef ALLOC_PRAGMA +#pragma alloc_text(PAGE, OsrFxEvtDeviceAdd) +#pragma alloc_text(PAGE, OsrFxEvtDevicePrepareHardware) +#pragma alloc_text(PAGE, OsrFxEvtDeviceD0Exit) +#pragma alloc_text(PAGE, SelectInterfaces) +#pragma alloc_text(PAGE, OsrFxSetPowerPolicy) +#pragma alloc_text(PAGE, OsrFxReadFdoRegistryKeyValue) +#pragma alloc_text(PAGE, GetDeviceEventLoggingNames) +#endif + + +/*++ +Routine Description: + + EvtDeviceAdd is called by the framework in response to AddDevice + call from the PnP manager. We create and initialize a Device object to + represent a new instance of the device. All the software resources + should be allocated in this callback. + +Arguments: + + Driver - Handle to a framework driver object created in DriverEntry + + DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +NTSTATUS +OsrFxEvtDeviceAdd( + _In_ WDFDRIVER Driver, + _In_ PWDFDEVICE_INIT DeviceInit + ) +{ + WDF_PNPPOWER_EVENT_CALLBACKS PnpPowerCallbacks; + WDF_OBJECT_ATTRIBUTES Attributes; + NTSTATUS Status; + WDFDEVICE Device; + WDF_DEVICE_PNP_CAPABILITIES PnpCaps; + WDF_IO_QUEUE_CONFIG IoQueueConfig; + PDEVICE_CONTEXT DeviceContext; + WDFQUEUE Queue; + GUID Activity; + + UNREFERENCED_PARAMETER(Driver); + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,"--> OsrFxEvtDeviceAdd routine\n"); + + // + // Initialize the PnpPowerCallbacks structure. Callback events for PNP + // and Power are specified here. If you don't supply any callbacks, + // the Framework will take appropriate default actions based on whether + // DeviceInit is initialized to be an FDO, a PDO or a filter device + // object. + // + WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&PnpPowerCallbacks); + + // + // For usb Devices, PrepareHardware callback is the to place select the + // interface and configure the device. + // + PnpPowerCallbacks.EvtDevicePrepareHardware = OsrFxEvtDevicePrepareHardware; + + // + // These two callbacks start and stop the wdfusb pipe continuous reader + // as we go in and out of the D0-working state. + // + PnpPowerCallbacks.EvtDeviceD0Entry = OsrFxEvtDeviceD0Entry; + PnpPowerCallbacks.EvtDeviceD0Exit = OsrFxEvtDeviceD0Exit; + PnpPowerCallbacks.EvtDeviceSelfManagedIoFlush = OsrFxEvtDeviceSelfManagedIoFlush; + + WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &PnpPowerCallbacks); + + WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered); + + // + // Now specify the size of the device extension where we track per-device + // context. DeviceInit is completely initialized. So, call the framework + // to create the device and attach it to the lower stack. + // + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attributes, DEVICE_CONTEXT); + + Status = WdfDeviceCreate(&DeviceInit, &Attributes, &Device); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceCreate failed with Status code %!STATUS!\n", Status); + return Status; + } + + // + // Setup the Activity ID so that we can log events using it. + // + Activity = DeviceToActivityId(Device); + + // + // Get the DeviceObject context by using accessor function specified in + // the WDF_DECLARE_CONTEXT_TYPE_WITH_NAME macro for DEVICE_CONTEXT. + // + DeviceContext = GetDeviceContext(Device); + + // + // Get the device's friendly name and location so that we can use it in + // error logging. If this fails then it will setup dummy strings. + // + GetDeviceEventLoggingNames(Device); + + // + // Tell the framework to set the SurpriseRemovalOK in the DeviceCaps so + // that you don't get the popup in user-mode when you surprise remove the device. + // + WDF_DEVICE_PNP_CAPABILITIES_INIT(&PnpCaps); + PnpCaps.SurpriseRemovalOK = WdfTrue; + + WdfDeviceSetPnpCapabilities(Device, &PnpCaps); + + // + // Create a parallel default queue and register an event callback to + // receive ioctl requests. We will create separate Queues for + // handling read and write requests. All other requests will be + // completed with error Status automatically by the framework. + // + WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&IoQueueConfig, + WdfIoQueueDispatchParallel); + + IoQueueConfig.EvtIoDeviceControl = OsrFxEvtIoDeviceControl; + + // + // By default, Static Driver Verifier (SDV) displays a warning if it + // doesn't find the EvtIoStop callback on a power-managed queue. + // The 'assume' below causes SDV to suppress this warning. If the driver + // has not explicitly set PowerManaged to WdfFalse, the framework creates + // power-managed queues when the device is not a filter driver. Normally + // the EvtIoStop is required for power-managed queues, but for this driver + // it is not needed b/c the driver doesn't hold on to the requests for a + // long time or forward them to other drivers. + // + // If the EvtIoStop callback is not implemented, the framework waits for + // all driver-owned requests to be done before moving into the Dx/sleep + // states or before removing the device, which is the correct behavior + // for this type of driver. If the requests were taking an indeterminate + // amount of time to complete, or if the driver forwarded the requests + // to a lower driver/another stack, the queue should have an + // EvtIoStop/EvtIoResume. + // + __analysis_assume(IoQueueConfig.EvtIoStop != 0); + + Status = WdfIoQueueCreate(Device, + &IoQueueConfig, + WDF_NO_OBJECT_ATTRIBUTES, + &Queue); + + __analysis_assume(IoQueueConfig.EvtIoStop == 0); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfIoQueueCreate failed %!STATUS!\n", Status); + goto Error; + } + + // + // We will create a separate sequential queue and configure it + // to receive read requests. We also need to register a EvtIoStop + // handler so that we can acknowledge requests that are pending + // at the target driver. + // + WDF_IO_QUEUE_CONFIG_INIT(&IoQueueConfig, WdfIoQueueDispatchSequential); + + IoQueueConfig.EvtIoRead = OsrFxEvtIoRead; + IoQueueConfig.EvtIoStop = OsrFxEvtIoStop; + + Status = WdfIoQueueCreate(Device, + &IoQueueConfig, + WDF_NO_OBJECT_ATTRIBUTES, + &Queue); + + if (!NT_SUCCESS (Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfIoQueueCreate failed 0x%x\n", Status); + goto Error; + } + + Status = WdfDeviceConfigureRequestDispatching(Device, + Queue, + WdfRequestTypeRead); + + if (!NT_SUCCESS (Status)) + { + assert(NT_SUCCESS(Status)); + + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceConfigureRequestDispatching failed 0x%x\n", Status); + goto Error; + } + + + // + // We will create another sequential queue and configure it + // to receive write requests. + // + WDF_IO_QUEUE_CONFIG_INIT(&IoQueueConfig, WdfIoQueueDispatchSequential); + + IoQueueConfig.EvtIoWrite = OsrFxEvtIoWrite; + IoQueueConfig.EvtIoStop = OsrFxEvtIoStop; + + Status = WdfIoQueueCreate(Device, + &IoQueueConfig, + WDF_NO_OBJECT_ATTRIBUTES, + &Queue); + + if (!NT_SUCCESS (Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfIoQueueCreate failed 0x%x\n", Status); + goto Error; + } + + Status = WdfDeviceConfigureRequestDispatching(Device, + Queue, + WdfRequestTypeWrite); + + if (!NT_SUCCESS (Status)) + { + assert(NT_SUCCESS(Status)); + + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceConfigureRequestDispatching failed 0x%x\n", Status); + goto Error; + } + + // + // Register a manual I/O queue for handling Interrupt Message Read Requests. + // This queue will be used for storing requests that need to wait for an + // interrupt to occur before they can be completed. + // + WDF_IO_QUEUE_CONFIG_INIT(&IoQueueConfig, WdfIoQueueDispatchManual); + + // + // This queue is used for requests that don't directly access the device. The + // requests in this queue are serviced only when the device is in a fully + // powered state and sends an interrupt. So we can use a non-power managed + // queue to park the requests since we dont care whether the device is idle + // or fully powered up. + // + IoQueueConfig.PowerManaged = WdfFalse; + + Status = WdfIoQueueCreate(Device, + &IoQueueConfig, + WDF_NO_OBJECT_ATTRIBUTES, + &DeviceContext->InterruptMsgQueue); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfIoQueueCreate failed 0x%x\n", Status); + goto Error; + } + + // + // Register a device interface so that app can find our device and talk to it. + // + Status = WdfDeviceCreateDeviceInterface(Device, + (LPGUID) &GUID_DEVINTERFACE_OSRUSBFX2, + NULL // Reference string + ); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceCreateDeviceInterface failed %!STATUS!\n", Status); + goto Error; + } + +#if defined(NTDDI_WIN10_RS2) && (NTDDI_VERSION >= NTDDI_WIN10_RS2) + // + // Adding Custom Capability: + // + // Adds a custom capability to the device interface instance that allows a Windows + // Store device app to access this interface using Windows.Devices.Custom namespace. + // This capability can be defined either in the INF or here as shown below. In order + // to define it from the INF, uncomment the section "OsrUsb Interface installation" + // from the INF and then remove the block of code below. + // + WDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData = { 0 }; + static const wchar_t customCapabilities[] = L"microsoft.hsaTestCustomCapability_q536wpkpf5cy2\0"; + + WDF_DEVICE_INTERFACE_PROPERTY_DATA_INIT(&PropertyData, + &GUID_DEVINTERFACE_OSRUSBFX2, + &DEVPKEY_DeviceInterface_UnrestrictedAppCapabilities); + + Status = WdfDeviceAssignInterfaceProperty(Device, + &PropertyData, + DEVPROP_TYPE_STRING_LIST, + sizeof(customCapabilities), + (PVOID)customCapabilities); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceAssignInterfaceProperty failed %!STATUS!\n", Status); + goto Error; + } +#endif + + // + // Create the lock that we use to serialize calls to ResetDevice(). As an + // alternative to using a WDFWAITLOCK to serialize the calls, a sequential + // WDFQUEUE can be created and reset IOCTLs would be forwarded to it. + // + WDF_OBJECT_ATTRIBUTES_INIT(&Attributes); + Attributes.ParentObject = Device; + + Status = WdfWaitLockCreate(&Attributes, &DeviceContext->ResetDeviceWaitLock); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfWaitLockCreate failed %!STATUS!\n", Status); + goto Error; + } + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- OsrFxEvtDeviceAdd\n"); + + return Status; + +Error: + + // + // Log failure to add the device. + // + EventWriteFailAddDevice(DeviceContext->DeviceName, + DeviceContext->Location, + Status); + + return Status; +} + + +/*++ + +Routine Description: + + In this callback, the driver does whatever is necessary to make the + hardware ready to use. In the case of a USB device, this involves + reading and selecting descriptors. + +Arguments: + + Device - Handle to the device + + ResourceList - Handle to a resource-list object that identifies the + raw hardware resources that the PnP manager assigned + to the Device + + ResourceListTranslated - Handle to a resource-list object that + identifies the translated hardware resources + that the PnP manager assigned to the device + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +NTSTATUS +OsrFxEvtDevicePrepareHardware( + _In_ WDFDEVICE Device, + _In_ WDFCMRESLIST ResourceList, + _In_ WDFCMRESLIST ResourceListTranslated + ) +{ + NTSTATUS Status; + PDEVICE_CONTEXT DeviceContext; + WDF_USB_DEVICE_INFORMATION DeviceInfo; + ULONG WaitWakeEnable; + + UNREFERENCED_PARAMETER(ResourceList); + UNREFERENCED_PARAMETER(ResourceListTranslated); + + WaitWakeEnable = FALSE; + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, + "--> EvtDevicePrepareHardware\n"); + + DeviceContext = GetDeviceContext(Device); + + // + // Create a USB device handle so that we can communicate with the + // underlying USB stack. The WDFUSBDEVICE handle is used to query, + // configure, and manage all aspects of the USB device. + // These aspects include device properties, bus properties, + // and I/O creation and synchronization. We only create the device the + // first time that PrepareHardware is called. If the device is restarted by + // PnP Manager to rebalance resources, we will use the same device handle + // but then select the interfaces again because the USB stack could + // reconfigure the device on restart. + // + if (DeviceContext->UsbDevice == NULL) + { + Status = WdfUsbTargetDeviceCreate(Device, + WDF_NO_OBJECT_ATTRIBUTES, + &DeviceContext->UsbDevice); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfUsbTargetDeviceCreate failed with status code %!STATUS!\n", Status); + return Status; + } + } + + // + // Retrieve USBD version information, port driver capabilites and device + // capabilites such as speed, power, etc. + // + WDF_USB_DEVICE_INFORMATION_INIT(&DeviceInfo); + + Status = WdfUsbTargetDeviceRetrieveInformation(DeviceContext->UsbDevice, + &DeviceInfo); + if (NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, + "IsDeviceHighSpeed: %s\n", + (DeviceInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED) ? "TRUE" : + "FALSE"); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, + "IsDeviceSelfPowered: %s\n", + (DeviceInfo.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED) ? "TRUE" : + "FALSE"); + + WaitWakeEnable = DeviceInfo.Traits & + WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE; + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, + "IsDeviceRemoteWakeable: %s\n", + WaitWakeEnable ? "TRUE" : + "FALSE"); + // + // Save these for use later. + // + DeviceContext->UsbDeviceTraits = DeviceInfo.Traits; + } + else + { + DeviceContext->UsbDeviceTraits = 0; + } + + Status = SelectInterfaces(Device); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "SelectInterfaces failed 0x%x\n", Status); + + return Status; + } + + // + // Enable wait-wake and idle timeout if the device supports it. + // + if (WaitWakeEnable) + { + Status = OsrFxSetPowerPolicy(Device); + + if (!NT_SUCCESS (Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "OsrFxSetPowerPolicy failed %!STATUS!\n", Status); + return Status; + } + } + + Status = OsrFxConfigContReaderForInterruptEndPoint(DeviceContext); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP, "<-- EvtDevicePrepareHardware\n"); + + return Status; +} + + +/*++ + +Routine Description: + + EvtDeviceD0Entry event callback must perform any operations that are + necessary before the specified device is used. It will be called every + time the hardware needs to be (re-)initialized. + + This function is not marked pageable because this function is in the + device power-up path. When a function is marked pagable and the code + section is paged out, it will generate a page fault which could impact + the fast resume behavior because the client driver will have to wait + until the system drivers can service this page fault. + + This function runs at PASSIVE_LEVEL, even though it is not paged. A + driver can optionally make this function pageable if DO_POWER_PAGABLE + is set. Even if DO_POWER_PAGABLE isn't set, this function still runs + at PASSIVE_LEVEL. In this case, though, the function absolutely must + not do anything that will cause a page fault. + +Arguments: + + Device - Handle to a framework device object + + PreviousState - Device power state which the device was in most recently. + If the device is being newly started, this will be + PowerDeviceUnspecified. + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +NTSTATUS +OsrFxEvtDeviceD0Entry( + _In_ WDFDEVICE Device, + _In_ WDF_POWER_DEVICE_STATE PreviousState + ) +{ + PDEVICE_CONTEXT DeviceContext; + NTSTATUS Status; + BOOLEAN IsTargetStarted; + + DeviceContext = GetDeviceContext(Device); + IsTargetStarted = FALSE; + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, + "-->OsrFxEvtEvtDeviceD0Entry - coming from %s\n", + DbgDevicePowerString(PreviousState)); + + // + // Since continuous reader is configured for this interrupt-pipe, we must explicitly start + // the I/O target to get the framework to post read requests. + // + Status = WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(DeviceContext->InterruptPipe)); + + if (!NT_SUCCESS(Status)) { + TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER, + "Failed to start interrupt pipe %!STATUS!\n", Status); + goto End; + } + + IsTargetStarted = TRUE; + +End: + + if (!NT_SUCCESS(Status)) + { + // + // Failure in D0Entry will lead to the device being removed. So stop + // sthe continuous reader in preparation for the ensuing remove. + // + if (IsTargetStarted) + { + WdfIoTargetStop(WdfUsbTargetPipeGetIoTarget(DeviceContext->InterruptPipe), + WdfIoTargetCancelSentIo); + } + } + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, "<--OsrFxEvtEvtDeviceD0Entry\n"); + + return Status; +} + + +/*++ + +Routine Description: + + This routine undoes anything done in EvtDeviceD0Entry. It is called + whenever the device leaves the D0 state, which happens when the device is + stopped, when it is removed, and when it is powered off. + + The device is still in D0 when this callback is invoked, which means that + the driver can still touch hardware in this routine. + + EvtDeviceD0Exit event callback must perform any operations that are + necessary before the specified device is moved out of the D0 state. If the + driver needs to save hardware state before the device is powered down, then + that should be done here. + + This function runs at PASSIVE_LEVEL, though it is generally not paged. A + driver can optionally make this function pageable if DO_POWER_PAGABLE is set. + + Even if DO_POWER_PAGABLE isn't set, this function still runs at + PASSIVE_LEVEL. In this case, though, the function absolutely must not do + anything that will cause a page fault. + +Arguments: + + Device - Handle to a framework device object + + TargetState - Device power state which the device will be put in once this + callback is complete + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + + If this function succeeds it implies that the device can be used. + +--*/ +NTSTATUS +OsrFxEvtDeviceD0Exit( + _In_ WDFDEVICE Device, + _In_ WDF_POWER_DEVICE_STATE TargetState + ) +{ + PDEVICE_CONTEXT DeviceContext; + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, + "-->OsrFxEvtDeviceD0Exit - moving to %s\n", + DbgDevicePowerString(TargetState)); + + DeviceContext = GetDeviceContext(Device); + + WdfIoTargetStop(WdfUsbTargetPipeGetIoTarget(DeviceContext->InterruptPipe), WdfIoTargetCancelSentIo); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER, + "<--OsrFxEvtDeviceD0Exit\n"); + + return STATUS_SUCCESS; +} + + +/*++ + +Routine Description: + + This routine handles flush Activity for the device's + self-managed I/O operations. + +Arguments: + + Device - Handle to a framework device object + +Return Value: + + VOID + +--*/ +VOID +OsrFxEvtDeviceSelfManagedIoFlush( + _In_ WDFDEVICE Device + ) +{ + // + // Service the interrupt message queue to drain any outstanding + // requests + // + OsrUsbIoctlGetInterruptMessage(Device, STATUS_DEVICE_REMOVED); +} + + +/*++ + +Routine Description: + + This routine sets the power policy for the device. + +Arguments: + + Device - Handle to a framework device object + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +OsrFxSetPowerPolicy( + _In_ WDFDEVICE Device + ) +{ + WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings; + WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS wakeSettings; + NTSTATUS Status = STATUS_SUCCESS; + + PAGED_CODE(); + + // + // Init the idle policy structure. + // + WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings, IdleUsbSelectiveSuspend); + + idleSettings.IdleTimeout = 10000; // 10 seconds + + Status = WdfDeviceAssignS0IdleSettings(Device, &idleSettings); + + if ( !NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceSetPowerPolicyS0IdlePolicy failed %x\n", Status); + return Status; + } + + // + // Init wait-wake policy structure. + // + WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings); + + Status = WdfDeviceAssignSxWakeSettings(Device, &wakeSettings); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfDeviceAssignSxWakeSettings failed %x\n", Status); + return Status; + } + + return Status; +} + + +/*++ + +Routine Description: + + This helper routine selects the configuration, interface and + creates a context for every pipe (end point) in that interface. + +Arguments: + + Device - Handle to a framework device object + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +SelectInterfaces( + _In_ WDFDEVICE Device + ) +{ + WDF_USB_DEVICE_SELECT_CONFIG_PARAMS configParams; + NTSTATUS Status = STATUS_SUCCESS; + PDEVICE_CONTEXT DeviceContext; + WDFUSBPIPE Pipe; + WDF_USB_PIPE_INFORMATION PipeInfo; + UCHAR Index; + UCHAR NumberConfiguredPipes; + WDFUSBINTERFACE UsbInterface; + + PAGED_CODE(); + + DeviceContext = GetDeviceContext(Device); + + WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE( &configParams); + + UsbInterface = WdfUsbTargetDeviceGetInterface(DeviceContext->UsbDevice, 0); + + if (NULL == UsbInterface) + { + Status = STATUS_UNSUCCESSFUL; + + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "WdfUsbTargetDeviceGetInterface 0 failed %!STATUS! \n", + Status); + return Status; + } + + configParams.Types.SingleInterface.ConfiguredUsbInterface = UsbInterface; + + configParams.Types.SingleInterface.NumberConfiguredPipes = WdfUsbInterfaceGetNumConfiguredPipes(UsbInterface); + + DeviceContext->UsbInterface = configParams.Types.SingleInterface.ConfiguredUsbInterface; + + NumberConfiguredPipes = configParams.Types.SingleInterface.NumberConfiguredPipes; + + // + // Get pipe handles. + // + for (Index = 0; Index < NumberConfiguredPipes; Index++) + { + WDF_USB_PIPE_INFORMATION_INIT(&PipeInfo); + + Pipe = WdfUsbInterfaceGetConfiguredPipe(DeviceContext->UsbInterface, + Index, + &PipeInfo); + + // + // Tell the framework that it's okay to read less than + // MaximumPacketSize. + // + WdfUsbTargetPipeSetNoMaximumPacketSizeCheck(Pipe); + + if (WdfUsbPipeTypeInterrupt == PipeInfo.PipeType) + { + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "Interrupt Pipe is 0x%p\n", Pipe); + DeviceContext->InterruptPipe = Pipe; + } + + if ((WdfUsbPipeTypeBulk == PipeInfo.PipeType) && + (WdfUsbTargetPipeIsInEndpoint(Pipe))) + { + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "BulkInput Pipe is 0x%p\n", Pipe); + DeviceContext->BulkReadPipe = Pipe; + } + + if ((WdfUsbPipeTypeBulk == PipeInfo.PipeType) && + (WdfUsbTargetPipeIsOutEndpoint(Pipe))) + { + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "BulkOutput Pipe is 0x%p\n", Pipe); + DeviceContext->BulkWritePipe = Pipe; + } + + } + + // + // If we didn't find all 3 pipes, fail the start. + // + if (!((DeviceContext->BulkWritePipe) && + ((DeviceContext->BulkReadPipe) && + (DeviceContext->InterruptPipe)))) + { + Status = STATUS_INVALID_DEVICE_STATE; + + TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, + "Device is not configured properly %!STATUS!\n", + Status); + + return Status; + } + + return Status; +} + + +/*++ + +Routine Description: + + Retrieve the friendly name and the location string into WDFMEMORY objects + and store them in the device context. + +Arguments: + + Device - Handle to a device framework object + +Return Value: + + VOID + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +VOID +GetDeviceEventLoggingNames( + _In_ WDFDEVICE Device + ) +{ + PDEVICE_CONTEXT DeviceContext = GetDeviceContext(Device); + WDF_OBJECT_ATTRIBUTES ObjectAttributes; + WDFMEMORY DeviceNameMemory = NULL; + WDFMEMORY LocationMemory = NULL; + NTSTATUS Status; + + PAGED_CODE(); + + // + // We want both memory objects to be children of the device so that they + // will be deleted automatically when the device is removed. + // + WDF_OBJECT_ATTRIBUTES_INIT(&ObjectAttributes); + ObjectAttributes.ParentObject = Device; + + // + // First get the length of the string. If the FriendlyName + // is not there then get the length of the device's description. + // + Status = WdfDeviceAllocAndQueryProperty(Device, + DevicePropertyFriendlyName, + NonPagedPoolNx, + &ObjectAttributes, + &DeviceNameMemory); + + if (!NT_SUCCESS(Status)) + { + Status = WdfDeviceAllocAndQueryProperty(Device, + DevicePropertyDeviceDescription, + NonPagedPoolNx, + &ObjectAttributes, + &DeviceNameMemory); + } + + if (NT_SUCCESS(Status)) + { + DeviceContext->DeviceNameMemory = DeviceNameMemory; + DeviceContext->DeviceName = WdfMemoryGetBuffer(DeviceNameMemory, NULL); + } + else + { + DeviceContext->DeviceNameMemory = NULL; + DeviceContext->DeviceName = L"(error retrieving name)"; + } + + // + // Retrieve the device location string. + // + Status = WdfDeviceAllocAndQueryProperty(Device, + DevicePropertyLocationInformation, + NonPagedPoolNx, + WDF_NO_OBJECT_ATTRIBUTES, + &LocationMemory); + + if (NT_SUCCESS(Status)) + { + DeviceContext->LocationMemory = LocationMemory; + DeviceContext->Location = WdfMemoryGetBuffer(LocationMemory, NULL); + } + else + { + DeviceContext->LocationMemory = NULL; + DeviceContext->Location = L"(error retrieving location)"; + } +} + + +/*++ + +Routine Description: + + Retrieve the correct string for a given power device state. + +Arguments: + + Type - The device power state to turn into a string + +Return Value: + + The name that corresponds to the WDF_POWER_DEVICE_STATE given, or + "Unknown Device Power State" if none was found. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +PCHAR +DbgDevicePowerString( + _In_ WDF_POWER_DEVICE_STATE Type + ) +{ + switch (Type) + { + case WdfPowerDeviceInvalid: + return "WdfPowerDeviceInvalid"; + case WdfPowerDeviceD0: + return "WdfPowerDeviceD0"; + case WdfPowerDeviceD1: + return "WdfPowerDeviceD1"; + case WdfPowerDeviceD2: + return "WdfPowerDeviceD2"; + case WdfPowerDeviceD3: + return "WdfPowerDeviceD3"; + case WdfPowerDeviceD3Final: + return "WdfPowerDeviceD3Final"; + case WdfPowerDevicePrepareForHibernation: + return "WdfPowerDevicePrepareForHibernation"; + case WdfPowerDeviceMaximum: + return "WdfPowerDeviceMaximum"; + default: + return "Unknown Device Power State"; + } +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/driver.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/driver.c new file mode 100644 index 00000000..2be5d2ed --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/driver.c @@ -0,0 +1,281 @@ +/*++ + +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: + + Driver.c + +Abstract: + + Main module. + + This driver is for the Open System Resources USB-FX2 Learning Kit designed + and built by OSR specifically for use in teaching software developers how to write + drivers for USB devices. + + The board supports a single configuration. The board automatically + detects the speed of the host controller, and supplies either the + high or full speed configuration based on the host controller's speed. + + The firmware supports 3 endpoints: + + Endpoint number 1 is used to indicate the state of the 8-switch + switch-pack on the OSR USB-FX2 board. A single byte representing + the switch state is sent (a) when the board is first started, + (b) when the board resumes after selective-suspend, + (c) whenever the state of the switches is changed. + + Endpoints 6 and 8 perform an internal loop-back function. + Data that is sent to the board at EP6 is returned to the host on EP8. + + For further information on the endpoints, please refer to the spec + http://www.osronline.com/hardware/OSRFX2_32.pdf. + + Vendor ID of the device is 0x4705 and Product ID is 0x210. + +Environment: + + User mode only + +--*/ + +#include "osrusbfx2.h" + +#if defined(EVENT_TRACING) +// +// The trace message header (.tmh) file must be included in a source file +// before any WPP macro calls and after defining a WPP_CONTROL_GUIDS +// macro (defined in trace.h). During the compilation, WPP scans the source +// files for DoTraceMessage() calls and builds a .tmh file which stores a unique +// data GUID for each message, the text resource string for each message, +// and the data types of the variables passed in for each message. This file +// is automatically generated and used during post-processing. +// +#include "driver.tmh" +#else +ULONG DebugLevel = TRACE_LEVEL_INFORMATION; +ULONG DebugFlag = 0xff; +#endif + +#ifdef ALLOC_PRAGMA +#pragma alloc_text(INIT, DriverEntry) +#pragma alloc_text(PAGE, OsrFxEvtDriverContextCleanup) +#endif + + +/*++ + +Routine Description: + + DriverEntry initializes the driver and is the first routine called by the + system after the driver is loaded. + +Parameters Description: + + DriverObject - Represents the instance of the function driver that is loaded + into memory. DriverEntry must initialize members of + DriverObject before it returns to the caller. DriverObject + is allocated by the system before the driver is loaded, and + it is released by the system after the system unloads the + function driver from memory + + RegistryPath - Represents the driver specific path in the registry. + The function driver can use the path to store driver related + data between reboots. The path does not store hardware + instance specific data + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +NTSTATUS +DriverEntry( + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath + ) +{ + WDF_DRIVER_CONFIG Config; + NTSTATUS Status; + WDF_OBJECT_ATTRIBUTES Attributes; + + // + // Initialize WPP Tracing. + // + WPP_INIT_TRACING(DriverObject, RegistryPath); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, + "OSRUSBFX2 Driver Sample - Driver Framework Edition.\n"); + + // + // Register with ETW (unified tracing). + // + EventRegisterOSRUSBFX2(); + + // + // Initiialize driver config to control the attributes that + // are global to the driver. Note that framework by default + // provides a driver unload routine. If you create any resources + // in the DriverEntry and want to be cleaned in driver unload, + // you can override that by manually setting the EvtDriverUnload in the + // config structure. In general xxx_CONFIG_INIT macros are provided to + // initialize most commonly used members. + // + + WDF_DRIVER_CONFIG_INIT(&Config, + OsrFxEvtDeviceAdd); + + // + // Register a cleanup callback so that we can call WPP_CLEANUP when + // the framework driver object is deleted during driver unload. + // + WDF_OBJECT_ATTRIBUTES_INIT(&Attributes); + Attributes.EvtCleanupCallback = OsrFxEvtDriverContextCleanup; + + // + // Create a framework driver object to represent our driver. + // + Status = WdfDriverCreate(DriverObject, + RegistryPath, + &Attributes, + &Config, + WDF_NO_HANDLE); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, + "WdfDriverCreate failed with Status 0x%x\n", Status); + // + // Cleanup tracing here because DriverContextCleanup will not be called + // as we have failed to create WDFDRIVER object itself. + // Please note that if your return failure from DriverEntry after the + // WDFDRIVER object is created successfully, you don't have to + // call WPP cleanup because in those cases DriverContextCleanup + // will be executed when the framework deletes the DriverObject. + // + WPP_CLEANUP(DriverObject); + EventUnregisterOSRUSBFX2(); + } + + return Status; +} + + +/*++ +Routine Description: + + Free resources allocated in DriverEntry that are not automatically + cleaned up by the framework. + +Arguments: + + Driver - Handle to a WDF driver object + +Return Value: + + VOID + +--*/ +VOID +OsrFxEvtDriverContextCleanup( + _In_ WDFOBJECT Driver + ) +{ + PAGED_CODE (); + + // + // For the case when WPP is not being used. + // + UNREFERENCED_PARAMETER(Driver); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, + "--> OsrFxEvtDriverContextCleanup\n"); + + WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER) Driver)); + + EventUnregisterOSRUSBFX2(); +} + + +#if !defined(EVENT_TRACING) +/*++ + +Routine Description: + + Debug print for the sample driver. + +Arguments: + + DebugPrintLevel - Print level between 0 and 3, with 3 the most verbose + + DebugPrintFlag - Message mask + + DebugMessage - Format string of the message to print + + ... - Values used by the format string + +Return Value: + + VOID + + --*/ +VOID +TraceEvents ( + _In_ ULONG DebugPrintLevel, + _In_ ULONG DebugPrintFlag, + _Printf_format_string_ _In_ PCSTR DebugMessage, + ... + ) +{ +#if DBG +#define TEMP_BUFFER_SIZE 1024 + va_list List; + CHAR DebugMessageBuffer[TEMP_BUFFER_SIZE]; + HRESULT hr; + + va_start(List, DebugMessage); + + if (DebugMessage) + { + // + // Using new safe string functions instead of _vsnprintf. + // This function takes care of NULL terminating if the message + // is longer than the buffer. + // + hr = StringCchVPrintfA(DebugMessageBuffer, + sizeof(DebugMessageBuffer), + DebugMessage, + List); + + if(FAILED(hr)) + { + DbgPrint(_DRIVER_NAME_": StringCchVPrintfA failed with HRESULT 0x%x\n", hr); + return; + } + + if ((DebugPrintLevel <= TRACE_LEVEL_ERROR) || + ((DebugPrintLevel <= DebugLevel) && + ((DebugPrintFlag & DebugFlag) == DebugPrintFlag))) + { + DbgPrint("%s %s", _DRIVER_NAME_, DebugMessageBuffer); + } + } + + va_end(List); + + return; +#else + UNREFERENCED_PARAMETER(DebugPrintLevel); + UNREFERENCED_PARAMETER(DebugPrintFlag); + UNREFERENCED_PARAMETER(DebugMessage); +#endif +} + +#endif \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/ioctl.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/ioctl.c new file mode 100644 index 00000000..2c6792a4 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/ioctl.c @@ -0,0 +1,1151 @@ +/*++ + +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: + + Ioctl.c + +Abstract: + + USB device driver for OSR USB-FX2 Learning Kit + +Environment: + + User mode only + +--*/ + +#include "osrusbfx2.h" + +#if defined(EVENT_TRACING) +#include "ioctl.tmh" +#endif + +#pragma alloc_text(PAGE, OsrFxEvtIoDeviceControl) +#pragma alloc_text(PAGE, ResetPipe) +#pragma alloc_text(PAGE, ResetDevice) +#pragma alloc_text(PAGE, ReenumerateDevice) +#pragma alloc_text(PAGE, GetBarGraphState) +#pragma alloc_text(PAGE, SetBarGraphState) +#pragma alloc_text(PAGE, GetSevenSegmentState) +#pragma alloc_text(PAGE, SetSevenSegmentState) +#pragma alloc_text(PAGE, GetSwitchState) + + +/*++ + +Routine Description: + + This event is called when the framework receives IRP_MJ_DEVICE_CONTROL + requests from the system. + +Arguments: + + Queue - Handle to the framework queue object that is + associated with the I/O request + + Request - Handle to a framework request object + + OutputBufferLength - Length of the request's output buffer, if an output + buffer is available + + InputBufferLength - Length of the request's input buffer, if an input + buffer is available + + IoControlCode - The driver-defined or system-defined I/O control code + (IOCTL) that is associated with the request + +Return Value: + + VOID + +--*/ +VOID +OsrFxEvtIoDeviceControl( + _In_ WDFQUEUE Queue, + _In_ WDFREQUEST Request, + _In_ size_t OutputBufferLength, + _In_ size_t InputBufferLength, + _In_ ULONG IoControlCode + ) +{ + WDFDEVICE Device; + PDEVICE_CONTEXT DeviceContext; + size_t BytesReturned = 0; + PBAR_GRAPH_STATE BarGraphState = NULL; + PSWITCH_STATE SwitchState = NULL; + PUCHAR SevenSegment = NULL; + BOOLEAN RequestPending = FALSE; + NTSTATUS Status = STATUS_INVALID_DEVICE_REQUEST; + + UNREFERENCED_PARAMETER(InputBufferLength); + UNREFERENCED_PARAMETER(OutputBufferLength); + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "--> OsrFxEvtIoDeviceControl\n"); + + // + // Initialize variables. + // + Device = WdfIoQueueGetDevice(Queue); + DeviceContext = GetDeviceContext(Device); + + switch(IoControlCode) + { + + case IOCTL_OSRUSBFX2_GET_CONFIG_DESCRIPTOR: + { + PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor = NULL; + USHORT RequiredSize = 0; + + // + // First get the size of the config descriptor. + // + Status = WdfUsbTargetDeviceRetrieveConfigDescriptor(DeviceContext->UsbDevice, + NULL, + &RequiredSize); + + if (Status != STATUS_BUFFER_TOO_SMALL) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "WdfUsbTargetDeviceRetrieveConfigDescriptor failed 0x%x\n", + Status); + break; + } + + // + // Get the buffer - make sure the buffer is big enough. + // + Status = WdfRequestRetrieveOutputBuffer(Request, + (size_t)RequiredSize, + &ConfigurationDescriptor, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "WdfRequestRetrieveOutputBuffer failed 0x%x\n", + Status); + break; + } + + Status = WdfUsbTargetDeviceRetrieveConfigDescriptor(DeviceContext->UsbDevice, + ConfigurationDescriptor, + &RequiredSize); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "WdfUsbTargetDeviceRetrieveConfigDescriptor failed 0x%x\n", + Status); + break; + } + + BytesReturned = RequiredSize; + } + + break; + + case IOCTL_OSRUSBFX2_RESET_DEVICE: + + Status = ResetDevice(Device); + break; + + case IOCTL_OSRUSBFX2_REENUMERATE_DEVICE: + // + // Otherwise, call our function to re-enumerate the device. + // + Status = ReenumerateDevice(DeviceContext); + + BytesReturned = 0; + break; + + case IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY: + // + // Make sure the caller's output buffer is large enough + // to hold the state of the bar graph. + // + Status = WdfRequestRetrieveOutputBuffer(Request, + sizeof(BAR_GRAPH_STATE), + &BarGraphState, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "User's output buffer is too small for this IOCTL, expecting a BAR_GRAPH_STATE\n"); + break; + } + + // + // Call our function to get the bar graph state. + // + Status = GetBarGraphState(DeviceContext, BarGraphState); + + // + // Return the user their data. + // + if (NT_SUCCESS(Status)) + { + BytesReturned = sizeof(BAR_GRAPH_STATE); + } + else + { + BytesReturned = 0; + } + + break; + + case IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY: + Status = WdfRequestRetrieveInputBuffer(Request, + sizeof(BAR_GRAPH_STATE), + &BarGraphState, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "User's input buffer is too small for this IOCTL, expecting a BAR_GRAPH_STATE\n"); + break; + } + + // + // Call our routine to set the bar graph state. + // + Status = SetBarGraphState(DeviceContext, BarGraphState); + + // + // There's no data returned for this call. + // + BytesReturned = 0; + break; + + case IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY: + Status = WdfRequestRetrieveOutputBuffer(Request, + sizeof(UCHAR), + &SevenSegment, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "User's output buffer is too small for this IOCTL, expecting an UCHAR\n"); + break; + } + + // + // Call our function to get the 7 segment state. + // + Status = GetSevenSegmentState(DeviceContext, SevenSegment); + + // + // If we succeeded return the user their data. + // + if (NT_SUCCESS(Status)) + { + BytesReturned = sizeof(UCHAR); + } + else + { + BytesReturned = 0; + } + + break; + + case IOCTL_OSRUSBFX2_SET_7_SEGMENT_DISPLAY: + Status = WdfRequestRetrieveInputBuffer(Request, + sizeof(UCHAR), + &SevenSegment, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "User's input buffer is too small for this IOCTL, expecting an UCHAR\n"); + + BytesReturned = sizeof(UCHAR); + break; + } + + // + // Call our routine to set the 7 segment state. + // + Status = SetSevenSegmentState(DeviceContext, SevenSegment); + + // + // There's no data returned for this call. + // + BytesReturned = 0; + break; + + case IOCTL_OSRUSBFX2_READ_SWITCHES: + Status = WdfRequestRetrieveOutputBuffer(Request, + sizeof(SWITCH_STATE), + &SwitchState, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "User's output buffer is too small for this IOCTL, expecting a SWITCH_STATE\n"); + + BytesReturned = sizeof(SWITCH_STATE); + break; + } + + // + // Call our routine to get the state of the switches. + // + Status = GetSwitchState(DeviceContext, SwitchState); + + // + // If successful, return the user their data. + // + if (NT_SUCCESS(Status)) + { + BytesReturned = sizeof(SWITCH_STATE); + } + else + { + // + // Don't return any data. + // + BytesReturned = 0; + } + + break; + + case IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE: + // + // Forward the request to an interrupt message queue and dont complete + // the request until an interrupt from the USB Device occurs. + // + Status = WdfRequestForwardToIoQueue(Request, + DeviceContext->InterruptMsgQueue); + + if (NT_SUCCESS(Status)) + { + RequestPending = TRUE; + } + + break; + + default : + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + + if (RequestPending == FALSE) + { + WdfRequestCompleteWithInformation(Request, Status, BytesReturned); + } + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "<-- OsrFxEvtIoDeviceControl\n"); + + return; +} + + +/*++ + +Routine Description: + + This routine resets the pipe. + +Arguments: + + Pipe - framework pipe handle + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +ResetPipe( + _In_ WDFUSBPIPE Pipe + ) +{ + NTSTATUS Status; + + PAGED_CODE(); + + // + // This routine synchronously submits a URB_FUNCTION_RESET_PIPE + // request down the stack. + // + Status = WdfUsbTargetPipeResetSynchronously(Pipe, + WDF_NO_HANDLE, + NULL); + + if (NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "ResetPipe - success\n"); + + Status = STATUS_SUCCESS; + } + else + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "ResetPipe - failed\n"); + } + + return Status; +} + + +/*++ + +Routine Description: + + This routine stops all of the device's pipes. + +Arguments: + + DeviceContext - The device context with the pipe information + +Return Value: + + VOID + +--*/ +VOID +StopAllPipes( + _In_ PDEVICE_CONTEXT DeviceContext + ) +{ + WdfIoTargetStop(WdfUsbTargetPipeGetIoTarget(DeviceContext->InterruptPipe), + WdfIoTargetCancelSentIo); + + WdfIoTargetStop(WdfUsbTargetPipeGetIoTarget(DeviceContext->BulkReadPipe), + WdfIoTargetCancelSentIo); + + WdfIoTargetStop(WdfUsbTargetPipeGetIoTarget(DeviceContext->BulkWritePipe), + WdfIoTargetCancelSentIo); +} + + +/*++ + +Routine Description: + + This routine starts all of the device's pipes. + +Arguments: + + DeviceContext - The device context with the pipe information + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +NTSTATUS +StartAllPipes( + _In_ PDEVICE_CONTEXT DeviceContext + ) +{ + NTSTATUS Status; + + Status = WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(DeviceContext->InterruptPipe)); + + if (!NT_SUCCESS(Status)) + { + return Status; + } + + Status = WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(DeviceContext->BulkReadPipe)); + + if (!NT_SUCCESS(Status)) + { + return Status; + } + + Status = WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(DeviceContext->BulkWritePipe)); + + if (!NT_SUCCESS(Status)) + { + return Status; + } + + return Status; +} + + +/*++ + +Routine Description: + + This routine calls WdfUsbTargetDeviceResetPortSynchronously to reset the + device if it's still connected. + +Arguments: + + Device - Handle to a framework device object + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +ResetDevice( + _In_ WDFDEVICE Device + ) +{ + PDEVICE_CONTEXT DeviceContext; + NTSTATUS Status; + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "--> ResetDevice\n"); + + DeviceContext = GetDeviceContext(Device); + + // + // A NULL timeout indicates an infinite wake. + // + Status = WdfWaitLockAcquire(DeviceContext->ResetDeviceWaitLock, NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "ResetDevice - could not acquire lock\n"); + + return Status; + } + + StopAllPipes(DeviceContext); + + Status = WdfUsbTargetDeviceResetPortSynchronously(DeviceContext->UsbDevice); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "ResetDevice failed - 0x%x\n", + Status); + } + + Status = StartAllPipes(DeviceContext); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "Failed to start all pipes - 0x%x\n", + Status); + } + + WdfWaitLockRelease(DeviceContext->ResetDeviceWaitLock); + + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, + "<-- ResetDevice\n"); + + return Status; +} + + +/*++ + +Routine Description + + This routine re-enumerates the USB device. + +Arguments: + + DeviceContext - One of our device extensions + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +ReenumerateDevice( + _In_ PDEVICE_CONTEXT DeviceContext + ) +{ + NTSTATUS Status; + WDF_USB_CONTROL_SETUP_PACKET ControlSetupPacket; + WDF_REQUEST_SEND_OPTIONS SendOptions; + GUID Activity; + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "--> ReenumerateDevice\n"); + + WDF_REQUEST_SEND_OPTIONS_INIT(&SendOptions, + WDF_REQUEST_SEND_OPTION_TIMEOUT); + + WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&SendOptions, + DEFAULT_CONTROL_TRANSFER_TIMEOUT); + + WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&ControlSetupPacket, + BmRequestHostToDevice, + BmRequestToDevice, + USBFX2LK_REENUMERATE, + 0, + 0); + + + Status = WdfUsbTargetDeviceSendControlTransferSynchronously(DeviceContext->UsbDevice, + WDF_NO_HANDLE, + &SendOptions, + &ControlSetupPacket, + NULL, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "ReenumerateDevice: Failed to Reenumerate - 0x%x \n", + Status); + } + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "<-- ReenumerateDevice\n"); + + // + // Send event to the event log. + // + Activity = DeviceToActivityId(WdfObjectContextGetObject(DeviceContext)); + + EventWriteDeviceReenumerated(DeviceContext->DeviceName, + DeviceContext->Location, + Status); + + return Status; + +} + + +/*++ + +Routine Description + + This routine gets the state of the bar graph on the board. + +Arguments: + + DeviceContext - One of our device extensions + + BarGraphState - Struct that receives the bar graph's state + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +GetBarGraphState( + _In_ PDEVICE_CONTEXT DeviceContext, + _Out_ PBAR_GRAPH_STATE BarGraphState + ) +{ + NTSTATUS Status; + WDF_USB_CONTROL_SETUP_PACKET ControlSetupPacket; + WDF_REQUEST_SEND_OPTIONS SendOptions; + WDF_MEMORY_DESCRIPTOR MemoryDescriptor; + ULONG BytesTransferred; + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "--> GetBarGraphState\n"); + + WDF_REQUEST_SEND_OPTIONS_INIT(&SendOptions, + WDF_REQUEST_SEND_OPTION_TIMEOUT); + + WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&SendOptions, + DEFAULT_CONTROL_TRANSFER_TIMEOUT); + + WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&ControlSetupPacket, + BmRequestDeviceToHost, + BmRequestToDevice, + USBFX2LK_READ_BARGRAPH_DISPLAY, + 0, + 0); + + // + // Set the buffer to 0, the board will OR in everything that is set. + // + BarGraphState->BarsAsUChar = 0; + + + WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&MemoryDescriptor, + BarGraphState, + sizeof(BAR_GRAPH_STATE)); + + Status = WdfUsbTargetDeviceSendControlTransferSynchronously(DeviceContext->UsbDevice, + WDF_NO_HANDLE, + &SendOptions, + &ControlSetupPacket, + &MemoryDescriptor, + &BytesTransferred); + + if(!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "GetBarGraphState: Failed to GetBarGraphState - 0x%x \n", + Status); + } + else + { + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "GetBarGraphState: LED mask is 0x%x\n", + BarGraphState->BarsAsUChar); + } + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "<-- GetBarGraphState\n"); + + return Status; + +} + + +/*++ + +Routine Description + + This routine sets the state of the bar graph on the board. + +Arguments: + + DeviceContext - One of our device extensions + + BarGraphState - Struct that describes the bar graph's desired state + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +SetBarGraphState( + _In_ PDEVICE_CONTEXT DeviceContext, + _In_ PBAR_GRAPH_STATE BarGraphState + ) +{ + NTSTATUS Status; + WDF_USB_CONTROL_SETUP_PACKET ControlSetupPacket; + WDF_REQUEST_SEND_OPTIONS SendOptions; + WDF_MEMORY_DESCRIPTOR MemoryDescriptor; + ULONG BytesTransferred; + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "--> SetBarGraphState\n"); + + WDF_REQUEST_SEND_OPTIONS_INIT(&SendOptions, + WDF_REQUEST_SEND_OPTION_TIMEOUT); + + WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&SendOptions, + DEFAULT_CONTROL_TRANSFER_TIMEOUT); + + WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&ControlSetupPacket, + BmRequestHostToDevice, + BmRequestToDevice, + USBFX2LK_SET_BARGRAPH_DISPLAY, + 0, + 0); + + WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&MemoryDescriptor, + BarGraphState, + sizeof(BAR_GRAPH_STATE)); + + Status = WdfUsbTargetDeviceSendControlTransferSynchronously(DeviceContext->UsbDevice, + NULL, + &SendOptions, + &ControlSetupPacket, + &MemoryDescriptor, + &BytesTransferred); + + if(!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "SetBarGraphState: Failed - 0x%x \n", + Status); + } + else + { + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "SetBarGraphState: LED mask is 0x%x\n", + BarGraphState->BarsAsUChar); + } + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "<-- SetBarGraphState\n"); + + return Status; +} + + +/*++ + +Routine Description + + This routine gets the state of the 7 segment display on the board + by sending a synchronous control command. + + NOTE: It's not good practice to send a synchronous request in the + context of the user thread because if the transfer takes a long + time to complete, you end up holding the user thread. + + I'm choosing to do synchronous transfer because a) I know this one + completes immediately and b) for demonstration. + +Arguments: + + DeviceContext - One of our device extensions + + SevenSegment - Receives the state of the 7 segment display + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +GetSevenSegmentState( + _In_ PDEVICE_CONTEXT DeviceContext, + _Out_ PUCHAR SevenSegment + ) +{ + NTSTATUS Status; + WDF_USB_CONTROL_SETUP_PACKET ControlSetupPacket; + WDF_REQUEST_SEND_OPTIONS SendOptions; + WDF_MEMORY_DESCRIPTOR MemoryDescriptor; + ULONG BytesTransferred; + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "GetSetSevenSegmentState: Enter\n"); + + PAGED_CODE(); + + WDF_REQUEST_SEND_OPTIONS_INIT(&SendOptions, + WDF_REQUEST_SEND_OPTION_TIMEOUT); + + WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&SendOptions, + DEFAULT_CONTROL_TRANSFER_TIMEOUT); + + WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&ControlSetupPacket, + BmRequestDeviceToHost, + BmRequestToDevice, + USBFX2LK_READ_7SEGMENT_DISPLAY, + 0, + 0); + + // + // Set the buffer to 0, the board will OR in everything that is set. + // + *SevenSegment = 0; + + WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&MemoryDescriptor, + SevenSegment, + sizeof(UCHAR)); + + Status = WdfUsbTargetDeviceSendControlTransferSynchronously(DeviceContext->UsbDevice, + NULL, + &SendOptions, + &ControlSetupPacket, + &MemoryDescriptor, + &BytesTransferred); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "GetSevenSegmentState: Failed to get 7 Segment state - 0x%x \n", + Status); + } + else + { + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "GetSevenSegmentState: 7 Segment mask is 0x%x\n", + *SevenSegment); + } + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "GetSetSevenSegmentState: Exit\n"); + + return Status; +} + + +/*++ + +Routine Description + + This routine sets the state of the 7 segment display on the board. + +Arguments: + + DeviceContext - One of our device extensions + + SevenSegment - Desired state of the 7 segment display + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +SetSevenSegmentState( + _In_ PDEVICE_CONTEXT DeviceContext, + _In_ PUCHAR SevenSegment + ) +{ + NTSTATUS Status; + WDF_USB_CONTROL_SETUP_PACKET ControlSetupPacket; + WDF_REQUEST_SEND_OPTIONS SendOptions; + WDF_MEMORY_DESCRIPTOR MemoryDescriptor; + ULONG BytesTransferred; + + PAGED_CODE(); + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "--> SetSevenSegmentState\n"); + + WDF_REQUEST_SEND_OPTIONS_INIT(&SendOptions, + WDF_REQUEST_SEND_OPTION_TIMEOUT); + + WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&SendOptions, + DEFAULT_CONTROL_TRANSFER_TIMEOUT); + + WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&ControlSetupPacket, + BmRequestHostToDevice, + BmRequestToDevice, + USBFX2LK_SET_7SEGMENT_DISPLAY, + 0, + 0); + + WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&MemoryDescriptor, + SevenSegment, + sizeof(UCHAR)); + + Status = WdfUsbTargetDeviceSendControlTransferSynchronously(DeviceContext->UsbDevice, + NULL, + &SendOptions, + &ControlSetupPacket, + &MemoryDescriptor, + &BytesTransferred); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "SetSevenSegmentState: Failed to set 7 Segment state - 0x%x \n", + Status); + } + else + { + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "SetSevenSegmentState: 7 Segment mask is 0x%x\n", + *SevenSegment); + } + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "<-- SetSevenSegmentState\n"); + + return Status; + +} + + +/*++ + +Routine Description + + This routine gets the state of the switches on the board. + +Arguments: + + DeviceContext - One of our device extensions + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL or another NTSTATUS error code otherwise. + +--*/ +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +GetSwitchState( + _In_ PDEVICE_CONTEXT DeviceContext, + _In_ PSWITCH_STATE SwitchState + ) +{ + NTSTATUS Status; + WDF_USB_CONTROL_SETUP_PACKET ControlSetupPacket; + WDF_REQUEST_SEND_OPTIONS SendOptions; + WDF_MEMORY_DESCRIPTOR MemoryDescriptor; + ULONG BytesTransferred; + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "--> GetSwitchState\n"); + + PAGED_CODE(); + + WDF_REQUEST_SEND_OPTIONS_INIT(&SendOptions, + WDF_REQUEST_SEND_OPTION_TIMEOUT); + + WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&SendOptions, + DEFAULT_CONTROL_TRANSFER_TIMEOUT); + + WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(&ControlSetupPacket, + BmRequestDeviceToHost, + BmRequestToDevice, + USBFX2LK_READ_SWITCHES, + 0, + 0); + + SwitchState->SwitchesAsUChar = 0; + + WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&MemoryDescriptor, + SwitchState, + sizeof(SWITCH_STATE)); + + Status = WdfUsbTargetDeviceSendControlTransferSynchronously(DeviceContext->UsbDevice, + NULL, + &SendOptions, + &ControlSetupPacket, + &MemoryDescriptor, + &BytesTransferred); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "GetSwitchState: Failed to get switches - 0x%x \n", + Status); + } + else + { + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "GetSwitchState: Switch mask is 0x%x\n", + SwitchState->SwitchesAsUChar); + } + + TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, + "<-- GetSwitchState\n"); + + return Status; +} + + +/*++ + +Routine Description + + This method handles the completion of the pending request for the IOCTL + IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE. + +Arguments: + + Device - Handle to a framework device object + +Return Value: + + VOID + +--*/ +VOID +OsrUsbIoctlGetInterruptMessage( + _In_ WDFDEVICE Device, + _In_ NTSTATUS ReaderStatus + ) +{ + NTSTATUS Status; + WDFREQUEST Request; + PDEVICE_CONTEXT DeviceContext; + size_t BytesReturned = 0; + PSWITCH_STATE SwitchState = NULL; + + DeviceContext = GetDeviceContext(Device); + + do + { + // + // Check if there are any pending requests in the Interrupt Message Queue. + // If a request is found then complete the pending request. + // + Status = WdfIoQueueRetrieveNextRequest(DeviceContext->InterruptMsgQueue, + &Request); + + if (NT_SUCCESS(Status)) + { + Status = WdfRequestRetrieveOutputBuffer(Request, + sizeof(SWITCH_STATE), + &SwitchState, + NULL); + + if (!NT_SUCCESS(Status)) + { + TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, + "User's output buffer is too small for this IOCTL, expecting a SWITCH_STATE\n"); + + BytesReturned = sizeof(SWITCH_STATE); + } + else + { + // + // Copy the state information saved by the continuous reader. + // + if (NT_SUCCESS(ReaderStatus)) + { + SwitchState->SwitchesAsUChar = DeviceContext->CurrentSwitchState; + BytesReturned = sizeof(SWITCH_STATE); + } + else + { + BytesReturned = 0; + } + } + + // + // Complete the request. If we failed to get the output buffer then + // complete with that status. Otherwise complete with the Status from the reader. + // + WdfRequestCompleteWithInformation(Request, + NT_SUCCESS(Status) ? ReaderStatus : + Status, + BytesReturned); + + Status = STATUS_SUCCESS; + } + else if (Status != STATUS_NO_MORE_ENTRIES) + { + KdPrint(("WdfIoQueueRetrieveNextRequest Status %08x\n", Status)); + } + + Request = NULL; + + } while (Status == STATUS_SUCCESS); +} + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.Filters b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.Filters new file mode 100644 index 00000000..26fecf1e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.Filters @@ -0,0 +1,302 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {F15AAD6B-59E8-4958-90A3-552BD48EAFE2} + + + h;hpp;hxx;hm;inl;inc;xsd + {4DD84A7D-DF53-4EE0-A484-1352320A6750} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {EF018331-C5CB-4F90-8D54-2EF10F370E8A} + + + inf;inv;inx;mof;mc; + {9A3958FE-0B1F-4C9F-9827-83322770EC8A} + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + Source Files + + + + + + + + + Resource Files + + + + + Header Files + + + + Header Files + + + + Header Files + + + + Header Files + + + + Header Files + + + + Header Files + + + + Header Files + + + + Header Files + + + + Header Files + + + + + + Driver Files + + + \ No newline at end of file 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 new file mode 100644 index 00000000..807337f8 Binary files /dev/null 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 new file mode 100644 index 00000000..838add16 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj @@ -0,0 +1,269 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {5B711254-3F53-4E1D-A1AD-CC81E34588B7} + $(MSBuildProjectName) + 2 + Debug + Win32 + {F915ED95-7BE9-4CDB-B09A-0D3F4C9657FE} + osrfx2_DCHU_base + $(LatestTargetPlatformVersion) + + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + true + true + TraceEvents(LEVEL,FLAGS,MSG,...) + {um-default.tpl}*.tmh + ENABLE_WPP_RECORDER=1;WPP_MACRO_USE_KM_VERSION_FOR_UM=1 + + + true + true + .\$(IntDir) + true + .\$(IntDir) + true + fx2Events + true + Designer + + + + osrfx2_DCHU_base + 1 + false + + + osrfx2_DCHU_base + 1 + false + + + osrfx2_DCHU_base + 1 + false + + + osrfx2_DCHU_base + 1 + false + + + + true + Level4 + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + true + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + + + 1.0.0.0 + + + + + true + Level4 + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + true + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + + + 1.0.0.0 + + + + + true + Level4 + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + true + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + + + 1.0.0.0 + + + + + true + Level4 + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + true + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);..\inc + %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + + + 1.0.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h new file mode 100644 index 00000000..1452aebf --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.h @@ -0,0 +1,312 @@ +/*++ + +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: + + osrusbfx2.h + +Abstract: + + Contains structure definitions and function prototypes private to + the driver. + +Environment: + + User mode + +--*/ + +#include +#include +#pragma warning( disable: 4201 ) // nonstandard extension used : nameless struct/union +#include +#include +#include +#include +#include +typedef struct _IO_STACK_LOCATION *PIO_STACK_LOCATION; +#include +#include +#include +#include +#include +#include +#include + +#include "public.h" + +// +// Include auto-generated ETW event functions (created by MC.EXE from +// osrusbfx2.man) +// +#include +#include "fx2Events.h" + +#ifndef _PRIVATE_H +#define _PRIVATE_H + +#define POOL_TAG (ULONG) 'FRSO' +#define _DRIVER_NAME_ "OSRUSBFX2" + +#define TEST_BOARD_TRANSFER_BUFFER_SIZE (64*1024) +#define DEVICE_DESC_LENGTH 256 + +extern const __declspec(selectany) LONGLONG DEFAULT_CONTROL_TRANSFER_TIMEOUT = 5 * -1 * WDF_TIMEOUT_TO_SEC; + +// +// Define the vendor commands supported by our device +// +#define USBFX2LK_READ_7SEGMENT_DISPLAY 0xD4 +#define USBFX2LK_READ_SWITCHES 0xD6 +#define USBFX2LK_READ_BARGRAPH_DISPLAY 0xD7 +#define USBFX2LK_SET_BARGRAPH_DISPLAY 0xD8 +#define USBFX2LK_IS_HIGH_SPEED 0xD9 +#define USBFX2LK_REENUMERATE 0xDA +#define USBFX2LK_SET_7SEGMENT_DISPLAY 0xDB + +// +// Define the features that we can clear +// and set on our device +// +#define USBFX2LK_FEATURE_EPSTALL 0x00 +#define USBFX2LK_FEATURE_WAKE 0x01 + +// +// Order of endpoints in the interface descriptor +// +#define INTERRUPT_IN_ENDPOINT_INDEX 0 +#define BULK_OUT_ENDPOINT_INDEX 1 +#define BULK_IN_ENDPOINT_INDEX 2 + +// +// A structure representing the instance information associated with +// this particular device. +// + +typedef struct _DEVICE_CONTEXT { + + WDFUSBDEVICE UsbDevice; + + WDFUSBINTERFACE UsbInterface; + + WDFUSBPIPE BulkReadPipe; + + WDFUSBPIPE BulkWritePipe; + + WDFUSBPIPE InterruptPipe; + + WDFWAITLOCK ResetDeviceWaitLock; + + UCHAR CurrentSwitchState; + + WDFQUEUE InterruptMsgQueue; + + ULONG UsbDeviceTraits; + + // + // The following fields are used during event logging to + // report the events relative to this specific instance + // of the device. + // + + WDFMEMORY DeviceNameMemory; + PCWSTR DeviceName; + + WDFMEMORY LocationMemory; + PCWSTR Location; + +} DEVICE_CONTEXT, *PDEVICE_CONTEXT; + +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, GetDeviceContext) + +extern ULONG DebugLevel; + +typedef +NTSTATUS +(*PFN_IO_GET_ACTIVITY_ID_IRP) ( + _In_ PIRP Irp, + _Out_ LPGUID Guid + ); + +typedef +NTSTATUS +(*PFN_IO_SET_DEVICE_INTERFACE_PROPERTY_DATA) ( + _In_ PUNICODE_STRING SymbolicLinkName, + _In_ CONST DEVPROPKEY *PropertyKey, + _In_ LCID Lcid, + _In_ ULONG Flags, + _In_ DEVPROPTYPE Type, + _In_ ULONG Size, + _In_opt_ PVOID Data + ); + +DRIVER_INITIALIZE DriverEntry; + +EVT_WDF_OBJECT_CONTEXT_CLEANUP OsrFxEvtDriverContextCleanup; + +EVT_WDF_DRIVER_DEVICE_ADD OsrFxEvtDeviceAdd; + +EVT_WDF_DEVICE_PREPARE_HARDWARE OsrFxEvtDevicePrepareHardware; + +EVT_WDF_IO_QUEUE_IO_READ OsrFxEvtIoRead; + +EVT_WDF_IO_QUEUE_IO_WRITE OsrFxEvtIoWrite; + +EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL OsrFxEvtIoDeviceControl; + +EVT_WDF_REQUEST_COMPLETION_ROUTINE EvtRequestReadCompletionRoutine; + +EVT_WDF_REQUEST_COMPLETION_ROUTINE EvtRequestWriteCompletionRoutine; + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +ResetPipe( + _In_ WDFUSBPIPE Pipe + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +ResetDevice( + _In_ WDFDEVICE Device + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +SelectInterfaces( + _In_ WDFDEVICE Device + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +ReenumerateDevice( + _In_ PDEVICE_CONTEXT DevContext + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +GetBarGraphState( + _In_ PDEVICE_CONTEXT DevContext, + _Out_ PBAR_GRAPH_STATE BarGraphState + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +SetBarGraphState( + _In_ PDEVICE_CONTEXT DevContext, + _In_ PBAR_GRAPH_STATE BarGraphState + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +GetSevenSegmentState( + _In_ PDEVICE_CONTEXT DevContext, + _Out_ PUCHAR SevenSegment + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +SetSevenSegmentState( + _In_ PDEVICE_CONTEXT DevContext, + _In_ PUCHAR SevenSegment + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +GetSwitchState( + _In_ PDEVICE_CONTEXT DevContext, + _In_ PSWITCH_STATE SwitchState + ); + +VOID +OsrUsbIoctlGetInterruptMessage( + _In_ WDFDEVICE Device, + _In_ NTSTATUS ReaderStatus + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +OsrFxSetPowerPolicy( + _In_ WDFDEVICE Device + ); + +_IRQL_requires_(PASSIVE_LEVEL) +NTSTATUS +OsrFxConfigContReaderForInterruptEndPoint( + _In_ PDEVICE_CONTEXT DeviceContext + ); + +EVT_WDF_USB_READER_COMPLETION_ROUTINE OsrFxEvtUsbInterruptPipeReadComplete; + +EVT_WDF_USB_READERS_FAILED OsrFxEvtUsbInterruptReadersFailed; + +EVT_WDF_IO_QUEUE_IO_STOP OsrFxEvtIoStop; + +EVT_WDF_DEVICE_D0_ENTRY OsrFxEvtDeviceD0Entry; + +EVT_WDF_DEVICE_D0_EXIT OsrFxEvtDeviceD0Exit; + +EVT_WDF_DEVICE_SELF_MANAGED_IO_FLUSH OsrFxEvtDeviceSelfManagedIoFlush; + +_IRQL_requires_(PASSIVE_LEVEL) +BOOLEAN +OsrFxReadFdoRegistryKeyValue( + _In_ PWDFDEVICE_INIT DeviceInit, + _In_ PWCHAR Name, + _Out_ PULONG Value + ); + +_IRQL_requires_max_(DISPATCH_LEVEL) +VOID +OsrFxEnumerateChildren( + _In_ WDFDEVICE Device + ); + +_IRQL_requires_(PASSIVE_LEVEL) +VOID +GetDeviceEventLoggingNames( + _In_ WDFDEVICE Device + ); + +_IRQL_requires_(PASSIVE_LEVEL) +PCHAR +DbgDevicePowerString( + _In_ WDF_POWER_DEVICE_STATE Type + ); + +FORCEINLINE +GUID +RequestToActivityId( + _In_ WDFREQUEST Request + ) +{ + GUID activity = {0}; + + // + // Use the WDFREQUEST handle as the activity ID + // + RtlCopyMemory(&activity, &Request, sizeof(WDFREQUEST)); + + return activity; +} + +FORCEINLINE +GUID +DeviceToActivityId( + _In_ WDFDEVICE Device + ) +{ + GUID activity = {0}; + RtlCopyMemory(&activity, &Device, sizeof(WDFDEVICE)); + return activity; +} + + +#endif + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.man b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.man new file mode 100644 index 00000000..19f363d5 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.man @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.rc b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.rc new file mode 100644 index 00000000..84f89a6c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrusbfx2.rc @@ -0,0 +1,13 @@ +#include + +#include + +#define VER_FILETYPE VFT_DLL +#define VER_FILESUBTYPE VFT_UNKNOWN +#define VER_FILEDESCRIPTION_STR "WDF Sample Driver for OSR USB-FX2 Learning Kit" +#define VER_INTERNALNAME_STR "osrusbfx2um.dll" +#define VER_ORIGINALFILENAME_STR "osrusbfx2um.dll" + +#include "common.ver" + +#include "fx2Events.rc" diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/trace.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/trace.h new file mode 100644 index 00000000..5a72dcaf --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/trace.h @@ -0,0 +1,115 @@ +/*++ + +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: + + TRACE.h + +Abstract: + + Header file for the debug tracing related function defintions and macros. + +Environment: + + Kernel mode + +--*/ + +#include // For TRACE_LEVEL definitions + +#if !defined(EVENT_TRACING) + +// +// TODO: These defines are missing in evntrace.h +// in some DDK build environments (XP). +// +#if !defined(TRACE_LEVEL_NONE) + #define TRACE_LEVEL_NONE 0 + #define TRACE_LEVEL_CRITICAL 1 + #define TRACE_LEVEL_FATAL 1 + #define TRACE_LEVEL_ERROR 2 + #define TRACE_LEVEL_WARNING 3 + #define TRACE_LEVEL_INFORMATION 4 + #define TRACE_LEVEL_VERBOSE 5 + #define TRACE_LEVEL_RESERVED6 6 + #define TRACE_LEVEL_RESERVED7 7 + #define TRACE_LEVEL_RESERVED8 8 + #define TRACE_LEVEL_RESERVED9 9 +#endif + + +// +// Define Debug Flags +// +#define DBG_INIT 0x00000001 +#define DBG_PNP 0x00000002 +#define DBG_POWER 0x00000004 +#define DBG_WMI 0x00000008 +#define DBG_CREATE_CLOSE 0x00000010 +#define DBG_IOCTL 0x00000020 +#define DBG_WRITE 0x00000040 +#define DBG_READ 0x00000080 + + +VOID +TraceEvents ( + _In_ ULONG DebugPrintLevel, + _In_ ULONG DebugPrintFlag, + _Printf_format_string_ + _In_ PCSTR DebugMessage, + ... + ); + +#define WPP_INIT_TRACING(RegistryPath) +#define WPP_CLEANUP() + +#else +// +// If software tracing is defined in the sources file.. +// WPP_DEFINE_CONTROL_GUID specifies the GUID used for this driver. +// *** REPLACE THE GUID WITH YOUR OWN UNIQUE ID *** +// WPP_DEFINE_BIT allows setting debug bit masks to selectively print. +// The names defined in the WPP_DEFINE_BIT call define the actual names +// that are used to control the level of tracing for the control guid +// specified. +// +// NOTE: If you are adopting this sample for your driver, please generate +// a new guid, using tools\other\i386\guidgen.exe present in the +// DDK. +// +// Name of the logger is OSRUSBFX2 and the guid is +// {D23A0C5A-D307-4f0e-AE8E-E2A355AD5DAB} +// (0xd23a0c5a, 0xd307, 0x4f0e, 0xae, 0x8e, 0xe2, 0xa3, 0x55, 0xad, 0x5d, 0xab); +// + +#define WPP_CHECK_FOR_NULL_STRING //to prevent exceptions due to NULL strings + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID(OsrUsbFxTraceGuid,(d23a0c5a,d307,4f0e,ae8e,E2A355AD5DAB), \ + WPP_DEFINE_BIT(DBG_INIT) /* bit 0 = 0x00000001 */ \ + WPP_DEFINE_BIT(DBG_PNP) /* bit 1 = 0x00000002 */ \ + WPP_DEFINE_BIT(DBG_POWER) /* bit 2 = 0x00000004 */ \ + WPP_DEFINE_BIT(DBG_WMI) /* bit 3 = 0x00000008 */ \ + WPP_DEFINE_BIT(DBG_CREATE_CLOSE) /* bit 4 = 0x00000010 */ \ + WPP_DEFINE_BIT(DBG_IOCTL) /* bit 5 = 0x00000020 */ \ + WPP_DEFINE_BIT(DBG_WRITE) /* bit 6 = 0x00000040 */ \ + WPP_DEFINE_BIT(DBG_READ) /* bit 7 = 0x00000080 */ \ + /* You can have up to 32 defines. If you want more than that,\ + you have to provide another trace control GUID */\ + ) + + +#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) WPP_LEVEL_LOGGER(flags) +#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) + + +#endif + + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.c new file mode 100644 index 00000000..3e41778e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.c @@ -0,0 +1,421 @@ +/*++ + +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: + + filter.c + +Abstract: + + This module shows how to a write a generic filter driver. The driver demonstrates how + to support device I/O control requests through queues. All I/O requests are passed on to + the lower driver. This filter driver shows how to handle IRP postprocessing by forwarding + the requests with and without a completion routine. To forward with a completion routine + set the define FORWARD_REQUEST_WITH_COMPLETION to 1. + +Environment: + + User mode + +--*/ + +#include "filter.h" + + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (INIT, DriverEntry) +#pragma alloc_text (PAGE, FilterEvtDeviceAdd) +#endif + + +/*++ + +Routine Description: + + Installable driver initialization entry point. + This entry point is called directly by the I/O system. + +Arguments: + + DriverObject - Pointer to the driver object + + RegistryPath - Pointer to a unicode string representing the path + to the driver-specific key in the registry. + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL otherwise. + +--*/ +NTSTATUS +DriverEntry( + IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegistryPath + ) +{ + WDF_DRIVER_CONFIG Config; + NTSTATUS Status; + WDFDRIVER hDriver; + + KdPrint(("Generic Upper Filter Driver Sample - Driver Framework Edition.\n")); + + // + // Initialize driver config to control the attributes that + // are global to the driver. Note that the framework by default + // provides a driver unload routine. If you created any resources + // in DriverEntry and want them to be cleaned up when the driver unloads, + // you can override that by manually setting the EvtDriverUnload in the + // config structure. In general xxx_CONFIG_INIT macros are provided to + // initialize most commonly used members. + // + + WDF_DRIVER_CONFIG_INIT(&Config, + FilterEvtDeviceAdd); + + // + // Create a framework driver object to represent our driver. + // + Status = WdfDriverCreate(DriverObject, + RegistryPath, + WDF_NO_OBJECT_ATTRIBUTES, + &Config, + &hDriver); + + if (!NT_SUCCESS(Status)) + { + KdPrint(("WdfDriverCreate failed with status 0x%x\n", Status)); + } + + return Status; +} + + +/*++ +Routine Description: + + EvtDeviceAdd is called by the framework in response to the AddDevice + call from the PnP manager. Here you can query the device properties + using WdfFdoInitWdmGetPhysicalDevice/IoGetDeviceProperty and based + on that, decide to create a filter device object and attach it to the + function stack. If you are not interested in filtering this particular + instance of the device, you can just return STATUS_SUCCESS without creating + a framework device. + +Arguments: + + Driver - Handle to a framework driver object created in DriverEntry + + DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure. + +Return Value: + + NTSTATUS + +--*/ +NTSTATUS +FilterEvtDeviceAdd( + IN WDFDRIVER Driver, + IN PWDFDEVICE_INIT DeviceInit + ) +{ + WDF_OBJECT_ATTRIBUTES DeviceAttributes; + PFILTER_EXTENSION FilterExt; + NTSTATUS Status; + WDFDEVICE Device; + WDF_IO_QUEUE_CONFIG IoQueueConfig; + + PAGED_CODE (); + + UNREFERENCED_PARAMETER(Driver); + + // + // Tell the framework that you are a filter driver. The framework + // takes care of inherting all the device flags & characteristics + // from the higher device that you are attaching to. + // + WdfFdoInitSetFilter(DeviceInit); + + // + // Specify the size of the device extension where we track per device + // context. + // + + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&DeviceAttributes, FILTER_EXTENSION); + + // + // Create a framework device object. This call will in turn create + // a WDM device object, attach it to the lower stack, and set the + // appropriate flags and attributes. + // + Status = WdfDeviceCreate(&DeviceInit, &DeviceAttributes, &Device); + + if (!NT_SUCCESS(Status)) + { + KdPrint(("WdfDeviceCreate failed with status code 0x%x\n", Status)); + return Status; + } + + FilterExt = FilterGetData(Device); + + // + // Configure the default queue to be Parallel. + // + WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&IoQueueConfig, + WdfIoQueueDispatchParallel); + + // + // The framework by default creates non-power managed queues for + // filter drivers. + // + IoQueueConfig.EvtIoDeviceControl = FilterEvtIoDeviceControl; + + Status = WdfIoQueueCreate(Device, + &IoQueueConfig, + WDF_NO_OBJECT_ATTRIBUTES, + WDF_NO_HANDLE // Pointer to default queue + ); + + if (!NT_SUCCESS(Status)) + { + KdPrint(("WdfIoQueueCreate failed 0x%x\n", Status)); + return Status; + } + + return Status; +} + + +/*++ + +Routine Description: + + This routine is the dispatch routine for internal device control requests. + +Arguments: + + Queue - Handle to the framework queue object that is associated + with the I/O request + + Request - Handle to a framework request object + + OutputBufferLength - Length of the request's output buffer, + if an output buffer is available + + InputBufferLength - Length of the request's input buffer, + if an input buffer is available + + IoControlCode - The driver-defined or system-defined I/O control code + (IOCTL) that is associated with the request + +Return Value: + + VOID + +--*/ +VOID +FilterEvtIoDeviceControl( + IN WDFQUEUE Queue, + IN WDFREQUEST Request, + IN size_t OutputBufferLength, + IN size_t InputBufferLength, + IN ULONG IoControlCode + ) +{ + PFILTER_EXTENSION FilterExt; + NTSTATUS Status = STATUS_SUCCESS; + WDFDEVICE Device; + + UNREFERENCED_PARAMETER(OutputBufferLength); + UNREFERENCED_PARAMETER(InputBufferLength); + + KdPrint(("Entered FilterEvtIoDeviceControl\n")); + + Device = WdfIoQueueGetDevice(Queue); + + FilterExt = FilterGetData(Device); + + switch (IoControlCode) + { + + // + // Put your cases for handling IOCTLs here + // + + default: + Status = STATUS_SUCCESS; + } + + if (!NT_SUCCESS(Status)) + { + WdfRequestComplete(Request, Status); + return; + } + + // + // Forward the request down. WdfDeviceGetIoTarget returns + // the default target, which represents the device attached to us below in + // the stack. + // +#if FORWARD_REQUEST_WITH_COMPLETION + // + // Use this routine to forward a request if you are interested in post + // processing the IRP. + // + FilterForwardRequestWithCompletionRoutine(Request, + WdfDeviceGetIoTarget(Device)); +#else + FilterForwardRequest(Request, WdfDeviceGetIoTarget(Device)); +#endif + + return; +} + + +/*++ +Routine Description: + + Passes a request on to the lower driver. + +Arguments: + + Request - The request to pass on to the lower driver + + Target - The lower driver to pass the request to + +Return Value: + + VOID + +--*/ +VOID +FilterForwardRequest( + IN WDFREQUEST Request, + IN WDFIOTARGET Target + ) +{ + WDF_REQUEST_SEND_OPTIONS Options; + BOOLEAN RequestSent; + NTSTATUS Status; + + // + // We are not interested in post processing the IRP so + // fire and forget. + // + WDF_REQUEST_SEND_OPTIONS_INIT(&Options, + WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET); + + RequestSent = WdfRequestSend(Request, Target, &Options); + + if (RequestSent == FALSE) { + Status = WdfRequestGetStatus(Request); + KdPrint(("WdfRequestSend failed: 0x%x\n", Status)); + WdfRequestComplete(Request, Status); + } + + return; +} + +#if FORWARD_REQUEST_WITH_COMPLETION + +VOID +FilterForwardRequestWithCompletionRoutine( + IN WDFREQUEST Request, + IN WDFIOTARGET Target + ) +/*++ +Routine Description: + + This routine forwards the request to a lower driver with + a completion so that when the request is completed by the + lower driver, it can regain control of the request and look + at the result. + +Arguments: + + Request - The request to pass on to the lower driver + + Target - The lower driver to pass the request to + +Return Value: + + VOID + +--*/ +{ + BOOLEAN RequestSent; + NTSTATUS Status; + + // + // The following function essentially copies the content of the + // current stack location of the underlying IRP to the next one. + // + WdfRequestFormatRequestUsingCurrentType(Request); + + WdfRequestSetCompletionRoutine(Request, + FilterRequestCompletionRoutine, + WDF_NO_CONTEXT); + + RequestSent = WdfRequestSend(Request, + Target, + WDF_NO_SEND_OPTIONS); + + if (RequestSent == FALSE) + { + Status = WdfRequestGetStatus(Request); + KdPrint(("WdfRequestSend failed: 0x%x\n", Status)); + WdfRequestComplete(Request, Status); + } + + return; +} + + +/*++ + +Routine Description: + + Completion Routine. + +Arguments: + + Target - Target handle + + Request - Request handle + + Params - Request completion params + + Context - Driver supplied context + +Return Value: + + VOID + +--*/ +VOID +FilterRequestCompletionRoutine( + IN WDFREQUEST Request, + IN WDFIOTARGET Target, + PWDF_REQUEST_COMPLETION_PARAMS CompletionParams, + IN WDFCONTEXT Context + ) +{ + UNREFERENCED_PARAMETER(Target); + UNREFERENCED_PARAMETER(Context); + + WdfRequestComplete(Request, CompletionParams->IoStatus.Status); + + return; +} + +#endif //FORWARD_REQUEST_WITH_COMPLETION + + + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.h new file mode 100644 index 00000000..e9042c29 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.h @@ -0,0 +1,85 @@ +/*++ + +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: + + filter.h + +Abstract: + + Contains structure definitions and function prototypes for a generic filter driver. + +Environment: + + User mode + +--*/ + +#include +#include +#pragma warning( disable: 4201 ) // nonstandard extension used : nameless struct/union +#include +#include +#include +#include + +#if !defined(_FILTER_H_) +#define _FILTER_H_ + + +#define DRIVERNAME "Generic.sys: " + +// +// Change the following define to 1 if you want to forward +// the request with a completion routine. +// +#define FORWARD_REQUEST_WITH_COMPLETION 0 + + +typedef struct _FILTER_EXTENSION +{ + WDFDEVICE WdfDevice; + // More context data here + +}FILTER_EXTENSION, *PFILTER_EXTENSION; + + +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FILTER_EXTENSION, + FilterGetData) + +DRIVER_INITIALIZE DriverEntry; +EVT_WDF_DRIVER_DEVICE_ADD FilterEvtDeviceAdd; +EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL FilterEvtIoDeviceControl; + +VOID +FilterForwardRequest( + IN WDFREQUEST Request, + IN WDFIOTARGET Target + ); + +#if FORWARD_REQUEST_WITH_COMPLETION + +VOID +FilterForwardRequestWithCompletionRoutine( + IN WDFREQUEST Request, + IN WDFIOTARGET Target + ); + +VOID +FilterRequestCompletionRoutine( + IN WDFREQUEST Request, + IN WDFIOTARGET Target, + PWDF_REQUEST_COMPLETION_PARAMS CompletionParams, + IN WDFCONTEXT Context + ); + +#endif //FORWARD_REQUEST_WITH_COMPLETION + +#endif + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.rc b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.rc new file mode 100644 index 00000000..0c108f44 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/filter.rc @@ -0,0 +1,12 @@ +#include +#include +#include + +#define VER_FILETYPE VFT_DLL +#define VER_FILESUBTYPE VFT_UNKNOWN +#define VER_FILEDESCRIPTION_STR "UMDF 2.0 Filter Driver for the Toaster Stack" +#define VER_INTERNALNAME_STR DRIVERNAME +#define VER_ORIGINALFILENAME_STR DRIVERNAME + +#include "common.ver" + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.Filters b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.Filters new file mode 100644 index 00000000..2e7de4fc --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.Filters @@ -0,0 +1,31 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {B98D4FD9-00A8-4964-AE34-6AF1F833564B} + + + h;hpp;hxx;hm;inl;inc;xsd + {30413FCB-C550-4E4B-85F0-F39789145A19} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {D54A0D65-9B62-45F4-8B43-F92BC9FF355C} + + + inf;inv;inx;mof;mc; + {71F51C61-8117-4556-90E5-DE06697F59D6} + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj new file mode 100644 index 00000000..0ef42141 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj @@ -0,0 +1,186 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {3CC42473-D121-41F4-AE26-1F2F0AC65E82} + $(MSBuildProjectName) + 2 + false + true + Debug + Win32 + {1A4A32BA-1596-4F52-BC48-B85A6D8D5D12} + $(LatestTargetPlatformVersion) + osrfx2_DCHU_filter + + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + + $(SolutionDir)$(Platform)\$(ConfigurationName)\ + + + + + + + + + + + + + + + $(ProjectName) + + + $(ProjectName) + .dll + + + $(ProjectName) + + + $(ProjectName) + + + + true + Level4 + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib + + + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalIncludeDirectories);..\..\inc + + + + + true + Level4 + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(AdditionalDependencies);$(SDK_LIB_PATH)onecore.lib + + + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalIncludeDirectories);..\..\inc + + + + + true + Level4 + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib + + + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalIncludeDirectories);..\..\inc + + + + + true + Level4 + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(AdditionalDependencies);$(SDK_LIB_PATH)onecore.lib + + + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalIncludeDirectories);..\..\inc + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/dump.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/dump.c new file mode 100644 index 00000000..69074bf1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/dump.c @@ -0,0 +1,444 @@ +/*++ + +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: + + DUMP.C + +Abstract: + + Routines to dump the descriptors information in a human readable form. + +Environment: + + user mode only + +--*/ + +#include +#include +#include +#include "devioctl.h" + +#pragma warning(disable:4200) // +#pragma warning(disable:4201) // nameless struct/union +#pragma warning(disable:4214) // bit field types other than int + +#include +#include "usbdi.h" +#include "public.h" + +#pragma warning(default:4200) +#pragma warning(default:4201) +#pragma warning(default:4214) + +HANDLE +OpenDevice( + _In_ BOOL Synchronous + ); + + +char* +usbDescriptorTypeString(UCHAR bDescriptorType ) +/*++ +Routine Description: + + Called to get ascii string of USB descriptor + +Arguments: + + PUSB_ENDPOINT_DESCRIPTOR->bDescriptorType or + PUSB_DEVICE_DESCRIPTOR->bDescriptorType or + PUSB_INTERFACE_DESCRIPTOR->bDescriptorType or + PUSB_STRING_DESCRIPTOR->bDescriptorType or + PUSB_POWER_DESCRIPTOR->bDescriptorType or + PUSB_CONFIGURATION_DESCRIPTOR->bDescriptorType + +Return Value: + + ptr to string + +--*/ +{ + + switch(bDescriptorType) { + + case USB_DEVICE_DESCRIPTOR_TYPE: + return "USB_DEVICE_DESCRIPTOR_TYPE"; + + case USB_CONFIGURATION_DESCRIPTOR_TYPE: + return "USB_CONFIGURATION_DESCRIPTOR_TYPE"; + + + case USB_STRING_DESCRIPTOR_TYPE: + return "USB_STRING_DESCRIPTOR_TYPE"; + + + case USB_INTERFACE_DESCRIPTOR_TYPE: + return "USB_INTERFACE_DESCRIPTOR_TYPE"; + + + case USB_ENDPOINT_DESCRIPTOR_TYPE: + return "USB_ENDPOINT_DESCRIPTOR_TYPE"; + + +#ifdef USB_POWER_DESCRIPTOR_TYPE // this is the older definintion which is actually obsolete + // workaround for temporary bug in 98ddk, older USB100.h file + case USB_POWER_DESCRIPTOR_TYPE: + return "USB_POWER_DESCRIPTOR_TYPE"; +#endif + +#ifdef USB_RESERVED_DESCRIPTOR_TYPE // this is the current version of USB100.h as in NT5DDK + + case USB_RESERVED_DESCRIPTOR_TYPE: + return "USB_RESERVED_DESCRIPTOR_TYPE"; + + case USB_CONFIG_POWER_DESCRIPTOR_TYPE: + return "USB_CONFIG_POWER_DESCRIPTOR_TYPE"; + + case USB_INTERFACE_POWER_DESCRIPTOR_TYPE: + return "USB_INTERFACE_POWER_DESCRIPTOR_TYPE"; +#endif // for current nt5ddk version of USB100.h + + default: + return "??? UNKNOWN!!"; + } +} + + +char * +usbEndPointTypeString(UCHAR bmAttributes) +/*++ +Routine Description: + + Called to get ascii string of endpt descriptor type + +Arguments: + + PUSB_ENDPOINT_DESCRIPTOR->bmAttributes + +Return Value: + + ptr to string + +--*/ +{ + UINT typ = bmAttributes & USB_ENDPOINT_TYPE_MASK; + + + switch( typ) { + case USB_ENDPOINT_TYPE_INTERRUPT: + return "USB_ENDPOINT_TYPE_INTERRUPT"; + + case USB_ENDPOINT_TYPE_BULK: + return "USB_ENDPOINT_TYPE_BULK"; + + case USB_ENDPOINT_TYPE_ISOCHRONOUS: + return "USB_ENDPOINT_TYPE_ISOCHRONOUS"; + + case USB_ENDPOINT_TYPE_CONTROL: + return "USB_ENDPOINT_TYPE_CONTROL"; + + default: + return "??? UNKNOWN!!"; + } +} + + +char * +usbConfigAttributesString(UCHAR bmAttributes) +/*++ +Routine Description: + + Called to get ascii string of USB_CONFIGURATION_DESCRIPTOR attributes + +Arguments: + + PUSB_CONFIGURATION_DESCRIPTOR->bmAttributes + +Return Value: + + ptr to string + +--*/ +{ + UINT typ = bmAttributes & USB_CONFIG_POWERED_MASK; + + + switch( typ) { + + case USB_CONFIG_BUS_POWERED: + return "USB_CONFIG_BUS_POWERED"; + + case USB_CONFIG_SELF_POWERED: + return "USB_CONFIG_SELF_POWERED"; + + case USB_CONFIG_REMOTE_WAKEUP: + return "USB_CONFIG_REMOTE_WAKEUP"; + + + default: + return "??? UNKNOWN!!"; + } +} + + +void +print_USB_CONFIGURATION_DESCRIPTOR(PUSB_CONFIGURATION_DESCRIPTOR cd) +/*++ +Routine Description: + + Called to do formatted ascii dump to console of a USB config descriptor + +Arguments: + + ptr to USB configuration descriptor + +Return Value: + + none + +--*/ +{ + printf("\n===================\nUSB_CONFIGURATION_DESCRIPTOR\n"); + + printf( + "bLength = 0x%x, decimal %d\n", cd->bLength, cd->bLength + ); + + printf( + "bDescriptorType = 0x%x ( %s )\n", cd->bDescriptorType, + usbDescriptorTypeString( cd->bDescriptorType ) + ); + + printf( + "wTotalLength = 0x%x, decimal %d\n", cd->wTotalLength, cd->wTotalLength + ); + + printf( + "bNumInterfaces = 0x%x, decimal %d\n", cd->bNumInterfaces, cd->bNumInterfaces + ); + + printf( + "bConfigurationValue = 0x%x, decimal %d\n", + cd->bConfigurationValue, cd->bConfigurationValue + ); + + printf( + "iConfiguration = 0x%x, decimal %d\n", cd->iConfiguration, cd->iConfiguration + ); + + printf( + "bmAttributes = 0x%x ( %s )\n", cd->bmAttributes, + usbConfigAttributesString( cd->bmAttributes ) + ); + + printf( + "MaxPower = 0x%x, decimal %d\n", cd->MaxPower, cd->MaxPower + ); +} + + +void +print_USB_INTERFACE_DESCRIPTOR(PUSB_INTERFACE_DESCRIPTOR id, UINT ix) +/*++ +Routine Description: + + Called to do formatted ascii dump to console of a USB interface descriptor + +Arguments: + + ptr to USB interface descriptor + +Return Value: + + none + +--*/ +{ + printf("\n-----------------------------\nUSB_INTERFACE_DESCRIPTOR #%d\n", ix); + + + printf( + "bLength = 0x%x\n", id->bLength + ); + + + printf( + "bDescriptorType = 0x%x ( %s )\n", id->bDescriptorType, + usbDescriptorTypeString( id->bDescriptorType ) + ); + + + printf( + "bInterfaceNumber = 0x%x\n", id->bInterfaceNumber + ); + printf( + "bAlternateSetting = 0x%x\n", id->bAlternateSetting + ); + printf( + "bNumEndpoints = 0x%x\n", id->bNumEndpoints + ); + printf( + "bInterfaceClass = 0x%x\n", id->bInterfaceClass + ); + printf( + "bInterfaceSubClass = 0x%x\n", id->bInterfaceSubClass + ); + printf( + "bInterfaceProtocol = 0x%x\n", id->bInterfaceProtocol + ); + printf( + "bInterface = 0x%x\n", id->iInterface + ); +} + + +void +print_USB_ENDPOINT_DESCRIPTOR(PUSB_ENDPOINT_DESCRIPTOR ed, int i) +/*++ +Routine Description: + + Called to do formatted ascii dump to console of a USB endpoint descriptor + +Arguments: + + ptr to USB endpoint descriptor, + index of this endpt in interface desc + +Return Value: + + none + +--*/ +{ + printf( + "------------------------------\nUSB_ENDPOINT_DESCRIPTOR for Pipe%02d\n", i + ); + + printf( + "bLength = 0x%x\n", ed->bLength + ); + + printf( + "bDescriptorType = 0x%x ( %s )\n", ed->bDescriptorType, + usbDescriptorTypeString( ed->bDescriptorType ) + ); + + if ( USB_ENDPOINT_DIRECTION_IN( ed->bEndpointAddress ) ) { + printf( + "bEndpointAddress= 0x%x ( INPUT )\n", ed->bEndpointAddress + ); + } else { + printf( + "bEndpointAddress= 0x%x ( OUTPUT )\n", ed->bEndpointAddress + ); + } + + printf( + "bmAttributes= 0x%x ( %s )\n", ed->bmAttributes, + usbEndPointTypeString ( ed->bmAttributes ) + ); + + printf( + "wMaxPacketSize= 0x%x, decimal %d\n", ed->wMaxPacketSize, + ed->wMaxPacketSize + ); + + printf( + "bInterval = 0x%x, decimal %d\n", ed->bInterval, ed->bInterval + ); +} + + +BOOL +DumpUsbConfig() +/*++ +Routine Description: + + Called to do formatted ascii dump to console of USB + configuration, interface, and endpoint descriptors. + +Arguments: + + none + +Return Value: + + TRUE or FALSE + +--*/ +{ + HANDLE hDev; + UINT success; + int siz, nBytes; + char buf[256] = {'\0'}; + + hDev = OpenDevice(TRUE); + if(hDev == INVALID_HANDLE_VALUE) + { + return FALSE; + } + + siz = sizeof(buf); + + success = DeviceIoControl(hDev, + IOCTL_OSRUSBFX2_GET_CONFIG_DESCRIPTOR, + buf, + siz, + buf, + siz, + (PULONG) &nBytes, + NULL); + + if(success == FALSE) { + printf("Ioct - GetConfigDesc failed %d\n", GetLastError()); + } else { + + ULONG i; + UINT j, n; + char *pch; + PUSB_CONFIGURATION_DESCRIPTOR cd; + PUSB_INTERFACE_DESCRIPTOR id; + PUSB_ENDPOINT_DESCRIPTOR ed; + + pch = buf; + n = 0; + + cd = (PUSB_CONFIGURATION_DESCRIPTOR) pch; + + print_USB_CONFIGURATION_DESCRIPTOR( cd ); + + pch += cd->bLength; + + do { + id = (PUSB_INTERFACE_DESCRIPTOR) pch; + + print_USB_INTERFACE_DESCRIPTOR(id, n++); + + pch += id->bLength; + for (j=0; jbNumEndpoints; j++) { + + ed = (PUSB_ENDPOINT_DESCRIPTOR) pch; + + print_USB_ENDPOINT_DESCRIPTOR(ed,j); + + pch += ed->bLength; + } + i = (ULONG)(pch - buf); + + } while (iwTotalLength); + } + + CloseHandle(hDev); + + return success; + +} + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.Filters b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.Filters new file mode 100644 index 00000000..f9efc3e3 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.Filters @@ -0,0 +1,30 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {D5BFAD22-1AD2-44F8-AC33-05C04A9C26D9} + + + h;hpp;hxx;hm;inl;inc;xsd + {14E678C7-EAC3-42F6-9F4B-2CDD17427D73} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {CEE0A75C-90B6-472A-8FC1-9375F1EAD2C9} + + + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.vcxproj new file mode 100644 index 00000000..49932df1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrfx2_DCHU_testapp.vcxproj @@ -0,0 +1,193 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {6EED5CDD-5526-40DC-97F9-582857E10187} + $(MSBuildProjectName) + Debug + Win32 + {F19E45AF-8B05-4204-A66B-9BDBFE333233} + osrfx2_DCHU_testapp + + + + Windows10 + False + Universal + + WindowsApplicationForDrivers10.0 + Application + + + Windows10 + True + Universal + + WindowsApplicationForDrivers10.0 + Application + + + Windows10 + False + Universal + + WindowsApplicationForDrivers10.0 + Application + + + Windows10 + True + Universal + + WindowsApplicationForDrivers10.0 + Application + + + + $(IntDir) + + + + + + + + + + + + + + + + osrusbfx2 + + + osrusbfx2 + + + osrusbfx2 + + + osrusbfx2 + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj new file mode 100644 index 00000000..e1450faf --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj @@ -0,0 +1,194 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {6EED5CDD-5526-40DC-97F9-582857E10187} + $(MSBuildProjectName) + Debug + Win32 + {F19E45AF-8B05-4204-A66B-9BDBFE333233} + osrfx2_DCHU_testapp + $(LatestTargetPlatformVersion) + + + + Windows10 + False + Universal + + WindowsApplicationForDrivers10.0 + Application + + + Windows10 + True + Universal + + WindowsApplicationForDrivers10.0 + Application + + + Windows10 + False + Universal + + WindowsApplicationForDrivers10.0 + Application + + + Windows10 + True + Universal + + WindowsApplicationForDrivers10.0 + Application + + + + $(IntDir) + + + + + + + + + + + + + + + + osrfx2_DCHU_testapp + + + osrfx2_DCHU_testapp + + + osrfx2_DCHU_testapp + + + osrfx2_DCHU_testapp + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\sys\inc + %(PreprocessorDefinitions);UNICODE;_UNICODE + + + %(AdditionalDependencies);onecore.lib + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/test.cmd b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/test.cmd new file mode 100644 index 00000000..30b18b85 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/test.cmd @@ -0,0 +1,6 @@ +FOR /L %%i IN (0,1,100000) do ( + + osrusbfx2.exe -r 512 -w 512 -c 1000000 -v + +) + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/testapp.c b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/testapp.c new file mode 100644 index 00000000..455c2bbe --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/testapp.c @@ -0,0 +1,1214 @@ +/*++ + +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: + + testapp.c + +Abstract: + + Console test app for Osr Fx2 Learning Kit. + +Environment: + + user mode only + +--*/ + + +#include +_Analysis_mode_(_Analysis_code_type_user_code_) + +#include +#include +#include +#include + +#include "devioctl.h" +#include "strsafe.h" + +#pragma warning(disable:4200) // +#pragma warning(disable:4201) // nameless struct/union +#pragma warning(disable:4214) // bit field types other than int + +#include +#include +#include "usbdi.h" +#include "public.h" + +#pragma warning(default:4200) +#pragma warning(default:4201) +#pragma warning(default:4214) + +#define WHILE(a) \ +while(__pragma(warning(disable:4127)) a __pragma(warning(disable:4127))) + +#define MAX_DEVPATH_LENGTH 256 +#define NUM_ASYNCH_IO 100 +#define BUFFER_SIZE 1024 +#define READER_TYPE 1 +#define WRITER_TYPE 2 + +BOOL G_fDumpUsbConfig = FALSE; // flags set in response to console command line switches +BOOL G_fDumpReadData = FALSE; +BOOL G_fRead = FALSE; +BOOL G_fWrite = FALSE; +BOOL G_fPlayWithDevice = FALSE; +BOOL G_fPerformAsyncIo = FALSE; +ULONG G_IterationCount = 1; //count of iterations of the test we are to perform +ULONG G_WriteLen = 512; // #bytes to write +ULONG G_ReadLen = 512; // #bytes to read + +BOOL +DumpUsbConfig( // defined in dump.c + ); + +typedef enum _INPUT_FUNCTION { + LIGHT_ONE_BAR = 1, + CLEAR_ONE_BAR, + LIGHT_ALL_BARS, + CLEAR_ALL_BARS, + GET_BAR_GRAPH_LIGHT_STATE, + GET_SWITCH_STATE, + GET_SWITCH_STATE_AS_INTERRUPT_MESSAGE, + GET_7_SEGEMENT_STATE, + SET_7_SEGEMENT_STATE, + RESET_DEVICE, + REENUMERATE_DEVICE, +} INPUT_FUNCTION; + +_Success_(return) +BOOL +GetDevicePath( + _In_ LPGUID InterfaceGuid, + _Out_writes_z_(BufLen) PWCHAR DevicePath, + _In_ size_t BufLen + ) +{ + CONFIGRET cr = CR_SUCCESS; + PWSTR deviceInterfaceList = NULL; + ULONG deviceInterfaceListLength = 0; + PWSTR nextInterface; + HRESULT hr = E_FAIL; + BOOL bRet = TRUE; + + cr = CM_Get_Device_Interface_List_Size( + &deviceInterfaceListLength, + InterfaceGuid, + NULL, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); + if (cr != CR_SUCCESS) { + printf("Error 0x%x retrieving device interface list size.\n", cr); + goto clean0; + } + + if (deviceInterfaceListLength <= 1) { + bRet = FALSE; + printf("Error: No active device interfaces found.\n" + " Is the sample driver loaded?"); + goto clean0; + } + + deviceInterfaceList = (PWSTR)malloc(deviceInterfaceListLength * sizeof(WCHAR)); + if (deviceInterfaceList == NULL) { + bRet = FALSE; + printf("Error allocating memory for device interface list.\n"); + goto clean0; + } + ZeroMemory(deviceInterfaceList, deviceInterfaceListLength * sizeof(WCHAR)); + + cr = CM_Get_Device_Interface_List( + InterfaceGuid, + NULL, + deviceInterfaceList, + deviceInterfaceListLength, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); + if (cr != CR_SUCCESS) { + printf("Error 0x%x retrieving device interface list.\n", cr); + goto clean0; + } + + nextInterface = deviceInterfaceList + wcslen(deviceInterfaceList) + 1; + if (*nextInterface != UNICODE_NULL) { + printf("Warning: More than one device interface instance found. \n" + "Selecting first matching device.\n\n"); + } + + hr = StringCchCopy(DevicePath, BufLen, deviceInterfaceList); + if (FAILED(hr)) { + bRet = FALSE; + printf("Error: StringCchCopy failed with HRESULT 0x%x", hr); + goto clean0; + } + +clean0: + if (deviceInterfaceList != NULL) { + free(deviceInterfaceList); + } + if (CR_SUCCESS != cr) { + bRet = FALSE; + } + + return bRet; +} + +_Check_return_ +_Ret_notnull_ +_Success_(return != INVALID_HANDLE_VALUE) +HANDLE +OpenDevice( + _In_ BOOL Synchronous + ) + +/*++ +Routine Description: + + Called by main() to open an instance of our device after obtaining its name + +Arguments: + + Synchronous - TRUE, if Device is to be opened for synchronous access. + FALSE, otherwise. + +Return Value: + + Device handle on success else INVALID_HANDLE_VALUE + +--*/ + +{ + HANDLE hDev; + WCHAR completeDeviceName[MAX_DEVPATH_LENGTH]; + + if ( !GetDevicePath( + (LPGUID) &GUID_DEVINTERFACE_OSRUSBFX2, + completeDeviceName, + sizeof(completeDeviceName)/sizeof(completeDeviceName[0])) ) + { + return INVALID_HANDLE_VALUE; + } + + printf("DeviceName = (%S)\n", completeDeviceName); + + if(Synchronous) { + hDev = CreateFile(completeDeviceName, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, // default security + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + } else { + + hDev = CreateFile(completeDeviceName, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, // default security + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, + NULL); + } + + if (hDev == INVALID_HANDLE_VALUE) { + printf("Failed to open the device, error - %d", GetLastError()); + } else { + printf("Opened the device successfully.\n"); + } + + return hDev; +} + + + +VOID +Usage() + +/*++ +Routine Description: + + Called by main() to dump usage info to the console when + the app is called with no parms or with an invalid parm + +Arguments: + + None + +Return Value: + + None + +--*/ + +{ + printf("Usage for osrusbfx2 testapp:\n"); + printf("-r [n] where n is number of bytes to read\n"); + printf("-w [n] where n is number of bytes to write\n"); + printf("-c [n] where n is number of iterations (default = 1)\n"); + printf("-v verbose -- dumps read data\n"); + printf("-p to control bar LEDs, seven segment, and dip switch\n"); + printf("-a to perform asynchronous I/O\n"); + printf("-u to dump USB configuration and pipe info \n"); + + return; +} + + +void +Parse( + _In_ int argc, + _In_reads_(argc) LPSTR *argv + ) + +/*++ +Routine Description: + + Called by main() to parse command line parms + +Arguments: + + argc and argv that was passed to main() + +Return Value: + + Sets global flags as per user function request + +--*/ + +{ + int i; + + if ( argc < 2 ) // give usage if invoked with no parms + Usage(); + + for (i=0; i= argc) { + Usage(); + exit(1); + } + else { +#pragma warning(suppress: 6385) + G_ReadLen = atoi(&argv[i+1][0]); + G_fRead = TRUE; + } + i++; + break; + case 'w': + case 'W': + if (i+1 >= argc) { + Usage(); + exit(1); + } + else { + G_WriteLen = atoi(&argv[i+1][0]); + G_fWrite = TRUE; + } + i++; + break; + case 'c': + case 'C': + if (i+1 >= argc) { + Usage(); + exit(1); + } + else { + G_IterationCount = atoi(&argv[i+1][0]); + } + i++; + break; + case 'u': + case 'U': + G_fDumpUsbConfig = TRUE; + break; + case 'p': + case 'P': + G_fPlayWithDevice = TRUE; + break; + case 'a': + case 'A': + G_fPerformAsyncIo = TRUE; + break; + case 'v': + case 'V': + G_fDumpReadData = TRUE; + break; + default: + Usage(); + } + } + } +} + +BOOL +Compare_Buffs( + _In_reads_bytes_(buff1length) char *buff1, + _In_ ULONG buff1length, + _In_reads_bytes_(buff2length) char *buff2, + _In_ ULONG buff2length + ) +/*++ +Routine Description: + + Called to verify read and write buffers match for loopback test + +Arguments: + + buffers to compare and length + +Return Value: + + TRUE if buffers match, else FALSE + +--*/ +{ + int ok = 1; + + if (buff1length != buff2length || memcmp(buff1, buff2, buff1length )) { + // Edi, and Esi point to the mismatching char and ecx indicates the + // remaining length. + ok = 0; + } + + return ok; +} + +#define NPERLN 8 + +VOID +Dump( + UCHAR *b, + int len +) + +/*++ +Routine Description: + + Called to do formatted ascii dump to console of the io buffer + +Arguments: + + buffer and length + +Return Value: + + none + +--*/ + +{ + ULONG i; + ULONG longLen = (ULONG)len / sizeof( ULONG ); + PULONG pBuf = (PULONG) b; + + // dump an ordinal ULONG for each sizeof(ULONG)'th byte + printf("\n****** BEGIN DUMP LEN decimal %d, 0x%x\n", len,len); + for (i=0; i 8){ + printf("Invalid bar number!\n"); + goto Error; + } + + bar--; // normalize to 0 to 7 + + barGraphState.BarsAsUChar = 1 << (UCHAR)bar; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &barGraphState, // Ptr to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Ptr to OutBuffer + 0, // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + break; + + case CLEAR_ONE_BAR: + + + printf("Which Bar (input number 1 thru 8)?\n"); + if (scanf_s ("%d", &bar) <= 0) { + + printf("Error reading input!\n"); + goto Error; + + } + + if(bar == 0 || bar > 8){ + printf("Invalid bar number!\n"); + goto Error; + } + + bar--; + + // + // Read the current state + // + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY, + NULL, // Ptr to InBuffer + 0, // Length of InBuffer + &barGraphState, // Ptr to OutBuffer + sizeof(BAR_GRAPH_STATE), // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + if (barGraphState.BarsAsUChar & (1 << bar)) { + + printf("Bar is set...Clearing it\n"); + barGraphState.BarsAsUChar &= ~(1 << bar); + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &barGraphState, // Ptr to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Ptr to OutBuffer + 0, // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + + } + + } else { + + printf("Bar not set.\n"); + + } + + break; + + case LIGHT_ALL_BARS: + + barGraphState.BarsAsUChar = 0xFF; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &barGraphState, // Ptr to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Ptr to OutBuffer + 0, // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + break; + + case CLEAR_ALL_BARS: + + barGraphState.BarsAsUChar = 0; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &barGraphState, // Ptr to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Ptr to OutBuffer + 0, // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + break; + + + case GET_BAR_GRAPH_LIGHT_STATE: + + barGraphState.BarsAsUChar = 0; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY, + NULL, // Ptr to InBuffer + 0, // Length of InBuffer + &barGraphState, // Ptr to OutBuffer + sizeof(BAR_GRAPH_STATE), // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + printf("Bar Graph: \n"); + printf(" Bar8 is %s\n", barGraphState.Bar8 ? "ON" : "OFF"); + printf(" Bar7 is %s\n", barGraphState.Bar7 ? "ON" : "OFF"); + printf(" Bar6 is %s\n", barGraphState.Bar6 ? "ON" : "OFF"); + printf(" Bar5 is %s\n", barGraphState.Bar5 ? "ON" : "OFF"); + printf(" Bar4 is %s\n", barGraphState.Bar4 ? "ON" : "OFF"); + printf(" Bar3 is %s\n", barGraphState.Bar3 ? "ON" : "OFF"); + printf(" Bar2 is %s\n", barGraphState.Bar2 ? "ON" : "OFF"); + printf(" Bar1 is %s\n", barGraphState.Bar1 ? "ON" : "OFF"); + + break; + + case GET_SWITCH_STATE: + + switchState.SwitchesAsUChar = 0; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_READ_SWITCHES, + NULL, // Ptr to InBuffer + 0, // Length of InBuffer + &switchState, // Ptr to OutBuffer + sizeof(SWITCH_STATE), // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + printf("Switches: \n"); + printf(" Switch8 is %s\n", switchState.Switch8 ? "ON" : "OFF"); + printf(" Switch7 is %s\n", switchState.Switch7 ? "ON" : "OFF"); + printf(" Switch6 is %s\n", switchState.Switch6 ? "ON" : "OFF"); + printf(" Switch5 is %s\n", switchState.Switch5 ? "ON" : "OFF"); + printf(" Switch4 is %s\n", switchState.Switch4 ? "ON" : "OFF"); + printf(" Switch3 is %s\n", switchState.Switch3 ? "ON" : "OFF"); + printf(" Switch2 is %s\n", switchState.Switch2 ? "ON" : "OFF"); + printf(" Switch1 is %s\n", switchState.Switch1 ? "ON" : "OFF"); + + break; + + case GET_SWITCH_STATE_AS_INTERRUPT_MESSAGE: + + switchState.SwitchesAsUChar = 0; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE, + NULL, // Ptr to InBuffer + 0, // Length of InBuffer + &switchState, // Ptr to OutBuffer + sizeof(switchState), // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + printf("Switches: %d\n",index); + printf(" Switch8 is %s\n", switchState.Switch8 ? "ON" : "OFF"); + printf(" Switch7 is %s\n", switchState.Switch7 ? "ON" : "OFF"); + printf(" Switch6 is %s\n", switchState.Switch6 ? "ON" : "OFF"); + printf(" Switch5 is %s\n", switchState.Switch5 ? "ON" : "OFF"); + printf(" Switch4 is %s\n", switchState.Switch4 ? "ON" : "OFF"); + printf(" Switch3 is %s\n", switchState.Switch3 ? "ON" : "OFF"); + printf(" Switch2 is %s\n", switchState.Switch2 ? "ON" : "OFF"); + printf(" Switch1 is %s\n", switchState.Switch1 ? "ON" : "OFF"); + + break; + + case GET_7_SEGEMENT_STATE: + + sevenSegment = 0; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY, + NULL, // Ptr to InBuffer + 0, // Length of InBuffer + &sevenSegment, // Ptr to OutBuffer + sizeof(UCHAR), // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + printf("7 Segment mask: 0x%x\n", sevenSegment); + break; + + case SET_7_SEGEMENT_STATE: + + for (i = 0; i < 8; i++) { + + sevenSegment = 1 << i; + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_SET_7_SEGMENT_DISPLAY, + &sevenSegment, // Ptr to InBuffer + sizeof(UCHAR), // Length of InBuffer + NULL, // Ptr to OutBuffer + 0, // Length of OutBuffer + &index, // BytesReturned + 0)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + printf("This is %d\n", i); + Sleep(500); + + } + + printf("7 Segment mask: 0x%x\n", sevenSegment); + break; + + case RESET_DEVICE: + + printf("Reset the device\n"); + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_RESET_DEVICE, + NULL, // Ptr to InBuffer + 0, // Length of InBuffer + NULL, // Ptr to OutBuffer + 0, // Length of OutBuffer + &index, // BytesReturned + NULL)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + break; + + case REENUMERATE_DEVICE: + + printf("Re-enumerate the device\n"); + + if (!DeviceIoControl(deviceHandle, + IOCTL_OSRUSBFX2_REENUMERATE_DEVICE, + NULL, // Ptr to InBuffer + 0, // Length of InBuffer + NULL, // Ptr to OutBuffer + 0, // Length of OutBuffer + &index, // BytesReturned + NULL)) { // Ptr to Overlapped structure + + code = GetLastError(); + + printf("DeviceIoControl failed with error 0x%x\n", code); + + goto Error; + } + + // + // Close the handle to the device and exit out so that + // the driver can unload when the device is surprise-removed + // and reenumerated. + // + default: + + result = TRUE; + goto Error; + + } + + } // end of while loop + +Error: + + CloseHandle(deviceHandle); + return result; + +} + + +ULONG +AsyncIo( + PVOID ThreadParameter + ) +{ + HANDLE hDevice = INVALID_HANDLE_VALUE; + HANDLE hCompletionPort = NULL; + OVERLAPPED *pOvList = NULL; + PUCHAR buf = NULL; + ULONG_PTR i; + ULONG ioType = (ULONG)(ULONG_PTR)ThreadParameter; + ULONG error; + + hDevice = OpenDevice(FALSE); + + if (hDevice == INVALID_HANDLE_VALUE) { + printf("Cannot open device %d\n", GetLastError()); + goto Error; + } + + hCompletionPort = CreateIoCompletionPort(hDevice, NULL, 1, 0); + + if (hCompletionPort == NULL) { + printf("Cannot open completion port %d \n",GetLastError()); + goto Error; + } + + pOvList = (OVERLAPPED *)malloc(NUM_ASYNCH_IO * sizeof(OVERLAPPED)); + + if (pOvList == NULL) { + printf("Cannot allocate overlapped array \n"); + goto Error; + } + + buf = (PUCHAR)malloc(NUM_ASYNCH_IO * BUFFER_SIZE); + + if (buf == NULL) { + printf("Cannot allocate buffer \n"); + goto Error; + } + + ZeroMemory(pOvList, NUM_ASYNCH_IO * sizeof(OVERLAPPED)); + ZeroMemory(buf, NUM_ASYNCH_IO * BUFFER_SIZE); + + // + // Issue asynch I/O + // + + for (i = 0; i < NUM_ASYNCH_IO; i++) { + if (ioType == READER_TYPE) { + if ( ReadFile( hDevice, + buf + (i* BUFFER_SIZE), + BUFFER_SIZE, + NULL, + &pOvList[i]) == 0) { + + error = GetLastError(); + if (error != ERROR_IO_PENDING) { + printf(" %Iu th read failed %d \n",i, GetLastError()); + goto Error; + } + } + + } else { + if ( WriteFile( hDevice, + buf + (i* BUFFER_SIZE), + BUFFER_SIZE, + NULL, + &pOvList[i]) == 0) { + error = GetLastError(); + if (error != ERROR_IO_PENDING) { + printf(" %Iu th write failed %d \n",i, GetLastError()); + goto Error; + } + } + } + } + + // + // Wait for the I/Os to complete. If one completes then reissue the I/O + // + + WHILE (1) { + OVERLAPPED *completedOv; + ULONG_PTR key; + ULONG numberOfBytesTransferred; + + if ( GetQueuedCompletionStatus(hCompletionPort, &numberOfBytesTransferred, + &key, &completedOv, INFINITE) == 0) { + printf("GetQueuedCompletionStatus failed %d\n", GetLastError()); + goto Error; + } + + // + // Read successfully completed. Issue another one. + // + + if (ioType == READER_TYPE) { + + i = completedOv - pOvList; + + printf("Number of bytes read by request number %Iu is %d\n", + i, numberOfBytesTransferred); + + if ( ReadFile( hDevice, + buf + (i * BUFFER_SIZE), + BUFFER_SIZE, + NULL, + completedOv) == 0) { + error = GetLastError(); + if (error != ERROR_IO_PENDING) { + printf("%Iu th Read failed %d \n", i, GetLastError()); + goto Error; + } + } + } else { + + i = completedOv - pOvList; + + printf("Number of bytes written by request number %Iu is %d\n", + i, numberOfBytesTransferred); + + if ( WriteFile( hDevice, + buf + (i * BUFFER_SIZE), + BUFFER_SIZE, + NULL, + completedOv) == 0) { + error = GetLastError(); + if (error != ERROR_IO_PENDING) { + printf("%Iu th write failed %d \n", i, GetLastError()); + goto Error; + } + } + } + } + +Error: + if (hDevice != INVALID_HANDLE_VALUE) { + CloseHandle(hDevice); + } + + if (hCompletionPort) { + CloseHandle(hCompletionPort); + } + + if (pOvList) { + free(pOvList); + } + if (buf) { + free(buf); + } + + return 1; + +} + + +int +_cdecl +main( + _In_ int argc, + _In_reads_(argc) LPSTR *argv + ) +/*++ +Routine Description: + + Entry point to rwbulk.exe + Parses cmdline, performs user-requested tests + +Arguments: + + argc, argv standard console 'c' app arguments + +Return Value: + + Zero + +--*/ + +{ + char * pinBuf = NULL; + char * poutBuf = NULL; + ULONG nBytesRead; + ULONG nBytesWrite = 0; + int ok; + int retValue = 0; + UINT success; + HANDLE hRead = INVALID_HANDLE_VALUE; + HANDLE hWrite = INVALID_HANDLE_VALUE; + ULONG fail = 0L; + ULONG i; + + + Parse(argc, argv ); + + // + // dump USB configuation and pipe info + // + if (G_fDumpUsbConfig) { + DumpUsbConfig(); + } + + if (G_fPlayWithDevice) { + PlayWithDevice(); + goto exit; + } + + if (G_fPerformAsyncIo) { + HANDLE th1; + + // + // Create a reader thread + // + th1 = CreateThread( NULL, // Default Security Attrib. + 0, // Initial Stack Size, + AsyncIo, // Thread Func + (LPVOID)READER_TYPE, + 0, // Creation Flags + NULL ); // Don't need the Thread Id. + + if (th1 == NULL) { + printf("Couldn't create reader thread - error %d\n", GetLastError()); + retValue = 1; + goto exit; + } + + // + // Use this thread for peforming write. + // + AsyncIo((PVOID)WRITER_TYPE); + + goto exit; + } + + // + // doing a read, write, or both test + // + if ((G_fRead) || (G_fWrite)) { + + if (G_fRead) { + if ( G_fDumpReadData ) { // round size to sizeof ULONG for readable dumping + while( G_ReadLen % sizeof( ULONG ) ) { + G_ReadLen++; + } + } + + // + // open the output file + // + hRead = OpenDevice(TRUE); + if(hRead == INVALID_HANDLE_VALUE) { + retValue = 1; + goto exit; + } + + pinBuf = malloc(G_ReadLen); + } + + if (G_fWrite) { + if ( G_fDumpReadData ) { // round size to sizeof ULONG for readable dumping + while( G_WriteLen % sizeof( ULONG ) ) { + G_WriteLen++; + } + } + + // + // open the output file + // + hWrite = OpenDevice(TRUE); + if(hWrite == INVALID_HANDLE_VALUE) { + retValue = 1; + goto exit; + } + + poutBuf = malloc(G_WriteLen); + } + + for (i = 0; i < G_IterationCount; i++) { + ULONG j; + + if (G_fWrite && poutBuf && hWrite != INVALID_HANDLE_VALUE) { + + PULONG pOut = (PULONG) poutBuf; + ULONG numLongs = G_WriteLen / sizeof( ULONG ); + + // + // put some data in the output buffer + // + for (j=0; j + +#include + +#define VER_FILETYPE VFT_DLL +#define VER_FILESUBTYPE VFT2_UNKNOWN +#define VER_FILEDESCRIPTION_STR "OSRUSBFX2 Bulk & Isoch Read and Write test App" +#define VER_INTERNALNAME_STR "osrusbfx2.exe" +#define VER_ORIGINALFILENAME_STR "osrusbfx2.exe" + +#include + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp new file mode 100644 index 00000000..98a3975c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + CppWindowsService.cpp + +Abstract: + + The file defines the entry point of the application. According to the + arguments in the command line, the function installs or uninstalls or + starts the service by calling into different routines. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include +#include +#include "ServiceBase.h" +#include "SampleService.h" +#pragma endregion + +// +// Settings of the service +// + +// +// Internal name of the service +// +#define SERVICE_NAME L"OsrUsbFx2UmUserSvc" + + +/*++ + +Routine Description: + + Entry point for the service. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +INT +wmain( + INT Argc, + WCHAR *Argv[] + ) +{ + CSampleService service(SERVICE_NAME); + + if (!CServiceBase::Run(service)) + { + wprintf(L"Service failed to run w/err 0x%08lx\n", GetLastError()); + } + + return 0; +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp new file mode 100644 index 00000000..157a6cb9 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/Main.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h new file mode 100644 index 00000000..dcbd950e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp new file mode 100644 index 00000000..c39e4838 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/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_base/osrfx2_DCHU_usersvc/SampleService.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h new file mode 100644 index 00000000..eee8a609 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h @@ -0,0 +1,174 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + SampleService.h + +Abstract: + + Provides a sample service class that derives from the service base class - + CServiceBase. The sample service logs the service start and stop + information to the Application event log, and shows how to run the main + function of the service in a thread pool worker thread. + +Environment: + + User mode + +--*/ + +#pragma once + +#include "ServiceBase.h" +#include "Main.h" + +class CSampleService : public CServiceBase +{ +public: + + /*++ + + Routine Description: + + The constructor of CSampleService. It initializes a new instance + of the CSampleService class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. Inherits properties from the class CServiceBase. + + Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + + Return Value: + + VOID + + --*/ + CSampleService(PWSTR ServiceName, + BOOL CanStop = TRUE, + BOOL CanShutdown = TRUE, + BOOL CanPauseContinue = FALSE); + + /*++ + + Routine Description: + + The virtual destructor of CSampleService. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual ~CSampleService(); + +protected: + + /*++ + + Routine Description: + + This function is executed when a Start command is sent to the + service by the SCM or when the operating system starts (for a service + that starts automatically). It specifies actions to take when the + service starts. In this code sample, OnStart logs a service-start + message to the Application log, and queues the main service function for + execution in a thread pool worker thread. + + NOTE: A service application is designed to be long running. Therefore, + it usually polls or monitors something in the system. The monitoring is + set up in the OnStart method. However, OnStart does not actually do the + monitoring. The OnStart method must return to the operating system after + the service's operation has begun. It must not loop forever or block. To + set up a simple monitoring mechanism, one general solution is to create + a timer in OnStart. The timer would then raise events in your code + periodically, at which time your service could do its monitoring. The + other solution is to spawn a new thread to perform the main service + functions, which is demonstrated in this code sample. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + virtual VOID OnStart(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + This function is executed when a Stop command is sent to the service by SCM. + It specifies actions to take when a service stops running. In this code + sample, OnStop logs a service-stop message to the Application log, and + waits for the finish of the main service function. + + Be sure to periodically call ReportServiceStatus() with + SERVICE_STOP_PENDING if the procedure is going to take a long time. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnStop(); + + + /*++ + + Routine Description: + + This method performs the main function of the service. It runs + on a thread pool worker thread. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID ServiceWorkerThread(); + +private: + + // + // Determines if the service is currently stopping. + // + BOOL m_fStopping; + + // + // The handle to wait for a stop event. + // + HANDLE m_hStoppedEvent; +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp new file mode 100644 index 00000000..4c20af2e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp @@ -0,0 +1,794 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + ServiceBase.cpp + +Abstract: + + Provides a base class for a service that will exist as part of a service + application. CServiceBase must be derived from when creating a new service + class. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include "ServiceBase.h" +#include "Main.h" +#include "Utils.h" +#include +#include +#pragma endregion + + +#pragma region Static Members + +// +// Initialize the singleton service instance. +// +CServiceBase *CServiceBase::s_service = NULL; + + +/*++ + +Routine Description: + + Register the executable for a service with the Service Control + Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start + command, which results in a call to the OnStart method in the service. + This method blocks until the service has stopped. + +Arguments: + + Service - The reference to a CServiceBase object. It will become the + singleton service instance of this service application. + +Return Value: + + If the function succeeds, the return value is TRUE. If the function + fails, the return value is FALSE. To get extended error information, + call GetLastError. + +--*/ +BOOL +CServiceBase::Run( + CServiceBase &Service + ) +{ + s_service = &Service; + + SERVICE_TABLE_ENTRY serviceTable[] = + { + { Service.m_name, ServiceMain }, + { NULL, NULL } + }; + + // + // Connects the main thread of a service process to the service control + // manager, which causes the thread to be the service control dispatcher + // thread for the calling process. This call returns when the service has + // stopped. The process should simply terminate when the call returns. + // + return StartServiceCtrlDispatcher(serviceTable); +} + + +/*++ + +Routine Description: + + The entry point for the service. It registers the handler function + for the service and starts the service. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +WINAPI +CServiceBase::ServiceMain( + DWORD Argc, + PWSTR *Argv + ) +{ + assert(s_service != NULL); + + // + // Register the handler function for the service. + // + s_service->m_statusHandle = RegisterServiceCtrlHandler(s_service->m_name, + ServiceCtrlHandler); + + if (s_service->m_statusHandle == NULL) + { + throw GetLastError(); + } + + // + // Start the service. + // + s_service->Start(Argc, Argv); +} + + +/*++ + +Routine Description: + + Called by the SCM whenever a control code is sent to the service. + +Arguments: + + CtrlCode - The control code. This parameter can be one of + the following values: + + SERVICE_CONTROL_CONTINUE + SERVICE_CONTROL_INTERROGATE + SERVICE_CONTROL_NETBINDADD + SERVICE_CONTROL_NETBINDDISABLE + SERVICE_CONTROL_NETBINDREMOVE + SERVICE_CONTROL_PARAMCHANGE + SERVICE_CONTROL_PAUSE + SERVICE_CONTROL_SHUTDOWN + SERVICE_CONTROL_STOP + + This parameter can also be a user-defined control + code ranging from 128 to 255. + +Return Value: + + VOID + +--*/ +VOID +WINAPI +CServiceBase::ServiceCtrlHandler( + DWORD Ctrl + ) +{ + switch (Ctrl) + { + case SERVICE_CONTROL_STOP: + s_service->Stop(); + break; + case SERVICE_CONTROL_PAUSE: + s_service->Pause(); + break; + case SERVICE_CONTROL_CONTINUE: + s_service->Continue(); + break; + case SERVICE_CONTROL_SHUTDOWN: + s_service->Shutdown(); + break; + case SERVICE_CONTROL_INTERROGATE: + break; + default: + break; + } +} + +#pragma endregion + + +#pragma region Service Constructor and Destructor + +/*++ + +Routine Description: + + The constructor of CServiceBase. It initializes a new instance + of the CServiceBase class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. + +Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + +Return Value: + + VOID + +--*/ +CServiceBase::CServiceBase( + PWSTR ServiceName, + BOOL CanStop, + BOOL CanShutdown, + BOOL CanPauseContinue + ) +{ + // + // Service name must be a valid string and cannot be NULL. + // + m_name = (ServiceName == NULL) ? L"" : ServiceName; + + m_statusHandle = NULL; + + // + // The service runs in its own process. + // + m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + + // + // The service is starting. + // + m_status.dwCurrentState = SERVICE_START_PENDING; + + // + // The accepted commands of the service. + // + DWORD dwControlsAccepted = 0; + + if (CanStop) + { + dwControlsAccepted |= SERVICE_ACCEPT_STOP; + } + + if (CanShutdown) + { + dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN; + } + + if (CanPauseContinue) + { + dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE; + } + + m_status.dwControlsAccepted = dwControlsAccepted; + + m_status.dwWin32ExitCode = NO_ERROR; + m_status.dwServiceSpecificExitCode = 0; + m_status.dwCheckPoint = 0; + m_status.dwWaitHint = 0; + + SetupEvents(); +} + + +/*++ + +Routine Description: + + The virtual destructor of CServiceBase. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +CServiceBase::~CServiceBase() +{ + DestroyEvents(); +} + +#pragma endregion + + +#pragma region Service Start, Stop, Pause, Continue, and Shutdown + +/*++ + +Routine Description: + + This function starts the service. It calls the OnStart virtual function + in which you can specify the actions to take when the service starts. If + an error occurs during the startup, the error will be logged in the + Application event log, and the service will be stopped. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Start( + DWORD Argc, + PWSTR *Argv +) +{ + try + { + // + // Tell SCM that the service is starting. + // + SetServiceStatus(SERVICE_START_PENDING); + + // + // Perform service-specific initialization. + // + OnStart(Argc, Argv); + + // + // Tell SCM that the service is started. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Start", Error); + + // + // Set the service status to be stopped. + // + SetServiceStatus(SERVICE_STOPPED, Error); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to start.", EVENTLOG_ERROR_TYPE); + + // + // Set the service status to be stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Start + command is sent to the service by the SCM or when the operating system + starts (for a service that starts automatically). Specifies actions to + take when the service starts. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the + procedure is going to take long time. You may also consider spawning a + new thread in OnStart to perform time-consuming initialization tasks. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnStart( + DWORD Argc, + PWSTR *Argv +) +{ + SetVariables(); +} + + +/*++ + +Routine Description: + + This function stops the service. It calls the OnStop virtual + function in which you can specify the actions to take when the service + stops. If an error occurs, the error will be logged in the Application + event log, and the service will be restored to the original state. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Stop() +{ + DWORD OriginalState = m_status.dwCurrentState; + + try + { + // + // Tell SCM that the service is stopping. + // + SetServiceStatus(SERVICE_STOP_PENDING); + + // + // Perform service-specific stop operations. + // + OnStop(); + + // + // Tell SCM that the service is stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Stop", Error); + + // + // Set the orginal service status. + // + SetServiceStatus(OriginalState); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to stop.", EVENTLOG_ERROR_TYPE); + + // + // Set the orginal service status. + // + SetServiceStatus(OriginalState); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Stop + command is sent to the service by the SCM. Specifies actions to take + when a service stops running. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the + procedure is going to take long time. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnStop() +{ +} + + +/*++ + +Routine Description: + + The function pauses the service if the service supports pause + and continue. It calls the OnPause virtual function in which you can + specify the actions to take when the service pauses. If an error occurs, + the error will be logged in the Application event log, and the service + will become running. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Pause() +{ + try + { + // + // Tell SCM that the service is pausing. + // + SetServiceStatus(SERVICE_PAUSE_PENDING); + + // + // Perform service-specific pause operations. + // + OnPause(); + + // + // Tell SCM that the service is paused. + // + SetServiceStatus(SERVICE_PAUSED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Pause", Error); + + // + // Tell SCM that the service is still running. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to pause.", EVENTLOG_ERROR_TYPE); + + // + // Tell SCM that the service is still running. + // + SetServiceStatus(SERVICE_RUNNING); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Pause + command is sent to the service by the SCM. Specifies actions to take + when a service pauses. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnPause() +{ +} + + +/*++ + +Routine Description: + + The function resumes normal functioning after being paused if + the service supports pause and continue. It calls the OnContinue virtual + function in which you can specify the actions to take when the service + continues. If an error occurs, the error will be logged in the + Application event log, and the service will still be paused. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Continue() +{ + try + { + // + // Tell SCM that the service is resuming. + // + SetServiceStatus(SERVICE_CONTINUE_PENDING); + + // + // Perform service-specific continue operations. + // + OnContinue(); + + // + // Tell SCM that the service is running. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Continue", Error); + + // + // Tell SCM that the service is still paused. + // + SetServiceStatus(SERVICE_PAUSED); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to resume.", EVENTLOG_ERROR_TYPE); + + // + // Tell SCM that the service is still paused. + // + SetServiceStatus(SERVICE_PAUSED); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, OnContinue runs when a + Continue command is sent to the service by the SCM. Specifies actions to + take when a service resumes normal functioning after being paused. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnContinue() +{ +} + + +/*++ + +Routine Description: + + The function executes when the system is shutting down. It + calls the OnShutdown virtual function in which you can specify what + should occur immediately prior to the system shutting down. If an error + occurs, the error will be logged in the Application event log. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Shutdown() +{ + try + { + // + // Perform service-specific shutdown operations. + // + OnShutdown(); + + // + // Tell SCM that the service is stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Shutdown", Error); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to shut down.", EVENTLOG_ERROR_TYPE); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when the system + is shutting down. Specifies what should occur immediately prior to the + system shutting down. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnShutdown() +{ +} + +#pragma endregion + + +#pragma region Helper Functions + +/*++ + +Routine Description: + + The function sets the service status and reports the status to the SCM. + +Arguments: + + CurrentState - The current state of the service + + Win32ExitCode - The error code to report + + WaitHint - The estimated time for pending operation, in milliseconds + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::SetServiceStatus( + DWORD CurrentState, + DWORD Win32ExitCode, + DWORD WaitHint + ) +{ + static DWORD CheckPoint = 1; + + // + // Fill in the SERVICE_STATUS structure of the service. + // + + m_status.dwCurrentState = CurrentState; + m_status.dwWin32ExitCode = Win32ExitCode; + m_status.dwWaitHint = WaitHint; + + m_status.dwCheckPoint = ((CurrentState == SERVICE_RUNNING) || + (CurrentState == SERVICE_STOPPED)) ? 0 : + CheckPoint++; + + // + // Report the status of the service to the SCM. + // + ::SetServiceStatus(m_statusHandle, &m_status); +} + +#pragma endregion \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h new file mode 100644 index 00000000..106597e1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h @@ -0,0 +1,423 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + ServiceBase.cpp + +Abstract: + + Provides a base class for a service that will exist as part of a service + application. CServiceBase must be derived from when creating a new service + class. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include "Utils.h" + +class CServiceBase +{ +public: + + /*++ + + Routine Description: + + Register the executable for a service with the Service Control + Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start + command, which results in a call to the OnStart method in the service. + This method blocks until the service has stopped. + + Arguments: + + Service - The reference to a CServiceBase object. It will become the + singleton service instance of this service application. + + Return Value: + + If the function succeeds, the return value is TRUE. If the function + fails, the return value is FALSE. To get extended error information, + call GetLastError. + + --*/ + static BOOL Run(CServiceBase &service); + + + /*++ + + Routine Description: + + The constructor of CServiceBase. It initializes a new instance + of the CServiceBase class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. + + Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + + Return Value: + + VOID + + --*/ + CServiceBase(PWSTR ServiceName, + BOOL CanStop = TRUE, + BOOL CanShutdown = TRUE, + BOOL CanPauseContinue = FALSE); + + + /*++ + + Routine Description: + + The virtual destructor of CServiceBase. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual ~CServiceBase(); + + + /*++ + + Routine Description: + + This function stops the service. It calls the OnStop virtual + function in which you can specify the actions to take when the service + stops. If an error occurs, the error will be logged in the Application + event log, and the service will be restored to the original state. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Stop(); + +protected: + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Start + command is sent to the service by the SCM or when the operating system + starts (for a service that starts automatically). Specifies actions to + take when the service starts. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the + procedure is going to take long time. You may also consider spawning a + new thread in OnStart to perform time-consuming initialization tasks. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + virtual VOID OnStart(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Stop + command is sent to the service by the SCM. Specifies actions to take + when a service stops running. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the + procedure is going to take long time. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnStop(); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Pause + command is sent to the service by the SCM. Specifies actions to take + when a service pauses. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnPause(); + + + /*++ + + Routine Description: + + When implemented in a derived class, OnContinue runs when a + Continue command is sent to the service by the SCM. Specifies actions to + take when a service resumes normal functioning after being paused. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnContinue(); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when the system + is shutting down. Specifies what should occur immediately prior to the + system shutting down. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnShutdown(); + + + /*++ + + Routine Description: + + The function sets the service status and reports the status to the SCM. + + Arguments: + + CurrentState - The current state of the service + + Win32ExitCode - The error code to report + + WaitHint - The estimated time for pending operation, in milliseconds + + Return Value: + + VOID + + --*/ + VOID SetServiceStatus(DWORD CurrentState, + DWORD Win32ExitCode = NO_ERROR, + DWORD WaitHint = 0); + +private: + + /*++ + + Routine Description: + + The entry point for the service. It registers the handler function + for the service and starts the service. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + static VOID WINAPI ServiceMain(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + Called by the SCM whenever a control code is sent to the service. + + Arguments: + + CtrlCode - The control code. This parameter can be one of + the following values: + + SERVICE_CONTROL_CONTINUE + SERVICE_CONTROL_INTERROGATE + SERVICE_CONTROL_NETBINDADD + SERVICE_CONTROL_NETBINDDISABLE + SERVICE_CONTROL_NETBINDREMOVE + SERVICE_CONTROL_PARAMCHANGE + SERVICE_CONTROL_PAUSE + SERVICE_CONTROL_SHUTDOWN + SERVICE_CONTROL_STOP + + This parameter can also be a user-defined control + code ranging from 128 to 255. + + Return Value: + + VOID + + --*/ + static VOID WINAPI ServiceCtrlHandler(DWORD Ctrl); + + + /*++ + + Routine Description: + + This function starts the service. It calls the OnStart virtual function + in which you can specify the actions to take when the service starts. If + an error occurs during the startup, the error will be logged in the + Application event log, and the service will be stopped. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + VOID Start(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + The function pauses the service if the service supports pause + and continue. It calls the OnPause virtual function in which you can + specify the actions to take when the service pauses. If an error occurs, + the error will be logged in the Application event log, and the service + will become running. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Pause(); + + + /*++ + + Routine Description: + + The function resumes normal functioning after being paused if + the service supports pause and continue. It calls the OnContinue virtual + function in which you can specify the actions to take when the service + continues. If an error occurs, the error will be logged in the + Application event log, and the service will still be paused. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Continue(); + + + /*++ + + Routine Description: + + The function executes when the system is shutting down. It + calls the OnShutdown virtual function in which you can specify what + should occur immediately prior to the system shutting down. If an error + occurs, the error will be logged in the Application event log. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Shutdown(); + + + // + // The singleton service instance. + // + static CServiceBase *s_service; + + // + // The name of the service. + // + PWSTR m_name; + + // + // The status of the service. + // + SERVICE_STATUS m_status; + + // + // The service status handle. + // + SERVICE_STATUS_HANDLE m_statusHandle; +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h new file mode 100644 index 00000000..3d851537 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h @@ -0,0 +1,80 @@ +/****************************** Module Header ******************************\ +* Module Name: ThreadPool.h +* Project: CppWindowsService +* Copyright (c) Microsoft Corporation. +* +* The class was designed by Kenny Kerr. It provides the ability to queue +* simple member functions of a class to the Windows thread pool. +* +* Using the thread pool is simple and feels natural in C++. +* +* class CSampleService +* { +* public: +* +* void AsyncRun() +* { +* CThreadPool::QueueUserWorkItem(&Service::Run, this); +* } +* +* void Run() +* { +* // Some lengthy operation +* } +* }; +* +* Kenny Kerr spends most of his time designing and building distributed +* applications for the Microsoft Windows platform. He also has a particular +* passion for C++ and security programming. Reach Kenny at +* http://weblogs.asp.net/kennykerr/ or visit his Web site: +* http://www.kennyandkarin.com/Kenny/. +* +* This source is subject to the Microsoft Public License. +* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL. +* All other rights reserved. +* +* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +\***************************************************************************/ + +#pragma once + +#include + + +class CThreadPool +{ +public: + + template + static void QueueUserWorkItem(void (T::*function)(void), + T *object, ULONG flags = WT_EXECUTELONGFUNCTION) + { + typedef std::pair CallbackType; + std::auto_ptr p(new CallbackType(function, object)); + + if (::QueueUserWorkItem(ThreadProc, p.get(), flags)) + { + // The ThreadProc now has the responsibility of deleting the pair. + p.release(); + } + else + { + throw GetLastError(); + } + } + +private: + + template + static DWORD WINAPI ThreadProc(PVOID context) + { + typedef std::pair CallbackType; + + std::auto_ptr p(static_cast(context)); + + (p->second->*p->first)(); + return 0; + } +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp new file mode 100644 index 00000000..e8fc87ee --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp @@ -0,0 +1,156 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Utils.cpp + +Abstract: + + Provides utility function to SampleApp.cpp. + +Environment: + + User mode + +--*/ + +#include "Utils.h" + +// +// Service trace event provider +// {54a25c42-cd91-4210-98cc-c3447b56e447} +// +EXTERN_C __declspec(selectany) const GUID SERVICE_PROVIDER_GUID = { 0x54a25c42, 0xcd91, 0x4210,{ 0x98, 0xcc, 0xc3, 0x44, 0x7b, 0x56, 0xe4, 0x47 } }; + +REGHANDLE m_etwRegHandle; + + +/*++ + +Routine Description: + + Sets up logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +SetupEvents() +{ + NTSTATUS status = EventRegister(&SERVICE_PROVIDER_GUID, + nullptr, + nullptr, + &m_etwRegHandle); + + if (status != ERROR_SUCCESS) + { + wprintf(L"Provider not registered. EventRegister failed with error: 0x%08X\n", status); + } +} + + +/*++ + +Routine Description: + + Destroys logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +DestroyEvents() +{ + if (m_etwRegHandle != NULL) + { + EventUnregister(m_etwRegHandle); + } +} + + +/*++ + +Routine Description: + + Log a message. + +Arguments: + + Message - The string message to be logged + + Level - The type of event to be logged. This parameter can + be one of the following values: + + TRACE_LEVEL_CRITICAL + TRACE_LEVEL_ERROR + TRACE_LEVEL_WARNING + TRACE_LEVEL_INFORMATION + TRACE_LEVEL_VERBOSE + +Return Value: + + VOID + +--*/ +VOID +WriteToEventLog( + PWSTR Message, + BYTE Level + ) +{ + if (m_etwRegHandle != NULL) + { + EventWriteString(m_etwRegHandle, Level, 0, Message); + } +} + + +/*++ + +Routine Description: + + Log an error message. + +Arguments: + + Function - The function that gives the error + + Error - The error code + +Return Value: + + VOID + +--*/ +VOID +WriteToErrorLog( + PWSTR Function, + DWORD Error + ) +{ + WCHAR Message[260]; + + StringCchPrintf(Message, ARRAYSIZE(Message), + L"%ws failed with error: 0x%08x", Function, Error); + + WriteToEventLog(Message, TRACE_LEVEL_ERROR); +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h new file mode 100644 index 00000000..b619f461 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Utils.cpp + +Abstract: + + Provides utility function to SampleApp.cpp. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include +#include +#include + +/*++ + +Routine Description: + + Sets up logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID SetupEvents(); + + +/*++ + +Routine Description: + + Destroys logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID DestroyEvents(); + + +/*++ + +Routine Description: + + Log a message. + +Arguments: + + Message - The string message to be logged + + Level - The type of event to be logged. This parameter can + be one of the following values: + + TRACE_LEVEL_CRITICAL + TRACE_LEVEL_ERROR + TRACE_LEVEL_WARNING + TRACE_LEVEL_INFORMATION + TRACE_LEVEL_VERBOSE + +Return Value: + + VOID + +--*/ +VOID WriteToEventLog(PWSTR Message, BYTE Level); + + +/*++ + +Routine Description: + + Log an error message. + +Arguments: + + Function - The function that gives the error + + Error - The error code + +Return Value: + + VOID + +--*/ +VOID WriteToErrorLog(PWSTR Function, DWORD Error); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters new file mode 100644 index 00000000..7f12a302 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters @@ -0,0 +1,54 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx new file mode 100644 index 00000000..68f1f4fd Binary files /dev/null and b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx differ diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj new file mode 100644 index 00000000..eab4b251 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj @@ -0,0 +1,206 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} + osrfx2_DCHU_usersvc + Win32Proj + osrfx2_DCHU_usersvc + 10.0.15063.0 + + + + Application + Unicode + true + v140 + + + Application + Unicode + v140 + + + Application + Unicode + 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.sln b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln new file mode 100644 index 00000000..e09b5650 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln @@ -0,0 +1,73 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component", "{E498C537-BA1A-4E9D-8F1E-9DC7646D2E1A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware", "{E50E958C-B5D0-43E0-9D81-87F484F11E9F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component\osrfx2_DCHU_component.vcxproj", "{F90EFA96-B075-4531-B4E1-F406362D16BF}" + ProjectSection(ProjectDependencies) = postProject + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {26D91630-B8FF-4102-A258-32F7D1C84E20} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware\osrfx2_DCHU_componentsoftware.vcxproj", "{26D91630-B8FF-4102-A258-32F7D1C84E20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.ActiveCfg = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Build.0 = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Deploy.0 = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Build.0 = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.ActiveCfg = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Build.0 = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Deploy.0 = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.ActiveCfg = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Build.0 = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Deploy.0 = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.ActiveCfg = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Build.0 = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Deploy.0 = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.ActiveCfg = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Build.0 = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Deploy.0 = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.ActiveCfg = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Build.0 = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Deploy.0 = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.ActiveCfg = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Build.0 = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Deploy.0 = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM64.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.ActiveCfg = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.Build.0 = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.Build.0 = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM64.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.ActiveCfg = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.Build.0 = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {F90EFA96-B075-4531-B4E1-F406362D16BF} = {E498C537-BA1A-4E9D-8F1E-9DC7646D2E1A} + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {E50E958C-B5D0-43E0-9D81-87F484F11E9F} + EndGlobalSection +EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters new file mode 100644 index 00000000..fa953f4c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx new file mode 100644 index 00000000..2d9bb813 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx @@ -0,0 +1,64 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_component.INF +; +;Abstract: +; +; Installation inf for one of the OSR FX2 Learning Kit's +; AddComponent directives +; +;--*/ + +[Version] +Signature = "$Windows NT$" +Class = SoftwareComponent +ClassGuid = {5c4c3332-344d-483c-8739-259e934c9cc8} +Provider = %ManufacturerName% +CatalogFile = osrfx2_DCHU_component.cat + +[Manufacturer] +%ManufacturerName% = OsrFx2Component, NT$ARCH$ + +[OsrFx2Component.NT$ARCH$] +%DeviceName% = OsrFx2Component_Install, SWC\VID_045e&PID_94ab + +[SourceDisksFiles] +osrfx2_DCHU_componentsoftware.exe = 1 + +[SourceDisksNames] +1 = %DiskName% + +[DestinationDirs] +DefaultDestDir = 13 ; copy to driverstore + +[OsrFx2Component_Install.NT] +CopyFiles = OsrFx2Component_CopyFiles + +[OsrFx2Component_Install.NT.Services] +AddService = , 0x00000002 + +[OsrFx2Component_Install.NT.Software] +AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall + +[OsrFx2Component_SoftwareInstall] +SoftwareType = 1 +SoftwareBinary = osrfx2_DCHU_componentsoftware.exe +SoftwareArguments = <> +SoftwareVersion = 1.0.0.0 + +[OsrFx2Component_CopyFiles] +osrfx2_DCHU_componentsoftware.exe + +[Strings] +ManufacturerName = "Contoso" +DiskName = "OsrFx2 DCHU Component Installation Disk" +DeviceName = "OsrFx2 DCHU Component Device" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj new file mode 100644 index 00000000..fed7ddf4 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj @@ -0,0 +1,272 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + + + + + + + + + + + + + + + + + + + {F90EFA96-B075-4531-B4E1-F406362D16BF} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.5 + 12.0 + Debug + Win32 + osrfx2_DCHU_component + osrfx2_DCHU_component + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp new file mode 100644 index 00000000..c14e66d1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp @@ -0,0 +1,489 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + osrfx2_DCHU_componentsoftware.cpp + +Abstract: + + An example .exe to run using the AddSoftware directive within an INF. + Contains an example on how to obtain a handle to the primary device using + SoftwareArguments within an AddSoftware directive's section. + +Environment: + + User mode + +--*/ + +#include "stdafx.h" + +#define BUFFER_SIZE (128 * sizeof(WCHAR)) +#define DEVICE_REG_SUBKEY L"OSR" +#define DEVICE_VALUE_OP_MODE L"OperatingMode" +#define DEVICE_VALUE_OP_PARAMS L"OperatingParams" +#define DEVICE_VALUE_OP_EXCEPTIONS L"OperatingExceptions" +#define CONTOSO_FILEPATH L"C:\\Program Files\\Contoso" +#define OSRFX2_DCHU_FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU" +#define FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU\\AddSoftwareInstallationFile.txt" +#define FILE_CONTENT L"Operating Mode: %ws\r\nOperating Params: %ws\r\nOperating Exceptions: %ws" + + +/*++ + +Routine Description: + +Arguments: + +Return Value: + + +--*/ +DWORD +WriteToFile( + _In_ PWSTR MessageText, + _In_ DWORD MessageTextLength + ) +{ + DWORD Err = ERROR_SUCCESS; + BOOL ErrorFlag = FALSE; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD BytesToWrite; + DWORD BytesWritten; + + if (!CreateDirectory(CONTOSO_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + if (!CreateDirectory(OSRFX2_DCHU_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + hFile = CreateFile(FILEPATH, + GENERIC_WRITE, + 0, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + BytesToWrite = MessageTextLength * sizeof(WCHAR); + + ErrorFlag = WriteFile(hFile, + MessageText, + BytesToWrite, + &BytesWritten, + NULL); + + if ((!ErrorFlag) || + (BytesToWrite != BytesWritten)) + { + Err = GetLastError(); + goto cleanup; + } + +cleanup: + + if (hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile); + } + + return Err; +} + + +/*++ + +Routine Description: + + Obtains the handle to the device that used a separate Software Component + INF to install software. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +__cdecl +_tmain( + INT Argc, + TCHAR *Argv[]) +{ + DWORD Err = ERROR_SUCCESS; + HRESULT hr = S_OK; + BOOL ErrorFlag = FALSE; + DWORD BytesToWrite = 0; + DWORD BytesWritten = 0; + PTSTR DeviceInstanceId; + HDEVINFO DevInfoList = INVALID_HANDLE_VALUE; + SP_DEVINFO_DATA DevInfoData; + WCHAR ParentDeviceInstanceId[MAX_DEVICE_ID_LEN]; + DWORD RequiredSize; + DEVPROPTYPE DevPropType; + SP_DEVINFO_DATA ParentDevInfoData; + HKEY DevRegKey = NULL; + PWSTR OperatingMode = NULL; + PWSTR OperatingParams = NULL; + PWSTR OperatingExceptions = NULL; + DWORD ValueType; + DWORD ValueSize = BUFFER_SIZE; + HKEY DevOsrRegKey = NULL; + PWSTR FileText = NULL; + DWORD FileTextLength; + + // + // Validate arguments. + // + if (Argc != 2) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + OperatingMode = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingMode == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingParams = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingParams == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingExceptions = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingExceptions == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + // + // Argv[1] should be the device instance ID. + // + DeviceInstanceId = Argv[1]; + + // + // Create a device info list to store queried device handles. + // + DevInfoList = SetupDiCreateDeviceInfoList(NULL, NULL); + + if (DevInfoList == INVALID_HANDLE_VALUE) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Add the Software Component device that called AddSoftware to the + // device info list, which will be used to find the primary device that + // called AddComponent in the first place. + // + if (!SetupDiOpenDeviceInfo(DevInfoList, + DeviceInstanceId, + NULL, + 0, + &DevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Get the device instance id of the opened device's parent. + // + if (!SetupDiGetDeviceProperty(DevInfoList, + &DevInfoData, + &DEVPKEY_Device_Parent, + &DevPropType, + (PBYTE)ParentDeviceInstanceId, + sizeof(ParentDeviceInstanceId), + &RequiredSize, + 0)) + { + Err = GetLastError(); + goto cleanup; + } + + if ((DevPropType != DEVPROP_TYPE_STRING) || + (RequiredSize < sizeof(WCHAR))) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + ParentDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Get the parent of the device we retrieved first, which is the device + // that called AddComponent in its INF. + // + if (!SetupDiOpenDeviceInfoW(DevInfoList, + ParentDeviceInstanceId, + NULL, + 0, + &ParentDevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Open up the HW registry keys of the primary device. + // + DevRegKey = SetupDiOpenDevRegKey(DevInfoList, + &ParentDevInfoData, + DICS_FLAG_GLOBAL, + 0, + DIREG_DEV, + KEY_READ); + + if (DevRegKey == INVALID_HANDLE_VALUE) + { + Err = GetLastError(); + DevRegKey = NULL; + goto cleanup; + } + + Err = RegOpenKeyEx(DevRegKey, + DEVICE_REG_SUBKEY, + 0, + KEY_QUERY_VALUE, + &DevOsrRegKey); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + + // + // Retrieve the registry values defined in the primary device's INF. + // Note that if the extension INF was applied, the extension INF would + // overwrite OperatingParams and create OperatingExceptions. + // + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingMode = (PTSTR)realloc(OperatingMode, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingMode[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingMode[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_PARAMS, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingParams = (PTSTR)realloc(OperatingParams, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingParams[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingParams[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingExceptions = (PTSTR)realloc(OperatingExceptions, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingExceptions[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingExceptions[0] = TEXT('\0'); + } + + FileTextLength = (DWORD)wcslen(OperatingMode) + + (DWORD)wcslen(OperatingParams) + + (DWORD)wcslen(OperatingExceptions) + + (DWORD)wcslen(FILE_CONTENT) - + 9; // Subtract the 3 %ws + + FileText = (PWSTR)malloc((FileTextLength + 1) * sizeof(WCHAR)); + + if (FileText == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + hr = StringCchPrintf(FileText, + FileTextLength + 1, + FILE_CONTENT, + OperatingMode, + OperatingParams, + OperatingExceptions); + + if (FAILED(hr)) + { + Err = HRESULT_CODE(hr); + goto cleanup; + } + + Err = WriteToFile(FileText, FileTextLength); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + +cleanup: + + if (FileText != NULL) + { + free(FileText); + } + + if (OperatingExceptions != NULL) + { + free(OperatingExceptions); + } + + if (OperatingParams != NULL) + { + free(OperatingParams); + } + + if (OperatingMode != NULL) + { + free(OperatingMode); + } + + if (DevOsrRegKey != NULL) + { + RegCloseKey(DevOsrRegKey); + } + + if (DevRegKey != NULL) + { + RegCloseKey(DevRegKey); + } + + if (DevInfoList != INVALID_HANDLE_VALUE) + { + SetupDiDestroyDeviceInfoList(DevInfoList); + } + + return; +} + diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters new file mode 100644 index 00000000..395438fa --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj new file mode 100644 index 00000000..c9f4e88b --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj @@ -0,0 +1,168 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {26D91630-B8FF-4102-A258-32F7D1C84E20} + Win32Proj + osrfx2_DCHU_componentsoftware + 10.0.15063.0 + osrfx2_DCHU_componentsoftware + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + $(ProjectName) + + + false + + + false + $(ProjectName) + .exe + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp new file mode 100644 index 00000000..79325e21 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// osrusbfx2umsoftware.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h new file mode 100644 index 00000000..edb61924 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h @@ -0,0 +1,18 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: reference additional headers your program requires here diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h new file mode 100644 index 00000000..87c0086d --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln new file mode 100644 index 00000000..517da9dd --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension\osrfx2_DCHU_extension.vcxproj", "{0588DF70-3923-42E6-8DC9-13C2C0186F20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.ActiveCfg = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Build.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Deploy.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Build.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.ActiveCfg = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Build.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Deploy.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.ActiveCfg = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Build.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Deploy.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.ActiveCfg = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Build.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Deploy.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.ActiveCfg = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Build.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Deploy.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.ActiveCfg = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Build.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Deploy.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.ActiveCfg = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Build.0 = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters new file mode 100644 index 00000000..0ba1a59c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx new file mode 100644 index 00000000..bc81fc7f --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx @@ -0,0 +1,48 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_extension.INF +; +;Abstract: +; +; Extension inf for the OSR FX2 Learning Kit +; +;--*/ + +[Version] +Signature = "$WINDOWS NT$" +Class = Extension +ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} +Provider = %ManufacturerName% +ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} +CatalogFile = osrfx2_DCHU_extension.cat +DriverVer = 05/16/2017,15.14.36.721 + +[Manufacturer] +%ManufacturerName% = OsrFx2Extension, NT$ARCH$ + +[OsrFx2Extension.NT$ARCH$] +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_045e&Pid_94aa&mi_00 +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 + +[OsrFx2Extension_Install.NT] +; empty + +[OsrFx2Extension_Install.NT.HW] +AddReg = OsrFx2Extension_AddReg + +[OsrFx2Extension_AddReg] +HKR, OSR, "OperatingParams",, "-Extended" +HKR, OSR, "OperatingExceptions",, "x86" + +[Strings] +ManufacturerName = "Contoso" +OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" \ 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 new file mode 100644 index 00000000..84cc35c5 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj @@ -0,0 +1,262 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + {0588DF70-3923-42E6-8DC9-13C2C0186F20} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.5 + 12.0 + Debug + Win32 + osrfx2_DCHU_extension + osrfx2_DCHU_extension + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + + \ No newline at end of file -- cgit v1.3.1 From e98f4cac93ec65a484be77d8a795538b02dab72e Mon Sep 17 00:00:00 2001 From: Girish Pattabiraman Date: Tue, 6 Jun 2017 17:52:51 -0700 Subject: 1. Removed property page extension to make Sysvad universal driver. 2. Updated project files to build with universal Target platform 3. Sample componentized INFs added to SysVad --- .../KeywordDetectorContosoAdapter.vcxproj | 8 +- audio/sysvad/Package/package.VcxProj | 3 - audio/sysvad/README.md | 8 +- audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj | 8 +- audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj.Filters | 21 +- audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj | 8 +- .../SwapAPO/DelayAPO/DelayAPO.vcxproj.Filters | 60 + .../PropPageExtensions/AdvEndpointPropPage.cpp | 1087 ------------------ .../PropPageExtensions/AdvEndpointPropPage.h | 74 -- .../PropPageExtensions/AdvEndpointPropPage.rgs | 27 - audio/sysvad/SwapAPO/PropPageExtensions/CplExt.cpp | 73 -- audio/sysvad/SwapAPO/PropPageExtensions/CplExt.idl | 73 -- audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rc | 208 ---- audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rgs | 11 - audio/sysvad/SwapAPO/PropPageExtensions/Parts.cpp | 298 ----- audio/sysvad/SwapAPO/PropPageExtensions/Parts.h | 49 - .../SwapAPO/PropPageExtensions/PropPageExt.def | 9 - .../SwapAPO/PropPageExtensions/PropPageExt.vcxproj | 275 ----- .../PropPageExtensions/PropPageExt.vcxproj.Filters | 51 - .../SwapAPO/PropPageExtensions/SwapPropPage.cpp | 1154 -------------------- .../SwapAPO/PropPageExtensions/SwapPropPage.h | 92 -- .../SwapAPO/PropPageExtensions/SwapPropPage.rgs | 27 - .../PropPageExtensions/TopologyExaminers.cpp | 162 --- .../SwapAPO/PropPageExtensions/TopologyExaminers.h | 50 - .../SwapAPO/PropPageExtensions/UIWidgets.cpp | 321 ------ .../sysvad/SwapAPO/PropPageExtensions/UIWidgets.h | 405 ------- audio/sysvad/SwapAPO/PropPageExtensions/makefile | 36 - audio/sysvad/SwapAPO/PropPageExtensions/music.ico | Bin 26694 -> 0 bytes audio/sysvad/SwapAPO/PropPageExtensions/resource.h | 34 - audio/sysvad/SwapAPO/PropPageExtensions/sources | 60 - audio/sysvad/SwapAPO/PropPageExtensions/stdafx.cpp | 18 - audio/sysvad/SwapAPO/PropPageExtensions/stdafx.h | 67 -- .../TabletAudioSample/ComponentizedApoSample.inf | Bin 0 -> 15522 bytes .../TabletAudioSample/ComponentizedAudioSample.inf | Bin 0 -> 43560 bytes .../ComponentizedAudioSampleExtension.inf | Bin 0 -> 9534 bytes .../TabletAudioSample/TabletAudioSample.vcxproj | 8 +- .../sysvad/TabletAudioSample/tabletaudiosample.inf | Bin 65586 -> 61298 bytes audio/sysvad/sysvad.sln | 4 - 38 files changed, 97 insertions(+), 4692 deletions(-) create mode 100644 audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj.Filters delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.cpp delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.h delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.rgs delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/CplExt.cpp delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/CplExt.idl delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rc delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rgs delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/Parts.cpp delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/Parts.h delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.def delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj.Filters delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.cpp delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.h delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.rgs delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.cpp delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.h delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.cpp delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.h delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/makefile delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/music.ico delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/resource.h delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/sources delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/stdafx.cpp delete mode 100644 audio/sysvad/SwapAPO/PropPageExtensions/stdafx.h create mode 100644 audio/sysvad/TabletAudioSample/ComponentizedApoSample.inf create mode 100644 audio/sysvad/TabletAudioSample/ComponentizedAudioSample.inf create mode 100644 audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inf diff --git a/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj b/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj index fc459cfa..54913231 100644 --- a/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj +++ b/audio/sysvad/KeywordDetectorAdapter/KeywordDetectorContosoAdapter.vcxproj @@ -31,7 +31,7 @@ Windows10 False - Desktop + Universal WindowsApplicationForDrivers10.0 DynamicLibrary @@ -39,7 +39,7 @@ Windows10 True - Desktop + Universal WindowsApplicationForDrivers10.0 DynamicLibrary @@ -47,7 +47,7 @@ Windows10 False - Desktop + Universal WindowsApplicationForDrivers10.0 DynamicLibrary @@ -55,7 +55,7 @@ Windows10 True - Desktop + Universal WindowsApplicationForDrivers10.0 DynamicLibrary diff --git a/audio/sysvad/Package/package.VcxProj b/audio/sysvad/Package/package.VcxProj index 0ea6ab39..cd7c9ddc 100644 --- a/audio/sysvad/Package/package.VcxProj +++ b/audio/sysvad/Package/package.VcxProj @@ -31,9 +31,6 @@ {8851AB85-70B3-4798-A149-BA366DF9EC25} - - {D253C552-154D-49E1-820A-B2CD9D9FF13E} - {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF} diff --git a/audio/sysvad/README.md b/audio/sysvad/README.md index a7bce35e..9dfc0193 100644 --- a/audio/sysvad/README.md +++ b/audio/sysvad/README.md @@ -28,7 +28,7 @@ Perform the following steps to build this sample driver. In Microsoft Visual Studio, Click **File** \> **Open** \> **Project/Solution...** and navigate to the folder that contains the sample files (for example, *C:\Windows-driver-samples\audio\sysvad*). Double-click the *sysvad* solution file. -In Visual Studio locate the Solution Explorer. (If this is not already open, choose **Solution Explorer** from the **View** menu.) In Solution Explorer, you can see one solution that has four projects. Note that the project titled SwapAPO is actually a folder that contains two projects - APO and PropPageExtensions. +In Visual Studio locate the Solution Explorer. (If this is not already open, choose **Solution Explorer** from the **View** menu.) In Solution Explorer, you can see one solution that has four projects. **2. Set the sample's configuration and platform** @@ -48,14 +48,12 @@ The package should contain these files: File | Description -----|------------ -TabletAudioSample.sys OR PhoneAudioSample| The driver file. +TabletAudioSample.sys OR PhoneAudioSample.sys| The driver file. SwapAPO.dll | A sample APO. DelayAPO.dll | A sample APO. -PropPageExt.dll | A sample driver extension for a property page. sysvad.cat | A signed catalog file, which serves as the signature for the entire package. TabletAudioSample.inf | An information (INF) file that contains information needed to install the driver. -PhoneAudioSample.inf | An information (INF) file that contains information needed to install the driver. -WdfCoinstaller01011.dll | The coinstaller for version 1.xx of KMDF. +PhoneAudioSample.inf | An information (INF) file that contains information needed to install the driver. Run the sample -------------- diff --git a/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj b/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj index 87400997..563f6375 100644 --- a/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj +++ b/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj @@ -31,7 +31,7 @@ Windows10 False - Desktop + Universal false WindowsApplicationForDrivers10.0 @@ -40,7 +40,7 @@ Windows10 True - Desktop + Universal false WindowsApplicationForDrivers10.0 @@ -49,7 +49,7 @@ Windows10 False - Desktop + Universal false WindowsApplicationForDrivers10.0 @@ -58,7 +58,7 @@ Windows10 True - Desktop + Universal false WindowsApplicationForDrivers10.0 diff --git a/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj.Filters b/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj.Filters index 7cb395b8..631acbca 100644 --- a/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj.Filters +++ b/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj.Filters @@ -33,13 +33,28 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + Header Files + + + + + + Resource Files + + + Source Files + + \ No newline at end of file diff --git a/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj b/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj index 229ce262..68fd57b6 100644 --- a/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj +++ b/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj @@ -31,7 +31,7 @@ Windows10 False - Desktop + Universal false WindowsApplicationForDrivers10.0 @@ -40,7 +40,7 @@ Windows10 True - Desktop + Universal false WindowsApplicationForDrivers10.0 @@ -49,7 +49,7 @@ Windows10 False - Desktop + Universal false WindowsApplicationForDrivers10.0 @@ -58,7 +58,7 @@ Windows10 True - Desktop + Universal false WindowsApplicationForDrivers10.0 diff --git a/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj.Filters b/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj.Filters new file mode 100644 index 00000000..a1e7102a --- /dev/null +++ b/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj.Filters @@ -0,0 +1,60 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {5f4ff11d-7a0b-4f75-9d79-744ae028cc53} + + + h;hpp;hxx;hm;inl;inc;xsd + {bd103b81-05b2-440e-84e7-0723d7fe4109} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {a57b6b78-38ae-4348-ade3-0200e81a3dd7} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + + + + Header Files + + + + Header Files + + + + + + Resource Files + + + Source Files + + + \ No newline at end of file diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.cpp b/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.cpp deleted file mode 100644 index 73c243b4..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.cpp +++ /dev/null @@ -1,1087 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: AdvEndpointPropPage.cpp -// -// Abstract: Implementation of CAdvEndpointPropPage -// -// ---------------------------------------------------------------------------- - - -#include "stdafx.h" -#include -#include -#include "UIWidgets.h" -#include "Parts.h" -#include "TopologyExaminers.h" -#include "AdvEndpointPropPage.h" -#include - -_Analysis_mode_(_Analysis_code_type_user_driver_) - -#define MAX_SEARCH_DEPTH 5 // when searching for a host pin or interface - -static IID s_rgAdvCtrlInterfaces[] = -{ - __uuidof(IAudioLoudness), - __uuidof(IAudioAutoGainControl), - __uuidof(IDeviceSpecificProperty) -}; - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::CAdvEndpointPropPage -// -// Description: -// CAdvEndpointPropPage constructor -// ---------------------------------------------------------------------------- -CAdvEndpointPropPage::CAdvEndpointPropPage() -: m_pAudioExtParams(NULL) -{ -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::~CAdvEndpointPropPage -// -// Description: -// CAdvEndpointPropPage destructor -// ---------------------------------------------------------------------------- -CAdvEndpointPropPage::~CAdvEndpointPropPage() -{ - CUIWidget* pWidget; - - while (m_lstWidgets.RemoveHead(&pWidget)) - { - SAFE_DELETE(pWidget); - } - - SAFE_RELEASE(m_pAudioExtParams->pEndpoint); - SAFE_RELEASE(m_pAudioExtParams->pPnpInterface); - SAFE_RELEASE(m_pAudioExtParams->pPnpDevnode); - - SAFE_DELETE(m_pAudioExtParams); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::MakeNewWidget -// -// Description: -// Adds a widget to the list -// -// Parameters: -// pPart - [in] Part interface -// iid - [in] Advanced control IID which controls the kind of widget -// that gets created -// nCtrlId - [in] ID of the control -// -// Return: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CAdvEndpointPropPage::MakeNewWidget -( - IPart* pPart, - REFIID iid, - UINT nCtrlId -) -{ - UNREFERENCED_PARAMETER(nCtrlId); - - HRESULT hr = S_OK; - LISTPOS posChk; - CUIWidget* pNewWidget = NULL; - - if ((iid == __uuidof(IAudioLoudness)) || - (iid == __uuidof(IAudioAutoGainControl))) - { - pNewWidget = new CBooleanWidget(pPart, iid); - IF_TRUE_ACTION_JUMP((pNewWidget == NULL), hr = E_OUTOFMEMORY, Exit); - } - else if (iid == __uuidof(IDeviceSpecificProperty)) - { - CComPtr spDevSpec; - VARTYPE vt; - - hr = pPart->Activate(CLSCTX_INPROC_SERVER, __uuidof(IDeviceSpecificProperty), (void**)&spDevSpec); - IF_FAILED_JUMP(hr, Exit); - - hr = spDevSpec->GetType(&vt); - IF_FAILED_JUMP(hr, Exit); - - if (vt == VT_BOOL) - { - pNewWidget = new CBooleanWidget(pPart, iid); - IF_TRUE_ACTION_JUMP((pNewWidget == NULL), hr = E_OUTOFMEMORY, Exit); - } - else if (vt == VT_I4) - { - pNewWidget = new CLongWidget(pPart); - IF_TRUE_ACTION_JUMP((pNewWidget == NULL), hr = E_OUTOFMEMORY, Exit); - } - else if (vt == VT_UI4) - { - pNewWidget = new CLongWidget(pPart); - IF_TRUE_ACTION_JUMP((pNewWidget == NULL), hr = E_OUTOFMEMORY, Exit); - } - else - { - hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - goto Exit; - } - } - - ATLASSERT(pNewWidget); - - posChk = m_lstWidgets.AddTail(pNewWidget); - if (posChk == NULL) - { - hr = E_OUTOFMEMORY; - SAFE_DELETE(pNewWidget); - } - -Exit: - return hr; -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::GetDeviceFriendlyName -// -// Description: -// Retrieves the endpoint's friendly name -// -// Parameters: -// ppNameOut - [out] The friendly name of the endpoint -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CAdvEndpointPropPage::GetDeviceFriendlyName -( - _Outptr_result_maybenull_ LPWSTR* ppNameOut -) -{ - HRESULT hr = S_OK; - CComPtr spProperties; - PROPVARIANT var; - - IF_TRUE_ACTION_JUMP((m_pAudioExtParams == NULL), hr = E_POINTER, Exit); - IF_TRUE_ACTION_JUMP((ppNameOut == NULL), hr = E_POINTER, Exit); - - *ppNameOut = NULL; - - PropVariantInit(&var); - - if (m_pAudioExtParams->pEndpoint != NULL) - { - // Open the PropertyStore for read access - hr = m_pAudioExtParams->pEndpoint->OpenPropertyStore(STGM_READ, &spProperties); - IF_FAILED_JUMP(hr, Exit); - - // Retrieve the friendly name of the endpoint - hr = spProperties->GetValue(PKEY_Device_FriendlyName, &var); - if (SUCCEEDED(hr) && (var.vt == VT_LPWSTR)) - { - *ppNameOut = var.pwszVal; - } - else - { - PropVariantClear(&var); - } - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::OnInitDialog -// -// Description: -// Dialog initialization routine -// -// Parameters: -// hwndDlg - [in] Handle to dialog box -// wParam - [in] Handle to control to receive the default keyboard focus -// lParam - [in] Specifies additional message-specific information -// -// Return values: -// TRUE to direct the system to set the keyboard focus to the control -// specified by wParam. Otherwise, it should return FALSE to prevent the -// system from setting the default keyboard focus. -// ---------------------------------------------------------------------------- -BOOL CAdvEndpointPropPage::OnInitDialog -( - HWND hwndDlg, - WPARAM wParam, - LPARAM lParam -) -{ - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - - LPWSTR pwstrEndpointName = NULL; - - LISTPOS pos; - CUIWidget* pWidget; - SRECT rcWidget(34, 144, 0, 0); - RECT rcDlg; - HRESULT hr = S_OK; - UINT id = 1800; - - // Retrieve the endpoint's friendly name - hr = GetDeviceFriendlyName(&pwstrEndpointName); - IF_FAILED_JUMP(hr, Exit); - - // Update the property page with retrieved information - SetWindowText(GetDlgItem(hwndDlg, IDC_EPP_ENDPOINT_NAME), pwstrEndpointName); - - // Initialize and create widgets - hr = InitializeWidgets(); - if (hr == E_NOTFOUND) - { - // If no widgets were found, show a message to depict that - SetWindowText(GetDlgItem(hwndDlg, IDC_NO_ADV_CONTROLS_FOUND), - L"No advanced controls found."); - } - else - { - // Create widget windows - ::GetClientRect(hwndDlg, &rcDlg); - rcWidget.w = rcDlg.right - rcDlg.left - 28; - rcWidget.h = 14; - - pos = m_lstWidgets.GetHeadPosition(); - while (pos) - { - pWidget = NULL; - m_lstWidgets.GetNext(pos, &pWidget); - - hr = pWidget->Create(hwndDlg, rcWidget, id); - if (SUCCEEDED(hr)) - { - id++; - - // offset to next widget - rcWidget.y = rcWidget.y + rcWidget.h + 12; - } - } - } - -Exit: - SAFE_COTASKMEMFREE(pwstrEndpointName); - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::OnApply -// -// Description: -// Handle the pressing of the apply button -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// wParam - [in] Handle to the control to receive the default keyboard focus -// lParam - [in] Specifies additional message-specific information -// -// Return values: -// TRUE to set keyboard focus on control -// ---------------------------------------------------------------------------- -BOOL CAdvEndpointPropPage::OnApply -( - HWND hwndDlg, - WPARAM wParam, - LPARAM lParam -) -{ - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - - CUIWidget* pWidget; - LISTPOS pos; - - pos = m_lstWidgets.GetHeadPosition(); - - while (pos) - { - pWidget = NULL; - m_lstWidgets.GetNext(pos, &pWidget); - pWidget->CommitValue(); - } - - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); - - return(TRUE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::OnCheckBoxClicked -// -// Description: -// Handle the clicking of the check boxes -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// wParam - [in] Handle to the control to receive the default keyboard focus -// lParam - [in] Specifies additional message-specific information -// -// Return values: -// FALSE to not set default keyboard focus -// ---------------------------------------------------------------------------- -BOOL CAdvEndpointPropPage::OnCheckBoxClicked -( - HWND hwndDlg, - WPARAM wParam, - LPARAM lParam -) -{ - UNREFERENCED_PARAMETER(lParam); - - CUIWidget* pWidget; - LISTPOS pos; - - pos = m_lstWidgets.GetHeadPosition(); - - while (pos) - { - pWidget = NULL; - m_lstWidgets.GetNext(pos, &pWidget); - - if (pWidget->OwnsCtrlId(LOWORD(wParam))) - { - pWidget->OnClick(); - } - } - - // Enable the Apply button upon user changing the control - SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); - - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::DialogProcPage1 -// -// Description: -// Callback for property page -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// uMsg - [in] Specifies the message -// wParam - [in] Specifies additional message-specific information -// lParam - [in] Specifies additional message-specific information -// -// Return values: -// TRUE if it processed the message, FALSE if not -// ---------------------------------------------------------------------------- -INT_PTR CALLBACK CAdvEndpointPropPage::DialogProcPage1 -( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - CAdvEndpointPropPage* pthis = (CAdvEndpointPropPage*)(LONG_PTR)GetWindowLongPtr( - hwndDlg, GWLP_USERDATA); - BOOL fRet = FALSE; - - switch (uMsg) - { - case WM_INITDIALOG: - { - // Extract the context data from PROPSHEETPAGE::lParam - PROPSHEETPAGE* pSheetDesc = (PROPSHEETPAGE*)lParam; - - // Create the property page factory class -#pragma warning(push) -#pragma warning(disable: 28197) - pthis = new CComObject(); -#pragma warning(pop) - if (pthis == NULL) - { - return(FALSE); - } - - // Save this object in lParam - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)pthis); - - // Keep audio extension parameters passed by the control panel - pthis->m_pAudioExtParams = (AudioExtensionParams*)pSheetDesc->lParam; - - fRet = pthis->OnInitDialog(hwndDlg, wParam, lParam); - break; - } - - case WM_NOTIFY: - { - switch (((NMHDR FAR*)lParam)->code) - { - case PSN_APPLY: - if (pthis) - { - // Apply button pressed - fRet = pthis->OnApply(hwndDlg, wParam, lParam); - } - break; - } - break; - } - - case WM_COMMAND: - { - if (pthis) - { - // Check box clicked - fRet = pthis->OnCheckBoxClicked(hwndDlg, wParam, lParam); - } - break; - } - - case WM_DESTROY: - { - SAFE_DELETE(pthis); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL); - fRet = TRUE; - break; - } - } - - return(fRet); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::PropSheetPageProc -// -// Description: -// Callback that gets invoked right after page creation or right before -// before page destruction -// -// Parameters: -// hwnd - Reserved; must be NULL -// uMsg - [in] Action flag. PSPCB_ADDREF, PSPCB_CREATE, or PSPCB_RELEASE -// ppsp - [in, out] Pointer to a PROPSHEETPAGE structure that defines -// the page being created or destroyed. -// -// Return values: -// Depends on the value of the uMsg parameter -// ---------------------------------------------------------------------------- -UINT CALLBACK CAdvEndpointPropPage::PropSheetPageProc -( - HWND hwnd, - UINT uMsg, - LPPROPSHEETPAGE ppsp -) -{ - UNREFERENCED_PARAMETER(hwnd); - UNREFERENCED_PARAMETER(uMsg); - UNREFERENCED_PARAMETER(ppsp); - - // if (uMsg == PSPCB_CREATE) ... - return(1); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::Initialize -// -// Description: -// Implementation of IShellExtInit::Initialize. Initializes a property -// sheet extension, shortcut menu extension, or drag-and-drop handler. -// -// Parameters: -// pidlFolder - [in] Address of an ITEMIDLIST structure that uniquely -// identifies a folder. For property sheet extensions, -// this parameter is NULL. -// pdtobj - [out] Address of an IDataObject interface object that can be -// used to retrieve the objects being acted upon. -// hkeyProgID - [in] Registry key for the file object or folder type. -// -// Return values: -// Returns NOERROR if successful, or an OLE-defined error value otherwise -// ---------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT CAdvEndpointPropPage::Initialize -( - LPCITEMIDLIST pidlFolder, - IDataObject* pdtobj, - HKEY hkeyProgID -) -{ - UNREFERENCED_PARAMETER(pidlFolder); - UNREFERENCED_PARAMETER(pdtobj); - UNREFERENCED_PARAMETER(hkeyProgID); - - return(S_OK); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::FindHostConnector -// -// Description: -// This method initiates a search for a software connector that supports -// the supplied format. If one is found, it returns a path to that -// connector. -// -// Parameters: -// pKsFormat - [in] Requested format -// cbFormat - [in] Size of format buffer in BYTEs -// bRejectMixedPaths - [in] If TRUE, stop looking if you find a mix unit -// ppPath - [out] The path to the Host pin -// -// Remarks: -// To get the host connector, just take the zeroth element in the -// resulting path -// -// Return: -// S_OK on success, E_NOTFOUND if not. Other error code indicates -// something unexpected. -// ---------------------------------------------------------------------------- -HRESULT CAdvEndpointPropPage::FindHostConnector -( - PKSDATAFORMAT pKsFormat, - ULONG cbFormat, - BOOL bRejectMixedPaths, - IPartsList** ppPath -) -{ - HRESULT hr; - CPartsList* pPathOut = NULL; - CComPtr spTopology; - UINT cConnectors; - CComPtr spEndpointConnector; - CComPtr spConStart; - CComQIPtr spPartStart; - DataFlow flow; - UINT cDepth = 0; - CFormatExaminer* pExaminer = NULL; - - IF_TRUE_ACTION_JUMP((ppPath == NULL), hr = E_POINTER, Exit); - *ppPath = NULL; - - ATLASSERT(m_pAudioExtParams->pEndpoint != NULL); - - // Get IDeviceTopology interface for the Endpoint - hr = m_pAudioExtParams->pEndpoint->Activate(__uuidof(IDeviceTopology), CLSCTX_ALL, NULL, (void**)&spTopology); - IF_FAILED_JUMP(hr, Exit); - - // Get the connector to start searching from. By definition, an endpoint device can only have 1 connector. - hr = spTopology->GetConnectorCount(&cConnectors); - IF_FAILED_JUMP(hr, Exit); - - ATLASSERT(cConnectors == 1); - IF_TRUE_ACTION_JUMP((cConnectors != 1), hr = E_FAIL, Exit); - - // Since an endpoint device can only have 1 connector, get the connector at index 0 - hr = spTopology->GetConnector(0, &spEndpointConnector); - IF_FAILED_JUMP(hr, Exit); - - hr = spEndpointConnector->GetConnectedTo(&spConStart); - IF_FAILED_JUMP(hr, Exit); - - // get the dataflow (required by Search method) - hr = spConStart->GetDataFlow(&flow); - IF_FAILED_JUMP(hr, Exit); - - // QI for IPart (required by Search method) - spPartStart = spConStart; - - // Create an examiner that looks for a pin with the specified format - pExaminer = new CFormatExaminer(pKsFormat, cbFormat); - IF_TRUE_ACTION_JUMP((pExaminer == NULL), hr = E_OUTOFMEMORY, Exit); - - // Create a new parts list -#pragma warning(push) -#pragma warning(disable: 28197) - pPathOut = new CPartsList(); -#pragma warning(pop) - IF_TRUE_ACTION_JUMP((pPathOut == NULL), hr = E_OUTOFMEMORY, Exit); - - // Start looking - hr = Search(spPartStart, flow, pExaminer, pPathOut, cDepth, bRejectMixedPaths); - if (bRejectMixedPaths && (hr == E_NOTFOUND)) - { - // Don't actually reject mixed paths, just avoid them - hr = Search(spPartStart, flow, pExaminer, pPathOut, cDepth, FALSE); - } - IF_FAILED_JUMP(hr, Exit); - - hr = pPathOut->QueryInterface(__uuidof(IPartsList), (void**)ppPath); - -Exit: - SAFE_RELEASE(pPathOut); - - SAFE_DELETE(pExaminer); - - return hr; -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::Search -// -// Description: -// Searches the device topology for parts that satisfy the supplied -// examiner. -// -// Parameters: -// pPartStart - [in] The IPart to start looking at -// flowStart - [in] The flow of the starting part. This never changes -// so it is passed as an argument. -// pExaminer - [in] The examiner that tests each IPart against some criteria -// pPathAggregate - [out] The cumulative path that has been searched -// cDepth - [in] Stop looking if we reach this recursion depth -// bRejectMixedPaths - [in] If TRUE, then stop looking if we encounter a -// MIX unit -// -// Remarks: -// The search may span several FunctionInstances connected by DeviceModel -// IConnections. The algorithm works as follows: -// -// 1) Each connector in the model is tested against the following -// (in order): -// a) Is the flow opposite that of the starting part? -// If no then goto next connector. -// b) Does there exist a path from the starting part to this -// connector? If no then goto next connector. -// c) Is the supplied examiner satisfied by the path? -// If yes, then return. -// d) Is this connector connected to another connector? -// If yes, then add the connector to a list of "deferred -// connectors" to be checked if no other connectors in this model -// satisfy (c) -// -// 2) If the function still hasn't returned, then for each connector in -// the list generated in step 1d: -// a) Get the connector that it is connected to -// b) Recurse into this function with "that" connector as the starting -// part -// -// The point of the list of "deferred connectors" is to minimize the -// length of the paths that we find. e.g. if two viable paths exist, one -// (A) which spans 3 models, and another (B) which spans only 2, then B -// will be found first, regardless of the ordering of connections in the -// models involved. -// -// Note that when a path is found, all of the parts involved in that path -// are aggregated into pPathAggregate IN REVERSE ORDER. In general, all -// the parts in pPathAggregate will not belong to a single model, so when -// using pPathAggregate, you must use IPart::GetTopologyObject to get the -// model and/or FunctionInstance of the part (i.e. don't cache the value -// of either). -// -// Return: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CAdvEndpointPropPage::Search -( - IPart* pPartStart, - DataFlow flowStart, - IExaminer* pExaminer, - CPartsList* pPathAggregate, - UINT cDepth, - BOOL bRejectMixedPaths -) -{ - HRESULT hr = S_OK; - TList lstDeferredConnectors; - BOOL bHaveViableConnector = FALSE; - - { - CComPtr spTopology; - UINT cConnectors; - - // Bail if we are recursing too deep - IF_TRUE_ACTION_JUMP((cDepth == MAX_SEARCH_DEPTH), hr = E_NOTFOUND, Exit); - - // Get DeviceModel and DeviceModelUtil interfaces associated with pPartStart. - // We can't just pass these as params, because each time this function is called - // recursively, we are talking about a part (pPartStart) on a different device. - hr = pPartStart->GetTopologyObject(&spTopology); - IF_FAILED_JUMP(hr, Exit); - - // - // [Step 1] Examine each connector. - // - hr = spTopology->GetConnectorCount(&cConnectors); - IF_FAILED_JUMP(hr, Exit); - - for (UINT c = 0; (c < cConnectors) && !bHaveViableConnector; c++) - { - CComPtr spConTest; - DataFlow flowTest; - CComPtr spPath; - CComPtr spPartTest; - BOOL bConnectorIsConnected; - - hr = spTopology->GetConnector(c, &spConTest); - IF_FAILED_JUMP(hr, Exit); - - hr = spConTest->GetDataFlow(&flowTest); - IF_FAILED_JUMP(hr, Exit); - - // [1a] We only care about connectors whose dataflow is opposite that of pConStart - // (i.e. on the other side of the topology) - if (flowTest == flowStart) - continue; - - // QI for IPart - spPartTest = spConTest; - - ATLASSERT(spPartTest); - IF_TRUE_ACTION_JUMP((spPartTest == NULL), hr = E_NOINTERFACE, Exit); - - // [1b] See if there exists a path from one to the other - hr = spTopology->GetSignalPath(pPartStart, spPartTest, bRejectMixedPaths, &spPath); - - // If no path exists from here to there, then try the next connector - if (hr != S_OK) - continue; - - // [1c] Let pExaminer take a look at this path, but don't worry if it fails - pExaminer->Examine(spPath); - - // See if pExaminer has found what it was looking for yet - if (pExaminer->IsSatisfied()) - { - bHaveViableConnector = TRUE; - - // add all of the parts in spPath to pPathAggregate - hr = pPathAggregate->AddParts(spPath); - break; - } - - // [1d] See if the connector is connected. If so, add to the list of deferred - // connectors - hr = spConTest->IsConnected(&bConnectorIsConnected); - - if (SUCCEEDED(hr) && bConnectorIsConnected) - { - LISTPOS posChk; - IConnector* pConDeferred; - - // Get another interface pointer that is NOT a CComPtr, so it doesn't - // get released until we want (note that .Detach means that when spConTest - // goes out of scope it won't release the interface) - pConDeferred = spConTest.Detach(); - - // Add to list of connectors to look more closely at - posChk = lstDeferredConnectors.AddTail(pConDeferred); - - if (posChk == NULL) - { - hr = E_OUTOFMEMORY; - pConDeferred->Release(); - goto Exit; - } - } - } - - if (!bHaveViableConnector) - { - // - // [Step 2] Jump to connected devices and test them. - // - - LISTPOS pos = lstDeferredConnectors.GetHeadPosition(); - - while (pos != NULL) - { - CComPtr spConConnectedTo; - IConnector* pConDeferred = NULL; // this will be cleaned up at the end of the function - CComPtr spPartConnectedTo; - CComPtr spPath; - CComQIPtr spPartDeferred; - - // Get the deferred connector. RefCount should be 1 - lstDeferredConnectors.GetNext(pos, &pConDeferred); - - // Get the part (a connector) that this connector is connected to - hr = pConDeferred->GetConnectedTo(&spConConnectedTo); - IF_FAILED_JUMP(hr, Exit); - - // Search that device model as well. Note that we can just reuse the dataflow here - spPartConnectedTo = spConConnectedTo; - ATLASSERT(spPartConnectedTo != NULL); - IF_TRUE_ACTION_JUMP((spPartConnectedTo == NULL), hr = E_NOINTERFACE, Exit); - - // Recursion - hr = Search(spPartConnectedTo, flowStart, pExaminer, pPathAggregate, cDepth + 1, bRejectMixedPaths); - if (FAILED(hr)) - continue; - - // We found what we were looking for! - bHaveViableConnector = TRUE; - - // We need to figure out how we got here again and add that path to pPath - spPartDeferred = pConDeferred; - ATLASSERT(spPartDeferred != NULL); - - // Note: If we fail past here, pPathAggregate will contain some parts. These will - // be cleaned up by CPartsList destructor - IF_TRUE_ACTION_JUMP((spPartDeferred == NULL), hr = E_NOINTERFACE, Exit); - - hr = spTopology->GetSignalPath(pPartStart, spPartDeferred, bRejectMixedPaths, &spPath); - IF_FAILED_JUMP(hr, Exit); - - // Add all of the parts in spPath to pPathAggregate - hr = pPathAggregate->AddParts(spPath); - IF_FAILED_JUMP(hr, Exit); - - break; - } - } - } - -Exit: - // Cleanup - IConnector* pConDelete; - while (lstDeferredConnectors.RemoveHead(&pConDelete)) - { - SAFE_RELEASE(pConDelete); - } - - // Adjust result. If there were no errors, but we didn't find what - // we were searching for, then return "not found" - if (SUCCEEDED(hr) && (!bHaveViableConnector)) - { - hr = E_NOTFOUND; - } - - return hr; -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::InitializeWidgets -// -// Description: -// Looks for parts in the path that support any of these control -// interfaces: -// -- IAudioLoudness -// -- IAudioAutoGainControl -// -- IDeviceSpecificProperty -// -// Return: -// S_OK if at least one control found -// E_NOTFOUND if no controls found -// other if unexpected error -// -// --------------------------------------------------------------------------- -HRESULT CAdvEndpointPropPage::InitializeWidgets() -{ - HRESULT hr = S_OK; - HRESULT hrWarn = S_OK; - CComPtr spPath; - UINT cParts; - BOOL bFoundSomething = FALSE; - UINT nCtrlId = 900; - - // Note: Can use the endpoint format instead of this ... - KSDATAFORMAT format; - ZeroMemory(&format, sizeof(format)); - - format.FormatSize = sizeof(KSDATAFORMAT); - format.MajorFormat = KSDATAFORMAT_TYPE_AUDIO; - format.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - format.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX; - - // See if we can find a path to any old PCM host pin by only passing sizeof(KSDATAFORMAT) - hr = FindHostConnector(&format, sizeof(KSDATAFORMAT), FALSE, &spPath); - IF_FAILED_JUMP(hr, Exit); - - // - hr = spPath->GetCount(&cParts); - IF_FAILED_JUMP(hr, Exit); - - // Look for parts that support any of the interfaces in s_rgAdvCtrlInterfaces - for (UINT i = 0; i < cParts; i++) - { - UINT cInterfaces; - CComPtr spPart; - - hr = spPath->GetPart(i, &spPart); - IF_FAILED_JUMP(hr, Exit); - - hr = spPart->GetControlInterfaceCount(&cInterfaces); - IF_FAILED_JUMP(hr, Exit); - - for (UINT j = 0; j < cInterfaces; j++) - { - CComPtr spInterfaceDesc; - GUID iid; - - hr = spPart->GetControlInterface(j, &spInterfaceDesc); - IF_FAILED_JUMP(hr, Exit); - - hr = spInterfaceDesc->GetIID(&iid); - IF_FAILED_JUMP(hr, Exit); - - for (int k = 0; k < ARRAYSIZE(s_rgAdvCtrlInterfaces); k++) - { - if (iid == s_rgAdvCtrlInterfaces[k]) - { - bFoundSomething = TRUE; - - hrWarn = MakeNewWidget(spPart, iid, nCtrlId++); - } - } - } - } - - if (!bFoundSomething) - { - hr = E_NOTFOUND; - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::AddPages -// -// Description: -// Implementation of IShellPropSheetExt::AddPages. Adds one or more pages -// to a property sheet that the Shell displays for a file object. -// -// Parameters: -// lpfnAddPage - [in] Address of a function that the property sheet -// handler calls to add a page to the property sheet. The -// function takes a property sheet handle returned by the -// CreatePropertySheetPage function and the lParam parameter -// passed to the AddPages method. -// lParam - [in] Parameter to pass to the function specified by the -// lpfnAddPage method. -// -// Return values: -// Returns S_OK if successful. If the method fails, an OLE-defined error -// code is returned -// ---------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT STDMETHODCALLTYPE CAdvEndpointPropPage::AddPages -( - LPFNADDPROPSHEETPAGE lpfnAddPage, // See PrSht.h - LPARAM lParam // Used by caller, don't modify -) -{ - HRESULT hr = S_OK; - PROPSHEETPAGE psp; - HPROPSHEETPAGE hPage1 = NULL; - AudioExtensionParams* pAudioParams = (AudioExtensionParams*)lParam; -#pragma warning(push) -#pragma warning(disable: 28197) - AudioExtensionParams* pAudioParamsCopy = new AudioExtensionParams; -#pragma warning(pop) - - if (pAudioParamsCopy == NULL) - { - return E_OUTOFMEMORY; - } - - // Make a copy of the params - CopyMemory(pAudioParamsCopy, pAudioParams, sizeof(AudioExtensionParams)); - SAFE_ADDREF(pAudioParams->pEndpoint); - SAFE_ADDREF(pAudioParams->pPnpInterface); - SAFE_ADDREF(pAudioParams->pPnpDevnode); - - // Initialize property page params and create page - psp.dwSize = sizeof(psp); - psp.dwFlags = PSP_USEREFPARENT | PSP_USECALLBACK; - psp.hInstance = _AtlBaseModule.GetModuleInstance(); - psp.hIcon = 0; - psp.pcRefParent = (UINT*)&m_dwRef; - psp.lParam = (LPARAM)pAudioParamsCopy; - psp.pszTemplate = MAKEINTRESOURCE(IDD_ADV_ENDPOINT_PROP_PAGE); - psp.pfnDlgProc = (DLGPROC)DialogProcPage1; - psp.pfnCallback = PropSheetPageProc; - - // Create the property sheet page and add the page - hPage1 = CreatePropertySheetPage(&psp); - if (hPage1) - { - if (!lpfnAddPage(hPage1, pAudioParams->AddPageParam)) - { - hr = E_FAIL; - delete pAudioParamsCopy; - DestroyPropertySheetPage(hPage1); - } - else - { - // Add ref for page - this->AddRef(); - } - } - else - { - delete pAudioParamsCopy; - hr = E_OUTOFMEMORY; - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CAdvEndpointPropPage::ReplacePage -// -// Description: -// Implementation of IShellPropSheetExt::ReplacePage. Replaces a page in -// a property sheet for a Control Panel object. -// -// Parameters: -// uPageID - [in] Identifier of the page to replace -// lpfnReplacePage - [in] Address of a function that the property sheet -// handler calls to replace a page to the property -// sheet. The function takes a property sheet handle -// returned by the CreatePropertySheetPage function and -// the lParam parameter passed to the ReplacePage -// method. -// lParam - [in] Parameter to pass to the function specified by the -// lpfnReplacePage parameter. -// -// Return values: -// Returns NOERROR if successful, or an OLE-defined error value otherwise -// ---------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT STDMETHODCALLTYPE CAdvEndpointPropPage::ReplacePage -( - UINT uPageID, - LPFNSVADDPROPSHEETPAGE lpfnReplaceWith, - LPARAM lParam -) -{ - UNREFERENCED_PARAMETER(uPageID); - UNREFERENCED_PARAMETER(lpfnReplaceWith); - UNREFERENCED_PARAMETER(lParam); - - return(S_FALSE); -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.h b/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.h deleted file mode 100644 index 0d02ef97..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.h +++ /dev/null @@ -1,74 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: AdvEndpointPropPage.h -// -// Abstract: Declaration of the CAdvEndpointPropPage class -// -// ---------------------------------------------------------------------------- - - -#pragma once - - -class ATL_NO_VTABLE CAdvEndpointPropPage : - public CComObjectRootEx, - public CComCoClass, - public IDispatchImpl, - public IShellExtInit, - public IShellPropSheetExt -{ -public: - CAdvEndpointPropPage(); - ~CAdvEndpointPropPage(); - - DECLARE_REGISTRY_RESOURCEID(IDR_ADV_ENDPOINT_PROP_PAGE) - - BEGIN_COM_MAP(CAdvEndpointPropPage) - COM_INTERFACE_ENTRY(IAdvEndpointPropPage) - COM_INTERFACE_ENTRY(IDispatch) - COM_INTERFACE_ENTRY(IShellExtInit) - COM_INTERFACE_ENTRY(IShellPropSheetExt) - END_COM_MAP() - - DECLARE_PROTECT_FINAL_CONSTRUCT() - - HRESULT FinalConstruct() - { - return S_OK; - } - - void FinalRelease() - { - } - - static INT_PTR CALLBACK DialogProcPage1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - static UINT CALLBACK PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp); - - // IShellExtInit - STDMETHOD(Initialize)(_In_opt_ LPCITEMIDLIST pidlFolder, _In_opt_ IDataObject* pdtobj, _In_opt_ HKEY hkeyProgID); - - // IShellPropSheetExt - STDMETHOD(AddPages)(_In_ LPFNADDPROPSHEETPAGE lpfnAddPage, _In_ LPARAM lParam); - STDMETHOD(ReplacePage)(_In_ UINT uPageID, _In_ LPFNSVADDPROPSHEETPAGE lpfnReplaceWith, _In_ LPARAM lParam); - -private: - AudioExtensionParams* m_pAudioExtParams; - TList m_lstWidgets; - - HRESULT FindHostConnector(PKSDATAFORMAT pKsFormat, ULONG cbFormat, BOOL bRejectMixedPaths, IPartsList** ppPath); - HRESULT Search(IPart* pStart, DataFlow flowStart, IExaminer* pExaminer, CPartsList* pPath, UINT cDepth, BOOL bRejectMixedPaths); - HRESULT InitializeWidgets(); - HRESULT GetDeviceFriendlyName(_Outptr_result_maybenull_ LPWSTR* ppNameOut); - HRESULT MakeNewWidget(IPart* pPart, REFIID iid, UINT nCtrlId); - BOOL OnInitDialog (HWND hwndDlg, WPARAM wParam, LPARAM lParam); - BOOL OnApply(HWND hwndDlg, WPARAM wParam, LPARAM lParam); - BOOL OnCheckBoxClicked(HWND hwndDlg, WPARAM wParam, LPARAM lParam); -}; - -OBJECT_ENTRY_AUTO(__uuidof(AdvEndpointPropPage), CAdvEndpointPropPage) diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.rgs b/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.rgs deleted file mode 100644 index eecbc126..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/AdvEndpointPropPage.rgs +++ /dev/null @@ -1,27 +0,0 @@ -HKCR -{ - CplExt.AdvEndpointPropPage.1 = s 'AdvEndpointPropPage Class' - { - CLSID = s '{6C57B2A2-91F5-4b90-93D5-FAB82485ECA6}' - } - CplExt.AdvEndpointPropPage = s 'AdvEndpointPropPage Class' - { - CLSID = s '{6C57B2A2-91F5-4b90-93D5-FAB82485ECA6}' - CurVer = s 'CplExt.AdvEndpointPropPage.1' - } - NoRemove CLSID - { - ForceRemove {6C57B2A2-91F5-4b90-93D5-FAB82485ECA6} = s 'AdvEndpointPropPage Class' - { - ProgID = s 'CplExt.AdvEndpointPropPage.1' - VersionIndependentProgID = s 'CplExt.AdvEndpointPropPage' - ForceRemove 'Programmable' - InprocServer32 = s '%MODULE%' - { - val ThreadingModel = s 'Apartment' - } - val AppID = s '%APPID%' - 'TypeLib' = s '{59390583-ED40-46D9-9B16-7800B9CC5CC2}' - } - } -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.cpp b/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.cpp deleted file mode 100644 index b64d51a2..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.cpp +++ /dev/null @@ -1,73 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: CplExt.cpp -// -// Abstract: Implementation of DLL Exports -// -// ---------------------------------------------------------------------------- - - -#include "stdafx.h" - -_Analysis_mode_(_Analysis_code_type_user_driver_) - -HINSTANCE g_hInstance = NULL; - - -class CCplExtModule : public CAtlDllModuleT< CCplExtModule > -{ -public : - DECLARE_LIBID(LIBID_CplExtLib) - DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CPL_EXT, "{A7D2EC8B-B70F-434C-A0CE-0DF324805F7D}") -}; - -CCplExtModule _AtlModule; - - -// DLL Entry Point -extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - g_hInstance = hInstance; - return _AtlModule.DllMain(dwReason, lpReserved); -} - - -// Used to determine whether the DLL can be unloaded by OLE -__control_entrypoint(DllExport) -STDAPI DllCanUnloadNow(void) -{ - return _AtlModule.DllCanUnloadNow(); -} - - -// Returns a class factory to create an object of the requested type -_Check_return_ -STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID FAR* ppv) -{ - return _AtlModule.DllGetClassObject(rclsid, riid, ppv); -} - - -// DllRegisterServer - Adds entries to the system registry -__control_entrypoint(DllExport) -STDAPI DllRegisterServer(void) -{ - // registers object, typelib and all interfaces in typelib - HRESULT hr = _AtlModule.DllRegisterServer(); - return hr; -} - - -// DllUnregisterServer - Removes entries from the system registry -__control_entrypoint(DllExport) -STDAPI DllUnregisterServer(void) -{ - HRESULT hr = _AtlModule.DllUnregisterServer(); - return hr; -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.idl b/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.idl deleted file mode 100644 index 3254cbd8..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.idl +++ /dev/null @@ -1,73 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: CplExt.idl -// -// Abstract: IDL source for CplExt. This file will be processed by the -// MIDL tool to produce the type library (CplExt.tlb) and -// marshalling code. -// -// ---------------------------------------------------------------------------- - - -import "oaidl.idl"; -import "ocidl.idl"; - -[ - object, - uuid(E6DB299B-B925-415A-879B-4A76D072F39A), - dual, - nonextensible, - helpstring("ISwapPropPage Interface"), - pointer_default(unique) -] -interface ISwapPropPage : IDispatch{ -}; - - -[ - object, - uuid(D379F7FB-66E0-427f-890D-1F479AD73B4B), - dual, - nonextensible, - helpstring("IAdvEndpointPropPage Interface"), - pointer_default(unique) -] -interface IAdvEndpointPropPage : IDispatch{ -}; - - -[ - uuid(59390583-ED40-46D9-9B16-7800B9CC5CC2), - version(1.0), - helpstring("CplExt 1.0 Type Library") -] -library CplExtLib -{ - importlib("stdole2.tlb"); - - // For Swap Property Page - [ - uuid(19166F23-5F08-47F9-BB57-9F57A977D88E), - helpstring("SwapPropPage Class") - ] - coclass SwapPropPage - { - [default] interface ISwapPropPage; - }; - - // For Advanced Endpoint Property Page - [ - uuid(6C57B2A2-91F5-4b90-93D5-FAB82485ECA6), - helpstring("AdvEndpointPropPage Class") - ] - coclass AdvEndpointPropPage - { - [default] interface IAdvEndpointPropPage; - }; -}; diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rc b/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rc deleted file mode 100644 index 415ed22e..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rc +++ /dev/null @@ -1,208 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "1 TYPELIB ""cplext.tlb""\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "TODO: " - VALUE "FileDescription", "TODO: " - VALUE "FileVersion", "1.0.0.1" - VALUE "InternalName", "CplExt.dll" - VALUE "LegalCopyright", "TODO: (c) . All rights reserved." - VALUE "OriginalFilename", "CplExt.dll" - VALUE "ProductName", "TODO: " - VALUE "ProductVersion", "1.0.0.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// REGISTRY -// - -IDR_CPL_EXT REGISTRY "CplExt.rgs" -IDR_SWAP_PROP_PAGE REGISTRY "SwapPropPage.rgs" -IDR_ADV_ENDPOINT_PROP_PAGE REGISTRY "AdvEndpointPropPage.rgs" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_SWAP_PROP_PAGE DIALOGEX 0, 0, 284, 246 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "System Effects - Sample" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "",IDC_SPP_ENDPOINT_NAME,19,34,211,8 - CONTROL "&Disable System Effects",IDC_DISABLE_SYSFX,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,22,92,89,8 - CONTROL "Enable Channel Swap &SFX",IDC_ENABLE_SWAP_SFX,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,22,112,98,8 - CONTROL "Enable Channel Swap &MFX",IDC_ENABLE_SWAP_MFX,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,22,132,99,8 - CONTROL "Enable D&elay SFX",IDC_ENABLE_DELAY_SFX,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,22,152,98,8 - CONTROL "Enable Del&ay MFX",IDC_ENABLE_DELAY_MFX,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,22,172,99,8 - GROUPBOX "Endpoint Name",IDC_STATIC,7,18,270,37 - GROUPBOX "System Effects Configuration",IDC_STATIC,7,71,270,132 -END - -IDD_ADV_ENDPOINT_PROP_PAGE DIALOGEX 0, 0, 284, 244 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD | WS_CAPTION | - WS_SYSMENU -CAPTION "Custom - Sample" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "",IDC_EPP_ENDPOINT_NAME,19,34,211,8 - LTEXT "",IDC_NO_ADV_CONTROLS_FOUND,20,90,232,9 - GROUPBOX "Endpoint Name",IDC_STATIC,7,18,270,37 - GROUPBOX "Advanced Controls",IDC_STATIC,7,71,270,154 -END - -IDD_WIDGET_GEN_LONG DIALOGEX 0, 0, 200, 12 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE -EXSTYLE WS_EX_STATICEDGE -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - RTEXT "L",IDC_GEN_LABEL,0,2,94,8 - CONTROL "",IDC_GEN_SLIDER,"msctls_trackbar32",TBS_BOTH | - TBS_NOTICKS | WS_TABSTOP | 0x400,96,0,76,13 - RTEXT "-6 dB",IDC_GEN_VALUE,174,1,24,10,0,WS_EX_STATICEDGE -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_SWAP_PROP_PAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 277 - TOPMARGIN, 7 - BOTTOMMARGIN, 239 - END - - IDD_ADV_ENDPOINT_PROP_PAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 277 - TOPMARGIN, 7 - BOTTOMMARGIN, 237 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_AUDIO_ICON ICON "music.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_PROJ_NAME "CplExt" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -1 TYPELIB "cplext.tlb" - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rgs b/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rgs deleted file mode 100644 index 1c97b062..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/CplExt.rgs +++ /dev/null @@ -1,11 +0,0 @@ -HKCR -{ - NoRemove AppID - { - '%APPID%' = s 'CplExt' - 'CplExt.DLL' - { - val AppID = s '%APPID%' - } - } -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/Parts.cpp b/audio/sysvad/SwapAPO/PropPageExtensions/Parts.cpp deleted file mode 100644 index 41130ead..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/Parts.cpp +++ /dev/null @@ -1,298 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows DevTopo.dll -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: Parts.cpp -// -// Abstract: Implementation of CPart and derived classes. -// -// -------------------------------------------------------------------------------- - -#include "stdafx.h" -#include -#include "Parts.h" - -_Analysis_mode_(_Analysis_code_type_user_driver_) - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::CPartsList -// -// Description: -// CPartsList constructor -// ---------------------------------------------------------------------- -CPartsList::CPartsList() : - m_refCount(1) -{ -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::~CPartsList -// -// Description: -// CPartsList destructor -// ---------------------------------------------------------------------- -CPartsList::~CPartsList() -{ - ATLASSERT(m_refCount == 0); - - IPart* pIPart; - while (m_lstParts.RemoveHead(&pIPart)) - { - SAFE_RELEASE(pIPart); - } -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::QueryInterface -// -// Description: -// Implementation of IUnknown::QueryInterface -// -// Parameters: -// riid - [in] Identifier of the interface being queried -// ppvObj - [in] Pointer to a buffer that receives a pointer to the -// object whose interface is queried -// -// Return: -// S_OK if successful -// ---------------------------------------------------------------------- -STDMETHODIMP CPartsList::QueryInterface -( - const IID& iid, - void** ppUnk -) -{ - if (!ppUnk) - return E_POINTER; - - HRESULT hr = E_NOINTERFACE; - *ppUnk = NULL; - - if (iid == __uuidof(IPartsList)) - { - *ppUnk = (IPartsList*)this; - hr = S_OK; - AddRef(); - } - else - if (iid == __uuidof(IUnknown)) - { - *ppUnk = (IUnknown*)this; - hr = S_OK; - AddRef(); - } - - return hr; -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::AddRef -// -// Description: -// Implementation of IUnknown::AddRef -// -// Return: -// New refcount -// ---------------------------------------------------------------------- -ULONG STDMETHODCALLTYPE CPartsList::AddRef(void) -{ - return InterlockedIncrement(&m_refCount); -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::Release -// -// Description: -// Implementation of IUnknown::Release -// -// Return: -// New refcount -// ---------------------------------------------------------------------- -ULONG STDMETHODCALLTYPE CPartsList::Release(void) -{ - ATLASSERT(m_refCount > 0); - LONG lRef = InterlockedDecrement(&m_refCount); - ATLASSERT(lRef >= 0); - - if (lRef == 0) - { - delete this; - } - return lRef; -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::AddPart -// -// Description: -// Adds an item to the list of IPart interfaces -// -// Parameters: -// pIPart - [in] Part to add to the list -// -// Return: -// S_OK if successful -// ---------------------------------------------------------------------- -STDMETHODIMP CPartsList::AddPart -( - IPart* pIPart -) -{ - if (pIPart == NULL) - return E_POINTER; - - // Protect m_lstParts access - m_CritSection.Enter(); - - pIPart->AddRef(); - m_lstParts.AddTail(pIPart); - - m_CritSection.Leave(); - - return S_OK; -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::AddPart -// -// Description: -// Adds the PartsList Parts to the list of IPart interfaces -// -// Parameters: -// pIParts - [in] List of Parts to be added to the list -// -// Return: -// S_OK if successful -// ---------------------------------------------------------------------- -STDMETHODIMP CPartsList::AddParts -( - IPartsList* pIParts -) -{ - ATLASSERT(pIParts != NULL); - - HRESULT hr = S_OK; - UINT i, cParts = 0; - - // Protect m_lstParts - m_CritSection.Enter(); - - // Loop through specified parts list - hr = pIParts->GetCount(&cParts); - IF_FAILED_JUMP(hr, Exit); - - for (i = 0; (i < cParts) && (hr == S_OK); i++) - { - IPart* pIPart; - - // ... and copy reference to each part - hr = pIParts->GetPart(i, &pIPart); - IF_FAILED_JUMP(hr, Exit); - - // ... to this list - m_lstParts.AddTail(pIPart); - } - -Exit: - m_CritSection.Leave(); - - return hr; -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::GetCount -// -// Description: -// Returns the count of items in the list of IParts -// -// Parameters: -// pCount - [out] the count of parts in this list -// -// Return: -// S_OK if successful -// -// ---------------------------------------------------------------------- -_Use_decl_annotations_ -STDMETHODIMP CPartsList::GetCount -( - UINT* pCount -) -{ - if (pCount == NULL) - return E_POINTER; - - // Protect m_lstParts access - m_CritSection.Enter(); - - *pCount = m_lstParts.GetCount(); - - m_CritSection.Leave(); - - return S_OK; -} - - -// ---------------------------------------------------------------------- -// Function: -// CPartsList::GetPart -// -// Description: -// Returns the nIndex-th item in the list of IParts -// -// Parameters: -// nIndex - [in] index of the part to access -// uMsg - [out] the part at the specified index -// -// Return: -// S_OK if successful -// -// ---------------------------------------------------------------------- -_Use_decl_annotations_ -STDMETHODIMP CPartsList::GetPart -( - UINT nIndex, - IPart** ppPart -) -{ - HRESULT hr; - IPart* pIPart = NULL; - - // Protect m_lstParts access - m_CritSection.Enter(); - - IF_TRUE_ACTION_JUMP((ppPart == NULL), hr = E_POINTER, Exit); - - *ppPart = NULL; - - IF_TRUE_ACTION_JUMP((nIndex >= m_lstParts.GetCount()), hr = E_INVALIDARG, Exit); - - IF_TRUE_ACTION_JUMP((!m_lstParts.GetAt(nIndex, &pIPart)), hr = E_NOTFOUND, Exit); - - // Take care of AddRef and ensure correct interface in one shot - hr = pIPart->QueryInterface(__uuidof(IPart), reinterpret_cast(ppPart)); - IF_FAILED_JUMP(hr, Exit); - -Exit: - m_CritSection.Leave(); - - return hr; -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/Parts.h b/audio/sysvad/SwapAPO/PropPageExtensions/Parts.h deleted file mode 100644 index 1cad63f5..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/Parts.h +++ /dev/null @@ -1,49 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows DevTopo.dll -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: Parts.h -// -// Abstract: CPartsList is a list container of parts -// -// -------------------------------------------------------------------------------- - -#pragma once - - -class CPartsList : public IPartsList -{ -private: - - // This is a REAL refcount. When it goes to zero, the object is destroyed. - LONG m_refCount; - TList m_lstParts; - - CCriticalSection m_CritSection; - -protected: - ~CPartsList(); // Refcounted objects should have a private destructor. - -public: - CPartsList(); - - STDMETHOD(AddPart)(IPart* pIPart); - STDMETHOD(AddParts)(IPartsList* pIParts); - -public: - - // IPartsList - STDMETHOD(GetCount)(_Out_ UINT* pCount); - STDMETHOD(GetPart)(_In_ UINT nIndex, _Out_ IPart** ppPart); - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(const IID& iid, void** ppUnk); - ULONG STDMETHODCALLTYPE AddRef(void); - ULONG STDMETHODCALLTYPE Release(void); - - friend class CDeviceTopology; -}; diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.def b/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.def deleted file mode 100644 index aa2797ce..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.def +++ /dev/null @@ -1,9 +0,0 @@ -; PropPageExt.def : Declares the module parameters. - -LIBRARY "PropPageExt.DLL" - -EXPORTS - DllCanUnloadNow PRIVATE - DllGetClassObject PRIVATE - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj b/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj deleted file mode 100644 index 836e70cd..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj +++ /dev/null @@ -1,275 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {D253C552-154D-49E1-820A-B2CD9D9FF13E} - $(MSBuildProjectName) - false - true - Debug - Win32 - {025DDC98-E8D3-43AF-862D-3FDA9A8432E9} - - - - Windows10 - False - Desktop - - WindowsApplicationForDrivers10.0 - DynamicLibrary - - - Windows10 - True - Desktop - - WindowsApplicationForDrivers10.0 - DynamicLibrary - - - Windows10 - False - Desktop - - WindowsApplicationForDrivers10.0 - DynamicLibrary - - - Windows10 - True - Desktop - - WindowsApplicationForDrivers10.0 - DynamicLibrary - - - - $(IntDir) - - - - - - - - - - - - - - - - PropPageExt - Dynamic - - - PropPageExt - Dynamic - - - PropPageExt - Dynamic - - - PropPageExt - Dynamic - - - - Sync - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - - - Sync - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - - - Sync - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - - - Sync - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - - - true - Level4 - %(AdditionalOptions) /wd4127 - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);advapi32.lib;kernel32.lib;user32.lib;ole32.lib;oleaut32.lib;uuid.lib;shlwapi.lib;comctl32.lib;rpcrt4.lib - PropPageExt.def - - - - - true - Level4 - %(AdditionalOptions) /wd4127 - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);advapi32.lib;kernel32.lib;user32.lib;ole32.lib;oleaut32.lib;uuid.lib;shlwapi.lib;comctl32.lib;rpcrt4.lib - PropPageExt.def - - - - - true - Level4 - %(AdditionalOptions) /wd4127 - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);advapi32.lib;kernel32.lib;user32.lib;ole32.lib;oleaut32.lib;uuid.lib;shlwapi.lib;comctl32.lib;rpcrt4.lib - PropPageExt.def - - - - - true - Level4 - %(AdditionalOptions) /wd4127 - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\Inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);advapi32.lib;kernel32.lib;user32.lib;ole32.lib;oleaut32.lib;uuid.lib;shlwapi.lib;comctl32.lib;rpcrt4.lib - PropPageExt.def - - - - - ;%(AdditionalIncludeDirectories) - stdafx.h - Use - $(IntDir)\stdafx.pch - - - ;%(AdditionalIncludeDirectories) - stdafx.h - Use - $(IntDir)\stdafx.pch - - - ;%(AdditionalIncludeDirectories) - stdafx.h - Use - $(IntDir)\stdafx.pch - - - ;%(AdditionalIncludeDirectories) - stdafx.h - Create - $(IntDir)\stdafx.pch - - - ;%(AdditionalIncludeDirectories) - stdafx.h - Use - $(IntDir)\stdafx.pch - - - ;%(AdditionalIncludeDirectories) - stdafx.h - Use - $(IntDir)\stdafx.pch - - - ;%(AdditionalIncludeDirectories) - stdafx.h - Use - $(IntDir)\stdafx.pch - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj.Filters b/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj.Filters deleted file mode 100644 index 98832fba..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/PropPageExt.vcxproj.Filters +++ /dev/null @@ -1,51 +0,0 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {413921B3-AEE4-4E51-B616-E356BEC9E42E} - - - h;hpp;hxx;hm;inl;inc;xsd - {0B044B82-EDD8-49A9-ACEE-2E7C98CCA3DC} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {1E3956FB-B7AD-48BF-AD18-28527349BEED} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.cpp b/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.cpp deleted file mode 100644 index cdc2b0e2..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.cpp +++ /dev/null @@ -1,1154 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: SwapPropPage.cpp -// -// Abstract: Implementation of the CSwapPropPage class -// -// ---------------------------------------------------------------------------- - - -#include "stdafx.h" -#include // DEFINE_GUID -#include -#include -#include -#include "SwapPropPage.h" -#include -#include -#include "cplext_i.c" - -_Analysis_mode_(_Analysis_code_type_user_driver_) - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::CSwapPropPage -// -// Description: -// CSwapPropPage constructor -// ---------------------------------------------------------------------------- -CSwapPropPage::CSwapPropPage() -: m_pAudioFXExtParams(NULL) -, m_fDisableSysFX(FALSE) -, m_fEnableSwapSFX(FALSE) -, m_fEnableSwapMFX(FALSE) -, m_fEnableDelaySFX(FALSE) -, m_fEnableDelayMFX(FALSE) -, m_fReset(FALSE) -{ -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::~CSwapPropPage -// -// Description: -// CSwapPropPage destructor -// ---------------------------------------------------------------------------- -CSwapPropPage::~CSwapPropPage() -{ - SAFE_RELEASE(m_pAudioFXExtParams->pFxProperties); - SAFE_DELETE(m_pAudioFXExtParams); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::GetDeviceFriendlyName -// -// Description: -// Retrieves the endpoint's friendly name -// -// Parameters: -// ppNameOut - [out] The friendly name of the endpoint -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::GetDeviceFriendlyName -( - _Outptr_result_maybenull_ LPWSTR* ppNameOut -) -{ - CComPtr spEnumerator; - CComPtr spProperties; - CComPtr spMMDevice; - HRESULT hr = S_OK; - PROPVARIANT var; - - IF_TRUE_ACTION_JUMP((ppNameOut == NULL), hr = E_POINTER, Exit); - - *ppNameOut = NULL; - - // Create device enumerator and get IMMDevice from the device ID - hr = spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator)); - IF_FAILED_JUMP(hr, Exit); - - hr = spEnumerator->GetDevice(m_pAudioFXExtParams->pwstrEndpointID, &spMMDevice); - IF_FAILED_JUMP(hr, Exit); - - // Open the PropertyStore for read access - hr = spMMDevice->OpenPropertyStore(STGM_READ, &spProperties); - IF_FAILED_JUMP(hr, Exit); - - PropVariantInit(&var); - - // Retrieve the friendly name of the endpoint - hr = spProperties->GetValue(PKEY_Device_FriendlyName, &var); - if (SUCCEEDED(hr) && (var.vt == VT_LPWSTR)) - { - *ppNameOut = var.pwszVal; - } - else - { - PropVariantClear(&var); - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::RetrieveSysFXState -// -// Description: -// Get the current state (enabled or disabled) of system effects -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::RetrieveSysFXState(BOOL *pfDisabled) -{ - HRESULT hr = E_POINTER; - - if ((m_pAudioFXExtParams != NULL) && (m_pAudioFXExtParams->pFxProperties != NULL)) - { - PROPVARIANT var; - PropVariantInit(&var); - - // Get the state of whether system effects are enabled or not - hr = m_pAudioFXExtParams->pFxProperties->GetValue(PKEY_AudioEndpoint_Disable_SysFx, &var); - if (SUCCEEDED(hr) && (var.vt == VT_UI4)) - { - *pfDisabled = (var.ulVal != 0L); - } - - PropVariantClear(&var); - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::SetSysFXState -// -// Description: -// Enable or disable system effects -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::SetSysFXState() -{ - BOOL fCurrentState = 0; - HRESULT hr = RetrieveSysFXState(&fCurrentState); - IF_FAILED_JUMP(hr, Exit); - - if (fCurrentState != m_fDisableSysFX) - { - PROPVARIANT var; - var.vt = VT_UI4; - var.ulVal = (m_fDisableSysFX ? 1L : 0L); - - // Enable or disable SysFX - hr = m_pAudioFXExtParams->pFxProperties->SetValue(PKEY_AudioEndpoint_Disable_SysFx, var); - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::RetrieveSwapSFXState -// -// Description: -// Get the current state (enabled or disabled) of channel swap SFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::RetrieveSwapSFXState(BOOL *pfEnabled) -{ - HRESULT hr = E_POINTER; - - if ((m_pAudioFXExtParams != NULL) && (m_pAudioFXExtParams->pFxProperties != NULL)) - { - PROPVARIANT var; - PropVariantInit(&var); - - // Get the state of whether channel swap SFX is enabled or not - hr = m_pAudioFXExtParams->pFxProperties->GetValue(PKEY_Endpoint_Enable_Channel_Swap_SFX, &var); - if (SUCCEEDED(hr) && (var.vt == VT_UI4)) - { - *pfEnabled = (var.ulVal != 0L); - } - - PropVariantClear(&var); - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::SetSwapSFXState -// -// Description: -// Enable or disable channel swap SFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::SetSwapSFXState() -{ - BOOL fCurrentState = 0; - HRESULT hr = RetrieveSwapSFXState(&fCurrentState); - IF_FAILED_JUMP(hr, Exit); - - if (fCurrentState != m_fEnableSwapSFX) - { - PROPVARIANT var; - var.vt = VT_UI4; - var.ulVal = (m_fEnableSwapSFX ? 1L : 0L); - - // Enable or disable channel swap SFX - hr = m_pAudioFXExtParams->pFxProperties->SetValue(PKEY_Endpoint_Enable_Channel_Swap_SFX, var); - - // Enabling or disabling the swap effect can be done with the engine running - // It does not invalidate anything which should be locked by IAudioProcessingObjectConfiguration::LockForProcess - // In particular, it does not impact IAudioProcessingObject::GetLatency - // So we do not need to call IAudioEndpointFormatControl::ResetToDefault here - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::RetrieveSwapMFXState -// -// Description: -// Get the current state (enabled or disabled) of channel swap MFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::RetrieveSwapMFXState(BOOL *pfEnabled) -{ - HRESULT hr = E_POINTER; - - if ((m_pAudioFXExtParams != NULL) && (m_pAudioFXExtParams->pFxProperties != NULL)) - { - PROPVARIANT var; - PropVariantInit(&var); - - // Get the state of whether channel swap MFX is enabled or not - hr = m_pAudioFXExtParams->pFxProperties->GetValue(PKEY_Endpoint_Enable_Channel_Swap_MFX, &var); - if (SUCCEEDED(hr) && (var.vt == VT_UI4)) - { - *pfEnabled = (var.ulVal != 0L); - } - - PropVariantClear(&var); - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::SetSwapMFXState -// -// Description: -// Enable or disable channel swap MFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::SetSwapMFXState() -{ - BOOL fCurrentState = 0; - HRESULT hr = RetrieveSwapMFXState(&fCurrentState); - IF_FAILED_JUMP(hr, Exit); - - if (fCurrentState != m_fEnableSwapMFX) - { - PROPVARIANT var; - var.vt = VT_UI4; - var.ulVal = (m_fEnableSwapMFX ? 1L : 0L); - - // Enable or disable channel swap MFX - hr = m_pAudioFXExtParams->pFxProperties->SetValue(PKEY_Endpoint_Enable_Channel_Swap_MFX, var); - - // Enabling or disabling the swap effect can be done with the engine running - // It does not invalidate anything which should be locked by IAudioProcessingObjectConfiguration::LockForProcess - // In particular, it does not impact IAudioProcessingObject::GetLatency - // So we do not need to call IAudioEndpointFormatControl::ResetToDefault here - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::RetrieveDelaySFXState -// -// Description: -// Get the current state (enabled or disabled) of delay SFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::RetrieveDelaySFXState(BOOL *pfEnabled) -{ - HRESULT hr = E_POINTER; - - if ((m_pAudioFXExtParams != NULL) && (m_pAudioFXExtParams->pFxProperties != NULL)) - { - PROPVARIANT var; - PropVariantInit(&var); - - // Get the state of whether channel swap SFX is enabled or not - hr = m_pAudioFXExtParams->pFxProperties->GetValue(PKEY_Endpoint_Enable_Delay_SFX, &var); - if (SUCCEEDED(hr) && (var.vt == VT_UI4)) - { - *pfEnabled = (var.ulVal != 0L); - } - - PropVariantClear(&var); - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::SetSwapSFXState -// -// Description: -// Enable or disable channel swap SFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::SetDelaySFXState() -{ - BOOL fCurrentState = 0; - HRESULT hr = RetrieveDelaySFXState(&fCurrentState); - IF_FAILED_JUMP(hr, Exit); - - if (fCurrentState != m_fEnableDelaySFX) - { - PROPVARIANT var; - var.vt = VT_UI4; - var.ulVal = (m_fEnableDelaySFX ? 1L : 0L); - - // Enable or disable delay SFX - hr = m_pAudioFXExtParams->pFxProperties->SetValue(PKEY_Endpoint_Enable_Delay_SFX, var); - IF_FAILED_JUMP(hr, Exit); - - // Enabling or disabling delay changes the value that should be returned by IAudioProcessingObject::GetLatency - // This is one of the things that is locked by IAudioProcessingObjectConfiguration::LockForProcess - // So we need to call IAudioEndpointFormatControl::ResetToDefault - // This will prompt AudioDG to tear down the graph and build it up again - m_fReset = TRUE; - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::RetrieveDelayMFXState -// -// Description: -// Get the current state (enabled or disabled) of delay MFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::RetrieveDelayMFXState(BOOL *pfEnabled) -{ - HRESULT hr = E_POINTER; - - if ((m_pAudioFXExtParams != NULL) && (m_pAudioFXExtParams->pFxProperties != NULL)) - { - PROPVARIANT var; - PropVariantInit(&var); - - // Get the state of whether channel swap MFX is enabled or not - hr = m_pAudioFXExtParams->pFxProperties->GetValue(PKEY_Endpoint_Enable_Delay_MFX, &var); - if (SUCCEEDED(hr) && (var.vt == VT_UI4)) - { - *pfEnabled = (var.ulVal != 0L); - } - - PropVariantClear(&var); - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::SetDelayMFXState -// -// Description: -// Enable or disable delay MFX -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CSwapPropPage::SetDelayMFXState() -{ - BOOL fCurrentState = 0; - HRESULT hr = RetrieveDelayMFXState(&fCurrentState); - IF_FAILED_JUMP(hr, Exit); - - if (fCurrentState != m_fEnableDelayMFX) - { - PROPVARIANT var; - var.vt = VT_UI4; - var.ulVal = (m_fEnableDelayMFX ? 1L : 0L); - - // Enable or disable delay MFX - hr = m_pAudioFXExtParams->pFxProperties->SetValue(PKEY_Endpoint_Enable_Delay_MFX, var); - IF_FAILED_JUMP(hr, Exit); - - // Enabling or disabling delay changes the value that should be returned by IAudioProcessingObject::GetLatency - // This is one of the things that is locked by IAudioProcessingObjectConfiguration::LockForProcess - // So we need to call IAudioEndpointFormatControl::ResetToDefault - // This will prompt AudioDG to tear down the graph and build it up again - m_fReset = TRUE; - } - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::OnInitDialog -// -// Description: -// Dialog initialization routine -// -// Parameters: -// hwndDlg - [in] Handle to dialog box -// wParam - [in] Handle to control to receive the default keyboard focus -// lParam - [in] Specifies additional message-specific information -// -// Return values: -// TRUE to direct the system to set the keyboard focus to the control -// specified by wParam. Otherwise, it should return FALSE to prevent the -// system from setting the default keyboard focus. -// ---------------------------------------------------------------------------- -BOOL CSwapPropPage::OnInitDialog -( - HWND hwndDlg, - WPARAM wParam, - LPARAM lParam -) -{ - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); - - HRESULT hr = S_OK; - LPWSTR pwstrEndpointName = NULL; - - // Retrieve the endpoint's friendly name, system effects, and swap SFX and MFX states - hr = GetDeviceFriendlyName(&pwstrEndpointName); - IF_FAILED_JUMP(hr, Exit); - - hr = RetrieveSysFXState(&m_fDisableSysFX); - IF_FAILED_JUMP(hr, Exit); - - hr = RetrieveSwapSFXState(&m_fEnableSwapSFX); - IF_FAILED_JUMP(hr, Exit); - - hr = RetrieveSwapMFXState(&m_fEnableSwapMFX); - IF_FAILED_JUMP(hr, Exit); - - hr = RetrieveDelaySFXState(&m_fEnableDelaySFX); - IF_FAILED_JUMP(hr, Exit); - - hr = RetrieveDelayMFXState(&m_fEnableDelayMFX); - IF_FAILED_JUMP(hr, Exit); - - // Update the property page with retrieved information - SetWindowText(GetDlgItem(hwndDlg, IDC_SPP_ENDPOINT_NAME), pwstrEndpointName); - - // Based on the retrieved states, toggle the checkboxes to reflect them - if (m_fDisableSysFX) - { - CheckDlgButton(hwndDlg, IDC_DISABLE_SYSFX, BST_CHECKED); - - // Disable APO toggling controls on the page - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_SFX), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_MFX), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_SFX), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_MFX), FALSE); - } - else - { - CheckDlgButton(hwndDlg, IDC_DISABLE_SYSFX, BST_UNCHECKED); - - // Enable APO toggling controls on the page - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_SFX), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_MFX), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_SFX), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_MFX), TRUE); - } - - if (m_fEnableSwapSFX) - { - CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_SFX, BST_CHECKED); - } - else - { - CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_SFX, BST_UNCHECKED); - } - - if (m_fEnableSwapMFX) - { - CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_MFX, BST_CHECKED); - } - else - { - CheckDlgButton(hwndDlg, IDC_ENABLE_SWAP_MFX, BST_UNCHECKED); - } - - if (m_fEnableDelaySFX) - { - CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_SFX, BST_CHECKED); - } - else - { - CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_SFX, BST_UNCHECKED); - } - - if (m_fEnableDelayMFX) - { - CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_MFX, BST_CHECKED); - } - else - { - CheckDlgButton(hwndDlg, IDC_ENABLE_DELAY_MFX, BST_UNCHECKED); - } - -Exit: - SAFE_COTASKMEMFREE(pwstrEndpointName); - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::OnApply -// -// Description: -// Handle the pressing of the apply button -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// -// Return values: -// TRUE to set keyboard focus on control -// ---------------------------------------------------------------------------- -BOOL CSwapPropPage::OnApply -( - HWND hwndDlg -) -{ - HRESULT hr = S_OK; - - // Commit the settings - hr = SetSysFXState(); - IF_FAILED_JUMP(hr, Exit); - - hr = SetSwapSFXState(); - IF_FAILED_JUMP(hr, Exit); - - hr = SetSwapMFXState(); - IF_FAILED_JUMP(hr, Exit); - - hr = SetDelaySFXState(); - IF_FAILED_JUMP(hr, Exit); - - hr = SetDelayMFXState(); - IF_FAILED_JUMP(hr, Exit); - - if (NULL != m_pAudioFXExtParams && NULL != m_pAudioFXExtParams->pFxProperties) - { - hr = m_pAudioFXExtParams->pFxProperties->Commit(); - IF_FAILED_JUMP(hr, Exit); - - if (m_fReset) - { - // something changed that forces us to reset the format support - CComPtr spEnumerator; - CComPtr spMMDevice; - - // Create device enumerator and get IMMDevice from the device ID - hr = spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator)); - IF_FAILED_JUMP(hr, Exit); - - hr = spEnumerator->GetDevice(m_pAudioFXExtParams->pwstrEndpointID, &spMMDevice); - IF_FAILED_JUMP(hr, Exit); - - CComPtr spEndpointFormat; - hr = spMMDevice->Activate(__uuidof(IAudioEndpointFormatControl), CLSCTX_ALL, NULL, (void **)&spEndpointFormat); - IF_FAILED_JUMP(hr, Exit); - - spEndpointFormat->ResetToDefault(ENDPOINT_FORMAT_RESET_MIX_ONLY); - m_fReset = FALSE; - } - } - -Exit: - if (SUCCEEDED(hr)) - { - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); - } - else - { - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID); - } - - return(TRUE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::OnCheckBoxClickedDisableSysFX -// -// Description: -// Handle the clicking of the Disable System Effects check box -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// -// Return values: -// FALSE to not set default keyboard focus -// ---------------------------------------------------------------------------- -BOOL CSwapPropPage::OnCheckBoxClickedDisableSysFX -( - HWND hwndDlg -) -{ - // Check the state of the check box and update associated data member - if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_DISABLE_SYSFX)) - { - m_fDisableSysFX = TRUE; - - // Disable APO toggling controls on the page - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_SFX), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_MFX), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_SFX), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_MFX), FALSE); - } - else - { - m_fDisableSysFX = FALSE; - - // Enable APO toggling controls on the page - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_SFX), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_SWAP_MFX), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_SFX), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE_DELAY_MFX), TRUE); - } - - // If the user changes the check box, enable the Apply button - SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); - - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::OnCheckBoxClickedEnableSwapSFX -// -// Description: -// Handle the clicking of the Enable Channel Swap SFX check box -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// -// Return values: -// FALSE to not set default keyboard focus -// ---------------------------------------------------------------------------- -BOOL CSwapPropPage::OnCheckBoxClickedEnableSwapSFX -( - HWND hwndDlg -) -{ - // Check the state of the check box and update associated data member - if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLE_SWAP_SFX)) - { - m_fEnableSwapSFX = TRUE; - } - else - { - m_fEnableSwapSFX = FALSE; - } - - // If the user changes the check box, enable the Apply button - SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); - - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::OnCheckBoxClickedEnableSwapMFX -// -// Description: -// Handle the clicking of the Enable Channel Swap MFX check box -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// -// Return values: -// FALSE to not set default keyboard focus -// ---------------------------------------------------------------------------- -BOOL CSwapPropPage::OnCheckBoxClickedEnableSwapMFX -( - HWND hwndDlg -) -{ - // Check the state of the check box and update associated data member - if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLE_SWAP_MFX)) - { - m_fEnableSwapMFX = TRUE; - } - else - { - m_fEnableSwapMFX = FALSE; - } - - // If the user changes the check box, enable the Apply button - SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); - - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::OnCheckBoxClickedEnableDelaySFX -// -// Description: -// Handle the clicking of the Enable Delay SFX check box -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// -// Return values: -// FALSE to not set default keyboard focus -// ---------------------------------------------------------------------------- -BOOL CSwapPropPage::OnCheckBoxClickedEnableDelaySFX -( - HWND hwndDlg -) -{ - // Check the state of the check box and update associated data member - if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLE_DELAY_SFX)) - { - m_fEnableDelaySFX = TRUE; - } - else - { - m_fEnableDelaySFX = FALSE; - } - - // If the user changes the check box, enable the Apply button - SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); - - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::OnCheckBoxClickedEnableDelayMFX -// -// Description: -// Handle the clicking of the Enable Delay MFX check box -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// -// Return values: -// FALSE to not set default keyboard focus -// ---------------------------------------------------------------------------- -BOOL CSwapPropPage::OnCheckBoxClickedEnableDelayMFX -( - HWND hwndDlg -) -{ - // Check the state of the check box and update associated data member - if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_ENABLE_DELAY_MFX)) - { - m_fEnableDelayMFX = TRUE; - } - else - { - m_fEnableDelayMFX = FALSE; - } - - // If the user changes the check box, enable the Apply button - SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0); - - return(FALSE); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::DialogProcPage1 -// -// Description: -// Callback for property page -// -// Parameters: -// hwndDlg - [in] Handle to the dialog box -// uMsg - [in] Specifies the message -// wParam - [in] Specifies additional message-specific information -// lParam - [in] Specifies additional message-specific information -// -// Return values: -// TRUE if it processed the message, FALSE if not -// ---------------------------------------------------------------------------- -INT_PTR CALLBACK CSwapPropPage::DialogProcPage1 -( - HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam -) -{ - CSwapPropPage* pthis = (CSwapPropPage*)(LONG_PTR)GetWindowLongPtr( - hwndDlg, GWLP_USERDATA); - BOOL fRet = FALSE; - - switch (uMsg) - { - case WM_INITDIALOG: - { - // Extract the context data from PROPSHEETPAGE::lParam - PROPSHEETPAGE* pSheetDesc = (PROPSHEETPAGE*)lParam; - - // Create the property page factory class -#pragma warning(push) -#pragma warning(disable: 28197) - pthis = new CComObject(); -#pragma warning(pop) - if (pthis == NULL) - { - return(FALSE); - } - - // Save this object in lParam - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)pthis); - - // Keep audio FX extension parameters passed by the control panel - pthis->m_pAudioFXExtParams = (AudioFXExtensionParams*)pSheetDesc->lParam; - - fRet = pthis->OnInitDialog(hwndDlg, wParam, lParam); - break; - } - - case WM_NOTIFY: - { - switch (((NMHDR FAR*)lParam)->code) - { - case PSN_APPLY: - if (pthis) - { - // Apply button pressed - fRet = pthis->OnApply(hwndDlg); - } - break; - } - break; - } - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - // Handle the clicking of the check boxes - case IDC_DISABLE_SYSFX: - if (pthis) - { - fRet = pthis->OnCheckBoxClickedDisableSysFX(hwndDlg); - } - break; - - case IDC_ENABLE_SWAP_SFX: - if (pthis) - { - fRet = pthis->OnCheckBoxClickedEnableSwapSFX(hwndDlg); - } - break; - - case IDC_ENABLE_SWAP_MFX: - if (pthis) - { - fRet = pthis->OnCheckBoxClickedEnableSwapMFX(hwndDlg); - } - break; - - case IDC_ENABLE_DELAY_SFX: - if (pthis) - { - fRet = pthis->OnCheckBoxClickedEnableDelaySFX(hwndDlg); - } - break; - - case IDC_ENABLE_DELAY_MFX: - if (pthis) - { - fRet = pthis->OnCheckBoxClickedEnableDelayMFX(hwndDlg); - } - break; - } - break; - } - - case WM_DESTROY: - { - SAFE_DELETE(pthis); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL); - fRet = TRUE; - break; - } - } - - return(fRet); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::PropSheetPageProc -// -// Description: -// Callback that gets invoked right after page creation or right before -// before page destruction -// -// Parameters: -// hwnd - Reserved; must be NULL -// uMsg - [in] Action flag. PSPCB_ADDREF, PSPCB_CREATE, or PSPCB_RELEASE -// ppsp - [in, out] Pointer to a PROPSHEETPAGE structure that defines -// the page being created or destroyed. -// -// Return values: -// Depends on the value of the uMsg parameter -// ---------------------------------------------------------------------------- -UINT CALLBACK CSwapPropPage::PropSheetPageProc -( - HWND hwnd, - UINT uMsg, - LPPROPSHEETPAGE ppsp -) -{ - UNREFERENCED_PARAMETER(hwnd); - UNREFERENCED_PARAMETER(uMsg); - UNREFERENCED_PARAMETER(ppsp); - - // if (uMsg == PSPCB_CREATE) ... - return(1); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::Initialize -// -// Description: -// Implementation of IShellExtInit::Initialize. Initializes a property -// sheet extension, shortcut menu extension, or drag-and-drop handler. -// -// Parameters: -// pidlFolder - [in] Address of an ITEMIDLIST structure that uniquely -// identifies a folder. For property sheet extensions, -// this parameter is NULL. -// pdtobj - [out] Address of an IDataObject interface object that can be -// used to retrieve the objects being acted upon. -// hkeyProgID - [in] Registry key for the file object or folder type. -// -// Return values: -// Returns NOERROR if successful, or an OLE-defined error value otherwise -// ---------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT CSwapPropPage::Initialize -( - LPCITEMIDLIST pidlFolder, - IDataObject* pdtobj, - HKEY hkeyProgID -) -{ - UNREFERENCED_PARAMETER(pidlFolder); - UNREFERENCED_PARAMETER(pdtobj); - UNREFERENCED_PARAMETER(hkeyProgID); - - return(S_OK); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::AddPages -// -// Description: -// Implementation of IShellPropSheetExt::AddPages. Adds one or more pages -// to a property sheet that the Shell displays for a file object. -// -// Parameters: -// lpfnAddPage - [in] Address of a function that the property sheet -// handler calls to add a page to the property sheet. The -// function takes a property sheet handle returned by the -// CreatePropertySheetPage function and the lParam parameter -// passed to the AddPages method. -// lParam - [in] Parameter to pass to the function specified by the -// lpfnAddPage method. -// -// Return values: -// Returns S_OK if successful. If the method fails, an OLE-defined error -// code is returned -// ---------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT STDMETHODCALLTYPE CSwapPropPage::AddPages -( - LPFNADDPROPSHEETPAGE lpfnAddPage, // See PrSht.h - LPARAM lParam // Used by caller, don't modify -) -{ - HRESULT hr = S_OK; - PROPSHEETPAGE psp; - HPROPSHEETPAGE hPage1 = NULL; - AudioFXExtensionParams* pAudioFXParams = (AudioFXExtensionParams*)lParam; -#pragma warning(push) -#pragma warning(disable: 28197) - AudioFXExtensionParams* pAudioFXParamsCopy = new AudioFXExtensionParams; -#pragma warning(pop) - - if (pAudioFXParamsCopy == NULL) - { - return E_OUTOFMEMORY; - } - - // Make a copy of the params - CopyMemory(pAudioFXParamsCopy, pAudioFXParams, sizeof(AudioFXExtensionParams)); - SAFE_ADDREF(pAudioFXParamsCopy->pFxProperties); - - // Initialize property page params and create page - psp.dwSize = sizeof(psp); - psp.dwFlags = PSP_USEREFPARENT | PSP_USECALLBACK; - psp.hInstance = _AtlBaseModule.GetModuleInstance(); - psp.hIcon = 0; - psp.pcRefParent = (UINT*)&m_dwRef; - psp.lParam = (LPARAM)pAudioFXParamsCopy; - psp.pszTemplate = MAKEINTRESOURCE(IDD_SWAP_PROP_PAGE); - psp.pfnDlgProc = (DLGPROC)DialogProcPage1; - psp.pfnCallback = PropSheetPageProc; - - // Create the property sheet page and add the page - hPage1 = CreatePropertySheetPage(&psp); - if (hPage1) - { - if (!lpfnAddPage(hPage1, pAudioFXParams->AddPageParam)) - { - hr = E_FAIL; - delete pAudioFXParamsCopy; - DestroyPropertySheetPage(hPage1); - } - else - { - // Add ref for page - this->AddRef(); - } - } - else - { - delete pAudioFXParamsCopy; - hr = E_OUTOFMEMORY; - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CSwapPropPage::ReplacePage -// -// Description: -// Implementation of IShellPropSheetExt::ReplacePage. Replaces a page in -// a property sheet for a Control Panel object. -// -// Parameters: -// uPageID - [in] Identifier of the page to replace -// lpfnReplacePage - [in] Address of a function that the property sheet -// handler calls to replace a page to the property -// sheet. The function takes a property sheet handle -// returned by the CreatePropertySheetPage function and -// the lParam parameter passed to the ReplacePage -// method. -// lParam - [in] Parameter to pass to the function specified by the -// lpfnReplacePage parameter. -// -// Return values: -// Returns NOERROR if successful, or an OLE-defined error value otherwise -// ---------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT STDMETHODCALLTYPE CSwapPropPage::ReplacePage -( - UINT uPageID, - LPFNSVADDPROPSHEETPAGE lpfnReplaceWith, - LPARAM lParam -) -{ - UNREFERENCED_PARAMETER(uPageID); - UNREFERENCED_PARAMETER(lpfnReplaceWith); - UNREFERENCED_PARAMETER(lParam); - - return(S_FALSE); -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.h b/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.h deleted file mode 100644 index 295e29bc..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.h +++ /dev/null @@ -1,92 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: SwapPropPage.h -// -// Abstract: Declaration of the CSwapPropPage class -// -// ---------------------------------------------------------------------------- - - -#pragma once - -// ---------------------------------------------------------------------- -// CSwapPropPage class -// -class ATL_NO_VTABLE CSwapPropPage : - public CComObjectRootEx, - public CComCoClass, - public IDispatchImpl, - public IShellExtInit, - public IShellPropSheetExt -{ -public: - CSwapPropPage(); - ~CSwapPropPage(); - - DECLARE_REGISTRY_RESOURCEID(IDR_SWAP_PROP_PAGE) - - BEGIN_COM_MAP(CSwapPropPage) - COM_INTERFACE_ENTRY(ISwapPropPage) - COM_INTERFACE_ENTRY(IDispatch) - COM_INTERFACE_ENTRY(IShellExtInit) - COM_INTERFACE_ENTRY(IShellPropSheetExt) - END_COM_MAP() - - DECLARE_PROTECT_FINAL_CONSTRUCT() - - HRESULT FinalConstruct() - { - return S_OK; - } - - void FinalRelease() - { - } - - static INT_PTR CALLBACK DialogProcPage1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - static UINT CALLBACK PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp); - - // IShellExtInit - STDMETHOD(Initialize)(_In_opt_ LPCITEMIDLIST pidlFolder, _In_opt_ IDataObject* pdtobj, _In_opt_ HKEY hkeyProgID); - - // IShellPropSheetExt - STDMETHOD(AddPages)(_In_ LPFNADDPROPSHEETPAGE lpfnAddPage, _In_ LPARAM lParam); - STDMETHOD(ReplacePage)(_In_ UINT uPageID, _In_ LPFNSVADDPROPSHEETPAGE lpfnReplaceWith, _In_ LPARAM lParam); - -private: - AudioFXExtensionParams* m_pAudioFXExtParams; - BOOL m_fDisableSysFX; - BOOL m_fEnableSwapSFX; - BOOL m_fEnableSwapMFX; - BOOL m_fEnableDelaySFX; - BOOL m_fEnableDelayMFX; - BOOL m_fReset; - - HRESULT GetDeviceFriendlyName(_Outptr_result_maybenull_ LPWSTR* ppNameOut); - HRESULT RetrieveSysFXState(BOOL *pfDisabled); - HRESULT SetSysFXState(); - HRESULT RetrieveSwapSFXState(BOOL *pfEnabled); - HRESULT SetSwapSFXState(); - HRESULT RetrieveSwapMFXState(BOOL *pfEnabled); - HRESULT SetSwapMFXState(); - HRESULT RetrieveDelaySFXState(BOOL *pfEnabled); - HRESULT SetDelaySFXState(); - HRESULT RetrieveDelayMFXState(BOOL *pfEnabled); - HRESULT SetDelayMFXState(); - - BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam); - BOOL OnApply(HWND hwndDlg); - BOOL OnCheckBoxClickedDisableSysFX(HWND hwndDlg); - BOOL OnCheckBoxClickedEnableSwapSFX(HWND hwndDlg); - BOOL OnCheckBoxClickedEnableSwapMFX(HWND hwndDlg); - BOOL OnCheckBoxClickedEnableDelaySFX(HWND hwndDlg); - BOOL OnCheckBoxClickedEnableDelayMFX(HWND hwndDlg); -}; - -OBJECT_ENTRY_AUTO(__uuidof(SwapPropPage), CSwapPropPage) diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.rgs b/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.rgs deleted file mode 100644 index 6ede57a1..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/SwapPropPage.rgs +++ /dev/null @@ -1,27 +0,0 @@ -HKCR -{ - CplExt.SwapPropPage.1 = s 'SwapPropPage Class' - { - CLSID = s '{19166F23-5F08-47F9-BB57-9F57A977D88E}' - } - CplExt.SwapPropPage = s 'SwapPropPage Class' - { - CLSID = s '{19166F23-5F08-47F9-BB57-9F57A977D88E}' - CurVer = s 'CplExt.SwapPropPage.1' - } - NoRemove CLSID - { - ForceRemove {19166F23-5F08-47F9-BB57-9F57A977D88E} = s 'SwapPropPage Class' - { - ProgID = s 'CplExt.SwapPropPage.1' - VersionIndependentProgID = s 'CplExt.SwapPropPage' - ForceRemove 'Programmable' - InprocServer32 = s '%MODULE%' - { - val ThreadingModel = s 'Apartment' - } - val AppID = s '%APPID%' - 'TypeLib' = s '{59390583-ED40-46D9-9B16-7800B9CC5CC2}' - } - } -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.cpp b/audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.cpp deleted file mode 100644 index b224f4c1..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.cpp +++ /dev/null @@ -1,162 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: TopologyExaminers.cpp -// -// Description: -// -// -------------------------------------------------------------------------------- - - -#include "stdafx.h" -#include "DeviceTopology.h" -#include "TopologyExaminers.h" - -_Analysis_mode_(_Analysis_code_type_user_driver_) - -// ---------------------------------------------------------------------------- -// Function: -// CFormatExaminer::CFormatExaminer -// -// Description: -// CFormatExaminer constructor -// ---------------------------------------------------------------------------- -CFormatExaminer::CFormatExaminer -( - PKSDATAFORMAT pKsFormat, - ULONG cbFormat -) -: m_bSatisfied(FALSE), - m_pFormatReq(NULL) -{ - ATLASSERT(pKsFormat); - ATLASSERT(cbFormat >= sizeof(KSDATAFORMAT)); - - // If any of this fails, then Examine will fail - if (cbFormat >= sizeof(KSDATAFORMAT)) - { - m_pFormatReq = (PKSDATAFORMAT)(new BYTE[cbFormat]); - CopyMemory(m_pFormatReq, pKsFormat, cbFormat); - if (cbFormat < m_pFormatReq->FormatSize) - m_pFormatReq->FormatSize = cbFormat; - } -} - - -// ---------------------------------------------------------------------------- -// Function: -// CFormatExaminer::~CFormatExaminer -// -// Description: -// CFormatExaminer destructor -// ---------------------------------------------------------------------------- -CFormatExaminer::~CFormatExaminer() -{ - SAFE_DELETE_ARRAY(m_pFormatReq); -} - - -// ---------------------------------------------------------------------- -// Function: -// CFormatExaminer::Examine -// -// Description: -// Implementation of IExaminer::Examine. This method checks the supplied -// path an IConnector that support the KS streaming format (KSDATAFORMAT) -// that this examiner was set up to look for. -// -// Parameters: -// pPath - [in] List of parts to examine -// -// Remarks: -// This examiner only cares about the first part in the list, which is -// always a connector or an endpoint. Therefore it only needs to make -// sure that there is a zeroth element in the list and examine that. -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------- -HRESULT CFormatExaminer::Examine -( - IPartsList* pPath -) -{ - ATLASSERT(pPath != NULL); - - HRESULT hr = S_OK; - UINT cParts; - CComPtr spPart; - - // Make sure there is at least 1 part - hr = pPath->GetCount(&cParts); - IF_FAILED_JUMP(hr, Exit); - - IF_TRUE_ACTION_JUMP((cParts == 0), hr = E_NOTFOUND, Exit); - - // This examiner only cares about Connectors so don't bother walking the - // path, just look at the last in the list, which should be a connector. - hr = pPath->GetPart(0, &spPart); - IF_FAILED_JUMP(hr, Exit); - - hr = ExaminePart(spPart); - -Exit: - return hr; -} - - -// ---------------------------------------------------------------------- -// Function: -// CFormatExaminer::ExaminePart -// -// Description: -// Tests a single IPart against the examination criteria, namely be a -// connector that supports whatever KS Streaming format (KSDATAFORMAT) -// this examiner was set up to look for -// -// Parameters: -// pIPart - [in] Part to examine -// -// Remarks: -// 1) Make sure the connector is of type Software_IO -// 2) Activate IKsFormatSupport on the connector -// 3) Call IKsFormatSupport::IsFormatSupported(m_pFormatReq). -// -// ---------------------------------------------------------------------- -HRESULT CFormatExaminer::ExaminePart -( - IPart* pIPart -) -{ - ATLASSERT(pIPart); - - HRESULT hr = S_OK; - - // 1) Check category and make sure it is a software_IO pin - ConnectorType conType; - CComPtr spConnector; - CComPtr spFormatSupport; - - hr = pIPart->QueryInterface(__uuidof(IConnector), (void**)&spConnector); - IF_FAILED_JUMP(hr, Exit); - - hr = spConnector->GetType(&conType); - IF_FAILED_JUMP(hr, Exit); - - IF_TRUE_ACTION_JUMP((conType != Software_IO), hr = E_NOTFOUND, Exit); - - // 2) Activate IKsFormatSupport interface - hr = pIPart->Activate(CLSCTX_INPROC_SERVER, __uuidof(IKsFormatSupport), (void**)&spFormatSupport); - IF_FAILED_JUMP(hr, Exit); - - // 3) Ask the interface if this format is supported - hr = spFormatSupport->IsFormatSupported(m_pFormatReq, m_pFormatReq->FormatSize, &m_bSatisfied); - -Exit: - return hr; -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.h b/audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.h deleted file mode 100644 index eafd52f0..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/TopologyExaminers.h +++ /dev/null @@ -1,50 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: TopologyExaminers.h -// -// Abstract: An interface and supporting class(es) for examining device -// model IParts -// -// ---------------------------------------------------------------------------- - -#pragma once - - -// ---------------------------------------------------------------------- -// interface IExaminer -// An interface for examining devicemodel IParts -// ---------------------------------------------------------------------- -interface IExaminer -{ -public: - virtual HRESULT Examine(IPartsList* pPath) = 0; - virtual BOOL IsSatisfied() = 0; -}; - - -// -------------------------------------------------------------------------------- -// class CFormatExaminer -// A class that examines IConnectors looking for a soft connector that supports -// a given KS streaming format (KSDATAFORMAT). -// ---------------------------------------------------------------------- -class CFormatExaminer : public IExaminer -{ -private: - PKSDATAFORMAT m_pFormatReq; - BOOL m_bSatisfied; - - HRESULT ExaminePart(IPart* pIPart); - -public: - CFormatExaminer(PKSDATAFORMAT pKsFormat, ULONG cbFormat); - ~CFormatExaminer(); - - HRESULT Examine(IPartsList* pPath); - BOOL IsSatisfied() { return m_bSatisfied; } -}; diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.cpp b/audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.cpp deleted file mode 100644 index 9dc272af..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.cpp +++ /dev/null @@ -1,321 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: UIWidgets.cpp -// -// Abstract: Implementation of CUIWidget and derived classes -// -// ---------------------------------------------------------------------------- - - -#include "stdafx.h" -#include -#include "UIWidgets.h" - -_Analysis_mode_(_Analysis_code_type_user_driver_) - -// ---------------------------------------------------------------------- -// CUIWidget base class - - -// ---------------------------------------------------------------------------- -// Function: -// CUIWidget::CUIWidget -// -// Description: -// CUIWidget constructor -// ---------------------------------------------------------------------------- -CUIWidget::CUIWidget -( - IPart* pPart, - REFIID iid -) -: m_hwndParentDlg(NULL), - m_iid(iid), - m_wstrLabel(NULL), - m_bRegisteredForCallbacks(NULL) -{ - // This is done here rather than in the initializer list to avoid a prefix error - if (pPart != NULL) - { - m_spPart = pPart; - } - - m_dwProcessId = GetCurrentProcessId(); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CUIWidget::~CUIWidget -// -// Description: -// CUIWidget destructor -// ---------------------------------------------------------------------------- -CUIWidget::~CUIWidget() -{ - SAFE_COTASKMEMFREE(m_wstrLabel); - - if (m_bRegisteredForCallbacks) - { - m_spPart->UnregisterControlChangeCallback(this); - } -} - - -// ---------------------------------------------------------------------------- -// Function: -// CUIWidget::Create -// -// Description: -// -- Activates the control interface on the specified part -// -- Registers for control change callbacks -// -// Parameters: -// hwndDlg - [in] Parent dialog of the widget -// rc - [in] Not used -// ctrlIdBase - [in] Not used -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CUIWidget::Create -( - HWND hwndDlg, - SRECT& /*rc*/, - UINT& /*ctrlIdBase*/ -) -{ - HRESULT hr; - - m_hwndParentDlg = hwndDlg; - - RPC_STATUS rpcs = UuidCreate(&m_guidEventContext); - if (rpcs != RPC_S_OK) - { - hr = HRESULT_FROM_WIN32(rpcs); - goto Exit; - } - - hr = m_spPart->Activate(CLSCTX_INPROC_SERVER, m_iid, (void**)&m_spControl); - IF_FAILED_JUMP(hr, Exit); - - hr = m_spPart->RegisterControlChangeCallback(m_iid, this); - IF_FAILED_JUMP(hr, Exit); - - m_bRegisteredForCallbacks = TRUE; - - hr = m_spPart->GetName(&m_wstrLabel); - -Exit: - return hr; -}; - - -// ---------------------------------------------------------------------- -// Function: -// CUIWidget::OnNotify -// -// Description: -// Implementation of IControlChangeNotify::OnNotify -// Called when someone calls a "Set" method on a control interface. -// -// Parameters: -// dwProcessId - [in] Process ID -// pguidEventContext - Event context guid -// -// Return: -// S_OK always -// ---------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT CUIWidget::OnNotify -( - DWORD dwProcessId, - LPCGUID pguidEventContext -) -{ - UNREFERENCED_PARAMETER(dwProcessId); - - if ((pguidEventContext == NULL) || - (*pguidEventContext != m_guidEventContext)) - { - // Delegate to derived class - HandleControlChangeNotification(); - } - - return S_OK; -} - - -// ---------------------------------------------------------------------- -// ---------------------------------------------------------------------- -// CBooleanWidget - - -// ---------------------------------------------------------------------------- -// Function: -// CBooleanWidget::CBooleanWidget -// -// Description: -// CBooleanWidget constructor -// ---------------------------------------------------------------------------- -CBooleanWidget::CBooleanWidget -( - IPart* pPart, - REFIID iid -) -: CUIWidget(pPart, iid), - m_hwndCheckbox(NULL), - m_bCurrentValue(FALSE) -{ -} - - -// ---------------------------------------------------------------------------- -// Function: -// CBooleanWidget::Create -// -// Description: -// Creates the widget which is a dialog -// -// Parameters: -// hwndDlg - [in] Parent dialog of the widget -// rc - [in] Position of the widget -// nCtrlId - [in] Child-window identifier -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CBooleanWidget::Create -( - HWND hwndDlg, - SRECT& rc, - UINT& nCtrlId -) -{ - HRESULT hr; - HFONT hFont; - DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX; - - // Activate the control interface and register for callbacks - hr = CUIWidget::Create(hwndDlg, rc, nCtrlId); - IF_FAILED_JUMP(hr, Exit); - - // Create a check box - rc.w = 300; - rc.h = 20; - m_hwndCheckbox = CreateWindowEx( - 0, //WS_EX_STATICEDGE, - WC_BUTTON, - m_wstrLabel, - dwStyle, - rc.x, rc.y, // put at (x,y) - rc.w, rc.h, - m_hwndParentDlg, - (HMENU)(UINT_PTR)nCtrlId, - NULL, - 0); - IF_TRUE_ACTION_JUMP((m_hwndCheckbox == NULL), hr = HRESULT_FROM_WIN32(GetLastError()), Exit); - - // Make the new control use the same font as the dialog - hFont = Window_GetFont(hwndDlg); - Window_SetFont(m_hwndCheckbox, hFont); - - // Get the current value - hr = HandleControlChangeNotification(); - IF_FAILED_JUMP(hr, Exit); - -Exit: - return hr; -} - - -// ---------------------------------------------------------------------- -// Function: -// CBooleanWidget::HandleControlChangeNotification() -// -// Description: -// Handles widget change notifications -// -// Return: -// S_OK if successful -// ---------------------------------------------------------------------- -HRESULT CBooleanWidget::HandleControlChangeNotification() -{ - HRESULT hr = S_OK; - - ATLASSERT(m_spControl); - ATLASSERT(m_hwndCheckbox); - - // Set value on DeviceTopology control interface - if (m_iid == __uuidof(IAudioLoudness)) - { - CComQIPtr spLoudness = m_spControl; - hr = spLoudness->GetEnabled(&m_bCurrentValue); - } - else if (m_iid == __uuidof(IAudioAutoGainControl)) - { - CComQIPtr spAGC = m_spControl; - hr = spAGC->GetEnabled(&m_bCurrentValue); - } - else if (m_iid == __uuidof(IDeviceSpecificProperty)) - { - CComQIPtr spBoolCtrl = m_spControl; - DWORD cbValue = sizeof(m_bCurrentValue); - - hr = spBoolCtrl->GetValue(&m_bCurrentValue, &cbValue); - } - - // Set the check box to reflect the current value - SendMessage(m_hwndCheckbox, BM_SETCHECK, (WPARAM)(int)(m_bCurrentValue), 0L); - - return hr; -} - - -// ---------------------------------------------------------------------------- -// Function: -// CBooleanWidget::CommitValue -// -// Description: -// Commit the value set on the control -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -HRESULT CBooleanWidget::CommitValue() -{ - HRESULT hr = S_OK; - - ATLASSERT(m_spControl); - ATLASSERT(m_hwndCheckbox); - - // Get current value from check box - m_bCurrentValue = ((int)(DWORD)SendMessage(m_hwndCheckbox, BM_GETCHECK, 0L, 0L)); - - // Set value on DeviceTopology control interface - if (m_iid == __uuidof(IAudioLoudness)) - { - CComQIPtr spLoudness = m_spControl; - hr = spLoudness->SetEnabled(m_bCurrentValue, GetEventContext()); - } - else if (m_iid == __uuidof(IAudioAutoGainControl)) - { - CComQIPtr spAGC = m_spControl; - hr = spAGC->SetEnabled(m_bCurrentValue, GetEventContext()); - } - else if (m_iid == __uuidof(IDeviceSpecificProperty)) - { - CComQIPtr spBoolCtrl = m_spControl; - - hr = spBoolCtrl->SetValue(&m_bCurrentValue, sizeof(m_bCurrentValue), - GetEventContext()); - } - - return hr; -}; diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.h b/audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.h deleted file mode 100644 index 1f807bd4..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/UIWidgets.h +++ /dev/null @@ -1,405 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: UIWidgets.h -// -// Abstract: Declaration of CUIWidget and derived classes -// -// ---------------------------------------------------------------------------- - - -#pragma once - - -// ---------------------------------------------------------------------------- -// Class: -// CUIWidget -// -// Description: -// Base class for different types of widgets -// -// ---------------------------------------------------------------------------- -class CUIWidget : public IControlChangeNotify -{ -protected: - HWND m_hwndParentDlg; - IID m_iid; - CComPtr m_spPart; - CComPtr m_spControl; - DWORD m_dwProcessId; - LPWSTR m_wstrLabel; - BOOL m_bRegisteredForCallbacks; - GUID m_guidEventContext; - -public: - CUIWidget(IPart* pPart, REFIID iid); - virtual ~CUIWidget(); - - virtual HRESULT Create(HWND hwndDlg, SRECT& rc, UINT& nCtrlIdBase); - virtual HRESULT HandleControlChangeNotification() = 0; - virtual BOOL OwnsCtrlId(int ctrlId) - { - UNREFERENCED_PARAMETER(ctrlId); - return FALSE; - } - virtual HRESULT OnClick() { return S_OK; } - virtual HRESULT OnHScroll() { return S_OK; } - virtual LPCGUID GetEventContext() { return &m_guidEventContext; } - virtual HRESULT CommitValue() { return S_OK; } - - // IControlChangeNotify - STDMETHOD(OnNotify)(_In_ DWORD dwProcessId, _In_opt_ LPCGUID pguidEventContext); - - // IUnknown (since we implement IControlChangeNotify) - HRESULT STDMETHODCALLTYPE QueryInterface(const IID& iid, void** ppUnk) - { - UNREFERENCED_PARAMETER(iid); - - *ppUnk = NULL; - return E_NOTIMPL; - } - ULONG STDMETHODCALLTYPE AddRef(void) - { return 0; } - ULONG STDMETHODCALLTYPE Release(void) - { return 0; } -}; - - -// ---------------------------------------------------------------------------- -// Class: -// CBooleanWidget -// -// Description: -// Handles IAudioLoudness, IAudioAutoGainControl and -// IGenericBooleanProperty -// -// ---------------------------------------------------------------------------- -class CBooleanWidget : public CUIWidget -{ -protected: - BOOL m_bCurrentValue; - HWND m_hwndCheckbox; - -public: - CBooleanWidget(IPart* pPart, REFIID iid); - - HRESULT Create(HWND hwndDlg, SRECT& rc, UINT& nCtrlIdBase); // virtual - - virtual HRESULT HandleControlChangeNotification(); - virtual BOOL OwnsCtrlId(int ctrlId) - { return (ctrlId == GetDlgCtrlID(m_hwndCheckbox)); } - HRESULT CommitValue(); -}; - - -// ---------------------------------------------------------------------------- -// TODO: Underlying plumbing for the LONG and ULOG types aren't implemented -// yet in audiocore. Once that's implemented and verified working, need to -// remove #if TEST stuff -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// Class: -// CLongWidget -// -// Description: -// Handles IDeviceSpecificProperty -// ---------------------------------------------------------------------------- -template -class CLongWidget : public CUIWidget -{ -public: - CLongWidget(IPart* pPart); - ~CLongWidget(); - virtual HRESULT Create(HWND hwndDlg, SRECT& rc, UINT& ctrlIdBase); - virtual HRESULT HandleControlChangeNotification(); - virtual HRESULT CommitValue(); - -private: - HWND m_hwnd; - HWND m_hwndLabel; - HWND m_hwndTrackbar; - HWND m_hwndValue; - _TYPE_ m_Value; - _TYPE_ m_Min; - _TYPE_ m_Max; - LONG m_Stepping; - CComQIPtr m_spDevSpecControl; - - static INT_PTR CALLBACK DlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - void UpdateValueText(); -}; - - -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -// Implementation of CLongWidget - - -// ---------------------------------------------------------------------------- -// Function: -// CLongWidget<_TYPE_>::CLongWidget -// -// Description: -// CLongWidget<_TYPE_> constructor -// ---------------------------------------------------------------------------- -template -CLongWidget<_TYPE_>::CLongWidget(IPart* pPart) -: CUIWidget(pPart, __uuidof(IDeviceSpecificProperty)), - m_hwndTrackbar(NULL), - m_hwndLabel(NULL), - m_Value(0), - m_Min(0), - m_Max(0), - m_Stepping(1) -{ -} - - -// ---------------------------------------------------------------------------- -// Function: -// CLongWidget<_TYPE_>::CLongWidget -// -// Description: -// CLongWidget<_TYPE_> destructor -// ---------------------------------------------------------------------------- -template -CLongWidget<_TYPE_>::~CLongWidget() -{ - DestroyWindow(m_hwnd); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CLongWidget<_TYPE_>::Create -// -// Description: -// Creates the widget which is a dialog -// -// Parameters: -// hwndDlg - [in] Parent dialog of the widget -// rc - [in] Position of the widget -// ctrlIdBase - [in] Not used -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -template -HRESULT CLongWidget<_TYPE_>::Create -( - HWND hwndDlg, - SRECT& rc, - UINT& ctrlIdBase -) -{ - HRESULT hr = S_OK; - HFONT hFont; - RECT rcClient; - LONG lMin, lMax; - - // Activate the control interface and register for callbacks - hr = CUIWidget::Create(hwndDlg, rc, ctrlIdBase); - IF_FAILED_JUMP(hr, Exit); - - // QI for specific interface - m_spDevSpecControl = m_spControl; - - // Create dialog - m_hwnd = CreateDialogParam( g_hInstance, - MAKEINTRESOURCE(IDD_WIDGET_GEN_LONG), - hwndDlg, - CLongWidget<_TYPE_>::DlgProc, - (LPARAM)this); - - IF_TRUE_ACTION_JUMP((m_hwnd == NULL), hr = HRESULT_FROM_WIN32(GetLastError()), Exit); - - SetWindowPos(m_hwnd, NULL, rc.x, rc.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - GetClientRect(m_hwnd, &rcClient); - rc.w = rcClient.right - rcClient.left; - rc.h = rcClient.bottom - rcClient.top; - - // Make the new controls use the same font as the dialog - hFont = Window_GetFont(hwndDlg); - - m_hwndLabel = GetDlgItem(m_hwnd, IDC_GEN_LABEL); - m_hwndTrackbar = GetDlgItem(m_hwnd, IDC_GEN_SLIDER); - m_hwndValue = GetDlgItem(m_hwnd, IDC_GEN_VALUE); - - Window_SetFont(m_hwndValue, hFont); - Window_SetFont(m_hwndLabel, hFont); - SetWindowText(m_hwndLabel, m_wstrLabel); - - // Set value text - hr = m_spDevSpecControl->Get4BRange(&lMin, &lMax, &m_Stepping); - IF_FAILED_JUMP(hr, Exit); - - m_Min = (_TYPE_)lMin; - m_Max = (_TYPE_)lMax; - - // Set trackbar range and ticks - TrackBar_SetRange(m_hwndTrackbar, 0, 100); - TrackBar_SetTickFrequency(m_hwndTrackbar, 20); // 5 ticks - - // Set trackbar position - HandleControlChangeNotification(); - - // Update the numeric representation of the trackbar - UpdateValueText(); - -Exit: - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CLongWidget<_TYPE_>::HandleControlChangeNotification -// -// Description: -// Handles widget change notifications -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -template -HRESULT CLongWidget<_TYPE_>::HandleControlChangeNotification() -{ - ATLASSERT(m_spDevSpecControl); - ATLASSERT(m_hwndTrackbar); - - HRESULT hr = S_OK; - DWORD cbValue = sizeof(m_Value); - - // Get current value - hr = m_spDevSpecControl->GetValue(&m_Value, &cbValue); - - if (SUCCEEDED(hr)) - { - float fPos = (float)(m_Value - m_Min) / (float)(m_Max - m_Min); - - // Update trackbar position - TrackBar_SetPos(m_hwndTrackbar, (int)(fPos * 100.f)); - } - - return(hr); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CLongWidget<_TYPE_>::CommitValue -// -// Description: -// Commit the value set on the control -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -template -HRESULT CLongWidget<_TYPE_>::CommitValue() -{ - ATLASSERT(m_spDevSpecControl); - ATLASSERT(m_hwndTrackbar); - - HRESULT hr = S_OK; - float fPos; - DWORD cbValue = sizeof(m_Value); - - // Calculate new value from trackbar position - fPos = (float)TrackBar_GetPos(m_hwndTrackbar) / 100.f; - m_Value = (_TYPE_)((float)(m_Max - m_Min) * fPos) + m_Min; - - // Commit current setting of trackbar - hr = m_spDevSpecControl->SetValue(&m_Value, cbValue, GetEventContext()); - - return(hr); -}; - - -// ---------------------------------------------------------------------------- -// Function: -// CLongWidget<_TYPE_>::DlgProc -// -// Description: -// Callback for widget dialog -// -// Parameters: -// hwndDlg - [in] Handle to the widget dialog -// uMsg - [in] Specifies the message -// wParam - [in] Specifies additional message-specific information -// lParam - [in] Specifies additional message-specific information -// -// Return values: -// TRUE if it processed the message, FALSE if not -// ---------------------------------------------------------------------------- -template -INT_PTR CALLBACK CLongWidget<_TYPE_>::DlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - UNREFERENCED_PARAMETER(wParam); - - CLongWidget<_TYPE_>* pthis = (CLongWidget<_TYPE_>*) - (LONG_PTR)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - BOOL fRet = FALSE; - - switch (msg) - { - case WM_INITDIALOG: - { - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - fRet = FALSE; // don't set focus - break; - } - - case WM_DESTROY: - { - // Don't delete. The Widget destructor is what posts the WM_DESTROY - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL); - fRet = TRUE; - break; - } - - case WM_HSCROLL: - - if (pthis) - { - pthis->m_Value = TrackBar_GetPos(pthis->m_hwndTrackbar); - pthis->UpdateValueText(); - - // Enable the Apply button upon user changing the control - SendMessage(GetParent(GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)(GetParent(hwndDlg)), 0); - } - fRet = TRUE; - break; - } - - return(fRet); -} - - -// ---------------------------------------------------------------------------- -// Function: -// CLongWidget<_TYPE_>::UpdateValueText -// -// Description: -// Updates the numeric representation of the trackbar -// -// Return values: -// S_OK if successful -// ---------------------------------------------------------------------------- -template -void CLongWidget<_TYPE_>::UpdateValueText() -{ - WCHAR wsz[12]; - - StringCbPrintfW(wsz, sizeof(wsz), L"0x%08x", m_Value); - - // Set new text - SetWindowText(m_hwndValue, wsz); -} diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/makefile b/audio/sysvad/SwapAPO/PropPageExtensions/makefile deleted file mode 100644 index c7837f4f..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/makefile +++ /dev/null @@ -1,36 +0,0 @@ -############################################################################# -# -# Copyright (c) Microsoft Corporation. -# All Rights Reserved. -# -# Makefile for wdm\audio\sysfx\apo -# -############################################################################# - -## NT BUILD ENVIROMENT - -# -# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source -# file to this component. This file merely indirects to the real make file -# that is shared by all the components of NT. -# -!if defined(IA64) -!message This sample is not to be built for IA64 targets -!else - -!IF DEFINED(_NT_TARGET_VERSION) -#! IF $(_NT_TARGET_VERSION)>=0x501 -! IF $(_NT_TARGET_VERSION)>=0x600 -! INCLUDE $(NTMAKEENV)\makefile.def -! ELSE -# Only warn once per directory -! INCLUDE $(NTMAKEENV)\makefile.plt -! IF "$(BUILD_PASS)"=="PASS1" -! message BUILDMSG: Warning : Building the sample "$(MAKEDIR)" for downlevel build environments is temporarily disabled in WDK for Beta2. -! ENDIF -! ENDIF -!ELSE -! INCLUDE $(NTMAKEENV)\makefile.def -!ENDIF - -!endif \ No newline at end of file diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/music.ico b/audio/sysvad/SwapAPO/PropPageExtensions/music.ico deleted file mode 100644 index 3207a9dc..00000000 Binary files a/audio/sysvad/SwapAPO/PropPageExtensions/music.ico and /dev/null differ diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/resource.h b/audio/sysvad/SwapAPO/PropPageExtensions/resource.h deleted file mode 100644 index a8d36a5a..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/resource.h +++ /dev/null @@ -1,34 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by CplExt.rc -// -#define IDC_DISABLE_SYSFX 5000 // The "Disable System Effects" UI control must have ID 5000 -#define IDS_PROJ_NAME 100 -#define IDR_CPL_EXT 101 -#define IDR_SWAP_PROP_PAGE 102 -#define IDR_ADV_ENDPOINT_PROP_PAGE 103 -#define IDI_AUDIO_ICON 200 -#define IDD_SWAP_PROP_PAGE 201 -#define IDC_ENABLE_SWAP_SFX 203 -#define IDC_ENABLE_SWAP_MFX 204 -#define IDC_SPP_ENDPOINT_NAME 205 -#define IDD_ADV_ENDPOINT_PROP_PAGE 210 -#define IDC_NO_ADV_CONTROLS_FOUND 211 -#define IDC_EPP_ENDPOINT_NAME 212 -#define IDD_WIDGET_GEN_LONG 213 -#define IDC_GEN_LABEL 214 -#define IDC_GEN_SLIDER 215 -#define IDC_GEN_VALUE 216 -#define IDC_ENABLE_DELAY_SFX 217 -#define IDC_ENABLE_DELAY_MFX 218 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 230 -#define _APS_NEXT_COMMAND_VALUE 32768 -#define _APS_NEXT_CONTROL_VALUE 225 -#define _APS_NEXT_SYMED_VALUE 104 -#endif -#endif diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/sources b/audio/sysvad/SwapAPO/PropPageExtensions/sources deleted file mode 100644 index 898884b6..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/sources +++ /dev/null @@ -1,60 +0,0 @@ -TARGETNAME=PropPageExt -TARGETTYPE=DYNLINK - -USE_ATL=1 - -USE_NATIVE_EH=1 - - -DLLENTRY=_DllMainCRTStartup -PRECOMPILED_CXX=1 -PRECOMPILED_INCLUDE=stdafx.h -PRECOMPILED_PCH=stdafx.pch - -MSC_WARNING_LEVEL=-W4 \ - -WX - -# -# stdafx.h defines _ATL_ALL_WARNINGS -# Disabling 4127 is necessary to allow this driver to build in the WDK environment. -# -USER_C_FLAGS=/wd4127 - -C_DEFINES=-DUNICODE \ - -D_UNICODE - -# -# Indicate to the WDK that this sample only supports Win10[+] -# -MINIMUM_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINTHRESHOLD) - -# Indicate that this DLL must be included in the driver package -DDK_NO_PACKAGE_PROJECT=0 -DDK_INCLUDE_PACKAGE_PROJECT=1 - -INCLUDES=$(INCLUDES); \ - ..\Inc; \ - $(DDK_INC_PATH); -SOURCES=CplExt.idl \ - CplExt.rc \ - CplExt.cpp \ - SwapPropPage.cpp \ - AdvEndpointPropPage.cpp \ - UIWidgets.cpp \ - TopologyExaminers.cpp \ - Parts.cpp \ - - -TARGETLIBS= \ - \ - $(SDK_LIB_PATH)\onecore_downlevel.lib \ - $(ONECORE_PRIV_SDK_LIB_PATH)\OneCore_Forwarder_user32.lib \ - $(SDK_LIB_PATH)\onecore_downlevel.lib \ - $(SDK_LIB_PATH)\oleaut32.lib \ - $(INTERNAL_SDK_LIB_PATH)\onecoreuapuuid.lib \ - $(SDK_LIB_PATH)\shlwapi.lib \ - $(SDK_LIB_PATH)\comctl32.lib \ - $(SDK_LIB_PATH)\rpcrt4.lib \ - - - diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/stdafx.cpp b/audio/sysvad/SwapAPO/PropPageExtensions/stdafx.cpp deleted file mode 100644 index 26e28d90..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/stdafx.cpp +++ /dev/null @@ -1,18 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: stdafx.cpp -// -// Abstract: Source file that includes just the standard includes -// -// ---------------------------------------------------------------------------- - - -#include "stdafx.h" - -_Analysis_mode_(_Analysis_code_type_user_driver_) diff --git a/audio/sysvad/SwapAPO/PropPageExtensions/stdafx.h b/audio/sysvad/SwapAPO/PropPageExtensions/stdafx.h deleted file mode 100644 index a116cf07..00000000 --- a/audio/sysvad/SwapAPO/PropPageExtensions/stdafx.h +++ /dev/null @@ -1,67 +0,0 @@ -//**@@@*@@@**************************************************** -// -// Microsoft Windows -// Copyright (C) Microsoft Corporation. All rights reserved. -// -//**@@@*@@@**************************************************** - -// -// FileName: stdafx.h -// -// Abstract: Include file for standard system include files, or project -// specific include files that are used frequently, but are -// changed infrequently -// -// ---------------------------------------------------------------------------- - - -#pragma once - -#ifndef STRICT -#define STRICT -#endif - -//// Modify the following defines if you have to target a platform prior to the ones specified below. -//// Refer to MSDN for the latest info on corresponding values for different platforms. -//#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. -//#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. -//#endif -// -//#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. -//#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later. -//#endif -// -//#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -//#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -//#endif -// -//#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -//#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. -//#endif - -#define _ATL_APARTMENT_THREADED -#define _ATL_NO_AUTOMATIC_NAMESPACE - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -// Turns off ATL's hiding of some common and often safely ignored warning messages -#define _ATL_ALL_WARNINGS - -#define _ATL_NO_HOSTING - -#include "resource.h" -#include -#include -#include -#include // atl windows -using namespace ATL; - -#include -#include -#include -#include -#include "CplExt.h" - -extern HINSTANCE g_hInstance; - -_Analysis_mode_(_Analysis_code_type_user_driver_) diff --git a/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inf b/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inf new file mode 100644 index 00000000..a60abe3f Binary files /dev/null and b/audio/sysvad/TabletAudioSample/ComponentizedApoSample.inf differ diff --git a/audio/sysvad/TabletAudioSample/ComponentizedAudioSample.inf b/audio/sysvad/TabletAudioSample/ComponentizedAudioSample.inf new file mode 100644 index 00000000..6e380029 Binary files /dev/null and b/audio/sysvad/TabletAudioSample/ComponentizedAudioSample.inf differ diff --git a/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inf b/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inf new file mode 100644 index 00000000..d91e44ba Binary files /dev/null and b/audio/sysvad/TabletAudioSample/ComponentizedAudioSampleExtension.inf differ diff --git a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj index 272a3b97..8efc42cf 100644 --- a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj +++ b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj @@ -32,7 +32,7 @@ Windows10 False - Desktop + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -40,7 +40,7 @@ Windows10 True - Desktop + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -48,7 +48,7 @@ Windows10 False - Desktop + Universal KMDF WindowsKernelModeDriver10.0 Driver @@ -56,7 +56,7 @@ Windows10 True - Desktop + Universal KMDF WindowsKernelModeDriver10.0 Driver diff --git a/audio/sysvad/TabletAudioSample/tabletaudiosample.inf b/audio/sysvad/TabletAudioSample/tabletaudiosample.inf index c9f533af..8a0eb788 100644 Binary files a/audio/sysvad/TabletAudioSample/tabletaudiosample.inf and b/audio/sysvad/TabletAudioSample/tabletaudiosample.inf differ diff --git a/audio/sysvad/sysvad.sln b/audio/sysvad/sysvad.sln index d504350b..c56cef29 100644 --- a/audio/sysvad/sysvad.sln +++ b/audio/sysvad/sysvad.sln @@ -7,8 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{FA56 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "KeywordDetectorAdapter", "KeywordDetectorAdapter", "{DBD14E7B-7F95-4743-86E3-4E16FA43F990}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PropPageExtensions", "PropPageExtensions", "{50D3DF82-019A-4434-B17F-72BBC291415F}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SwapAPO", "SwapAPO", "{684FF1CF-64CC-430E-81F7-9D603EF56D59}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "APO", "APO", "{367FF255-7280-48C4-90AC-767124A8D5F7}" @@ -23,8 +21,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package", "package\package. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeywordDetectorContosoAdapter", "KeywordDetectorAdapter\KeywordDetectorContosoAdapter.vcxproj", "{E0F02048-78A4-4FE8-B863-66E6CB6A2C37}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PropPageExt", "SwapAPO\PropPageExtensions\PropPageExt.vcxproj", "{D253C552-154D-49E1-820A-B2CD9D9FF13E}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SwapAPO", "SwapAPO\APO\SwapAPO.vcxproj", "{691F1D0F-CA50-46CD-8BBA-A59E9E8EB601}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DelayAPO", "SwapAPO\DelayAPO\DelayAPO.vcxproj", "{8851AB85-70B3-4798-A149-BA366DF9EC25}" -- cgit v1.3.1 From 19fa751dea92ced9c834a6a168dc151c68d8e060 Mon Sep 17 00:00:00 2001 From: Rajib Dutta Date: Thu, 8 Jun 2017 15:55:25 -0700 Subject: Changes in the way UcmInitializeDevice and Ppm_CreateConnectors calls are made. UcmInitializeDevice needs to be called from EvtDeviceAdd callbcack otherwise connect APIs may not work. Hence moving the function call to Ppm_Initialize which is called from EvtDeviceAdd callback. Creating a work item to create connectors and enable UCSI notifications so as to not block D0 Entry and thereby boot sequence during startup. --- usb/UcmCxUcsi/Fdo.cpp | 103 +++++++++++++++++++++++++++++++++----------------- usb/UcmCxUcsi/Fdo.h | 1 + usb/UcmCxUcsi/Ppm.cpp | 9 +++++ 3 files changed, 79 insertions(+), 34 deletions(-) diff --git a/usb/UcmCxUcsi/Fdo.cpp b/usb/UcmCxUcsi/Fdo.cpp index 88aa9129..29f19279 100644 --- a/usb/UcmCxUcsi/Fdo.cpp +++ b/usb/UcmCxUcsi/Fdo.cpp @@ -27,6 +27,7 @@ EVT_WDF_DEVICE_D0_ENTRY Fdo_EvtDeviceD0Entry; EVT_WDF_DEVICE_D0_EXIT Fdo_EvtDeviceD0Exit; EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT Fdo_EvtDeviceSelfManagedIoInit; EVT_WDF_DEVICE_SELF_MANAGED_IO_RESTART Fdo_EvtDeviceSelfManagedIoRestart; +EVT_WDF_WORKITEM Fdo_ConnectorAndNotificationWorkItem; _IRQL_requires_max_(PASSIVE_LEVEL) NTSTATUS @@ -112,8 +113,11 @@ Fdo_Initialize ( _In_ PFDO_CONTEXT FdoCtx ) { + NTSTATUS status; WDFDEVICE device; WDF_DEVICE_STATE deviceState; + WDF_WORKITEM_CONFIG workItemConfig; + WDF_OBJECT_ATTRIBUTES attributes; PAGED_CODE(); @@ -130,8 +134,27 @@ Fdo_Initialize ( deviceState.NotDisableable = WdfFalse; WdfDeviceSetDeviceState(device, &deviceState); + // + // Create a workitem that will create connectors and enable notifications + // so that we don't block D0 Entry and thereby boot sequence of the system. + // + + WDF_WORKITEM_CONFIG_INIT(&workItemConfig, Fdo_ConnectorAndNotificationWorkItem); + + WDF_OBJECT_ATTRIBUTES_INIT(&attributes); + attributes.ParentObject = device; + + status = WdfWorkItemCreate(&workItemConfig, &attributes, &FdoCtx->ConnectorAndNotificationWorkItem); + if (!NT_SUCCESS(status)) + { + TRACE_ERROR(TRACE_FLAG_FDO, "[Device: 0x%p] WdfWorkItemCreate for ConnectorAndNotificationWorkItem failed - %!STATUS!", device, status); + goto Exit; + } + TRACE_INFO(TRACE_FLAG_FDO, "[Device: 0x%p] FDO initialized", device); +Exit: + TRACE_FUNC_EXIT(TRACE_FLAG_FDO); return STATUS_SUCCESS; @@ -304,44 +327,35 @@ Fdo_EvtDeviceSelfManagedIoInit ( _In_ WDFDEVICE Device ) { - NTSTATUS status; - PPPM_CONTEXT ppmCtx; - UCM_MANAGER_CONFIG ucmConfig; + PFDO_CONTEXT fdoCtx; PAGED_CODE(); TRACE_FUNC_ENTRY(TRACE_FLAG_FDO); - ppmCtx = &Fdo_GetContext(Device)->PpmCtx; + fdoCtx = Fdo_GetContext(Device); - // - // Since the PPM uses a power-managed queue to handle command requests, self-managed I/O init - // is when we can start processing commands. - // + WdfWorkItemEnqueue(fdoCtx->ConnectorAndNotificationWorkItem); - UCM_MANAGER_CONFIG_INIT(&ucmConfig); + TRACE_FUNC_EXIT(TRACE_FLAG_FDO); - // - // Initialize our device with UCM. - // + return STATUS_SUCCESS; +} - status = UcmInitializeDevice(Device, &ucmConfig); - if (!NT_SUCCESS(status)) - { - TRACE_ERROR(TRACE_FLAG_FDO, "[Device: 0x%p] UcmInitializeDevice failed - %!STATUS!", Device, status); - goto Exit; - } +NTSTATUS +Fdo_EvtDeviceSelfManagedIoRestart ( + _In_ WDFDEVICE Device + ) +{ + NTSTATUS status; + PPPM_CONTEXT ppmCtx; - status = Ucm_CreateConnectors(ppmCtx); - if (!NT_SUCCESS(status)) - { - goto Exit; - } + PAGED_CODE(); - // - // Connector objects are ready. Now we can enable all notifications. - // + TRACE_FUNC_ENTRY(TRACE_FLAG_FDO); + + ppmCtx = &Fdo_GetContext(Device)->PpmCtx; status = Ppm_EnableNotifications(ppmCtx); if (!NT_SUCCESS(status)) @@ -356,21 +370,33 @@ Exit: return status; } - -NTSTATUS -Fdo_EvtDeviceSelfManagedIoRestart ( - _In_ WDFDEVICE Device - ) +VOID +Fdo_ConnectorAndNotificationWorkItem( + _In_ WDFWORKITEM WorkItem +) { NTSTATUS status; PPPM_CONTEXT ppmCtx; + PFDO_CONTEXT fdoCtx; + WDFDEVICE device; PAGED_CODE(); TRACE_FUNC_ENTRY(TRACE_FLAG_FDO); - ppmCtx = &Fdo_GetContext(Device)->PpmCtx; + device = (WDFDEVICE)WdfWorkItemGetParentObject(WorkItem); + fdoCtx = Fdo_GetContext(device); + ppmCtx = &fdoCtx->PpmCtx; + status = Ucm_CreateConnectors(ppmCtx); + if (!NT_SUCCESS(status)) + { + goto Exit; + } + + // + // Connector objects are ready. Now we can enable all notifications. + // status = Ppm_EnableNotifications(ppmCtx); if (!NT_SUCCESS(status)) { @@ -378,8 +404,17 @@ Fdo_EvtDeviceSelfManagedIoRestart ( } Exit: + // + // Failing to create the connectors or enable notifications are both + // unrecoverable failures. Attempt to have WDF reload the driver. + // + if (!NT_SUCCESS(status)) + { + TRACE_ERROR(TRACE_FLAG_FDO, "[Device: 0x%p] Failed to initialize PPM connectors - attempting to restart device.", device); + WdfDeviceSetFailed(fdoCtx->WdfDevice, WdfDeviceFailedAttemptRestart); + } - TRACE_FUNC_EXIT(TRACE_FLAG_FDO); + TRACE_INFO(TRACE_FLAG_FDO, "[Device: 0x%p] Work item complete.", device); - return status; + TRACE_FUNC_EXIT(TRACE_FLAG_FDO); } diff --git a/usb/UcmCxUcsi/Fdo.h b/usb/UcmCxUcsi/Fdo.h index c6f2c921..2266df26 100644 --- a/usb/UcmCxUcsi/Fdo.h +++ b/usb/UcmCxUcsi/Fdo.h @@ -26,6 +26,7 @@ typedef struct _FDO_CONTEXT ACPI_CONTEXT AcpiCtx; PPM_CONTEXT PpmCtx; + WDFWORKITEM ConnectorAndNotificationWorkItem; } FDO_CONTEXT, *PFDO_CONTEXT; diff --git a/usb/UcmCxUcsi/Ppm.cpp b/usb/UcmCxUcsi/Ppm.cpp index 522adf27..33be0be9 100644 --- a/usb/UcmCxUcsi/Ppm.cpp +++ b/usb/UcmCxUcsi/Ppm.cpp @@ -54,6 +54,7 @@ Ppm_Initialize ( WDF_IO_QUEUE_CONFIG queueConfig; WDF_IO_TARGET_OPEN_PARAMS openParams; WDF_WORKITEM_CONFIG workItemConfig; + UCM_MANAGER_CONFIG ucmConfig; PAGED_CODE(); @@ -132,6 +133,14 @@ Ppm_Initialize ( goto Exit; } + UCM_MANAGER_CONFIG_INIT(&ucmConfig); + status = UcmInitializeDevice(device, &ucmConfig); + if (!NT_SUCCESS(status)) + { + TRACE_ERROR(TRACE_FLAG_PPM, "[Device: 0x%p] UcmInitializeDevice failed - %!STATUS!", device, status); + goto Exit; + } + TRACE_INFO(TRACE_FLAG_PPM, "[Device: 0x%p] PPM initialized", device); Exit: -- cgit v1.3.1 From 635134edafad4c1a6cd5cbe42f76dea9a3bf5940 Mon Sep 17 00:00:00 2001 From: Ted Hudek Date: Tue, 13 Jun 2017 13:48:30 -0700 Subject: convert DCHU readme to md, add links to docs --- general/DCHU/README.md | 27 +++++++++++++++++++++++++++ general/DCHU/README.txt | 43 ------------------------------------------- 2 files changed, 27 insertions(+), 43 deletions(-) create mode 100644 general/DCHU/README.md delete mode 100644 general/DCHU/README.txt diff --git a/general/DCHU/README.md b/general/DCHU/README.md new file mode 100644 index 00000000..df571af6 --- /dev/null +++ b/general/DCHU/README.md @@ -0,0 +1,27 @@ +# Driver package installation toolkit for universal drivers + +This sample illustrates the DCHU principles of universal driver design. The sample uses the [OSR FX2 learning kit](http://store.osr.com/product/osr-usb-fx2-learning-kit-v2/). For a detailed code walkthrough, see [Universal Driver Scenarios](https://docs.microsoft.com/windows-hardware/drivers/develop/universal-driver-scenarios). + +There are three Visual Studio solutions in this sample. Each one represents a single submission on the [Windows Hardware Dev Center dashboard](https://developer.microsoft.com/windows/hardware/dashboard-sign-in). The solutions are split into the following subdirectories: + +* `osrfx2_DCHU_base` : The driver for the OSR FX2 Learning Kit. This includes the device driver, an upper filter driver for the device (a no-op), a Win32 User Service that controls lights on the device, and a console app that can control the device. + +* `osrfx2_DCHU_extension`: An extension driver for the OSR FX2 device. This extension modifies some registry settings originally specified by the base driver (`osrfx2_DCHU_base`). + +* `osrfx2_DCHU_component`: A Software Component that installs on a device that the base driver package's INF (`osrfx2_DCHU_base.inf`) creates using the [INF AddComponent Directive](https://docs.microsoft.com/windows-hardware/drivers/install/inf-addcomponent-directive). This Software Component executes a legacy .exe to install a file in the `C:\Program Files\...` directory that reads the OSR FX2 device's registry settings applied in the base driver package's INF (`osrfx2_DCHU_base.inf`) + +Each of these solutions can be built with the latest WDK on Visual Studio 2015. Additionally, you can also download a [Universal Windows Platform app (UWP)](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomCapability) that controls the OSR FX2 Learning Kit's device. To learn how to pair a UWP app with a device, see [Hardware access for Universal Windows Platform apps](https://docs.microsoft.com/windows-hardware/drivers/devapps/hardware-access-for-universal-windows-platform-apps) + +The app and the contents of this sample can coexist, but on Windows 10, version 1703, to build the app with Visual Studio 2017, the computer cannot have the WDK installed. + +To install these driver packages, make sure that the target machine is in Test Mode, using `bcdedit /set testsigning on`. + +Then, use `pnputil /i /a ` to install each of the three driver packages. They should +be installed in the following order: + + * `osrfx2_DCHU_base` + * `osrfx2_DCHU_extension` + * `osrfx2_DCHU_component` + +Technically the order of `osrfx2_DCHU_extension` and `osrfx2_DCHU_component` doesn't matter, but the software within `osrfx2_DCHU_component` will read the registry set by the extension to show that an extension INF's settings are applied *after* the base INF's. + \ No newline at end of file diff --git a/general/DCHU/README.txt b/general/DCHU/README.txt deleted file mode 100644 index a63bed27..00000000 --- a/general/DCHU/README.txt +++ /dev/null @@ -1,43 +0,0 @@ -Driver package installation toolkit for universal drivers - -Directions: - -Each portion of the sample is separated by driver package: - -osrfx2_DCHU_base : The driver for the Osr Fx2 Learning Kit. This includes the device driver, - an upper filter driver for the device (a no-op), a Win32 User Service that - controls lights on the device, and a console app that can control the device. - -osrfx2_DCHU_extension: An extension driver for the Osr Fx2 device. This extension modifies - some registry settings laid down by the base driver (osrfx2_DCHU_base). - -osrfx2_DCHU_component: A Software Component that installs on a device that the base driver - package's INF (osrfx2_DCHU_base.inf) creates using AddComponent. - This Software Component executes a legacy .exe to install a file - in the C:\Program Files\... directory that reads the Osr Fx2 device's - registry settings applied in the base driver package's INF (osrfx2_DCHU_base.inf) - -Each of these solutions can be built with the latest WDK on Visual Studio 2015. Additionally, -an HSA that can also control the Osr Fx2 Learning Kit's device is available here: - -https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomCapability - -The HSA and the contents of this sample can coexist, but currently the HSA can only be built -with Visual Studio 2017 on a machine *WITHOUT* the WDK. This limitation is reportedly fixed -in RS3. - -To install these driver packages, make sure that the target machine is in Test Mode, using: - - bcdedit /set testsigning on - -And then use pnputil /i /a to install each of the three driver packages. They should -be installed in this order: - - osrfx2_DCHU_base - osrfx2_DCHU_extension - osrfx2_DCHU_component - -Technically the order of osrfx2_DCHU_extension and ...component doesn't matter, but the software -within osrfx2_DCHU_component will read the regisry set by the extension to show that an extension -INF's settings are applied *after* the base INF's. - \ No newline at end of file -- cgit v1.3.1 From 72d6e020298b18db58119f6b1ab66f1b917f0deb Mon Sep 17 00:00:00 2001 From: Yen Lee Date: Mon, 19 Jun 2017 12:39:38 -0700 Subject: ZeroMemory statistics data for retrieval (#147) * ZeroMemory Statistics Data ZeroMemory Statistics Data so later memory comparison can succeed. * Zero memory statistics data * Need to zero memory a bit earlier --- pos/drivers/MagneticStripeReader/Ioctl.cpp | 3 +++ pos/drivers/barcodescanner/Ioctl.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pos/drivers/MagneticStripeReader/Ioctl.cpp b/pos/drivers/MagneticStripeReader/Ioctl.cpp index dd8ffb62..8da18b93 100644 --- a/pos/drivers/MagneticStripeReader/Ioctl.cpp +++ b/pos/drivers/MagneticStripeReader/Ioctl.cpp @@ -593,6 +593,9 @@ NTSTATUS ProcessRetrieveStatisticsRequest(_In_ WDFREQUEST Request, _In_ size_t O PosValueStatisticsEntry Entries[1]; } StatisticsData; + // Initialize statics data so header data are identical for the same requested + RtlZeroMemory(&StatisticsData, sizeof(StatisticsData)); + StatisticsData.Header.DataLength = sizeof(StatisticsData); wcscpy_s(StatisticsData.Header.DeviceInformation.DeviceCategory, L"MSR"); wcscpy_s(StatisticsData.Header.DeviceInformation.FirmwareRevision, L""); diff --git a/pos/drivers/barcodescanner/Ioctl.cpp b/pos/drivers/barcodescanner/Ioctl.cpp index e9c01dff..834f09ff 100644 --- a/pos/drivers/barcodescanner/Ioctl.cpp +++ b/pos/drivers/barcodescanner/Ioctl.cpp @@ -429,6 +429,9 @@ NTSTATUS ProcessRetrieveStatisticsRequest(_In_ WDFREQUEST Request, _In_ size_t O PosValueStatisticsEntry Entries[1]; } StatisticsData; + // Initialize statics data so header data are identical for the same requested + RtlZeroMemory(&StatisticsData, sizeof(StatisticsData)); + StatisticsData.Header.DataLength = sizeof(StatisticsData); wcscpy_s(StatisticsData.Header.DeviceInformation.DeviceCategory, L"Scanner"); wcscpy_s(StatisticsData.Header.DeviceInformation.FirmwareRevision, L""); -- cgit v1.3.1 From 6a7b5d032d331efe11d1c8f33f399296e529d9b7 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 21 Jun 2017 09:41:28 -0700 Subject: issue #127: Remove timerConfig.AutomaticSerialization = FALSE from KMDF echo sample --- general/echo/kmdf/driver/AutoSync/queue.c | 8 +++---- general/echo/kmdf/driver/DriverSync/device.c | 11 ---------- general/echo/kmdf/driver/DriverSync/queue.c | 33 ++++++++++++++++++---------- general/echo/umdf2/driver/AutoSync/queue.c | 19 +++++++--------- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/general/echo/kmdf/driver/AutoSync/queue.c b/general/echo/kmdf/driver/AutoSync/queue.c index b821add2..d881c003 100644 --- a/general/echo/kmdf/driver/AutoSync/queue.c +++ b/general/echo/kmdf/driver/AutoSync/queue.c @@ -86,7 +86,7 @@ Return Value: // with the same lock. // queueAttributes.SynchronizationScope = WdfSynchronizationScopeQueue; - + queueAttributes.EvtDestroyCallback = EchoEvtIoQueueContextDestroy; status = WdfIoQueueCreate( @@ -155,12 +155,12 @@ Return Value: PAGED_CODE(); // - // Create a WDFTIMER object + // Create a periodic timer. + // + // WDF_TIMER_CONFIG_INIT_PERIODIC sets AutomaticSerialization to TRUE by default. // WDF_TIMER_CONFIG_INIT_PERIODIC(&timerConfig, EchoEvtTimerFunc, Period); - timerConfig.AutomaticSerialization = FALSE; - WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes); timerAttributes.ParentObject = Queue; // Synchronize with the I/O Queue diff --git a/general/echo/kmdf/driver/DriverSync/device.c b/general/echo/kmdf/driver/DriverSync/device.c index c9dbcbb4..23f684e9 100644 --- a/general/echo/kmdf/driver/DriverSync/device.c +++ b/general/echo/kmdf/driver/DriverSync/device.c @@ -77,17 +77,6 @@ Return Value: WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT); - // - // By not setting the synchronization scope and using the default, there is - // no locking between any of the callbacks in this driver. - // - // We will create a sequential queue so all of the EvtIoXxx callbacks are - // serialized against each other (at least until the request is completed), - // but the cancel routine and the timer DPC are not synchronized against the - // queue's EvtIoXxx callbacks. - // - // attributes.SynchronizationScope = ... - status = WdfDeviceCreate(&DeviceInit, &attributes, &device); if (NT_SUCCESS(status)) { diff --git a/general/echo/kmdf/driver/DriverSync/queue.c b/general/echo/kmdf/driver/DriverSync/queue.c index 78c199d2..7835b73b 100644 --- a/general/echo/kmdf/driver/DriverSync/queue.c +++ b/general/echo/kmdf/driver/DriverSync/queue.c @@ -158,6 +158,18 @@ Return Value: // Fill in a callback for destroy, and our QUEUE_CONTEXT size // WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, QUEUE_CONTEXT); + + // + // By not setting the synchronization scope and using the default, there is + // no locking between any of the callbacks in this driver. + // + // We will create a sequential queue so all of the EvtIoXxx callbacks are + // serialized against each other (at least until the request is completed), + // but the cancel routine and the timer DPC are not synchronized against the + // queue's EvtIoXxx callbacks. + // + // attributes.SynchronizationScope = ... + attributes.EvtDestroyCallback = EchoEvtIoQueueContextDestroy; status = WdfIoQueueCreate( @@ -192,7 +204,7 @@ Return Value: KdPrint(("WdfSpinLockCreate failed 0x%x\n",status)); return status; } - + // // Create the Queue timer // @@ -234,16 +246,15 @@ Return Value: PAGED_CODE(); // - // Create a WDFTIMER object + // Create a periodic timer. + // + // By not setting the synchronization scope and using the default at WdfIoQueueCreate, + // we are explicitly *not* serializing against the queue's lock. Instead, we will do + // that on our own. // WDF_TIMER_CONFIG_INIT_PERIODIC(&timerConfig, EchoEvtTimerFunc, Period); WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes); - - // - // We are explicitly *not* serializing against the queue's lock, we will do - // that on our own. - // timerAttributes.ParentObject = Queue; Status = WdfTimerCreate( @@ -456,9 +467,9 @@ EchoSetCurrentRequest( queueContext->CurrentStatus = STATUS_SUCCESS; // - // Set the cancel routine under the lock, otherwise if we set it outside - // of the lock, the timer could run and attempt to mark the request - // uncancelable before we can mark it cancelable on this thread. Use + // Set the cancel routine under the lock, otherwise if we set it outside + // of the lock, the timer could run and attempt to mark the request + // uncancelable before we can mark it cancelable on this thread. Use // WdfRequestMarkCancelableEx here to prevent to deadlock with ourselves // (cancel routine tries to acquire the queue object lock). // @@ -746,7 +757,7 @@ Return Value: // } } - + WdfSpinLockRelease(queueContext->SpinLock); // diff --git a/general/echo/umdf2/driver/AutoSync/queue.c b/general/echo/umdf2/driver/AutoSync/queue.c index 3162a683..98860df6 100644 --- a/general/echo/umdf2/driver/AutoSync/queue.c +++ b/general/echo/umdf2/driver/AutoSync/queue.c @@ -79,7 +79,7 @@ Return Value: // with the same lock. // queueAttributes.SynchronizationScope = WdfSynchronizationScopeQueue; - + queueAttributes.EvtDestroyCallback = EchoEvtIoQueueContextDestroy; status = WdfIoQueueCreate( @@ -145,21 +145,18 @@ Return Value: WDF_OBJECT_ATTRIBUTES timerAttributes; // - // Create a WDFTIMER object + // Create a non-periodic timer since WDF does not allow periodic timer + // at passive level, which is the level UMDF callbacks are invoked at. + // The workaround is to always restart the timer in the timer callback. + // + // WDF_TIMER_CONFIG_INIT sets AutomaticSerialization to TRUE by default. // WDF_TIMER_CONFIG_INIT(&timerConfig, EchoEvtTimerFunc); - // - // WDF_OBJECT_ATTRIBUTES_INIT sets AutomaticSerialization to TRUE by default - // WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes); timerAttributes.ParentObject = Queue; // Synchronize with the I/O Queue - timerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + timerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - // - // Create a non-periodic timer since WDF does not allow periodic timer - // with autosynchronization at passive level - // Status = WdfTimerCreate(&timerConfig, &timerAttributes, Timer // Output handle @@ -530,7 +527,7 @@ Return Value: } // - // Restart the Timer since WDF does not allow periodic timer + // Restart the Timer since WDF does not allow periodic timer // with autosynchronization at passive level // WdfTimerStart(Timer, WDF_REL_TIMEOUT_IN_MS(TIMER_PERIOD)); -- cgit v1.3.1 From 30789342078bd8876351260a4460a400cfbcb6f6 Mon Sep 17 00:00:00 2001 From: Girish Pattabiraman Date: Thu, 22 Jun 2017 17:23:01 -0700 Subject: Added 32 bit format on Microphone Array 1 & 2 endpoints. --- audio/sysvad/EndpointsCommon/micarraywavtable.h | 50 ++++++++++++------------- audio/sysvad/ToneGenerator.cpp | 29 +++++++++++--- 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/audio/sysvad/EndpointsCommon/micarraywavtable.h b/audio/sysvad/EndpointsCommon/micarraywavtable.h index 3b6c2df0..beda8742 100644 --- a/audio/sysvad/EndpointsCommon/micarraywavtable.h +++ b/audio/sysvad/EndpointsCommon/micarraywavtable.h @@ -21,8 +21,8 @@ Abstract: #define MICARRAY_RAW_CHANNELS 2 // Channels for raw mode #define MICARRAY_PROCESSED_CHANNELS 1 // Channels for default mode #define MICARRAY_DEVICE_MAX_CHANNELS 2 // Max channels overall -#define MICARRAY_MIN_BITS_PER_SAMPLE_PCM 16 // Min Bits Per Sample -#define MICARRAY_MAX_BITS_PER_SAMPLE_PCM 16 // Max Bits Per Sample +#define MICARRAY_16_BITS_PER_SAMPLE_PCM 16 // 16 Bits Per Sample +#define MICARRAY_32_BITS_PER_SAMPLE_PCM 32 // 32 Bits Per Sample #define MICARRAY_RAW_SAMPLE_RATE 48000 // Raw sample rate #define MICARRAY_PROCESSED_MIN_SAMPLE_RATE 8000 // Min Sample Rate #define MICARRAY_PROCESSED_MAX_SAMPLE_RATE 48000 // Max Sample Rate @@ -253,7 +253,7 @@ KSDATAFORMAT_WAVEFORMATEXTENSIBLE MicArrayPinSupportedDeviceFormats[] = } }, // 8 - Note the ENDPOINT_MINIPAIR structures for the mic arrays use this last element as the proposed RAW format - // 48 KHz 16-bit 2 channels + // 48 KHz 32-bit 2 channels { { sizeof(KSDATAFORMAT_WAVEFORMATEXTENSIBLE), @@ -269,12 +269,12 @@ KSDATAFORMAT_WAVEFORMATEXTENSIBLE MicArrayPinSupportedDeviceFormats[] = WAVE_FORMAT_EXTENSIBLE, 2, 48000, - 192000, - 4, - 16, + 384000, + 8, + 32, sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) }, - 16, + 32, 0, // No channel configuration for unprocessed mic array STATICGUIDOF(KSDATAFORMAT_SUBTYPE_PCM) } @@ -398,8 +398,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesRawStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_RAW_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_32_BITS_PER_SAMPLE_PCM, + MICARRAY_32_BITS_PER_SAMPLE_PCM, MICARRAY_RAW_SAMPLE_RATE, MICARRAY_RAW_SAMPLE_RATE }, @@ -419,8 +419,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, MICARRAY_PROCESSED_MIN_SAMPLE_RATE, MICARRAY_PROCESSED_MIN_SAMPLE_RATE }, @@ -435,8 +435,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, 11025, 11025 }, @@ -451,8 +451,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, 16000, 16000 }, @@ -467,8 +467,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, 22050, 22050 }, @@ -483,8 +483,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, 24000, 24000 }, @@ -499,8 +499,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, 32000, 32000 }, @@ -515,8 +515,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, 44100, 44100 }, @@ -531,8 +531,8 @@ KSDATARANGE_AUDIO MicArrayPinDataRangesProcessedStream[] = STATICGUIDOF(KSDATAFORMAT_SPECIFIER_WAVEFORMATEX) }, MICARRAY_PROCESSED_CHANNELS, - MICARRAY_MIN_BITS_PER_SAMPLE_PCM, - MICARRAY_MAX_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, + MICARRAY_16_BITS_PER_SAMPLE_PCM, MICARRAY_PROCESSED_MAX_SAMPLE_RATE, MICARRAY_PROCESSED_MAX_SAMPLE_RATE }, diff --git a/audio/sysvad/ToneGenerator.cpp b/audio/sysvad/ToneGenerator.cpp index 807c50c3..2a01e49a 100644 --- a/audio/sysvad/ToneGenerator.cpp +++ b/audio/sysvad/ToneGenerator.cpp @@ -20,6 +20,14 @@ const double TWO_PI = M_PI * 2; extern DWORD g_DisableToneGenerator; +// +// Double to long conversion. +// +long ConvertToLong(double Value) +{ + return (long)(Value * _I32_MAX); +}; + // // Double to short conversion. // @@ -97,11 +105,23 @@ VOID ToneGenerator::InitNewFrame unsigned char *dataBuffer = reinterpret_cast(Frame); dataBuffer[i] = ConvertToUChar(sinValue); } - else // 16 bits per sample + else if (m_BitsPerSample == 16) { short *dataBuffer = reinterpret_cast(Frame); dataBuffer[i] = ConvertToShort(sinValue); } + else if (m_BitsPerSample == 24) + { + BYTE *dataBuffer = Frame; + long val = ConvertToLong(sinValue); + val = val >> 8; + RtlCopyMemory(dataBuffer, &val, 3); + } + else if (m_BitsPerSample == 32) + { + long *dataBuffer = reinterpret_cast(Frame); + dataBuffer[i] = ConvertToLong(sinValue); + } } m_Theta += m_SampleIncrement; @@ -120,7 +140,6 @@ VOID ToneGenerator::InitNewFrame // Buffer - Buffer to hold the samples // BufferLength - Length of the buffer. // -// Note: this function supports 16bit and 8bit samples only. // void ToneGenerator::GenerateSine ( @@ -210,13 +229,11 @@ NTSTATUS ToneGenerator::Init KFLOATING_SAVE saveData; // - // This sample supports PCM 16bit formats only. + // This sample supports PCM formats only. // if ((WfExt->Format.wFormatTag != WAVE_FORMAT_PCM && !(WfExt->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && - IsEqualGUIDAligned(WfExt->SubFormat, KSDATAFORMAT_SUBTYPE_PCM))) || - (WfExt->Format.wBitsPerSample != 16 && - WfExt->Format.wBitsPerSample != 8)) + IsEqualGUIDAligned(WfExt->SubFormat, KSDATAFORMAT_SUBTYPE_PCM)))) { status = STATUS_NOT_SUPPORTED; } -- cgit v1.3.1 From 9aea7d128a7e38adde1aff912776e022a61a3d31 Mon Sep 17 00:00:00 2001 From: Ted Hudek Date: Thu, 13 Jul 2017 11:26:01 -0700 Subject: updates per customer feedback --- avstream/avshws/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/avstream/avshws/README.md b/avstream/avshws/README.md index 73d4a389..240f9b6c 100644 --- a/avstream/avshws/README.md +++ b/avstream/avshws/README.md @@ -8,7 +8,7 @@ This sample features enhanced parameter validation and overflow detection. Provision a target computer --------------------------- -After you've installed the sample on your host computer, run Visual Studio, and from the **File** menu, select **Open**, then **Project/Solution...**, navigate to the directory where you've copied the Avshws sample, then to the C++ folder, and select **avshws.vcxproj** (the VC++ Project). +After you've cloned the sample repo to your host computer, run Visual Studio, and from the **File** menu, select **Open**, then **Project/Solution...**, navigate to the Avshws sample directory, and select **avshws.sln**. In the **Solution Explorer** pane in Visual Studio, at the top is **Solution 'avshws'**. Right-click this and select **Configuration Manager**. Follow the instructions in [Building a Driver with the WDK](http://msdn.microsoft.com/en-us/library/windows/hardware/ff554644) to set the platform, operating system, and debug configuration you want to use, and to build the sample. This sample project will automatically sign the driver package. @@ -17,7 +17,7 @@ Provision your target computer using instructions in, for example, [Preparing a Deploy the driver to the target computer ---------------------------------------- -Now you can deploy the Avshws driver that you've just built to the target computer, using guidance in [Deploying a Driver to a Test Computer](http://msdn.microsoft.com/en-us/library/windows/hardware/hh454834). Specifically, find the package file under the **Package** folder in the Avshws solution. Right-click **package** and select **Properties**. Under Configuration Properties, click **Driver install** and then **Deployment**. Here you must click the check box for **Enable deployment**, and then click the button to the right of **\**. In the next dialog you enter the **Target Computer Name** and can let the host computer automatically provision the target computer and set up debugger options. +Now you can deploy the Avshws driver that you've just built to the target computer, using guidance in [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer). Specifically, in the Visual Studio Solution Explorer, right click the Avshws project and select **Properties**. Under Configuration Properties, click **Driver Install** and then **Deployment**. Enter the **Target Device Name** and the host computer automatically provisions the target computer and sets up debugger options. Finally, in Visual Studio, from the **Build** menu select **Deploy Solution** to deploy the sample to the target computer. On the target computer, you can see the deployed package in the **%Systemdrive%\\drivertest\\drivers** folder. @@ -26,7 +26,7 @@ Install the driver On the target computer, open Device Manager, and follow these steps: -1. In the **Action** menu, click **Add Legacy Hardware**, and the **Add Hardware Wizard** appears. Click **Next** and then **Next** again. +1. In the **Action** menu, select the top node and click **Add Legacy Hardware**. Click **Next** and then **Next** again. You might need to select **Have disk** and search for the driver in the target driver folder that was set up when the test computer was provisioned. 2. In the **Add Hardware** window, select **Show All Devices**. 3. In the **Manufacturer** list in the left pane, click **Microsoft**. 4. You should see the **AVStream Simulated Hardware Sample** in the **Model** pane on the right. Click this and then click **Next**. @@ -55,8 +55,8 @@ Run the sample Follow these steps to see how the sample driver functions: 1. After installation has completed, access the driver through the Graphedt tool. Graphedt.exe is available in the *tools* directory of the WDK. -2. Before running GraphEdit, use the regsvr32 utility to register the proppage.dll DLL and to enable GraphEdit to display property pages for some of the built-in Microsoft DirectShow filters. Open an elevated command window with Administrator privileges, and navigate to the WDK or SDK *tools* directory that contains proppage.dll. -3. On the command line, type regsvr32 proppage.dll. If the registration succeeds, you'll get a message, "DllRegisterServer in proppage.dll succeeded." Click OK. +2. Before running GraphEdt, use the regsvr32 utility to register the proppage.dll DLL and to enable GraphEdit to display property pages for some of the built-in Microsoft DirectShow filters. Open an elevated command window with Administrator privileges, and navigate to the WDK or SDK *tools* directory that contains proppage.dll. +3. On the command line, type `regsvr32 "c:\Program Files (x86)\Windows Kits\10\Tools\x64\proppage.dll"`. If the registration succeeds, you'll get a message, "DllRegisterServer in proppage.dll succeeded." Click OK. 4. In the Graphedt tool, click the **Graph** menu and click **Insert Filters**. The sample appears under "WDM Streaming Capture Devices" as "avshws Source." 5. Click **Insert Filter**. The sample appears in the graph as a single filter labeled, "avshws Source." There is one output pin, which is the video capture pin. This pin emits video in YUY2 format. 6. Attach this filter to either a DirectShow Video Renderer or to the VMR default video renderer. Then click **Play**. -- cgit v1.3.1 From 25e7ff1a8513f9fe370562118ca336488650503d Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Mon, 17 Jul 2017 11:04:11 -0700 Subject: Update USB vendor list to 2017-05-31 --- usb/usbview/vndrlist.h | 868 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 762 insertions(+), 106 deletions(-) diff --git a/usb/usbview/vndrlist.h b/usb/usbview/vndrlist.h index aa2db6c6..5e3f69b3 100644 --- a/usb/usbview/vndrlist.h +++ b/usb/usbview/vndrlist.h @@ -10,23 +10,23 @@ Abstract: This header file contains a list of all currently known USB Vendor IDs and the vendor name associated with each Vendor ID. - + Source: http://www.usb.org -Environment: +Environment: Kernel & user mode Revision History: 04-25-97 : created - 03-28-03 : refreshed with latest list from usb.org - 05-04-05 : refreshed with latest list from usb.org - 05-02-07 : refreshed with latest list from usb.org - 03-19-08 : refreshed with latest list from usb.org - + 03-28-03 : refreshed with latest list from usb.org + 05-04-05 : refreshed with latest list from usb.org + 05-02-07 : refreshed with latest list from usb.org + 03-19-08 : refreshed with latest list from usb.org + --*/ #ifndef __VNDRLIST_H__ @@ -35,7 +35,7 @@ Revision History: // // Vendor ID structure // -typedef struct _VENDOR_ID { +typedef struct _VENDOR_ID { USHORT usVendorID; PCHAR szVendor; } VENDOR_ID, *PVENDOR_ID; @@ -47,10 +47,10 @@ typedef struct _VENDOR_ID { // This information has not been independently verified and no claims // are made here as to its accuracy. // -// 10323 total +// 10978 total // VENDOR_ID USBVendorIDs[] = -{ +{ { 0x0079, "Shenzhen Longshengwei Technology, Co., Ltd." }, { 0x013A, "Aimgene Technology Co., Ltd" }, { 0x03CC, "GN OTOMETRICS" }, @@ -61,7 +61,7 @@ VENDOR_ID USBVendorIDs[] = { 0x03EC, "Iwatsu America Inc." }, { 0x03ED, "Mitel Corporation" }, { 0x03EE, "Mitsumi" }, - { 0x03F0, "Hewlett Packard" }, + { 0x03F0, "HP Inc." }, { 0x03F1, "Genoa Technology" }, { 0x03F2, "Oak Technology, Inc" }, { 0x03F3, "Adaptec, Inc." }, @@ -198,7 +198,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0486, "ASUS Computers Inc." }, { 0x0487, "Stewart Connector" }, { 0x0488, "Cirque Corporation" }, - { 0x0489, "Foxconn / Hon Hai" }, + { 0x0489, "Foxconn - Hon Hai" }, { 0x048A, "S-MOS Systems, Inc." }, { 0x048C, "Alps Electric Ireland Ltd." }, { 0x048D, "ITE Tech Inc." }, @@ -503,7 +503,7 @@ VENDOR_ID USBVendorIDs[] = { 0x05C5, "Digi International Inc." }, { 0x05C6, "Qualcomm, Inc" }, { 0x05C7, "Qtronix Corp" }, - { 0x05C8, "Foxlink/Cheng Uei Precision Industry Co., Ltd." }, + { 0x05C8, "Foxlink/Cheng Uei Precision Industry Co., Ltd" }, { 0x05C9, "Semtech" }, { 0x05CA, "Ricoh Company Ltd." }, { 0x05CB, "PowerVision Technologies Inc." }, @@ -533,7 +533,7 @@ VENDOR_ID USBVendorIDs[] = { 0x05E4, "Red Wing Corporation" }, { 0x05E5, "Fuji Electric Co., Ltd." }, { 0x05E6, "Keithley Instruments" }, - { 0x05E7, "EIZO Nanoa Technologies Inc." }, + { 0x05E7, "EIZO Nanao Technologies Inc." }, { 0x05E8, "ICC, Inc." }, { 0x05E9, "Kawasaki Microelectronics America, Inc." }, { 0x05EA, "Evergreen Systems International" }, @@ -600,7 +600,7 @@ VENDOR_ID USBVendorIDs[] = { 0x062B, "Greatlink Electronics Taiwan Ltd." }, { 0x062C, "Institute for Information Industry" }, { 0x062D, "Taiwan Tai-Hao Enterprises Co. Ltd." }, - { 0x062E, "JPC/MAIN SUPER Inc." }, + { 0x062E, "JPC-MAIN SUPER Inc." }, { 0x062F, "Sin Sheng Terminal & Machine Inc." }, { 0x0630, "ORL" }, { 0x0631, "JUJO Electronics Corporation" }, @@ -713,7 +713,7 @@ VENDOR_ID USBVendorIDs[] = { 0x06A0, "USB Systems Design" }, { 0x06A1, "Alexon Co., Ltd." }, { 0x06A2, "Topro Technology Inc." }, - { 0x06A3, "Mad Catz Europe Ltd." }, + { 0x06A3, "Logitech Europe S.A." }, { 0x06A4, "Xiamen Doowell Electron Co., Ltd." }, { 0x06A5, "Divio" }, { 0x06A7, "MicroStore, Inc." }, @@ -924,11 +924,11 @@ VENDOR_ID USBVendorIDs[] = { 0x077A, "NIDEC SANKYO CORPORATION" }, { 0x077B, "Linksys" }, { 0x077C, "Forward Electronics Co., Ltd." }, - { 0x077D, "Griffin Technology" }, + { 0x077D, "Griffin Technology LLC" }, { 0x077E, "Softing GmbH" }, { 0x077F, "Well Excellent & Most Corp." }, { 0x0780, "ORGA Kartensysteme GmbH" }, - { 0x0781, "SanDisk Corporation" }, + { 0x0781, "Western Digital, Sandisk" }, { 0x0782, "Trackerball" }, { 0x0783, "C3PO, S.L." }, { 0x0784, "Pretec Corporation" }, @@ -1000,7 +1000,7 @@ VENDOR_ID USBVendorIDs[] = { 0x07C6, "ShareWave, Inc." }, { 0x07C7, "Powertech Industrial Co., Ltd." }, { 0x07C8, "B.U.G., Inc." }, - { 0x07C9, "Allied Telesyn International" }, + { 0x07C9, "Allied Telesis Inc" }, { 0x07CA, "AVerMedia Technologies, Inc." }, { 0x07CB, "Kingmax Technology Inc." }, { 0x07CC, "LIWANLI Innovation Co., Ltd" }, @@ -1107,7 +1107,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0832, "Kouwell Electronics Corp." }, { 0x0833, "Sourcenext Corporation" }, { 0x0834, "Ciponic Technology Co., Ltd." }, - { 0x0835, "Action Star Enterprise Co., Ltd." }, + { 0x0835, "Action Star Technology Co., Ltd." }, { 0x0836, "Evertz Microsystems Ltd." }, { 0x0837, "Renishaw PLC" }, { 0x0838, "Precision MicroControl Corporation" }, @@ -1165,7 +1165,7 @@ VENDOR_ID USBVendorIDs[] = { 0x086C, "DeTeWe" }, { 0x086D, "ICE Technology" }, { 0x086E, "System TALKS Inc." }, - { 0x086F, "MEC IMEX INC/HPT" }, + { 0x086F, "MEC IMEX INC-HPT" }, { 0x0870, "Metricom, Inc." }, { 0x0871, "Merge Technologies Inc." }, { 0x0872, "Broadxent, Inc." }, @@ -1174,7 +1174,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0875, "Mecel AB" }, { 0x0876, "3M Home Health Systems" }, { 0x0877, "Lew Engineering" }, - { 0x0878, "SYSTEC Computer Gmbh." }, + { 0x0878, "SYSTEC Computer Gmbh" }, { 0x0879, "Comtrol Corporation" }, { 0x087A, "Getemed GmbH" }, { 0x087B, "Cornerstone Peripherals Technology" }, @@ -1237,7 +1237,7 @@ VENDOR_ID USBVendorIDs[] = { 0x08B6, "Imagek, Inc." }, { 0x08B7, "NATSU Corporation Limited" }, { 0x08B8, "J. Gordon Electronic Design, Inc." }, - { 0x08B9, "RadioShack Corporation" }, + { 0x08B9, "General Wireless Operations Inc" }, { 0x08BA, "Fujitsu General Limited" }, { 0x08BB, "Texas Instruments Japan" }, { 0x08BC, "Dr. G. Schuhfried GmbH" }, @@ -1416,7 +1416,7 @@ VENDOR_ID USBVendorIDs[] = { 0x096B, "ML Electronics Ltd." }, { 0x096C, "GOPEL electronic GmbH" }, { 0x096D, "PennyLan" }, - { 0x096E, "Feitian New Technology Co." }, + { 0x096E, "Feitian Technologies Co., Ltd." }, { 0x096F, "Memory Link" }, { 0x0970, "K.S. Vector Co., Ltd." }, { 0x0971, "GretagMacbeth AG" }, @@ -1828,7 +1828,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0B0B, "Datamax Corporation" }, { 0x0B0C, "Todos Data System AB" }, { 0x0B0D, "Project Lab" }, - { 0x0B0E, "GN Netcom" }, + { 0x0B0E, "GN Audio" }, { 0x0B0F, "AVID Technology" }, { 0x0B10, "Pcally" }, { 0x0B11, "I Tech Solutions Co., Ltd." }, @@ -1980,7 +1980,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0BAA, "Dr. Gerhard Schmidt GmbH" }, { 0x0BAB, "House Ear Institute" }, { 0x0BAC, "Biometric Access Corporation" }, - { 0x0BAD, "Lab-Volt Itee" }, + { 0x0BAD, "Festo Didactic Ltd/Ltee" }, { 0x0BAE, "IGEN International, Inc." }, { 0x0BAF, "U.S. Robotics" }, { 0x0BB0, "Concord Camera Corp." }, @@ -2094,7 +2094,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0C1C, "Hang Zhou Silan Microelectronics Co. Ltd" }, { 0x0C1D, "Digital Audio Corporation" }, { 0x0C1E, "TAKAYA CORP." }, - { 0x0C1F, "Ultra Electronics Ltd (Ocean Systems)" }, + { 0x0C1F, "Magicard Ltd" }, { 0x0C20, "Viditec Inc." }, { 0x0C21, "Lunatronic" }, { 0x0C22, "TallyGenicom LP" }, @@ -2219,7 +2219,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0C9A, "Hanool Robotics Corp" }, { 0x0C9B, "Jobin Yvon, Inc." }, { 0x0C9C, "Brand Innovators" }, - { 0x0C9D, "Semtek IP Incorporated" }, + { 0x0C9D, "DyOcean" }, { 0x0C9E, "PLEXUS MULTIMEDIA PTE LTD" }, { 0x0C9F, "Extenex Corporation" }, { 0x0CA0, "Robert Bosch GmbH - Automotive Aftermarket" }, @@ -2263,7 +2263,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0CC7, "Kontron Medical AG" }, { 0x0CC8, "Technotools Corporation" }, { 0x0CC9, "BroadMAX Technologies, Inc." }, - { 0x0CCA, "AMPHENOL" }, + { 0x0CCA, "Amphenol Corporation" }, { 0x0CCB, "SKNET CORPORATION LTD." }, { 0x0CCC, "DOMEX TECHNOLOGY CORPORATION" }, { 0x0CCD, "TerraTec Electronic GmbH" }, @@ -2631,7 +2631,7 @@ VENDOR_ID USBVendorIDs[] = { 0x0E3E, "Good Technology, Inc." }, { 0x0E3F, "AM Group Corp." }, { 0x0E40, "Proteq LTDA" }, - { 0x0E41, "Line 6" }, + { 0x0E41, "Line 6, Inc." }, { 0x0E42, "Puretek Industrial Co., Ltd." }, { 0x0E43, "Holly Lin International Technology Inc." }, { 0x0E44, "Sun-Riseful Technology Co., Ltd." }, @@ -3148,7 +3148,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1045, "Transiciel Technologies" }, { 0x1046, "Hitachi Asahi Electronics Co., Ltd." }, { 0x1047, "HOYA CORPORATION Vision Care Company" }, - { 0x1048, "Targus Group International" }, + { 0x1048, "Targus International LLC" }, { 0x1049, "Studio Technologies, Inc." }, { 0x104A, "WACOH Corporation" }, { 0x104B, "CSM GmbH" }, @@ -3164,7 +3164,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1055, "Complex Micro Interconnection Co., Ltd." }, { 0x1056, "Hsin Chen Ent Co., Ltd." }, { 0x1057, "ON Semiconductor" }, - { 0x1058, "Western Digital Technologies, Inc." }, + { 0x1058, "Western Digital, Branded" }, { 0x1059, "Giesecke & Devrient GmbH" }, { 0x105A, "DDS, Inc." }, { 0x105B, "TOKIWA WEST Co., Ltd." }, @@ -3175,7 +3175,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1060, "Easthome Industrial Co., Ltd." }, { 0x1061, "Cardinal Components Inc." }, { 0x1062, "Sumitomo Electric Industries, Ltd." }, - { 0x1063, "LPKF Motion & Control GmbH" }, + { 0x1063, "LPKF Laser & Electronics AG" }, { 0x1064, "INNOPLUS Co., Ltd." }, { 0x1065, "ImageQuest Co., Ltd." }, { 0x1066, "Eten Information Systems Co., Ltd." }, @@ -3468,7 +3468,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1186, "Scientec System" }, { 0x1187, "Techno Valley Co., Ltd." }, { 0x1188, "Bloomberg L.P." }, - { 0x1189, "Trisat Industrial Co., Ltd." }, + { 0x1189, "Trisat IndTry Computer Co. LTD." }, { 0x118A, "KEBA AG" }, { 0x118B, "AXIOMTEK Co., Ltd." }, { 0x118C, "INFINIT GmbH" }, @@ -3967,7 +3967,7 @@ VENDOR_ID USBVendorIDs[] = { 0x137A, "Weldon Technologies, Inc." }, { 0x137B, "SCAPS GmbH" }, { 0x137C, "Yaskawa Electric Corporation" }, - { 0x137D, "Pericom Semiconductor Corp." }, + { 0x137D, "Diodes Incorporated" }, { 0x137E, "XL Microwave, Inc." }, { 0x137F, "Sata Hi Tech Services" }, { 0x1380, "Staveley Instruments" }, @@ -4001,7 +4001,7 @@ VENDOR_ID USBVendorIDs[] = { 0x139C, "Deltronics" }, { 0x139D, "Digisafe Pte. Ltd." }, { 0x139E, "Valueplus Inc." }, - { 0x139F, "NAGRAVISION SA" }, + { 0x139F, "Audio Technology Switzerland SA" }, { 0x13A0, "Essilor International" }, { 0x13A1, "Canas Co., Ltd." }, { 0x13A2, "Pesa Switching Systems, Inc." }, @@ -4095,7 +4095,7 @@ VENDOR_ID USBVendorIDs[] = { 0x13FA, "Radiantech, Inc." }, { 0x13FB, "Noritsu Koki Co., Ltd." }, { 0x13FC, "Compucat Research Pty Limited" }, - { 0x13FD, "Initio Corporation" }, + { 0x13FD, "Initio (HK) Corporation Limited" }, { 0x13FE, "Phison Electronics Corp." }, { 0x13FF, "VIEWCON ELECTRONIC LTD." }, { 0x1400, "Axxion Group Corp." }, @@ -4321,7 +4321,7 @@ VENDOR_ID USBVendorIDs[] = { 0x14DE, "Jetway Information Co., Ltd." }, { 0x14DF, "COMPRION GmbH" }, { 0x14E0, "Winradio Communications" }, - { 0x14E1, "Dialogue Technology Corp." }, + { 0x14E1, "Imagination Broadway Ltd" }, { 0x14E2, "Avistar Communications Corporation" }, { 0x14E3, "Medmont Pty Ltd." }, { 0x14E4, "S.CAM Co., Ltd." }, @@ -4456,7 +4456,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1565, "Advance Modules" }, { 0x1566, "WIN ACCORD LTD." }, { 0x1567, "MUTOH Industries Ltd." }, - { 0x1568, "Sunf Pu Technology Co., Ltd" }, + { 0x1568, "Sunf Pu Technology (Dong-Guan) Co., Ltd." }, { 0x1569, "Mad City Labs, Inc." }, { 0x156A, "Logical Solutions, Inc." }, { 0x156B, "Cairn Research Ltd." }, @@ -4522,7 +4522,7 @@ VENDOR_ID USBVendorIDs[] = { 0x15A7, "APPSware Wireless LLC dba Apriva" }, { 0x15A8, "Shen Zhen Teamspower Electronics Co., Ltd." }, { 0x15A9, "Gemtek Technology Co., Ltd." }, - { 0x15AA, "DongGuan Ya Lian Electronics Co., Ltd." }, + { 0x15AA, "GuangDong Ya Lian Technology Co., Ltd" }, { 0x15AB, "Virgin HealthMiles, Inc." }, { 0x15AC, "Smartware" }, { 0x15AD, "Bleile Datentechnik GmbH" }, @@ -4670,7 +4670,7 @@ VENDOR_ID USBVendorIDs[] = { 0x163B, "Controlled Speed Engineering Ltd." }, { 0x163C, "Watchdata System Co., Ltd." }, { 0x163D, "Million Tech Dev. Ltd." }, - { 0x163E, "HongLin Electronics Co., Ltd." }, + { 0x163E, "Dezhou HongJu Communication Technology Co., Ltd." }, { 0x163F, "AVEX Technologies, Inc." }, { 0x1640, "M3 Electronics, Inc." }, { 0x1641, "eMagin Corporation" }, @@ -5527,7 +5527,7 @@ VENDOR_ID USBVendorIDs[] = { 0x199A, "DNA-Technology" }, { 0x199B, "MicroStrain, Inc." }, { 0x199C, "Richnex Microelectronics Corporation" }, - { 0x199D, "Dexxon Data Media" }, + { 0x199D, "Dexxon Groupe" }, { 0x199E, "The Imaging Source Europe GmbH" }, { 0x199F, "Benica Corporation" }, { 0x19A0, "Krautkramer Japan Co., Ltd." }, @@ -5731,7 +5731,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1A67, "Privaris" }, { 0x1A68, "Double Top Technology Ltd." }, { 0x1A69, "Kalon Semiconductor, Inc." }, - { 0x1A6A, "Spansion Inc." }, + { 0x1A6A, "Cypress Semiconductor GmbH" }, { 0x1A6B, "Taiwin Electronics Co., Ltd." }, { 0x1A6C, "Hivion Co., Ltd." }, { 0x1A6D, "SamYoung Electronics Co., Ltd" }, @@ -5746,7 +5746,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1A76, "JADAK Technologies, Inc." }, { 0x1A77, "American Master Import 26, Inc." }, { 0x1A78, "AirLink Communications, Inc." }, - { 0x1A79, "Bayer Health Care LLC" }, + { 0x1A79, "Ascensia Diabetes Care" }, { 0x1A7A, "Softron Co., Ltd." }, { 0x1A7B, "Lumberg Connect GmbH" }, { 0x1A7C, "Evoluent LLC" }, @@ -5888,7 +5888,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1B04, "MEILHAUS Electronic GmbH" }, { 0x1B05, "Cracol Developments Ltd." }, { 0x1B06, "OPGAL" }, - { 0x1B07, "WEY Elektronik AG" }, + { 0x1B07, "WEY Technology AG" }, { 0x1B08, "Actimo Inc." }, { 0x1B09, "MISUZU INDUSTRIES CORPORATION" }, { 0x1B0A, "Sense Technology Inc." }, @@ -6068,7 +6068,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1BB8, "MIZOUE PROJECT JAPAN Corporation" }, { 0x1BB9, "Qpixel Technology, Inc." }, { 0x1BBA, "Medicomp, Inc." }, - { 0x1BBB, "TCT Mobile Limited" }, + { 0x1BBB, "TCL Communication Ltd" }, { 0x1BBC, "KATHREIN-Werke KG" }, { 0x1BBD, "Videology Imaging Solutions, Inc." }, { 0x1BBE, "CE+T s.a." }, @@ -6089,7 +6089,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1BCD, "AZKOYEN" }, { 0x1BCE, "Contac Cable Industrial Limited" }, { 0x1BCF, "Sunplus Innovation Technology Inc." }, - { 0x1BD0, "Hangzhou Riyue Electronic Co., Ltd." }, + { 0x1BD0, "Hangzhou Riyue Electronics Co., Ltd." }, { 0x1BD1, "Companion Worlds, Inc." }, { 0x1BD2, "Beijing G & D Card Systems Co., Ltd." }, { 0x1BD3, "3layer Engineering" }, @@ -6098,7 +6098,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1BD6, "Lodam electronics" }, { 0x1BD7, "TouchNetworks, Inc." }, { 0x1BD8, "Image Computer Systems Limited" }, - { 0x1BD9, "Control Products, Inc." }, + { 0x1BD9, "Emerson" }, { 0x1BDA, "University of Southampton" }, { 0x1BDB, "Spectral Applied Research" }, { 0x1BDC, "Slacker" }, @@ -6186,7 +6186,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1C2E, "LiveWire Test Labs, Inc." }, { 0x1C2F, "Wessex Advanced Switching Products Ltd." }, { 0x1C30, "Li Creative Technologies, Inc." }, - { 0x1C31, "LS Mtron" }, + { 0x1C31, "LS Mtron Ltd." }, { 0x1C32, "INTELBANQ" }, { 0x1C33, "EK-TEAM GmbH" }, { 0x1C34, "Pro-Active" }, @@ -6665,7 +6665,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1E0D, "NEOWAVE" }, { 0x1E0E, "SHANGHAI BASECOM LTD." }, { 0x1E0F, "mSilica Inc." }, - { 0x1E10, "Point Grey Research Inc." }, + { 0x1E10, "FLIR Integrated Imaging Solutions" }, { 0x1E11, "Hoya Xponent" }, { 0x1E12, "OCTRIAN" }, { 0x1E13, "Burgundy Electric, LLC" }, @@ -6900,7 +6900,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1EF8, "CRITICAL LINK, LLC" }, { 0x1EF9, "US Army Electronic Proving Ground" }, { 0x1EFA, "SEIKO Precision Inc." }, - { 0x1EFB, "TOUR & ANDERSSON AB" }, + { 0x1EFB, "IMI Hydronic Engineering International SA" }, { 0x1EFC, "IMOGEN STUDIO" }, { 0x1EFD, "ROFIN-SINAR LASER GMBH" }, { 0x1EFE, "Sound Design Technologies" }, @@ -6931,7 +6931,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1F17, "APIS Device, Inc." }, { 0x1F18, "Teseq GmbH" }, { 0x1F19, "POLATIS INC." }, - { 0x1F1A, "SANDEN CORPORATION" }, + { 0x1F1A, "Sanden Retail Systems Corporation" }, { 0x1F1B, "NORTHROP GRUMMAN SPERRY MARINE" }, { 0x1F1C, "LXE, INC." }, { 0x1F1D, "How Weih Precision Technology (Shenzhen) Co., Ltd." }, @@ -6990,7 +6990,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1F52, "Systems & Electronic Development FZCO (SEDCO)" }, { 0x1F53, "SK telesys" }, { 0x1F54, "LOEC, INC." }, - { 0x1F55, "Fujitsu Semiconductor Europe GmbH" }, + { 0x1F55, "Fujitsu Electronics Europe GmbH" }, { 0x1F56, "MUT" }, { 0x1F57, "PIGNOLO S.P.A." }, { 0x1F58, "Inmarsat" }, @@ -7086,7 +7086,7 @@ VENDOR_ID USBVendorIDs[] = { 0x1FB2, "WITHINGS" }, { 0x1FB3, "Matchbeeper AB" }, { 0x1FB4, "Owl Computing Technologies, Inc." }, - { 0x1FB5, "Unify GmbH & Co. KG" }, + { 0x1FB5, "Unify Software and Solutions GmbH & Co. KG" }, { 0x1FB6, "SheKel" }, { 0x1FB7, "J & D Tech Co., Ltd." }, { 0x1FB8, "DORMA TIME + ACCESS GmbH" }, @@ -7196,7 +7196,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2020, "Shanghai BroadMobi Communication Technology Co., Ltd." }, { 0x2021, "Smartd ltd" }, { 0x2022, "AMICON Ltd." }, - { 0x2023, "BERTHOLD DETECTION SYSTEMS GmbH" }, + { 0x2023, "Berthold Technologies GmbH & Co. KG" }, { 0x2024, "Shoto Technologies LLC" }, { 0x2025, "NANOSENSE" }, { 0x2026, "EASUN REYROLLE LIMITED" }, @@ -7283,7 +7283,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2077, "Shenzhen Gongjin Electronics Co., Ltd." }, { 0x2078, "Epsilon Electronics, Inc dba Power Acoustik Electronics" }, { 0x2079, "New Concept Gaming Ltd." }, - { 0x207A, "CETWIN AB" }, + { 0x207A, "C.E.T.W.I.N System Solutions Sweden AB" }, { 0x207B, "Technetix Group Ltd." }, { 0x207C, "NESA International, Inc." }, { 0x207D, "CESI Technology Co., Ltd." }, @@ -7311,7 +7311,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2093, "Ambu A/S" }, { 0x2094, "Yoostar Entertainment Group, Inc." }, { 0x2095, "CE LINK LIMITED" }, - { 0x2096, "Microconn Electronic Co., Ltd." }, + { 0x2096, "Shenzhen Microconn Investment and Development Co., Ltd." }, { 0x2097, "USBPARTNER" }, { 0x2098, "TouchTable, Inc." }, { 0x2099, "Systematic Development Group, LLC" }, @@ -7421,7 +7421,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2101, "NAS Technologies Corp." }, { 0x2102, "Vitalograph Ltd." }, { 0x2103, "OHMORI ELECTRIC INDUSTRIES CO., LTD." }, - { 0x2104, "Tobii Technology AB" }, + { 0x2104, "Tobii AB" }, { 0x2105, "Retail Innovation HTT AB" }, { 0x2106, "Sharp Korea Corporation" }, { 0x2107, "Amstore CD Production Ltd." }, @@ -7483,7 +7483,7 @@ VENDOR_ID USBVendorIDs[] = { 0x213F, "Digitron Instrumentation Ltd." }, { 0x2140, "Sichuan Jiuzhou Electric Group Co., Ltd." }, { 0x2141, "ZT Group Int'l, Inc." }, - { 0x2142, "Pulsecom" }, + { 0x2142, "Enginuity Communications" }, { 0x2143, "InDevR Inc." }, { 0x2144, "Sea Tel, Inc." }, { 0x2145, "Ballard Technology" }, @@ -7535,7 +7535,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2173, "HUIZHOU HUANGJI PRECISIONS FLEX ELECTRONICAL CO., LTD." }, { 0x2174, "Transcend Information, Inc." }, { 0x2175, "Light Blue Optics, Inc." }, - { 0x2176, "TMC/Allion Test Labs" }, + { 0x2176, "TMC - Allion Test Labs" }, { 0x2177, "CHAUVIN ARNOUX" }, { 0x2178, "Ion Science" }, { 0x2179, "UGtizer Corp." }, @@ -7553,7 +7553,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2185, "FUJIWORK Co., Ltd." }, { 0x2186, "Home Server Technologies Inc." }, { 0x2187, "ESPACE SERVICES MULTIMEDIAS" }, - { 0x2188, "CalDigit" }, + { 0x2188, "CalDigit, Inc." }, { 0x2189, "SEMNTECH" }, { 0x218A, "EXELYS LLC" }, { 0x218B, "Blackbird Technologies Inc." }, @@ -7613,7 +7613,7 @@ VENDOR_ID USBVendorIDs[] = { 0x21C1, "Baumann Electronic Controls, LLC" }, { 0x21C2, "Shenzhen V-Interface Technology Co., Ltd." }, { 0x21C3, "MASIMO LABORATORIES INC." }, - { 0x21C4, "Netcom Technology (HK) Limited" }, + { 0x21C4, "Longsys Electronics (HK) Co., Ltd." }, { 0x21C5, "Vukic Computer Instruments GmbH" }, { 0x21C6, "PSS Hong Kong Limited" }, { 0x21C7, "Unisoku Co., Ltd." }, @@ -7648,7 +7648,7 @@ VENDOR_ID USBVendorIDs[] = { 0x21E4, "Xcellen Co., Ltd." }, { 0x21E5, "Kruglov Evgeniy Vladimirovich" }, { 0x21E6, "OCZ Technology Group" }, - { 0x21E7, "Sagem Communications SAS" }, + { 0x21E7, "Sagemcom Broadband SAS" }, { 0x21E8, "BOEHNKE + PARTNER GmbH Steuerungssysteme" }, { 0x21E9, "Jiafuh Metal & Plastic (ShenZhen) Co., Ltd." }, { 0x21EA, "JUST MAKE ELECTRONICS CO., LTD." }, @@ -7765,7 +7765,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2259, "Skypine Electronics (Shenzhen) Co., Ltd." }, { 0x225A, "Vivanco GmbH" }, { 0x225B, "Lineage Power" }, - { 0x225C, "Burroughs Payment Systems, Inc." }, + { 0x225C, "Digital Check Corp" }, { 0x225D, "Sagem Securite" }, { 0x225E, "Unholtz-Dickie Corp." }, { 0x225F, "Ace Karaoke Corp." }, @@ -7873,7 +7873,7 @@ VENDOR_ID USBVendorIDs[] = { 0x22C5, "Himax Technologies, Inc." }, { 0x22C6, "Baker Hughes Production Quest" }, { 0x22C7, "MEMUP" }, - { 0x22C8, "Karming Electronic (Shenzhen) Co., Ltd." }, + { 0x22C8, "Shenzhen Xinerchang Electronics Co., Ltd." }, { 0x22C9, "StepOver GmbH" }, { 0x22CA, "Amimon Ltd." }, { 0x22CB, "Forware Spain S.L." }, @@ -7977,7 +7977,7 @@ VENDOR_ID USBVendorIDs[] = { 0x232D, "Edinburgh Instruments Ltd." }, { 0x232E, "EA, Elektro-Automatik GmbH & Co. KG" }, { 0x232F, "Motic China Group Co., Ltd." }, - { 0x2330, "Tensorcom" }, + { 0x2330, "Tensorcom, Inc." }, { 0x2331, "PUZZLE LOGIC INC." }, { 0x2332, "Coges S.p.A." }, { 0x2333, "Zamzee Co." }, @@ -8098,9 +8098,9 @@ VENDOR_ID USBVendorIDs[] = { 0x23A6, "Tronical Components GmbH" }, { 0x23A7, "System In Frontier Inc." }, { 0x23A8, "Sagio A/S" }, - { 0x23A9, "SiliconGo Microelectronics Co., Ltd." }, + { 0x23A9, "SiliconGo Microelectronics Inc." }, { 0x23AA, "DOK (HK) Trading Limited" }, - { 0x23AB, "Shenzhen Zhengtong Electronics Co., Ltd." }, + { 0x23AB, "SZZT ELECTRONICS CO., LTD" }, { 0x23AC, "Marunix Electron Limited" }, { 0x23AD, "voxeljet technology GmbH" }, { 0x23AE, "DIGITAL DEVICES UG" }, @@ -8174,7 +8174,7 @@ VENDOR_ID USBVendorIDs[] = { 0x23F2, "Northern Digital Inc." }, { 0x23F3, "Funke Digital TV" }, { 0x23F4, "NXT Plc" }, - { 0x23F5, "Speed Conn Co., Ltd." }, + { 0x23F5, "Speed Conn Electronics (Shenzhen) Co., Ltd." }, { 0x23F6, "Gamesman Ltd." }, { 0x23F7, "TechRhythm, Inc." }, { 0x23F8, "Xiangde Electronic Technologies (Shenzhen) Co., Ltd." }, @@ -8191,7 +8191,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2403, "XTRAMUS TECHNOLOGIES" }, { 0x2404, "GE MDS" }, { 0x2405, "Custom Computer Services, Inc." }, - { 0x2406, "INSIDE Secure" }, + { 0x2406, "WIseKey" }, { 0x2407, "Incasolution Co., Ltd." }, { 0x2408, "Catalyst Enterprises, Inc." }, { 0x2409, "BCInet, Inc." }, @@ -8261,7 +8261,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2449, "SHAEFER GmbH" }, { 0x244A, "Onzo Ltd." }, { 0x244B, "Applied Technical Systems" }, - { 0x244C, "Minebea Co., Ltd." }, + { 0x244C, "MinebeaMitsumi Inc." }, { 0x244D, "Pantec Biosolutions AG" }, { 0x244E, "ShopGuard Ltd." }, { 0x244F, "iWall A/S" }, @@ -8271,7 +8271,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2453, "BAANTO" }, { 0x2454, "Velosti Technology Limited" }, { 0x2455, "Anton/Bauer, Inc." }, - { 0x2456, "Nikki Denso Co., Ltd." }, + { 0x2456, "CKD NIKKI DENSO CO., LTD" }, { 0x2457, "Alcomp. Inc." }, { 0x2458, "Bluegiga Technologies Oy" }, { 0x2459, "Secure Holdings Limited" }, @@ -8292,7 +8292,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2468, "New Cosmos Electric Co., Ltd." }, { 0x2469, "Gloria Music Corp." }, { 0x246A, "UNH Interoperability Laboratory" }, - { 0x246B, "Perfect Fortune Electric Wire & Cable (ShenZhen) Co Ltd" }, + { 0x246B, "Perfect Fortune Electric Wire & Cable (ShenZhen) Co. Ltd." }, { 0x246C, "Shanghai Fudan Microelectronics Co., Ltd." }, { 0x246D, "TrackMan A/S" }, { 0x246E, "Movinto Fun AB" }, @@ -8306,7 +8306,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2476, "Yost Engineering Inc." }, { 0x2477, "UbiVelox" }, { 0x2478, "Sonix Technology (Shenzhen) Co., Ltd." }, - { 0x2479, "visiosens GmbH" }, + { 0x2479, "smartek d.o.o." }, { 0x247A, "Suzhou Jutze Technologies Co., Ltd" }, { 0x247B, "Digibras Industria do Brasil S.A" }, { 0x247C, "Fullconn Industry Inc." }, @@ -8462,7 +8462,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2512, "RNDPLUS Co., Ltd." }, { 0x2513, "RMI Laser, LLC" }, { 0x2514, "Fullpower Technologies" }, - { 0x2515, "KOREA O/S TECHNOLOGIES" }, + { 0x2515, "AMITEK" }, { 0x2516, "Cooler Master Co., Ltd." }, { 0x2517, "Marel EHF" }, { 0x2518, "Anite Telecoms Inc." }, @@ -8571,7 +8571,7 @@ VENDOR_ID USBVendorIDs[] = { 0x257F, "8devices" }, { 0x2580, "DJ Techtools (Golden Sol Music LLC. Is Holding Co.)" }, { 0x2581, "Plug-up" }, - { 0x2582, "Systeme Helmholz GmbH" }, + { 0x2582, "Helmholz GmbH & Co. KG" }, { 0x2583, "VECTRUX DISTRIBUTORS LLC" }, { 0x2584, "COSMO CO., LTD." }, { 0x2585, "HomeChip Ltd." }, @@ -8739,7 +8739,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2627, "Vectron Systems AG" }, { 0x2628, "TEN-TEC, INC." }, { 0x2629, "Winstars Technology Limited" }, - { 0x262A, "SAVITECH Corporation" }, + { 0x262A, "SAVITECH CORP." }, { 0x262B, "YTOP Electronics Technical (Kunshan) Co., Ltd." }, { 0x262C, "Scannx" }, { 0x262D, "Fujian Witsi Microelectronics Technology Co., Ltd." }, @@ -8770,7 +8770,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2646, "Bel Canto Design, Ltd." }, { 0x2647, "FORMER ENGINEERING SERVICE CO., LTD." }, { 0x2648, "Telongo LLC" }, - { 0x2649, "BYOS Audio, Inc." }, + { 0x2649, "Soundspring Audio, Inc" }, { 0x264A, "THERMALTAKE Technology Co., Ltd." }, { 0x264B, "Industrial Indexing Systems" }, { 0x264C, "Si14 SpA" }, @@ -8968,7 +8968,7 @@ VENDOR_ID USBVendorIDs[] = { 0x270C, "Inhon Computer Co., Ltd." }, { 0x270D, "ROSAND Technologies" }, { 0x270E, "Applied Security Inc." }, - { 0x270F, "HGST, a Western Digital Company" }, + { 0x270F, "Western Digital, HGST" }, { 0x2710, "Kontron America, Inc." }, { 0x2711, "ASD Inc." }, { 0x2712, "US Army Benet Laboratories" }, @@ -8976,7 +8976,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2714, "i'm S.p.A." }, { 0x2715, "Photron Limited" }, { 0x2716, "YUEN DA ELECTRONIC PRODUCTS FACTORY" }, - { 0x2717, "Beijing Xiaomi Communications Co., Ltd." }, + { 0x2717, "Xiaomi Communications Co., Ltd." }, { 0x2718, "Tamaggo" }, { 0x2719, "4iiii Innovations Inc." }, { 0x271A, "KONE Industrial Ltd." }, @@ -8987,7 +8987,7 @@ VENDOR_ID USBVendorIDs[] = { 0x271F, "Shanghai Nufront Electronic Technology Co., Ltd." }, { 0x2720, "motrona GmbH" }, { 0x2721, "Germaneers GmbH" }, - { 0x2722, "FOOSUNG TECH" }, + { 0x2722, "TRANIT" }, { 0x2723, "KUK Electronic AG" }, { 0x2724, "XS Technology, Inc." }, { 0x2725, "L-3 Applied Signal & Image Technology" }, @@ -9137,7 +9137,7 @@ VENDOR_ID USBVendorIDs[] = { 0x27B6, "TechnoKom Ltd." }, { 0x27B7, "Fraunhofer IMS" }, { 0x27B8, "ThingM Corporation" }, - { 0x27B9, "Azend Group Corp." }, + { 0x27B9, "Ziotech Corp" }, { 0x27BA, "Aoptix Technologies, Inc." }, { 0x27BB, "Plenom A/S" }, { 0x27BC, "KeyView" }, @@ -9190,11 +9190,11 @@ VENDOR_ID USBVendorIDs[] = { 0x27EB, "ACCUCOMM, INC." }, { 0x27EC, "SEETECH CO., LTD." }, { 0x27ED, "Tescom-Emerson Process Management" }, - { 0x27EE, "Palmer Performance Engineering, Inc." }, + { 0x27EE, "DashLogic Inc." }, { 0x27EF, "TAIYO SEIKI CO., LTD." }, { 0x27F0, "DITECT Corporation" }, { 0x27F1, "VERTU Corporation Limited" }, - { 0x27F2, "Sibridge Tech." }, + { 0x27F2, "Softnautics Private Limited" }, { 0x27F3, "Indutherm Erwaermungsanlagen GmbH" }, { 0x27F4, "LEGIC Identsystems Ltd." }, { 0x27F5, "Relume Technologies, Inc." }, @@ -9259,7 +9259,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2830, "GD-Broadband" }, { 0x2831, "Power Integrations" }, { 0x2832, "Applied Research Associates" }, - { 0x2833, "Oculus VR, Inc." }, + { 0x2833, "Oculus VR LLC" }, { 0x2834, "JM Concept" }, { 0x2835, "SEIDENSHA ELECTRONICS Co., Ltd." }, { 0x2836, "OUYA Inc." }, @@ -9342,7 +9342,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2883, "abatec group AG" }, { 0x2884, "Bor" }, { 0x2885, "Quantec SA" }, - { 0x2886, "Seeed Technology Limited" }, + { 0x2886, "Seeed Technology Co., Ltd." }, { 0x2887, "Specwerkz" }, { 0x2888, "VEX Robotics, Inc." }, { 0x2889, "TrueVision Systems, Inc." }, @@ -9425,7 +9425,7 @@ VENDOR_ID USBVendorIDs[] = { 0x28D6, "Electrogamez USA Inc." }, { 0x28D7, "Tekron International" }, { 0x28D8, "Panda Ocean Inc." }, - { 0x28D9, "Shenzhen Ourconn Technology Co., Ltd." }, + { 0x28D9, "Shenzhen Yoshuo Precision Components Co., Ltd." }, { 0x28DA, "G.SKILL Int'l Enterprice Co., Ltd." }, { 0x28DB, "Konftel AB" }, { 0x28DC, "Power Electronics International, Inc." }, @@ -9442,7 +9442,7 @@ VENDOR_ID USBVendorIDs[] = { 0x28E7, "Glyph Production Technologies" }, { 0x28E8, "Jefferson Audio Video Systems, Inc." }, { 0x28E9, "GigaDevice Semiconductor (Beijing) Inc." }, - { 0x28EA, "Dongguan City Guangye Electronic Co., Ltd." }, + { 0x28EA, "Dongguan Vast Electronics Co.,Ltd" }, { 0x28EB, "SHEN ZHEN SHI YUAN AI HARDWARE ELECTRONIC CO., LTD." }, { 0x28EC, "Transcom Instruments Co., Ltd." }, { 0x28ED, "Shenzhen AraTek Biometrics Technology Co., Ltd." }, @@ -9539,7 +9539,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2948, "Access Network Technology Limited" }, { 0x2949, "Shenzhen JSR Technology Co., Ltd." }, { 0x294A, "Shenzhen Xinguodu Technology Co., Ltd." }, - { 0x294B, "snakebyte asia Ltd." }, + { 0x294B, "snakebyte Asia Ltd." }, { 0x294C, "Terminus Circuits Pvt Ltd." }, { 0x294D, "Cellwise Holding Co., Ltd." }, { 0x294E, "SHIH HUA TECHNOLOGY LTD." }, @@ -9563,7 +9563,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2960, "Power Probe, Inc." }, { 0x2961, "Miselu Inc." }, { 0x2962, "Wilocity Ltd." }, - { 0x2963, "FingerQ Macao Commercial Offshore Limited" }, + { 0x2963, "BIO-key International, Inc." }, { 0x2964, "Kintech Co., Ltd." }, { 0x2965, "Kortek" }, { 0x2966, "Schatz AG" }, @@ -9601,7 +9601,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2986, "Rapt Touch (Ireland) Ltd." }, { 0x2987, "Lyve Minds, Inc." }, { 0x2988, "3D Systems Corporation" }, - { 0x2989, "Nanjing Fujitsu Computer Products Co., Ltd." }, + { 0x2989, "Nanjing Fujitsu Electronics Information Technology Co., Ltd" }, { 0x298A, "Singeen Electronics Technologies (Dongguan) Co., Ltd." }, { 0x298B, "Hanil ProTech" }, { 0x298C, "GL Solutions Inc." }, @@ -9613,7 +9613,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2992, "Lantos Technologies, Inc." }, { 0x2993, "ADPlaus Technology Limited" }, { 0x2995, "Resodyn Corporation" }, - { 0x2996, "Unwired Technology" }, + { 0x2996, "Delphi Data Connectivity" }, { 0x2997, "Inogeni Inc." }, { 0x2998, "EOS S.r.l." }, { 0x2999, "Fourtec Technologies Ltd." }, @@ -9759,7 +9759,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2A25, "Fourstar Group" }, { 0x2A26, "Tragant International Co., Ltd." }, { 0x2A27, "DongGuan LianGang Optoelectronic Technology Co., Ltd." }, - { 0x2A28, "The Hig, LLC" }, + { 0x2A28, "Higbie, LLC dba kinetuex" }, { 0x2A29, "PayPal, Inc." }, { 0x2A2A, "TARGAMITE LLC" }, { 0x2A2B, "NooElec Inc." }, @@ -9804,7 +9804,6 @@ VENDOR_ID USBVendorIDs[] = { 0x2A52, "L CARD Ltd." }, { 0x2A53, "x-odos GmbH" }, { 0x2A54, "Black Diamond Advanced Technology, LLC" }, - { 0x2A55, "Diodes Inc." }, { 0x2A56, "eemagine Medical Imaging Solutions GmbH" }, { 0x2A57, "Bellingham + Stanley Limited" }, { 0x2A58, "ALIGN Corporation Limited" }, @@ -9813,7 +9812,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2A5B, "Integrity Applications Ltd." }, { 0x2A5C, "Dalian Zonewin Electronics Co., Ltd." }, { 0x2A5D, "Zhejiang Wanli Jo Ju Automation Technonolgy Co., Ltd." }, - { 0x2A5E, "DuPont" }, + { 0x2A5E, "The Chemours Company" }, { 0x2A5F, "Tencent Technology (Shenzhen) Company Limited" }, { 0x2A60, "Oscadi SAS" }, { 0x2A61, "Ellex Medical Pty Ltd." }, @@ -9852,7 +9851,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2A82, "Printek, Inc." }, { 0x2A83, "Autodesk Inc." }, { 0x2A84, "ATE Systems" }, - { 0x2A85, "Hank Electronics Ltd." }, + { 0x2A85, "HANK ELECTRONICS CO., LTD" }, { 0x2A86, "KITRIS AG" }, { 0x2A87, "Kummler + Matter AG" }, { 0x2A88, "DFU Technology Ltd." }, @@ -9882,7 +9881,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2AA0, "Casco Products Corp." }, { 0x2AA1, "Ivanhoe (DE), Inc." }, { 0x2AA2, "GTI Spindle Technology, Inc." }, - { 0x2AA3, "Altron" }, + { 0x2AA3, "Strike Technologies a Division of Penbro Kelnick (Pty) Ltd" }, { 0x2AA4, "Voim Technologies Inc." }, { 0x2AA5, "Pen Generations, Inc." }, { 0x2AA6, "ChengFong International Limited" }, @@ -9949,7 +9948,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2AE3, "Jiuzhou Digital (Hong Kong) Limited" }, { 0x2AE4, "Next! s.c. Slawomir Piela, Bartlomiej Dryja" }, { 0x2AE5, "Fairphone B.V." }, - { 0x2AE6, "Enel Distribuzione" }, + { 0x2AE6, "e-distribuzione Spa" }, { 0x2AE7, "Advanced Media, Inc." }, { 0x2AE8, "Quintic Microelectronics (Wuxi) Co., Ltd." }, { 0x2AE9, "Regal Beloit Canada ULC. dba Thomson Power Systems" }, @@ -10131,7 +10130,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2B99, "360fly, Inc." }, { 0x2B9A, "HUIZHOU CHENG SHUO HARDWARE PLASTIC CO., LTD." }, { 0x2B9B, "Zhongshan Aute Electronics Technology Co., Ltd." }, - { 0x2B9C, "Guangdong King Link Industry Co., Ltd." }, + { 0x2B9C, "Guangdong King Link Industrial Co., Ltd." }, { 0x2B9D, "HARTING Electric GmbH & Co. KG" }, { 0x2B9E, "ZPower LLC" }, { 0x2B9F, "Scietera Technologies, Inc." }, @@ -10148,7 +10147,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2BAA, "New World Technologies Inc." }, { 0x2BAB, "Grandstream Networks, Inc." }, { 0x2BAC, "Polyera Corporation" }, - { 0x2BAD, "XIN JI (SHENZHEN) COMPUTER PARTS CO., LTD." }, + { 0x2BAD, "XinJi Technologies Ltd." }, { 0x2BAE, "Holinail H.K. Limited" }, { 0x2BAF, "Getac Technology Corp." }, { 0x2BB0, "ITES Co., Ltd." }, @@ -10162,7 +10161,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2BB8, "OCC (Zhuhai) Electronic Co., Ltd." }, { 0x2BB9, "ARGUS-SPECTRUM" }, { 0x2BBA, "Sinseader Electronic Co., Ltd." }, - { 0x2BBB, "DONGGUAN YELLOWKNIFE Industrial Co., Ltd." }, + { 0x2BBB, "DONGGUAN YELLOW KNIFE Industrial Co., Ltd." }, { 0x2BBC, "Guided Ultrasonics Ltd" }, { 0x2BBD, "RF Creations Ltd." }, { 0x2BBE, "Chengyi Semiconductors (Shanghai) Co., Ltd." }, @@ -10192,14 +10191,14 @@ VENDOR_ID USBVendorIDs[] = { 0x2BD6, "CoroWare, Inc." }, { 0x2BD7, "EcuTek International Ltd." }, { 0x2BD8, "ROPEX Industrie-Elektronik GmbH" }, - { 0x2BD9, "Kubicam" }, + { 0x2BD9, "Huddly" }, { 0x2BDA, "Panono GmbH" }, { 0x2BDB, "LOVEOX CO., LTD." }, { 0x2BDC, "Automation Electronics Inc." }, { 0x2BDD, "Charm Sciences Inc." }, { 0x2BDE, "Pickering Interfaces Limited" }, { 0x2BDF, "Hangzhou Hikvision Digital Technology Co., Ltd." }, - { 0x2BE0, "FULLINK ELECTRONICS TECHNOLOGY (SZ) LTD" }, + { 0x2BE0, "Fullink Technology Co., Ltd" }, { 0x2BE1, "AutoChips Inc." }, { 0x2BE2, "Electric Connector Technology Co., Ltd." }, { 0x2BE3, "Hydac Electronic GmbH" }, @@ -10271,7 +10270,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2C25, "Shanghai TAIDU INTELLIGENT TECHNOLOGY CO., LTD." }, { 0x2C26, "Micromax International Corporation" }, { 0x2C27, "YAWATA Electric Industrial Co., Ltd." }, - { 0x2C28, "XXCAL JAPAN Inc." }, + { 0x2C28, "Granite River Labs Japan Ltd." }, { 0x2C29, "Coagent Enterprise Limited" }, { 0x2C2A, "LEIA Inc." }, { 0x2C2B, "NetScout Systems, Inc." }, @@ -10284,7 +10283,7 @@ VENDOR_ID USBVendorIDs[] = { 0x2C32, "MCS Micronic Computer Systeme GmbH" }, { 0x2C33, "Shinobiya.com Co., Ltd." }, { 0x2C34, "Xerox Business Services (Switzerland) AG" }, - { 0x2C35, "Decto LLC" }, + { 0x2C35, "Decto, Inc." }, { 0x2C36, "Bonsai Lab, Inc." }, { 0x2C37, "Shenzhen Adition Audio Science & Technology Co., Ltd." }, { 0x2C38, "Goldenconn Electronics Technology (Suzhou) Co., Ltd." }, @@ -10322,6 +10321,662 @@ VENDOR_ID USBVendorIDs[] = { 0x2C58, "Dyden Corporation" }, { 0x2C59, "EBARA CORPORATION" }, { 0x2C5A, "Mobilus Automotive Inc" }, + { 0x2C5B, "Shenglan Technology Co. Ltd" }, + { 0x2C5C, "Neusoft Corporation" }, + { 0x2C5D, "SIP Simya Electronics Technology Co., Ltd." }, + { 0x2C5E, "ELVES Automotive Co., Ltd" }, + { 0x2C5F, "YOODS Co., Ltd." }, + { 0x2C60, "Sirin LABS AG" }, + { 0x2C61, "Jadmam Corporation dba: Boytone" }, + { 0x2C62, "Trice Medical" }, + { 0x2C63, "Electronica Steren, S.A. de C.V." }, + { 0x2C64, "Creaform Inc. (Ametek Ultra Precision Technologies)" }, + { 0x2C65, "Nokia Technologies" }, + { 0x2C66, "EMOTIQ srl" }, + { 0x2C67, "VentureCraft, Ltd." }, + { 0x2C68, "EMRight Technology Co., Ltd." }, + { 0x2C69, "BBPOS Limited" }, + { 0x2C6A, "Joint Stock Company Research Centre Module" }, + { 0x2C6B, "System JD Co., Ltd" }, + { 0x2C6C, "Nano TouchSystems co., Ltd." }, + { 0x2C6D, "Gibson Innovations" }, + { 0x2C6E, "Shen Zhen Xian Shuo Technology Co. Ltd." }, + { 0x2C6F, "PST Eletronica LTDA" }, + { 0x2C70, "PERI, Inc." }, + { 0x2C71, "Bozhou BoTong Information Technology Co., Ltd." }, + { 0x2C72, "BlueberryE GmbH" }, + { 0x2C73, "Qiku Internet Network Scientific (Shenzhen) Co., Ltd." }, + { 0x2C74, "CJSC Nordavind" }, + { 0x2C75, "Net And Print Inc." }, + { 0x2C76, "DATAPATH LTD" }, + { 0x2C77, "Profindustry GmbH" }, + { 0x2C78, "BRAGI GmbH" }, + { 0x2C79, "WAWGD, Inc. (DBA: Foresight Sports)" }, + { 0x2C7A, "AutoNavi Software Co., Ltd." }, + { 0x2C7B, "Beijing ASU Tech Co., Ltd." }, + { 0x2C7C, "Anysmart Technologies Co., Ltd." }, + { 0x2C7D, "Shenzhen Protruly Electronic Co., Ltd." }, + { 0x2C7E, "Dongguan Allpass Electronic Co., Ltd." }, + { 0x2C7F, "SHENZHEN D-VITEC INDUSTRIAL CO., LTD." }, + { 0x2C80, "motomobile AG" }, + { 0x2C81, "Indie Semiconductor" }, + { 0x2C82, "Cloud9 Technologies LLC" }, + { 0x2C83, "LRP electronic GmbH" }, + { 0x2C84, "Innodezign MauRitius Limited" }, + { 0x2C85, "Audientes" }, + { 0x2C86, "Ultraflux" }, + { 0x2C87, "ISKN" }, + { 0x2C88, "K-Tronic SRL" }, + { 0x2C89, "Younes Medical Technologies" }, + { 0x2C8A, "Advanced Casino Electronics" }, + { 0x2C8B, "Huizhou Dehong Technology Co., Ltd." }, + { 0x2C8C, "PowerCenter Technology Limited" }, + { 0x2C8D, "Mizco International, Inc." }, + { 0x2C8E, "Unique Secure Limited" }, + { 0x2C8F, "Regulus Company Ltd." }, + { 0x2C90, "I. AM. PLUS, LLC" }, + { 0x2C91, "Corigine, Inc." }, + { 0x2C92, "Ningbo Yinzhou Shengke Electronics Co., Ltd." }, + { 0x2C93, "SWFL Inc. dba: Filament" }, + { 0x2C94, "HIRATSUKA Engineering Co., Ltd." }, + { 0x2C95, "TOSHIBA MACHINE CO., LTD." }, + { 0x2C96, "KBS Industrieelektronik GmbH" }, + { 0x2C97, "LEDGER" }, + { 0x2C98, "Fosfomatic Technology LLC" }, + { 0x2C99, "Prusa Research s.r.o." }, + { 0x2C9A, "Lawo AG" }, + { 0x2C9B, "SPECIM, Spectral Imaging Ltd." }, + { 0x2C9C, "Vayyar Imaging LTD." }, + { 0x2C9D, "Nod Inc." }, + { 0x2C9E, "Shanghai Linguo Technology Co.,Ltd." }, + { 0x2C9F, "e-Smart Systems Pvt. Ltd." }, + { 0x2CA0, "Leagtech Jiangxi Electronic Co., Ltd." }, + { 0x2CA1, "Veetone Technologies Limited" }, + { 0x2CA2, "GuangZhou MingPing Electronics Technology" }, + { 0x2CA3, "DJI Technology Co., Ltd." }, + { 0x2CA4, "Shenzhen Alex Technology Co., Ltd." }, + { 0x2CA5, "Fussen Technology Co., Ltd." }, + { 0x2CA6, "Dai-ichi Dentsu Ltd." }, + { 0x2CA7, "Heptagon Advanced Micro Optics" }, + { 0x2CA8, "STATSports" }, + { 0x2CA9, "JITS TECHNOLOGY CO., LIMITED" }, + { 0x2CAA, "LIVV Brand llc" }, + { 0x2CAB, "AppWorld S. de R.L. de C.V." }, + { 0x2CAC, "MGF Sviesos Konversija, UAB" }, + { 0x2CAD, "EMS Security Group Ltd." }, + { 0x2CAE, "Clyde Broadcast Products Ltd." }, + { 0x2CAF, "IDS GmbH" }, + { 0x2CB0, "Creative bits Solutions" }, + { 0x2CB1, "Avista Corporation" }, + { 0x2CB2, "NAGANO KEIKI CO., LTD." }, + { 0x2CB3, "Shenzhen Bolin Image Science Technology Co., Ltd." }, + { 0x2CB4, "Ava Enterprises, Inc. dba Boss Audio Systems" }, + { 0x2CB5, "SUS Corp." }, + { 0x2CB6, "Borqs Hong Kong Limited" }, + { 0x2CB7, "Fibocom Wireless Inc." }, + { 0x2CB8, "Shenzhen Sydixon Electronic Technology Co., Ltd." }, + { 0x2CB9, "On-Bright Electronics (Shanghai) Co., Ltd." }, + { 0x2CBA, "Dongguan Puxu Industrial Co., Ltd." }, + { 0x2CBB, "Shenzhen Soling Indusrtial Co., Ltd." }, + { 0x2CBD, "EGGCYTE, INC." }, + { 0x2CBE, "uQontrol" }, + { 0x2CBF, "Donggguan Yuhua Electronic Co., Ltd." }, + { 0x2CC0, "Hangzhou Zero Zero Technology Co., Ltd." }, + { 0x2CC1, "SIGFOX" }, + { 0x2CC2, "Lautsprecher Teufel GmbH" }, + { 0x2CC3, "A-VEKT K.K." }, + { 0x2CC4, "Sanden Advanced Technology Corporation" }, + { 0x2CC5, "Metatronics" }, + { 0x2CC6, "Prodigy Technovations Pvt Ltd" }, + { 0x2CC7, "EmergiTech, Inc" }, + { 0x2CC8, "Hewlett Packard Enterprise" }, + { 0x2CC9, "Monolithic Power Systems Inc." }, + { 0x2CCA, "Amphenol Advanced Sensors" }, + { 0x2CCB, "USB Memory Direct" }, + { 0x2CCC, "Silicon Mitus Inc." }, + { 0x2CCD, "ITOS Inc." }, + { 0x2CCE, "SMARTY Performance King SA" }, + { 0x2CCF, "Hypersecu Information Systems, Inc." }, + { 0x2CD0, "Technics Global Electronics & JCE Co., Ltd." }, + { 0x2CD1, "Tamron Co., Ltd." }, + { 0x2CD2, "Mikrotikls S/A" }, + { 0x2CD3, "Life Robotics Inc." }, + { 0x2CD4, "NGK SPARK PLUG CO., LTD." }, + { 0x2CD5, "Institut Dr. Foerster GmbH & Co. KG" }, + { 0x2CD6, "Immersive Media" }, + { 0x2CD7, "Cosemi Technologies Inc." }, + { 0x2CD8, "Nanoport Technology, Inc." }, + { 0x2CD9, "Cambrionix Ltd" }, + { 0x2CDA, "CXUN Co. Ltd." }, + { 0x2CDB, "China Tsp Inc" }, + { 0x2CDC, "Sea & Sun Technology GmbH" }, + { 0x2CDD, "IAI Corporation" }, + { 0x2CDE, "RTI International" }, + { 0x2CDF, "Tecno Alarm S.R.L." }, + { 0x2CE0, "iClassmate Educational Technologies Co., Ltd." }, + { 0x2CE1, "Gradus Group" }, + { 0x2CE2, "Yanfeng Visteon (Chongqing) Automotive Electronics Co" }, + { 0x2CE3, "Alcorlink Corp." }, + { 0x2CE4, "ISBC Ltd." }, + { 0x2CE5, "InX8 Inc dba AKiTiO" }, + { 0x2CE6, "SDAN Tecchnology Co., Ltd." }, + { 0x2CE7, "Lemobile Information Technology (Beijing) Co., Ltd." }, + { 0x2CE8, "DongGuan Hongweixiang Electronic Technology Co., Ltd." }, + { 0x2CE9, "Suzhu Jingshi Electronic Technology Co., Ltd." }, + { 0x2CEA, "Zhong Shan City Richsound Electronic Industrial Ltd." }, + { 0x2CEB, "Dongguang Kangbang Electronics Co., Ltd." }, + { 0x2CEC, "Ascon Tecnologic" }, + { 0x2CED, "KMC Controls, Inc." }, + { 0x2CEE, "Winpower Qmadix Technology Co., Ltd." }, + { 0x2CEF, "Toptest Technologies Co., Ltd." }, + { 0x2CF0, "Nuand, LLC" }, + { 0x2CF1, "DTS, Inc." }, + { 0x2CF2, "KUNSHAN DLK Electronics Technology Co., Ltd." }, + { 0x2CF3, "Konekt, Inc." }, + { 0x2CF4, "CAM2 Technologies, LLC dba: Czitek" }, + { 0x2CF5, "EBARA REFRIGERATION EQUIPMENT & SYSTEMS CO., LTD." }, + { 0x2CF6, "Eye-Fi, Inc." }, + { 0x2CF7, "PPST, Inc." }, + { 0x2CF8, "Itron" }, + { 0x2CF9, "Terrafix Ltd." }, + { 0x2CFA, "Meta Company" }, + { 0x2CFB, "Nanchang Haozhun Electronics Co., Ltd." }, + { 0x2CFC, "DeLaval International AB" }, + { 0x2CFD, "GoerTek Inc." }, + { 0x2CFE, "Alpha Data Parallel Systems" }, + { 0x2CFF, "ITHAKi" }, + { 0x2D00, "VDO Cyclecomputing, Cycle Parts GmbH" }, + { 0x2D01, "Gopod Group Limited" }, + { 0x2D02, "Zhi Sheng Electronics Technology Co., Ltd." }, + { 0x2D03, "ECCO Safety Group" }, + { 0x2D05, "Technology Solutions (UK) Limited" }, + { 0x2D06, "Jireh Industries Ltd." }, + { 0x2D07, "MSI.TOKYO, Inc." }, + { 0x2D08, "ZIT Ltd." }, + { 0x2D09, "Dongguan Evervictory Electronic Co., Ltd." }, + { 0x2D0A, "Kingsignal Technology Co., Ltd." }, + { 0x2D0B, "IPD CO., LTD" }, + { 0x2D0C, "B & P Automation Dynamics Ltd" }, + { 0x2D0D, "Star Vision Electronics Limited" }, + { 0x2D0E, "Linxee (Beijing) Technology LTD." }, + { 0x2D0F, "M8TRIX TECH LLC" }, + { 0x2D10, "Shenzhen San Guan Si Yuan Technology Limited" }, + { 0x2D11, "Servelec Technologies" }, + { 0x2D12, "SICPA Security Solutions SA" }, + { 0x2D13, "DONG GUAN EBEN ELECTRONIC CO., LTD" }, + { 0x2D14, "Palit Microsystems Ltd" }, + { 0x2D15, "Si-Ware Systems" }, + { 0x2D16, "DONGGUAN WELLINK ELECTRONIC CO., LTD." }, + { 0x2D17, "TECHVIWIN INTERNATIONAL (HONGKONG) LIMITED" }, + { 0x2D18, "Hui Zhou Kai Yue Electronics Co., Ltd" }, + { 0x2D19, "Churchill Navigation" }, + { 0x2D1A, "Phononic" }, + { 0x2D1B, "Suzhou Yourfriend Electronic Co., Ltd." }, + { 0x2D1C, "Club 3D BV" }, + { 0x2D1D, "Design Pool Limited" }, + { 0x2D1E, "Excalibur" }, + { 0x2D1F, "Wacom Taiwan Information Co. Ltd." }, + { 0x2D20, "UL LLC" }, + { 0x2D21, "Koozyt, Inc." }, + { 0x2D22, "SEIKOSHA Co., Ltd." }, + { 0x2D23, "Shenzhen Microtest Automation Co., Ltd." }, + { 0x2D24, "Warwick Audio Technologies Ltd" }, + { 0x2D25, "Kronegger GmbH" }, + { 0x2D26, "Greenfield Technology" }, + { 0x2D27, "Global Optics Limited" }, + { 0x2D28, "Beijing ANTVR Technology Co., LTD" }, + { 0x2D29, "Beijing Baofengmojing Technologies Co. Ltd" }, + { 0x2D2A, "Shenzhen ZDT Technology Co., LTD" }, + { 0x2D2B, "STYL Solutions Pte Ltd" }, + { 0x2D2C, "Tankya Developing Co., Limited" }, + { 0x2D2D, "Guangzhou Botao Information Technology Co., Ltd" }, + { 0x2D2E, "Hieyoung International (Hong Kong) Limited" }, + { 0x2D2F, "PT Phototechnics AG" }, + { 0x2D30, "Addasound Denmark A/S" }, + { 0x2D31, "Synox Tech Co., Ltd." }, + { 0x2D32, "JR Technik Co., Ltd." }, + { 0x2D33, "Elysia-raytest GmbH" }, + { 0x2D34, "Nureva Inc." }, + { 0x2D35, "SIGMA TECH. CO., LTD" }, + { 0x2D36, "Blu5 View Pte. Ltd." }, + { 0x2D37, "Xprinter Co., Ltd" }, + { 0x2D38, "Shanghai OXi Technology Co., Ltd" }, + { 0x2D39, "Roofer Technology (Shenzhen) Co. Ltd" }, + { 0x2D3A, "Le Touch (Shenzhen) Electronics Co., Ltd." }, + { 0x2D3B, "Lencheng Electronics Co., Ltd" }, + { 0x2D3C, "FOVE, Inc." }, + { 0x2D3D, "Battlespace Simulations, Inc." }, + { 0x2D3E, "Technica Del Arte BV" }, + { 0x2D3F, "ViCentra B.V." }, + { 0x2D40, "Beijing Pico Technology Co., Ltd." }, + { 0x2D41, "Dongguan Mankind Plastic Electronics Co., Ltd" }, + { 0x2D42, "Protech Electronics & Technology Limited" }, + { 0x2D43, "OSSIC Corporation" }, + { 0x2D44, "FAMAR FUEGUINA S.A." }, + { 0x2D45, "JSC TION SMART MICROCLIMATE" }, + { 0x2D46, "JSC Yukon Advanced Optics Worldwide" }, + { 0x2D47, "INVENCO GROUP LIMITED" }, + { 0x2D48, "StarBridge, Inc." }, + { 0x2D49, "Shanghai Deepoon Technology Co., Ltd." }, + { 0x2D4A, "Helioway Enterprises Co., Ltd" }, + { 0x2D4B, "Dongguan Hongwei Electronics Co.,Ltd" }, + { 0x2D4C, "Ixtra Tech Inc" }, + { 0x2D4D, "Razer Inc" }, + { 0x2D4E, "Electronic Equipment BV" }, + { 0x2D4F, "Dongguan Hanker Electronic Technology Co., Ltd." }, + { 0x2D50, "CryLaS - Crystal Laser Systems GmbH" }, + { 0x2D51, "NITTA Corporation" }, + { 0x2D52, "YiQin Electronics Co.,Ltd" }, + { 0x2D53, "OWOW Products B.V." }, + { 0x2D54, "C-Smartlink Information Technology Co., Ltd." }, + { 0x2D55, "Nagravision SA" }, + { 0x2D56, "DongGuan Kelta Electro Mechanical Products CO, LTD" }, + { 0x2D58, "Lyra Semiconductor Incorporated" }, + { 0x2D59, "Sunyking Technology Co., Ltd" }, + { 0x2D5A, "Shenzhen YAAN Precision Connector Co., Ltd." }, + { 0x2D5B, "SunTo Technology (Shen Zhen) Corporation Limited" }, + { 0x2D5C, "Daiwoo Electronics Lo., LTD" }, + { 0x2D5D, "Loctek Ergonomic Technology Corp." }, + { 0x2D5E, "Sky UK Limited" }, + { 0x2D5F, "Shanghai Yuewen information technology Co., Ltd." }, + { 0x2D60, "Comarch S.A." }, + { 0x2D61, "Shenzhen Hongjixin Plastic & Electronics Co., Ltd" }, + { 0x2D62, "Weifang Genius Electronics Co.,Ltd." }, + { 0x2D63, "Cable Technology Corp." }, + { 0x2D64, "H.D.T. S.R.L" }, + { 0x2D65, "DPA Microphones" }, + { 0x2D66, "Oley Company Limited" }, + { 0x2D67, "Fengfan (Suzhou) Audio Technology Co., Ltd." }, + { 0x2D68, "Lumulabs d.o.o." }, + { 0x2D6A, "AIPHONE Co., LTD" }, + { 0x2D6B, "NetUP Inc." }, + { 0x2D6C, "Sphericam Inc." }, + { 0x2D6D, "Shenzhen HaiWei Technology Co., LTD" }, + { 0x2D6E, "Jiangsu Jing Lian Electronic Technology Co., Ltd" }, + { 0x2D6F, "Tobii Dynavox" }, + { 0x2D70, "Zhongshan Winner Electronic Technology CO., LTD" }, + { 0x2D71, "OVERKIZ" }, + { 0x2D72, "DOGAWIST - Investment GmbH" }, + { 0x2D73, "XtremeMac Sarl" }, + { 0x2D74, "CMO America; dba ZipKord Solutions" }, + { 0x2D75, "Shenzhen Taiji Electronics Co., Ltd." }, + { 0x2D76, "SiliConch Systems Private Limited" }, + { 0x2D77, "SweDeltaco AB" }, + { 0x2D78, "Dental Imaging Technology Corporation" }, + { 0x2D79, "Shenzhen Legendary Technologies Co., LTD." }, + { 0x2D7A, "Dongguan JingFeng Electronics Technology Co., Ltd" }, + { 0x2D7B, "Panasonic Lighting Americas, Inc." }, + { 0x2D7C, "Dongguan City Qingda Electronic Co., Ltd." }, + { 0x2D7D, "Televes S.A." }, + { 0x2D7E, "NISSIN ELECTRIC Corporation" }, + { 0x2D7F, "Sinar Photography AG" }, + { 0x2D80, "Pendo Technology China Corporation" }, + { 0x2D81, "Evollve Inc." }, + { 0x2D82, "boud" }, + { 0x2D84, "Zhuhai J-Speed Technology Co., Ltd." }, + { 0x2D85, "Asahi Electronics Laboratory" }, + { 0x2D86, "Dongguan Team Force Electronic Co., Ltd" }, + { 0x2D87, "Zhuhai Spark Electronic Equipment Co., Ltd" }, + { 0x2D88, "Prinics Co., Ltd." }, + { 0x2D89, "Ekahau" }, + { 0x2D8A, "I-O Conn (GuangDong) Technologies Co., Ltd" }, + { 0x2D8B, "Eclatkey Semiconductor Technology Company Limited" }, + { 0x2D8C, "Hongrida Electronic Technology Co. LTD" }, + { 0x2D8D, "MISUMI Corporation" }, + { 0x2D8E, "Color Sentinel Systems, LLC" }, + { 0x2D8F, "Shenzhen Bing Chuang Wei Technology Co., Ltd." }, + { 0x2D90, "Humanplus" }, + { 0x2D91, "SDI Technologies Inc." }, + { 0x2D92, "Shanghai Fengtian Electronic Co., LTD." }, + { 0x2D93, "STK TECHNOLOGY CO., LTD." }, + { 0x2D94, "TokenWorks Inc." }, + { 0x2D95, "Vivo Mobile Communication Co., Ltd." }, + { 0x2D96, "SHENZHEN WAMAXLINK ELECTRONIC TECHNOLOGY CO., LTD" }, + { 0x2D97, "Dong Guan JingHe Electronics Technology Co., Ltd" }, + { 0x2D98, "Shenzhen Ruiming Technology Co., Ltd." }, + { 0x2D99, "Edifier International Limited" }, + { 0x2D9A, "Jiangsu GuoGuang Electronic Information Technology Co.," }, + { 0x2D9B, "iStorage Limited" }, + { 0x2D9C, "Global Connector Technology" }, + { 0x2D9D, "Dongguan Suntes Electronics Technology Co., Ltd." }, + { 0x2D9E, "Sivantos GmbH" }, + { 0x2D9F, "SABRENT" }, + { 0x2DA0, "IN-VISION Digital Imaging Optics GmbH" }, + { 0x2DA1, "Koden Electronics Co., Ltd" }, + { 0x2DA2, "CIMA SPA con socio unico" }, + { 0x2DA3, "Superior Communications" }, + { 0x2DA4, "GE Multilin" }, + { 0x2DA5, "Tokai Rika Create Corporation" }, + { 0x2DA6, "SiChuan Rui Thai Electronic Technology Co., Ltd." }, + { 0x2DA7, "Topland Corporation" }, + { 0x2DA8, "Harmonic Drive Systems Inc." }, + { 0x2DA9, "ELECTRONIC ASSEMBLY GmbH" }, + { 0x2DAA, "Shenzhen Jing Tuo Jin Electronics Co., Ltd." }, + { 0x2DAB, "CYD Electronics (Shenzhen) Co., Ltd." }, + { 0x2DAC, "Shenzhen YZB Electronics Technology Co., Ltd" }, + { 0x2DAD, "GoerTek Dynaudio Co., Ltd" }, + { 0x2DAE, "Hex Technology Limited" }, + { 0x2DAF, "IF Link Electronics Co Limited" }, + { 0x2DB0, "Shenzhen Welltech Cable Co., Ltd" }, + { 0x2DB1, "DongGuan Greatek Electronics Technology Co., LTD" }, + { 0x2DB2, "Imperx, Inc" }, + { 0x2DB3, "i Digital Galaxy Ltd." }, + { 0x2DB4, "Dongguan Changtuo Hardware Technology Co., Ltd." }, + { 0x2DB5, "Fuji Ceramics Corporation" }, + { 0x2DB6, "Kunshan 3e Electronics Co., Ltd." }, + { 0x2DB7, "Premium Sound Solutions Sdn. Bhd." }, + { 0x2DB8, "Foshan Yami Electric Ltd." }, + { 0x2DB9, "Danelec Marine A/S" }, + { 0x2DBA, "Houwa System Design, k.k" }, + { 0x2DBB, "Huajie IMI Technology Co., Ltd." }, + { 0x2DBC, "Mikroelektronika d.o.o" }, + { 0x2DBD, "Shanghai Xiaoyi Technology Co., Ltd" }, + { 0x2DBE, "MA Lighting Technology GmbH" }, + { 0x2DBF, "Tul Corporation" }, + { 0x2DC0, "Chipsea Technologies (Shenzhen) Corp" }, + { 0x2DC1, "littleBits" }, + { 0x2DC2, "MintWave Co., Ltd." }, + { 0x2DC3, "Action Industries (M) SDN BHD" }, + { 0x2DC4, "Six 15 Technologies" }, + { 0x2DC5, "Cytek Biosciences, Inc." }, + { 0x2DC6, "Dongguan Kingtron Electronics Technology Co., Ltd." }, + { 0x2DC7, "Lacroix Sofrel" }, + { 0x2DC8, "8BITDO TECHNOLOGY HK LIMITED" }, + { 0x2DC9, "3T B.V." }, + { 0x2DCA, "OEM Systems Co., Ltd." }, + { 0x2DCB, "i-Money Technology Co., Ltd." }, + { 0x2DCC, "Suzhou Keda Technology Co., Ltd." }, + { 0x2DCD, "Yeonho Electronics" }, + { 0x2DCE, "Shen Zhen Farmer Technology Co., Limited" }, + { 0x2DCF, "Dialog Semiconductor (UK) Ltd" }, + { 0x2DD0, "iBaby Labs, Inc" }, + { 0x2DD1, "Empathy Co., Ltd." }, + { 0x2DD2, "HARNICS Co., LTD." }, + { 0x2DD3, "Viscell, LLC" }, + { 0x2DD5, "Gingy Technology Inc." }, + { 0x2DD6, "Suzhou SuperMax Smart System Co., Ltd." }, + { 0x2DD7, "enRoute Co., Ltd." }, + { 0x2DD8, "Perception Sensors and Instrumentation Ltd" }, + { 0x2DD9, "Dong Guan Fei Tai Electronics CO., LTD." }, + { 0x2DDA, "Miura Systems Ltd" }, + { 0x2DDB, "Shenzhen DAK Technology Co., Ltd" }, + { 0x2DDC, "Audiolink Co., Ltd" }, + { 0x2DDD, "Princeton Infrared Technologies, Inc." }, + { 0x2DDE, "The Chamberlain Group, Inc." }, + { 0x2DDF, "BOMTECH ELECTRONICS CO., LTD." }, + { 0x2DE0, "Active-semi, Inc" }, + { 0x2DE1, "Jiang Su Denseting Precision Technology Co., Ltd." }, + { 0x2DE2, "PathPartner Technology Pvt. Ltd" }, + { 0x2DE3, "Shanghai Yitu Technology Co., Ltd." }, + { 0x2DE4, "Best Case and Accessories, Inc." }, + { 0x2DE5, "KaiJet Technology International Limited, Inc. dba j5create" }, + { 0x2DE6, "Amazon Fulfillment Services, Inc." }, + { 0x2DE7, "The LightCo, Inc." }, + { 0x2DE8, "Shenzhen City Xiaoduan Electrical Co., LTD." }, + { 0x2DE9, "CAR MATE MFG. CO., LTD." }, + { 0x2DEA, "LightFactor" }, + { 0x2DEB, "Hold-Key Electric Wire & Cable Co Ltd" }, + { 0x2DEC, "ZNi Technology Co., Ltd" }, + { 0x2DED, "Aquil Star Precision Industrial (Shenzhen) Co., Ltd" }, + { 0x2DEE, "Shenzhen MeiG Smart Technology Co., Ltd" }, + { 0x2DEF, "Kirale Technologies SL" }, + { 0x2DF0, "CANVASBIO CO., LTD" }, + { 0x2DF1, "Inovonics Corp" }, + { 0x2DF2, "LIPS Corporation" }, + { 0x2DF3, "LongSung Technology (Shanghai) Co., Ltd." }, + { 0x2DF4, "Jumplux Technology Co., Ltd." }, + { 0x2DF5, "Helium Systems Inc." }, + { 0x2DF6, "Greektown Casino-Hotel, LLC" }, + { 0x2DF7, "Fastwel Group Ltd." }, + { 0x2DF8, "ITEST" }, + { 0x2DF9, "EZQuest, Inc." }, + { 0x2DFA, "3DRUDDER" }, + { 0x2DFB, "Bren-Tronics, Inc." }, + { 0x2DFC, "Graphic Products" }, + { 0x2DFD, "Ubisoft Entertainment SA" }, + { 0x2DFE, "Next Thing Co." }, + { 0x2DFF, "Unicept GmbH" }, + { 0x2E00, "CIB Security Inc" }, + { 0x2E01, "Symetrix, Inc." }, + { 0x2E02, "Softiron" }, + { 0x2E03, "Zhejiang Dahua Technology Co., Ltd." }, + { 0x2E04, "HMD Global Oy" }, + { 0x2E05, "CKD Corporation" }, + { 0x2E06, "Shenzhen Junlan Electronic Ltd" }, + { 0x2E07, "Lafayette Instrument Company" }, + { 0x2E08, "Zhongshan Dumei Weite Electronics Co., Ltd" }, + { 0x2E09, "Beijing LLVision Technology Co. LTD" }, + { 0x2E0A, "Dytran Instruments" }, + { 0x2E0B, "Datafield Industries (HK) Ltd" }, + { 0x2E0C, "Shenzhen Mek Intellisys PTE Ltd" }, + { 0x2E0D, "Suzhou FanglinTechnology Co., Ltd" }, + { 0x2E0E, "Hatteland Display AS" }, + { 0x2E0F, "Institute for Defense Analyses / Center for Computing Sciences" }, + { 0x2E10, "LinkMTech Inc." }, + { 0x2E11, "ShenZhen ShenTai WeiXiang Electronics Co., Ltd" }, + { 0x2E12, "Hongkong Chenyang Electronic Co., Limited" }, + { 0x2E13, "Intelligent Automation (Zhuhai) Co., Ltd" }, + { 0x2E14, "Expressive" }, + { 0x2E15, "Now Technologies" }, + { 0x2E16, "Glosys Inc." }, + { 0x2E17, "Essential Products, Inc." }, + { 0x2E18, "NorthStar Battery Company, LLC" }, + { 0x2E19, "Additel Corporation" }, + { 0x2E1A, "Shenzhen Arashi Vision Company Limited" }, + { 0x2E1B, "BeiJie Electronics Technology Co., Ltd" }, + { 0x2E1C, "Shenzhen Auto-Link World Information Technology Co., Ltd." }, + { 0x2E1D, "Clarion (Malaysia) Sdn. Bhd." }, + { 0x2E1E, "Sound Technology (C.Q.) Co., Ltd" }, + { 0x2E1F, "BrainScope Company, Inc." }, + { 0x2E20, "Guangzhou Long Do Co.,Ltd" }, + { 0x2E21, "DOSCH&AMAND Research GmbH&CoKG" }, + { 0x2E22, "DongGuan LinSong precision electronics CO., LTD" }, + { 0x2E23, "Shenzhen Baojia Battery Technology Co., Ltd." }, + { 0x2E24, "Hyperkin Inc." }, + { 0x2E25, "Gold Cable (Zhongshan) Electronic Co., Ltd." }, + { 0x2E26, "Monoprice, Inc." }, + { 0x2E27, "Lion Semiconductor" }, + { 0x2E28, "VOLTRONIC POWER TECHNOLOGY CORP." }, + { 0x2E29, "Clas Ohlson AB" }, + { 0x2E2B, "Shenzhen Qinps Technology Co Limited" }, + { 0x2E2C, "Dashine Electronics Co, Ltd" }, + { 0x2E2D, "Anaren Inc." }, + { 0x2E2E, "First Design System Inc." }, + { 0x2E2F, "Gulden Ophthalmics, Inc." }, + { 0x2E30, "Andon Health Co., Ltd." }, + { 0x2E31, "Thine Electronics, Inc." }, + { 0x2E32, "Shenzhen Red Star Electronics Co., Ltd." }, + { 0x2E33, "Squarehead Technology" }, + { 0x2E34, "ALLDATA LLC" }, + { 0x2E35, "Shenzhen PYS Industrial Co., LTD" }, + { 0x2E36, "Depo Electronics Limited" }, + { 0x2E37, "IRISO ELECTRONICS CO., LTD" }, + { 0x2E38, "OHM ELECTRONIC INC." }, + { 0x2E39, "Epic Tech, LLC" }, + { 0x2E3A, "Nanaboshi Electric Mfg. Co., Ltd." }, + { 0x2E3B, "uSens Inc" }, + { 0x2E3C, "ARTERY Technology Co., Ltd." }, + { 0x2E3D, "ASWAN ELEC. SALES CO., LTD." }, + { 0x2E3E, "Karma Automotive" }, + { 0x2E3F, "Poly-Planar Group LLC" }, + { 0x2E40, "Mobile Technologies Inc" }, + { 0x2E41, "DONGGUAN RONGDEKANG ELECTRONIC TECHNOLOGY CO., LTD." }, + { 0x2E42, "Hunan Ronghe Microelectronics Co., Ltd." }, + { 0x2E43, "Owl Labs, Inc" }, + { 0x2E44, "Idealens Technology (Chengdu) Co., Ltd." }, + { 0x2E45, "Widex A/S" }, + { 0x2E46, "Mobileconn Technology Co., Ltd." }, + { 0x2E47, "X-Media Tech, Inc." }, + { 0x2E48, "Andromium Inc." }, + { 0x2E49, "A&T Corporation" }, + { 0x2E4A, "Xiamen Jinhaode Electronic Co., Ltd" }, + { 0x2E4B, "ART SPA" }, + { 0x2E4C, "Carter Duncan Corp." }, + { 0x2E4D, "Vinpower, Inc." }, + { 0x2E4E, "METER Group, Inc" }, + { 0x2E4F, "Audiotec Fischer GmbH" }, + { 0x2E50, "beyerdynamic GmbH & Co. KG" }, + { 0x2E51, "EVER Sp. Z.o.o." }, + { 0x2E52, "Toughbuilt Industries Inc" }, + { 0x2E53, "Shenzhen East-Toptech Electronic Technology Co., Ltd" }, + { 0x2E54, "Yin Run Precise Metal Products CO., LTD." }, + { 0x2E55, "FIP Formatura Iniezione Polimeri an Aliaxis Company" }, + { 0x2E56, "Juchin Technology (JIANGXI) Co., Ltd" }, + { 0x2E57, "MEGWARE Computer Vertrieb und Service GmbH" }, + { 0x2E58, "GONGNIU GROUP CO., LTD." }, + { 0x2E59, "Maui Imaging, Inc." }, + { 0x2E5A, "Mysher Technology Co., Ltd." }, + { 0x2E5B, "Fitipower Integrated Technology Inc." }, + { 0x2E5C, "Y.H.S. Co., Ltd" }, + { 0x2E5D, "Dong Guan LM-Link Precise Electronic Co., Ltd." }, + { 0x2E5E, "Mei Shun He Electronic Limited" }, + { 0x2E5F, "Shenzhen BTC Technology Co., Ltd." }, + { 0x2E60, "castAR, Inc." }, + { 0x2E61, "NetBurner, Inc." }, + { 0x2E62, "Will Semiconductor Co., LTD" }, + { 0x2E63, "Polaris-Labs Shenzhen Co., Ltd" }, + { 0x2E64, "Shenzhen Kaibao Technology Co., Ltd." }, + { 0x2E65, "Kunshan Xintaili Precision Components Co., Ltd." }, + { 0x2E66, "SALICRU, S.A." }, + { 0x2E67, "Elevation Lab, Inc." }, + { 0x2E68, "Tessonics Inc." }, + { 0x2E69, "Swift Navigation Inc" }, + { 0x2E6A, "Wilderness Labs Inc." }, + { 0x2E6B, "DMX, LLC dba Mood Media" }, + { 0x2E6C, "Uwatec AG" }, + { 0x2E6D, "Laser Argentina S.A." }, + { 0x2E6E, "E4D Technologies LLC" }, + { 0x2E6F, "Areca Technology Corporation" }, + { 0x2E70, "Revision Electronics & Power Systems Inc." }, + { 0x2E71, "Futurepath Electronics Technology (Dongguan) Co., Ltd." }, + { 0x2E72, "DongGuan YongHao Electronics Co., LTD" }, + { 0x2E73, "Backyard Brains" }, + { 0x2E74, "Magenta Labs Inc." }, + { 0x2E75, "Shanghai Hinge Electronic Technologies Co., Ltd." }, + { 0x2E76, "Guangdong Jinrun Electronics Co., Ltd." }, + { 0x2E77, "LOGICDATA Electronics & Software Entwicklungs GmbH" }, + { 0x2E78, "ES Gear Ltd." }, + { 0x2E79, "NP System Development Co., Ltd." }, + { 0x2E7A, "Jiangsu BDSTAR Navigation Electronic Co., Ltd." }, + { 0x2E7B, "Terrada Music Score CO., Ltd." }, + { 0x2E7C, "Pyramid Solutions" }, + { 0x2E7D, "Shenzhen Xin Yong Yang Technology Co., Ltd." }, + { 0x2E7E, "ValueHD Corporation" }, + { 0x2E7F, "Aries Manufacturing - a division of Boss Tech Products Inc." }, + { 0x2E80, "Join Tek Corporation Co., Ltd." }, + { 0x2E81, "Zodiac Inflight Innovations" }, + { 0x2E82, "Sapphire Technology Limited" }, + { 0x2E83, "Ocean Tek Enterprise Co., Ltd." }, + { 0x2E84, "Sheng San Electronics (Shen Zhen) Co., Ltd." }, + { 0x2E85, "Verizon" }, + { 0x2E86, "SBO HEARING A/S" }, + { 0x2E87, "Shenzhen Injoinic Technology Co., Ltd." }, + { 0x2E88, "Huada Semiconductor Corporation Limited" }, + { 0x2E89, "Group Dekko, Inc." }, + { 0x2E8A, "Raspberry Pi (Trading) Limited" }, + { 0x2E8B, "Asia Optical International Ltd." }, + { 0x2E8C, "Aisino Wincor Manufacturing (Shanghai) Co., Ltd." }, + { 0x2E8D, "YSC Science Technique Electron (Yi Chun) Co., Ltd" }, + { 0x2E8E, "Bitatek CO., LTD" }, + { 0x2E8F, "Shenzhen Weiduli Technology Co., Ltd." }, + { 0x2E90, "Wireless Media Tech CO., Limited" }, + { 0x2E91, "Shenzhen Suprint Smart Technology Co., Ltd." }, + { 0x2E92, "bioMerieux, Inc." }, + { 0x2E93, "Shenzhen Huikeyuan Electronic Technology Co., Ltd." }, + { 0x2E94, "Graviton Inc." }, + { 0x2E95, "Scuf Gaming International, LLC" }, + { 0x2E96, "Aspect Microsystems Corp." }, + { 0x2E97, "Aerocool Advanced Technologies Corporation" }, + { 0x2E98, "Nekteck, Inc." }, + { 0x2E99, "Hynetek Semiconductor Co., Ltd" }, + { 0x2E9A, "MS Solutions Co., Ltd." }, + { 0x2E9B, "New Imaging Technologies" }, + { 0x2E9C, "Shenzhen Silkway Technology Co., Ltd." }, + { 0x2E9D, "Resolved Instruments Inc." }, + { 0x2E9E, "SoundAI Technology Co., Ltd." }, + { 0x2E9F, "EyeTech Digital Systems, Inc." }, + { 0x2EA0, "Magnescale Co., Ltd." }, + { 0x2EA1, "DASANELECTRON CO., LTD" }, + { 0x2EA2, "Ningbo Kangda Electronic Co., Ltd." }, + { 0x2EA3, "POSLAB Technology Corporation" }, + { 0x2EA4, "Hubbell Incorporated (Delaware), Wiring Device Kellems Division" }, + { 0x2EA5, "Dongguanshi Qitaiprecision Moulds Co., Ltd." }, + { 0x2EA6, "Foreign Trade Corporation dba. Technocel" }, + { 0x2EA7, "Muhanbit" }, + { 0x2EA8, "Changsha JingJia Microelectronics Co., LTD." }, + { 0x2EA9, "Yuneec International (China) Co., Ltd." }, + { 0x2EAA, "TSUME S.A." }, + { 0x2EAB, "Zong Cable Technology Co., Ltd." }, + { 0x2EAC, "Jia Yang Electronics (Dongguan) Co., Ltd." }, + { 0x2EAD, "Align Technology Inc." }, + { 0x2EAE, "Shenzhen TOMTOP Technology Co., Ltd." }, + { 0x2EAF, "microsonic co., ltd." }, + { 0x2EB0, "Commtech, Inc." }, + { 0x2EB1, "Samsung SmartThings" }, + { 0x2EB2, "Markus Klotz GmbH" }, + { 0x2EB3, "Shenzhen Tokwa Precision Technology Co., Ltd." }, + { 0x2EB4, "Beijer Automotive BV" }, + { 0x2EB5, "Dongguan HengYue Communication Technology Co., Ltd." }, + { 0x2EB6, "The Vehicle Group LTD" }, + { 0x2EB7, "Digital Divide Systems Ltd." }, + { 0x2EB8, "Yueqing Nuode Electronic Technology Co., Ltd." }, + { 0x2EB9, "SSI Computer Corp." }, + { 0x2EBA, "Shenzhen E&C Smart Link Technology Co., Ltd." }, + { 0x2EBB, "Shanghai Tuzheng Information Technology Co., Ltd." }, + { 0x2EBC, "RAIDON Technology Inc." }, + { 0x2EBD, "Netstor Technology Co., Ltd." }, + { 0x2EBE, "Delphi Automotive Systems, LLC" }, + { 0x2EBF, "Shenzhen D&D Technology Co., Ltd" }, + { 0x2EC0, "GuideTech" }, + { 0x2EC1, "Avid Identification Systems, Inc." }, + { 0x2EC2, "Loupedeck Oy" }, + { 0x2EC3, "Shenzhen Huntkey Electric Co., Ltd." }, + { 0x2EC4, "tetralux S.a.r.l." }, + { 0x2EC5, "Ariba Technology Co., LTD." }, + { 0x2EC6, "Facebook, Inc." }, + { 0x2EC7, "ITECH Electronic Co., Ltd." }, + { 0x2EC8, "Ningbo Prime Electronic Co., Ltd." }, + { 0x2EC9, "Shenzhou Rongan Technology (Beijing) Limited" }, + { 0x2ECA, "AQuantia Corp" }, + { 0x2ECB, "Zhejiang Quzhou Gelinte Wire and Cable Co., Ltd." }, + { 0x2ECC, "ASR Microelectronics (Shanghai) Co., Ltd." }, + { 0x2ECD, "EUROICC" }, + { 0x2ECE, "E-Lead Electronic Co., Ltd." }, + { 0x2ECF, "Fluo Technology Ltd." }, + { 0x2ED0, "Mind Alive Inc." }, + { 0x2ED1, "QBit Semiconductor LTD" }, + { 0x2ED2, "APOLLO GIKEN Co., Ltd." }, + { 0x2ED3, "Shenzhen Xinhongya Electronics Corporation" }, + { 0x2ED4, "Butterfly Network Inc." }, + { 0x2ED5, "QSAN Technology, Inc." }, + { 0x2ED6, "Shenzhen Xinliyang Co., Ltd." }, + { 0x2ED7, "Libratel Inc" }, + { 0x2ED8, "Dongguan Lontion Industrial Co., Ltd." }, + { 0x2ED9, "Microscopes International, LLC" }, + { 0x2EDA, "Wenzhou Haitong Communication Electronics Co., Ltd." }, + { 0x2EDB, "NeuroHabilitation Corporation" }, + { 0x2EDC, "Nippon Techno Lab., Inc." }, + { 0x2EDD, "reMarkable AS" }, + { 0x2EDE, "Technik Industrial Company Limited" }, + { 0x2EDF, "Huizhou Wealth Metal Micro Control Limited" }, + { 0x2EE0, "Pogotec Inc." }, + { 0x2EE1, "Safetrust Inc" }, + { 0x2EE2, "Kashimura Co., Ltd." }, + { 0x2EE3, "Kin Keung Electrical Mfg. Ltd." }, + { 0x2EE4, "Osprey Video, Inc." }, + { 0x2EE6, "NEURODIGITAL TECHNOLOGIES, S.L." }, + { 0x2EE7, "GOOGFIT TECH LIMITED" }, + { 0x2EE8, "Zunidata Systems, Inc." }, + { 0x2EE9, "Adigal LLC" }, + { 0x2EEA, "Loma Systems" }, + { 0x2EEB, "Jianduan Technology (Shenzhen) Co., Ltd." }, + { 0x2EEC, "Sensor Industries Limited" }, + { 0x2EED, "Shenzhen Panhui Technologies Co., Ltd." }, + { 0x2EEE, "Beijing Qunli Tiancheng Network Technology Company" }, + { 0x2EEF, "Booz Allen Hamilton" }, + { 0x2EF0, "Zhongshan Auxus Electronic Technology Co., Ltd." }, + { 0x2EF1, "Tatvik Biosystems Private Limited" }, + { 0x2EF2, "Shenzhen Goodwin Technology Co., Ltd." }, { 0x2FB2, "Fujitsu Limited" }, { 0x3176, "WHANAM ELECTRONICS CO., Ltd. MS division" }, { 0x3552, "BD Consumer Healthcare" }, @@ -10335,7 +10990,7 @@ VENDOR_ID USBVendorIDs[] = { 0x4317, "Broadcom WLAN" }, { 0x4426, "TANITA Corporation" }, { 0x4745, "Beijing Tiertime Technology Co., Ltd." }, - { 0x4791, "HGST BRANDED BUSINESS" }, + { 0x4791, "Western Digital, G-Tech" }, { 0x4909, "GE Healthcare Bio-Sciences AB" }, { 0x4971, "HITACHI GLOBAL STORAGE TECHNOLOGIES" }, { 0x4B53, "Key Soft Service" }, @@ -10373,6 +11028,7 @@ VENDOR_ID USBVendorIDs[] = { 0xFF01, "DisplayPort (VESA)" }, { 0xFF02, "MHL, LLC" }, { 0xFF03, "MIPI Debug" }, + { 0xFF04, "HDMI" }, { 0x0000, "Vendor ID not listed with USB.org" } }; -- cgit v1.3.1 From 2cda40f84726694a5e0ea20226e776f533cc7bce Mon Sep 17 00:00:00 2001 From: Andrew Yang Date: Mon, 31 Jul 2017 12:15:02 -0700 Subject: Correcting UCSI_MAX_NUM_PDOS --- usb/UcmCxUcsi/Ppm.h | 2 +- usb/UcmCxUcsi/Ucsi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usb/UcmCxUcsi/Ppm.h b/usb/UcmCxUcsi/Ppm.h index 341c25d4..e83399bf 100644 --- a/usb/UcmCxUcsi/Ppm.h +++ b/usb/UcmCxUcsi/Ppm.h @@ -68,7 +68,7 @@ typedef struct _PPM_CONNECTOR_CHANGE_CONTEXT LONG InProgress; UCM_CHARGING_STATE ChargingState; UCM_PD_REQUEST_DATA_OBJECT Rdo; - UCM_PD_POWER_DATA_OBJECT Pdos[7]; + UCM_PD_POWER_DATA_OBJECT Pdos[UCSI_MAX_NUM_PDOS]; UCHAR PdoCount; } PPM_CONNECTOR_CHANGE_CONTEXT, *PPPM_CONNECTOR_CHANGE_CONTEXT; diff --git a/usb/UcmCxUcsi/Ucsi.h b/usb/UcmCxUcsi/Ucsi.h index 72950d6c..1c03d5a3 100644 --- a/usb/UcmCxUcsi/Ucsi.h +++ b/usb/UcmCxUcsi/Ucsi.h @@ -29,7 +29,7 @@ Environment: #define UCSI_MAX_NUM_ALT_MODE 0x80 #define UCSI_MIN_TIME_TO_RESPOND_WITH_BUSY 0x0A #define UCSI_GET_ERROR_STATUS_DATA_LENGTH 0x10 -#define UCSI_MAX_NUM_PDOS 0x32 // Table 6-32 Counter parameters PD 2.0 V1.1 +#define UCSI_MAX_NUM_PDOS 0x7 // PD Rev2.0 Ver1.3: "6.2.1.2 Number of Data Objects" and "6.4.1 Capabilities Message" typedef enum _UCSI_COMMAND -- cgit v1.3.1 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 From 6b1c74b716187c96159eded0ec2acef1afed2716 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 16 Aug 2017 13:20:04 -0700 Subject: Remove any reference to tostrcls.dll from INF file The sample class installer itself has been removed long time back. --- general/toaster/toastpkg/inf/toastpkg.inf | 6 ------ general/toaster/toastpkg/toastcd/amd64/tostrcls.dll | Bin 16384 -> 0 bytes general/toaster/toastpkg/toastcd/i386/tostrcls.dll | Bin 15872 -> 0 bytes general/toaster/toastpkg/toastcd/toastpkg.inf | 6 ------ 4 files changed, 12 deletions(-) delete mode 100644 general/toaster/toastpkg/toastcd/amd64/tostrcls.dll delete mode 100644 general/toaster/toastpkg/toastcd/i386/tostrcls.dll diff --git a/general/toaster/toastpkg/inf/toastpkg.inf b/general/toaster/toastpkg/inf/toastpkg.inf index f1edae86..04ac6103 100644 --- a/general/toaster/toastpkg/inf/toastpkg.inf +++ b/general/toaster/toastpkg/inf/toastpkg.inf @@ -32,7 +32,6 @@ CatalogFile.NTAMD64 = tstamd64.cat [DestinationDirs] DefaultDestDir = 12 CoInstaller_CopyFiles = 11 -ToasterClassInstallerCopyFiles = 11 ; ================= Class section ===================== @@ -43,12 +42,8 @@ CopyFiles=ToasterClassInstallerCopyFiles [ToasterClassReg] HKR,,,0,%ClassName% HKR,,Icon,,100 -HKR,,Installer32,,"tostrcls.dll,ToasterClassInstaller" HKR,,DeviceCharacteristics,0x10001,0x100 ; Use same security checks on relative opens -[ToasterClassInstallerCopyFiles] -tostrcls.dll - ;***************************************** ; Toaster Device Install Section ;***************************************** @@ -120,7 +115,6 @@ OriginalInfSourcePath = %1% [SourceDisksFiles] toaster.sys = 1,, tostrco2.dll = 1,, -tostrcls.dll = 1,, [Strings] SPSVCINST_ASSOCSERVICE= 0x00000002 diff --git a/general/toaster/toastpkg/toastcd/amd64/tostrcls.dll b/general/toaster/toastpkg/toastcd/amd64/tostrcls.dll deleted file mode 100644 index 80fe0dc0..00000000 Binary files a/general/toaster/toastpkg/toastcd/amd64/tostrcls.dll and /dev/null differ diff --git a/general/toaster/toastpkg/toastcd/i386/tostrcls.dll b/general/toaster/toastpkg/toastcd/i386/tostrcls.dll deleted file mode 100644 index 7ac337f8..00000000 Binary files a/general/toaster/toastpkg/toastcd/i386/tostrcls.dll and /dev/null differ diff --git a/general/toaster/toastpkg/toastcd/toastpkg.inf b/general/toaster/toastpkg/toastcd/toastpkg.inf index f1edae86..04ac6103 100644 --- a/general/toaster/toastpkg/toastcd/toastpkg.inf +++ b/general/toaster/toastpkg/toastcd/toastpkg.inf @@ -32,7 +32,6 @@ CatalogFile.NTAMD64 = tstamd64.cat [DestinationDirs] DefaultDestDir = 12 CoInstaller_CopyFiles = 11 -ToasterClassInstallerCopyFiles = 11 ; ================= Class section ===================== @@ -43,12 +42,8 @@ CopyFiles=ToasterClassInstallerCopyFiles [ToasterClassReg] HKR,,,0,%ClassName% HKR,,Icon,,100 -HKR,,Installer32,,"tostrcls.dll,ToasterClassInstaller" HKR,,DeviceCharacteristics,0x10001,0x100 ; Use same security checks on relative opens -[ToasterClassInstallerCopyFiles] -tostrcls.dll - ;***************************************** ; Toaster Device Install Section ;***************************************** @@ -120,7 +115,6 @@ OriginalInfSourcePath = %1% [SourceDisksFiles] toaster.sys = 1,, tostrco2.dll = 1,, -tostrcls.dll = 1,, [Strings] SPSVCINST_ASSOCSERVICE= 0x00000002 -- cgit v1.3.1 From 66e7808d81f69a6f8a86fd6d54e8144ca306d442 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 16 Aug 2017 14:30:32 -0700 Subject: avstream\samplemft0\resource.h : warning C4335: Mac file format detected --- avstream/samplemft0/resource.h | Bin 1710 -> 1708 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/avstream/samplemft0/resource.h b/avstream/samplemft0/resource.h index d20cf5a1..3446618b 100644 Binary files a/avstream/samplemft0/resource.h and b/avstream/samplemft0/resource.h differ -- cgit v1.3.1 From bf93ae3e9d74d8863e23e10482da04d01c9fa947 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 16 Aug 2017 14:31:32 -0700 Subject: error 1209: Section [destinationdirs] is defined multiple times --- .../toaster/toastDrv/kmdf/bus/dynamic/dynambus.inx | Bin 5836 -> 5754 bytes .../toaster/toastDrv/kmdf/bus/static/statbus.inx | Bin 5740 -> 5658 bytes .../toastDrv/kmdf/func/featured/wdffeatured.inx | Bin 5952 -> 5870 bytes .../toaster/toastDrv/kmdf/func/simple/wdfsimple.inx | Bin 6920 -> 6838 bytes general/toaster/umdf2/filter/generic/filterum.inx | Bin 4946 -> 4904 bytes .../toaster/umdf2/func/featured/wdffeaturedum.inx | Bin 4962 -> 4924 bytes general/toaster/umdf2/func/simple/wdfsimpleum.inx | Bin 4838 -> 4796 bytes network/modem/fakemodem/mdmfake.inx | Bin 24276 -> 24198 bytes .../HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx | Bin 7394 -> 7088 bytes sd/sdiomars/mars.inx | Bin 4248 -> 4166 bytes sensors/ADXL345Acc/ADXL345Acc.inx | Bin 5384 -> 5282 bytes sensors/Activity/Activity.inx | Bin 5180 -> 5078 bytes sensors/CustomSensors/CustomSensors.inx | Bin 5464 -> 5352 bytes sensors/Pedometer/Pedometer.inx | Bin 5234 -> 5130 bytes .../SimpleDeviceOrientationSensor.inx | Bin 6446 -> 6302 bytes smartcrd/pscr/pscr.inx | Bin 6338 -> 6260 bytes usb/UcmCxUcsi/UcmCxUcsi.inf | Bin 4922 -> 4888 bytes 17 files changed, 0 insertions(+), 0 deletions(-) diff --git a/general/toaster/toastDrv/kmdf/bus/dynamic/dynambus.inx b/general/toaster/toastDrv/kmdf/bus/dynamic/dynambus.inx index 9f7634b1..c51e1e9b 100644 Binary files a/general/toaster/toastDrv/kmdf/bus/dynamic/dynambus.inx and b/general/toaster/toastDrv/kmdf/bus/dynamic/dynambus.inx differ diff --git a/general/toaster/toastDrv/kmdf/bus/static/statbus.inx b/general/toaster/toastDrv/kmdf/bus/static/statbus.inx index 0725d2bb..a28b3144 100644 Binary files a/general/toaster/toastDrv/kmdf/bus/static/statbus.inx and b/general/toaster/toastDrv/kmdf/bus/static/statbus.inx differ diff --git a/general/toaster/toastDrv/kmdf/func/featured/wdffeatured.inx b/general/toaster/toastDrv/kmdf/func/featured/wdffeatured.inx index 32916e7e..73a1a1ea 100644 Binary files a/general/toaster/toastDrv/kmdf/func/featured/wdffeatured.inx and b/general/toaster/toastDrv/kmdf/func/featured/wdffeatured.inx differ diff --git a/general/toaster/toastDrv/kmdf/func/simple/wdfsimple.inx b/general/toaster/toastDrv/kmdf/func/simple/wdfsimple.inx index ad55da36..69fbea75 100644 Binary files a/general/toaster/toastDrv/kmdf/func/simple/wdfsimple.inx and b/general/toaster/toastDrv/kmdf/func/simple/wdfsimple.inx differ diff --git a/general/toaster/umdf2/filter/generic/filterum.inx b/general/toaster/umdf2/filter/generic/filterum.inx index 6686b2fb..0efeb0d3 100644 Binary files a/general/toaster/umdf2/filter/generic/filterum.inx and b/general/toaster/umdf2/filter/generic/filterum.inx differ diff --git a/general/toaster/umdf2/func/featured/wdffeaturedum.inx b/general/toaster/umdf2/func/featured/wdffeaturedum.inx index 067ca605..bb8af311 100644 Binary files a/general/toaster/umdf2/func/featured/wdffeaturedum.inx and b/general/toaster/umdf2/func/featured/wdffeaturedum.inx differ diff --git a/general/toaster/umdf2/func/simple/wdfsimpleum.inx b/general/toaster/umdf2/func/simple/wdfsimpleum.inx index 18576c76..3187b27f 100644 Binary files a/general/toaster/umdf2/func/simple/wdfsimpleum.inx and b/general/toaster/umdf2/func/simple/wdfsimpleum.inx differ diff --git a/network/modem/fakemodem/mdmfake.inx b/network/modem/fakemodem/mdmfake.inx index 7dbe55c0..6d94c1ec 100644 Binary files a/network/modem/fakemodem/mdmfake.inx and b/network/modem/fakemodem/mdmfake.inx differ diff --git a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx b/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx index a1f0bf1a..c7d1ba0f 100644 Binary files a/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx and b/network/radio/HidSwitchDriverSample/RadioSwitchHidUsbFx2.inx differ diff --git a/sd/sdiomars/mars.inx b/sd/sdiomars/mars.inx index 5e0fbef1..773ff95e 100644 Binary files a/sd/sdiomars/mars.inx and b/sd/sdiomars/mars.inx differ diff --git a/sensors/ADXL345Acc/ADXL345Acc.inx b/sensors/ADXL345Acc/ADXL345Acc.inx index 8d7649da..763a75e8 100644 Binary files a/sensors/ADXL345Acc/ADXL345Acc.inx and b/sensors/ADXL345Acc/ADXL345Acc.inx differ diff --git a/sensors/Activity/Activity.inx b/sensors/Activity/Activity.inx index 7f2558c1..91c32a5c 100644 Binary files a/sensors/Activity/Activity.inx and b/sensors/Activity/Activity.inx differ diff --git a/sensors/CustomSensors/CustomSensors.inx b/sensors/CustomSensors/CustomSensors.inx index b26b6848..6a0ec8cc 100644 Binary files a/sensors/CustomSensors/CustomSensors.inx and b/sensors/CustomSensors/CustomSensors.inx differ diff --git a/sensors/Pedometer/Pedometer.inx b/sensors/Pedometer/Pedometer.inx index 4aea1609..f9cb099f 100644 Binary files a/sensors/Pedometer/Pedometer.inx and b/sensors/Pedometer/Pedometer.inx differ diff --git a/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx b/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx index 7de2e6f0..6c61d4e6 100644 Binary files a/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx and b/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx differ diff --git a/smartcrd/pscr/pscr.inx b/smartcrd/pscr/pscr.inx index 50cd311c..22a8b269 100644 Binary files a/smartcrd/pscr/pscr.inx and b/smartcrd/pscr/pscr.inx differ diff --git a/usb/UcmCxUcsi/UcmCxUcsi.inf b/usb/UcmCxUcsi/UcmCxUcsi.inf index 604f04ba..c1204c40 100644 Binary files a/usb/UcmCxUcsi/UcmCxUcsi.inf and b/usb/UcmCxUcsi/UcmCxUcsi.inf differ -- cgit v1.3.1 From 562f9f003d163470eaab98517f0770dc328f292b Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Fri, 4 Aug 2017 07:15:57 -0700 Subject: Build clean SysVad sample w/ RS2 WDK --- audio/sysvad/common.cpp | 1309 ++++++++++++++++++++++++++--------------------- audio/sysvad/sysvad.h | 44 +- audio/sysvad/sysvad.sln | 10 - 3 files changed, 754 insertions(+), 609 deletions(-) diff --git a/audio/sysvad/common.cpp b/audio/sysvad/common.cpp index d046d336..2aadb5e6 100644 --- a/audio/sysvad/common.cpp +++ b/audio/sysvad/common.cpp @@ -8,7 +8,7 @@ Module Name: Abstract: - Implementation of the AdapterCommon class. + Implementation of the AdapterCommon class. --*/ @@ -29,7 +29,7 @@ Abstract: #include "bthhfpminipairs.h" // # of sec before sync request is cancelled. -#define BTH_HFP_SYNC_REQ_TIMEOUT_IN_SEC 60 +#define BTH_HFP_SYNC_REQ_TIMEOUT_IN_SEC 60 #define BTH_HFP_NOTIFICATION_MAX_ERROR_COUNT 5 #endif // SYSVAD_BTH_BYPASS @@ -50,18 +50,18 @@ class BthHfpDevice; // Forward declaration. /////////////////////////////////////////////////////////////////////////////// // CAdapterCommon -// -class CAdapterCommon : +// +class CAdapterCommon : public IAdapterCommon, public IAdapterPowerManagement, - public CUnknown + public CUnknown { private: PSERVICEGROUP m_pServiceGroupWave; PDEVICE_OBJECT m_pDeviceObject; PDEVICE_OBJECT m_pPhysicalDeviceObject; - WDFDEVICE m_WdfDevice; // Wdf device. - DEVICE_POWER_STATE m_PowerState; + WDFDEVICE m_WdfDevice; // Wdf device. + DEVICE_POWER_STATE m_PowerState; PCSYSVADHW m_pHW; // Virtual SYSVAD HW object PPORTCLSETWHELPER m_pPortClsEtwHelper; @@ -82,21 +82,21 @@ class CAdapterCommon : IMP_IAdapterPowerManagement; //===================================================================== - // IAdapterCommon methods + // IAdapterCommon methods STDMETHODIMP_(NTSTATUS) Init - ( + ( _In_ PDEVICE_OBJECT DeviceObject ); STDMETHODIMP_(PDEVICE_OBJECT) GetDeviceObject(void); - + STDMETHODIMP_(PDEVICE_OBJECT) GetPhysicalDeviceObject(void); - + STDMETHODIMP_(WDFDEVICE) GetWdfDevice(void); STDMETHODIMP_(void) SetWaveServiceGroup - ( + ( _In_ PSERVICEGROUP ServiceGroup ); @@ -142,26 +142,26 @@ class CAdapterCommon : STDMETHODIMP_(void) MixerReset(void); STDMETHODIMP_(LONG) MixerVolumeRead - ( + ( _In_ ULONG Index, _In_ ULONG Channel ); STDMETHODIMP_(void) MixerVolumeWrite - ( + ( _In_ ULONG Index, _In_ ULONG Channel, - _In_ LONG Value + _In_ LONG Value ); STDMETHODIMP_(LONG) MixerPeakMeterRead - ( + ( _In_ ULONG Index, _In_ ULONG Channel ); - STDMETHODIMP_(NTSTATUS) WriteEtwEvent - ( + STDMETHODIMP_(NTSTATUS) WriteEtwEvent + ( _In_ EPcMiniportEngineEvent miniportEventType, _In_ ULONGLONG ullData1, _In_ ULONGLONG ullData2, @@ -169,13 +169,13 @@ class CAdapterCommon : _In_ ULONGLONG ullData4 ); - STDMETHODIMP_(VOID) SetEtwHelper - ( + STDMETHODIMP_(VOID) SetEtwHelper + ( PPORTCLSETWHELPER _pPortClsEtwHelper ); - + STDMETHODIMP_(NTSTATUS) InstallSubdevice - ( + ( _In_opt_ PIRP Irp, _In_ PWSTR Name, _In_ REFGUID PortClassId, @@ -191,12 +191,12 @@ class CAdapterCommon : _Out_opt_ PUNKNOWN * OutPortUnknown, _Out_opt_ PUNKNOWN * OutMiniportUnknown ); - + STDMETHODIMP_(NTSTATUS) UnregisterSubdevice ( _In_opt_ PUNKNOWN UnknownPort ); - + STDMETHODIMP_(NTSTATUS) ConnectTopologies ( _In_ PUNKNOWN UnknownTopology, @@ -204,7 +204,7 @@ class CAdapterCommon : _In_ PHYSICALCONNECTIONTABLE* PhysicalConnections, _In_ ULONG PhysicalConnectionCount ); - + STDMETHODIMP_(NTSTATUS) DisconnectTopologies ( _In_ PUNKNOWN UnknownTopology, @@ -212,10 +212,10 @@ class CAdapterCommon : _In_ PHYSICALCONNECTIONTABLE* PhysicalConnections, _In_ ULONG PhysicalConnectionCount ); - + STDMETHODIMP_(NTSTATUS) InstallEndpointFilters ( - _In_opt_ PIRP Irp, + _In_opt_ PIRP Irp, _In_ PENDPOINT_MINIPAIR MiniportPair, _In_opt_ PVOID DeviceContext, _Out_opt_ PUNKNOWN * UnknownTopology, @@ -223,7 +223,7 @@ class CAdapterCommon : _Out_opt_ PUNKNOWN * UnknownMiniportTopology, _Out_opt_ PUNKNOWN * UnknownMiniportWave ); - + STDMETHODIMP_(NTSTATUS) RemoveEndpointFilters ( _In_ PENDPOINT_MINIPAIR MiniportPair, @@ -248,23 +248,23 @@ class CAdapterCommon : #ifdef SYSVAD_BTH_BYPASS STDMETHODIMP_(NTSTATUS) InitBthScoBypass(); - + STDMETHODIMP_(VOID) CleanupBthScoBypass(); #endif // SYSVAD_BTH_BYPASS STDMETHODIMP_(VOID) Cleanup(); - + //===================================================================== // friends friend NTSTATUS NewAdapterCommon - ( + ( _Out_ PUNKNOWN * Unknown, _In_ REFCLSID, _In_opt_ PUNKNOWN UnknownOuter, _When_((PoolType & NonPagedPoolMustSucceed) != 0, __drv_reportError("Must succeed pool allocations are forbidden. " "Allocation failures cause a system crash")) - _In_ POOL_TYPE PoolType + _In_ POOL_TYPE PoolType ); #ifdef SYSVAD_BTH_BYPASS @@ -282,12 +282,12 @@ class CAdapterCommon : BOOL m_BthHfpEnableCleanup; // Do cleanup if true. private: - static + static DRIVER_NOTIFICATION_CALLBACK_ROUTINE EvtBthHfpScoBypassInterfaceChange; - - static + + static EVT_WDF_WORKITEM EvtBthHfpScoBypassInterfaceWorkItem; - + protected: BthHfpDevice * BthHfpDeviceFind ( @@ -323,7 +323,7 @@ class CAdapterCommon : _In_ PUNKNOWN UnknownPort, _In_ PUNKNOWN UnknownMiniport ); - + NTSTATUS RemoveCachedSubdevice ( _In_ PWSTR Name @@ -450,33 +450,33 @@ struct BthHfpEventCallback // This class represents a the Bluetooth Hands-Free Profile SCO Bypass device. // There is one class for each interface (id = symbolic-link-name). // -class BthHfpDevice : +class BthHfpDevice : IBthHfpDeviceCommon, - public CUnknown + public CUnknown { private: eBthHfpState m_State; - + CAdapterCommon * m_Adapter; WDFIOTARGET m_WdfIoTarget; - + LIST_ENTRY m_ListEntry; UNICODE_STRING m_SymbolicLinkName; - + // // The Topo Filter Desc and Topo Pins structures referenced from - // the Miniports structure are deep copies: they start as copies of the - // static structures and are modified to allow per-SCO-Device pin - // categories based on the info obtained from + // the Miniports structure are deep copies: they start as copies of the + // static structures and are modified to allow per-SCO-Device pin + // categories based on the info obtained from // IOCTL_BTHHFP_DEVICE_GET_DESCRIPTOR2 // PENDPOINT_MINIPAIR m_SpeakerMiniports; PENDPOINT_MINIPAIR m_MicMiniports; - + PUNKNOWN m_UnknownSpeakerTopology; PUNKNOWN m_UnknownSpeakerWave; PUNKNOWN m_UnknownMicTopology; - PUNKNOWN m_UnknownMicWave; + PUNKNOWN m_UnknownMicWave; PBTHHFP_DESCRIPTOR2 m_Descriptor; PKSPROPERTY_VALUES m_VolumePropValues; @@ -486,7 +486,7 @@ class BthHfpDevice : BOOL m_ConnectionStatus; LONG m_ConnectionStatusLong; }; // unnamed. - + union{ NTSTATUS m_StreamStatus; LONG m_StreamStatusLong; @@ -495,11 +495,11 @@ class BthHfpDevice : KEVENT m_StreamStatusEvent; // - // Set to TRUE when the HF (remote device) wants to disable the + // Set to TRUE when the HF (remote device) wants to disable the // NR + EC of the AG (local system). // LONG m_NRECDisableStatusLong; - + WDFREQUEST m_StreamReq; WDFREQUEST m_SpeakerVolumeReq; WDFREQUEST m_MicVolumeReq; @@ -525,7 +525,7 @@ class BthHfpDevice : NTSTATUS Init ( - _In_ CAdapterCommon * Adapter, + _In_ CAdapterCommon * Adapter, _In_ PUNICODE_STRING SymbolicLinkName ); @@ -548,7 +548,7 @@ class BthHfpDevice : } static - BthHfpDevice * + BthHfpDevice * GetBthHfpDevice ( _In_ PLIST_ENTRY le @@ -560,69 +560,69 @@ class BthHfpDevice : public: //===================================================================== // - // IBthHfpDeviceCommon functions. + // IBthHfpDeviceCommon functions. // STDMETHODIMP_(BOOL) IsVolumeSupported(); - + STDMETHODIMP_(PKSPROPERTY_VALUES) GetVolumeSettings ( - _Out_ PULONG Size + _Out_ PULONG Size ); - + STDMETHODIMP_(LONG) GetSpeakerVolume(); - + STDMETHODIMP_(NTSTATUS) SetSpeakerVolume ( _In_ ULONG Volume ); - + STDMETHODIMP_(LONG) GetMicVolume(); - + STDMETHODIMP_(NTSTATUS) SetMicVolume ( _In_ ULONG Volume ); - + STDMETHODIMP_(BOOL) GetConnectionStatus(); - + STDMETHODIMP_(NTSTATUS) Connect(); - + STDMETHODIMP_(NTSTATUS) Disconnect(); - + STDMETHODIMP_(BOOL) GetStreamStatus(); - + STDMETHODIMP_(NTSTATUS) StreamOpen(); - + STDMETHODIMP_(NTSTATUS) StreamClose(); - + STDMETHODIMP_(GUID) GetContainerId(); - + STDMETHODIMP_(VOID) SetSpeakerVolumeHandler ( _In_opt_ PFNEVENTNOTIFICATION EventHandler, _In_opt_ PVOID EventHandlerContext ); - + STDMETHODIMP_(VOID) SetSpeakerConnectionStatusHandler ( _In_opt_ PFNEVENTNOTIFICATION EventHandler, _In_opt_ PVOID EventHandlerContext ); - + STDMETHODIMP_(VOID) SetMicVolumeHandler ( _In_opt_ PFNEVENTNOTIFICATION EventHandler, _In_opt_ PVOID EventHandlerContext ); - + STDMETHODIMP_(VOID) SetMicConnectionStatusHandler ( _In_opt_ PFNEVENTNOTIFICATION EventHandler, _In_opt_ PVOID EventHandlerContext ); - + STDMETHODIMP_(BOOL) IsNRECSupported(); - + STDMETHODIMP_(BOOL) GetNRECDisableStatus(); private: @@ -640,7 +640,7 @@ class BthHfpDevice : _When_(InLength == 0 && OutLength == 0, _In_opt_) PVOID Buffer ); - + NTSTATUS SendIoCtrlAsynchronously ( _In_ WDFREQUEST Request, @@ -650,51 +650,51 @@ class BthHfpDevice : _In_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine, _In_ WDFCONTEXT Context ); - + NTSTATUS GetBthHfpDescriptor ( _Out_ PBTHHFP_DESCRIPTOR2 * Descriptor ); - + NTSTATUS EnableBthHfpNrecDisableStatusNotification(); - + NTSTATUS GetBthHfpVolumePropertyValues ( _In_ ULONG Length, _Out_ PKSPROPERTY_VALUES * PropValues ); - + NTSTATUS SetBthHfpSpeakerVolume ( - _In_ LONG Volume + _In_ LONG Volume ); - + NTSTATUS GetBthHfpSpeakerVolume ( - _Out_ LONG * Volume + _Out_ LONG * Volume ); - + NTSTATUS EnableBthHfpSpeakerVolumeStatusNotification(); - + NTSTATUS SetBthHfpMicVolume ( - _In_ LONG Volume + _In_ LONG Volume ); - + NTSTATUS GetBthHfpMicVolume ( - _Out_ LONG * Volume + _Out_ LONG * Volume ); - + NTSTATUS EnableBthHfpMicVolumeStatusNotification(); - + NTSTATUS GetBthHfpConnectionStatus ( - _Out_ BOOL * ConnectionStatus + _Out_ BOOL * ConnectionStatus ); - + NTSTATUS EnableBthHfpConnectionStatusNotification(); - + static NTSTATUS CreateCustomEndpointMinipair ( @@ -717,24 +717,24 @@ class BthHfpDevice : ( _In_ PENDPOINT_MINIPAIR CustomMinipair ); - + NTSTATUS GetBthHfpCodecId ( _Out_ UCHAR * CodecId ); NTSTATUS SetBthHfpConnect(); - + NTSTATUS SetBthHfpDisconnect(); NTSTATUS SetBthHfpStreamOpen(); NTSTATUS SetBthHfpStreamClose(); - + NTSTATUS EnableBthHfpStreamStatusNotification(); - + NTSTATUS StopBthHfpStreamStatusNotification(); - + // // WDF I/O Target callback. // @@ -750,12 +750,12 @@ class BthHfpDevice : // // Status notifications callbacks. // - static + static EVT_WDF_REQUEST_COMPLETION_ROUTINE EvtBthHfpDeviceStreamStatusCompletion; - static + static EVT_WDF_REQUEST_COMPLETION_ROUTINE EvtBthHfpDeviceNotificationStatusCompletion; - + static EVT_WDF_WORKITEM EvtBthHfpDeviceNotificationStatusWorkItem; }; @@ -805,14 +805,14 @@ NTSTATUS SysvadIoSetDeviceInterfacePropertyDataMultiple #pragma code_seg("PAGE") NTSTATUS NewAdapterCommon -( +( _Out_ PUNKNOWN * Unknown, _In_ REFCLSID, _In_opt_ PUNKNOWN UnknownOuter, _When_((PoolType & NonPagedPoolMustSucceed) != 0, __drv_reportError("Must succeed pool allocations are forbidden. " "Allocation failures cause a system crash")) - _In_ POOL_TYPE PoolType + _In_ POOL_TYPE PoolType ) /*++ @@ -822,7 +822,7 @@ Routine Description: Arguments: - Unknown - + Unknown - UnknownOuter - @@ -842,7 +842,7 @@ Return Value: // // This sample supports only one instance of this object. - // (b/c of CSaveData's static members and Bluetooth HFP logic). + // (b/c of CSaveData's static members and Bluetooth HFP logic). // if (InterlockedCompareExchange(&CAdapterCommon::m_AdapterInstances, 1, 0) != 0) { @@ -850,7 +850,7 @@ Return Value: DPF(D_ERROR, ("NewAdapterCommon failed, only one instance is allowed")); goto Done; } - + // // Allocate an adapter object. // @@ -862,22 +862,22 @@ Return Value: goto Done; } - // + // // Success. // *Unknown = PUNKNOWN((PADAPTERCOMMON)(p)); - (*Unknown)->AddRef(); - ntStatus = STATUS_SUCCESS; + (*Unknown)->AddRef(); + ntStatus = STATUS_SUCCESS; -Done: +Done: return ntStatus; } // NewAdapterCommon //============================================================================= #pragma code_seg("PAGE") CAdapterCommon::~CAdapterCommon -( - void +( + void ) /*++ @@ -901,12 +901,12 @@ Return Value: delete m_pHW; m_pHW = NULL; } - + CSaveData::DestroyWorkItems(); SAFE_RELEASE(m_pPortClsEtwHelper); SAFE_RELEASE(m_pServiceGroupWave); - + if (m_WdfDevice) { WdfObjectDelete(m_WdfDevice); @@ -915,11 +915,11 @@ Return Value: InterlockedDecrement(&CAdapterCommon::m_AdapterInstances); ASSERT(CAdapterCommon::m_AdapterInstances == 0); -} // ~CAdapterCommon +} // ~CAdapterCommon //============================================================================= #pragma code_seg("PAGE") -STDMETHODIMP_(PDEVICE_OBJECT) +STDMETHODIMP_(PDEVICE_OBJECT) CAdapterCommon::GetDeviceObject ( void @@ -939,13 +939,13 @@ Return Value: --*/ { PAGED_CODE(); - + return m_pDeviceObject; } // GetDeviceObject //============================================================================= #pragma code_seg("PAGE") -STDMETHODIMP_(PDEVICE_OBJECT) +STDMETHODIMP_(PDEVICE_OBJECT) CAdapterCommon::GetPhysicalDeviceObject ( void @@ -965,13 +965,13 @@ Return Value: --*/ { PAGED_CODE(); - + return m_pPhysicalDeviceObject; } // GetPhysicalDeviceObject //============================================================================= #pragma code_seg("PAGE") -STDMETHODIMP_(WDFDEVICE) +STDMETHODIMP_(WDFDEVICE) CAdapterCommon::GetWdfDevice ( void @@ -993,7 +993,7 @@ Return Value: --*/ { PAGED_CODE(); - + return m_WdfDevice; } // GetWdfDevice @@ -1001,8 +1001,8 @@ Return Value: #pragma code_seg("PAGE") NTSTATUS CAdapterCommon::Init -( - _In_ PDEVICE_OBJECT DeviceObject +( + _In_ PDEVICE_OBJECT DeviceObject ) /*++ @@ -1053,7 +1053,7 @@ Return Value: Done); // - // Create a WDF miniport to represent the adapter. Note that WDF miniports + // Create a WDF miniport to represent the adapter. Note that WDF miniports // are NOT audio miniports. An audio adapter is associated with a single WDF // miniport. This driver uses WDF to simplify the handling of the Bluetooth // SCO HFP Bypass interface. @@ -1070,7 +1070,7 @@ Return Value: Done); // Initialize HW. - // + // m_pHW = new (NonPagedPoolNx, SYSVAD_POOLTAG) CSYSVADHW; if (!m_pHW) { @@ -1078,7 +1078,7 @@ Return Value: ntStatus = STATUS_INSUFFICIENT_RESOURCES; } IF_FAILED_JUMP(ntStatus, Done); - + m_pHW->MixerReset(); // @@ -1097,8 +1097,8 @@ Done: #pragma code_seg("PAGE") STDMETHODIMP_(void) CAdapterCommon::MixerReset -( - void +( + void ) /*++ @@ -1115,7 +1115,7 @@ Return Value: --*/ { PAGED_CODE(); - + if (m_pHW) { m_pHW->MixerReset(); @@ -1125,60 +1125,60 @@ Return Value: //============================================================================= /* Here are the definitions of the standard miniport events. -Event type : eMINIPORT_IHV_DEFINED +Event type : eMINIPORT_IHV_DEFINED Parameter 1 : Defined and used by IHVs Parameter 2 : Defined and used by IHVs Parameter 3 :Defined and used by IHVs Parameter 4 :Defined and used by IHVs Event type: eMINIPORT_BUFFER_COMPLETE -Parameter 1: Current linear buffer position -Parameter 2: the previous WaveRtBufferWritePosition that the drive received +Parameter 1: Current linear buffer position +Parameter 2: the previous WaveRtBufferWritePosition that the drive received Parameter 3: Data length completed Parameter 4:0 Event type: eMINIPORT_PIN_STATE -Parameter 1: Current linear buffer position -Parameter 2: the previous WaveRtBufferWritePosition that the drive received -Parameter 3: Pin State 0->KS_STOP, 1->KS_ACQUIRE, 2->KS_PAUSE, 3->KS_RUN +Parameter 1: Current linear buffer position +Parameter 2: the previous WaveRtBufferWritePosition that the drive received +Parameter 3: Pin State 0->KS_STOP, 1->KS_ACQUIRE, 2->KS_PAUSE, 3->KS_RUN Parameter 4:0 Event type: eMINIPORT_GET_STREAM_POS -Parameter 1: Current linear buffer position -Parameter 2: the previous WaveRtBufferWritePosition that the drive received +Parameter 1: Current linear buffer position +Parameter 2: the previous WaveRtBufferWritePosition that the drive received Parameter 3: 0 Parameter 4:0 Event type: eMINIPORT_SET_WAVERT_BUFFER_WRITE_POS -Parameter 1: Current linear buffer position -Parameter 2: the previous WaveRtBufferWritePosition that the drive received +Parameter 1: Current linear buffer position +Parameter 2: the previous WaveRtBufferWritePosition that the drive received Parameter 3: the arget WaveRtBufferWritePosition received from portcls Parameter 4:0 Event type: eMINIPORT_GET_PRESENTATION_POS -Parameter 1: Current linear buffer position -Parameter 2: the previous WaveRtBufferWritePosition that the drive received +Parameter 1: Current linear buffer position +Parameter 2: the previous WaveRtBufferWritePosition that the drive received Parameter 3: Presentation position Parameter 4:0 -Event type: eMINIPORT_PROGRAM_DMA -Parameter 1: Current linear buffer position -Parameter 2: the previous WaveRtBufferWritePosition that the drive received +Event type: eMINIPORT_PROGRAM_DMA +Parameter 1: Current linear buffer position +Parameter 2: the previous WaveRtBufferWritePosition that the drive received Parameter 3: Starting WaveRt buffer offset Parameter 4: Data length Event type: eMINIPORT_GLITCH_REPORT -Parameter 1: Current linear buffer position -Parameter 2: the previous WaveRtBufferWritePosition that the drive received -Parameter 3: major glitch code: 1:WaveRT buffer is underrun, - 2:decoder errors, +Parameter 1: Current linear buffer position +Parameter 2: the previous WaveRtBufferWritePosition that the drive received +Parameter 3: major glitch code: 1:WaveRT buffer is underrun, + 2:decoder errors, 3:receive the same wavert buffer two in a row in event driven mode Parameter 4: minor code for the glitch cause Event type: eMINIPORT_LAST_BUFFER_RENDERED -Parameter 1: Current linear buffer position -Parameter 2: the very last WaveRtBufferWritePosition that the driver received +Parameter 1: Current linear buffer position +Parameter 2: the very last WaveRtBufferWritePosition that the driver received Parameter 3: 0 Parameter 4: 0 @@ -1186,7 +1186,7 @@ Parameter 4: 0 #pragma code_seg() STDMETHODIMP CAdapterCommon::WriteEtwEvent -( +( _In_ EPcMiniportEngineEvent miniportEventType, _In_ ULONGLONG ullData1, _In_ ULONGLONG ullData2, @@ -1207,12 +1207,12 @@ CAdapterCommon::WriteEtwEvent #pragma code_seg("PAGE") STDMETHODIMP_(void) CAdapterCommon::SetEtwHelper -( +( PPORTCLSETWHELPER _pPortClsEtwHelper ) { PAGED_CODE(); - + SAFE_RELEASE(m_pPortClsEtwHelper); m_pPortClsEtwHelper = _pPortClsEtwHelper; @@ -1227,9 +1227,9 @@ CAdapterCommon::SetEtwHelper #pragma code_seg("PAGE") STDMETHODIMP CAdapterCommon::NonDelegatingQueryInterface -( +( _In_ REFIID Interface, - _COM_Outptr_ PVOID * Object + _COM_Outptr_ PVOID * Object ) /*++ @@ -1239,7 +1239,7 @@ Routine Description: Arguments: - Interface - + Interface - Object - @@ -1283,8 +1283,8 @@ Return Value: #pragma code_seg("PAGE") STDMETHODIMP_(void) CAdapterCommon::SetWaveServiceGroup -( - _In_ PSERVICEGROUP ServiceGroup +( + _In_ PSERVICEGROUP ServiceGroup ) /*++ @@ -1301,7 +1301,7 @@ Return Value: { PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::SetWaveServiceGroup]")); - + SAFE_RELEASE(m_pServiceGroupWave); m_pServiceGroupWave = ServiceGroup; @@ -1551,7 +1551,7 @@ Return Value: //============================================================================= #pragma code_seg() STDMETHODIMP_(ULONG) -CAdapterCommon::MixerMuxRead() +CAdapterCommon::MixerMuxRead() /*++ Routine Description: @@ -1613,7 +1613,7 @@ Return Value: #pragma code_seg() STDMETHODIMP_(LONG) CAdapterCommon::MixerVolumeRead -( +( _In_ ULONG Index, _In_ ULONG Channel ) @@ -1647,7 +1647,7 @@ Return Value: #pragma code_seg() STDMETHODIMP_(void) CAdapterCommon::MixerVolumeWrite -( +( _In_ ULONG Index, _In_ ULONG Channel, _In_ LONG Value @@ -1682,7 +1682,7 @@ Return Value: #pragma code_seg() STDMETHODIMP_(LONG) CAdapterCommon::MixerPeakMeterRead -( +( _In_ ULONG Index, _In_ ULONG Channel ) @@ -1716,8 +1716,8 @@ Return Value: #pragma code_seg() STDMETHODIMP_(void) CAdapterCommon::PowerChangeState -( - _In_ POWER_STATE NewState +( + _In_ POWER_STATE NewState ) /*++ @@ -1726,7 +1726,7 @@ Routine Description: Arguments: - NewState - The requested, new power state for the device. + NewState - The requested, new power state for the device. Return Value: @@ -1737,29 +1737,29 @@ Note: To assist the driver, PortCls will pause any active audio streams prior to calling this method to place the device in a sleep state. After calling this method, PortCls - will unpause active audio streams, to wake the device up. Miniports can opt for + will unpause active audio streams, to wake the device up. Miniports can opt for additional notification by utilizing the IPowerNotify interface. - The miniport driver must perform the requested change to the device's power state - before it returns from the PowerChangeState call. If the miniport driver needs to - save or restore any device state before a power-state change, the miniport driver + The miniport driver must perform the requested change to the device's power state + before it returns from the PowerChangeState call. If the miniport driver needs to + save or restore any device state before a power-state change, the miniport driver should support the IPowerNotify interface, which allows it to receive advance warning - of any such change. Before returning from a successful PowerChangeState call, the + of any such change. Before returning from a successful PowerChangeState call, the miniport driver should cache the new power state. - While the miniport driver is in one of the sleep states (any state other than + While the miniport driver is in one of the sleep states (any state other than PowerDeviceD0), it must avoid writing to the hardware. The miniport driver must cache any hardware accesses that need to be deferred until the device powers up again. If - the power state is changing from one of the sleep states to PowerDeviceD0, the + the power state is changing from one of the sleep states to PowerDeviceD0, the miniport driver should perform any deferred hardware accesses after it has powered up - the device. If the power state is changing from PowerDeviceD0 to a sleep state, the + the device. If the power state is changing from PowerDeviceD0 to a sleep state, the miniport driver can perform any necessary hardware accesses during the PowerChangeState call before it powers down the device. While powered down, a miniport driver is never asked to create a miniport driver object or stream object. PortCls always places the device in the PowerDeviceD0 state before calling the miniport driver's NewStream method. - + --*/ { DPF_ENTER(("[CAdapterCommon::PowerChangeState]")); @@ -1791,15 +1791,15 @@ Note: m_PowerState = NewState.DeviceState; DPF - ( - D_VERBOSE, - ("Entering D%u", ULONG(m_PowerState) - ULONG(PowerDeviceD0)) + ( + D_VERBOSE, + ("Entering D%u", ULONG(m_PowerState) - ULONG(PowerDeviceD0)) ); break; - + default: - + DPF(D_VERBOSE, ("Unknown Device Power State")); break; } @@ -1810,20 +1810,20 @@ Note: #pragma code_seg() STDMETHODIMP_(NTSTATUS) CAdapterCommon::QueryDeviceCapabilities -( - _Inout_updates_bytes_(sizeof(DEVICE_CAPABILITIES)) PDEVICE_CAPABILITIES PowerDeviceCaps +( + _Inout_updates_bytes_(sizeof(DEVICE_CAPABILITIES)) PDEVICE_CAPABILITIES PowerDeviceCaps ) /*++ Routine Description: - Called at startup to get the caps for the device. This structure provides - the system with the mappings between system power state and device power - state. This typically will not need modification by the driver. + Called at startup to get the caps for the device. This structure provides + the system with the mappings between system power state and device power + state. This typically will not need modification by the driver. Arguments: - PowerDeviceCaps - The device's capabilities. + PowerDeviceCaps - The device's capabilities. Return Value: @@ -1842,14 +1842,14 @@ Return Value: #pragma code_seg() STDMETHODIMP_(NTSTATUS) CAdapterCommon::QueryPowerChangeState -( - _In_ POWER_STATE NewStateQuery +( + _In_ POWER_STATE NewStateQuery ) /*++ Routine Description: - Query to see if the device can change to this power state + Query to see if the device can change to this power state Arguments: @@ -1954,7 +1954,7 @@ Done: #pragma code_seg("PAGE") STDMETHODIMP_(NTSTATUS) CAdapterCommon::InstallSubdevice -( +( _In_opt_ PIRP Irp, _In_ PWSTR Name, _In_ REFGUID PortClassId, @@ -1975,34 +1975,34 @@ CAdapterCommon::InstallSubdevice Routine Description: - This function creates and registers a subdevice consisting of a port - driver, a minport driver and a set of resources bound together. It will - also optionally place a pointer to an interface on the port driver in a - specified location before initializing the port driver. This is done so - that a common ISR can have access to the port driver during - initialization, when the ISR might fire. + This function creates and registers a subdevice consisting of a port + driver, a minport driver and a set of resources bound together. It will + also optionally place a pointer to an interface on the port driver in a + specified location before initializing the port driver. This is done so + that a common ISR can have access to the port driver during + initialization, when the ISR might fire. Arguments: Irp - pointer to the irp object. Name - name of the miniport. Passes to PcRegisterSubDevice - + PortClassId - port class id. Passed to PcNewPort. MiniportClassId - miniport class id. Passed to PcNewMiniport. - MiniportCreate - pointer to a miniport creation function. If NULL, + MiniportCreate - pointer to a miniport creation function. If NULL, PcNewMiniport is used. - + DeviceContext - deviceType specific. - MiniportPair - endpoint configuration info. + MiniportPair - endpoint configuration info. ResourceList - pointer to the resource list. PortInterfaceId - GUID that represents the port interface. - + OutPortInterface - pointer to store the port interface OutPortUnknown - pointer to store the unknown port interface. @@ -2045,9 +2045,9 @@ Return Value: { if (MiniportCreate) { - ntStatus = + ntStatus = MiniportCreate - ( + ( &miniport, MiniportClassId, NULL, @@ -2059,10 +2059,10 @@ Return Value: } else { - ntStatus = + ntStatus = PcNewMiniport ( - (PMINIPORT *) &miniport, + (PMINIPORT *) &miniport, MiniportClassId ); } @@ -2078,14 +2078,14 @@ Return Value: // still succeed. // #pragma warning(disable:6387) - ntStatus = + ntStatus = port->Init - ( + ( m_pDeviceObject, Irp, miniport, adapterCommon, - ResourceList + ResourceList ); #pragma warning (pop) @@ -2093,12 +2093,12 @@ Return Value: { // Register the subdevice (port/miniport combination). // - ntStatus = + ntStatus = PcRegisterSubdevice - ( + ( m_pDeviceObject, Name, - port + port ); } } @@ -2109,31 +2109,31 @@ Return Value: { if (OutPortUnknown) { - ntStatus = + ntStatus = port->QueryInterface - ( + ( IID_IUnknown, - (PVOID *)OutPortUnknown + (PVOID *)OutPortUnknown ); } if (OutPortInterface) { - ntStatus = + ntStatus = port->QueryInterface - ( + ( PortInterfaceId, - (PVOID *) OutPortInterface + (PVOID *) OutPortInterface ); } if (OutMiniportUnknown) { - ntStatus = + ntStatus = miniport->QueryInterface - ( + ( IID_IUnknown, - (PVOID *)OutMiniportUnknown + (PVOID *)OutMiniportUnknown ); } @@ -2179,10 +2179,10 @@ Return Value: DPF_ENTER(("[CAdapterCommon::UnregisterSubdevice]")); ASSERT(m_pDeviceObject != NULL); - + NTSTATUS ntStatus = STATUS_SUCCESS; PUNREGISTERSUBDEVICE unregisterSubdevice = NULL; - + if (NULL == UnknownPort) { return ntStatus; @@ -2191,7 +2191,7 @@ Return Value: // // Get the IUnregisterSubdevice interface. // - ntStatus = UnknownPort->QueryInterface( + ntStatus = UnknownPort->QueryInterface( IID_IUnregisterSubdevice, (PVOID *)&unregisterSubdevice); @@ -2209,7 +2209,7 @@ Return Value: // unregisterSubdevice->Release(); } - + return ntStatus; } @@ -2239,9 +2239,9 @@ Return Value: { PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::ConnectTopologies]")); - + ASSERT(m_pDeviceObject != NULL); - + NTSTATUS ntStatus = STATUS_SUCCESS; // @@ -2251,13 +2251,13 @@ Return Value: // for (ULONG i = 0; i < PhysicalConnectionCount && NT_SUCCESS(ntStatus); i++) { - + switch(PhysicalConnections[i].eType) { case CONNECTIONTYPE_TOPOLOGY_OUTPUT: ntStatus = PcRegisterPhysicalConnection - ( + ( m_pDeviceObject, UnknownTopology, PhysicalConnections[i].ulTopology, @@ -2272,7 +2272,7 @@ Return Value: case CONNECTIONTYPE_WAVE_OUTPUT: ntStatus = PcRegisterPhysicalConnection - ( + ( m_pDeviceObject, UnknownWave, PhysicalConnections[i].ulWave, @@ -2285,7 +2285,7 @@ Return Value: } break; } - } + } // // Cleanup in case of error. @@ -2326,9 +2326,9 @@ Return Value: { PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::DisconnectTopologies]")); - + ASSERT(m_pDeviceObject != NULL); - + NTSTATUS ntStatus = STATUS_SUCCESS; NTSTATUS ntStatus2 = STATUS_SUCCESS; PUNREGISTERPHYSICALCONNECTION unregisterPhysicalConnection = NULL; @@ -2336,12 +2336,12 @@ Return Value: // // Get the IUnregisterPhysicalConnection interface // - ntStatus = UnknownTopology->QueryInterface( + ntStatus = UnknownTopology->QueryInterface( IID_IUnregisterPhysicalConnection, (PVOID *)&unregisterPhysicalConnection); - + if (NT_SUCCESS(ntStatus)) - { + { for (ULONG i = 0; i < PhysicalConnectionCount; i++) { switch(PhysicalConnections[i].eType) @@ -2382,9 +2382,9 @@ Return Value: { ntStatus = ntStatus2; } - } + } } - + // // Release the IUnregisterPhysicalConnection interface. // @@ -2576,7 +2576,7 @@ CAdapterCommon::Cleanup() STDMETHODIMP_(NTSTATUS) CAdapterCommon::InstallEndpointFilters ( - _In_opt_ PIRP Irp, + _In_opt_ PIRP Irp, _In_ PENDPOINT_MINIPAIR MiniportPair, _In_opt_ PVOID DeviceContext, _Out_opt_ PUNKNOWN * UnknownTopology, @@ -2587,7 +2587,7 @@ CAdapterCommon::InstallEndpointFilters { PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::InstallEndpointFilters]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; PUNKNOWN unknownTopology = NULL; PUNKNOWN unknownWave = NULL; @@ -2606,7 +2606,7 @@ CAdapterCommon::InstallEndpointFilters { *UnknownWave = NULL; } - + if (UnknownMiniportTopology) { *UnknownMiniportTopology = NULL; @@ -2627,7 +2627,7 @@ CAdapterCommon::InstallEndpointFilters ntStatus = InstallSubdevice(Irp, MiniportPair->TopoName, // make sure this name matches with SYSVAD..szPname in the inf's [Strings] section CLSID_PortTopology, - CLSID_PortTopology, + CLSID_PortTopology, MiniportPair->TopoCreateCallback, MiniportPair->TopoInterfacePropertyCount, MiniportPair->TopoInterfaceProperties, @@ -2655,7 +2655,7 @@ CAdapterCommon::InstallEndpointFilters ntStatus = InstallSubdevice(Irp, MiniportPair->WaveName, // make sure this name matches with SYSVAD..szPname in the inf's [Strings] section CLSID_PortWaveRT, - CLSID_PortWaveRT, + CLSID_PortWaveRT, MiniportPair->WaveCreateCallback, MiniportPair->WaveInterfacePropertyCount, MiniportPair->WaveInterfaceProperties, @@ -2663,7 +2663,7 @@ CAdapterCommon::InstallEndpointFilters MiniportPair, NULL, IID_IPortWaveRT, - NULL, + NULL, &unknownWave, &unknownMiniWave ); @@ -2698,7 +2698,7 @@ CAdapterCommon::InstallEndpointFilters unknownTopology->AddRef(); *UnknownTopology = unknownTopology; } - + if (UnknownWave != NULL && unknownWave != NULL) { unknownWave->AddRef(); @@ -2724,14 +2724,14 @@ CAdapterCommon::InstallEndpointFilters UnregisterSubdevice(unknownTopology); RemoveCachedSubdevice(MiniportPair->TopoName); } - + if (bWaveCreated && unknownWave != NULL) { UnregisterSubdevice(unknownWave); RemoveCachedSubdevice(MiniportPair->WaveName); } } - + SAFE_RELEASE(unknownMiniTopo); SAFE_RELEASE(unknownTopology); SAFE_RELEASE(unknownMiniWave); @@ -2752,9 +2752,9 @@ CAdapterCommon::RemoveEndpointFilters { PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::RemoveEndpointFilters]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; - + if (UnknownTopology != NULL && UnknownWave != NULL) { ntStatus = DisconnectTopologies( @@ -2769,7 +2769,7 @@ CAdapterCommon::RemoveEndpointFilters } } - + RemoveCachedSubdevice(MiniportPair->WaveName); ntStatus = UnregisterSubdevice(UnknownWave); @@ -2790,7 +2790,7 @@ CAdapterCommon::RemoveEndpointFilters // All Done. // ntStatus = STATUS_SUCCESS; - + return ntStatus; } @@ -2808,8 +2808,8 @@ CAdapterCommon::GetFilters { PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::GetFilters]")); - - NTSTATUS ntStatus = STATUS_SUCCESS; + + NTSTATUS ntStatus = STATUS_SUCCESS; PUNKNOWN unknownTopologyPort = NULL; PUNKNOWN unknownTopologyMiniport = NULL; PUNKNOWN unknownWavePort = NULL; @@ -2866,7 +2866,7 @@ CAdapterCommon::SetIdlePowerManagement PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::SetIdlePowerManagement]")); - NTSTATUS ntStatus = STATUS_SUCCESS; + NTSTATUS ntStatus = STATUS_SUCCESS; IUnknown *pUnknown = NULL; PPORTCLSPOWER pPortClsPower = NULL; // refcounting disable requests. Each miniport is responsible for calling this in pairs, @@ -2878,7 +2878,7 @@ CAdapterCommon::SetIdlePowerManagement ntStatus = GetFilters(MiniportPair, NULL, NULL, &pUnknown, NULL); if (NT_SUCCESS(ntStatus)) { - ntStatus = + ntStatus = pUnknown->QueryInterface ( IID_IPortClsPower, @@ -2935,15 +2935,15 @@ Routine Description: Arguments: WorkItem - WDF work-item object. - + --*/ { PAGED_CODE(); DPF_ENTER(("[EvtBthHfpScoBypassInterfaceWorkItem]")); CAdapterCommon * This; - - if (WorkItem == NULL) + + if (WorkItem == NULL) { return; } @@ -2955,7 +2955,7 @@ Arguments: { PLIST_ENTRY le = NULL; BthHfpWorkTask * task = NULL; - + // // Retrieve a taask. // @@ -2967,7 +2967,7 @@ Arguments: InitializeListHead(le); } ExReleaseFastMutex(&This->m_BthHfpFastMutex); - + if (task == NULL) { break; @@ -2975,7 +2975,7 @@ Arguments: ASSERT(task->Device != NULL); _Analysis_assume_(task->Device != NULL); - + // // Process the task. // @@ -3023,7 +3023,7 @@ Routine Description: Arguments: SymbolicLinkName - interface's symbolic link. - + Return Value: BthHfpDevice pointer or NULL. @@ -3032,17 +3032,17 @@ Return Value: { PAGED_CODE(); DPF_ENTER(("[CAdapterCommon::BthHfpDeviceFind]")); - + PLIST_ENTRY le = NULL; BthHfpDevice * bthDevice = NULL; ExAcquireFastMutex(&m_BthHfpFastMutex); - + for (le = m_BthHfpDevices.Flink; le != &m_BthHfpDevices; le = le->Flink) { BthHfpDevice * tmpBthDevice = BthHfpDevice::GetBthHfpDevice(le); ASSERT(tmpBthDevice != NULL); - + PUNICODE_STRING unicodeStr = tmpBthDevice->GetSymbolicLinkName(); ASSERT(unicodeStr != NULL); @@ -3055,7 +3055,7 @@ Return Value: break; } } - + ExReleaseFastMutex(&m_BthHfpFastMutex); return bthDevice; @@ -3077,7 +3077,7 @@ Routine Description: Arguments: SymbolicLinkName - new interface's symbolic link. - + Return Value: NT status code. @@ -3090,7 +3090,7 @@ Return Value: NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDevice * bthDevice = NULL; BthHfpWorkTask * bthWorkTask = NULL; - + DPF(D_VERBOSE, ("BthHfpScoInterfaceArrival: SymbolicLinkName %wZ", SymbolicLinkName)); // @@ -3106,7 +3106,7 @@ Return Value: ntStatus = STATUS_SUCCESS; goto Done; } - + // // Alloc a new structure for this Bluetooth hands-free device. // @@ -3117,9 +3117,9 @@ Return Value: ntStatus = STATUS_INSUFFICIENT_RESOURCES; goto Done; } - + DPF(D_VERBOSE, ("BthHfpScoInterfaceArrival: created BthHfpDevice 0x%p ", bthDevice)); - + // // Basic initialization of the Bluetooth Hands-Free Profile interface. // The audio miniport creation is done later by the BthHfpDevice.Start() @@ -3139,7 +3139,7 @@ Return Value: ntStatus = STATUS_INSUFFICIENT_RESOURCES; goto Done; } - + // bthWorkTask->L.Size is set to sizeof(BthHfpWorkTask) in the Look Aside List configuration #pragma warning(suppress: 6386) RtlZeroMemory(bthWorkTask, sizeof(*bthWorkTask)); @@ -3147,9 +3147,9 @@ Return Value: InitializeListHead(&bthWorkTask->ListEntry); // Note that bthDevice has one reference at this point. bthWorkTask->Device = bthDevice; - + ExAcquireFastMutex(&m_BthHfpFastMutex); - + // // Insert this new Bluetooth HFP device in our list. // @@ -3165,13 +3165,13 @@ Return Value: // Schedule a work-item if not already running. // WdfWorkItemEnqueue(m_BthHfpWorkItem); - + ExReleaseFastMutex(&m_BthHfpFastMutex); Done: if (!NT_SUCCESS(ntStatus)) { - // Release the last ref, this will delete the BthHfpDevice + // Release the last ref, this will delete the BthHfpDevice SAFE_RELEASE(bthDevice); if (bthWorkTask != NULL) @@ -3180,7 +3180,7 @@ Done: bthWorkTask = NULL; } } - + return ntStatus; } @@ -3200,7 +3200,7 @@ Routine Description: Arguments: SymbolicLinkName - interface's symbolic link to remove. - + Return Value: NT status code. @@ -3213,7 +3213,7 @@ Return Value: NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDevice * bthDevice = NULL; BthHfpWorkTask * bthWorkTask = NULL; - + DPF(D_VERBOSE, ("BthHfpScoInterfaceRemoval: SymbolicLinkName %wZ", SymbolicLinkName)); // @@ -3227,7 +3227,7 @@ Return Value: ntStatus = STATUS_SUCCESS; goto Done; } - + // // Init a work task. // @@ -3238,7 +3238,7 @@ Return Value: ntStatus = STATUS_INSUFFICIENT_RESOURCES; goto Done; } - + // bthWorkTask->L.Size is set to sizeof(BthHfpWorkTask) in the Look Aside List configuration #pragma warning(suppress: 6386) RtlZeroMemory(bthWorkTask, sizeof(*bthWorkTask)); @@ -3248,7 +3248,7 @@ Return Value: bthWorkTask->Device = bthDevice; ExAcquireFastMutex(&m_BthHfpFastMutex); - + // // Remove this Bluetooth device from our list and release the associated reference. // @@ -3265,7 +3265,7 @@ Return Value: // Schedule a work-item if not already running. // WdfWorkItemEnqueue(m_BthHfpWorkItem); - + ExReleaseFastMutex(&m_BthHfpFastMutex); // @@ -3280,7 +3280,7 @@ Done: // Release the ref we got in find. SAFE_RELEASE(bthDevice); } - + return ntStatus; } @@ -3298,9 +3298,9 @@ Routine Description: This callback is invoked when a new HFP SCO Bypass interface is added or removed. Arguments: - NotificationPointer - Interface change notification + NotificationPointer - Interface change notification Context - CAdapterCommon ptr. - + Return Value: NT status code. @@ -3309,32 +3309,32 @@ Return Value: { PAGED_CODE(); DPF_ENTER(("[EvtBthHfpScoBypassInterfaceChange]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; CAdapterCommon * This = NULL; PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification = (PDEVICE_INTERFACE_CHANGE_NOTIFICATION) NotificationPointer; - + // // Make sure this is the interface class we extect. Any other class guid // is an error, but let it go since it is not fatal to the machine. // - if (!IsEqualGUID(Notification->InterfaceClassGuid, GUID_DEVINTERFACE_BLUETOOTH_HFP_SCO_HCIBYPASS)) + if (!IsEqualGUID(Notification->InterfaceClassGuid, GUID_DEVINTERFACE_BLUETOOTH_HFP_SCO_HCIBYPASS)) { DPF(D_VERBOSE, ("EvtBthHfpScoBypassInterfaceChange: bad interface ClassGuid")); ASSERTMSG("EvtBthHfpScoBypassInterfaceChange: bad interface ClassGuid ", FALSE); - + goto Done; } This = (CAdapterCommon *)Context; ASSERT(This != NULL); _Analysis_assume_(This != NULL); - + // - // Take action based on the event. Any other event type is an error, + // Take action based on the event. Any other event type is an error, // but let it go since it is not fatal to the machine. // - if (IsEqualGUID(Notification->Event, GUID_DEVICE_INTERFACE_ARRIVAL)) + if (IsEqualGUID(Notification->Event, GUID_DEVICE_INTERFACE_ARRIVAL)) { ntStatus = This->BthHfpScoInterfaceArrival(Notification->SymbolicLinkName); } @@ -3342,13 +3342,13 @@ Return Value: { ntStatus = This->BthHfpScoInterfaceRemoval(Notification->SymbolicLinkName); } - else + else { DPF(D_VERBOSE, ("EvtBthHfpScoBypassInterfaceChange: bad " "GUID_DEVINTERFACE_BLUETOOTH_HFP_SCO_HCIBYPASS event")); ASSERTMSG("EvtBthHfpScoBypassInterfaceChange: bad " "GUID_DEVINTERFACE_BLUETOOTH_HFP_SCO_HCIBYPASS event ", FALSE); - + goto Done; } @@ -3379,7 +3379,7 @@ Return Value: WDF_WORKITEM_CONFIG wiConfig; WDF_OBJECT_ATTRIBUTES attributes; BthHfpWorkItemContext * wiContext; - + // // Init spin-lock, linked lists, work-item, event, etc. // Init all members to default values. This basic init should not fail. @@ -3396,7 +3396,7 @@ Return Value: POOL_NX_ALLOCATION, m_BhtHfpWorkTaskPoolElementSize, MINADAPTER_POOLTAG, - 0); + 0); // // Enable Bluetooth HFP SCO-Bypass Cleanup. // Do any allocation/initialization that can fail after this point. @@ -3421,7 +3421,7 @@ Return Value: wiContext = GetBthHfpWorkItemContext(m_BthHfpWorkItem); wiContext->Adapter = this; // weak ref. - + // // Register for bluetooth heandsfree profile interface changes. // @@ -3470,7 +3470,7 @@ Routine Description: { return; } - + // // Unregister for bluetooth heandsfree profile interface changes. // @@ -3489,20 +3489,20 @@ Routine Description: WdfObjectDelete(m_BthHfpWorkItem); m_BthHfpWorkItem = NULL; } - + ASSERT(IsListEmpty(&m_BthHfpWorkTasks)); - + // - // Stop and delete all BthHfpDevices. We are the only thread accessing this list, + // Stop and delete all BthHfpDevices. We are the only thread accessing this list, // so there is no need to acquire the mutex. // while (!IsListEmpty(&m_BthHfpDevices)) { BthHfpDevice * bthDevice = NULL; PLIST_ENTRY le = NULL; - + le = RemoveHeadList(&m_BthHfpDevices); - + bthDevice = BthHfpDevice::GetBthHfpDevice(le); InitializeListHead(le); @@ -3512,9 +3512,9 @@ Routine Description: // This should be the last reference. bthDevice->Release(); } - + ASSERT(IsListEmpty(&m_BthHfpDevices)); - + // // General cleanup. // @@ -3531,9 +3531,9 @@ Routine Description: #pragma code_seg("PAGE") STDMETHODIMP BthHfpDevice::NonDelegatingQueryInterface -( +( _In_ REFIID Interface, - _COM_Outptr_ PVOID * Object + _COM_Outptr_ PVOID * Object ) /*++ @@ -3543,7 +3543,7 @@ Routine Description: Arguments: - Interface - + Interface - Object - @@ -3580,7 +3580,7 @@ Return Value: } // NonDelegatingQueryInterface //============================================================================= -// Dummy stubs to override the default WDF behavior of closing the target +// Dummy stubs to override the default WDF behavior of closing the target // on query remove. This driver closes and deletes the supporting objects // when the target removes the BTH HFP SCO Bypass interface. // @@ -3588,13 +3588,13 @@ Return Value: #pragma code_seg("PAGE") NTSTATUS BthHfpDevice::EvtBthHfpTargetQueryRemove -( +( _In_ WDFIOTARGET IoTarget ) { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::EvtBthHfpTargetQueryRemove]")); - + UNREFERENCED_PARAMETER(IoTarget); return STATUS_SUCCESS; } @@ -3602,25 +3602,25 @@ BthHfpDevice::EvtBthHfpTargetQueryRemove #pragma code_seg("PAGE") VOID BthHfpDevice::EvtBthHfpTargetRemoveCanceled -( +( _In_ WDFIOTARGET IoTarget ) { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::EvtBthHfpTargetRemoveCanceled]")); - + UNREFERENCED_PARAMETER(IoTarget); } #pragma code_seg("PAGE") VOID BthHfpDevice::EvtBthHfpTargetRemoveComplete -( +( _In_ WDFIOTARGET IoTarget ) { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::EvtBthHfpTargetRemoveComplete]")); - + UNREFERENCED_PARAMETER(IoTarget); } @@ -3629,7 +3629,7 @@ BthHfpDevice::EvtBthHfpTargetRemoveComplete NTSTATUS BthHfpDevice::Init ( - _In_ CAdapterCommon * Adapter, + _In_ CAdapterCommon * Adapter, _In_ PUNICODE_STRING SymbolicLinkName ) { @@ -3644,7 +3644,7 @@ BthHfpDevice::Init WDF_WORKITEM_CONFIG wiConfig; AddRef(); // first ref. - + // // Basic init of all the class' members. // @@ -3662,13 +3662,13 @@ BthHfpDevice::Init m_Descriptor = NULL; m_VolumePropValues = NULL; - // Notification updates. + // Notification updates. m_SpeakerVolumeLevel = 0; m_MicVolumeLevel = 0; m_ConnectionStatusLong = FALSE; m_StreamStatusLong = STATUS_INVALID_DEVICE_STATE; // Sco stream is not open. m_NRECDisableStatusLong = FALSE; - + m_StreamReq = NULL; m_SpeakerVolumeReq = NULL; m_MicVolumeReq = NULL; @@ -3677,21 +3677,21 @@ BthHfpDevice::Init m_WorkItem = NULL; m_ReqCollection = NULL; - + m_nStreams = 0; KeInitializeEvent(&m_StreamStatusEvent, NotificationEvent, TRUE); InitializeListHead(&m_ListEntry); KeInitializeSpinLock(&m_Lock); - + RtlZeroMemory(&m_SymbolicLinkName, sizeof(m_SymbolicLinkName)); - + RtlZeroMemory(&m_SpeakerVolumeCallback, sizeof(m_SpeakerVolumeCallback)); RtlZeroMemory(&m_SpeakerConnectionStatusCallback, sizeof(m_SpeakerConnectionStatusCallback)); RtlZeroMemory(&m_MicVolumeCallback, sizeof(m_MicVolumeCallback)); RtlZeroMemory(&m_MicConnectionStatusCallback, sizeof(m_MicConnectionStatusCallback)); - + // // Allocate a notification WDF work-item. // @@ -3719,12 +3719,12 @@ BthHfpDevice::Init ntStatus = WdfCollectionCreate( &attributes, &m_ReqCollection); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Init: WdfCollectionCreate failed: 0x%x", ntStatus)), Done); - + // // Open the target interface. // @@ -3741,18 +3741,18 @@ BthHfpDevice::Init WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME( &openParams, SymbolicLinkName, - STANDARD_RIGHTS_ALL); - + STANDARD_RIGHTS_ALL); + openParams.EvtIoTargetQueryRemove = EvtBthHfpTargetQueryRemove; openParams.EvtIoTargetRemoveCanceled = EvtBthHfpTargetRemoveCanceled; openParams.EvtIoTargetRemoveComplete = EvtBthHfpTargetRemoveComplete; - + ntStatus = WdfIoTargetOpen(m_WdfIoTarget, &openParams); IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Init: WdfIoTargetOpen(%wZ) failed: 0x%x", SymbolicLinkName, ntStatus)), Done); - + // // Make a copy of the symbolic link name. // @@ -3765,20 +3765,20 @@ BthHfpDevice::Init { ntStatus = STATUS_INSUFFICIENT_RESOURCES; } - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Init: ExAllocatePoolWithTag failed, out of memory")), Done); - + RtlCopyUnicodeString(&m_SymbolicLinkName, SymbolicLinkName); // // Allocate the WDF requests for status notifications. // - + // - // IOCTL_BTHHFP_DEVICE_GET_NRECDISABLE_STATUS_UPDATE + // IOCTL_BTHHFP_DEVICE_GET_NRECDISABLE_STATUS_UPDATE // WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, BthHfpDeviceNotificationReqContext); attributes.ParentObject = m_Adapter->GetWdfDevice(); @@ -3794,7 +3794,7 @@ BthHfpDevice::Init // Init context. reqCtx = GetBthHfpDeviceNotificationReqContext(m_NRECDisableStatusReq); reqCtx->BthHfpDevice = this; // weak ref. - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3804,7 +3804,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3814,9 +3814,9 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + // - // IOCTL_BTHHFP_SPEAKER_GET_VOLUME_STATUS_UPDATE + // IOCTL_BTHHFP_SPEAKER_GET_VOLUME_STATUS_UPDATE // WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, BthHfpDeviceNotificationReqContext); attributes.ParentObject = m_Adapter->GetWdfDevice(); @@ -3832,7 +3832,7 @@ BthHfpDevice::Init // Init context. reqCtx = GetBthHfpDeviceNotificationReqContext(m_SpeakerVolumeReq); reqCtx->BthHfpDevice = this; // weak ref. - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3842,7 +3842,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3852,7 +3852,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + // // IOCTL_BTHHFP_MIC_GET_VOLUME_STATUS_UPDATE // @@ -3866,11 +3866,11 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfRequestCreate(Mic-Volume) failed, 0x%x", ntStatus)), Done); - + // Init context. reqCtx = GetBthHfpDeviceNotificationReqContext(m_MicVolumeReq); reqCtx->BthHfpDevice = this; // weak ref. - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3880,7 +3880,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3890,7 +3890,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + // // IOCTL_BTHHFP_DEVICE_GET_CONNECTION_STATUS_UPDATE // @@ -3904,11 +3904,11 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfRequestCreate(Connection-Status) failed, 0x%x", ntStatus)), Done); - + // Init context. reqCtx = GetBthHfpDeviceNotificationReqContext(m_ConnectionReq); reqCtx->BthHfpDevice = this; // weak ref. - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3918,7 +3918,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3928,7 +3928,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + // // IOCTL_BTHHFP_STREAM_GET_STATUS_UPDATE // @@ -3942,11 +3942,11 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfRequestCreate(Stream-Status) failed, 0x%x", ntStatus)), Done); - + // Init context. reqCtx = GetBthHfpDeviceNotificationReqContext(m_StreamReq); reqCtx->BthHfpDevice = this; // weak ref. - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3956,7 +3956,7 @@ BthHfpDevice::Init ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), Done); - + ntStatus = WdfMemoryCreatePreallocated( WDF_NO_OBJECT_ATTRIBUTES, &reqCtx->Buffer, @@ -3965,14 +3965,14 @@ BthHfpDevice::Init IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Init: WdfMemoryCreatePreallocated failed, 0x%x", ntStatus)), - Done); - + Done); + // // This remote device is now in running state. No need to use interlock operations // b/c at this time this is the only thread accessing this info. // m_State = eBthHfpStateRunning; - + // // Init successful. // @@ -3985,8 +3985,8 @@ Done: //============================================================================= #pragma code_seg("PAGE") BthHfpDevice::~BthHfpDevice -( - void +( + void ) /*++ @@ -4007,7 +4007,7 @@ Return Value: ASSERT(m_State != eBthHfpStateRunning); ASSERT(IsListEmpty(&m_ListEntry)); - + // // Release ref to remote stack. // @@ -4058,7 +4058,7 @@ Return Value: WdfObjectDelete(ctx->MemIn); ctx->MemIn = NULL; } - + if (ctx->MemOut != NULL) { WdfObjectDelete(ctx->MemOut); @@ -4069,7 +4069,7 @@ Return Value: WdfObjectDelete(m_SpeakerVolumeReq); m_SpeakerVolumeReq = NULL; } - + if (m_MicVolumeReq != NULL) { BthHfpDeviceNotificationReqContext * ctx; @@ -4081,7 +4081,7 @@ Return Value: WdfObjectDelete(ctx->MemIn); ctx->MemIn = NULL; } - + if (ctx->MemOut != NULL) { WdfObjectDelete(ctx->MemOut); @@ -4092,7 +4092,7 @@ Return Value: WdfObjectDelete(m_MicVolumeReq); m_MicVolumeReq = NULL; } - + if (m_ConnectionReq != NULL) { BthHfpDeviceNotificationReqContext * ctx; @@ -4104,7 +4104,7 @@ Return Value: WdfObjectDelete(ctx->MemIn); ctx->MemIn = NULL; } - + if (ctx->MemOut != NULL) { WdfObjectDelete(ctx->MemOut); @@ -4115,7 +4115,7 @@ Return Value: WdfObjectDelete(m_ConnectionReq); m_ConnectionReq = NULL; } - + if (m_StreamReq != NULL) { BthHfpDeviceNotificationReqContext * ctx; @@ -4127,7 +4127,7 @@ Return Value: WdfObjectDelete(ctx->MemIn); ctx->MemIn = NULL; } - + if (ctx->MemOut != NULL) { WdfObjectDelete(ctx->MemOut); @@ -4159,13 +4159,13 @@ Return Value: ASSERT(m_UnknownSpeakerTopology == NULL); SAFE_RELEASE(m_UnknownSpeakerTopology); - + ASSERT(m_UnknownSpeakerWave == NULL); SAFE_RELEASE(m_UnknownSpeakerWave); - + ASSERT(m_UnknownMicTopology == NULL); SAFE_RELEASE(m_UnknownMicTopology); - + ASSERT(m_UnknownMicWave == NULL); SAFE_RELEASE(m_UnknownMicWave); @@ -4175,10 +4175,10 @@ Return Value: ASSERT(m_SpeakerConnectionStatusCallback.Handler == NULL); ASSERT(m_MicVolumeCallback.Handler == NULL); ASSERT(m_MicConnectionStatusCallback.Handler == NULL); -} // ~CAdapterCommon +} // ~CAdapterCommon // -// IBthHfpDeviceCommon implementation. +// IBthHfpDeviceCommon implementation. // //============================================================================= @@ -4188,7 +4188,7 @@ BthHfpDevice::IsVolumeSupported() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::IsVolumeSupported]")); - + return m_Descriptor->SupportsVolume; } @@ -4197,16 +4197,16 @@ BthHfpDevice::IsVolumeSupported() PKSPROPERTY_VALUES BthHfpDevice::GetVolumeSettings ( - _Out_ PULONG Size + _Out_ PULONG Size ) { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetVolumeSettings]")); ASSERT(Size != NULL); - + *Size = m_Descriptor->VolumePropertyValuesSize; - + return m_VolumePropValues; } @@ -4217,7 +4217,7 @@ BthHfpDevice::GetSpeakerVolume() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetSpeakerVolume]")); - + return InterlockedCompareExchange(&m_SpeakerVolumeLevel, 0, 0); } @@ -4231,7 +4231,7 @@ BthHfpDevice::SetSpeakerVolume { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetSpeakerVolume]")); - + return SetBthHfpSpeakerVolume(Volume); } @@ -4242,7 +4242,7 @@ BthHfpDevice::GetMicVolume() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetMicVolume]")); - + return InterlockedCompareExchange(&m_MicVolumeLevel, 0, 0); } @@ -4256,7 +4256,7 @@ BthHfpDevice::SetMicVolume { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetMicVolume]")); - + return SetBthHfpMicVolume(Volume); } @@ -4267,7 +4267,7 @@ BthHfpDevice::GetConnectionStatus() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetConnectionStatus]")); - + return (BOOL)InterlockedCompareExchange(&m_ConnectionStatusLong, 0, 0); } @@ -4333,7 +4333,7 @@ BthHfpDevice::Connect() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::Connect]")); - + return SetBthHfpConnect(); } @@ -4344,7 +4344,7 @@ BthHfpDevice::Disconnect() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::Disconnect]")); - + return SetBthHfpDisconnect(); } @@ -4374,12 +4374,12 @@ BthHfpDevice::StreamOpen() LONG nStreams = 0; ASSERT(m_nStreams >= 0); - + nStreams = InterlockedIncrement(&m_nStreams); if (nStreams == 1) { BOOLEAN streamOpen = FALSE; - + ntStatus = SetBthHfpStreamOpen(); if (NT_SUCCESS(ntStatus)) { @@ -4416,19 +4416,19 @@ BthHfpDevice::StreamClose() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::StreamClose]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; LONG nStreams = 0; ASSERT(m_nStreams > 0); - + nStreams = InterlockedDecrement(&m_nStreams); if (nStreams == 0) { ntStatus = SetBthHfpStreamClose(); - + StopBthHfpStreamStatusNotification(); - + m_StreamStatus = STATUS_INVALID_DEVICE_STATE; } @@ -4442,7 +4442,7 @@ BthHfpDevice::GetContainerId() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetContainerId]")); - + return m_Descriptor->ContainerId; } @@ -4459,7 +4459,7 @@ BthHfpDevice::SetSpeakerVolumeHandler DPF_ENTER(("[BthHfpDevice::SetSpeakerVolumeHandler]")); ASSERT(EventHandler == NULL || m_SpeakerVolumeCallback.Handler == NULL); - + m_SpeakerVolumeCallback.Handler = EventHandler; // weak ref. m_SpeakerVolumeCallback.Context = EventHandlerContext; } @@ -4475,9 +4475,9 @@ BthHfpDevice::SetSpeakerConnectionStatusHandler { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetSpeakerConnectionStatusHandler]")); - + ASSERT(EventHandler == NULL || m_SpeakerConnectionStatusCallback.Handler == NULL); - + m_SpeakerConnectionStatusCallback.Handler = EventHandler; // weak ref. m_SpeakerConnectionStatusCallback.Context = EventHandlerContext; } @@ -4493,9 +4493,9 @@ BthHfpDevice::SetMicVolumeHandler { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetMicVolumeHandler]")); - + ASSERT(EventHandler == NULL || m_MicVolumeCallback.Handler == NULL); - + m_MicVolumeCallback.Handler = EventHandler; // weak ref. m_MicVolumeCallback.Context = EventHandlerContext; } @@ -4511,9 +4511,9 @@ BthHfpDevice::SetMicConnectionStatusHandler { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetMicConnectionStatusHandler]")); - + ASSERT(EventHandler == NULL || m_MicConnectionStatusCallback.Handler == NULL); - + m_MicConnectionStatusCallback.Handler = EventHandler; // weak ref. m_MicConnectionStatusCallback.Context = EventHandlerContext; } @@ -4525,7 +4525,7 @@ BthHfpDevice::IsNRECSupported() { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::IsNRECSupported]")); - + return m_Descriptor->SupportsNREC; } @@ -4547,7 +4547,7 @@ BthHfpDevice::GetNRECDisableStatus() //============================================================================= #pragma code_seg() -NTSTATUS +NTSTATUS BthHfpDevice::SendIoCtrlAsynchronously ( _In_ WDFREQUEST Request, @@ -4567,7 +4567,7 @@ Routine Description: --*/ { DPF_ENTER(("[BthHfpDevice::SendIoCtrlAsynchronously]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BOOLEAN fSent = FALSE; @@ -4601,7 +4601,7 @@ Routine Description: { ntStatus = STATUS_INVALID_DEVICE_STATE; } - + DPF(D_ERROR, ("SendIoCtrlAsynchronously: WdfRequestSend(0x%x) failed, 0x%x", IoControlCode, ntStatus)); goto Done; } @@ -4618,7 +4618,7 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::SendIoCtrlSynchronously ( _In_opt_ WDFREQUEST Request, @@ -4640,7 +4640,7 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SendIoCtrlSynchronously]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; PWDF_MEMORY_DESCRIPTOR memInPtr = NULL; PWDF_MEMORY_DESCRIPTOR memOutPtr = NULL; @@ -4662,14 +4662,14 @@ Routine Description: WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&memOut, Buffer, OutLength); memOutPtr = &memOut; } - + WDF_REQUEST_SEND_OPTIONS_INIT( - &reqOpts, - WDF_REQUEST_SEND_OPTION_TIMEOUT | + &reqOpts, + WDF_REQUEST_SEND_OPTION_TIMEOUT | WDF_REQUEST_SEND_OPTION_SYNCHRONOUS); reqOpts.Timeout = WDF_REL_TIMEOUT_IN_SEC(BTH_HFP_SYNC_REQ_TIMEOUT_IN_SEC); - + ntStatus = WdfIoTargetSendIoctlSynchronously( m_WdfIoTarget, Request, @@ -4678,7 +4678,7 @@ Routine Description: memOutPtr, &reqOpts, NULL); // bytes returned. - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_VERBOSE, ("SendIoCtrlSynchronously: WdfIoTargetSendIoctlSynchronously(0x%x) failed, 0x%x", IoControlCode, ntStatus)), @@ -4705,7 +4705,7 @@ Routine Description: Arguments: WorkItem - WDF work-item object. - + --*/ { DPF_ENTER(("[BthHfpDevice::EvtBthHfpDeviceNotificationStatusWorkItem]")); @@ -4713,8 +4713,8 @@ Arguments: NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDevice * This; KIRQL oldIrql; - - if (WorkItem == NULL) + + if (WorkItem == NULL) { return; } @@ -4724,11 +4724,11 @@ Arguments: for (;;) { - BOOL resend = TRUE; + BOOL resend = TRUE; WDFREQUEST req = NULL; BthHfpDeviceNotificationReqContext * reqCtx; WDF_REQUEST_COMPLETION_PARAMS params; - + // // Retrieve a task. // @@ -4750,10 +4750,10 @@ Arguments: // WDF_REQUEST_COMPLETION_PARAMS_INIT(¶ms); WdfRequestGetCompletionParams(req, ¶ms); - + reqCtx = GetBthHfpDeviceNotificationReqContext(req); ASSERT(reqCtx != NULL); - + // // Handle this notification. // @@ -4766,7 +4766,7 @@ Arguments: InterlockedExchange(&This->m_NRECDisableStatusLong, (LONG)reqCtx->Buffer.BoolStatus); } break; - + case IOCTL_BTHHFP_SPEAKER_GET_VOLUME_STATUS_UPDATE: { LONG oldVolume; @@ -4783,7 +4783,7 @@ Arguments: } } break; - + case IOCTL_BTHHFP_MIC_GET_VOLUME_STATUS_UPDATE: { LONG oldVolume; @@ -4814,7 +4814,7 @@ Arguments: This->m_SpeakerConnectionStatusCallback.Handler( This->m_SpeakerConnectionStatusCallback.Context); } - + if (This->m_MicConnectionStatusCallback.Handler != NULL) { This->m_MicConnectionStatusCallback.Handler( @@ -4827,7 +4827,7 @@ Arguments: default: // This should never happen. resend = FALSE; - DPF(D_ERROR, ("EvtBthHfpDeviceNotificationStatusWorkItem: invalid request ctrl 0x%x", + DPF(D_ERROR, ("EvtBthHfpDeviceNotificationStatusWorkItem: invalid request ctrl 0x%x", params.Parameters.Ioctl.IoControlCode)); break; } @@ -4836,19 +4836,19 @@ Arguments: if (resend) { WDF_REQUEST_REUSE_PARAMS reuseParams; - + WDF_REQUEST_REUSE_PARAMS_INIT( - &reuseParams, + &reuseParams, WDF_REQUEST_REUSE_NO_FLAGS, STATUS_SUCCESS); - + ntStatus = WdfRequestReuse(req, &reuseParams); if (!NT_SUCCESS(ntStatus)) { DPF(D_ERROR, ("EvtBthHfpDeviceNotificationStatusWorkItem: WdfRequestReuse failed, 0x%x", ntStatus)); break; } - + // Resend status notification request. reqCtx->Buffer.bImmediate = FALSE; @@ -4859,11 +4859,11 @@ Arguments: reqCtx->MemOut, EvtBthHfpDeviceNotificationStatusCompletion, This); - + if (!NT_SUCCESS(ntStatus)) { DPF(D_ERROR, ("EvtBthHfpDeviceNotificationStatusWorkItem: SendIoCtrlAsynchronously" - "(0x%x) failed, 0x%x", + "(0x%x) failed, 0x%x", params.Parameters.Ioctl.IoControlCode, ntStatus)); break; } @@ -4873,7 +4873,7 @@ Arguments: //============================================================================= #pragma code_seg() -void +void BthHfpDevice::EvtBthHfpDeviceNotificationStatusCompletion ( _In_ WDFREQUEST Request, @@ -4883,15 +4883,15 @@ BthHfpDevice::EvtBthHfpDeviceNotificationStatusCompletion ) { DPF_ENTER(("[BthHfpDevice::EvtBthHfpDeviceNotificationStatusCompletion]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * ctx = NULL; BthHfpDevice * This = NULL; KIRQL oldIrql; - + UNREFERENCED_PARAMETER(Target); UNREFERENCED_PARAMETER(Context); - + ctx = GetBthHfpDeviceNotificationReqContext(Request); This = ctx->BthHfpDevice; ASSERT(This != NULL); @@ -4920,7 +4920,7 @@ BthHfpDevice::EvtBthHfpDeviceNotificationStatusCompletion ctx->Errors = 0; } - // + // // Let the work-item thread process this request. // KeAcquireSpinLock(&This->m_Lock, &oldIrql); @@ -4938,7 +4938,7 @@ Done:; //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::GetBthHfpDescriptor ( _Out_ PBTHHFP_DESCRIPTOR2 * Descriptor @@ -4954,15 +4954,15 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetBthHfpDescriptor]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; WDFREQUEST req = NULL; PBTHHFP_DESCRIPTOR2 descriptor = NULL; ULONG length = 0; ULONG_PTR information = 0; - WDF_REQUEST_REUSE_PARAMS reuseParams; + WDF_REQUEST_REUSE_PARAMS reuseParams; WDF_OBJECT_ATTRIBUTES attributes; - + *Descriptor = NULL; // @@ -4988,30 +4988,30 @@ Routine Description: NULL, NULL, NULL); - + if (ntStatus != STATUS_BUFFER_TOO_SMALL) { if (NT_SUCCESS(ntStatus)) { ntStatus = STATUS_INVALID_DEVICE_STATE; } - + DPF(D_ERROR, ("GetBthHfpDescriptor: SendIoCtrlSynchronously(IOCTL_BTHHFP_DEVICE_GET_DESCRIPTOR2): failed, 0x%x", ntStatus)); goto Done; } - + ntStatus = STATUS_SUCCESS; information = WdfRequestGetInformation(req); if (information == 0 || information > ULONG_MAX) { - ntStatus = STATUS_INVALID_DEVICE_STATE; + ntStatus = STATUS_INVALID_DEVICE_STATE; DPF(D_ERROR, ("GetBthHfpDescriptor: IOCTL_BTHHFP_DEVICE_GET_DESCRIPTOR2 buffer too big (%Id): 0x%x", information, ntStatus)); goto Done; } length = (ULONG)information; - + // // Allocate memory needed to hold the info. // @@ -5029,16 +5029,16 @@ Routine Description: // Get the Bth HFP SCO Bypass descriptor. // WDF_REQUEST_REUSE_PARAMS_INIT( - &reuseParams, + &reuseParams, WDF_REQUEST_REUSE_NO_FLAGS, STATUS_SUCCESS); - + ntStatus = WdfRequestReuse(req, &reuseParams); IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("GetBthHfpDescriptor: WdfRequestReuse failed, 0x%x", ntStatus)), Done); - + ntStatus = SendIoCtrlSynchronously( req, IOCTL_BTHHFP_DEVICE_GET_DESCRIPTOR2, @@ -5055,14 +5055,14 @@ Routine Description: // *Descriptor = descriptor; ntStatus = STATUS_SUCCESS; - + Done: if (!NT_SUCCESS(ntStatus)) { if (descriptor != NULL) { ExFreePoolWithTag(descriptor, MINADAPTER_POOLTAG); - } + } } if (req != NULL) @@ -5070,25 +5070,25 @@ Done: WdfObjectDelete(req); req = NULL; } - + return ntStatus; } //============================================================================= #pragma code_seg() -NTSTATUS +NTSTATUS BthHfpDevice::EnableBthHfpNrecDisableStatusNotification() /*++ Routine Description: - This function registers for Bluetooth Hands-Free Profile SCO Bypass NREC-Disable - status change notification. + This function registers for Bluetooth Hands-Free Profile SCO Bypass NREC-Disable + status change notification. --*/ { DPF_ENTER(("[BthHfpDevice::EnableBthHfpNrecDisableStatusNotification]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * ctx = NULL; @@ -5097,8 +5097,8 @@ Routine Description: // // This is a notification request. // - ctx->Buffer.bImmediate = FALSE; - + ctx->Buffer.bImmediate = FALSE; + // // Get the Bth HFP SCO Bypass NREC-Disable status (async). // @@ -5109,7 +5109,7 @@ Routine Description: ctx->MemOut, EvtBthHfpDeviceNotificationStatusCompletion, this); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("EnableBthHfpNrecDisableStatusNotification: SendIoCtrlAsynchronously(IOCTL_BTHHFP_DEVICE_GET_NRECDISABLE_STATUS_UPDATE) failed, 0x%x", ntStatus)), @@ -5119,7 +5119,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5127,7 +5127,7 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::GetBthHfpVolumePropertyValues ( _In_ ULONG Length, @@ -5144,10 +5144,10 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetBthHfpVolumePropertyValues]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; PKSPROPERTY_VALUES propValues = NULL; - + *PropValues = NULL; // @@ -5168,11 +5168,11 @@ Routine Description: // ntStatus = SendIoCtrlSynchronously( NULL, - IOCTL_BTHHFP_DEVICE_GET_VOLUMEPROPERTYVALUES, - 0, - Length, + IOCTL_BTHHFP_DEVICE_GET_VOLUMEPROPERTYVALUES, + 0, + Length, propValues); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("GetBthHfpVolumePropertyValues: SendIoCtrlSynchronously(IOCTL_BTHHFP_DEVICE_GET_VOLUMEPROPERTYVALUES) failed, 0x%x", ntStatus)), @@ -5183,25 +5183,25 @@ Routine Description: // *PropValues = propValues; ntStatus = STATUS_SUCCESS; - + Done: if (!NT_SUCCESS(ntStatus)) { if (propValues != NULL) { ExFreePoolWithTag(propValues, MINADAPTER_POOLTAG); - } + } } - + return ntStatus; } //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::SetBthHfpSpeakerVolume ( - _In_ LONG Volume + _In_ LONG Volume ) /*++ @@ -5214,9 +5214,9 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetBthHfpSpeakerVolume]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; - + // // Get the Bth HFP SCO Bypass speaker volume. // @@ -5226,7 +5226,7 @@ Routine Description: sizeof(Volume), 0, &Volume); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("SetBthHfpSpeakerVolume: SendIoCtrlSynchronously(IOCTL_BTHHFP_SPEAKER_SET_VOLUME) failed, 0x%x", ntStatus)), @@ -5236,7 +5236,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5244,10 +5244,10 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::GetBthHfpSpeakerVolume ( - _Out_ LONG * Volume + _Out_ LONG * Volume ) /*++ @@ -5260,14 +5260,14 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetBthHfpSpeakerVolume]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationBuffer buffer = {0}; *Volume = 0; - + buffer.bImmediate = TRUE; - + // // Get the Bth HFP SCO Bypass speaker volume. // @@ -5277,7 +5277,7 @@ Routine Description: sizeof(buffer.bImmediate), sizeof(buffer.Volume), &buffer); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("GetBthHfpSpeakerVolume: SendIoCtrlSynchronously(IOCTL_BTHHFP_SPEAKER_GET_VOLUME_STATUS_UPDATE) failed, 0x%x", ntStatus)), @@ -5288,7 +5288,7 @@ Routine Description: // *Volume = buffer.Volume; ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5296,19 +5296,19 @@ Done: //============================================================================= #pragma code_seg() -NTSTATUS +NTSTATUS BthHfpDevice::EnableBthHfpSpeakerVolumeStatusNotification() /*++ Routine Description: - This function registers for Bluetooth Hands-Free Profile SCO Bypass speaker - volume change notification. + This function registers for Bluetooth Hands-Free Profile SCO Bypass speaker + volume change notification. --*/ { DPF_ENTER(("[BthHfpDevice::EnableBthHfpSpeakerVolumeStatusNotification]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * ctx = NULL; @@ -5317,8 +5317,8 @@ Routine Description: // // This is a notification request. // - ctx->Buffer.bImmediate = FALSE; - + ctx->Buffer.bImmediate = FALSE; + // // Register for speaker volume updates. // @@ -5329,7 +5329,7 @@ Routine Description: ctx->MemOut, EvtBthHfpDeviceNotificationStatusCompletion, this); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("EnableBthHfpSpeakerVolumeStatusNotification: SendIoCtrlAsynchronously(IOCTL_BTHHFP_SPEAKER_GET_VOLUME_STATUS_UPDATE) failed, 0x%x", ntStatus)), @@ -5339,7 +5339,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5347,10 +5347,10 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::SetBthHfpMicVolume ( - _In_ LONG Volume + _In_ LONG Volume ) /*++ @@ -5363,9 +5363,9 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetBthHfpMicVolume]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; - + // // Get the Bth HFP SCO Bypass mic volume. // @@ -5375,7 +5375,7 @@ Routine Description: sizeof(Volume), 0, &Volume); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("SetBthHfpMicVolume: SendIoCtrlSynchronously(IOCTL_BTHHFP_MIC_SET_VOLUME) failed, 0x%x", ntStatus)), @@ -5385,7 +5385,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5393,10 +5393,10 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::GetBthHfpMicVolume ( - _Out_ LONG * Volume + _Out_ LONG * Volume ) /*++ @@ -5409,14 +5409,14 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetBthHfpMicVolume]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationBuffer buffer = {0}; - + *Volume = 0; - + buffer.bImmediate = TRUE; - + // // Get the Bth HFP SCO Bypass mic volume. // @@ -5426,7 +5426,7 @@ Routine Description: sizeof(buffer.bImmediate), sizeof(buffer.Volume), &buffer); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("GetBthHfpMicVolume: SendIoCtrlSynchronously(IOCTL_BTHHFP_MIC_GET_VOLUME_STATUS_UPDATE) failed, 0x%x", ntStatus)), @@ -5437,7 +5437,7 @@ Routine Description: // *Volume = buffer.Volume; ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5445,29 +5445,29 @@ Done: //============================================================================= #pragma code_seg() -NTSTATUS +NTSTATUS BthHfpDevice::EnableBthHfpMicVolumeStatusNotification() /*++ Routine Description: - This function registers for Bluetooth Hands-Free Profile SCO Bypass mic - volume change notification. + This function registers for Bluetooth Hands-Free Profile SCO Bypass mic + volume change notification. --*/ { DPF_ENTER(("[BthHfpDevice::EnableBthHfpMicVolumeStatusNotification]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * ctx = NULL; ctx = GetBthHfpDeviceNotificationReqContext(m_MicVolumeReq); - + // // This is a notification request. // - ctx->Buffer.bImmediate = FALSE; - + ctx->Buffer.bImmediate = FALSE; + // // Register for mic volume updates. // @@ -5478,7 +5478,7 @@ Routine Description: ctx->MemOut, EvtBthHfpDeviceNotificationStatusCompletion, this); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("EnableBthHfpMicVolumeStatusNotification: SendIoCtrlAsynchronously(IOCTL_BTHHFP_MIC_GET_VOLUME_STATUS_UPDATE) failed, 0x%x", ntStatus)), @@ -5488,7 +5488,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5496,10 +5496,10 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::GetBthHfpConnectionStatus ( - _Out_ BOOL * ConnectionStatus + _Out_ BOOL * ConnectionStatus ) /*++ @@ -5512,12 +5512,12 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::GetBthHfpConnectionStatus]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BOOL bValue = TRUE; // In: bImmediate, Out: value. - + *ConnectionStatus = 0; - + // // Get the Bth HFP SCO Bypass connection status. // @@ -5527,7 +5527,7 @@ Routine Description: sizeof(bValue), sizeof(bValue), &bValue); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("GetBthHfpConnectionStatus: SendIoCtrlSynchronously(IOCTL_BTHHFP_DEVICE_GET_CONNECTION_STATUS_UPDATE) failed, 0x%x", ntStatus)), @@ -5538,7 +5538,7 @@ Routine Description: // *ConnectionStatus = bValue; ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5546,29 +5546,29 @@ Done: //============================================================================= #pragma code_seg() -NTSTATUS +NTSTATUS BthHfpDevice::EnableBthHfpConnectionStatusNotification() /*++ Routine Description: - This function registers for Bluetooth Hands-Free Profile SCO Bypass - connection status notification. + This function registers for Bluetooth Hands-Free Profile SCO Bypass + connection status notification. --*/ { DPF_ENTER(("[BthHfpDevice::EnableBthHfpConnectionStatusNotification]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * ctx = NULL; ctx = GetBthHfpDeviceNotificationReqContext(m_ConnectionReq); - + // // Make sure this obj is alive while the IRP is active. // - ctx->Buffer.bImmediate = FALSE; - + ctx->Buffer.bImmediate = FALSE; + // // Get the Bth HFP SCO Bypass connection status. // @@ -5579,7 +5579,7 @@ Routine Description: ctx->MemOut, EvtBthHfpDeviceNotificationStatusCompletion, this); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("EnableBthHfpConnectionStatusNotification: SendIoCtrlAsynchronously(IOCTL_BTHHFP_DEVICE_GET_CONNECTION_STATUS_UPDATE) failed, 0x%x", ntStatus)), @@ -5589,7 +5589,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5597,7 +5597,7 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::SetBthHfpConnect() /*++ @@ -5605,18 +5605,18 @@ Routine Description: This function synchronously requests a Bluetooth Hands-Free Profile level connection to the paired Bluetooth device. - - This request initiates the Service Level Connection establishment procedure - and completes without waiting for the connection procedure to complete. + + This request initiates the Service Level Connection establishment procedure + and completes without waiting for the connection procedure to complete. Connection status can be determined using IOCTL_BTHHFP_GET_CONNECTION_STATUS_UPDATE. --*/ { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetBthHfpConnect]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; - + ntStatus = SendIoCtrlSynchronously( NULL, IOCTL_BTHHFP_DEVICE_REQUEST_CONNECT, @@ -5633,7 +5633,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5641,7 +5641,7 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::SetBthHfpDisconnect() /*++ @@ -5650,17 +5650,17 @@ Routine Description: This function synchronously requests a Bluetooth Hands-Free Profile level connection to the paired Bluetooth device. - This request initiates disconnection of the Service Level Connection and - completes without waiting for the disconnection to complete. Connection + This request initiates disconnection of the Service Level Connection and + completes without waiting for the disconnection to complete. Connection status can be determined using IOCTL_BTHHFP_GET_CONNECTION_STATUS_UPDATE. --*/ { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetBthHfpDisconnect]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; - + ntStatus = SendIoCtrlSynchronously( NULL, IOCTL_BTHHFP_DEVICE_REQUEST_DISCONNECT, @@ -5677,7 +5677,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5685,7 +5685,7 @@ Done: //============================================================================= #pragma code_seg() -void +void BthHfpDevice::EvtBthHfpDeviceStreamStatusCompletion ( _In_ WDFREQUEST Request, @@ -5697,18 +5697,18 @@ BthHfpDevice::EvtBthHfpDeviceStreamStatusCompletion Routine Description: - Completion callback for the Bluetooth Hands-Free Profile SCO Bypass - stream status notification. + Completion callback for the Bluetooth Hands-Free Profile SCO Bypass + stream status notification. --*/ { DPF_ENTER(("[BthHfpDevice::EvtBthHfpDeviceStreamStatusCompletion]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * reqCtx = NULL; BthHfpDevice * This = NULL; NTSTATUS ntResult = STATUS_SUCCESS; - + UNREFERENCED_PARAMETER(Target); UNREFERENCED_PARAMETER(Context); @@ -5724,15 +5724,15 @@ Routine Description: { ntResult = STATUS_INVALID_DEVICE_STATE; } - else + else { ntResult = reqCtx->Buffer.NtStatus; } InterlockedExchange(&This->m_StreamStatusLong, (LONG)ntResult); - + // - // Let the stop routine know we are done. Stop routine will + // Let the stop routine know we are done. Stop routine will // re-init the request. // KeSetEvent(&This->m_StreamStatusEvent, IO_NO_INCREMENT, FALSE); @@ -5740,29 +5740,29 @@ Routine Description: //============================================================================= #pragma code_seg() -NTSTATUS +NTSTATUS BthHfpDevice::EnableBthHfpStreamStatusNotification() /*++ Routine Description: - This function registers for Bluetooth Hands-Free Profile SCO Bypass - stream status notification. + This function registers for Bluetooth Hands-Free Profile SCO Bypass + stream status notification. --*/ { DPF_ENTER(("[BthHfpDevice::EnableBthHfpStreamStatusNotification]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * ctx = NULL; ASSERT(m_nStreams > 0); - + ctx = GetBthHfpDeviceNotificationReqContext(m_StreamReq); - ctx->Buffer.bImmediate = FALSE; + ctx->Buffer.bImmediate = FALSE; KeClearEvent(&m_StreamStatusEvent); - + // // Get the Bth HFP SCO Bypass connection status. // @@ -5773,7 +5773,7 @@ Routine Description: ctx->MemOut, EvtBthHfpDeviceStreamStatusCompletion, this); - + if (!NT_SUCCESS(ntStatus)) { KeSetEvent(&m_StreamStatusEvent, IO_NO_INCREMENT, FALSE); @@ -5785,7 +5785,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5793,13 +5793,13 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::StopBthHfpStreamStatusNotification() /*++ Routine Description: - This function stops the Bluetooth Hands-Free Profile SCO Bypass + This function stops the Bluetooth Hands-Free Profile SCO Bypass connection status notification. The function waits for the request to be done before returning. @@ -5807,26 +5807,26 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::StopBthHfpStreamStatusNotification]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; BthHfpDeviceNotificationReqContext * reqCtx = NULL; - WDF_REQUEST_REUSE_PARAMS reuseParams; - + WDF_REQUEST_REUSE_PARAMS reuseParams; + WdfRequestCancelSentRequest(m_StreamReq); KeWaitForSingleObject(&m_StreamStatusEvent, Executive, KernelMode, FALSE, NULL); reqCtx = GetBthHfpDeviceNotificationReqContext(m_StreamReq); ASSERT(reqCtx != NULL); UNREFERENCED_VAR(reqCtx); - - // + + // // Re-init the request for later. // WDF_REQUEST_REUSE_PARAMS_INIT( - &reuseParams, + &reuseParams, WDF_REQUEST_REUSE_NO_FLAGS, STATUS_SUCCESS); - + ntStatus = WdfRequestReuse(m_StreamReq, &reuseParams); if (!NT_SUCCESS(ntStatus)) { @@ -5838,7 +5838,7 @@ Routine Description: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::SetBthHfpStreamOpen() /*++ @@ -5851,9 +5851,9 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetBthHfpStreamOpen]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; - + ntStatus = SendIoCtrlSynchronously( NULL, IOCTL_BTHHFP_STREAM_OPEN, @@ -5867,7 +5867,7 @@ Routine Description: DPF(D_VERBOSE, ("SetBthHfpStreamOpen: the stream channel is already open")); ntStatus = STATUS_SUCCESS; } - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("SetBthHfpStreamOpen: SendIoCtrlSynchronously(IOCTL_BTHHFP_STREAM_OPEN) failed, 0x%x", ntStatus)), @@ -5877,7 +5877,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5885,7 +5885,7 @@ Done: //============================================================================= #pragma code_seg("PAGE") -NTSTATUS +NTSTATUS BthHfpDevice::SetBthHfpStreamClose() /*++ @@ -5897,9 +5897,9 @@ Routine Description: { PAGED_CODE(); DPF_ENTER(("[BthHfpDevice::SetBthHfpStreamClose]")); - + NTSTATUS ntStatus = STATUS_SUCCESS; - + ntStatus = SendIoCtrlSynchronously( NULL, IOCTL_BTHHFP_STREAM_CLOSE, @@ -5916,7 +5916,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done: return ntStatus; @@ -5924,7 +5924,7 @@ Done: //============================================================================= #pragma code_seg("PAGE") -VOID +VOID BthHfpDevice::Start() /*++ @@ -5966,9 +5966,9 @@ Routine Description: // Volume settings. ntStatus = GetBthHfpVolumePropertyValues( - m_Descriptor->VolumePropertyValuesSize, + m_Descriptor->VolumePropertyValuesSize, &volumePropValues); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Start: GetBthHfpVolumePropertyValues: failed to retrieve KSPROPERTY_VALUES, 0x%x", ntStatus)), @@ -5991,9 +5991,9 @@ Routine Description: ntStatus, DPF(D_ERROR, ("Start: GetBthHfpMicVolume: failed, 0x%x", ntStatus)), Done); - + m_MicVolumeLevel = volume; - } + } // // Get connection status. @@ -6031,8 +6031,8 @@ Routine Description: // Customize the topology/wave descriptors for this instance // ntStatus = CreateCustomEndpointMinipair( - g_BthHfpRenderEndpoints[bthMiniportsIndex], - &m_Descriptor->FriendlyName, + g_BthHfpRenderEndpoints[bthMiniportsIndex], + &m_Descriptor->FriendlyName, &m_Descriptor->OutputPinCategory, &m_SpeakerMiniports); IF_FAILED_ACTION_JUMP( @@ -6041,7 +6041,7 @@ Routine Description: Done); ntStatus = CreateCustomEndpointMinipair( - g_BthHfpCaptureEndpoints[bthMiniportsIndex], + g_BthHfpCaptureEndpoints[bthMiniportsIndex], &m_Descriptor->FriendlyName, &m_Descriptor->InputPinCategory, &m_MicMiniports); @@ -6065,7 +6065,7 @@ Routine Description: &m_UnknownSpeakerTopology, &m_UnknownSpeakerWave, NULL, NULL ); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Start: InstallEndpointRenderFilters (Bth HFP SCO-Bypass): failed, 0x%x", ntStatus)), @@ -6078,7 +6078,7 @@ Routine Description: &m_UnknownMicTopology, &m_UnknownMicWave, NULL, NULL ); - + IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Start: InstallEndpointCaptureFilters (Bth HFP SCO-Bypass): failed, 0x%x", ntStatus)), @@ -6087,28 +6087,28 @@ Routine Description: // // Pend status notifications. // - + // NREC disable AudioGateway (AG) status. ntStatus = EnableBthHfpNrecDisableStatusNotification(); IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Start: EnableBthHfpNrecDisableStatusNotification: failed, 0x%x", ntStatus)), Done); - + // Volume speaker status. ntStatus = EnableBthHfpSpeakerVolumeStatusNotification(); IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Start: EnableBthHfpSpeakerVolumeStatusNotification: failed, 0x%x", ntStatus)), Done); - + // Volume mic status. ntStatus = EnableBthHfpMicVolumeStatusNotification(); IF_FAILED_ACTION_JUMP( ntStatus, DPF(D_ERROR, ("Start: EnableBthHfpMicVolumeStatusNotification: failed, 0x%x", ntStatus)), Done); - + // Connection status. ntStatus = EnableBthHfpConnectionStatusNotification(); IF_FAILED_ACTION_JUMP( @@ -6120,7 +6120,7 @@ Routine Description: // All done. // ntStatus = STATUS_SUCCESS; - + Done:; if (!NT_SUCCESS(ntStatus)) { @@ -6314,10 +6314,10 @@ BthHfpDevice::DeleteCustomEndpointMinipair ExFreePoolWithTag(pCustomMinipair, SYSVAD_POOLTAG); } } - + //============================================================================= #pragma code_seg("PAGE") -VOID +VOID BthHfpDevice::Stop() /*++ @@ -6326,7 +6326,7 @@ Routine Description: Asynchronously called to stop the audio device. After returning from this function, there are no more async notifications pending (volume, connection, etc.). - + --*/ { PAGED_CODE(); @@ -6338,7 +6338,7 @@ Routine Description: state = (eBthHfpState) InterlockedExchange((PLONG)&m_State, eBthHfpStateStopping); ASSERT(state == eBthHfpStateRunning || state == eBthHfpStateFailed); UNREFERENCED_VAR(state); - + // // Stop async notifications. // @@ -6348,7 +6348,7 @@ Routine Description: // Wait for work-item. // WdfWorkItemFlush(m_WorkItem); - + // // Remove the topology and wave render filters. // @@ -6358,7 +6358,7 @@ Routine Description: m_SpeakerMiniports, m_UnknownSpeakerTopology, m_UnknownSpeakerWave); - + if (!NT_SUCCESS(ntStatus)) { DPF(D_ERROR, ("RemoveEndpointFilters (Bth HFP SCO-Bypass Speaker): failed, 0x%x", ntStatus)); @@ -6374,7 +6374,7 @@ Routine Description: m_MicMiniports, m_UnknownMicTopology, m_UnknownMicWave); - + if (!NT_SUCCESS(ntStatus)) { DPF(D_ERROR, ("RemoveEndpointFilters (Bth HFP SCO-Bypass Capture): failed, 0x%x", ntStatus)); @@ -6404,4 +6404,139 @@ Routine Description: #endif // SYSVAD_BTH_BYPASS +// +// The following are copied from: +// \Program Files\Windows Kits\10\Include\10.0.15063.0\km\stdunk.h +// + +#ifdef _NEW_DELETE_OPERATORS_ + +// Note: Since VS2015 Update 2 overloaded operator new and operator delete may not +// be declared inline (Level 1 (/W1) on-by-default, warning C4595). +// See https://msdn.microsoft.com/en-us/library/mt656697.aspx +// +// To mitigate this issue, add "#define _NEW_DELETE_OPERATORS_" before "#include " +// and implement non-inline operator new and operator delete locally. + +/***************************************************************************** + * ::new() + ***************************************************************************** + * New function for creating objects with a specified allocation tag. + */ +// PVOID operator new +// ( +// size_t iSize, +// _When_((poolType & NonPagedPoolMustSucceed) != 0, +// __drv_reportError("Must succeed pool allocations are forbidden. " +// "Allocation failures cause a system crash")) +// POOL_TYPE poolType +// ) +// { +// PVOID result = ExAllocatePoolWithTag(poolType,iSize,'wNcP'); +// +// if (result) +// { +// RtlZeroMemory(result,iSize); +// } +// +// return result; +// } + +/***************************************************************************** + * ::new() + ***************************************************************************** + * New function for creating objects with a specified allocation tag. + */ +PVOID operator new +( + size_t iSize, + _When_((poolType & NonPagedPoolMustSucceed) != 0, + __drv_reportError("Must succeed pool allocations are forbidden. " + "Allocation failures cause a system crash")) + POOL_TYPE poolType, + ULONG tag +) +{ + PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag); + + if (result) + { + RtlZeroMemory(result,iSize); + } + + return result; +} + +/***************************************************************************** + * ::delete() + ***************************************************************************** + * Delete function. + */ +// void __cdecl operator delete +// ( +// PVOID pVoid +// ) +// { +// if (pVoid) +// { +// ExFreePool(pVoid); +// } +// } + +/***************************************************************************** + * ::delete() + ***************************************************************************** + * Delete function. + */ +// void __cdecl operator delete +// ( +// PVOID pVoid, +// ULONG tag +// ) +// { +// if (pVoid) +// { +// ExFreePoolWithTag(pVoid,tag); +// } +// } + +void __cdecl operator delete +( + _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid, + _In_ size_t cbSize +) +{ + UNREFERENCED_PARAMETER(cbSize); + + if (pVoid) + { + ExFreePool(pVoid); + } +} + +void __cdecl operator delete[] +( + _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid +) +{ + if (pVoid) + { + ExFreePool(pVoid); + } +} +// void __cdecl operator delete[] +// ( +// _Pre_maybenull_ __drv_freesMem(Mem) PVOID pVoid, +// _In_ size_t cbSize +// ) +// { +// UNREFERENCED_PARAMETER(cbSize); + +// if (pVoid) +// { +// ExFreePool(pVoid); +// } +// } + +#endif //!_NEW_DELETE_OPERATORS_ diff --git a/audio/sysvad/sysvad.h b/audio/sysvad/sysvad.h index 0065f3e3..e99a54b2 100644 --- a/audio/sysvad/sysvad.h +++ b/audio/sysvad/sysvad.h @@ -16,7 +16,27 @@ Abstract: #define _SYSVAD_H_ #include + +// Note: Since VS2015 Update 2 overloaded operator new and operator delete may not +// be declared inline (Level 1 (/W1) on-by-default, warning C4595). +// See https://msdn.microsoft.com/en-us/library/mt656697.aspx +// +// To mitigate this issue, add "#define _NEW_DELETE_OPERATORS_" before "#include " +// and implement non-inline operator new and operator delete locally. +// +#define _NEW_DELETE_OPERATORS_ #include +// non-inline operator new and operator delete are implemented in common.cpp +PVOID operator new +( + size_t iSize, + _When_((poolType & NonPagedPoolMustSucceed) != 0, + __drv_reportError("Must succeed pool allocations are forbidden. " + "Allocation failures cause a system crash")) + POOL_TYPE poolType, + ULONG tag +); + #include #include #include @@ -42,7 +62,7 @@ DEFINE_GUIDSTRUCT("5B722BF8-F0AB-47ee-B9C8-8D61D31375A1", PID_SYSVAD); #define PID_SYSVAD DEFINE_GUIDNAMED(PID_SYSVAD) // Pool tag used for SYSVAD allocations -#define SYSVAD_POOLTAG 'DVSM' +#define SYSVAD_POOLTAG 'DVSM' // Debug module name #define STR_MODULENAME "SYSVAD: " @@ -50,9 +70,9 @@ DEFINE_GUIDSTRUCT("5B722BF8-F0AB-47ee-B9C8-8D61D31375A1", PID_SYSVAD); // Debug utility macros #define D_FUNC 4 #define D_BLAB DEBUGLVL_BLAB -#define D_VERBOSE DEBUGLVL_VERBOSE -#define D_TERSE DEBUGLVL_TERSE -#define D_ERROR DEBUGLVL_ERROR +#define D_VERBOSE DEBUGLVL_VERBOSE +#define D_TERSE DEBUGLVL_TERSE +#define D_ERROR DEBUGLVL_ERROR #define DPF _DbgPrintF #define DPF_ENTER(x) DPF(D_FUNC, x) @@ -67,7 +87,7 @@ DEFINE_GUIDSTRUCT("5B722BF8-F0AB-47ee-B9C8-8D61D31375A1", PID_SYSVAD); #define KSPROPERTY_TYPE_ALL KSPROPERTY_TYPE_BASICSUPPORT | \ KSPROPERTY_TYPE_GET | \ KSPROPERTY_TYPE_SET - + // Specific node numbers #define DEV_SPECIFIC_VT_BOOL 9 #define DEV_SPECIFIC_VT_I4 10 @@ -90,7 +110,7 @@ DEFINE_GUIDSTRUCT("5B722BF8-F0AB-47ee-B9C8-8D61D31375A1", PID_SYSVAD); #define VALUE_NORMALIZE(v, step) \ ((v) > 0 ? VALUE_NORMALIZE_P((v), (step)) : -(VALUE_NORMALIZE_P(-(v), (step)))) - + #define VALUE_NORMALIZE_IN_RANGE_EX(v, min, max, step) \ ((v) > (max) ? (max) : \ (v) < (min) ? (min) : \ @@ -216,7 +236,7 @@ typedef struct _PortClassDeviceContext // 32 64 Byte off ULONG_PTR m_pulReserved1[2]; // 0-7 0-15 First two pointers are reserved. PDEVICE_OBJECT m_DoNotUsePhysicalDeviceObject; // 8-11 16-23 Reserved pointer to our Physical Device Object (PDO). PVOID m_pvReserved2; // 12-15 24-31 Reserved pointer to our Start Device function. - PVOID m_pvReserved3; // 16-19 32-39 "Out Memory" according to DDK. + PVOID m_pvReserved3; // 16-19 32-39 "Out Memory" according to DDK. IAdapterCommon* m_pCommon; // 20-23 40-47 Pointer to our adapter common object. #ifdef _USE_SingleComponentMultiFxStates POHANDLE m_poHandle; // 24-27 48-55 PoFxDevice handle. @@ -234,7 +254,7 @@ typedef struct _PortClassDeviceContext // 32 64 Byte off // #define MajorTarget_to_Obj(ptr) \ reinterpret_cast(ptr) - + #define MinorTarget_to_Obj(ptr) \ static_cast(reinterpret_cast(ptr)) @@ -250,8 +270,8 @@ extern DWORD g_DisableBthScoBypass; // Generic topology handler NTSTATUS PropertyHandler_Topology -( - _In_ PPCPROPERTY_REQUEST PropertyRequest +( + _In_ PPCPROPERTY_REQUEST PropertyRequest ); // Default WaveFilter automation table. @@ -267,8 +287,8 @@ NTSTATUS PropertyHandler_OffloadPin ); NTSTATUS PropertyHandler_GenericPin -( - _In_ PPCPROPERTY_REQUEST PropertyRequest +( + _In_ PPCPROPERTY_REQUEST PropertyRequest ); // common.h uses some of the above definitions. diff --git a/audio/sysvad/sysvad.sln b/audio/sysvad/sysvad.sln index c56cef29..4aef7d1f 100644 --- a/audio/sysvad/sysvad.sln +++ b/audio/sysvad/sysvad.sln @@ -61,14 +61,6 @@ Global {E0F02048-78A4-4FE8-B863-66E6CB6A2C37}.Debug|x64.Build.0 = Debug|x64 {E0F02048-78A4-4FE8-B863-66E6CB6A2C37}.Release|x64.ActiveCfg = Release|x64 {E0F02048-78A4-4FE8-B863-66E6CB6A2C37}.Release|x64.Build.0 = Release|x64 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Debug|Win32.ActiveCfg = Debug|Win32 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Debug|Win32.Build.0 = Debug|Win32 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Release|Win32.ActiveCfg = Release|Win32 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Release|Win32.Build.0 = Release|Win32 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Debug|x64.ActiveCfg = Debug|x64 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Debug|x64.Build.0 = Debug|x64 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Release|x64.ActiveCfg = Release|x64 - {D253C552-154D-49E1-820A-B2CD9D9FF13E}.Release|x64.Build.0 = Release|x64 {691F1D0F-CA50-46CD-8BBA-A59E9E8EB601}.Debug|Win32.ActiveCfg = Debug|Win32 {691F1D0F-CA50-46CD-8BBA-A59E9E8EB601}.Debug|Win32.Build.0 = Debug|Win32 {691F1D0F-CA50-46CD-8BBA-A59E9E8EB601}.Release|Win32.ActiveCfg = Release|Win32 @@ -116,13 +108,11 @@ Global GlobalSection(NestedProjects) = preSolution {830B14D5-0E32-4F9E-AEFA-4C9F6FC13C2A} = {FA56D96B-290B-4C73-A5E1-02C1861D3224} {E0F02048-78A4-4FE8-B863-66E6CB6A2C37} = {DBD14E7B-7F95-4743-86E3-4E16FA43F990} - {D253C552-154D-49E1-820A-B2CD9D9FF13E} = {50D3DF82-019A-4434-B17F-72BBC291415F} {691F1D0F-CA50-46CD-8BBA-A59E9E8EB601} = {367FF255-7280-48C4-90AC-767124A8D5F7} {8851AB85-70B3-4798-A149-BA366DF9EC25} = {367FF255-7280-48C4-90AC-767124A8D5F7} {33E61864-6F2C-4F9F-BE70-8F8985A4F283} = {0B4B8E51-20A8-43A4-A8DA-42FF90D628AC} {FABA4668-DB5E-4F6C-9D25-A0B25AD084EE} = {D0DBEBE9-0DCC-4EA7-966B-C029C1334D9E} {E4DF0EEE-D35B-47F2-A9B1-41EA97C465FF} = {C06F6070-75EE-4F57-8D35-4AC2AB08D029} - {50D3DF82-019A-4434-B17F-72BBC291415F} = {684FF1CF-64CC-430E-81F7-9D603EF56D59} {367FF255-7280-48C4-90AC-767124A8D5F7} = {684FF1CF-64CC-430E-81F7-9D603EF56D59} EndGlobalSection EndGlobal -- cgit v1.3.1 From 3ea77dce79b649dd75c43d6cf22378667e8124c2 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 16 Aug 2017 14:55:19 -0700 Subject: Build avshws sample with RS2 WDK --- avstream/avshws/avshws.h | 125 +++++++++--------------------- avstream/avshws/device.cpp | 185 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 184 insertions(+), 126 deletions(-) diff --git a/avstream/avshws/avshws.h b/avstream/avshws/avshws.h index 70f220f3..a6b3d8bc 100644 --- a/avstream/avshws/avshws.h +++ b/avstream/avshws/avshws.h @@ -10,7 +10,7 @@ Abstract: - AVStream Simulated Hardware Sample header file. This is the + AVStream Simulated Hardware Sample header file. This is the main header. History: @@ -43,6 +43,14 @@ extern "C" { #include #include #include + +// Note: Since VS2015 Update 2 overloaded operator new and operator delete may not +// be declared inline (Level 1 (/W1) on-by-default, warning C4595). +// See https://msdn.microsoft.com/en-us/library/mt656697.aspx +// +// To mitigate this issue, add "#define _NEW_DELETE_OPERATORS_" before "#include " +// and implement non-inline operator new and operator delete locally. +#define _NEW_DELETE_OPERATORS_ #include /************************************************* @@ -76,7 +84,7 @@ const DebugLevel = DEBUGLVL_TERSE; #define ABS(x) ((x) < 0 ? (-(x)) : (x)) -#ifndef mmioFOURCC +#ifndef mmioFOURCC #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \ ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) ) @@ -137,12 +145,12 @@ CaptureFilterCategories [CAPTURE_FILTER_CATEGORIES_COUNT]; // // capture.cpp externs: // -extern +extern const KSALLOCATOR_FRAMING_EX CapturePinAllocatorFraming; -extern +extern const KSPIN_DISPATCH CapturePinDispatch; @@ -210,103 +218,38 @@ public: }; - /************************************************* Global Functions *************************************************/ -/*++ - -Routine Description: - - Array delete() operator. - -Arguments: - - pVoid - - The memory to free. - -Return Value: - - None - ---*/ -inline -void -__cdecl -operator delete[]( - PVOID pVoid -) -{ - if (pVoid) - { - ExFreePool(pVoid); - } -} - -/*++ - -Routine Description: - - Sized delete() operator. - -Arguments: - - pVoid - - The memory to free. - - size - - The size of the memory to free. - -Return Value: - - None - ---*/ -inline void __cdecl operator delete +void __cdecl operator delete[] ( - void *pVoid, - size_t /*size*/ -) -{ - if (pVoid) - { - ExFreePool(pVoid); - } -} - -/*++ + PVOID pVoid +); -Routine Description: - - Sized delete[]() operator. - -Arguments: - - pVoid - - The memory to free. - - size - - The size of the memory to free. - -Return Value: +void __cdecl operator delete +( + void *pVoid, + size_t /*size*/ +); - None +void __cdecl operator delete[] +( + void *pVoid, + size_t /*size*/ +); ---*/ -inline void __cdecl operator delete[] +PVOID operator new ( - void *pVoid, - size_t /*size*/ -) -{ - if (pVoid) - { - ExFreePool(pVoid); - } -} + size_t iSize, + _When_((poolType & NonPagedPoolMustSucceed) != 0, + __drv_reportError("Must succeed pool allocations are forbidden. " + "Allocation failures cause a system crash")) + POOL_TYPE poolType, + ULONG tag +); /************************************************* @@ -320,4 +263,4 @@ inline void __cdecl operator delete[] #include "filter.h" #include "capture.h" #include -#endif //_avshws_h_ \ No newline at end of file +#endif //_avshws_h_ diff --git a/avstream/avshws/device.cpp b/avstream/avshws/device.cpp index 75b06cd5..2f54aca4 100644 --- a/avstream/avshws/device.cpp +++ b/avstream/avshws/device.cpp @@ -161,7 +161,7 @@ Return Value: // // By PnP, it's possible to receive multiple starts without an intervening // stop (to reevaluate resources, for example). Thus, we only perform - // creations of the simulation on the initial start and ignore any + // creations of the simulation on the initial start and ignore any // subsequent start. Hardware drivers with resources should evaluate // resources and make changes on 2nd start. // @@ -173,7 +173,7 @@ Return Value: // If we couldn't create the hardware simulation, fail. // Status = STATUS_INSUFFICIENT_RESOURCES; - + } else { Status = KsAddItemToObjectBag ( m_Device -> Bag, @@ -197,15 +197,15 @@ Return Value: // // Set up DMA... // - // Ordinarilly, we'd be using InterfaceBuffer or - // InterfaceTypeUndefined if !NT_SUCCESS (IfStatus) as the - // InterfaceType below; however, for the purposes of this sample, + // Ordinarilly, we'd be using InterfaceBuffer or + // InterfaceTypeUndefined if !NT_SUCCESS (IfStatus) as the + // InterfaceType below; however, for the purposes of this sample, // we lie and say we're on the PCI Bus. Otherwise, we're using map // registers on x86 32 bit physical to 32 bit logical and this isn't // what I want to show in this sample. // // - // NTSTATUS IfStatus = + // NTSTATUS IfStatus = IoGetDeviceProperty ( m_Device -> PhysicalDeviceObject, @@ -216,7 +216,7 @@ Return Value: ); // - // Initialize our fake device description. We claim to be a + // Initialize our fake device description. We claim to be a // bus-mastering 32-bit scatter/gather capable piece of hardware. // DeviceDescription.Version = DEVICE_DESCRIPTION_VERSION; @@ -229,7 +229,7 @@ Return Value: DeviceDescription.Dma32BitAddresses = TRUE; DeviceDescription.AutoInitialize = FALSE; DeviceDescription.MaximumLength = (ULONG) -1; - + // // Get a DMA adapter object from the system. // @@ -238,21 +238,21 @@ Return Value: &DeviceDescription, &m_NumberOfMapRegisters ); - + if (!m_DmaAdapterObject) { Status = STATUS_UNSUCCESSFUL; } - + } - + if (NT_SUCCESS (Status)) { // - // Initialize our DMA adapter object with AVStream. This is + // Initialize our DMA adapter object with AVStream. This is // **ONLY** necessary **IF** you are doing DMA directly into // capture buffers as this sample does. For this, // KSPIN_FLAG_GENERATE_MAPPINGS must be specified on a queue. // - + // // The (1 << 20) below is the maximum size of a single s/g mapping // that this hardware can handle. Note that I have pulled this @@ -264,11 +264,11 @@ Return Value: (1 << 20), sizeof (KSMAPPING) ); - + } #endif } - + return Status; } @@ -306,7 +306,7 @@ Return Value: // // Return the DMA adapter back to the system. // - m_DmaAdapterObject -> DmaOperations -> + m_DmaAdapterObject -> DmaOperations -> PutDmaAdapter (m_DmaAdapterObject); m_DmaAdapterObject = NULL; @@ -328,7 +328,7 @@ AcquireHardwareResources ( Routine Description: - Acquire hardware resources for the capture hardware. If the + Acquire hardware resources for the capture hardware. If the resources are already acquired, this will return an error. The hardware configuration must be passed as a VideoInfoHeader. @@ -376,44 +376,44 @@ Return Value: delete m_ImageSynth; m_ImageSynth = NULL; } - + // // Create the necessary type of image synthesizer. // if (m_VideoInfoHeader -> bmiHeader.biBitCount == 24 && m_VideoInfoHeader -> bmiHeader.biCompression == KS_BI_RGB) { - + // // If we're RGB24, create a new RGB24 synth. RGB24 surfaces // can be in either orientation. The origin is lower left if // height < 0. Otherwise, it's upper left. // - m_ImageSynth = new (NonPagedPoolNx, 'RysI') + m_ImageSynth = new (NonPagedPoolNx, 'RysI') CRGB24Synthesizer ( m_VideoInfoHeader -> bmiHeader.biHeight >= 0 ); - + } else if (m_VideoInfoHeader -> bmiHeader.biBitCount == 16 && (m_VideoInfoHeader -> bmiHeader.biCompression == FOURCC_YUY2)) { - + // // If we're UYVY, create the YUV synth. // m_ImageSynth = new(NonPagedPoolNx, 'YysI') CYUVSynthesizer; - + } else // // We don't synthesize anything but RGB 24 and UYVY. // Status = STATUS_INVALID_PARAMETER; - + if (NT_SUCCESS (Status) && !m_ImageSynth) { - + Status = STATUS_INSUFFICIENT_RESOURCES; - - } + + } if (NT_SUCCESS (Status)) { // @@ -428,7 +428,7 @@ Return Value: // ReleaseHardwareResources (); } - + } else { // @@ -660,9 +660,9 @@ Return Value: PAGED_CODE(); - - return + + return m_HardwareSimulation -> ProgramScatterGatherMappings ( Clone, Buffer, @@ -749,7 +749,7 @@ Return Value: // of hardware registers (ReadNumberOfMappingsCompleted) which would likely // be done in the ISR. // - ULONG NumMappingsCompleted = + ULONG NumMappingsCompleted = m_HardwareSimulation -> ReadNumberOfMappingsCompleted (); // @@ -774,7 +774,7 @@ Return Value: // CaptureFilterDescriptor: // // The filter descriptor for the capture device. -DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) { +DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) { &CaptureFilterDescriptor }; @@ -810,8 +810,8 @@ CaptureDeviceDispatch = { // This is the device descriptor for the capture device. It points to the // dispatch table and contains a list of filter descriptors that describe // filter-types that this device supports. Note that the filter-descriptors -// can be created dynamically and the factories created via -// KsCreateFilterFactory as well. +// can be created dynamically and the factories created via +// KsCreateFilterFactory as well. // const KSDEVICE_DESCRIPTOR @@ -865,7 +865,7 @@ Return Value: // at add & start. Everything is done based on the descriptors passed // here. // - return + return KsInitializeDriver ( DriverObject, RegistryPath, @@ -873,3 +873,118 @@ Return Value: ); } + +/************************************************* + + Global Functions + +*************************************************/ + +/*++ + +Routine Description: + + Array delete() operator. + +Arguments: + + pVoid - + The memory to free. + +Return Value: + + None + +--*/ +void +__cdecl +operator delete[]( + PVOID pVoid +) +{ + if (pVoid) + { + ExFreePool(pVoid); + } +} + +/*++ + +Routine Description: + + Sized delete() operator. + +Arguments: + + pVoid - + The memory to free. + + size - + The size of the memory to free. + +Return Value: + + None + +--*/ +void __cdecl operator delete +( + void *pVoid, + size_t /*size*/ +) +{ + if (pVoid) + { + ExFreePool(pVoid); + } +} + +/*++ + +Routine Description: + + Sized delete[]() operator. + +Arguments: + + pVoid - + The memory to free. + + size - + The size of the memory to free. + +Return Value: + + None + +--*/ +void __cdecl operator delete[] +( + void *pVoid, + size_t /*size*/ +) +{ + if (pVoid) + { + ExFreePool(pVoid); + } +} + +PVOID operator new +( + size_t iSize, + _When_((poolType & NonPagedPoolMustSucceed) != 0, + __drv_reportError("Must succeed pool allocations are forbidden. " + "Allocation failures cause a system crash")) + POOL_TYPE poolType, + ULONG tag +) +{ + PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag); + + if (result) { + RtlZeroMemory(result,iSize); + } + + return result; +} -- cgit v1.3.1 From 1d7c765b29ab9c2ac3348b2c54f1343e8be4fb8e Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 16 Aug 2017 15:29:02 -0700 Subject: Build keyboard layout sample --- input/layout/fe_kbds/jpn/101/kbd101.vcxproj | 8 +++++++- input/layout/fe_kbds/jpn/106/kbd106.vcxproj | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/input/layout/fe_kbds/jpn/101/kbd101.vcxproj b/input/layout/fe_kbds/jpn/101/kbd101.vcxproj index 8f5a90fe..ad201083 100644 --- a/input/layout/fe_kbds/jpn/101/kbd101.vcxproj +++ b/input/layout/fe_kbds/jpn/101/kbd101.vcxproj @@ -161,6 +161,7 @@ %(AdditionalOptions) /ignore:4254 kbd101.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME @@ -186,11 +187,13 @@ %(AdditionalOptions) /ignore:4254 kbd101.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME %(PreprocessorDefinitions);JAPAN %(AdditionalIncludeDirectories);..\inc + Default @@ -211,6 +214,7 @@ %(AdditionalOptions) /ignore:4254 kbd101.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME @@ -236,11 +240,13 @@ %(AdditionalOptions) /ignore:4254 kbd101.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME %(PreprocessorDefinitions);JAPAN %(AdditionalIncludeDirectories);..\inc + Default @@ -272,4 +278,4 @@ - \ No newline at end of file + diff --git a/input/layout/fe_kbds/jpn/106/kbd106.vcxproj b/input/layout/fe_kbds/jpn/106/kbd106.vcxproj index 00e66e63..133ef341 100644 --- a/input/layout/fe_kbds/jpn/106/kbd106.vcxproj +++ b/input/layout/fe_kbds/jpn/106/kbd106.vcxproj @@ -161,6 +161,7 @@ %(AdditionalOptions) /ignore:4254 kbd106.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME @@ -186,11 +187,13 @@ %(AdditionalOptions) /ignore:4254 kbd106.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME %(PreprocessorDefinitions);JAPAN %(AdditionalIncludeDirectories);..\inc + Default @@ -211,6 +214,7 @@ %(AdditionalOptions) /ignore:4254 kbd106.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME @@ -236,11 +240,13 @@ %(AdditionalOptions) /ignore:4254 kbd106.def true + true %(PreprocessorDefinitions);FE_SB;FE_IME %(PreprocessorDefinitions);JAPAN %(AdditionalIncludeDirectories);..\inc + Default @@ -272,4 +278,4 @@ - \ No newline at end of file + -- cgit v1.3.1 From 2f230d1ce3cffc441533a360979124391f565e52 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 16 Aug 2017 15:58:03 -0700 Subject: REDO: avstream\samplemft0\resource.h: file corruption --- avstream/samplemft0/resource.h | Bin 1708 -> 828 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/avstream/samplemft0/resource.h b/avstream/samplemft0/resource.h index 3446618b..b2eb3f8b 100644 Binary files a/avstream/samplemft0/resource.h and b/avstream/samplemft0/resource.h differ -- cgit v1.3.1 From 836052c0d882f2a694343060e0ed89f73440b4c3 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 16 Aug 2017 16:47:37 -0700 Subject: Fix typo in WFPSamplerCalloutDriver.inx --- network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX b/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX index 4c5777be..7ad880cd 100644 --- a/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX +++ b/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX @@ -24,7 +24,7 @@ ClassGuid = {57465043-616C-6C6F-7574-5F636C617373} Provider = %ProviderString% CatalogFile = WFPSamplerCalloutDriver.Cat - DriverVer = + DriverVer = [SourceDisksNames.$ARCH$] 1 = %WFPSamplerCalloutDriverDiskId%,,,"" @@ -33,7 +33,7 @@ WFPSamplerCalloutDriver.sys = 1,, [ClassInstall32.nt$ARCH$] - AddReg = WFPCalloutsClassReg + AddReg = WFPCalloutClassReg [DestinationDirs] DefaultDestDir = 12 ;/// %WinDir%\System32\Drivers -- cgit v1.3.1 From 75d68b365bfc5e1d17f9c69f37ff789aa30e2d79 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 17 Aug 2017 09:56:51 -0700 Subject: Add sensors combo driver sample --- sensors/SensorsComboDriver/Cat/product.pbxproj | 11 + sensors/SensorsComboDriver/Cat/sources | 16 + sensors/SensorsComboDriver/Cat/sources.dep | 2 + sensors/SensorsComboDriver/Driver/AlsClient.cpp | 639 +++++++++++++++ sensors/SensorsComboDriver/Driver/BarClient.cpp | 464 +++++++++++ sensors/SensorsComboDriver/Driver/Clients.cpp | 880 +++++++++++++++++++++ sensors/SensorsComboDriver/Driver/Clients.h | 389 +++++++++ sensors/SensorsComboDriver/Driver/Device.cpp | 477 +++++++++++ sensors/SensorsComboDriver/Driver/Driver.cpp | 100 +++ sensors/SensorsComboDriver/Driver/Driver.h | 31 + .../Driver/GeomagneticOrientationClient.cpp | 485 ++++++++++++ .../Driver/GravityVectorClient.cpp | 499 ++++++++++++ sensors/SensorsComboDriver/Driver/GyrClient.cpp | 510 ++++++++++++ sensors/SensorsComboDriver/Driver/MagClient.cpp | 537 +++++++++++++ sensors/SensorsComboDriver/Driver/PrxClient.cpp | 458 +++++++++++ .../Driver/SensorsComboDriver.ctl | 1 + .../Driver/SensorsComboDriver.def | 6 + .../Driver/SensorsComboDriver.inx | Bin 0 -> 5638 bytes .../Driver/SensorsComboDriver.vcxproj | 200 +++++ .../Driver/SensorsComboDriver.vcxproj.Filters | 67 ++ sensors/SensorsComboDriver/Driver/SensorsTrace.h | 100 +++ .../Driver/linearaccelerometerclient.cpp | 507 ++++++++++++ sensors/SensorsComboDriver/Driver/product.pbxproj | 19 + .../Driver/relativefusionclient.cpp | 515 ++++++++++++ sensors/SensorsComboDriver/Driver/sources | 56 ++ sensors/SensorsComboDriver/Driver/sources.dep | 3 + .../Metadata/SensorsComboDriver-gallery.xml | 160 ++++ .../Metadata/SensorsComboDriver.kml | 129 +++ .../Metadata/SensorsComboDriver.sln | 28 + .../SensorsComboDriver/Metadata/product.pbxproj | 11 + sensors/SensorsComboDriver/Metadata/sources | 4 + sensors/SensorsComboDriver/dirs | 4 + 32 files changed, 7308 insertions(+) create mode 100644 sensors/SensorsComboDriver/Cat/product.pbxproj create mode 100644 sensors/SensorsComboDriver/Cat/sources create mode 100644 sensors/SensorsComboDriver/Cat/sources.dep create mode 100644 sensors/SensorsComboDriver/Driver/AlsClient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/BarClient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/Clients.cpp create mode 100644 sensors/SensorsComboDriver/Driver/Clients.h create mode 100644 sensors/SensorsComboDriver/Driver/Device.cpp create mode 100644 sensors/SensorsComboDriver/Driver/Driver.cpp create mode 100644 sensors/SensorsComboDriver/Driver/Driver.h create mode 100644 sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/GyrClient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/MagClient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/PrxClient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl create mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.def create mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx create mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj create mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters create mode 100644 sensors/SensorsComboDriver/Driver/SensorsTrace.h create mode 100644 sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/product.pbxproj create mode 100644 sensors/SensorsComboDriver/Driver/relativefusionclient.cpp create mode 100644 sensors/SensorsComboDriver/Driver/sources create mode 100644 sensors/SensorsComboDriver/Driver/sources.dep create mode 100644 sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml create mode 100644 sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml create mode 100644 sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln create mode 100644 sensors/SensorsComboDriver/Metadata/product.pbxproj create mode 100644 sensors/SensorsComboDriver/Metadata/sources create mode 100644 sensors/SensorsComboDriver/dirs diff --git a/sensors/SensorsComboDriver/Cat/product.pbxproj b/sensors/SensorsComboDriver/Cat/product.pbxproj new file mode 100644 index 00000000..fb8943d8 --- /dev/null +++ b/sensors/SensorsComboDriver/Cat/product.pbxproj @@ -0,0 +1,11 @@ + + + + v110 + Utility + + + + + + \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Cat/sources b/sensors/SensorsComboDriver/Cat/sources new file mode 100644 index 00000000..ad2d5c99 --- /dev/null +++ b/sensors/SensorsComboDriver/Cat/sources @@ -0,0 +1,16 @@ +!undef NT_SIGNCODE + +!undef C_DEFINES +!undef INCLUDES +!undef TARGETLIBS + +TARGETNAME=SensorsComboDriver +TARGETTYPE=CATALOG +TARGET_DESTINATION=NTTEST\drivers\Sensors\V2 + +# 8.1 = 2:6.2 +CATALOG_OS_VERSION_LIST= 2:6.2 \ + +SOURCES= \ + $(OBJ_PATH)\..\driver\$(O)\$(TARGETNAME).dll \ + $(OBJ_PATH)\..\driver\$(O)\$(TARGETNAME).inf \ \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Cat/sources.dep b/sensors/SensorsComboDriver/Cat/sources.dep new file mode 100644 index 00000000..151fbb3f --- /dev/null +++ b/sensors/SensorsComboDriver/Cat/sources.dep @@ -0,0 +1,2 @@ +BUILD_PASS2_CONSUMES= \ + drivers\mobilepc\sensors\samples\sensorscombodriver\driver|PASS2 \ \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/AlsClient.cpp b/sensors/SensorsComboDriver/Driver/AlsClient.cpp new file mode 100644 index 00000000..eb7080a2 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/AlsClient.cpp @@ -0,0 +1,639 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "AlsClient.tmh" + +#define SENSORV2_POOL_TAG_AMBIENT_LIGHT '2LmA' + +#define Als_Initial_MinDataInterval_Ms (10) // 100Hz +#define Als_Initial_Lux_Threshold_Pct (1.0f) // Percent threshold: 100% +#define Als_Initial_Lux_Threshold_Abs (0.0f) // Absolute threshold: 0 lux +#define Als_Initial_Kelvin_Threshold_Abs (100.0f) // Absolute threshold: 100 Kelvins +#define Als_Initial_Chromaticity_X_Threshold_Abs (0.01f) // Absolute threshold: 0.01 of a CIE 1931 chromaticity x coordinate +#define Als_Initial_Chromaticity_Y_Threshold_Abs (0.01f) // Absolute threshold: 0.01 of a CIE 1931 chromaticity y coordinate + +#define AlsDevice_Minimum_Lux (-4.0f) +#define AlsDevice_Maximum_Lux (4.0f) +#define AlsDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define AlsDevice_Range_Lux (AlsDevice_Maximum_Lux - AlsDevice_Minimum_Lux) +#define AlsDevice_Resolution_Lux (AlsDevice_Range_Lux / AlsDevice_Precision) + +// Ambient Light Sensor Unique ID +// {2D2A4524-51E3-4E68-9B0F-5CAEDFB12C02} +DEFINE_GUID(GUID_AlsDevice_UniqueID, + 0x2d2a4524, 0x51e3, 0x4e68, 0x9b, 0xf, 0x5c, 0xae, 0xdf, 0xb1, 0x2c, 0x2); + +// Sensor data +typedef enum +{ + ALS_DATA_TIMESTAMP = 0, + ALS_DATA_LUX, + ALS_DATA_KELVINS, + ALS_DATA_CHROMATICITY_X, + ALS_DATA_CHROMATICITY_Y, + ALS_DATA_ISVALID, + ALS_DATA_COUNT +} ALS_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + ALS_THRESHOLD_LUX_PCT = 0, + ALS_THRESHOLD_LUX_ABS, + ALS_THRESHOLD_KELVINS_ABS, + ALS_THRESHOLD_CHROMATICITY_X_ABS, + ALS_THRESHOLD_CHROMATICITY_Y_ABS, + ALS_THRESHOLD_COUNT +} ALS_THRESHOLD_INDEX; + +// +// Sensor Enumeration Properties +// + +typedef enum +{ + SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX is adding properties to the base SENSOR_ENUMERATION_PROPERTIES_COUNT enum. + SENSOR_ALS_COLOR_CAPABLE, // In order to keep the SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX enum indexing coherent with the SENSOR_ENUMERATION_PROPERTIES_INDEX enum, + // set SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED to the index of the last value in the SENSOR_ENUMERATION_PROPERTIES_INDEX enum + SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT +} SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX; + +typedef enum +{ + SENSOR_PROPERTY_ALS_RESPONSE_CURVE = SENSOR_COMMON_PROPERTY_COUNT, // SENSOR_ALS_PROPERTIES_INDEX is adding SENSOR_PROPERTY_ALS_RESPONSE_CURVE to the base SENSOR_COMMON_PROPERTIES_INDEX enum. + // In order to keep the SENSOR_ALS_PROPERTIES_INDEX enum indexing coherent with the SENSOR_COMMON_PROPERTIES_INDEX enum, + // set SENSOR_PROPERTY_ALS_RESPONSE_CURVE to the index of the last value in the SENSOR_COMMON_PROPERTIES_INDEX enum + SENSOR_ALS_PROPERTY_COUNT +} SENSOR_ALS_PROPERTIES_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +AlsDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! ALS WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! ALS WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_AmbientLight, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"ALS", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_AlsDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(TRUE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + + m_pEnumerationProperties->List[SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED].Key = DEVPKEY_LightSensor_AutoBrightnessPreferred; + InitPropVariantFromBoolean(TRUE, + &(m_pEnumerationProperties->List[SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED].Value)); + + m_pEnumerationProperties->List[SENSOR_ALS_COLOR_CAPABLE].Key = DEVPKEY_LightSensor_ColorCapable; + InitPropVariantFromBoolean(TRUE, + &(m_pEnumerationProperties->List[SENSOR_ALS_COLOR_CAPABLE].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(ALS_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = ALS_DATA_COUNT; + + m_pSupportedDataFields->List[ALS_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[ALS_DATA_LUX] = PKEY_SensorData_LightLevel_Lux; + m_pSupportedDataFields->List[ALS_DATA_KELVINS] = PKEY_SensorData_LightTemperature_Kelvins; + m_pSupportedDataFields->List[ALS_DATA_CHROMATICITY_X] = PKEY_SensorData_LightChromaticityX; + m_pSupportedDataFields->List[ALS_DATA_CHROMATICITY_Y] = PKEY_SensorData_LightChromaticityY; + m_pSupportedDataFields->List[ALS_DATA_ISVALID] = PKEY_SensorData_IsValid; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(ALS_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = ALS_DATA_COUNT; + + m_pData->List[ALS_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[ALS_DATA_TIMESTAMP].Value)); + + m_pData->List[ALS_DATA_LUX].Key = PKEY_SensorData_LightLevel_Lux; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_LUX].Value)); + + m_pData->List[ALS_DATA_KELVINS].Key = PKEY_SensorData_LightTemperature_Kelvins; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_KELVINS].Value)); + + m_pData->List[ALS_DATA_CHROMATICITY_X].Key = PKEY_SensorData_LightChromaticityX; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_CHROMATICITY_X].Value)); + + m_pData->List[ALS_DATA_CHROMATICITY_Y].Key = PKEY_SensorData_LightChromaticityY; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_CHROMATICITY_Y].Value)); + + m_pData->List[ALS_DATA_ISVALID].Key = PKEY_SensorData_IsValid; + InitPropVariantFromBoolean(TRUE, &(m_pData->List[ALS_DATA_ISVALID].Value)); + + m_CachedData = { + 1.0f, // Lux + 1.0f, // Kelvins + 0.5f, // Chromaticity X + 0.5f, // Chromaticity Y + TRUE // IsValid + }; + + m_LastSample = { + 0.0f, // Lux + 0.0f, // Kelvins + 0.0f, // Chromaticity X + 0.0f, // Chromaticity Y + TRUE // IsValid + }; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ALS_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_ALS_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Als_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Als_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = Als_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_AmbientLight, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + + ULONG responseCurve[10] = {}; // Array to contain the response curve data. + + // **************************************************************************************** + // The response curve consists of an array of byte pairs. + // The first byte contains the percentage brightness offset to be applied to the display. + // The second byte contains the corresponding ambient light value (in LUX). + // **************************************************************************************** + // (0, 10) + responseCurve[0] = 0; responseCurve[1] = 10; + // (10, 40) + responseCurve[2] = 10; responseCurve[3] = 40; + // (40, 100) + responseCurve[4] = 40; responseCurve[5] = 100; + // (68, 400) + responseCurve[6] = 68; responseCurve[7] = 400; + // (90, 1000) + responseCurve[8] = 90; responseCurve[9] = 1000; + + m_pProperties->List[SENSOR_PROPERTY_ALS_RESPONSE_CURVE].Key = PKEY_LightSensor_ResponseCurve; + InitPropVariantFromUInt32Vector(responseCurve, + 10, + &(m_pProperties->List[SENSOR_PROPERTY_ALS_RESPONSE_CURVE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(AlsDevice_Resolution_Lux, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(AlsDevice_Minimum_Lux, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(AlsDevice_Maximum_Lux, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(ALS_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = ALS_THRESHOLD_COUNT; + + // Set lux threshold + m_pThresholds->List[ALS_THRESHOLD_LUX_PCT].Key = PKEY_SensorData_LightLevel_Lux; + InitPropVariantFromFloat(Als_Initial_Lux_Threshold_Pct, + &(m_pThresholds->List[ALS_THRESHOLD_LUX_PCT].Value)); + m_CachedThresholds.LuxPct = Als_Initial_Lux_Threshold_Pct; + + m_pThresholds->List[ALS_THRESHOLD_LUX_ABS].Key = PKEY_SensorData_LightLevel_Lux_Threshold_AbsoluteDifference; + InitPropVariantFromFloat(Als_Initial_Lux_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_LUX_ABS].Value)); + m_CachedThresholds.LuxAbs = Als_Initial_Lux_Threshold_Abs; + + // Set kelvins threshold + m_pThresholds->List[ALS_THRESHOLD_KELVINS_ABS].Key = PKEY_SensorData_LightTemperature_Kelvins; + InitPropVariantFromFloat(Als_Initial_Kelvin_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_KELVINS_ABS].Value)); + m_CachedThresholds.KelvinsAbs = Als_Initial_Kelvin_Threshold_Abs; + + // Set chromaticity x threshold + m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_X_ABS].Key = PKEY_SensorData_LightChromaticityX; + InitPropVariantFromFloat(Als_Initial_Chromaticity_X_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_X_ABS].Value)); + m_CachedThresholds.ChromaticityXAbs = Als_Initial_Chromaticity_X_Threshold_Abs; + + // Set chromaticity y threshold + m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_Y_ABS].Key = PKEY_SensorData_LightChromaticityY; + InitPropVariantFromFloat(Als_Initial_Chromaticity_Y_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_Y_ABS].Value)); + m_CachedThresholds.ChromaticityYAbs = Als_Initial_Chromaticity_Y_Threshold_Abs; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +AlsDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime(&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! ALS GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( + ( + // Lux thresholds needs to exceed absolute and percentage + ((abs(m_CachedData.Lux - m_LastSample.Lux) >= (m_LastSample.Lux * m_CachedThresholds.LuxPct)) && + (abs(m_CachedData.Lux - m_LastSample.Lux) >= m_CachedThresholds.LuxAbs)) || + // If IsValid has changed, the sample is valid + (m_CachedData.IsValid != m_LastSample.IsValid) || + // Kelvin temperature and Chromaticity thresholds + (abs(m_CachedData.Kelvins - m_LastSample.Kelvins) >= m_CachedThresholds.KelvinsAbs) || + (abs(m_CachedData.ChromaticityX - m_LastSample.ChromaticityX) >= m_CachedThresholds.ChromaticityXAbs) || + (abs(m_CachedData.ChromaticityY - m_LastSample.ChromaticityY) >= m_CachedThresholds.ChromaticityYAbs) + ) + && + ( + // In thresholded mode, don't send sample if the last sample sent was not IsValid and current sample is also not IsValid + !((m_CachedThresholds.LuxAbs != 0.0f) && (m_CachedThresholds.LuxPct != 0.0f) && + (m_CachedThresholds.KelvinsAbs != 0.0f) && (m_CachedThresholds.ChromaticityXAbs != 0.0f) && + (m_CachedThresholds.ChromaticityYAbs != 0.0f) && !m_CachedData.IsValid && !m_LastSample.IsValid) + ) + ) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample.Lux, &(m_pData->List[ALS_DATA_LUX].Value)); + + InitPropVariantFromFloat(m_LastSample.Kelvins, &(m_pData->List[ALS_DATA_KELVINS].Value)); + + InitPropVariantFromFloat(m_LastSample.ChromaticityX, &(m_pData->List[ALS_DATA_CHROMATICITY_X].Value)); + + InitPropVariantFromFloat(m_LastSample.ChromaticityY, &(m_pData->List[ALS_DATA_CHROMATICITY_Y].Value)); + + InitPropVariantFromBoolean(m_LastSample.IsValid, &(m_pData->List[ALS_DATA_ISVALID].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[ALS_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! ALS Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +AlsDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightLevel_Lux, + &m_CachedThresholds.LuxPct); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get lux pct data from cached threshold %!STATUS!", Status); + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightLevel_Lux_Threshold_AbsoluteDifference, + &m_CachedThresholds.LuxAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get lux abs data from cached threshold %!STATUS!", Status); + } + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightTemperature_Kelvins, + &m_CachedThresholds.KelvinsAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get kelvin data from cached threshold %!STATUS!", Status); + } + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightChromaticityX, + &m_CachedThresholds.ChromaticityXAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get chromaticity x data from cached threshold %!STATUS!", Status); + } + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightChromaticityY, + &m_CachedThresholds.ChromaticityYAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get chromaticity y data from cached threshold %!STATUS!", Status); + } + } + + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/BarClient.cpp b/sensors/SensorsComboDriver/Driver/BarClient.cpp new file mode 100644 index 00000000..97135c59 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/BarClient.cpp @@ -0,0 +1,464 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Clients.h" + +#include "BarClient.tmh" + +#define SENSORV2_POOL_TAG_BAROMETER '2RaB' + +#define Bar_Initial_MinDataInterval_Ms (10) // 100Hz +#define Bar_Initial_Threshold_Bar (0.001f) // 1 mBar ~= 10 meter + +#define BarDevice_Minimum_Bar (0.3f) +#define BarDevice_Maximum_Bar (1.1f) +#define BarDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define BarDevice_Range_Bar (BarDevice_Maximum_Bar - BarDevice_Minimum_Bar) +#define BarDevice_Resolution_Bar (BarDevice_Range_Bar / BarDevice_Precision) + +// Barometer Unique ID +// {46CB48CE-272D-4402-8E09-07748F8940CA} +DEFINE_GUID(GUID_BarDevice_UniqueID, + 0x46cb48ce, 0x272d, 0x4402, 0x8e, 0x9, 0x7, 0x74, 0x8f, 0x89, 0x40, 0xca); + +// Sensor data +typedef enum +{ + BAR_DATA_TIMESTAMP = 0, + BAR_DATA_PRESSURE, + BAR_DATA_COUNT +} BAR_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + BAR_THRESHOLD_PRESSURE = 0, + BAR_THRESHOLD_COUNT +} BAR_THRESHOLD_INDEX; + + + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +BarDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! BAR WdfWaitLockCreate failed %!STATUS!", Status); + } + + // + // Create timer object for polling sensor samples + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! BAR WdfTimerCreate failed %!STATUS!", Status); + } + } + + // + // Sensor Enumeration Properties + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Barometer, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Barometer", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_BarDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + } + + // + // Supported Data-Fields + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(BAR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pSupportedDataFields)); + if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = BAR_DATA_COUNT; + + m_pSupportedDataFields->List[BAR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[BAR_DATA_PRESSURE] = PKEY_SensorData_AtmosphericPressure_Bars; + } + } + + // + // Data + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(BAR_DATA_COUNT); + FILETIME Time = {}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = BAR_DATA_COUNT; + + m_pData->List[BAR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[BAR_DATA_TIMESTAMP].Value)); + + m_pData->List[BAR_DATA_PRESSURE].Key = PKEY_SensorData_AtmosphericPressure_Bars; + InitPropVariantFromFloat(0.0f, &(m_pData->List[BAR_DATA_PRESSURE].Value)); + + m_CachedData = 1.013f; + m_LastSample = 0.0f; + } + } + + // + // Sensor Properties + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Bar_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Bar_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = Bar_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Barometer, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + } + + // + // Data filed properties + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(BarDevice_Resolution_Bar, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(BarDevice_Minimum_Bar, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(BarDevice_Maximum_Bar, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + } + + // + // Set default threshold + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(BAR_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = BAR_THRESHOLD_COUNT; + + m_pThresholds->List[BAR_THRESHOLD_PRESSURE].Key = PKEY_SensorData_AtmosphericPressure_Bars; + InitPropVariantFromFloat(Bar_Initial_Threshold_Bar, + &(m_pThresholds->List[BAR_THRESHOLD_PRESSURE].Value)); + + m_CachedThresholds = Bar_Initial_Threshold_Bar; + m_FirstSample = TRUE; + } + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +BarDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (FALSE != m_FirstSample) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! BAR GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ((abs(m_CachedData - m_LastSample) >= m_CachedThresholds)) + { + DataReady = TRUE; + } + } + + if (FALSE != DataReady) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample, &(m_pData->List[BAR_DATA_PRESSURE].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[BAR_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! BAR Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +BarDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AtmosphericPressure_Bars, + &m_CachedThresholds); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! BAR PropKeyFindKeyGetFloat for pressure failed %!STATUS!", Status); + } + + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/Clients.cpp b/sensors/SensorsComboDriver/Driver/Clients.cpp new file mode 100644 index 00000000..4524b6b6 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/Clients.cpp @@ -0,0 +1,880 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of driver callback function +// from clx to clients. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "Clients.tmh" + +static const UINT SYSTEM_TICK_COUNT_1MS = 1; // 1ms +//------------------------------------------------------------------------------ +// Function: OnTimerExpire +// +// This callback is called when interval wait time has expired and driver is ready +// to collect new sample. The callback reads current value, compare value to threshold, +// pushes it up to CLX framework, and schedule next wake up time. +// +// Arguments: +// Timer: IN: WDF timer object +// +// Return Value: +// None +//------------------------------------------------------------------------------ +VOID +OnTimerExpire( + _In_ WDFTIMER Timer + ) +{ + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + pDevice = GetContextFromSensorInstance(WdfTimerGetParentObject(Timer)); + if (pDevice == nullptr) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // Get data and push to clx + Lock(pDevice->m_Lock); + Status = pDevice->GetData(); + if (!NT_SUCCESS(Status) && Status != STATUS_DATA_NOT_ACCEPTED) + { + TraceError("COMBO %!FUNC! GetData Failed %!STATUS!", Status); + } + Unlock(pDevice->m_Lock); + + // Schedule next wake up time + if (pDevice->m_MinimumIntervalMs <= pDevice->m_IntervalMs && + FALSE != pDevice->m_PoweredOn && + FALSE != pDevice->m_Started) + { + LONGLONG WaitTime = 0; // in unit of 100ns + + if (pDevice->m_StartTime == 0) + { + // in case we fail to get sensor start time, use static wait time + WaitTime = WDF_REL_TIMEOUT_IN_MS(pDevice->m_IntervalMs); + } + else + { + ULONG CurrentTimeMs = 0; + + // dynamically calculate wait time to avoid jitter + Status = GetPerformanceTime (&CurrentTimeMs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GetPerformanceTime %!STATUS!", Status); + WaitTime = WDF_REL_TIMEOUT_IN_MS(pDevice->m_IntervalMs); + } + else + { + pDevice->m_SampleCount++; + if (CurrentTimeMs > (pDevice->m_StartTime + (pDevice->m_IntervalMs * (pDevice->m_SampleCount + 1)))) + { + // If we skipped two or more beats, reschedule the timer with a zero due time to catch up on missing samples + WaitTime = 0; + } + else + { + // Else, just compute the remaining time + WaitTime = (pDevice->m_StartTime + + (pDevice->m_IntervalMs * (pDevice->m_SampleCount + 1))) - CurrentTimeMs; + } + + WaitTime = WDF_REL_TIMEOUT_IN_MS(WaitTime); + } + } + + WdfTimerStart(pDevice->m_Timer, WaitTime); + } + +Exit: + + SENSOR_FunctionExit(Status); +} + + + +//------------------------------------------------------------------------------ +// Function: OnStart +// +// Called by Sensor CLX to begin continously sampling the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnStart( + _In_ SENSOROBJECT SensorInstance + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Sensor(%p) parameter is invalid. Failed %!STATUS!", static_cast(&SensorInstance), Status); + goto Exit; + } + + if (pDevice->m_PoweredOn == FALSE) + { + Status = STATUS_DEVICE_NOT_READY; + TraceError("COMBO %!FUNC! Sensor is not powered on! %!STATUS!", Status); + goto Exit; + } + + // + // Start worker thread + // + + pDevice->m_IntervalMs; + + pDevice->m_FirstSample = TRUE; + + // Start polling + + pDevice->m_Started = TRUE; + + InitPropVariantFromUInt32(SensorState_Active, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(pDevice->m_MinimumIntervalMs)); + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnStop +// +// Called by Sensor CLX to stop continously sampling the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnStop( + _In_ SENSOROBJECT SensorInstance + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Sensor(%p) parameter is invalid. Failed %!STATUS!", static_cast(&SensorInstance), Status); + goto Exit; + } + + // Stop polling + + pDevice->m_Started = FALSE; + + WdfTimerStop(pDevice->m_Timer, TRUE); + + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + // + // Restoring system time resolution + // + if (TIMERR_NOERROR != timeEndPeriod(SYSTEM_TICK_COUNT_1MS)) + { + // not a failure, just log message + Status = STATUS_UNSUCCESSFUL; + TraceWarning("COMBO %!FUNC! timeEndPeriod failed to restore timer resolution! %!STATUS!", Status); + } + +Exit: + SENSOR_FunctionExit(Status); + + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetSupportedDataFields +// +// Called by Sensor CLX to get supported data fields. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pFields: INOUT_OPT: pointer to a list of supported properties +// pSize: OUT: number of bytes for the list of supported properties +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetSupportedDataFields( + _In_ SENSOROBJECT SensorInstance, + _Inout_opt_ PSENSOR_PROPERTY_LIST pFields, + _Out_ PULONG pSize + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (nullptr == pFields) + { + // Just return size + *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; + } + else + { + if (pFields->AllocatedSizeInBytes < pDevice->m_pSupportedDataFields->AllocatedSizeInBytes) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out data + Status = PropertiesListCopy (pFields, pDevice->m_pSupportedDataFields); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! PropertiesListCopy failed %!STATUS!", Status); + goto Exit; + } + + *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetProperties +// +// Called by Sensor CLX to get sensor properties. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pProperties: INOUT_OPT: pointer to a list of sensor properties +// pSize: OUT: number of bytes for the list of sensor properties +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetProperties( + _In_ SENSOROBJECT SensorInstance, + _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, + _Out_ PULONG pSize + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (nullptr == pProperties) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); + } + else + { + if (pProperties->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pProperties)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall(pProperties, pDevice->m_pProperties); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + +//------------------------------------------------------------------------------ +// Function: OnGetDataFieldProperties +// +// Called by Sensor CLX to get data field properties. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// DataField: IN: pointer to the propertykey of requested property +// pProperties: INOUT_OPT: pointer to a list of sensor properties +// pSize: OUT: number of bytes for the list of sensor properties +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetDataFieldProperties( + _In_ SENSOROBJECT SensorInstance, + _In_ const PROPERTYKEY *DataField, + _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, + _Out_ PULONG pSize +) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize || nullptr == DataField) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (IsKeyPresentInPropertyList(pDevice->m_pSupportedDataFields, DataField) != FALSE) + { + if (nullptr == pProperties) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties); + } + else + { + if (pProperties->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall (pProperties, pDevice->m_pDataFieldProperties); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties); + } + } + else + { + Status = STATUS_NOT_SUPPORTED; + TraceError("COMBO %!FUNC! Sensor does NOT have properties for this data field. Failed %!STATUS!", Status); + goto Exit; + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetDataInterval +// +// Called by Sensor CLX to get sampling rate of the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// DataRateMs: OUT: sampling rate in ms +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetDataInterval( + _In_ SENSOROBJECT SensorInstance, + _Out_ PULONG DataRateMs + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameter!"); + goto Exit; + } + + if (DataRateMs == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! DataRateMs(%p) parameter is invalid. Failed %!STATUS!", static_cast(DataRateMs), Status); + goto Exit; + } + + *DataRateMs = pDevice->m_IntervalMs; + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnSetDataInterval +// +// Called by Sensor CLX to set sampling rate of the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// DataRateMs: IN: sampling rate in ms +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnSetDataInterval( + _In_ SENSOROBJECT SensorInstance, + _In_ ULONG DataRateMs + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr || DataRateMs == 0) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameter!"); + goto Exit; + } + + pDevice->m_IntervalMs = DataRateMs; + + // reschedule sample to return as soon as possible if it's started + if (FALSE != pDevice->m_Started) + { + pDevice->m_Started = FALSE; + WdfTimerStop(pDevice->m_Timer, TRUE); + + pDevice->m_Started = TRUE; + pDevice->m_FirstSample = TRUE; + WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(pDevice->m_MinimumIntervalMs)); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetDataThresholds +// +// Called by Sensor CLX to get data thresholds. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pThresholds: INOUT_OPT: pointer to a list of sensor thresholds +// pSize: OUT: number of bytes for the list of sensor thresholds +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetDataThresholds( + _In_ SENSOROBJECT SensorInstance, + _Inout_opt_ PSENSOR_COLLECTION_LIST pThresholds, + _Out_ PULONG pSize + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters!"); + goto Exit; + } + + if (nullptr == pThresholds) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); + } + else + { + if (pThresholds->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pThresholds)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small!"); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall (pThresholds, pDevice->m_pThresholds); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnSetDataThresholds +// +// Called by Sensor CLX to set data thresholds. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pThresholds: IN: pointer to a list of sensor thresholds +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnSetDataThresholds( + _In_ SENSOROBJECT SensorInstance, + _In_ PSENSOR_COLLECTION_LIST pThresholds + ) +{ + ULONG Element; + BOOLEAN IsLocked = FALSE; + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameter!"); + goto Exit; + } + + Lock(pDevice->m_Lock); + IsLocked = TRUE; + + for (Element = 0; Element < pThresholds->Count; Element++) + { + Status = PropKeyFindKeySetPropVariant(pDevice->m_pThresholds, + &(pThresholds->List[Element].Key), + TRUE, + &(pThresholds->List[Element].Value)); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Sensor does NOT have threshold for this data field. Failed %!STATUS!", Status); + goto Exit; + } + } + + // Update cached threshholds + Status = pDevice->UpdateCachedThreshold(); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! UpdateCachedThreshold failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + if (IsLocked) + { + Unlock(pDevice->m_Lock); + IsLocked = FALSE; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnIoControl +// +// Called by Sensor CLX to handle IOCTLs that clx does not support +// +// Arguments: +// SensorInstance: IN: Sensor object +// Request: IN: WDF request object +// OutputBufferLength: IN: number of bytes to retrieve from output buffer +// InputBufferLength: IN: number of bytes to retrieve from input buffer +// IoControlCode: IN: IOCTL control code +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS OnIoControl( + _In_ SENSOROBJECT /*SensorInstance*/, // Sensor object + _In_ WDFREQUEST /*Request*/, // WDF request object + _In_ size_t /*OutputBufferLength*/, // number of bytes to retrieve from output buffer + _In_ size_t /*InputBufferLength*/, // number of bytes to retrieve from input buffer + _In_ ULONG /*IoControlCode*/ // IOCTL control code + ) +{ + NTSTATUS Status = STATUS_NOT_SUPPORTED; + + SENSOR_FunctionEnter(); + + SENSOR_FunctionExit(Status); + return Status; +} + + + +// Called by Sensor CLX to begin keeping history +NTSTATUS OnStartHistory(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->StartHistory(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to stop keeping history. +NTSTATUS OnStopHistory(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->StopHistory(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to enable wake +NTSTATUS OnEnableWake(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + pDevice->m_WakeEnabled = TRUE; + Status = pDevice->EnableWake(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to disable wake +NTSTATUS OnDisableWake(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + pDevice->m_WakeEnabled = FALSE; + Status = pDevice->DisableWake(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to clear all history stored in the sensor. +NTSTATUS OnClearHistory(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->ClearHistory(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to start retrieving history. +NTSTATUS OnStartHistoryRetrieval( + _In_ SENSOROBJECT SensorInstance, + _Inout_updates_bytes_(HistorySizeInBytes) PSENSOR_COLLECTION_LIST pHistoryBuffer, + _In_ ULONG HistorySizeInBytes) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else if (sizeof(SENSOR_COLLECTION_LIST) > HistorySizeInBytes) + { + Status = STATUS_BUFFER_TOO_SMALL; + TraceError("COMBO %!FUNC! HistorySizeInBytes is too small %!STATUS!", Status); + } + else + { + Status = pDevice->StartHistoryRetrieval(pHistoryBuffer, HistorySizeInBytes); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to cancel history retrieval. +NTSTATUS OnCancelHistoryRetrieval(_In_ SENSOROBJECT SensorInstance, _Out_ PULONG pBytesWritten) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->CancelHistoryRetrieval(pBytesWritten); + } + + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/Clients.h b/sensors/SensorsComboDriver/Driver/Clients.h new file mode 100644 index 00000000..a8992fa7 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/Clients.h @@ -0,0 +1,389 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved +// +// Abstract: +// +// This module contains the type definitions for the client +// driver's device callback class. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#pragma once + +#include +#include +#include +#include + +#include "SensorsTrace.h" +#include +#include + +// +// CLX Callbacks +// +EVT_SENSOR_DRIVER_START_SENSOR OnStart; +EVT_SENSOR_DRIVER_STOP_SENSOR OnStop; +EVT_SENSOR_DRIVER_GET_SUPPORTED_DATA_FIELDS OnGetSupportedDataFields; +EVT_SENSOR_DRIVER_GET_PROPERTIES OnGetProperties; +EVT_SENSOR_DRIVER_GET_DATA_FIELD_PROPERTIES OnGetDataFieldProperties; +EVT_SENSOR_DRIVER_GET_DATA_INTERVAL OnGetDataInterval; +EVT_SENSOR_DRIVER_SET_DATA_INTERVAL OnSetDataInterval; +EVT_SENSOR_DRIVER_GET_DATA_THRESHOLDS OnGetDataThresholds; +EVT_SENSOR_DRIVER_SET_DATA_THRESHOLDS OnSetDataThresholds; +EVT_SENSOR_DRIVER_DEVICE_IO_CONTROL OnIoControl; +EVT_SENSOR_DRIVER_START_SENSOR_HISTORY OnStartHistory; +EVT_SENSOR_DRIVER_STOP_SENSOR_HISTORY OnStopHistory; +EVT_SENSOR_DRIVER_CLEAR_SENSOR_HISTORY OnClearHistory; +EVT_SENSOR_DRIVER_START_HISTORY_RETRIEVAL OnStartHistoryRetrieval; +EVT_SENSOR_DRIVER_CANCEL_HISTORY_RETRIEVAL OnCancelHistoryRetrieval; +EVT_SENSOR_DRIVER_ENABLE_WAKE OnEnableWake; +EVT_SENSOR_DRIVER_DISABLE_WAKE OnDisableWake; + +EVT_WDF_TIMER OnTimerExpire; + + +/*++ +Routine Description: + Critical section lock/unlock to protect shared context +Return Value: + None +--*/ +#define Lock(lock) { WdfWaitLockAcquire(lock, NULL); } +#define Unlock(lock) { WdfWaitLockRelease(lock); } + +#define SENSORV2_POOL_TAG_COMBO '2bmC' + +// +// Sensor Enumeration Properties +// +typedef enum +{ + SENSOR_TYPE_GUID = 0, + SENSOR_MANUFACTURER, + SENSOR_MODEL, + SENSOR_CONNECTION_TYPE, + SENSOR_PERSISTENT_UNIQUEID, + SENSOR_ISPRIMARY, + SENSOR_ENUMERATION_PROPERTIES_COUNT +} SENSOR_ENUMERATION_PROPERTIES_INDEX; + +enum class SensorConnectionType : ULONG +{ + Integrated = 0, + Attached = 1, + External = 2 +}; + +// +// Data-field Properties +// +typedef enum +{ + SENSOR_RESOLUTION = 0, + SENSOR_MIN_RANGE, + SENSOR_MAX_RANGE, + SENSOR_DATA_FIELD_PROPERTY_COUNT +} SENSOR_DATA_FIELD_PROPERTY_INDEX; + +// +// Sensor Common Properties +// +typedef enum +{ + SENSOR_COMMON_PROPERTY_STATE = 0, + SENSOR_COMMON_PROPERTY_MIN_INTERVAL, + SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE, + SENSOR_COMMON_PROPERTY_TYPE, + SENSOR_COMMON_PROPERTY_COUNT +} SENSOR_COMMON_PROPERTIES_INDEX; + + + +// +// Base --------------------------------------------------------------------- +// +typedef class _ComboDevice +{ +public: + // + // WDF + // + WDFDEVICE m_Device; + SENSOROBJECT m_SensorInstance; + WDFWAITLOCK m_Lock; + WDFTIMER m_Timer; + + // + // Sensor Operation + // + BOOLEAN m_PoweredOn; + BOOLEAN m_Started; + ULONG m_IntervalMs; + ULONG m_MinimumIntervalMs; + BOOLEAN m_FirstSample; + ULONG m_StartTime; + ULONGLONG m_SampleCount; + BOOLEAN m_WakeEnabled; + + // + // Sensor Specific Properties + // + PSENSOR_COLLECTION_LIST m_pEnumerationProperties; + PSENSOR_COLLECTION_LIST m_pProperties; + PSENSOR_PROPERTY_LIST m_pSupportedDataFields; + PSENSOR_COLLECTION_LIST m_pDataFieldProperties; + PSENSOR_COLLECTION_LIST m_pThresholds; + PSENSOR_COLLECTION_LIST m_pData; + +public: + // + // Sensor specific functions + // + virtual NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj) = NULL; + virtual NTSTATUS GetData() = NULL; + virtual NTSTATUS UpdateCachedThreshold() = NULL; + virtual NTSTATUS EnableWake() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS DisableWake() { return STATUS_NOT_SUPPORTED; } + + // + // History functions - none of the sensors in this driver actually support history yet, this is for testing purpose now. + // + virtual NTSTATUS StartHistory() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS StopHistory() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS ClearHistory() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS StartHistoryRetrieval(_Inout_ PSENSOR_COLLECTION_LIST /*pHistoryBuffer*/, _In_ ULONG /*HistorySizeInBytes*/) { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS CancelHistoryRetrieval(_Out_ PULONG /*pBytesWritten*/) { return STATUS_NOT_SUPPORTED; } + +} ComboDevice, *PComboDevice; + +// Set up accessor function to retrieve device context +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ComboDevice, GetContextFromSensorInstance); + + +// +// Ambient Light -------------------------------------------------------------- +// +typedef class _AlsDevice : public _ComboDevice +{ +private: + // Internal struct used to store readings + typedef struct _AlsData + { + FLOAT Lux; + FLOAT Kelvins; + FLOAT ChromaticityX; + FLOAT ChromaticityY; + BOOL IsValid; + } AlsData, *PAlsData; + + // Internal struct used to store thresholds + typedef struct _AlsThresholdData + { + FLOAT LuxPct; + FLOAT LuxAbs; + FLOAT KelvinsAbs; + FLOAT ChromaticityXAbs; + FLOAT ChromaticityYAbs; + } AlsThresholdData; + +private: + + AlsThresholdData m_CachedThresholds; + AlsData m_CachedData; + AlsData m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} AlsDevice, *PAlsDevice; + + + +// +// Barometer -------------------------------------------------------------- +// +typedef class _BarDevice : public _ComboDevice +{ +private: + + FLOAT m_CachedThresholds; + FLOAT m_CachedData; + FLOAT m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} BarDevice, *PBarDevice; + + + +// +// Gyroscope ------------------------------------------------------------------ +// +typedef class _GyrDevice : public _ComboDevice +{ +private: + + VEC3D m_CachedThresholds; + VEC3D m_CachedData; + VEC3D m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} GyrDevice, *PGyrDevice; + + + +// +// Magnetometer --------------------------------------------------------------- +// +typedef struct _MagData +{ + VEC3D Axis; + ULONG Accuracy; +} MagData, *PMagData; + +typedef class _MagDevice : public _ComboDevice +{ +private: + + VEC3D m_CachedThresholds; + MagData m_CachedData; + MagData m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} MagDevice, *PMagDevice; + + + +// +// Proximity ------------------------------------------------------------------ +// +typedef struct +{ + BOOL Detected; + ULONG DistanceMillimeters; +} PrxData, *PPrxData; + +typedef class _PrxDevice : public _ComboDevice +{ +private: + + PrxData m_CachedData; + PrxData m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} PrxDevice, *PPrxDevice; + + + +// +// Relative Fusion ------------------------------------------------------------------ +// +typedef class _RelativeFusionDevice : public _ComboDevice +{ +private: + + QUATERNION m_CachedThresholds; + QUATERNION m_CachedData; + QUATERNION m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} RelativeFusionDevice, *PRelativeFusionDevice; + +// +// Linear Accelerometer -------------------------------------------------------------- +// +typedef class _LinearAccelerometerDevice : public _ComboDevice +{ +private: + + typedef struct _LinearAccelerometerSample + { + VEC3D Axis; + BOOL Shake; + } LinearAccelerometerSample, *PLinearAccelerometerSample; + + LinearAccelerometerSample m_CachedThresholds; + LinearAccelerometerSample m_CachedData; + LinearAccelerometerSample m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} LinearAccelerometerDevice, *PLinearAccelerometerDevice; + +// +// Gravity Vector -------------------------------------------------------------- +// +typedef class _GravityVectorDevice : public _ComboDevice +{ +private: + + VEC3D m_CachedThresholds; + VEC3D m_CachedData; + VEC3D m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} GravityVectorDevice, *PGravityVectorDevice; + +// +// Geomagnetic Orientation ------------------------------------------------------------------ +// +typedef class _GeomagneticOrientationDevice : public _ComboDevice +{ +private: + + typedef struct _GeomagneticOrientationSample + { + QUATERNION Quaternion; + FLOAT RotationAngle_Degrees; + FLOAT DeclinationAngle_Degrees; + } GeomagneticOrientationSample, *PGeomagneticOrientationSample; + + GeomagneticOrientationSample m_CachedThresholds; + GeomagneticOrientationSample m_CachedData; + GeomagneticOrientationSample m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} GeomagneticOrientationDevice, *PGeomagneticOrientationDevice; diff --git a/sensors/SensorsComboDriver/Driver/Device.cpp b/sensors/SensorsComboDriver/Driver/Device.cpp new file mode 100644 index 00000000..b93bbbd1 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/Device.cpp @@ -0,0 +1,477 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of WDF callback functions +// for combo driver. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" +#include "Driver.h" + +#include + +#include "Device.tmh" + +//--------------------------------------- +// Declare and map devices below +//--------------------------------------- +enum Device +{ + Device_Als = 0, + Device_Bar, + Device_GeomagneticOrientation, + Device_GravityVector, + Device_Gyr, + Device_LinearAccelerometer, + Device_Mag, + Device_Prx, + Device_RelativeFusion, + // Keep this last + Device_Count +}; + +static const ULONG SensorInstanceCount = Device_Count; +static SENSOROBJECT SensorInstancesBuffer[SensorInstanceCount]; // Global buffer to avoid allocate and free + +inline size_t GetDeviceSizeAtIndex( + _In_ ULONG Index) +{ + size_t result = 0; + switch (static_cast(Index)) + { + case Device_Als: result = sizeof(AlsDevice); break; + case Device_Bar: result = sizeof(BarDevice); break; + case Device_GeomagneticOrientation: result = sizeof(GeomagneticOrientationDevice); break; + case Device_GravityVector: result = sizeof(GravityVectorDevice); break; + case Device_Gyr: result = sizeof(GyrDevice); break; + case Device_LinearAccelerometer: result = sizeof(LinearAccelerometerDevice); break; + case Device_Mag: result = sizeof(MagDevice); break; + case Device_Prx: result = sizeof(PrxDevice); break; + case Device_RelativeFusion: result = sizeof(RelativeFusionDevice); break; + default: break; // invalid + } + return result; +} + +void AllocateDeviceAtIndex( + _In_ ULONG Index, + _Inout_ PComboDevice* ppDevice + ) +{ + switch (static_cast(Index)) + { + case Device_Als: *ppDevice = new(*ppDevice) AlsDevice; break; + case Device_Bar: *ppDevice = new(*ppDevice) BarDevice; break; + case Device_GeomagneticOrientation: *ppDevice = new(*ppDevice) GeomagneticOrientationDevice; break; + case Device_GravityVector: *ppDevice = new(*ppDevice) GravityVectorDevice; break; + case Device_Gyr: *ppDevice = new(*ppDevice) GyrDevice; break; + case Device_LinearAccelerometer: *ppDevice = new(*ppDevice) LinearAccelerometerDevice; break; + case Device_Mag: *ppDevice = new(*ppDevice) MagDevice; break; + case Device_Prx: *ppDevice = new(*ppDevice) PrxDevice; break; + case Device_RelativeFusion: *ppDevice = new(*ppDevice) RelativeFusionDevice; break; + + default: break; // invalid (let driver fail) + } +} + +//------------------------------------------------------------------------------ +// +// Function: OnDeviceAdd +// +// This routine is the AddDevice entry point for the combo client +// driver. This routine is called by the framework in response to AddDevice +// call from the PnP manager. It will create and initialize the device object +// to represent a new instance of the sensor client. +// +// Arguments: +// Driver: IN: Supplies a handle to the driver object created in DriverEntry +// DeviceInit: IN: Supplies a pointer to a framework-allocated WDFDEVICE_INIT structure +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnDeviceAdd( + _In_ WDFDRIVER /*Driver*/, + _Inout_ PWDFDEVICE_INIT pDeviceInit + ) +{ + WDF_PNPPOWER_EVENT_CALLBACKS Callbacks; + WDFDEVICE Device; + WDF_OBJECT_ATTRIBUTES FdoAttributes; + ULONG Flag = 0; + SENSOR_CONTROLLER_CONFIG SensorConfig; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + WDF_OBJECT_ATTRIBUTES_INIT(&FdoAttributes); + + // + // Initialize FDO attributes and set up file object with sensor extension + // + Status = SensorsCxDeviceInitConfig(pDeviceInit, &FdoAttributes, Flag); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorsCxDeviceInitConfig failed %!STATUS!", Status); + goto Exit; + } + + // + // Register the PnP callbacks with the framework. + // + WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&Callbacks); + Callbacks.EvtDevicePrepareHardware = OnPrepareHardware; + Callbacks.EvtDeviceReleaseHardware = OnReleaseHardware; + Callbacks.EvtDeviceD0Entry = OnD0Entry; + Callbacks.EvtDeviceD0Exit = OnD0Exit; + + WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &Callbacks); + + // + // Call the framework to create the device + // + Status = WdfDeviceCreate(&pDeviceInit, &FdoAttributes, &Device); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! WdfDeviceCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Register CLX callback function pointers + // + SENSOR_CONTROLLER_CONFIG_INIT(&SensorConfig); + SensorConfig.DriverIsPowerPolicyOwner = WdfUseDefault; + + SensorConfig.EvtSensorStart = OnStart; + SensorConfig.EvtSensorStop = OnStop; + SensorConfig.EvtSensorGetSupportedDataFields = OnGetSupportedDataFields; + SensorConfig.EvtSensorGetDataInterval = OnGetDataInterval; + SensorConfig.EvtSensorSetDataInterval = OnSetDataInterval; + SensorConfig.EvtSensorGetDataFieldProperties = OnGetDataFieldProperties; + SensorConfig.EvtSensorGetDataThresholds = OnGetDataThresholds; + SensorConfig.EvtSensorSetDataThresholds = OnSetDataThresholds; + SensorConfig.EvtSensorGetProperties = OnGetProperties; + SensorConfig.EvtSensorDeviceIoControl = OnIoControl; + SensorConfig.EvtSensorStartHistory = OnStartHistory; + SensorConfig.EvtSensorStopHistory = OnStopHistory; + SensorConfig.EvtSensorClearHistory = OnClearHistory; + SensorConfig.EvtSensorStartHistoryRetrieval = OnStartHistoryRetrieval; + SensorConfig.EvtSensorCancelHistoryRetrieval = OnCancelHistoryRetrieval; + SensorConfig.EvtSensorEnableWake = OnEnableWake; + SensorConfig.EvtSensorDisableWake = OnDisableWake; + + // + // Set up power capabilities and IO queues + // + Status = SensorsCxDeviceInitialize(Device, &SensorConfig); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorDeviceInitialize failed %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + +//------------------------------------------------------------------------------ +// +// Function: OnPrepareHardware +// +// This routine is called by the framework when the PnP manager sends an +// IRP_MN_START_DEVICE request to the driver stack. This routine is +// responsible for performing operations that are necessary to make the +// driver's device operational (for e.g. mapping the hardware resources +// into memory). +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// ResourcesRaw: IN: Supplies a handle to a collection of framework resource +// objects. This collection identifies the raw (bus-relative) hardware +// resources that have been assigned to the device. +// ResourcesTranslated: IN: Supplies a handle to a collection of framework +// resource objects. This collection identifies the translated +// (system-physical) hardware resources that have been assigned to the +// device. The resources appear from the CPU's point of view. +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnPrepareHardware( + _In_ WDFDEVICE Device, + _In_ WDFCMRESLIST /*ResourcesRaw*/, + _In_ WDFCMRESLIST /*ResourcesTranslated*/ + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + for (ULONG Count = 0; Count < SensorInstanceCount; Count++) + { + PComboDevice pDevice = nullptr; + WDF_OBJECT_ATTRIBUTES SensorAttr; + SENSOR_CONFIG SensorConfig; + SENSOROBJECT SensorInstance; + + // Create WDFOBJECT for the sensor + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&SensorAttr, ComboDevice); + SensorAttr.ContextSizeOverride = GetDeviceSizeAtIndex(Count); + + // Register sensor instance with clx + Status = SensorsCxSensorCreate(Device, &SensorAttr, &SensorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorsCxSensorCreate failed %!STATUS!", Status); + goto Exit; + } + + pDevice = GetContextFromSensorInstance(SensorInstance); + if (nullptr == pDevice) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + AllocateDeviceAtIndex(Count, &pDevice); + + // Fill out properties + Status = pDevice->Initialize(Device, SensorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Initialize device object failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_CONFIG_INIT(&SensorConfig); + SensorConfig.pEnumerationList = pDevice->m_pEnumerationProperties; + Status = SensorsCxSensorInitialize(SensorInstance, &SensorConfig); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorsCxSensorInitialize failed %!STATUS!", Status); + goto Exit; + } + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// +// Function: OnReleaseHardware +// +// This routine is called by the framework when the PnP manager is revoking +// ownership of our resources. This may be in response to either +// IRP_MN_STOP_DEVICE or IRP_MN_REMOVE_DEVICE. This routine is responsible for +// performing cleanup of resources allocated in PrepareHardware callback. +// This callback is invoked before passing the request down to the lower driver. +// This routine will also be invoked by the framework if the prepare hardware +// callback returns a failure. +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// ResourcesTranslated: IN: Supplies a handle to a collection of framework +// resource objects. This collection identifies the translated +// (system-physical) hardware resources that have been assigned to the +// device. The resources appear from the CPU's point of view. +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnReleaseHardware( + _In_ WDFDEVICE Device, + _In_ WDFCMRESLIST /*ResourcesTranslated*/ + ) +{ + ULONG Count = SensorInstanceCount; + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + for (Count = 0; Count < SensorInstanceCount; Count++) + { + pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // Delete lock + if (NULL != pDevice->m_Lock) + { + WdfObjectDelete(pDevice->m_Lock); + pDevice->m_Lock = NULL; + } + + // Delete sensor instance + if (NULL != pDevice->m_SensorInstance) + { + WdfObjectDelete(pDevice->m_SensorInstance); + // The pDevice context created using WdfMemoryCreate and parented to m_SensorInstance is automatically + // destroyed when m_SensorInstance is deleted. pDevice is therefore no longer accessible beyond the above call to WdfObjectDelete. + // We can therefore not set the m_SensorInstance member back to NULL. We instead set pDevice to nullptr. + pDevice = nullptr; + } + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// +// Function: OnD0Entry +// +// This routine is invoked by the framework to program the device to goto +// D0, which is the working state. The framework invokes callback every +// time the hardware needs to be (re-)initialized. This includes after +// IRP_MN_START_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE, +// and IRP_MN_SET_POWER-D0. +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// PreviousState: IN: WDF_POWER_DEVICE_STATE-typed enumerator that identifies +// the device power state that the device was in before this transition to D0 +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnD0Entry( + _In_ WDFDEVICE Device, + _In_ WDF_POWER_DEVICE_STATE /*PreviousState*/ + ) +{ + ULONG Count = SensorInstanceCount; + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Get sensor instances + // + Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + // + // Powering on all sensor instances + // + for (Count = 0; Count < SensorInstanceCount; Count++) + { + pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + pDevice->m_PoweredOn = TRUE; + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// +// Function: OnD0Exit +// +// This routine is invoked by the framework to program the device to go into +// a certain Dx state. The framework invokes callback every the the device is +// leaving the D0 state, which happens when the device is stopped, when it is +// removed, and when it is powered off. +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// TargetState: IN: Supplies the device power state which the device will be put +// in once the callback is complete +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnD0Exit( + _In_ WDFDEVICE Device, + _In_ WDF_POWER_DEVICE_STATE /*TargetState*/ + ) +{ + ULONG Count = SensorInstanceCount; + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Get sensor instances + // + Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + // + // Powering off all sensor instances + // + for (Count = 0; Count < SensorInstanceCount; Count++) + { + pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + pDevice->m_PoweredOn = FALSE; + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} diff --git a/sensors/SensorsComboDriver/Driver/Driver.cpp b/sensors/SensorsComboDriver/Driver/Driver.cpp new file mode 100644 index 00000000..1ebc7a01 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/Driver.cpp @@ -0,0 +1,100 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of entry and exit point of combo driver. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" +#include "Driver.h" + +#include "Driver.tmh" + +//------------------------------------------------------------------------------ +// Function: DriverEntry +// +// This routine is the driver initialization entry point. +// +// Arguments: +// DriverObject: IN: Pointer to the driver object created by the I/O manager +// RegistryPath: IN: Pointer to the driver specific registry key +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +DriverEntry( + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath + ) +{ + WDF_DRIVER_CONFIG DriverConfig; + NTSTATUS Status = STATUS_SUCCESS; + + // + // Initialize WPP Tracing + // + WPP_INIT_TRACING(DriverObject, NULL); + + SENSOR_FunctionEnter(); + + DriverConfig.DriverPoolTag = SENSORV2_POOL_TAG_COMBO; + + // + // Initialize the driver configuration structure. + // + WDF_DRIVER_CONFIG_INIT(&DriverConfig, OnDeviceAdd); + DriverConfig.EvtDriverUnload = OnDriverUnload; + + // + // Create a framework driver object to represent our driver. + // + Status = WdfDriverCreate(DriverObject, + RegistryPath, + WDF_NO_OBJECT_ATTRIBUTES, + &DriverConfig, + WDF_NO_HANDLE); + + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! WdfDriverCreate failed: %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnDriverUnload +// +// This routine is called when the driver unloads. +// +// Arguments: +// Driver: IN: driver object +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +VOID +OnDriverUnload( + _In_ WDFDRIVER Driver + ) +{ + SENSOR_FunctionEnter(); + + UNREFERENCED_PARAMETER(Driver); + + SENSOR_FunctionExit(STATUS_SUCCESS); + + WPP_CLEANUP(Driver); + + return; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/Driver.h b/sensors/SensorsComboDriver/Driver/Driver.h new file mode 100644 index 00000000..de307270 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/Driver.h @@ -0,0 +1,31 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved +// +// Abstract: +// +// This module contains the type definitions for the combo +// driver callback class. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#pragma once + +WDF_EXTERN_C_START + +// +// Driver Entry/Exit Functions +// +DRIVER_INITIALIZE DriverEntry; +EVT_WDF_DRIVER_UNLOAD OnDriverUnload; + +// +// WDF Device Callbacks +// +EVT_WDF_DRIVER_DEVICE_ADD OnDeviceAdd; +EVT_WDF_DEVICE_PREPARE_HARDWARE OnPrepareHardware; +EVT_WDF_DEVICE_RELEASE_HARDWARE OnReleaseHardware; +EVT_WDF_DEVICE_D0_ENTRY OnD0Entry; +EVT_WDF_DEVICE_D0_EXIT OnD0Exit; + +WDF_EXTERN_C_END \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp b/sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp new file mode 100644 index 00000000..b20339a7 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp @@ -0,0 +1,485 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "GeomagneticOrientationClient.tmh" + +#define SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION '9OeG' + +#define GeomagneticOrientation_Initial_MinDataInterval_Ms (10) // 100Hz + +#define GeomagneticOrientation_Quarternion_Maximum (1.0f) +#define GeomagneticOrientation_Quarternion_Minimum (-1.0f) +#define GeomagneticOrientation_Quarternion_Resolution ((GeomagneticOrientation_Quarternion_Maximum-GeomagneticOrientation_Quarternion_Minimum)/65536) + +// Geomagnetic Orientation Sensor Unique ID +// {E4F5FDEA-F268-480F-9D88-A368D381C4C2} +DEFINE_GUID(GUID_GeomagneticOrientationDevice_UniqueID, + 0xe4f5fdea, 0xf268, 0x480f, 0x9d, 0x88, 0xa3, 0x68, 0xd3, 0x81, 0xc4, 0xc2); + +// Sensor data +typedef enum +{ + GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP = 0, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z, + GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES, + GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES, + GEOMAGNETIC_ORIENTATION_DATA_COUNT +} GEOMAGNETIC_ORIENTATION_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES = 0, + GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT +} GEOMAGNETIC_ORIENTATION_THRESHOLD_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GeomagneticOrientationDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Geomagnetic Orientation WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GeomagneticOrientation, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Geomagnetic Orientation Sensor", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_GeomagneticOrientationDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GEOMAGNETIC_ORIENTATION_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pSupportedDataFields)); + if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = GEOMAGNETIC_ORIENTATION_DATA_COUNT; + + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W] = PKEY_SensorData_QuaternionW; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X] = PKEY_SensorData_QuaternionX; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y] = PKEY_SensorData_QuaternionY; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z] = PKEY_SensorData_QuaternionZ; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES] = PKEY_SensorData_RotationAngle_Degrees; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES] = PKEY_SensorData_DeclinationAngle_Degrees; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GEOMAGNETIC_ORIENTATION_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = GEOMAGNETIC_ORIENTATION_DATA_COUNT; + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; + InitPropVariantFromFloat(1.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Key = PKEY_SensorData_RotationAngle_Degrees; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Key = PKEY_SensorData_DeclinationAngle_Degrees; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Value)); + + ZeroMemory(&m_LastSample, sizeof(m_LastSample)); + ZeroMemory(&m_CachedData, sizeof(m_CachedData)); + m_CachedData.Quaternion.W = 1.0f; // This is the initial position + m_CachedData.Quaternion.X = 0.0f; // This is the initial position + m_CachedData.Quaternion.Y = 0.0f; // This is the initial position + m_CachedData.Quaternion.Z = 0.0f; // This is the initial position + m_CachedData.RotationAngle_Degrees = 0.0f; // This is the initial position + m_CachedData.DeclinationAngle_Degrees = 0.0f; // This is the initial position + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(GeomagneticOrientation_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = GeomagneticOrientation_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = GeomagneticOrientation_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GeomagneticOrientation, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT; + + m_pThresholds->List[GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES].Key = PKEY_SensorData_RotationAngle_Degrees; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES].Value)); + + ZeroMemory(&m_CachedThresholds, sizeof(m_CachedThresholds)); + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GeomagneticOrientationDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (FALSE != m_FirstSample) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ((abs(m_CachedData.RotationAngle_Degrees - m_LastSample.RotationAngle_Degrees) >= m_CachedThresholds.RotationAngle_Degrees)) + { + DataReady = TRUE; + } + } + + if (FALSE != DataReady) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample.Quaternion.W, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.X, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.Y, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.Z, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Value)); + InitPropVariantFromFloat(m_LastSample.RotationAngle_Degrees, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Value)); + InitPropVariantFromFloat(m_LastSample.DeclinationAngle_Degrees, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! GeomagneticOrientationDevice Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GeomagneticOrientationDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_RotationAngle_Degrees, + &m_CachedThresholds.RotationAngle_Degrees); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice PropKeyFindKeyGetFloat for Rotation Angle failed! %!STATUS!", Status); + goto Exit; + } +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp b/sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp new file mode 100644 index 00000000..4dc53d7e --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp @@ -0,0 +1,499 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Clients.h" + +#include "GravityVectorClient.tmh" + + + +#define SENSORV2_POOL_TAG_GRAVITY_VECTOR '6ArG' + +#define GravityVectorDevice_Default_MinDataInterval (4) +#define GravityVectorDevice_Default_Axis_Threshold (1.0f) +#define GravityVectorDevice_Axis_Resolution (4.0f / 65536.0f) // in delta g +#define GravityVectorDevice_Axis_Minimum (-2.0f) // in g +#define GravityVectorDevice_Axis_Maximum (2.0f) // in g + + +// Linear Accelerometer Unique ID +// {56E11473-2BB7-41E4-863A-DA014200C0DC} +DEFINE_GUID(GUID_GravityVectorDevice_UniqueID, + 0x56e11473, 0x2bb7, 0x41e4, 0x86, 0x3a, 0xda, 0x1, 0x42, 0x0, 0xc0, 0xdc); + +// Sensor data +typedef enum +{ + GRAVITY_VECTOR_DATA_X = 0, + GRAVITY_VECTOR_DATA_Y, + GRAVITY_VECTOR_DATA_Z, + GRAVITY_VECTOR_DATA_TIMESTAMP, + GRAVITY_VECTOR_DATA_COUNT +} GRAVITY_VECTOR_DATA_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GravityVectorDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + TimerConfig.TolerableDelay = 0; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GravityVector, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Gravity Vector Sensor", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_GravityVectorDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = GRAVITY_VECTOR_DATA_COUNT; + + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_X] = PKEY_SensorData_AccelerationX_Gs; + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_Y] = PKEY_SensorData_AccelerationY_Gs; + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_Z] = PKEY_SensorData_AccelerationZ_Gs; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = GRAVITY_VECTOR_DATA_COUNT; + + m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Value)); + + m_pData->List[GRAVITY_VECTOR_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_X].Value)); + + m_pData->List[GRAVITY_VECTOR_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_Y].Value)); + + m_pData->List[GRAVITY_VECTOR_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_Z].Value)); + + m_CachedData.X = 0.0f; + m_CachedData.Y = 0.0f; + m_CachedData.Z = 0.0f; + + m_LastSample.X = 0.0f; + m_LastSample.Y = 0.0f; + m_LastSample.Z = 0.0f; + } + + // + // Sensor Properties + // + { + m_IntervalMs = GravityVectorDevice_Default_MinDataInterval; + + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("GRA %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(GravityVectorDevice_Default_MinDataInterval, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GravityVector, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(GravityVectorDevice_Axis_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(GravityVectorDevice_Axis_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(GravityVectorDevice_Axis_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT - 1); // Timestamp does not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = GRAVITY_VECTOR_DATA_COUNT - 1; + + m_pThresholds->List[GRAVITY_VECTOR_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, + &(m_pThresholds->List[GRAVITY_VECTOR_DATA_X].Value)); + + m_pThresholds->List[GRAVITY_VECTOR_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, + &(m_pThresholds->List[GRAVITY_VECTOR_DATA_Y].Value)); + + m_pThresholds->List[GRAVITY_VECTOR_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, + &(m_pThresholds->List[GRAVITY_VECTOR_DATA_Z].Value)); + + m_CachedThresholds.X = GravityVectorDevice_Default_Axis_Threshold; + m_CachedThresholds.Y = GravityVectorDevice_Default_Axis_Threshold; + m_CachedThresholds.Z = GravityVectorDevice_Default_Axis_Threshold; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GravityVectorDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! GRA GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.X = m_CachedData.X; + m_LastSample.Y = m_CachedData.Y; + m_LastSample.Z = m_CachedData.Z; + + // push to clx + InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[GRAVITY_VECTOR_DATA_X].Value)); + InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[GRAVITY_VECTOR_DATA_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[GRAVITY_VECTOR_DATA_Z].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! GRA Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GravityVectorDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationX_Gs, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationY_Gs, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationZ_Gs, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/GyrClient.cpp b/sensors/SensorsComboDriver/Driver/GyrClient.cpp new file mode 100644 index 00000000..389e6e8e --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/GyrClient.cpp @@ -0,0 +1,510 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "GyrClient.tmh" + +#define SENSORV2_POOL_TAG_GYROSCOPE '2oyG' + +// Chasis says 5-250Hz but unit test fails if below 250Hz??? +#define Gyr_MinDataInterval_Ms (4) // 250Hz +#define Gyr_Initial_Threshold_DegreesPerSecond (10.0f) + +#define GyrDevice_Minimum_DegreesPerSecond (-2000.0f) +#define GyrDevice_Maximum_DegreesPerSecond (2000.0f) +#define GyrDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define GyrDevice_Range_DegreesPerSecond \ + (GyrDevice_Maximum_DegreesPerSecond - GyrDevice_Minimum_DegreesPerSecond) +#define GyrDevice_Resolution_DegreesPerSecond \ + (GyrDevice_Range_DegreesPerSecond / GyrDevice_Precision) + +// Gyroscope Unique ID +// {61A61B96-1E4C-47C6-8697-654680101446} +DEFINE_GUID(GUID_GyrDevice_UniqueID, + 0x61a61b96, 0x1e4c, 0x47c6, 0x86, 0x97, 0x65, 0x46, 0x80, 0x10, 0x14, 0x46); + +// Sensor data +typedef enum +{ + GYR_DATA_TIMESTAMP = 0, + GYR_DATA_X, + GYR_DATA_Y, + GYR_DATA_Z, + GYR_DATA_COUNT +} GYR_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + GYR_THRESHOLD_X = 0, + GYR_THRESHOLD_Y, + GYR_THRESHOLD_Z, + GYR_THRESHOLD_COUNT +} GYR_THRESHOLD_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GyrDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + TimerConfig.TolerableDelay = 0; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Gyrometer3D, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"GYR", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_GyrDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GYR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = GYR_DATA_COUNT; + + m_pSupportedDataFields->List[GYR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[GYR_DATA_X] = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; + m_pSupportedDataFields->List[GYR_DATA_Y] = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; + m_pSupportedDataFields->List[GYR_DATA_Z] = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GYR_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = GYR_DATA_COUNT; + + m_pData->List[GYR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[GYR_DATA_TIMESTAMP].Value)); + + m_pData->List[GYR_DATA_X].Key = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; + InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_X].Value)); + + m_pData->List[GYR_DATA_Y].Key = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; + InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_Y].Value)); + + m_pData->List[GYR_DATA_Z].Key = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; + InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_Z].Value)); + + m_CachedData.X = 0.0f; + m_CachedData.Y = 0.0f; + m_CachedData.Z = 0.0f; + + m_LastSample.X = 0.0f; + m_LastSample.Y = 0.0f; + m_LastSample.Z = 0.0f; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Gyr_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Gyr_MinDataInterval_Ms; + m_MinimumIntervalMs = Gyr_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Gyrometer3D, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(GyrDevice_Resolution_DegreesPerSecond, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(GyrDevice_Minimum_DegreesPerSecond, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(GyrDevice_Maximum_DegreesPerSecond, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GYR_THRESHOLD_COUNT); // Timestamp and shake do not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = GYR_THRESHOLD_COUNT; + + m_pThresholds->List[GYR_THRESHOLD_X].Key = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; + InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, + &(m_pThresholds->List[GYR_THRESHOLD_X].Value)); + + m_pThresholds->List[GYR_THRESHOLD_Y].Key = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; + InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, + &(m_pThresholds->List[GYR_THRESHOLD_Y].Value)); + + m_pThresholds->List[GYR_THRESHOLD_Z].Key = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; + InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, + &(m_pThresholds->List[GYR_THRESHOLD_Z].Value)); + + m_CachedThresholds.X = Gyr_Initial_Threshold_DegreesPerSecond; + m_CachedThresholds.Y = Gyr_Initial_Threshold_DegreesPerSecond; + m_CachedThresholds.Z = Gyr_Initial_Threshold_DegreesPerSecond; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GyrDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! GYR GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.X = m_CachedData.X; + m_LastSample.Y = m_CachedData.Y; + m_LastSample.Z = m_CachedData.Z; + + // push to clx + InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[GYR_DATA_X].Value)); + InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[GYR_DATA_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[GYR_DATA_Z].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GYR_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! GYR Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GyrDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AngularVelocityX_DegreesPerSecond, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AngularVelocityY_DegreesPerSecond, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AngularVelocityZ_DegreesPerSecond, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/MagClient.cpp b/sensors/SensorsComboDriver/Driver/MagClient.cpp new file mode 100644 index 00000000..5768cbc5 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/MagClient.cpp @@ -0,0 +1,537 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "MagClient.tmh" + +#define SENSORV2_POOL_TAG_MAGNETOMETER '2ngM' + +#define Mag_Initial_MinDataInterval_Ms (10) // 100Hz +#define Mag_Initial_Threshold_Microteslas (5.0f) // 5uT + +#define MagDevice_Minimum_Microteslas (-2000.0f) +#define MagDevice_Maximum_Microteslas (2000.0f) +#define MagDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define MagDevice_Range_Microteslas \ + (MagDevice_Maximum_Microteslas - MagDevice_Minimum_Microteslas) +#define MagDevice_Resolution_Microteslas \ + (MagDevice_Range_Microteslas / MagDevice_Precision) + +// Magnetometer Sensor Unique ID +// {0746712D-DFB1-42A7-8AAE-6089D2423CDE} +DEFINE_GUID(GUID_MagDevice_UniqueID, + 0x746712d, 0xdfb1, 0x42a7, 0x8a, 0xae, 0x60, 0x89, 0xd2, 0x42, 0x3c, 0xde); + +// Sensor data +typedef enum +{ + MAG_DATA_TIMESTAMP = 0, + MAG_DATA_X, + MAG_DATA_Y, + MAG_DATA_Z, + MAG_DATA_ACCURACY, + MAG_DATA_COUNT +} MAG_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + MAG_THRESHOLD_X = 0, + MAG_THRESHOLD_Y, + MAG_THRESHOLD_Z, + MAG_THRESHOLD_COUNT +} MAG_THRESHOLD_INDEX; + +// +// Sensor Enumeration Properties +// +typedef enum +{ + SENSOR_MAG_NAME = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX is adding SENSOR_MAG_NAME to the base SENSOR_ENUMERATION_PROPERTIES_INDEX enum. + // In order to keep the SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX enum indexing coherent with the SENSOR_ENUMERATION_PROPERTIES_INDEX enum, + // set SENSOR_MAG_NAME to the index of the last value in the SENSOR_ENUMERATION_PROPERTIES_INDEX enum + SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT +} SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX; + + + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +MagDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Magnetometer3D, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"MAG", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_MagDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + // + // Alternate name used by SensorOpen + // + + m_pEnumerationProperties->List[SENSOR_MAG_NAME].Key = DEVPKEY_Sensor_Name; + InitPropVariantFromString(L"\\\\.\\Mag", + &(m_pEnumerationProperties->List[SENSOR_MAG_NAME].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(MAG_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = MAG_DATA_COUNT; + + m_pSupportedDataFields->List[MAG_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[MAG_DATA_X] = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; + m_pSupportedDataFields->List[MAG_DATA_Y] = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; + m_pSupportedDataFields->List[MAG_DATA_Z] = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; + m_pSupportedDataFields->List[MAG_DATA_ACCURACY] = PKEY_SensorData_MagnetometerAccuracy; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(MAG_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = MAG_DATA_COUNT; + + m_pData->List[MAG_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[MAG_DATA_TIMESTAMP].Value)); + + m_pData->List[MAG_DATA_X].Key = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; + InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_X].Value)); + + m_pData->List[MAG_DATA_Y].Key = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; + InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_Y].Value)); + + m_pData->List[MAG_DATA_Z].Key = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; + InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_Z].Value)); + + m_pData->List[MAG_DATA_ACCURACY].Key = PKEY_SensorData_MagnetometerAccuracy; + InitPropVariantFromUInt32(MagnetometerAccuracy_Unknown, &(m_pData->List[MAG_DATA_ACCURACY].Value)); + + m_CachedData.Axis.X = 0.0f; + m_CachedData.Axis.Y = 1.0f; + m_CachedData.Axis.Z = 0.0f; + m_CachedData.Accuracy = MagnetometerAccuracy_High; + + m_LastSample.Axis.X = 0.0f; + m_LastSample.Axis.Y = 0.0f; + m_LastSample.Axis.Z = 0.0f; + m_LastSample.Accuracy = MagnetometerAccuracy_Unknown; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Mag_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Mag_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = Mag_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Magnetometer3D, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(MagDevice_Resolution_Microteslas, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(MagDevice_Minimum_Microteslas, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(MagDevice_Maximum_Microteslas, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(MAG_THRESHOLD_COUNT); // Timestamp and shake do not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = MAG_THRESHOLD_COUNT; + + m_pThresholds->List[MAG_THRESHOLD_X].Key = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; + InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, + &(m_pThresholds->List[MAG_THRESHOLD_X].Value)); + + m_pThresholds->List[MAG_THRESHOLD_Y].Key = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; + InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, + &(m_pThresholds->List[MAG_THRESHOLD_Y].Value)); + + m_pThresholds->List[MAG_THRESHOLD_Z].Key = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; + InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, + &(m_pThresholds->List[MAG_THRESHOLD_Z].Value)); + + m_CachedThresholds.X = Mag_Initial_Threshold_Microteslas; + m_CachedThresholds.Y = Mag_Initial_Threshold_Microteslas; + m_CachedThresholds.Z = Mag_Initial_Threshold_Microteslas; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +MagDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! MAG GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.Axis.X - m_LastSample.Axis.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Axis.Y - m_LastSample.Axis.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Axis.Z - m_LastSample.Axis.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.Axis.X = m_CachedData.Axis.X; + m_LastSample.Axis.Y = m_CachedData.Axis.Y; + m_LastSample.Axis.Z = m_CachedData.Axis.Z; + m_LastSample.Accuracy = m_CachedData.Accuracy; + + // push to clx + InitPropVariantFromFloat (m_LastSample.Axis.X, &(m_pData->List[MAG_DATA_X].Value)); + InitPropVariantFromFloat (m_LastSample.Axis.Y, &(m_pData->List[MAG_DATA_Y].Value)); + InitPropVariantFromFloat (m_LastSample.Axis.Z, &(m_pData->List[MAG_DATA_Z].Value)); + InitPropVariantFromUInt32(m_LastSample.Accuracy, &(m_pData->List[MAG_DATA_ACCURACY].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[MAG_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! MAG Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +MagDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_MagneticFieldStrengthX_Microteslas, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_MagneticFieldStrengthY_Microteslas, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_MagneticFieldStrengthZ_Microteslas, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/PrxClient.cpp b/sensors/SensorsComboDriver/Driver/PrxClient.cpp new file mode 100644 index 00000000..fa10e095 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/PrxClient.cpp @@ -0,0 +1,458 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "PrxClient.tmh" + +#define SENSORV2_POOL_TAG_PROXIMITY '2ixP' + +static const ULONG Prx_MinDataInterval_Ms = 10; // 100Hz + +static const ULONG PrxDevice_Minimum_Millimeters = 3; +static const ULONG PrxDevice_Maximum_Millimeters = 50; +static const ULONG PrxDevice_Resolution_Millimeters = 1; + +// Proximity Sensor Unique ID +// {4B6BE805-2432-4B6B-A5E3-DEA67CA43225} +DEFINE_GUID(GUID_PrxDevice_UniqueID, + 0x4b6be805, 0x2432, 0x4b6b, 0xa5, 0xe3, 0xde, 0xa6, 0x7c, 0xa4, 0x32, 0x25); + +// Sensor data +typedef enum +{ + PRX_DATA_TIMESTAMP = 0, + PRX_DATA_DETECT, + PRX_DATA_DISTANCE, + PRX_DATA_COUNT +} PRX_DATA_INDEX; + +static const ULONG PRX_THRESHOLD_COUNT = 0; // proxmity sensor has no threshold + +// +// Additional Sensor Properties +// +typedef enum +{ + SENSOR_PROPERTY_PRX_TYPE = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_PRX_PROPERTIES_INDEX is adding SENSOR_PROPERTY_PRX_TYPE to the base SENSOR_PROPERTIES_INDEX enum. + // In order to keep the SENSOR_PRX_PROPERTIES_INDEX enum indexing coherent with the SENSOR_PROPERTIES_INDEX enum, + // set SENSOR_PROPERTY_PRX_TYPE to the index of the last value in the SENSOR_PROPERTIES_INDEX enum + SENSOR_ISWAKECAPABLE = SENSOR_PROPERTY_PRX_TYPE + 1, + SENSOR_PRX_ENUMERATION_PROPERTY_COUNT +} SENSOR_PRX_PROPERTIES_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +PrxDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! PRX WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! PRX WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_PRX_ENUMERATION_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + m_pEnumerationProperties->Count = SENSOR_PRX_ENUMERATION_PROPERTY_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Proximity, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"PRX", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_PrxDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + + m_pEnumerationProperties->List[SENSOR_PROPERTY_PRX_TYPE].Key = DEVPKEY_Sensor_ProximityType; + InitPropVariantFromUInt32(PROXIMITY_TYPE::ProximityType_HumanProximity, + &(m_pEnumerationProperties->List[SENSOR_PROPERTY_PRX_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_ISWAKECAPABLE].Key = PKEY_Sensor_WakeCapable; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISWAKECAPABLE].Value)); + + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(PRX_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = PRX_DATA_COUNT; + + m_pSupportedDataFields->List[PRX_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[PRX_DATA_DETECT] = PKEY_SensorData_ProximityDetection; + m_pSupportedDataFields->List[PRX_DATA_DISTANCE] = PKEY_SensorData_ProximityDistanceMillimeters; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(PRX_DATA_COUNT); + FILETIME Time = {}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = PRX_DATA_COUNT; + + m_pData->List[PRX_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[PRX_DATA_TIMESTAMP].Value)); + + m_pData->List[PRX_DATA_DETECT].Key = PKEY_SensorData_ProximityDetection; + InitPropVariantFromBoolean(FALSE, &(m_pData->List[PRX_DATA_DETECT].Value)); + + m_pData->List[PRX_DATA_DISTANCE].Key = PKEY_SensorData_ProximityDistanceMillimeters; + InitPropVariantFromUInt32(FALSE, &(m_pData->List[PRX_DATA_DISTANCE].Value)); + + m_CachedData.Detected = FALSE; + m_CachedData.DistanceMillimeters = PrxDevice_Maximum_Millimeters; + + m_LastSample.Detected = FALSE; + m_LastSample.DistanceMillimeters = PrxDevice_Maximum_Millimeters; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Prx_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Prx_MinDataInterval_Ms; + m_MinimumIntervalMs = Prx_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Proximity, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromUInt32(PrxDevice_Resolution_Millimeters, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromUInt32(PrxDevice_Minimum_Millimeters, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromUInt32(PrxDevice_Maximum_Millimeters, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(PRX_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +PrxDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime(&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! PRX GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of detection state, and only push the data back to + // clx. This is usually done in HW. + if (m_CachedData.Detected != m_LastSample.Detected) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromBoolean(m_LastSample.Detected, &(m_pData->List[PRX_DATA_DETECT].Value)); + InitPropVariantFromUInt32(m_LastSample.DistanceMillimeters, &(m_pData->List[PRX_DATA_DISTANCE].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[PRX_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! PRX Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +PrxDevice::UpdateCachedThreshold( + ) +{ + TraceInformation("COMBO %!FUNC! PRX do not have threshold!"); + + return STATUS_SUCCESS; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl new file mode 100644 index 00000000..5b5dff98 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl @@ -0,0 +1 @@ +3C773167,F26D,4F72,A1DE,95F1FD795840 SimpleDeviceOrientationSensorTraceGuid diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.def b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.def new file mode 100644 index 00000000..5273e711 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.def @@ -0,0 +1,6 @@ +; SensorsComboDriver.def : Declares the module parameters. + +LIBRARY SensorsComboDriver + +EXPORTS + diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx new file mode 100644 index 00000000..50326f48 Binary files /dev/null and b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx differ diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj new file mode 100644 index 00000000..15e5d0a5 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {C3964BD1-B485-4236-8BB4-E2981B800AC1} + $(MSBuildProjectName) + 2 + Debug + Win32 + {5E23E5F0-A79D-451A-A6E3-AA8ECD5B1E10} + + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + true + true + SensorsComboDriver + sensorstrace.h + + + $(InfArch) + true + .\$(IntDir)\SensorsComboDriver.inf + + + + SensorsComboDriver + + + SensorsComboDriver + + + SensorsComboDriver + + + SensorsComboDriver + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters new file mode 100644 index 00000000..7e7513b9 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters @@ -0,0 +1,67 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {657C491B-7C92-4AB8-B003-546E3A3A86FF} + + + h;hpp;hxx;hm;inl;inc;xsd + {9D074C38-4627-4BCD-A647-8CEDAA88C3B0} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {F78FFA14-EFF9-47BC-83D9-680F26ED1E81} + + + inf;inv;inx;mof;mc; + {BC2DC265-BF39-4FD7-AF86-19C090D6C725} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Driver Files + + + \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/SensorsTrace.h b/sensors/SensorsComboDriver/Driver/SensorsTrace.h new file mode 100644 index 00000000..85a8b811 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/SensorsTrace.h @@ -0,0 +1,100 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved +// +//Abstract: +// +// Header file for the debug tracing related function defintions and macros. +// +//Environment: +// +// User mode + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +// Define the tracing flags. +// +// Tracing GUID - 3C773167-F26D-4F72-A1DE-95F1FD795840 + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID( \ + SimpleDeviceOrientationSensorTraceGuid, (3C773167,F26D,4F72,A1DE,95F1FD795840), \ + WPP_DEFINE_BIT(EntryExit) \ + WPP_DEFINE_BIT(DataFlow) \ + WPP_DEFINE_BIT(Verbose) \ + WPP_DEFINE_BIT(Information) \ + WPP_DEFINE_BIT(Warning) \ + WPP_DEFINE_BIT(Error) \ + WPP_DEFINE_BIT(Fatal) \ + WPP_DEFINE_BIT(DriverStatus) \ + ) + +#define WPP_FLAG_LEVEL_LOGGER(flag, level) WPP_LEVEL_LOGGER(flag) + +#define WPP_FLAG_LEVEL_ENABLED(flag, level) (WPP_LEVEL_ENABLED(flag) && WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) + +#define WPP_LEVEL_FLAGS_LOGGER(level,flags) WPP_LEVEL_LOGGER(flags) + +#define WPP_LEVEL_FLAGS_ENABLED(level, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= level) + +// This comment block is scanned by the trace preprocessor to define our +// Trace function. +// +// begin_wpp config +// +// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); +// +// FUNC TraceFatal{LEVEL=TRACE_LEVEL_FATAL,FLAGS=Fatal}(MSG,...); +// FUNC TraceError{LEVEL=TRACE_LEVEL_ERROR,FLAGS=Error}(MSG,...); +// FUNC TraceWarning{LEVEL=TRACE_LEVEL_WARNING,FLAGS=Warning}(MSG,...); +// FUNC TraceInformation{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=Information}(MSG,...); +// FUNC TraceVerbose{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=Verbose}(MSG,...); +// FUNC TracePerformance{PERF=DUMMY,LEVEL=TRACE_LEVEL_PERF}(FLAGS,MSG,...); +// +// FUNC TraceData{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=DataFlow}(MSG,...); +// +// FUNC TraceDriverStatus{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=DriverStatus}(MSG,...); +// +// end_wpp + +// SENSOR ------------------------------------------------------------------------------------------------ + +// MACRO: SENSOR_FunctionEnter +// +// begin_wpp config +// USEPREFIX (SENSOR_FunctionEnter, "%!STDPREFIX! SENSOR %!FUNC! FunctionEnter"); +// FUNC SENSOR_FunctionEnter{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(...); +// end_wpp + + +// MACRO: SENSOR_FunctionExit +// +// begin_wpp config +// USEPREFIX (SENSOR_FunctionExit, "%!STDPREFIX! SENSOR %!FUNC! FunctionExit: %!STATUS!", __status); +// FUNC SENSOR_FunctionExit{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(SENSOREXIT); +// end_wpp +#define WPP_LEVEL_FLAGS_SENSOREXIT_ENABLED(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_ENABLED(LEVEL, FLAGS) +#define WPP_LEVEL_FLAGS_SENSOREXIT_LOGGER(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_LOGGER(LEVEL, FLAGS) + +#define WPP_LEVEL_FLAGS_SENSOREXIT_PRE(LEVEL, FLAGS, status) { \ + NTSTATUS __status = status; +#define WPP_LEVEL_FLAGS_SENSOREXIT_POST(LEVEL, FLAGS, status) /*TraceMessage()*/; \ + } + + + +// WPP Recorder ------------------------------------------------------------------------------------------- +// +// The following two macros are required to enable WPP Recorder functionality for clients of the Sensor Class Extension +// +#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_FILTER(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_FILTER(LEVEL, FLAGS) +#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_ARGS(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_ARGS(LEVEL, FLAGS) + + +#ifdef __cplusplus +} +#endif + + diff --git a/sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp b/sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp new file mode 100644 index 00000000..036c294f --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp @@ -0,0 +1,507 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Clients.h" + +#include "LinearAccelerometerClient.tmh" + +#define SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER '2CaL' + +#define LinearAccelerometerDevice_Default_MinDataInterval (4) +#define LinearAccelerometerDevice_Default_Axis_Threshold (1.0f) +#define LinearAccelerometerDevice_Axis_Resolution (4.0f / 65536.0f) // in delta g +#define LinearAccelerometerDevice_Axis_Minimum (-2.0f) // in g +#define LinearAccelerometerDevice_Axis_Maximum (2.0f) // in g + +// Linear Accelerometer Unique ID +// {2BAAA1A7-6795-42A0-B830-82526CFD28D1} +DEFINE_GUID(GUID_LinearAccelerometerDevice_UniqueID, + 0x2baaa1a7, 0x6795, 0x42a0, 0xb8, 0x30, 0x82, 0x52, 0x6c, 0xfd, 0x28, 0xd1); + +// Sensor data +typedef enum +{ + LINEAR_ACCELEROMETER_DATA_X = 0, + LINEAR_ACCELEROMETER_DATA_Y, + LINEAR_ACCELEROMETER_DATA_Z, + LINEAR_ACCELEROMETER_DATA_TIMESTAMP, + LINEAR_ACCELEROMETER_DATA_SHAKE, + LINEAR_ACCELEROMETER_DATA_COUNT +} LINEAR_ACCELEROMETER_DATA_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +LinearAccelerometerDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + TimerConfig.TolerableDelay = 0; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_LinearAccelerometer, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Linear Accelerometer", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_LinearAccelerometerDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = LINEAR_ACCELEROMETER_DATA_COUNT; + + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_X] = PKEY_SensorData_AccelerationX_Gs; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_Y] = PKEY_SensorData_AccelerationY_Gs; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_Z] = PKEY_SensorData_AccelerationZ_Gs; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_SHAKE] = PKEY_SensorData_Shake; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = LINEAR_ACCELEROMETER_DATA_COUNT; + + m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Key = PKEY_SensorData_Shake; + InitPropVariantFromBoolean(FALSE, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Value)); + + m_CachedData.Axis.X = 0.0f; + m_CachedData.Axis.Y = 0.0f; + m_CachedData.Axis.Z = -1.0f; + m_CachedData.Shake = FALSE; + + m_LastSample.Axis.X = 0.0f; + m_LastSample.Axis.Y = 0.0f; + m_LastSample.Axis.Z = 0.0f; + m_LastSample.Shake = FALSE; + } + + // + // Sensor Properties + // + { + m_IntervalMs = LinearAccelerometerDevice_Default_MinDataInterval; + + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("LAC %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(LinearAccelerometerDevice_Default_MinDataInterval, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_LinearAccelerometer, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT - 2); // Timestamp and shake do not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = LINEAR_ACCELEROMETER_DATA_COUNT - 2; + + m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, + &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_X].Value)); + + m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, + &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); + + m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, + &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); + + m_CachedThresholds.Axis.X = LinearAccelerometerDevice_Default_Axis_Threshold; + m_CachedThresholds.Axis.Y = LinearAccelerometerDevice_Default_Axis_Threshold; + m_CachedThresholds.Axis.Z = LinearAccelerometerDevice_Default_Axis_Threshold; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +LinearAccelerometerDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! LAC GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.Axis.X - m_LastSample.Axis.X) >= m_CachedThresholds.Axis.X) || + (abs(m_CachedData.Axis.Y - m_LastSample.Axis.Y) >= m_CachedThresholds.Axis.Y) || + (abs(m_CachedData.Axis.Z - m_LastSample.Axis.Z) >= m_CachedThresholds.Axis.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.Axis.X = m_CachedData.Axis.X; + m_LastSample.Axis.Y = m_CachedData.Axis.Y; + m_LastSample.Axis.Z = m_CachedData.Axis.Z; + + m_LastSample.Shake = m_CachedData.Shake; + + // push to clx + InitPropVariantFromFloat(m_LastSample.Axis.X, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Value)); + InitPropVariantFromFloat(m_LastSample.Axis.Y, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Axis.Z, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); + + InitPropVariantFromBoolean(m_LastSample.Shake, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! LAC Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +LinearAccelerometerDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationX_Gs, + &m_CachedThresholds.Axis.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationY_Gs, + &m_CachedThresholds.Axis.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationZ_Gs, + &m_CachedThresholds.Axis.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/product.pbxproj b/sensors/SensorsComboDriver/Driver/product.pbxproj new file mode 100644 index 00000000..c127ac09 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/product.pbxproj @@ -0,0 +1,19 @@ + + + + v110 + Utility + + + true + true + + + + + + + true + + + \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/relativefusionclient.cpp b/sensors/SensorsComboDriver/Driver/relativefusionclient.cpp new file mode 100644 index 00000000..872099a6 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/relativefusionclient.cpp @@ -0,0 +1,515 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "RelativeFusionClient.tmh" + +#define SENSORV2_POOL_TAG_RELATIVE_FUSION '2FsR' + +#define RelativeFusion_Initial_MinDataInterval_Ms (10) // 100Hz + +#define RelativeFusion_Quarternion_Maximum (1.0f) +#define RelativeFusion_Quarternion_Minimum (-1.0f) +#define RelativeFusion_Quarternion_Resolution ((RelativeFusion_Quarternion_Maximum-RelativeFusion_Quarternion_Minimum)/65536) + +// Relative Fusion Sensor Unique ID +// {0D324DDF-05AD-4285-875A-B2BCF565D2BA} +DEFINE_GUID(GUID_RelativeFusionDevice_UniqueID, + 0xd324ddf, 0x5ad, 0x4285, 0x87, 0x5a, 0xb2, 0xbc, 0xf5, 0x65, 0xd2, 0xba); + + +// Sensor data +typedef enum +{ + RELATIVE_FUSION_DATA_TIMESTAMP = 0, + RELATIVE_FUSION_DATA_QUATERNION_W, + RELATIVE_FUSION_DATA_QUATERNION_X, + RELATIVE_FUSION_DATA_QUATERNION_Y, + RELATIVE_FUSION_DATA_QUATERNION_Z, + RELATIVE_FUSION_DATA_COUNT +} RELATIVE_FUSION_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + RELATIVE_FUSION_THRESHOLD_QUATERNION_W = 0, + RELATIVE_FUSION_THRESHOLD_QUATERNION_X, + RELATIVE_FUSION_THRESHOLD_QUATERNION_Y, + RELATIVE_FUSION_THRESHOLD_QUATERNION_Z, + RELATIVE_FUSION_THRESHOLD_COUNT +} RELATIVE_FUSION_THRESHOLD_INDEX; + + + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +RelativeFusionDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Relative Fusion WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_RelativeOrientation, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Relative Fusion Device", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_RelativeFusionDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(RELATIVE_FUSION_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pSupportedDataFields)); + if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = RELATIVE_FUSION_DATA_COUNT; + + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_W] = PKEY_SensorData_QuaternionW; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_X] = PKEY_SensorData_QuaternionX; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_Y] = PKEY_SensorData_QuaternionY; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_Z] = PKEY_SensorData_QuaternionZ; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(RELATIVE_FUSION_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = RELATIVE_FUSION_DATA_COUNT; + + m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Value)); + + ZeroMemory(&m_LastSample, sizeof(m_LastSample)); + ZeroMemory(&m_CachedData, sizeof(m_CachedData)); + m_CachedData.W = 1.0f; // This is the initial position + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(RelativeFusion_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = RelativeFusion_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = RelativeFusion_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_RelativeOrientation, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(RelativeFusion_Quarternion_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(RelativeFusion_Quarternion_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(RelativeFusion_Quarternion_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(RELATIVE_FUSION_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = RELATIVE_FUSION_THRESHOLD_COUNT; + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_W].Value)); + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_X].Value)); + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Y].Value)); + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Z].Value)); + + ZeroMemory(&m_CachedThresholds, sizeof(m_CachedThresholds)); + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +RelativeFusionDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (FALSE != m_FirstSample) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! RelativeFusionDevice GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ((abs(m_CachedData.W - m_LastSample.W) >= m_CachedThresholds.W) || + (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (FALSE != DataReady) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample.W, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Value)); + InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Value)); + InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Value)); + + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! RelativeFusionDevice Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +RelativeFusionDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionW, + &m_CachedThresholds.W); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for W failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionX, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionY, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionZ, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/sources b/sensors/SensorsComboDriver/Driver/sources new file mode 100644 index 00000000..cdee3b36 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/sources @@ -0,0 +1,56 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. + +TARGETNAME = SensorsComboDriver +TARGETTYPE = DYNLINK +TARGET_DESTINATION = NTTEST\drivers\Sensors\V2 + +DLLDEF = SensorsComboDriver.def + +MINIMUM_NT_TARGET_VERSION = $(_NT_TARGET_VERSION_WINV64) +DDK_TARGET_PLATFORM = Universal + +USE_UNICRT = 1 +USE_MSVCRT = 1 + +UMDF_VERSION_MAJOR = 2 + +C_DEFINES = $(C_DEFINES)\ + /D_UNICODE \ + /DUNICODE \ + /DWPP_MACRO_USE_KM_VERSION_FOR_UM \ + +MSC_WARNING_LEVEL = /W4 /WX + +INCLUDES = $(INCLUDES); \ + $(SDK_INC_PATH); \ +### Point to the public version of Windows.Devices.Sensors.h + $(SDK_INC_PATH)\ABI; \ + $(DDK_INC_PATH)\sensors\1.1; \ + $(SDK_INC_PATH)\sensors\1.1; \ + +TARGETLIBS = $(TARGETLIBS) \ + $(ONECORE_SDK_LIB_VPATH)\onecoreuap.lib \ + $(SDK_LIB_PATH)\propsys.lib \ + $(MINCORE_SDK_LIB_VPATH)\api-ms-win-mm-time-l1.lib \ + $(SDK_LIB_PATH)\sensorsutils.lib \ + $(SDK_LIB_PATH)\sensors\$(SENSORS_VER_PATH)\sensorscxstub.lib \ + +SOURCES = \ + alsclient.cpp \ + barclient.cpp \ + clients.cpp \ + device.cpp \ + driver.cpp \ + geomagneticorientationclient.cpp \ + gravityvectorclient.cpp \ + gyrclient.cpp \ + linearaccelerometerclient.cpp \ + magclient.cpp \ + prxclient.cpp \ + relativefusionclient.cpp \ + +RUN_WPP = $(SOURCES) -dll \ + -p:SensorsComboDriver \ + -scan:sensorstrace.h + +GENERIC_INFS = SensorsComboDriver.inx diff --git a/sensors/SensorsComboDriver/Driver/sources.dep b/sensors/SensorsComboDriver/Driver/sources.dep new file mode 100644 index 00000000..d8383c18 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver/sources.dep @@ -0,0 +1,3 @@ +PUBLIC_PASS0_CONSUMES= \ + onecore\drivers\mobilepc\sensors\drivers\sensorsv2\inc|PASS0 \ + diff --git a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml new file mode 100644 index 00000000..67db4cb6 --- /dev/null +++ b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml @@ -0,0 +1,160 @@ + + + + + Sensors Combo Driver + + + + + + + + + + + + +

The sensors combo driver sensor sample shows how to write UMDF v2 drivers to control various types of virtual sensors such as Ambient Light, Barometer, Gyroscope, Magnetometer, Geomagnetic, Gravity Vector, Proximity, Linear Accelerometer and Relative Fusion.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+
+ + +
+ +

To install the sample driver, follow these steps:

+ + Ensure that the driver builds without errors. + Copy the DLL and INF files to a separate folder. + Enter the command "devcon.exe install SensorsComboDriver.inf ACPI\<HWID>" to install the driver on an existing device node. You can find the devcon.exe program in the tools\devcon folder where you installed the WDK. + +
+
+
+ File manifest + +

The following source files are in the src\Sensors\SensorsComboDriver folder and are used to build the SensorsComboDriver.dll and SensorsComboDriver.inf files.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileDescription
+

device.h, device.cpp

+
+

Implements the driver's WDF PnP event callbacks and helper methods

+
+

Clients.cpp

+
+

Implements the driver's callback functions from the class extension to the various sensors inside the combo driver.

+
+

driver.h, driver.cpp

+
+

WDF driver entry event callbacks and helper methods

+
+

makefile.inc

+
+

Defines custom build actions. Includes the conversion of the .INX file into a .INF file.

+
+

SensorsTrace.h

+
+

Implementation of the sensor traces files.

+
+

SensorsComboDriver.ctl

+
+

Declaration of driver's tracing GUID

+
+

SensorsComboDriver.inx

+
+

Describes the installation of the driver. The build process converts this into a .INF.

+
+

Trace.h

+
+

Sets up WPP tracing.

+
+
+
+
+
+
+ + + + + +
diff --git a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml new file mode 100644 index 00000000..517e6bbd --- /dev/null +++ b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln new file mode 100644 index 00000000..e6f4e500 --- /dev/null +++ b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0 +MinimumVisualStudioVersion = 12.0 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SensorsComboDriver", "SensorsComboDriver.vcxproj", "{C3964BD1-B485-4236-8BB4-E2981B800AC1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|Win32.ActiveCfg = Debug|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|Win32.Build.0 = Debug|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|Win32.ActiveCfg = Release|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|Win32.Build.0 = Release|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|x64.ActiveCfg = Debug|x64 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|x64.Build.0 = Debug|x64 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|x64.ActiveCfg = Release|x64 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/sensors/SensorsComboDriver/Metadata/product.pbxproj b/sensors/SensorsComboDriver/Metadata/product.pbxproj new file mode 100644 index 00000000..fb8943d8 --- /dev/null +++ b/sensors/SensorsComboDriver/Metadata/product.pbxproj @@ -0,0 +1,11 @@ + + + + v110 + Utility + + + + + + \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Metadata/sources b/sensors/SensorsComboDriver/Metadata/sources new file mode 100644 index 00000000..4f324037 --- /dev/null +++ b/sensors/SensorsComboDriver/Metadata/sources @@ -0,0 +1,4 @@ +TARGETTYPE = NOTARGET + +SOURCES=\ + SensorsComboDriver.kml \ \ No newline at end of file diff --git a/sensors/SensorsComboDriver/dirs b/sensors/SensorsComboDriver/dirs new file mode 100644 index 00000000..7f4c72f7 --- /dev/null +++ b/sensors/SensorsComboDriver/dirs @@ -0,0 +1,4 @@ +DIRS = \ + Driver \ + Cat \ + Metadata \ \ No newline at end of file -- cgit v1.3.1 From d8f8698314b265b58c3a9b694ec4041c3c01ad11 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 17 Aug 2017 10:06:16 -0700 Subject: Remove extraneous files in SensorsComboDriver --- sensors/SensorsComboDriver/AlsClient.cpp | 639 +++++++++++++++ sensors/SensorsComboDriver/BarClient.cpp | 464 +++++++++++ sensors/SensorsComboDriver/Cat/product.pbxproj | 11 - sensors/SensorsComboDriver/Cat/sources | 16 - sensors/SensorsComboDriver/Cat/sources.dep | 2 - sensors/SensorsComboDriver/Clients.cpp | 880 +++++++++++++++++++++ sensors/SensorsComboDriver/Clients.h | 389 +++++++++ sensors/SensorsComboDriver/Device.cpp | 477 +++++++++++ sensors/SensorsComboDriver/Driver.cpp | 100 +++ sensors/SensorsComboDriver/Driver.h | 31 + sensors/SensorsComboDriver/Driver/AlsClient.cpp | 639 --------------- sensors/SensorsComboDriver/Driver/BarClient.cpp | 464 ----------- sensors/SensorsComboDriver/Driver/Clients.cpp | 880 --------------------- sensors/SensorsComboDriver/Driver/Clients.h | 389 --------- sensors/SensorsComboDriver/Driver/Device.cpp | 477 ----------- sensors/SensorsComboDriver/Driver/Driver.cpp | 100 --- sensors/SensorsComboDriver/Driver/Driver.h | 31 - .../Driver/GeomagneticOrientationClient.cpp | 485 ------------ .../Driver/GravityVectorClient.cpp | 499 ------------ sensors/SensorsComboDriver/Driver/GyrClient.cpp | 510 ------------ sensors/SensorsComboDriver/Driver/MagClient.cpp | 537 ------------- sensors/SensorsComboDriver/Driver/PrxClient.cpp | 458 ----------- .../Driver/SensorsComboDriver.ctl | 1 - .../Driver/SensorsComboDriver.def | 6 - .../Driver/SensorsComboDriver.inx | Bin 5638 -> 0 bytes .../Driver/SensorsComboDriver.vcxproj | 200 ----- .../Driver/SensorsComboDriver.vcxproj.Filters | 67 -- sensors/SensorsComboDriver/Driver/SensorsTrace.h | 100 --- .../Driver/linearaccelerometerclient.cpp | 507 ------------ sensors/SensorsComboDriver/Driver/product.pbxproj | 19 - .../Driver/relativefusionclient.cpp | 515 ------------ sensors/SensorsComboDriver/Driver/sources | 56 -- sensors/SensorsComboDriver/Driver/sources.dep | 3 - .../GeomagneticOrientationClient.cpp | 485 ++++++++++++ sensors/SensorsComboDriver/GravityVectorClient.cpp | 499 ++++++++++++ sensors/SensorsComboDriver/GyrClient.cpp | 510 ++++++++++++ sensors/SensorsComboDriver/MagClient.cpp | 537 +++++++++++++ .../Metadata/SensorsComboDriver-gallery.xml | 160 ---- .../Metadata/SensorsComboDriver.kml | 129 --- .../Metadata/SensorsComboDriver.sln | 28 - .../SensorsComboDriver/Metadata/product.pbxproj | 11 - sensors/SensorsComboDriver/Metadata/sources | 4 - sensors/SensorsComboDriver/PrxClient.cpp | 458 +++++++++++ sensors/SensorsComboDriver/SensorsComboDriver.inx | Bin 0 -> 5638 bytes sensors/SensorsComboDriver/SensorsComboDriver.sln | 28 + .../SensorsComboDriver/SensorsComboDriver.vcxproj | 200 +++++ .../SensorsComboDriver.vcxproj.Filters | 67 ++ sensors/SensorsComboDriver/SensorsTrace.h | 100 +++ sensors/SensorsComboDriver/dirs | 4 - .../linearaccelerometerclient.cpp | 507 ++++++++++++ .../SensorsComboDriver/relativefusionclient.cpp | 515 ++++++++++++ 51 files changed, 6886 insertions(+), 7308 deletions(-) create mode 100644 sensors/SensorsComboDriver/AlsClient.cpp create mode 100644 sensors/SensorsComboDriver/BarClient.cpp delete mode 100644 sensors/SensorsComboDriver/Cat/product.pbxproj delete mode 100644 sensors/SensorsComboDriver/Cat/sources delete mode 100644 sensors/SensorsComboDriver/Cat/sources.dep create mode 100644 sensors/SensorsComboDriver/Clients.cpp create mode 100644 sensors/SensorsComboDriver/Clients.h create mode 100644 sensors/SensorsComboDriver/Device.cpp create mode 100644 sensors/SensorsComboDriver/Driver.cpp create mode 100644 sensors/SensorsComboDriver/Driver.h delete mode 100644 sensors/SensorsComboDriver/Driver/AlsClient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/BarClient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/Clients.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/Clients.h delete mode 100644 sensors/SensorsComboDriver/Driver/Device.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/Driver.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/Driver.h delete mode 100644 sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/GyrClient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/MagClient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/PrxClient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl delete mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.def delete mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx delete mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj delete mode 100644 sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters delete mode 100644 sensors/SensorsComboDriver/Driver/SensorsTrace.h delete mode 100644 sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/product.pbxproj delete mode 100644 sensors/SensorsComboDriver/Driver/relativefusionclient.cpp delete mode 100644 sensors/SensorsComboDriver/Driver/sources delete mode 100644 sensors/SensorsComboDriver/Driver/sources.dep create mode 100644 sensors/SensorsComboDriver/GeomagneticOrientationClient.cpp create mode 100644 sensors/SensorsComboDriver/GravityVectorClient.cpp create mode 100644 sensors/SensorsComboDriver/GyrClient.cpp create mode 100644 sensors/SensorsComboDriver/MagClient.cpp delete mode 100644 sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml delete mode 100644 sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml delete mode 100644 sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln delete mode 100644 sensors/SensorsComboDriver/Metadata/product.pbxproj delete mode 100644 sensors/SensorsComboDriver/Metadata/sources create mode 100644 sensors/SensorsComboDriver/PrxClient.cpp create mode 100644 sensors/SensorsComboDriver/SensorsComboDriver.inx create mode 100644 sensors/SensorsComboDriver/SensorsComboDriver.sln create mode 100644 sensors/SensorsComboDriver/SensorsComboDriver.vcxproj create mode 100644 sensors/SensorsComboDriver/SensorsComboDriver.vcxproj.Filters create mode 100644 sensors/SensorsComboDriver/SensorsTrace.h delete mode 100644 sensors/SensorsComboDriver/dirs create mode 100644 sensors/SensorsComboDriver/linearaccelerometerclient.cpp create mode 100644 sensors/SensorsComboDriver/relativefusionclient.cpp diff --git a/sensors/SensorsComboDriver/AlsClient.cpp b/sensors/SensorsComboDriver/AlsClient.cpp new file mode 100644 index 00000000..eb7080a2 --- /dev/null +++ b/sensors/SensorsComboDriver/AlsClient.cpp @@ -0,0 +1,639 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "AlsClient.tmh" + +#define SENSORV2_POOL_TAG_AMBIENT_LIGHT '2LmA' + +#define Als_Initial_MinDataInterval_Ms (10) // 100Hz +#define Als_Initial_Lux_Threshold_Pct (1.0f) // Percent threshold: 100% +#define Als_Initial_Lux_Threshold_Abs (0.0f) // Absolute threshold: 0 lux +#define Als_Initial_Kelvin_Threshold_Abs (100.0f) // Absolute threshold: 100 Kelvins +#define Als_Initial_Chromaticity_X_Threshold_Abs (0.01f) // Absolute threshold: 0.01 of a CIE 1931 chromaticity x coordinate +#define Als_Initial_Chromaticity_Y_Threshold_Abs (0.01f) // Absolute threshold: 0.01 of a CIE 1931 chromaticity y coordinate + +#define AlsDevice_Minimum_Lux (-4.0f) +#define AlsDevice_Maximum_Lux (4.0f) +#define AlsDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define AlsDevice_Range_Lux (AlsDevice_Maximum_Lux - AlsDevice_Minimum_Lux) +#define AlsDevice_Resolution_Lux (AlsDevice_Range_Lux / AlsDevice_Precision) + +// Ambient Light Sensor Unique ID +// {2D2A4524-51E3-4E68-9B0F-5CAEDFB12C02} +DEFINE_GUID(GUID_AlsDevice_UniqueID, + 0x2d2a4524, 0x51e3, 0x4e68, 0x9b, 0xf, 0x5c, 0xae, 0xdf, 0xb1, 0x2c, 0x2); + +// Sensor data +typedef enum +{ + ALS_DATA_TIMESTAMP = 0, + ALS_DATA_LUX, + ALS_DATA_KELVINS, + ALS_DATA_CHROMATICITY_X, + ALS_DATA_CHROMATICITY_Y, + ALS_DATA_ISVALID, + ALS_DATA_COUNT +} ALS_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + ALS_THRESHOLD_LUX_PCT = 0, + ALS_THRESHOLD_LUX_ABS, + ALS_THRESHOLD_KELVINS_ABS, + ALS_THRESHOLD_CHROMATICITY_X_ABS, + ALS_THRESHOLD_CHROMATICITY_Y_ABS, + ALS_THRESHOLD_COUNT +} ALS_THRESHOLD_INDEX; + +// +// Sensor Enumeration Properties +// + +typedef enum +{ + SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX is adding properties to the base SENSOR_ENUMERATION_PROPERTIES_COUNT enum. + SENSOR_ALS_COLOR_CAPABLE, // In order to keep the SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX enum indexing coherent with the SENSOR_ENUMERATION_PROPERTIES_INDEX enum, + // set SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED to the index of the last value in the SENSOR_ENUMERATION_PROPERTIES_INDEX enum + SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT +} SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX; + +typedef enum +{ + SENSOR_PROPERTY_ALS_RESPONSE_CURVE = SENSOR_COMMON_PROPERTY_COUNT, // SENSOR_ALS_PROPERTIES_INDEX is adding SENSOR_PROPERTY_ALS_RESPONSE_CURVE to the base SENSOR_COMMON_PROPERTIES_INDEX enum. + // In order to keep the SENSOR_ALS_PROPERTIES_INDEX enum indexing coherent with the SENSOR_COMMON_PROPERTIES_INDEX enum, + // set SENSOR_PROPERTY_ALS_RESPONSE_CURVE to the index of the last value in the SENSOR_COMMON_PROPERTIES_INDEX enum + SENSOR_ALS_PROPERTY_COUNT +} SENSOR_ALS_PROPERTIES_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +AlsDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! ALS WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! ALS WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_AmbientLight, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"ALS", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_AlsDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(TRUE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + + m_pEnumerationProperties->List[SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED].Key = DEVPKEY_LightSensor_AutoBrightnessPreferred; + InitPropVariantFromBoolean(TRUE, + &(m_pEnumerationProperties->List[SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED].Value)); + + m_pEnumerationProperties->List[SENSOR_ALS_COLOR_CAPABLE].Key = DEVPKEY_LightSensor_ColorCapable; + InitPropVariantFromBoolean(TRUE, + &(m_pEnumerationProperties->List[SENSOR_ALS_COLOR_CAPABLE].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(ALS_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = ALS_DATA_COUNT; + + m_pSupportedDataFields->List[ALS_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[ALS_DATA_LUX] = PKEY_SensorData_LightLevel_Lux; + m_pSupportedDataFields->List[ALS_DATA_KELVINS] = PKEY_SensorData_LightTemperature_Kelvins; + m_pSupportedDataFields->List[ALS_DATA_CHROMATICITY_X] = PKEY_SensorData_LightChromaticityX; + m_pSupportedDataFields->List[ALS_DATA_CHROMATICITY_Y] = PKEY_SensorData_LightChromaticityY; + m_pSupportedDataFields->List[ALS_DATA_ISVALID] = PKEY_SensorData_IsValid; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(ALS_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = ALS_DATA_COUNT; + + m_pData->List[ALS_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[ALS_DATA_TIMESTAMP].Value)); + + m_pData->List[ALS_DATA_LUX].Key = PKEY_SensorData_LightLevel_Lux; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_LUX].Value)); + + m_pData->List[ALS_DATA_KELVINS].Key = PKEY_SensorData_LightTemperature_Kelvins; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_KELVINS].Value)); + + m_pData->List[ALS_DATA_CHROMATICITY_X].Key = PKEY_SensorData_LightChromaticityX; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_CHROMATICITY_X].Value)); + + m_pData->List[ALS_DATA_CHROMATICITY_Y].Key = PKEY_SensorData_LightChromaticityY; + InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_CHROMATICITY_Y].Value)); + + m_pData->List[ALS_DATA_ISVALID].Key = PKEY_SensorData_IsValid; + InitPropVariantFromBoolean(TRUE, &(m_pData->List[ALS_DATA_ISVALID].Value)); + + m_CachedData = { + 1.0f, // Lux + 1.0f, // Kelvins + 0.5f, // Chromaticity X + 0.5f, // Chromaticity Y + TRUE // IsValid + }; + + m_LastSample = { + 0.0f, // Lux + 0.0f, // Kelvins + 0.0f, // Chromaticity X + 0.0f, // Chromaticity Y + TRUE // IsValid + }; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ALS_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_ALS_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Als_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Als_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = Als_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_AmbientLight, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + + ULONG responseCurve[10] = {}; // Array to contain the response curve data. + + // **************************************************************************************** + // The response curve consists of an array of byte pairs. + // The first byte contains the percentage brightness offset to be applied to the display. + // The second byte contains the corresponding ambient light value (in LUX). + // **************************************************************************************** + // (0, 10) + responseCurve[0] = 0; responseCurve[1] = 10; + // (10, 40) + responseCurve[2] = 10; responseCurve[3] = 40; + // (40, 100) + responseCurve[4] = 40; responseCurve[5] = 100; + // (68, 400) + responseCurve[6] = 68; responseCurve[7] = 400; + // (90, 1000) + responseCurve[8] = 90; responseCurve[9] = 1000; + + m_pProperties->List[SENSOR_PROPERTY_ALS_RESPONSE_CURVE].Key = PKEY_LightSensor_ResponseCurve; + InitPropVariantFromUInt32Vector(responseCurve, + 10, + &(m_pProperties->List[SENSOR_PROPERTY_ALS_RESPONSE_CURVE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(AlsDevice_Resolution_Lux, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(AlsDevice_Minimum_Lux, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(AlsDevice_Maximum_Lux, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(ALS_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_AMBIENT_LIGHT, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = ALS_THRESHOLD_COUNT; + + // Set lux threshold + m_pThresholds->List[ALS_THRESHOLD_LUX_PCT].Key = PKEY_SensorData_LightLevel_Lux; + InitPropVariantFromFloat(Als_Initial_Lux_Threshold_Pct, + &(m_pThresholds->List[ALS_THRESHOLD_LUX_PCT].Value)); + m_CachedThresholds.LuxPct = Als_Initial_Lux_Threshold_Pct; + + m_pThresholds->List[ALS_THRESHOLD_LUX_ABS].Key = PKEY_SensorData_LightLevel_Lux_Threshold_AbsoluteDifference; + InitPropVariantFromFloat(Als_Initial_Lux_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_LUX_ABS].Value)); + m_CachedThresholds.LuxAbs = Als_Initial_Lux_Threshold_Abs; + + // Set kelvins threshold + m_pThresholds->List[ALS_THRESHOLD_KELVINS_ABS].Key = PKEY_SensorData_LightTemperature_Kelvins; + InitPropVariantFromFloat(Als_Initial_Kelvin_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_KELVINS_ABS].Value)); + m_CachedThresholds.KelvinsAbs = Als_Initial_Kelvin_Threshold_Abs; + + // Set chromaticity x threshold + m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_X_ABS].Key = PKEY_SensorData_LightChromaticityX; + InitPropVariantFromFloat(Als_Initial_Chromaticity_X_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_X_ABS].Value)); + m_CachedThresholds.ChromaticityXAbs = Als_Initial_Chromaticity_X_Threshold_Abs; + + // Set chromaticity y threshold + m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_Y_ABS].Key = PKEY_SensorData_LightChromaticityY; + InitPropVariantFromFloat(Als_Initial_Chromaticity_Y_Threshold_Abs, + &(m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_Y_ABS].Value)); + m_CachedThresholds.ChromaticityYAbs = Als_Initial_Chromaticity_Y_Threshold_Abs; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +AlsDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime(&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! ALS GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( + ( + // Lux thresholds needs to exceed absolute and percentage + ((abs(m_CachedData.Lux - m_LastSample.Lux) >= (m_LastSample.Lux * m_CachedThresholds.LuxPct)) && + (abs(m_CachedData.Lux - m_LastSample.Lux) >= m_CachedThresholds.LuxAbs)) || + // If IsValid has changed, the sample is valid + (m_CachedData.IsValid != m_LastSample.IsValid) || + // Kelvin temperature and Chromaticity thresholds + (abs(m_CachedData.Kelvins - m_LastSample.Kelvins) >= m_CachedThresholds.KelvinsAbs) || + (abs(m_CachedData.ChromaticityX - m_LastSample.ChromaticityX) >= m_CachedThresholds.ChromaticityXAbs) || + (abs(m_CachedData.ChromaticityY - m_LastSample.ChromaticityY) >= m_CachedThresholds.ChromaticityYAbs) + ) + && + ( + // In thresholded mode, don't send sample if the last sample sent was not IsValid and current sample is also not IsValid + !((m_CachedThresholds.LuxAbs != 0.0f) && (m_CachedThresholds.LuxPct != 0.0f) && + (m_CachedThresholds.KelvinsAbs != 0.0f) && (m_CachedThresholds.ChromaticityXAbs != 0.0f) && + (m_CachedThresholds.ChromaticityYAbs != 0.0f) && !m_CachedData.IsValid && !m_LastSample.IsValid) + ) + ) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample.Lux, &(m_pData->List[ALS_DATA_LUX].Value)); + + InitPropVariantFromFloat(m_LastSample.Kelvins, &(m_pData->List[ALS_DATA_KELVINS].Value)); + + InitPropVariantFromFloat(m_LastSample.ChromaticityX, &(m_pData->List[ALS_DATA_CHROMATICITY_X].Value)); + + InitPropVariantFromFloat(m_LastSample.ChromaticityY, &(m_pData->List[ALS_DATA_CHROMATICITY_Y].Value)); + + InitPropVariantFromBoolean(m_LastSample.IsValid, &(m_pData->List[ALS_DATA_ISVALID].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[ALS_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! ALS Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +AlsDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightLevel_Lux, + &m_CachedThresholds.LuxPct); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get lux pct data from cached threshold %!STATUS!", Status); + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightLevel_Lux_Threshold_AbsoluteDifference, + &m_CachedThresholds.LuxAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get lux abs data from cached threshold %!STATUS!", Status); + } + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightTemperature_Kelvins, + &m_CachedThresholds.KelvinsAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get kelvin data from cached threshold %!STATUS!", Status); + } + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightChromaticityX, + &m_CachedThresholds.ChromaticityXAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get chromaticity x data from cached threshold %!STATUS!", Status); + } + } + + if (NT_SUCCESS(Status)) + { + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_LightChromaticityY, + &m_CachedThresholds.ChromaticityYAbs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Failed to get chromaticity y data from cached threshold %!STATUS!", Status); + } + } + + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/BarClient.cpp b/sensors/SensorsComboDriver/BarClient.cpp new file mode 100644 index 00000000..97135c59 --- /dev/null +++ b/sensors/SensorsComboDriver/BarClient.cpp @@ -0,0 +1,464 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Clients.h" + +#include "BarClient.tmh" + +#define SENSORV2_POOL_TAG_BAROMETER '2RaB' + +#define Bar_Initial_MinDataInterval_Ms (10) // 100Hz +#define Bar_Initial_Threshold_Bar (0.001f) // 1 mBar ~= 10 meter + +#define BarDevice_Minimum_Bar (0.3f) +#define BarDevice_Maximum_Bar (1.1f) +#define BarDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define BarDevice_Range_Bar (BarDevice_Maximum_Bar - BarDevice_Minimum_Bar) +#define BarDevice_Resolution_Bar (BarDevice_Range_Bar / BarDevice_Precision) + +// Barometer Unique ID +// {46CB48CE-272D-4402-8E09-07748F8940CA} +DEFINE_GUID(GUID_BarDevice_UniqueID, + 0x46cb48ce, 0x272d, 0x4402, 0x8e, 0x9, 0x7, 0x74, 0x8f, 0x89, 0x40, 0xca); + +// Sensor data +typedef enum +{ + BAR_DATA_TIMESTAMP = 0, + BAR_DATA_PRESSURE, + BAR_DATA_COUNT +} BAR_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + BAR_THRESHOLD_PRESSURE = 0, + BAR_THRESHOLD_COUNT +} BAR_THRESHOLD_INDEX; + + + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +BarDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! BAR WdfWaitLockCreate failed %!STATUS!", Status); + } + + // + // Create timer object for polling sensor samples + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! BAR WdfTimerCreate failed %!STATUS!", Status); + } + } + + // + // Sensor Enumeration Properties + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Barometer, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Barometer", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_BarDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + } + + // + // Supported Data-Fields + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(BAR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pSupportedDataFields)); + if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = BAR_DATA_COUNT; + + m_pSupportedDataFields->List[BAR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[BAR_DATA_PRESSURE] = PKEY_SensorData_AtmosphericPressure_Bars; + } + } + + // + // Data + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(BAR_DATA_COUNT); + FILETIME Time = {}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = BAR_DATA_COUNT; + + m_pData->List[BAR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[BAR_DATA_TIMESTAMP].Value)); + + m_pData->List[BAR_DATA_PRESSURE].Key = PKEY_SensorData_AtmosphericPressure_Bars; + InitPropVariantFromFloat(0.0f, &(m_pData->List[BAR_DATA_PRESSURE].Value)); + + m_CachedData = 1.013f; + m_LastSample = 0.0f; + } + } + + // + // Sensor Properties + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Bar_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Bar_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = Bar_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Barometer, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + } + + // + // Data filed properties + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(BarDevice_Resolution_Bar, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(BarDevice_Minimum_Bar, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(BarDevice_Maximum_Bar, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + } + + // + // Set default threshold + // + if (NT_SUCCESS(Status)) + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(BAR_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_BAROMETER, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); + } + else + { + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = BAR_THRESHOLD_COUNT; + + m_pThresholds->List[BAR_THRESHOLD_PRESSURE].Key = PKEY_SensorData_AtmosphericPressure_Bars; + InitPropVariantFromFloat(Bar_Initial_Threshold_Bar, + &(m_pThresholds->List[BAR_THRESHOLD_PRESSURE].Value)); + + m_CachedThresholds = Bar_Initial_Threshold_Bar; + m_FirstSample = TRUE; + } + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +BarDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (FALSE != m_FirstSample) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! BAR GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ((abs(m_CachedData - m_LastSample) >= m_CachedThresholds)) + { + DataReady = TRUE; + } + } + + if (FALSE != DataReady) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample, &(m_pData->List[BAR_DATA_PRESSURE].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[BAR_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! BAR Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +BarDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AtmosphericPressure_Bars, + &m_CachedThresholds); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! BAR PropKeyFindKeyGetFloat for pressure failed %!STATUS!", Status); + } + + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Cat/product.pbxproj b/sensors/SensorsComboDriver/Cat/product.pbxproj deleted file mode 100644 index fb8943d8..00000000 --- a/sensors/SensorsComboDriver/Cat/product.pbxproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - v110 - Utility - - - - - - \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Cat/sources b/sensors/SensorsComboDriver/Cat/sources deleted file mode 100644 index ad2d5c99..00000000 --- a/sensors/SensorsComboDriver/Cat/sources +++ /dev/null @@ -1,16 +0,0 @@ -!undef NT_SIGNCODE - -!undef C_DEFINES -!undef INCLUDES -!undef TARGETLIBS - -TARGETNAME=SensorsComboDriver -TARGETTYPE=CATALOG -TARGET_DESTINATION=NTTEST\drivers\Sensors\V2 - -# 8.1 = 2:6.2 -CATALOG_OS_VERSION_LIST= 2:6.2 \ - -SOURCES= \ - $(OBJ_PATH)\..\driver\$(O)\$(TARGETNAME).dll \ - $(OBJ_PATH)\..\driver\$(O)\$(TARGETNAME).inf \ \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Cat/sources.dep b/sensors/SensorsComboDriver/Cat/sources.dep deleted file mode 100644 index 151fbb3f..00000000 --- a/sensors/SensorsComboDriver/Cat/sources.dep +++ /dev/null @@ -1,2 +0,0 @@ -BUILD_PASS2_CONSUMES= \ - drivers\mobilepc\sensors\samples\sensorscombodriver\driver|PASS2 \ \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Clients.cpp b/sensors/SensorsComboDriver/Clients.cpp new file mode 100644 index 00000000..4524b6b6 --- /dev/null +++ b/sensors/SensorsComboDriver/Clients.cpp @@ -0,0 +1,880 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of driver callback function +// from clx to clients. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "Clients.tmh" + +static const UINT SYSTEM_TICK_COUNT_1MS = 1; // 1ms +//------------------------------------------------------------------------------ +// Function: OnTimerExpire +// +// This callback is called when interval wait time has expired and driver is ready +// to collect new sample. The callback reads current value, compare value to threshold, +// pushes it up to CLX framework, and schedule next wake up time. +// +// Arguments: +// Timer: IN: WDF timer object +// +// Return Value: +// None +//------------------------------------------------------------------------------ +VOID +OnTimerExpire( + _In_ WDFTIMER Timer + ) +{ + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + pDevice = GetContextFromSensorInstance(WdfTimerGetParentObject(Timer)); + if (pDevice == nullptr) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // Get data and push to clx + Lock(pDevice->m_Lock); + Status = pDevice->GetData(); + if (!NT_SUCCESS(Status) && Status != STATUS_DATA_NOT_ACCEPTED) + { + TraceError("COMBO %!FUNC! GetData Failed %!STATUS!", Status); + } + Unlock(pDevice->m_Lock); + + // Schedule next wake up time + if (pDevice->m_MinimumIntervalMs <= pDevice->m_IntervalMs && + FALSE != pDevice->m_PoweredOn && + FALSE != pDevice->m_Started) + { + LONGLONG WaitTime = 0; // in unit of 100ns + + if (pDevice->m_StartTime == 0) + { + // in case we fail to get sensor start time, use static wait time + WaitTime = WDF_REL_TIMEOUT_IN_MS(pDevice->m_IntervalMs); + } + else + { + ULONG CurrentTimeMs = 0; + + // dynamically calculate wait time to avoid jitter + Status = GetPerformanceTime (&CurrentTimeMs); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GetPerformanceTime %!STATUS!", Status); + WaitTime = WDF_REL_TIMEOUT_IN_MS(pDevice->m_IntervalMs); + } + else + { + pDevice->m_SampleCount++; + if (CurrentTimeMs > (pDevice->m_StartTime + (pDevice->m_IntervalMs * (pDevice->m_SampleCount + 1)))) + { + // If we skipped two or more beats, reschedule the timer with a zero due time to catch up on missing samples + WaitTime = 0; + } + else + { + // Else, just compute the remaining time + WaitTime = (pDevice->m_StartTime + + (pDevice->m_IntervalMs * (pDevice->m_SampleCount + 1))) - CurrentTimeMs; + } + + WaitTime = WDF_REL_TIMEOUT_IN_MS(WaitTime); + } + } + + WdfTimerStart(pDevice->m_Timer, WaitTime); + } + +Exit: + + SENSOR_FunctionExit(Status); +} + + + +//------------------------------------------------------------------------------ +// Function: OnStart +// +// Called by Sensor CLX to begin continously sampling the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnStart( + _In_ SENSOROBJECT SensorInstance + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Sensor(%p) parameter is invalid. Failed %!STATUS!", static_cast(&SensorInstance), Status); + goto Exit; + } + + if (pDevice->m_PoweredOn == FALSE) + { + Status = STATUS_DEVICE_NOT_READY; + TraceError("COMBO %!FUNC! Sensor is not powered on! %!STATUS!", Status); + goto Exit; + } + + // + // Start worker thread + // + + pDevice->m_IntervalMs; + + pDevice->m_FirstSample = TRUE; + + // Start polling + + pDevice->m_Started = TRUE; + + InitPropVariantFromUInt32(SensorState_Active, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(pDevice->m_MinimumIntervalMs)); + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnStop +// +// Called by Sensor CLX to stop continously sampling the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnStop( + _In_ SENSOROBJECT SensorInstance + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Sensor(%p) parameter is invalid. Failed %!STATUS!", static_cast(&SensorInstance), Status); + goto Exit; + } + + // Stop polling + + pDevice->m_Started = FALSE; + + WdfTimerStop(pDevice->m_Timer, TRUE); + + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + // + // Restoring system time resolution + // + if (TIMERR_NOERROR != timeEndPeriod(SYSTEM_TICK_COUNT_1MS)) + { + // not a failure, just log message + Status = STATUS_UNSUCCESSFUL; + TraceWarning("COMBO %!FUNC! timeEndPeriod failed to restore timer resolution! %!STATUS!", Status); + } + +Exit: + SENSOR_FunctionExit(Status); + + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetSupportedDataFields +// +// Called by Sensor CLX to get supported data fields. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pFields: INOUT_OPT: pointer to a list of supported properties +// pSize: OUT: number of bytes for the list of supported properties +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetSupportedDataFields( + _In_ SENSOROBJECT SensorInstance, + _Inout_opt_ PSENSOR_PROPERTY_LIST pFields, + _Out_ PULONG pSize + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (nullptr == pFields) + { + // Just return size + *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; + } + else + { + if (pFields->AllocatedSizeInBytes < pDevice->m_pSupportedDataFields->AllocatedSizeInBytes) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out data + Status = PropertiesListCopy (pFields, pDevice->m_pSupportedDataFields); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! PropertiesListCopy failed %!STATUS!", Status); + goto Exit; + } + + *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetProperties +// +// Called by Sensor CLX to get sensor properties. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pProperties: INOUT_OPT: pointer to a list of sensor properties +// pSize: OUT: number of bytes for the list of sensor properties +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetProperties( + _In_ SENSOROBJECT SensorInstance, + _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, + _Out_ PULONG pSize + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (nullptr == pProperties) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); + } + else + { + if (pProperties->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pProperties)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall(pProperties, pDevice->m_pProperties); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + +//------------------------------------------------------------------------------ +// Function: OnGetDataFieldProperties +// +// Called by Sensor CLX to get data field properties. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// DataField: IN: pointer to the propertykey of requested property +// pProperties: INOUT_OPT: pointer to a list of sensor properties +// pSize: OUT: number of bytes for the list of sensor properties +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetDataFieldProperties( + _In_ SENSOROBJECT SensorInstance, + _In_ const PROPERTYKEY *DataField, + _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, + _Out_ PULONG pSize +) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize || nullptr == DataField) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (IsKeyPresentInPropertyList(pDevice->m_pSupportedDataFields, DataField) != FALSE) + { + if (nullptr == pProperties) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties); + } + else + { + if (pProperties->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall (pProperties, pDevice->m_pDataFieldProperties); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties); + } + } + else + { + Status = STATUS_NOT_SUPPORTED; + TraceError("COMBO %!FUNC! Sensor does NOT have properties for this data field. Failed %!STATUS!", Status); + goto Exit; + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetDataInterval +// +// Called by Sensor CLX to get sampling rate of the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// DataRateMs: OUT: sampling rate in ms +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetDataInterval( + _In_ SENSOROBJECT SensorInstance, + _Out_ PULONG DataRateMs + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameter!"); + goto Exit; + } + + if (DataRateMs == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! DataRateMs(%p) parameter is invalid. Failed %!STATUS!", static_cast(DataRateMs), Status); + goto Exit; + } + + *DataRateMs = pDevice->m_IntervalMs; + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnSetDataInterval +// +// Called by Sensor CLX to set sampling rate of the sensor. +// +// Arguments: +// SensorInstance: IN: sensor device object +// DataRateMs: IN: sampling rate in ms +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnSetDataInterval( + _In_ SENSOROBJECT SensorInstance, + _In_ ULONG DataRateMs + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr || DataRateMs == 0) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameter!"); + goto Exit; + } + + pDevice->m_IntervalMs = DataRateMs; + + // reschedule sample to return as soon as possible if it's started + if (FALSE != pDevice->m_Started) + { + pDevice->m_Started = FALSE; + WdfTimerStop(pDevice->m_Timer, TRUE); + + pDevice->m_Started = TRUE; + pDevice->m_FirstSample = TRUE; + WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(pDevice->m_MinimumIntervalMs)); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnGetDataThresholds +// +// Called by Sensor CLX to get data thresholds. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pThresholds: INOUT_OPT: pointer to a list of sensor thresholds +// pSize: OUT: number of bytes for the list of sensor thresholds +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnGetDataThresholds( + _In_ SENSOROBJECT SensorInstance, + _Inout_opt_ PSENSOR_COLLECTION_LIST pThresholds, + _Out_ PULONG pSize + ) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameters!"); + goto Exit; + } + + if (nullptr == pThresholds) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); + } + else + { + if (pThresholds->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pThresholds)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! Buffer is too small!"); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall (pThresholds, pDevice->m_pThresholds); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnSetDataThresholds +// +// Called by Sensor CLX to set data thresholds. +// +// Arguments: +// SensorInstance: IN: sensor device object +// pThresholds: IN: pointer to a list of sensor thresholds +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnSetDataThresholds( + _In_ SENSOROBJECT SensorInstance, + _In_ PSENSOR_COLLECTION_LIST pThresholds + ) +{ + ULONG Element; + BOOLEAN IsLocked = FALSE; + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Invalid parameter!"); + goto Exit; + } + + Lock(pDevice->m_Lock); + IsLocked = TRUE; + + for (Element = 0; Element < pThresholds->Count; Element++) + { + Status = PropKeyFindKeySetPropVariant(pDevice->m_pThresholds, + &(pThresholds->List[Element].Key), + TRUE, + &(pThresholds->List[Element].Value)); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! Sensor does NOT have threshold for this data field. Failed %!STATUS!", Status); + goto Exit; + } + } + + // Update cached threshholds + Status = pDevice->UpdateCachedThreshold(); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! UpdateCachedThreshold failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + if (IsLocked) + { + Unlock(pDevice->m_Lock); + IsLocked = FALSE; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnIoControl +// +// Called by Sensor CLX to handle IOCTLs that clx does not support +// +// Arguments: +// SensorInstance: IN: Sensor object +// Request: IN: WDF request object +// OutputBufferLength: IN: number of bytes to retrieve from output buffer +// InputBufferLength: IN: number of bytes to retrieve from input buffer +// IoControlCode: IN: IOCTL control code +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS OnIoControl( + _In_ SENSOROBJECT /*SensorInstance*/, // Sensor object + _In_ WDFREQUEST /*Request*/, // WDF request object + _In_ size_t /*OutputBufferLength*/, // number of bytes to retrieve from output buffer + _In_ size_t /*InputBufferLength*/, // number of bytes to retrieve from input buffer + _In_ ULONG /*IoControlCode*/ // IOCTL control code + ) +{ + NTSTATUS Status = STATUS_NOT_SUPPORTED; + + SENSOR_FunctionEnter(); + + SENSOR_FunctionExit(Status); + return Status; +} + + + +// Called by Sensor CLX to begin keeping history +NTSTATUS OnStartHistory(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->StartHistory(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to stop keeping history. +NTSTATUS OnStopHistory(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->StopHistory(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to enable wake +NTSTATUS OnEnableWake(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + pDevice->m_WakeEnabled = TRUE; + Status = pDevice->EnableWake(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to disable wake +NTSTATUS OnDisableWake(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + pDevice->m_WakeEnabled = FALSE; + Status = pDevice->DisableWake(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to clear all history stored in the sensor. +NTSTATUS OnClearHistory(_In_ SENSOROBJECT SensorInstance) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->ClearHistory(); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to start retrieving history. +NTSTATUS OnStartHistoryRetrieval( + _In_ SENSOROBJECT SensorInstance, + _Inout_updates_bytes_(HistorySizeInBytes) PSENSOR_COLLECTION_LIST pHistoryBuffer, + _In_ ULONG HistorySizeInBytes) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else if (sizeof(SENSOR_COLLECTION_LIST) > HistorySizeInBytes) + { + Status = STATUS_BUFFER_TOO_SMALL; + TraceError("COMBO %!FUNC! HistorySizeInBytes is too small %!STATUS!", Status); + } + else + { + Status = pDevice->StartHistoryRetrieval(pHistoryBuffer, HistorySizeInBytes); + } + + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to cancel history retrieval. +NTSTATUS OnCancelHistoryRetrieval(_In_ SENSOROBJECT SensorInstance, _Out_ PULONG pBytesWritten) +{ + PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + } + else + { + Status = pDevice->CancelHistoryRetrieval(pBytesWritten); + } + + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Clients.h b/sensors/SensorsComboDriver/Clients.h new file mode 100644 index 00000000..a8992fa7 --- /dev/null +++ b/sensors/SensorsComboDriver/Clients.h @@ -0,0 +1,389 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved +// +// Abstract: +// +// This module contains the type definitions for the client +// driver's device callback class. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#pragma once + +#include +#include +#include +#include + +#include "SensorsTrace.h" +#include +#include + +// +// CLX Callbacks +// +EVT_SENSOR_DRIVER_START_SENSOR OnStart; +EVT_SENSOR_DRIVER_STOP_SENSOR OnStop; +EVT_SENSOR_DRIVER_GET_SUPPORTED_DATA_FIELDS OnGetSupportedDataFields; +EVT_SENSOR_DRIVER_GET_PROPERTIES OnGetProperties; +EVT_SENSOR_DRIVER_GET_DATA_FIELD_PROPERTIES OnGetDataFieldProperties; +EVT_SENSOR_DRIVER_GET_DATA_INTERVAL OnGetDataInterval; +EVT_SENSOR_DRIVER_SET_DATA_INTERVAL OnSetDataInterval; +EVT_SENSOR_DRIVER_GET_DATA_THRESHOLDS OnGetDataThresholds; +EVT_SENSOR_DRIVER_SET_DATA_THRESHOLDS OnSetDataThresholds; +EVT_SENSOR_DRIVER_DEVICE_IO_CONTROL OnIoControl; +EVT_SENSOR_DRIVER_START_SENSOR_HISTORY OnStartHistory; +EVT_SENSOR_DRIVER_STOP_SENSOR_HISTORY OnStopHistory; +EVT_SENSOR_DRIVER_CLEAR_SENSOR_HISTORY OnClearHistory; +EVT_SENSOR_DRIVER_START_HISTORY_RETRIEVAL OnStartHistoryRetrieval; +EVT_SENSOR_DRIVER_CANCEL_HISTORY_RETRIEVAL OnCancelHistoryRetrieval; +EVT_SENSOR_DRIVER_ENABLE_WAKE OnEnableWake; +EVT_SENSOR_DRIVER_DISABLE_WAKE OnDisableWake; + +EVT_WDF_TIMER OnTimerExpire; + + +/*++ +Routine Description: + Critical section lock/unlock to protect shared context +Return Value: + None +--*/ +#define Lock(lock) { WdfWaitLockAcquire(lock, NULL); } +#define Unlock(lock) { WdfWaitLockRelease(lock); } + +#define SENSORV2_POOL_TAG_COMBO '2bmC' + +// +// Sensor Enumeration Properties +// +typedef enum +{ + SENSOR_TYPE_GUID = 0, + SENSOR_MANUFACTURER, + SENSOR_MODEL, + SENSOR_CONNECTION_TYPE, + SENSOR_PERSISTENT_UNIQUEID, + SENSOR_ISPRIMARY, + SENSOR_ENUMERATION_PROPERTIES_COUNT +} SENSOR_ENUMERATION_PROPERTIES_INDEX; + +enum class SensorConnectionType : ULONG +{ + Integrated = 0, + Attached = 1, + External = 2 +}; + +// +// Data-field Properties +// +typedef enum +{ + SENSOR_RESOLUTION = 0, + SENSOR_MIN_RANGE, + SENSOR_MAX_RANGE, + SENSOR_DATA_FIELD_PROPERTY_COUNT +} SENSOR_DATA_FIELD_PROPERTY_INDEX; + +// +// Sensor Common Properties +// +typedef enum +{ + SENSOR_COMMON_PROPERTY_STATE = 0, + SENSOR_COMMON_PROPERTY_MIN_INTERVAL, + SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE, + SENSOR_COMMON_PROPERTY_TYPE, + SENSOR_COMMON_PROPERTY_COUNT +} SENSOR_COMMON_PROPERTIES_INDEX; + + + +// +// Base --------------------------------------------------------------------- +// +typedef class _ComboDevice +{ +public: + // + // WDF + // + WDFDEVICE m_Device; + SENSOROBJECT m_SensorInstance; + WDFWAITLOCK m_Lock; + WDFTIMER m_Timer; + + // + // Sensor Operation + // + BOOLEAN m_PoweredOn; + BOOLEAN m_Started; + ULONG m_IntervalMs; + ULONG m_MinimumIntervalMs; + BOOLEAN m_FirstSample; + ULONG m_StartTime; + ULONGLONG m_SampleCount; + BOOLEAN m_WakeEnabled; + + // + // Sensor Specific Properties + // + PSENSOR_COLLECTION_LIST m_pEnumerationProperties; + PSENSOR_COLLECTION_LIST m_pProperties; + PSENSOR_PROPERTY_LIST m_pSupportedDataFields; + PSENSOR_COLLECTION_LIST m_pDataFieldProperties; + PSENSOR_COLLECTION_LIST m_pThresholds; + PSENSOR_COLLECTION_LIST m_pData; + +public: + // + // Sensor specific functions + // + virtual NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj) = NULL; + virtual NTSTATUS GetData() = NULL; + virtual NTSTATUS UpdateCachedThreshold() = NULL; + virtual NTSTATUS EnableWake() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS DisableWake() { return STATUS_NOT_SUPPORTED; } + + // + // History functions - none of the sensors in this driver actually support history yet, this is for testing purpose now. + // + virtual NTSTATUS StartHistory() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS StopHistory() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS ClearHistory() { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS StartHistoryRetrieval(_Inout_ PSENSOR_COLLECTION_LIST /*pHistoryBuffer*/, _In_ ULONG /*HistorySizeInBytes*/) { return STATUS_NOT_SUPPORTED; } + virtual NTSTATUS CancelHistoryRetrieval(_Out_ PULONG /*pBytesWritten*/) { return STATUS_NOT_SUPPORTED; } + +} ComboDevice, *PComboDevice; + +// Set up accessor function to retrieve device context +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ComboDevice, GetContextFromSensorInstance); + + +// +// Ambient Light -------------------------------------------------------------- +// +typedef class _AlsDevice : public _ComboDevice +{ +private: + // Internal struct used to store readings + typedef struct _AlsData + { + FLOAT Lux; + FLOAT Kelvins; + FLOAT ChromaticityX; + FLOAT ChromaticityY; + BOOL IsValid; + } AlsData, *PAlsData; + + // Internal struct used to store thresholds + typedef struct _AlsThresholdData + { + FLOAT LuxPct; + FLOAT LuxAbs; + FLOAT KelvinsAbs; + FLOAT ChromaticityXAbs; + FLOAT ChromaticityYAbs; + } AlsThresholdData; + +private: + + AlsThresholdData m_CachedThresholds; + AlsData m_CachedData; + AlsData m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} AlsDevice, *PAlsDevice; + + + +// +// Barometer -------------------------------------------------------------- +// +typedef class _BarDevice : public _ComboDevice +{ +private: + + FLOAT m_CachedThresholds; + FLOAT m_CachedData; + FLOAT m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} BarDevice, *PBarDevice; + + + +// +// Gyroscope ------------------------------------------------------------------ +// +typedef class _GyrDevice : public _ComboDevice +{ +private: + + VEC3D m_CachedThresholds; + VEC3D m_CachedData; + VEC3D m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} GyrDevice, *PGyrDevice; + + + +// +// Magnetometer --------------------------------------------------------------- +// +typedef struct _MagData +{ + VEC3D Axis; + ULONG Accuracy; +} MagData, *PMagData; + +typedef class _MagDevice : public _ComboDevice +{ +private: + + VEC3D m_CachedThresholds; + MagData m_CachedData; + MagData m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} MagDevice, *PMagDevice; + + + +// +// Proximity ------------------------------------------------------------------ +// +typedef struct +{ + BOOL Detected; + ULONG DistanceMillimeters; +} PrxData, *PPrxData; + +typedef class _PrxDevice : public _ComboDevice +{ +private: + + PrxData m_CachedData; + PrxData m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} PrxDevice, *PPrxDevice; + + + +// +// Relative Fusion ------------------------------------------------------------------ +// +typedef class _RelativeFusionDevice : public _ComboDevice +{ +private: + + QUATERNION m_CachedThresholds; + QUATERNION m_CachedData; + QUATERNION m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} RelativeFusionDevice, *PRelativeFusionDevice; + +// +// Linear Accelerometer -------------------------------------------------------------- +// +typedef class _LinearAccelerometerDevice : public _ComboDevice +{ +private: + + typedef struct _LinearAccelerometerSample + { + VEC3D Axis; + BOOL Shake; + } LinearAccelerometerSample, *PLinearAccelerometerSample; + + LinearAccelerometerSample m_CachedThresholds; + LinearAccelerometerSample m_CachedData; + LinearAccelerometerSample m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} LinearAccelerometerDevice, *PLinearAccelerometerDevice; + +// +// Gravity Vector -------------------------------------------------------------- +// +typedef class _GravityVectorDevice : public _ComboDevice +{ +private: + + VEC3D m_CachedThresholds; + VEC3D m_CachedData; + VEC3D m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} GravityVectorDevice, *PGravityVectorDevice; + +// +// Geomagnetic Orientation ------------------------------------------------------------------ +// +typedef class _GeomagneticOrientationDevice : public _ComboDevice +{ +private: + + typedef struct _GeomagneticOrientationSample + { + QUATERNION Quaternion; + FLOAT RotationAngle_Degrees; + FLOAT DeclinationAngle_Degrees; + } GeomagneticOrientationSample, *PGeomagneticOrientationSample; + + GeomagneticOrientationSample m_CachedThresholds; + GeomagneticOrientationSample m_CachedData; + GeomagneticOrientationSample m_LastSample; + +public: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + NTSTATUS UpdateCachedThreshold(); + +} GeomagneticOrientationDevice, *PGeomagneticOrientationDevice; diff --git a/sensors/SensorsComboDriver/Device.cpp b/sensors/SensorsComboDriver/Device.cpp new file mode 100644 index 00000000..b93bbbd1 --- /dev/null +++ b/sensors/SensorsComboDriver/Device.cpp @@ -0,0 +1,477 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of WDF callback functions +// for combo driver. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" +#include "Driver.h" + +#include + +#include "Device.tmh" + +//--------------------------------------- +// Declare and map devices below +//--------------------------------------- +enum Device +{ + Device_Als = 0, + Device_Bar, + Device_GeomagneticOrientation, + Device_GravityVector, + Device_Gyr, + Device_LinearAccelerometer, + Device_Mag, + Device_Prx, + Device_RelativeFusion, + // Keep this last + Device_Count +}; + +static const ULONG SensorInstanceCount = Device_Count; +static SENSOROBJECT SensorInstancesBuffer[SensorInstanceCount]; // Global buffer to avoid allocate and free + +inline size_t GetDeviceSizeAtIndex( + _In_ ULONG Index) +{ + size_t result = 0; + switch (static_cast(Index)) + { + case Device_Als: result = sizeof(AlsDevice); break; + case Device_Bar: result = sizeof(BarDevice); break; + case Device_GeomagneticOrientation: result = sizeof(GeomagneticOrientationDevice); break; + case Device_GravityVector: result = sizeof(GravityVectorDevice); break; + case Device_Gyr: result = sizeof(GyrDevice); break; + case Device_LinearAccelerometer: result = sizeof(LinearAccelerometerDevice); break; + case Device_Mag: result = sizeof(MagDevice); break; + case Device_Prx: result = sizeof(PrxDevice); break; + case Device_RelativeFusion: result = sizeof(RelativeFusionDevice); break; + default: break; // invalid + } + return result; +} + +void AllocateDeviceAtIndex( + _In_ ULONG Index, + _Inout_ PComboDevice* ppDevice + ) +{ + switch (static_cast(Index)) + { + case Device_Als: *ppDevice = new(*ppDevice) AlsDevice; break; + case Device_Bar: *ppDevice = new(*ppDevice) BarDevice; break; + case Device_GeomagneticOrientation: *ppDevice = new(*ppDevice) GeomagneticOrientationDevice; break; + case Device_GravityVector: *ppDevice = new(*ppDevice) GravityVectorDevice; break; + case Device_Gyr: *ppDevice = new(*ppDevice) GyrDevice; break; + case Device_LinearAccelerometer: *ppDevice = new(*ppDevice) LinearAccelerometerDevice; break; + case Device_Mag: *ppDevice = new(*ppDevice) MagDevice; break; + case Device_Prx: *ppDevice = new(*ppDevice) PrxDevice; break; + case Device_RelativeFusion: *ppDevice = new(*ppDevice) RelativeFusionDevice; break; + + default: break; // invalid (let driver fail) + } +} + +//------------------------------------------------------------------------------ +// +// Function: OnDeviceAdd +// +// This routine is the AddDevice entry point for the combo client +// driver. This routine is called by the framework in response to AddDevice +// call from the PnP manager. It will create and initialize the device object +// to represent a new instance of the sensor client. +// +// Arguments: +// Driver: IN: Supplies a handle to the driver object created in DriverEntry +// DeviceInit: IN: Supplies a pointer to a framework-allocated WDFDEVICE_INIT structure +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnDeviceAdd( + _In_ WDFDRIVER /*Driver*/, + _Inout_ PWDFDEVICE_INIT pDeviceInit + ) +{ + WDF_PNPPOWER_EVENT_CALLBACKS Callbacks; + WDFDEVICE Device; + WDF_OBJECT_ATTRIBUTES FdoAttributes; + ULONG Flag = 0; + SENSOR_CONTROLLER_CONFIG SensorConfig; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + WDF_OBJECT_ATTRIBUTES_INIT(&FdoAttributes); + + // + // Initialize FDO attributes and set up file object with sensor extension + // + Status = SensorsCxDeviceInitConfig(pDeviceInit, &FdoAttributes, Flag); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorsCxDeviceInitConfig failed %!STATUS!", Status); + goto Exit; + } + + // + // Register the PnP callbacks with the framework. + // + WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&Callbacks); + Callbacks.EvtDevicePrepareHardware = OnPrepareHardware; + Callbacks.EvtDeviceReleaseHardware = OnReleaseHardware; + Callbacks.EvtDeviceD0Entry = OnD0Entry; + Callbacks.EvtDeviceD0Exit = OnD0Exit; + + WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &Callbacks); + + // + // Call the framework to create the device + // + Status = WdfDeviceCreate(&pDeviceInit, &FdoAttributes, &Device); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! WdfDeviceCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Register CLX callback function pointers + // + SENSOR_CONTROLLER_CONFIG_INIT(&SensorConfig); + SensorConfig.DriverIsPowerPolicyOwner = WdfUseDefault; + + SensorConfig.EvtSensorStart = OnStart; + SensorConfig.EvtSensorStop = OnStop; + SensorConfig.EvtSensorGetSupportedDataFields = OnGetSupportedDataFields; + SensorConfig.EvtSensorGetDataInterval = OnGetDataInterval; + SensorConfig.EvtSensorSetDataInterval = OnSetDataInterval; + SensorConfig.EvtSensorGetDataFieldProperties = OnGetDataFieldProperties; + SensorConfig.EvtSensorGetDataThresholds = OnGetDataThresholds; + SensorConfig.EvtSensorSetDataThresholds = OnSetDataThresholds; + SensorConfig.EvtSensorGetProperties = OnGetProperties; + SensorConfig.EvtSensorDeviceIoControl = OnIoControl; + SensorConfig.EvtSensorStartHistory = OnStartHistory; + SensorConfig.EvtSensorStopHistory = OnStopHistory; + SensorConfig.EvtSensorClearHistory = OnClearHistory; + SensorConfig.EvtSensorStartHistoryRetrieval = OnStartHistoryRetrieval; + SensorConfig.EvtSensorCancelHistoryRetrieval = OnCancelHistoryRetrieval; + SensorConfig.EvtSensorEnableWake = OnEnableWake; + SensorConfig.EvtSensorDisableWake = OnDisableWake; + + // + // Set up power capabilities and IO queues + // + Status = SensorsCxDeviceInitialize(Device, &SensorConfig); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorDeviceInitialize failed %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + +//------------------------------------------------------------------------------ +// +// Function: OnPrepareHardware +// +// This routine is called by the framework when the PnP manager sends an +// IRP_MN_START_DEVICE request to the driver stack. This routine is +// responsible for performing operations that are necessary to make the +// driver's device operational (for e.g. mapping the hardware resources +// into memory). +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// ResourcesRaw: IN: Supplies a handle to a collection of framework resource +// objects. This collection identifies the raw (bus-relative) hardware +// resources that have been assigned to the device. +// ResourcesTranslated: IN: Supplies a handle to a collection of framework +// resource objects. This collection identifies the translated +// (system-physical) hardware resources that have been assigned to the +// device. The resources appear from the CPU's point of view. +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnPrepareHardware( + _In_ WDFDEVICE Device, + _In_ WDFCMRESLIST /*ResourcesRaw*/, + _In_ WDFCMRESLIST /*ResourcesTranslated*/ + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + for (ULONG Count = 0; Count < SensorInstanceCount; Count++) + { + PComboDevice pDevice = nullptr; + WDF_OBJECT_ATTRIBUTES SensorAttr; + SENSOR_CONFIG SensorConfig; + SENSOROBJECT SensorInstance; + + // Create WDFOBJECT for the sensor + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&SensorAttr, ComboDevice); + SensorAttr.ContextSizeOverride = GetDeviceSizeAtIndex(Count); + + // Register sensor instance with clx + Status = SensorsCxSensorCreate(Device, &SensorAttr, &SensorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorsCxSensorCreate failed %!STATUS!", Status); + goto Exit; + } + + pDevice = GetContextFromSensorInstance(SensorInstance); + if (nullptr == pDevice) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + AllocateDeviceAtIndex(Count, &pDevice); + + // Fill out properties + Status = pDevice->Initialize(Device, SensorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Initialize device object failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_CONFIG_INIT(&SensorConfig); + SensorConfig.pEnumerationList = pDevice->m_pEnumerationProperties; + Status = SensorsCxSensorInitialize(SensorInstance, &SensorConfig); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! SensorsCxSensorInitialize failed %!STATUS!", Status); + goto Exit; + } + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// +// Function: OnReleaseHardware +// +// This routine is called by the framework when the PnP manager is revoking +// ownership of our resources. This may be in response to either +// IRP_MN_STOP_DEVICE or IRP_MN_REMOVE_DEVICE. This routine is responsible for +// performing cleanup of resources allocated in PrepareHardware callback. +// This callback is invoked before passing the request down to the lower driver. +// This routine will also be invoked by the framework if the prepare hardware +// callback returns a failure. +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// ResourcesTranslated: IN: Supplies a handle to a collection of framework +// resource objects. This collection identifies the translated +// (system-physical) hardware resources that have been assigned to the +// device. The resources appear from the CPU's point of view. +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnReleaseHardware( + _In_ WDFDEVICE Device, + _In_ WDFCMRESLIST /*ResourcesTranslated*/ + ) +{ + ULONG Count = SensorInstanceCount; + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + for (Count = 0; Count < SensorInstanceCount; Count++) + { + pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // Delete lock + if (NULL != pDevice->m_Lock) + { + WdfObjectDelete(pDevice->m_Lock); + pDevice->m_Lock = NULL; + } + + // Delete sensor instance + if (NULL != pDevice->m_SensorInstance) + { + WdfObjectDelete(pDevice->m_SensorInstance); + // The pDevice context created using WdfMemoryCreate and parented to m_SensorInstance is automatically + // destroyed when m_SensorInstance is deleted. pDevice is therefore no longer accessible beyond the above call to WdfObjectDelete. + // We can therefore not set the m_SensorInstance member back to NULL. We instead set pDevice to nullptr. + pDevice = nullptr; + } + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// +// Function: OnD0Entry +// +// This routine is invoked by the framework to program the device to goto +// D0, which is the working state. The framework invokes callback every +// time the hardware needs to be (re-)initialized. This includes after +// IRP_MN_START_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE, +// and IRP_MN_SET_POWER-D0. +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// PreviousState: IN: WDF_POWER_DEVICE_STATE-typed enumerator that identifies +// the device power state that the device was in before this transition to D0 +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnD0Entry( + _In_ WDFDEVICE Device, + _In_ WDF_POWER_DEVICE_STATE /*PreviousState*/ + ) +{ + ULONG Count = SensorInstanceCount; + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Get sensor instances + // + Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + // + // Powering on all sensor instances + // + for (Count = 0; Count < SensorInstanceCount; Count++) + { + pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + pDevice->m_PoweredOn = TRUE; + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// +// Function: OnD0Exit +// +// This routine is invoked by the framework to program the device to go into +// a certain Dx state. The framework invokes callback every the the device is +// leaving the D0 state, which happens when the device is stopped, when it is +// removed, and when it is powered off. +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// TargetState: IN: Supplies the device power state which the device will be put +// in once the callback is complete +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +OnD0Exit( + _In_ WDFDEVICE Device, + _In_ WDF_POWER_DEVICE_STATE /*TargetState*/ + ) +{ + ULONG Count = SensorInstanceCount; + PComboDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Get sensor instances + // + Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + // + // Powering off all sensor instances + // + for (Count = 0; Count < SensorInstanceCount; Count++) + { + pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + pDevice->m_PoweredOn = FALSE; + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} diff --git a/sensors/SensorsComboDriver/Driver.cpp b/sensors/SensorsComboDriver/Driver.cpp new file mode 100644 index 00000000..1ebc7a01 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver.cpp @@ -0,0 +1,100 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of entry and exit point of combo driver. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" +#include "Driver.h" + +#include "Driver.tmh" + +//------------------------------------------------------------------------------ +// Function: DriverEntry +// +// This routine is the driver initialization entry point. +// +// Arguments: +// DriverObject: IN: Pointer to the driver object created by the I/O manager +// RegistryPath: IN: Pointer to the driver specific registry key +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +DriverEntry( + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath + ) +{ + WDF_DRIVER_CONFIG DriverConfig; + NTSTATUS Status = STATUS_SUCCESS; + + // + // Initialize WPP Tracing + // + WPP_INIT_TRACING(DriverObject, NULL); + + SENSOR_FunctionEnter(); + + DriverConfig.DriverPoolTag = SENSORV2_POOL_TAG_COMBO; + + // + // Initialize the driver configuration structure. + // + WDF_DRIVER_CONFIG_INIT(&DriverConfig, OnDeviceAdd); + DriverConfig.EvtDriverUnload = OnDriverUnload; + + // + // Create a framework driver object to represent our driver. + // + Status = WdfDriverCreate(DriverObject, + RegistryPath, + WDF_NO_OBJECT_ATTRIBUTES, + &DriverConfig, + WDF_NO_HANDLE); + + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! WdfDriverCreate failed: %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: OnDriverUnload +// +// This routine is called when the driver unloads. +// +// Arguments: +// Driver: IN: driver object +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +VOID +OnDriverUnload( + _In_ WDFDRIVER Driver + ) +{ + SENSOR_FunctionEnter(); + + UNREFERENCED_PARAMETER(Driver); + + SENSOR_FunctionExit(STATUS_SUCCESS); + + WPP_CLEANUP(Driver); + + return; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver.h b/sensors/SensorsComboDriver/Driver.h new file mode 100644 index 00000000..de307270 --- /dev/null +++ b/sensors/SensorsComboDriver/Driver.h @@ -0,0 +1,31 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved +// +// Abstract: +// +// This module contains the type definitions for the combo +// driver callback class. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#pragma once + +WDF_EXTERN_C_START + +// +// Driver Entry/Exit Functions +// +DRIVER_INITIALIZE DriverEntry; +EVT_WDF_DRIVER_UNLOAD OnDriverUnload; + +// +// WDF Device Callbacks +// +EVT_WDF_DRIVER_DEVICE_ADD OnDeviceAdd; +EVT_WDF_DEVICE_PREPARE_HARDWARE OnPrepareHardware; +EVT_WDF_DEVICE_RELEASE_HARDWARE OnReleaseHardware; +EVT_WDF_DEVICE_D0_ENTRY OnD0Entry; +EVT_WDF_DEVICE_D0_EXIT OnD0Exit; + +WDF_EXTERN_C_END \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/AlsClient.cpp b/sensors/SensorsComboDriver/Driver/AlsClient.cpp deleted file mode 100644 index eb7080a2..00000000 --- a/sensors/SensorsComboDriver/Driver/AlsClient.cpp +++ /dev/null @@ -1,639 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" - -#include "AlsClient.tmh" - -#define SENSORV2_POOL_TAG_AMBIENT_LIGHT '2LmA' - -#define Als_Initial_MinDataInterval_Ms (10) // 100Hz -#define Als_Initial_Lux_Threshold_Pct (1.0f) // Percent threshold: 100% -#define Als_Initial_Lux_Threshold_Abs (0.0f) // Absolute threshold: 0 lux -#define Als_Initial_Kelvin_Threshold_Abs (100.0f) // Absolute threshold: 100 Kelvins -#define Als_Initial_Chromaticity_X_Threshold_Abs (0.01f) // Absolute threshold: 0.01 of a CIE 1931 chromaticity x coordinate -#define Als_Initial_Chromaticity_Y_Threshold_Abs (0.01f) // Absolute threshold: 0.01 of a CIE 1931 chromaticity y coordinate - -#define AlsDevice_Minimum_Lux (-4.0f) -#define AlsDevice_Maximum_Lux (4.0f) -#define AlsDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data -#define AlsDevice_Range_Lux (AlsDevice_Maximum_Lux - AlsDevice_Minimum_Lux) -#define AlsDevice_Resolution_Lux (AlsDevice_Range_Lux / AlsDevice_Precision) - -// Ambient Light Sensor Unique ID -// {2D2A4524-51E3-4E68-9B0F-5CAEDFB12C02} -DEFINE_GUID(GUID_AlsDevice_UniqueID, - 0x2d2a4524, 0x51e3, 0x4e68, 0x9b, 0xf, 0x5c, 0xae, 0xdf, 0xb1, 0x2c, 0x2); - -// Sensor data -typedef enum -{ - ALS_DATA_TIMESTAMP = 0, - ALS_DATA_LUX, - ALS_DATA_KELVINS, - ALS_DATA_CHROMATICITY_X, - ALS_DATA_CHROMATICITY_Y, - ALS_DATA_ISVALID, - ALS_DATA_COUNT -} ALS_DATA_INDEX; - -// Sensor thresholds -typedef enum -{ - ALS_THRESHOLD_LUX_PCT = 0, - ALS_THRESHOLD_LUX_ABS, - ALS_THRESHOLD_KELVINS_ABS, - ALS_THRESHOLD_CHROMATICITY_X_ABS, - ALS_THRESHOLD_CHROMATICITY_Y_ABS, - ALS_THRESHOLD_COUNT -} ALS_THRESHOLD_INDEX; - -// -// Sensor Enumeration Properties -// - -typedef enum -{ - SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX is adding properties to the base SENSOR_ENUMERATION_PROPERTIES_COUNT enum. - SENSOR_ALS_COLOR_CAPABLE, // In order to keep the SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX enum indexing coherent with the SENSOR_ENUMERATION_PROPERTIES_INDEX enum, - // set SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED to the index of the last value in the SENSOR_ENUMERATION_PROPERTIES_INDEX enum - SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT -} SENSOR_ALS_ENUMERATION_PROPERTIES_INDEX; - -typedef enum -{ - SENSOR_PROPERTY_ALS_RESPONSE_CURVE = SENSOR_COMMON_PROPERTY_COUNT, // SENSOR_ALS_PROPERTIES_INDEX is adding SENSOR_PROPERTY_ALS_RESPONSE_CURVE to the base SENSOR_COMMON_PROPERTIES_INDEX enum. - // In order to keep the SENSOR_ALS_PROPERTIES_INDEX enum indexing coherent with the SENSOR_COMMON_PROPERTIES_INDEX enum, - // set SENSOR_PROPERTY_ALS_RESPONSE_CURVE to the index of the last value in the SENSOR_COMMON_PROPERTIES_INDEX enum - SENSOR_ALS_PROPERTY_COUNT -} SENSOR_ALS_PROPERTIES_INDEX; - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -AlsDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! ALS WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! ALS WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, - Size, - &MemoryHandle, - (PVOID*)&m_pEnumerationProperties); - if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) - { - TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ALS_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_AmbientLight, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"ALS", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_AlsDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(TRUE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - - m_pEnumerationProperties->List[SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED].Key = DEVPKEY_LightSensor_AutoBrightnessPreferred; - InitPropVariantFromBoolean(TRUE, - &(m_pEnumerationProperties->List[SENSOR_ALS_AUTOBRIGHTNESS_PREFERRED].Value)); - - m_pEnumerationProperties->List[SENSOR_ALS_COLOR_CAPABLE].Key = DEVPKEY_LightSensor_ColorCapable; - InitPropVariantFromBoolean(TRUE, - &(m_pEnumerationProperties->List[SENSOR_ALS_COLOR_CAPABLE].Value)); - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(ALS_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, - Size, - &MemoryHandle, - (PVOID*)&m_pSupportedDataFields); - if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) - { - TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = ALS_DATA_COUNT; - - m_pSupportedDataFields->List[ALS_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[ALS_DATA_LUX] = PKEY_SensorData_LightLevel_Lux; - m_pSupportedDataFields->List[ALS_DATA_KELVINS] = PKEY_SensorData_LightTemperature_Kelvins; - m_pSupportedDataFields->List[ALS_DATA_CHROMATICITY_X] = PKEY_SensorData_LightChromaticityX; - m_pSupportedDataFields->List[ALS_DATA_CHROMATICITY_Y] = PKEY_SensorData_LightChromaticityY; - m_pSupportedDataFields->List[ALS_DATA_ISVALID] = PKEY_SensorData_IsValid; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(ALS_DATA_COUNT); - FILETIME Time = {0}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, - Size, - &MemoryHandle, - (PVOID*)&m_pData); - if (!NT_SUCCESS(Status) || m_pData == nullptr) - { - TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = ALS_DATA_COUNT; - - m_pData->List[ALS_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[ALS_DATA_TIMESTAMP].Value)); - - m_pData->List[ALS_DATA_LUX].Key = PKEY_SensorData_LightLevel_Lux; - InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_LUX].Value)); - - m_pData->List[ALS_DATA_KELVINS].Key = PKEY_SensorData_LightTemperature_Kelvins; - InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_KELVINS].Value)); - - m_pData->List[ALS_DATA_CHROMATICITY_X].Key = PKEY_SensorData_LightChromaticityX; - InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_CHROMATICITY_X].Value)); - - m_pData->List[ALS_DATA_CHROMATICITY_Y].Key = PKEY_SensorData_LightChromaticityY; - InitPropVariantFromFloat(0.0f, &(m_pData->List[ALS_DATA_CHROMATICITY_Y].Value)); - - m_pData->List[ALS_DATA_ISVALID].Key = PKEY_SensorData_IsValid; - InitPropVariantFromBoolean(TRUE, &(m_pData->List[ALS_DATA_ISVALID].Value)); - - m_CachedData = { - 1.0f, // Lux - 1.0f, // Kelvins - 0.5f, // Chromaticity X - 0.5f, // Chromaticity Y - TRUE // IsValid - }; - - m_LastSample = { - 0.0f, // Lux - 0.0f, // Kelvins - 0.0f, // Chromaticity X - 0.0f, // Chromaticity Y - TRUE // IsValid - }; - } - - // - // Sensor Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ALS_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, - Size, - &MemoryHandle, - (PVOID*)&m_pProperties); - if (!NT_SUCCESS(Status) || m_pProperties == nullptr) - { - TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_ALS_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(Als_Initial_MinDataInterval_Ms, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - m_IntervalMs = Als_Initial_MinDataInterval_Ms; - m_MinimumIntervalMs = Als_Initial_MinDataInterval_Ms; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_AmbientLight, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - - ULONG responseCurve[10] = {}; // Array to contain the response curve data. - - // **************************************************************************************** - // The response curve consists of an array of byte pairs. - // The first byte contains the percentage brightness offset to be applied to the display. - // The second byte contains the corresponding ambient light value (in LUX). - // **************************************************************************************** - // (0, 10) - responseCurve[0] = 0; responseCurve[1] = 10; - // (10, 40) - responseCurve[2] = 10; responseCurve[3] = 40; - // (40, 100) - responseCurve[4] = 40; responseCurve[5] = 100; - // (68, 400) - responseCurve[6] = 68; responseCurve[7] = 400; - // (90, 1000) - responseCurve[8] = 90; responseCurve[9] = 1000; - - m_pProperties->List[SENSOR_PROPERTY_ALS_RESPONSE_CURVE].Key = PKEY_LightSensor_ResponseCurve; - InitPropVariantFromUInt32Vector(responseCurve, - 10, - &(m_pProperties->List[SENSOR_PROPERTY_ALS_RESPONSE_CURVE].Value)); - } - - // - // Data filed properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, - Size, - &MemoryHandle, - (PVOID*)&m_pDataFieldProperties); - if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) - { - TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(AlsDevice_Resolution_Lux, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(AlsDevice_Minimum_Lux, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(AlsDevice_Maximum_Lux, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(ALS_THRESHOLD_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, - Size, - &MemoryHandle, - (PVOID*)&m_pThresholds); - if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) - { - TraceError("COMBO %!FUNC! ALS WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = ALS_THRESHOLD_COUNT; - - // Set lux threshold - m_pThresholds->List[ALS_THRESHOLD_LUX_PCT].Key = PKEY_SensorData_LightLevel_Lux; - InitPropVariantFromFloat(Als_Initial_Lux_Threshold_Pct, - &(m_pThresholds->List[ALS_THRESHOLD_LUX_PCT].Value)); - m_CachedThresholds.LuxPct = Als_Initial_Lux_Threshold_Pct; - - m_pThresholds->List[ALS_THRESHOLD_LUX_ABS].Key = PKEY_SensorData_LightLevel_Lux_Threshold_AbsoluteDifference; - InitPropVariantFromFloat(Als_Initial_Lux_Threshold_Abs, - &(m_pThresholds->List[ALS_THRESHOLD_LUX_ABS].Value)); - m_CachedThresholds.LuxAbs = Als_Initial_Lux_Threshold_Abs; - - // Set kelvins threshold - m_pThresholds->List[ALS_THRESHOLD_KELVINS_ABS].Key = PKEY_SensorData_LightTemperature_Kelvins; - InitPropVariantFromFloat(Als_Initial_Kelvin_Threshold_Abs, - &(m_pThresholds->List[ALS_THRESHOLD_KELVINS_ABS].Value)); - m_CachedThresholds.KelvinsAbs = Als_Initial_Kelvin_Threshold_Abs; - - // Set chromaticity x threshold - m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_X_ABS].Key = PKEY_SensorData_LightChromaticityX; - InitPropVariantFromFloat(Als_Initial_Chromaticity_X_Threshold_Abs, - &(m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_X_ABS].Value)); - m_CachedThresholds.ChromaticityXAbs = Als_Initial_Chromaticity_X_Threshold_Abs; - - // Set chromaticity y threshold - m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_Y_ABS].Key = PKEY_SensorData_LightChromaticityY; - InitPropVariantFromFloat(Als_Initial_Chromaticity_Y_Threshold_Abs, - &(m_pThresholds->List[ALS_THRESHOLD_CHROMATICITY_Y_ABS].Value)); - m_CachedThresholds.ChromaticityYAbs = Als_Initial_Chromaticity_Y_Threshold_Abs; - - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -AlsDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (m_FirstSample != FALSE) - { - Status = GetPerformanceTime(&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! ALS GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ( - ( - // Lux thresholds needs to exceed absolute and percentage - ((abs(m_CachedData.Lux - m_LastSample.Lux) >= (m_LastSample.Lux * m_CachedThresholds.LuxPct)) && - (abs(m_CachedData.Lux - m_LastSample.Lux) >= m_CachedThresholds.LuxAbs)) || - // If IsValid has changed, the sample is valid - (m_CachedData.IsValid != m_LastSample.IsValid) || - // Kelvin temperature and Chromaticity thresholds - (abs(m_CachedData.Kelvins - m_LastSample.Kelvins) >= m_CachedThresholds.KelvinsAbs) || - (abs(m_CachedData.ChromaticityX - m_LastSample.ChromaticityX) >= m_CachedThresholds.ChromaticityXAbs) || - (abs(m_CachedData.ChromaticityY - m_LastSample.ChromaticityY) >= m_CachedThresholds.ChromaticityYAbs) - ) - && - ( - // In thresholded mode, don't send sample if the last sample sent was not IsValid and current sample is also not IsValid - !((m_CachedThresholds.LuxAbs != 0.0f) && (m_CachedThresholds.LuxPct != 0.0f) && - (m_CachedThresholds.KelvinsAbs != 0.0f) && (m_CachedThresholds.ChromaticityXAbs != 0.0f) && - (m_CachedThresholds.ChromaticityYAbs != 0.0f) && !m_CachedData.IsValid && !m_LastSample.IsValid) - ) - ) - { - DataReady = TRUE; - } - } - - if (DataReady != FALSE) - { - // update last sample - m_LastSample = m_CachedData; - - // push to clx - InitPropVariantFromFloat(m_LastSample.Lux, &(m_pData->List[ALS_DATA_LUX].Value)); - - InitPropVariantFromFloat(m_LastSample.Kelvins, &(m_pData->List[ALS_DATA_KELVINS].Value)); - - InitPropVariantFromFloat(m_LastSample.ChromaticityX, &(m_pData->List[ALS_DATA_CHROMATICITY_X].Value)); - - InitPropVariantFromFloat(m_LastSample.ChromaticityY, &(m_pData->List[ALS_DATA_CHROMATICITY_Y].Value)); - - InitPropVariantFromBoolean(m_LastSample.IsValid, &(m_pData->List[ALS_DATA_ISVALID].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[ALS_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! ALS Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -AlsDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_LightLevel_Lux, - &m_CachedThresholds.LuxPct); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Failed to get lux pct data from cached threshold %!STATUS!", Status); - } - - if (NT_SUCCESS(Status)) - { - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_LightLevel_Lux_Threshold_AbsoluteDifference, - &m_CachedThresholds.LuxAbs); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Failed to get lux abs data from cached threshold %!STATUS!", Status); - } - } - - if (NT_SUCCESS(Status)) - { - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_LightTemperature_Kelvins, - &m_CachedThresholds.KelvinsAbs); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Failed to get kelvin data from cached threshold %!STATUS!", Status); - } - } - - if (NT_SUCCESS(Status)) - { - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_LightChromaticityX, - &m_CachedThresholds.ChromaticityXAbs); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Failed to get chromaticity x data from cached threshold %!STATUS!", Status); - } - } - - if (NT_SUCCESS(Status)) - { - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_LightChromaticityY, - &m_CachedThresholds.ChromaticityYAbs); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Failed to get chromaticity y data from cached threshold %!STATUS!", Status); - } - } - - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/BarClient.cpp b/sensors/SensorsComboDriver/Driver/BarClient.cpp deleted file mode 100644 index 97135c59..00000000 --- a/sensors/SensorsComboDriver/Driver/BarClient.cpp +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (UMDF) - -#include "Clients.h" - -#include "BarClient.tmh" - -#define SENSORV2_POOL_TAG_BAROMETER '2RaB' - -#define Bar_Initial_MinDataInterval_Ms (10) // 100Hz -#define Bar_Initial_Threshold_Bar (0.001f) // 1 mBar ~= 10 meter - -#define BarDevice_Minimum_Bar (0.3f) -#define BarDevice_Maximum_Bar (1.1f) -#define BarDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data -#define BarDevice_Range_Bar (BarDevice_Maximum_Bar - BarDevice_Minimum_Bar) -#define BarDevice_Resolution_Bar (BarDevice_Range_Bar / BarDevice_Precision) - -// Barometer Unique ID -// {46CB48CE-272D-4402-8E09-07748F8940CA} -DEFINE_GUID(GUID_BarDevice_UniqueID, - 0x46cb48ce, 0x272d, 0x4402, 0x8e, 0x9, 0x7, 0x74, 0x8f, 0x89, 0x40, 0xca); - -// Sensor data -typedef enum -{ - BAR_DATA_TIMESTAMP = 0, - BAR_DATA_PRESSURE, - BAR_DATA_COUNT -} BAR_DATA_INDEX; - -// Sensor thresholds -typedef enum -{ - BAR_THRESHOLD_PRESSURE = 0, - BAR_THRESHOLD_COUNT -} BAR_THRESHOLD_INDEX; - - - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -BarDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! BAR WdfWaitLockCreate failed %!STATUS!", Status); - } - - // - // Create timer object for polling sensor samples - // - if (NT_SUCCESS(Status)) - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! BAR WdfTimerCreate failed %!STATUS!", Status); - } - } - - // - // Sensor Enumeration Properties - // - if (NT_SUCCESS(Status)) - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_BAROMETER, - Size, - &MemoryHandle, - reinterpret_cast(&m_pEnumerationProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) - { - TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); - } - else - { - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Barometer, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"Barometer", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_BarDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - } - } - - // - // Supported Data-Fields - // - if (NT_SUCCESS(Status)) - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(BAR_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_BAROMETER, - Size, - &MemoryHandle, - reinterpret_cast(&m_pSupportedDataFields)); - if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) - { - TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); - } - else - { - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = BAR_DATA_COUNT; - - m_pSupportedDataFields->List[BAR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[BAR_DATA_PRESSURE] = PKEY_SensorData_AtmosphericPressure_Bars; - } - } - - // - // Data - // - if (NT_SUCCESS(Status)) - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(BAR_DATA_COUNT); - FILETIME Time = {}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_BAROMETER, - Size, - &MemoryHandle, - reinterpret_cast(&m_pData)); - if (!NT_SUCCESS(Status) || nullptr == m_pData) - { - TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); - } - else - { - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = BAR_DATA_COUNT; - - m_pData->List[BAR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[BAR_DATA_TIMESTAMP].Value)); - - m_pData->List[BAR_DATA_PRESSURE].Key = PKEY_SensorData_AtmosphericPressure_Bars; - InitPropVariantFromFloat(0.0f, &(m_pData->List[BAR_DATA_PRESSURE].Value)); - - m_CachedData = 1.013f; - m_LastSample = 0.0f; - } - } - - // - // Sensor Properties - // - if (NT_SUCCESS(Status)) - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_BAROMETER, - Size, - &MemoryHandle, - reinterpret_cast(&m_pProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pProperties) - { - TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); - } - else - { - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(Bar_Initial_MinDataInterval_Ms, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - m_IntervalMs = Bar_Initial_MinDataInterval_Ms; - m_MinimumIntervalMs = Bar_Initial_MinDataInterval_Ms; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Barometer, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - } - - // - // Data filed properties - // - if (NT_SUCCESS(Status)) - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_BAROMETER, - Size, - &MemoryHandle, - reinterpret_cast(&m_pDataFieldProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) - { - TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); - } - else - { - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(BarDevice_Resolution_Bar, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(BarDevice_Minimum_Bar, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(BarDevice_Maximum_Bar, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - } - - // - // Set default threshold - // - if (NT_SUCCESS(Status)) - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(BAR_THRESHOLD_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_BAROMETER, - Size, - &MemoryHandle, - reinterpret_cast(&m_pThresholds)); - if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) - { - TraceError("COMBO %!FUNC! BAR WdfMemoryCreate failed %!STATUS!", Status); - } - else - { - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = BAR_THRESHOLD_COUNT; - - m_pThresholds->List[BAR_THRESHOLD_PRESSURE].Key = PKEY_SensorData_AtmosphericPressure_Bars; - InitPropVariantFromFloat(Bar_Initial_Threshold_Bar, - &(m_pThresholds->List[BAR_THRESHOLD_PRESSURE].Value)); - - m_CachedThresholds = Bar_Initial_Threshold_Bar; - m_FirstSample = TRUE; - } - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -BarDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (FALSE != m_FirstSample) - { - Status = GetPerformanceTime (&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! BAR GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ((abs(m_CachedData - m_LastSample) >= m_CachedThresholds)) - { - DataReady = TRUE; - } - } - - if (FALSE != DataReady) - { - // update last sample - m_LastSample = m_CachedData; - - // push to clx - InitPropVariantFromFloat(m_LastSample, &(m_pData->List[BAR_DATA_PRESSURE].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[BAR_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! BAR Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -BarDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_UNSUCCESSFUL; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AtmosphericPressure_Bars, - &m_CachedThresholds); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! BAR PropKeyFindKeyGetFloat for pressure failed %!STATUS!", Status); - } - - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/Clients.cpp b/sensors/SensorsComboDriver/Driver/Clients.cpp deleted file mode 100644 index 4524b6b6..00000000 --- a/sensors/SensorsComboDriver/Driver/Clients.cpp +++ /dev/null @@ -1,880 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of driver callback function -// from clx to clients. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" - -#include "Clients.tmh" - -static const UINT SYSTEM_TICK_COUNT_1MS = 1; // 1ms -//------------------------------------------------------------------------------ -// Function: OnTimerExpire -// -// This callback is called when interval wait time has expired and driver is ready -// to collect new sample. The callback reads current value, compare value to threshold, -// pushes it up to CLX framework, and schedule next wake up time. -// -// Arguments: -// Timer: IN: WDF timer object -// -// Return Value: -// None -//------------------------------------------------------------------------------ -VOID -OnTimerExpire( - _In_ WDFTIMER Timer - ) -{ - PComboDevice pDevice = nullptr; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - pDevice = GetContextFromSensorInstance(WdfTimerGetParentObject(Timer)); - if (pDevice == nullptr) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - goto Exit; - } - - // Get data and push to clx - Lock(pDevice->m_Lock); - Status = pDevice->GetData(); - if (!NT_SUCCESS(Status) && Status != STATUS_DATA_NOT_ACCEPTED) - { - TraceError("COMBO %!FUNC! GetData Failed %!STATUS!", Status); - } - Unlock(pDevice->m_Lock); - - // Schedule next wake up time - if (pDevice->m_MinimumIntervalMs <= pDevice->m_IntervalMs && - FALSE != pDevice->m_PoweredOn && - FALSE != pDevice->m_Started) - { - LONGLONG WaitTime = 0; // in unit of 100ns - - if (pDevice->m_StartTime == 0) - { - // in case we fail to get sensor start time, use static wait time - WaitTime = WDF_REL_TIMEOUT_IN_MS(pDevice->m_IntervalMs); - } - else - { - ULONG CurrentTimeMs = 0; - - // dynamically calculate wait time to avoid jitter - Status = GetPerformanceTime (&CurrentTimeMs); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GetPerformanceTime %!STATUS!", Status); - WaitTime = WDF_REL_TIMEOUT_IN_MS(pDevice->m_IntervalMs); - } - else - { - pDevice->m_SampleCount++; - if (CurrentTimeMs > (pDevice->m_StartTime + (pDevice->m_IntervalMs * (pDevice->m_SampleCount + 1)))) - { - // If we skipped two or more beats, reschedule the timer with a zero due time to catch up on missing samples - WaitTime = 0; - } - else - { - // Else, just compute the remaining time - WaitTime = (pDevice->m_StartTime + - (pDevice->m_IntervalMs * (pDevice->m_SampleCount + 1))) - CurrentTimeMs; - } - - WaitTime = WDF_REL_TIMEOUT_IN_MS(WaitTime); - } - } - - WdfTimerStart(pDevice->m_Timer, WaitTime); - } - -Exit: - - SENSOR_FunctionExit(Status); -} - - - -//------------------------------------------------------------------------------ -// Function: OnStart -// -// Called by Sensor CLX to begin continously sampling the sensor. -// -// Arguments: -// SensorInstance: IN: sensor device object -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnStart( - _In_ SENSOROBJECT SensorInstance - ) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (pDevice == nullptr) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Sensor(%p) parameter is invalid. Failed %!STATUS!", static_cast(&SensorInstance), Status); - goto Exit; - } - - if (pDevice->m_PoweredOn == FALSE) - { - Status = STATUS_DEVICE_NOT_READY; - TraceError("COMBO %!FUNC! Sensor is not powered on! %!STATUS!", Status); - goto Exit; - } - - // - // Start worker thread - // - - pDevice->m_IntervalMs; - - pDevice->m_FirstSample = TRUE; - - // Start polling - - pDevice->m_Started = TRUE; - - InitPropVariantFromUInt32(SensorState_Active, - &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(pDevice->m_MinimumIntervalMs)); - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnStop -// -// Called by Sensor CLX to stop continously sampling the sensor. -// -// Arguments: -// SensorInstance: IN: sensor device object -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnStop( - _In_ SENSOROBJECT SensorInstance - ) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (pDevice == nullptr) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Sensor(%p) parameter is invalid. Failed %!STATUS!", static_cast(&SensorInstance), Status); - goto Exit; - } - - // Stop polling - - pDevice->m_Started = FALSE; - - WdfTimerStop(pDevice->m_Timer, TRUE); - - InitPropVariantFromUInt32(SensorState_Idle, - &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - // - // Restoring system time resolution - // - if (TIMERR_NOERROR != timeEndPeriod(SYSTEM_TICK_COUNT_1MS)) - { - // not a failure, just log message - Status = STATUS_UNSUCCESSFUL; - TraceWarning("COMBO %!FUNC! timeEndPeriod failed to restore timer resolution! %!STATUS!", Status); - } - -Exit: - SENSOR_FunctionExit(Status); - - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnGetSupportedDataFields -// -// Called by Sensor CLX to get supported data fields. The typical usage is to call -// this function once with buffer pointer as NULL to acquire the required size -// for the buffer, allocate buffer, then call the function again to retrieve -// sensor information. -// -// Arguments: -// SensorInstance: IN: sensor device object -// pFields: INOUT_OPT: pointer to a list of supported properties -// pSize: OUT: number of bytes for the list of supported properties -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnGetSupportedDataFields( - _In_ SENSOROBJECT SensorInstance, - _Inout_opt_ PSENSOR_PROPERTY_LIST pFields, - _Out_ PULONG pSize - ) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice || nullptr == pSize) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); - goto Exit; - } - - if (nullptr == pFields) - { - // Just return size - *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; - } - else - { - if (pFields->AllocatedSizeInBytes < pDevice->m_pSupportedDataFields->AllocatedSizeInBytes) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); - goto Exit; - } - - // Fill out data - Status = PropertiesListCopy (pFields, pDevice->m_pSupportedDataFields); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! PropertiesListCopy failed %!STATUS!", Status); - goto Exit; - } - - *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; - } - -Exit: - if (!NT_SUCCESS(Status)) - { - *pSize = 0; - } - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnGetProperties -// -// Called by Sensor CLX to get sensor properties. The typical usage is to call -// this function once with buffer pointer as NULL to acquire the required size -// for the buffer, allocate buffer, then call the function again to retrieve -// sensor information. -// -// Arguments: -// SensorInstance: IN: sensor device object -// pProperties: INOUT_OPT: pointer to a list of sensor properties -// pSize: OUT: number of bytes for the list of sensor properties -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnGetProperties( - _In_ SENSOROBJECT SensorInstance, - _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, - _Out_ PULONG pSize - ) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice || nullptr == pSize) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); - goto Exit; - } - - if (nullptr == pProperties) - { - // Just return size - *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); - } - else - { - if (pProperties->AllocatedSizeInBytes < - CollectionsListGetMarshalledSize(pDevice->m_pProperties)) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); - goto Exit; - } - - // Fill out all data - Status = CollectionsListCopyAndMarshall(pProperties, pDevice->m_pProperties); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); - goto Exit; - } - - *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); - } - -Exit: - if (!NT_SUCCESS(Status)) - { - *pSize = 0; - } - SENSOR_FunctionExit(Status); - return Status; -} - - -//------------------------------------------------------------------------------ -// Function: OnGetDataFieldProperties -// -// Called by Sensor CLX to get data field properties. The typical usage is to call -// this function once with buffer pointer as NULL to acquire the required size -// for the buffer, allocate buffer, then call the function again to retrieve -// sensor information. -// -// Arguments: -// SensorInstance: IN: sensor device object -// DataField: IN: pointer to the propertykey of requested property -// pProperties: INOUT_OPT: pointer to a list of sensor properties -// pSize: OUT: number of bytes for the list of sensor properties -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnGetDataFieldProperties( - _In_ SENSOROBJECT SensorInstance, - _In_ const PROPERTYKEY *DataField, - _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, - _Out_ PULONG pSize -) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice || nullptr == pSize || nullptr == DataField) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Invalid parameters! %!STATUS!", Status); - goto Exit; - } - - if (IsKeyPresentInPropertyList(pDevice->m_pSupportedDataFields, DataField) != FALSE) - { - if (nullptr == pProperties) - { - // Just return size - *pSize = CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties); - } - else - { - if (pProperties->AllocatedSizeInBytes < - CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties)) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - TraceError("COMBO %!FUNC! Buffer is too small. Failed %!STATUS!", Status); - goto Exit; - } - - // Fill out all data - Status = CollectionsListCopyAndMarshall (pProperties, pDevice->m_pDataFieldProperties); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); - goto Exit; - } - - *pSize = CollectionsListGetMarshalledSize(pDevice->m_pDataFieldProperties); - } - } - else - { - Status = STATUS_NOT_SUPPORTED; - TraceError("COMBO %!FUNC! Sensor does NOT have properties for this data field. Failed %!STATUS!", Status); - goto Exit; - } - -Exit: - if (!NT_SUCCESS(Status)) - { - *pSize = 0; - } - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnGetDataInterval -// -// Called by Sensor CLX to get sampling rate of the sensor. -// -// Arguments: -// SensorInstance: IN: sensor device object -// DataRateMs: OUT: sampling rate in ms -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnGetDataInterval( - _In_ SENSOROBJECT SensorInstance, - _Out_ PULONG DataRateMs - ) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (pDevice == nullptr) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Invalid parameter!"); - goto Exit; - } - - if (DataRateMs == nullptr) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! DataRateMs(%p) parameter is invalid. Failed %!STATUS!", static_cast(DataRateMs), Status); - goto Exit; - } - - *DataRateMs = pDevice->m_IntervalMs; - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnSetDataInterval -// -// Called by Sensor CLX to set sampling rate of the sensor. -// -// Arguments: -// SensorInstance: IN: sensor device object -// DataRateMs: IN: sampling rate in ms -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnSetDataInterval( - _In_ SENSOROBJECT SensorInstance, - _In_ ULONG DataRateMs - ) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (pDevice == nullptr || DataRateMs == 0) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Invalid parameter!"); - goto Exit; - } - - pDevice->m_IntervalMs = DataRateMs; - - // reschedule sample to return as soon as possible if it's started - if (FALSE != pDevice->m_Started) - { - pDevice->m_Started = FALSE; - WdfTimerStop(pDevice->m_Timer, TRUE); - - pDevice->m_Started = TRUE; - pDevice->m_FirstSample = TRUE; - WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(pDevice->m_MinimumIntervalMs)); - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnGetDataThresholds -// -// Called by Sensor CLX to get data thresholds. The typical usage is to call -// this function once with buffer pointer as NULL to acquire the required size -// for the buffer, allocate buffer, then call the function again to retrieve -// sensor information. -// -// Arguments: -// SensorInstance: IN: sensor device object -// pThresholds: INOUT_OPT: pointer to a list of sensor thresholds -// pSize: OUT: number of bytes for the list of sensor thresholds -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnGetDataThresholds( - _In_ SENSOROBJECT SensorInstance, - _Inout_opt_ PSENSOR_COLLECTION_LIST pThresholds, - _Out_ PULONG pSize - ) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice || nullptr == pSize) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Invalid parameters!"); - goto Exit; - } - - if (nullptr == pThresholds) - { - // Just return size - *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); - } - else - { - if (pThresholds->AllocatedSizeInBytes < - CollectionsListGetMarshalledSize(pDevice->m_pThresholds)) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - TraceError("COMBO %!FUNC! Buffer is too small!"); - goto Exit; - } - - // Fill out all data - Status = CollectionsListCopyAndMarshall (pThresholds, pDevice->m_pThresholds); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); - goto Exit; - } - - *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); - } - -Exit: - if (!NT_SUCCESS(Status)) - { - *pSize = 0; - } - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnSetDataThresholds -// -// Called by Sensor CLX to set data thresholds. -// -// Arguments: -// SensorInstance: IN: sensor device object -// pThresholds: IN: pointer to a list of sensor thresholds -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnSetDataThresholds( - _In_ SENSOROBJECT SensorInstance, - _In_ PSENSOR_COLLECTION_LIST pThresholds - ) -{ - ULONG Element; - BOOLEAN IsLocked = FALSE; - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (pDevice == nullptr) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Invalid parameter!"); - goto Exit; - } - - Lock(pDevice->m_Lock); - IsLocked = TRUE; - - for (Element = 0; Element < pThresholds->Count; Element++) - { - Status = PropKeyFindKeySetPropVariant(pDevice->m_pThresholds, - &(pThresholds->List[Element].Key), - TRUE, - &(pThresholds->List[Element].Value)); - if (!NT_SUCCESS(Status)) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! Sensor does NOT have threshold for this data field. Failed %!STATUS!", Status); - goto Exit; - } - } - - // Update cached threshholds - Status = pDevice->UpdateCachedThreshold(); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! UpdateCachedThreshold failed! %!STATUS!", Status); - goto Exit; - } - -Exit: - if (IsLocked) - { - Unlock(pDevice->m_Lock); - IsLocked = FALSE; - } - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnIoControl -// -// Called by Sensor CLX to handle IOCTLs that clx does not support -// -// Arguments: -// SensorInstance: IN: Sensor object -// Request: IN: WDF request object -// OutputBufferLength: IN: number of bytes to retrieve from output buffer -// InputBufferLength: IN: number of bytes to retrieve from input buffer -// IoControlCode: IN: IOCTL control code -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS OnIoControl( - _In_ SENSOROBJECT /*SensorInstance*/, // Sensor object - _In_ WDFREQUEST /*Request*/, // WDF request object - _In_ size_t /*OutputBufferLength*/, // number of bytes to retrieve from output buffer - _In_ size_t /*InputBufferLength*/, // number of bytes to retrieve from input buffer - _In_ ULONG /*IoControlCode*/ // IOCTL control code - ) -{ - NTSTATUS Status = STATUS_NOT_SUPPORTED; - - SENSOR_FunctionEnter(); - - SENSOR_FunctionExit(Status); - return Status; -} - - - -// Called by Sensor CLX to begin keeping history -NTSTATUS OnStartHistory(_In_ SENSOROBJECT SensorInstance) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - } - else - { - Status = pDevice->StartHistory(); - } - - SENSOR_FunctionExit(Status); - return Status; -} - -// Called by Sensor CLX to stop keeping history. -NTSTATUS OnStopHistory(_In_ SENSOROBJECT SensorInstance) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - } - else - { - Status = pDevice->StopHistory(); - } - - SENSOR_FunctionExit(Status); - return Status; -} - -// Called by Sensor CLX to enable wake -NTSTATUS OnEnableWake(_In_ SENSOROBJECT SensorInstance) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - } - else - { - pDevice->m_WakeEnabled = TRUE; - Status = pDevice->EnableWake(); - } - - SENSOR_FunctionExit(Status); - return Status; -} - -// Called by Sensor CLX to disable wake -NTSTATUS OnDisableWake(_In_ SENSOROBJECT SensorInstance) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - } - else - { - pDevice->m_WakeEnabled = FALSE; - Status = pDevice->DisableWake(); - } - - SENSOR_FunctionExit(Status); - return Status; -} - -// Called by Sensor CLX to clear all history stored in the sensor. -NTSTATUS OnClearHistory(_In_ SENSOROBJECT SensorInstance) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - } - else - { - Status = pDevice->ClearHistory(); - } - - SENSOR_FunctionExit(Status); - return Status; -} - -// Called by Sensor CLX to start retrieving history. -NTSTATUS OnStartHistoryRetrieval( - _In_ SENSOROBJECT SensorInstance, - _Inout_updates_bytes_(HistorySizeInBytes) PSENSOR_COLLECTION_LIST pHistoryBuffer, - _In_ ULONG HistorySizeInBytes) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - } - else if (sizeof(SENSOR_COLLECTION_LIST) > HistorySizeInBytes) - { - Status = STATUS_BUFFER_TOO_SMALL; - TraceError("COMBO %!FUNC! HistorySizeInBytes is too small %!STATUS!", Status); - } - else - { - Status = pDevice->StartHistoryRetrieval(pHistoryBuffer, HistorySizeInBytes); - } - - SENSOR_FunctionExit(Status); - return Status; -} - -// Called by Sensor CLX to cancel history retrieval. -NTSTATUS OnCancelHistoryRetrieval(_In_ SENSOROBJECT SensorInstance, _Out_ PULONG pBytesWritten) -{ - PComboDevice pDevice = GetContextFromSensorInstance(SensorInstance); - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - } - else - { - Status = pDevice->CancelHistoryRetrieval(pBytesWritten); - } - - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/Clients.h b/sensors/SensorsComboDriver/Driver/Clients.h deleted file mode 100644 index a8992fa7..00000000 --- a/sensors/SensorsComboDriver/Driver/Clients.h +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved -// -// Abstract: -// -// This module contains the type definitions for the client -// driver's device callback class. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#pragma once - -#include -#include -#include -#include - -#include "SensorsTrace.h" -#include -#include - -// -// CLX Callbacks -// -EVT_SENSOR_DRIVER_START_SENSOR OnStart; -EVT_SENSOR_DRIVER_STOP_SENSOR OnStop; -EVT_SENSOR_DRIVER_GET_SUPPORTED_DATA_FIELDS OnGetSupportedDataFields; -EVT_SENSOR_DRIVER_GET_PROPERTIES OnGetProperties; -EVT_SENSOR_DRIVER_GET_DATA_FIELD_PROPERTIES OnGetDataFieldProperties; -EVT_SENSOR_DRIVER_GET_DATA_INTERVAL OnGetDataInterval; -EVT_SENSOR_DRIVER_SET_DATA_INTERVAL OnSetDataInterval; -EVT_SENSOR_DRIVER_GET_DATA_THRESHOLDS OnGetDataThresholds; -EVT_SENSOR_DRIVER_SET_DATA_THRESHOLDS OnSetDataThresholds; -EVT_SENSOR_DRIVER_DEVICE_IO_CONTROL OnIoControl; -EVT_SENSOR_DRIVER_START_SENSOR_HISTORY OnStartHistory; -EVT_SENSOR_DRIVER_STOP_SENSOR_HISTORY OnStopHistory; -EVT_SENSOR_DRIVER_CLEAR_SENSOR_HISTORY OnClearHistory; -EVT_SENSOR_DRIVER_START_HISTORY_RETRIEVAL OnStartHistoryRetrieval; -EVT_SENSOR_DRIVER_CANCEL_HISTORY_RETRIEVAL OnCancelHistoryRetrieval; -EVT_SENSOR_DRIVER_ENABLE_WAKE OnEnableWake; -EVT_SENSOR_DRIVER_DISABLE_WAKE OnDisableWake; - -EVT_WDF_TIMER OnTimerExpire; - - -/*++ -Routine Description: - Critical section lock/unlock to protect shared context -Return Value: - None ---*/ -#define Lock(lock) { WdfWaitLockAcquire(lock, NULL); } -#define Unlock(lock) { WdfWaitLockRelease(lock); } - -#define SENSORV2_POOL_TAG_COMBO '2bmC' - -// -// Sensor Enumeration Properties -// -typedef enum -{ - SENSOR_TYPE_GUID = 0, - SENSOR_MANUFACTURER, - SENSOR_MODEL, - SENSOR_CONNECTION_TYPE, - SENSOR_PERSISTENT_UNIQUEID, - SENSOR_ISPRIMARY, - SENSOR_ENUMERATION_PROPERTIES_COUNT -} SENSOR_ENUMERATION_PROPERTIES_INDEX; - -enum class SensorConnectionType : ULONG -{ - Integrated = 0, - Attached = 1, - External = 2 -}; - -// -// Data-field Properties -// -typedef enum -{ - SENSOR_RESOLUTION = 0, - SENSOR_MIN_RANGE, - SENSOR_MAX_RANGE, - SENSOR_DATA_FIELD_PROPERTY_COUNT -} SENSOR_DATA_FIELD_PROPERTY_INDEX; - -// -// Sensor Common Properties -// -typedef enum -{ - SENSOR_COMMON_PROPERTY_STATE = 0, - SENSOR_COMMON_PROPERTY_MIN_INTERVAL, - SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE, - SENSOR_COMMON_PROPERTY_TYPE, - SENSOR_COMMON_PROPERTY_COUNT -} SENSOR_COMMON_PROPERTIES_INDEX; - - - -// -// Base --------------------------------------------------------------------- -// -typedef class _ComboDevice -{ -public: - // - // WDF - // - WDFDEVICE m_Device; - SENSOROBJECT m_SensorInstance; - WDFWAITLOCK m_Lock; - WDFTIMER m_Timer; - - // - // Sensor Operation - // - BOOLEAN m_PoweredOn; - BOOLEAN m_Started; - ULONG m_IntervalMs; - ULONG m_MinimumIntervalMs; - BOOLEAN m_FirstSample; - ULONG m_StartTime; - ULONGLONG m_SampleCount; - BOOLEAN m_WakeEnabled; - - // - // Sensor Specific Properties - // - PSENSOR_COLLECTION_LIST m_pEnumerationProperties; - PSENSOR_COLLECTION_LIST m_pProperties; - PSENSOR_PROPERTY_LIST m_pSupportedDataFields; - PSENSOR_COLLECTION_LIST m_pDataFieldProperties; - PSENSOR_COLLECTION_LIST m_pThresholds; - PSENSOR_COLLECTION_LIST m_pData; - -public: - // - // Sensor specific functions - // - virtual NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj) = NULL; - virtual NTSTATUS GetData() = NULL; - virtual NTSTATUS UpdateCachedThreshold() = NULL; - virtual NTSTATUS EnableWake() { return STATUS_NOT_SUPPORTED; } - virtual NTSTATUS DisableWake() { return STATUS_NOT_SUPPORTED; } - - // - // History functions - none of the sensors in this driver actually support history yet, this is for testing purpose now. - // - virtual NTSTATUS StartHistory() { return STATUS_NOT_SUPPORTED; } - virtual NTSTATUS StopHistory() { return STATUS_NOT_SUPPORTED; } - virtual NTSTATUS ClearHistory() { return STATUS_NOT_SUPPORTED; } - virtual NTSTATUS StartHistoryRetrieval(_Inout_ PSENSOR_COLLECTION_LIST /*pHistoryBuffer*/, _In_ ULONG /*HistorySizeInBytes*/) { return STATUS_NOT_SUPPORTED; } - virtual NTSTATUS CancelHistoryRetrieval(_Out_ PULONG /*pBytesWritten*/) { return STATUS_NOT_SUPPORTED; } - -} ComboDevice, *PComboDevice; - -// Set up accessor function to retrieve device context -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ComboDevice, GetContextFromSensorInstance); - - -// -// Ambient Light -------------------------------------------------------------- -// -typedef class _AlsDevice : public _ComboDevice -{ -private: - // Internal struct used to store readings - typedef struct _AlsData - { - FLOAT Lux; - FLOAT Kelvins; - FLOAT ChromaticityX; - FLOAT ChromaticityY; - BOOL IsValid; - } AlsData, *PAlsData; - - // Internal struct used to store thresholds - typedef struct _AlsThresholdData - { - FLOAT LuxPct; - FLOAT LuxAbs; - FLOAT KelvinsAbs; - FLOAT ChromaticityXAbs; - FLOAT ChromaticityYAbs; - } AlsThresholdData; - -private: - - AlsThresholdData m_CachedThresholds; - AlsData m_CachedData; - AlsData m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} AlsDevice, *PAlsDevice; - - - -// -// Barometer -------------------------------------------------------------- -// -typedef class _BarDevice : public _ComboDevice -{ -private: - - FLOAT m_CachedThresholds; - FLOAT m_CachedData; - FLOAT m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} BarDevice, *PBarDevice; - - - -// -// Gyroscope ------------------------------------------------------------------ -// -typedef class _GyrDevice : public _ComboDevice -{ -private: - - VEC3D m_CachedThresholds; - VEC3D m_CachedData; - VEC3D m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} GyrDevice, *PGyrDevice; - - - -// -// Magnetometer --------------------------------------------------------------- -// -typedef struct _MagData -{ - VEC3D Axis; - ULONG Accuracy; -} MagData, *PMagData; - -typedef class _MagDevice : public _ComboDevice -{ -private: - - VEC3D m_CachedThresholds; - MagData m_CachedData; - MagData m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} MagDevice, *PMagDevice; - - - -// -// Proximity ------------------------------------------------------------------ -// -typedef struct -{ - BOOL Detected; - ULONG DistanceMillimeters; -} PrxData, *PPrxData; - -typedef class _PrxDevice : public _ComboDevice -{ -private: - - PrxData m_CachedData; - PrxData m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} PrxDevice, *PPrxDevice; - - - -// -// Relative Fusion ------------------------------------------------------------------ -// -typedef class _RelativeFusionDevice : public _ComboDevice -{ -private: - - QUATERNION m_CachedThresholds; - QUATERNION m_CachedData; - QUATERNION m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} RelativeFusionDevice, *PRelativeFusionDevice; - -// -// Linear Accelerometer -------------------------------------------------------------- -// -typedef class _LinearAccelerometerDevice : public _ComboDevice -{ -private: - - typedef struct _LinearAccelerometerSample - { - VEC3D Axis; - BOOL Shake; - } LinearAccelerometerSample, *PLinearAccelerometerSample; - - LinearAccelerometerSample m_CachedThresholds; - LinearAccelerometerSample m_CachedData; - LinearAccelerometerSample m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} LinearAccelerometerDevice, *PLinearAccelerometerDevice; - -// -// Gravity Vector -------------------------------------------------------------- -// -typedef class _GravityVectorDevice : public _ComboDevice -{ -private: - - VEC3D m_CachedThresholds; - VEC3D m_CachedData; - VEC3D m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} GravityVectorDevice, *PGravityVectorDevice; - -// -// Geomagnetic Orientation ------------------------------------------------------------------ -// -typedef class _GeomagneticOrientationDevice : public _ComboDevice -{ -private: - - typedef struct _GeomagneticOrientationSample - { - QUATERNION Quaternion; - FLOAT RotationAngle_Degrees; - FLOAT DeclinationAngle_Degrees; - } GeomagneticOrientationSample, *PGeomagneticOrientationSample; - - GeomagneticOrientationSample m_CachedThresholds; - GeomagneticOrientationSample m_CachedData; - GeomagneticOrientationSample m_LastSample; - -public: - - NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); - NTSTATUS GetData(); - NTSTATUS UpdateCachedThreshold(); - -} GeomagneticOrientationDevice, *PGeomagneticOrientationDevice; diff --git a/sensors/SensorsComboDriver/Driver/Device.cpp b/sensors/SensorsComboDriver/Driver/Device.cpp deleted file mode 100644 index b93bbbd1..00000000 --- a/sensors/SensorsComboDriver/Driver/Device.cpp +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of WDF callback functions -// for combo driver. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" -#include "Driver.h" - -#include - -#include "Device.tmh" - -//--------------------------------------- -// Declare and map devices below -//--------------------------------------- -enum Device -{ - Device_Als = 0, - Device_Bar, - Device_GeomagneticOrientation, - Device_GravityVector, - Device_Gyr, - Device_LinearAccelerometer, - Device_Mag, - Device_Prx, - Device_RelativeFusion, - // Keep this last - Device_Count -}; - -static const ULONG SensorInstanceCount = Device_Count; -static SENSOROBJECT SensorInstancesBuffer[SensorInstanceCount]; // Global buffer to avoid allocate and free - -inline size_t GetDeviceSizeAtIndex( - _In_ ULONG Index) -{ - size_t result = 0; - switch (static_cast(Index)) - { - case Device_Als: result = sizeof(AlsDevice); break; - case Device_Bar: result = sizeof(BarDevice); break; - case Device_GeomagneticOrientation: result = sizeof(GeomagneticOrientationDevice); break; - case Device_GravityVector: result = sizeof(GravityVectorDevice); break; - case Device_Gyr: result = sizeof(GyrDevice); break; - case Device_LinearAccelerometer: result = sizeof(LinearAccelerometerDevice); break; - case Device_Mag: result = sizeof(MagDevice); break; - case Device_Prx: result = sizeof(PrxDevice); break; - case Device_RelativeFusion: result = sizeof(RelativeFusionDevice); break; - default: break; // invalid - } - return result; -} - -void AllocateDeviceAtIndex( - _In_ ULONG Index, - _Inout_ PComboDevice* ppDevice - ) -{ - switch (static_cast(Index)) - { - case Device_Als: *ppDevice = new(*ppDevice) AlsDevice; break; - case Device_Bar: *ppDevice = new(*ppDevice) BarDevice; break; - case Device_GeomagneticOrientation: *ppDevice = new(*ppDevice) GeomagneticOrientationDevice; break; - case Device_GravityVector: *ppDevice = new(*ppDevice) GravityVectorDevice; break; - case Device_Gyr: *ppDevice = new(*ppDevice) GyrDevice; break; - case Device_LinearAccelerometer: *ppDevice = new(*ppDevice) LinearAccelerometerDevice; break; - case Device_Mag: *ppDevice = new(*ppDevice) MagDevice; break; - case Device_Prx: *ppDevice = new(*ppDevice) PrxDevice; break; - case Device_RelativeFusion: *ppDevice = new(*ppDevice) RelativeFusionDevice; break; - - default: break; // invalid (let driver fail) - } -} - -//------------------------------------------------------------------------------ -// -// Function: OnDeviceAdd -// -// This routine is the AddDevice entry point for the combo client -// driver. This routine is called by the framework in response to AddDevice -// call from the PnP manager. It will create and initialize the device object -// to represent a new instance of the sensor client. -// -// Arguments: -// Driver: IN: Supplies a handle to the driver object created in DriverEntry -// DeviceInit: IN: Supplies a pointer to a framework-allocated WDFDEVICE_INIT structure -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnDeviceAdd( - _In_ WDFDRIVER /*Driver*/, - _Inout_ PWDFDEVICE_INIT pDeviceInit - ) -{ - WDF_PNPPOWER_EVENT_CALLBACKS Callbacks; - WDFDEVICE Device; - WDF_OBJECT_ATTRIBUTES FdoAttributes; - ULONG Flag = 0; - SENSOR_CONTROLLER_CONFIG SensorConfig; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - WDF_OBJECT_ATTRIBUTES_INIT(&FdoAttributes); - - // - // Initialize FDO attributes and set up file object with sensor extension - // - Status = SensorsCxDeviceInitConfig(pDeviceInit, &FdoAttributes, Flag); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! SensorsCxDeviceInitConfig failed %!STATUS!", Status); - goto Exit; - } - - // - // Register the PnP callbacks with the framework. - // - WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&Callbacks); - Callbacks.EvtDevicePrepareHardware = OnPrepareHardware; - Callbacks.EvtDeviceReleaseHardware = OnReleaseHardware; - Callbacks.EvtDeviceD0Entry = OnD0Entry; - Callbacks.EvtDeviceD0Exit = OnD0Exit; - - WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &Callbacks); - - // - // Call the framework to create the device - // - Status = WdfDeviceCreate(&pDeviceInit, &FdoAttributes, &Device); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! WdfDeviceCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Register CLX callback function pointers - // - SENSOR_CONTROLLER_CONFIG_INIT(&SensorConfig); - SensorConfig.DriverIsPowerPolicyOwner = WdfUseDefault; - - SensorConfig.EvtSensorStart = OnStart; - SensorConfig.EvtSensorStop = OnStop; - SensorConfig.EvtSensorGetSupportedDataFields = OnGetSupportedDataFields; - SensorConfig.EvtSensorGetDataInterval = OnGetDataInterval; - SensorConfig.EvtSensorSetDataInterval = OnSetDataInterval; - SensorConfig.EvtSensorGetDataFieldProperties = OnGetDataFieldProperties; - SensorConfig.EvtSensorGetDataThresholds = OnGetDataThresholds; - SensorConfig.EvtSensorSetDataThresholds = OnSetDataThresholds; - SensorConfig.EvtSensorGetProperties = OnGetProperties; - SensorConfig.EvtSensorDeviceIoControl = OnIoControl; - SensorConfig.EvtSensorStartHistory = OnStartHistory; - SensorConfig.EvtSensorStopHistory = OnStopHistory; - SensorConfig.EvtSensorClearHistory = OnClearHistory; - SensorConfig.EvtSensorStartHistoryRetrieval = OnStartHistoryRetrieval; - SensorConfig.EvtSensorCancelHistoryRetrieval = OnCancelHistoryRetrieval; - SensorConfig.EvtSensorEnableWake = OnEnableWake; - SensorConfig.EvtSensorDisableWake = OnDisableWake; - - // - // Set up power capabilities and IO queues - // - Status = SensorsCxDeviceInitialize(Device, &SensorConfig); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! SensorDeviceInitialize failed %!STATUS!", Status); - goto Exit; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - -//------------------------------------------------------------------------------ -// -// Function: OnPrepareHardware -// -// This routine is called by the framework when the PnP manager sends an -// IRP_MN_START_DEVICE request to the driver stack. This routine is -// responsible for performing operations that are necessary to make the -// driver's device operational (for e.g. mapping the hardware resources -// into memory). -// -// Argument: -// Device: IN: Supplies a handle to the framework device object -// ResourcesRaw: IN: Supplies a handle to a collection of framework resource -// objects. This collection identifies the raw (bus-relative) hardware -// resources that have been assigned to the device. -// ResourcesTranslated: IN: Supplies a handle to a collection of framework -// resource objects. This collection identifies the translated -// (system-physical) hardware resources that have been assigned to the -// device. The resources appear from the CPU's point of view. -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnPrepareHardware( - _In_ WDFDEVICE Device, - _In_ WDFCMRESLIST /*ResourcesRaw*/, - _In_ WDFCMRESLIST /*ResourcesTranslated*/ - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - for (ULONG Count = 0; Count < SensorInstanceCount; Count++) - { - PComboDevice pDevice = nullptr; - WDF_OBJECT_ATTRIBUTES SensorAttr; - SENSOR_CONFIG SensorConfig; - SENSOROBJECT SensorInstance; - - // Create WDFOBJECT for the sensor - WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&SensorAttr, ComboDevice); - SensorAttr.ContextSizeOverride = GetDeviceSizeAtIndex(Count); - - // Register sensor instance with clx - Status = SensorsCxSensorCreate(Device, &SensorAttr, &SensorInstance); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! SensorsCxSensorCreate failed %!STATUS!", Status); - goto Exit; - } - - pDevice = GetContextFromSensorInstance(SensorInstance); - if (nullptr == pDevice) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - goto Exit; - } - - AllocateDeviceAtIndex(Count, &pDevice); - - // Fill out properties - Status = pDevice->Initialize(Device, SensorInstance); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Initialize device object failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_CONFIG_INIT(&SensorConfig); - SensorConfig.pEnumerationList = pDevice->m_pEnumerationProperties; - Status = SensorsCxSensorInitialize(SensorInstance, &SensorConfig); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! SensorsCxSensorInitialize failed %!STATUS!", Status); - goto Exit; - } - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// -// Function: OnReleaseHardware -// -// This routine is called by the framework when the PnP manager is revoking -// ownership of our resources. This may be in response to either -// IRP_MN_STOP_DEVICE or IRP_MN_REMOVE_DEVICE. This routine is responsible for -// performing cleanup of resources allocated in PrepareHardware callback. -// This callback is invoked before passing the request down to the lower driver. -// This routine will also be invoked by the framework if the prepare hardware -// callback returns a failure. -// -// Argument: -// Device: IN: Supplies a handle to the framework device object -// ResourcesTranslated: IN: Supplies a handle to a collection of framework -// resource objects. This collection identifies the translated -// (system-physical) hardware resources that have been assigned to the -// device. The resources appear from the CPU's point of view. -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnReleaseHardware( - _In_ WDFDEVICE Device, - _In_ WDFCMRESLIST /*ResourcesTranslated*/ - ) -{ - ULONG Count = SensorInstanceCount; - PComboDevice pDevice = nullptr; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); - if (!NT_SUCCESS(Status)) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); - goto Exit; - } - - for (Count = 0; Count < SensorInstanceCount; Count++) - { - pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - goto Exit; - } - - // Delete lock - if (NULL != pDevice->m_Lock) - { - WdfObjectDelete(pDevice->m_Lock); - pDevice->m_Lock = NULL; - } - - // Delete sensor instance - if (NULL != pDevice->m_SensorInstance) - { - WdfObjectDelete(pDevice->m_SensorInstance); - // The pDevice context created using WdfMemoryCreate and parented to m_SensorInstance is automatically - // destroyed when m_SensorInstance is deleted. pDevice is therefore no longer accessible beyond the above call to WdfObjectDelete. - // We can therefore not set the m_SensorInstance member back to NULL. We instead set pDevice to nullptr. - pDevice = nullptr; - } - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// -// Function: OnD0Entry -// -// This routine is invoked by the framework to program the device to goto -// D0, which is the working state. The framework invokes callback every -// time the hardware needs to be (re-)initialized. This includes after -// IRP_MN_START_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE, -// and IRP_MN_SET_POWER-D0. -// -// Argument: -// Device: IN: Supplies a handle to the framework device object -// PreviousState: IN: WDF_POWER_DEVICE_STATE-typed enumerator that identifies -// the device power state that the device was in before this transition to D0 -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnD0Entry( - _In_ WDFDEVICE Device, - _In_ WDF_POWER_DEVICE_STATE /*PreviousState*/ - ) -{ - ULONG Count = SensorInstanceCount; - PComboDevice pDevice = nullptr; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Get sensor instances - // - Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); - if (!NT_SUCCESS(Status)) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); - goto Exit; - } - - // - // Powering on all sensor instances - // - for (Count = 0; Count < SensorInstanceCount; Count++) - { - pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - goto Exit; - } - - pDevice->m_PoweredOn = TRUE; - InitPropVariantFromUInt32(SensorState_Idle, - &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// -// Function: OnD0Exit -// -// This routine is invoked by the framework to program the device to go into -// a certain Dx state. The framework invokes callback every the the device is -// leaving the D0 state, which happens when the device is stopped, when it is -// removed, and when it is powered off. -// -// Argument: -// Device: IN: Supplies a handle to the framework device object -// TargetState: IN: Supplies the device power state which the device will be put -// in once the callback is complete -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -OnD0Exit( - _In_ WDFDEVICE Device, - _In_ WDF_POWER_DEVICE_STATE /*TargetState*/ - ) -{ - ULONG Count = SensorInstanceCount; - PComboDevice pDevice = nullptr; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Get sensor instances - // - Status = SensorsCxDeviceGetSensorList(Device, SensorInstancesBuffer, &Count); - if (!NT_SUCCESS(Status)) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); - goto Exit; - } - - // - // Powering off all sensor instances - // - for (Count = 0; Count < SensorInstanceCount; Count++) - { - pDevice = GetContextFromSensorInstance(SensorInstancesBuffer[Count]); - if (nullptr == pDevice) - { - Status = STATUS_INVALID_PARAMETER; - TraceError("COMBO %!FUNC! GetContextFromSensorInstance failed %!STATUS!", Status); - goto Exit; - } - - pDevice->m_PoweredOn = FALSE; - InitPropVariantFromUInt32(SensorState_Idle, - &(pDevice->m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} diff --git a/sensors/SensorsComboDriver/Driver/Driver.cpp b/sensors/SensorsComboDriver/Driver/Driver.cpp deleted file mode 100644 index 1ebc7a01..00000000 --- a/sensors/SensorsComboDriver/Driver/Driver.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of entry and exit point of combo driver. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" -#include "Driver.h" - -#include "Driver.tmh" - -//------------------------------------------------------------------------------ -// Function: DriverEntry -// -// This routine is the driver initialization entry point. -// -// Arguments: -// DriverObject: IN: Pointer to the driver object created by the I/O manager -// RegistryPath: IN: Pointer to the driver specific registry key -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -DriverEntry( - _In_ PDRIVER_OBJECT DriverObject, - _In_ PUNICODE_STRING RegistryPath - ) -{ - WDF_DRIVER_CONFIG DriverConfig; - NTSTATUS Status = STATUS_SUCCESS; - - // - // Initialize WPP Tracing - // - WPP_INIT_TRACING(DriverObject, NULL); - - SENSOR_FunctionEnter(); - - DriverConfig.DriverPoolTag = SENSORV2_POOL_TAG_COMBO; - - // - // Initialize the driver configuration structure. - // - WDF_DRIVER_CONFIG_INIT(&DriverConfig, OnDeviceAdd); - DriverConfig.EvtDriverUnload = OnDriverUnload; - - // - // Create a framework driver object to represent our driver. - // - Status = WdfDriverCreate(DriverObject, - RegistryPath, - WDF_NO_OBJECT_ATTRIBUTES, - &DriverConfig, - WDF_NO_HANDLE); - - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! WdfDriverCreate failed: %!STATUS!", Status); - goto Exit; - } - -Exit: - SENSOR_FunctionExit(Status); - - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: OnDriverUnload -// -// This routine is called when the driver unloads. -// -// Arguments: -// Driver: IN: driver object -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -VOID -OnDriverUnload( - _In_ WDFDRIVER Driver - ) -{ - SENSOR_FunctionEnter(); - - UNREFERENCED_PARAMETER(Driver); - - SENSOR_FunctionExit(STATUS_SUCCESS); - - WPP_CLEANUP(Driver); - - return; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/Driver.h b/sensors/SensorsComboDriver/Driver/Driver.h deleted file mode 100644 index de307270..00000000 --- a/sensors/SensorsComboDriver/Driver/Driver.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved -// -// Abstract: -// -// This module contains the type definitions for the combo -// driver callback class. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#pragma once - -WDF_EXTERN_C_START - -// -// Driver Entry/Exit Functions -// -DRIVER_INITIALIZE DriverEntry; -EVT_WDF_DRIVER_UNLOAD OnDriverUnload; - -// -// WDF Device Callbacks -// -EVT_WDF_DRIVER_DEVICE_ADD OnDeviceAdd; -EVT_WDF_DEVICE_PREPARE_HARDWARE OnPrepareHardware; -EVT_WDF_DEVICE_RELEASE_HARDWARE OnReleaseHardware; -EVT_WDF_DEVICE_D0_ENTRY OnD0Entry; -EVT_WDF_DEVICE_D0_EXIT OnD0Exit; - -WDF_EXTERN_C_END \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp b/sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp deleted file mode 100644 index b20339a7..00000000 --- a/sensors/SensorsComboDriver/Driver/GeomagneticOrientationClient.cpp +++ /dev/null @@ -1,485 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" - -#include "GeomagneticOrientationClient.tmh" - -#define SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION '9OeG' - -#define GeomagneticOrientation_Initial_MinDataInterval_Ms (10) // 100Hz - -#define GeomagneticOrientation_Quarternion_Maximum (1.0f) -#define GeomagneticOrientation_Quarternion_Minimum (-1.0f) -#define GeomagneticOrientation_Quarternion_Resolution ((GeomagneticOrientation_Quarternion_Maximum-GeomagneticOrientation_Quarternion_Minimum)/65536) - -// Geomagnetic Orientation Sensor Unique ID -// {E4F5FDEA-F268-480F-9D88-A368D381C4C2} -DEFINE_GUID(GUID_GeomagneticOrientationDevice_UniqueID, - 0xe4f5fdea, 0xf268, 0x480f, 0x9d, 0x88, 0xa3, 0x68, 0xd3, 0x81, 0xc4, 0xc2); - -// Sensor data -typedef enum -{ - GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP = 0, - GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W, - GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X, - GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y, - GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z, - GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES, - GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES, - GEOMAGNETIC_ORIENTATION_DATA_COUNT -} GEOMAGNETIC_ORIENTATION_DATA_INDEX; - -// Sensor thresholds -typedef enum -{ - GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES = 0, - GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT -} GEOMAGNETIC_ORIENTATION_THRESHOLD_INDEX; - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GeomagneticOrientationDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Geomagnetic Orientation WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pEnumerationProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_GeomagneticOrientation, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"Geomagnetic Orientation Sensor", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_GeomagneticOrientationDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GEOMAGNETIC_ORIENTATION_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pSupportedDataFields)); - if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = GEOMAGNETIC_ORIENTATION_DATA_COUNT; - - m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W] = PKEY_SensorData_QuaternionW; - m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X] = PKEY_SensorData_QuaternionX; - m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y] = PKEY_SensorData_QuaternionY; - m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z] = PKEY_SensorData_QuaternionZ; - m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES] = PKEY_SensorData_RotationAngle_Degrees; - m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES] = PKEY_SensorData_DeclinationAngle_Degrees; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GEOMAGNETIC_ORIENTATION_DATA_COUNT); - FILETIME Time = {0}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pData)); - if (!NT_SUCCESS(Status) || nullptr == m_pData) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = GEOMAGNETIC_ORIENTATION_DATA_COUNT; - - m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Value)); - - m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; - InitPropVariantFromFloat(1.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Value)); - - m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; - InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Value)); - - m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; - InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Value)); - - m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; - InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Value)); - - m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Key = PKEY_SensorData_RotationAngle_Degrees; - InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Value)); - - m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Key = PKEY_SensorData_DeclinationAngle_Degrees; - InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Value)); - - ZeroMemory(&m_LastSample, sizeof(m_LastSample)); - ZeroMemory(&m_CachedData, sizeof(m_CachedData)); - m_CachedData.Quaternion.W = 1.0f; // This is the initial position - m_CachedData.Quaternion.X = 0.0f; // This is the initial position - m_CachedData.Quaternion.Y = 0.0f; // This is the initial position - m_CachedData.Quaternion.Z = 0.0f; // This is the initial position - m_CachedData.RotationAngle_Degrees = 0.0f; // This is the initial position - m_CachedData.DeclinationAngle_Degrees = 0.0f; // This is the initial position - } - - // - // Sensor Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pProperties) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(GeomagneticOrientation_Initial_MinDataInterval_Ms, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - m_IntervalMs = GeomagneticOrientation_Initial_MinDataInterval_Ms; - m_MinimumIntervalMs = GeomagneticOrientation_Initial_MinDataInterval_Ms; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_GeomagneticOrientation, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - - // - // Data filed properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pDataFieldProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Resolution, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Minimum, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Maximum, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pThresholds)); - if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT; - - m_pThresholds->List[GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES].Key = PKEY_SensorData_RotationAngle_Degrees; - InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES].Value)); - - ZeroMemory(&m_CachedThresholds, sizeof(m_CachedThresholds)); - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GeomagneticOrientationDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (FALSE != m_FirstSample) - { - Status = GetPerformanceTime (&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ((abs(m_CachedData.RotationAngle_Degrees - m_LastSample.RotationAngle_Degrees) >= m_CachedThresholds.RotationAngle_Degrees)) - { - DataReady = TRUE; - } - } - - if (FALSE != DataReady) - { - // update last sample - m_LastSample = m_CachedData; - - // push to clx - InitPropVariantFromFloat(m_LastSample.Quaternion.W, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Value)); - InitPropVariantFromFloat(m_LastSample.Quaternion.X, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Value)); - InitPropVariantFromFloat(m_LastSample.Quaternion.Y, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Value)); - InitPropVariantFromFloat(m_LastSample.Quaternion.Z, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Value)); - InitPropVariantFromFloat(m_LastSample.RotationAngle_Degrees, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Value)); - InitPropVariantFromFloat(m_LastSample.DeclinationAngle_Degrees, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! GeomagneticOrientationDevice Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GeomagneticOrientationDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_UNSUCCESSFUL; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_RotationAngle_Degrees, - &m_CachedThresholds.RotationAngle_Degrees); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GeomagneticOrientationDevice PropKeyFindKeyGetFloat for Rotation Angle failed! %!STATUS!", Status); - goto Exit; - } -Exit: - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp b/sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp deleted file mode 100644 index 4dc53d7e..00000000 --- a/sensors/SensorsComboDriver/Driver/GravityVectorClient.cpp +++ /dev/null @@ -1,499 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (UMDF) - -#include "Clients.h" - -#include "GravityVectorClient.tmh" - - - -#define SENSORV2_POOL_TAG_GRAVITY_VECTOR '6ArG' - -#define GravityVectorDevice_Default_MinDataInterval (4) -#define GravityVectorDevice_Default_Axis_Threshold (1.0f) -#define GravityVectorDevice_Axis_Resolution (4.0f / 65536.0f) // in delta g -#define GravityVectorDevice_Axis_Minimum (-2.0f) // in g -#define GravityVectorDevice_Axis_Maximum (2.0f) // in g - - -// Linear Accelerometer Unique ID -// {56E11473-2BB7-41E4-863A-DA014200C0DC} -DEFINE_GUID(GUID_GravityVectorDevice_UniqueID, - 0x56e11473, 0x2bb7, 0x41e4, 0x86, 0x3a, 0xda, 0x1, 0x42, 0x0, 0xc0, 0xdc); - -// Sensor data -typedef enum -{ - GRAVITY_VECTOR_DATA_X = 0, - GRAVITY_VECTOR_DATA_Y, - GRAVITY_VECTOR_DATA_Z, - GRAVITY_VECTOR_DATA_TIMESTAMP, - GRAVITY_VECTOR_DATA_COUNT -} GRAVITY_VECTOR_DATA_INDEX; - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GravityVectorDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GRA WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - TimerConfig.TolerableDelay = 0; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GRA WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GRAVITY_VECTOR, - Size, - &MemoryHandle, - (PVOID*)&m_pEnumerationProperties); - if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) - { - TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_GravityVector, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"Gravity Vector Sensor", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_GravityVectorDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GRAVITY_VECTOR, - Size, - &MemoryHandle, - (PVOID*)&m_pSupportedDataFields); - if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) - { - TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = GRAVITY_VECTOR_DATA_COUNT; - - m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_X] = PKEY_SensorData_AccelerationX_Gs; - m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_Y] = PKEY_SensorData_AccelerationY_Gs; - m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_Z] = PKEY_SensorData_AccelerationZ_Gs; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT); - FILETIME Time = {0}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GRAVITY_VECTOR, - Size, - &MemoryHandle, - (PVOID*)&m_pData); - if (!NT_SUCCESS(Status) || m_pData == nullptr) - { - TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = GRAVITY_VECTOR_DATA_COUNT; - - m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Value)); - - m_pData->List[GRAVITY_VECTOR_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; - InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_X].Value)); - - m_pData->List[GRAVITY_VECTOR_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; - InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_Y].Value)); - - m_pData->List[GRAVITY_VECTOR_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; - InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_Z].Value)); - - m_CachedData.X = 0.0f; - m_CachedData.Y = 0.0f; - m_CachedData.Z = 0.0f; - - m_LastSample.X = 0.0f; - m_LastSample.Y = 0.0f; - m_LastSample.Z = 0.0f; - } - - // - // Sensor Properties - // - { - m_IntervalMs = GravityVectorDevice_Default_MinDataInterval; - - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GRAVITY_VECTOR, - Size, - &MemoryHandle, - (PVOID*)&m_pProperties); - if (!NT_SUCCESS(Status) || m_pProperties == nullptr) - { - TraceError("GRA %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(GravityVectorDevice_Default_MinDataInterval, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_GravityVector, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - - // - // Data field properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GRAVITY_VECTOR, - Size, - &MemoryHandle, - (PVOID*)&m_pDataFieldProperties); - if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) - { - TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(GravityVectorDevice_Axis_Resolution, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(GravityVectorDevice_Axis_Minimum, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(GravityVectorDevice_Axis_Maximum, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT - 1); // Timestamp does not have thresholds - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GRAVITY_VECTOR, - Size, - &MemoryHandle, - (PVOID*)&m_pThresholds); - if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) - { - TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = GRAVITY_VECTOR_DATA_COUNT - 1; - - m_pThresholds->List[GRAVITY_VECTOR_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; - InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, - &(m_pThresholds->List[GRAVITY_VECTOR_DATA_X].Value)); - - m_pThresholds->List[GRAVITY_VECTOR_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; - InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, - &(m_pThresholds->List[GRAVITY_VECTOR_DATA_Y].Value)); - - m_pThresholds->List[GRAVITY_VECTOR_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; - InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, - &(m_pThresholds->List[GRAVITY_VECTOR_DATA_Z].Value)); - - m_CachedThresholds.X = GravityVectorDevice_Default_Axis_Threshold; - m_CachedThresholds.Y = GravityVectorDevice_Default_Axis_Threshold; - m_CachedThresholds.Z = GravityVectorDevice_Default_Axis_Threshold; - - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GravityVectorDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (m_FirstSample != FALSE) - { - Status = GetPerformanceTime (&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! GRA GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ( (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || - (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || - (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) - { - DataReady = TRUE; - } - } - - if (DataReady != FALSE) - { - // update last sample - m_LastSample.X = m_CachedData.X; - m_LastSample.Y = m_CachedData.Y; - m_LastSample.Z = m_CachedData.Z; - - // push to clx - InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[GRAVITY_VECTOR_DATA_X].Value)); - InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[GRAVITY_VECTOR_DATA_Y].Value)); - InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[GRAVITY_VECTOR_DATA_Z].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! GRA Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GravityVectorDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AccelerationX_Gs, - &m_CachedThresholds.X); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AccelerationY_Gs, - &m_CachedThresholds.Y); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AccelerationZ_Gs, - &m_CachedThresholds.Z); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); - goto Exit; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/GyrClient.cpp b/sensors/SensorsComboDriver/Driver/GyrClient.cpp deleted file mode 100644 index 389e6e8e..00000000 --- a/sensors/SensorsComboDriver/Driver/GyrClient.cpp +++ /dev/null @@ -1,510 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" - -#include "GyrClient.tmh" - -#define SENSORV2_POOL_TAG_GYROSCOPE '2oyG' - -// Chasis says 5-250Hz but unit test fails if below 250Hz??? -#define Gyr_MinDataInterval_Ms (4) // 250Hz -#define Gyr_Initial_Threshold_DegreesPerSecond (10.0f) - -#define GyrDevice_Minimum_DegreesPerSecond (-2000.0f) -#define GyrDevice_Maximum_DegreesPerSecond (2000.0f) -#define GyrDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data -#define GyrDevice_Range_DegreesPerSecond \ - (GyrDevice_Maximum_DegreesPerSecond - GyrDevice_Minimum_DegreesPerSecond) -#define GyrDevice_Resolution_DegreesPerSecond \ - (GyrDevice_Range_DegreesPerSecond / GyrDevice_Precision) - -// Gyroscope Unique ID -// {61A61B96-1E4C-47C6-8697-654680101446} -DEFINE_GUID(GUID_GyrDevice_UniqueID, - 0x61a61b96, 0x1e4c, 0x47c6, 0x86, 0x97, 0x65, 0x46, 0x80, 0x10, 0x14, 0x46); - -// Sensor data -typedef enum -{ - GYR_DATA_TIMESTAMP = 0, - GYR_DATA_X, - GYR_DATA_Y, - GYR_DATA_Z, - GYR_DATA_COUNT -} GYR_DATA_INDEX; - -// Sensor thresholds -typedef enum -{ - GYR_THRESHOLD_X = 0, - GYR_THRESHOLD_Y, - GYR_THRESHOLD_Z, - GYR_THRESHOLD_COUNT -} GYR_THRESHOLD_INDEX; - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GyrDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GYR WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - TimerConfig.TolerableDelay = 0; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GYR WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GYROSCOPE, - Size, - &MemoryHandle, - (PVOID*)&m_pEnumerationProperties); - if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) - { - TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Gyrometer3D, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"GYR", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_GyrDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GYR_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GYROSCOPE, - Size, - &MemoryHandle, - (PVOID*)&m_pSupportedDataFields); - if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) - { - TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = GYR_DATA_COUNT; - - m_pSupportedDataFields->List[GYR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[GYR_DATA_X] = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; - m_pSupportedDataFields->List[GYR_DATA_Y] = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; - m_pSupportedDataFields->List[GYR_DATA_Z] = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GYR_DATA_COUNT); - FILETIME Time = {0}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GYROSCOPE, - Size, - &MemoryHandle, - (PVOID*)&m_pData); - if (!NT_SUCCESS(Status) || m_pData == nullptr) - { - TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = GYR_DATA_COUNT; - - m_pData->List[GYR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[GYR_DATA_TIMESTAMP].Value)); - - m_pData->List[GYR_DATA_X].Key = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; - InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_X].Value)); - - m_pData->List[GYR_DATA_Y].Key = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; - InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_Y].Value)); - - m_pData->List[GYR_DATA_Z].Key = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; - InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_Z].Value)); - - m_CachedData.X = 0.0f; - m_CachedData.Y = 0.0f; - m_CachedData.Z = 0.0f; - - m_LastSample.X = 0.0f; - m_LastSample.Y = 0.0f; - m_LastSample.Z = 0.0f; - } - - // - // Sensor Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GYROSCOPE, - Size, - &MemoryHandle, - (PVOID*)&m_pProperties); - if (!NT_SUCCESS(Status) || m_pProperties == nullptr) - { - TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(Gyr_MinDataInterval_Ms, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - m_IntervalMs = Gyr_MinDataInterval_Ms; - m_MinimumIntervalMs = Gyr_MinDataInterval_Ms; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Gyrometer3D, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - - // - // Data filed properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GYROSCOPE, - Size, - &MemoryHandle, - (PVOID*)&m_pDataFieldProperties); - if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) - { - TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(GyrDevice_Resolution_DegreesPerSecond, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(GyrDevice_Minimum_DegreesPerSecond, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(GyrDevice_Maximum_DegreesPerSecond, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GYR_THRESHOLD_COUNT); // Timestamp and shake do not have thresholds - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_GYROSCOPE, - Size, - &MemoryHandle, - (PVOID*)&m_pThresholds); - if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) - { - TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = GYR_THRESHOLD_COUNT; - - m_pThresholds->List[GYR_THRESHOLD_X].Key = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; - InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, - &(m_pThresholds->List[GYR_THRESHOLD_X].Value)); - - m_pThresholds->List[GYR_THRESHOLD_Y].Key = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; - InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, - &(m_pThresholds->List[GYR_THRESHOLD_Y].Value)); - - m_pThresholds->List[GYR_THRESHOLD_Z].Key = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; - InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, - &(m_pThresholds->List[GYR_THRESHOLD_Z].Value)); - - m_CachedThresholds.X = Gyr_Initial_Threshold_DegreesPerSecond; - m_CachedThresholds.Y = Gyr_Initial_Threshold_DegreesPerSecond; - m_CachedThresholds.Z = Gyr_Initial_Threshold_DegreesPerSecond; - - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GyrDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (m_FirstSample != FALSE) - { - Status = GetPerformanceTime (&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! GYR GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ( (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || - (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || - (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) - { - DataReady = TRUE; - } - } - - if (DataReady != FALSE) - { - // update last sample - m_LastSample.X = m_CachedData.X; - m_LastSample.Y = m_CachedData.Y; - m_LastSample.Z = m_CachedData.Z; - - // push to clx - InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[GYR_DATA_X].Value)); - InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[GYR_DATA_Y].Value)); - InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[GYR_DATA_Z].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GYR_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! GYR Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -GyrDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AngularVelocityX_DegreesPerSecond, - &m_CachedThresholds.X); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AngularVelocityY_DegreesPerSecond, - &m_CachedThresholds.Y); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AngularVelocityZ_DegreesPerSecond, - &m_CachedThresholds.Z); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); - goto Exit; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/MagClient.cpp b/sensors/SensorsComboDriver/Driver/MagClient.cpp deleted file mode 100644 index 5768cbc5..00000000 --- a/sensors/SensorsComboDriver/Driver/MagClient.cpp +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" - -#include "MagClient.tmh" - -#define SENSORV2_POOL_TAG_MAGNETOMETER '2ngM' - -#define Mag_Initial_MinDataInterval_Ms (10) // 100Hz -#define Mag_Initial_Threshold_Microteslas (5.0f) // 5uT - -#define MagDevice_Minimum_Microteslas (-2000.0f) -#define MagDevice_Maximum_Microteslas (2000.0f) -#define MagDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data -#define MagDevice_Range_Microteslas \ - (MagDevice_Maximum_Microteslas - MagDevice_Minimum_Microteslas) -#define MagDevice_Resolution_Microteslas \ - (MagDevice_Range_Microteslas / MagDevice_Precision) - -// Magnetometer Sensor Unique ID -// {0746712D-DFB1-42A7-8AAE-6089D2423CDE} -DEFINE_GUID(GUID_MagDevice_UniqueID, - 0x746712d, 0xdfb1, 0x42a7, 0x8a, 0xae, 0x60, 0x89, 0xd2, 0x42, 0x3c, 0xde); - -// Sensor data -typedef enum -{ - MAG_DATA_TIMESTAMP = 0, - MAG_DATA_X, - MAG_DATA_Y, - MAG_DATA_Z, - MAG_DATA_ACCURACY, - MAG_DATA_COUNT -} MAG_DATA_INDEX; - -// Sensor thresholds -typedef enum -{ - MAG_THRESHOLD_X = 0, - MAG_THRESHOLD_Y, - MAG_THRESHOLD_Z, - MAG_THRESHOLD_COUNT -} MAG_THRESHOLD_INDEX; - -// -// Sensor Enumeration Properties -// -typedef enum -{ - SENSOR_MAG_NAME = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX is adding SENSOR_MAG_NAME to the base SENSOR_ENUMERATION_PROPERTIES_INDEX enum. - // In order to keep the SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX enum indexing coherent with the SENSOR_ENUMERATION_PROPERTIES_INDEX enum, - // set SENSOR_MAG_NAME to the index of the last value in the SENSOR_ENUMERATION_PROPERTIES_INDEX enum - SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT -} SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX; - - - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -MagDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! GYR WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! MAG WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_MAGNETOMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pEnumerationProperties); - if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) - { - TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Magnetometer3D, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"MAG", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_MagDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - // - // Alternate name used by SensorOpen - // - - m_pEnumerationProperties->List[SENSOR_MAG_NAME].Key = DEVPKEY_Sensor_Name; - InitPropVariantFromString(L"\\\\.\\Mag", - &(m_pEnumerationProperties->List[SENSOR_MAG_NAME].Value)); - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(MAG_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_MAGNETOMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pSupportedDataFields); - if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) - { - TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = MAG_DATA_COUNT; - - m_pSupportedDataFields->List[MAG_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[MAG_DATA_X] = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; - m_pSupportedDataFields->List[MAG_DATA_Y] = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; - m_pSupportedDataFields->List[MAG_DATA_Z] = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; - m_pSupportedDataFields->List[MAG_DATA_ACCURACY] = PKEY_SensorData_MagnetometerAccuracy; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(MAG_DATA_COUNT); - FILETIME Time = {0}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_MAGNETOMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pData); - if (!NT_SUCCESS(Status) || m_pData == nullptr) - { - TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = MAG_DATA_COUNT; - - m_pData->List[MAG_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[MAG_DATA_TIMESTAMP].Value)); - - m_pData->List[MAG_DATA_X].Key = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; - InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_X].Value)); - - m_pData->List[MAG_DATA_Y].Key = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; - InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_Y].Value)); - - m_pData->List[MAG_DATA_Z].Key = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; - InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_Z].Value)); - - m_pData->List[MAG_DATA_ACCURACY].Key = PKEY_SensorData_MagnetometerAccuracy; - InitPropVariantFromUInt32(MagnetometerAccuracy_Unknown, &(m_pData->List[MAG_DATA_ACCURACY].Value)); - - m_CachedData.Axis.X = 0.0f; - m_CachedData.Axis.Y = 1.0f; - m_CachedData.Axis.Z = 0.0f; - m_CachedData.Accuracy = MagnetometerAccuracy_High; - - m_LastSample.Axis.X = 0.0f; - m_LastSample.Axis.Y = 0.0f; - m_LastSample.Axis.Z = 0.0f; - m_LastSample.Accuracy = MagnetometerAccuracy_Unknown; - } - - // - // Sensor Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_MAGNETOMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pProperties); - if (!NT_SUCCESS(Status) || m_pProperties == nullptr) - { - TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(Mag_Initial_MinDataInterval_Ms, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - m_IntervalMs = Mag_Initial_MinDataInterval_Ms; - m_MinimumIntervalMs = Mag_Initial_MinDataInterval_Ms; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Magnetometer3D, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - - // - // Data field properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_MAGNETOMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pDataFieldProperties); - if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) - { - TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(MagDevice_Resolution_Microteslas, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(MagDevice_Minimum_Microteslas, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(MagDevice_Maximum_Microteslas, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(MAG_THRESHOLD_COUNT); // Timestamp and shake do not have thresholds - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_MAGNETOMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pThresholds); - if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) - { - TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = MAG_THRESHOLD_COUNT; - - m_pThresholds->List[MAG_THRESHOLD_X].Key = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; - InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, - &(m_pThresholds->List[MAG_THRESHOLD_X].Value)); - - m_pThresholds->List[MAG_THRESHOLD_Y].Key = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; - InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, - &(m_pThresholds->List[MAG_THRESHOLD_Y].Value)); - - m_pThresholds->List[MAG_THRESHOLD_Z].Key = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; - InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, - &(m_pThresholds->List[MAG_THRESHOLD_Z].Value)); - - m_CachedThresholds.X = Mag_Initial_Threshold_Microteslas; - m_CachedThresholds.Y = Mag_Initial_Threshold_Microteslas; - m_CachedThresholds.Z = Mag_Initial_Threshold_Microteslas; - - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -MagDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (m_FirstSample != FALSE) - { - Status = GetPerformanceTime (&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! MAG GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ( (abs(m_CachedData.Axis.X - m_LastSample.Axis.X) >= m_CachedThresholds.X) || - (abs(m_CachedData.Axis.Y - m_LastSample.Axis.Y) >= m_CachedThresholds.Y) || - (abs(m_CachedData.Axis.Z - m_LastSample.Axis.Z) >= m_CachedThresholds.Z)) - { - DataReady = TRUE; - } - } - - if (DataReady != FALSE) - { - // update last sample - m_LastSample.Axis.X = m_CachedData.Axis.X; - m_LastSample.Axis.Y = m_CachedData.Axis.Y; - m_LastSample.Axis.Z = m_CachedData.Axis.Z; - m_LastSample.Accuracy = m_CachedData.Accuracy; - - // push to clx - InitPropVariantFromFloat (m_LastSample.Axis.X, &(m_pData->List[MAG_DATA_X].Value)); - InitPropVariantFromFloat (m_LastSample.Axis.Y, &(m_pData->List[MAG_DATA_Y].Value)); - InitPropVariantFromFloat (m_LastSample.Axis.Z, &(m_pData->List[MAG_DATA_Z].Value)); - InitPropVariantFromUInt32(m_LastSample.Accuracy, &(m_pData->List[MAG_DATA_ACCURACY].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[MAG_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! MAG Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -MagDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_MagneticFieldStrengthX_Microteslas, - &m_CachedThresholds.X); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_MagneticFieldStrengthY_Microteslas, - &m_CachedThresholds.Y); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_MagneticFieldStrengthZ_Microteslas, - &m_CachedThresholds.Z); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); - goto Exit; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/PrxClient.cpp b/sensors/SensorsComboDriver/Driver/PrxClient.cpp deleted file mode 100644 index fa10e095..00000000 --- a/sensors/SensorsComboDriver/Driver/PrxClient.cpp +++ /dev/null @@ -1,458 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" - -#include "PrxClient.tmh" - -#define SENSORV2_POOL_TAG_PROXIMITY '2ixP' - -static const ULONG Prx_MinDataInterval_Ms = 10; // 100Hz - -static const ULONG PrxDevice_Minimum_Millimeters = 3; -static const ULONG PrxDevice_Maximum_Millimeters = 50; -static const ULONG PrxDevice_Resolution_Millimeters = 1; - -// Proximity Sensor Unique ID -// {4B6BE805-2432-4B6B-A5E3-DEA67CA43225} -DEFINE_GUID(GUID_PrxDevice_UniqueID, - 0x4b6be805, 0x2432, 0x4b6b, 0xa5, 0xe3, 0xde, 0xa6, 0x7c, 0xa4, 0x32, 0x25); - -// Sensor data -typedef enum -{ - PRX_DATA_TIMESTAMP = 0, - PRX_DATA_DETECT, - PRX_DATA_DISTANCE, - PRX_DATA_COUNT -} PRX_DATA_INDEX; - -static const ULONG PRX_THRESHOLD_COUNT = 0; // proxmity sensor has no threshold - -// -// Additional Sensor Properties -// -typedef enum -{ - SENSOR_PROPERTY_PRX_TYPE = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_PRX_PROPERTIES_INDEX is adding SENSOR_PROPERTY_PRX_TYPE to the base SENSOR_PROPERTIES_INDEX enum. - // In order to keep the SENSOR_PRX_PROPERTIES_INDEX enum indexing coherent with the SENSOR_PROPERTIES_INDEX enum, - // set SENSOR_PROPERTY_PRX_TYPE to the index of the last value in the SENSOR_PROPERTIES_INDEX enum - SENSOR_ISWAKECAPABLE = SENSOR_PROPERTY_PRX_TYPE + 1, - SENSOR_PRX_ENUMERATION_PROPERTY_COUNT -} SENSOR_PRX_PROPERTIES_INDEX; - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -PrxDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! PRX WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! PRX WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_PRX_ENUMERATION_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_PROXIMITY, - Size, - &MemoryHandle, - reinterpret_cast(&m_pEnumerationProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) - { - TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; - m_pEnumerationProperties->Count = SENSOR_PRX_ENUMERATION_PROPERTY_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Proximity, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"PRX", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_PrxDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - - m_pEnumerationProperties->List[SENSOR_PROPERTY_PRX_TYPE].Key = DEVPKEY_Sensor_ProximityType; - InitPropVariantFromUInt32(PROXIMITY_TYPE::ProximityType_HumanProximity, - &(m_pEnumerationProperties->List[SENSOR_PROPERTY_PRX_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_ISWAKECAPABLE].Key = PKEY_Sensor_WakeCapable; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISWAKECAPABLE].Value)); - - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(PRX_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_PROXIMITY, - Size, - &MemoryHandle, - (PVOID*)&m_pSupportedDataFields); - if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) - { - TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = PRX_DATA_COUNT; - - m_pSupportedDataFields->List[PRX_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[PRX_DATA_DETECT] = PKEY_SensorData_ProximityDetection; - m_pSupportedDataFields->List[PRX_DATA_DISTANCE] = PKEY_SensorData_ProximityDistanceMillimeters; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(PRX_DATA_COUNT); - FILETIME Time = {}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_PROXIMITY, - Size, - &MemoryHandle, - reinterpret_cast(&m_pData)); - if (!NT_SUCCESS(Status) || nullptr == m_pData) - { - TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = PRX_DATA_COUNT; - - m_pData->List[PRX_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[PRX_DATA_TIMESTAMP].Value)); - - m_pData->List[PRX_DATA_DETECT].Key = PKEY_SensorData_ProximityDetection; - InitPropVariantFromBoolean(FALSE, &(m_pData->List[PRX_DATA_DETECT].Value)); - - m_pData->List[PRX_DATA_DISTANCE].Key = PKEY_SensorData_ProximityDistanceMillimeters; - InitPropVariantFromUInt32(FALSE, &(m_pData->List[PRX_DATA_DISTANCE].Value)); - - m_CachedData.Detected = FALSE; - m_CachedData.DistanceMillimeters = PrxDevice_Maximum_Millimeters; - - m_LastSample.Detected = FALSE; - m_LastSample.DistanceMillimeters = PrxDevice_Maximum_Millimeters; - } - - // - // Sensor Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_PROXIMITY, - Size, - &MemoryHandle, - reinterpret_cast(&m_pProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pProperties) - { - TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(Prx_MinDataInterval_Ms, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - m_IntervalMs = Prx_MinDataInterval_Ms; - m_MinimumIntervalMs = Prx_MinDataInterval_Ms; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_Proximity, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - - // - // Data field properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_PROXIMITY, - Size, - &MemoryHandle, - reinterpret_cast(&m_pDataFieldProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) - { - TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromUInt32(PrxDevice_Resolution_Millimeters, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromUInt32(PrxDevice_Minimum_Millimeters, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromUInt32(PrxDevice_Maximum_Millimeters, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(PRX_THRESHOLD_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_PROXIMITY, - Size, - &MemoryHandle, - reinterpret_cast(&m_pThresholds)); - if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) - { - TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -PrxDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (m_FirstSample != FALSE) - { - Status = GetPerformanceTime(&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! PRX GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of detection state, and only push the data back to - // clx. This is usually done in HW. - if (m_CachedData.Detected != m_LastSample.Detected) - { - DataReady = TRUE; - } - } - - if (DataReady != FALSE) - { - // update last sample - m_LastSample = m_CachedData; - - // push to clx - InitPropVariantFromBoolean(m_LastSample.Detected, &(m_pData->List[PRX_DATA_DETECT].Value)); - InitPropVariantFromUInt32(m_LastSample.DistanceMillimeters, &(m_pData->List[PRX_DATA_DISTANCE].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[PRX_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! PRX Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -PrxDevice::UpdateCachedThreshold( - ) -{ - TraceInformation("COMBO %!FUNC! PRX do not have threshold!"); - - return STATUS_SUCCESS; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl deleted file mode 100644 index 5b5dff98..00000000 --- a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.ctl +++ /dev/null @@ -1 +0,0 @@ -3C773167,F26D,4F72,A1DE,95F1FD795840 SimpleDeviceOrientationSensorTraceGuid diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.def b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.def deleted file mode 100644 index 5273e711..00000000 --- a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.def +++ /dev/null @@ -1,6 +0,0 @@ -; SensorsComboDriver.def : Declares the module parameters. - -LIBRARY SensorsComboDriver - -EXPORTS - diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx deleted file mode 100644 index 50326f48..00000000 Binary files a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.inx and /dev/null differ diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj deleted file mode 100644 index 15e5d0a5..00000000 --- a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {C3964BD1-B485-4236-8BB4-E2981B800AC1} - $(MSBuildProjectName) - 2 - Debug - Win32 - {5E23E5F0-A79D-451A-A6E3-AA8ECD5B1E10} - - - - Windows10 - False - Universal - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Universal - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - False - Universal - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Universal - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - - $(IntDir) - - - - - - - - - - - - - - - - true - true - SensorsComboDriver - sensorstrace.h - - - $(InfArch) - true - .\$(IntDir)\SensorsComboDriver.inf - - - - SensorsComboDriver - - - SensorsComboDriver - - - SensorsComboDriver - - - SensorsComboDriver - - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - true - Level4 - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - Sync - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def - - - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - true - Level4 - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - Sync - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def - - - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - true - Level4 - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - Sync - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def - - - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - true - Level4 - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - Sync - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM - %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters b/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters deleted file mode 100644 index 7e7513b9..00000000 --- a/sensors/SensorsComboDriver/Driver/SensorsComboDriver.vcxproj.Filters +++ /dev/null @@ -1,67 +0,0 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {657C491B-7C92-4AB8-B003-546E3A3A86FF} - - - h;hpp;hxx;hm;inl;inc;xsd - {9D074C38-4627-4BCD-A647-8CEDAA88C3B0} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {F78FFA14-EFF9-47BC-83D9-680F26ED1E81} - - - inf;inv;inx;mof;mc; - {BC2DC265-BF39-4FD7-AF86-19C090D6C725} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Driver Files - - - \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/SensorsTrace.h b/sensors/SensorsComboDriver/Driver/SensorsTrace.h deleted file mode 100644 index 85a8b811..00000000 --- a/sensors/SensorsComboDriver/Driver/SensorsTrace.h +++ /dev/null @@ -1,100 +0,0 @@ -//Copyright (C) Microsoft Corporation, All Rights Reserved -// -//Abstract: -// -// Header file for the debug tracing related function defintions and macros. -// -//Environment: -// -// User mode - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -// Define the tracing flags. -// -// Tracing GUID - 3C773167-F26D-4F72-A1DE-95F1FD795840 - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - SimpleDeviceOrientationSensorTraceGuid, (3C773167,F26D,4F72,A1DE,95F1FD795840), \ - WPP_DEFINE_BIT(EntryExit) \ - WPP_DEFINE_BIT(DataFlow) \ - WPP_DEFINE_BIT(Verbose) \ - WPP_DEFINE_BIT(Information) \ - WPP_DEFINE_BIT(Warning) \ - WPP_DEFINE_BIT(Error) \ - WPP_DEFINE_BIT(Fatal) \ - WPP_DEFINE_BIT(DriverStatus) \ - ) - -#define WPP_FLAG_LEVEL_LOGGER(flag, level) WPP_LEVEL_LOGGER(flag) - -#define WPP_FLAG_LEVEL_ENABLED(flag, level) (WPP_LEVEL_ENABLED(flag) && WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) - -#define WPP_LEVEL_FLAGS_LOGGER(level,flags) WPP_LEVEL_LOGGER(flags) - -#define WPP_LEVEL_FLAGS_ENABLED(level, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= level) - -// This comment block is scanned by the trace preprocessor to define our -// Trace function. -// -// begin_wpp config -// -// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); -// -// FUNC TraceFatal{LEVEL=TRACE_LEVEL_FATAL,FLAGS=Fatal}(MSG,...); -// FUNC TraceError{LEVEL=TRACE_LEVEL_ERROR,FLAGS=Error}(MSG,...); -// FUNC TraceWarning{LEVEL=TRACE_LEVEL_WARNING,FLAGS=Warning}(MSG,...); -// FUNC TraceInformation{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=Information}(MSG,...); -// FUNC TraceVerbose{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=Verbose}(MSG,...); -// FUNC TracePerformance{PERF=DUMMY,LEVEL=TRACE_LEVEL_PERF}(FLAGS,MSG,...); -// -// FUNC TraceData{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=DataFlow}(MSG,...); -// -// FUNC TraceDriverStatus{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=DriverStatus}(MSG,...); -// -// end_wpp - -// SENSOR ------------------------------------------------------------------------------------------------ - -// MACRO: SENSOR_FunctionEnter -// -// begin_wpp config -// USEPREFIX (SENSOR_FunctionEnter, "%!STDPREFIX! SENSOR %!FUNC! FunctionEnter"); -// FUNC SENSOR_FunctionEnter{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(...); -// end_wpp - - -// MACRO: SENSOR_FunctionExit -// -// begin_wpp config -// USEPREFIX (SENSOR_FunctionExit, "%!STDPREFIX! SENSOR %!FUNC! FunctionExit: %!STATUS!", __status); -// FUNC SENSOR_FunctionExit{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(SENSOREXIT); -// end_wpp -#define WPP_LEVEL_FLAGS_SENSOREXIT_ENABLED(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_ENABLED(LEVEL, FLAGS) -#define WPP_LEVEL_FLAGS_SENSOREXIT_LOGGER(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_LOGGER(LEVEL, FLAGS) - -#define WPP_LEVEL_FLAGS_SENSOREXIT_PRE(LEVEL, FLAGS, status) { \ - NTSTATUS __status = status; -#define WPP_LEVEL_FLAGS_SENSOREXIT_POST(LEVEL, FLAGS, status) /*TraceMessage()*/; \ - } - - - -// WPP Recorder ------------------------------------------------------------------------------------------- -// -// The following two macros are required to enable WPP Recorder functionality for clients of the Sensor Class Extension -// -#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_FILTER(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_FILTER(LEVEL, FLAGS) -#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_ARGS(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_ARGS(LEVEL, FLAGS) - - -#ifdef __cplusplus -} -#endif - - diff --git a/sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp b/sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp deleted file mode 100644 index 036c294f..00000000 --- a/sensors/SensorsComboDriver/Driver/linearaccelerometerclient.cpp +++ /dev/null @@ -1,507 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (UMDF) - -#include "Clients.h" - -#include "LinearAccelerometerClient.tmh" - -#define SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER '2CaL' - -#define LinearAccelerometerDevice_Default_MinDataInterval (4) -#define LinearAccelerometerDevice_Default_Axis_Threshold (1.0f) -#define LinearAccelerometerDevice_Axis_Resolution (4.0f / 65536.0f) // in delta g -#define LinearAccelerometerDevice_Axis_Minimum (-2.0f) // in g -#define LinearAccelerometerDevice_Axis_Maximum (2.0f) // in g - -// Linear Accelerometer Unique ID -// {2BAAA1A7-6795-42A0-B830-82526CFD28D1} -DEFINE_GUID(GUID_LinearAccelerometerDevice_UniqueID, - 0x2baaa1a7, 0x6795, 0x42a0, 0xb8, 0x30, 0x82, 0x52, 0x6c, 0xfd, 0x28, 0xd1); - -// Sensor data -typedef enum -{ - LINEAR_ACCELEROMETER_DATA_X = 0, - LINEAR_ACCELEROMETER_DATA_Y, - LINEAR_ACCELEROMETER_DATA_Z, - LINEAR_ACCELEROMETER_DATA_TIMESTAMP, - LINEAR_ACCELEROMETER_DATA_SHAKE, - LINEAR_ACCELEROMETER_DATA_COUNT -} LINEAR_ACCELEROMETER_DATA_INDEX; - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -LinearAccelerometerDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! LAC WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - TimerConfig.TolerableDelay = 0; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! LAC WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pEnumerationProperties); - if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) - { - TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_LinearAccelerometer, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"Linear Accelerometer", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_LinearAccelerometerDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pSupportedDataFields); - if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) - { - TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = LINEAR_ACCELEROMETER_DATA_COUNT; - - m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_X] = PKEY_SensorData_AccelerationX_Gs; - m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_Y] = PKEY_SensorData_AccelerationY_Gs; - m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_Z] = PKEY_SensorData_AccelerationZ_Gs; - m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_SHAKE] = PKEY_SensorData_Shake; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT); - FILETIME Time = {0}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pData); - if (!NT_SUCCESS(Status) || m_pData == nullptr) - { - TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = LINEAR_ACCELEROMETER_DATA_COUNT; - - m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Value)); - - m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; - InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Value)); - - m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; - InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); - - m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; - InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); - - m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Key = PKEY_SensorData_Shake; - InitPropVariantFromBoolean(FALSE, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Value)); - - m_CachedData.Axis.X = 0.0f; - m_CachedData.Axis.Y = 0.0f; - m_CachedData.Axis.Z = -1.0f; - m_CachedData.Shake = FALSE; - - m_LastSample.Axis.X = 0.0f; - m_LastSample.Axis.Y = 0.0f; - m_LastSample.Axis.Z = 0.0f; - m_LastSample.Shake = FALSE; - } - - // - // Sensor Properties - // - { - m_IntervalMs = LinearAccelerometerDevice_Default_MinDataInterval; - - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pProperties); - if (!NT_SUCCESS(Status) || m_pProperties == nullptr) - { - TraceError("LAC %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(LinearAccelerometerDevice_Default_MinDataInterval, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_LinearAccelerometer, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - - // - // Data field properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pDataFieldProperties); - if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) - { - TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Resolution, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Minimum, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Maximum, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT - 2); // Timestamp and shake do not have thresholds - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, - Size, - &MemoryHandle, - (PVOID*)&m_pThresholds); - if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) - { - TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = LINEAR_ACCELEROMETER_DATA_COUNT - 2; - - m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; - InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, - &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_X].Value)); - - m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; - InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, - &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); - - m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; - InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, - &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); - - m_CachedThresholds.Axis.X = LinearAccelerometerDevice_Default_Axis_Threshold; - m_CachedThresholds.Axis.Y = LinearAccelerometerDevice_Default_Axis_Threshold; - m_CachedThresholds.Axis.Z = LinearAccelerometerDevice_Default_Axis_Threshold; - - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -LinearAccelerometerDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (m_FirstSample != FALSE) - { - Status = GetPerformanceTime (&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! LAC GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ( (abs(m_CachedData.Axis.X - m_LastSample.Axis.X) >= m_CachedThresholds.Axis.X) || - (abs(m_CachedData.Axis.Y - m_LastSample.Axis.Y) >= m_CachedThresholds.Axis.Y) || - (abs(m_CachedData.Axis.Z - m_LastSample.Axis.Z) >= m_CachedThresholds.Axis.Z)) - { - DataReady = TRUE; - } - } - - if (DataReady != FALSE) - { - // update last sample - m_LastSample.Axis.X = m_CachedData.Axis.X; - m_LastSample.Axis.Y = m_CachedData.Axis.Y; - m_LastSample.Axis.Z = m_CachedData.Axis.Z; - - m_LastSample.Shake = m_CachedData.Shake; - - // push to clx - InitPropVariantFromFloat(m_LastSample.Axis.X, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Value)); - InitPropVariantFromFloat(m_LastSample.Axis.Y, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); - InitPropVariantFromFloat(m_LastSample.Axis.Z, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); - - InitPropVariantFromBoolean(m_LastSample.Shake, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Value)); - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! LAC Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -LinearAccelerometerDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AccelerationX_Gs, - &m_CachedThresholds.Axis.X); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AccelerationY_Gs, - &m_CachedThresholds.Axis.Y); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_AccelerationZ_Gs, - &m_CachedThresholds.Axis.Z); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); - goto Exit; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/product.pbxproj b/sensors/SensorsComboDriver/Driver/product.pbxproj deleted file mode 100644 index c127ac09..00000000 --- a/sensors/SensorsComboDriver/Driver/product.pbxproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - v110 - Utility - - - true - true - - - - - - - true - - - \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/relativefusionclient.cpp b/sensors/SensorsComboDriver/Driver/relativefusionclient.cpp deleted file mode 100644 index 872099a6..00000000 --- a/sensors/SensorsComboDriver/Driver/relativefusionclient.cpp +++ /dev/null @@ -1,515 +0,0 @@ -// Copyright (C) Microsoft Corporation, All Rights Reserved. -// -// Abstract: -// -// This module contains the implementation of sensor specific functions. -// -// Environment: -// -// Windows User-Mode Driver Framework (WUDF) - -#include "Clients.h" - -#include "RelativeFusionClient.tmh" - -#define SENSORV2_POOL_TAG_RELATIVE_FUSION '2FsR' - -#define RelativeFusion_Initial_MinDataInterval_Ms (10) // 100Hz - -#define RelativeFusion_Quarternion_Maximum (1.0f) -#define RelativeFusion_Quarternion_Minimum (-1.0f) -#define RelativeFusion_Quarternion_Resolution ((RelativeFusion_Quarternion_Maximum-RelativeFusion_Quarternion_Minimum)/65536) - -// Relative Fusion Sensor Unique ID -// {0D324DDF-05AD-4285-875A-B2BCF565D2BA} -DEFINE_GUID(GUID_RelativeFusionDevice_UniqueID, - 0xd324ddf, 0x5ad, 0x4285, 0x87, 0x5a, 0xb2, 0xbc, 0xf5, 0x65, 0xd2, 0xba); - - -// Sensor data -typedef enum -{ - RELATIVE_FUSION_DATA_TIMESTAMP = 0, - RELATIVE_FUSION_DATA_QUATERNION_W, - RELATIVE_FUSION_DATA_QUATERNION_X, - RELATIVE_FUSION_DATA_QUATERNION_Y, - RELATIVE_FUSION_DATA_QUATERNION_Z, - RELATIVE_FUSION_DATA_COUNT -} RELATIVE_FUSION_DATA_INDEX; - -// Sensor thresholds -typedef enum -{ - RELATIVE_FUSION_THRESHOLD_QUATERNION_W = 0, - RELATIVE_FUSION_THRESHOLD_QUATERNION_X, - RELATIVE_FUSION_THRESHOLD_QUATERNION_Y, - RELATIVE_FUSION_THRESHOLD_QUATERNION_Z, - RELATIVE_FUSION_THRESHOLD_COUNT -} RELATIVE_FUSION_THRESHOLD_INDEX; - - - -//------------------------------------------------------------------------------ -// Function: Initialize -// -// This routine initializes the sensor to its default properties -// -// Arguments: -// Device: IN: WDFDEVICE object -// SensorInstance: IN: SENSOROBJECT for each sensor instance -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -RelativeFusionDevice::Initialize( - _In_ WDFDEVICE Device, - _In_ SENSOROBJECT SensorInstance - ) -{ - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // - // Store device and instance - // - m_Device = Device; - m_SensorInstance = SensorInstance; - m_Started = FALSE; - - // - // Create Lock - // - Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! Relative Fusion WdfWaitLockCreate failed %!STATUS!", Status); - goto Exit; - } - - // - // Create timer object for polling sensor samples - // - { - WDF_OBJECT_ATTRIBUTES TimerAttributes; - WDF_TIMER_CONFIG TimerConfig; - - WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); - WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); - TimerAttributes.ParentObject = SensorInstance; - TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; - - Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice WdfTimerCreate failed %!STATUS!", Status); - goto Exit; - } - } - - // - // Sensor Enumeration Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_RELATIVE_FUSION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pEnumerationProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); - m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; - - m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_RelativeOrientation, - &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); - - m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; - InitPropVariantFromString(L"Manufacturer name", - &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); - - m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; - InitPropVariantFromString(L"Relative Fusion Device", - &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); - - m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; - // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration - InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), - &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); - - m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; - InitPropVariantFromCLSID(GUID_RelativeFusionDevice_UniqueID, - &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); - - m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; - InitPropVariantFromBoolean(FALSE, - &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); - } - - // - // Supported Data-Fields - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_PROPERTY_LIST_SIZE(RELATIVE_FUSION_DATA_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_RELATIVE_FUSION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pSupportedDataFields)); - if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); - m_pSupportedDataFields->Count = RELATIVE_FUSION_DATA_COUNT; - - m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; - m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_W] = PKEY_SensorData_QuaternionW; - m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_X] = PKEY_SensorData_QuaternionX; - m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_Y] = PKEY_SensorData_QuaternionY; - m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_Z] = PKEY_SensorData_QuaternionZ; - } - - // - // Data - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(RELATIVE_FUSION_DATA_COUNT); - FILETIME Time = {0}; - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_RELATIVE_FUSION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pData)); - if (!NT_SUCCESS(Status) || nullptr == m_pData) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pData, Size); - m_pData->Count = RELATIVE_FUSION_DATA_COUNT; - - m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; - GetSystemTimePreciseAsFileTime(&Time); - InitPropVariantFromFileTime(&Time, &(m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Value)); - - m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; - InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Value)); - - m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; - InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Value)); - - m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; - InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Value)); - - m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; - InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Value)); - - ZeroMemory(&m_LastSample, sizeof(m_LastSample)); - ZeroMemory(&m_CachedData, sizeof(m_CachedData)); - m_CachedData.W = 1.0f; // This is the initial position - } - - // - // Sensor Properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_RELATIVE_FUSION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pProperties) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); - m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; - InitPropVariantFromUInt32(SensorState_Initializing, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; - InitPropVariantFromUInt32(RelativeFusion_Initial_MinDataInterval_Ms, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); - m_IntervalMs = RelativeFusion_Initial_MinDataInterval_Ms; - m_MinimumIntervalMs = RelativeFusion_Initial_MinDataInterval_Ms; - - m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; - InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); - - m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; - InitPropVariantFromCLSID(GUID_SensorType_RelativeOrientation, - &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); - } - - // - // Data filed properties - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_RELATIVE_FUSION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pDataFieldProperties)); - if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); - m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; - - m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; - InitPropVariantFromFloat(RelativeFusion_Quarternion_Resolution, - &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); - - m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; - InitPropVariantFromFloat(RelativeFusion_Quarternion_Minimum, - &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); - - m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; - InitPropVariantFromFloat(RelativeFusion_Quarternion_Maximum, - &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); - } - - // - // Set default threshold - // - { - WDF_OBJECT_ATTRIBUTES MemoryAttributes; - WDFMEMORY MemoryHandle = NULL; - ULONG Size = SENSOR_COLLECTION_LIST_SIZE(RELATIVE_FUSION_THRESHOLD_COUNT); - - MemoryHandle = NULL; - WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); - MemoryAttributes.ParentObject = SensorInstance; - Status = WdfMemoryCreate(&MemoryAttributes, - PagedPool, - SENSORV2_POOL_TAG_RELATIVE_FUSION, - Size, - &MemoryHandle, - reinterpret_cast(&m_pThresholds)); - if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); - goto Exit; - } - - SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); - m_pThresholds->Count = RELATIVE_FUSION_THRESHOLD_COUNT; - - m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; - InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_W].Value)); - - m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; - InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_X].Value)); - - m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; - InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Y].Value)); - - m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; - InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Z].Value)); - - ZeroMemory(&m_CachedThresholds, sizeof(m_CachedThresholds)); - m_FirstSample = TRUE; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: GetData -// -// This routine is called by worker thread to read a single sample, compare threshold -// and push it back to CLX. It simulates hardware thresholding by only generating data -// when the change of data is greater than threshold. -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -RelativeFusionDevice::GetData( - ) -{ - BOOLEAN DataReady = FALSE; - FILETIME TimeStamp = {0}; - NTSTATUS Status = STATUS_SUCCESS; - - SENSOR_FunctionEnter(); - - // new sample? - if (FALSE != m_FirstSample) - { - Status = GetPerformanceTime (&m_StartTime); - if (!NT_SUCCESS(Status)) - { - m_StartTime = 0; - TraceError("COMBO %!FUNC! RelativeFusionDevice GetPerformanceTime %!STATUS!", Status); - } - - m_SampleCount = 0; - - DataReady = TRUE; - } - else - { - // Compare the change of data to threshold, and only push the data back to - // clx if the change exceeds threshold. This is usually done in HW. - if ((abs(m_CachedData.W - m_LastSample.W) >= m_CachedThresholds.W) || - (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || - (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || - (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) - { - DataReady = TRUE; - } - } - - if (FALSE != DataReady) - { - // update last sample - m_LastSample = m_CachedData; - - // push to clx - InitPropVariantFromFloat(m_LastSample.W, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Value)); - InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Value)); - InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Value)); - InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Value)); - - - GetSystemTimePreciseAsFileTime(&TimeStamp); - InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Value)); - - SensorsCxSensorDataReady(m_SensorInstance, m_pData); - m_FirstSample = FALSE; - } - else - { - Status = STATUS_DATA_NOT_ACCEPTED; - TraceInformation("COMBO %!FUNC! RelativeFusionDevice Data did NOT meet the threshold"); - } - - SENSOR_FunctionExit(Status); - return Status; -} - - - -//------------------------------------------------------------------------------ -// Function: UpdateCachedThreshold -// -// This routine updates the cached threshold -// -// Arguments: -// None -// -// Return Value: -// NTSTATUS code -//------------------------------------------------------------------------------ -NTSTATUS -RelativeFusionDevice::UpdateCachedThreshold( - ) -{ - NTSTATUS Status = STATUS_UNSUCCESSFUL; - - SENSOR_FunctionEnter(); - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_QuaternionW, - &m_CachedThresholds.W); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for W failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_QuaternionX, - &m_CachedThresholds.X); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_QuaternionY, - &m_CachedThresholds.Y); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); - goto Exit; - } - - Status = PropKeyFindKeyGetFloat(m_pThresholds, - &PKEY_SensorData_QuaternionZ, - &m_CachedThresholds.Z); - if (!NT_SUCCESS(Status)) - { - TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); - goto Exit; - } - -Exit: - SENSOR_FunctionExit(Status); - return Status; -} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Driver/sources b/sensors/SensorsComboDriver/Driver/sources deleted file mode 100644 index cdee3b36..00000000 --- a/sensors/SensorsComboDriver/Driver/sources +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. - -TARGETNAME = SensorsComboDriver -TARGETTYPE = DYNLINK -TARGET_DESTINATION = NTTEST\drivers\Sensors\V2 - -DLLDEF = SensorsComboDriver.def - -MINIMUM_NT_TARGET_VERSION = $(_NT_TARGET_VERSION_WINV64) -DDK_TARGET_PLATFORM = Universal - -USE_UNICRT = 1 -USE_MSVCRT = 1 - -UMDF_VERSION_MAJOR = 2 - -C_DEFINES = $(C_DEFINES)\ - /D_UNICODE \ - /DUNICODE \ - /DWPP_MACRO_USE_KM_VERSION_FOR_UM \ - -MSC_WARNING_LEVEL = /W4 /WX - -INCLUDES = $(INCLUDES); \ - $(SDK_INC_PATH); \ -### Point to the public version of Windows.Devices.Sensors.h - $(SDK_INC_PATH)\ABI; \ - $(DDK_INC_PATH)\sensors\1.1; \ - $(SDK_INC_PATH)\sensors\1.1; \ - -TARGETLIBS = $(TARGETLIBS) \ - $(ONECORE_SDK_LIB_VPATH)\onecoreuap.lib \ - $(SDK_LIB_PATH)\propsys.lib \ - $(MINCORE_SDK_LIB_VPATH)\api-ms-win-mm-time-l1.lib \ - $(SDK_LIB_PATH)\sensorsutils.lib \ - $(SDK_LIB_PATH)\sensors\$(SENSORS_VER_PATH)\sensorscxstub.lib \ - -SOURCES = \ - alsclient.cpp \ - barclient.cpp \ - clients.cpp \ - device.cpp \ - driver.cpp \ - geomagneticorientationclient.cpp \ - gravityvectorclient.cpp \ - gyrclient.cpp \ - linearaccelerometerclient.cpp \ - magclient.cpp \ - prxclient.cpp \ - relativefusionclient.cpp \ - -RUN_WPP = $(SOURCES) -dll \ - -p:SensorsComboDriver \ - -scan:sensorstrace.h - -GENERIC_INFS = SensorsComboDriver.inx diff --git a/sensors/SensorsComboDriver/Driver/sources.dep b/sensors/SensorsComboDriver/Driver/sources.dep deleted file mode 100644 index d8383c18..00000000 --- a/sensors/SensorsComboDriver/Driver/sources.dep +++ /dev/null @@ -1,3 +0,0 @@ -PUBLIC_PASS0_CONSUMES= \ - onecore\drivers\mobilepc\sensors\drivers\sensorsv2\inc|PASS0 \ - diff --git a/sensors/SensorsComboDriver/GeomagneticOrientationClient.cpp b/sensors/SensorsComboDriver/GeomagneticOrientationClient.cpp new file mode 100644 index 00000000..b20339a7 --- /dev/null +++ b/sensors/SensorsComboDriver/GeomagneticOrientationClient.cpp @@ -0,0 +1,485 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "GeomagneticOrientationClient.tmh" + +#define SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION '9OeG' + +#define GeomagneticOrientation_Initial_MinDataInterval_Ms (10) // 100Hz + +#define GeomagneticOrientation_Quarternion_Maximum (1.0f) +#define GeomagneticOrientation_Quarternion_Minimum (-1.0f) +#define GeomagneticOrientation_Quarternion_Resolution ((GeomagneticOrientation_Quarternion_Maximum-GeomagneticOrientation_Quarternion_Minimum)/65536) + +// Geomagnetic Orientation Sensor Unique ID +// {E4F5FDEA-F268-480F-9D88-A368D381C4C2} +DEFINE_GUID(GUID_GeomagneticOrientationDevice_UniqueID, + 0xe4f5fdea, 0xf268, 0x480f, 0x9d, 0x88, 0xa3, 0x68, 0xd3, 0x81, 0xc4, 0xc2); + +// Sensor data +typedef enum +{ + GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP = 0, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y, + GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z, + GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES, + GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES, + GEOMAGNETIC_ORIENTATION_DATA_COUNT +} GEOMAGNETIC_ORIENTATION_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES = 0, + GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT +} GEOMAGNETIC_ORIENTATION_THRESHOLD_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GeomagneticOrientationDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Geomagnetic Orientation WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GeomagneticOrientation, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Geomagnetic Orientation Sensor", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_GeomagneticOrientationDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GEOMAGNETIC_ORIENTATION_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pSupportedDataFields)); + if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = GEOMAGNETIC_ORIENTATION_DATA_COUNT; + + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W] = PKEY_SensorData_QuaternionW; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X] = PKEY_SensorData_QuaternionX; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y] = PKEY_SensorData_QuaternionY; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z] = PKEY_SensorData_QuaternionZ; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES] = PKEY_SensorData_RotationAngle_Degrees; + m_pSupportedDataFields->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES] = PKEY_SensorData_DeclinationAngle_Degrees; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GEOMAGNETIC_ORIENTATION_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = GEOMAGNETIC_ORIENTATION_DATA_COUNT; + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; + InitPropVariantFromFloat(1.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Key = PKEY_SensorData_RotationAngle_Degrees; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Value)); + + m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Key = PKEY_SensorData_DeclinationAngle_Degrees; + InitPropVariantFromFloat(0.0, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Value)); + + ZeroMemory(&m_LastSample, sizeof(m_LastSample)); + ZeroMemory(&m_CachedData, sizeof(m_CachedData)); + m_CachedData.Quaternion.W = 1.0f; // This is the initial position + m_CachedData.Quaternion.X = 0.0f; // This is the initial position + m_CachedData.Quaternion.Y = 0.0f; // This is the initial position + m_CachedData.Quaternion.Z = 0.0f; // This is the initial position + m_CachedData.RotationAngle_Degrees = 0.0f; // This is the initial position + m_CachedData.DeclinationAngle_Degrees = 0.0f; // This is the initial position + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(GeomagneticOrientation_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = GeomagneticOrientation_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = GeomagneticOrientation_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GeomagneticOrientation, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(GeomagneticOrientation_Quarternion_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GEOMAGNETIC_ORIENTATION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = GEOMAGNETIC_ORIENTATION_THRESHOLD_COUNT; + + m_pThresholds->List[GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES].Key = PKEY_SensorData_RotationAngle_Degrees; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[GEOMAGNETIC_ORIENTATION_THRESHOLD_ROTATION_ANGLES_DEGREES].Value)); + + ZeroMemory(&m_CachedThresholds, sizeof(m_CachedThresholds)); + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GeomagneticOrientationDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (FALSE != m_FirstSample) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ((abs(m_CachedData.RotationAngle_Degrees - m_LastSample.RotationAngle_Degrees) >= m_CachedThresholds.RotationAngle_Degrees)) + { + DataReady = TRUE; + } + } + + if (FALSE != DataReady) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample.Quaternion.W, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_W].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.X, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_X].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.Y, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.Z, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_QUATERNION_Z].Value)); + InitPropVariantFromFloat(m_LastSample.RotationAngle_Degrees, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_ROTATION_ANGLE_DEGREES].Value)); + InitPropVariantFromFloat(m_LastSample.DeclinationAngle_Degrees, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_DECLINATION_ANGLE_DEGREES].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GEOMAGNETIC_ORIENTATION_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! GeomagneticOrientationDevice Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GeomagneticOrientationDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_RotationAngle_Degrees, + &m_CachedThresholds.RotationAngle_Degrees); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GeomagneticOrientationDevice PropKeyFindKeyGetFloat for Rotation Angle failed! %!STATUS!", Status); + goto Exit; + } +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/GravityVectorClient.cpp b/sensors/SensorsComboDriver/GravityVectorClient.cpp new file mode 100644 index 00000000..4dc53d7e --- /dev/null +++ b/sensors/SensorsComboDriver/GravityVectorClient.cpp @@ -0,0 +1,499 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Clients.h" + +#include "GravityVectorClient.tmh" + + + +#define SENSORV2_POOL_TAG_GRAVITY_VECTOR '6ArG' + +#define GravityVectorDevice_Default_MinDataInterval (4) +#define GravityVectorDevice_Default_Axis_Threshold (1.0f) +#define GravityVectorDevice_Axis_Resolution (4.0f / 65536.0f) // in delta g +#define GravityVectorDevice_Axis_Minimum (-2.0f) // in g +#define GravityVectorDevice_Axis_Maximum (2.0f) // in g + + +// Linear Accelerometer Unique ID +// {56E11473-2BB7-41E4-863A-DA014200C0DC} +DEFINE_GUID(GUID_GravityVectorDevice_UniqueID, + 0x56e11473, 0x2bb7, 0x41e4, 0x86, 0x3a, 0xda, 0x1, 0x42, 0x0, 0xc0, 0xdc); + +// Sensor data +typedef enum +{ + GRAVITY_VECTOR_DATA_X = 0, + GRAVITY_VECTOR_DATA_Y, + GRAVITY_VECTOR_DATA_Z, + GRAVITY_VECTOR_DATA_TIMESTAMP, + GRAVITY_VECTOR_DATA_COUNT +} GRAVITY_VECTOR_DATA_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GravityVectorDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + TimerConfig.TolerableDelay = 0; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GravityVector, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Gravity Vector Sensor", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_GravityVectorDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = GRAVITY_VECTOR_DATA_COUNT; + + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_X] = PKEY_SensorData_AccelerationX_Gs; + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_Y] = PKEY_SensorData_AccelerationY_Gs; + m_pSupportedDataFields->List[GRAVITY_VECTOR_DATA_Z] = PKEY_SensorData_AccelerationZ_Gs; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = GRAVITY_VECTOR_DATA_COUNT; + + m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Value)); + + m_pData->List[GRAVITY_VECTOR_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_X].Value)); + + m_pData->List[GRAVITY_VECTOR_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_Y].Value)); + + m_pData->List[GRAVITY_VECTOR_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[GRAVITY_VECTOR_DATA_Z].Value)); + + m_CachedData.X = 0.0f; + m_CachedData.Y = 0.0f; + m_CachedData.Z = 0.0f; + + m_LastSample.X = 0.0f; + m_LastSample.Y = 0.0f; + m_LastSample.Z = 0.0f; + } + + // + // Sensor Properties + // + { + m_IntervalMs = GravityVectorDevice_Default_MinDataInterval; + + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("GRA %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(GravityVectorDevice_Default_MinDataInterval, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_GravityVector, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(GravityVectorDevice_Axis_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(GravityVectorDevice_Axis_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(GravityVectorDevice_Axis_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GRAVITY_VECTOR_DATA_COUNT - 1); // Timestamp does not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GRAVITY_VECTOR, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! GRA WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = GRAVITY_VECTOR_DATA_COUNT - 1; + + m_pThresholds->List[GRAVITY_VECTOR_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, + &(m_pThresholds->List[GRAVITY_VECTOR_DATA_X].Value)); + + m_pThresholds->List[GRAVITY_VECTOR_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, + &(m_pThresholds->List[GRAVITY_VECTOR_DATA_Y].Value)); + + m_pThresholds->List[GRAVITY_VECTOR_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(GravityVectorDevice_Default_Axis_Threshold, + &(m_pThresholds->List[GRAVITY_VECTOR_DATA_Z].Value)); + + m_CachedThresholds.X = GravityVectorDevice_Default_Axis_Threshold; + m_CachedThresholds.Y = GravityVectorDevice_Default_Axis_Threshold; + m_CachedThresholds.Z = GravityVectorDevice_Default_Axis_Threshold; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GravityVectorDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! GRA GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.X = m_CachedData.X; + m_LastSample.Y = m_CachedData.Y; + m_LastSample.Z = m_CachedData.Z; + + // push to clx + InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[GRAVITY_VECTOR_DATA_X].Value)); + InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[GRAVITY_VECTOR_DATA_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[GRAVITY_VECTOR_DATA_Z].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GRAVITY_VECTOR_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! GRA Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GravityVectorDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationX_Gs, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationY_Gs, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationZ_Gs, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GRA PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/GyrClient.cpp b/sensors/SensorsComboDriver/GyrClient.cpp new file mode 100644 index 00000000..389e6e8e --- /dev/null +++ b/sensors/SensorsComboDriver/GyrClient.cpp @@ -0,0 +1,510 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "GyrClient.tmh" + +#define SENSORV2_POOL_TAG_GYROSCOPE '2oyG' + +// Chasis says 5-250Hz but unit test fails if below 250Hz??? +#define Gyr_MinDataInterval_Ms (4) // 250Hz +#define Gyr_Initial_Threshold_DegreesPerSecond (10.0f) + +#define GyrDevice_Minimum_DegreesPerSecond (-2000.0f) +#define GyrDevice_Maximum_DegreesPerSecond (2000.0f) +#define GyrDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define GyrDevice_Range_DegreesPerSecond \ + (GyrDevice_Maximum_DegreesPerSecond - GyrDevice_Minimum_DegreesPerSecond) +#define GyrDevice_Resolution_DegreesPerSecond \ + (GyrDevice_Range_DegreesPerSecond / GyrDevice_Precision) + +// Gyroscope Unique ID +// {61A61B96-1E4C-47C6-8697-654680101446} +DEFINE_GUID(GUID_GyrDevice_UniqueID, + 0x61a61b96, 0x1e4c, 0x47c6, 0x86, 0x97, 0x65, 0x46, 0x80, 0x10, 0x14, 0x46); + +// Sensor data +typedef enum +{ + GYR_DATA_TIMESTAMP = 0, + GYR_DATA_X, + GYR_DATA_Y, + GYR_DATA_Z, + GYR_DATA_COUNT +} GYR_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + GYR_THRESHOLD_X = 0, + GYR_THRESHOLD_Y, + GYR_THRESHOLD_Z, + GYR_THRESHOLD_COUNT +} GYR_THRESHOLD_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GyrDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + TimerConfig.TolerableDelay = 0; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Gyrometer3D, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"GYR", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_GyrDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(GYR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = GYR_DATA_COUNT; + + m_pSupportedDataFields->List[GYR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[GYR_DATA_X] = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; + m_pSupportedDataFields->List[GYR_DATA_Y] = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; + m_pSupportedDataFields->List[GYR_DATA_Z] = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GYR_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = GYR_DATA_COUNT; + + m_pData->List[GYR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[GYR_DATA_TIMESTAMP].Value)); + + m_pData->List[GYR_DATA_X].Key = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; + InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_X].Value)); + + m_pData->List[GYR_DATA_Y].Key = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; + InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_Y].Value)); + + m_pData->List[GYR_DATA_Z].Key = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; + InitPropVariantFromFloat(0.0f, &(m_pData->List[GYR_DATA_Z].Value)); + + m_CachedData.X = 0.0f; + m_CachedData.Y = 0.0f; + m_CachedData.Z = 0.0f; + + m_LastSample.X = 0.0f; + m_LastSample.Y = 0.0f; + m_LastSample.Z = 0.0f; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Gyr_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Gyr_MinDataInterval_Ms; + m_MinimumIntervalMs = Gyr_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Gyrometer3D, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(GyrDevice_Resolution_DegreesPerSecond, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(GyrDevice_Minimum_DegreesPerSecond, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(GyrDevice_Maximum_DegreesPerSecond, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(GYR_THRESHOLD_COUNT); // Timestamp and shake do not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_GYROSCOPE, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! GYR WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = GYR_THRESHOLD_COUNT; + + m_pThresholds->List[GYR_THRESHOLD_X].Key = PKEY_SensorData_AngularVelocityX_DegreesPerSecond; + InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, + &(m_pThresholds->List[GYR_THRESHOLD_X].Value)); + + m_pThresholds->List[GYR_THRESHOLD_Y].Key = PKEY_SensorData_AngularVelocityY_DegreesPerSecond; + InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, + &(m_pThresholds->List[GYR_THRESHOLD_Y].Value)); + + m_pThresholds->List[GYR_THRESHOLD_Z].Key = PKEY_SensorData_AngularVelocityZ_DegreesPerSecond; + InitPropVariantFromFloat(Gyr_Initial_Threshold_DegreesPerSecond, + &(m_pThresholds->List[GYR_THRESHOLD_Z].Value)); + + m_CachedThresholds.X = Gyr_Initial_Threshold_DegreesPerSecond; + m_CachedThresholds.Y = Gyr_Initial_Threshold_DegreesPerSecond; + m_CachedThresholds.Z = Gyr_Initial_Threshold_DegreesPerSecond; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GyrDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! GYR GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.X = m_CachedData.X; + m_LastSample.Y = m_CachedData.Y; + m_LastSample.Z = m_CachedData.Z; + + // push to clx + InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[GYR_DATA_X].Value)); + InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[GYR_DATA_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[GYR_DATA_Z].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[GYR_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! GYR Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +GyrDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AngularVelocityX_DegreesPerSecond, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AngularVelocityY_DegreesPerSecond, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AngularVelocityZ_DegreesPerSecond, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/MagClient.cpp b/sensors/SensorsComboDriver/MagClient.cpp new file mode 100644 index 00000000..5768cbc5 --- /dev/null +++ b/sensors/SensorsComboDriver/MagClient.cpp @@ -0,0 +1,537 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "MagClient.tmh" + +#define SENSORV2_POOL_TAG_MAGNETOMETER '2ngM' + +#define Mag_Initial_MinDataInterval_Ms (10) // 100Hz +#define Mag_Initial_Threshold_Microteslas (5.0f) // 5uT + +#define MagDevice_Minimum_Microteslas (-2000.0f) +#define MagDevice_Maximum_Microteslas (2000.0f) +#define MagDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define MagDevice_Range_Microteslas \ + (MagDevice_Maximum_Microteslas - MagDevice_Minimum_Microteslas) +#define MagDevice_Resolution_Microteslas \ + (MagDevice_Range_Microteslas / MagDevice_Precision) + +// Magnetometer Sensor Unique ID +// {0746712D-DFB1-42A7-8AAE-6089D2423CDE} +DEFINE_GUID(GUID_MagDevice_UniqueID, + 0x746712d, 0xdfb1, 0x42a7, 0x8a, 0xae, 0x60, 0x89, 0xd2, 0x42, 0x3c, 0xde); + +// Sensor data +typedef enum +{ + MAG_DATA_TIMESTAMP = 0, + MAG_DATA_X, + MAG_DATA_Y, + MAG_DATA_Z, + MAG_DATA_ACCURACY, + MAG_DATA_COUNT +} MAG_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + MAG_THRESHOLD_X = 0, + MAG_THRESHOLD_Y, + MAG_THRESHOLD_Z, + MAG_THRESHOLD_COUNT +} MAG_THRESHOLD_INDEX; + +// +// Sensor Enumeration Properties +// +typedef enum +{ + SENSOR_MAG_NAME = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX is adding SENSOR_MAG_NAME to the base SENSOR_ENUMERATION_PROPERTIES_INDEX enum. + // In order to keep the SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX enum indexing coherent with the SENSOR_ENUMERATION_PROPERTIES_INDEX enum, + // set SENSOR_MAG_NAME to the index of the last value in the SENSOR_ENUMERATION_PROPERTIES_INDEX enum + SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT +} SENSOR_MAG_ENUMERATION_PROPERTIES_INDEX; + + + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +MagDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! GYR WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_MAG_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Magnetometer3D, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"MAG", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_MagDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + // + // Alternate name used by SensorOpen + // + + m_pEnumerationProperties->List[SENSOR_MAG_NAME].Key = DEVPKEY_Sensor_Name; + InitPropVariantFromString(L"\\\\.\\Mag", + &(m_pEnumerationProperties->List[SENSOR_MAG_NAME].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(MAG_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = MAG_DATA_COUNT; + + m_pSupportedDataFields->List[MAG_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[MAG_DATA_X] = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; + m_pSupportedDataFields->List[MAG_DATA_Y] = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; + m_pSupportedDataFields->List[MAG_DATA_Z] = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; + m_pSupportedDataFields->List[MAG_DATA_ACCURACY] = PKEY_SensorData_MagnetometerAccuracy; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(MAG_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = MAG_DATA_COUNT; + + m_pData->List[MAG_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[MAG_DATA_TIMESTAMP].Value)); + + m_pData->List[MAG_DATA_X].Key = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; + InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_X].Value)); + + m_pData->List[MAG_DATA_Y].Key = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; + InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_Y].Value)); + + m_pData->List[MAG_DATA_Z].Key = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; + InitPropVariantFromFloat(0.0f, &(m_pData->List[MAG_DATA_Z].Value)); + + m_pData->List[MAG_DATA_ACCURACY].Key = PKEY_SensorData_MagnetometerAccuracy; + InitPropVariantFromUInt32(MagnetometerAccuracy_Unknown, &(m_pData->List[MAG_DATA_ACCURACY].Value)); + + m_CachedData.Axis.X = 0.0f; + m_CachedData.Axis.Y = 1.0f; + m_CachedData.Axis.Z = 0.0f; + m_CachedData.Accuracy = MagnetometerAccuracy_High; + + m_LastSample.Axis.X = 0.0f; + m_LastSample.Axis.Y = 0.0f; + m_LastSample.Axis.Z = 0.0f; + m_LastSample.Accuracy = MagnetometerAccuracy_Unknown; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Mag_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Mag_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = Mag_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Magnetometer3D, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(MagDevice_Resolution_Microteslas, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(MagDevice_Minimum_Microteslas, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(MagDevice_Maximum_Microteslas, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(MAG_THRESHOLD_COUNT); // Timestamp and shake do not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_MAGNETOMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! MAG WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = MAG_THRESHOLD_COUNT; + + m_pThresholds->List[MAG_THRESHOLD_X].Key = PKEY_SensorData_MagneticFieldStrengthX_Microteslas; + InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, + &(m_pThresholds->List[MAG_THRESHOLD_X].Value)); + + m_pThresholds->List[MAG_THRESHOLD_Y].Key = PKEY_SensorData_MagneticFieldStrengthY_Microteslas; + InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, + &(m_pThresholds->List[MAG_THRESHOLD_Y].Value)); + + m_pThresholds->List[MAG_THRESHOLD_Z].Key = PKEY_SensorData_MagneticFieldStrengthZ_Microteslas; + InitPropVariantFromFloat(Mag_Initial_Threshold_Microteslas, + &(m_pThresholds->List[MAG_THRESHOLD_Z].Value)); + + m_CachedThresholds.X = Mag_Initial_Threshold_Microteslas; + m_CachedThresholds.Y = Mag_Initial_Threshold_Microteslas; + m_CachedThresholds.Z = Mag_Initial_Threshold_Microteslas; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +MagDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! MAG GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.Axis.X - m_LastSample.Axis.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Axis.Y - m_LastSample.Axis.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Axis.Z - m_LastSample.Axis.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.Axis.X = m_CachedData.Axis.X; + m_LastSample.Axis.Y = m_CachedData.Axis.Y; + m_LastSample.Axis.Z = m_CachedData.Axis.Z; + m_LastSample.Accuracy = m_CachedData.Accuracy; + + // push to clx + InitPropVariantFromFloat (m_LastSample.Axis.X, &(m_pData->List[MAG_DATA_X].Value)); + InitPropVariantFromFloat (m_LastSample.Axis.Y, &(m_pData->List[MAG_DATA_Y].Value)); + InitPropVariantFromFloat (m_LastSample.Axis.Z, &(m_pData->List[MAG_DATA_Z].Value)); + InitPropVariantFromUInt32(m_LastSample.Accuracy, &(m_pData->List[MAG_DATA_ACCURACY].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[MAG_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! MAG Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +MagDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_MagneticFieldStrengthX_Microteslas, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_MagneticFieldStrengthY_Microteslas, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_MagneticFieldStrengthZ_Microteslas, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! MAG PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml deleted file mode 100644 index 67db4cb6..00000000 --- a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver-gallery.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - Sensors Combo Driver - - - - - - - - - - - - -

The sensors combo driver sensor sample shows how to write UMDF v2 drivers to control various types of virtual sensors such as Ambient Light, Barometer, Gyroscope, Magnetometer, Geomagnetic, Gravity Vector, Proximity, Linear Accelerometer and Relative Fusion.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
- - -
- -

To install the sample driver, follow these steps:

- - Ensure that the driver builds without errors. - Copy the DLL and INF files to a separate folder. - Enter the command "devcon.exe install SensorsComboDriver.inf ACPI\<HWID>" to install the driver on an existing device node. You can find the devcon.exe program in the tools\devcon folder where you installed the WDK. - -
-
-
- File manifest - -

The following source files are in the src\Sensors\SensorsComboDriver folder and are used to build the SensorsComboDriver.dll and SensorsComboDriver.inf files.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileDescription
-

device.h, device.cpp

-
-

Implements the driver's WDF PnP event callbacks and helper methods

-
-

Clients.cpp

-
-

Implements the driver's callback functions from the class extension to the various sensors inside the combo driver.

-
-

driver.h, driver.cpp

-
-

WDF driver entry event callbacks and helper methods

-
-

makefile.inc

-
-

Defines custom build actions. Includes the conversion of the .INX file into a .INF file.

-
-

SensorsTrace.h

-
-

Implementation of the sensor traces files.

-
-

SensorsComboDriver.ctl

-
-

Declaration of driver's tracing GUID

-
-

SensorsComboDriver.inx

-
-

Describes the installation of the driver. The build process converts this into a .INF.

-
-

Trace.h

-
-

Sets up WPP tracing.

-
-
-
-
-
-
- - - - - -
diff --git a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml deleted file mode 100644 index 517e6bbd..00000000 --- a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.kml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln b/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln deleted file mode 100644 index e6f4e500..00000000 --- a/sensors/SensorsComboDriver/Metadata/SensorsComboDriver.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 -MinimumVisualStudioVersion = 12.0 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SensorsComboDriver", "SensorsComboDriver.vcxproj", "{C3964BD1-B485-4236-8BB4-E2981B800AC1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|Win32.ActiveCfg = Debug|Win32 - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|Win32.Build.0 = Debug|Win32 - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|Win32.ActiveCfg = Release|Win32 - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|Win32.Build.0 = Release|Win32 - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|x64.ActiveCfg = Debug|x64 - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|x64.Build.0 = Debug|x64 - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|x64.ActiveCfg = Release|x64 - {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/sensors/SensorsComboDriver/Metadata/product.pbxproj b/sensors/SensorsComboDriver/Metadata/product.pbxproj deleted file mode 100644 index fb8943d8..00000000 --- a/sensors/SensorsComboDriver/Metadata/product.pbxproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - v110 - Utility - - - - - - \ No newline at end of file diff --git a/sensors/SensorsComboDriver/Metadata/sources b/sensors/SensorsComboDriver/Metadata/sources deleted file mode 100644 index 4f324037..00000000 --- a/sensors/SensorsComboDriver/Metadata/sources +++ /dev/null @@ -1,4 +0,0 @@ -TARGETTYPE = NOTARGET - -SOURCES=\ - SensorsComboDriver.kml \ \ No newline at end of file diff --git a/sensors/SensorsComboDriver/PrxClient.cpp b/sensors/SensorsComboDriver/PrxClient.cpp new file mode 100644 index 00000000..fa10e095 --- /dev/null +++ b/sensors/SensorsComboDriver/PrxClient.cpp @@ -0,0 +1,458 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "PrxClient.tmh" + +#define SENSORV2_POOL_TAG_PROXIMITY '2ixP' + +static const ULONG Prx_MinDataInterval_Ms = 10; // 100Hz + +static const ULONG PrxDevice_Minimum_Millimeters = 3; +static const ULONG PrxDevice_Maximum_Millimeters = 50; +static const ULONG PrxDevice_Resolution_Millimeters = 1; + +// Proximity Sensor Unique ID +// {4B6BE805-2432-4B6B-A5E3-DEA67CA43225} +DEFINE_GUID(GUID_PrxDevice_UniqueID, + 0x4b6be805, 0x2432, 0x4b6b, 0xa5, 0xe3, 0xde, 0xa6, 0x7c, 0xa4, 0x32, 0x25); + +// Sensor data +typedef enum +{ + PRX_DATA_TIMESTAMP = 0, + PRX_DATA_DETECT, + PRX_DATA_DISTANCE, + PRX_DATA_COUNT +} PRX_DATA_INDEX; + +static const ULONG PRX_THRESHOLD_COUNT = 0; // proxmity sensor has no threshold + +// +// Additional Sensor Properties +// +typedef enum +{ + SENSOR_PROPERTY_PRX_TYPE = SENSOR_ENUMERATION_PROPERTIES_COUNT, // SENSOR_PRX_PROPERTIES_INDEX is adding SENSOR_PROPERTY_PRX_TYPE to the base SENSOR_PROPERTIES_INDEX enum. + // In order to keep the SENSOR_PRX_PROPERTIES_INDEX enum indexing coherent with the SENSOR_PROPERTIES_INDEX enum, + // set SENSOR_PROPERTY_PRX_TYPE to the index of the last value in the SENSOR_PROPERTIES_INDEX enum + SENSOR_ISWAKECAPABLE = SENSOR_PROPERTY_PRX_TYPE + 1, + SENSOR_PRX_ENUMERATION_PROPERTY_COUNT +} SENSOR_PRX_PROPERTIES_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +PrxDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! PRX WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! PRX WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_PRX_ENUMERATION_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + m_pEnumerationProperties->Count = SENSOR_PRX_ENUMERATION_PROPERTY_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Proximity, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"PRX", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_PrxDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + + m_pEnumerationProperties->List[SENSOR_PROPERTY_PRX_TYPE].Key = DEVPKEY_Sensor_ProximityType; + InitPropVariantFromUInt32(PROXIMITY_TYPE::ProximityType_HumanProximity, + &(m_pEnumerationProperties->List[SENSOR_PROPERTY_PRX_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_ISWAKECAPABLE].Key = PKEY_Sensor_WakeCapable; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISWAKECAPABLE].Value)); + + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(PRX_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = PRX_DATA_COUNT; + + m_pSupportedDataFields->List[PRX_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[PRX_DATA_DETECT] = PKEY_SensorData_ProximityDetection; + m_pSupportedDataFields->List[PRX_DATA_DISTANCE] = PKEY_SensorData_ProximityDistanceMillimeters; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(PRX_DATA_COUNT); + FILETIME Time = {}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = PRX_DATA_COUNT; + + m_pData->List[PRX_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[PRX_DATA_TIMESTAMP].Value)); + + m_pData->List[PRX_DATA_DETECT].Key = PKEY_SensorData_ProximityDetection; + InitPropVariantFromBoolean(FALSE, &(m_pData->List[PRX_DATA_DETECT].Value)); + + m_pData->List[PRX_DATA_DISTANCE].Key = PKEY_SensorData_ProximityDistanceMillimeters; + InitPropVariantFromUInt32(FALSE, &(m_pData->List[PRX_DATA_DISTANCE].Value)); + + m_CachedData.Detected = FALSE; + m_CachedData.DistanceMillimeters = PrxDevice_Maximum_Millimeters; + + m_LastSample.Detected = FALSE; + m_LastSample.DistanceMillimeters = PrxDevice_Maximum_Millimeters; + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(Prx_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = Prx_MinDataInterval_Ms; + m_MinimumIntervalMs = Prx_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Proximity, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromUInt32(PrxDevice_Resolution_Millimeters, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromUInt32(PrxDevice_Minimum_Millimeters, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromUInt32(PrxDevice_Maximum_Millimeters, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(PRX_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_PROXIMITY, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! PRX WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +PrxDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime(&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! PRX GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of detection state, and only push the data back to + // clx. This is usually done in HW. + if (m_CachedData.Detected != m_LastSample.Detected) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromBoolean(m_LastSample.Detected, &(m_pData->List[PRX_DATA_DETECT].Value)); + InitPropVariantFromUInt32(m_LastSample.DistanceMillimeters, &(m_pData->List[PRX_DATA_DISTANCE].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[PRX_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! PRX Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +PrxDevice::UpdateCachedThreshold( + ) +{ + TraceInformation("COMBO %!FUNC! PRX do not have threshold!"); + + return STATUS_SUCCESS; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/SensorsComboDriver.inx b/sensors/SensorsComboDriver/SensorsComboDriver.inx new file mode 100644 index 00000000..50326f48 Binary files /dev/null and b/sensors/SensorsComboDriver/SensorsComboDriver.inx differ diff --git a/sensors/SensorsComboDriver/SensorsComboDriver.sln b/sensors/SensorsComboDriver/SensorsComboDriver.sln new file mode 100644 index 00000000..e6f4e500 --- /dev/null +++ b/sensors/SensorsComboDriver/SensorsComboDriver.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0 +MinimumVisualStudioVersion = 12.0 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SensorsComboDriver", "SensorsComboDriver.vcxproj", "{C3964BD1-B485-4236-8BB4-E2981B800AC1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|Win32.ActiveCfg = Debug|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|Win32.Build.0 = Debug|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|Win32.ActiveCfg = Release|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|Win32.Build.0 = Release|Win32 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|x64.ActiveCfg = Debug|x64 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Debug|x64.Build.0 = Debug|x64 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|x64.ActiveCfg = Release|x64 + {C3964BD1-B485-4236-8BB4-E2981B800AC1}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj b/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj new file mode 100644 index 00000000..15e5d0a5 --- /dev/null +++ b/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {C3964BD1-B485-4236-8BB4-E2981B800AC1} + $(MSBuildProjectName) + 2 + Debug + Win32 + {5E23E5F0-A79D-451A-A6E3-AA8ECD5B1E10} + + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + true + true + SensorsComboDriver + sensorstrace.h + + + $(InfArch) + true + .\$(IntDir)\SensorsComboDriver.inf + + + + SensorsComboDriver + + + SensorsComboDriver + + + SensorsComboDriver + + + SensorsComboDriver + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + SensorsComboDriver.def + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj.Filters b/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj.Filters new file mode 100644 index 00000000..7e7513b9 --- /dev/null +++ b/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj.Filters @@ -0,0 +1,67 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {657C491B-7C92-4AB8-B003-546E3A3A86FF} + + + h;hpp;hxx;hm;inl;inc;xsd + {9D074C38-4627-4BCD-A647-8CEDAA88C3B0} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {F78FFA14-EFF9-47BC-83D9-680F26ED1E81} + + + inf;inv;inx;mof;mc; + {BC2DC265-BF39-4FD7-AF86-19C090D6C725} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Driver Files + + + \ No newline at end of file diff --git a/sensors/SensorsComboDriver/SensorsTrace.h b/sensors/SensorsComboDriver/SensorsTrace.h new file mode 100644 index 00000000..85a8b811 --- /dev/null +++ b/sensors/SensorsComboDriver/SensorsTrace.h @@ -0,0 +1,100 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved +// +//Abstract: +// +// Header file for the debug tracing related function defintions and macros. +// +//Environment: +// +// User mode + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +// Define the tracing flags. +// +// Tracing GUID - 3C773167-F26D-4F72-A1DE-95F1FD795840 + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID( \ + SimpleDeviceOrientationSensorTraceGuid, (3C773167,F26D,4F72,A1DE,95F1FD795840), \ + WPP_DEFINE_BIT(EntryExit) \ + WPP_DEFINE_BIT(DataFlow) \ + WPP_DEFINE_BIT(Verbose) \ + WPP_DEFINE_BIT(Information) \ + WPP_DEFINE_BIT(Warning) \ + WPP_DEFINE_BIT(Error) \ + WPP_DEFINE_BIT(Fatal) \ + WPP_DEFINE_BIT(DriverStatus) \ + ) + +#define WPP_FLAG_LEVEL_LOGGER(flag, level) WPP_LEVEL_LOGGER(flag) + +#define WPP_FLAG_LEVEL_ENABLED(flag, level) (WPP_LEVEL_ENABLED(flag) && WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) + +#define WPP_LEVEL_FLAGS_LOGGER(level,flags) WPP_LEVEL_LOGGER(flags) + +#define WPP_LEVEL_FLAGS_ENABLED(level, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= level) + +// This comment block is scanned by the trace preprocessor to define our +// Trace function. +// +// begin_wpp config +// +// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); +// +// FUNC TraceFatal{LEVEL=TRACE_LEVEL_FATAL,FLAGS=Fatal}(MSG,...); +// FUNC TraceError{LEVEL=TRACE_LEVEL_ERROR,FLAGS=Error}(MSG,...); +// FUNC TraceWarning{LEVEL=TRACE_LEVEL_WARNING,FLAGS=Warning}(MSG,...); +// FUNC TraceInformation{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=Information}(MSG,...); +// FUNC TraceVerbose{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=Verbose}(MSG,...); +// FUNC TracePerformance{PERF=DUMMY,LEVEL=TRACE_LEVEL_PERF}(FLAGS,MSG,...); +// +// FUNC TraceData{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=DataFlow}(MSG,...); +// +// FUNC TraceDriverStatus{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=DriverStatus}(MSG,...); +// +// end_wpp + +// SENSOR ------------------------------------------------------------------------------------------------ + +// MACRO: SENSOR_FunctionEnter +// +// begin_wpp config +// USEPREFIX (SENSOR_FunctionEnter, "%!STDPREFIX! SENSOR %!FUNC! FunctionEnter"); +// FUNC SENSOR_FunctionEnter{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(...); +// end_wpp + + +// MACRO: SENSOR_FunctionExit +// +// begin_wpp config +// USEPREFIX (SENSOR_FunctionExit, "%!STDPREFIX! SENSOR %!FUNC! FunctionExit: %!STATUS!", __status); +// FUNC SENSOR_FunctionExit{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(SENSOREXIT); +// end_wpp +#define WPP_LEVEL_FLAGS_SENSOREXIT_ENABLED(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_ENABLED(LEVEL, FLAGS) +#define WPP_LEVEL_FLAGS_SENSOREXIT_LOGGER(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_LOGGER(LEVEL, FLAGS) + +#define WPP_LEVEL_FLAGS_SENSOREXIT_PRE(LEVEL, FLAGS, status) { \ + NTSTATUS __status = status; +#define WPP_LEVEL_FLAGS_SENSOREXIT_POST(LEVEL, FLAGS, status) /*TraceMessage()*/; \ + } + + + +// WPP Recorder ------------------------------------------------------------------------------------------- +// +// The following two macros are required to enable WPP Recorder functionality for clients of the Sensor Class Extension +// +#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_FILTER(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_FILTER(LEVEL, FLAGS) +#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_ARGS(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_ARGS(LEVEL, FLAGS) + + +#ifdef __cplusplus +} +#endif + + diff --git a/sensors/SensorsComboDriver/dirs b/sensors/SensorsComboDriver/dirs deleted file mode 100644 index 7f4c72f7..00000000 --- a/sensors/SensorsComboDriver/dirs +++ /dev/null @@ -1,4 +0,0 @@ -DIRS = \ - Driver \ - Cat \ - Metadata \ \ No newline at end of file diff --git a/sensors/SensorsComboDriver/linearaccelerometerclient.cpp b/sensors/SensorsComboDriver/linearaccelerometerclient.cpp new file mode 100644 index 00000000..036c294f --- /dev/null +++ b/sensors/SensorsComboDriver/linearaccelerometerclient.cpp @@ -0,0 +1,507 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Clients.h" + +#include "LinearAccelerometerClient.tmh" + +#define SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER '2CaL' + +#define LinearAccelerometerDevice_Default_MinDataInterval (4) +#define LinearAccelerometerDevice_Default_Axis_Threshold (1.0f) +#define LinearAccelerometerDevice_Axis_Resolution (4.0f / 65536.0f) // in delta g +#define LinearAccelerometerDevice_Axis_Minimum (-2.0f) // in g +#define LinearAccelerometerDevice_Axis_Maximum (2.0f) // in g + +// Linear Accelerometer Unique ID +// {2BAAA1A7-6795-42A0-B830-82526CFD28D1} +DEFINE_GUID(GUID_LinearAccelerometerDevice_UniqueID, + 0x2baaa1a7, 0x6795, 0x42a0, 0xb8, 0x30, 0x82, 0x52, 0x6c, 0xfd, 0x28, 0xd1); + +// Sensor data +typedef enum +{ + LINEAR_ACCELEROMETER_DATA_X = 0, + LINEAR_ACCELEROMETER_DATA_Y, + LINEAR_ACCELEROMETER_DATA_Z, + LINEAR_ACCELEROMETER_DATA_TIMESTAMP, + LINEAR_ACCELEROMETER_DATA_SHAKE, + LINEAR_ACCELEROMETER_DATA_COUNT +} LINEAR_ACCELEROMETER_DATA_INDEX; + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +LinearAccelerometerDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + TimerConfig.TolerableDelay = 0; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_LinearAccelerometer, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Linear Accelerometer", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_LinearAccelerometerDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = LINEAR_ACCELEROMETER_DATA_COUNT; + + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_X] = PKEY_SensorData_AccelerationX_Gs; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_Y] = PKEY_SensorData_AccelerationY_Gs; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_Z] = PKEY_SensorData_AccelerationZ_Gs; + m_pSupportedDataFields->List[LINEAR_ACCELEROMETER_DATA_SHAKE] = PKEY_SensorData_Shake; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = LINEAR_ACCELEROMETER_DATA_COUNT; + + m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(0.0, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); + + m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Key = PKEY_SensorData_Shake; + InitPropVariantFromBoolean(FALSE, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Value)); + + m_CachedData.Axis.X = 0.0f; + m_CachedData.Axis.Y = 0.0f; + m_CachedData.Axis.Z = -1.0f; + m_CachedData.Shake = FALSE; + + m_LastSample.Axis.X = 0.0f; + m_LastSample.Axis.Y = 0.0f; + m_LastSample.Axis.Z = 0.0f; + m_LastSample.Shake = FALSE; + } + + // + // Sensor Properties + // + { + m_IntervalMs = LinearAccelerometerDevice_Default_MinDataInterval; + + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("LAC %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(LinearAccelerometerDevice_Default_MinDataInterval, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_LinearAccelerometer, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data field properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pDataFieldProperties == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(LinearAccelerometerDevice_Axis_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(LINEAR_ACCELEROMETER_DATA_COUNT - 2); // Timestamp and shake do not have thresholds + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("COMBO %!FUNC! LAC WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = LINEAR_ACCELEROMETER_DATA_COUNT - 2; + + m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_X].Key = PKEY_SensorData_AccelerationX_Gs; + InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, + &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_X].Value)); + + m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Y].Key = PKEY_SensorData_AccelerationY_Gs; + InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, + &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); + + m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Z].Key = PKEY_SensorData_AccelerationZ_Gs; + InitPropVariantFromFloat(LinearAccelerometerDevice_Default_Axis_Threshold, + &(m_pThresholds->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); + + m_CachedThresholds.Axis.X = LinearAccelerometerDevice_Default_Axis_Threshold; + m_CachedThresholds.Axis.Y = LinearAccelerometerDevice_Default_Axis_Threshold; + m_CachedThresholds.Axis.Z = LinearAccelerometerDevice_Default_Axis_Threshold; + + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +LinearAccelerometerDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (m_FirstSample != FALSE) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! LAC GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ( (abs(m_CachedData.Axis.X - m_LastSample.Axis.X) >= m_CachedThresholds.Axis.X) || + (abs(m_CachedData.Axis.Y - m_LastSample.Axis.Y) >= m_CachedThresholds.Axis.Y) || + (abs(m_CachedData.Axis.Z - m_LastSample.Axis.Z) >= m_CachedThresholds.Axis.Z)) + { + DataReady = TRUE; + } + } + + if (DataReady != FALSE) + { + // update last sample + m_LastSample.Axis.X = m_CachedData.Axis.X; + m_LastSample.Axis.Y = m_CachedData.Axis.Y; + m_LastSample.Axis.Z = m_CachedData.Axis.Z; + + m_LastSample.Shake = m_CachedData.Shake; + + // push to clx + InitPropVariantFromFloat(m_LastSample.Axis.X, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_X].Value)); + InitPropVariantFromFloat(m_LastSample.Axis.Y, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Axis.Z, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_Z].Value)); + + InitPropVariantFromBoolean(m_LastSample.Shake, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_SHAKE].Value)); + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[LINEAR_ACCELEROMETER_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! LAC Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +LinearAccelerometerDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationX_Gs, + &m_CachedThresholds.Axis.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationY_Gs, + &m_CachedThresholds.Axis.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_AccelerationZ_Gs, + &m_CachedThresholds.Axis.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! LAC PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/SensorsComboDriver/relativefusionclient.cpp b/sensors/SensorsComboDriver/relativefusionclient.cpp new file mode 100644 index 00000000..872099a6 --- /dev/null +++ b/sensors/SensorsComboDriver/relativefusionclient.cpp @@ -0,0 +1,515 @@ +// Copyright (C) Microsoft Corporation, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of sensor specific functions. +// +// Environment: +// +// Windows User-Mode Driver Framework (WUDF) + +#include "Clients.h" + +#include "RelativeFusionClient.tmh" + +#define SENSORV2_POOL_TAG_RELATIVE_FUSION '2FsR' + +#define RelativeFusion_Initial_MinDataInterval_Ms (10) // 100Hz + +#define RelativeFusion_Quarternion_Maximum (1.0f) +#define RelativeFusion_Quarternion_Minimum (-1.0f) +#define RelativeFusion_Quarternion_Resolution ((RelativeFusion_Quarternion_Maximum-RelativeFusion_Quarternion_Minimum)/65536) + +// Relative Fusion Sensor Unique ID +// {0D324DDF-05AD-4285-875A-B2BCF565D2BA} +DEFINE_GUID(GUID_RelativeFusionDevice_UniqueID, + 0xd324ddf, 0x5ad, 0x4285, 0x87, 0x5a, 0xb2, 0xbc, 0xf5, 0x65, 0xd2, 0xba); + + +// Sensor data +typedef enum +{ + RELATIVE_FUSION_DATA_TIMESTAMP = 0, + RELATIVE_FUSION_DATA_QUATERNION_W, + RELATIVE_FUSION_DATA_QUATERNION_X, + RELATIVE_FUSION_DATA_QUATERNION_Y, + RELATIVE_FUSION_DATA_QUATERNION_Z, + RELATIVE_FUSION_DATA_COUNT +} RELATIVE_FUSION_DATA_INDEX; + +// Sensor thresholds +typedef enum +{ + RELATIVE_FUSION_THRESHOLD_QUATERNION_W = 0, + RELATIVE_FUSION_THRESHOLD_QUATERNION_X, + RELATIVE_FUSION_THRESHOLD_QUATERNION_Y, + RELATIVE_FUSION_THRESHOLD_QUATERNION_Z, + RELATIVE_FUSION_THRESHOLD_COUNT +} RELATIVE_FUSION_THRESHOLD_INDEX; + + + +//------------------------------------------------------------------------------ +// Function: Initialize +// +// This routine initializes the sensor to its default properties +// +// Arguments: +// Device: IN: WDFDEVICE object +// SensorInstance: IN: SENSOROBJECT for each sensor instance +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +RelativeFusionDevice::Initialize( + _In_ WDFDEVICE Device, + _In_ SENSOROBJECT SensorInstance + ) +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // + // Store device and instance + // + m_Device = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // + // Create Lock + // + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! Relative Fusion WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Create timer object for polling sensor samples + // + { + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + + WDF_TIMER_CONFIG_INIT(&TimerConfig, OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + } + + // + // Sensor Enumeration Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pEnumerationProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pEnumerationProperties) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_RelativeOrientation, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"Manufacturer name", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Relative Fusion Device", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Key = DEVPKEY_Sensor_ConnectionType; + // The DEVPKEY_Sensor_ConnectionType values match the SensorConnectionType enumeration + InitPropVariantFromUInt32(static_cast(SensorConnectionType::Integrated), + &(m_pEnumerationProperties->List[SENSOR_CONNECTION_TYPE].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_RelativeFusionDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_PROPERTY_LIST_SIZE(RELATIVE_FUSION_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pSupportedDataFields)); + if (!NT_SUCCESS(Status) || nullptr == m_pSupportedDataFields) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = RELATIVE_FUSION_DATA_COUNT; + + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_W] = PKEY_SensorData_QuaternionW; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_X] = PKEY_SensorData_QuaternionX; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_Y] = PKEY_SensorData_QuaternionY; + m_pSupportedDataFields->List[RELATIVE_FUSION_DATA_QUATERNION_Z] = PKEY_SensorData_QuaternionZ; + } + + // + // Data + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(RELATIVE_FUSION_DATA_COUNT); + FILETIME Time = {0}; + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pData)); + if (!NT_SUCCESS(Status) || nullptr == m_pData) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = RELATIVE_FUSION_DATA_COUNT; + + m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Value)); + + m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; + InitPropVariantFromFloat(0.0, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Value)); + + ZeroMemory(&m_LastSample, sizeof(m_LastSample)); + ZeroMemory(&m_CachedData, sizeof(m_CachedData)); + m_CachedData.W = 1.0f; // This is the initial position + } + + // + // Sensor Properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_COMMON_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pProperties) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_COMMON_PROPERTY_COUNT; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(RelativeFusion_Initial_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MIN_INTERVAL].Value)); + m_IntervalMs = RelativeFusion_Initial_MinDataInterval_Ms; + m_MinimumIntervalMs = RelativeFusion_Initial_MinDataInterval_Ms; + + m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_RelativeOrientation, + &(m_pProperties->List[SENSOR_COMMON_PROPERTY_TYPE].Value)); + } + + // + // Data filed properties + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pDataFieldProperties)); + if (!NT_SUCCESS(Status) || nullptr == m_pDataFieldProperties) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pDataFieldProperties, Size); + m_pDataFieldProperties->Count = SENSOR_DATA_FIELD_PROPERTY_COUNT; + + m_pDataFieldProperties->List[SENSOR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(RelativeFusion_Quarternion_Resolution, + &(m_pDataFieldProperties->List[SENSOR_RESOLUTION].Value)); + + m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(RelativeFusion_Quarternion_Minimum, + &(m_pDataFieldProperties->List[SENSOR_MIN_RANGE].Value)); + + m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(RelativeFusion_Quarternion_Maximum, + &(m_pDataFieldProperties->List[SENSOR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + ULONG Size = SENSOR_COLLECTION_LIST_SIZE(RELATIVE_FUSION_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSORV2_POOL_TAG_RELATIVE_FUSION, + Size, + &MemoryHandle, + reinterpret_cast(&m_pThresholds)); + if (!NT_SUCCESS(Status) || nullptr == m_pThresholds) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = RELATIVE_FUSION_THRESHOLD_COUNT; + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_W].Value)); + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_X].Value)); + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Y].Value)); + + m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; + InitPropVariantFromFloat(0.0f, &(m_pThresholds->List[RELATIVE_FUSION_THRESHOLD_QUATERNION_Z].Value)); + + ZeroMemory(&m_CachedThresholds, sizeof(m_CachedThresholds)); + m_FirstSample = TRUE; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: GetData +// +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +RelativeFusionDevice::GetData( + ) +{ + BOOLEAN DataReady = FALSE; + FILETIME TimeStamp = {0}; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // new sample? + if (FALSE != m_FirstSample) + { + Status = GetPerformanceTime (&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("COMBO %!FUNC! RelativeFusionDevice GetPerformanceTime %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. This is usually done in HW. + if ((abs(m_CachedData.W - m_LastSample.W) >= m_CachedThresholds.W) || + (abs(m_CachedData.X - m_LastSample.X) >= m_CachedThresholds.X) || + (abs(m_CachedData.Y - m_LastSample.Y) >= m_CachedThresholds.Y) || + (abs(m_CachedData.Z - m_LastSample.Z) >= m_CachedThresholds.Z)) + { + DataReady = TRUE; + } + } + + if (FALSE != DataReady) + { + // update last sample + m_LastSample = m_CachedData; + + // push to clx + InitPropVariantFromFloat(m_LastSample.W, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_W].Value)); + InitPropVariantFromFloat(m_LastSample.X, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_X].Value)); + InitPropVariantFromFloat(m_LastSample.Y, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Z, &(m_pData->List[RELATIVE_FUSION_DATA_QUATERNION_Z].Value)); + + + GetSystemTimePreciseAsFileTime(&TimeStamp); + InitPropVariantFromFileTime(&TimeStamp, &(m_pData->List[RELATIVE_FUSION_DATA_TIMESTAMP].Value)); + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("COMBO %!FUNC! RelativeFusionDevice Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + return Status; +} + + + +//------------------------------------------------------------------------------ +// Function: UpdateCachedThreshold +// +// This routine updates the cached threshold +// +// Arguments: +// None +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +RelativeFusionDevice::UpdateCachedThreshold( + ) +{ + NTSTATUS Status = STATUS_UNSUCCESSFUL; + + SENSOR_FunctionEnter(); + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionW, + &m_CachedThresholds.W); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for W failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionX, + &m_CachedThresholds.X); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionY, + &m_CachedThresholds.Y); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(m_pThresholds, + &PKEY_SensorData_QuaternionZ, + &m_CachedThresholds.Z); + if (!NT_SUCCESS(Status)) + { + TraceError("COMBO %!FUNC! RelativeFusionDevice PropKeyFindKeyGetFloat for Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file -- cgit v1.3.1 From c55a6ccfde77b7e09acaca0d59c8c288b5626288 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Thu, 17 Aug 2017 17:52:11 -0700 Subject: Point to .inx file when .inf file is not available --- .../bthecho/bthcli/sys/BthEchoSampleCli.vcxproj | 2 +- .../bthecho/bthsrv/sys/BthEchoSampleSrv.vcxproj | 2 +- bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj | 2 +- general/PLX9x5x/sys/Pci9x5x.vcxproj | 2 +- general/echo/kmdf/driver/AutoSync/echo.vcxproj | 4 +- general/echo/kmdf/driver/DriverSync/echo_2.vcxproj | 2 +- general/echo/umdf/WUDFEchoDriver.vcxproj | 2 +- general/echo/umdf2/driver/AutoSync/echo.vcxproj | 2 +- .../echo/umdfSocketEcho/Driver/SocketEcho.vcxproj | 2 +- general/pcidrv/kmdf/HW/PCIDRV.vcxproj | 2 +- general/umdfSkeleton/UMDFSkeleton.vcxproj | 2 +- hid/firefly/driver/firefly.vcxproj | 2 +- hid/hidusbfx2/sys/hidusbfx2.vcxproj | 2 +- hid/vhidmini2/driver/kmdf/vhidmini.vcxproj | 2 +- hid/vhidmini2/driver/umdf2/VhidminiUm.vcxproj | 2 +- .../SingleComponentSingleStateUm.vcxproj | 2 +- .../Driver/MultiComp/driver/WdfMultiComp.vcxproj | 2 +- .../SingleComp/SingleComponentFStateDriver.vcxproj | 2 +- serial/VirtualSerial/ComPort/virtualserial.vcxproj | 2 +- serial/VirtualSerial/FakeModem/fakemodem.vcxproj | 2 +- .../ComPort/VirtualSerial2um.vcxproj | 2 +- .../VirtualSerial2/FakeModem/fakemodem2um.vcxproj | 2 +- serial/serial/wdfserial.vcxproj | 2 +- simbatt/func/simbatt.vcxproj | 193 +++++++++++++++++++++ simbatt/func/simbatt.vcxproj.Filters | 34 ++++ storage/ramdisk/src/WdfRamdisk.vcxproj | 2 +- .../sys/kmdf_enumswitches.vcxproj | 2 +- usb/ufxclientsample/ufxclientsample.vcxproj | 2 +- .../umdf_filter/WUDFOsrUsbFilter.vcxproj | 2 +- .../umdf_filter/WUDFOsrUsbFilter.vcxproj | 2 +- usb/umdf_fx2/driver/WUDFOsrUsbFx2.vcxproj | 2 +- usb/usbsamp/sys/driver/usbsamp.vcxproj | 2 +- usb/wdf_osrfx2_lab/kmdf/step1/osrusbfx2.vcxproj | 2 +- usb/wdf_osrfx2_lab/kmdf/step2/osrusbfx2.vcxproj | 2 +- usb/wdf_osrfx2_lab/kmdf/step3/osrusbfx2.vcxproj | 2 +- usb/wdf_osrfx2_lab/kmdf/step4/osrusbfx2.vcxproj | 2 +- usb/wdf_osrfx2_lab/kmdf/step5/osrusbfx2.vcxproj | 2 +- .../umdf/step1/WUDFOsrUsbFx2_1.vcxproj | 2 +- .../umdf/step2/WUDFOsrUsbFx2_2.vcxproj | 2 +- .../umdf/step3/WUDFOsrUsbFx2_3.vcxproj | 2 +- .../umdf/step4/WUDFOsrUsbFx2_4.vcxproj | 2 +- wmi/wmisamp/WmiSamp.vcxproj | 2 +- 42 files changed, 268 insertions(+), 41 deletions(-) create mode 100644 simbatt/func/simbatt.vcxproj create mode 100644 simbatt/func/simbatt.vcxproj.Filters diff --git a/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.vcxproj b/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.vcxproj index d7d2be78..35a2afb7 100644 --- a/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.vcxproj +++ b/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.vcxproj @@ -180,7 +180,7 @@ - + diff --git a/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.vcxproj b/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.vcxproj index 43afa40e..8e5c6c80 100644 --- a/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.vcxproj +++ b/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.vcxproj @@ -180,7 +180,7 @@ - + diff --git a/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj b/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj index c28833ce..1aa3a43c 100644 --- a/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj +++ b/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj @@ -189,7 +189,7 @@ - + diff --git a/general/PLX9x5x/sys/Pci9x5x.vcxproj b/general/PLX9x5x/sys/Pci9x5x.vcxproj index c422c342..c46f37d4 100644 --- a/general/PLX9x5x/sys/Pci9x5x.vcxproj +++ b/general/PLX9x5x/sys/Pci9x5x.vcxproj @@ -210,7 +210,7 @@ - + diff --git a/general/echo/kmdf/driver/AutoSync/echo.vcxproj b/general/echo/kmdf/driver/AutoSync/echo.vcxproj index b41d49c9..ee243a5d 100644 --- a/general/echo/kmdf/driver/AutoSync/echo.vcxproj +++ b/general/echo/kmdf/driver/AutoSync/echo.vcxproj @@ -146,7 +146,7 @@ - + @@ -158,4 +158,4 @@ - \ No newline at end of file + diff --git a/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj b/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj index 95957fec..4a77818d 100644 --- a/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj +++ b/general/echo/kmdf/driver/DriverSync/echo_2.vcxproj @@ -158,7 +158,7 @@ - + diff --git a/general/echo/umdf/WUDFEchoDriver.vcxproj b/general/echo/umdf/WUDFEchoDriver.vcxproj index c9a5a638..b00330bf 100644 --- a/general/echo/umdf/WUDFEchoDriver.vcxproj +++ b/general/echo/umdf/WUDFEchoDriver.vcxproj @@ -235,7 +235,7 @@ - + diff --git a/general/echo/umdf2/driver/AutoSync/echo.vcxproj b/general/echo/umdf2/driver/AutoSync/echo.vcxproj index e3a2e18d..17763154 100644 --- a/general/echo/umdf2/driver/AutoSync/echo.vcxproj +++ b/general/echo/umdf2/driver/AutoSync/echo.vcxproj @@ -158,7 +158,7 @@ - + diff --git a/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj b/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj index 750422be..14a05def 100644 --- a/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj +++ b/general/echo/umdfSocketEcho/Driver/SocketEcho.vcxproj @@ -224,7 +224,7 @@ - + diff --git a/general/pcidrv/kmdf/HW/PCIDRV.vcxproj b/general/pcidrv/kmdf/HW/PCIDRV.vcxproj index fdf14d4d..763937ed 100644 --- a/general/pcidrv/kmdf/HW/PCIDRV.vcxproj +++ b/general/pcidrv/kmdf/HW/PCIDRV.vcxproj @@ -339,7 +339,7 @@ - + diff --git a/general/umdfSkeleton/UMDFSkeleton.vcxproj b/general/umdfSkeleton/UMDFSkeleton.vcxproj index 54fa7d0f..53f8195c 100644 --- a/general/umdfSkeleton/UMDFSkeleton.vcxproj +++ b/general/umdfSkeleton/UMDFSkeleton.vcxproj @@ -238,7 +238,7 @@ - + diff --git a/hid/firefly/driver/firefly.vcxproj b/hid/firefly/driver/firefly.vcxproj index 05c03248..227093f7 100644 --- a/hid/firefly/driver/firefly.vcxproj +++ b/hid/firefly/driver/firefly.vcxproj @@ -168,7 +168,7 @@ - + diff --git a/hid/hidusbfx2/sys/hidusbfx2.vcxproj b/hid/hidusbfx2/sys/hidusbfx2.vcxproj index 65cb0d6e..e6b49d5b 100644 --- a/hid/hidusbfx2/sys/hidusbfx2.vcxproj +++ b/hid/hidusbfx2/sys/hidusbfx2.vcxproj @@ -207,7 +207,7 @@ - + diff --git a/hid/vhidmini2/driver/kmdf/vhidmini.vcxproj b/hid/vhidmini2/driver/kmdf/vhidmini.vcxproj index 91db487f..5b21fbc4 100644 --- a/hid/vhidmini2/driver/kmdf/vhidmini.vcxproj +++ b/hid/vhidmini2/driver/kmdf/vhidmini.vcxproj @@ -158,7 +158,7 @@ - + diff --git a/hid/vhidmini2/driver/umdf2/VhidminiUm.vcxproj b/hid/vhidmini2/driver/umdf2/VhidminiUm.vcxproj index 654dc525..d6ae5219 100644 --- a/hid/vhidmini2/driver/umdf2/VhidminiUm.vcxproj +++ b/hid/vhidmini2/driver/umdf2/VhidminiUm.vcxproj @@ -186,7 +186,7 @@ - + diff --git a/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.vcxproj b/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.vcxproj index cb4351ad..9880f41f 100644 --- a/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.vcxproj +++ b/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.vcxproj @@ -204,7 +204,7 @@ - + diff --git a/pofx/WDF/Driver/MultiComp/driver/WdfMultiComp.vcxproj b/pofx/WDF/Driver/MultiComp/driver/WdfMultiComp.vcxproj index 9bee0e4a..757c4960 100644 --- a/pofx/WDF/Driver/MultiComp/driver/WdfMultiComp.vcxproj +++ b/pofx/WDF/Driver/MultiComp/driver/WdfMultiComp.vcxproj @@ -167,7 +167,7 @@ - + diff --git a/pofx/WDF/Driver/SingleComp/SingleComponentFStateDriver.vcxproj b/pofx/WDF/Driver/SingleComp/SingleComponentFStateDriver.vcxproj index c8992a26..2ce99fce 100644 --- a/pofx/WDF/Driver/SingleComp/SingleComponentFStateDriver.vcxproj +++ b/pofx/WDF/Driver/SingleComp/SingleComponentFStateDriver.vcxproj @@ -155,7 +155,7 @@ - + diff --git a/serial/VirtualSerial/ComPort/virtualserial.vcxproj b/serial/VirtualSerial/ComPort/virtualserial.vcxproj index 06ff48d6..4adeded9 100644 --- a/serial/VirtualSerial/ComPort/virtualserial.vcxproj +++ b/serial/VirtualSerial/ComPort/virtualserial.vcxproj @@ -235,7 +235,7 @@ - + diff --git a/serial/VirtualSerial/FakeModem/fakemodem.vcxproj b/serial/VirtualSerial/FakeModem/fakemodem.vcxproj index 9ab1fad8..fb0caada 100644 --- a/serial/VirtualSerial/FakeModem/fakemodem.vcxproj +++ b/serial/VirtualSerial/FakeModem/fakemodem.vcxproj @@ -235,7 +235,7 @@ - + diff --git a/serial/VirtualSerial2/ComPort/VirtualSerial2um.vcxproj b/serial/VirtualSerial2/ComPort/VirtualSerial2um.vcxproj index 9d739c58..e7331743 100644 --- a/serial/VirtualSerial2/ComPort/VirtualSerial2um.vcxproj +++ b/serial/VirtualSerial2/ComPort/VirtualSerial2um.vcxproj @@ -172,7 +172,7 @@ - + diff --git a/serial/VirtualSerial2/FakeModem/fakemodem2um.vcxproj b/serial/VirtualSerial2/FakeModem/fakemodem2um.vcxproj index 5adc985c..cb219183 100644 --- a/serial/VirtualSerial2/FakeModem/fakemodem2um.vcxproj +++ b/serial/VirtualSerial2/FakeModem/fakemodem2um.vcxproj @@ -172,7 +172,7 @@ - + diff --git a/serial/serial/wdfserial.vcxproj b/serial/serial/wdfserial.vcxproj index 4361e805..30db6172 100644 --- a/serial/serial/wdfserial.vcxproj +++ b/serial/serial/wdfserial.vcxproj @@ -368,7 +368,7 @@ - + diff --git a/simbatt/func/simbatt.vcxproj b/simbatt/func/simbatt.vcxproj new file mode 100644 index 00000000..3f0fd780 --- /dev/null +++ b/simbatt/func/simbatt.vcxproj @@ -0,0 +1,193 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {49F35704-9A04-4CCF-A290-BBE79906C901} + $(MSBuildProjectName) + 1 + Debug + Win32 + {0D5B7AF0-B4D6-4392-8A7A-BC502932382B} + + + + Windows10 + False + Universal + KMDF + WindowsKernelModeDriver10.0 + Driver + + + Windows10 + True + Universal + KMDF + WindowsKernelModeDriver10.0 + Driver + + + Windows10 + False + Universal + KMDF + WindowsKernelModeDriver10.0 + Driver + + + Windows10 + True + Universal + KMDF + WindowsKernelModeDriver10.0 + Driver + + + + $(IntDir) + + + + + + + + + + + + + + + + simbatt + + + simbatt + + + simbatt + + + simbatt + + + + true + Level4 + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalDependencies);$(DDK_LIB_PATH)\battc.lib + + + + + true + Level4 + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalDependencies);$(DDK_LIB_PATH)\battc.lib + + + + + true + Level4 + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalDependencies);$(DDK_LIB_PATH)\battc.lib + + + + + true + Level4 + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(PreprocessorDefinitions);DRIVER;DEBUGPRINT + %(AdditionalIncludeDirectories);..\..\inc + + + %(AdditionalDependencies);$(DDK_LIB_PATH)\battc.lib + + + + + + + + + + + + + + + + + + + + + diff --git a/simbatt/func/simbatt.vcxproj.Filters b/simbatt/func/simbatt.vcxproj.Filters new file mode 100644 index 00000000..d49b9ea2 --- /dev/null +++ b/simbatt/func/simbatt.vcxproj.Filters @@ -0,0 +1,34 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {63F140E0-F457-4EEA-8613-ED2B91AE7D9F} + + + h;hpp;hxx;hm;inl;inc;xsd + {FFA977A6-9EDF-47F0-B11A-FA7BC6343241} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {1FBAF52B-66F2-429F-9082-30FE16F9322D} + + + inf;inv;inx;mof;mc; + {E85B4F3F-86D3-48A8-8441-6CDF36ABDDDC} + + + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/storage/ramdisk/src/WdfRamdisk.vcxproj b/storage/ramdisk/src/WdfRamdisk.vcxproj index 10e35ae1..70a054f1 100644 --- a/storage/ramdisk/src/WdfRamdisk.vcxproj +++ b/storage/ramdisk/src/WdfRamdisk.vcxproj @@ -138,7 +138,7 @@ - + diff --git a/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj b/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj index 3230fc6e..e771d816 100644 --- a/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj +++ b/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj @@ -208,7 +208,7 @@
- + diff --git a/usb/ufxclientsample/ufxclientsample.vcxproj b/usb/ufxclientsample/ufxclientsample.vcxproj index 9d7a21ff..b304b4f6 100644 --- a/usb/ufxclientsample/ufxclientsample.vcxproj +++ b/usb/ufxclientsample/ufxclientsample.vcxproj @@ -199,7 +199,7 @@ - + diff --git a/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilter.vcxproj b/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilter.vcxproj index f12c647f..13921d4d 100644 --- a/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilter.vcxproj +++ b/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilter.vcxproj @@ -266,7 +266,7 @@ - + diff --git a/usb/umdf_filter_umdf/umdf_filter/WUDFOsrUsbFilter.vcxproj b/usb/umdf_filter_umdf/umdf_filter/WUDFOsrUsbFilter.vcxproj index f12c647f..13921d4d 100644 --- a/usb/umdf_filter_umdf/umdf_filter/WUDFOsrUsbFilter.vcxproj +++ b/usb/umdf_filter_umdf/umdf_filter/WUDFOsrUsbFilter.vcxproj @@ -266,7 +266,7 @@ - + diff --git a/usb/umdf_fx2/driver/WUDFOsrUsbFx2.vcxproj b/usb/umdf_fx2/driver/WUDFOsrUsbFx2.vcxproj index 18b66c7f..f0a96388 100644 --- a/usb/umdf_fx2/driver/WUDFOsrUsbFx2.vcxproj +++ b/usb/umdf_fx2/driver/WUDFOsrUsbFx2.vcxproj @@ -254,7 +254,7 @@ - + diff --git a/usb/usbsamp/sys/driver/usbsamp.vcxproj b/usb/usbsamp/sys/driver/usbsamp.vcxproj index ae4b4a66..7a9dec32 100644 --- a/usb/usbsamp/sys/driver/usbsamp.vcxproj +++ b/usb/usbsamp/sys/driver/usbsamp.vcxproj @@ -182,7 +182,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/kmdf/step1/osrusbfx2.vcxproj b/usb/wdf_osrfx2_lab/kmdf/step1/osrusbfx2.vcxproj index 1ec8c281..43a6ba8c 100644 --- a/usb/wdf_osrfx2_lab/kmdf/step1/osrusbfx2.vcxproj +++ b/usb/wdf_osrfx2_lab/kmdf/step1/osrusbfx2.vcxproj @@ -152,7 +152,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/kmdf/step2/osrusbfx2.vcxproj b/usb/wdf_osrfx2_lab/kmdf/step2/osrusbfx2.vcxproj index 5a1b9666..281bba9c 100644 --- a/usb/wdf_osrfx2_lab/kmdf/step2/osrusbfx2.vcxproj +++ b/usb/wdf_osrfx2_lab/kmdf/step2/osrusbfx2.vcxproj @@ -152,7 +152,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/kmdf/step3/osrusbfx2.vcxproj b/usb/wdf_osrfx2_lab/kmdf/step3/osrusbfx2.vcxproj index 569cda97..312b81da 100644 --- a/usb/wdf_osrfx2_lab/kmdf/step3/osrusbfx2.vcxproj +++ b/usb/wdf_osrfx2_lab/kmdf/step3/osrusbfx2.vcxproj @@ -152,7 +152,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/kmdf/step4/osrusbfx2.vcxproj b/usb/wdf_osrfx2_lab/kmdf/step4/osrusbfx2.vcxproj index 13904fea..f4605118 100644 --- a/usb/wdf_osrfx2_lab/kmdf/step4/osrusbfx2.vcxproj +++ b/usb/wdf_osrfx2_lab/kmdf/step4/osrusbfx2.vcxproj @@ -152,7 +152,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/kmdf/step5/osrusbfx2.vcxproj b/usb/wdf_osrfx2_lab/kmdf/step5/osrusbfx2.vcxproj index 38f8d8e4..157cb7c8 100644 --- a/usb/wdf_osrfx2_lab/kmdf/step5/osrusbfx2.vcxproj +++ b/usb/wdf_osrfx2_lab/kmdf/step5/osrusbfx2.vcxproj @@ -169,7 +169,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj b/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj index aef4ae60..be860e25 100644 --- a/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj +++ b/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj @@ -252,7 +252,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj b/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj index ee7c654f..833776a8 100644 --- a/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj +++ b/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj @@ -252,7 +252,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj b/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj index 25e7b78b..9e8b452a 100644 --- a/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj +++ b/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj @@ -252,7 +252,7 @@ - + diff --git a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj b/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj index 725e33b5..56247b8e 100644 --- a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj +++ b/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj @@ -252,7 +252,7 @@ - + diff --git a/wmi/wmisamp/WmiSamp.vcxproj b/wmi/wmisamp/WmiSamp.vcxproj index 70763334..42cfda79 100644 --- a/wmi/wmisamp/WmiSamp.vcxproj +++ b/wmi/wmisamp/WmiSamp.vcxproj @@ -131,7 +131,7 @@ - + -- cgit v1.3.1 From 2512ace1807d52d8039a5e529ac77020cbc8f363 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Thu, 17 Aug 2017 17:53:31 -0700 Subject: Fix more instances of: error 1209: Section [destinationdirs] is defined multiple times --- bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.inx | Bin 6024 -> 5944 bytes bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.inx | Bin 6038 -> 5958 bytes general/echo/kmdf/driver/AutoSync/echo.inx | Bin 4942 -> 4842 bytes general/echo/kmdf/driver/DriverSync/echo_2.inx | Bin 5088 -> 4998 bytes general/echo/umdf2/driver/AutoSync/echoum.inx | Bin 3962 -> 3924 bytes general/echo/umdfSocketEcho/Driver/SocketEcho.inx | Bin 4234 -> 4280 bytes general/pcidrv/kmdf/genpci.inx | Bin 7284 -> 7198 bytes hid/firefly/driver/firefly.inx | Bin 7336 -> 7250 bytes hid/hidusbfx2/sys/hidusbfx2.inx | Bin 12300 -> 12214 bytes .../SingleComp/SingleComponentSingleStateUm.inx | Bin 4510 -> 4472 bytes .../SingleComp/SingleComponentFStateSample.inx | Bin 6302 -> 6220 bytes serial/serial/serial.inx | Bin 6294 -> 6212 bytes storage/ramdisk/src/ramdisk.inx | Bin 5460 -> 5378 bytes usb/kmdf_enumswitches/sys/kmdf_enumswitches.inx | Bin 6066 -> 5984 bytes .../umdf_filter/WUDFOsrUsbFilterOnKmDriver.inx | Bin 6616 -> 6574 bytes usb/usbsamp/sys/driver/usbsamp.inx | Bin 6530 -> 6444 bytes usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx | Bin 5940 -> 5920 bytes usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx | Bin 5940 -> 5920 bytes usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx | Bin 5940 -> 5920 bytes usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx | Bin 5940 -> 5920 bytes wmi/wmisamp/wmisamp.inx | Bin 6098 -> 6012 bytes 21 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.inx b/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.inx index 3c8332e9..16c1ef51 100644 Binary files a/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.inx and b/bluetooth/bthecho/bthcli/sys/BthEchoSampleCli.inx differ diff --git a/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.inx b/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.inx index 8518d776..efb08654 100644 Binary files a/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.inx and b/bluetooth/bthecho/bthsrv/sys/BthEchoSampleSrv.inx differ diff --git a/general/echo/kmdf/driver/AutoSync/echo.inx b/general/echo/kmdf/driver/AutoSync/echo.inx index d22c8806..bfb3b356 100644 Binary files a/general/echo/kmdf/driver/AutoSync/echo.inx and b/general/echo/kmdf/driver/AutoSync/echo.inx differ diff --git a/general/echo/kmdf/driver/DriverSync/echo_2.inx b/general/echo/kmdf/driver/DriverSync/echo_2.inx index 235d12c0..ea524f85 100644 Binary files a/general/echo/kmdf/driver/DriverSync/echo_2.inx and b/general/echo/kmdf/driver/DriverSync/echo_2.inx differ diff --git a/general/echo/umdf2/driver/AutoSync/echoum.inx b/general/echo/umdf2/driver/AutoSync/echoum.inx index 4e3cd6b3..cae8b45f 100644 Binary files a/general/echo/umdf2/driver/AutoSync/echoum.inx and b/general/echo/umdf2/driver/AutoSync/echoum.inx differ diff --git a/general/echo/umdfSocketEcho/Driver/SocketEcho.inx b/general/echo/umdfSocketEcho/Driver/SocketEcho.inx index b80dee9a..b660186b 100644 Binary files a/general/echo/umdfSocketEcho/Driver/SocketEcho.inx and b/general/echo/umdfSocketEcho/Driver/SocketEcho.inx differ diff --git a/general/pcidrv/kmdf/genpci.inx b/general/pcidrv/kmdf/genpci.inx index b278dcd8..1ccf8ca9 100644 Binary files a/general/pcidrv/kmdf/genpci.inx and b/general/pcidrv/kmdf/genpci.inx differ diff --git a/hid/firefly/driver/firefly.inx b/hid/firefly/driver/firefly.inx index fb03d695..38479b3d 100644 Binary files a/hid/firefly/driver/firefly.inx and b/hid/firefly/driver/firefly.inx differ diff --git a/hid/hidusbfx2/sys/hidusbfx2.inx b/hid/hidusbfx2/sys/hidusbfx2.inx index e8c28f32..43a55fb0 100644 Binary files a/hid/hidusbfx2/sys/hidusbfx2.inx and b/hid/hidusbfx2/sys/hidusbfx2.inx differ diff --git a/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.inx b/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.inx index 09ce986d..7eab5b70 100644 Binary files a/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.inx and b/pofx/UMDF2/Driver/SingleComp/SingleComponentSingleStateUm.inx differ diff --git a/pofx/WDF/Driver/SingleComp/SingleComponentFStateSample.inx b/pofx/WDF/Driver/SingleComp/SingleComponentFStateSample.inx index e0400f52..2a15c660 100644 Binary files a/pofx/WDF/Driver/SingleComp/SingleComponentFStateSample.inx and b/pofx/WDF/Driver/SingleComp/SingleComponentFStateSample.inx differ diff --git a/serial/serial/serial.inx b/serial/serial/serial.inx index 21cae30e..3322653b 100644 Binary files a/serial/serial/serial.inx and b/serial/serial/serial.inx differ diff --git a/storage/ramdisk/src/ramdisk.inx b/storage/ramdisk/src/ramdisk.inx index cf48a217..b3de10f9 100644 Binary files a/storage/ramdisk/src/ramdisk.inx and b/storage/ramdisk/src/ramdisk.inx differ diff --git a/usb/kmdf_enumswitches/sys/kmdf_enumswitches.inx b/usb/kmdf_enumswitches/sys/kmdf_enumswitches.inx index 52017d13..7336000f 100644 Binary files a/usb/kmdf_enumswitches/sys/kmdf_enumswitches.inx and b/usb/kmdf_enumswitches/sys/kmdf_enumswitches.inx differ diff --git a/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilterOnKmDriver.inx b/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilterOnKmDriver.inx index a267e119..6153e18b 100644 Binary files a/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilterOnKmDriver.inx and b/usb/umdf_filter_kmdf/umdf_filter/WUDFOsrUsbFilterOnKmDriver.inx differ diff --git a/usb/usbsamp/sys/driver/usbsamp.inx b/usb/usbsamp/sys/driver/usbsamp.inx index 4dc3fad2..5b16de78 100644 Binary files a/usb/usbsamp/sys/driver/usbsamp.inx and b/usb/usbsamp/sys/driver/usbsamp.inx differ diff --git a/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx b/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx index dea03ff6..69f0c0c4 100644 Binary files a/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx and b/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx differ diff --git a/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx b/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx index 17baa44d..98d8c453 100644 Binary files a/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx and b/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx differ diff --git a/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx b/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx index 729c6aef..c4846f6e 100644 Binary files a/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx and b/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx differ diff --git a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx b/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx index 3eaae162..215e5f98 100644 Binary files a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx and b/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx differ diff --git a/wmi/wmisamp/wmisamp.inx b/wmi/wmisamp/wmisamp.inx index be89d405..72916d73 100644 Binary files a/wmi/wmisamp/wmisamp.inx and b/wmi/wmisamp/wmisamp.inx differ -- cgit v1.3.1 From 094cc5792d5e7f2f7fe11c9731fac1e98cb7049b Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Fri, 18 Aug 2017 11:34:13 -0700 Subject: Add missing simbatt.sln --- simbatt/func/simbatt.sln | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 simbatt/func/simbatt.sln diff --git a/simbatt/func/simbatt.sln b/simbatt/func/simbatt.sln new file mode 100644 index 00000000..3935e76a --- /dev/null +++ b/simbatt/func/simbatt.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0 +MinimumVisualStudioVersion = 12.0 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simbatt", "simbatt.vcxproj", "{49F35704-9A04-4CCF-A290-BBE79906C901}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {49F35704-9A04-4CCF-A290-BBE79906C901}.Debug|Win32.ActiveCfg = Debug|Win32 + {49F35704-9A04-4CCF-A290-BBE79906C901}.Debug|Win32.Build.0 = Debug|Win32 + {49F35704-9A04-4CCF-A290-BBE79906C901}.Release|Win32.ActiveCfg = Release|Win32 + {49F35704-9A04-4CCF-A290-BBE79906C901}.Release|Win32.Build.0 = Release|Win32 + {49F35704-9A04-4CCF-A290-BBE79906C901}.Debug|x64.ActiveCfg = Debug|x64 + {49F35704-9A04-4CCF-A290-BBE79906C901}.Debug|x64.Build.0 = Debug|x64 + {49F35704-9A04-4CCF-A290-BBE79906C901}.Release|x64.ActiveCfg = Release|x64 + {49F35704-9A04-4CCF-A290-BBE79906C901}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal -- cgit v1.3.1 From f0fbfbdba856bb905a6466d47bd760cf8622ec0f Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Fri, 18 Aug 2017 12:11:30 -0700 Subject: Fix another typo in WFPSamplerCalloutDriver.inx --- network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX b/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX index 7ad880cd..5fe96e36 100644 --- a/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX +++ b/network/trans/WFPSampler/sys/WFPSamplerCalloutDriver.InX @@ -48,7 +48,7 @@ [DefaultUninstall.nt$ARCH$] DelFiles = WFPSamplerCalloutDriver.DriverFiles - DelReg = WFPCalloutsClassReg + DelReg = WFPCalloutClassReg [DefaultUninstall.nt$ARCH$.Services] DelService = %WFPSamplerCalloutDriverServiceName%,0x200 ;/// SPSVCINST_STOPSERVICE -- cgit v1.3.1 From 8a305a42a31c99ffa586c4118692a5bf5c9d22ef Mon Sep 17 00:00:00 2001 From: Mike Fenelon Date: Fri, 18 Aug 2017 15:03:15 -0700 Subject: Update all currnet Print Samples to support VS2017 and Windows 10 --- .../BlankProjSrc/BlankProject.vcxproj | 54 + print/SampleOpenXPS/SampleOpenXPS.sln | 16 +- print/SampleXPS/BlankProjSrc/BlankProject.vcxproj | 54 + print/SampleXPS/SampleXPS.sln | 16 +- .../SimplePipelineFilter/SimplePipelineFilter.sln | 16 +- .../SimplePipelineFilter/WdkPipelineFilter.vcxproj | 114 ++ .../WdkPipelineFilter.vcxproj.Filters | 58 +- print/XPSDrvSmpl/Package/package.VcxProj | 16 + print/XPSDrvSmpl/XPSDrvSmpl.sln | 120 +- print/XPSDrvSmpl/install/xdsmpl.inf | 13 +- print/XPSDrvSmpl/src/common/pshndlr.cpp | 4 +- print/XPSDrvSmpl/src/common/ptquerybld.cpp | 12 +- print/XPSDrvSmpl/src/common/wmpthndlr.cpp | 4 +- print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj | 90 + .../src/common/xdsmplcmn.vcxproj.Filters | 2026 ++++++++++++++++++++ .../XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj | 118 ++ .../src/filters/booklet/xdbook.vcxproj.Filters | 25 +- .../XPSDrvSmpl/src/filters/color/XDColMan.vcxproj | 120 ++ .../src/filters/color/XDColMan.vcxproj.Filters | 234 ++- print/XPSDrvSmpl/src/filters/color/cmimg.cpp | 2 +- print/XPSDrvSmpl/src/filters/color/dictionary.cpp | 2 +- print/XPSDrvSmpl/src/filters/color/profman.cpp | 2 +- print/XPSDrvSmpl/src/filters/common/ptmanage.cpp | 2 +- .../XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj | 118 ++ .../src/filters/common/xdfltcmn.vcxproj.Filters | 101 + print/XPSDrvSmpl/src/filters/nup/nupsax.cpp | 4 +- print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj | 118 ++ .../src/filters/nup/xdnup.vcxproj.Filters | 45 +- print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp | 2 +- .../XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj | 126 ++ .../src/filters/scaling/xdscale.vcxproj.Filters | 34 +- print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp | 2 +- .../src/filters/watermark/xdwmark.vcxproj | 118 ++ .../src/filters/watermark/xdwmark.vcxproj.Filters | 156 +- print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj | 96 + .../src/filters/xdcont/xdcont.vcxproj.Filters | 101 + print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj | 108 ++ print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj.Filters | 493 ++++- print/XpsRasFilter/XpsRasFilter.sln | 16 +- print/XpsRasFilter/install/xpsrassmpl.inf | 13 +- print/XpsRasFilter/src/precomp.h | 1 + print/XpsRasFilter/src/xpsrasfilter.vcxproj | 106 + .../XpsRasFilter/src/xpsrasfilter.vcxproj.Filters | 130 +- print/autoconfig/AutoCnfg.inf | 5 +- print/autoconfig/AutoConfig.sln | 30 +- print/autoconfig/AutoConfig.vcxproj | 48 + print/autoconfig/AutoConfig.vcxproj.Filters | 12 + print/autoconfig/Package/package.VcxProj | 16 + print/autoconfig/README.md | 2 +- print/cpsuisam/cpsuisam.sln | 16 +- print/cpsuisam/cpsuisam.vcxproj | 98 + print/cpsuisam/cpsuisam.vcxproj.Filters | 34 + .../ExtensionSample/PrinterExtensionSample.csproj | 66 + .../PrinterExtensionLibrary.csproj | 18 + .../PrinterExtensionSample.sln | 40 + .../ConstraintScript.sln | 6 + .../ConstraintScript.vcxproj | 48 + .../HostBasedSampleDriver.sln | 10 + .../HostBasedSampleDriver.vcxproj | 54 +- .../Package/package.VcxProj | 16 + .../USBMon-Bidi-Extension.sln | 6 + .../USBMon-Bidi-Extension.vcxproj | 48 + .../WSDMon-Bidi-Extension.sln | 6 + .../WSDMon-Bidi-Extension.vcxproj | 48 + 64 files changed, 5512 insertions(+), 121 deletions(-) diff --git a/print/SampleOpenXPS/BlankProjSrc/BlankProject.vcxproj b/print/SampleOpenXPS/BlankProjSrc/BlankProject.vcxproj index a1944404..f59d1592 100644 --- a/print/SampleOpenXPS/BlankProjSrc/BlankProject.vcxproj +++ b/print/SampleOpenXPS/BlankProjSrc/BlankProject.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -35,6 +43,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary
+ + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -43,6 +59,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -66,9 +90,15 @@ + + + + + + @@ -79,9 +109,15 @@ BlankProject + + BlankProject + BlankProject + + BlankProject + BlankProject @@ -97,6 +133,15 @@ true + + + + + + + true + + @@ -106,6 +151,15 @@ true + + + + + + + true + + diff --git a/print/SampleOpenXPS/SampleOpenXPS.sln b/print/SampleOpenXPS/SampleOpenXPS.sln index bf6c23a2..d532a21b 100644 --- a/print/SampleOpenXPS/SampleOpenXPS.sln +++ b/print/SampleOpenXPS/SampleOpenXPS.sln @@ -1,24 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 12.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlankProject", "BlankProjSrc\BlankProject.vcxproj", "{3B7F3284-4571-493B-87DF-0DCEB924EDED}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Debug|ARM64.Build.0 = Debug|ARM64 {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Debug|Win32.ActiveCfg = Debug|Win32 {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Debug|Win32.Build.0 = Debug|Win32 - {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|Win32.ActiveCfg = Release|Win32 - {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|Win32.Build.0 = Release|Win32 {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Debug|x64.ActiveCfg = Debug|x64 {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Debug|x64.Build.0 = Debug|x64 + {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|ARM64.ActiveCfg = Release|ARM64 + {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|ARM64.Build.0 = Release|ARM64 + {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|Win32.ActiveCfg = Release|Win32 + {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|Win32.Build.0 = Release|Win32 {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|x64.ActiveCfg = Release|x64 {3B7F3284-4571-493B-87DF-0DCEB924EDED}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/print/SampleXPS/BlankProjSrc/BlankProject.vcxproj b/print/SampleXPS/BlankProjSrc/BlankProject.vcxproj index c151252b..35a097ad 100644 --- a/print/SampleXPS/BlankProjSrc/BlankProject.vcxproj +++ b/print/SampleXPS/BlankProjSrc/BlankProject.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -35,6 +43,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -43,6 +59,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -66,9 +90,15 @@ + + + + + + @@ -79,9 +109,15 @@ BlankProject + + BlankProject + BlankProject + + BlankProject + BlankProject @@ -97,6 +133,15 @@ true + + + + + + + true + + @@ -106,6 +151,15 @@ true + + + + + + + true + + diff --git a/print/SampleXPS/SampleXPS.sln b/print/SampleXPS/SampleXPS.sln index bff99c63..52802ac5 100644 --- a/print/SampleXPS/SampleXPS.sln +++ b/print/SampleXPS/SampleXPS.sln @@ -1,24 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 12.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlankProject", "BlankProjSrc\BlankProject.vcxproj", "{58038762-96ED-45A6-A3FF-C5898C7D1618}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {58038762-96ED-45A6-A3FF-C5898C7D1618}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {58038762-96ED-45A6-A3FF-C5898C7D1618}.Debug|ARM64.Build.0 = Debug|ARM64 {58038762-96ED-45A6-A3FF-C5898C7D1618}.Debug|Win32.ActiveCfg = Debug|Win32 {58038762-96ED-45A6-A3FF-C5898C7D1618}.Debug|Win32.Build.0 = Debug|Win32 - {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|Win32.ActiveCfg = Release|Win32 - {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|Win32.Build.0 = Release|Win32 {58038762-96ED-45A6-A3FF-C5898C7D1618}.Debug|x64.ActiveCfg = Debug|x64 {58038762-96ED-45A6-A3FF-C5898C7D1618}.Debug|x64.Build.0 = Debug|x64 + {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|ARM64.ActiveCfg = Release|ARM64 + {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|ARM64.Build.0 = Release|ARM64 + {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|Win32.ActiveCfg = Release|Win32 + {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|Win32.Build.0 = Release|Win32 {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|x64.ActiveCfg = Release|x64 {58038762-96ED-45A6-A3FF-C5898C7D1618}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/print/SimplePipelineFilter/SimplePipelineFilter.sln b/print/SimplePipelineFilter/SimplePipelineFilter.sln index b7c29a27..fb7b4926 100644 --- a/print/SimplePipelineFilter/SimplePipelineFilter.sln +++ b/print/SimplePipelineFilter/SimplePipelineFilter.sln @@ -1,24 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 12.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WdkPipelineFilter", "WdkPipelineFilter.vcxproj", "{80A8ADEB-D954-428E-8809-7308A4F007EF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {80A8ADEB-D954-428E-8809-7308A4F007EF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {80A8ADEB-D954-428E-8809-7308A4F007EF}.Debug|ARM64.Build.0 = Debug|ARM64 {80A8ADEB-D954-428E-8809-7308A4F007EF}.Debug|Win32.ActiveCfg = Debug|Win32 {80A8ADEB-D954-428E-8809-7308A4F007EF}.Debug|Win32.Build.0 = Debug|Win32 - {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|Win32.ActiveCfg = Release|Win32 - {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|Win32.Build.0 = Release|Win32 {80A8ADEB-D954-428E-8809-7308A4F007EF}.Debug|x64.ActiveCfg = Debug|x64 {80A8ADEB-D954-428E-8809-7308A4F007EF}.Debug|x64.Build.0 = Debug|x64 + {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|ARM64.ActiveCfg = Release|ARM64 + {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|ARM64.Build.0 = Release|ARM64 + {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|Win32.ActiveCfg = Release|Win32 + {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|Win32.Build.0 = Release|Win32 {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|x64.ActiveCfg = Release|x64 {80A8ADEB-D954-428E-8809-7308A4F007EF}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj b/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj index dbbd36cb..cfbb05f1 100644 --- a/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj +++ b/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -34,6 +42,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -42,6 +58,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -65,9 +89,15 @@ + + + + + + @@ -103,9 +133,15 @@ WdkPipelineFilter + + WdkPipelineFilter + WdkPipelineFilter + + WdkPipelineFilter + WdkPipelineFilter @@ -117,11 +153,21 @@ %(AdditionalDependencies);user32.lib;kernel32.lib;oleaut32.lib;ole32.lib;uuid.lib;advapi32.lib + + + %(AdditionalDependencies);user32.lib;kernel32.lib;oleaut32.lib;ole32.lib;uuid.lib;advapi32.lib + + %(AdditionalDependencies);user32.lib;kernel32.lib;oleaut32.lib;ole32.lib;uuid.lib;advapi32.lib + + + %(AdditionalDependencies);user32.lib;kernel32.lib;oleaut32.lib;ole32.lib;uuid.lib;advapi32.lib + + %(AdditionalDependencies);user32.lib;kernel32.lib;oleaut32.lib;ole32.lib;uuid.lib;advapi32.lib @@ -138,12 +184,24 @@ _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -174,6 +232,24 @@ %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + MultiThreaded + MultiThreadedDebug + true + Level4 + %(PreprocessorDefinitions);_UNICODE;UNICODE + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + MultiThreaded @@ -192,6 +268,24 @@ %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + MultiThreaded + MultiThreadedDebug + true + Level4 + %(PreprocessorDefinitions);_UNICODE;UNICODE + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + MultiThreaded @@ -238,6 +332,16 @@ + + + %(AdditionalOptions) /ignore:4070 + FilterSample.def + + + + + + %(AdditionalOptions) /ignore:4070 @@ -248,6 +352,16 @@ + + + %(AdditionalOptions) /ignore:4070 + FilterSample.def + + + + + + %(AdditionalOptions) /ignore:4070 diff --git a/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj.Filters b/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj.Filters index 60366d81..278a2bc6 100644 --- a/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj.Filters +++ b/print/SimplePipelineFilter/WdkPipelineFilter.vcxproj.Filters @@ -27,13 +27,65 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + + + Source Files + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/Package/package.VcxProj b/print/XPSDrvSmpl/Package/package.VcxProj index 697ef9af..228c7db4 100644 --- a/print/XPSDrvSmpl/Package/package.VcxProj +++ b/print/XPSDrvSmpl/Package/package.VcxProj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -75,10 +83,18 @@ Windows10 true + + Windows10 + true + Windows10 false + + Windows10 + false + diff --git a/print/XPSDrvSmpl/XPSDrvSmpl.sln b/print/XPSDrvSmpl/XPSDrvSmpl.sln index 03628549..600e4e74 100644 --- a/print/XPSDrvSmpl/XPSDrvSmpl.sln +++ b/print/XPSDrvSmpl/XPSDrvSmpl.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 12.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{5A68CA37-F621-4113-B573-8A361135203B}" EndProject @@ -92,98 +92,146 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xdbook", "src\filters\bookl EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Debug|ARM64.Build.0 = Debug|ARM64 + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Debug|ARM64.Deploy.0 = Debug|ARM64 {4A7303D2-92DB-4537-A380-24D334FC24FE}.Debug|Win32.ActiveCfg = Debug|Win32 {4A7303D2-92DB-4537-A380-24D334FC24FE}.Debug|Win32.Build.0 = Debug|Win32 - {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|Win32.ActiveCfg = Release|Win32 - {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|Win32.Build.0 = Release|Win32 {4A7303D2-92DB-4537-A380-24D334FC24FE}.Debug|x64.ActiveCfg = Debug|x64 {4A7303D2-92DB-4537-A380-24D334FC24FE}.Debug|x64.Build.0 = Debug|x64 + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|ARM64.ActiveCfg = Release|ARM64 + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|ARM64.Build.0 = Release|ARM64 + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|ARM64.Deploy.0 = Release|ARM64 + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|Win32.ActiveCfg = Release|Win32 + {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|Win32.Build.0 = Release|Win32 {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|x64.ActiveCfg = Release|x64 {4A7303D2-92DB-4537-A380-24D334FC24FE}.Release|x64.Build.0 = Release|x64 + {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Debug|ARM64.Build.0 = Debug|ARM64 {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Debug|Win32.ActiveCfg = Debug|Win32 {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Debug|Win32.Build.0 = Debug|Win32 - {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|Win32.ActiveCfg = Release|Win32 - {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|Win32.Build.0 = Release|Win32 {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Debug|x64.ActiveCfg = Debug|x64 {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Debug|x64.Build.0 = Debug|x64 + {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|ARM64.ActiveCfg = Release|ARM64 + {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|ARM64.Build.0 = Release|ARM64 + {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|Win32.ActiveCfg = Release|Win32 + {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|Win32.Build.0 = Release|Win32 {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|x64.ActiveCfg = Release|x64 {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98}.Release|x64.Build.0 = Release|x64 + {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Debug|ARM64.Build.0 = Debug|ARM64 {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Debug|Win32.ActiveCfg = Debug|Win32 {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Debug|Win32.Build.0 = Debug|Win32 - {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|Win32.ActiveCfg = Release|Win32 - {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|Win32.Build.0 = Release|Win32 {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Debug|x64.ActiveCfg = Debug|x64 {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Debug|x64.Build.0 = Debug|x64 + {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|ARM64.ActiveCfg = Release|ARM64 + {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|ARM64.Build.0 = Release|ARM64 + {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|Win32.ActiveCfg = Release|Win32 + {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|Win32.Build.0 = Release|Win32 {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|x64.ActiveCfg = Release|x64 {42677515-C196-4C0F-99A2-F11E2FB55BF6}.Release|x64.Build.0 = Release|x64 + {7441D7F2-F509-4A47-9404-3EB8653AE037}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {7441D7F2-F509-4A47-9404-3EB8653AE037}.Debug|ARM64.Build.0 = Debug|ARM64 {7441D7F2-F509-4A47-9404-3EB8653AE037}.Debug|Win32.ActiveCfg = Debug|Win32 {7441D7F2-F509-4A47-9404-3EB8653AE037}.Debug|Win32.Build.0 = Debug|Win32 - {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|Win32.ActiveCfg = Release|Win32 - {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|Win32.Build.0 = Release|Win32 {7441D7F2-F509-4A47-9404-3EB8653AE037}.Debug|x64.ActiveCfg = Debug|x64 {7441D7F2-F509-4A47-9404-3EB8653AE037}.Debug|x64.Build.0 = Debug|x64 + {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|ARM64.ActiveCfg = Release|ARM64 + {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|ARM64.Build.0 = Release|ARM64 + {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|Win32.ActiveCfg = Release|Win32 + {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|Win32.Build.0 = Release|Win32 {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|x64.ActiveCfg = Release|x64 {7441D7F2-F509-4A47-9404-3EB8653AE037}.Release|x64.Build.0 = Release|x64 + {0F8262C1-75D8-4A92-BCB6-37A290891708}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0F8262C1-75D8-4A92-BCB6-37A290891708}.Debug|ARM64.Build.0 = Debug|ARM64 {0F8262C1-75D8-4A92-BCB6-37A290891708}.Debug|Win32.ActiveCfg = Debug|Win32 {0F8262C1-75D8-4A92-BCB6-37A290891708}.Debug|Win32.Build.0 = Debug|Win32 - {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|Win32.ActiveCfg = Release|Win32 - {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|Win32.Build.0 = Release|Win32 {0F8262C1-75D8-4A92-BCB6-37A290891708}.Debug|x64.ActiveCfg = Debug|x64 {0F8262C1-75D8-4A92-BCB6-37A290891708}.Debug|x64.Build.0 = Debug|x64 + {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|ARM64.ActiveCfg = Release|ARM64 + {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|ARM64.Build.0 = Release|ARM64 + {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|Win32.ActiveCfg = Release|Win32 + {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|Win32.Build.0 = Release|Win32 {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|x64.ActiveCfg = Release|x64 {0F8262C1-75D8-4A92-BCB6-37A290891708}.Release|x64.Build.0 = Release|x64 + {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Debug|ARM64.Build.0 = Debug|ARM64 {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Debug|Win32.ActiveCfg = Debug|Win32 {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Debug|Win32.Build.0 = Debug|Win32 - {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|Win32.ActiveCfg = Release|Win32 - {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|Win32.Build.0 = Release|Win32 {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Debug|x64.ActiveCfg = Debug|x64 {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Debug|x64.Build.0 = Debug|x64 + {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|ARM64.ActiveCfg = Release|ARM64 + {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|ARM64.Build.0 = Release|ARM64 + {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|Win32.ActiveCfg = Release|Win32 + {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|Win32.Build.0 = Release|Win32 {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|x64.ActiveCfg = Release|x64 {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A}.Release|x64.Build.0 = Release|x64 + {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Debug|ARM64.Build.0 = Debug|ARM64 {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Debug|Win32.ActiveCfg = Debug|Win32 {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Debug|Win32.Build.0 = Debug|Win32 - {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|Win32.ActiveCfg = Release|Win32 - {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|Win32.Build.0 = Release|Win32 {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Debug|x64.ActiveCfg = Debug|x64 {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Debug|x64.Build.0 = Debug|x64 + {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|ARM64.ActiveCfg = Release|ARM64 + {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|ARM64.Build.0 = Release|ARM64 + {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|Win32.ActiveCfg = Release|Win32 + {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|Win32.Build.0 = Release|Win32 {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|x64.ActiveCfg = Release|x64 {E31D1C4F-8E0D-428A-8583-5159CE690B33}.Release|x64.Build.0 = Release|x64 + {1893FA97-40A9-480F-BB77-279F959EAE6E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1893FA97-40A9-480F-BB77-279F959EAE6E}.Debug|ARM64.Build.0 = Debug|ARM64 {1893FA97-40A9-480F-BB77-279F959EAE6E}.Debug|Win32.ActiveCfg = Debug|Win32 {1893FA97-40A9-480F-BB77-279F959EAE6E}.Debug|Win32.Build.0 = Debug|Win32 - {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|Win32.ActiveCfg = Release|Win32 - {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|Win32.Build.0 = Release|Win32 {1893FA97-40A9-480F-BB77-279F959EAE6E}.Debug|x64.ActiveCfg = Debug|x64 {1893FA97-40A9-480F-BB77-279F959EAE6E}.Debug|x64.Build.0 = Debug|x64 + {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|ARM64.ActiveCfg = Release|ARM64 + {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|ARM64.Build.0 = Release|ARM64 + {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|Win32.ActiveCfg = Release|Win32 + {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|Win32.Build.0 = Release|Win32 {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|x64.ActiveCfg = Release|x64 {1893FA97-40A9-480F-BB77-279F959EAE6E}.Release|x64.Build.0 = Release|x64 + {23BA577F-B171-4CEC-92E0-49EE44564366}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {23BA577F-B171-4CEC-92E0-49EE44564366}.Debug|ARM64.Build.0 = Debug|ARM64 {23BA577F-B171-4CEC-92E0-49EE44564366}.Debug|Win32.ActiveCfg = Debug|Win32 {23BA577F-B171-4CEC-92E0-49EE44564366}.Debug|Win32.Build.0 = Debug|Win32 - {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|Win32.ActiveCfg = Release|Win32 - {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|Win32.Build.0 = Release|Win32 {23BA577F-B171-4CEC-92E0-49EE44564366}.Debug|x64.ActiveCfg = Debug|x64 {23BA577F-B171-4CEC-92E0-49EE44564366}.Debug|x64.Build.0 = Debug|x64 + {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|ARM64.ActiveCfg = Release|ARM64 + {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|ARM64.Build.0 = Release|ARM64 + {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|Win32.ActiveCfg = Release|Win32 + {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|Win32.Build.0 = Release|Win32 {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|x64.ActiveCfg = Release|x64 {23BA577F-B171-4CEC-92E0-49EE44564366}.Release|x64.Build.0 = Release|x64 + {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Debug|ARM64.Build.0 = Debug|ARM64 {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Debug|Win32.ActiveCfg = Debug|Win32 {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Debug|Win32.Build.0 = Debug|Win32 - {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|Win32.ActiveCfg = Release|Win32 - {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|Win32.Build.0 = Release|Win32 {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Debug|x64.ActiveCfg = Debug|x64 {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Debug|x64.Build.0 = Debug|x64 + {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|ARM64.ActiveCfg = Release|ARM64 + {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|ARM64.Build.0 = Release|ARM64 + {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|Win32.ActiveCfg = Release|Win32 + {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|Win32.Build.0 = Release|Win32 {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|x64.ActiveCfg = Release|x64 {C9C14C99-103E-45CB-B1B4-2C165429E35C}.Release|x64.Build.0 = Release|x64 + {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Debug|ARM64.Build.0 = Debug|ARM64 {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Debug|Win32.ActiveCfg = Debug|Win32 {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Debug|Win32.Build.0 = Debug|Win32 - {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|Win32.ActiveCfg = Release|Win32 - {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|Win32.Build.0 = Release|Win32 {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Debug|x64.ActiveCfg = Debug|x64 {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Debug|x64.Build.0 = Debug|x64 + {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|ARM64.ActiveCfg = Release|ARM64 + {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|ARM64.Build.0 = Release|ARM64 + {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|Win32.ActiveCfg = Release|Win32 + {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|Win32.Build.0 = Release|Win32 {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|x64.ActiveCfg = Release|x64 {8D542B56-EB45-43B1-AAB8-417352F5BDE6}.Release|x64.Build.0 = Release|x64 EndGlobalSection @@ -191,17 +239,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {4A7303D2-92DB-4537-A380-24D334FC24FE} = {5A68CA37-F621-4113-B573-8A361135203B} - {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98} = {3F637C27-BDFE-4466-838C-5FBDE4C5F2C1} - {42677515-C196-4C0F-99A2-F11E2FB55BF6} = {A51E3BEB-5868-445C-8F87-AC7D05C4EE2D} - {7441D7F2-F509-4A47-9404-3EB8653AE037} = {8D891397-002B-4AF1-929E-0515D8F2F5AB} - {0F8262C1-75D8-4A92-BCB6-37A290891708} = {413B0724-5117-4BD6-99EF-D6B59859E1B3} - {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A} = {A82FAF9C-BCCE-4569-9EB2-36DA4D239DA8} - {E31D1C4F-8E0D-428A-8583-5159CE690B33} = {5452CCB0-EF39-4699-A8E0-C86D595FC4DA} - {1893FA97-40A9-480F-BB77-279F959EAE6E} = {8C5A07F5-C9E0-430D-A908-2C1161C952ED} - {23BA577F-B171-4CEC-92E0-49EE44564366} = {8B19C579-DB40-4D8B-A605-165366FAB6CD} - {C9C14C99-103E-45CB-B1B4-2C165429E35C} = {D804D2D8-5ED5-42B3-A77D-1A46D3ACB727} - {8D542B56-EB45-43B1-AAB8-417352F5BDE6} = {3904D25E-E461-4A90-A544-E1C74A32086A} {3F637C27-BDFE-4466-838C-5FBDE4C5F2C1} = {199CBE46-0460-42FA-AB80-DD3C89310F4A} {A51E3BEB-5868-445C-8F87-AC7D05C4EE2D} = {199CBE46-0460-42FA-AB80-DD3C89310F4A} {8D891397-002B-4AF1-929E-0515D8F2F5AB} = {199CBE46-0460-42FA-AB80-DD3C89310F4A} @@ -213,5 +250,16 @@ Global {8B19C579-DB40-4D8B-A605-165366FAB6CD} = {5234E3C1-1C0C-49A6-900E-EEC5815604BA} {D804D2D8-5ED5-42B3-A77D-1A46D3ACB727} = {5234E3C1-1C0C-49A6-900E-EEC5815604BA} {3904D25E-E461-4A90-A544-E1C74A32086A} = {5234E3C1-1C0C-49A6-900E-EEC5815604BA} + {4A7303D2-92DB-4537-A380-24D334FC24FE} = {5A68CA37-F621-4113-B573-8A361135203B} + {E5DC3A24-691A-4F3A-B519-E4C49B2DAC98} = {3F637C27-BDFE-4466-838C-5FBDE4C5F2C1} + {42677515-C196-4C0F-99A2-F11E2FB55BF6} = {A51E3BEB-5868-445C-8F87-AC7D05C4EE2D} + {7441D7F2-F509-4A47-9404-3EB8653AE037} = {8D891397-002B-4AF1-929E-0515D8F2F5AB} + {0F8262C1-75D8-4A92-BCB6-37A290891708} = {413B0724-5117-4BD6-99EF-D6B59859E1B3} + {D38B87BF-5778-4DA8-8DCE-B0F37F087D5A} = {A82FAF9C-BCCE-4569-9EB2-36DA4D239DA8} + {E31D1C4F-8E0D-428A-8583-5159CE690B33} = {5452CCB0-EF39-4699-A8E0-C86D595FC4DA} + {1893FA97-40A9-480F-BB77-279F959EAE6E} = {8C5A07F5-C9E0-430D-A908-2C1161C952ED} + {23BA577F-B171-4CEC-92E0-49EE44564366} = {8B19C579-DB40-4D8B-A605-165366FAB6CD} + {C9C14C99-103E-45CB-B1B4-2C165429E35C} = {D804D2D8-5ED5-42B3-A77D-1A46D3ACB727} + {8D542B56-EB45-43B1-AAB8-417352F5BDE6} = {3904D25E-E461-4A90-A544-E1C74A32086A} EndGlobalSection EndGlobal diff --git a/print/XPSDrvSmpl/install/xdsmpl.inf b/print/XPSDrvSmpl/install/xdsmpl.inf index eb94e358..5d93dfbd 100644 --- a/print/XPSDrvSmpl/install/xdsmpl.inf +++ b/print/XPSDrvSmpl/install/xdsmpl.inf @@ -24,7 +24,7 @@ Class=Printer DriverVer=10/17/2008,6.1.6930.0 [Manufacturer] -%ManufacturerName%=Standard,NTx86,NTia64,NTamd64,NTx86.6.0,NTia64.6.0,NTamd64.6.0 +%ManufacturerName%=Standard,NTx86,NTia64,NTamd64,NTx86.6.0,NTia64.6.0,NTamd64.6.0,NTarm64.6.0 [Standard.NTx86] "XPSDrv Sample Driver" = INSTALL_XDSMPL_FILTERS_PRE_VISTA @@ -44,6 +44,9 @@ DriverVer=10/17/2008,6.1.6930.0 [Standard.NTamd64.6.0] "XPSDrv Sample Driver" = INSTALL_XDSMPL_FILTERS_VISTA +[Standard.NTarm64.6.0] +"XPSDrv Sample Driver" = INSTALL_XDSMPL_FILTERS_VISTA + [INSTALL_XDSMPL_FILTERS_PRE_VISTA] CopyFiles=XPSDrvSample,ConfigPlugin,COLORPROFILES DriverFile=mxdwdrv.dll @@ -75,6 +78,10 @@ CoreDriverDependencies={D20EA372-DD35-4950-9ED8-A6335AFE79F0}, {D20EA372-DD35-49 PackageAware=TRUE CoreDriverDependencies={D20EA372-DD35-4950-9ED8-A6335AFE79F0}, {D20EA372-DD35-4950-9ED8-A6335AFE79F5} +[PrinterPackageInstallation.arm64] +PackageAware=TRUE +CoreDriverDependencies={D20EA372-DD35-4950-9ED8-A6335AFE79F0}, {D20EA372-DD35-4950-9ED8-A6335AFE79F5} + [DestinationDirs] DefaultDestDir=66000 COLORPROFILES=66003 @@ -114,6 +121,10 @@ xdsmpl-pipelineconfig.xml 1 = %Location%,, 2 = %Location%,,,amd64 +[SourceDisksNames.arm64] +1 = %Location%,, +2 = %Location%,,,arm64 + [SourceDisksFiles] xdsmpl.gpd = 1 xdnames.gpd = 1 diff --git a/print/XPSDrvSmpl/src/common/pshndlr.cpp b/print/XPSDrvSmpl/src/common/pshndlr.cpp index 989837be..868378da 100644 --- a/print/XPSDrvSmpl/src/common/pshndlr.cpp +++ b/print/XPSDrvSmpl/src/common/pshndlr.cpp @@ -133,7 +133,7 @@ CPSHandler::CPSHandler( cstrNSPrefix.Delete(iIndex, 1) > 0) { CStringXDW cstrOrgNamespaces; - cstrOrgNamespaces.Format(szNSSelection, cstrNSPrefix, FRAMEWORK_URI); + cstrOrgNamespaces.Format(szNSSelection, static_cast(cstrNSPrefix), FRAMEWORK_URI); hr = m_pPrintDocument->setProperty(CComBSTR(szSelectNS), CComVariant(cstrOrgNamespaces)); } @@ -1593,7 +1593,7 @@ CPSHandler::GetPrefixFromURI( // Construct the Root Query string // CStringXDW cstrRootQuery; - cstrRootQuery.Format(szPTRootQuery, szTmpNS, m_bstrDocumentType); + cstrRootQuery.Format(szPTRootQuery, szTmpNS, static_cast(m_bstrDocumentType)); // // Find the PrintSchema element so we can retrieve the private namespace prefix diff --git a/print/XPSDrvSmpl/src/common/ptquerybld.cpp b/print/XPSDrvSmpl/src/common/ptquerybld.cpp index 885af0b2..c2113932 100644 --- a/print/XPSDrvSmpl/src/common/ptquerybld.cpp +++ b/print/XPSDrvSmpl/src/common/ptquerybld.cpp @@ -236,7 +236,7 @@ CPTQueryBuilder::AddFeature( if (SUCCEEDED(hr)) { CStringXDW cstrFeatureQuery; - cstrFeatureQuery.Format(szPTQFeature, m_bstrFrameworkNS, bstrKeyword); + cstrFeatureQuery.Format(szPTQFeature, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrFeatureQuery); } @@ -305,7 +305,7 @@ CPTQueryBuilder::AddProperty( if (SUCCEEDED(hr)) { CStringXDW cstrPropertyQuery; - cstrPropertyQuery.Format(szPTQProperty, m_bstrFrameworkNS, bstrKeyword); + cstrPropertyQuery.Format(szPTQProperty, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrPropertyQuery); } @@ -369,7 +369,7 @@ CPTQueryBuilder::AddScoredProperty( if (SUCCEEDED(hr)) { CStringXDW cstrScoredPropertyQuery; - cstrScoredPropertyQuery.Format(szPTQScoredProperty, m_bstrFrameworkNS, bstrKeyword); + cstrScoredPropertyQuery.Format(szPTQScoredProperty, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrScoredPropertyQuery); } @@ -437,7 +437,7 @@ CPTQueryBuilder::AddParamRef( if (SUCCEEDED(hr)) { CStringXDW cstrParamRefQuery; - cstrParamRefQuery.Format(szPTQParamRef, m_bstrFrameworkNS, bstrKeyword); + cstrParamRefQuery.Format(szPTQParamRef, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrParamRefQuery); } @@ -490,13 +490,13 @@ CPTQueryBuilder::AddOption( { CStringXDW cstrQueryRoot(m_bstrQuery); CStringXDW cstrOptionQuery; - cstrOptionQuery.Format(szPTQOptionSH, m_bstrFrameworkNS); + cstrOptionQuery.Format(szPTQOptionSH, static_cast(m_bstrFrameworkNS)); if (SUCCEEDED(hr = m_bstrQuery.Append(cstrOptionQuery)) && SUCCEEDED(hr = m_bstrQuery.Append(szPTQOrNodes)) && SUCCEEDED(hr = m_bstrQuery.Append(cstrQueryRoot))) { - cstrOptionQuery.Format(szPTQOptionLH, m_bstrFrameworkNS, bstrKeywordNS, m_bstrFrameworkNS); + cstrOptionQuery.Format(szPTQOptionLH, static_cast(m_bstrFrameworkNS), bstrKeywordNS, static_cast(m_bstrFrameworkNS)); hr = m_bstrQuery.Append(cstrOptionQuery); } } diff --git a/print/XPSDrvSmpl/src/common/wmpthndlr.cpp b/print/XPSDrvSmpl/src/common/wmpthndlr.cpp index dcb1eff7..49792d6a 100644 --- a/print/XPSDrvSmpl/src/common/wmpthndlr.cpp +++ b/print/XPSDrvSmpl/src/common/wmpthndlr.cpp @@ -1123,7 +1123,7 @@ CWMPTHandler::GetTxtPropTypeAndValue( case FontColor: { cstrType = SCHEMA_STRING; - cstrValue.Format(L"%s", pWmData->txtData.bstrFontColor); + cstrValue.Format(L"%s", static_cast(pWmData->txtData.bstrFontColor)); } break; @@ -1137,7 +1137,7 @@ CWMPTHandler::GetTxtPropTypeAndValue( case Text: { cstrType = SCHEMA_STRING; - cstrValue.Format(L"%s", pWmData->txtData.bstrText); + cstrValue.Format(L"%s", static_cast(pWmData->txtData.bstrText)); } break; diff --git a/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj b/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj index a88401cd..ad460948 100644 --- a/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj +++ b/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 StaticLibrary
+ + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + StaticLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 StaticLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + StaticLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -93,6 +123,22 @@ %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + true + Level4 + Sync + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -109,6 +155,22 @@ %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + true + Level4 + Sync + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + %(AdditionalIncludeDirectories);.\;.\..\inc;.\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -152,6 +214,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -163,6 +236,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -188,9 +272,15 @@ xdsmplcmn + + xdsmplcmn + xdsmplcmn + + xdsmplcmn + xdsmplcmn diff --git a/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj.Filters b/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj.Filters index 522e133e..61c9a129 100644 --- a/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/common/xdsmplcmn.vcxproj.Filters @@ -115,4 +115,2030 @@ Source Files + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj b/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj index 97f7ddaf..30db60d3 100644 --- a/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj +++ b/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -80,9 +110,15 @@ xdbook + + xdbook + xdbook + + xdbook + xdbook @@ -95,12 +131,24 @@ _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -132,6 +180,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -151,6 +218,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -200,6 +286,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -211,6 +308,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -265,11 +373,21 @@ xdbook.def + + + xdbook.def + + xdbook.def + + + xdbook.def + + xdbook.def diff --git a/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj.Filters b/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj.Filters index e9afca89..d01c09e2 100644 --- a/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/filters/booklet/xdbook.vcxproj.Filters @@ -30,13 +30,32 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + Header Files + + + + + Header Files + + + + + + + Source Files + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj b/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj index c7cc5343..78daab4b 100644 --- a/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj +++ b/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -80,9 +110,15 @@ XDColMan + + XDColMan + XDColMan + + XDColMan + XDColMan @@ -96,6 +132,13 @@ _DllMainCRTStartup + + + %(AdditionalDependencies);mscms.lib;windowscodecs.lib + _DllMainCRTStartup@12 + _DllMainCRTStartup + + %(AdditionalDependencies);mscms.lib;windowscodecs.lib @@ -103,6 +146,13 @@ _DllMainCRTStartup + + + %(AdditionalDependencies);mscms.lib;windowscodecs.lib + _DllMainCRTStartup@12 + _DllMainCRTStartup + + %(AdditionalDependencies);mscms.lib;windowscodecs.lib @@ -136,6 +186,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -155,6 +224,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -204,6 +292,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -215,6 +314,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -335,11 +445,21 @@ XDColMan.def + + + XDColMan.def + + XDColMan.def + + + XDColMan.def + + XDColMan.def diff --git a/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj.Filters b/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj.Filters index db9fe1c4..2bcbd7d8 100644 --- a/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/filters/color/XDColMan.vcxproj.Filters @@ -63,13 +63,241 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + Source Files + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/filters/color/cmimg.cpp b/print/XPSDrvSmpl/src/filters/color/cmimg.cpp index f44fa028..5f861422 100644 --- a/print/XPSDrvSmpl/src/filters/color/cmimg.cpp +++ b/print/XPSDrvSmpl/src/filters/color/cmimg.cpp @@ -537,7 +537,7 @@ CColorManagedImage::GetResURI( // Create a unique name for the bitmap for this print session // CStringXDW cstrURI; - cstrURI.Format(L"%s_%u.wdp", cstrFileName, GetUniqueNumber()); + cstrURI.Format(L"%s_%u.wdp", static_cast(cstrFileName), GetUniqueNumber()); SysFreeString(*pbstrResURI); *pbstrResURI = cstrURI.AllocSysString(); diff --git a/print/XPSDrvSmpl/src/filters/color/dictionary.cpp b/print/XPSDrvSmpl/src/filters/color/dictionary.cpp index 5106aad7..efd15760 100644 --- a/print/XPSDrvSmpl/src/filters/color/dictionary.cpp +++ b/print/XPSDrvSmpl/src/filters/color/dictionary.cpp @@ -273,7 +273,7 @@ CRemoteDictionary::GetResURI( // Create a unique name for the dictionary for this print session // CStringXDW cstrURI; - cstrURI.Format(L"%s_%u.dict", m_bstrDictionaryURI, GetUniqueNumber()); + cstrURI.Format(L"%s_%u.dict", static_cast(m_bstrDictionaryURI), GetUniqueNumber()); *pbstrResURI = cstrURI.AllocSysString(); } diff --git a/print/XPSDrvSmpl/src/filters/color/profman.cpp b/print/XPSDrvSmpl/src/filters/color/profman.cpp index 8bd06284..16ee9dc2 100644 --- a/print/XPSDrvSmpl/src/filters/color/profman.cpp +++ b/print/XPSDrvSmpl/src/filters/color/profman.cpp @@ -692,7 +692,7 @@ CProfileManager::GetResURI( // Create a unique name for the profile for this print session // CStringXDW cstrURI; - cstrURI.Format(L"/%s_%u%s", cstrFileName, GetUniqueNumber(), cstrFileExt); + cstrURI.Format(L"/%s_%u%s", static_cast(cstrFileName), GetUniqueNumber(), static_cast(cstrFileExt)); *pbstrResURI = cstrURI.AllocSysString(); } diff --git a/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp b/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp index 209c344a..b1c52db2 100644 --- a/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp +++ b/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp @@ -1034,7 +1034,7 @@ CPTManager::GetMergedTicket( { CStringXDA cstrMessage; CStringXDA cstrError(bstrErrorMessage); - cstrMessage.Format("PTMergeAndValidatePrintTicket failed with message: %s\n", cstrError); + cstrMessage.Format("PTMergeAndValidatePrintTicket failed with message: %s\n", static_cast(cstrError)); ERR(cstrMessage.GetBuffer()); } diff --git a/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj b/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj index 636dce26..44ec5cb7 100644 --- a/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj +++ b/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 StaticLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + StaticLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 StaticLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + StaticLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -88,6 +118,17 @@ %(AdditionalIncludeDirectories);..\xdcont + + + %(AdditionalIncludeDirectories);..\xdcont + + + %(AdditionalIncludeDirectories);..\xdcont + + + %(AdditionalIncludeDirectories);..\xdcont + + %(AdditionalIncludeDirectories);..\xdcont @@ -99,6 +140,17 @@ %(AdditionalIncludeDirectories);..\xdcont + + + %(AdditionalIncludeDirectories);..\xdcont + + + %(AdditionalIncludeDirectories);..\xdcont + + + %(AdditionalIncludeDirectories);..\xdcont + + %(AdditionalIncludeDirectories);..\xdcont @@ -124,9 +176,15 @@ xdfltcmn + + xdfltcmn + xdfltcmn + + xdfltcmn + xdfltcmn @@ -152,6 +210,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -171,6 +248,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -220,6 +316,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -231,6 +338,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE diff --git a/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj.Filters b/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj.Filters index d43f3fa3..926f85a0 100644 --- a/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/filters/common/xdfltcmn.vcxproj.Filters @@ -43,4 +43,105 @@ Source Files + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp b/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp index 830f6928..399b353b 100644 --- a/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp +++ b/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp @@ -363,8 +363,8 @@ CNUpSaxHandler::startElement( sizePage.Height); cstrOut.Format(L"(bstrMatrix), + static_cast(strClip)); // // Add additional namespaces from the FixedPage diff --git a/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj b/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj index ec80a406..ef276008 100644 --- a/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj +++ b/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -80,9 +110,15 @@ xdnup + + xdnup + xdnup + + xdnup + xdnup @@ -95,12 +131,24 @@ _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -132,6 +180,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -151,6 +218,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -200,6 +286,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -211,6 +308,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -277,11 +385,21 @@ xdnup.def + + + xdnup.def + + xdnup.def + + + xdnup.def + + xdnup.def diff --git a/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj.Filters b/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj.Filters index 57c9ed18..b52a76f1 100644 --- a/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/filters/nup/xdnup.vcxproj.Filters @@ -36,13 +36,52 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + + + Source Files + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp b/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp index 44e0d5d3..7a7bc160 100644 --- a/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp +++ b/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp @@ -699,7 +699,7 @@ CPageScaling::GetOpenTagXML( if (SUCCEEDED(hr = CreateTransform(&bstrMatrixXForm))) { CStringXDW cstrCanvas; - cstrCanvas.Format(L"(bstrMatrixXForm)); *pbstrXML = cstrCanvas.AllocSysString(); } } diff --git a/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj b/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj index 6de38ad0..05e4aeb5 100644 --- a/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj +++ b/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -80,9 +110,15 @@ xdscale + + xdscale + xdscale + + xdscale + xdscale @@ -95,12 +131,24 @@ _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -136,6 +184,29 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\xdcont + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\xdcont + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\xdcont + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);.\..\xdcont\$(IntDir)\xdcont.lib + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\xdcont @@ -159,6 +230,29 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\xdcont + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\xdcont + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\xdcont + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);.\..\xdcont\$(IntDir)\xdcont.lib + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\xdcont @@ -216,6 +310,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -227,6 +332,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -287,11 +403,21 @@ xdscale.def + + + xdscale.def + + xdscale.def + + + xdscale.def + + xdscale.def diff --git a/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj.Filters b/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj.Filters index c72bf9da..0f7b4ae3 100644 --- a/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/filters/scaling/xdscale.vcxproj.Filters @@ -33,13 +33,41 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + + Header Files + + + + + + Header Files + + + + + + Header Files + + + + + + + + Source Files + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp b/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp index 578995bf..a7c9d595 100644 --- a/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp +++ b/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp @@ -159,7 +159,7 @@ CVectorWatermark::CreateXMLElement( try { CStringXDW strOpenCanvas; - strOpenCanvas.Format(L"", bstrWMOpacity, bstrMatrixXForm); + strOpenCanvas.Format(L"", static_cast(bstrWMOpacity), static_cast(bstrMatrixXForm)); IStream* pStream; CComBSTR bstrContent; diff --git a/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj b/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj index 740e3c9d..db90ca84 100644 --- a/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj +++ b/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -80,9 +110,15 @@ xdwmark + + xdwmark + xdwmark + + xdwmark + xdwmark @@ -95,12 +131,24 @@ _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -132,6 +180,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -151,6 +218,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -200,6 +286,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -211,6 +308,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -307,11 +415,21 @@ xdwmark.def + + + xdwmark.def + + xdwmark.def + + + xdwmark.def + + xdwmark.def diff --git a/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj.Filters b/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj.Filters index fbaaa4cc..9825590c 100644 --- a/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/filters/watermark/xdwmark.vcxproj.Filters @@ -51,13 +51,163 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + Resource Files + + + Source Files + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj b/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj index b414e460..37d7855a 100644 --- a/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj +++ b/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 StaticLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + StaticLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 StaticLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + StaticLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -80,9 +110,15 @@ xdcont + + xdcont + xdcont + + xdcont + xdcont @@ -108,6 +144,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -127,6 +182,25 @@ %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);uuid.lib;WIAGUID.lib;msxml6.lib;Kernel32.lib;ole32.lib;oleaut32.lib;prntvpt.lib;winspool.lib;gdi32.lib;gdiplus.lib;shlwapi.lib;Advapi32.lib;user32.lib;.\..\..\debug\$(IntDir)\xdsdbg.lib;.\..\..\common\$(IntDir)\xdsmplcmn.lib;.\..\..\filters\common\$(IntDir)\xdfltcmn.lib + + %(AdditionalIncludeDirectories);..\;..\common;..\..\inc;..\..\common;..\..\debug;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus @@ -176,6 +250,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE @@ -187,6 +272,17 @@ %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + + %(PreprocessorDefinitions);_UNICODE;UNICODE + + %(PreprocessorDefinitions);_UNICODE;UNICODE diff --git a/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj.Filters b/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj.Filters index 2cf80087..d56ecb83 100644 --- a/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/filters/xdcont/xdcont.vcxproj.Filters @@ -43,4 +43,105 @@ Source Files + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + \ No newline at end of file diff --git a/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj b/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj index 92148069..89faeba5 100644 --- a/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj +++ b/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -44,6 +60,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -83,12 +113,24 @@ _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -110,6 +152,15 @@ Sync + + + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + MultiThreaded @@ -119,6 +170,15 @@ Sync + + + MultiThreaded + MultiThreadedDebug + true + Level4 + Sync + + MultiThreaded @@ -140,9 +200,15 @@ xdsmplui + + xdsmplui + xdsmplui + + xdsmplui + xdsmplui @@ -170,6 +236,27 @@ xdsmplui.def + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(PreprocessorDefinitions);PLUGIN_PRINTTICKET + %(AdditionalIncludeDirectories);..\inc;..\debug;..\common;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(PreprocessorDefinitions);PLUGIN_PRINTTICKET + %(AdditionalIncludeDirectories);..\inc;..\debug;..\common;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(PreprocessorDefinitions);PLUGIN_PRINTTICKET + %(AdditionalIncludeDirectories);..\inc;..\debug;..\common;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib;Comdlg32.lib;.\..\debug\$(IntDir)\xdsdbg.lib;.\..\common\$(IntDir)\xdsmplcmn.lib + xdsmplui.def + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE @@ -191,6 +278,27 @@ xdsmplui.def + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(PreprocessorDefinitions);PLUGIN_PRINTTICKET + %(AdditionalIncludeDirectories);..\inc;..\debug;..\common;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(PreprocessorDefinitions);PLUGIN_PRINTTICKET + %(AdditionalIncludeDirectories);..\inc;..\debug;..\common;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(PreprocessorDefinitions);PLUGIN_PRINTTICKET + %(AdditionalIncludeDirectories);..\inc;..\debug;..\common;$(DDK_INC_PATH);$(SDK_INC_PATH)\gdiplus + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib;Comdlg32.lib;.\..\debug\$(IntDir)\xdsdbg.lib;.\..\common\$(IntDir)\xdsmplcmn.lib + xdsmplui.def + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE diff --git a/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj.Filters b/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj.Filters index 90668633..4d74c630 100644 --- a/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj.Filters +++ b/print/XPSDrvSmpl/src/ui/xdsmplui.vcxproj.Filters @@ -72,13 +72,500 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + + + + + + + + + + + + Source Files + + \ No newline at end of file diff --git a/print/XpsRasFilter/XpsRasFilter.sln b/print/XpsRasFilter/XpsRasFilter.sln index e7a317ef..1c155e19 100644 --- a/print/XpsRasFilter/XpsRasFilter.sln +++ b/print/XpsRasFilter/XpsRasFilter.sln @@ -1,24 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 12.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xpsrasfilter", "src\xpsrasfilter.vcxproj", "{D8784A15-C959-4CDF-B5B8-A603F347BDA4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Debug|ARM64.Build.0 = Debug|ARM64 {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Debug|Win32.ActiveCfg = Debug|Win32 {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Debug|Win32.Build.0 = Debug|Win32 - {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|Win32.ActiveCfg = Release|Win32 - {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|Win32.Build.0 = Release|Win32 {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Debug|x64.ActiveCfg = Debug|x64 {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Debug|x64.Build.0 = Debug|x64 + {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|ARM64.ActiveCfg = Release|ARM64 + {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|ARM64.Build.0 = Release|ARM64 + {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|Win32.ActiveCfg = Release|Win32 + {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|Win32.Build.0 = Release|Win32 {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|x64.ActiveCfg = Release|x64 {D8784A15-C959-4CDF-B5B8-A603F347BDA4}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/print/XpsRasFilter/install/xpsrassmpl.inf b/print/XpsRasFilter/install/xpsrassmpl.inf index 3e7a8224..d16530be 100644 --- a/print/XpsRasFilter/install/xpsrassmpl.inf +++ b/print/XpsRasFilter/install/xpsrassmpl.inf @@ -24,7 +24,7 @@ Class=Printer DriverVer=10/17/2008,6.1.6930.0 [Manufacturer] -%ManufacturerName%=Standard,NTx86.6.1,NTia64.6.1,NTamd64.6.1 +%ManufacturerName%=Standard,NTx86.6.1,NTia64.6.1,NTamd64.6.1,NTarm64.6.1 [Standard.NTx86.6.1] @@ -36,6 +36,9 @@ DriverVer=10/17/2008,6.1.6930.0 [Standard.NTamd64.6.1] "XPSRas WDK Sample Driver" = INSTALL_FILTER +[Standard.NTarm64.6.1] +"XPSRas WDK Sample Driver" = INSTALL_FILTER + [INSTALL_FILTER] CopyFiles=XPSRasSample DriverFile=mxdwdrv.dll @@ -56,6 +59,10 @@ CoreDriverDependencies={D20EA372-DD35-4950-9ED8-A6335AFE79F0}, {D20EA372-DD35-49 PackageAware=TRUE CoreDriverDependencies={D20EA372-DD35-4950-9ED8-A6335AFE79F0}, {D20EA372-DD35-4950-9ED8-A6335AFE79F5} +[PrinterPackageInstallation.arm64] +PackageAware=TRUE +CoreDriverDependencies={D20EA372-DD35-4950-9ED8-A6335AFE79F0}, {D20EA372-DD35-4950-9ED8-A6335AFE79F5} + [DestinationDirs] DefaultDestDir=66000 @@ -76,6 +83,10 @@ xpsrasfilter.dll 1 = %Location%,, 2 = %Location%,,,amd64 +[SourceDisksNames.arm64] +1 = %Location%,, +2 = %Location%,,,arm64 + [SourceDisksFiles] xpsrassmpl.gpd = 1 xpsrassmpl-pipelineconfig.xml = 1 diff --git a/print/XpsRasFilter/src/precomp.h b/print/XpsRasFilter/src/precomp.h index 97e8f4ee..8cfbe37b 100644 --- a/print/XpsRasFilter/src/precomp.h +++ b/print/XpsRasFilter/src/precomp.h @@ -36,6 +36,7 @@ __user_driver #include #include #include +#include // STL #include diff --git a/print/XpsRasFilter/src/xpsrasfilter.vcxproj b/print/XpsRasFilter/src/xpsrasfilter.vcxproj index f7ce2baf..267efbef 100644 --- a/print/XpsRasFilter/src/xpsrasfilter.vcxproj +++ b/print/XpsRasFilter/src/xpsrasfilter.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -34,6 +42,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 True @@ -42,6 +58,14 @@ WindowsApplicationForDrivers10.0 DynamicLibrary + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + DynamicLibrary + Windows10 False @@ -65,9 +89,15 @@ + + + + + + @@ -174,9 +204,15 @@ xpsrasfilter + + xpsrasfilter + xpsrasfilter + + xpsrasfilter + xpsrasfilter @@ -189,12 +225,24 @@ _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 _DllMainCRTStartup + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -221,6 +269,20 @@ %(AdditionalDependencies);uuid.lib;prntvpt.lib;Kernel32.lib;winspool.lib;ole32.lib;oleaut32.lib;Advapi32.lib + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(AdditionalDependencies);uuid.lib;prntvpt.lib;Kernel32.lib;winspool.lib;ole32.lib;oleaut32.lib;Advapi32.lib + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) @@ -235,6 +297,20 @@ %(AdditionalDependencies);uuid.lib;prntvpt.lib;Kernel32.lib;winspool.lib;ole32.lib;oleaut32.lib;Advapi32.lib + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) + + + %(AdditionalDependencies);uuid.lib;prntvpt.lib;Kernel32.lib;winspool.lib;ole32.lib;oleaut32.lib;Advapi32.lib + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH) @@ -266,9 +342,15 @@ Dynamic + + Dynamic + Dynamic + + Dynamic + Dynamic @@ -282,6 +364,13 @@ Level4 + + + Sync + true + Level4 + + Sync @@ -289,6 +378,13 @@ Level4 + + + Sync + true + Level4 + + Sync @@ -308,11 +404,21 @@ xpsrasfilter.def + + + xpsrasfilter.def + + xpsrasfilter.def + + + xpsrasfilter.def + + xpsrasfilter.def diff --git a/print/XpsRasFilter/src/xpsrasfilter.vcxproj.Filters b/print/XpsRasFilter/src/xpsrasfilter.vcxproj.Filters index bc40227c..220e456f 100644 --- a/print/XpsRasFilter/src/xpsrasfilter.vcxproj.Filters +++ b/print/XpsRasFilter/src/xpsrasfilter.vcxproj.Filters @@ -42,13 +42,137 @@ Source Files - - Source Files - Resource Files + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + Source Files + + \ No newline at end of file diff --git a/print/autoconfig/AutoCnfg.inf b/print/autoconfig/AutoCnfg.inf index 17209219..4c9208d0 100644 --- a/print/autoconfig/AutoCnfg.inf +++ b/print/autoconfig/AutoCnfg.inf @@ -21,7 +21,7 @@ CatalogFile=AutoCnfg.cat ; that we will display in the Dialog box ; [Manufacturer] -%ManufacturerName%=Standard, NTx86, NTamd64, NTia64 +%ManufacturerName%=Standard, NTx86, NTamd64, NTia64, NTarm64 ; ; Model sections. @@ -42,6 +42,9 @@ CatalogFile=AutoCnfg.cat "Unidrv AutoConfiguration Sample" = INSTALL_AUTO_CONFIG.UNI,DO_NOT_USE_THIS_HWID1 "PScript5 AutoConfiguration Sample" = INSTALL_AUTO_CONFIG.PS,DO_NOT_USE_THIS_HWID2 +[Standard.NTarm64] +"Unidrv AutoConfiguration Sample" = INSTALL_AUTO_CONFIG.UNI,DO_NOT_USE_THIS_HWID1 +"PScript5 AutoConfiguration Sample" = INSTALL_AUTO_CONFIG.PS,DO_NOT_USE_THIS_HWID2 ; diff --git a/print/autoconfig/AutoConfig.sln b/print/autoconfig/AutoConfig.sln index c813e5fa..41c3f755 100644 --- a/print/autoconfig/AutoConfig.sln +++ b/print/autoconfig/AutoConfig.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 12.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{C8C5A4C2-DE1C-4B59-9E50-DD766C931F7A}" EndProject @@ -13,26 +13,40 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutoConfig", "AutoConfig.vc EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Debug|ARM64.Build.0 = Debug|ARM64 + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Debug|ARM64.Deploy.0 = Debug|ARM64 {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Debug|Win32.ActiveCfg = Debug|Win32 {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Debug|Win32.Build.0 = Debug|Win32 - {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|Win32.ActiveCfg = Release|Win32 - {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|Win32.Build.0 = Release|Win32 {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Debug|x64.ActiveCfg = Debug|x64 {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Debug|x64.Build.0 = Debug|x64 + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|ARM64.ActiveCfg = Release|ARM64 + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|ARM64.Build.0 = Release|ARM64 + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|ARM64.Deploy.0 = Release|ARM64 + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|Win32.ActiveCfg = Release|Win32 + {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|Win32.Build.0 = Release|Win32 {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|x64.ActiveCfg = Release|x64 {34C973B1-CBF0-4A78-A05A-176FCFB1D25F}.Release|x64.Build.0 = Release|x64 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Debug|ARM64.Build.0 = Debug|ARM64 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Debug|ARM64.Deploy.0 = Debug|ARM64 {DBBDF822-170C-4685-BAE7-5E0531334164}.Debug|Win32.ActiveCfg = Debug|Win32 {DBBDF822-170C-4685-BAE7-5E0531334164}.Debug|Win32.Build.0 = Debug|Win32 - {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|Win32.ActiveCfg = Release|Win32 - {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|Win32.Build.0 = Release|Win32 {DBBDF822-170C-4685-BAE7-5E0531334164}.Debug|x64.ActiveCfg = Debug|x64 {DBBDF822-170C-4685-BAE7-5E0531334164}.Debug|x64.Build.0 = Debug|x64 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|ARM64.ActiveCfg = Release|ARM64 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|ARM64.Build.0 = Release|ARM64 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|ARM64.Deploy.0 = Release|ARM64 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|Win32.ActiveCfg = Release|Win32 + {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|Win32.Build.0 = Release|Win32 {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|x64.ActiveCfg = Release|x64 {DBBDF822-170C-4685-BAE7-5E0531334164}.Release|x64.Build.0 = Release|x64 EndGlobalSection @@ -40,8 +54,8 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {C8C5A4C2-DE1C-4B59-9E50-DD766C931F7A} = {02B91EC2-24FC-4562-AEB5-4269AA96F54F} {34C973B1-CBF0-4A78-A05A-176FCFB1D25F} = {C8C5A4C2-DE1C-4B59-9E50-DD766C931F7A} {DBBDF822-170C-4685-BAE7-5E0531334164} = {02B91EC2-24FC-4562-AEB5-4269AA96F54F} - {C8C5A4C2-DE1C-4B59-9E50-DD766C931F7A} = {02B91EC2-24FC-4562-AEB5-4269AA96F54F} EndGlobalSection EndGlobal diff --git a/print/autoconfig/AutoConfig.vcxproj b/print/autoconfig/AutoConfig.vcxproj index 8ec3679c..2cf8308a 100644 --- a/print/autoconfig/AutoConfig.vcxproj +++ b/print/autoconfig/AutoConfig.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -36,6 +44,14 @@ WindowsKernelModeDriver10.0 Utility + + Windows10 + False + Desktop + None + WindowsKernelModeDriver10.0 + Utility + Windows10 True @@ -44,6 +60,14 @@ WindowsKernelModeDriver10.0 Utility + + Windows10 + True + Desktop + None + WindowsKernelModeDriver10.0 + Utility + Windows10 False @@ -67,9 +91,15 @@ + + + + + + @@ -80,9 +110,15 @@ AutoConfig + + AutoConfig + AutoConfig + + AutoConfig + AutoConfig @@ -107,12 +143,24 @@ + + + + + + + + + + + + diff --git a/print/autoconfig/AutoConfig.vcxproj.Filters b/print/autoconfig/AutoConfig.vcxproj.Filters index 189b108d..de588577 100644 --- a/print/autoconfig/AutoConfig.vcxproj.Filters +++ b/print/autoconfig/AutoConfig.vcxproj.Filters @@ -18,4 +18,16 @@ {4E1D1476-C128-41DB-8AC6-44D5C6CD9B08} + + + Driver Files + + + + + + + + + \ No newline at end of file diff --git a/print/autoconfig/Package/package.VcxProj b/print/autoconfig/Package/package.VcxProj index 536ee697..21f048f5 100644 --- a/print/autoconfig/Package/package.VcxProj +++ b/print/autoconfig/Package/package.VcxProj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -48,10 +56,18 @@ Windows10 true + + Windows10 + true + Windows10 false + + Windows10 + false + diff --git a/print/autoconfig/README.md b/print/autoconfig/README.md index e4642008..d215c36f 100644 --- a/print/autoconfig/README.md +++ b/print/autoconfig/README.md @@ -1,4 +1,4 @@ -Print auto-configuration sample +Print auto-configuration sample test =============================== This sample demonstrates how to implement auto-configuration in v4 print drivers. diff --git a/print/cpsuisam/cpsuisam.sln b/print/cpsuisam/cpsuisam.sln index 5f01ba5a..252f1c33 100644 --- a/print/cpsuisam/cpsuisam.sln +++ b/print/cpsuisam/cpsuisam.sln @@ -1,24 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 12.0 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpsuisam", "cpsuisam.vcxproj", "{96055373-96CC-491C-916C-0BC49C225094}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 + Release|ARM64 = Release|ARM64 + Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {96055373-96CC-491C-916C-0BC49C225094}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {96055373-96CC-491C-916C-0BC49C225094}.Debug|ARM64.Build.0 = Debug|ARM64 {96055373-96CC-491C-916C-0BC49C225094}.Debug|Win32.ActiveCfg = Debug|Win32 {96055373-96CC-491C-916C-0BC49C225094}.Debug|Win32.Build.0 = Debug|Win32 - {96055373-96CC-491C-916C-0BC49C225094}.Release|Win32.ActiveCfg = Release|Win32 - {96055373-96CC-491C-916C-0BC49C225094}.Release|Win32.Build.0 = Release|Win32 {96055373-96CC-491C-916C-0BC49C225094}.Debug|x64.ActiveCfg = Debug|x64 {96055373-96CC-491C-916C-0BC49C225094}.Debug|x64.Build.0 = Debug|x64 + {96055373-96CC-491C-916C-0BC49C225094}.Release|ARM64.ActiveCfg = Release|ARM64 + {96055373-96CC-491C-916C-0BC49C225094}.Release|ARM64.Build.0 = Release|ARM64 + {96055373-96CC-491C-916C-0BC49C225094}.Release|Win32.ActiveCfg = Release|Win32 + {96055373-96CC-491C-916C-0BC49C225094}.Release|Win32.Build.0 = Release|Win32 {96055373-96CC-491C-916C-0BC49C225094}.Release|x64.ActiveCfg = Release|x64 {96055373-96CC-491C-916C-0BC49C225094}.Release|x64.Build.0 = Release|x64 EndGlobalSection diff --git a/print/cpsuisam/cpsuisam.vcxproj b/print/cpsuisam/cpsuisam.vcxproj index dc7d31fc..8315bee6 100644 --- a/print/cpsuisam/cpsuisam.vcxproj +++ b/print/cpsuisam/cpsuisam.vcxproj @@ -1,10 +1,18 @@  + + Debug + ARM64 + Debug Win32 + + Release + ARM64 + Release Win32 @@ -34,6 +42,14 @@ WindowsApplicationForDrivers10.0 Application
+ + Windows10 + False + Desktop + + WindowsApplicationForDrivers10.0 + Application + Windows10 True @@ -42,6 +58,14 @@ WindowsApplicationForDrivers10.0 Application + + Windows10 + True + Desktop + + WindowsApplicationForDrivers10.0 + Application + Windows10 False @@ -65,9 +89,15 @@ + + + + + + @@ -78,9 +108,15 @@ cpsuisam + + cpsuisam + cpsuisam + + cpsuisam + cpsuisam @@ -101,6 +137,20 @@ %(AdditionalIncludeDirectories);. + + + %(AdditionalDependencies);comdlg32.lib;winspool.lib;comctl32.lib;shlwapi.lib;compstui.lib + + + %(AdditionalIncludeDirectories);. + + + %(AdditionalIncludeDirectories);. + + + %(AdditionalIncludeDirectories);. + + %(AdditionalDependencies);comdlg32.lib;winspool.lib;comctl32.lib;shlwapi.lib;compstui.lib @@ -115,6 +165,20 @@ %(AdditionalIncludeDirectories);. + + + %(AdditionalDependencies);comdlg32.lib;winspool.lib;comctl32.lib;shlwapi.lib;compstui.lib + + + %(AdditionalIncludeDirectories);. + + + %(AdditionalIncludeDirectories);. + + + %(AdditionalIncludeDirectories);. + + %(AdditionalDependencies);comdlg32.lib;winspool.lib;comctl32.lib;shlwapi.lib;compstui.lib @@ -154,6 +218,17 @@ %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam @@ -165,6 +240,17 @@ %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam + + %(PreprocessorDefinitions);WIN32;STRICT;UNICODE;_UNICODE;cpsuisam @@ -193,12 +279,24 @@ + + + + + + + + + + + + diff --git a/print/cpsuisam/cpsuisam.vcxproj.Filters b/print/cpsuisam/cpsuisam.vcxproj.Filters index 3921f2cf..d51cba0d 100644 --- a/print/cpsuisam/cpsuisam.vcxproj.Filters +++ b/print/cpsuisam/cpsuisam.vcxproj.Filters @@ -33,4 +33,38 @@ Resource Files + + + Header Files + + + + + + Header Files + + + + + + Header Files + + + + + + Header Files + + + + + + + + Resource Files + + + Source Files + + \ No newline at end of file diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj index bbb7f044..293ca0e4 100644 --- a/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj +++ b/print/v4PrintDriverSamples/PrinterExtensionSample/ExtensionSample/PrinterExtensionSample.csproj @@ -118,6 +118,72 @@ 4 false + + bin\Win10 Debug\ + DEBUG;TRACE + x86 + true + full + false + prompt + 4 + false + + + bin\Win10 Release\ + TRACE + x86 + true + pdbonly + true + prompt + 4 + false + + + bin\x64\Win10 Debug\ + DEBUG;TRACE + x64 + true + full + false + prompt + 4 + false + + + bin\x64\Win10 Release\ + TRACE + x64 + true + pdbonly + true + prompt + 4 + false + + + bin\ARM64\Win10 Debug\ + DEBUG;TRACE + ARM64 + true + full + false + prompt + 4 + false + + + bin\ARM64\Win10 Release\ + TRACE + ARM64 + true + pdbonly + true + prompt + 4 + false + diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj index 8ecb8721..3c24e74b 100644 --- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj +++ b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionLibrary/PrinterExtensionLibrary.csproj @@ -50,6 +50,24 @@ prompt 4
+ + true + full + false + bin\Win10 Debug\ + DEBUG;TRACE;WINDOWS_81_APIS + prompt + 4 + + + true + pdbonly + true + bin\Win10 Release\ + TRACE;WINDOWS_81_APIS + prompt + 4 + diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionSample.sln b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionSample.sln index 29f0dec4..ac95581f 100644 --- a/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionSample.sln +++ b/print/v4PrintDriverSamples/PrinterExtensionSample/PrinterExtensionSample.sln @@ -21,10 +21,18 @@ Global Win8.1 Debug|x64 = Win8.1 Debug|x64 Win8.1 Release|x86 = Win8.1 Release|x86 Win8.1 Release|x64 = Win8.1 Release|x64 + Win10 Debug|x86 = Win10 Debug|x86 + Win10 Debug|x64 = Win10 Debug|x64 + Win10 Debug|ARM64 = Win10 Debug|ARM64 + Win10 Release|x86 = Win10 Release|x86 + Win10 Release|x64 = Win10 Release|x64 + Win10 Release|ARM64 = Win10 Release|ARM64 Win8 Debug|Any CPU = Win8 Debug|Any CPU Win8 Release|Any CPU = Win8 Release|Any CPU Win8.1 Debug|Any CPU = Win8.1 Debug|Any CPU Win8.1 Release|Any CPU = Win8.1 Release|Any CPU + Win10 Debug|Any CPU = Win10 Debug|Any CPU + Win10 Release|Any CPU = Win10 Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|x86.ActiveCfg = Win8 Debug|x86 @@ -43,6 +51,18 @@ Global {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|x86.Build.0 = Win8.1 Release|x86 {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x86.ActiveCfg = Win10 Debug|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x86.Build.0 = Win10 Debug|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x86.ActiveCfg = Win10 Release|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x86.Build.0 = Win10 Release|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|x86 {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Debug|Any CPU.Build.0 = Win8 Debug|x86 {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8 Release|Any CPU.ActiveCfg = Win8 Release|x86 @@ -51,6 +71,10 @@ Global {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Debug|Any CPU.Build.0 = Win8.1 Debug|x86 {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|Any CPU.ActiveCfg = Win8.1 Release|x86 {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win8.1 Release|Any CPU.Build.0 = Win8.1 Release|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|Any CPU.ActiveCfg = Win10 Debug|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Debug|Any CPU.Build.0 = Win10 Debug|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|Any CPU.ActiveCfg = Win10 Release|x86 + {CF554A99-6889-4B86-934F-B6AADBFEFC01}.Win10 Release|Any CPU.Build.0 = Win10 Release|x86 {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|x86.ActiveCfg = Win8 Debug|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|x86.Build.0 = Win8 Debug|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|x64.ActiveCfg = Win8 Debug|Any CPU @@ -67,6 +91,18 @@ Global {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|x86.Build.0 = Win8.1 Release|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|x64.Build.0 = Win8.1 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x86.ActiveCfg = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x86.Build.0 = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x64.ActiveCfg = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|x64.Build.0 = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|ARM64.Build.0 = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x86.ActiveCfg = Win10 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x86.Build.0 = Win10 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x64.ActiveCfg = Win10 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|x64.Build.0 = Win10 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|ARM64.ActiveCfg = Win10 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|ARM64.Build.0 = Win10 Release|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|Any CPU.ActiveCfg = Win8 Debug|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Debug|Any CPU.Build.0 = Win8 Debug|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8 Release|Any CPU.ActiveCfg = Win8 Release|Any CPU @@ -75,6 +111,10 @@ Global {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Debug|Any CPU.Build.0 = Win8.1 Debug|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|Any CPU.ActiveCfg = Win8.1 Release|Any CPU {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win8.1 Release|Any CPU.Build.0 = Win8.1 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|Any CPU.ActiveCfg = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Debug|Any CPU.Build.0 = Win10 Debug|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|Any CPU.ActiveCfg = Win10 Release|Any CPU + {D8DA0C4D-F972-4546-9068-8EB256F222F7}.Win10 Release|Any CPU.Build.0 = Win10 Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.sln b/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.sln index 64832ae7..67e9e904 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.sln +++ b/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.sln @@ -11,6 +11,8 @@ Global Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 Release|x64 = Release|x64 + Debug|ARM64 = Debug|ARM64 + Release|ARM64 = Release|ARM64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -21,6 +23,10 @@ Global {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Debug|x64.Build.0 = Debug|x64 {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Release|x64.ActiveCfg = Release|x64 {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Release|x64.Build.0 = Release|x64 + {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Debug|ARM64.Build.0 = Debug|ARM64 + {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Release|ARM64.ActiveCfg = Release|ARM64 + {6701474B-F8FF-4260-BFA6-3CA57816EF12}.Release|ARM64.Build.0 = Release|ARM64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.vcxproj b/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.vcxproj index 68fdd15a..a6e21240 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.vcxproj +++ b/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/ConstraintScript.vcxproj @@ -17,6 +17,14 @@ Release x64 + + Debug + ARM64 + + + Release + ARM64 + {6701474B-F8FF-4260-BFA6-3CA57816EF12} @@ -59,6 +67,22 @@ WindowsKernelModeDriver10.0 Utility + + Windows10 + False + Desktop + None + WindowsKernelModeDriver10.0 + Utility + + + Windows10 + True + Desktop + None + WindowsKernelModeDriver10.0 + Utility + $(IntDir) @@ -75,6 +99,12 @@ + + + + + + ConstraintScript @@ -88,6 +118,12 @@ ConstraintScript + + ConstraintScript + + + ConstraintScript + @@ -115,6 +151,18 @@ + + + + + + + + + + + + diff --git a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.sln b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.sln index 5c04f0c9..da7ca087 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.sln +++ b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.sln @@ -15,6 +15,8 @@ Global Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 Release|x64 = Release|x64 + Debug|ARM64 = Debug|ARM64 + Release|ARM64 = Release|ARM64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B756657D-AC58-4D5A-A446-1582707D012E}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -25,6 +27,10 @@ Global {B756657D-AC58-4D5A-A446-1582707D012E}.Debug|x64.Build.0 = Debug|x64 {B756657D-AC58-4D5A-A446-1582707D012E}.Release|x64.ActiveCfg = Release|x64 {B756657D-AC58-4D5A-A446-1582707D012E}.Release|x64.Build.0 = Release|x64 + {B756657D-AC58-4D5A-A446-1582707D012E}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {B756657D-AC58-4D5A-A446-1582707D012E}.Debug|ARM64.Build.0 = Debug|ARM64 + {B756657D-AC58-4D5A-A446-1582707D012E}.Release|ARM64.ActiveCfg = Release|ARM64 + {B756657D-AC58-4D5A-A446-1582707D012E}.Release|ARM64.Build.0 = Release|ARM64 {9D446972-7555-4D86-9665-CB304793A0C7}.Debug|Win32.ActiveCfg = Debug|Win32 {9D446972-7555-4D86-9665-CB304793A0C7}.Debug|Win32.Build.0 = Debug|Win32 {9D446972-7555-4D86-9665-CB304793A0C7}.Release|Win32.ActiveCfg = Release|Win32 @@ -33,6 +39,10 @@ Global {9D446972-7555-4D86-9665-CB304793A0C7}.Debug|x64.Build.0 = Debug|x64 {9D446972-7555-4D86-9665-CB304793A0C7}.Release|x64.ActiveCfg = Release|x64 {9D446972-7555-4D86-9665-CB304793A0C7}.Release|x64.Build.0 = Release|x64 + {9D446972-7555-4D86-9665-CB304793A0C7}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {9D446972-7555-4D86-9665-CB304793A0C7}.Debug|ARM64.Build.0 = Debug|ARM64 + {9D446972-7555-4D86-9665-CB304793A0C7}.Release|ARM64.ActiveCfg = Release|ARM64 + {9D446972-7555-4D86-9665-CB304793A0C7}.Release|ARM64.Build.0 = Release|ARM64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.vcxproj b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.vcxproj index 7e7d744c..9242769a 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.vcxproj +++ b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/HostBasedSampleDriver.vcxproj @@ -17,6 +17,14 @@ Release x64 + + Debug + ARM64 + + + Release + ARM64 + {9D446972-7555-4D86-9665-CB304793A0C7} @@ -60,6 +68,22 @@ WindowsKernelModeDriver10.0 Utility + + Windows10 + False + Desktop + None + WindowsKernelModeDriver10.0 + Utility + + + Windows10 + True + Desktop + None + WindowsKernelModeDriver10.0 + Utility + $(IntDir) @@ -76,6 +100,12 @@ + + + + + + HostBasedSampleDriver @@ -89,6 +119,12 @@ HostBasedSampleDriver + + HostBasedSampleDriver + + + HostBasedSampleDriver + @@ -96,12 +132,6 @@ - - - - - - @@ -127,6 +157,18 @@ + + + + + + + + + + + + diff --git a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/Package/package.VcxProj b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/Package/package.VcxProj index 700c98ca..d68c6610 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/Package/package.VcxProj +++ b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/Package/package.VcxProj @@ -17,6 +17,14 @@ Release x64 + + Debug + ARM64 + + + Release + ARM64 + @@ -52,6 +60,14 @@ Windows10 false + + Windows10 + true + + + Windows10 + false + diff --git a/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.sln b/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.sln index dc681627..04c53721 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.sln +++ b/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.sln @@ -11,6 +11,8 @@ Global Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 Release|x64 = Release|x64 + Debug|ARM64 = Debug|ARM64 + Release|ARM64 = Release|ARM64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A43939C2-3210-449C-B415-CD3C91108C58}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -21,6 +23,10 @@ Global {A43939C2-3210-449C-B415-CD3C91108C58}.Debug|x64.Build.0 = Debug|x64 {A43939C2-3210-449C-B415-CD3C91108C58}.Release|x64.ActiveCfg = Release|x64 {A43939C2-3210-449C-B415-CD3C91108C58}.Release|x64.Build.0 = Release|x64 + {A43939C2-3210-449C-B415-CD3C91108C58}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {A43939C2-3210-449C-B415-CD3C91108C58}.Debug|ARM64.Build.0 = Debug|ARM64 + {A43939C2-3210-449C-B415-CD3C91108C58}.Release|ARM64.ActiveCfg = Release|ARM64 + {A43939C2-3210-449C-B415-CD3C91108C58}.Release|ARM64.Build.0 = Release|ARM64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.vcxproj b/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.vcxproj index cf955d03..0a5d5d4c 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.vcxproj +++ b/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/USBMon-Bidi-Extension.vcxproj @@ -17,6 +17,14 @@ Release x64 + + Debug + ARM64 + + + Release + ARM64 + {A43939C2-3210-449C-B415-CD3C91108C58} @@ -59,6 +67,22 @@ WindowsKernelModeDriver10.0 Utility + + Windows10 + False + Desktop + None + WindowsKernelModeDriver10.0 + Utility + + + Windows10 + True + Desktop + None + WindowsKernelModeDriver10.0 + Utility + $(IntDir) @@ -75,6 +99,12 @@ + + + + + + USBMon-Bidi-Extension @@ -88,6 +118,12 @@ USBMon-Bidi-Extension + + USBMon-Bidi-Extension + + + USBMon-Bidi-Extension + @@ -116,6 +152,18 @@ + + + + + + + + + + + + diff --git a/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.sln b/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.sln index 31560b5a..2e8d1d08 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.sln +++ b/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.sln @@ -11,6 +11,8 @@ Global Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 Release|x64 = Release|x64 + Debug|ARM64 = Debug|ARM64 + Release|ARM64 = Release|ARM64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F7531C4D-8172-499C-A273-601A99F93A4D}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -21,6 +23,10 @@ Global {F7531C4D-8172-499C-A273-601A99F93A4D}.Debug|x64.Build.0 = Debug|x64 {F7531C4D-8172-499C-A273-601A99F93A4D}.Release|x64.ActiveCfg = Release|x64 {F7531C4D-8172-499C-A273-601A99F93A4D}.Release|x64.Build.0 = Release|x64 + {F7531C4D-8172-499C-A273-601A99F93A4D}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {F7531C4D-8172-499C-A273-601A99F93A4D}.Debug|ARM64.Build.0 = Debug|ARM64 + {F7531C4D-8172-499C-A273-601A99F93A4D}.Release|ARM64.ActiveCfg = Release|ARM64 + {F7531C4D-8172-499C-A273-601A99F93A4D}.Release|ARM64.Build.0 = Release|ARM64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.vcxproj b/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.vcxproj index f0afdde5..6b6b54a8 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.vcxproj +++ b/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/WSDMon-Bidi-Extension.vcxproj @@ -17,6 +17,14 @@ Release x64 + + Debug + ARM64 + + + Release + ARM64 + {F7531C4D-8172-499C-A273-601A99F93A4D} @@ -59,6 +67,22 @@ WindowsKernelModeDriver10.0 Utility + + Windows10 + False + Desktop + None + WindowsKernelModeDriver10.0 + Utility + + + Windows10 + True + Desktop + None + WindowsKernelModeDriver10.0 + Utility + $(IntDir) @@ -75,6 +99,12 @@ + + + + + + WSDMon-Bidi-Extension @@ -88,6 +118,12 @@ WSDMon-Bidi-Extension + + WSDMon-Bidi-Extension + + + WSDMon-Bidi-Extension + @@ -115,6 +151,18 @@ + + + + + + + + + + + + -- cgit v1.3.1 From 47282c86ceae6ebf779687737ea8ea38a0f3f2fa Mon Sep 17 00:00:00 2001 From: Matthew Montera Date: Fri, 18 Aug 2017 17:10:41 -0700 Subject: AddComponent to Extension Put the Win32 Service into the base, and created two separate extensions that create the component in a loose and tight manner. --- general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln | 19 + .../osrfx2_DCHU_base/osrfx2_DCHU_base.inx | Bin 6664 -> 10398 bytes .../osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj | 36 +- .../osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj | 12 +- .../osrfx2_DCHU_testapp/osrusbfx2.vcxproj | 8 +- .../osrfx2_DCHU_usersvc/CppWindowsService.cpp | 74 ++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp | 1152 ++++++++++++++++++++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h | 342 ++++++ .../osrfx2_DCHU_usersvc/SampleService.cpp | 287 +++++ .../osrfx2_DCHU_usersvc/SampleService.h | 174 +++ .../osrfx2_DCHU_usersvc/ServiceBase.cpp | 794 ++++++++++++++ .../osrfx2_DCHU_usersvc/ServiceBase.h | 423 +++++++ .../osrfx2_DCHU_usersvc/ThreadPool.h | 80 ++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp | 156 +++ .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h | 111 ++ .../osrfx2_DCHU_usersvc.filters | 54 + .../osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx | Bin 0 -> 3190 bytes .../osrfx2_DCHU_usersvc.vcxproj | 206 ++++ .../osrfx2_DCHU_component.sln | 73 -- .../osrfx2_DCHU_component.filters | 14 - .../osrfx2_DCHU_component.inx | 64 -- .../osrfx2_DCHU_component.vcxproj | 272 ----- .../osrfx2_DCHU_componentsoftware.cpp | 489 --------- .../osrfx2_DCHU_componentsoftware.filters | 33 - .../osrfx2_DCHU_componentsoftware.vcxproj | 169 --- .../osrfx2_DCHU_componentsoftware/stdafx.cpp | 8 - .../osrfx2_DCHU_componentsoftware/stdafx.h | 18 - .../osrfx2_DCHU_componentsoftware/targetver.h | 8 - .../osrfx2_DCHU_extension.sln | 73 -- .../osrfx2_DCHU_extension.filters | 14 - .../osrfx2_DCHU_extension.inx | 79 -- .../osrfx2_DCHU_extension.vcxproj | 281 ----- .../osrfx2_DCHU_usersvc/CppWindowsService.cpp | 74 -- .../osrfx2_DCHU_usersvc/Main.cpp | 320 ------ .../osrfx2_DCHU_usersvc/Main.h | 261 ----- .../osrfx2_DCHU_usersvc/SampleService.cpp | 254 ----- .../osrfx2_DCHU_usersvc/SampleService.h | 174 --- .../osrfx2_DCHU_usersvc/ServiceBase.cpp | 794 -------------- .../osrfx2_DCHU_usersvc/ServiceBase.h | 423 ------- .../osrfx2_DCHU_usersvc/ThreadPool.h | 80 -- .../osrfx2_DCHU_usersvc/Utils.cpp | 156 --- .../osrfx2_DCHU_usersvc/Utils.h | 111 -- .../osrfx2_DCHU_usersvc.filters | 54 - .../osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx | Bin 3190 -> 0 bytes .../osrfx2_DCHU_usersvc.vcxproj | 206 ---- .../osrfx2_DCHU_component.filters | 14 + .../osrfx2_DCHU_component.inx | 64 ++ .../osrfx2_DCHU_component.vcxproj | 276 +++++ .../osrfx2_DCHU_componentsoftware.cpp | 489 +++++++++ .../osrfx2_DCHU_componentsoftware.filters | 33 + .../osrfx2_DCHU_componentsoftware.vcxproj | 169 +++ .../osrfx2_DCHU_componentsoftware/stdafx.cpp | 8 + .../osrfx2_DCHU_componentsoftware/stdafx.h | 18 + .../osrfx2_DCHU_componentsoftware/targetver.h | 8 + .../osrfx2_DCHU_extension.sln | 102 ++ .../osrfx2_DCHU_extension.filters | 14 + .../osrfx2_DCHU_extension.inx | 54 + .../osrfx2_DCHU_extension.vcxproj | 266 +++++ .../osrfx2_DCHU_component.inx | 64 ++ .../osrfx2_DCHU_componentsoftware.cpp | 489 +++++++++ .../osrfx2_DCHU_componentsoftware.filters | 33 + .../osrfx2_DCHU_componentsoftware.vcxproj | 169 +++ .../osrfx2_DCHU_componentsoftware/stdafx.cpp | 8 + .../osrfx2_DCHU_componentsoftware/stdafx.h | 18 + .../osrfx2_DCHU_componentsoftware/targetver.h | 8 + .../osrfx2_DCHU_extension.sln | 73 ++ .../osrfx2_DCHU_extension.filters | 14 + .../osrfx2_DCHU_extension.inx | 55 + .../osrfx2_DCHU_extension.vcxproj | 273 +++++ 69 files changed, 6629 insertions(+), 4520 deletions(-) create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx create mode 100644 general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h delete mode 100644 general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx delete mode 100644 general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx create mode 100644 general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln index ce0593e1..dfa90dbd 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base.sln @@ -10,6 +10,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_base", "osrfx2_DCHU_base\osrfx2_DCHU_base.vcxproj", "{5B711254-3F53-4E1D-A1AD-CC81E34588B7}" ProjectSection(ProjectDependencies) = postProject {3CC42473-D121-41F4-AE26-1F2F0AC65E82} = {3CC42473-D121-41F4-AE26-1F2F0AC65E82} + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_testapp", "osrfx2_DCHU_testapp\osrusbfx2.vcxproj", "{6EED5CDD-5526-40DC-97F9-582857E10187}" @@ -18,6 +19,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_filter", "osrfx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_filter", "osrfx2_DCHU_filter\osrfx2_DCHU_filter.vcxproj", "{3CC42473-D121-41F4-AE26-1F2F0AC65E82}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc", "{DA04929E-1AFF-4EB7-935F-E9485C0316DB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc\osrfx2_DCHU_usersvc.vcxproj", "{DE70E2D1-6A4D-4984-BD82-CE750889F0D3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -42,6 +47,7 @@ Global {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|ARM64.ActiveCfg = Release|Win32 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.ActiveCfg = Release|Win32 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.Build.0 = Release|Win32 + {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|Win32.Deploy.0 = Release|Win32 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|x64.ActiveCfg = Release|x64 {5B711254-3F53-4E1D-A1AD-CC81E34588B7}.Release|x64.Build.0 = Release|x64 {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|ARM.ActiveCfg = Debug|Win32 @@ -72,6 +78,18 @@ Global {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.ActiveCfg = Release|x64 {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.Build.0 = Release|x64 {3CC42473-D121-41F4-AE26-1F2F0AC65E82}.Release|x64.Deploy.0 = Release|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM.ActiveCfg = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM64.ActiveCfg = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|Win32.Build.0 = Debug|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.ActiveCfg = Debug|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.Build.0 = Debug|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM.ActiveCfg = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM64.ActiveCfg = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|Win32.ActiveCfg = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|Win32.Build.0 = Release|Win32 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.ActiveCfg = Release|x64 + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -80,5 +98,6 @@ Global {5B711254-3F53-4E1D-A1AD-CC81E34588B7} = {3B268182-F450-4AB8-B350-A2CF6495F756} {6EED5CDD-5526-40DC-97F9-582857E10187} = {52ABC41E-9AAA-4DA8-8986-F6298E32C8A3} {3CC42473-D121-41F4-AE26-1F2F0AC65E82} = {1665ED66-7966-4FE2-9BA5-B5843511E325} + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {DA04929E-1AFF-4EB7-935F-E9485C0316DB} EndGlobalSection EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx index c4cead6a..4b37e644 100644 Binary files a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx and b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.inx differ diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj index 4a34c9dc..4cfeed87 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj @@ -26,7 +26,7 @@ Win32 {F915ED95-7BE9-4CDB-B09A-0D3F4C9657FE} osrfx2_DCHU_base - $(LatestTargetPlatformVersion) + 10.0.15063.0 @@ -42,7 +42,7 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -50,7 +50,7 @@ False Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -58,12 +58,12 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary - $(IntDir) + $(SolutionDir)$(Platform)\$(ConfigurationName)\ @@ -137,6 +137,7 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 @@ -162,6 +163,7 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 @@ -187,6 +189,7 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 @@ -212,21 +215,30 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib;$(SDK_LIB_PATH)\WppRecorderUM.lib + 1.0.0.0 + + + + + + + + - + @@ -234,11 +246,19 @@ - - + + + + + + + + + + diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj index 0ef42141..5e015f80 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj @@ -27,7 +27,7 @@ Debug Win32 {1A4A32BA-1596-4F52-BC48-B85A6D8D5D12} - $(LatestTargetPlatformVersion) + 10.0.15063.0 osrfx2_DCHU_filter @@ -44,7 +44,7 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -52,7 +52,7 @@ False Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -60,7 +60,7 @@ True Universal UMDF - WindowsUserModeDriver10.0 + v140 DynamicLibrary @@ -101,7 +101,7 @@ - %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib + %(AdditionalDependencies);$(SDK_LIB_PATH)onecore.lib %(AdditionalIncludeDirectories);..\..\inc @@ -137,7 +137,7 @@ - %(AdditionalDependencies);$(SDK_LIB_PATH)\onecore.lib + %(AdditionalDependencies);$(SDK_LIB_PATH)onecore.lib %(AdditionalIncludeDirectories);..\..\inc diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj index e1450faf..9ac1e4f3 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj @@ -25,7 +25,7 @@ Win32 {F19E45AF-8B05-4204-A66B-9BDBFE333233} osrfx2_DCHU_testapp - $(LatestTargetPlatformVersion) + 10.0.15063.0 @@ -41,7 +41,7 @@ True Universal - WindowsApplicationForDrivers10.0 + v140 Application @@ -49,7 +49,7 @@ False Universal - WindowsApplicationForDrivers10.0 + v140 Application @@ -57,7 +57,7 @@ True Universal - WindowsApplicationForDrivers10.0 + v140 Application diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp new file mode 100644 index 00000000..98a3975c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/CppWindowsService.cpp @@ -0,0 +1,74 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + CppWindowsService.cpp + +Abstract: + + The file defines the entry point of the application. According to the + arguments in the command line, the function installs or uninstalls or + starts the service by calling into different routines. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include +#include +#include "ServiceBase.h" +#include "SampleService.h" +#pragma endregion + +// +// Settings of the service +// + +// +// Internal name of the service +// +#define SERVICE_NAME L"OsrUsbFx2UmUserSvc" + + +/*++ + +Routine Description: + + Entry point for the service. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +INT +wmain( + INT Argc, + WCHAR *Argv[] + ) +{ + CSampleService service(SERVICE_NAME); + + if (!CServiceBase::Run(service)) + { + wprintf(L"Service failed to run w/err 0x%08lx\n", GetLastError()); + } + + return 0; +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp new file mode 100644 index 00000000..e9d24c1b --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp @@ -0,0 +1,1152 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Main.cpp + +Abstract: + + Implements the functions to control the OSR USB FX2 device. + +Environment: + + User mode + +--*/ + +#include "Main.h" +#include "Utils.h" + +// +// Keep track of where the OSRFX2 device's bar graph currently is. +// +INT CurrentBar; +BAR_GRAPH_STATE BarGraphState; + +/*++ + +Routine Description: + + Sets the variables in this service to their default values. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +SetVariables() +{ + CurrentBar = 0; +} + + +/*++ + +Routine Description: + + Retrieves the device path of a given interface. + +Arguments: + + InterfaceGuid - The GUID of the interface to search for + + DevicePath - The resulting device path + + DevicePathLength - The length of DevicePath + +Return Value: + + TRUE if the function succeeded and FALSE otherwise. Errors + are logged in the Application event log. + +--*/ +_Success_(return) +BOOL +GetDevicePath( + _In_ LPGUID InterfaceGuid, + _Out_writes_z_(DevicePathLength) PWCHAR DevicePath, + _In_ size_t DevicePathLength + ) +{ + HRESULT hr = E_FAIL; + BOOL Return = FALSE; + CONFIGRET Status = CR_SUCCESS; + PWSTR DeviceInterfaceList = NULL; + ULONG DeviceInterfaceListLength = 0; + PWSTR NextInterface; + + // + // Determine if there are any interfaces that match the OSRFX2 device. + // + Status = CM_Get_Device_Interface_List_Size(&DeviceInterfaceListLength, + InterfaceGuid, + NULL, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); + + if (Status != CR_SUCCESS) + { + WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", + CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); + goto clean0; + } + + if (DeviceInterfaceListLength < 1) + { + WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", + CM_MapCrToWin32Err(Status, ERROR_EMPTY)); + goto clean0; + } + + DeviceInterfaceList = (PWSTR)malloc(DeviceInterfaceListLength * sizeof(WCHAR)); + + if (DeviceInterfaceList == NULL) + { + WriteToEventLog(L"Failed to allocate memory for the device interface list", + TRACE_LEVEL_ERROR); + goto clean0; + } + + ZeroMemory(DeviceInterfaceList, DeviceInterfaceListLength * sizeof(WCHAR)); + + Status = CM_Get_Device_Interface_List(InterfaceGuid, + NULL, + DeviceInterfaceList, + DeviceInterfaceListLength, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); + + if (Status != CR_SUCCESS) + { + WriteToErrorLog(L"CM_Get_Device_Interface_List", + CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); + goto clean0; + } + + if (*DeviceInterfaceList == UNICODE_NULL) + { + WriteToEventLog(L"CM_Get_Device_Interface_List returned an empty list", + TRACE_LEVEL_ERROR); + } + + // + // This sample only expects one interface for the OSRFX2 device. For other + // devices, though, it maybe necessary to sift through the interfaces + // from CM_Get_Device_Interface_List in order to find the correct device. + // + NextInterface = DeviceInterfaceList + wcslen(DeviceInterfaceList) + 1; + + if (*NextInterface != UNICODE_NULL) + { + WriteToEventLog(L"More than one device interface instance found. " + "Selecting first matching device.", + TRACE_LEVEL_WARNING); + } + + hr = StringCchCopy(DevicePath, DevicePathLength, DeviceInterfaceList); + + if (FAILED(hr)) + { + WriteToErrorLog(L"StringCchCopy", HRESULT_CODE(hr)); + goto clean0; + } + +clean0: + + if (DeviceInterfaceList != NULL) + { + free(DeviceInterfaceList); + } + + if (Status == CR_SUCCESS) + { + Return = TRUE; + } + + return Return; +} + + +/*++ + +Routine Description: + + Opens up the OSR USB FX2 device handle. + +Arguments: + + Synchronous - Whether or not this device should be opened for syncrhonous + access + +Return Value: + + The handle to the OSR USB FX2 device. + +--*/ +_Check_return_ +_Ret_notnull_ +_Success_(return != INVALID_HANDLE_VALUE) +HANDLE +OpenDevice( + _In_ BOOL Synchronous +) +{ + HANDLE DeviceHandle; + WCHAR DeviceName[MAX_DEVPATH_LENGTH]; + + if (!GetDevicePath((LPGUID)&GUID_DEVINTERFACE_OSRUSBFX2, + DeviceName, + sizeof(DeviceName) / sizeof(DeviceName[0]))) + { + return INVALID_HANDLE_VALUE; + } + + // + // Open a handle to the interface. + // + if (Synchronous) + { + DeviceHandle = CreateFile(DeviceName, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, // default security + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + } + else + { + DeviceHandle = CreateFile(DeviceName, + GENERIC_WRITE | GENERIC_READ, + FILE_SHARE_WRITE | FILE_SHARE_READ, + NULL, // default security + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, + NULL); + } + + if (DeviceHandle == INVALID_HANDLE_VALUE) + { + WriteToErrorLog(L"CreateFile", GetLastError()); + } + else + { + WriteToEventLog(L"Opened Device Successfully", TRACE_LEVEL_INFORMATION); + } + + return DeviceHandle; +} + + +/*++ + +Routine Description: + + Handles an interface arrival notification. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +InterfaceArrivalAction( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + // + // Now that the interface has arrived, open a handle to it, and then + // register that handle for device events. + // + EnterCriticalSection(&Context->Lock); + + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + // + // The handle was already retrieved. + // + Err = ERROR_SUCCESS; + goto cleanup; + } + + Context->DeviceInterfaceHandle = OpenDevice(FALSE); + + if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + Err = GetLastError(); + WriteToErrorLog(L"Could not open device interface", Err); + goto cleanup; + } + + Err = RegisterDeviceNotifications(Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not register device notifications", Err); + goto cleanup; + } + +cleanup: + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles an interface arrival notification. + +Arguments: + + hNotify - The notification that fired the callback + + hContext - The callback context + + Action - The type of notification + + EventData - Additional information about the callback + + EventDataSize - The size of EventData + +Return Value: + + A Win32 error code. + +--*/ +DWORD +InterfaceCallback( + _In_ HCMNOTIFICATION hNotify, + _In_ PVOID hContext, + _In_ CM_NOTIFY_ACTION Action, + _In_ PCM_NOTIFY_EVENT_DATA EventData, + _In_ DWORD EventDataSize + ) +{ + DWORD Err = ERROR_SUCCESS; + PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + + // + // Validate Context. + // + if (Context == NULL) + { + goto cleanup; + } + + if (Action == CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL) + { + Err = InterfaceArrivalAction(Context); + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Registers the service for notifications using the notification handle in + Context. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +RegisterInterfaceNotifications( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + CONFIGRET cr; + CM_NOTIFY_FILTER NotifyFilter = {0}; + + if (Context == NULL) + { + goto cleanup; + } + + ZeroMemory(&NotifyFilter, sizeof(NotifyFilter)); + NotifyFilter.cbSize = sizeof(NotifyFilter); + NotifyFilter.FilterType = CM_NOTIFY_FILTER_TYPE_DEVICEINTERFACE; + NotifyFilter.u.DeviceInterface.ClassGuid = GUID_DEVINTERFACE_OSRUSBFX2; + + cr = CM_Register_Notification(&NotifyFilter, + (PVOID)Context, + (PCM_NOTIFY_CALLBACK)InterfaceCallback, + &Context->InterfaceNotificationHandle); + + if (cr != CR_SUCCESS) + { + Err = CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); + WriteToErrorLog(L"CM_Register_Notification", Err); + goto cleanup; + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Unregister for interface notifications. Note, this routine deadlocks + when called from an interface callback. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +UnregisterInterfaceNotifications( + PHANDLE_CONTEXT Context + ) +{ + CONFIGRET cr; + + if (Context->InterfaceNotificationHandle != NULL) + { + cr = CM_Unregister_Notification(Context->InterfaceNotificationHandle); + + Context->InterfaceNotificationHandle = NULL; + } + + return CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); +} + + +/*++ + +Routine Description: + + Callback for when a device is being query removed. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceQueryRemoveAction( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + // + // Close open handles to allow the device to exit + // + CloseHandle(Context->DeviceInterfaceHandle); + + Context->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + This callback avoids a deadlock when unregistering device notifications. + Rather than calling CM_Unregister_Notification from the callback, the + callback gives that work to a separate thread to avoid deadlock. + +Arguments: + + Instance - The thread's callback instance + + hContext - The callback context + + pWork - The thread handle + +Return Value: + + VOID + +--*/ +VOID +CALLBACK +UnregisterWorkerThreadCallback( + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _Inout_opt_ PVOID hContext, + _Inout_ PTP_WORK pWork + ) +{ + PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + + EnterCriticalSection(&Context->Lock); + + UnregisterDeviceNotifications(Context); + + // + // Close the device handle. + // + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + CloseHandle(Context->DeviceInterfaceHandle); + + Context->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + } + + LeaveCriticalSection(&Context->Lock); +} + + +/*++ + +Routine Description: + + Handles a device query remove failed notification. + +Arguments: + + hNotify - The notification that spurred this callback + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceQueryRemoveFailedAction( + HCMNOTIFICATION hNotify, + PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + // + // In case this callback fires before the registration call returns, make + // sure the notification handle is properly set. + // + Context->InterfaceNotificationHandle = hNotify; + + // + // Unregister the device callback, and then close the handle + // + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } + + LeaveCriticalSection(&Context->Lock); + + // + // Wait for the callback and then re-register the device + // + WaitForThreadpoolWorkCallbacks(Context->Work, FALSE); + + EnterCriticalSection(&Context->Lock); + + if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + Context->DeviceInterfaceHandle = OpenDevice(FALSE); + } + + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + RegisterDeviceNotifications(Context); + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles a device remove pending notification. + +Arguments: + + hNotify - The notification that spurred this callback + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceRemovePendingAction( + HCMNOTIFICATION hNotify, + PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + // + // In case this callback fires before the registration call returns, make + // sure the notification handle is properly set. + // + Context->InterfaceNotificationHandle = hNotify; + + // + // Unregister the device callback, and then close the handle + // + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles a device remove complete notification. + +Arguments: + + hNotify - The notification that spurred this callback + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceRemoveCompleteAction( + HCMNOTIFICATION hNotify, + PHANDLE_CONTEXT Context + ) +{ + __debugbreak(); + + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + // + // In case this callback fires before the registration call returns, make + // sure the notification handle is properly set. + // + Context->InterfaceNotificationHandle = hNotify; + + // + // Unregister the device callback, and then close the handle + // + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } + + LeaveCriticalSection(&Context->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Handles device notifications. + +Arguments: + + hNotify - The notification that spurred this callback + + hContext - The callback context + + Action - The type of callback + + EventData - Additional information about this callback + + EventDataSize - The size of EventData + +Return Value: + + A Win32 error code. + +--*/ +DWORD +DeviceCallback( + _In_ HCMNOTIFICATION hNotify, + _In_ PVOID hContext, + _In_ CM_NOTIFY_ACTION Action, + _In_ PCM_NOTIFY_EVENT_DATA EventData, + _In_ DWORD EventDataSize +) +{ + DWORD Err = ERROR_SUCCESS; + PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + + // + // Validate Context. + // + if (Context == NULL) + { + goto cleanup; + } + + switch (Action) + { + + case CM_NOTIFY_ACTION_DEVICEQUERYREMOVE: + DeviceQueryRemoveAction(Context); + break; + + case CM_NOTIFY_ACTION_DEVICEQUERYREMOVEFAILED: + DeviceQueryRemoveFailedAction(hNotify, Context); + break; + + case CM_NOTIFY_ACTION_DEVICEREMOVEPENDING: + DeviceRemovePendingAction(hNotify, Context); + break; + + case CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE: + DeviceRemoveCompleteAction(hNotify, Context); + break; + + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Register for device notifications. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +RegisterDeviceNotifications( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + CONFIGRET cr; + CM_NOTIFY_FILTER NotifyFilter = {0}; + + NotifyFilter.cbSize = sizeof(NotifyFilter); + NotifyFilter.FilterType = CM_NOTIFY_FILTER_TYPE_DEVICEHANDLE; + NotifyFilter.u.DeviceHandle.hTarget = Context->DeviceInterfaceHandle; + + cr = CM_Register_Notification(&NotifyFilter, + (PVOID)Context, + (PCM_NOTIFY_CALLBACK)DeviceCallback, + &Context->DeviceNotificationHandle); + + if (cr != CR_SUCCESS) + { + Err = CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); + WriteToEventLog(L"Could not register for notifications", TRACE_LEVEL_WARNING); + goto cleanup; + } + + Context->Unregister = FALSE; + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Unregister for device notifications. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +UnregisterDeviceNotifications( + PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + CONFIGRET cr; + + if (Context->DeviceNotificationHandle != NULL) + { + cr = CM_Unregister_Notification(Context->DeviceNotificationHandle); + + if (cr != CR_SUCCESS) + { + Err = CM_MapCrToWin32Err(cr, ERROR_INVALID_DATA); + WriteToEventLog(L"Could not unregister notifications", TRACE_LEVEL_WARNING); + } + + Context->DeviceNotificationHandle = NULL; + } + + return Err; +} + + +/*++ + +Routine Description: + + Initialize the given PHANDLE_CONTEXT. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +InitializeContext( + _Out_ PHANDLE_CONTEXT* Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + *Context = (PHANDLE_CONTEXT)malloc(sizeof(HANDLE_CONTEXT)); + + if (*Context == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + (*Context)->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + + InitializeCriticalSection(&(*Context)->Lock); + + (*Context)->Work = CreateThreadpoolWork(UnregisterWorkerThreadCallback, (PVOID)(*Context), NULL); + + if ((*Context)->Work == NULL) + { + WriteToErrorLog(L"Could not create worker thread callback", ERROR_OUTOFMEMORY); + goto cleanup; + } + + (*Context)->DeviceNotificationHandle = NULL; + (*Context)->InterfaceNotificationHandle = NULL; + + // + // Register for device interface events to open and close the handle to + // the interface. + // + Err = RegisterInterfaceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not register notifications", Err); + goto cleanup; + } + + EnterCriticalSection(&(*Context)->Lock); + + // + // The interface may already have arrived while registering for + // notifications. + // + if ((*Context)->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + (*Context)->DeviceInterfaceHandle = OpenDevice(FALSE); + } + + if ((*Context)->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + Err = RegisterDeviceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not register device notifications", Err); + goto cleanup; + } + } + + // + // If OpenDevice ends up returning INVALID_HANDLE_VALUE, that's fine + // since a notification for the interface will arrive later. + // + +cleanup: + + LeaveCriticalSection(&(*Context)->Lock); + + return Err; +} + + +/*++ + +Routine Description: + + Clean up the given PHANDLE_CONTEXT. + +Arguments: + + Context - The callback context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +CloseContext( + _In_ PHANDLE_CONTEXT* Context + ) +{ + DWORD Err = ERROR_SUCCESS; + BOOL Unregister = FALSE; + + if ((Context == NULL) || + (*Context == NULL)) + { + // + // Nothing to remove. + // + goto cleanup; + } + + EnterCriticalSection(&(*Context)->Lock); + + if (!(*Context)->Unregister) + { + // + // Unregister from the callback here. + // + Unregister = TRUE; + (*Context)->Unregister = TRUE; + } + + LeaveCriticalSection(&(*Context)->Lock); + + // + // Unregister from the interface first, so that re-appearance of the interface + // doesn't cause us to register device events again. + // + Err = UnregisterInterfaceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not unregister interface notifications", Err); + } + + if (Unregister) + { + Err = UnregisterDeviceNotifications(*Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not unregister device notifications", Err); + } + } + else + { + WaitForThreadpoolWorkCallbacks((*Context)->Work, FALSE); + } + + // + // No need to lock here, UnregisterDeviceNotifications will wait for all + // outstanding callbacks before returning. + // + if ((*Context)->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + CloseHandle((*Context)->DeviceInterfaceHandle); + + (*Context)->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + } + + if ((*Context)->Work != NULL) + { + CloseThreadpoolWork((*Context)->Work); + } + + DeleteCriticalSection(&(*Context)->Lock); + + free(*Context); + + *Context = NULL; + +cleanup: + + return Err; +} + +/*++ + +Routine Description: + + Turns off all of the bar graph lights on the OSR USB FX2 device. + +Arguments: + + Context - The callback context + +Return Value: + + VOID + +--*/ +DWORD +ClearAllBars( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + ULONG BytesReturned; + + BarGraphState.BarsAsUChar = 0; + + if (!DeviceIoControl(Context->DeviceInterfaceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &BarGraphState, // Pointer to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Pointer to OutBuffer + 0, // Length of OutBuffer + &BytesReturned, // BytesReturned + 0)) // Pointer to Overlapped structure + { + Err = GetLastError(); + WriteToErrorLog(L"DeviceIOControl", Err); + goto cleanup; + } + +cleanup: + + return Err; +} + + +/*++ + +Routine Description: + + Lights the next bar on the OSR USB FX2 device. + +Arguments: + + Context - The callback context + +Return Value: + + VOID + +--*/ +DWORD +LightNextBar( + _In_ PHANDLE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + ULONG BytesReturned; + + // + // Normalize to 0-7 + // + CurrentBar += 1; + + if (CurrentBar > 7) + { + CurrentBar = 0; + } + + BarGraphState.BarsAsUChar = 1 << (UCHAR)CurrentBar; + + if (!DeviceIoControl(Context->DeviceInterfaceHandle, + IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, + &BarGraphState, // Pointer to InBuffer + sizeof(BAR_GRAPH_STATE), // Length of InBuffer + NULL, // Pointer to OutBuffer + 0, // Length of OutBuffer + &BytesReturned, // BytesReturned + 0)) // Pointer to Overlapped structure + { + Err = GetLastError(); + WriteToErrorLog(L"DeviceIOControl", Err); + goto cleanup; + } + +cleanup: + + return Err; +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h new file mode 100644 index 00000000..ecdfa4ad --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h @@ -0,0 +1,342 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Main.h + +Abstract: + + Implements the functions to control the OSR USB FX2 device. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +// {573E8C73-0CB4-4471-A1BF-FAB26C31D384} +DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, + 0x573e8c73, 0xcb4, 0x4471, 0xa1, 0xbf, 0xfa, 0xb2, 0x6c, 0x31, 0xd3, 0x84); + +// +// Most device interface paths will fit into a buffer of this size. +// However, some could be longer, and a larger buffer or dynamically +// allocated buffer may be needed for robust code. +// +#define MAX_DEVPATH_LENGTH 1024 + +#pragma warning(push) +#pragma warning(disable:4201) // nameless struct/union +#pragma warning(disable:4214) // bit field types other than int + +typedef struct _HANDLE_CONTEXT { + HANDLE DeviceInterfaceHandle; + CRITICAL_SECTION Lock; + PTP_WORK Work; + BOOL Unregister; + HCMNOTIFICATION InterfaceNotificationHandle; + HCMNOTIFICATION DeviceNotificationHandle; +} HANDLE_CONTEXT, *PHANDLE_CONTEXT; + +// +// Define the structures that will be used by the IOCTL +// interface to the driver +// + +// +// BAR_GRAPH_STATE +// +// BAR_GRAPH_STATE is a bit field structure with each +// bit corresponding to one of the bar graph on the +// OSRFX2 Development Board +// +#include +typedef struct _BAR_GRAPH_STATE { + + union { + + struct { + // + // Individual bars starting from the + // top of the stack of bars + // + // NOTE: There are actually 10 bars, + // but the very top two do not light + // and are not counted here + // + UCHAR Bar1 : 1; + UCHAR Bar2 : 1; + UCHAR Bar3 : 1; + UCHAR Bar4 : 1; + UCHAR Bar5 : 1; + UCHAR Bar6 : 1; + UCHAR Bar7 : 1; + UCHAR Bar8 : 1; + }; + + // + // The state of all the bar graph as a single + // UCHAR + // + UCHAR BarsAsUChar; + + }; + +}BAR_GRAPH_STATE, *PBAR_GRAPH_STATE; + +// +// SWITCH_STATE +// +// SWITCH_STATE is a bit field structure with each +// bit corresponding to one of the switches on the +// OSRFX2 Development Board +// +typedef struct _SWITCH_STATE { + + union { + struct { + // + // Individual switches starting from the + // left of the set of switches + // + UCHAR Switch1 : 1; + UCHAR Switch2 : 1; + UCHAR Switch3 : 1; + UCHAR Switch4 : 1; + UCHAR Switch5 : 1; + UCHAR Switch6 : 1; + UCHAR Switch7 : 1; + UCHAR Switch8 : 1; + }; + + // + // The state of all the switches as a single + // UCHAR + // + UCHAR SwitchesAsUChar; + + }; + + +}SWITCH_STATE, *PSWITCH_STATE; + +#include + +#pragma warning(pop) + +#define IOCTL_INDEX 0x800 +#define FILE_DEVICE_OSRUSBFX2 65500U + +#define IOCTL_OSRUSBFX2_GET_CONFIG_DESCRIPTOR CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + +#define IOCTL_OSRUSBFX2_RESET_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 1, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + +#define IOCTL_OSRUSBFX2_REENUMERATE_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 3, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + +#define IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 4, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + + +#define IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 5, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + + +#define IOCTL_OSRUSBFX2_READ_SWITCHES CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 6, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + + +#define IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 7, \ + METHOD_BUFFERED, \ + FILE_READ_ACCESS) + + +#define IOCTL_OSRUSBFX2_SET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ + IOCTL_INDEX + 8, \ + METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) + +#define IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE CTL_CODE(FILE_DEVICE_OSRUSBFX2,\ + IOCTL_INDEX + 9, \ + METHOD_OUT_DIRECT, \ + FILE_READ_ACCESS) + +/*++ + +Routine Description: + + Sets the variables in this service to their default values. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID SetVariables(VOID); + + +/*++ + +Routine Description: + + Opens up the OSR USB FX2 device handle. + +Arguments: + + Synchronous - Whether or not this device should be + opened for synchronous access + +Return Value: + + The handle to the OSR USB FX2 device. + +--*/ +HANDLE OpenDevice(_In_ BOOL Synchronous); + + +/*++ + +Routine Description: + + Turns off all of the bar graph lights on the OSR USB FX2 device. + +Arguments: + + DeviceHandle - The handle to the OSR USB FX2 device. + +Return Value: + + VOID + +--*/ +DWORD ClearAllBars(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + + Lights the next bar on the OSR USB FX2 device. + +Arguments: + + DeviceHandle - The handle to the OSR USB FX2 device. + +Return Value: + +VOID + +--*/ +DWORD LightNextBar(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + +Register for device notifications. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD RegisterDeviceNotifications(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + +Unregister for device notifications. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD UnregisterDeviceNotifications(PHANDLE_CONTEXT Context); + + +/*++ + +Routine Description: + +Initialize the given PHANDLE_CONTEXT. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD InitializeContext(PHANDLE_CONTEXT* Context); + + +/*++ + +Routine Description: + +Clean up the given PHANDLE_CONTEXT. + +Arguments: + +Context - The callback context + +Return Value: + +A Win32 error code. + +--*/ +DWORD CloseContext(PHANDLE_CONTEXT* Context); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp new file mode 100644 index 00000000..0a246eb4 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp @@ -0,0 +1,287 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + SampleService.cpp + +Abstract: + + Provides a sample service class that derives from the service base class - + CServiceBase. The sample service logs the service start and stop + information to the Application event log, and shows how to run the main + function of the service in a thread pool worker thread. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include "SampleService.h" +#include "ThreadPool.h" +#pragma endregion + +// +// Variables used for device notifications should normally be local. However, +// we must use a global variable here since there is a potential race condition +// when the service needs to restart during device installation that could +// cause the service to prevent the device from being restarted as well. So, +// this variable is global so that the services OnStart and OnStart method can +// handle its creation and destruction. +// +PHANDLE_CONTEXT Context; + +/*++ + +Routine Description: + + The constructor of CSampleService. It initializes a new instance + of the CSampleService class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. Inherits properties from the class CServiceBase. + +Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + +Return Value: + + VOID + +--*/ +CSampleService::CSampleService( + PWSTR ServiceName, + BOOL CanStop, + BOOL CanShutdown, + BOOL CanPauseContinue + ) +: CServiceBase(ServiceName, CanStop, CanShutdown, CanPauseContinue) +{ + m_fStopping = FALSE; + + // + // Create a manual-reset event that is not signaled at first to indicate + // the stopped signal of the service. + // + m_hStoppedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + if (m_hStoppedEvent == NULL) + { + throw GetLastError(); + } +} + + +/*++ + +Routine Description: + + The virtual destructor of CSampleService. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +CSampleService::~CSampleService() +{ + if (m_hStoppedEvent) + { + CloseHandle(m_hStoppedEvent); + m_hStoppedEvent = NULL; + } +} + + +/*++ + +Routine Description: + + This function is executed when a Start command is sent to the + service by the SCM or when the operating system starts (for a service + that starts automatically). It specifies actions to take when the + service starts. In this code sample, OnStart logs a service-start + message to the Application log, and queues the main service function for + execution in a thread pool worker thread. + + NOTE: A service application is designed to be long running. Therefore, + it usually polls or monitors something in the system. The monitoring is + set up in the OnStart method. However, OnStart does not actually do the + monitoring. The OnStart method must return to the operating system after + the service's operation has begun. It must not loop forever or block. To + set up a simple monitoring mechanism, one general solution is to create + a timer in OnStart. The timer would then raise events in your code + periodically, at which time your service could do its monitoring. The + other solution is to spawn a new thread to perform the main service + functions, which is demonstrated in this code sample. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CSampleService::OnStart( + DWORD Argc, + PWSTR *Argv + ) +{ + // + // Log a service start message to the Application log. + // + WriteToEventLog(L"SampleService in OnStart", + EVENTLOG_INFORMATION_TYPE); + + // + // Set up any variables the service needs. + // + SetVariables(); + + // + // Set up the context, and register for notifications. + // + InitializeContext(&Context); + + // + // Queue the main service function for execution in a worker thread. + // + CThreadPool::QueueUserWorkItem(&CSampleService::ServiceWorkerThread, this); +} + + +/*++ + +Routine Description: + + This method performs the main function of the service. It runs + on a thread pool worker thread. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CSampleService::ServiceWorkerThread() +{ + DWORD Err = ERROR_SUCCESS; + + // + // Periodically check if the service is stopping. + // + while (!m_fStopping) + { + // + // Perform main service function here... + // + + // + // Wait for the device to arrive. + // + if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + ::Sleep(2000); + continue; + } + + Err = ClearAllBars(Context); + + if (Err != ERROR_SUCCESS) + { + continue; + } + + Err = LightNextBar(Context); + + if (Err != ERROR_SUCCESS) + { + continue; + } + + ::Sleep(2000); // Simulate some lengthy operations. + } + + // + // Signal the stopped event. + // + SetEvent(m_hStoppedEvent); +} + + +/*++ + +Routine Description: + + This function is executed when a Stop command is sent to the service by SCM. + It specifies actions to take when a service stops running. In this code + sample, OnStop logs a service-stop message to the Application log, and + waits for the finish of the main service function. + + Be sure to periodically call ReportServiceStatus() with + SERVICE_STOP_PENDING if the procedure is going to take a long time. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CSampleService::OnStop() +{ + __debugbreak(); + + // + // Log a service stop message to the Application log. + // + WriteToEventLog(L"SampleService in OnStop", + EVENTLOG_INFORMATION_TYPE); + + // + // Indicate that the service is stopping and wait for the finish of the + // main service function (ServiceWorkerThread). + // + m_fStopping = TRUE; + + if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0) + { + throw GetLastError(); + } + + // + // Clean up the context after the worker thread has finished. + // + CloseContext(&Context); +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h new file mode 100644 index 00000000..eee8a609 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h @@ -0,0 +1,174 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + SampleService.h + +Abstract: + + Provides a sample service class that derives from the service base class - + CServiceBase. The sample service logs the service start and stop + information to the Application event log, and shows how to run the main + function of the service in a thread pool worker thread. + +Environment: + + User mode + +--*/ + +#pragma once + +#include "ServiceBase.h" +#include "Main.h" + +class CSampleService : public CServiceBase +{ +public: + + /*++ + + Routine Description: + + The constructor of CSampleService. It initializes a new instance + of the CSampleService class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. Inherits properties from the class CServiceBase. + + Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + + Return Value: + + VOID + + --*/ + CSampleService(PWSTR ServiceName, + BOOL CanStop = TRUE, + BOOL CanShutdown = TRUE, + BOOL CanPauseContinue = FALSE); + + /*++ + + Routine Description: + + The virtual destructor of CSampleService. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual ~CSampleService(); + +protected: + + /*++ + + Routine Description: + + This function is executed when a Start command is sent to the + service by the SCM or when the operating system starts (for a service + that starts automatically). It specifies actions to take when the + service starts. In this code sample, OnStart logs a service-start + message to the Application log, and queues the main service function for + execution in a thread pool worker thread. + + NOTE: A service application is designed to be long running. Therefore, + it usually polls or monitors something in the system. The monitoring is + set up in the OnStart method. However, OnStart does not actually do the + monitoring. The OnStart method must return to the operating system after + the service's operation has begun. It must not loop forever or block. To + set up a simple monitoring mechanism, one general solution is to create + a timer in OnStart. The timer would then raise events in your code + periodically, at which time your service could do its monitoring. The + other solution is to spawn a new thread to perform the main service + functions, which is demonstrated in this code sample. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + virtual VOID OnStart(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + This function is executed when a Stop command is sent to the service by SCM. + It specifies actions to take when a service stops running. In this code + sample, OnStop logs a service-stop message to the Application log, and + waits for the finish of the main service function. + + Be sure to periodically call ReportServiceStatus() with + SERVICE_STOP_PENDING if the procedure is going to take a long time. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnStop(); + + + /*++ + + Routine Description: + + This method performs the main function of the service. It runs + on a thread pool worker thread. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID ServiceWorkerThread(); + +private: + + // + // Determines if the service is currently stopping. + // + BOOL m_fStopping; + + // + // The handle to wait for a stop event. + // + HANDLE m_hStoppedEvent; +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp new file mode 100644 index 00000000..4c20af2e --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.cpp @@ -0,0 +1,794 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + ServiceBase.cpp + +Abstract: + + Provides a base class for a service that will exist as part of a service + application. CServiceBase must be derived from when creating a new service + class. + +Environment: + + User mode + +--*/ + +#pragma region Includes +#include "ServiceBase.h" +#include "Main.h" +#include "Utils.h" +#include +#include +#pragma endregion + + +#pragma region Static Members + +// +// Initialize the singleton service instance. +// +CServiceBase *CServiceBase::s_service = NULL; + + +/*++ + +Routine Description: + + Register the executable for a service with the Service Control + Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start + command, which results in a call to the OnStart method in the service. + This method blocks until the service has stopped. + +Arguments: + + Service - The reference to a CServiceBase object. It will become the + singleton service instance of this service application. + +Return Value: + + If the function succeeds, the return value is TRUE. If the function + fails, the return value is FALSE. To get extended error information, + call GetLastError. + +--*/ +BOOL +CServiceBase::Run( + CServiceBase &Service + ) +{ + s_service = &Service; + + SERVICE_TABLE_ENTRY serviceTable[] = + { + { Service.m_name, ServiceMain }, + { NULL, NULL } + }; + + // + // Connects the main thread of a service process to the service control + // manager, which causes the thread to be the service control dispatcher + // thread for the calling process. This call returns when the service has + // stopped. The process should simply terminate when the call returns. + // + return StartServiceCtrlDispatcher(serviceTable); +} + + +/*++ + +Routine Description: + + The entry point for the service. It registers the handler function + for the service and starts the service. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +WINAPI +CServiceBase::ServiceMain( + DWORD Argc, + PWSTR *Argv + ) +{ + assert(s_service != NULL); + + // + // Register the handler function for the service. + // + s_service->m_statusHandle = RegisterServiceCtrlHandler(s_service->m_name, + ServiceCtrlHandler); + + if (s_service->m_statusHandle == NULL) + { + throw GetLastError(); + } + + // + // Start the service. + // + s_service->Start(Argc, Argv); +} + + +/*++ + +Routine Description: + + Called by the SCM whenever a control code is sent to the service. + +Arguments: + + CtrlCode - The control code. This parameter can be one of + the following values: + + SERVICE_CONTROL_CONTINUE + SERVICE_CONTROL_INTERROGATE + SERVICE_CONTROL_NETBINDADD + SERVICE_CONTROL_NETBINDDISABLE + SERVICE_CONTROL_NETBINDREMOVE + SERVICE_CONTROL_PARAMCHANGE + SERVICE_CONTROL_PAUSE + SERVICE_CONTROL_SHUTDOWN + SERVICE_CONTROL_STOP + + This parameter can also be a user-defined control + code ranging from 128 to 255. + +Return Value: + + VOID + +--*/ +VOID +WINAPI +CServiceBase::ServiceCtrlHandler( + DWORD Ctrl + ) +{ + switch (Ctrl) + { + case SERVICE_CONTROL_STOP: + s_service->Stop(); + break; + case SERVICE_CONTROL_PAUSE: + s_service->Pause(); + break; + case SERVICE_CONTROL_CONTINUE: + s_service->Continue(); + break; + case SERVICE_CONTROL_SHUTDOWN: + s_service->Shutdown(); + break; + case SERVICE_CONTROL_INTERROGATE: + break; + default: + break; + } +} + +#pragma endregion + + +#pragma region Service Constructor and Destructor + +/*++ + +Routine Description: + + The constructor of CServiceBase. It initializes a new instance + of the CServiceBase class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. + +Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + +Return Value: + + VOID + +--*/ +CServiceBase::CServiceBase( + PWSTR ServiceName, + BOOL CanStop, + BOOL CanShutdown, + BOOL CanPauseContinue + ) +{ + // + // Service name must be a valid string and cannot be NULL. + // + m_name = (ServiceName == NULL) ? L"" : ServiceName; + + m_statusHandle = NULL; + + // + // The service runs in its own process. + // + m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + + // + // The service is starting. + // + m_status.dwCurrentState = SERVICE_START_PENDING; + + // + // The accepted commands of the service. + // + DWORD dwControlsAccepted = 0; + + if (CanStop) + { + dwControlsAccepted |= SERVICE_ACCEPT_STOP; + } + + if (CanShutdown) + { + dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN; + } + + if (CanPauseContinue) + { + dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE; + } + + m_status.dwControlsAccepted = dwControlsAccepted; + + m_status.dwWin32ExitCode = NO_ERROR; + m_status.dwServiceSpecificExitCode = 0; + m_status.dwCheckPoint = 0; + m_status.dwWaitHint = 0; + + SetupEvents(); +} + + +/*++ + +Routine Description: + + The virtual destructor of CServiceBase. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +CServiceBase::~CServiceBase() +{ + DestroyEvents(); +} + +#pragma endregion + + +#pragma region Service Start, Stop, Pause, Continue, and Shutdown + +/*++ + +Routine Description: + + This function starts the service. It calls the OnStart virtual function + in which you can specify the actions to take when the service starts. If + an error occurs during the startup, the error will be logged in the + Application event log, and the service will be stopped. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Start( + DWORD Argc, + PWSTR *Argv +) +{ + try + { + // + // Tell SCM that the service is starting. + // + SetServiceStatus(SERVICE_START_PENDING); + + // + // Perform service-specific initialization. + // + OnStart(Argc, Argv); + + // + // Tell SCM that the service is started. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Start", Error); + + // + // Set the service status to be stopped. + // + SetServiceStatus(SERVICE_STOPPED, Error); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to start.", EVENTLOG_ERROR_TYPE); + + // + // Set the service status to be stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Start + command is sent to the service by the SCM or when the operating system + starts (for a service that starts automatically). Specifies actions to + take when the service starts. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the + procedure is going to take long time. You may also consider spawning a + new thread in OnStart to perform time-consuming initialization tasks. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnStart( + DWORD Argc, + PWSTR *Argv +) +{ + SetVariables(); +} + + +/*++ + +Routine Description: + + This function stops the service. It calls the OnStop virtual + function in which you can specify the actions to take when the service + stops. If an error occurs, the error will be logged in the Application + event log, and the service will be restored to the original state. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Stop() +{ + DWORD OriginalState = m_status.dwCurrentState; + + try + { + // + // Tell SCM that the service is stopping. + // + SetServiceStatus(SERVICE_STOP_PENDING); + + // + // Perform service-specific stop operations. + // + OnStop(); + + // + // Tell SCM that the service is stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Stop", Error); + + // + // Set the orginal service status. + // + SetServiceStatus(OriginalState); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to stop.", EVENTLOG_ERROR_TYPE); + + // + // Set the orginal service status. + // + SetServiceStatus(OriginalState); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Stop + command is sent to the service by the SCM. Specifies actions to take + when a service stops running. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the + procedure is going to take long time. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnStop() +{ +} + + +/*++ + +Routine Description: + + The function pauses the service if the service supports pause + and continue. It calls the OnPause virtual function in which you can + specify the actions to take when the service pauses. If an error occurs, + the error will be logged in the Application event log, and the service + will become running. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Pause() +{ + try + { + // + // Tell SCM that the service is pausing. + // + SetServiceStatus(SERVICE_PAUSE_PENDING); + + // + // Perform service-specific pause operations. + // + OnPause(); + + // + // Tell SCM that the service is paused. + // + SetServiceStatus(SERVICE_PAUSED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Pause", Error); + + // + // Tell SCM that the service is still running. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to pause.", EVENTLOG_ERROR_TYPE); + + // + // Tell SCM that the service is still running. + // + SetServiceStatus(SERVICE_RUNNING); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when a Pause + command is sent to the service by the SCM. Specifies actions to take + when a service pauses. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnPause() +{ +} + + +/*++ + +Routine Description: + + The function resumes normal functioning after being paused if + the service supports pause and continue. It calls the OnContinue virtual + function in which you can specify the actions to take when the service + continues. If an error occurs, the error will be logged in the + Application event log, and the service will still be paused. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Continue() +{ + try + { + // + // Tell SCM that the service is resuming. + // + SetServiceStatus(SERVICE_CONTINUE_PENDING); + + // + // Perform service-specific continue operations. + // + OnContinue(); + + // + // Tell SCM that the service is running. + // + SetServiceStatus(SERVICE_RUNNING); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Continue", Error); + + // + // Tell SCM that the service is still paused. + // + SetServiceStatus(SERVICE_PAUSED); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to resume.", EVENTLOG_ERROR_TYPE); + + // + // Tell SCM that the service is still paused. + // + SetServiceStatus(SERVICE_PAUSED); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, OnContinue runs when a + Continue command is sent to the service by the SCM. Specifies actions to + take when a service resumes normal functioning after being paused. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnContinue() +{ +} + + +/*++ + +Routine Description: + + The function executes when the system is shutting down. It + calls the OnShutdown virtual function in which you can specify what + should occur immediately prior to the system shutting down. If an error + occurs, the error will be logged in the Application event log. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::Shutdown() +{ + try + { + // + // Perform service-specific shutdown operations. + // + OnShutdown(); + + // + // Tell SCM that the service is stopped. + // + SetServiceStatus(SERVICE_STOPPED); + } + catch (DWORD Error) + { + // + // Log the error. + // + WriteToErrorLog(L"Service Shutdown", Error); + } + catch (...) + { + // + // Log the error. + // + WriteToEventLog(L"Service failed to shut down.", EVENTLOG_ERROR_TYPE); + } +} + + +/*++ + +Routine Description: + + When implemented in a derived class, executes when the system + is shutting down. Specifies what should occur immediately prior to the + system shutting down. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::OnShutdown() +{ +} + +#pragma endregion + + +#pragma region Helper Functions + +/*++ + +Routine Description: + + The function sets the service status and reports the status to the SCM. + +Arguments: + + CurrentState - The current state of the service + + Win32ExitCode - The error code to report + + WaitHint - The estimated time for pending operation, in milliseconds + +Return Value: + + VOID + +--*/ +VOID +CServiceBase::SetServiceStatus( + DWORD CurrentState, + DWORD Win32ExitCode, + DWORD WaitHint + ) +{ + static DWORD CheckPoint = 1; + + // + // Fill in the SERVICE_STATUS structure of the service. + // + + m_status.dwCurrentState = CurrentState; + m_status.dwWin32ExitCode = Win32ExitCode; + m_status.dwWaitHint = WaitHint; + + m_status.dwCheckPoint = ((CurrentState == SERVICE_RUNNING) || + (CurrentState == SERVICE_STOPPED)) ? 0 : + CheckPoint++; + + // + // Report the status of the service to the SCM. + // + ::SetServiceStatus(m_statusHandle, &m_status); +} + +#pragma endregion \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h new file mode 100644 index 00000000..106597e1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ServiceBase.h @@ -0,0 +1,423 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + ServiceBase.cpp + +Abstract: + + Provides a base class for a service that will exist as part of a service + application. CServiceBase must be derived from when creating a new service + class. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include "Utils.h" + +class CServiceBase +{ +public: + + /*++ + + Routine Description: + + Register the executable for a service with the Service Control + Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start + command, which results in a call to the OnStart method in the service. + This method blocks until the service has stopped. + + Arguments: + + Service - The reference to a CServiceBase object. It will become the + singleton service instance of this service application. + + Return Value: + + If the function succeeds, the return value is TRUE. If the function + fails, the return value is FALSE. To get extended error information, + call GetLastError. + + --*/ + static BOOL Run(CServiceBase &service); + + + /*++ + + Routine Description: + + The constructor of CServiceBase. It initializes a new instance + of the CServiceBase class. The optional parameters (CanStop, + CanShutdown and CanPauseContinue) allow you to specify whether the + service can be stopped, paused and continued, or be notified when system + shutdown occurs. + + Arguments: + + ServiceName - The name of the service + + CanStop - The service can be stopped + + CanShutdown - The service is notified when system shutdown occurs + + CanPauseContinue - The service can be paused and continued + + Return Value: + + VOID + + --*/ + CServiceBase(PWSTR ServiceName, + BOOL CanStop = TRUE, + BOOL CanShutdown = TRUE, + BOOL CanPauseContinue = FALSE); + + + /*++ + + Routine Description: + + The virtual destructor of CServiceBase. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual ~CServiceBase(); + + + /*++ + + Routine Description: + + This function stops the service. It calls the OnStop virtual + function in which you can specify the actions to take when the service + stops. If an error occurs, the error will be logged in the Application + event log, and the service will be restored to the original state. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Stop(); + +protected: + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Start + command is sent to the service by the SCM or when the operating system + starts (for a service that starts automatically). Specifies actions to + take when the service starts. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the + procedure is going to take long time. You may also consider spawning a + new thread in OnStart to perform time-consuming initialization tasks. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + virtual VOID OnStart(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Stop + command is sent to the service by the SCM. Specifies actions to take + when a service stops running. Be sure to periodically call + CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the + procedure is going to take long time. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnStop(); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when a Pause + command is sent to the service by the SCM. Specifies actions to take + when a service pauses. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnPause(); + + + /*++ + + Routine Description: + + When implemented in a derived class, OnContinue runs when a + Continue command is sent to the service by the SCM. Specifies actions to + take when a service resumes normal functioning after being paused. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnContinue(); + + + /*++ + + Routine Description: + + When implemented in a derived class, executes when the system + is shutting down. Specifies what should occur immediately prior to the + system shutting down. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + virtual VOID OnShutdown(); + + + /*++ + + Routine Description: + + The function sets the service status and reports the status to the SCM. + + Arguments: + + CurrentState - The current state of the service + + Win32ExitCode - The error code to report + + WaitHint - The estimated time for pending operation, in milliseconds + + Return Value: + + VOID + + --*/ + VOID SetServiceStatus(DWORD CurrentState, + DWORD Win32ExitCode = NO_ERROR, + DWORD WaitHint = 0); + +private: + + /*++ + + Routine Description: + + The entry point for the service. It registers the handler function + for the service and starts the service. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + static VOID WINAPI ServiceMain(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + Called by the SCM whenever a control code is sent to the service. + + Arguments: + + CtrlCode - The control code. This parameter can be one of + the following values: + + SERVICE_CONTROL_CONTINUE + SERVICE_CONTROL_INTERROGATE + SERVICE_CONTROL_NETBINDADD + SERVICE_CONTROL_NETBINDDISABLE + SERVICE_CONTROL_NETBINDREMOVE + SERVICE_CONTROL_PARAMCHANGE + SERVICE_CONTROL_PAUSE + SERVICE_CONTROL_SHUTDOWN + SERVICE_CONTROL_STOP + + This parameter can also be a user-defined control + code ranging from 128 to 255. + + Return Value: + + VOID + + --*/ + static VOID WINAPI ServiceCtrlHandler(DWORD Ctrl); + + + /*++ + + Routine Description: + + This function starts the service. It calls the OnStart virtual function + in which you can specify the actions to take when the service starts. If + an error occurs during the startup, the error will be logged in the + Application event log, and the service will be stopped. + + Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + + Return Value: + + VOID + + --*/ + VOID Start(DWORD Argc, PWSTR *Argv); + + + /*++ + + Routine Description: + + The function pauses the service if the service supports pause + and continue. It calls the OnPause virtual function in which you can + specify the actions to take when the service pauses. If an error occurs, + the error will be logged in the Application event log, and the service + will become running. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Pause(); + + + /*++ + + Routine Description: + + The function resumes normal functioning after being paused if + the service supports pause and continue. It calls the OnContinue virtual + function in which you can specify the actions to take when the service + continues. If an error occurs, the error will be logged in the + Application event log, and the service will still be paused. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Continue(); + + + /*++ + + Routine Description: + + The function executes when the system is shutting down. It + calls the OnShutdown virtual function in which you can specify what + should occur immediately prior to the system shutting down. If an error + occurs, the error will be logged in the Application event log. + + Arguments: + + VOID + + Return Value: + + VOID + + --*/ + VOID Shutdown(); + + + // + // The singleton service instance. + // + static CServiceBase *s_service; + + // + // The name of the service. + // + PWSTR m_name; + + // + // The status of the service. + // + SERVICE_STATUS m_status; + + // + // The service status handle. + // + SERVICE_STATUS_HANDLE m_statusHandle; +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h new file mode 100644 index 00000000..3d851537 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/ThreadPool.h @@ -0,0 +1,80 @@ +/****************************** Module Header ******************************\ +* Module Name: ThreadPool.h +* Project: CppWindowsService +* Copyright (c) Microsoft Corporation. +* +* The class was designed by Kenny Kerr. It provides the ability to queue +* simple member functions of a class to the Windows thread pool. +* +* Using the thread pool is simple and feels natural in C++. +* +* class CSampleService +* { +* public: +* +* void AsyncRun() +* { +* CThreadPool::QueueUserWorkItem(&Service::Run, this); +* } +* +* void Run() +* { +* // Some lengthy operation +* } +* }; +* +* Kenny Kerr spends most of his time designing and building distributed +* applications for the Microsoft Windows platform. He also has a particular +* passion for C++ and security programming. Reach Kenny at +* http://weblogs.asp.net/kennykerr/ or visit his Web site: +* http://www.kennyandkarin.com/Kenny/. +* +* This source is subject to the Microsoft Public License. +* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL. +* All other rights reserved. +* +* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +\***************************************************************************/ + +#pragma once + +#include + + +class CThreadPool +{ +public: + + template + static void QueueUserWorkItem(void (T::*function)(void), + T *object, ULONG flags = WT_EXECUTELONGFUNCTION) + { + typedef std::pair CallbackType; + std::auto_ptr p(new CallbackType(function, object)); + + if (::QueueUserWorkItem(ThreadProc, p.get(), flags)) + { + // The ThreadProc now has the responsibility of deleting the pair. + p.release(); + } + else + { + throw GetLastError(); + } + } + +private: + + template + static DWORD WINAPI ThreadProc(PVOID context) + { + typedef std::pair CallbackType; + + std::auto_ptr p(static_cast(context)); + + (p->second->*p->first)(); + return 0; + } +}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp new file mode 100644 index 00000000..e8fc87ee --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.cpp @@ -0,0 +1,156 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Utils.cpp + +Abstract: + + Provides utility function to SampleApp.cpp. + +Environment: + + User mode + +--*/ + +#include "Utils.h" + +// +// Service trace event provider +// {54a25c42-cd91-4210-98cc-c3447b56e447} +// +EXTERN_C __declspec(selectany) const GUID SERVICE_PROVIDER_GUID = { 0x54a25c42, 0xcd91, 0x4210,{ 0x98, 0xcc, 0xc3, 0x44, 0x7b, 0x56, 0xe4, 0x47 } }; + +REGHANDLE m_etwRegHandle; + + +/*++ + +Routine Description: + + Sets up logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +SetupEvents() +{ + NTSTATUS status = EventRegister(&SERVICE_PROVIDER_GUID, + nullptr, + nullptr, + &m_etwRegHandle); + + if (status != ERROR_SUCCESS) + { + wprintf(L"Provider not registered. EventRegister failed with error: 0x%08X\n", status); + } +} + + +/*++ + +Routine Description: + + Destroys logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID +DestroyEvents() +{ + if (m_etwRegHandle != NULL) + { + EventUnregister(m_etwRegHandle); + } +} + + +/*++ + +Routine Description: + + Log a message. + +Arguments: + + Message - The string message to be logged + + Level - The type of event to be logged. This parameter can + be one of the following values: + + TRACE_LEVEL_CRITICAL + TRACE_LEVEL_ERROR + TRACE_LEVEL_WARNING + TRACE_LEVEL_INFORMATION + TRACE_LEVEL_VERBOSE + +Return Value: + + VOID + +--*/ +VOID +WriteToEventLog( + PWSTR Message, + BYTE Level + ) +{ + if (m_etwRegHandle != NULL) + { + EventWriteString(m_etwRegHandle, Level, 0, Message); + } +} + + +/*++ + +Routine Description: + + Log an error message. + +Arguments: + + Function - The function that gives the error + + Error - The error code + +Return Value: + + VOID + +--*/ +VOID +WriteToErrorLog( + PWSTR Function, + DWORD Error + ) +{ + WCHAR Message[260]; + + StringCchPrintf(Message, ARRAYSIZE(Message), + L"%ws failed with error: 0x%08x", Function, Error); + + WriteToEventLog(Message, TRACE_LEVEL_ERROR); +} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h new file mode 100644 index 00000000..b619f461 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Utils.h @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + Utils.cpp + +Abstract: + + Provides utility function to SampleApp.cpp. + +Environment: + + User mode + +--*/ + +#pragma once + +#include +#include +#include +#include + +/*++ + +Routine Description: + + Sets up logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID SetupEvents(); + + +/*++ + +Routine Description: + + Destroys logging. + +Arguments: + + VOID + +Return Value: + + VOID + +--*/ +VOID DestroyEvents(); + + +/*++ + +Routine Description: + + Log a message. + +Arguments: + + Message - The string message to be logged + + Level - The type of event to be logged. This parameter can + be one of the following values: + + TRACE_LEVEL_CRITICAL + TRACE_LEVEL_ERROR + TRACE_LEVEL_WARNING + TRACE_LEVEL_INFORMATION + TRACE_LEVEL_VERBOSE + +Return Value: + + VOID + +--*/ +VOID WriteToEventLog(PWSTR Message, BYTE Level); + + +/*++ + +Routine Description: + + Log an error message. + +Arguments: + + Function - The function that gives the error + + Error - The error code + +Return Value: + + VOID + +--*/ +VOID WriteToErrorLog(PWSTR Function, DWORD Error); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters new file mode 100644 index 00000000..7f12a302 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters @@ -0,0 +1,54 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx new file mode 100644 index 00000000..61e1e958 Binary files /dev/null and b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx differ diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj new file mode 100644 index 00000000..8547d303 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj @@ -0,0 +1,206 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} + osrfx2_DCHU_usersvc + Win32Proj + osrfx2_DCHU_usersvc + 10.0.15063.0 + + + + Application + Unicode + true + v140 + + + Application + Unicode + v140 + + + Application + Unicode + false + v140 + + + Application + Unicode + v140 + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Full + WIN32;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreaded + + + Level3 + EditAndContinue + + + true + Console + MachineX86 + onecoreuap.lib;%(AdditionalDependencies); + + + + + Full + true + WIN32;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + true + + + Level3 + ProgramDatabase + + + true + Console + true + true + MachineX86 + onecoreuap.lib;%(AdditionalDependencies); + + + + + X64 + + + Full + WIN32;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreaded + + + Level3 + ProgramDatabase + + + true + Console + MachineX64 + onecoreuap.lib;%(AdditionalDependencies); + + + + + + + + + X64 + + + Full + true + WIN32;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + true + + + Level3 + ProgramDatabase + + + true + Console + true + true + MachineX64 + onecoreuap.lib;%(AdditionalDependencies); + + + + + + + + + + + + + + + + + + + true + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln deleted file mode 100644 index e09b5650..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component.sln +++ /dev/null @@ -1,73 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component", "{E498C537-BA1A-4E9D-8F1E-9DC7646D2E1A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware", "{E50E958C-B5D0-43E0-9D81-87F484F11E9F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component\osrfx2_DCHU_component.vcxproj", "{F90EFA96-B075-4531-B4E1-F406362D16BF}" - ProjectSection(ProjectDependencies) = postProject - {26D91630-B8FF-4102-A258-32F7D1C84E20} = {26D91630-B8FF-4102-A258-32F7D1C84E20} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware\osrfx2_DCHU_componentsoftware.vcxproj", "{26D91630-B8FF-4102-A258-32F7D1C84E20}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.ActiveCfg = Debug|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Build.0 = Debug|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Deploy.0 = Debug|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Build.0 = Debug|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.ActiveCfg = Debug|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Build.0 = Debug|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Deploy.0 = Debug|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.ActiveCfg = Debug|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Build.0 = Debug|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Deploy.0 = Debug|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.ActiveCfg = Release|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Build.0 = Release|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Deploy.0 = Release|ARM - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.ActiveCfg = Release|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Build.0 = Release|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Deploy.0 = Release|ARM64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.ActiveCfg = Release|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Build.0 = Release|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Deploy.0 = Release|x64 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.ActiveCfg = Release|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Build.0 = Release|Win32 - {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Deploy.0 = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM.ActiveCfg = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM64.ActiveCfg = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.ActiveCfg = Debug|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.Build.0 = Debug|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.ActiveCfg = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.Build.0 = Debug|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM.ActiveCfg = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM64.ActiveCfg = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.ActiveCfg = Release|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.Build.0 = Release|x64 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.ActiveCfg = Release|Win32 - {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {F90EFA96-B075-4531-B4E1-F406362D16BF} = {E498C537-BA1A-4E9D-8F1E-9DC7646D2E1A} - {26D91630-B8FF-4102-A258-32F7D1C84E20} = {E50E958C-B5D0-43E0-9D81-87F484F11E9F} - EndGlobalSection -EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters deleted file mode 100644 index fa953f4c..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {8E41214B-6785-4CFE-B992-037D68949A14} - inf;inv;inx;mof;mc; - - - - - Driver Files - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx deleted file mode 100644 index 8baab1a0..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.inx +++ /dev/null @@ -1,64 +0,0 @@ -;/*++ -; -;Copyright (c) Microsoft Corporation. All rights reserved. -; -; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR -; PURPOSE. -; -;Module Name: -; -; osrfx2_DCHU_component.INF -; -;Abstract: -; -; Installation inf for one of the OSR FX2 Learning Kit's -; AddComponent directives -; -;--*/ - -[Version] -Signature = "$Windows NT$" -Class = SoftwareComponent -ClassGuid = {5c4c3332-344d-483c-8739-259e934c9cc8} -Provider = %ManufacturerName% -CatalogFile = osrfx2_DCHU_component.cat - -[Manufacturer] -%ManufacturerName% = OsrFx2Component, NT$ARCH$ - -[OsrFx2Component.NT$ARCH$] -%DeviceName% = OsrFx2Component_Install, SWC\VID_045e&PID_94ab - -[SourceDisksFiles] -osrfx2_DCHU_componentsoftware.exe = 1 - -[SourceDisksNames] -1 = %DiskName% - -[DestinationDirs] -OsrFx2Component_CopyFiles = 13 ; copy to driverstore - -[OsrFx2Component_Install.NT] -CopyFiles = OsrFx2Component_CopyFiles - -[OsrFx2Component_Install.NT.Services] -AddService = , 0x00000002 - -[OsrFx2Component_Install.NT.Software] -AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall - -[OsrFx2Component_SoftwareInstall] -SoftwareType = 1 -SoftwareBinary = osrfx2_DCHU_componentsoftware.exe -SoftwareArguments = <> -SoftwareVersion = 1.0.0.0 - -[OsrFx2Component_CopyFiles] -osrfx2_DCHU_componentsoftware.exe - -[Strings] -ManufacturerName = "Contoso" -DiskName = "OsrFx2 DCHU Component Installation Disk" -DeviceName = "OsrFx2 DCHU Component Device" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj deleted file mode 100644 index fed7ddf4..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj +++ /dev/null @@ -1,272 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM - - - Release - ARM - - - Debug - ARM64 - - - Release - ARM64 - - - - - - - - - - - - - - - - - - - - - - - - - {F90EFA96-B075-4531-B4E1-F406362D16BF} - {4605da2c-74a5-4865-98e1-152ef136825f} - v4.5 - 12.0 - Debug - Win32 - osrfx2_DCHU_component - osrfx2_DCHU_component - - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - - - - - - - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - 1.0.0.0 - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp deleted file mode 100644 index c14e66d1..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - osrfx2_DCHU_componentsoftware.cpp - -Abstract: - - An example .exe to run using the AddSoftware directive within an INF. - Contains an example on how to obtain a handle to the primary device using - SoftwareArguments within an AddSoftware directive's section. - -Environment: - - User mode - ---*/ - -#include "stdafx.h" - -#define BUFFER_SIZE (128 * sizeof(WCHAR)) -#define DEVICE_REG_SUBKEY L"OSR" -#define DEVICE_VALUE_OP_MODE L"OperatingMode" -#define DEVICE_VALUE_OP_PARAMS L"OperatingParams" -#define DEVICE_VALUE_OP_EXCEPTIONS L"OperatingExceptions" -#define CONTOSO_FILEPATH L"C:\\Program Files\\Contoso" -#define OSRFX2_DCHU_FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU" -#define FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU\\AddSoftwareInstallationFile.txt" -#define FILE_CONTENT L"Operating Mode: %ws\r\nOperating Params: %ws\r\nOperating Exceptions: %ws" - - -/*++ - -Routine Description: - -Arguments: - -Return Value: - - ---*/ -DWORD -WriteToFile( - _In_ PWSTR MessageText, - _In_ DWORD MessageTextLength - ) -{ - DWORD Err = ERROR_SUCCESS; - BOOL ErrorFlag = FALSE; - HANDLE hFile = INVALID_HANDLE_VALUE; - DWORD BytesToWrite; - DWORD BytesWritten; - - if (!CreateDirectory(CONTOSO_FILEPATH, NULL)) - { - Err = GetLastError(); - - if (Err == ERROR_ALREADY_EXISTS) - { - Err = ERROR_SUCCESS; - } - else - { - goto cleanup; - } - } - - if (!CreateDirectory(OSRFX2_DCHU_FILEPATH, NULL)) - { - Err = GetLastError(); - - if (Err == ERROR_ALREADY_EXISTS) - { - Err = ERROR_SUCCESS; - } - else - { - goto cleanup; - } - } - - hFile = CreateFile(FILEPATH, - GENERIC_WRITE, - 0, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Err = ERROR_INVALID_PARAMETER; - goto cleanup; - } - - BytesToWrite = MessageTextLength * sizeof(WCHAR); - - ErrorFlag = WriteFile(hFile, - MessageText, - BytesToWrite, - &BytesWritten, - NULL); - - if ((!ErrorFlag) || - (BytesToWrite != BytesWritten)) - { - Err = GetLastError(); - goto cleanup; - } - -cleanup: - - if (hFile != INVALID_HANDLE_VALUE) - { - CloseHandle(hFile); - } - - return Err; -} - - -/*++ - -Routine Description: - - Obtains the handle to the device that used a separate Software Component - INF to install software. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -__cdecl -_tmain( - INT Argc, - TCHAR *Argv[]) -{ - DWORD Err = ERROR_SUCCESS; - HRESULT hr = S_OK; - BOOL ErrorFlag = FALSE; - DWORD BytesToWrite = 0; - DWORD BytesWritten = 0; - PTSTR DeviceInstanceId; - HDEVINFO DevInfoList = INVALID_HANDLE_VALUE; - SP_DEVINFO_DATA DevInfoData; - WCHAR ParentDeviceInstanceId[MAX_DEVICE_ID_LEN]; - DWORD RequiredSize; - DEVPROPTYPE DevPropType; - SP_DEVINFO_DATA ParentDevInfoData; - HKEY DevRegKey = NULL; - PWSTR OperatingMode = NULL; - PWSTR OperatingParams = NULL; - PWSTR OperatingExceptions = NULL; - DWORD ValueType; - DWORD ValueSize = BUFFER_SIZE; - HKEY DevOsrRegKey = NULL; - PWSTR FileText = NULL; - DWORD FileTextLength; - - // - // Validate arguments. - // - if (Argc != 2) - { - Err = ERROR_INVALID_PARAMETER; - goto cleanup; - } - - OperatingMode = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); - - if (OperatingMode == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - OperatingParams = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); - - if (OperatingParams == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - OperatingExceptions = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); - - if (OperatingExceptions == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - // - // Argv[1] should be the device instance ID. - // - DeviceInstanceId = Argv[1]; - - // - // Create a device info list to store queried device handles. - // - DevInfoList = SetupDiCreateDeviceInfoList(NULL, NULL); - - if (DevInfoList == INVALID_HANDLE_VALUE) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - - // - // Add the Software Component device that called AddSoftware to the - // device info list, which will be used to find the primary device that - // called AddComponent in the first place. - // - if (!SetupDiOpenDeviceInfo(DevInfoList, - DeviceInstanceId, - NULL, - 0, - &DevInfoData)) - { - Err = GetLastError(); - goto cleanup; - } - - // - // Get the device instance id of the opened device's parent. - // - if (!SetupDiGetDeviceProperty(DevInfoList, - &DevInfoData, - &DEVPKEY_Device_Parent, - &DevPropType, - (PBYTE)ParentDeviceInstanceId, - sizeof(ParentDeviceInstanceId), - &RequiredSize, - 0)) - { - Err = GetLastError(); - goto cleanup; - } - - if ((DevPropType != DEVPROP_TYPE_STRING) || - (RequiredSize < sizeof(WCHAR))) - { - Err = ERROR_INVALID_PARAMETER; - goto cleanup; - } - - ParentDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - - // - // Get the parent of the device we retrieved first, which is the device - // that called AddComponent in its INF. - // - if (!SetupDiOpenDeviceInfoW(DevInfoList, - ParentDeviceInstanceId, - NULL, - 0, - &ParentDevInfoData)) - { - Err = GetLastError(); - goto cleanup; - } - - // - // Open up the HW registry keys of the primary device. - // - DevRegKey = SetupDiOpenDevRegKey(DevInfoList, - &ParentDevInfoData, - DICS_FLAG_GLOBAL, - 0, - DIREG_DEV, - KEY_READ); - - if (DevRegKey == INVALID_HANDLE_VALUE) - { - Err = GetLastError(); - DevRegKey = NULL; - goto cleanup; - } - - Err = RegOpenKeyEx(DevRegKey, - DEVICE_REG_SUBKEY, - 0, - KEY_QUERY_VALUE, - &DevOsrRegKey); - - if (Err != ERROR_SUCCESS) - { - goto cleanup; - } - - // - // Retrieve the registry values defined in the primary device's INF. - // Note that if the extension INF was applied, the extension INF would - // overwrite OperatingParams and create OperatingExceptions. - // - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_MODE, - NULL, - &ValueType, - (LPBYTE)OperatingMode, - &ValueSize); - - while (Err == ERROR_MORE_DATA) - { - // - // Create a larger buffer. - // - OperatingMode = (PTSTR)realloc(OperatingMode, ValueSize); - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_MODE, - NULL, - &ValueType, - (LPBYTE)OperatingMode, - &ValueSize); - } - - if (Err != ERROR_SUCCESS) - { - OperatingMode[0] = TEXT('\0'); - } - else if ((ValueType != REG_SZ) || - (ValueSize < sizeof(TCHAR))) - { - Err = ERROR_REGISTRY_CORRUPT; - OperatingMode[0] = TEXT('\0'); - } - - ValueSize = BUFFER_SIZE; - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_PARAMS, - NULL, - &ValueType, - (LPBYTE)OperatingParams, - &ValueSize); - - while (Err == ERROR_MORE_DATA) - { - // - // Create a larger buffer. - // - OperatingParams = (PTSTR)realloc(OperatingParams, ValueSize); - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_MODE, - NULL, - &ValueType, - (LPBYTE)OperatingParams, - &ValueSize); - } - - if (Err != ERROR_SUCCESS) - { - OperatingParams[0] = TEXT('\0'); - } - else if ((ValueType != REG_SZ) || - (ValueSize < sizeof(TCHAR))) - { - Err = ERROR_REGISTRY_CORRUPT; - OperatingParams[0] = TEXT('\0'); - } - - ValueSize = BUFFER_SIZE; - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_EXCEPTIONS, - NULL, - &ValueType, - (LPBYTE)OperatingExceptions, - &ValueSize); - - while (Err == ERROR_MORE_DATA) - { - // - // Create a larger buffer. - // - OperatingExceptions = (PTSTR)realloc(OperatingExceptions, ValueSize); - - Err = RegQueryValueEx(DevOsrRegKey, - DEVICE_VALUE_OP_EXCEPTIONS, - NULL, - &ValueType, - (LPBYTE)OperatingExceptions, - &ValueSize); - } - - if (Err != ERROR_SUCCESS) - { - OperatingExceptions[0] = TEXT('\0'); - } - else if ((ValueType != REG_SZ) || - (ValueSize < sizeof(TCHAR))) - { - Err = ERROR_REGISTRY_CORRUPT; - OperatingExceptions[0] = TEXT('\0'); - } - - FileTextLength = (DWORD)wcslen(OperatingMode) + - (DWORD)wcslen(OperatingParams) + - (DWORD)wcslen(OperatingExceptions) + - (DWORD)wcslen(FILE_CONTENT) - - 9; // Subtract the 3 %ws - - FileText = (PWSTR)malloc((FileTextLength + 1) * sizeof(WCHAR)); - - if (FileText == NULL) - { - Err = ERROR_OUTOFMEMORY; - goto cleanup; - } - - hr = StringCchPrintf(FileText, - FileTextLength + 1, - FILE_CONTENT, - OperatingMode, - OperatingParams, - OperatingExceptions); - - if (FAILED(hr)) - { - Err = HRESULT_CODE(hr); - goto cleanup; - } - - Err = WriteToFile(FileText, FileTextLength); - - if (Err != ERROR_SUCCESS) - { - goto cleanup; - } - -cleanup: - - if (FileText != NULL) - { - free(FileText); - } - - if (OperatingExceptions != NULL) - { - free(OperatingExceptions); - } - - if (OperatingParams != NULL) - { - free(OperatingParams); - } - - if (OperatingMode != NULL) - { - free(OperatingMode); - } - - if (DevOsrRegKey != NULL) - { - RegCloseKey(DevOsrRegKey); - } - - if (DevRegKey != NULL) - { - RegCloseKey(DevRegKey); - } - - if (DevInfoList != INVALID_HANDLE_VALUE) - { - SetupDiDestroyDeviceInfoList(DevInfoList); - } - - return; -} - diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters deleted file mode 100644 index 395438fa..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj deleted file mode 100644 index 2bb8b05d..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj +++ /dev/null @@ -1,169 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {26D91630-B8FF-4102-A258-32F7D1C84E20} - Win32Proj - osrfx2_DCHU_componentsoftware - 10.0.15063.0 - osrfx2_DCHU_componentsoftware - - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - true - $(ProjectName) - - - false - - - false - $(ProjectName) - .exe - - - - Use - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Console - true - onecoreuap.lib;setupapi.lib; - - - - - Use - Level3 - Disabled - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Console - true - onecoreuap.lib;setupapi.lib; - - - - - Level3 - Use - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - Console - true - true - true - onecoreuap.lib;setupapi.lib; - - - - - Level3 - Use - MaxSpeed - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Console - true - true - true - onecoreuap.lib;setupapi.lib; - - - - - - - - - - - - Create - Create - Create - Create - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp deleted file mode 100644 index 79325e21..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// osrusbfx2umsoftware.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h deleted file mode 100644 index edb61924..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/stdafx.h +++ /dev/null @@ -1,18 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// TODO: reference additional headers your program requires here diff --git a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h b/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h deleted file mode 100644 index 87c0086d..00000000 --- a/general/DCHU/osrfx2_DCHU_component/osrfx2_DCHU_componentsoftware/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln deleted file mode 100644 index 386ba436..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension.sln +++ /dev/null @@ -1,73 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DHCU_extension", "osrfx2_DHCU_extension", "{4577857A-CCAE-42EB-BDE2-16C1E3DC7B14}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc", "{D10B02D6-7E48-4F78-8AAE-20C93E77FA52}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension\osrfx2_DCHU_extension.vcxproj", "{0588DF70-3923-42E6-8DC9-13C2C0186F20}" - ProjectSection(ProjectDependencies) = postProject - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_usersvc", "osrfx2_DCHU_usersvc\osrfx2_DCHU_usersvc.vcxproj", "{DE70E2D1-6A4D-4984-BD82-CE750889F0D3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.ActiveCfg = Debug|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Build.0 = Debug|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Deploy.0 = Debug|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Build.0 = Debug|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.ActiveCfg = Debug|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Build.0 = Debug|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Deploy.0 = Debug|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.ActiveCfg = Debug|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Build.0 = Debug|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Deploy.0 = Debug|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.ActiveCfg = Release|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Build.0 = Release|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Deploy.0 = Release|ARM - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.ActiveCfg = Release|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Build.0 = Release|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Deploy.0 = Release|ARM64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.ActiveCfg = Release|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Build.0 = Release|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Deploy.0 = Release|x64 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.ActiveCfg = Release|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Build.0 = Release|Win32 - {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Deploy.0 = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM.ActiveCfg = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|ARM64.ActiveCfg = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.ActiveCfg = Debug|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x64.Build.0 = Debug|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x86.ActiveCfg = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Debug|x86.Build.0 = Debug|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM.ActiveCfg = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|ARM64.ActiveCfg = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.ActiveCfg = Release|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x64.Build.0 = Release|x64 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x86.ActiveCfg = Release|Win32 - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {0588DF70-3923-42E6-8DC9-13C2C0186F20} = {4577857A-CCAE-42EB-BDE2-16C1E3DC7B14} - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} = {D10B02D6-7E48-4F78-8AAE-20C93E77FA52} - EndGlobalSection -EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters deleted file mode 100644 index 0ba1a59c..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {8E41214B-6785-4CFE-B992-037D68949A14} - inf;inv;inx;mof;mc; - - - - - Driver Files - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx deleted file mode 100644 index d90c39f7..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx +++ /dev/null @@ -1,79 +0,0 @@ -;/*++ -; -;Copyright (c) Microsoft Corporation. All rights reserved. -; -; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR -; PURPOSE. -; -;Module Name: -; -; osrfx2_DCHU_extension.INF -; -;Abstract: -; -; Extension inf for the OSR FX2 Learning Kit -; -;--*/ - -[Version] -Signature = "$WINDOWS NT$" -Class = Extension -ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} -Provider = %ManufacturerName% -ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} -CatalogFile = osrfx2_DCHU_extension.cat -DriverVer = 05/16/2017,15.14.36.721 - -[Manufacturer] -%ManufacturerName% = OsrFx2Extension, NT$ARCH$ - -[OsrFx2Extension.NT$ARCH$] -%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_045e&Pid_94aa&mi_00 -%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 - -[OsrFx2Extension_Install.NT] -CopyInf=osrfx2_DCHU_usersvc.inf - -[OsrFx2Extension_Install.NT.HW] -AddReg = OsrFx2Extension_AddReg -AddReg = OsrFx2Extension_COMAddReg - -[OsrFx2Extension_AddReg] -HKR, OSR, "OperatingParams",, "-Extended" -HKR, OSR, "OperatingExceptions",, "x86" - -; Add all registry keys to successfully register the -; In-Process ATL COM Server MSFT Sample. -[OsrFx2Extension_COMAddReg] -HKCR,AppID\ATLDllCOMServer.DLL,AppID,,"{9DD18FED-55F6-4741-AF25-798B90C4AED5}" -HKCR,AppID\{9DD18FED-55F6-4741-AF25-798B90C4AED5},,,"ATLDllCOMServer" -HKCR,ATLDllCOMServer.SimpleObject,,,"SimpleObject Class" -HKCR,ATLDllCOMServer.SimpleObject\CLSID,,,"{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}" -HKCR,ATLDllCOMServer.SimpleObject\CurVer,,,"ATLDllCOMServer.SimpleObject.1" -HKCR,ATLDllCOMServer.SimpleObject.1,,,"SimpleObject Class" -HKCR,ATLDllCOMServer.SimpleObject.1\CLSID,,,"{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084},,,"SimpleObject Class" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\InprocServer32,,%REG_EXPAND_SZ%,"%%SystemRoot%%\System32\ATLDllCOMServer.dll" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\InprocServer32,ThreadingModel,,"Apartment" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\ProgID,,,"ATLDllCOMServer.SimpleObject.1" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\Programmable,,%FLG_ADDREG_KEYONLY% -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\TypeLib,,,"{9B23EFED-A0C1-46B6-A903-218206447F3E}" -HKCR,CLSID\{92FCF37F-F6C7-4F8A-AA09-1A14BA118084}\VersionIndependentProgID,,,"ATLDllCOMServer.SimpleObject" - -[OsrFx2Extension_Install.NT.Components] -AddComponent = osrfx2_DCHU_component,,OsrFx2Extension_ComponentInstall -AddComponent = osrfx2_DCHU_usersvc,,OsrFx2Extension_ComponentInstall_UserSvc - -[OsrFx2Extension_ComponentInstall] -ComponentIds=VID_045e&PID_94ab - -[OsrFx2Extension_ComponentInstall_UserSvc] -ComponentIds=VID_045e&PID_94ac - -[Strings] -ManufacturerName = "Contoso" -OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" -REG_EXPAND_SZ = 0x00020000 -FLG_ADDREG_KEYONLY = 0x00000010 \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj deleted file mode 100644 index 232cfa89..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj +++ /dev/null @@ -1,281 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM - - - Release - ARM - - - Debug - ARM64 - - - Release - ARM64 - - - - - - - - - - - - - - - - - - - - - - - - - - {0588DF70-3923-42E6-8DC9-13C2C0186F20} - {4605da2c-74a5-4865-98e1-152ef136825f} - v4.6.1 - 12.0 - Debug - Win32 - osrfx2_DCHU_extension - osrfx2_DCHU_extension - - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - true - WindowsKernelModeDriver10.0 - Utility - Package - true - - - Windows10 - false - WindowsKernelModeDriver10.0 - Utility - Package - true - - - - - - - - - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - DbgengRemoteDebugger - - - - False - False - True - - 133563 - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - $(InfArch) - 1.0.0.0 - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp deleted file mode 100644 index 98a3975c..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/CppWindowsService.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - CppWindowsService.cpp - -Abstract: - - The file defines the entry point of the application. According to the - arguments in the command line, the function installs or uninstalls or - starts the service by calling into different routines. - -Environment: - - User mode - ---*/ - -#pragma region Includes -#include -#include -#include "ServiceBase.h" -#include "SampleService.h" -#pragma endregion - -// -// Settings of the service -// - -// -// Internal name of the service -// -#define SERVICE_NAME L"OsrUsbFx2UmUserSvc" - - -/*++ - -Routine Description: - - Entry point for the service. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -INT -wmain( - INT Argc, - WCHAR *Argv[] - ) -{ - CSampleService service(SERVICE_NAME); - - if (!CServiceBase::Run(service)) - { - wprintf(L"Service failed to run w/err 0x%08lx\n", GetLastError()); - } - - return 0; -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp deleted file mode 100644 index 157a6cb9..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Main.cpp - -Abstract: - - Implements the functions to control the OSR USB FX2 device. - -Environment: - - User mode - ---*/ - -#include "Main.h" -#include "Utils.h" - -INT CurrentBar; -BAR_GRAPH_STATE BarGraphState; - -/*++ - -Routine Description: - - Sets the variables in this service to their default values. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -SetVariables() -{ - CurrentBar = 0; -} - - -/*++ - -Routine Description: - - Retrieves the device path of a given interface. - -Arguments: - - InterfaceGuid - The GUID of the interface to search for - - DevicePath - The resulting device path - - DevicePathLength - The length of DevicePath - -Return Value: - - TRUE if the function succeeded and FALSE otherwise. Errors - are logged in the Application event log. - ---*/ -_Success_(return) -BOOL -GetDevicePath( - _In_ LPGUID InterfaceGuid, - _Out_writes_z_(DevicePathLength) PWCHAR DevicePath, - _In_ size_t DevicePathLength - ) -{ - HRESULT hr = E_FAIL; - BOOL Return = FALSE; - CONFIGRET Status = CR_SUCCESS; - PWSTR DeviceInterfaceList = NULL; - ULONG DeviceInterfaceListLength = 0; - PWSTR NextInterface; - - Status = CM_Get_Device_Interface_List_Size(&DeviceInterfaceListLength, - InterfaceGuid, - NULL, - CM_GET_DEVICE_INTERFACE_LIST_PRESENT); - - if (Status != CR_SUCCESS) - { - WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", - CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); - goto clean0; - } - - if (DeviceInterfaceListLength < 1) - { - WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", - CM_MapCrToWin32Err(Status, ERROR_EMPTY)); - goto clean0; - } - - DeviceInterfaceList = (PWSTR)malloc(DeviceInterfaceListLength * sizeof(WCHAR)); - - if (DeviceInterfaceList == NULL) - { - WriteToEventLog(L"Failed to allocate memory for the device interface list", - TRACE_LEVEL_ERROR); - goto clean0; - } - - ZeroMemory(DeviceInterfaceList, DeviceInterfaceListLength * sizeof(WCHAR)); - - Status = CM_Get_Device_Interface_List(InterfaceGuid, - NULL, - DeviceInterfaceList, - DeviceInterfaceListLength, - CM_GET_DEVICE_INTERFACE_LIST_PRESENT); - - if (Status != CR_SUCCESS) - { - WriteToErrorLog(L"CM_Get_Device_Interface_List", - CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); - goto clean0; - } - - if (*DeviceInterfaceList == UNICODE_NULL) - { - WriteToEventLog(L"CM_Get_Device_Interface_List returned an empty list", - TRACE_LEVEL_ERROR); - } - - NextInterface = DeviceInterfaceList + wcslen(DeviceInterfaceList) + 1; - - if (*NextInterface != UNICODE_NULL) - { - WriteToEventLog(L"More than one device interface instance found. " - "Selecting first matching device.", - TRACE_LEVEL_WARNING); - } - - hr = StringCchCopy(DevicePath, DevicePathLength, DeviceInterfaceList); - - if (FAILED(hr)) - { - WriteToErrorLog(L"StringCchCopy", HRESULT_CODE(hr)); - goto clean0; - } - -clean0: - - if (DeviceInterfaceList != NULL) - { - free(DeviceInterfaceList); - } - - if (Status == CR_SUCCESS) - { - Return = TRUE; - } - - return Return; -} - - -/*++ - -Routine Description: - - Opens up the OSR USB FX2 device handle. - -Arguments: - - Synchronous - Whether or not this device should be - opened for synchronous access - -Return Value: - - The handle to the OSR USB FX2 device. - ---*/ -_Check_return_ -_Ret_notnull_ -_Success_(return != INVALID_HANDLE_VALUE) -HANDLE -OpenDevice( - _In_ BOOL Synchronous - ) -{ - HANDLE DeviceHandle; - WCHAR DeviceName[MAX_DEVPATH_LENGTH]; - - if (!GetDevicePath((LPGUID)&GUID_DEVINTERFACE_OSRUSBFX2, - DeviceName, - sizeof(DeviceName) / sizeof(DeviceName[0]))) - { - return INVALID_HANDLE_VALUE; - } - - if (Synchronous) - { - DeviceHandle = CreateFile(DeviceName, - GENERIC_WRITE | GENERIC_READ, - FILE_SHARE_WRITE | FILE_SHARE_READ, - NULL, // default security - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - } - else - { - DeviceHandle = CreateFile(DeviceName, - GENERIC_WRITE | GENERIC_READ, - FILE_SHARE_WRITE | FILE_SHARE_READ, - NULL, // default security - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, - NULL); - } - - if (DeviceHandle == INVALID_HANDLE_VALUE) - { - WriteToErrorLog(L"CreateFile", GetLastError()); - } - else - { - WriteToEventLog(L"Opened Device Successfully", TRACE_LEVEL_INFORMATION); - } - - return DeviceHandle; -} - - -/*++ - -Routine Description: - - Turns off all of the bar graph lights on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device - -Return Value: - - VOID - ---*/ -VOID -ClearAllBars( - _In_ HANDLE DeviceHandle - ) -{ - ULONG BytesReturned; - - BarGraphState.BarsAsUChar = 0; - - if (!DeviceIoControl(DeviceHandle, - IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, - &BarGraphState, // Pointer to InBuffer - sizeof(BAR_GRAPH_STATE), // Length of InBuffer - NULL, // Pointer to OutBuffer - 0, // Length of OutBuffer - &BytesReturned, // BytesReturned - 0)) // Pointer to Overlapped structure - { - WriteToErrorLog(L"DeviceIOControl", GetLastError()); - } -} - - -/*++ - -Routine Description: - - Lights the next bar on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device - -Return Value: - - VOID - ---*/ -VOID -LightNextBar( - _In_ HANDLE DeviceHandle - ) -{ - ULONG BytesReturned; - - // - // Normalize to 0-7 - // - CurrentBar += 1; - - if (CurrentBar > 7) - { - CurrentBar = 0; - } - - BarGraphState.BarsAsUChar = 1 << (UCHAR)CurrentBar; - - if (!DeviceIoControl(DeviceHandle, - IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY, - &BarGraphState, // Pointer to InBuffer - sizeof(BAR_GRAPH_STATE), // Length of InBuffer - NULL, // Pointer to OutBuffer - 0, // Length of OutBuffer - &BytesReturned, // BytesReturned - 0)) // Pointer to Overlapped structure - { - WriteToErrorLog(L"DeviceIOControl", GetLastError()); - } -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h deleted file mode 100644 index dcbd950e..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Main.h +++ /dev/null @@ -1,261 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Main.h - -Abstract: - - Implements the functions to control the OSR USB FX2 device. - -Environment: - - User mode - ---*/ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -// {573E8C73-0CB4-4471-A1BF-FAB26C31D384} -DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, - 0x573e8c73, 0xcb4, 0x4471, 0xa1, 0xbf, 0xfa, 0xb2, 0x6c, 0x31, 0xd3, 0x84); - -// -// Most device interface paths will fit into a buffer of this size. -// However, some could be longer, and a larger buffer or dynamically -// allocated buffer may be needed for robust code. -// -#define MAX_DEVPATH_LENGTH 1024 - -#pragma warning(push) -#pragma warning(disable:4201) // nameless struct/union -#pragma warning(disable:4214) // bit field types other than int - -// -// Define the structures that will be used by the IOCTL -// interface to the driver -// - -// -// BAR_GRAPH_STATE -// -// BAR_GRAPH_STATE is a bit field structure with each -// bit corresponding to one of the bar graph on the -// OSRFX2 Development Board -// -#include -typedef struct _BAR_GRAPH_STATE { - - union { - - struct { - // - // Individual bars starting from the - // top of the stack of bars - // - // NOTE: There are actually 10 bars, - // but the very top two do not light - // and are not counted here - // - UCHAR Bar1 : 1; - UCHAR Bar2 : 1; - UCHAR Bar3 : 1; - UCHAR Bar4 : 1; - UCHAR Bar5 : 1; - UCHAR Bar6 : 1; - UCHAR Bar7 : 1; - UCHAR Bar8 : 1; - }; - - // - // The state of all the bar graph as a single - // UCHAR - // - UCHAR BarsAsUChar; - - }; - -}BAR_GRAPH_STATE, *PBAR_GRAPH_STATE; - -// -// SWITCH_STATE -// -// SWITCH_STATE is a bit field structure with each -// bit corresponding to one of the switches on the -// OSRFX2 Development Board -// -typedef struct _SWITCH_STATE { - - union { - struct { - // - // Individual switches starting from the - // left of the set of switches - // - UCHAR Switch1 : 1; - UCHAR Switch2 : 1; - UCHAR Switch3 : 1; - UCHAR Switch4 : 1; - UCHAR Switch5 : 1; - UCHAR Switch6 : 1; - UCHAR Switch7 : 1; - UCHAR Switch8 : 1; - }; - - // - // The state of all the switches as a single - // UCHAR - // - UCHAR SwitchesAsUChar; - - }; - - -}SWITCH_STATE, *PSWITCH_STATE; - -#include - -#pragma warning(pop) - -#define IOCTL_INDEX 0x800 -#define FILE_DEVICE_OSRUSBFX2 65500U - -#define IOCTL_OSRUSBFX2_GET_CONFIG_DESCRIPTOR CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - -#define IOCTL_OSRUSBFX2_RESET_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 1, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - -#define IOCTL_OSRUSBFX2_REENUMERATE_DEVICE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 3, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - -#define IOCTL_OSRUSBFX2_GET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 4, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - - -#define IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 5, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - - -#define IOCTL_OSRUSBFX2_READ_SWITCHES CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 6, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - - -#define IOCTL_OSRUSBFX2_GET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 7, \ - METHOD_BUFFERED, \ - FILE_READ_ACCESS) - - -#define IOCTL_OSRUSBFX2_SET_7_SEGMENT_DISPLAY CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 8, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - -#define IOCTL_OSRUSBFX2_GET_INTERRUPT_MESSAGE CTL_CODE(FILE_DEVICE_OSRUSBFX2,\ - IOCTL_INDEX + 9, \ - METHOD_OUT_DIRECT, \ - FILE_READ_ACCESS) - -/*++ - -Routine Description: - - Sets the variables in this service to their default values. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID SetVariables(); - - -/*++ - -Routine Description: - - Opens up the OSR USB FX2 device handle. - -Arguments: - - Synchronous - Whether or not this device should be - opened for synchronous access - -Return Value: - - The handle to the OSR USB FX2 device. - ---*/ -HANDLE OpenDevice(_In_ BOOL Synchronous); - - -/*++ - -Routine Description: - - Turns off all of the bar graph lights on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device. - -Return Value: - - VOID - ---*/ -VOID ClearAllBars(HANDLE deviceHandle); - - -/*++ - -Routine Description: - - Lights the next bar on the OSR USB FX2 device. - -Arguments: - - DeviceHandle - The handle to the OSR USB FX2 device. - -Return Value: - -VOID - ---*/ -VOID LightNextBar(HANDLE deviceHandle); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp deleted file mode 100644 index c39e4838..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - SampleService.cpp - -Abstract: - - Provides a sample service class that derives from the service base class - - CServiceBase. The sample service logs the service start and stop - information to the Application event log, and shows how to run the main - function of the service in a thread pool worker thread. - -Environment: - - User mode - ---*/ - -#pragma region Includes -#include "SampleService.h" -#include "ThreadPool.h" -#pragma endregion - -HANDLE DeviceHandle; - -/*++ - -Routine Description: - - The constructor of CSampleService. It initializes a new instance - of the CSampleService class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. Inherits properties from the class CServiceBase. - -Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - -Return Value: - - VOID - ---*/ -CSampleService::CSampleService( - PWSTR ServiceName, - BOOL CanStop, - BOOL CanShutdown, - BOOL CanPauseContinue - ) -: CServiceBase(ServiceName, CanStop, CanShutdown, CanPauseContinue) -{ - m_fStopping = FALSE; - - // - // Create a manual-reset event that is not signaled at first to indicate - // the stopped signal of the service. - // - m_hStoppedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (m_hStoppedEvent == NULL) - { - throw GetLastError(); - } -} - - -/*++ - -Routine Description: - - The virtual destructor of CSampleService. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -CSampleService::~CSampleService() -{ - if (m_hStoppedEvent) - { - CloseHandle(m_hStoppedEvent); - m_hStoppedEvent = NULL; - } -} - - -/*++ - -Routine Description: - - This function is executed when a Start command is sent to the - service by the SCM or when the operating system starts (for a service - that starts automatically). It specifies actions to take when the - service starts. In this code sample, OnStart logs a service-start - message to the Application log, and queues the main service function for - execution in a thread pool worker thread. - - NOTE: A service application is designed to be long running. Therefore, - it usually polls or monitors something in the system. The monitoring is - set up in the OnStart method. However, OnStart does not actually do the - monitoring. The OnStart method must return to the operating system after - the service's operation has begun. It must not loop forever or block. To - set up a simple monitoring mechanism, one general solution is to create - a timer in OnStart. The timer would then raise events in your code - periodically, at which time your service could do its monitoring. The - other solution is to spawn a new thread to perform the main service - functions, which is demonstrated in this code sample. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -CSampleService::OnStart( - DWORD Argc, - PWSTR *Argv - ) -{ - // - // Log a service start message to the Application log. - // - WriteToEventLog(L"SampleService in OnStart", - EVENTLOG_INFORMATION_TYPE); - - // - // Set variables in the base class - // - - // - // Open the device - // - DeviceHandle = OpenDevice(FALSE); - - if (DeviceHandle == INVALID_HANDLE_VALUE) - { - return; - } - - // - // Queue the main service function for execution in a worker thread. - // - CThreadPool::QueueUserWorkItem(&CSampleService::ServiceWorkerThread, this); -} - - -/*++ - -Routine Description: - - This method performs the main function of the service. It runs - on a thread pool worker thread. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CSampleService::ServiceWorkerThread() -{ - // - // Periodically check if the service is stopping. - // - while (!m_fStopping) - { - // - // Perform main service function here... - // - - ClearAllBars(DeviceHandle); - LightNextBar(DeviceHandle); - - ::Sleep(2000); // Simulate some lengthy operations. - } - - // - // Signal the stopped event. - // - SetEvent(m_hStoppedEvent); -} - - -/*++ - -Routine Description: - - This function is executed when a Stop command is sent to the service by SCM. - It specifies actions to take when a service stops running. In this code - sample, OnStop logs a service-stop message to the Application log, and - waits for the finish of the main service function. - - Be sure to periodically call ReportServiceStatus() with - SERVICE_STOP_PENDING if the procedure is going to take a long time. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CSampleService::OnStop() -{ - // - // Log a service stop message to the Application log. - // - WriteToEventLog(L"SampleService in OnStop", - EVENTLOG_INFORMATION_TYPE); - - // - // Indicate that the service is stopping and wait for the finish of the - // main service function (ServiceWorkerThread). - // - m_fStopping = TRUE; - - if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0) - { - throw GetLastError(); - } -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h deleted file mode 100644 index eee8a609..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/SampleService.h +++ /dev/null @@ -1,174 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - SampleService.h - -Abstract: - - Provides a sample service class that derives from the service base class - - CServiceBase. The sample service logs the service start and stop - information to the Application event log, and shows how to run the main - function of the service in a thread pool worker thread. - -Environment: - - User mode - ---*/ - -#pragma once - -#include "ServiceBase.h" -#include "Main.h" - -class CSampleService : public CServiceBase -{ -public: - - /*++ - - Routine Description: - - The constructor of CSampleService. It initializes a new instance - of the CSampleService class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. Inherits properties from the class CServiceBase. - - Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - - Return Value: - - VOID - - --*/ - CSampleService(PWSTR ServiceName, - BOOL CanStop = TRUE, - BOOL CanShutdown = TRUE, - BOOL CanPauseContinue = FALSE); - - /*++ - - Routine Description: - - The virtual destructor of CSampleService. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual ~CSampleService(); - -protected: - - /*++ - - Routine Description: - - This function is executed when a Start command is sent to the - service by the SCM or when the operating system starts (for a service - that starts automatically). It specifies actions to take when the - service starts. In this code sample, OnStart logs a service-start - message to the Application log, and queues the main service function for - execution in a thread pool worker thread. - - NOTE: A service application is designed to be long running. Therefore, - it usually polls or monitors something in the system. The monitoring is - set up in the OnStart method. However, OnStart does not actually do the - monitoring. The OnStart method must return to the operating system after - the service's operation has begun. It must not loop forever or block. To - set up a simple monitoring mechanism, one general solution is to create - a timer in OnStart. The timer would then raise events in your code - periodically, at which time your service could do its monitoring. The - other solution is to spawn a new thread to perform the main service - functions, which is demonstrated in this code sample. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - virtual VOID OnStart(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - This function is executed when a Stop command is sent to the service by SCM. - It specifies actions to take when a service stops running. In this code - sample, OnStop logs a service-stop message to the Application log, and - waits for the finish of the main service function. - - Be sure to periodically call ReportServiceStatus() with - SERVICE_STOP_PENDING if the procedure is going to take a long time. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnStop(); - - - /*++ - - Routine Description: - - This method performs the main function of the service. It runs - on a thread pool worker thread. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID ServiceWorkerThread(); - -private: - - // - // Determines if the service is currently stopping. - // - BOOL m_fStopping; - - // - // The handle to wait for a stop event. - // - HANDLE m_hStoppedEvent; -}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp deleted file mode 100644 index 4c20af2e..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.cpp +++ /dev/null @@ -1,794 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - ServiceBase.cpp - -Abstract: - - Provides a base class for a service that will exist as part of a service - application. CServiceBase must be derived from when creating a new service - class. - -Environment: - - User mode - ---*/ - -#pragma region Includes -#include "ServiceBase.h" -#include "Main.h" -#include "Utils.h" -#include -#include -#pragma endregion - - -#pragma region Static Members - -// -// Initialize the singleton service instance. -// -CServiceBase *CServiceBase::s_service = NULL; - - -/*++ - -Routine Description: - - Register the executable for a service with the Service Control - Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start - command, which results in a call to the OnStart method in the service. - This method blocks until the service has stopped. - -Arguments: - - Service - The reference to a CServiceBase object. It will become the - singleton service instance of this service application. - -Return Value: - - If the function succeeds, the return value is TRUE. If the function - fails, the return value is FALSE. To get extended error information, - call GetLastError. - ---*/ -BOOL -CServiceBase::Run( - CServiceBase &Service - ) -{ - s_service = &Service; - - SERVICE_TABLE_ENTRY serviceTable[] = - { - { Service.m_name, ServiceMain }, - { NULL, NULL } - }; - - // - // Connects the main thread of a service process to the service control - // manager, which causes the thread to be the service control dispatcher - // thread for the calling process. This call returns when the service has - // stopped. The process should simply terminate when the call returns. - // - return StartServiceCtrlDispatcher(serviceTable); -} - - -/*++ - -Routine Description: - - The entry point for the service. It registers the handler function - for the service and starts the service. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -WINAPI -CServiceBase::ServiceMain( - DWORD Argc, - PWSTR *Argv - ) -{ - assert(s_service != NULL); - - // - // Register the handler function for the service. - // - s_service->m_statusHandle = RegisterServiceCtrlHandler(s_service->m_name, - ServiceCtrlHandler); - - if (s_service->m_statusHandle == NULL) - { - throw GetLastError(); - } - - // - // Start the service. - // - s_service->Start(Argc, Argv); -} - - -/*++ - -Routine Description: - - Called by the SCM whenever a control code is sent to the service. - -Arguments: - - CtrlCode - The control code. This parameter can be one of - the following values: - - SERVICE_CONTROL_CONTINUE - SERVICE_CONTROL_INTERROGATE - SERVICE_CONTROL_NETBINDADD - SERVICE_CONTROL_NETBINDDISABLE - SERVICE_CONTROL_NETBINDREMOVE - SERVICE_CONTROL_PARAMCHANGE - SERVICE_CONTROL_PAUSE - SERVICE_CONTROL_SHUTDOWN - SERVICE_CONTROL_STOP - - This parameter can also be a user-defined control - code ranging from 128 to 255. - -Return Value: - - VOID - ---*/ -VOID -WINAPI -CServiceBase::ServiceCtrlHandler( - DWORD Ctrl - ) -{ - switch (Ctrl) - { - case SERVICE_CONTROL_STOP: - s_service->Stop(); - break; - case SERVICE_CONTROL_PAUSE: - s_service->Pause(); - break; - case SERVICE_CONTROL_CONTINUE: - s_service->Continue(); - break; - case SERVICE_CONTROL_SHUTDOWN: - s_service->Shutdown(); - break; - case SERVICE_CONTROL_INTERROGATE: - break; - default: - break; - } -} - -#pragma endregion - - -#pragma region Service Constructor and Destructor - -/*++ - -Routine Description: - - The constructor of CServiceBase. It initializes a new instance - of the CServiceBase class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. - -Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - -Return Value: - - VOID - ---*/ -CServiceBase::CServiceBase( - PWSTR ServiceName, - BOOL CanStop, - BOOL CanShutdown, - BOOL CanPauseContinue - ) -{ - // - // Service name must be a valid string and cannot be NULL. - // - m_name = (ServiceName == NULL) ? L"" : ServiceName; - - m_statusHandle = NULL; - - // - // The service runs in its own process. - // - m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; - - // - // The service is starting. - // - m_status.dwCurrentState = SERVICE_START_PENDING; - - // - // The accepted commands of the service. - // - DWORD dwControlsAccepted = 0; - - if (CanStop) - { - dwControlsAccepted |= SERVICE_ACCEPT_STOP; - } - - if (CanShutdown) - { - dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN; - } - - if (CanPauseContinue) - { - dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE; - } - - m_status.dwControlsAccepted = dwControlsAccepted; - - m_status.dwWin32ExitCode = NO_ERROR; - m_status.dwServiceSpecificExitCode = 0; - m_status.dwCheckPoint = 0; - m_status.dwWaitHint = 0; - - SetupEvents(); -} - - -/*++ - -Routine Description: - - The virtual destructor of CServiceBase. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -CServiceBase::~CServiceBase() -{ - DestroyEvents(); -} - -#pragma endregion - - -#pragma region Service Start, Stop, Pause, Continue, and Shutdown - -/*++ - -Routine Description: - - This function starts the service. It calls the OnStart virtual function - in which you can specify the actions to take when the service starts. If - an error occurs during the startup, the error will be logged in the - Application event log, and the service will be stopped. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Start( - DWORD Argc, - PWSTR *Argv -) -{ - try - { - // - // Tell SCM that the service is starting. - // - SetServiceStatus(SERVICE_START_PENDING); - - // - // Perform service-specific initialization. - // - OnStart(Argc, Argv); - - // - // Tell SCM that the service is started. - // - SetServiceStatus(SERVICE_RUNNING); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Start", Error); - - // - // Set the service status to be stopped. - // - SetServiceStatus(SERVICE_STOPPED, Error); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to start.", EVENTLOG_ERROR_TYPE); - - // - // Set the service status to be stopped. - // - SetServiceStatus(SERVICE_STOPPED); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when a Start - command is sent to the service by the SCM or when the operating system - starts (for a service that starts automatically). Specifies actions to - take when the service starts. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the - procedure is going to take long time. You may also consider spawning a - new thread in OnStart to perform time-consuming initialization tasks. - -Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnStart( - DWORD Argc, - PWSTR *Argv -) -{ - SetVariables(); -} - - -/*++ - -Routine Description: - - This function stops the service. It calls the OnStop virtual - function in which you can specify the actions to take when the service - stops. If an error occurs, the error will be logged in the Application - event log, and the service will be restored to the original state. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Stop() -{ - DWORD OriginalState = m_status.dwCurrentState; - - try - { - // - // Tell SCM that the service is stopping. - // - SetServiceStatus(SERVICE_STOP_PENDING); - - // - // Perform service-specific stop operations. - // - OnStop(); - - // - // Tell SCM that the service is stopped. - // - SetServiceStatus(SERVICE_STOPPED); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Stop", Error); - - // - // Set the orginal service status. - // - SetServiceStatus(OriginalState); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to stop.", EVENTLOG_ERROR_TYPE); - - // - // Set the orginal service status. - // - SetServiceStatus(OriginalState); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when a Stop - command is sent to the service by the SCM. Specifies actions to take - when a service stops running. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the - procedure is going to take long time. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnStop() -{ -} - - -/*++ - -Routine Description: - - The function pauses the service if the service supports pause - and continue. It calls the OnPause virtual function in which you can - specify the actions to take when the service pauses. If an error occurs, - the error will be logged in the Application event log, and the service - will become running. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Pause() -{ - try - { - // - // Tell SCM that the service is pausing. - // - SetServiceStatus(SERVICE_PAUSE_PENDING); - - // - // Perform service-specific pause operations. - // - OnPause(); - - // - // Tell SCM that the service is paused. - // - SetServiceStatus(SERVICE_PAUSED); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Pause", Error); - - // - // Tell SCM that the service is still running. - // - SetServiceStatus(SERVICE_RUNNING); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to pause.", EVENTLOG_ERROR_TYPE); - - // - // Tell SCM that the service is still running. - // - SetServiceStatus(SERVICE_RUNNING); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when a Pause - command is sent to the service by the SCM. Specifies actions to take - when a service pauses. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnPause() -{ -} - - -/*++ - -Routine Description: - - The function resumes normal functioning after being paused if - the service supports pause and continue. It calls the OnContinue virtual - function in which you can specify the actions to take when the service - continues. If an error occurs, the error will be logged in the - Application event log, and the service will still be paused. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Continue() -{ - try - { - // - // Tell SCM that the service is resuming. - // - SetServiceStatus(SERVICE_CONTINUE_PENDING); - - // - // Perform service-specific continue operations. - // - OnContinue(); - - // - // Tell SCM that the service is running. - // - SetServiceStatus(SERVICE_RUNNING); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Continue", Error); - - // - // Tell SCM that the service is still paused. - // - SetServiceStatus(SERVICE_PAUSED); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to resume.", EVENTLOG_ERROR_TYPE); - - // - // Tell SCM that the service is still paused. - // - SetServiceStatus(SERVICE_PAUSED); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, OnContinue runs when a - Continue command is sent to the service by the SCM. Specifies actions to - take when a service resumes normal functioning after being paused. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnContinue() -{ -} - - -/*++ - -Routine Description: - - The function executes when the system is shutting down. It - calls the OnShutdown virtual function in which you can specify what - should occur immediately prior to the system shutting down. If an error - occurs, the error will be logged in the Application event log. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::Shutdown() -{ - try - { - // - // Perform service-specific shutdown operations. - // - OnShutdown(); - - // - // Tell SCM that the service is stopped. - // - SetServiceStatus(SERVICE_STOPPED); - } - catch (DWORD Error) - { - // - // Log the error. - // - WriteToErrorLog(L"Service Shutdown", Error); - } - catch (...) - { - // - // Log the error. - // - WriteToEventLog(L"Service failed to shut down.", EVENTLOG_ERROR_TYPE); - } -} - - -/*++ - -Routine Description: - - When implemented in a derived class, executes when the system - is shutting down. Specifies what should occur immediately prior to the - system shutting down. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::OnShutdown() -{ -} - -#pragma endregion - - -#pragma region Helper Functions - -/*++ - -Routine Description: - - The function sets the service status and reports the status to the SCM. - -Arguments: - - CurrentState - The current state of the service - - Win32ExitCode - The error code to report - - WaitHint - The estimated time for pending operation, in milliseconds - -Return Value: - - VOID - ---*/ -VOID -CServiceBase::SetServiceStatus( - DWORD CurrentState, - DWORD Win32ExitCode, - DWORD WaitHint - ) -{ - static DWORD CheckPoint = 1; - - // - // Fill in the SERVICE_STATUS structure of the service. - // - - m_status.dwCurrentState = CurrentState; - m_status.dwWin32ExitCode = Win32ExitCode; - m_status.dwWaitHint = WaitHint; - - m_status.dwCheckPoint = ((CurrentState == SERVICE_RUNNING) || - (CurrentState == SERVICE_STOPPED)) ? 0 : - CheckPoint++; - - // - // Report the status of the service to the SCM. - // - ::SetServiceStatus(m_statusHandle, &m_status); -} - -#pragma endregion \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h deleted file mode 100644 index 106597e1..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ServiceBase.h +++ /dev/null @@ -1,423 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - ServiceBase.cpp - -Abstract: - - Provides a base class for a service that will exist as part of a service - application. CServiceBase must be derived from when creating a new service - class. - -Environment: - - User mode - ---*/ - -#pragma once - -#include -#include "Utils.h" - -class CServiceBase -{ -public: - - /*++ - - Routine Description: - - Register the executable for a service with the Service Control - Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start - command, which results in a call to the OnStart method in the service. - This method blocks until the service has stopped. - - Arguments: - - Service - The reference to a CServiceBase object. It will become the - singleton service instance of this service application. - - Return Value: - - If the function succeeds, the return value is TRUE. If the function - fails, the return value is FALSE. To get extended error information, - call GetLastError. - - --*/ - static BOOL Run(CServiceBase &service); - - - /*++ - - Routine Description: - - The constructor of CServiceBase. It initializes a new instance - of the CServiceBase class. The optional parameters (CanStop, - CanShutdown and CanPauseContinue) allow you to specify whether the - service can be stopped, paused and continued, or be notified when system - shutdown occurs. - - Arguments: - - ServiceName - The name of the service - - CanStop - The service can be stopped - - CanShutdown - The service is notified when system shutdown occurs - - CanPauseContinue - The service can be paused and continued - - Return Value: - - VOID - - --*/ - CServiceBase(PWSTR ServiceName, - BOOL CanStop = TRUE, - BOOL CanShutdown = TRUE, - BOOL CanPauseContinue = FALSE); - - - /*++ - - Routine Description: - - The virtual destructor of CServiceBase. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual ~CServiceBase(); - - - /*++ - - Routine Description: - - This function stops the service. It calls the OnStop virtual - function in which you can specify the actions to take when the service - stops. If an error occurs, the error will be logged in the Application - event log, and the service will be restored to the original state. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Stop(); - -protected: - - /*++ - - Routine Description: - - When implemented in a derived class, executes when a Start - command is sent to the service by the SCM or when the operating system - starts (for a service that starts automatically). Specifies actions to - take when the service starts. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the - procedure is going to take long time. You may also consider spawning a - new thread in OnStart to perform time-consuming initialization tasks. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - virtual VOID OnStart(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - When implemented in a derived class, executes when a Stop - command is sent to the service by the SCM. Specifies actions to take - when a service stops running. Be sure to periodically call - CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the - procedure is going to take long time. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnStop(); - - - /*++ - - Routine Description: - - When implemented in a derived class, executes when a Pause - command is sent to the service by the SCM. Specifies actions to take - when a service pauses. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnPause(); - - - /*++ - - Routine Description: - - When implemented in a derived class, OnContinue runs when a - Continue command is sent to the service by the SCM. Specifies actions to - take when a service resumes normal functioning after being paused. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnContinue(); - - - /*++ - - Routine Description: - - When implemented in a derived class, executes when the system - is shutting down. Specifies what should occur immediately prior to the - system shutting down. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - virtual VOID OnShutdown(); - - - /*++ - - Routine Description: - - The function sets the service status and reports the status to the SCM. - - Arguments: - - CurrentState - The current state of the service - - Win32ExitCode - The error code to report - - WaitHint - The estimated time for pending operation, in milliseconds - - Return Value: - - VOID - - --*/ - VOID SetServiceStatus(DWORD CurrentState, - DWORD Win32ExitCode = NO_ERROR, - DWORD WaitHint = 0); - -private: - - /*++ - - Routine Description: - - The entry point for the service. It registers the handler function - for the service and starts the service. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - static VOID WINAPI ServiceMain(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - Called by the SCM whenever a control code is sent to the service. - - Arguments: - - CtrlCode - The control code. This parameter can be one of - the following values: - - SERVICE_CONTROL_CONTINUE - SERVICE_CONTROL_INTERROGATE - SERVICE_CONTROL_NETBINDADD - SERVICE_CONTROL_NETBINDDISABLE - SERVICE_CONTROL_NETBINDREMOVE - SERVICE_CONTROL_PARAMCHANGE - SERVICE_CONTROL_PAUSE - SERVICE_CONTROL_SHUTDOWN - SERVICE_CONTROL_STOP - - This parameter can also be a user-defined control - code ranging from 128 to 255. - - Return Value: - - VOID - - --*/ - static VOID WINAPI ServiceCtrlHandler(DWORD Ctrl); - - - /*++ - - Routine Description: - - This function starts the service. It calls the OnStart virtual function - in which you can specify the actions to take when the service starts. If - an error occurs during the startup, the error will be logged in the - Application event log, and the service will be stopped. - - Arguments: - - Argc - The number of command line arguments - - Argv - The array of command line arguments - - Return Value: - - VOID - - --*/ - VOID Start(DWORD Argc, PWSTR *Argv); - - - /*++ - - Routine Description: - - The function pauses the service if the service supports pause - and continue. It calls the OnPause virtual function in which you can - specify the actions to take when the service pauses. If an error occurs, - the error will be logged in the Application event log, and the service - will become running. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Pause(); - - - /*++ - - Routine Description: - - The function resumes normal functioning after being paused if - the service supports pause and continue. It calls the OnContinue virtual - function in which you can specify the actions to take when the service - continues. If an error occurs, the error will be logged in the - Application event log, and the service will still be paused. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Continue(); - - - /*++ - - Routine Description: - - The function executes when the system is shutting down. It - calls the OnShutdown virtual function in which you can specify what - should occur immediately prior to the system shutting down. If an error - occurs, the error will be logged in the Application event log. - - Arguments: - - VOID - - Return Value: - - VOID - - --*/ - VOID Shutdown(); - - - // - // The singleton service instance. - // - static CServiceBase *s_service; - - // - // The name of the service. - // - PWSTR m_name; - - // - // The status of the service. - // - SERVICE_STATUS m_status; - - // - // The service status handle. - // - SERVICE_STATUS_HANDLE m_statusHandle; -}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h deleted file mode 100644 index 3d851537..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/ThreadPool.h +++ /dev/null @@ -1,80 +0,0 @@ -/****************************** Module Header ******************************\ -* Module Name: ThreadPool.h -* Project: CppWindowsService -* Copyright (c) Microsoft Corporation. -* -* The class was designed by Kenny Kerr. It provides the ability to queue -* simple member functions of a class to the Windows thread pool. -* -* Using the thread pool is simple and feels natural in C++. -* -* class CSampleService -* { -* public: -* -* void AsyncRun() -* { -* CThreadPool::QueueUserWorkItem(&Service::Run, this); -* } -* -* void Run() -* { -* // Some lengthy operation -* } -* }; -* -* Kenny Kerr spends most of his time designing and building distributed -* applications for the Microsoft Windows platform. He also has a particular -* passion for C++ and security programming. Reach Kenny at -* http://weblogs.asp.net/kennykerr/ or visit his Web site: -* http://www.kennyandkarin.com/Kenny/. -* -* This source is subject to the Microsoft Public License. -* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL. -* All other rights reserved. -* -* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, -* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. -\***************************************************************************/ - -#pragma once - -#include - - -class CThreadPool -{ -public: - - template - static void QueueUserWorkItem(void (T::*function)(void), - T *object, ULONG flags = WT_EXECUTELONGFUNCTION) - { - typedef std::pair CallbackType; - std::auto_ptr p(new CallbackType(function, object)); - - if (::QueueUserWorkItem(ThreadProc, p.get(), flags)) - { - // The ThreadProc now has the responsibility of deleting the pair. - p.release(); - } - else - { - throw GetLastError(); - } - } - -private: - - template - static DWORD WINAPI ThreadProc(PVOID context) - { - typedef std::pair CallbackType; - - std::auto_ptr p(static_cast(context)); - - (p->second->*p->first)(); - return 0; - } -}; \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp deleted file mode 100644 index e8fc87ee..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Utils.cpp - -Abstract: - - Provides utility function to SampleApp.cpp. - -Environment: - - User mode - ---*/ - -#include "Utils.h" - -// -// Service trace event provider -// {54a25c42-cd91-4210-98cc-c3447b56e447} -// -EXTERN_C __declspec(selectany) const GUID SERVICE_PROVIDER_GUID = { 0x54a25c42, 0xcd91, 0x4210,{ 0x98, 0xcc, 0xc3, 0x44, 0x7b, 0x56, 0xe4, 0x47 } }; - -REGHANDLE m_etwRegHandle; - - -/*++ - -Routine Description: - - Sets up logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -SetupEvents() -{ - NTSTATUS status = EventRegister(&SERVICE_PROVIDER_GUID, - nullptr, - nullptr, - &m_etwRegHandle); - - if (status != ERROR_SUCCESS) - { - wprintf(L"Provider not registered. EventRegister failed with error: 0x%08X\n", status); - } -} - - -/*++ - -Routine Description: - - Destroys logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID -DestroyEvents() -{ - if (m_etwRegHandle != NULL) - { - EventUnregister(m_etwRegHandle); - } -} - - -/*++ - -Routine Description: - - Log a message. - -Arguments: - - Message - The string message to be logged - - Level - The type of event to be logged. This parameter can - be one of the following values: - - TRACE_LEVEL_CRITICAL - TRACE_LEVEL_ERROR - TRACE_LEVEL_WARNING - TRACE_LEVEL_INFORMATION - TRACE_LEVEL_VERBOSE - -Return Value: - - VOID - ---*/ -VOID -WriteToEventLog( - PWSTR Message, - BYTE Level - ) -{ - if (m_etwRegHandle != NULL) - { - EventWriteString(m_etwRegHandle, Level, 0, Message); - } -} - - -/*++ - -Routine Description: - - Log an error message. - -Arguments: - - Function - The function that gives the error - - Error - The error code - -Return Value: - - VOID - ---*/ -VOID -WriteToErrorLog( - PWSTR Function, - DWORD Error - ) -{ - WCHAR Message[260]; - - StringCchPrintf(Message, ARRAYSIZE(Message), - L"%ws failed with error: 0x%08x", Function, Error); - - WriteToEventLog(Message, TRACE_LEVEL_ERROR); -} \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h deleted file mode 100644 index b619f461..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/Utils.h +++ /dev/null @@ -1,111 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - - THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR - PURPOSE. - -Module Name: - - Utils.cpp - -Abstract: - - Provides utility function to SampleApp.cpp. - -Environment: - - User mode - ---*/ - -#pragma once - -#include -#include -#include -#include - -/*++ - -Routine Description: - - Sets up logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID SetupEvents(); - - -/*++ - -Routine Description: - - Destroys logging. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID DestroyEvents(); - - -/*++ - -Routine Description: - - Log a message. - -Arguments: - - Message - The string message to be logged - - Level - The type of event to be logged. This parameter can - be one of the following values: - - TRACE_LEVEL_CRITICAL - TRACE_LEVEL_ERROR - TRACE_LEVEL_WARNING - TRACE_LEVEL_INFORMATION - TRACE_LEVEL_VERBOSE - -Return Value: - - VOID - ---*/ -VOID WriteToEventLog(PWSTR Message, BYTE Level); - - -/*++ - -Routine Description: - - Log an error message. - -Arguments: - - Function - The function that gives the error - - Error - The error code - -Return Value: - - VOID - ---*/ -VOID WriteToErrorLog(PWSTR Function, DWORD Error); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters deleted file mode 100644 index 7f12a302..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.filters +++ /dev/null @@ -1,54 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx deleted file mode 100644 index 61e1e958..00000000 Binary files a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.inx and /dev/null differ diff --git a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj b/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj deleted file mode 100644 index 111fd2bf..00000000 --- a/general/DCHU/osrfx2_DCHU_extension/osrfx2_DCHU_usersvc/osrfx2_DCHU_usersvc.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {DE70E2D1-6A4D-4984-BD82-CE750889F0D3} - osrfx2_DCHU_usersvc - Win32Proj - osrfx2_DCHU_usersvc - 10.0.15063.0 - - - - Application - Unicode - true - v141 - - - Application - Unicode - v141 - - - Application - Unicode - true - v141 - - - Application - Unicode - v141 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreaded - - - Level3 - EditAndContinue - - - true - Console - MachineX86 - onecoreuap.lib;%(AdditionalDependencies); - - - - - MaxSpeed - true - WIN32;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - true - - - Level3 - ProgramDatabase - - - true - Console - true - true - MachineX86 - onecoreuap.lib;%(AdditionalDependencies); - - - - - X64 - - - Disabled - WIN32;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreaded - - - Level3 - ProgramDatabase - - - true - Console - MachineX64 - onecoreuap.lib;%(AdditionalDependencies); - - - - - - - - - X64 - - - MaxSpeed - true - WIN32;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - true - Console - true - true - MachineX64 - onecoreuap.lib;%(AdditionalDependencies); - - - - - - - - - - - - - - - - - - - true - - - - - - \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters new file mode 100644 index 00000000..fa953f4c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx new file mode 100644 index 00000000..8baab1a0 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.inx @@ -0,0 +1,64 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_component.INF +; +;Abstract: +; +; Installation inf for one of the OSR FX2 Learning Kit's +; AddComponent directives +; +;--*/ + +[Version] +Signature = "$Windows NT$" +Class = SoftwareComponent +ClassGuid = {5c4c3332-344d-483c-8739-259e934c9cc8} +Provider = %ManufacturerName% +CatalogFile = osrfx2_DCHU_component.cat + +[Manufacturer] +%ManufacturerName% = OsrFx2Component, NT$ARCH$ + +[OsrFx2Component.NT$ARCH$] +%DeviceName% = OsrFx2Component_Install, SWC\VID_045e&PID_94ab + +[SourceDisksFiles] +osrfx2_DCHU_componentsoftware.exe = 1 + +[SourceDisksNames] +1 = %DiskName% + +[DestinationDirs] +OsrFx2Component_CopyFiles = 13 ; copy to driverstore + +[OsrFx2Component_Install.NT] +CopyFiles = OsrFx2Component_CopyFiles + +[OsrFx2Component_Install.NT.Services] +AddService = , 0x00000002 + +[OsrFx2Component_Install.NT.Software] +AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall + +[OsrFx2Component_SoftwareInstall] +SoftwareType = 1 +SoftwareBinary = osrfx2_DCHU_componentsoftware.exe +SoftwareArguments = <> +SoftwareVersion = 1.0.0.0 + +[OsrFx2Component_CopyFiles] +osrfx2_DCHU_componentsoftware.exe + +[Strings] +ManufacturerName = "Contoso" +DiskName = "OsrFx2 DCHU Component Installation Disk" +DeviceName = "OsrFx2 DCHU Component Device" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj new file mode 100644 index 00000000..bc19d287 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_component/osrfx2_DCHU_component.vcxproj @@ -0,0 +1,276 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + + + + + + + + + + + + + + + + + + + {F90EFA96-B075-4531-B4E1-F406362D16BF} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.5 + 12.0 + Debug + Win32 + osrfx2_DCHU_component + osrfx2_DCHU_component + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + 1.0.0.0 + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp new file mode 100644 index 00000000..c14e66d1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp @@ -0,0 +1,489 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + osrfx2_DCHU_componentsoftware.cpp + +Abstract: + + An example .exe to run using the AddSoftware directive within an INF. + Contains an example on how to obtain a handle to the primary device using + SoftwareArguments within an AddSoftware directive's section. + +Environment: + + User mode + +--*/ + +#include "stdafx.h" + +#define BUFFER_SIZE (128 * sizeof(WCHAR)) +#define DEVICE_REG_SUBKEY L"OSR" +#define DEVICE_VALUE_OP_MODE L"OperatingMode" +#define DEVICE_VALUE_OP_PARAMS L"OperatingParams" +#define DEVICE_VALUE_OP_EXCEPTIONS L"OperatingExceptions" +#define CONTOSO_FILEPATH L"C:\\Program Files\\Contoso" +#define OSRFX2_DCHU_FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU" +#define FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU\\AddSoftwareInstallationFile.txt" +#define FILE_CONTENT L"Operating Mode: %ws\r\nOperating Params: %ws\r\nOperating Exceptions: %ws" + + +/*++ + +Routine Description: + +Arguments: + +Return Value: + + +--*/ +DWORD +WriteToFile( + _In_ PWSTR MessageText, + _In_ DWORD MessageTextLength + ) +{ + DWORD Err = ERROR_SUCCESS; + BOOL ErrorFlag = FALSE; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD BytesToWrite; + DWORD BytesWritten; + + if (!CreateDirectory(CONTOSO_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + if (!CreateDirectory(OSRFX2_DCHU_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + hFile = CreateFile(FILEPATH, + GENERIC_WRITE, + 0, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + BytesToWrite = MessageTextLength * sizeof(WCHAR); + + ErrorFlag = WriteFile(hFile, + MessageText, + BytesToWrite, + &BytesWritten, + NULL); + + if ((!ErrorFlag) || + (BytesToWrite != BytesWritten)) + { + Err = GetLastError(); + goto cleanup; + } + +cleanup: + + if (hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile); + } + + return Err; +} + + +/*++ + +Routine Description: + + Obtains the handle to the device that used a separate Software Component + INF to install software. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +__cdecl +_tmain( + INT Argc, + TCHAR *Argv[]) +{ + DWORD Err = ERROR_SUCCESS; + HRESULT hr = S_OK; + BOOL ErrorFlag = FALSE; + DWORD BytesToWrite = 0; + DWORD BytesWritten = 0; + PTSTR DeviceInstanceId; + HDEVINFO DevInfoList = INVALID_HANDLE_VALUE; + SP_DEVINFO_DATA DevInfoData; + WCHAR ParentDeviceInstanceId[MAX_DEVICE_ID_LEN]; + DWORD RequiredSize; + DEVPROPTYPE DevPropType; + SP_DEVINFO_DATA ParentDevInfoData; + HKEY DevRegKey = NULL; + PWSTR OperatingMode = NULL; + PWSTR OperatingParams = NULL; + PWSTR OperatingExceptions = NULL; + DWORD ValueType; + DWORD ValueSize = BUFFER_SIZE; + HKEY DevOsrRegKey = NULL; + PWSTR FileText = NULL; + DWORD FileTextLength; + + // + // Validate arguments. + // + if (Argc != 2) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + OperatingMode = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingMode == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingParams = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingParams == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingExceptions = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingExceptions == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + // + // Argv[1] should be the device instance ID. + // + DeviceInstanceId = Argv[1]; + + // + // Create a device info list to store queried device handles. + // + DevInfoList = SetupDiCreateDeviceInfoList(NULL, NULL); + + if (DevInfoList == INVALID_HANDLE_VALUE) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Add the Software Component device that called AddSoftware to the + // device info list, which will be used to find the primary device that + // called AddComponent in the first place. + // + if (!SetupDiOpenDeviceInfo(DevInfoList, + DeviceInstanceId, + NULL, + 0, + &DevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Get the device instance id of the opened device's parent. + // + if (!SetupDiGetDeviceProperty(DevInfoList, + &DevInfoData, + &DEVPKEY_Device_Parent, + &DevPropType, + (PBYTE)ParentDeviceInstanceId, + sizeof(ParentDeviceInstanceId), + &RequiredSize, + 0)) + { + Err = GetLastError(); + goto cleanup; + } + + if ((DevPropType != DEVPROP_TYPE_STRING) || + (RequiredSize < sizeof(WCHAR))) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + ParentDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Get the parent of the device we retrieved first, which is the device + // that called AddComponent in its INF. + // + if (!SetupDiOpenDeviceInfoW(DevInfoList, + ParentDeviceInstanceId, + NULL, + 0, + &ParentDevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Open up the HW registry keys of the primary device. + // + DevRegKey = SetupDiOpenDevRegKey(DevInfoList, + &ParentDevInfoData, + DICS_FLAG_GLOBAL, + 0, + DIREG_DEV, + KEY_READ); + + if (DevRegKey == INVALID_HANDLE_VALUE) + { + Err = GetLastError(); + DevRegKey = NULL; + goto cleanup; + } + + Err = RegOpenKeyEx(DevRegKey, + DEVICE_REG_SUBKEY, + 0, + KEY_QUERY_VALUE, + &DevOsrRegKey); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + + // + // Retrieve the registry values defined in the primary device's INF. + // Note that if the extension INF was applied, the extension INF would + // overwrite OperatingParams and create OperatingExceptions. + // + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingMode = (PTSTR)realloc(OperatingMode, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingMode[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingMode[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_PARAMS, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingParams = (PTSTR)realloc(OperatingParams, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingParams[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingParams[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingExceptions = (PTSTR)realloc(OperatingExceptions, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingExceptions[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingExceptions[0] = TEXT('\0'); + } + + FileTextLength = (DWORD)wcslen(OperatingMode) + + (DWORD)wcslen(OperatingParams) + + (DWORD)wcslen(OperatingExceptions) + + (DWORD)wcslen(FILE_CONTENT) - + 9; // Subtract the 3 %ws + + FileText = (PWSTR)malloc((FileTextLength + 1) * sizeof(WCHAR)); + + if (FileText == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + hr = StringCchPrintf(FileText, + FileTextLength + 1, + FILE_CONTENT, + OperatingMode, + OperatingParams, + OperatingExceptions); + + if (FAILED(hr)) + { + Err = HRESULT_CODE(hr); + goto cleanup; + } + + Err = WriteToFile(FileText, FileTextLength); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + +cleanup: + + if (FileText != NULL) + { + free(FileText); + } + + if (OperatingExceptions != NULL) + { + free(OperatingExceptions); + } + + if (OperatingParams != NULL) + { + free(OperatingParams); + } + + if (OperatingMode != NULL) + { + free(OperatingMode); + } + + if (DevOsrRegKey != NULL) + { + RegCloseKey(DevOsrRegKey); + } + + if (DevRegKey != NULL) + { + RegCloseKey(DevRegKey); + } + + if (DevInfoList != INVALID_HANDLE_VALUE) + { + SetupDiDestroyDeviceInfoList(DevInfoList); + } + + return; +} + diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters new file mode 100644 index 00000000..395438fa --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj new file mode 100644 index 00000000..32ebdebe --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {26D91630-B8FF-4102-A258-32F7D1C84E20} + Win32Proj + osrfx2_DCHU_componentsoftware + 10.0.16245.0 + osrfx2_DCHU_componentsoftware + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + $(ProjectName) + + + false + + + false + $(ProjectName) + .exe + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp new file mode 100644 index 00000000..79325e21 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// osrusbfx2umsoftware.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h new file mode 100644 index 00000000..edb61924 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/stdafx.h @@ -0,0 +1,18 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: reference additional headers your program requires here diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h new file mode 100644 index 00000000..87c0086d --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln new file mode 100644 index 00000000..6cc1d6b0 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension.sln @@ -0,0 +1,102 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension", "{4577857A-CCAE-42EB-BDE2-16C1E3DC7B14}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension\osrfx2_DCHU_extension.vcxproj", "{0588DF70-3923-42E6-8DC9-13C2C0186F20}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component", "{E148C50E-31A6-423E-A867-526FD51DA164}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_component", "osrfx2_DCHU_component\osrfx2_DCHU_component.vcxproj", "{F90EFA96-B075-4531-B4E1-F406362D16BF}" + ProjectSection(ProjectDependencies) = postProject + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {26D91630-B8FF-4102-A258-32F7D1C84E20} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware", "{272BE7AA-9011-46FA-96C9-2051C9526476}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware\osrfx2_DCHU_componentsoftware.vcxproj", "{26D91630-B8FF-4102-A258-32F7D1C84E20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.ActiveCfg = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Build.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Deploy.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Build.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.ActiveCfg = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Build.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Deploy.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.ActiveCfg = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Build.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Deploy.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.ActiveCfg = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Build.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Deploy.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.ActiveCfg = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Build.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Deploy.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.ActiveCfg = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Build.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Deploy.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.ActiveCfg = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Build.0 = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Deploy.0 = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.ActiveCfg = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Build.0 = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM.Deploy.0 = Debug|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Build.0 = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.ActiveCfg = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Build.0 = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x64.Deploy.0 = Debug|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.ActiveCfg = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Build.0 = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Debug|x86.Deploy.0 = Debug|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.ActiveCfg = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Build.0 = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM.Deploy.0 = Release|ARM + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.ActiveCfg = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Build.0 = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|ARM64.Deploy.0 = Release|ARM64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.ActiveCfg = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Build.0 = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x64.Deploy.0 = Release|x64 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.ActiveCfg = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Build.0 = Release|Win32 + {F90EFA96-B075-4531-B4E1-F406362D16BF}.Release|x86.Deploy.0 = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM64.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.ActiveCfg = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.Build.0 = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.Build.0 = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM64.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.ActiveCfg = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.Build.0 = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20} = {4577857A-CCAE-42EB-BDE2-16C1E3DC7B14} + {F90EFA96-B075-4531-B4E1-F406362D16BF} = {E148C50E-31A6-423E-A867-526FD51DA164} + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {272BE7AA-9011-46FA-96C9-2051C9526476} + EndGlobalSection +EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters new file mode 100644 index 00000000..0ba1a59c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx new file mode 100644 index 00000000..660e5049 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx @@ -0,0 +1,54 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_extension.INF +; +;Abstract: +; +; Extension inf for the OSR FX2 Learning Kit +; +;--*/ + +[Version] +Signature = "$WINDOWS NT$" +Class = Extension +ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} +Provider = %ManufacturerName% +ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} +CatalogFile = osrfx2_DCHU_extension.cat +DriverVer = 05/16/2017,15.14.36.721 + +[Manufacturer] +%ManufacturerName% = OsrFx2Extension, NT$ARCH$ + +[OsrFx2Extension.NT$ARCH$] +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_045e&Pid_94aa&mi_00 +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 + +[OsrFx2Extension_Install.NT] +; Empty + +[OsrFx2Extension_Install.NT.HW] +AddReg = OsrFx2Extension_AddReg + +[OsrFx2Extension_AddReg] +HKR, OSR, "OperatingParams",, "-Extended" +HKR, OSR, "OperatingExceptions",, "x86" + +[OsrFx2Extension_Install.NT.Components] +AddComponent = osrfx2_DCHU_component,,OsrFx2Extension_ComponentInstall + +[OsrFx2Extension_ComponentInstall] +ComponentIds=VID_045e&PID_94ab + +[Strings] +ManufacturerName = "Contoso" +OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj new file mode 100644 index 00000000..bfc7ded6 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj @@ -0,0 +1,266 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + {0588DF70-3923-42E6-8DC9-13C2C0186F20} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.6.1 + 12.0 + Debug + Win32 + osrfx2_DCHU_extension + osrfx2_DCHU_extension + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx new file mode 100644 index 00000000..8baab1a0 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_component/osrfx2_DCHU_component.inx @@ -0,0 +1,64 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_component.INF +; +;Abstract: +; +; Installation inf for one of the OSR FX2 Learning Kit's +; AddComponent directives +; +;--*/ + +[Version] +Signature = "$Windows NT$" +Class = SoftwareComponent +ClassGuid = {5c4c3332-344d-483c-8739-259e934c9cc8} +Provider = %ManufacturerName% +CatalogFile = osrfx2_DCHU_component.cat + +[Manufacturer] +%ManufacturerName% = OsrFx2Component, NT$ARCH$ + +[OsrFx2Component.NT$ARCH$] +%DeviceName% = OsrFx2Component_Install, SWC\VID_045e&PID_94ab + +[SourceDisksFiles] +osrfx2_DCHU_componentsoftware.exe = 1 + +[SourceDisksNames] +1 = %DiskName% + +[DestinationDirs] +OsrFx2Component_CopyFiles = 13 ; copy to driverstore + +[OsrFx2Component_Install.NT] +CopyFiles = OsrFx2Component_CopyFiles + +[OsrFx2Component_Install.NT.Services] +AddService = , 0x00000002 + +[OsrFx2Component_Install.NT.Software] +AddSoftware = osrfx2_DCHU_componentsoftware,, OsrFx2Component_SoftwareInstall + +[OsrFx2Component_SoftwareInstall] +SoftwareType = 1 +SoftwareBinary = osrfx2_DCHU_componentsoftware.exe +SoftwareArguments = <> +SoftwareVersion = 1.0.0.0 + +[OsrFx2Component_CopyFiles] +osrfx2_DCHU_componentsoftware.exe + +[Strings] +ManufacturerName = "Contoso" +DiskName = "OsrFx2 DCHU Component Installation Disk" +DeviceName = "OsrFx2 DCHU Component Device" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp new file mode 100644 index 00000000..c14e66d1 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.cpp @@ -0,0 +1,489 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + + THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR + PURPOSE. + +Module Name: + + osrfx2_DCHU_componentsoftware.cpp + +Abstract: + + An example .exe to run using the AddSoftware directive within an INF. + Contains an example on how to obtain a handle to the primary device using + SoftwareArguments within an AddSoftware directive's section. + +Environment: + + User mode + +--*/ + +#include "stdafx.h" + +#define BUFFER_SIZE (128 * sizeof(WCHAR)) +#define DEVICE_REG_SUBKEY L"OSR" +#define DEVICE_VALUE_OP_MODE L"OperatingMode" +#define DEVICE_VALUE_OP_PARAMS L"OperatingParams" +#define DEVICE_VALUE_OP_EXCEPTIONS L"OperatingExceptions" +#define CONTOSO_FILEPATH L"C:\\Program Files\\Contoso" +#define OSRFX2_DCHU_FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU" +#define FILEPATH L"C:\\Program Files\\Contoso\\OsrFx2_DCHU\\AddSoftwareInstallationFile.txt" +#define FILE_CONTENT L"Operating Mode: %ws\r\nOperating Params: %ws\r\nOperating Exceptions: %ws" + + +/*++ + +Routine Description: + +Arguments: + +Return Value: + + +--*/ +DWORD +WriteToFile( + _In_ PWSTR MessageText, + _In_ DWORD MessageTextLength + ) +{ + DWORD Err = ERROR_SUCCESS; + BOOL ErrorFlag = FALSE; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD BytesToWrite; + DWORD BytesWritten; + + if (!CreateDirectory(CONTOSO_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + if (!CreateDirectory(OSRFX2_DCHU_FILEPATH, NULL)) + { + Err = GetLastError(); + + if (Err == ERROR_ALREADY_EXISTS) + { + Err = ERROR_SUCCESS; + } + else + { + goto cleanup; + } + } + + hFile = CreateFile(FILEPATH, + GENERIC_WRITE, + 0, + NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + BytesToWrite = MessageTextLength * sizeof(WCHAR); + + ErrorFlag = WriteFile(hFile, + MessageText, + BytesToWrite, + &BytesWritten, + NULL); + + if ((!ErrorFlag) || + (BytesToWrite != BytesWritten)) + { + Err = GetLastError(); + goto cleanup; + } + +cleanup: + + if (hFile != INVALID_HANDLE_VALUE) + { + CloseHandle(hFile); + } + + return Err; +} + + +/*++ + +Routine Description: + + Obtains the handle to the device that used a separate Software Component + INF to install software. + +Arguments: + + Argc - The number of command line arguments + + Argv - The array of command line arguments + +Return Value: + + VOID + +--*/ +VOID +__cdecl +_tmain( + INT Argc, + TCHAR *Argv[]) +{ + DWORD Err = ERROR_SUCCESS; + HRESULT hr = S_OK; + BOOL ErrorFlag = FALSE; + DWORD BytesToWrite = 0; + DWORD BytesWritten = 0; + PTSTR DeviceInstanceId; + HDEVINFO DevInfoList = INVALID_HANDLE_VALUE; + SP_DEVINFO_DATA DevInfoData; + WCHAR ParentDeviceInstanceId[MAX_DEVICE_ID_LEN]; + DWORD RequiredSize; + DEVPROPTYPE DevPropType; + SP_DEVINFO_DATA ParentDevInfoData; + HKEY DevRegKey = NULL; + PWSTR OperatingMode = NULL; + PWSTR OperatingParams = NULL; + PWSTR OperatingExceptions = NULL; + DWORD ValueType; + DWORD ValueSize = BUFFER_SIZE; + HKEY DevOsrRegKey = NULL; + PWSTR FileText = NULL; + DWORD FileTextLength; + + // + // Validate arguments. + // + if (Argc != 2) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + OperatingMode = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingMode == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingParams = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingParams == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + OperatingExceptions = (PWSTR)malloc(BUFFER_SIZE * sizeof(WCHAR)); + + if (OperatingExceptions == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + // + // Argv[1] should be the device instance ID. + // + DeviceInstanceId = Argv[1]; + + // + // Create a device info list to store queried device handles. + // + DevInfoList = SetupDiCreateDeviceInfoList(NULL, NULL); + + if (DevInfoList == INVALID_HANDLE_VALUE) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Add the Software Component device that called AddSoftware to the + // device info list, which will be used to find the primary device that + // called AddComponent in the first place. + // + if (!SetupDiOpenDeviceInfo(DevInfoList, + DeviceInstanceId, + NULL, + 0, + &DevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Get the device instance id of the opened device's parent. + // + if (!SetupDiGetDeviceProperty(DevInfoList, + &DevInfoData, + &DEVPKEY_Device_Parent, + &DevPropType, + (PBYTE)ParentDeviceInstanceId, + sizeof(ParentDeviceInstanceId), + &RequiredSize, + 0)) + { + Err = GetLastError(); + goto cleanup; + } + + if ((DevPropType != DEVPROP_TYPE_STRING) || + (RequiredSize < sizeof(WCHAR))) + { + Err = ERROR_INVALID_PARAMETER; + goto cleanup; + } + + ParentDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + // + // Get the parent of the device we retrieved first, which is the device + // that called AddComponent in its INF. + // + if (!SetupDiOpenDeviceInfoW(DevInfoList, + ParentDeviceInstanceId, + NULL, + 0, + &ParentDevInfoData)) + { + Err = GetLastError(); + goto cleanup; + } + + // + // Open up the HW registry keys of the primary device. + // + DevRegKey = SetupDiOpenDevRegKey(DevInfoList, + &ParentDevInfoData, + DICS_FLAG_GLOBAL, + 0, + DIREG_DEV, + KEY_READ); + + if (DevRegKey == INVALID_HANDLE_VALUE) + { + Err = GetLastError(); + DevRegKey = NULL; + goto cleanup; + } + + Err = RegOpenKeyEx(DevRegKey, + DEVICE_REG_SUBKEY, + 0, + KEY_QUERY_VALUE, + &DevOsrRegKey); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + + // + // Retrieve the registry values defined in the primary device's INF. + // Note that if the extension INF was applied, the extension INF would + // overwrite OperatingParams and create OperatingExceptions. + // + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingMode = (PTSTR)realloc(OperatingMode, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingMode, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingMode[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingMode[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_PARAMS, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingParams = (PTSTR)realloc(OperatingParams, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_MODE, + NULL, + &ValueType, + (LPBYTE)OperatingParams, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingParams[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingParams[0] = TEXT('\0'); + } + + ValueSize = BUFFER_SIZE; + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + + while (Err == ERROR_MORE_DATA) + { + // + // Create a larger buffer. + // + OperatingExceptions = (PTSTR)realloc(OperatingExceptions, ValueSize); + + Err = RegQueryValueEx(DevOsrRegKey, + DEVICE_VALUE_OP_EXCEPTIONS, + NULL, + &ValueType, + (LPBYTE)OperatingExceptions, + &ValueSize); + } + + if (Err != ERROR_SUCCESS) + { + OperatingExceptions[0] = TEXT('\0'); + } + else if ((ValueType != REG_SZ) || + (ValueSize < sizeof(TCHAR))) + { + Err = ERROR_REGISTRY_CORRUPT; + OperatingExceptions[0] = TEXT('\0'); + } + + FileTextLength = (DWORD)wcslen(OperatingMode) + + (DWORD)wcslen(OperatingParams) + + (DWORD)wcslen(OperatingExceptions) + + (DWORD)wcslen(FILE_CONTENT) - + 9; // Subtract the 3 %ws + + FileText = (PWSTR)malloc((FileTextLength + 1) * sizeof(WCHAR)); + + if (FileText == NULL) + { + Err = ERROR_OUTOFMEMORY; + goto cleanup; + } + + hr = StringCchPrintf(FileText, + FileTextLength + 1, + FILE_CONTENT, + OperatingMode, + OperatingParams, + OperatingExceptions); + + if (FAILED(hr)) + { + Err = HRESULT_CODE(hr); + goto cleanup; + } + + Err = WriteToFile(FileText, FileTextLength); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + +cleanup: + + if (FileText != NULL) + { + free(FileText); + } + + if (OperatingExceptions != NULL) + { + free(OperatingExceptions); + } + + if (OperatingParams != NULL) + { + free(OperatingParams); + } + + if (OperatingMode != NULL) + { + free(OperatingMode); + } + + if (DevOsrRegKey != NULL) + { + RegCloseKey(DevOsrRegKey); + } + + if (DevRegKey != NULL) + { + RegCloseKey(DevRegKey); + } + + if (DevInfoList != INVALID_HANDLE_VALUE) + { + SetupDiDestroyDeviceInfoList(DevInfoList); + } + + return; +} + diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters new file mode 100644 index 00000000..395438fa --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj new file mode 100644 index 00000000..32ebdebe --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {26D91630-B8FF-4102-A258-32F7D1C84E20} + Win32Proj + osrfx2_DCHU_componentsoftware + 10.0.16245.0 + osrfx2_DCHU_componentsoftware + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + $(ProjectName) + + + false + + + false + $(ProjectName) + .exe + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Console + true + true + true + onecoreuap.lib;setupapi.lib; + + + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp new file mode 100644 index 00000000..79325e21 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// osrusbfx2umsoftware.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h new file mode 100644 index 00000000..edb61924 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/stdafx.h @@ -0,0 +1,18 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// TODO: reference additional headers your program requires here diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h new file mode 100644 index 00000000..87c0086d --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln new file mode 100644 index 00000000..40b15034 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension.sln @@ -0,0 +1,73 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension", "{4577857A-CCAE-42EB-BDE2-16C1E3DC7B14}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_extension", "osrfx2_DCHU_extension\osrfx2_DCHU_extension.vcxproj", "{0588DF70-3923-42E6-8DC9-13C2C0186F20}" + ProjectSection(ProjectDependencies) = postProject + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {26D91630-B8FF-4102-A258-32F7D1C84E20} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware", "{B327FC27-5816-4F28-959F-4C35F1D22678}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrfx2_DCHU_componentsoftware", "osrfx2_DCHU_componentsoftware\osrfx2_DCHU_componentsoftware.vcxproj", "{26D91630-B8FF-4102-A258-32F7D1C84E20}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.ActiveCfg = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Build.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM.Deploy.0 = Debug|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Build.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.ActiveCfg = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Build.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x64.Deploy.0 = Debug|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.ActiveCfg = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Build.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Debug|x86.Deploy.0 = Debug|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.ActiveCfg = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Build.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM.Deploy.0 = Release|ARM + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.ActiveCfg = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Build.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|ARM64.Deploy.0 = Release|ARM64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.ActiveCfg = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Build.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x64.Deploy.0 = Release|x64 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.ActiveCfg = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Build.0 = Release|Win32 + {0588DF70-3923-42E6-8DC9-13C2C0186F20}.Release|x86.Deploy.0 = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|ARM64.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.ActiveCfg = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x64.Build.0 = Debug|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.ActiveCfg = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Debug|x86.Build.0 = Debug|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|ARM64.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.ActiveCfg = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x64.Build.0 = Release|x64 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.ActiveCfg = Release|Win32 + {26D91630-B8FF-4102-A258-32F7D1C84E20}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0588DF70-3923-42E6-8DC9-13C2C0186F20} = {4577857A-CCAE-42EB-BDE2-16C1E3DC7B14} + {26D91630-B8FF-4102-A258-32F7D1C84E20} = {B327FC27-5816-4F28-959F-4C35F1D22678} + EndGlobalSection +EndGlobal diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters new file mode 100644 index 00000000..0ba1a59c --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.filters @@ -0,0 +1,14 @@ + + + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx new file mode 100644 index 00000000..d6bc7e00 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx @@ -0,0 +1,55 @@ +;/*++ +; +;Copyright (c) Microsoft Corporation. All rights reserved. +; +; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +; KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +; PURPOSE. +; +;Module Name: +; +; osrfx2_DCHU_extension.INF +; +;Abstract: +; +; Extension inf for the OSR FX2 Learning Kit +; +;--*/ + +[Version] +Signature = "$WINDOWS NT$" +Class = Extension +ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} +Provider = %ManufacturerName% +ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} +CatalogFile = osrfx2_DCHU_extension.cat +DriverVer = 05/16/2017,15.14.36.721 + +[Manufacturer] +%ManufacturerName% = OsrFx2Extension, NT$ARCH$ + +[OsrFx2Extension.NT$ARCH$] +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_045e&Pid_94aa&mi_00 +%OsrFx2.ExtensionDesc% = OsrFx2Extension_Install, USB\Vid_0547&PID_1002 + +[OsrFx2Extension_Install.NT] +CopyInf=osrfx2_DCHU_component.inf + +[OsrFx2Extension_Install.NT.HW] +AddReg = OsrFx2Extension_AddReg +AddReg = OsrFx2Extension_COMAddReg + +[OsrFx2Extension_AddReg] +HKR, OSR, "OperatingParams",, "-Extended" +HKR, OSR, "OperatingExceptions",, "x86" + +[OsrFx2Extension_Install.NT.Components] +AddComponent = osrfx2_DCHU_component,,OsrFx2Extension_ComponentInstall + +[OsrFx2Extension_ComponentInstall] +ComponentIds=VID_045e&PID_94ab + +[Strings] +ManufacturerName = "Contoso" +OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj new file mode 100644 index 00000000..4542c3a7 --- /dev/null +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.vcxproj @@ -0,0 +1,273 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + + + + + + + + {0588DF70-3923-42E6-8DC9-13C2C0186F20} + {4605da2c-74a5-4865-98e1-152ef136825f} + v4.6.1 + 12.0 + Debug + Win32 + osrfx2_DCHU_extension + osrfx2_DCHU_extension + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + true + WindowsKernelModeDriver10.0 + Utility + Package + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Utility + Package + true + + + + + + + + + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + DbgengRemoteDebugger + + + + False + False + True + + 133563 + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + $(InfArch) + 1.0.0.0 + + + + + + \ No newline at end of file -- cgit v1.3.1 From 022a2da881f19f740d5b86122360de6015b2b0b6 Mon Sep 17 00:00:00 2001 From: Matthew Montera Date: Tue, 22 Aug 2017 11:43:26 -0700 Subject: Fixed project settings Fixed project settings and removed a debugbreak that I had missed. --- .../osrfx2_DCHU_base/osrfx2_DCHU_base.vcxproj | 6 +++--- .../osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj | 6 +++--- .../osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj | 6 +++--- general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp | 4 +--- .../osrfx2_DCHU_componentsoftware.vcxproj | 14 +++++++------- .../osrfx2_DCHU_componentsoftware.vcxproj | 14 +++++++------- 6 files changed, 24 insertions(+), 26 deletions(-) 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 4cfeed87..0c4dec56 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 @@ -42,7 +42,7 @@ True Universal UMDF - v140 + WindowsUserModeDriver10.0 DynamicLibrary @@ -50,7 +50,7 @@ False Universal UMDF - v140 + WindowsUserModeDriver10.0 DynamicLibrary @@ -58,7 +58,7 @@ True Universal UMDF - v140 + WindowsUserModeDriver10.0 DynamicLibrary diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj index 5e015f80..36d85583 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_filter/osrfx2_DCHU_filter.vcxproj @@ -44,7 +44,7 @@ True Universal UMDF - v140 + WindowsUserModeDriver10.0 DynamicLibrary @@ -52,7 +52,7 @@ False Universal UMDF - v140 + WindowsUserModeDriver10.0 DynamicLibrary @@ -60,7 +60,7 @@ True Universal UMDF - v140 + WindowsUserModeDriver10.0 DynamicLibrary diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj index 9ac1e4f3..225dcde2 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_testapp/osrusbfx2.vcxproj @@ -41,7 +41,7 @@ True Universal - v140 + WindowsApplicationForDrivers10.0 Application @@ -49,7 +49,7 @@ False Universal - v140 + WindowsApplicationForDrivers10.0 Application @@ -57,7 +57,7 @@ True Universal - v140 + WindowsApplicationForDrivers10.0 Application diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp index e9d24c1b..6484f834 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp @@ -678,9 +678,7 @@ DeviceRemoveCompleteAction( PHANDLE_CONTEXT Context ) { - __debugbreak(); - - DWORD Err = ERROR_SUCCESS; + DWORD Err = ERROR_SUCCESS; EnterCriticalSection(&Context->Lock); diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj index 32ebdebe..931646bb 100644 --- a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj @@ -22,34 +22,34 @@ {26D91630-B8FF-4102-A258-32F7D1C84E20} Win32Proj osrfx2_DCHU_componentsoftware - 10.0.16245.0 + 10.0.15063.0 osrfx2_DCHU_componentsoftware
Application true - v141 + v140 Unicode Application false - v141 - true + v140 + false Unicode Application true - v141 + v140 Unicode Application false - v141 - true + v140 + false Unicode diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj index 32ebdebe..931646bb 100644 --- a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_componentsoftware/osrfx2_DCHU_componentsoftware.vcxproj @@ -22,34 +22,34 @@ {26D91630-B8FF-4102-A258-32F7D1C84E20} Win32Proj osrfx2_DCHU_componentsoftware - 10.0.16245.0 + 10.0.15063.0 osrfx2_DCHU_componentsoftware
Application true - v141 + v140 Unicode Application false - v141 - true + v140 + false Unicode Application true - v141 + v140 Unicode Application false - v141 - true + v140 + false Unicode -- cgit v1.3.1 From 5f434058994bb32f63ca2578847be9c6388dd9c2 Mon Sep 17 00:00:00 2001 From: Matthew Montera Date: Tue, 22 Aug 2017 11:47:36 -0700 Subject: debugbreak removed another debugbreak --- general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp index 0a246eb4..5a59319b 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp @@ -261,8 +261,6 @@ Return Value: VOID CSampleService::OnStop() { - __debugbreak(); - // // Log a service stop message to the Application log. // -- cgit v1.3.1 From 3965a237da143d06f0a24e042cef0970b799ea19 Mon Sep 17 00:00:00 2001 From: Mike Fenelon Date: Thu, 24 Aug 2017 10:10:48 -0700 Subject: Initial add of V3 Samples --- .../C++/CUSTOMDRV.HLP | Bin 0 -> 5955 bytes .../C++/PSUIRep/Features.cpp | 2858 ++++++++++++++++ .../C++/PSUIRep/Features.h | 236 ++ .../C++/PSUIRep/Helper.cpp | 457 +++ .../C++/PSUIRep/Helper.h | 214 ++ .../C++/PSUIRep/OEMUI.rc | 260 ++ .../C++/PSUIRep/PSUIREP.vcxproj | 1066 ++++++ .../C++/PSUIRep/PSUIREP.vcxproj.Filters | 397 +++ .../C++/PSUIRep/StringUtils.cpp | 315 ++ .../C++/PSUIRep/StringUtils.h | 23 + .../C++/PSUIRep/debug.cpp | 405 +++ .../C++/PSUIRep/debug.h | 166 + .../C++/PSUIRep/devmode.cpp | 193 ++ .../C++/PSUIRep/devmode.h | 56 + .../C++/PSUIRep/dllentry.cpp | 49 + .../C++/PSUIRep/globals.cpp | 24 + .../C++/PSUIRep/globals.h | 31 + .../C++/PSUIRep/intrface.cpp | 709 ++++ .../C++/PSUIRep/intrface.h | 220 ++ .../C++/PSUIRep/oemui.cpp | 1042 ++++++ .../C++/PSUIRep/oemui.h | 33 + .../C++/PSUIRep/precomp.h | 55 + .../C++/PSUIRep/precompsrc.cpp | 1 + .../C++/PSUIRep/psuirep.def | 3 + .../C++/PSUIRep/resource.h | 92 + .../C++/PTPCPlPr/install/ptpcplpr.gpd | 763 +++++ .../C++/PTPCPlPr/install/ptpcplpr.inf | 107 + .../C++/PTPCPlPr/install/ptpcplpr.ini | 3 + .../C++/PTPCPlPr/src/PTPCPLPR.vcxproj | 904 +++++ .../C++/PTPCPlPr/src/PTPCPLPR.vcxproj.Filters | 272 ++ .../C++/PTPCPlPr/src/debug.hxx | 82 + .../C++/PTPCPlPr/src/dllentry.cxx | 48 + .../C++/PTPCPlPr/src/globals.cxx | 21 + .../C++/PTPCPlPr/src/globals.hxx | 25 + .../C++/PTPCPlPr/src/intrface.cxx | 493 +++ .../C++/PTPCPlPr/src/intrface.hxx | 178 + .../C++/PTPCPlPr/src/oem.hxx | 26 + .../C++/PTPCPlPr/src/oemptprovider.cxx | 1145 +++++++ .../C++/PTPCPlPr/src/oemptprovider.hxx | 143 + .../C++/PTPCPlPr/src/precomp.hxx | 49 + .../C++/PTPCPlPr/src/precompsrc.cpp | 1 + .../C++/PTPCPlPr/src/printschema.cxx | 64 + .../C++/PTPCPlPr/src/printschema.hxx | 74 + .../C++/PTPCPlPr/src/ptpcplpr.def | 3 + .../C++/PTPCPlPr/src/ptpcplpr.rc | 24 + .../C++/PTPCPlPr/src/xmlhandler.cxx | 1612 +++++++++ .../C++/PTPCPlPr/src/xmlhandler.hxx | 162 + .../C++/SyncSet/SYNCSET.vcxproj | 1066 ++++++ .../C++/SyncSet/SYNCSET.vcxproj.Filters | 272 ++ .../C++/SyncSet/SyncSet.def | 3 + .../C++/SyncSet/debug.cpp | 405 +++ .../C++/SyncSet/debug.h | 166 + .../C++/SyncSet/devmode.cpp | 214 ++ .../C++/SyncSet/devmode.h | 57 + .../C++/SyncSet/dllentry.cpp | 49 + .../C++/SyncSet/globals.cpp | 26 + .../C++/SyncSet/globals.h | 22 + .../C++/SyncSet/intrface.cpp | 612 ++++ .../C++/SyncSet/intrface.h | 192 ++ .../C++/SyncSet/oem.h | 24 + .../C++/SyncSet/oemui.cpp | 1099 ++++++ .../C++/SyncSet/oemui.h | 74 + .../C++/SyncSet/oemui.rc | 175 + .../C++/SyncSet/precomp.h | 53 + .../C++/SyncSet/precompsrc.cpp | 1 + .../C++/SyncSet/resource.h | 28 + .../C++/ThemeUI/OEMUI.rc | 169 + .../C++/ThemeUI/ThemeUI.Manifest | 22 + .../C++/ThemeUI/ThemeUISmpl.vcxproj | 1120 ++++++ .../C++/ThemeUI/ThemeUISmpl.vcxproj.Filters | 327 ++ .../C++/ThemeUI/debug.h | 82 + .../C++/ThemeUI/devmode.cpp | 187 + .../C++/ThemeUI/devmode.h | 55 + .../C++/ThemeUI/dllentry.cpp | 66 + .../C++/ThemeUI/fusutils.cpp | 118 + .../C++/ThemeUI/fusutils.h | 18 + .../C++/ThemeUI/globals.cpp | 29 + .../C++/ThemeUI/globals.h | 21 + .../C++/ThemeUI/intrface.cpp | 575 ++++ .../C++/ThemeUI/intrface.h | 179 + .../C++/ThemeUI/oem.h | 22 + .../C++/ThemeUI/oemui.cpp | 756 ++++ .../C++/ThemeUI/oemui.h | 45 + .../C++/ThemeUI/precomp.h | 61 + .../C++/ThemeUI/precompsrc.cpp | 1 + .../C++/ThemeUI/resource.h | 24 + .../C++/ThemeUI/themeuismpl.def | 3 + .../C++/WMarkPS.ini | 4 + .../C++/WMarkUni.ini | 5 + .../C++/bitmap.gpd | 509 +++ .../C++/bitmap.inf | 118 + .../C++/bitmap.ini | 5 + .../C++/bitmap/bitmap.def | 4 + .../C++/bitmap/bitmap.h | 81 + .../C++/bitmap/bitmap.rc | 110 + .../C++/bitmap/bitmap.vcxproj | 1090 ++++++ .../C++/bitmap/bitmap.vcxproj.Filters | 174 + .../C++/bitmap/ddihook.cpp | 114 + .../C++/bitmap/debug.h | 82 + .../C++/bitmap/devmode.cpp | 132 + .../C++/bitmap/devmode.h | 37 + .../C++/bitmap/dllentry.cpp | 50 + .../C++/bitmap/intrface.cpp | 2048 +++++++++++ .../C++/bitmap/intrface.h | 287 ++ .../C++/bitmap/precomp.h | 40 + .../C++/bitmap/precompsrc.cpp | 1 + .../C++/bitmap/resource.h | 17 + .../C++/custhlp.gpd | 563 +++ .../C++/custhlp.ini | 3 + .../C++/custhlp/CUSTHLP.def | 3 + .../C++/custhlp/CUSTHLP.vcxproj | 1060 ++++++ .../C++/custhlp/CUSTHLP.vcxproj.Filters | 220 ++ .../C++/custhlp/customhelp/customdrv.cnt | 3 + .../C++/custhlp/customhelp/customdrv.h | 11 + .../C++/custhlp/customhelp/customdrv.hpj | 17 + .../C++/custhlp/customhelp/customdrv.rtf | 22 + .../C++/custhlp/debug.h | 82 + .../C++/custhlp/devmode.cpp | 182 + .../C++/custhlp/devmode.h | 46 + .../C++/custhlp/dllentry.cpp | 49 + .../C++/custhlp/globals.cpp | 25 + .../C++/custhlp/globals.h | 22 + .../C++/custhlp/intrface.cpp | 562 +++ .../C++/custhlp/intrface.h | 182 + .../C++/custhlp/oemui.cpp | 960 ++++++ .../C++/custhlp/oemui.h | 47 + .../C++/custhlp/oemui.rc | 170 + .../C++/custhlp/precomp.h | 54 + .../C++/custhlp/precompsrc.cpp | 1 + .../C++/custhlp/resource.h | 23 + .../C++/gdl/res/gdlsmpl.gpd | 520 +++ .../C++/gdl/res/gdlsmpl.inf | 99 + .../C++/gdl/res/gdlsmpl.ini | 3 + .../C++/gdl/src/GDLSMPL.vcxproj | 1084 ++++++ .../C++/gdl/src/GDLSMPL.vcxproj.Filters | 134 + .../C++/gdl/src/debug.h | 82 + .../C++/gdl/src/devmode.cpp | 251 ++ .../C++/gdl/src/devmode.h | 52 + .../C++/gdl/src/gdlsmpl.cpp | 856 +++++ .../C++/gdl/src/gdlsmpl.def | 18 + .../C++/gdl/src/gdlsmpl.h | 79 + .../C++/gdl/src/gdlsmpl.rc | 106 + .../C++/gdl/src/intrface.cpp | 559 +++ .../C++/gdl/src/intrface.h | 212 ++ .../C++/gdl/src/precomp.h | 62 + .../C++/gdl/src/precompsrc.cpp | 1 + .../C++/oem.gpd | 704 ++++ .../C++/oem.ppd | 431 +++ .../C++/oemdll.inf | 219 ++ .../C++/oemdll.sln | 809 +++++ .../C++/oemprean.gpd | 706 ++++ .../C++/oemprean.htm | 514 +++ .../C++/oemprean.inf | 117 + .../C++/oemprean.ini | 4 + .../C++/oemprean/ddihook.cpp | 2069 +++++++++++ .../C++/oemprean/debug.cpp | 1503 ++++++++ .../C++/oemprean/debug.h | 215 ++ .../C++/oemprean/devmode.cpp | 229 ++ .../C++/oemprean/devmode.h | 43 + .../C++/oemprean/dllentry.cpp | 58 + .../C++/oemprean/intrface.cpp | 1819 ++++++++++ .../C++/oemprean/intrface.h | 288 ++ .../C++/oemprean/oemprean.def | 3 + .../C++/oemprean/oemprean.h | 259 ++ .../C++/oemprean/oemprean.rc | 110 + .../C++/oemprean/oemprean.vcxproj | 1096 ++++++ .../C++/oemprean/oemprean.vcxproj.Filters | 177 + .../C++/oemprean/precomp.h | 49 + .../C++/oemprean/precompsrc.cpp | 1 + .../C++/oemprean/resource.h | 17 + .../C++/oemps.ini | 3 + .../C++/oemps/OEMPS.rc | 109 + .../C++/oemps/OEMPS.vcxproj | 1096 ++++++ .../C++/oemps/OEMPS.vcxproj.Filters | 220 ++ .../C++/oemps/command.cpp | 278 ++ .../C++/oemps/command.h | 24 + .../C++/oemps/ddihook.cpp | 1049 ++++++ .../C++/oemps/debug.h | 82 + .../C++/oemps/devmode.cpp | 151 + .../C++/oemps/devmode.h | 44 + .../C++/oemps/dllentry.cpp | 50 + .../C++/oemps/intrface.cpp | 632 ++++ .../C++/oemps/intrface.h | 119 + .../C++/oemps/oemps.def | 3 + .../C++/oemps/oemps.h | 76 + .../C++/oemps/precomp.h | 47 + .../C++/oemps/precompsrc.cpp | 1 + .../C++/oemps/resource.h | 15 + .../C++/oemui.ini | 3 + .../C++/oemui/OEMUI.def | 3 + .../C++/oemui/OEMUI.rc | 169 + .../C++/oemui/OEMUI.vcxproj | 1042 ++++++ .../C++/oemui/OEMUI.vcxproj.Filters | 220 ++ .../C++/oemui/debug.h | 82 + .../C++/oemui/devmode.cpp | 182 + .../C++/oemui/devmode.h | 52 + .../C++/oemui/dllentry.cpp | 49 + .../C++/oemui/globals.cpp | 22 + .../C++/oemui/globals.h | 17 + .../C++/oemui/intrface.cpp | 567 +++ .../C++/oemui/intrface.h | 178 + .../C++/oemui/oemui.cpp | 737 ++++ .../C++/oemui/oemui.h | 37 + .../C++/oemui/precomp.h | 52 + .../C++/oemui/precompsrc.cpp | 1 + .../C++/oemui/resource.h | 24 + .../C++/oemuni.ini | 3 + .../C++/oemuni/OEMUNI.def | 3 + .../C++/oemuni/OEMUNI.h | 234 ++ .../C++/oemuni/OEMUNI.rc | 110 + .../C++/oemuni/OEMUNI.vcxproj | 1090 ++++++ .../C++/oemuni/OEMUNI.vcxproj.Filters | 174 + .../C++/oemuni/ddihook.cpp | 1670 +++++++++ .../C++/oemuni/debug.h | 82 + .../C++/oemuni/devmode.cpp | 222 ++ .../C++/oemuni/devmode.h | 43 + .../C++/oemuni/dllentry.cpp | 55 + .../C++/oemuni/intrface.cpp | 1797 ++++++++++ .../C++/oemuni/intrface.h | 283 ++ .../C++/oemuni/precomp.h | 36 + .../C++/oemuni/precompsrc.cpp | 1 + .../C++/oemuni/resource.h | 17 + .../C++/psuirep.ini | 3 + .../C++/syncset.gpd | 654 ++++ .../C++/syncset.ini | 3 + .../C++/themeui.ini | 3 + .../C++/uisamples.inf | 133 + .../C++/uniuirep/res/uniuirep.gpd | 559 +++ .../C++/uniuirep/res/uniuirep.inf | 99 + .../C++/uniuirep/res/uniuirep.ini | 3 + .../C++/uniuirep/src/Features.cpp | 1991 +++++++++++ .../C++/uniuirep/src/Features.h | 388 +++ .../C++/uniuirep/src/UNIUIREP.vcxproj | 1066 ++++++ .../C++/uniuirep/src/UNIUIREP.vcxproj.Filters | 223 ++ .../C++/uniuirep/src/debug.cpp | 405 +++ .../C++/uniuirep/src/debug.h | 166 + .../C++/uniuirep/src/devmode.cpp | 255 ++ .../C++/uniuirep/src/devmode.h | 48 + .../C++/uniuirep/src/dllentry.cpp | 82 + .../C++/uniuirep/src/intrface.cpp | 1151 +++++++ .../C++/uniuirep/src/intrface.h | 222 ++ .../C++/uniuirep/src/precomp.h | 68 + .../C++/uniuirep/src/precompsrc.cpp | 1 + .../C++/uniuirep/src/resource.h | 57 + .../C++/uniuirep/src/uniuirep.cpp | 492 +++ .../C++/uniuirep/src/uniuirep.def | 18 + .../C++/uniuirep/src/uniuirep.h | 55 + .../C++/uniuirep/src/uniuirep.rc | 192 ++ .../C++/watermark/common/debug.h | 82 + .../C++/watermark/common/devmode.cpp | 229 ++ .../C++/watermark/common/devmode.h | 56 + .../C++/watermark/common/oem.h | 24 + .../C++/watermark/wmarkps/WMARKPS.vcxproj | 1090 ++++++ .../C++/watermark/wmarkps/WMARKPS.vcxproj.Filters | 137 + .../C++/watermark/wmarkps/WMarkPS.def | 3 + .../C++/watermark/wmarkps/WMarkPS.rc | 130 + .../C++/watermark/wmarkps/command.cpp | 410 +++ .../C++/watermark/wmarkps/command.h | 22 + .../C++/watermark/wmarkps/dllentry.cpp | 54 + .../C++/watermark/wmarkps/drawmark.ps | Bin 0 -> 37 bytes .../C++/watermark/wmarkps/fdevmode.cpp | 20 + .../C++/watermark/wmarkps/intrface.cpp | 491 +++ .../C++/watermark/wmarkps/intrface.h | 116 + .../C++/watermark/wmarkps/precomp.h | 51 + .../C++/watermark/wmarkps/precompsrc.cpp | 1 + .../C++/watermark/wmarkps/resource.h | 18 + .../C++/watermark/wmarkps/wmark.ps | 33 + .../C++/watermark/wmarkps/wmarkps.h | 25 + .../C++/watermark/wmarkui/WMARKUI.vcxproj | 1096 ++++++ .../C++/watermark/wmarkui/WMARKUI.vcxproj.Filters | 140 + .../C++/watermark/wmarkui/dllentry.cpp | 52 + .../C++/watermark/wmarkui/fdevmode.cpp | 21 + .../C++/watermark/wmarkui/globals.cpp | 27 + .../C++/watermark/wmarkui/globals.h | 22 + .../C++/watermark/wmarkui/intrface.cpp | 522 +++ .../C++/watermark/wmarkui/intrface.h | 177 + .../C++/watermark/wmarkui/precomp.h | 50 + .../C++/watermark/wmarkui/precompsrc.cpp | 1 + .../C++/watermark/wmarkui/resource.h | 24 + .../C++/watermark/wmarkui/wmarkui.cpp | 590 ++++ .../C++/watermark/wmarkui/wmarkui.def | 3 + .../C++/watermark/wmarkui/wmarkui.h | 35 + .../C++/watermark/wmarkui/wmarkui.rc | 128 + .../C++/watermarkuni/common/debug.h | 82 + .../C++/watermarkuni/common/devmode.cpp | 216 ++ .../C++/watermarkuni/common/devmode.h | 52 + .../C++/watermarkuni/common/oem.h | 23 + .../C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj | 1150 +++++++ .../wmarkui/WMARKUNIUI.vcxproj.Filters | 140 + .../C++/watermarkuni/wmarkui/dllentry.cpp | 52 + .../C++/watermarkuni/wmarkui/fdevmode.cpp | 21 + .../C++/watermarkuni/wmarkui/globals.cpp | 26 + .../C++/watermarkuni/wmarkui/globals.h | 21 + .../C++/watermarkuni/wmarkui/intrface.cpp | 525 +++ .../C++/watermarkuni/wmarkui/intrface.h | 178 + .../C++/watermarkuni/wmarkui/precomp.h | 54 + .../C++/watermarkuni/wmarkui/precompsrc.cpp | 1 + .../C++/watermarkuni/wmarkui/resource.h | 26 + .../C++/watermarkuni/wmarkui/wmarkui.cpp | 594 ++++ .../C++/watermarkuni/wmarkui/wmarkui.h | 37 + .../C++/watermarkuni/wmarkui/wmarkui.rc | 124 + .../C++/watermarkuni/wmarkui/wmarkuniui.def | 3 + .../C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj | 1090 ++++++ .../watermarkuni/wmarkuni/WMARKUNI.vcxproj.Filters | 137 + .../C++/watermarkuni/wmarkuni/ddihook.cpp | 1226 +++++++ .../C++/watermarkuni/wmarkuni/dllentry.cpp | 51 + .../C++/watermarkuni/wmarkuni/fdevmode.cpp | 22 + .../C++/watermarkuni/wmarkuni/intrface.cpp | 950 +++++ .../C++/watermarkuni/wmarkuni/intrface.h | 254 ++ .../C++/watermarkuni/wmarkuni/name.h | 34 + .../C++/watermarkuni/wmarkuni/precomp.h | 53 + .../C++/watermarkuni/wmarkuni/precompsrc.cpp | 1 + .../C++/watermarkuni/wmarkuni/resource.h | 17 + .../C++/watermarkuni/wmarkuni/wmarkuni.def | 3 + .../C++/watermarkuni/wmarkuni/wmarkuni.h | 82 + .../C++/watermarkuni/wmarkuni/wmarkuni.rc | 104 + .../C++/winxp.inf | 139 + .../README.md | 87 + .../description.html | 430 +++ .../19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css | 295 ++ .../description/Brand.css | 3615 ++++++++++++++++++++ .../description/Combined.css | 0 .../description/Galleries.css | 417 +++ .../description/Layout.css | 147 + ...c96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css | 0 .../description/iframedescription.css | 179 + .../description/offline.js | 52 + .../license.rtf | 25 + 328 files changed, 88503 insertions(+) create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/CUSTOMDRV.HLP create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/OEMUI.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/psuirep.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/debug.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/dllentry.cxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.cxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.cxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oem.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.cxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precomp.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.cxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.cxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.hxx create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SyncSet.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oem.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/SyncSet/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/OEMUI.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUI.Manifest create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oem.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/themeuismpl.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/WMarkPS.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/WMarkUni.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/ddihook.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/bitmap/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.cnt create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.hpj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.rtf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/custhlp/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oem.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oem.ppd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemdll.sln create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean.htm create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/ddihook.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemprean/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/command.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/command.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/ddihook.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemps/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemui/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/ddihook.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/oemuni/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/psuirep.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/syncset.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/syncset.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/themeui.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.gpd create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.ini create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/common/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/common/oem.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/drawmark.ps create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/fdevmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmark.ps create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmarkps.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/fdevmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/debug.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/oem.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/fdevmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkuniui.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj.Filters create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/ddihook.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/dllentry.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/fdevmode.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/name.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precomp.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precompsrc.cpp create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/resource.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.def create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.h create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.rc create mode 100644 print/OEM Printer Customization Plug-in Samples/C++/winxp.inf create mode 100644 print/OEM Printer Customization Plug-in Samples/README.md create mode 100644 print/OEM Printer Customization Plug-in Samples/description.html create mode 100644 print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css create mode 100644 print/OEM Printer Customization Plug-in Samples/description/Brand.css create mode 100644 print/OEM Printer Customization Plug-in Samples/description/Combined.css create mode 100644 print/OEM Printer Customization Plug-in Samples/description/Galleries.css create mode 100644 print/OEM Printer Customization Plug-in Samples/description/Layout.css create mode 100644 print/OEM Printer Customization Plug-in Samples/description/dc96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css create mode 100644 print/OEM Printer Customization Plug-in Samples/description/iframedescription.css create mode 100644 print/OEM Printer Customization Plug-in Samples/description/offline.js create mode 100644 print/OEM Printer Customization Plug-in Samples/license.rtf diff --git a/print/OEM Printer Customization Plug-in Samples/C++/CUSTOMDRV.HLP b/print/OEM Printer Customization Plug-in Samples/C++/CUSTOMDRV.HLP new file mode 100644 index 00000000..8ba599b2 Binary files /dev/null and b/print/OEM Printer Customization Plug-in Samples/C++/CUSTOMDRV.HLP differ diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.cpp new file mode 100644 index 00000000..acee806b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.cpp @@ -0,0 +1,2858 @@ +// 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. +// +// Copyright 2001 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Features.cpp +// +// PURPOSE: Implementation wrapper class for PScript Driver Features and Options. +// + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "globals.h" +#include "devmode.h" +#include "stringutils.h" +#include "helper.h" +#include "features.h" +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// Internal Defines and Macros +//////////////////////////////////////////////////////// + +#define INITIAL_ENUM_FEATURES_SIZE 1024 +#define INITIAL_ENUM_OPTIONS_SIZE 64 +#define INITIAL_FEATURE_DISPLAY_NAME_SIZE 64 +#define INITIAL_OPTION_DISPLAY_NAME_SIZE 32 +#define INITIAL_GET_OPTION_SIZE 64 +#define INITIAL_GET_REASON_SIZE 1024 + +#define DRIVER_FEATURE_PREFIX '%' +#define IS_DRIVER_FEATURE(f) (DRIVER_FEATURE_PREFIX == (f)[0]) + +// Flags that the uDisplayNameID should be returned as +// MAKEINTRESOURCE() instead of loading the string resource. +#define RETURN_INT_RESOURCE 1 + +// Macros to test for conditions of KEYWORDMAP entry. +#define IS_MAPPING_INT_RESOURCE(p) ((p)->dwFlags & RETURN_INT_RESOURCE) + +// TAG the identifies feature OPTITEM data stuct. +#define FEATURE_OPTITEM_TAG 'FETR' + + +//////////////////////////////////////////////////////// +// Type Definitions +//////////////////////////////////////////////////////// + +// Struct used to identify OPTITEM as +// feature OPTITEM and to map back from +// an OPTITEM to the feature. +typedef struct _tagFeatureOptitemData +{ + DWORD dwSize; + DWORD dwTag; + PCSTR pszFeatureKeyword; + COptions *pOptions; + +} FEATUREOPTITEMDATA, *PFEATUREOPTITEMDATA; + + + +//////////////////////////////////////////////////////// +// Internal Constants +//////////////////////////////////////////////////////// + +static KEYWORDMAP gkmFeatureMap[] = +{ + "%AddEuro", NULL, IDS_ADD_EURO, OEMCUIP_PRNPROP, 0, + "%CtrlDAfter", NULL, IDS_CTRLD_AFTER, OEMCUIP_PRNPROP, 0, + "%CtrlDBefore", NULL, IDS_CTRLD_BEFORE, OEMCUIP_PRNPROP, 0, + //"%CustomPageSize", NULL, IDS_PSCRIPT_CUSTOMSIZE, OEMCUIP_DOCPROP, 0, + "%GraphicsTrueGray", NULL, IDS_TRUE_GRAY_GRAPH, OEMCUIP_PRNPROP, 0, + "%JobTimeout", NULL, IDS_JOBTIMEOUT, OEMCUIP_PRNPROP, 0, + "%MaxFontSizeAsBitmap", NULL, IDS_PSMAXBITMAP, OEMCUIP_PRNPROP, 0, + "%MetafileSpooling", NULL, IDS_METAFILE_SPOOLING, OEMCUIP_DOCPROP, 0, + "%MinFontSizeAsOutline", NULL, IDS_PSMINOUTLINE, OEMCUIP_PRNPROP, 0, + "%Mirroring", NULL, IDS_MIRROR, OEMCUIP_DOCPROP, 0, + "%Negative", NULL, IDS_NEGATIVE_PRINT, OEMCUIP_DOCPROP, 0, + "%Orientation", TEXT("COMPSTUI.DLL"), IDS_CPSUI_ORIENTATION, OEMCUIP_DOCPROP, RETURN_INT_RESOURCE, + "%OutputFormat", NULL, IDS_PSOUTPUT_OPTION, OEMCUIP_DOCPROP, 0, + "%OutputProtocol", NULL, IDS_PSPROTOCOL, OEMCUIP_PRNPROP, 0, + "%OutputPSLevel", NULL, IDS_PSLEVEL, OEMCUIP_DOCPROP, 0, + "%PageOrder", TEXT("COMPSTUI.DLL"), IDS_CPSUI_PAGEORDER, OEMCUIP_DOCPROP, RETURN_INT_RESOURCE, + "%PagePerSheet", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP, OEMCUIP_DOCPROP, RETURN_INT_RESOURCE, + "%PSErrorHandler", NULL, IDS_PSERROR_HANDLER, OEMCUIP_DOCPROP, 0, + "%PSMemory", NULL, IDS_POSTSCRIPT_VM, OEMCUIP_PRNPROP, 0, + "%TextTrueGray", NULL, IDS_TRUE_GRAY_TEXT, OEMCUIP_PRNPROP, 0, + "%TTDownloadFormat", NULL, IDS_PSTT_DLFORMAT, OEMCUIP_DOCPROP, 0, + "%WaitTimeout", NULL, IDS_WAITTIMEOUT, OEMCUIP_PRNPROP, 0, +}; +static const NUM_FEATURE_MAP = (sizeof(gkmFeatureMap)/sizeof(gkmFeatureMap[0])); + + +static KEYWORDMAP gkmOptionMap[] = +{ + "True", TEXT("COMPSTUI.DLL"), IDS_CPSUI_TRUE, 0, RETURN_INT_RESOURCE, + "False", TEXT("COMPSTUI.DLL"), IDS_CPSUI_FALSE, 0, RETURN_INT_RESOURCE, + "Portrait", TEXT("COMPSTUI.DLL"), IDS_CPSUI_PORTRAIT, 0, RETURN_INT_RESOURCE, + "Landscape", TEXT("COMPSTUI.DLL"), IDS_CPSUI_LANDSCAPE, 0, RETURN_INT_RESOURCE, + "RotatedLandscape", TEXT("COMPSTUI.DLL"), IDS_CPSUI_ROT_LAND, 0, RETURN_INT_RESOURCE, + "Speed", NULL, IDS_PSOPT_SPEED, 0, RETURN_INT_RESOURCE, + "Portability", NULL, IDS_PSOPT_PORTABILITY, 0, 0, + "EPS", NULL, IDS_PSOPT_EPS, 0, 0, + "Archive", NULL, IDS_PSOPT_ARCHIVE, 0, 0, + "ASCII", NULL, IDS_PSPROTOCOL_ASCII, 0, 0, + "BCP", NULL, IDS_PSPROTOCOL_BCP, 0, 0, + "TBCP", NULL, IDS_PSPROTOCOL_TBCP, 0, 0, + "Binary", NULL, IDS_PSPROTOCOL_BINARY, 0, 0, + "FrontToBack", TEXT("COMPSTUI.DLL"), IDS_CPSUI_FRONTTOBACK, 0, RETURN_INT_RESOURCE, + "BackToFront", TEXT("COMPSTUI.DLL"), IDS_CPSUI_BACKTOFRONT, 0, RETURN_INT_RESOURCE, + "1", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_NORMAL, 0, RETURN_INT_RESOURCE, + "2", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_TWOUP, 0, RETURN_INT_RESOURCE, + "4", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_FOURUP, 0, RETURN_INT_RESOURCE, + "6", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_SIXUP, 0, RETURN_INT_RESOURCE, + "9", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_NINEUP, 0, RETURN_INT_RESOURCE, + "16", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_SIXTEENUP, 0, RETURN_INT_RESOURCE, + "Booklet", TEXT("COMPSTUI.DLL"), IDS_CPSUI_BOOKLET, 0, RETURN_INT_RESOURCE, + "Automatic", NULL, IDS_TTDL_DEFAULT, 0, 0, + "Outline", NULL, IDS_TTDL_TYPE1, 0, 0, + "Bitmap", NULL, IDS_TTDL_TYPE3, 0, 0, + "NativeTrueType", NULL, IDS_TTDL_TYPE42, 0, 0, +}; +static const NUM_OPTION_MAP = (sizeof(gkmOptionMap)/sizeof(gkmOptionMap[0])); + + + + +//////////////////////////////////////////// +// +// COptions Methods +// + +// +// Private Methods +// + +// Initializes class data members. +void COptions::Init() +{ + m_wOptions = 0; + m_cType = TVOT_COMBOBOX; + m_pmszRaw = NULL; + m_pszFeature = NULL; + m_ppszOptions = NULL; + m_ptRange.x = 0; + m_ptRange.y = 0; + m_dwSize = 0; + m_pszUnits = NULL; + m_hHeap = NULL; + m_pInfo = NULL; +} + +void COptions::Clear() +{ + // Free memory associated with data members. + if(NULL != m_pmszRaw) HeapFree(m_hHeap, 0, m_pmszRaw); + if(NULL != m_ppszOptions) HeapFree(m_hHeap, 0, m_ppszOptions); + if( (NULL != m_pszUnits) && !IS_INTRESOURCE(m_pszUnits)) HeapFree(m_hHeap, 0, m_pszUnits); + + // Free option info. + FreeOptionInfo(); + + // Initialize data members. + Init(); +} + +// Frees memory associated with Option Info array. +void COptions::FreeOptionInfo() +{ + // Validate parameters. + if( (NULL == m_hHeap) + || + (NULL == m_pInfo) + ) + { + return; + } + + // Free strings in the array. + for(WORD wIndex = 0; wIndex < m_wOptions; ++wIndex) + { + PWSTR pszDisplay = m_pInfo[wIndex].pszDisplayName; + + if( (NULL != pszDisplay) + && + !(IS_INTRESOURCE(pszDisplay)) + ) + { + HeapFree(m_hHeap, 0, pszDisplay); + } + } + + // Free the array. + HeapFree(m_hHeap, 0, m_pInfo); + m_pInfo = NULL; +} + +// Will do init for features that need special handling. +HRESULT COptions::GetOptionsForSpecialFeatures(CUIHelper &Helper, POEMUIOBJ poemuiobj) +{ + HRESULT hrResult = E_NOTIMPL; + + + // See if this is a special feature. + // If it is, then call the special option init for the + // feature. + if(!lstrcmpA(m_pszFeature, "%CustomPageSize")) + { + // There is no option init for CustomPageSize. + // The item itself must be handled specially. + hrResult = S_OK; + } + else if( !lstrcmpA(m_pszFeature, "%JobTimeout") + || + !lstrcmpA(m_pszFeature, "%WaitTimeout") + ) + { + // JobTimeout and WaitTimeout feature options are string representations + // of an integer that represents number of seconds in the range 0 through + // 2,147,483,647 (i.e. LONG_MAX). However, COMPSTUI limits us to + // WORD size, which has range of 0 to 32,767 (i.e. SHRT_MAX). + m_cType = TVOT_UDARROW; + m_ptRange.x = 0; + m_ptRange.y = SHRT_MAX; + hrResult = GetOptionSelectionShort(Helper, poemuiobj); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForSpecialFeatures() failed to get current selection for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + } + else if( !lstrcmpA(m_pszFeature, "%MaxFontSizeAsBitmap") + || + !lstrcmpA(m_pszFeature, "%MinFontSizeAsOutline") + ) + { + // MaxFontSizeAsBitmap, and MinFontSizeAsOutline feature options + // are string representations of an integer that represents number + // of pixels in the range 0 through 32,767 (i.e. SHRT_MAX). + m_cType = TVOT_UDARROW; + m_ptRange.x = 0; + m_ptRange.y = SHRT_MAX; + hrResult = GetOptionSelectionShort(Helper, poemuiobj); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForSpecialFeatures() failed to get current selection for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + } + else if( !lstrcmpA(m_pszFeature, "%PSMemory") ) + { + DWORD dwType; + DWORD dwLevel; + DWORD dwNeeded; + + + // PSMemory option is string representation of an integer + // that represents number of seconds in the range 0 + // through 32,767 (i.e. SHRT_MAX). + // However, the minimum is 172 KB for Level 1 and 249 KB for level 2 + m_cType = TVOT_UDARROW; + m_ptRange.y = SHRT_MAX; + hrResult = GetOptionSelectionShort(Helper, poemuiobj); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForSpecialFeatures() failed to get current selection for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + + // Get the global attribute for max language level. + hrResult = Helper.GetGlobalAttribute(poemuiobj, + 0, + "LanguageLevel", + &dwType, + (PBYTE) &dwLevel, + sizeof(dwLevel), + &dwNeeded); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForSpecialFeatures() failed to get global attribute \"LanguageLevel\". (hrResult = 0x%x)\r\n"), + hrResult); + + goto Exit; + } + + // Set minimum range based on PS Max Language level. + switch(dwLevel) + { + case 1: + m_ptRange.x = 172; + break; + + default: + case 2: + case 3: + m_ptRange.x = 249; + break; + } + + // Get Units string. + //GetStringResource(m_pszUnits + } + else if(!lstrcmpA(m_pszFeature, "%OutputPSLevel")) + { + hrResult = GetOptionsForOutputPSLevel(Helper, poemuiobj); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForSpecialFeatures() failed to get current selection for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + } + + +Exit: + + return hrResult; +} + +// Do init for PS Level options. +HRESULT COptions::GetOptionsForOutputPSLevel(CUIHelper &Helper, POEMUIOBJ poemuiobj) +{ + WORD wCount = 0; + DWORD dwLevel = 0; + DWORD dwType = 0; + DWORD dwNeeded = 0; + HRESULT hrResult = E_NOTIMPL; + + + // PS Level is integers from 1 to "LanguageLevel" + // global atribute. + m_cType = TVOT_COMBOBOX; + + // Get the global attribute for max language level. + hrResult = Helper.GetGlobalAttribute(poemuiobj, + 0, + "LanguageLevel", + &dwType, + (PBYTE) &dwLevel, + sizeof(dwLevel), + &dwNeeded); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForOutputPSLevel() failed to get global attribute \"LanguageLevel\". (hrResult = 0x%x)\r\n"), + hrResult); + + goto Exit; + } + + // + // Create Options for PS Level + // + + // Set the number of options to the PS Level supported. + m_wOptions = (WORD) dwLevel; + + // Allocate keyword list. + // Allocate memory for pointer to keyword and the keyword itself, so that + // the memory for the keyword strings will get de-allocated with the keyword list + // on object destruction, just like regular features for which EnumOptions works. + // User the size of a pointer (4 bytes on x86, and 8 on IA64) so that + // it begining of the keyword strings will be DWORD or QUADWORD aligned + // for x86 and IA64 respectively. Keyword strings aren't required to + // be DWORD or QUADWORD aligned, but it is more optimal. Also, this gives + // some additional space for the case of %OutputPSLevel keywords, which are + // in the range of 1 through the max PostScript level supported, and only + // require 2 CHARs (1 for the digit and one for the NULL terminator). + m_ppszOptions = (PCSTR *) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, m_wOptions * ( sizeof(PSTR) + sizeof(PCSTR *) ) ); + if(NULL == m_ppszOptions) + { + ERR(ERRORTEXT("COptions::GetOptionsForOutputPSLevel() failed to allocate option keyword array for PS Level.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + + // Allocate option info array. + m_pInfo = (POPTION_INFO) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, m_wOptions * sizeof(OPTION_INFO)); + if(NULL == m_pInfo) + { + ERR(ERRORTEXT("COptions::GetOptionsForOutputPSLevel() failed to allocate info array for PS Level.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Init the option info. + for(wCount = 0; wCount < m_wOptions; ++wCount) + { + // Init keyword. + // The memory for both the keyword list and the keyword strings was allocated above. + m_ppszOptions[wCount] = (PSTR)(m_ppszOptions + m_wOptions) + (sizeof(PSTR) * wCount); + hrResult = StringCbPrintfA(const_cast(m_ppszOptions[wCount]), sizeof(PSTR), "%d", wCount + 1); + if(FAILED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForOutputPSLevel() failed to string representation of item %d.\r\n"), + wCount + 1); + + goto Exit; + } + + // Init option display name. + m_pInfo[wCount].pszDisplayName = (PWSTR) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, 2 * sizeof(WCHAR)); + if(NULL == m_pInfo[wCount].pszDisplayName) + { + ERR(ERRORTEXT("COptions::GetOptionsForOutputPSLevel() failed to allocate display string for Level %d.\r\n"), + wCount); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Init option display name. + hrResult = StringCchPrintfW(m_pInfo[wCount].pszDisplayName, 2, TEXT("%d"), wCount + 1); + if(FAILED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionsForOutputPSLevel() failed to create display name for item %d.\r\n"), + wCount + 1); + + goto Exit; + } + } + + // + // Get Current Selection + // + + hrResult = GetOptionSelectionIndex(Helper, poemuiobj); + + +Exit: + + // Don't need to clean up memory allocation on error, since + // all memory allocated are assigned to data members, which + // will be cleaned up in the object destructor. + + return hrResult; +} + +HRESULT COptions::GetOptionSelectionString(CUIHelper &Helper, POEMUIOBJ poemuiobj, _Outptr_result_maybenull_ PSTR *ppszSel) +{ + PSTR pmszFeature = NULL; + PSTR pmszBuf = NULL; + WORD wCount = 0; + PCSTR *ppszList = NULL; + DWORD dwFeatureSize = 0; + DWORD dwNeeded = 0; + DWORD dwSize = INITIAL_GET_OPTION_SIZE; + HRESULT hrResult = S_OK; + + *ppszSel = NULL; + + + // + // Make single feature multi-sz. + // + + // Allocate single feature multi-sz buffer that's the size of the Feature name, plus two bytes for multi-sz termination + if (FAILED(hrResult = SizeTToDWord(strlen(m_pszFeature) + 2, &dwFeatureSize))) + { + goto Exit; + } + + pmszFeature = (PSTR) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, dwFeatureSize); + if(NULL == pmszFeature) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionString() failed to allocate buffer for single feature multi-sz for feature %hs.\r\n"), + m_pszFeature); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Just need to do a regular string copy, since the buffer is already zero filled. + hrResult = StringCbCopyA(pmszFeature, dwFeatureSize, m_pszFeature); + if(FAILED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionString() failed to copy feature string %hs.\r\n"), m_pszFeature); + } + + // Allocated initial buffer of reasonible size. + pmszBuf = (PSTR) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, dwSize); + if(NULL == pmszBuf) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionString() failed to allocate buffer to get current setting for feature %hs.\r\n"), + m_pszFeature); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Get current option selection. + hrResult = Helper.GetOptions(poemuiobj, + 0, + pmszFeature, + dwFeatureSize, + pmszBuf, + dwSize, + &dwNeeded); + if( (E_OUTOFMEMORY == hrResult) && (dwSize < dwNeeded) ) + { + PSTR pTemp = NULL; + + + // INVARIANT: initial buffer not large enough. + + // Re-alloc buffer and try again. + pTemp = (PSTR) HeapReAlloc(m_hHeap, HEAP_ZERO_MEMORY, pmszBuf, dwNeeded); + if(NULL == pTemp) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionString() failed to re-allocate buffer to get current setting for feature %hs.\r\n"), + m_pszFeature); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + pmszBuf = pTemp; + + + // Try to get current option selection again. + hrResult = Helper.GetOptions(poemuiobj, + 0, + pmszFeature, + dwFeatureSize, + pmszBuf, + dwNeeded, + &dwNeeded); + } + + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionString() failed to get current setting for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + + // NOTE: The return string from GetOptions() may return + // contain no strings and not return a HRESULT error + // when the feature isn't supported in the current document or + // printer sticky mode. + if('\0' == pmszBuf[0]) + { + // Feature not supported for this sticky mode. + goto Exit; + } + + // Parse the results buffer to see what the current setting is. + hrResult = MakeStrPtrList(m_hHeap, pmszBuf, &ppszList, &wCount); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionString() failed to make string list for GetOptions() return for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + + // Check that we got 2 strings back. + if(2 != wCount) + { + WARNING(DLLTEXT("COptions::GetOptionSelectionString() the GetOption() return string list for \r\n\tfeature %hs is not of size 2.\r\n\tNumber of string is %d\r\n"), + m_pszFeature, + wCount); + + // Bail if we don't have at least 2 strings. + if(2 > wCount) + { + goto Exit; + } + } + + // Return copy of just the GetOption() result. + *ppszSel = MakeStringCopy(m_hHeap, ppszList[1]); + if(NULL == *ppszSel) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionString() failed to duplicate string GetOptions() return for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + +Exit: + + // Free local buffers. + if(NULL != pmszFeature) HeapFree(m_hHeap, 0, pmszFeature); + if(NULL != pmszBuf) HeapFree(m_hHeap, 0, pmszBuf); + if(NULL != ppszList) HeapFree(m_hHeap, 0, ppszList); + + return hrResult; +} + +// Gets current Options selection for LONG value. +HRESULT COptions::GetOptionSelectionLong(CUIHelper &Helper, POEMUIOBJ poemuiobj) +{ + PSTR pszSel = NULL; + HRESULT hrResult = S_OK; + + + // Get option selection string. + hrResult = GetOptionSelectionString(Helper, poemuiobj, &pszSel); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionLong() failed to get string for GetOptions() return for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + + // Convert string option to LONG and uses that as the selection. + if(NULL != pszSel) m_Sel = atol(pszSel); + + +Exit: + + // Free local buffers. + if(NULL != pszSel) HeapFree(m_hHeap, 0, pszSel); + + return hrResult; +} + +// Gets current Options selection for SHORT value. +HRESULT COptions::GetOptionSelectionShort(CUIHelper &Helper, POEMUIOBJ poemuiobj) +{ + PSTR pszSel = NULL; + HRESULT hrResult = S_OK; + + + // Get option selection string. + hrResult = GetOptionSelectionString(Helper, poemuiobj, &pszSel); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionLong() failed to get string for GetOptions() return for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + + // Convert string option to LONG and uses that as the selection. + if(NULL != pszSel) m_Sel = atoi(pszSel) & 0x00ffff; + + +Exit: + + // Free local buffers. + if(NULL != pszSel) HeapFree(m_hHeap, 0, pszSel); + + return hrResult; +} + +// Gets current option selection for feature. +HRESULT COptions::GetOptionSelectionIndex(CUIHelper &Helper, POEMUIOBJ poemuiobj) +{ + PSTR pszSel = NULL; + HRESULT hrResult = S_OK; + + + // Get option selection string. + hrResult = GetOptionSelectionString(Helper, poemuiobj, &pszSel); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::GetOptionSelectionIndex() failed to get string for GetOptions() return for feature %hs. (hrResult = 0x%x)\r\n"), + m_pszFeature, + hrResult); + + goto Exit; + } + + // Find the matching option for the string returned from GetOption. + m_Sel = FindOption(pszSel, m_wOptions - 1); + + +Exit: + + // Free local buffers. + if(NULL != pszSel) HeapFree(m_hHeap, 0, pszSel); + + return hrResult; +} + + + +// +// Public Methods +// + +// Default constructor +COptions::COptions() +{ + Init(); +} + +// Destructor +COptions::~COptions() +{ + Clear(); +} + +// Get the option list for a feature +HRESULT COptions::Acquire(_In_ HANDLE hHeap, + CUIHelper &Helper, + _In_ POEMUIOBJ poemuiobj, + _In_ PCSTR pszFeature) +{ + DWORD dwNeeded = 0; + HRESULT hrResult = S_OK; + + + VERBOSE(DLLTEXT("COptions::Acquire(0x%p, Helper, 0x%p, %hs) entered.\r\n"), + hHeap, + poemuiobj, + pszFeature ? pszFeature : "NULL"); + + // Don't retreive the Options again if we already got them. + if( (0 < m_wOptions) + && + (NULL != m_pszFeature) + && + !lstrcmpA(m_pszFeature, pszFeature) + ) + { + VERBOSE(DLLTEXT("COptions::Acquire() already have options for feature %hs.\r\n"), m_pszFeature); + VERBOSE(DLLTEXT("COptions::Acquire() returning with HRESULT of S_OK\r\n")); + + return S_OK; + } + + // Save the heap handle for use later, such as freeing memory at destruction. + m_hHeap = hHeap; + + // Store Keyword string. + m_pszFeature = pszFeature; + + + // + // Enumerate Options. + // + + + // Some features require special handling for initializing their options. + // EnumOpionts isn't implemented for these features. + // Return of E_NOTIMPL indicates it isn't the feature doesn't + // need special handling. + hrResult = GetOptionsForSpecialFeatures(Helper, poemuiobj); + if( SUCCEEDED(hrResult) + || + (!SUCCEEDED(hrResult) && (E_NOTIMPL != hrResult) ) + ) + { + // We either dealt with the special feature or incounter an error + // trying to deal with the special feature. + + goto Exit; + } + + // To try to cut down on having to call EnumOptions more than once, + // pre-allocate a buffer of reasonable size. + m_dwSize = INITIAL_ENUM_OPTIONS_SIZE; + m_pmszRaw = (PSTR) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, m_dwSize); + if(NULL == m_pmszRaw) + { + ERR(ERRORTEXT("COptions::Acquire() alloc for options for feature %hs failed.\r\n"), m_pszFeature); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + + // Try to get options list with initial buffer. + hrResult = Helper.EnumOptions(poemuiobj, 0, m_pszFeature, m_pmszRaw, m_dwSize, &dwNeeded); + if( (E_OUTOFMEMORY == hrResult) && (m_dwSize < dwNeeded)) + { + PSTR pTemp; + + + // INVARIANT: options list multi-sz wasn't large enough. + + // Re-allocate the buffer and try again. + pTemp = (PSTR) HeapReAlloc(m_hHeap, HEAP_ZERO_MEMORY, m_pmszRaw, dwNeeded); + if(NULL == pTemp) + { + ERR(ERRORTEXT("COptions::Acquire() re-alloc for options list for feature %hs failed.\r\n"), m_pszFeature); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + m_pmszRaw = pTemp; + m_dwSize = dwNeeded; + + // Try again to get the options list. + hrResult = Helper.EnumOptions(poemuiobj, 0, m_pszFeature, m_pmszRaw, m_dwSize, &dwNeeded); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::Acquire() failed to EnumOptions() for feature %hs after re-allocating buffer.\r\n"), m_pszFeature); + + goto Exit; + } + } + + // Make sure we got the option list. + // Can't do anything more with out it. + if(!SUCCEEDED(hrResult)) + { + if(E_NOTIMPL != hrResult) ERR(ERRORTEXT("COptions::Acquire() failed to enumerate options for feature %hs. (hrResult = 0x%x)\r\n"), m_pszFeature, hrResult); + + goto Exit; + } + + // INVARIANT: successfully got option keyword list. + + // Create array of string pointers to the Option names + // in the multi-sz we got from EnumOptions(). + hrResult = MakeStrPtrList(m_hHeap, m_pmszRaw, &m_ppszOptions, &m_wOptions); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::Acquire() failed to create pointer list to options. (hrResult = 0x%x)\r\n"), hrResult); + + goto Exit; + } + + // + // Build Option Information + // + + // Allocate array to hold feature info + m_pInfo = (POPTION_INFO) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, m_wOptions * sizeof(OPTION_INFO)); + if(NULL == m_pInfo) + { + ERR(ERRORTEXT("COptions::Acquire() failed to alloc feature info array.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // For each option, build or get useful information, such as display name. + for(WORD wIndex = 0; wIndex < m_wOptions; ++wIndex) + { + POPTION_INFO pCurrent = m_pInfo + wIndex; + + + // Get or build a keyword mapping entry + // that maps from keyword to usefully where to get info, such as + // display name, icon, option type, for keywords that may not be + // able to get info for from Helper. + pCurrent->pMapping = FindKeywordMapping(gkmOptionMap, NUM_OPTION_MAP, m_ppszOptions[wIndex]); + + // Get display names for each of the Options. + // The function implements a heuristic for detemining the display name, + // since can't get the display name from the UI Helper for all Options. + hrResult = DetermineOptionDisplayName(m_hHeap, + Helper, + poemuiobj, + m_pszFeature, + m_ppszOptions[wIndex], + pCurrent->pMapping, + &pCurrent->pszDisplayName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("COptions::Acquire() failed to get display name for %hs of feature %hs. (hrResult = 0x%x)\r\n"), + m_ppszOptions[wIndex], + m_pszFeature, + hrResult); + + goto Exit; + } + } + + // + // Get current option selection. + // + + hrResult = GetOptionSelectionIndex(Helper, poemuiobj); + + +Exit: + + // Clean up if weren't successful. + if(!SUCCEEDED(hrResult)) + { + Clear(); + } + + VERBOSE(DLLTEXT("COptions::Acquire() returning with HRESULT of 0x%x\r\n"), hrResult); + + return hrResult; +} + +// Return nth options keyword. +PCSTR COptions::GetKeyword(WORD wIndex) const +{ + // Validate parameters. + if( (wIndex >= m_wOptions) + || + (NULL == m_ppszOptions) + ) + { + return NULL; + } + + return m_ppszOptions[wIndex]; +} + +// Return nth options display name. +PCWSTR COptions::GetName(WORD wIndex) const +{ + // Validate parameters. + if( (wIndex >= m_wOptions) + || + (NULL == m_pInfo) + ) + { + ERR(ERRORTEXT("COptions::GetName() invalid parameters.\r\n")); + + return NULL; + } + + if(NULL == m_pInfo[wIndex].pszDisplayName) ERR(ERRORTEXT("COptions::GetName() returning NULL option display name.\r\n")); + + return m_pInfo[wIndex].pszDisplayName; +} + +// Find option with matching keyword string. +WORD COptions::FindOption(_In_opt_ PCSTR pszOption, WORD wDefault) const +{ + BOOL bFound = FALSE; + WORD wMatch = wDefault; + + + // Validate parameters. + if( (NULL == pszOption) + || + (NULL == m_ppszOptions) + ) + { + return wDefault; + } + + // Walk the option keyword looking for a match. + for(WORD wIndex = 0; !bFound && (wIndex < m_wOptions); ++wIndex) + { + bFound = !lstrcmpA(pszOption, m_ppszOptions[wIndex]); + if(bFound) + { + wMatch = wIndex; + } + } + + return wMatch; +} + +// Initializes OptItem with options for a feature. +HRESULT COptions::InitOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem) +{ + WORD wParams = 0; + WORD wOptions = 0; + HRESULT hrResult = S_OK; + + + // Set option selection. + pOptItem->pSel = m_pSel; + + // Get count of number of options. + // NOTE: Some feature options have no counts. + wOptions = GetCount(); + + // Different OPTTYPE types require different number of OPTPARAMs. + switch(m_cType) + { + // For up down arrow control, the OPTPARAMs need is 2. + case TVOT_UDARROW: + wParams = 2; + break; + + // For combobox, the OPTPARAMs needed is on per options. + case TVOT_COMBOBOX: + wParams = wOptions; + break; + + // The default is the option count. + default: + WARNING(DLLTEXT("COptions::InitOptItem() OPTTYPE type %d num of OPTPARAMs not handled. Default to option count of %d.\r\n"), + m_cType, + wOptions); + wParams = wOptions; + break; + } + + // Only do OPTTYPEs if we have non-Zero number of OPTPARAMs. + // Every OPTTYPE has at leas one OPTPARAM. + if(0 < wParams) + { + // Allocate memory for feature options. + pOptItem->pOptType = CreateOptType(hHeap, wParams); + if(NULL == pOptItem->pOptType) + { + ERR(ERRORTEXT("COptions::InitOptItem() failed to allocate OPTTYPEs for OPTITEM %hs.\r\n"), + m_pszFeature); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Set OPTTYPE. + pOptItem->pOptType->Type = m_cType; + + // Different OPTTYPE types require different initialization. + switch(m_cType) + { + // For up down arrow control, OPTPARAM[0] is used by the contrl. + // pOptParam[0]->pData is the Units description string. + // pOptParam[1].IconID is the min limit. + // pOptParam[1].lParam is the max limit. + case TVOT_UDARROW: + assert(2 == wParams); + pOptItem->pOptType->pOptParam[0].pData = m_pszUnits; + pOptItem->pOptType->pOptParam[1].IconID = m_ptRange.x; + pOptItem->pOptType->pOptParam[1].lParam = m_ptRange.y; + break; + + // For combobox, the pOptParam[n].pData is the display name of the option. + case TVOT_COMBOBOX: + for(WORD wIndex = 0; wIndex < wParams; ++wIndex) + { + pOptItem->pOptType->pOptParam[wIndex].pData = const_cast(GetName(wIndex)); + } + break; + + default: + ERR(ERRORTEXT("COptions::InitOptItem() OPTTYPE type %d OPTTYPE init not handled.\r\n"), + m_cType); + break; + } + } + + +Exit: + + return hrResult; +} + +// Refresh option selection. +HRESULT COptions::RefreshSelection(CUIHelper &Helper, POEMUIOBJ poemuiobj) +{ + HRESULT hrResult = S_OK; + + + // Method for getting option selection is based + // on OPTTYPE type. + switch(m_cType) + { + + case TVOT_UDARROW: + hrResult = GetOptionSelectionShort(Helper, poemuiobj); + break; + + case TVOT_COMBOBOX: + hrResult = GetOptionSelectionIndex(Helper, poemuiobj); + break; + + default: + ERR(ERRORTEXT("COptions::RefreshSelection() not handled for type %d OPTTYPE.\r\n"), + m_cType); + break; + } + + return hrResult; +} + + + +//////////////////////////////////////////// +// +// CFeatures Methods +// + +// +// Private Methods +// + +// Initializes class +void CFeatures::Init() +{ + // Initialize data members. + m_wFeatures = 0; + m_wDocFeatures = 0; + m_wPrintFeatures = 0; + m_pmszRaw = NULL; + m_ppszKeywords = NULL; + m_dwSize = 0; + m_hHeap = NULL; + m_pInfo = NULL; +} + +// Cleans up class and re-initialize it. +void CFeatures::Clear() +{ + // Free memory associated with data members. + if(NULL != m_pmszRaw) HeapFree(m_hHeap, 0, m_pmszRaw); + if(NULL != m_ppszKeywords) HeapFree(m_hHeap, 0, m_ppszKeywords); + + // Free feature info + FreeFeatureInfo(); + + // Re-initialize + Init(); +} + +// Free feature info +void CFeatures::FreeFeatureInfo() +{ + // Validate parameters. + if( (NULL == m_hHeap) + || + (NULL == m_pInfo) + ) + { + return; + } + + // Free memory associated with feature info. + for(WORD wIndex = 0; wIndex < m_wFeatures; ++wIndex) + { + PWSTR pszDisplay = m_pInfo[wIndex].pszDisplayName; + + + // Free display name. + if( (NULL != pszDisplay) + && + !IS_INTRESOURCE(pszDisplay) + ) + { + HeapFree(m_hHeap, 0, pszDisplay); + } + } + + // Free feature info array. + // Feature Info array allocated with new so + // that each of the constructors for COptions + // in fhte Feature Info array will be called. + delete[] m_pInfo; +} + +// Turns index for mode to modeless index, which +// is the real index to the feature. +WORD CFeatures::GetModelessIndex(WORD wIndex, DWORD dwMode) const +{ + WORD wCount = 0; + + + switch(dwMode) + { + // Number of features, all modes + case 0: + wCount = wIndex; + break; + + // Find the nth feature that matches the mode + case OEMCUIP_DOCPROP: + case OEMCUIP_PRNPROP: + // Walk the feature list looking for nth feature + // with matching mode. + for(wCount = 0; wCount < m_wFeatures; ++wCount) + { + // Count down to the feature we want. + // Only count down for matching modes. + if(dwMode == m_pInfo[wCount].dwMode) + { + if(0 == wIndex) + { + break; + } + else + { + --wIndex; + } + } + } + break; + } + + return wCount; +} + + +// +// Public Methods +// + +// Default constructor +CFeatures::CFeatures() +{ + Init(); +} + +// Destructor +CFeatures::~CFeatures() +{ + // Clean up class. + Clear(); +} + +// Gets Core Driver Features, if not already retrieved. +HRESULT CFeatures::Acquire(_In_ HANDLE hHeap, + CUIHelper &Helper, + _In_ POEMUIOBJ poemuiobj + ) +{ + WORD wIndex = 0; + DWORD dwNeeded = 0; + HRESULT hrResult = S_OK; + + + VERBOSE(DLLTEXT("CFeatures::Acquire(0x%p, Helper, 0x%p) entered.\r\n"), + hHeap, + poemuiobj); + + // Don't retreive the Features again if we already got them. + if(0 < m_wFeatures) + { + VERBOSE(DLLTEXT("CFeatures::Acquire() features already enumerated.\r\n")); + VERBOSE(DLLTEXT("CFeatures::Acquire() returning S_OK.\r\n")); + + return S_OK; + } + + // Save the heap handle for use later, such as freeing memory at destruction. + m_hHeap = hHeap; + + // + // Enumerate features. + // + + // To try to cut down on having to call EnumFeatures more than once, + // pre-allocate a buffer of reasonable size. + m_dwSize = INITIAL_ENUM_FEATURES_SIZE; + m_pmszRaw = (PSTR) HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY, m_dwSize); + if(NULL == m_pmszRaw) + { + ERR(ERRORTEXT("CFeatures::Acquire() alloc for feature list failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + + // Try to get feature list with initial buffer. + hrResult = Helper.EnumFeatures(poemuiobj, 0, m_pmszRaw, m_dwSize, &dwNeeded); + if( (E_OUTOFMEMORY == hrResult) && (m_dwSize < dwNeeded)) + { + PSTR pTemp; + + + // INVARIANT: feature list multi-sz wasn't large enough. + + + // Re-allocate the buffer and try again. + pTemp = (PSTR) HeapReAlloc(m_hHeap, HEAP_ZERO_MEMORY, m_pmszRaw, dwNeeded); + if(NULL == pTemp) + { + ERR(ERRORTEXT("CFeatures::Acquire() re-alloc for feature list failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + m_pmszRaw = pTemp; + m_dwSize = dwNeeded; + + // Try again to get the feature list. + hrResult = Helper.EnumFeatures(poemuiobj, 0, m_pmszRaw, m_dwSize, &dwNeeded); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("CFeatures::Acquire() failed to EnumFeatures() after re-allocating buffer.\r\n")); + + goto Exit; + } + } + + // Make sure we got the feature list. + // Can't do anything more with out it. + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("CFeatures::Acquire() failed to enumerate features. (hrResult = 0x%x)\r\n"), hrResult); + + goto Exit; + } + + // INVARIANT: successfully got feature keyword list. + + // Create array of string pointers to the feature keywords + // in the multi-sz we got from EnumFreatures(). + hrResult = MakeStrPtrList(m_hHeap, m_pmszRaw, &m_ppszKeywords, &m_wFeatures); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("CFeatures::Acquire() failed to create pointer list to keywords. (hrResult = 0x%x)\r\n"), hrResult); + + goto Exit; + } + + + // + // Build Feature Information + // + + + // Allocate array to hold feature info + // Use new for allocation so class + // constructors/destructors get called. + m_pInfo = new FEATURE_INFO[m_wFeatures]; + if(NULL == m_pInfo) + { + ERR(ERRORTEXT("CFeatures::Acquire() failed to alloc feature info array.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // For each feature, build/get feature info.... + for(wIndex = 0; wIndex < m_wFeatures; ++wIndex) + { + PFEATURE_INFO pCurrent = m_pInfo + wIndex; + + + // Get or build a keyword mapping entry + // that maps from keyword to usefully where to get info, such as + // display name, icon, option type, for keywords that may not be + // able to get info for from Helper. + pCurrent->pMapping = FindKeywordMapping(gkmFeatureMap, NUM_FEATURE_MAP, m_ppszKeywords[wIndex]); + + // Get display names for each of the featurs. + // The function implements a heuristic for detemining the display name, + // since can't get the display name from the UI Helper for all features. + hrResult = DetermineFeatureDisplayName(m_hHeap, + Helper, + poemuiobj, + m_ppszKeywords[wIndex], + pCurrent->pMapping, + &pCurrent->pszDisplayName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("CFeatures::Acquire() failed to get display name for feature %hs. (hrResult = 0x%x)\r\n"), + m_ppszKeywords[wIndex], + hrResult); + + goto Exit; + } + + // Get options for each feature. + // NOTE: some features don't have options; the HRESULT will be E_NOTIMPL for these. + hrResult = pCurrent->Options.Acquire(hHeap, + Helper, + poemuiobj, + m_ppszKeywords[wIndex]); + if(!SUCCEEDED(hrResult) && (E_NOTIMPL != hrResult)) + { + ERR(ERRORTEXT("CFeatures::Acquire() failed to get options for feature %hs. (hrResult = 0x%x)\r\n"), + m_ppszKeywords[wIndex], + hrResult); + + goto Exit; + } + + // Determine if feature is Printer or Document sticky. + hrResult = DetermineStickiness(Helper, + poemuiobj, + m_ppszKeywords[wIndex], + pCurrent->pMapping, + &pCurrent->dwMode); + // Don't propagate error if failure from unhandled driver feature. + if( !SUCCEEDED(hrResult) + && + !IS_DRIVER_FEATURE(m_ppszKeywords[wIndex]) + ) + { + ERR(ERRORTEXT("CFeatures::Acquire() failed to determine stickiness for feature %hs. (hrResult = 0x%x)\r\n"), + m_ppszKeywords[wIndex], + hrResult); + + goto Exit; + } + + // Keep track of mode counts. + switch(pCurrent->dwMode) + { + case OEMCUIP_DOCPROP: + ++m_wDocFeatures; + break; + + case OEMCUIP_PRNPROP: + ++m_wPrintFeatures; + break; + + default: + ERR(ERRORTEXT("CFeatures::Acquire() unknown stickiness for feature %hs.\r\n"), + m_ppszKeywords[wIndex]); + break; + } + + } + + // INVARIANT: successfully build feature list. + + // Make sure that we always return success if we reach this point. + hrResult = S_OK; + + +Exit: + + // Clean up if weren't successful. + if(!SUCCEEDED(hrResult)) + { + Clear(); + } + + + VERBOSE(DLLTEXT("CFeatures::Acquire() returning HRESULT of 0x%x.\r\n"), hrResult); + + return hrResult; +} + +// Returns number of features contained in class instance. +WORD CFeatures::GetCount(DWORD dwMode) const +{ + WORD wCount = 0; + + + switch(dwMode) + { + // Number of features, all modes + case 0: + wCount = m_wFeatures; + break; + + case OEMCUIP_DOCPROP: + wCount = m_wDocFeatures; + break; + + case OEMCUIP_PRNPROP: + wCount = m_wPrintFeatures; + break; + + } + + VERBOSE(DLLTEXT("CFeatures::GetCount() returning %d\r\n"), wCount); + + return wCount; +} + +// Returns nth feature's keyword +PCSTR CFeatures::GetKeyword(WORD wIndex, DWORD dwMode) const +{ + // Validate parameters. + if( (wIndex >= GetCount(dwMode)) + || + (NULL == m_ppszKeywords) + ) + { + return NULL; + } + + // Get internal index. + wIndex = GetModelessIndex(wIndex, dwMode); + + // Return keyword + return m_ppszKeywords[wIndex]; +} + +// Return nth feature's Display Name. +PCWSTR CFeatures::GetName(WORD wIndex, DWORD dwMode) const +{ + // Validate parameters. + if( (wIndex >= GetCount(dwMode)) + || + (NULL == m_pInfo) + ) + { + return NULL; + } + + // Get internal index. + wIndex = GetModelessIndex(wIndex, dwMode); + + // Return display name. + return m_pInfo[wIndex].pszDisplayName; +} + +// Returns pointer to option class for nth feature. +COptions* CFeatures::GetOptions(WORD wIndex, DWORD dwMode) const +{ + // Validate parameters. + if( (wIndex >= GetCount(dwMode)) + || + (NULL == m_pInfo) + ) + { + return NULL; + } + + // Get internal index. + wIndex = GetModelessIndex(wIndex, dwMode); + + // Return options pointer. + return &m_pInfo[wIndex].Options; +} + +// Formats OPTITEM for specied feature. +HRESULT CFeatures::InitOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem, WORD wIndex, DWORD dwMode) +{ + COptions *pOptions = NULL; + HRESULT hrResult = S_OK; + PFEATUREOPTITEMDATA pData = NULL; + + + // Validate parameters. + if( (wIndex >= GetCount(dwMode)) + || + (NULL == m_pInfo) + || + (NULL == pOptItem) + ) + { + return E_INVALIDARG; + } + + // Map mode index to internal index. + wIndex = GetModelessIndex(wIndex, dwMode); + + // Get name of feature. + pOptItem->pName = const_cast(GetName(wIndex)); + + // Add feature OPTITEM data to OPTITEM to facilitate saving + // selection changes. + pData = (PFEATUREOPTITEMDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(FEATUREOPTITEMDATA)); + if(NULL == pData) + { + ERR(ERRORTEXT("CFeatures::InitOptItem() failed to allocated memory for feature OPTITEM data.")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + pData->dwSize = sizeof(FEATUREOPTITEMDATA); + pData->dwTag = FEATURE_OPTITEM_TAG; + pData->pszFeatureKeyword = GetKeyword(wIndex); + pData->pOptions = GetOptions(wIndex); + pOptItem->UserData = (ULONG_PTR) pData; + + + // Get pointer to options for this feature. + // NOTE: some features do not have option list for various reasons. + pOptions = GetOptions(wIndex); + if(NULL != pOptions) + { + // Initialize COption parts of the OPTITEM + hrResult = pOptions->InitOptItem(hHeap, pOptItem); + } + +Exit: + + Dump(pOptItem); + + return hrResult; +} + +////////////////////////////////////////////////// +// +// Regular functions not part of class +// +////////////////////////////////////////////////// + + +// Maps feature keywords to display names for the features. +HRESULT DetermineFeatureDisplayName(_In_ HANDLE hHeap, + CUIHelper &Helper, + POEMUIOBJ poemuiobj, + _In_ PCSTR pszKeyword, + const PKEYWORDMAP pMapping, + _Outptr_result_maybenull_ PWSTR *ppszDisplayName) +{ + DWORD dwDataType = 0; + DWORD dwSize = INITIAL_FEATURE_DISPLAY_NAME_SIZE; + DWORD dwNeeded = 0; + HRESULT hrResult = S_OK; + + + // Validate parameters. + if( (NULL == hHeap) + || + (NULL == pszKeyword) + || + (NULL == ppszDisplayName) + ) + { + ERR(ERRORTEXT("DetermineFeatureDisplayName() invalid arguement.\r\n")); + + hrResult = E_INVALIDARG; + goto Exit; + } + + // + // Call the Helper function. + // + + // Helper will return Display Names for PPD Features, but + // not for Driver Synthisized features (i.e. features prefixed with %). + // Do it for Driver Synthisized features, just in case the helper + // interface changes to support it. + + // Pre-allocate a buffer of reasonable size to try + // to one have to call GetFeatureAttribute() once. + *ppszDisplayName = (PWSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize); + if(NULL == *ppszDisplayName) + { + ERR(ERRORTEXT("DetermineFeatureDisplayName() alloc for feature display name failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Try to get diplay name for feature from Helper. + hrResult = Helper.GetFeatureAttribute(poemuiobj, + 0, + pszKeyword, + "DisplayName", + &dwDataType, + (PBYTE) *ppszDisplayName, + dwSize, + &dwNeeded); + if( (E_OUTOFMEMORY == hrResult) && (dwSize < dwNeeded)) + { + PWSTR pTemp; + + + // INVARIANT: initial buffer wasn't large enough. + + // Re-alloc buffer and try again. + pTemp = (PWSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, *ppszDisplayName, dwNeeded); + if(NULL == pTemp) + { + ERR(ERRORTEXT("DetermineFeatureDisplayName() re-alloc for feature display name failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + *ppszDisplayName = pTemp; + + // Try to get the display name from Helper, again. + hrResult = Helper.GetFeatureAttribute(poemuiobj, + 0, + pszKeyword, + "DisplayName", + &dwDataType, + (PBYTE) *ppszDisplayName, + dwNeeded, + &dwNeeded); + } + + if(SUCCEEDED(hrResult)) + { + // INVARIANT: Successfully got display name from Helper for feature. + // Don't need to do anything more. + + // Check the data type, it should be kADT_UNICODE. + if(kADT_UNICODE != dwDataType) WARNING(DLLTEXT("DetermineFeatureDisplayName() feature attribute type not kADT_UNICODE. (dwDataType = %d)\r\n"), dwDataType); + + goto Exit; + } + + // INVARIANT: Did not get the display name from the Helper. + + // Free memory allocated for call to Helper. + if(NULL != *ppszDisplayName) + { + HeapFree(hHeap, 0, *ppszDisplayName); + *ppszDisplayName = NULL; + } + + // Try alternative methods for getting the display name other + // than from the Helper function. + // If we have a mapping entry, then try to get resource string + // for the display name. + // Otherwise, covert the keyword to UNICODE and use that. + if(NULL != pMapping) + { + // + // Try mapping the keyword to resource string. + // + + hrResult = GetDisplayNameFromMapping(hHeap, pMapping, ppszDisplayName); + } + else + { + // + // Convert the keyword to UNICODE and use that. + // + + // Convert ANSI keyword to Unicode string for display name. + // Need to remove the % for Driver Synthisized features. + // For debug version, add marker that shows that the display name was faked. + PCSTR pConvert = IS_DRIVER_FEATURE(pszKeyword) ? pszKeyword + 1 : pszKeyword; + #if DBG + CHAR szTemp[256]; + if(FAILED(StringCbPrintfA(szTemp, sizeof(szTemp), "%s (Keyword)", pConvert))) + { + ERR(ERRORTEXT("DetermineFeatureDisplayName() StringCbPrintfA() called failed.\r\n")); + } + pConvert = szTemp; + #endif + *ppszDisplayName = MakeUnicodeString(hHeap, pConvert); + if(NULL == *ppszDisplayName) + { + ERR(ERRORTEXT("DetermineFeatureDisplayName() alloc for feature display name failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Return success even though we faked a display name. + hrResult = S_OK; + } + + +Exit: + + // If failed, then return no string. + if(!SUCCEEDED(hrResult)) + { + if(ppszDisplayName && NULL != *ppszDisplayName) + { + HeapFree(hHeap, 0, *ppszDisplayName); + *ppszDisplayName = NULL; + } + } + + return hrResult; +} + +// Maps option keywords to display names for the option. +HRESULT DetermineOptionDisplayName(_In_ HANDLE hHeap, + CUIHelper &Helper, + POEMUIOBJ poemuiobj, + _In_ PCSTR pszFeature, + _In_ PCSTR pszOption, + const PKEYWORDMAP pMapping, + _Outptr_result_maybenull_ PWSTR *ppszDisplayName) +{ + DWORD dwDataType = 0; + DWORD dwSize = INITIAL_OPTION_DISPLAY_NAME_SIZE; + DWORD dwNeeded = 0; + HRESULT hrResult = S_OK; + + + // Validate parameters. + if( (NULL == hHeap) + || + (NULL == pszFeature) + || + (NULL == pszOption) + || + (NULL == ppszDisplayName) + ) + { + ERR(ERRORTEXT("DetermineOptionDisplayName() invalid arguement.\r\n")); + + hrResult = E_INVALIDARG; + goto Exit; + } + + // + // Call the Helper function. + // + + // Helper will return Display Names for PPD Feature Options, but + // not for Driver Synthisized features options (i.e. features prefixed with %). + // Do it for all options, just in case the helper interface changes to support it. + + // Pre-allocate a buffer of reasonable size to try + // to one have to call GetOptionAttribute() once. + *ppszDisplayName = (PWSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize); + if(NULL == *ppszDisplayName) + { + ERR(ERRORTEXT("DetermineOptionDisplayName() alloc for feature display name failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Try to get diplay name for feature from Helper. + hrResult = Helper.GetOptionAttribute(poemuiobj, + 0, + pszFeature, + pszOption, + "DisplayName", + &dwDataType, + (PBYTE) *ppszDisplayName, + dwSize, + &dwNeeded); + if( (E_OUTOFMEMORY == hrResult) && (dwSize < dwNeeded)) + { + PWSTR pTemp; + + + // INVARIANT: initial buffer wasn't large enough. + + // Re-alloc buffer and try again. + pTemp = (PWSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, *ppszDisplayName, dwNeeded); + if(NULL == pTemp) + { + ERR(ERRORTEXT("GetOptionAttribute() re-alloc for feature display name failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + *ppszDisplayName = pTemp; + + // Try to get the display name from Helper, again. + hrResult = Helper.GetOptionAttribute(poemuiobj, + 0, + pszFeature, + pszOption, + "DisplayName", + &dwDataType, + (PBYTE) *ppszDisplayName, + dwNeeded, + &dwNeeded); + } + + if(SUCCEEDED(hrResult)) + { + // INVARIANT: Successfully got display name from Helper for feature. + // Don't need to do anything more. + + // Check the data type, it should be kADT_UNICODE. + if(kADT_UNICODE != dwDataType) WARNING(DLLTEXT("DetermineOptionDisplayName() feature attribute type not kADT_UNICODE. (dwDataType = %d)\r\n"), dwDataType); + + goto Exit; + } + + // INVARIANT: Did not get the display name from the Helper. + + // Free memory allocated for call to Helper. + if(NULL != *ppszDisplayName) + { + HeapFree(hHeap, 0, *ppszDisplayName); + *ppszDisplayName = NULL; + } + + // Try alternative methods for getting the display name other + // than from the Helper function. + // If we have a mapping entry, then try to get resource string + // for the display name. + // Otherwise, covert the keyword to UNICODE and use that. + if(NULL != pMapping) + { + // + // Try mapping the keyword to resource string. + // + + hrResult = GetDisplayNameFromMapping(hHeap, pMapping, ppszDisplayName); + } + else + { + // + // Convert the keyword to UNICODE and use that. + // + + // Convert ANSI keyword to Unicode string for display name. + // For debug version, add marker that shows that the display name was faked. + PCSTR pConvert = pszOption; + #if DBG + CHAR szTemp[256]; + if(FAILED(StringCbPrintfA(szTemp, sizeof(szTemp), "%s (Keyword)", pConvert))) + { + ERR(ERRORTEXT("DetermineOptionDisplayName() StringCbPrintfA() called failed.\r\n")); + } + pConvert = szTemp; + #endif + *ppszDisplayName = MakeUnicodeString(hHeap, pConvert); + if(NULL == *ppszDisplayName) + { + ERR(ERRORTEXT("DetermineOptionDisplayName() alloc for feature display name failed.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Return success even though we faked a display name. + hrResult = S_OK; + } + + +Exit: + + // If failed, then return no string. + if(!SUCCEEDED(hrResult)) + { + if(ppszDisplayName && NULL != *ppszDisplayName) + { + HeapFree(hHeap, 0, *ppszDisplayName); + *ppszDisplayName = NULL; + } + } + + return hrResult; +} + +// Determines sticky mode for the feature. +HRESULT DetermineStickiness(CUIHelper &Helper, + POEMUIOBJ poemuiobj, + PCSTR pszKeyword, + const PKEYWORDMAP pMapping, + PDWORD pdwMode) +{ + CHAR szGroupType[32] = {0}; + DWORD dwType = 0; + DWORD dwNeeded = 0; + HRESULT hrResult = S_OK; + + + // Use mapping to see what stickiness of the feature is. + if(NULL != pMapping) + { + *pdwMode = pMapping->dwMode; + goto Exit; + } + + // By default make feature Document sticky, if we don't have mapping. + *pdwMode = OEMCUIP_DOCPROP; + + // Try to use Helper to determine stickiness. + hrResult = Helper.GetFeatureAttribute(poemuiobj, + 0, + pszKeyword, + "OpenGroupType", + &dwType, + (PBYTE) szGroupType, + sizeof(szGroupType), + &dwNeeded); + if(SUCCEEDED(hrResult)) + { + // INVARIANT: found out if feature is an installable option. + // Installable options are the only PPD features + // that are Printer sticky. + + if(!lstrcmpA(szGroupType, "InstallableOptions")) + { + *pdwMode = OEMCUIP_PRNPROP; + } + goto Exit; + } + + +Exit: + + return hrResult; +} + +// Find the mapping entry from the keyword. +PKEYWORDMAP FindKeywordMapping(PKEYWORDMAP pKeywordMap, WORD wMapSize, PCSTR pszKeyword) +{ + BOOL bFound = FALSE; + PKEYWORDMAP pMapping = NULL; + + + // Walk mapping array for matching keyword. + for(WORD wIndex = 0; !bFound && (wIndex < wMapSize); ++wIndex) + { + bFound = !lstrcmpA(pszKeyword, pKeywordMap[wIndex].pszKeyword); + if(bFound) + { + pMapping = pKeywordMap + wIndex; + } + } + + return pMapping; +} + +// Get display name from mapping entry. +HRESULT GetDisplayNameFromMapping(_In_ HANDLE hHeap, PKEYWORDMAP pMapping, _Outptr_result_maybenull_ PWSTR *ppszDisplayName) +{ + HMODULE hModule = NULL; + HRESULT hrResult = S_OK; + + + // Validate parameters. + if( (NULL == hHeap) + || + (NULL == pMapping) + || + (NULL == ppszDisplayName) + ) + { + hrResult = E_INVALIDARG; + goto Exit; + } + + // Check for simple case of returning INT resource. + if( (NULL == pMapping->pwszModule) + || + IS_MAPPING_INT_RESOURCE(pMapping) + ) + { + // Just need to do MAKEINTRESOURCE on the resource ID and return. + *ppszDisplayName = MAKEINTRESOURCE(pMapping->uDisplayNameID); + goto Exit; + } + + // We only need to get the module if we aren't loading the resource from + // this module (i.e. if module name isn't NULL). + // Also, as an optimization, we assume that the module has already been loaded, + // since the only cases currently are this module, driver ui, and Compstui.dll. + hModule = GetModuleHandle(pMapping->pwszModule); + if(NULL == hModule) + { + DWORD dwError = GetLastError(); + + + ERR(ERRORTEXT("GetDisplayNameFromMapping() for failed to load module %s. (Error %d)\r\n"), + pMapping->pwszModule, + dwError); + + hrResult = HRESULT_FROM_WIN32(dwError); + goto Exit; + } + + // INVARIANT: have handle to module to load resource from or the + // resource is being loaded from this module. + + // Get the string resouce. + hrResult = GetStringResource(hHeap, hModule, pMapping->uDisplayNameID, ppszDisplayName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("GetDisplayNameFromMapping() failed to load string. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + +Exit: + + return hrResult; +} + +// Test if an OPTITEM is an OPTITEM for a feature. +// Macro for testing if OPTITEM is feature OPTITEM +BOOL IsFeatureOptitem(POPTITEM pOptItem) +{ + BOOL bRet = FALSE; + PFEATUREOPTITEMDATA pData = NULL; + + + // Make sure pointers are NULL. + if( (NULL == pOptItem) + || + (NULL == pOptItem->UserData) + ) + { + // INVARIANT: can't be feature OPTITEM, since one of + // the necessary pointer are NULL. + + return FALSE; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItem->UserData); + + // Check size and tag. + bRet = (sizeof(FEATUREOPTITEMDATA) == pData->dwSize) + && + (FEATURE_OPTITEM_TAG == pData->dwTag); + + return bRet; +} + + + +// Walks array of OPTITEMs saving each feature OPTITEM +// that has changed. +HRESULT SaveFeatureOptItems(_In_ HANDLE hHeap, + CUIHelper *pHelper, + POEMUIOBJ poemuiobj, + HWND hWnd, + POPTITEM pOptItem, + WORD wItems) +{ + PSTR pmszPairs = NULL; + WORD wPairs = 0; + WORD wReasons = 0; + DWORD dwSize = 0; + DWORD dwResult = 0; + PCSTR *ppszReasons = NULL; + PWSTR pszConfilictFeature = NULL; + PWSTR pszConfilictOption = NULL; + PWSTR pszCaption = NULL; + PWSTR pszFormat = NULL; + PWSTR pszMessage = NULL; + HRESULT hrResult = S_OK; + + + // Validate parameters + if( (NULL == hHeap) + || + (NULL == pHelper) + || + (NULL == pOptItem) + ) + { + ERR(ERRORTEXT("SaveFeatureOptItems() called with invalid parameters.\r\n")); + + hrResult = E_INVALIDARG; + goto Exit; + } + + // Get feature option pairs to save. + hrResult = GetChangedFeatureOptions(hHeap, pOptItem, wItems, &pmszPairs, &wPairs, &dwSize); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems() failed to get changed feature option pairs. (hrResult = 0x%x)\r\n"), + hrResult); + + goto Exit; + } + + // Don't need to do anything more if no feature options changed. + if(0 == wPairs || !pmszPairs) + { + VERBOSE(DLLTEXT("SaveFeatureOptItems() no feature options that need to be set.\r\n")); + + goto Exit; + } + + // Set the change feature options. + // For the first SetOptions() call, don't have the + // core driver UI resolve conflicts, so we can + // prompt user for automatic resolution or let + // them do the conflict resolving. + hrResult = pHelper->SetOptions(poemuiobj, + SETOPTIONS_FLAG_KEEP_CONFLICT, + pmszPairs, + dwSize, + &dwResult); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems() call to SetOptions() failed. (hrResult = 0x%x, dwResult = %d\r\n"), + hrResult, + dwResult); + + goto Exit; + } + + // Check to see if we were able to save changed feature options, + // or if there is a conflict that needs resolution. + if(SETOPTIONS_RESULT_CONFLICT_REMAINED == dwResult) + { + int nRet; + DWORD dwRet; + CONFLICT Conflict; + PKEYWORDMAP pMapping = NULL; + + + // INVARIANT: constraint conflict, options weren't saved. + + // Get list of all features that have conflict. + hrResult = GetFirstConflictingFeature(hHeap, + pHelper, + poemuiobj, + pOptItem, + wItems, + &Conflict); + if(!SUCCEEDED(hrResult)) + { + goto Exit; + } + + // Create string pointer list in to multi-sz of first conflict. + hrResult = MakeStrPtrList(hHeap, Conflict.pmszReasons, &ppszReasons, &wReasons); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems() failed to make string list for conflict reasons. (hrResult = 0x%x)\r\n"), + hrResult); + + goto Exit; + } + + // Ensure that we have at least 2 reasons. Later code assumes that we do. + if (wReasons < 2) + { + hrResult = E_UNEXPECTED; + + goto Exit; + } + + // + // Get display versions of feature/option conflict reason. + // + + // Get or build a keyword mapping entry + // that maps from keyword to usefully where to get info, such as + // display name, icon, option type, for keywords that may not be + // able to get info for from Helper. + pMapping = FindKeywordMapping(gkmFeatureMap, NUM_FEATURE_MAP, ppszReasons[0]); + + // Get display names for each of the featurs. + // The function implements a heuristic for detemining the display name, + // since can't get the display name from the UI Helper for all features. + hrResult = DetermineFeatureDisplayName(hHeap, + *pHelper, + poemuiobj, + ppszReasons[0], + pMapping, + &pszConfilictFeature); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems failed to get display name for feature %hs. (hrResult = 0x%x)\r\n"), + ppszReasons[0], + hrResult); + + goto Exit; + } + + // Get or build a keyword mapping entry + // that maps from keyword to usefully where to get info, such as + // display name, icon, option type, for keywords that may not be + // able to get info for from Helper. + pMapping = FindKeywordMapping(gkmOptionMap, NUM_OPTION_MAP, ppszReasons[1]); + + // Get option display name. + hrResult = DetermineOptionDisplayName(hHeap, + *pHelper, + poemuiobj, + ppszReasons[0], + ppszReasons[1], + pMapping, + &pszConfilictOption); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems() failed to get display name for %hs of feature %hs. (hrResult = 0x%x)\r\n"), + ppszReasons[1], + ppszReasons[0], + hrResult); + + goto Exit; + } + + // + // Prompt user about how to resolve conflict. + // + + // Get caption name. + hrResult = GetStringResource(hHeap, ghInstance, IDS_NAME, &pszCaption); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems() failed to get caption name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + // Get message body format string. + hrResult = GetStringResource(hHeap, ghInstance, IDS_CONSTRAINT_CONFLICT, &pszFormat); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems() failed to get constraint conflict format. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + + // Get messsage body. + PVOID paArgs[4] = {pszConfilictFeature, + pszConfilictOption, + const_cast(Conflict.pszFeature), + Conflict.pszOption + }; + dwRet = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, + pszFormat, + 0, + 0, + (PWSTR) &pszMessage, + 0, + (va_list *) paArgs); + if(0 == dwRet) + { + DWORD dwError = GetLastError(); + + ERR(ERRORTEXT("SaveFeatureOptItems() failed to FormatMessage() for constraint conflict of feature %hs option %hs. (Last Error %d)\r\n"), + Conflict.pszFeatureKeyword, + Conflict.pszOptionKeyword, + dwError); + + hrResult = HRESULT_FROM_WIN32(dwError); + goto Exit; + } + + // Display simple message box with prompt. + nRet = MessageBox(hWnd, pszMessage, pszCaption, MB_YESNO | MB_ICONWARNING); + + // Check to see how user wants to resolve conflict. + if(IDYES == nRet) + { + // Let core driver resolve conflict resolution. + hrResult = pHelper->SetOptions(poemuiobj, + SETOPTIONS_FLAG_RESOLVE_CONFLICT, + pmszPairs, + dwSize, + &dwResult); + + // Conflict resolution requires refreshing current option + // selection for each feature, since selection may have + // changed because of conflict resolution. + RefreshOptItemSelection(pHelper, poemuiobj, pOptItem, wItems); + } + + // Return failure if there are still conflictts. + if(SETOPTIONS_RESULT_CONFLICT_REMAINED == dwResult) + { + hrResult = E_FAIL; + } + } + + +Exit: + + // Clean up... + + // cleanup heap allocs. + if(NULL != pmszPairs) HeapFree(hHeap, 0, pmszPairs); + if(NULL != ppszReasons) HeapFree(hHeap, 0, ppszReasons); + if(NULL != pszConfilictFeature) HeapFree(hHeap, 0, pszConfilictFeature); + if(NULL != pszConfilictOption) HeapFree(hHeap, 0, pszConfilictOption); + if(NULL != pszCaption) HeapFree(hHeap, 0, pszCaption); + if(NULL != pszFormat) HeapFree(hHeap, 0, pszFormat); + if(NULL != pszMessage) LocalFree(pszMessage); + + return hrResult; +} + +// Allocates buffer, if needed, and calls IPrintCoreUI2::WhyConsrained +// to get reason for constraint. +HRESULT GetWhyConstrained(_In_ HANDLE hHeap, + CUIHelper *pHelper, + POEMUIOBJ poemuiobj, + _In_ PCSTR pszFeature, + _In_ PCSTR pszOption, + _Inout_ PSTR *ppmszReason, + _Inout_ PDWORD pdwSize) +{ + PSTR pmszReasonList = *ppmszReason; + DWORD dwNeeded = 0; + HRESULT hrResult = S_OK; + + + // If buffer wasn't passed in, then allocate one. + if( (NULL == pmszReasonList) || (0 == *pdwSize) ) + { + // If no size or size is smaller than default, then change to default + // size. We want to try to only allocate and call once. + if(*pdwSize < INITIAL_GET_REASON_SIZE) + { + *pdwSize = INITIAL_GET_REASON_SIZE; + } + + // Alloc initial buffer for reason constrained. + pmszReasonList = (PSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, *pdwSize); + if(NULL == pmszReasonList) + { + ERR(ERRORTEXT("GetWhyConstrained() failed to alloc buffer for constraint reasons for feature %hs and option %hs.\r\n"), + pszFeature, + pszOption); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + } + + // Get reason for constraint. + hrResult = pHelper->WhyConstrained(poemuiobj, + 0, + pszFeature, + pszOption, + pmszReasonList, + *pdwSize, + &dwNeeded); + if( (E_OUTOFMEMORY == hrResult) + && + (*pdwSize < dwNeeded) + ) + { + PSTR pTemp; + + + // INVARIANT: initial buffer not large enough. + + // Re-alloc buffer to needed size. + pTemp = (PSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pmszReasonList, dwNeeded); + if(NULL == pTemp) + { + ERR(ERRORTEXT("GetWhyConstrained() failed to re-allocate buffer for constraint reason for feature %hs and option %hs.\r\n"), + pszFeature, + pszOption); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + pmszReasonList = pTemp; + *pdwSize = dwNeeded; + + // Retry getting constaint reason. + hrResult = pHelper->WhyConstrained(poemuiobj, + 0, + pszFeature, + pszOption, + pmszReasonList, + *pdwSize, + &dwNeeded); + } + + +Exit: + + // On error, do clean up. + if(!SUCCEEDED(hrResult)) + { + // Free reason buffer. + if(NULL != pmszReasonList) HeapFree(hHeap, 0, pmszReasonList); + + // Return NULL and zero size. + *ppmszReason = NULL; + *pdwSize = 0; + } + else + { + *ppmszReason = pmszReasonList; + } + + return hrResult; +} + +// Creates multi-sz list of feature option pairs that have changed. +HRESULT GetChangedFeatureOptions(_In_ HANDLE hHeap, + POPTITEM pOptItem, + WORD wItems, + _Outptr_result_maybenull_ PSTR *ppmszPairs, + _Out_ PWORD pwPairs, + _Out_ PDWORD pdwSize) +{ + WORD wCount = 0; + WORD wChanged = 0; + WORD wPairs = 0; + PSTR pmszPairs = NULL; + DWORD dwNeeded = 2; + DWORD dwOffset = 0; + HRESULT hrResult = S_OK; + PFEATUREOPTITEMDATA pData = NULL; + + + // Walk OPTITEM array looking or changed options, + // and calculating size needed for multi-sz buffer. + for(wCount = 0; wCount < wItems; ++wCount) + { + PSTR pszOption = NULL; + + + // Just go to next item if this OPTITEM hasn't + // changed or isn't a feature OPTITEM. + if( !(OPTIF_CHANGEONCE & pOptItem[wCount].Flags) + || + !IsFeatureOptitem(pOptItem + wCount) + ) + { + continue; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItem[wCount].UserData); + + // Increment options changed and size needed. + pszOption = GetOptionKeywordFromOptItem(hHeap, pOptItem + wCount); + if(NULL != pszOption) + { + ++wChanged; + + DWORD dwTmp = 0; + + if (FAILED(hrResult = SizeTToDWord(strlen(pData->pszFeatureKeyword) + strlen(pszOption) + 2, &dwTmp))) + { + goto Exit; + } + + dwNeeded += dwTmp; + + // Need to free option keyword string copy + // allocated in GetOptionKeywordFromOptItem(). + HeapFree(hHeap, 0, pszOption); + pszOption = NULL; + } + } + + // Don't need to do anything more if no feature options changed. + if(0 == wChanged) + { + goto Exit; + } + + // Allocate multi-sz buffer. + pmszPairs = (PSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwNeeded); + if(NULL == pmszPairs) + { + ERR(ERRORTEXT("GetChangedFeatureOptions() failed to allocate multi-sz.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Build mult-sz list of feature option pairs + // that changed. + for(wCount = 0, wPairs = 0; (wCount < wItems) && (wPairs < wChanged); ++wCount) + { + PSTR pszOption = NULL; + + + // Just go to next item if this OPTITEM hasn't + // changed or isn't a feature OPTITEM. + if( !(OPTIF_CHANGEONCE & pOptItem[wCount].Flags) + || + !IsFeatureOptitem(pOptItem + wCount) + ) + { + continue; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItem[wCount].UserData); + + // Add feature option pair. + pszOption = GetOptionKeywordFromOptItem(hHeap, pOptItem + wCount); + if(NULL != pszOption) + { + if (FAILED(hrResult = StringCbCopyA(pmszPairs + dwOffset, dwNeeded - dwOffset, pData->pszFeatureKeyword))) + { + goto Exit; + } + + DWORD dwTmp = 0; + + if (FAILED(hrResult = SizeTToDWord(strlen(pData->pszFeatureKeyword) + 1, &dwTmp))) + { + goto Exit; + } + + dwOffset += dwTmp; + + if (FAILED(hrResult = StringCbCopyA(pmszPairs + dwOffset, dwNeeded - dwOffset, pszOption))) + { + goto Exit; + } + + if (FAILED(hrResult = SizeTToDWord(strlen(pszOption) + 1, &dwTmp))) + { + goto Exit; + } + + dwOffset += dwTmp; + + // Keep track of number of pairs added, so + // we are able to exit loop as soon as + // we added all changed feature options. + ++wPairs; + + // Need to free option keyword string copy + // allocated in GetOptionKeywordFromOptItem(). + HeapFree(hHeap, 0, pszOption); + pszOption = NULL; + } + } + + +Exit: + + if(SUCCEEDED(hrResult)) + { + // INVARIANT: either successfully build mutli-sz of changed + // feature option pairs, or there are no feature + // that options changed. + + // Return pairs and number of pairs. + *pwPairs = wPairs; + *pdwSize = dwNeeded; + *ppmszPairs = pmszPairs; + } + else + { + // INVARINAT: error. + + // Clean up. + if(NULL == pmszPairs) HeapFree(hHeap, 0, pmszPairs); + + // Return NULL and zero count. + *pwPairs = 0; + *pdwSize = 0; + *ppmszPairs = NULL; + } + + return hrResult; +} + +// Returns pointer to option keyword for a feature OPTITEM. +PSTR GetOptionKeywordFromOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem) +{ + char szNumber[16] = {0}; + PSTR pszOption = NULL; + PFEATUREOPTITEMDATA pData = NULL; + + + // Validate parameter. + if(!IsFeatureOptitem(pOptItem)) + { + ERR(ERRORTEXT("GetOptionKeywordFromOptItem() invalid parameter.\r\n")); + + goto Exit; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItem->UserData); + + // Option selection is based on type of OPTTYPE. + switch(pOptItem->pOptType->Type) + { + // For up down arrow control, selection is just pOptItem->Sel + // converted to string. + case TVOT_UDARROW: + if(FAILED(StringCbPrintfA(szNumber, sizeof(szNumber)/sizeof(szNumber[0]), "%u", pOptItem->Sel))) + { + ERR(ERRORTEXT("GetOptionKeywordFromOptItem() failed to convert number to string.\r\n")); + } + szNumber[sizeof(szNumber)/sizeof(szNumber[0]) - 1] = '\0'; + pszOption = MakeStringCopy(hHeap, szNumber); + break; + + // For combobox, pOptItem->Sel is the index in to the + // option array. + case TVOT_COMBOBOX: + pszOption = MakeStringCopy(hHeap, pData->pOptions->GetKeyword((WORD)pOptItem->Sel)); + break; + + // The default is the option count. + default: + ERR(ERRORTEXT("GetOptionKeywordFromOptItem() OPTTYPE type %d num of OPTPARAMs not handled.\r\n"), + pOptItem->pOptType->Type); + + goto Exit; + break; + } + + +Exit: + + return pszOption; +} + +// Returns pointer to option display name for a feature OPTITEM. +PWSTR GetOptionDisplayNameFromOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem) +{ + WCHAR szNumber[16] = {0}; + PWSTR pszOption = NULL; + PFEATUREOPTITEMDATA pData = NULL; + + + // Validate parameter. + if(!IsFeatureOptitem(pOptItem)) + { + ERR(ERRORTEXT("GetOptionDisplayNameFromOptItem() invalid parameter.\r\n")); + + goto Exit; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItem->UserData); + + // Option selection is based on type of OPTTYPE. + switch(pOptItem->pOptType->Type) + { + // For up down arrow control, selection is just pOptItem->Sel + // converted to string. + case TVOT_UDARROW: + if(FAILED(StringCbPrintfW(szNumber, sizeof(szNumber)/sizeof(szNumber[0]), L"%u", pOptItem->Sel))) + { + ERR(ERRORTEXT("GetOptionDisplayNameFromOptItem() failed to convert number to string.\r\n")); + } + szNumber[sizeof(szNumber)/sizeof(szNumber[0]) - 1] = L'\0'; + pszOption = MakeStringCopy(hHeap, szNumber); + break; + + // For combobox, pOptItem->Sel is the index in to the + // option array. + case TVOT_COMBOBOX: + pszOption = MakeStringCopy(hHeap, pOptItem->pOptType->pOptParam[pOptItem->Sel].pData); + break; + + // The default is the option count. + default: + ERR(ERRORTEXT("GetOptionDisplayNameFromOptItem() OPTTYPE type %d num of OPTPARAMs not handled.\r\n"), + pOptItem->pOptType->Type); + + goto Exit; + break; + } + + +Exit: + + return pszOption; +} + +// Refreshes option selection for each feature OPTITEM +HRESULT RefreshOptItemSelection(CUIHelper *pHelper, + POEMUIOBJ poemuiobj, + POPTITEM pOptItems, + WORD wItems) +{ + HRESULT hrResult = S_OK; + PFEATUREOPTITEMDATA pData = NULL; + + + // Walk OPTITEM array refreshing feature OPTITEMs. + for(WORD wCount = 0; wCount < wItems; ++wCount) + { + // Just go to next item if this OPTITEM isn't a feature OPTITEM. + if(!IsFeatureOptitem(pOptItems + wCount)) + { + continue; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItems[wCount].UserData); + + // Refresh COption selection. + pData->pOptions->RefreshSelection(*pHelper, poemuiobj); + + // Assign COption selection to OPTITEM selection. + pOptItems[wCount].pSel = pData->pOptions->GetSelection(); + + } + + return hrResult; +} + +// Creates array of conflict features. +HRESULT GetFirstConflictingFeature(_In_ HANDLE hHeap, + CUIHelper *pHelper, + POEMUIOBJ poemuiobj, + POPTITEM pOptItem, + WORD wItems, + PCONFLICT pConflict) +{ + WORD wCount = 0; + HRESULT hrResult = S_OK; + PFEATUREOPTITEMDATA pData = NULL; + + + // Walk OPTITEM array looking or changed options that are in conflict. + for(wCount = 0; wCount < wItems; ++wCount) + { + // Just go to next item if this OPTITEM hasn't + // changed or isn't a feature OPTITEM. + if( !(OPTIF_CHANGEONCE & pOptItem[wCount].Flags) + || + !IsFeatureOptitem(pOptItem + wCount) + ) + { + continue; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItem[wCount].UserData); + + // Init conflict record if this feature is in conflict. + pConflict->pszOptionKeyword = GetOptionKeywordFromOptItem(hHeap, pOptItem + wCount); + if(NULL != pConflict->pszOptionKeyword) + { + // Get reason for conflict + // If the feature isn't in conflict, + // then the pmszReasonList will start + // with NULL terminator. + hrResult = GetWhyConstrained(hHeap, + pHelper, + poemuiobj, + pData->pszFeatureKeyword, + pConflict->pszOptionKeyword, + &pConflict->pmszReasons, + &pConflict->dwReasonsSize); + if(!SUCCEEDED(hrResult)) + { + // NOTE: driver features aren't supported by WhyConstrained. + if((E_INVALIDARG == hrResult) && IS_DRIVER_FEATURE(pData->pszFeatureKeyword)) + { + // Need to reset the result in case it is the last + // feature OPTITEM. + hrResult = S_OK; + continue; + } + + ERR(ERRORTEXT("GetConflictingFeatures() failed to get reason for feature %hs option %hs constraint. (hrResult = 0x%x)\r\n"), + pData->pszFeatureKeyword, + pConflict->pszOptionKeyword, + hrResult); + + goto Exit; + } + + // Record conflict if feature is in conflict. + if( (NULL != pConflict->pmszReasons) + && + (pConflict->pmszReasons[0] != '\0') + ) + { + // Save pointer to feature keyword. + pConflict->pszFeatureKeyword = pData->pszFeatureKeyword; + pConflict->pszFeature = pOptItem[wCount].pName; + pConflict->pszOption = GetOptionDisplayNameFromOptItem(hHeap, pOptItem + wCount); + + // Found first conflict. + break; + } + } + } + + +Exit: + + return hrResult; +} + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.h new file mode 100644 index 00000000..84fee27e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Features.h @@ -0,0 +1,236 @@ +// 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. +// +// Copyright 2001 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Features.h +// + +#pragma once + +//////////////////////////////////////////////////////// +// Defines and Macros +//////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////////////// +// Type Definitions +//////////////////////////////////////////////////////// + +// Struct used to map keyword to information +// such as display name and stickiness. +typedef struct _tagKeywordMap +{ + PCSTR pszKeyword; + PCWSTR pwszModule; + UINT uDisplayNameID; + DWORD dwMode; + DWORD dwFlags; + +} KEYWORDMAP, *PKEYWORDMAP; + + +// Struct container for info about +// feature that is in conflict. +typedef struct _tagConflict +{ + PCSTR pszFeatureKeyword; + PCWSTR pszFeature; + PSTR pszOptionKeyword; + PWSTR pszOption; + PSTR pmszReasons; + DWORD dwReasonsSize; + +} CONFLICT, *PCONFLICT; + + + +//////////////////////////////////////////////////////// +// Class Definitions +//////////////////////////////////////////////////////// + +// Class wrapper and container for Core Driver Feature Options. +class COptions +{ + private: + + // Option Infomation + class OPTION_INFO + { + public: + PKEYWORDMAP pMapping; + PWSTR pszDisplayName; + + public: + OPTION_INFO() + { + pMapping = NULL; + pszDisplayName = NULL; + } + + virtual ~OPTION_INFO(){} + }; + typedef class OPTION_INFO *POPTION_INFO; + + // Data Members + WORD m_wOptions; // Count of the number of options contained for an instance of the class. + BYTE m_cType; // CPSUI Option Type (i.e. what to set pOptItem->pOptType->Type to). + PSTR m_pmszRaw; // The RAW multi NULL terminated string buffer used for IPrintCoreUI2::EnumOptions(). + PCSTR m_pszFeature; // Pointer to the feature for which the enumerate options belong. + PCSTR *m_ppszOptions; // String list pointer that points to begining of each of the strings in multi-SZ pointed to by m_pmszRaw. + POINT m_ptRange; // Option range for features, such as %JobTimeout, that have a range of possible vaules not a small selection list. + DWORD m_dwSize; // Size of m_pmszRaw buffer. + PWSTR m_pszUnits; // String that contains the unit specifier for options, such as %JobTimeout, which need Units (i.e. seconds). + HANDLE m_hHeap; // Heap to do allocations from. + POPTION_INFO m_pInfo; // Array of Info about each option for a feature. + + union { // Current selected option for a feature. + LONG m_Sel; // This is what pOptItem->m_pSel or pOptItem->m_Sel + LPTSTR m_pSel; // will be set to. + }; + + public: + COptions(); + virtual ~COptions(); + + // Populate Options list for specified keyword. + HRESULT COptions::Acquire(_In_ HANDLE hHeap, + CUIHelper &Helper, + _In_ POEMUIOBJ poemuiobj, + _In_ PCSTR pszFeature); + + // Returns number of feature options contained in class instance. + inline WORD GetCount() const {return m_wOptions;} + + // Returns selection. + inline LPTSTR GetSelection() const {return m_pSel;} + + // Return nth options keyword. + PCSTR GetKeyword(WORD wIndex) const; + + // Return nth option Display Name. + PCWSTR GetName(WORD wIndex) const; + + // Find option with matching keyword string. + WORD FindOption(_In_opt_ PCSTR pszOption, WORD wDefault) const; + + // Initializes options portion of OPTITEM. + HRESULT InitOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem); + + // Refresh option selection. + HRESULT RefreshSelection(CUIHelper &Helper, POEMUIOBJ poemuiobj); + + private: + void Init(); + void Clear(); + void FreeOptionInfo(); + HRESULT GetOptionsForSpecialFeatures(CUIHelper &Helper, POEMUIOBJ poemuiobj); + HRESULT GetOptionsForOutputPSLevel(CUIHelper &Helper, POEMUIOBJ poemuiobj); + HRESULT GetOptionSelectionString(CUIHelper &Helper, POEMUIOBJ poemuiobj, _Outptr_result_maybenull_ PSTR *ppszSel); + HRESULT GetOptionSelectionLong(CUIHelper &Helper, POEMUIOBJ poemuiobj); + HRESULT GetOptionSelectionShort(CUIHelper &Helper, POEMUIOBJ poemuiobj); + HRESULT GetOptionSelectionIndex(CUIHelper &Helper, POEMUIOBJ poemuiobj); +}; + + +// Class wrapper and container for Cor Driver Features. +class CFeatures +{ + private: + + // Feature Infomation + class FEATURE_INFO + { + public: + PKEYWORDMAP pMapping; + PWSTR pszDisplayName; + COptions Options; + DWORD dwMode; + + public: + FEATURE_INFO() + { + pMapping = NULL; + pszDisplayName = NULL; + dwMode = 0; + } + + virtual ~FEATURE_INFO() {} + }; + typedef class FEATURE_INFO *PFEATURE_INFO; + + WORD m_wFeatures; // Count of the number of features. + WORD m_wDocFeatures; // Count of the number of Document sticky features. + WORD m_wPrintFeatures; // Count of the number of Printer sticky features. + PSTR m_pmszRaw; // Buffer for multi-SZ for call to IPrintCoreUI2::EnumFeatures. + PCSTR *m_ppszKeywords; // String list that points to each of the strings in m_pmszRaw. + DWORD m_dwSize; // Size of m_pmszRaw. + HANDLE m_hHeap; // Heap to do allocations from. + PFEATURE_INFO m_pInfo; // Array of feature information about each of the enumerate features. + + public: + CFeatures(); + virtual ~CFeatures(); + + // Populates the Feature list + HRESULT Acquire(_In_ HANDLE hHeap, CUIHelper &Helper, _In_ POEMUIOBJ poemuiobj); + + // Returns number of features contained in class instance. + WORD GetCount(DWORD dwMode = 0) const; + + // Returns feature keyword. + PCSTR GetKeyword(WORD wIndex, DWORD dwMode = 0) const; + + // Return feature Display Name. + PCWSTR GetName(WORD wIndex, DWORD dwMode = 0) const; + + // Returns pointer to option class for nth feature. + COptions* GetOptions(WORD wIndex, DWORD dwMode = 0) const; + + // Initializes OPTITEM for the feature. + HRESULT InitOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem, WORD wIndex, DWORD dwMode); + + private: + void Init(); + void Clear(); + void FreeFeatureInfo(); + WORD GetModelessIndex(WORD wIndex, DWORD dwMode) const; +}; + + + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT DetermineFeatureDisplayName(_In_ HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj, + _In_ PCSTR pszKeyword, const PKEYWORDMAP pMapping, + _Outptr_result_maybenull_ PWSTR *ppszDisplayName); +HRESULT DetermineOptionDisplayName(_In_ HANDLE hHeap, CUIHelper &Helper, POEMUIOBJ poemuiobj, + _In_ PCSTR pszFeature, _In_ PCSTR pszOption, + const PKEYWORDMAP pMapping, _Outptr_result_maybenull_ PWSTR *ppszDisplayName); +HRESULT DetermineStickiness(CUIHelper &Helper, POEMUIOBJ poemuiobj, PCSTR pszKeyword, + const PKEYWORDMAP pMapping,PDWORD pdwMode); + +PKEYWORDMAP FindKeywordMapping(PKEYWORDMAP pKeywordMap, WORD wMapSize, PCSTR pszKeyword); +HRESULT GetDisplayNameFromMapping(_In_ HANDLE hHeap, PKEYWORDMAP pMapping, _Outptr_result_maybenull_ PWSTR *ppszDisplayName); + +BOOL IsFeatureOptitem(POPTITEM pOptItem); +HRESULT SaveFeatureOptItems(_In_ HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj, + HWND hWnd, POPTITEM pOptItem, WORD wItems); +HRESULT GetWhyConstrained(_In_ HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj, + _In_ PCSTR pszFeature, _In_ PCSTR pszOption, _Inout_ PSTR *ppmszReason, + _Inout_ PDWORD pdwSize); +HRESULT GetChangedFeatureOptions(_In_ HANDLE hHeap, POPTITEM pOptItem, WORD wItems, + _Outptr_result_maybenull_ PSTR *ppmszPairs, _Out_ PWORD pdwPairs, _Out_ PDWORD pdwSize); +PSTR GetOptionKeywordFromOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem); +PWSTR GetOptionDisplayNameFromOptItem(_In_ HANDLE hHeap, POPTITEM pOptItem); +HRESULT RefreshOptItemSelection(CUIHelper *pHelper, POEMUIOBJ poemuiobj, POPTITEM pOptItems, + WORD wItems); +HRESULT GetFirstConflictingFeature(_In_ HANDLE hHeap, CUIHelper *pHelper, POEMUIOBJ poemuiobj, + POPTITEM pOptItem, WORD wItems, PCONFLICT pConflict); + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.cpp new file mode 100644 index 00000000..3e1a2da5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.cpp @@ -0,0 +1,457 @@ +// 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. +// +// Copyright 2001 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Helper.cpp +// +// +// PURPOSE: Implementation of wrapper class for Driver UI Helper interface. +// + +#include "precomp.h" +#include "Helper.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal Macros +//////////////////////////////////////////////////////// + + +// Macros for simplifying calling the Driver UI Helper interfaces correctly. + +#define CALL_HELPER(MethodName, args) \ + if (IsEqualGUID(&m_iidUIHelper, &IID_IPrintOemDriverUI)) \ + { \ + return static_cast(m_pUIHelper)->MethodName args; \ + } \ + else if (IsEqualGUID(&m_iidUIHelper, &IID_IPrintCoreUI2)) \ + { \ + return static_cast(m_pUIHelper)->MethodName args; \ + } \ + return E_NOINTERFACE; + +#define CALL_HELPER2(MethodName, args) \ + if (IsEqualGUID(&m_iidUIHelper, &IID_IPrintCoreUI2)) \ + { \ + return static_cast(m_pUIHelper)->MethodName args; \ + } \ + return E_NOINTERFACE; + + +///////////////////////////////////////////////////////////// +// +// CUIHelper Class Methods +// + +// +// Private Methods +// + +// Clears or initializes data members. +void CUIHelper::Clear() +{ + // Clear stored interface + m_pUIHelper = NULL; + m_iidUIHelper = GUID_NULL; +} + + +// +// Public Methods +// + +// Default contructor. +CUIHelper::CUIHelper() +{ + // Initialize the data members. + Clear(); +} + +// Constructor with assignment. +CUIHelper::CUIHelper(const IID &HelperIID, PVOID pHelper) +{ + // Assign the interface. + Assign(HelperIID, pHelper); +} + +// Destructor +CUIHelper::~CUIHelper() +{ + // Release the interface reference. + Release(); +} + +// Stores helper interface in helper entry structure. +void CUIHelper::Assign(const IID &HelperIID, PVOID pHelper) +{ + // If we already have a helper interface, release it. + if(IsValid()) + { + Release(); + } + + // Store helper interface and IID for it. + m_pUIHelper = static_cast(pHelper); + m_iidUIHelper = HelperIID; +} + +// Releases the helper interface and +// our removes the references to it. +ULONG CUIHelper::Release() +{ + ULONG ulRef = 0; + + + if(IsValid()) + { + // Release the interface. + // Since IPrintCoreUI2 inherits from IPrintOemDriverUI, + // it is safe to cast both types of helper interfaces + // to IPrintOemDriverUI for purposes of calling a + // method implemented in IPrintOemDriverUI. + // NOTE: can't cast to IUnknown since it just has pure virtual + // calls for AddRef and Release. + ulRef = static_cast(m_pUIHelper)->Release(); + + // Clear the data members. + Clear(); + } + + return ulRef; +} + + +// +// IPrintOemDriverUI methods +// + +// +// Helper function to get driver settings. This function is only supported +// for UI plugins that do not fully replace core driver's standard UI. +// + +HRESULT __stdcall CUIHelper::DrvGetDriverSetting( + PVOID pci, + PCSTR Feature, + PVOID pOutput, + DWORD cbSize, + PDWORD pcbNeeded, + PDWORD pdwOptionsReturned + ) +{ + CALL_HELPER(DrvGetDriverSetting, + (pci, + Feature, + pOutput, + cbSize, + pcbNeeded, + pdwOptionsReturned + ) + ); +} + +// +// Helper function to allow OEM plugins upgrade private registry +// settings. This function is supported for any UI plugins and should be +// called only by OEM's UpgradePrinter. +// + +HRESULT __stdcall CUIHelper::DrvUpgradeRegistrySetting( + HANDLE hPrinter, + PCSTR pFeature, + PCSTR pOption + ) +{ + CALL_HELPER(DrvUpgradeRegistrySetting, + (hPrinter, + pFeature, + pOption + ) + ); +} + +// +// Helper function to allow OEM plugins to update the driver UI settings. +// This function is only supported for UI plugins that do not fully replace +// core driver's standard UI. It should be called only when the UI is present. +// + +HRESULT __stdcall CUIHelper::DrvUpdateUISetting( + PVOID pci, + PVOID pOptItem, + DWORD dwPreviousSelection, + DWORD dwMode + ) +{ + CALL_HELPER(DrvUpdateUISetting, + (pci, + pOptItem, + dwPreviousSelection, + dwMode + ) + ); +} + +// +// IPrintCoreUI2 new methods +// + +// +// Following four helper functions are only supported for UI plugins that fully +// replace core driver's standard UI. They should only be called by the UI plugin's +// DocumentPropertySheets, DevicePropertySheets and their property sheet callback +// functions. +// +// Helper function to retrieve driver's current setting as a list of +// feature/option keyword pairs. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::GetOptions( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pmszFeaturesRequested, + DWORD cbIn, + PSTR pmszFeatureOptionBuf, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(GetOptions, + (poemuiobj, + dwFlags, + pmszFeaturesRequested, + cbIn, + pmszFeatureOptionBuf, + cbSize, + pcbNeeded + ) + ); +} + +// +// Helper function to change driver's setting using a list of feature/option +// keyword pairs. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::SetOptions( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pmszFeatureOptionBuf, + DWORD cbIn, + PDWORD pdwResult) +{ + CALL_HELPER2(SetOptions, + (poemuiobj, + dwFlags, + pmszFeatureOptionBuf, + cbIn, + pdwResult + ) + ); +} + +// +// Helper function to retrieve the option(s) of a given feature that are +// constrained in driver's current setting. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::EnumConstrainedOptions( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pszFeatureKeyword, + PSTR pmszConstrainedOptionList, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(EnumConstrainedOptions, + (poemuiobj, + dwFlags, + pszFeatureKeyword, + pmszConstrainedOptionList, + cbSize, + pcbNeeded + ) + ); +} + +// +// Helper function to retrieve a list of feature/option keyword pairs from +// driver's current setting that conflict with the given feature/option pair. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::WhyConstrained( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pszFeatureKeyword, + PCSTR pszOptionKeyword, + PSTR pmszReasonList, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(WhyConstrained, + (poemuiobj, + dwFlags, + pszFeatureKeyword, + pszOptionKeyword, + pmszReasonList, + cbSize, + pcbNeeded + ) + ); +} + +// +// Following five helper functions are supported for any UI plugins. +// +// Helper function to retrieve global attribute. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::GetGlobalAttribute( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pszAttribute, + PDWORD pdwDataType, + PBYTE pbData, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(GetGlobalAttribute, + (poemuiobj, + dwFlags, + pszAttribute, + pdwDataType, + pbData, + cbSize, + pcbNeeded + ) + ); +} + + +// +// Helper function to retrieve attribute of a given feature. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::GetFeatureAttribute( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pszFeatureKeyword, + PCSTR pszAttribute, + PDWORD pdwDataType, + PBYTE pbData, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(GetFeatureAttribute, + (poemuiobj, + dwFlags, + pszFeatureKeyword, + pszAttribute, + pdwDataType, + pbData, + cbSize, + pcbNeeded + ) + ); +} + +// +// Helper function to retrieve attribute of a given feature/option selection. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::GetOptionAttribute( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pszFeatureKeyword, + PCSTR pszOptionKeyword, + PCSTR pszAttribute, + PDWORD pdwDataType, + PBYTE pbData, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(GetOptionAttribute, + (poemuiobj, + dwFlags, + pszFeatureKeyword, + pszOptionKeyword, + pszAttribute, + pdwDataType, + pbData, + cbSize, + pcbNeeded + ) + ); +} + +// +// Helper function to retrieve the list of feature keyword. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::EnumFeatures( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PSTR pmszFeatureList, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(EnumFeatures, + (poemuiobj, + dwFlags, + pmszFeatureList, + cbSize, + pcbNeeded + ) + ); +} + +// +// Helper function to retrieve the list of options keyword of a given feature. +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::EnumOptions( + POEMUIOBJ poemuiobj, + DWORD dwFlags, + PCSTR pszFeatureKeyword, + PSTR pmszOptionList, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(EnumOptions, + (poemuiobj, + dwFlags, + pszFeatureKeyword, + pmszOptionList, + cbSize, + pcbNeeded + ) + ); +} + +// +// Helper function to query system simulation support +// +_Use_decl_annotations_ +HRESULT __stdcall CUIHelper::QuerySimulationSupport( + HANDLE hPrinter, + DWORD dwLevel, + PBYTE pCaps, + DWORD cbSize, + PDWORD pcbNeeded) +{ + CALL_HELPER2(QuerySimulationSupport, + (hPrinter, + dwLevel, + pCaps, + cbSize, + pcbNeeded + ) + ); +} + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.h new file mode 100644 index 00000000..31819dcc --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/Helper.h @@ -0,0 +1,214 @@ +// 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. +// +// Copyright 2001 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Helper.h +// +#pragma once + +class CUIHelper +{ + private: + IUnknown *m_pUIHelper; // pointer to Driver UI's Helper interface + IID m_iidUIHelper; // Driver UI's Helper interface IID + + public: + CUIHelper(); + CUIHelper(const IID &HelperIID, PVOID pHelper); + virtual ~CUIHelper(); + + inline BOOL IsValid() {return NULL != m_pUIHelper;} + + void Assign(const IID &HelperIID, PVOID pHelper); + ULONG Release(); + + // + // IPrintOemDriverUI methods + // + + // + // Helper function to get driver settings. This function is only supported + // for UI plugins that do not fully replace core driver's standard UI. + // + + STDMETHOD(DrvGetDriverSetting) (THIS_ + PVOID pci, + PCSTR Feature, + PVOID pOutput, + DWORD cbSize, + PDWORD pcbNeeded, + PDWORD pdwOptionsReturned + ); + + // + // Helper function to allow OEM plugins upgrade private registry + // settings. This function is supported for any UI plugins and should be + // called only by OEM's UpgradePrinter. + // + + STDMETHOD(DrvUpgradeRegistrySetting) (THIS_ + HANDLE hPrinter, + PCSTR pFeature, + PCSTR pOption + ); + + // + // Helper function to allow OEM plugins to update the driver UI settings. + // This function is only supported for UI plugins that do not fully replace + // core driver's standard UI. It should be called only when the UI is present. + // + + STDMETHOD(DrvUpdateUISetting) (THIS_ + PVOID pci, + PVOID pOptItem, + DWORD dwPreviousSelection, + DWORD dwMode + ); + + // + // IPrintCoreUI2 new methods + // + + // + // Following four helper functions are only supported for UI plugins that fully + // replace core driver's standard UI. They should only be called by the UI plugin's + // DocumentPropertySheets, DevicePropertySheets and their property sheet callback + // functions. + // + // Helper function to retrieve driver's current setting as a list of + // feature/option keyword pairs. + // + + STDMETHOD(GetOptions) (THIS_ + POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _In_reads_bytes_opt_(cbIn) PCSTR pmszFeaturesRequested, + DWORD cbIn, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PSTR pmszFeatureOptionBuf, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + // + // Helper function to change driver's setting using a list of feature/option + // keyword pairs. + // + + STDMETHOD(SetOptions) (THIS_ + POEMUIOBJ poemuiobj, + DWORD dwFlags, + _In_reads_bytes_(cbIn) PCSTR pmszFeatureOptionBuf, + DWORD cbIn, + _Out_ PDWORD pdwResult); + + // + // Helper function to retrieve the option(s) of a given feature that are + // constrained in driver's current setting. + // + + STDMETHOD(EnumConstrainedOptions) (THIS_ + _In_ POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _In_ PCSTR pszFeatureKeyword, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PSTR pmszConstrainedOptionList, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + + // + // Helper function to retrieve a list of feature/option keyword pairs from + // driver's current setting that conflict with the given feature/option pair. + // + + STDMETHOD(WhyConstrained) (THIS_ + POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _In_ PCSTR pszFeatureKeyword, + _In_ PCSTR pszOptionKeyword, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PSTR pmszReasonList, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + // + // Following five helper functions are supported for any UI plugins. + // + // Helper function to retrieve global attribute. + // + + STDMETHOD(GetGlobalAttribute) (THIS_ + POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _In_opt_ PCSTR pszAttribute, + _Out_ PDWORD pdwDataType, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PBYTE pbData, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + // + // Helper function to retrieve attribute of a given feature. + // + + STDMETHOD(GetFeatureAttribute) (THIS_ + POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _In_ PCSTR pszFeatureKeyword, + _In_opt_ PCSTR pszAttribute, + _Out_ PDWORD pdwDataType, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PBYTE pbData, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + // + // Helper function to retrieve attribute of a given feature/option selection. + // + + STDMETHOD(GetOptionAttribute) (THIS_ + POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _In_ PCSTR pszFeatureKeyword, + _In_ PCSTR pszOptionKeyword, + _In_opt_ PCSTR pszAttribute, + _Out_ PDWORD pdwDataType, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PBYTE pbData, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + // + // Helper function to retrieve the list of feature keyword. + // + + STDMETHOD(EnumFeatures) (THIS_ + POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PSTR pmszFeatureList, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + // + // Helper function to retrieve the list of options keyword of a given feature. + // + + STDMETHOD(EnumOptions) (THIS_ + POEMUIOBJ poemuiobj, + _Reserved_ DWORD dwFlags, + _In_ PCSTR pszFeatureKeyword, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PSTR pmszOptionList, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + // + // Helper function to query system simulation support + // + + STDMETHOD(QuerySimulationSupport) (THIS_ + HANDLE hPrinter, + DWORD dwLevel, + _Out_writes_bytes_to_opt_(cbSize, *pcbNeeded) PBYTE pCaps, + DWORD cbSize, + _Out_ _On_failure_(_When_(return == E_OUTOFMEMORY, _Post_valid_)) PDWORD pcbNeeded); + + private: + void Clear(); +}; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/OEMUI.rc b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/OEMUI.rc new file mode 100644 index 00000000..d68603e1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/OEMUI.rc @@ -0,0 +1,260 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "PS UI Replacement Sample" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "PSUIREP" + VALUE "LegalCopyright", "Copyright © 1998 - 2003 Microsoft Corp." + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "PSUIREP.dll" + VALUE "ProductName", "Microsoft PS UI Replacement Sample" + VALUE "ProductVersion", "1.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DEVICE_PROPPAGE DIALOG 0, 0, 179, 113 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Device Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Added Page",IDC_STATIC,55,14,68,11 + PUSHBUTTON "Calibrate",IDC_CALIBRATE,61,34,50,14 +END + +IDD_DOC_PROPPAGE DIALOG 0, 0, 210, 154 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Document Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Document Property Page",IDC_STATIC,60,73,108,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DEVICE_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 172 + TOPMARGIN, 8 + BOTTOMMARGIN, 106 + END + + IDD_DOC_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 203 + TOPMARGIN, 7 + BOTTOMMARGIN, 147 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_SECTION "OEM UI Added Item" + IDS_CALIBRATED "Printer has been calibrated." + IDS_NAME "OEM UI Customization DLL" + IDS_DEVICE_SETTINGS_NAME "Device Settings" + IDS_CONSTRAINT_CONFLICT "Ther are one or more conflicting settings.\r\nOne of the conflicting is:\r\n\t%1: %2\r\n\t%3: %4\r\n\r\nDo you want driver to automatically resolve conflict?" + IDS_DEV_SECTION "Device Settings OEM UI Added Item" + IDS_ADV_SECTION "Advanced OEM UI Added Item" +END + +STRINGTABLE +BEGIN + IDS_POSTSCRIPT_VM "Available PostScript Memory" + IDS_KBYTES "KB" + IDS_SECONDS "seconds" + IDS_PSTIMEOUTS "PostScript Timeout Values" + IDS_JOBTIMEOUT "Job Timeout" + IDS_WAITTIMEOUT "Wait Timeout" + IDS_PRINTER_DEFAULT "Use Current Setting in the Printer" + IDS_INSTALLABLE_OPTIONS "Installable Options" + IDS_DOWNLOAD_AS_SOFTFONT "" + IDS_USE_DEVFONTS "Use Device Fonts?" + IDS_FONTSUB_OPTION "Font Substitution" + IDS_FONTSUB_DEFAULT "Normal" + IDS_FONTSUB_SLOW "Slow but more accurate" + IDS_FONTSUB_TABLE "Font Substitution Table" + IDS_DEFAULT_TRAY " / Default tray" + IDS_DRAW_ONLY_FROM_SELECTED "Draw selected form only from this tray" +END + +STRINGTABLE +BEGIN + IDS_RESTORE_DEFAULTS "&Restore Defaults" + IDS_PRINTER_FEATURES "Printer Features" + IDS_METAFILE_SPOOLING "Advanced Printing Features" + IDS_ENABLED "&Enabled" + IDS_DISABLED "&Disabled" + IDS_PSOPTIONS "PostScript Options" + IDS_MIRROR "Mirrored Output" + IDS_NEGATIVE_PRINT "Negative Output" + IDS_PAGEINDEP "Page Independence" + IDS_COMPRESSBMP "Compress bitmaps" + IDS_CTRLD_BEFORE "Send CTRL-D Before Each Job" + IDS_CTRLD_AFTER "Send CTRL-D After Each Job" + IDS_JOB_CONTROL "Generate Job Control Code" + IDS_TEXT_ASGRX "Print Optimizations" +END + +STRINGTABLE +BEGIN + IDS_TRUE_GRAY_TEXT "Convert Gray Text to PostScript Gray" + IDS_TRUE_GRAY_GRAPH "Convert Gray Graphics to PostScript Gray" + IDS_ADD_EURO "Add Euro Currency Symbol to PostScript Fonts" +END + +STRINGTABLE +BEGIN + IDS_PAGE_PROTECTION "Page Protection" + IDS_CANCEL_CONFLICT "Restore my previous settings" + IDS_IGNORE_CONFLICT "Keep this setting, and I will change it later" + IDS_RESOLVE_CONFLICT "Resolve this conflict for me automatically" + IDS_DRIVERUI_COLORMODE "Color Mode Option" + IDS_ENVELOPE "Envelope" + IDS_ENV_PREFIX "Env" + IDS_PSPROTOCOL "Output Protocol" + IDS_PSPROTOCOL_ASCII "ASCII" + IDS_PSPROTOCOL_BCP "BCP" + IDS_PSPROTOCOL_TBCP "TBCP" + IDS_PSPROTOCOL_BINARY "Binary" + IDS_TRAY_FORMSOURCE "Automatically Select" + IDS_OEMERR_DLGTITLE "OEM Customization Module Failed" + IDS_OEMERR_OPTITEM "Couldn't add custom items from OEM customization module '%s'.\n\nPlease contact its vendor for support." +END + +STRINGTABLE +BEGIN + IDS_OEMERR_PROPSHEET "Couldn't add custom property sheet pages from OEM customization module '%s'.\n\nPlease contact its vendor for support." + IDS_CANCEL_CONFLICT_FINAL "I will resolve the conflict for myself" + IDS_PSERROR_HANDLER "Send PostScript Error Handler" + IDS_PSMINOUTLINE "Minimum Font Size to Download as Outline" + IDS_PSMAXBITMAP "Maximum Font Size to Download as Bitmap" + IDS_PIXELS "pixel(s)" + IDS_PSOUTPUT_OPTION "PostScript Output Option" + IDS_PSOPT_SPEED "Optimize for Speed" + IDS_PSOPT_PORTABILITY "Optimize for Portability" + IDS_PSOPT_EPS "Encapsulated PostScript (EPS)" + IDS_PSOPT_ARCHIVE "Archive Format" + IDS_PSTT_DLFORMAT "TrueType Font Download Option" + IDS_TTDL_DEFAULT "Automatic" + IDS_TTDL_TYPE1 "Outline" + IDS_TTDL_TYPE3 "Bitmap" + IDS_TTDL_TYPE42 "Native TrueType" +END + +STRINGTABLE +BEGIN + IDS_PSLEVEL "PostScript Language Level" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj new file mode 100644 index 00000000..a8816083 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj @@ -0,0 +1,1066 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {5D63CD51-110C-41B7-B8B0-6AB27398690B} + $(MSBuildProjectName) + Win10 Debug + Win32 + {50E3486C-DFB5-4447-A055-55B51DE6A08C} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + PSUIREP + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + PSUIREP.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj.Filters new file mode 100644 index 00000000..a7adcd57 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/PSUIREP.vcxproj.Filters @@ -0,0 +1,397 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {34758E7D-B1F9-45D1-BF4C-84952A011FD8} + + + h;hpp;hxx;hm;inl;inc;xsd + {5FBB97F9-5E07-46FA-9D57-352EF01D247C} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {B3D9DA9C-3DC0-474A-8E98-121243DA58B3} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + Header Files + + + + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.cpp new file mode 100644 index 00000000..01690f07 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.cpp @@ -0,0 +1,315 @@ +// 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. +// +// Copyright 2001 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: StringUtils.cpp +// +// PURPOSE: Implementation wrapper class for WinXP PS Driver Features and Options. +// + + +#include "precomp.h" +#include "debug.h" +#include "devmode.h" +#include "globals.h" +#include "helper.h" +#include "features.h" +#include "oemui.h" +#include "stringutils.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// Create a list of pointers to the strings +// in a multi-sz. +_Use_decl_annotations_ +HRESULT MakeStrPtrList(HANDLE hHeap, PCSTR pmszMultiSz, PCSTR **pppszList, PWORD pwCount) +{ + PCSTR *ppszList = NULL; + HRESULT hrResult = S_OK; + + + // Validate parameters + if( (NULL == hHeap) + || + (NULL == pmszMultiSz) + || + (NULL == pppszList) + || + (NULL == pwCount) + ) + { + return E_INVALIDARG; + } + + // Get the count of strings in the multi-sz. + *pwCount = mstrcount(pmszMultiSz); + if(0 == *pwCount) + { + WARNING(DLLTEXT("MakeStrPtrList() pmszMultiSz contains no strings.\r\n")); + + *pppszList = NULL; + + goto Exit; + } + + // Allocate pointer list. + *pppszList = (PCSTR *) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, (*pwCount) * sizeof(PCSTR)); + if(NULL == *pppszList) + { + ERR(ERRORTEXT("MakeStrPtrList() failed to allote array of PCSTR.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + ppszList = *pppszList; + + // Walk multi-sz mapping string pointers. + for(WORD wIndex = 0; wIndex < *pwCount; ++wIndex) + { + ppszList[wIndex] = pmszMultiSz; + pmszMultiSz += strlen(pmszMultiSz) + 1; + } + + +Exit: + + return hrResult; +} + + +// Determine how many strings are in the multi-sz. +WORD mstrcount(PCSTR pmszMultiSz) +{ + WORD wCount = 0; + + + // NULL string pointers have no strings. + if(NULL == pmszMultiSz) + { + return 0; + } + + // Walk list of strings counting them. + while(pmszMultiSz[0] != '\0') + { + ++wCount; + pmszMultiSz += strlen(pmszMultiSz) + 1; + } + + return wCount; +} + +// Allocates and converts ANSI string to Unicode. +PWSTR MakeUnicodeString(HANDLE hHeap, PCSTR pszAnsi) +{ + int nSize = 0; + PWSTR pszUnicode = NULL; + + + // Validate parameters + if( (NULL == hHeap) + || + (NULL == pszAnsi) + ) + { + return NULL; + } + + // Get the size needed for UNICODE string. + nSize = MultiByteToWideChar(CP_ACP, 0, pszAnsi, -1, NULL, 0); + if(0 != nSize) + { + // Allocate unicode string. + pszUnicode = (PWSTR) HeapAlloc(hHeap, 0, nSize * sizeof(WCHAR)); + if(NULL != pszUnicode) + { + // Convert ANSI to Unicode + nSize = MultiByteToWideChar(CP_ACP, 0, pszAnsi, -1, pszUnicode, nSize); + if(0 == nSize) + { + // INVARIANT: failed to convert. + + // free buffer and return NULL. + HeapFree(hHeap, 0, pszUnicode); + pszUnicode = NULL; + } + } + } + + return pszUnicode; +} + +// Allocates and copies source string. +PWSTR MakeStringCopy(HANDLE hHeap, PCWSTR pszSource) +{ + PWSTR pszCopy = NULL; + DWORD dwSize; + + + // Validate parameters + if( (NULL == hHeap) + || + (NULL == pszSource) + ) + { + return NULL; + } + + // Allocate memory for string duplication, and duplicate the string. + dwSize = (DWORD)(wcslen(pszSource) + 1) * sizeof(WCHAR); + pszCopy = (PWSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize); + if(NULL != pszCopy) + { + HRESULT hResult; + + + hResult = StringCbCopyW(pszCopy, dwSize, pszSource); + if(FAILED(hResult)) + { + HeapFree(hHeap, 0, pszCopy); + pszCopy = NULL; + SetLastError(hResult); + } + } + + return pszCopy; +} + +// Allocates and copies source string. +PSTR MakeStringCopy(HANDLE hHeap, PCSTR pszSource) +{ + PSTR pszCopy = NULL; + size_t dwSize; + + + // Validate parameters + if( (NULL == hHeap) + || + (NULL == pszSource) + ) + { + return NULL; + } + + // Allocate memory for string duplication, and duplicate the string. + dwSize = (strlen(pszSource) + 1) * sizeof(CHAR); + pszCopy = (PSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize); + if(NULL != pszCopy) + { + HRESULT hResult; + + hResult = StringCbCopyA(pszCopy, dwSize, pszSource); + if(FAILED(hResult)) + { + HeapFree(hHeap, 0, pszCopy); + pszCopy = NULL; + SetLastError(hResult); + } + } + + return pszCopy; +} + +// Frees list of strings. +// NOTE: don't use this for string list made with MakeStrPtrList(), since +// the strings pointed to be list made with MakeStrPtrList() will +// be freed when the multi-sz is freed. +void FreeStringList(HANDLE hHeap, _In_reads_(wCount) PWSTR *ppszList, WORD wCount) +{ + // Validate parameters. + if( (NULL == hHeap) + || + (NULL == ppszList) + ) + { + return; + } + + // Free each of the strings in the list. + for(WORD wIndex = 0; wIndex < wCount; ++wIndex) + { + if(NULL != ppszList[wIndex]) HeapFree(hHeap, 0, ppszList[wIndex]); + } + + // Free list. + HeapFree(hHeap, 0, ppszList); +} + + +// Retrieves pointer to a String resource. +HRESULT GetStringResource(HANDLE hHeap, HMODULE hModule, UINT uResource, _Outptr_result_maybenull_ PWSTR *ppszString) +{ + int nResult; + DWORD dwSize = MAX_PATH; + PWSTR pszString = NULL; + HRESULT hrResult = S_OK; + + + VERBOSE(DLLTEXT("GetStringResource(%#x, %#x, %d) entered.\r\n"), hHeap, hModule, uResource); + + // Validate parameters. + if( (NULL == hHeap) + || + (NULL == ppszString) + ) + { + return E_INVALIDARG; + } + + // Allocate buffer for string resource from heap; let the driver clean it up. + pszString = (PWSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(WCHAR)); + if(NULL == pszString) + { + ERR(ERRORTEXT("GetStringResource() failed to allocate string buffer!\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Load string resource; resize after loading so as not to waste memory. + nResult = LoadString(hModule, uResource, pszString, dwSize); + if(nResult > 0) + { + PWSTR pszTemp; + + + VERBOSE(DLLTEXT("LoadString() returned %d!\r\n"), nResult); + VERBOSE(DLLTEXT("String load was \"%s\".\r\n"), pszString); + + pszTemp = (PWSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszString, (nResult + 1) * sizeof(WCHAR)); + if(NULL != pszTemp) + { + pszString = pszTemp; + } + else + { + WARNING(DLLTEXT("GetStringResource() HeapReAlloc() of string retrieved failed! (Last Error was %d)\r\n"), GetLastError()); + } + } + else + { + DWORD dwError = GetLastError(); + + + ERR(ERRORTEXT("LoadString() returned %d! (Last Error was %d)\r\n"), nResult, GetLastError()); + ERR(ERRORTEXT("GetStringResource() failed to load string resource %d!\r\n"), uResource); + + HeapFree(hHeap, 0, pszString); + pszString = NULL; + hrResult = HRESULT_FROM_WIN32(dwError); + } + + +Exit: + + // Save string pointer to caller. + // NOTE: string pointer will be NULL on failure. + *ppszString = pszString; + + return hrResult; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.h new file mode 100644 index 00000000..35de69f2 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/StringUtils.h @@ -0,0 +1,23 @@ +// 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. +// +// Copyright 2001 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: StringUtils.h +// +// PURPOSE: Header file for string utility routines. +// +#pragma once + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// +_Success_(return >= 0 && *pwCount > 0) HRESULT MakeStrPtrList(HANDLE hHeap, PCSTR pmszMultiSz, _Outptr_result_buffer_(*pwCount) PCSTR **pppszList, _Out_ PWORD pwCount); +WORD mstrcount(PCSTR pmszMultiSz); +PWSTR MakeUnicodeString(HANDLE hHeap, PCSTR pszAnsi); +PWSTR MakeStringCopy(HANDLE hHeap, PCWSTR pszSource); +PSTR MakeStringCopy(HANDLE hHeap, PCSTR pszSource); +void FreeStringList(HANDLE hHeap, _In_reads_(wCount) PWSTR *ppszList, WORD wCount); +HRESULT GetStringResource(HANDLE hHeap, HMODULE hModule, UINT uResource, _Outptr_result_maybenull_ PWSTR *ppszString); diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.cpp new file mode 100644 index 00000000..f7a3d842 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.cpp @@ -0,0 +1,405 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.cpp +// +// PURPOSE: Debug functions. +// +// + +#include "precomp.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL DEFINES +//////////////////////////////////////////////////////// + +#define DEBUG_BUFFER_SIZE 1024 +#define PATH_SEPARATOR '\\' +#define MAX_LOOP 10 + +// Determine what level of debugging messages to eject. +#ifdef VERBOSE_MSG + #define DEBUG_LEVEL DBG_VERBOSE +#elif TERSE_MSG + #define DEBUG_LEVEL DBG_TERSE +#elif WARNING_MSG + #define DEBUG_LEVEL DBG_WARNING +#elif ERROR_MSG + #define DEBUG_LEVEL DBG_ERROR +#elif RIP_MSG + #define DEBUG_LEVEL DBG_RIP +#elif NO_DBG_MSG + #define DEBUG_LEVEL DBG_NONE +#else + #define DEBUG_LEVEL DBG_WARNING +#endif + + + +//////////////////////////////////////////////////////// +// EXTERNAL GLOBALS +//////////////////////////////////////////////////////// + +INT giDebugLevel = DEBUG_LEVEL; + + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static BOOL DebugMessageV(LPCSTR lpszMessage, va_list arglist); +static BOOL DebugMessageV(DWORD dwSize, LPCWSTR lpszMessage, va_list arglist); + + + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessageV +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// dwSize Size of temp buffer to hold formated string. +// +// lpszMessage Format string. +// +// arglist Variable argument list.. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +static BOOL DebugMessageV(LPCSTR lpszMessage, va_list arglist) +{ + DWORD dwSize = DEBUG_BUFFER_SIZE; + DWORD dwLoop = 0; + LPSTR lpszMsgBuf = NULL; + HRESULT hr; + + + // Parameter checking. + if( (NULL == lpszMessage) + || + (0 == dwSize) + ) + { + return FALSE; + } + + do + { + // Allocate memory for message buffer. + if(NULL != lpszMsgBuf) + { + delete[] lpszMsgBuf; + dwSize *= 2; + } + lpszMsgBuf = new CHAR[dwSize + 1]; + if(NULL == lpszMsgBuf) + { + return FALSE; + } + + hr = StringCbVPrintfA(lpszMsgBuf, (dwSize + 1) * sizeof(CHAR), lpszMessage, arglist); + + // Pass the variable parameters to wvsprintf to be formated. + } while (FAILED(hr) && (STRSAFE_E_INSUFFICIENT_BUFFER == hr) && (++dwLoop < MAX_LOOP) ); + + // Dump string to Debug output. + OutputDebugStringA(lpszMsgBuf); + + // Cleanup. + delete[] lpszMsgBuf; + + return SUCCEEDED(hr); +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessageV +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// dwSize Size of temp buffer to hold formated string. +// +// lpszMessage Format string. +// +// arglist Variable argument list.. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +static BOOL DebugMessageV(DWORD dwSize, LPCWSTR lpszMessage, va_list arglist) +{ + LPWSTR lpszMsgBuf; + HRESULT hResult; + + + // Parameter checking. + if( (NULL == lpszMessage) + || + (0 == dwSize) + ) + { + return FALSE; + } + + // Allocate memory for message buffer. + lpszMsgBuf = new WCHAR[dwSize + 1]; + if(NULL == lpszMsgBuf) + return FALSE; + + // Pass the variable parameters to wvsprintf to be formated. + hResult = StringCbVPrintfW(lpszMsgBuf, (dwSize + 1) * sizeof(WCHAR), lpszMessage, arglist); + + // Dump string to debug output. + OutputDebugStringW(lpszMsgBuf); + + // Clean up. + delete[] lpszMsgBuf; + + return SUCCEEDED(hResult); +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessage +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// lpszMessage Format string. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCSTR lpszMessage, ...) +{ + BOOL bResult; + va_list VAList; + + + // Pass the variable parameters to DebugMessageV for processing. + va_start(VAList, lpszMessage); + bResult = DebugMessageV(lpszMessage, VAList); + va_end(VAList); + + return bResult; +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessage +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// lpszMessage Format string. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCWSTR lpszMessage, ...) +{ + BOOL bResult; + va_list VAList; + + + // Pass the variable parameters to DebugMessageV to be processed. + va_start(VAList, lpszMessage); + bResult = DebugMessageV(MAX_PATH, lpszMessage, VAList); + va_end(VAList); + + return bResult; +} + +void Dump(PPUBLISHERINFO pPublisherInfo) +{ + VERBOSE(TEXT("pPublisherInfo:\r\n")); + if(NULL == pPublisherInfo) + { + VERBOSE(TEXT("\tpPublisherInfo is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tdwMode = %#x\r\n"), pPublisherInfo->dwMode); + VERBOSE(TEXT("\twMinoutlinePPEM = %d\r\n"), pPublisherInfo->wMinoutlinePPEM); + VERBOSE(TEXT("\twMaxbitmapPPEM = %d\r\n"), pPublisherInfo->wMaxbitmapPPEM); +} + +void Dump(POEMDMPARAM pOemDMParam) +{ + VERBOSE(TEXT("pOemDMParam:\r\n")); + if(NULL == pOemDMParam) + { + VERBOSE(TEXT("\tpOemDMParam is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pOemDMParam->cbSize); + VERBOSE(TEXT("\tpdriverobj = %#x\r\n"), pOemDMParam->pdriverobj); + VERBOSE(TEXT("\thPrinter = %#x\r\n"), pOemDMParam->hPrinter); + VERBOSE(TEXT("\thModule = %#x\r\n"), pOemDMParam->hModule); + VERBOSE(TEXT("\tpPublicDMIn = %#x\r\n"), pOemDMParam->pPublicDMIn); + VERBOSE(TEXT("\tpPublicDMOut = %#x\r\n"), pOemDMParam->pPublicDMOut); + VERBOSE(TEXT("\tpOEMDMIn = %#x\r\n"), pOemDMParam->pOEMDMIn); + VERBOSE(TEXT("\tpOEMDMOut = %#x\r\n"), pOemDMParam->pOEMDMOut); + VERBOSE(TEXT("\tcbBufSize = %d\r\n"), pOemDMParam->cbBufSize); +} + +void Dump(PPROPSHEETUI_INFO pPSUIInfo) +{ + VERBOSE(TEXT("pPSUIInfo:\r\n")); + if(NULL == pPSUIInfo) + { + VERBOSE(TEXT("\tpPSUIInfo is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pPSUIInfo->cbSize); + VERBOSE(TEXT("\tVersion = %#x\r\n"), pPSUIInfo->Version); + VERBOSE(TEXT("\tFlags = %#x\r\n"), pPSUIInfo->Flags); + VERBOSE(TEXT("\tReason = %d\r\n"), pPSUIInfo->Reason); + VERBOSE(TEXT("\thComPropSheet = %#x\r\n"), pPSUIInfo->hComPropSheet); + VERBOSE(TEXT("\tpfnComPropSheet = %#x\r\n"), pPSUIInfo->pfnComPropSheet); + VERBOSE(TEXT("\tlParamInit = %#x\r\n"), pPSUIInfo->lParamInit); + VERBOSE(TEXT("\tUserData = %#x\r\n"), pPSUIInfo->UserData); + VERBOSE(TEXT("\tResult = %#x\r\n"), pPSUIInfo->Result); +} + +void Dump(POPTITEM pOptItem) +{ + VERBOSE(TEXT("pOptItem:\r\n")); + if(NULL == pOptItem) + { + VERBOSE(TEXT("\tpOptItem is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pOptItem->cbSize); + VERBOSE(TEXT("\tLevel = %d\r\n"), pOptItem->Level); + VERBOSE(TEXT("\tDlgPageIdx = %d\r\n"), pOptItem->DlgPageIdx); + VERBOSE(TEXT("\tFlags = 0x%x\r\n"), pOptItem->Flags); + VERBOSE(TEXT("\tUserData = 0x%p\r\n"), pOptItem->UserData); + VERBOSE(TEXT("\tpName = %s\r\n"), pOptItem->pName ? pOptItem->pName : TEXT("")); + VERBOSE(TEXT("\tpSel = 0x%p\r\n"), pOptItem->pSel); + VERBOSE(TEXT("\tpExtChkBox = 0x%p\r\n"), pOptItem->pExtChkBox); + VERBOSE(TEXT("\tpExtChkBox = 0x%p\r\n"), pOptItem->pExtChkBox); + VERBOSE(TEXT("\tHelpIndex = 0x%x\r\n"), pOptItem->HelpIndex); + VERBOSE(TEXT("\tDMPubID = 0x%x\r\n"), pOptItem->DMPubID); + VERBOSE(TEXT("\tUserItemID = 0x%x\r\n"), pOptItem->UserItemID); + VERBOSE(TEXT("\twReserved = 0x%x\r\n"), pOptItem->wReserved); + VERBOSE(TEXT("\tpOIExt = 0x%p\r\n"), pOptItem->pOIExt); + + Dump(pOptItem->pOptType); +} + +void Dump(POPTTYPE pOptType) +{ + VERBOSE(TEXT("\tpOptType:\r\n")); + if(NULL == pOptType) + { + VERBOSE(TEXT("\t\tpOptType is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\t\tcbSize = %d\r\n"), pOptType->cbSize); + VERBOSE(TEXT("\t\tType = 0x%x\r\n"), pOptType->Type); + VERBOSE(TEXT("\t\tFlags = 0x%x\r\n"), pOptType->Flags); + VERBOSE(TEXT("\t\tCount = %d\r\n"), pOptType->Count); + VERBOSE(TEXT("\t\tCount = 0x%x\r\n"), pOptType->BegCtrlID); + VERBOSE(TEXT("\t\tStyle = 0x%x\r\n"), pOptType->Style); + + Dump(pOptType->pOptParam, pOptType->Count); +} + +void Dump(POPTPARAM pOptParam, WORD wCount) +{ + if(NULL == pOptParam) + { + VERBOSE(TEXT("\t\tpOptParam is NULL!\r\n")); + return; + } + + for(WORD wIndex = 0; wIndex < wCount; ++wIndex) + { + VERBOSE(TEXT("\t\tpOptParam[wIndex]:\r\n")); + VERBOSE(TEXT("\t\t\tcbSize = %d\r\n"), pOptParam[wIndex].cbSize); + VERBOSE(TEXT("\t\t\tFlags = 0x%x\r\n"), pOptParam[wIndex].Flags); + VERBOSE(TEXT("\t\t\tStyle = 0x%x\r\n"), pOptParam[wIndex].Style); + VERBOSE(TEXT("\t\t\tpData = 0x%p\r\n"), pOptParam[wIndex].pData); + VERBOSE(TEXT("\t\t\tIconID = 0x%p\r\n"), pOptParam[wIndex].IconID); + VERBOSE(TEXT("\t\t\tlParam = 0x%p\r\n"), pOptParam[wIndex].lParam); + } +} + + +PCSTR +StripDirPrefixA( + IN PCSTR pstrFilename + ) + +/*++ + +Routine Description: + + Strip the directory prefix off a filename (ANSI version) + +Arguments: + + pstrFilename - Pointer to filename string + +Return Value: + + Pointer to the last component of a filename (without directory prefix) + +--*/ + +{ + PCSTR pstr; + + pstr = strrchr(pstrFilename, PATH_SEPARATOR); + if (pstr) + return pstr + 1; + + return pstrFilename; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.h new file mode 100644 index 00000000..b4d57b0b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/debug.h @@ -0,0 +1,166 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. +// +// + +#pragma once + +// VC and Build use different debug defines. +// The following makes it so either will +// cause the inclusion of debugging code. +#if !defined(_DEBUG) && defined(DBG) + #define _DEBUG DBG +#elif defined(_DEBUG) && !defined(DBG) + #define DBG _DEBUG +#endif + + + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// + +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// VERBOSE(msg) +// Display a message if the current debug level is <= DBG_VERBOSE. +// +// TERSE(msg) +// Display a message if the current debug level is <= DBG_TERSE. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// ASSERTMSG(cond, msg) +// Verify a condition is true. If not, display a message and +// force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// These macros require extra parantheses for the msg argument +// example, ASSERTMSG(x > 0, ("x is less than 0\n")); +// WARNING(("App passed NULL pointer, ignoring...\n")); +// + +#define DBG_VERBOSE 1 +#define DBG_TERSE 2 +#define DBG_WARNING 3 +#define DBG_ERROR 4 +#define DBG_RIP 5 +#define DBG_NONE 6 + +#if DBG + + #define DebugMsg DebugMessage + + // + // Strip the directory prefix from a filename (ANSI version) + // + + PCSTR + StripDirPrefixA( + IN PCSTR pstrFilename + ); + + extern INT giDebugLevel; + + + #define DBGMSG(level, prefix, msg) { \ + if (giDebugLevel <= (level)) { \ + DebugMsg("%s %s (%d): ", prefix, StripDirPrefixA(__FILE__), __LINE__); \ + DebugMsg(msg); \ + } \ + } + + #define DBGPRINT(level, msg) { \ + if (giDebugLevel <= (level)) { \ + DebugMsg(msg); \ + } \ + } + + #define VERBOSE if(giDebugLevel <= DBG_VERBOSE) DebugMsg + #define TERSE if(giDebugLevel <= DBG_TERSE) DebugMsg + #define WARNING if(giDebugLevel <= DBG_WARNING) DebugMsg + #define ERR if(giDebugLevel <= DBG_ERROR) DebugMsg + + #define ASSERT(cond) { \ + if (! (cond)) { \ + RIP(("\n")); \ + } \ + } + + #define ASSERTMSG(cond, msg) { \ + if (! (cond)) { \ + RIP(msg); \ + } \ + } + + #define RIP(msg) { \ + DBGMSG(DBG_RIP, "RIP", msg); \ + DebugBreak(); \ + } + + +#else // !DBG + + #define DebugMsg NOP_FUNCTION + + #define VERBOSE NOP_FUNCTION + #define TERSE NOP_FUNCTION + #define WARNING NOP_FUNCTION + #define ERR NOP_FUNCTION + + #define ASSERT(cond) + + #define ASSERTMSG(cond, msg) + #define RIP(msg) + #define DBGMSG(level, prefix, msg) + #define DBGPRINT(level, msg) + +#endif + + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCSTR, ...); +BOOL DebugMessage(LPCWSTR, ...); +void Dump(PPUBLISHERINFO pPublisherInfo); +void Dump(POEMDMPARAM pOemDMParam); +void Dump(PPROPSHEETUI_INFO pPSUIInfo); +void Dump(POPTITEM pOptItem); +void Dump(POPTTYPE pOptType); +void Dump(POPTPARAM pOptParam, WORD wCount); + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.cpp new file mode 100644 index 00000000..43da0361 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.cpp @@ -0,0 +1,193 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + +#include "precomp.h" + +#include "debug.h" +#include "globals.h" +#include "devmode.h" +#include "helper.h" +#include "features.h" +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR(ERRORTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); + VERBOSE(DLLTEXT("\tdwMode = %d, pOemDMParam = %#lx.\r\n"), dwMode, pOemDMParam); + + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + case OEMDM_DEFAULT: + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + VERBOSE(DLLTEXT("pOEMDevOut after setting default values:\r\n")); + Dump(pOEMDevOut); + break; + + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut, pOemDMParam->cbBufSize); + break; + + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut, pOemDMParam->cbBufSize); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + Dump(pOemDMParam); + + return S_OK; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut, DWORD dwSize) +{ + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + || + (dwSize < sizeof(OEMDEV)) + ) + { + ERR(ERRORTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n")); + VERBOSE(DLLTEXT("pOEMDevIn:\r\n")); + Dump(pOEMDevIn); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(dwSize, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize))); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + } + + return TRUE; +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data, if not valid. + if(pOEMDevmode->dwDriverData > 100) + { + pOEMDevmode->dwDriverData = 0; + } + + // Set Advanced driver data, if not valid. + if(pOEMDevmode->dwAdvancedData > 100) + { + pOEMDevmode->dwAdvancedData = 0; + } + + return TRUE; +} + + +void Dump(PCOEMDEV pOEMDevmode) +{ + if( (NULL != pOEMDevmode) + && + (pOEMDevmode->dmOEMExtra.dwSize >= sizeof(OEMDEV)) + && + (OEM_SIGNATURE == pOEMDevmode->dmOEMExtra.dwSignature) + ) + { + VERBOSE(TEXT("\tdmOEMExtra.dwSize = %d\r\n"), pOEMDevmode->dmOEMExtra.dwSize); + VERBOSE(TEXT("\tdmOEMExtra.dwSignature = %#x\r\n"), pOEMDevmode->dmOEMExtra.dwSignature); + VERBOSE(TEXT("\tdmOEMExtra.dwVersion = %#x\r\n"), pOEMDevmode->dmOEMExtra.dwVersion); + VERBOSE(TEXT("\tdwDriverData = %#x\r\n"), pOEMDevmode->dwDriverData); + VERBOSE(TEXT("\tdwAdvancedData = %#x\r\n"), pOEMDevmode->dwAdvancedData); + } + else + { + ERR(ERRORTEXT("Dump(POEMDEV) unknown private OEM DEVMODE.\r\n")); + } +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.h new file mode 100644 index 00000000..83202d6a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/devmode.h @@ -0,0 +1,56 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + + + + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +// +//Can add info to the private devmode bellow here. +//Note : +// This structure must be prefixed by OEM_DMEXTRAHEADER +// Your plug-in must implement the IPrintOemUI::DevMode method +// +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + DWORD dwDriverData; + DWORD dwAdvancedData; + + // + //Private DevMode Members + // + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut, DWORD dwSize); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); +void Dump(PCOEMDEV pOEMDevIn); diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/dllentry.cpp new file mode 100644 index 00000000..da0a1885 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/dllentry.cpp @@ -0,0 +1,49 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "debug.h" +#include "globals.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.cpp new file mode 100644 index 00000000..785330cb --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.cpp @@ -0,0 +1,24 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.cpp +// +// PURPOSE: File that contains all the globals. +// + +#include "precomp.h" +#include "globals.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.h new file mode 100644 index 00000000..70d17f1c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/globals.h @@ -0,0 +1,31 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.h +// +// PURPOSE: Lists of globals declared in Globals.cpp. +// +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +// OEM Signature and version. +#define PROP_TITLE L"OEM PS UI Replacement Page" +#define DLLTEXT(s) TEXT("PSUIREP: ") TEXT(s) + +// OEM UI Misc defines. +#define ERRORTEXT(s) TEXT("ERROR ") DLLTEXT(s) + +// Module's Instance handle from DLLEntry of process. +extern HINSTANCE ghInstance; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.cpp new file mode 100644 index 00000000..5ab1bffe --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.cpp @@ -0,0 +1,709 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// PLATFORMS: Windows 2000, Windows XP, Windows Server 2003 +// + +#include "precomp.h" + + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "globals.h" +#include "devmode.h" +#include "stringutils.h" +#include "helper.h" +#include "features.h" +#include "oemui.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// Internal Constants +//////////////////////////////////////////////////////// + +// +// List all of the supported Driver UI Helper interface IIDs from the +// latest to the oldest, that's the order we will query for the +// the Driver UI Helper interface to use. +// + +const IID *Helper_IIDs[] = +{ + &IID_IPrintCoreUI2, + &IID_IPrintOemDriverUI, +}; +const NUM_HELPER_IIDs = (sizeof(Helper_IIDs)/sizeof(Helper_IIDs[0])); + + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0 ; // Count of active components +static long g_cServerLocks = 0 ; // Count of locks + + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI2 body +// +IOemUI2::IOemUI2() +{ + VERBOSE(DLLTEXT("IOemUI2:IOemUI2() default constructor called.\r\n\r\n")); + + // Init ref count to 1 on creation, since AddRef() is implied. + m_cRef = 1; + + // The default for UI Hiding is FALSE, since HideStandardUI method + // will only be called by Driver UIs that support it. + // Older Driver UIs don't know about this method and won't call us. + m_bHidingStandardUI = FALSE; + + // Increment component count. + InterlockedIncrement(&g_cComponents); +} + +IOemUI2::~IOemUI2() +{ + VERBOSE(DLLTEXT("IOemUI2:~IOemUI2() destructor called.\r\n\r\n")); + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); + + // Decrement component count. + InterlockedDecrement(&g_cComponents); +} + +HRESULT __stdcall IOemUI2::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE(DLLTEXT("IOemUI2:QueryInterface entry.\r\n\r\n")); + +#if DBG + TCHAR szIID[80] = {0}; + StringFromGUID2(iid, szIID, _countof(szIID)); // can not fail! +#endif + + // Determine what object to return, if any. + if(iid == IID_IUnknown) + { + *ppv = static_cast(this); + } + else if(iid == IID_IPrintOemUI2) + { + *ppv = static_cast(this); + } + else if(iid == IID_IPrintOemUI) + { + *ppv = static_cast(this); + } + else + { + // Interface not supported. +#if DBG + VERBOSE(DLLTEXT("IOemUI2::QueryInterface %s not supported.\r\n"), szIID); +#endif + + *ppv = NULL ; + return E_NOINTERFACE ; + } + +#if DBG + VERBOSE(DLLTEXT("IOemUI2::QueryInterface returning pointer to %s.\r\n"), szIID); +#endif + + reinterpret_cast(*ppv)->AddRef(); + return S_OK ; +} + +ULONG __stdcall IOemUI2::AddRef() +{ + VERBOSE(DLLTEXT("IOemUI2:AddRef entry.\r\n")); + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemUI2::Release() +{ + VERBOSE(DLLTEXT("IOemUI2:Release entry.\r\n")); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +HRESULT __stdcall IOemUI2::PublishDriverInterface( + IUnknown *pIUnknown) +{ + HRESULT hResult = S_OK; + + + VERBOSE(DLLTEXT("IOemUI2:PublishDriverInterface entry.\r\n")); + + // Core Driver UI shouldn't call us more than once if we were successful. + // Thus, if m_Helper is already valid, we shouldn't be getting called. + ASSERT(!m_Helper.IsValid()); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (!m_Helper.IsValid()) + { + PVOID pHelper = NULL; + + + // Try to get the newest version fo the Helper function + // that Driver UI supports. + hResult = E_FAIL; + for(DWORD dwIndex = 0; !SUCCEEDED(hResult) && (dwIndex < NUM_HELPER_IIDs); ++dwIndex) + { + // Query Driver UI for Helper interface. + hResult = pIUnknown->QueryInterface(*Helper_IIDs[dwIndex], &pHelper); + if(SUCCEEDED(hResult)) + { + // INVARIANT: we got a Helper interface. + + + // Store Helper interface. + m_Helper.Assign(*Helper_IIDs[dwIndex], pHelper); + } + } + } + + return hResult; +} + +HRESULT __stdcall IOemUI2::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IOemUI2::GetInfo(%d) entry.\r\r\n"), dwMode); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + WARNING(DLLTEXT("IOemUI2::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER\r\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("IOemUI2::GetInfo() exit insufficient buffer!\r\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IOemUI2::GetInfo() exit mode not supported.\r\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(DLLTEXT("IOemUI2::GetInfo() exit S_OK, (*pBuffer is %#x).\r\r\n"), *(PDWORD)pBuffer); + return S_OK; +} + +HRESULT __stdcall IOemUI2::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE(DLLTEXT("IOemUI2:DevMode(%d, %#x) entry.\r\n"), dwMode, pOemDMParam); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IOemUI2::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam) +{ + VERBOSE(DLLTEXT("IOemUI2:CommonUIProp entry.\r\n")); + + return hrOEMPropertyPage(dwMode, pOemCUIPParam); +} + + +HRESULT __stdcall IOemUI2::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI2:DocumentPropertySheets entry.\r\n")); + + return hrOEMDocumentPropertySheets(pPSUIInfo, + lParam, + m_Helper, + &m_Features, + m_bHidingStandardUI); +} + +HRESULT __stdcall IOemUI2::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI2:DevicePropertySheets entry.\r\n")); + + return hrOEMDevicePropertySheets(pPSUIInfo, + lParam, + m_Helper, + &m_Features, + m_bHidingStandardUI); +} + +HRESULT __stdcall IOemUI2::DeviceCapabilities( + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult) +{ + VERBOSE(DLLTEXT("IOemUI2:DeviceCapabilities entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI2::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM) +{ + VERBOSE(DLLTEXT("IOemUI2:DevQueryPrintEx entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI2::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo) +{ + VERBOSE(DLLTEXT("IOemUI2:UpgradePrinter entry.\r\n")); + + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI2::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI2:PrinterEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI2::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI2:DriverEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +HRESULT __stdcall IOemUI2::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData) +{ + VERBOSE(DLLTEXT("IOemUI2:QueryColorProfile entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(ulQueryMode); + UNREFERENCED_PARAMETER(pvProfileData); + UNREFERENCED_PARAMETER(pcbProfileData); + UNREFERENCED_PARAMETER(pflProfileData); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI2::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI2:FontInstallerDlgProc entry.\r\n")); + + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI2::UpdateExternalFonts( + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges) +{ + VERBOSE(DLLTEXT("IOemUI2:UpdateExternalFonts entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +// *********** IPrintOEMUI2 FUNCTIONS **************** + +// +// QueryJobAttribtues +// + +HRESULT __stdcall IOemUI2::QueryJobAttributes( + HANDLE hPrinter, + PDEVMODE pDevmode, + DWORD dwLevel, + LPBYTE lpAttributeInfo) +{ + TERSE(DLLTEXT("IOemUI2:QueryJobAttributes entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDevmode); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(lpAttributeInfo); + + return E_NOTIMPL; +} + +// +// Hide Standard UI +// + +HRESULT __stdcall IOemUI2::HideStandardUI( + DWORD dwMode) +{ + HRESULT hrReturn = E_NOTIMPL; + + + TERSE(DLLTEXT("IOemUI2:HideStandardUI entry.\r\n")); + + switch(dwMode) + { + // By returning S_OK for both OEMCUIP_DOCPROP and OEMCUIP_PRNPROP, + // we will hide the Standard UI for both Document Properties, + // and Device Properties. + // To not hide one or both, return E_NOTIMPL instead of S_OK, + case OEMCUIP_DOCPROP: + case OEMCUIP_PRNPROP: + // Flag that we are hiding the Standard UI. + // This is so we can tell easily between Driver UI + // that supports HideStandardUI (such as WinXP PS UI), + // or ones that don't (such as Win2K PS or Unidrv UI). + m_bHidingStandardUI = TRUE; + + hrReturn = S_OK; + break; + } + + return hrReturn; +} + +// +// DocumentEvent +// + +HRESULT __stdcall IOemUI2::DocumentEvent( + HANDLE hPrinter, + HDC hdc, + INT iEsc, + ULONG cbIn, + PVOID pbIn, + ULONG cbOut, + PVOID pbOut, + PINT piResult) +{ + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hdc); + UNREFERENCED_PARAMETER(iEsc); + UNREFERENCED_PARAMETER(cbIn); + UNREFERENCED_PARAMETER(pbIn); + UNREFERENCED_PARAMETER(cbOut); + UNREFERENCED_PARAMETER(pbOut); + UNREFERENCED_PARAMETER(piResult); + + return E_NOTIMPL; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this) ; + } + else + { +#if DBG + TCHAR szOutput[80] = {0}; + StringFromGUID2(iid, szOutput, _countof(szOutput)); // can not fail! + WARNING(DLLTEXT("IOemCF::QueryInterface %s not supported.\r\n"), szOutput); +#endif + + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + //DbgPrint(DLLTEXT("Class factory:\t\tCreate component.")) ; + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION ; + } + + // Create component. + IOemUI2* pOemCB = new IOemUI2 ; + if (pOemCB == NULL) + { + return E_OUTOFMEMORY ; + } + // Get the requested interface. + HRESULT hr = pOemCB->QueryInterface(iid, ppv) ; + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release() ; + return hr ; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks) ; + } + else + { + InterlockedDecrement(&g_cServerLocks) ; + } + return S_OK ; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK ; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:Create class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE ; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF ; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY ; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv) ; + pFontCF->Release() ; + + return hr ; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.h new file mode 100644 index 00000000..d723cbb7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/intrface.h @@ -0,0 +1,220 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.h +// +// PURPOSE: Header of interface for PScript5UI replacement plug-in. +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI2 +// +class IOemUI2: public IPrintOemUI2 +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + // + // IPrintOemUI2 methods + // + + // + // QueryJobAttributes + // + + STDMETHOD(QueryJobAttributes) (THIS_ + HANDLE hPrinter, + PDEVMODE pDevmode, + DWORD dwLevel, + LPBYTE lpAttributeInfo + ); + + // + // Hide Standard UI + // + + STDMETHOD(HideStandardUI) (THIS_ + DWORD dwMode + ); + + // + // DocumentEvent + // + + STDMETHOD(DocumentEvent) (THIS_ + HANDLE hPrinter, + HDC hdc, + INT iEsc, + ULONG cbIn, + PVOID pbIn, + ULONG cbOut, + PVOID pbOut, + PINT piResult + ); + + + IOemUI2(); + virtual ~IOemUI2(); + +protected: + LONG m_cRef; // Reference count + BOOL m_bHidingStandardUI; // Flag indicating if we are hiding the Standard UI. + // NOTE: Not all Driver UI versions support hinding + // the Standard Driver UI. + CUIHelper m_Helper; // Container for Driver UI Helper interface. + CFeatures m_Features; // Core Driver features and feature options. +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.cpp new file mode 100644 index 00000000..331be437 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.cpp @@ -0,0 +1,1042 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.cpp +// +// +// PURPOSE: Main file for OEM UI test module. +// + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "globals.h" +#include "devmode.h" +#include "stringutils.h" +#include "helper.h" +#include "features.h" +#include "oemui.h" + + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + +typedef struct _tagCBUserData +{ + HANDLE hComPropSheet; + HANDLE hPropPage; + POEMUIPSPARAM pOEMUIParam; + PFNCOMPROPSHEET pfnComPropSheet; + CUIHelper *pHelper; + POEMUIOBJ poemuiobj; + BOOL bPermission; + BOOL bHidingStandardUI; + +} CBUSERDATA, *PCBUSERDATA; + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUIItemCallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam); +LONG APIENTRY OEMDevUICallBack(PCPSUICBPARAM pCallbackParam); +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam); +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems); + + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM device or document property UI. +// +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hResult = S_OK; + + + VERBOSE(DLLTEXT("hrOEMPropertyPage(%d) entry.\r\n"), dwMode); + + // Validate parameters. + if( (OEMCUIP_DOCPROP != dwMode) + && + (OEMCUIP_PRNPROP != dwMode) + ) + { + ERR(ERRORTEXT("hrOEMPropertyPage() ERROR_INVALID_PARAMETER.\r\n")); + VERBOSE(DLLTEXT("\tdwMode = %d, pOEMUIParam = %#lx.\r\n"), dwMode, pOEMUIParam); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam); + break; + + case OEMCUIP_PRNPROP: + hResult = hrPrinterPropertyPage(dwMode, pOEMUIParam); + break; + + default: + // Should never reach this! + ERR(ERRORTEXT("hrOEMPropertyPage() Invalid dwMode, %d"), dwMode); + SetLastError(ERROR_INVALID_PARAMETER); + hResult = E_FAIL; + break; + } + + return hResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM document property UI. +// +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hrResult = S_OK; + + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM document property UI. + pOEMUIParam->cOEMOptItems = 1; + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() requesting %d number of items.\r\n"), pOEMUIParam->cOEMOptItems); + } + else + { + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() fill out %d items.\r\n"), pOEMUIParam->cOEMOptItems); + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMDocUIItemCallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + + hrResult = GetStringResource(pOEMUIParam->hOEMHeap, + (HMODULE) pOEMUIParam->hModule, + IDS_ADV_SECTION, + &pOEMUIParam->pOEMOptItems[0].pName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrDocumentPropertyPage() failed to get section name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + } + + +Exit: + + return hrResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM printer property UI. +// +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hrResult = S_OK; + + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM printer property UI. + pOEMUIParam->cOEMOptItems = 1; + + VERBOSE(DLLTEXT("hrPrinterPropertyPage() requesting %d number of items.\r\n"), pOEMUIParam->cOEMOptItems); + } + else + { + DWORD dwError; + DWORD dwDeviceValue; + DWORD dwType; + DWORD dwNeeded; + + + VERBOSE(DLLTEXT("hrPrinterPropertyPage() fill out %d items.\r\n"), pOEMUIParam->cOEMOptItems); + + // Get device settings value from printer. + dwError = GetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, &dwType, (PBYTE) &dwDeviceValue, + sizeof(dwDeviceValue), &dwNeeded); + if( (ERROR_SUCCESS != dwError) + || + (dwDeviceValue > 100) + ) + { + // Failed to get the device value or value is invalid, just use the default. + dwDeviceValue = 0; + } + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMPrinterUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + hrResult = GetStringResource(pOEMUIParam->hOEMHeap, + (HMODULE) pOEMUIParam->hModule, + IDS_DEV_SECTION, + &pOEMUIParam->pOEMOptItems[0].pName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrPrinterPropertyPage() failed to get section name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + pOEMUIParam->pOEMOptItems[0].Sel = dwDeviceValue; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + } + +Exit: + + return hrResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to Document property sheet. +// +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam, + CUIHelper &Helper, + CFeatures *pFeatures, + BOOL bHidingStandardUI) +{ + LONG_PTR lResult = 0; + HRESULT hrResult = S_OK; + + VERBOSE(DLLTEXT("OEMDocumentPropertySheets() entry.\r\n")); + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR(ERRORTEXT("OEMDocumentPropertySheets() ERROR_INVALID_PARAMETER.\r\n")); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + WORD wFeatures = 0; + WORD wIndex = 0; + DWORD dwSheets = 0; + PCBUSERDATA pUserData = NULL; + POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM) pPSUIInfo->lParamInit; + BOOL bPermission = ((pOEMUIParam->dwFlags & DM_NOPERMISSION) == 0); + HANDLE hHeap = pOEMUIParam->hOEMHeap; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + COMPROPSHEETUI Sheet; + + + // Make sure that we have the Core Driver Features. + // Only get features if we are hiding the standard + // document property sheets. + if(bHidingStandardUI) + { + pFeatures->Acquire(hHeap, Helper, pOEMUIParam->poemuiobj); + wFeatures = pFeatures->GetCount(OEMCUIP_DOCPROP); + } + + // Init property page. + memset(&Sheet, 0, sizeof(COMPROPSHEETUI)); + Sheet.cbSize = sizeof(COMPROPSHEETUI); + Sheet.Flags = bPermission ? CPSUIF_UPDATE_PERMISSION : 0; + Sheet.hInstCaller = ghInstance; + Sheet.pHelpFile = NULL; + Sheet.pfnCallBack = OEMDocUICallBack; + Sheet.pDlgPage = CPSUI_PDLGPAGE_TREEVIEWONLY; + Sheet.cOptItem = wFeatures + 1; + Sheet.IconID = IDI_CPSUI_PRINTER; + Sheet.CallerVersion = 0x100; + Sheet.OptItemVersion = 0x100; + + // Get Caller's name. + hrResult = GetStringResource(hHeap, ghInstance, IDS_NAME, &Sheet.pCallerName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to get caller name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + // Get section name. + hrResult = GetStringResource(hHeap, ghInstance, IDS_SECTION, &Sheet.pOptItemName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to get section name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + // Init user data. + pUserData = (PCBUSERDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CBUSERDATA)); + if(NULL == pUserData) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to allocate user data.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + pUserData->hComPropSheet = pPSUIInfo->hComPropSheet; + pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + pUserData->pOEMUIParam = pOEMUIParam; + pUserData->pHelper = &Helper; + pUserData->poemuiobj = pOEMUIParam->poemuiobj; + pUserData->bPermission = bPermission; + pUserData->bHidingStandardUI = bHidingStandardUI; + Sheet.UserData = (ULONG_PTR) pUserData; + + // Create OptItems for page. + Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem); + if(NULL == Sheet.pOptItem) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to allocate OPTITEMs.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Add Core Driver features. + for(wIndex = 0; wIndex < wFeatures; ++wIndex) + { + // Initialize level and basic state for feature. + Sheet.pOptItem[wIndex].Level = 1; + Sheet.pOptItem[wIndex].Flags = OPTIF_COLLAPSE; + + // Get the OPTITEM for this feature. + hrResult = pFeatures->InitOptItem(hHeap, + Sheet.pOptItem + wIndex, + wIndex, + OEMCUIP_DOCPROP); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to get OPTITEM for feature %hs.\r\n"), + pFeatures->GetKeyword(wIndex, OEMCUIP_DOCPROP)); + + goto Exit; + } + } + + // Initialize Plug-in OptItems + Sheet.pOptItem[wIndex].Level = 1; + Sheet.pOptItem[wIndex].Flags = OPTIF_COLLAPSE; + Sheet.pOptItem[wIndex].Sel = pOEMDev->dwDriverData; + + // get optitem name. + hrResult = GetStringResource(hHeap, ghInstance, IDS_SECTION, &Sheet.pOptItem[wIndex].pName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to get OptItem %d name. (hrResult = 0x%x)\r\n"), + wIndex, + hrResult); + goto Exit; + } + + Sheet.pOptItem[wIndex].pOptType = CreateOptType(hHeap, 2); + + Sheet.pOptItem[wIndex].pOptType->Type = TVOT_UDARROW; + Sheet.pOptItem[wIndex].pOptType->pOptParam[1].IconID = 0; + Sheet.pOptItem[wIndex].pOptType->pOptParam[1].lParam = 100; + + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PCOMPROPSHEETUI, + (LPARAM)&Sheet, (LPARAM)&dwSheets); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + + +Exit: + + pPSUIInfo->Result = lResult; + return hrResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to printer property sheet. +// +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam, + CUIHelper &Helper, + CFeatures *pFeatures, + BOOL bHidingStandardUI) +{ + LONG_PTR lResult = 0; + HRESULT hrResult = S_OK; + + + VERBOSE(DLLTEXT("hrOEMDevicePropertySheets(%#x, %#x) entry\r\n"), pPSUIInfo, lParam); + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() ERROR_INVALID_PARAMETER.\r\n")); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + Dump(pPSUIInfo); + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + PROPSHEETPAGE Page; + + // If hiding standard UI, then + // need to add Device Settings page, too. + if(bHidingStandardUI) + { + POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM) pPSUIInfo->lParamInit; + BOOL bPermission = ((pOEMUIParam->dwFlags & DPS_NOPERMISSION) == 0); + HANDLE hHeap = pOEMUIParam->hOEMHeap; + WORD wFeatures = 0; + WORD wIndex = 0; + DWORD dwSheets = 0; + DLGPAGE DlgPage; + PCBUSERDATA pUserData = NULL; + COMPROPSHEETUI Sheet; + + + // Make sure that we have the Core Driver Features. + pFeatures->Acquire(hHeap, Helper, pOEMUIParam->poemuiobj); + wFeatures = pFeatures->GetCount(OEMCUIP_PRNPROP); + + // Init DlgPage struct for Device Settings replacement page. + memset(&DlgPage, 0, sizeof(DLGPAGE)); + DlgPage.cbSize = sizeof(DLGPAGE); + DlgPage.DlgTemplateID = DP_STD_TREEVIEWPAGE; + + // Get Device Settings display name. + hrResult = GetStringResource(hHeap, ghInstance, IDS_DEVICE_SETTINGS_NAME, &DlgPage.pTabName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to get Device Settings display name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + // Init Device Settings replacement page. + memset(&Sheet, 0, sizeof(COMPROPSHEETUI)); + Sheet.cbSize = sizeof(COMPROPSHEETUI); + Sheet.Flags = bPermission ? CPSUIF_UPDATE_PERMISSION : 0; + Sheet.hInstCaller = ghInstance; + Sheet.pHelpFile = NULL; + Sheet.pfnCallBack = OEMDevUICallBack; + Sheet.pDlgPage = &DlgPage; //CPSUI_PDLGPAGE_TREEVIEWONLY; + Sheet.cOptItem = wFeatures; + Sheet.cDlgPage = 1; + Sheet.IconID = IDI_CPSUI_PRINTER; + Sheet.CallerVersion = 0x100; + Sheet.OptItemVersion = 0x100; + + // Get Caller's name. + hrResult = GetStringResource(hHeap, ghInstance, IDS_NAME, &Sheet.pCallerName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to get caller name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + // Get section name. + hrResult = GetStringResource(hHeap, ghInstance, IDS_SECTION, &Sheet.pOptItemName); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to get section name. (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + // Allocate and init User data used in our callback for this page. + pUserData = (PCBUSERDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CBUSERDATA)); + if(NULL == pUserData) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to allocate user data.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + pUserData->hComPropSheet = pPSUIInfo->hComPropSheet; + pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + pUserData->pOEMUIParam = pOEMUIParam; + pUserData->pHelper = &Helper; + pUserData->poemuiobj = pOEMUIParam->poemuiobj; + pUserData->bPermission = bPermission; + pUserData->bHidingStandardUI = bHidingStandardUI; + Sheet.UserData = (ULONG_PTR) pUserData; + + // Create OptItems for page. + Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem); + if(NULL == Sheet.pOptItem) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to allocate OPTITEMs.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Add Core Driver features. + for(wIndex = 0; wIndex < wFeatures; ++wIndex) + { + // Initialize level and basic state for feature. + Sheet.pOptItem[wIndex].Level = 1; + Sheet.pOptItem[wIndex].Flags = OPTIF_COLLAPSE; + + // Get the OPTITEM for this feature. + hrResult = pFeatures->InitOptItem(hHeap, + Sheet.pOptItem + wIndex, + wIndex, + OEMCUIP_PRNPROP); + if(!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to get OPTITEM for feature %hs.\r\n"), + pFeatures->GetKeyword(wIndex, OEMCUIP_PRNPROP)); + + goto Exit; + } + } + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PCOMPROPSHEETUI, + (LPARAM)&Sheet, (LPARAM)&dwSheets); + if(!SUCCEEDED(lResult)) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to add Device Settings replacement page. (lResult = 0x%x)\r\n"), + lResult); + goto Exit; + } + } + + // Init our property page. + memset(&Page, 0, sizeof(PROPSHEETPAGE)); + Page.dwSize = sizeof(PROPSHEETPAGE); + Page.dwFlags = PSP_DEFAULT; + Page.hInstance = ghInstance; + Page.pszTemplate = MAKEINTRESOURCE(IDD_DEVICE_PROPPAGE); + Page.pfnDlgProc = DevicePropPageProc; + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PROPSHEETPAGE, (LPARAM)&Page, 0); + if(!SUCCEEDED(lResult)) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() failed to add our Device Property page. (lResult = 0x%x)\r\n"), + lResult); + goto Exit; + } + + VERBOSE(DLLTEXT("hrOEMDevicePropertySheets() pfnComPropSheet returned %d.\r\n"), lResult); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + + +Exit: + + pPSUIInfo->Result = lResult; + return hrResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM printer property UI. +// +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + + VERBOSE(DLLTEXT("OEMPrinterUICallBack() entry, Reason is %d.\r\n"), pCallbackParam->Reason); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + { + DWORD dwDriverValue = pOEMUIParam->pOEMOptItems[0].Sel; + + // Store OptItems state in printer data. + SetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, REG_DWORD, (PBYTE) &dwDriverValue, sizeof(DWORD)); + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Call back for OEM device property UI. +// +#pragma warning(push) +// 2 MAX_PATH strings just slightly exceed the default threshold for the prefast stack usage warning +#pragma warning( disable : 6262 ) +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uiMsg) + { + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + switch(LOWORD(wParam)) + { + case IDC_CALIBRATE: + // Just display a message that the printer is calibrated, + // since we don't acutally calibrate anything. + { + TCHAR szName[MAX_PATH]; + TCHAR szCalibrated[MAX_PATH]; + + + LoadString(ghInstance, IDS_NAME, szName, sizeof(szName)/sizeof(szName[0])); + LoadString(ghInstance, IDS_CALIBRATED, szCalibrated, sizeof(szCalibrated)/sizeof(szCalibrated[0])); + MessageBox(hDlg, szCalibrated, szName, MB_OK); + } + break; + } + break; + + default: + return FALSE; + } + return TRUE; + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) // type of notification message + { + case PSN_SETACTIVE: + break; + + case PSN_KILLACTIVE: + break; + + case PSN_APPLY: + break; + + case PSN_RESET: + break; + } + } + break; + } + + return FALSE; +} +#pragma warning(pop) + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM document property UI. +// +LONG APIENTRY OEMDocUIItemCallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("OEMDocUIItemCallBack() entry, Reason is %d.\r\n"), pCallbackParam->Reason); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Store OptItems state in DEVMODE. + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_KILLACTIVE: + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pOEMUIParam->pOEMOptItems[0].Sel) != pOEMDev->dwAdvancedData) + { + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + pOEMUIParam->pOEMOptItems[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam) +{ + WORD wItems = pCallbackParam->cOptItem; + LONG lReturn = CPSUICB_ACTION_NONE; + POPTITEM pOptItem = pCallbackParam->pOptItem; + PCBUSERDATA pUserData = (PCBUSERDATA) pCallbackParam->UserData; + HANDLE hHeap = pUserData->pOEMUIParam->hOEMHeap; + POEMDEV pOEMDev = (POEMDEV) pUserData->pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("OEMDocUICallBack() entry, Reason is %d.\r\n"), pCallbackParam->Reason); + + // + // If user has no permission to change anything, then + // simply return without taking any action. + // + + if (!pUserData->bPermission && (pCallbackParam->Reason != CPSUICB_REASON_ABOUT)) + return CPSUICB_ACTION_NONE; + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + if(wItems > 0) + { + // Save feature options if hidig standard UI. + if(pUserData->bHidingStandardUI) + { + HRESULT hrResult; + + + // Save feature OPTITEMs. + hrResult = SaveFeatureOptItems(hHeap, + pUserData->pHelper, + pUserData->poemuiobj, + pCallbackParam->hDlg, + pOptItem, + wItems); + if(!SUCCEEDED(hrResult)) + { + // Return that we didn't save changes. + // NOTE: it is up to SaveFeatureOptItems() to display + // any UI for failure. + return CPSUICB_ACTION_NO_APPLY_EXIT; + } + } + + // Save OPTITEM that we explicitly added. + pOEMDev->dwDriverData = pOptItem[wItems - 1].Sel; + pUserData->pfnComPropSheet(pUserData->hComPropSheet, CPSFUNC_SET_RESULT, + (LPARAM)pUserData->hPropPage, + (LPARAM)CPSUI_OK); + + } + break; + + case CPSUICB_REASON_KILLACTIVE: + if(wItems > 0) + { + // Update OPTITEM that we explicitly added. + pOEMDev->dwDriverData = pOptItem[wItems - 1].Sel; + } + break; + + case CPSUICB_REASON_SETACTIVE: + if(wItems > 0) + { + if((DWORD)(pOptItem[wItems - 1].Sel) != pOEMDev->dwDriverData) + { + // Update OPTITEM that we explicitly added. + pOptItem[wItems - 1].Sel = pOEMDev->dwDriverData; + pOptItem[wItems - 1].Flags |= OPTIF_CHANGED; + } + } + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + break; + + default: + break; + } + + return lReturn; +} + +LONG APIENTRY OEMDevUICallBack(PCPSUICBPARAM pCallbackParam) +{ + WORD wItems = pCallbackParam->cOptItem; + LONG lReturn = CPSUICB_ACTION_NONE; + POPTITEM pOptItem = pCallbackParam->pOptItem; + PCBUSERDATA pUserData = (PCBUSERDATA) pCallbackParam->UserData; + HANDLE hHeap = pUserData->pOEMUIParam->hOEMHeap; + + + VERBOSE(DLLTEXT("OEMDevUICallBack() entry, Reason is %d.\r\n"), pCallbackParam->Reason); + + // + // If user has no permission to change anything, then + // simply return without taking any action. + // + + if (!pUserData->bPermission && (pCallbackParam->Reason != CPSUICB_REASON_ABOUT)) + return CPSUICB_ACTION_NONE; + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + if(wItems > 0) + { + // Save feature options if hidig standard UI. + if(pUserData->bHidingStandardUI) + { + HRESULT hrResult; + + + // Save feature OPTITEMs. + hrResult = SaveFeatureOptItems(hHeap, + pUserData->pHelper, + pUserData->poemuiobj, + pCallbackParam->hDlg, + pOptItem, + wItems); + if(!SUCCEEDED(hrResult)) + { + // Return that we didn't save changes. + // NOTE: it is up to SaveFeatureOptItems() to display + // any UI for failure. + return CPSUICB_ACTION_NO_APPLY_EXIT; + } + } + + + pUserData->pfnComPropSheet(pUserData->hComPropSheet, CPSFUNC_SET_RESULT, + (LPARAM)pUserData->hPropPage, + (LPARAM)CPSUI_OK); + } + break; + + case CPSUICB_REASON_KILLACTIVE: + break; + + case CPSUICB_REASON_SETACTIVE: + break; + + default: + break; + } + + return lReturn; +} + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Creates and Initializes OptItems. +// +POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems) +{ + POPTITEM pOptItems = NULL; + SIZE_T sizeOfOptItems = 0; + + // Compute the size of memory needed for the OptItems: + if (SUCCEEDED(SIZETMult(sizeof(OPTITEM), (SIZE_T)dwOptItems, &sizeOfOptItems))) + { + // Allocate memory for OptItems; + pOptItems = (POPTITEM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeOfOptItems); + if(NULL != pOptItems) + { + InitOptItems(pOptItems, dwOptItems); + } + else + { + ERR(ERRORTEXT("CreateOptItems() failed to allocate memory for OPTITEMs!\r\n")); + } + } + else + { + ERR(ERRORTEXT("CreateOptItems() failed to compute necessary memory size for OPTITEMs!\r\n")); + } + + return pOptItems; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems. +// +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems) +{ + VERBOSE(DLLTEXT("InitOptItems() entry.\r\n")); + + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for(DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OptType for OptItem. +// +POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams) +{ + POPTTYPE pOptType = NULL; + + + VERBOSE(DLLTEXT("CreateOptType() entry.\r\n")); + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + if(NULL != pOptType) + { + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, wOptParams * sizeof(OPTPARAM)); + if(NULL != pOptType->pOptParam) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + ERR(ERRORTEXT("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n")); + + // Free allocated memory and return NULL. + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR(ERRORTEXT("CreateOptType() failed to allocated memory for OPTTYPE!\r\n")); + } + + return pOptType; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.h new file mode 100644 index 00000000..c00b87ef --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/oemui.h @@ -0,0 +1,33 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.H +// +#pragma once + + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + +// Printer registry keys where OEM data is stored. +#define OEMUI_VALUE TEXT("OEMUI_VALUE") +#define OEMUI_DEVICE_VALUE TEXT("OEMUI_DEVICE_VALUE") + + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, CUIHelper &Helper, CFeatures *pFeatures, + BOOL bHidingStandardUI); +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, CUIHelper &Helper, CFeatures *pFeatures, + BOOL bHidingStandardUI); + +POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems); +POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams); diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precomp.h new file mode 100644 index 00000000..1374db76 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precomp.h @@ -0,0 +1,55 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// PURPOSE: Header files that should be in the precompiled header. +// +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Safe integer functions to detect integer overflow/underflow conditions: +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/psuirep.def b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/psuirep.def new file mode 100644 index 00000000..eacb15a5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/psuirep.def @@ -0,0 +1,3 @@ +LIBRARY PSUIREP +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/resource.h new file mode 100644 index 00000000..958598da --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PSUIRep/resource.h @@ -0,0 +1,92 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by OEMUI.rc +// +#define IDS_SECTION 1 +#define IDS_CALIBRATED 2 +#define IDS_NAME 3 +#define IDS_DEVICE_SETTINGS_NAME 4 +#define IDS_CONSTRAINT_CONFLICT 5 +#define IDS_DEV_SECTION 6 +#define IDS_ADV_SECTION 10 +#define IDD_DEVICE_PROPPAGE 106 +#define IDD_DOC_PROPPAGE 107 +#define IDS_POSTSCRIPT_VM 400 +#define IDS_KBYTES 401 +#define IDS_SECONDS 402 +#define IDS_PSTIMEOUTS 403 +#define IDS_JOBTIMEOUT 404 +#define IDS_WAITTIMEOUT 405 +#define IDS_PRINTER_DEFAULT 406 +#define IDS_INSTALLABLE_OPTIONS 407 +#define IDS_DOWNLOAD_AS_SOFTFONT 408 +#define IDS_USE_DEVFONTS 409 +#define IDS_FONTSUB_OPTION 410 +#define IDS_FONTSUB_DEFAULT 411 +#define IDS_FONTSUB_SLOW 412 +#define IDS_FONTSUB_TABLE 413 +#define IDS_DEFAULT_TRAY 414 +#define IDS_DRAW_ONLY_FROM_SELECTED 415 +#define IDS_RESTORE_DEFAULTS 417 +#define IDS_PRINTER_FEATURES 418 +#define IDS_METAFILE_SPOOLING 419 +#define IDS_ENABLED 420 +#define IDS_DISABLED 421 +#define IDS_PSOPTIONS 422 +#define IDS_MIRROR 423 +#define IDS_NEGATIVE_PRINT 424 +#define IDS_PAGEINDEP 425 +#define IDS_COMPRESSBMP 426 +#define IDS_CTRLD_BEFORE 427 +#define IDS_CTRLD_AFTER 428 +#define IDS_JOB_CONTROL 429 +#define IDS_TEXT_ASGRX 431 +#define IDS_PAGE_PROTECTION 432 +#define IDS_CANCEL_CONFLICT 433 +#define IDS_IGNORE_CONFLICT 434 +#define IDS_RESOLVE_CONFLICT 435 +#define IDS_GETDATA_FAILED 436 +#define IDS_DRIVERUI_COLORMODE 437 +#define IDS_ENVELOPE 438 +#define IDS_ENV_PREFIX 439 +#define IDS_PSPROTOCOL 440 +#define IDS_PSPROTOCOL_ASCII 441 +#define IDS_PSPROTOCOL_BCP 442 +#define IDS_PSPROTOCOL_TBCP 443 +#define IDS_PSPROTOCOL_BINARY 444 +#define IDS_TRAY_FORMSOURCE 445 +#define IDS_OEMERR_DLGTITLE 446 +#define IDS_OEMERR_OPTITEM 447 +#define IDS_OEMERR_PROPSHEET 448 +#define IDS_CANCEL_CONFLICT_FINAL 449 +#define IDS_PSERROR_HANDLER 450 +#define IDS_PSMINOUTLINE 451 +#define IDS_PSMAXBITMAP 452 +#define IDS_PIXELS 453 +#define IDS_PSOUTPUT_OPTION 454 +#define IDS_PSOPT_SPEED 455 +#define IDS_PSOPT_PORTABILITY 456 +#define IDS_PSOPT_EPS 457 +#define IDS_PSOPT_ARCHIVE 458 +#define IDS_PSTT_DLFORMAT 459 +#define IDS_TTDL_DEFAULT 460 +#define IDS_TTDL_TYPE1 461 +#define IDS_TTDL_TYPE3 462 +#define IDS_TTDL_TYPE42 463 +#define IDS_PSLEVEL 471 +#define IDS_TRUE_GRAY_TEXT 507 +#define IDS_TRUE_GRAY_GRAPH 508 +#define IDS_ADD_EURO 509 +#define IDS_PSCRIPT_CUSTOMSIZE 600 +#define IDC_CALIBRATE 1001 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1002 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.gpd b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.gpd new file mode 100644 index 00000000..fa3e7864 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.gpd @@ -0,0 +1,763 @@ +*GPDFileName: "ptpcplpr.gpd" +*GPDFileVersion: "1.0" +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*Include: "ttfsub.gpd" +*ModelName: "UniDrv PT/PC Plugin Provider" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 +*PrintRate: 16 +*PrintRateUnit: PPM +*PrintRatePPM: 16 + +*%****************************************************************************************** +*% Orientation +*%****************************************************************************************** +*Feature: Orientation +{ + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l0O" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.8 + *Cmd: "<1B>&l1O" + } + } +} + +*%****************************************************************************************** +*% Input Bin +*%****************************************************************************************** +*Feature: InputBin +{ + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: AUTO + *Option: AUTO + { + *rcNameID: =AUTO_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l0H" + } + } + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l1H" + } + } +} + +*%****************************************************************************************** +*% Resolution +*%****************************************************************************************** +*Feature: Resolution +{ + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: Option2 + *Option: Option1 + { + *Name: "600 x 600" =DOTS_PER_INCH + *DPI: PAIR(600, 600) + *TextDPI: PAIR(600, 600) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=600<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t600R" + } + } + *Option: Option2 + { + *Name: "300 x 300" =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=300<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } + *Option: Option3 + { + *Name: "150 x 150" =DOTS_PER_INCH + *DPI: PAIR(150, 150) + *TextDPI: PAIR(150, 150) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=150<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t150R" + } + } +} + +*%****************************************************************************************** +*% HP-GL/2 Graphics Support +*%****************************************************************************************** +*Ifdef: WINNT_51 +*Personality: =PERSONALITY_HPGL2 +*Feature: GraphicsMode +{ + *rcNameID: =GRAPHICSMODE_DISPLAY + *DefaultOption: RASTERMODE + *Option: HPGL2MODE + { + *rcNameID: =GRAPHICSMODE_HPGL2_DISPLAY + } + *Option: RASTERMODE + { + *rcNameID: =GRAPHICSMODE_RASTER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "@PJL SET LIMAGEENHANCE=OFF<0A>" + } + } +} +*Endif: + +*%****************************************************************************************** +*% Paper Size +*%****************************************************************************************** +*Feature: PaperSize +{ + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1028 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9500, 12500) + *PrintableOrigin: PAIR(400, 400) + *CursorOrigin: PAIR(300, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t5260x7704Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9500, 12200) + *PrintableOrigin: PAIR(450, 300) + *CursorOrigin: PAIR(200, 12900) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t7332x5880Y" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1692 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 600) + *CursorOrigin: PAIR(180, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t5880x8900Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 900) + *CursorOrigin: PAIR(180, 16500) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t8900x5880Y" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4109 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 11500) + *PrintableOrigin: PAIR(300, 300) + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t4860x7344Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8300, 11500) + *PrintableOrigin: PAIR(200, 300) + *CursorOrigin: PAIR(200, 12300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t7272x4980Y" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4249 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(288, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t5594x8201Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(204, 13824) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t8129x5714Y" + } + } + } + } + *Option: B5 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 3198 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(7900, 11140) + *PrintableOrigin: PAIR(352, 300) + *CursorOrigin: PAIR(300, 100) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t4970x7040Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(7760, 11140) + *PrintableOrigin: PAIR(300, 400) + *CursorOrigin: PAIR(100, 11940) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t6780x4970Y" + } + } + } + } +} + +*%****************************************************************************************** +*% Media Type +*%****************************************************************************************** +*Feature: MediaType +{ + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: STANDARD + *Option: STANDARD + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n6WdPlain" + } + } + *Option: CustomPhotographicPaper + { + *Name: "Photographic" + *PrintSchemaKeywordMap: "Photographic" + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n13WdPhotographic" + } + } +} + +*%****************************************************************************************** +*% Color Mode +*%****************************************************************************************** +*Feature: ColorMode +{ + *rcNameID: =COLOR_PRINTING_MODE_DISPLAY + *DefaultOption: 24bpp + *Option: Mono + { + *rcNameID: =MONO_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 1 + *Color?: FALSE + } + *Option: Color + { + *rcNameID: =COLOR_DISPLAY + *DevNumOfPlanes: 3 + *DevBPP: 1 + *DrvBPP: 4 + EXTERN_GLOBAL: *RasterSendAllData?: TRUE + *ColorPlaneOrder: LIST(CYAN, MAGENTA, YELLOW) + *Command: CmdSendCyanData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"V" } + *Command: CmdSendMagentaData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"V" } + *Command: CmdSendYellowData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelectBlackColor { *Cmd : "<1B>*v7S" } + *Command: CmdSelectRedColor { *Cmd : "<1B>*v6S" } + *Command: CmdSelectGreenColor { *Cmd : "<1B>*v5S" } + *Command: CmdSelectYellowColor { *Cmd : "<1B>*v4S" } + *Command: CmdSelectBlueColor { *Cmd : "<1B>*v3S" } + *Command: CmdSelectMagentaColor { *Cmd : "<1B>*v2S" } + *Command: CmdSelectCyanColor { *Cmd : "<1B>*v1S" } + *Command: CmdSelectWhiteColor { *Cmd : "<1B>*v0S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*r-3U" + } + } + *Option: 8bpp + { + *rcNameID: =8BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 8 + *DrvBPP: 8 + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*t0I<1B>*l184O<1B>*v6W<000108080808>" + } + } + *Option: 24bpp + { + *rcNameID: =24BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 24 + *DrvBPP: 24 + *Command: CmdEnableDRC { *Cmd : "<1B>*b3M" } + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSetSrcBmpWidth { *Cmd : "<1B>*r" %d{RasterDataWidthInBytes / 3}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*l184O<1B>*v6W<0003080808081B>*v0a0b0c7i255a255b255c0I<1B>*" ++ "o3W<060400>" + } + } +} + +*%****************************************************************************************** +*% HalfTone +*%****************************************************************************************** +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} + +*%****************************************************************************************** +*% Memory +*% +*% Note: Unidrv uses the font memory information to estimate when it needs to stop +*% downloading fonts for a page, and thus driver writers should err on the conservative +*% side. Otherwise, printers will generate "out of memory" device errors for pages with +*% a large number of fonts / unique glyphs. +*%****************************************************************************************** +*Feature: Memory +{ + *rcNameID: =PRINTER_MEMORY_DISPLAY + *DefaultOption: 32768KB + *Option: 4096KB + { + *Name: "4MB" + *MemoryConfigKB: PAIR(4096, 6750) + } + *Option: 8192KB + { + *Name: "8MB" + *MemoryConfigKB: PAIR(8192, 10350) + } + *Option: 16384KB + { + *Name: "16MB" + *MemoryConfigKB: PAIR(16384, 13950) + } + *Option: 24576KB + { + *Name: "24MB" + *MemoryConfigKB: PAIR(24576, 21150) + } + *Option: 32768KB + { + *Name: "32MB" + *MemoryConfigKB: PAIR(32768, 28350) + } + *Option: 49152KB + { + *Name: "48MB" + *MemoryConfigKB: PAIR(49152, 43050) + } + *Option: 65536KB + { + *Name: "64MB" + *MemoryConfigKB: PAIR(65536, 57150) + } + *Option: 98304KB + { + *Name: "96MB" + *MemoryConfigKB: PAIR(98304, 85950) + } + *Option: 102400KB + { + *Name: "100MB" + *MemoryConfigKB: PAIR(102400, 89700) + } + *Option: 114688KB + { + *Name: "112MB" + *MemoryConfigKB: PAIR(114688, 100550) + } + *Option: 131072KB + { + *Name: "128MB" + *MemoryConfigKB: PAIR(131072, 116250) + } +} + +*%****************************************************************************************** +*% Duplex Unit +*%****************************************************************************************** +*Feature: DuplexUnit +{ + *rcNameID: 429 + *FeatureType: PRINTER_PROPERTY + *DefaultOption: FALSE + *Option: FALSE + { + *rcNameID: 444 + *DisabledFeatures: LIST(Duplex.VERTICAL, Duplex.HORIZONTAL) + } + *Option: TRUE + { + *rcNameID: 443 + } +} + +*%****************************************************************************************** +*% Duplex Type +*%****************************************************************************************** +*Feature: Duplex +{ + *rcNameID: =TWO_SIDED_PRINTING_DISPLAY + *DefaultOption: NONE + *Option: NONE + { + *rcNameID: =NONE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l0S" + } + } + *Option: VERTICAL + { + *rcNameID: =FLIP_ON_LONG_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l1S" + } + } + *Option: HORIZONTAL + { + *rcNameID: =FLIP_ON_SHORT_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l2S" + } + } +} + +*%****************************************************************************************** +*% Page Photo Printing Intent +*%****************************************************************************************** +*Feature: PhotoPrintingIntent +{ + *Name: "Photo Printing Intent" + *PrintSchemaKeywordMap: "PagePhotoPrintingIntent" + *DefaultOption: None + *Option: None + { + *Name: "None" + *PrintSchemaKeywordMap: "None" + } + *Option: Draft + { + *Name: "Draft" + *PrintSchemaKeywordMap: "PhotoDraft" + } + *Option: Standard + { + *Name: "Standard" + *PrintSchemaKeywordMap: "PhotoStandard" + } + *Option: Best + { + *Name: "Best" + *PrintSchemaKeywordMap: "PhotoBest" + } +} + + +*Feature: OutputQuality +{ + *Name: "Page Output Quality" + *PrintSchemaKeywordMap: "PageOutputQuality" + *DefaultOption: None + *Option: None + { + *Name: "None" + *PrintSchemaKeywordMap: "None" + } + *Option: Draft + { + *Name: "Draft" + *PrintSchemaKeywordMap: "Draft" + } + *Option: High + { + *Name: "High" + *PrintSchemaKeywordMap: "High" + } + *Option: Photographic + { + *Name: "Photographic" + *PrintSchemaKeywordMap: "Photographic" + } +} + +*%****************************************************************************************** +*% Page Protect +*%****************************************************************************************** +*Feature: PageProtect +{ + *rcNameID: =PAGE_PROTECTION_DISPLAY + *DefaultOption: OFF + *Option: ON + { + *rcNameID: =ON_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=LETTER<0A>" + } + } + *Option: OFF + { + *rcNameID: =OFF_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=OFF<0A>" + } + } +} + +*%****************************************************************************************** +*% Doc setup commands +*%****************************************************************************************** +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.7 + *Cmd: "<1B>&u1200D<1B>*r0F" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "<1B>*b0M<0D>" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "<1B>E<1B>%%-12345X@PJL<20>LPORTROTATE<0A><1B>%%-12345X" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.13 + *Cmd: "<1B>&l" %d{NumOfCopies}"X" +} + +*%****************************************************************************************** +*% Cursor, Page and Color Commands +*%****************************************************************************************** +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT, RASTER, VECTOR) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*Command: CmdXMoveAbsolute { *Cmd : "<1B>*p" %d{(DestX) }"X" } +*Command: CmdXMoveRelRight { *Cmd : "<1B>*p+" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdXMoveRelLeft { *Cmd : "<1B>*p-" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdYMoveAbsolute { *Cmd : "<1B>*p" %d{(DestY) }"Y" } +*Command: CmdYMoveRelDown { *Cmd : "<1B>*p+" %d{(DestYRel) }"Y" } +*Command: CmdYMoveRelUp { *Cmd : "<1B>*p-" %d{(DestYRel) }"Y" } +*Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } +*Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } +*Command: CmdCR { *Cmd : "<0D>" } +*Command: CmdLF { *Cmd : "<0A>" } +*Command: CmdFF { *Cmd : "<0C>" } +*Command: CmdBackSpace { *Cmd : "<08>" } +*Command: CmdUniDirectionOn { *Cmd : "<00>" } +*Command: CmdUniDirectionOff { *Cmd : "<00>" } +*Command: CmdPushCursor { *Cmd : "<1B>&f0S" } +*Command: CmdPopCursor { *Cmd : "<1B>&f1S" } +*Command: CmdSetSimpleRotation { *Cmd : "<1B>&a" %d{PrintDirInCCDegrees}"P" } +*EjectPageWithFF?: TRUE +*Command: CmdEnableTIFF4 { *Cmd : "<1B>*b2M" } +*Command: CmdDisableCompression { *Cmd : "<1B>*b0M" } +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*%****************************************************************************************** +*% Font Descriptions and Commands +*%****************************************************************************************** +*TTFSEnabled?: TRUE +*DefaultFont: 136 +*DefaultCTT: 0 +*CharPosition: BASELINE +*DeviceFonts: LIST(136,138,146,147,148,149,150,151,152,153,154,155,156,157, ++ 163,164,165,166,196,197,198,199,200,201,202,203,209,210, ++ 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, ++ 227,228,229,230) +*MinFontID: 16534 +*MaxFontID: 32768 +*switch: Resolution +{ + *case: Option1 + { + *FontFormat: HPPCL_OUTLINE + } + *case: Option2 + { + *FontFormat: HPPCL_OUTLINE + } + *case: Option3 + { + *FontFormat: HPPCL_RES + } +} +*Command: CmdSetFontID { *Cmd : "<1B>*c" %d{NextFontID}"D" } +*Command: CmdSelectFontID { *Cmd : "<1B>(" %d{CurrentFontID}"X" } +*Command: CmdSetCharCode { *Cmd : "<1B>*c" %d{NextGlyph}"E" } +*Command: CmdUnderlineOn { *Cmd : "<1B>&dD" } +*Command: CmdUnderlineOff { *Cmd : "<1B>&d@" } +*Command: CmdWhiteTextOn { *Cmd : "<1B>*v1o1T" } +*Command: CmdWhiteTextOff { *Cmd : "<1B>*v0o0T" } + + +*%******************************************************************************************** +*%* Vector Commands. +*%******************************************************************************************** +*MinGrayFill: 1 +*MaxGrayFill: 100 +*Command: CmdSetRectWidth { *Cmd : "<1B>*c" %d{(RectXSize) }"A" } +*Command: CmdSetRectHeight { *Cmd : "<1B>*c" %d{(RectYSize) }"B" } +*Command: CmdRectGrayFill { *Cmd : "<1B>*c" %d{GrayPercentage }"g2P" } +*Command: CmdRectWhiteFill { *Cmd : "<1B>*c1P" } +*Command: CmdRectBlackFill { *Cmd : "<1B>*c0P" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.inf b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.inf new file mode 100644 index 00000000..c778b454 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.inf @@ -0,0 +1,107 @@ +; PTPCPlPr.INF +; +; INF file for OEM DLL PT/PC Plugin Provider sample +; +; Copyright 2001-2005 Microsoft Corporation + +[Version] +Signature="$Windows NT$" +Provider=%MS% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=09/09/2005,1.0.0.2 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Microsoft"=Microsoft, NTx86, NTamd64, NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Microsoft] +"UniDrv PT/PC Plugin Provider" = PTPCPLPR + +[Microsoft.NTx86] +"UniDrv PT/PC Plugin Provider" = PTPCPLPR + +[Microsoft.NTamd64] +"UniDrv PT/PC Plugin Provider" = PTPCPLPR + +[Microsoft.NTia64] +"UniDrv PT/PC Plugin Provider" = PTPCPLPR + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[PTPCPLPR] +CopyFiles=@PTPCPLPR.GPD +CopyFiles=@PTPCPLPR.INI +CopyFiles=@PTPCPLPR.DLL +DataFile=PTPCPLPR.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,UNIDRV_DATA,TTFSUB.OEM + + +; Copy Sections +; +; Lists of files that are actually copied. These sections are referenced +; from the installer sections, above. Only create a section if it contains +; two or more files (if we only copy a single file, identify it in the +; installer section, using the @filename notation) or if it's a color +; profile (since the DestinationDirs can only handle sections, and not +; individual files). +; + +; Nothing needed here + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMIntentSample% + +[SourceDisksFiles.X86] +PTPCPLPR.DLL = 100,x86 + +[SourceDisksFiles.amd64] +PTPCPLPR.DLL = 100,amd64 + +[SourceDisksFiles.IA64] +PTPCPLPR.DLL = 100,ia64 + +[SourceDisksFiles] +PTPCPLPR.GPD = 100 +PTPCPLPR.INI = 100 + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +MS="Microsoft DDK Sample" +OEMIntentSample="UniDrv PT/PC Plugin Provider" diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.ini b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.ini new file mode 100644 index 00000000..5535181a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/install/ptpcplpr.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=PTPCPLPR.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj new file mode 100644 index 00000000..33380c3f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj @@ -0,0 +1,904 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {CED613CF-6666-43FC-9414-02AFBDA83A34} + $(MSBuildProjectName) + Win10 Debug + Win32 + {77D353B7-7DE8-4AB3-A89C-86F5EB1FC56C} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + PTPCPLPR + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + MultiThreaded + MultiThreadedDebug + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;PLUGIN_PRINTTICKET + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;msxml6.lib;uuid.lib + PTPCPLPR.def + + + + + ;%(AdditionalIncludeDirectories) + precomp.hxx + Use + $(IntDir)\precomp.hxx.pch + + + ;%(AdditionalIncludeDirectories) + precomp.hxx + Use + $(IntDir)\precomp.hxx.pch + + + ;%(AdditionalIncludeDirectories) + precomp.hxx + Use + $(IntDir)\precomp.hxx.pch + + + ;%(AdditionalIncludeDirectories) + precomp.hxx + Use + $(IntDir)\precomp.hxx.pch + + + ;%(AdditionalIncludeDirectories) + precomp.hxx + Create + $(IntDir)\precomp.hxx.pch + + + ;%(AdditionalIncludeDirectories) + precomp.hxx + Use + $(IntDir)\precomp.hxx.pch + + + ;%(AdditionalIncludeDirectories) + precomp.hxx + Use + $(IntDir)\precomp.hxx.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj.Filters new file mode 100644 index 00000000..abd9c1c0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/PTPCPLPR.vcxproj.Filters @@ -0,0 +1,272 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {968C24E3-F5FE-4473-9D02-E46A409462B6} + + + h;hpp;hxx;hm;inl;inc;xsd + {D7302931-5FEA-4B5A-B5B1-7B1938023A9E} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {1475CB34-56B8-45D0-9740-D86566D868E6} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/debug.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/debug.hxx new file mode 100644 index 00000000..877fd6e3 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/debug.hxx @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.hxx +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/dllentry.cxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/dllentry.cxx new file mode 100644 index 00000000..4934dfc2 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/dllentry.cxx @@ -0,0 +1,48 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cxx +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.hxx" +#include "oem.hxx" +#include "debug.hxx" +#include "globals.hxx" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID ) +{ + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.cxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.cxx new file mode 100644 index 00000000..75abea62 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.cxx @@ -0,0 +1,21 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: globals.cxx +// + +#include "precomp.hxx" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.hxx new file mode 100644 index 00000000..72f3aa11 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/globals.hxx @@ -0,0 +1,25 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: globals.hxx +// + +#pragma once + +// +// Maximum string length limit for STRSAFE string length function StringCchLength +// Must be less than or equal to maximum upper bound on string length defined by STRSAFE +// library ie STRSAFE_MAX_CCH +// +#define STR_MAX_CCH 10000 + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +extern HINSTANCE ghInstance; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.cxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.cxx new file mode 100644 index 00000000..3d6f3b90 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.cxx @@ -0,0 +1,493 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.cxx +// +// +// PURPOSE: Implementation of interface for PScript4, PScript5, Unidrv4, +// Unidrv5 UI plug-ins. +// +// + + +#include "precomp.hxx" +#include "debug.hxx" +#include "intrface.hxx" +#include "oem.hxx" +#include "oemptprovider.hxx" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// Private Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0 ; // Count of active components +static long g_cServerLocks = 0 ; // Count of locks + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI body +// + +IOemUI::~IOemUI() +{ + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall IOemUI::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE(DLLTEXT("IOemUI:QueryInterface entry.\r\n\r\n")); + if (IID_IUnknown == iid) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IOemUI:Return pointer to IUnknown.\r\n\r\n")); + } + else if (IID_IPrintOemUI == iid) + { + *ppv = static_cast(this) ; + VERBOSE(DLLTEXT("IOemUI:Return pointer to IPrintOemUI.\r\n")); + } + else + { + VERBOSE(DLLTEXT("IOemUI::QueryInterface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemUI::AddRef() +{ + VERBOSE(DLLTEXT("IOemUI:AddRef entry.\r\n")); + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemUI::Release() +{ + VERBOSE(DLLTEXT("IOemUI:Release entry.\r\n")); + ASSERT (0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + } + return cRef; +} + +HRESULT __stdcall IOemUI::PublishDriverInterface( + IUnknown *) +{ + VERBOSE(DLLTEXT("IOemUI:PublishDriverInterface entry.\r\n")); + + return S_OK; +} + +HRESULT __stdcall IOemUI::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IOemUI::GetInfo entry.\r\r\n")); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + WARNING(DLLTEXT("IOemUI::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER\r\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("IOemUI::GetInfo() exit insufficient buffer!\r\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IOemUI::GetInfo() exit mode not supported.\r\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(DLLTEXT("IOemUI::GetInfo() exit S_OK.\r\r\n")); + return S_OK; +} + +HRESULT __stdcall IOemUI::DevMode( + DWORD , + POEMDMPARAM ) +{ + VERBOSE(DLLTEXT("IOemUI:DevMode entry.\r\n")); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::CommonUIProp( + DWORD , + POEMCUIPPARAM) +{ + VERBOSE(DLLTEXT("IOemUI:CommonUIProp entry.\r\n")); + + return E_NOTIMPL; +} + + +HRESULT __stdcall IOemUI::DocumentPropertySheets( + PPROPSHEETUI_INFO , + LPARAM ) +{ + VERBOSE(DLLTEXT("IOemUI:DocumentPropertySheets entry.\r\n")); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DevicePropertySheets( + PPROPSHEETUI_INFO , + LPARAM ) +{ + VERBOSE(DLLTEXT("IOemUI:DevicePropertySheets entry.\r\n")); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DeviceCapabilities( + POEMUIOBJ , + HANDLE , +_In_ PWSTR , + WORD , + PVOID , + PDEVMODE , + PVOID , + DWORD , + DWORD * ) +{ + VERBOSE(DLLTEXT("IOemUI:DeviceCapabilities entry.\r\n")); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DevQueryPrintEx( + POEMUIOBJ , + PDEVQUERYPRINT_INFO , + PDEVMODE , + PVOID ) +{ + VERBOSE(DLLTEXT("IOemUI:DevQueryPrintEx entry.\r\n")); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::UpgradePrinter( + DWORD , + PBYTE ) +{ + VERBOSE(DLLTEXT("IOemUI:UpgradePrinter entry.\r\n")); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::PrinterEvent( +_In_ PWSTR , + INT , + DWORD , + LPARAM ) +{ + VERBOSE(DLLTEXT("IOemUI:PrinterEvent entry.\r\n")); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DriverEvent( + DWORD , + DWORD , + LPBYTE , + LPARAM ) +{ + VERBOSE(DLLTEXT("IOemUI:DriverEvent entry.\r\n")); + + return E_NOTIMPL; +}; + + +#define PROFILE_NAME L"OEMPROFILE.icm\0" + +HRESULT __stdcall IOemUI::QueryColorProfile( + HANDLE , + POEMUIOBJ , + PDEVMODE , + PVOID , + ULONG , + VOID *, + ULONG *, + FLONG *) +{ + + VERBOSE(DLLTEXT("IOemUI:QueryColorProfile entry.\r\n")); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI::FontInstallerDlgProc( + HWND , + UINT , + WPARAM , + LPARAM ) +{ + VERBOSE(DLLTEXT("IOemUI:FontInstallerDlgProc entry.\r\n")); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI::UpdateExternalFonts( + HANDLE , + HANDLE , +_In_ PWSTR ) +{ + VERBOSE(DLLTEXT("IOemUI:UpdateExternalFonts entry.\r\n")); + + return E_NOTIMPL; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) {}; + ~IOemCF() {}; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((IID_IUnknown == iid) || (IID_IClassFactory == iid)) + { + *ppv = static_cast(this) ; + } + else + { + VERBOSE(DLLTEXT("IOemCF::QueryInterface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + HRESULT hr = S_OK; + + //DbgPrint(DLLTEXT("Class factory:\t\tCreate component.")) ; + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (NULL != pUnknownOuter) + { + return CLASS_E_NOAGGREGATION ; + } + + // Create component. + IOemUI* pOemCB = new IOemUI ; + if (NULL == pOemCB) + { + return E_OUTOFMEMORY ; + } + // Get the requested interface. + hr = pOemCB->QueryInterface(iid, ppv) ; + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release() ; + + if (FAILED(hr)) + { + IOEMPTProvider * pOemPT = new IOEMPTProvider(); + + if(NULL == pOemPT) + { + return E_OUTOFMEMORY; + } + + hr = pOemPT->QueryInterface(iid, ppv) ; + + pOemPT->Release(); + } + + return hr ; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks) ; + } + else + { + InterlockedDecrement(&g_cServerLocks) ; + } + return S_OK ; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((0 == g_cComponents) && (0 == g_cServerLocks)) + { + return S_OK ; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:Create class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (CLSID_OEMUI != clsid && CLSID_OEMPTPROVIDER != clsid) + { + return CLASS_E_CLASSNOTAVAILABLE ; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF ; // Reference count set to 1 + // in constructor + if (NULL == pFontCF) + { + return E_OUTOFMEMORY ; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv) ; + pFontCF->Release() ; + + return hr ; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.hxx new file mode 100644 index 00000000..99b950d3 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/intrface.hxx @@ -0,0 +1,178 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.cxx +// +// PURPOSE: Header of interface for PScript4, PScript5, Unidrv4, +// Unidrv5 UI plug-ins. +// +// + +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI +// +class IOemUI: public IPrintOemUI +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + IOemUI() : m_cRef(1) {}; + ~IOemUI(); + +protected: + LONG m_cRef; +}; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oem.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oem.hxx new file mode 100644 index 00000000..a8c7b03c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oem.hxx @@ -0,0 +1,26 @@ +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: oem.hxx +// + +#pragma once + +//////////////////////////////////////////////////////// +// OEM Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + +// OEM UI Misc defines. +#define DLLTEXT(s) "PTPC Plugin: " s + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.cxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.cxx new file mode 100644 index 00000000..e0e94632 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.cxx @@ -0,0 +1,1145 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: oemptprovider.cxx +// +// +// PURPOSE: Implementation of IOEMPTProvider Class. +// The Provider class implements the +// IPrintOemPrintTicketProvider interface functions that +// provide the plug-in access to Print Ticket and allow the +// plug-in to understand the Unidrv private setting in +// the Print Ticket and expose its private settings to +// Unidrv by putting them publicly in the Print Ticket. The +// various provider methods make use of the +// IPrintCoreHelper Interface methods to +// create instances of XML objects and to communicate +// information with Unidrv. +// +// Functions: +// IPrintOemPrintTicketProvider Interface Functions. +// Private Functions of class IOEMPTProvider. +// + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +#include "precomp.hxx" +#include "globals.hxx" +#include "debug.hxx" +#include "oem.hxx" +#include "xmlhandler.hxx" +#include "oemptprovider.hxx" +#include "printschema.hxx" + +/*++ + +Routine Name: + + IOEMPTProvider constructor + +Routine Description: + + Constructor + +Arguments: + + None + +Return Value: + + None + +--*/ +IOEMPTProvider::IOEMPTProvider() + : m_pCoreHelper(NULL), + m_cRef(1) +{ +} + +/*++ + +Routine Name: + + IOEMPTProvider destructor + +Routine Description: + + Destructor + +Arguments: + + None + +Return Value: + + None + +--*/ + +IOEMPTProvider::~IOEMPTProvider() +{ + + // + // Make sure that helper interface is released. + // + if (m_pCoreHelper) + { + m_pCoreHelper->Release(); + m_pCoreHelper = NULL; + } + + // + // If this instance of the object is being deleted, then the reference + // count should be zero. + // + ASSERT(0 == m_cRef); + +} + +/*++ + +Routine Name: + + IOEMPTProvider QueryInterface + +Routine Description: + + Returns a pointer to a specified interface on an object to which a client currently holds an + interface pointer. + This function must call IUnknown::AddRef on the pointer it returns. + +Arguments: + + riid - Identifier of requested Interface. + ppObj - Output variable that receives the pointer to requested Interface on success + +Return Value: + + HRESULT + S_OK - If the Interface requested is supported + E_NOINTERFACE otherwise + +--*/ + +STDMETHODIMP IOEMPTProvider::QueryInterface( + REFIID riid, + void **ppObj + ) +{ + if ((IID_IUnknown == riid) || (IID_IPrintOemPrintTicketProvider == riid)) + { + *ppObj = static_cast(this); + } + else + { + *ppObj = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppObj)->AddRef(); + return S_OK ; +} + +/*++ + +Routine Name: + + AddRef + +Routine Description: + + The AddRef method increments the reference count for an an interface + on an object. It should be called for every new copy of a pointer to + an interface on a given object. + +Arguments: + + None + +Return Value: + + Returns the value of the new reference count. + +--*/ + +STDMETHODIMP_(ULONG) IOEMPTProvider::AddRef( + VOID + ) +{ + return InterlockedIncrement(&m_cRef); +} + +/*++ + +Routine Name: + + Release + +Routine Description: + + The Release method decrements the reference count for the calling + interface on a object. If the reference count on the object falls + to 0, the object is freed from memory. + +Arguments: + + None + +Return Value: + + Returns the resulting value of the reference count. + +--*/ +_At_(this, __drv_freesMem(object)) +STDMETHODIMP_(ULONG) IOEMPTProvider::Release( + THIS + ) +{ + ULONG cRef = InterlockedDecrement(&m_cRef); + + if (0 == cRef) + { + delete this; + } + return cRef; +} + +/*++ + +Routine Name: + + GetSupportedVersions + +Routine Description: + + The routine returns major versions of Printschema schema supported by the plug-in Provider. + + +Arguments: + hPrinter - Printer Handle + ppVersions - OUT pointer to array of version numbers to be filled in by the plug-in + cVersions - OUT pointer to count of Number of versions supported by plug-in + +Return Value: + HRESULT + S_OK - On Success + E_* - On failure + +--*/ +STDMETHODIMP IOEMPTProvider::GetSupportedVersions +( + _In_ HANDLE , + _Outptr_result_buffer_maybenull_(*cVersions) INT *ppVersions[], + _Out_ INT *cVersions + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::GetSupportedVersions: entry.\r\n")); + + HRESULT hr = S_OK; + + // + // check if input parameters are valid + // + if (!ppVersions || !cVersions) + { + return E_INVALIDARG; + } + + // + // The Plug-in Provider need to allocate memory for the input version array and + // then fill it with version information + // + *ppVersions = (INT *)CoTaskMemAlloc(sizeof(INT)); + + if (!*ppVersions) + { + *cVersions = 0; + return E_OUTOFMEMORY; + } + else + { + // + // version number 1 is the only version supported currently + // + + *cVersions = 1; + (*ppVersions)[0] = PRINTSCHEMA_VERSION_NUMBER; + } + + return hr; +} + +/*++ + +Routine Name: + + BindPrinter + +Routine Description: + + Bind Printer is the part of the Unidrv's activity to bind to a device. It allows the plug-in to cache + certain information that can be used later on. + +Arguments: + + hPrinter - Printer Handle supplied by Unidrv + version - version of Printschema + pOptions - Flags passed out to set configurable options supported by caller + cNamespaces - Count of private namespaces of plug-in + ppNamespaces - OUT pointer to the array of Namespace URIs filled in by plug-in + +Return Value: + + HRESULT + S_OK - On Success + E_VERSION_NOT_SUPPORTED - if printer version specified is not supported by plug-in + E_* - On any other failure + +--*/ + +STDMETHODIMP IOEMPTProvider::BindPrinter +( + _In_ HANDLE hPrinter, + INT version, + _Out_ POEMPTOPTS pOptions, + _Out_ INT *cNamespaces, + _Outptr_result_buffer_maybenull_(*cNamespaces) BSTR **ppNamespaces + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::BindPrinter: entry.\r\n")); + + HRESULT hr = S_OK; + + // + // check if input parameters are NULL + // Printer Handle should be provided by Unidrv in this call, which is cached by plug-in provider and + // is later on used while making calls to Plug-in Helper Interface methods. + // + if (!pOptions || !cNamespaces || !ppNamespaces || !hPrinter) + { + return E_INVALIDARG; + } + + + *ppNamespaces = NULL; + + *cNamespaces = 0; + + // + // Agree on the Printschema version with Unidrv + // Version 1 is the only version currently supported + // + if (PRINTSCHEMA_VERSION_NUMBER != version) + { + return E_VERSION_NOT_SUPPORTED; + } + + // + // Bind to the Physical Printer device + // cache the printer handle for further use + // + m_hPrinterCached = hPrinter; + + // + // Flags to set configurable options, + // OEMPT_DEFAULT defined in prcomoem.h + // + *pOptions = OEMPT_DEFAULT; + + return hr; + +} + +/*++ + +Routine Name: + + PublishPrintTicketHelperInterface + +Routine Description: + + For a number of operations, the plug-in needs to use the Helper Interface utilities provided by + Unidrv. Unidrv uses this method to publish the Print Ticket Helper Interface, IPrintCoreHelper. + Plug-in should return SUCCESS after successfully incrementing the reference count of the interface. + +Arguments: + + pHelper - IPrintCoreHelper interface pointer + +Return Value: + + HRESULT + S_OK - On Success + E_* - On failure + +--*/ +STDMETHODIMP IOEMPTProvider::PublishPrintTicketHelperInterface +( + _In_ IUnknown *pHelper + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::PublishPrintTicketHelperInterface: entry.\r\n")); + + if (!pHelper) + { + return E_INVALIDARG; + } + + HRESULT hr = S_OK; + + // + // Need to store pointer to Driver Helper functions, if we already haven't. + // + if (NULL == m_pCoreHelper) + { + hr = pHelper->QueryInterface(IID_IPrintCoreHelperUni, (VOID**)&m_pCoreHelper); + } + + // + // It's possible that this routine will publish other interfaces in the + // future. If the object published did not support the desired interface, + // this routine should still succeed. + // + // If the helper interface is needed, but for some reason was not + // published (this would be an error on the OS's part), you should + // detect this and fail during the call-back where you intended to + // use the helper interface. + // + + if (E_NOINTERFACE == hr) + { + hr = S_OK; + } + + return hr; +} + +/*++ + +Routine Name: + + QueryDeviceDefaultNamespace + +Routine Description: + + Plug-in should specify the name of Private namespace URI that Unidrv + should be using to handle any features defined in the GPD that Unidrv + does not recognize plug-in may specify a set of namespaces as a result + of the call to BindPrinter method, and Unidrv needs to know which of + them is to be used as default namespace so that, for all the features + that Unidrv does not recognize, it will put them under this namespace + in Print Ticket. + + This method is optional. A plug-in can return E_NOTIMPL from this + method if there are multiple plug-ins and another plug-in is providing + the default, or if the plug-in does not want to change the default + namespace that unidrv provides. + + Note: It is Unidrv's responsibility to add the private namespace URI + that plug-in has specified through this call in the root node of the + DOM document, and also define a prefix for it so that plug-in should + use the prefix defined by Unidrv when it wishes to add any new node to + the Print Ticket under its private namespace. Plug-in should not define + its own prefix for this default private namespace URI. + +Arguments: + + pbstrNamespaceUri - OUT Pointer to namespace URI to be filled in and returned by plug-in + +Return Value: + + HRESULT + S_OK - On success + E_* - On failure + +--*/ + +STDMETHODIMP IOEMPTProvider::QueryDeviceDefaultNamespace +( + _Out_ BSTR * + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::QueryDeviceDefaultNamespace: entry.\r\n")); + + return E_NOTIMPL; +} + +/*++ + +Routine Name: + + ConvertPrintTicketToDevMode + +Routine Description: + + Unidrv will call this routine before it performs its part of PT->DM + conversion. The plug-in is passed with an input Print Ticket that is + fully populated, and Devmode which has default settings in it. For + this conversion, the plug-in needs to undo whatever changes it made to + the Print Ticket during Devmode->PT conversion. + +Arguments: + + pPrintTicket - pointer to input Print Ticket + cbDevmode - size in bytes of input full devmode + pDevmode - pointer to input full devmode buffer + cbDrvPrivateSize - buffer size in bytes of plug-in private devmode + pPrivateDevmode - pointer to plug-in private devmode buffer + + +Return Value: + + HRESULT + S_OK - On Success + E_* - On failure + +--*/ + +STDMETHODIMP IOEMPTProvider::ConvertPrintTicketToDevMode +( + _In_ IXMLDOMDocument2 *pPrintTicket, + ULONG cbDevmode, + _Inout_updates_bytes_(cbDevmode) + PDEVMODE pDevmode, + ULONG , // cbDrvPrivateSize + _Inout_ PVOID // pPrivateDevmode + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::ConvertPrintTicketToDevMode: entry.\r\n")); + + // + // cbDrvPrivateSize will be 0 because this plug-in doesn't + // support a private DEVMODE. + // + if (!cbDevmode || !pDevmode || !pPrintTicket) + { + return E_INVALIDARG; + } + + return S_OK; +} + +/*++ + +Routine Name: + + ConvertDevModeToPrintTicket + +Routine Description: + + Unidrv will call the routine with an Input Print + Ticket that is populated with public and Unidrv private features. For + those features in the GPD that Unidrv does not understand, it puts + them in the PT under the private namespace (either specified by the + plug-in through QueryDeviceDefaultNamespace or created by itself). It + is the plug-in's responsibility to read the corresponding features + from the input PT and put them in public printschema namespace, so + that any higher level application making use of a print ticket can + read and interpret these settings. + + +Arguments: + + cbDevmode - size in bytes of input full devmode + pDevmode - pointer to input full devmode buffer + cbDrvPrivateSize - buffer size in bytes of plug-in private devmode + pPrivateDevmode - pointer to plug-in private devmode buffer + pPrintTicket - pointer to input Print Ticket + +Return Value: + + HRESULT + S_OK - On Success + E_* - On failure + +--*/ +STDMETHODIMP IOEMPTProvider::ConvertDevModeToPrintTicket +( + ULONG cbDevmode, + _Inout_updates_bytes_(cbDevmode) + PDEVMODE pDevmode, + ULONG , // cbDrvPrivateSize + _Inout_ PVOID , // pPrivateDevmode, + _Inout_ IXMLDOMDocument2 *pPrintTicket + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::ConvertDevModeToPrintTicket: entry.\r\n")); + + // + // cbDrvPrivateSize will be 0 because this plug-in doesn't + // support a private DEVMODE. + // + if (!cbDevmode || !pDevmode || !pPrintTicket) + { + return E_INVALIDARG; + } + + HRESULT hr = S_OK; + + OEMPTXMLHandler opxh; + EIntentValue eIntentValue = printschema::photoprintingintent::None; + + // + // Initialize PrintTicketHandler + // + + hr = opxh.SetRoot(pPrintTicket, m_pCoreHelper); + + if (SUCCEEDED(hr)) + { + hr = ReadAndDeletePhotoPrintingIntent(opxh, eIntentValue); + } + + if (S_FALSE == hr) + { + hr = S_OK; + } + + return hr; +} + + +/*++ + +Routine Name: + + CompletePrintCapabilities + +Routine Description: + + Unidrv calls this routine with an input Device Capabilities Document + that is partially populated with Device capabilities information + filled in by Unidrv for features that it understands. The plug-in + needs to read any private features in the input Print Ticket, delete + them and add them back under Printschema namespace so that higher + level applications can understand them and make use of them. + +Arguments: + + pPrintTicket - pointer to input Print Ticket + pCapabilities - pointer to Device Capabilities Document. + +Return Value: + + HRESULT + S_OK - On Success + E_* - On failure + +--*/ +STDMETHODIMP IOEMPTProvider::CompletePrintCapabilities +( + _In_opt_ IXMLDOMDocument2 *, + _Inout_ IXMLDOMDocument2 *pCapabilities + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::CompletePrintCapabilities: entry.\r\n")); + + if (!pCapabilities) + { + return E_INVALIDARG; + } + + return S_OK; +} + +/*++ + +Routine Name: + + ExpandIntentOptions + +Routine Description: + + As part of its Merge and Validate Procedure, the + Unidrv/Postscript driver will call this routine to give the plug-in a + chance to expand options which represent intent into their individual + settings in other features in the print ticket. This has two + important effects: the client sees the results of the intent + expansion, and unidrv resolves constraints against the individual + features which are affected by the intent. + + If the plug-in does not support any intent features, then the plug-in + should simply return S_OK. + +Arguments: + + pPrintTicket - Pointer to input Print Ticket. + +Return Value: + + HRESULT + S_OK - On Success + E_* - On failure + +--*/ + +STDMETHODIMP IOEMPTProvider::ExpandIntentOptions( + _Inout_ IXMLDOMDocument2 *pPrintTicket + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::ExpandIntentOptions: entry.\r\n")); + + if (!pPrintTicket) + { + return E_INVALIDARG; + } + + HRESULT hr = S_OK; + OEMPTXMLHandler opxh; + + // + // Initialize PrintTicketHandler + // + + hr = opxh.SetRoot(pPrintTicket, m_pCoreHelper); + + // + // Read in the photo printing intent value, if it exists. If it + // doesn't, the default value of None is assumed instead. + // + + EIntentValue eIntentValue = printschema::photoprintingintent::None; + + if (SUCCEEDED(hr)) + { + hr = ReadAndDeletePhotoPrintingIntent(opxh, eIntentValue); + } + + if (S_FALSE == hr) + { + hr = S_OK; + } + + if (printschema::photoprintingintent::None != eIntentValue) + { + IOEMPTProvider::IntentConversionEntry entry = IOEMPTProvider::intentConversionTable[eIntentValue]; + + // + // Set appropriate values for PageMediaType and + // PageOutputQuality. Override any existing values of the + // options (by deleting before adding). + // + + if (SUCCEEDED(hr)) + { + hr = AddOrOverridePageMediaType(opxh, entry.pageMediaType); + } + + if (SUCCEEDED(hr)) + { + hr = AddOrOverridePageOutputQuality(opxh, entry.pageOutputQuality); + } + } + + return hr; +} + +/*++ + +Routine Name: + + ValidatePrintTicket + +Routine Description: + + The plug-in might need to delete any feature under private namespace + from input PT that are also in the public namespace because of Merge + and Validate. + + The Validate method should also perform any conflict resolution if + necessary looking at the settings made in public and unidrv private + part of Print Ticket, to make sure that the resultant Print Ticket is a + valid one, and has all constraints resolved. + +Arguments: + + pBaseTicket - Pointer to input Print Ticket. + +Return Value: + + HRESULT + S_NO_CONFLICT/S_CONFLICT_RESOLVED - On Success + E_* - On failure + +--*/ + +STDMETHODIMP IOEMPTProvider::ValidatePrintTicket( + _Inout_ IXMLDOMDocument2 *pPrintTicket + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::ValidatePrintTicket: entry.\r\n")); + + if (!pPrintTicket) + { + return E_INVALIDARG; + } + + // + // If the plug-in performs validation successfully, it needs to + // send either S_NO_CONFLICT or S_CONFLICT_RESOLVED as the result + // code, sending hr = S_OK will not work since Unidrv expects one + // of the above two success codes to interpret successful + // completion of plug-in validate method. + // + + return S_NO_CONFLICT; +} + +// +// Private stuff +// + +IOEMPTProvider::IntentConversionEntry IOEMPTProvider::intentConversionTable[] = +{ + { NULL, NULL, }, + { printschema::pagemediatype::PLAIN, printschema::pageoutputquality::DRAFT, }, + { printschema::pagemediatype::PHOTOGRAPHIC, printschema::pageoutputquality::HIGH, }, + { printschema::pagemediatype::PHOTOGRAPHIC, printschema::pageoutputquality::PHOTOGRAPHIC, }, +}; + +/*++ + +Routine Name: + + ReadAndDeletePhotoPrintingIntent + +Routine Description: + + This function gets the value of the Photo Printing Intent from a Print + Ticket and returns it in eIntentValue. It also deletes the entire + feature from the Ticket. + +Arguments: + + opxh - reference to input XMLHandler + eIntentValue - reference to output intent value + +Return Value: + + HRESULT + S_OK - On success, if intent was found + S_FALSE - On Success, if intent was not found + E_* - On failure + +--*/ + +HRESULT IOEMPTProvider::ReadAndDeletePhotoPrintingIntent( + OEMPTXMLHandler &opxh, + EIntentValue &eIntentValue + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::ReadAndDeletePhotoPrintingIntent: entry.\r\n")); + + HRESULT hr = S_OK; + + IXMLDOMElement *pPhotoPrintingIntentFeature = NULL; + IXMLDOMElement *pPhotoPrintingIntentOption = NULL; + + hr = opxh.GetFeatureNode(NULL, // meaning root is parent + printschema::KEYWORDS_URI, + printschema::photoprintingintent::FEATURE, + &pPhotoPrintingIntentFeature); + + // + // Check for S_OK == hr and not SUCCEEDED(hr) because + // GetFeatureNode returns S_FALSE if feature is not found + // + + if (S_OK == hr && pPhotoPrintingIntentFeature) + { + hr = opxh.GetOptionNode(pPhotoPrintingIntentFeature, + &pPhotoPrintingIntentOption); + } + + BSTR bstrIntentNamespace = NULL; + BSTR bstrIntentValue = NULL; + + if (S_OK == hr && pPhotoPrintingIntentOption) + { + hr = opxh.GetXMLAttribute(pPhotoPrintingIntentOption, &bstrIntentNamespace, &bstrIntentValue); + } + + if (S_OK == hr && NULL != bstrIntentNamespace) + { + if (0 != wcscmp(bstrIntentNamespace, printschema::KEYWORDS_URI)) + { + // + // We do not delete the node if it specifies a different + // namespace + // + hr = S_FALSE; + } + } + + // + // Search for intent, looping across all possible (valid) values, and store it in eIntentValue + // + + if (S_OK == hr && NULL != bstrIntentValue) + { + EIntentValue e = EIntentValue(0); + + for (; e < printschema::photoprintingintent::EIntentValueMax; ++e) + { + if (0 == wcscmp(bstrIntentValue, printschema::photoprintingintent::OPTIONS[e])) + { + eIntentValue = e; + break; + } + } + + if (printschema::photoprintingintent::EIntentValueMax == e) + { + // + // We do not delete the node if the attribute name + // in the Print Ticket is not one of the valid ones + // + hr = S_FALSE; + } + } + + // + // If found, delete intent + // + + if (S_OK == hr) + { + hr = opxh.DeleteFeatureNode(NULL, pPhotoPrintingIntentFeature); + } + + // + // Make sure all BSTRs are freed, ... + // + + if (bstrIntentNamespace) + { + SysFreeString(bstrIntentNamespace); + bstrIntentNamespace = NULL; + } + + if (bstrIntentValue) + { + SysFreeString(bstrIntentValue); + bstrIntentValue = NULL; + } + + // + // ... and interface pointers released + // + + if (pPhotoPrintingIntentFeature) + { + pPhotoPrintingIntentFeature->Release(); + } + + if (pPhotoPrintingIntentOption) + { + pPhotoPrintingIntentOption->Release(); + } + + return hr; +} + +/*++ + +Routine Name: + + AddOrOverridePageMediaType + +Routine Description: + + This routine takes in the value of the PageMediaType to be set, + depending on the intent that was present. It then deletes any existing + PageMediaType value in the ticket, and then adds the new PageMediaType + value. + +Arguments: + + opxh - reference to input XMLHandler + lpcwstrPageMediaType - input PageMediaType string + +Return Value: + + HRESULT + S_OK - On success + E_* - On failure + +--*/ + +HRESULT IOEMPTProvider::AddOrOverridePageMediaType( + OEMPTXMLHandler &opxh, + LPCWSTR lpcwstrPageMediaType + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::AddOrOverridePageMediaType: entry.\r\n")); + + HRESULT hr = S_OK; + + if (NULL == lpcwstrPageMediaType) + { + return S_OK; + } + + IXMLDOMElement *pPageMediaTypeOld = NULL; + IXMLDOMElement *pPageMediaTypeNew = NULL; + + // + // Search for, and delete any old PageMediaType option, since we're + // going to override it + // + + hr = opxh.GetFeatureNode(NULL, + printschema::KEYWORDS_URI, + printschema::pagemediatype::FEATURE, + &pPageMediaTypeOld); + + if (S_OK == hr) + { + hr = opxh.DeleteFeatureNode(NULL, pPageMediaTypeOld); + } + + // + // GetFeatureNode might have returned S_FALSE if it couldn't find + // such a node, so from now on, we check for SUCCEEDED + // + + // + // Create PageMediaType feature node + // + + if (SUCCEEDED(hr)) + { + hr = opxh.CreateFeatureNode(NULL, + printschema::KEYWORDS_URI, + printschema::pagemediatype::FEATURE, + &pPageMediaTypeNew); + } + + // + // Create option node under the feature node above + // + + if (SUCCEEDED(hr)) + { + hr = opxh.CreateOptionNode(pPageMediaTypeNew, + printschema::KEYWORDS_URI, + lpcwstrPageMediaType, + NULL); + } + + if (pPageMediaTypeOld) + { + pPageMediaTypeOld->Release(); + } + + if (pPageMediaTypeNew) + { + pPageMediaTypeNew->Release(); + } + + return hr; +} + +/*++ + +Routine Name: + + AddOrOverridePageOutputQuality + +Routine Description: + + This routine, similar to AddOrOverridePageMediaType, takes in the + value of the PageOutputQuality to be set, depending on the intent that + was present. It then deletes any existing PageOutputQuality value in + the ticket, and then adds the new PageOutputQuality value. + +Arguments: + + opxh - reference to input XMLHandler + lpcwstrPageOutputQuality - input PageOutputQuality string + +Return Value: + + HRESULT + S_OK - On success + E_* - On failure + +--*/ + +HRESULT IOEMPTProvider::AddOrOverridePageOutputQuality( + OEMPTXMLHandler &opxh, + LPCWSTR lpcwstrPageOutputQuality + ) +{ + VERBOSE(DLLTEXT("IOEMPTProvider::AddOrOverridePageOutputQuality: entry.\r\n")); + + HRESULT hr = S_OK; + + if (NULL == lpcwstrPageOutputQuality) + { + return S_OK; + } + + IXMLDOMElement *pPageOutputQualityOld = NULL; + IXMLDOMElement *pPageOutputQualityNew = NULL; + + // + // Search for, and delete any old PageOutputQuality option, since we're + // going to override it + // + + hr = opxh.GetFeatureNode(NULL, + printschema::KEYWORDS_URI, + printschema::pageoutputquality::FEATURE, + &pPageOutputQualityOld); + + if (S_OK == hr) + { + hr = opxh.DeleteFeatureNode(NULL, pPageOutputQualityOld); + } + + // + // GetFeatureNode might have returned S_FALSE if it couldn't find + // such a node, so from now on, we check for SUCCEEDED + // + + // + // Create PageOutputQuality feature node + // + + if (SUCCEEDED(hr)) + { + hr = opxh.CreateFeatureNode(NULL, + printschema::KEYWORDS_URI, + printschema::pageoutputquality::FEATURE, + &pPageOutputQualityNew); + } + + // + // Create option node under the feature node above + // + + if (SUCCEEDED(hr)) + { + hr = opxh.CreateOptionNode(pPageOutputQualityNew, + printschema::KEYWORDS_URI, + lpcwstrPageOutputQuality, + NULL); + } + + if (pPageOutputQualityOld) + { + pPageOutputQualityOld->Release(); + } + + if (pPageOutputQualityNew) + { + pPageOutputQualityNew->Release(); + } + + return hr; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.hxx new file mode 100644 index 00000000..77b54be1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/oemptprovider.hxx @@ -0,0 +1,143 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: oemptprovider.hxx +// +// +// PURPOSE: Definition of IOEMPTProvider Class. +// +// + +#pragma once + +#include "xmlhandler.hxx" +#include "printschema.hxx" + +using printschema::photoprintingintent::EIntentValue; + +// +// The Provider class to Implement IPrintOemPrintTicketProvider Interface +// + +class IOEMPTProvider : public IPrintOemPrintTicketProvider +{ +public: + + // + // Public Methods go here + // + IOEMPTProvider(); + virtual ~IOEMPTProvider(); + + // + // Basic COM Methods + // + STDMETHODIMP QueryInterface(THIS_ REFIID riid, void **ppvObj); + + STDMETHODIMP_(ULONG) AddRef(THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHODIMP_(ULONG) Release(THIS); + + + // + // IPrintOemPrintTicketProvider methods + // + + STDMETHOD(GetSupportedVersions)(THIS_ + _In_ HANDLE hPrinter, + _Outptr_result_buffer_maybenull_(*cVersions) INT *ppVersions[], + _Out_ INT *cVersions + ); + + STDMETHOD(BindPrinter)(THIS_ + _In_ HANDLE hPrinter, + INT version, + _Out_ POEMPTOPTS pOptions, + _Out_ INT *cNamespaces, + _Outptr_result_buffer_maybenull_(*cNamespaces) BSTR **ppNamespaces + ); + + STDMETHOD(PublishPrintTicketHelperInterface)(THIS_ + _In_ IUnknown *pHelper + ); + + STDMETHOD(QueryDeviceDefaultNamespace)(THIS_ + _Out_ BSTR *pbstrNamespaceUri + ); + + STDMETHOD(ConvertPrintTicketToDevMode)(THIS_ + _In_ IXMLDOMDocument2 *pPrintTicket, + ULONG cbDevmode, + _Inout_updates_bytes_(cbDevmode) + PDEVMODE pDevmode, + ULONG cbDrvPrivateSize, + _Inout_ PVOID pPrivateDevmode + ); + + STDMETHOD(ConvertDevModeToPrintTicket)(THIS_ + ULONG cbDevmode, + _Inout_updates_bytes_(cbDevmode) + PDEVMODE pDevmode, + ULONG cbDrvPrivateSize, + _Inout_ PVOID pPrivateDevmode, + _Inout_ IXMLDOMDocument2 *pPrintTicket + ); + + STDMETHOD(CompletePrintCapabilities)(THIS_ + _In_opt_ IXMLDOMDocument2 *pPrintTicket, + _Inout_ IXMLDOMDocument2 *pCapabilities + ); + + STDMETHOD(ExpandIntentOptions)(THIS_ + _Inout_ IXMLDOMDocument2 *pPrintTicket + ); + + STDMETHOD(ValidatePrintTicket)(THIS_ + _Inout_ IXMLDOMDocument2 *pPrintTicket + ); + +private: + + // + // Data members go here + // + LONG m_cRef; // COM reference count + HANDLE m_hPrinterCached; // cached printer handle + IPrintCoreHelperUni *m_pCoreHelper; // cached pointer to plug-in helper interface + + struct IntentConversionEntry + { + LPCWSTR pageMediaType; + LPCWSTR pageOutputQuality; + }; + + static IntentConversionEntry intentConversionTable[printschema::photoprintingintent::EIntentValueMax]; + + // + // Private Methods + // + + HRESULT ReadAndDeletePhotoPrintingIntent( + OEMPTXMLHandler &opxh, + EIntentValue &eIntentValue + ); + + HRESULT AddOrOverridePageMediaType( + OEMPTXMLHandler &opxh, + LPCWSTR lpcwstrPageMediaType + ); + + HRESULT AddOrOverridePageOutputQuality( + OEMPTXMLHandler &opxh, + LPCWSTR lpcwstrPageOutputQuality + ); + +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precomp.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precomp.hxx new file mode 100644 index 00000000..fc8cb4be --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precomp.hxx @@ -0,0 +1,49 @@ +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.hxx +// +// PURPOSE: Header files that should be in the precompiled header. +// + +#pragma once + +// Required header files that shouldn't change often. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include +#include + +#include "common.ver" + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precompsrc.cpp new file mode 100644 index 00000000..5d84a122 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.hxx" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.cxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.cxx new file mode 100644 index 00000000..d22ffc10 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.cxx @@ -0,0 +1,64 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: printschema.cxx +// +// PURPOSE: Constant definitions for print schema names. +// +// + +#include "precomp.hxx" +#include "printschema.hxx" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +LPCWSTR printschema::FRAMEWORK_URI = + L"http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"; + +LPCWSTR printschema::KEYWORDS_URI = + L"http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords"; + +// +// Element types defined in Printschema framework +// + +LPCWSTR printschema::FEATURE_ELEMENT_NAME = L"Feature"; +LPCWSTR printschema::OPTION_ELEMENT_NAME = L"Option"; +LPCWSTR printschema::NAME_ATTRIBUTE_NAME = L"name"; + +// +// Elements described as Printschema keywords +// + +LPCWSTR printschema::photoprintingintent::FEATURE = L"PagePhotoPrintingIntent"; +LPCWSTR printschema::photoprintingintent::OPTIONS[] = { L"None", L"PhotoDraft", L"PhotoStandard", L"PhotoBest", }; + +namespace printschema +{ + namespace photoprintingintent + { + // + // operator prefix increment + // + const EIntentValue & operator++(EIntentValue &e) + + { + e = (EIntentValue)(e + 1); + return e; + } + } +} + +LPCWSTR printschema::pagemediatype::FEATURE = L"PageMediaType"; +LPCWSTR printschema::pagemediatype::PLAIN = L"Plain"; +LPCWSTR printschema::pagemediatype::PHOTOGRAPHIC = L"Photographic"; + +LPCWSTR printschema::pageoutputquality::FEATURE = L"PageOutputQuality"; +LPCWSTR printschema::pageoutputquality::DRAFT = L"Draft"; +LPCWSTR printschema::pageoutputquality::HIGH = L"High"; +LPCWSTR printschema::pageoutputquality::PHOTOGRAPHIC = L"Photographic"; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.hxx new file mode 100644 index 00000000..e6bd73b4 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/printschema.hxx @@ -0,0 +1,74 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: printschema.hxx +// +// PURPOSE: Constant declarations for print schema names. +// + +#pragma once + +typedef +enum tagPrintschemaVersion +{ + PRINTSCHEMA_VERSION_NUMBER = 1 +} EPrintschemaVersion; + + +namespace printschema +{ + + extern LPCWSTR FRAMEWORK_URI; + + extern LPCWSTR KEYWORDS_URI; + + // + // Element types defined in Printschema framework + // + + extern LPCWSTR FEATURE_ELEMENT_NAME; + extern LPCWSTR OPTION_ELEMENT_NAME; + extern LPCWSTR NAME_ATTRIBUTE_NAME; + + // + // Elements described as Printschema keywords + // + + namespace photoprintingintent + { + extern LPCWSTR FEATURE; + + enum EIntentValue + { + None = 0, + Draft, + Standard, + Best, + EIntentValueMax, // size of enum list + }; + + extern LPCWSTR OPTIONS[EIntentValueMax]; + + const EIntentValue & operator++(EIntentValue &e); + } + + namespace pagemediatype + { + extern LPCWSTR FEATURE; + extern LPCWSTR PLAIN; + extern LPCWSTR PHOTOGRAPHIC; + } + + namespace pageoutputquality + { + extern LPCWSTR FEATURE; + extern LPCWSTR DRAFT; + extern LPCWSTR HIGH; + extern LPCWSTR PHOTOGRAPHIC; + } + +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.def b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.def new file mode 100644 index 00000000..20165c2d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.def @@ -0,0 +1,3 @@ +LIBRARY PTPCPLPR +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.rc b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.rc new file mode 100644 index 00000000..c40881de --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/ptpcplpr.rc @@ -0,0 +1,24 @@ +#include "winres.h" +#include + +#define VER_FILETYPE VFT_DLL +#define VER_FILESUBTYPE VFT2_UNKNOWN +#define VER_FILEDESCRIPTION_STR "PT/PC Plugin Provider Module" +#define VER_INTERNALNAME_STR "PTPCPlPr" +#define VER_ORIGINALFILENAME_STR "PTPCPlPr.dll" + +///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + +#include "common.ver" diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.cxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.cxx new file mode 100644 index 00000000..4bbee2e8 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.cxx @@ -0,0 +1,1612 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: xmlhandler.cxx +// +// +// PURPOSE: Helper Class that handles all functionality related to +// processing of input PrintTicket/PrintCapabilities XML documents. +// +// +// Functions: Public and Private functions of class OEMPTXMLHandler. +// + +#include "precomp.hxx" + +#include "globals.hxx" +#include "printschema.hxx" +#include "xmlhandler.hxx" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//Disable the warnings generated by PFEFAST for conversion between wchar_t * and BSTR +//because MSXML defines all its interfaces parameters as BSTR but officially declares itself +//to be wchar_t safe. + +#pragma prefast(disable:__WARNING_WCHAR_TO_BSTR) + +// +// MSXML makes the guarantee that we can call it's methods with LPTSTRs instead +// of BSTRs, so we need to do a const cast whenever we pass our strings to MSXML. +// +#define MSXMLSTR(lptstr_value) (const_cast(lptstr_value)) + +/*++ +Routine Name: + OEMPTXMLHandler +Routine Description: + Print Ticket Handler Constructor + + +Arguments: + None + +Return Value: + None + +--*/ + +OEMPTXMLHandler::OEMPTXMLHandler() : + m_pRootDocument(NULL), + m_pRootElement(NULL), + m_pNSManager(NULL), + m_dwNextIndex(0) +{ +} + +/*++ +Routine Name: + ~OEMPTXMLHandler( +Routine Description: + Print Ticket Handler Destructor + +Arguments: + None + +Return Value: + None + +--*/ + +OEMPTXMLHandler::~OEMPTXMLHandler() +{ + if (m_pRootDocument) + { + m_pRootDocument->Release(); + m_pRootDocument = NULL; + } + if (m_pRootElement) + { + m_pRootElement->Release(); + m_pRootElement = NULL; + } + if (m_pNSManager) + { + m_pNSManager->Release(); + m_pNSManager = NULL; + } +} + +/*++ +Routine Name: + SetRoot + +Routine Description: + + Initialization routine. Sets root of the DOM tree. Alos creates an instance of xml namespace manager + using plug-in helper interface method. + + Note: This routine MUST BE called before any other xml handling routines are called. + Note also that it is not necessary to call CoInitializeEx because Unidrv has already + made that call while creating the DOM tree with appropriate arguments passed on to it + and when Unidrv makes a call to one of plug-in interface routines, since plug-in is + running in the same thread, it does not need to make that call again + In fact the plug-in SHOULD NOT make that call to CoInitializeEx , because Unidrv must have made + that call with some particular concurrency model settings which plug-in cannot find out, + so the plug-in might end up changing the concurrency setting made by Unidrv. + +Arguments: + pRoot - Root of the input DOM tree. + + +Return Value: + HRESULT Completion status code + +--*/ +HRESULT +OEMPTXMLHandler::SetRoot( + _In_ IXMLDOMDocument2 *pRoot, + _In_ IPrintCoreHelper *pHelper + ) +{ + HRESULT hr = S_OK; + + // + // check if input paramters are not NULL + // + if (!pRoot || !pHelper) + { + return E_INVALIDARG; + } + + m_pRootDocument = pRoot; + + m_pRootDocument->AddRef(); + + + // + // Make use of Plug-in Helper Interface method provided by Unidrv to create an Instance of MSXML Namespace Manager. + // The plug-in must make use of Helper Interface provided by Unidrv while creating instance of namespacemanager + // of MSXML DOM document, the plug-in should not load MSXML6.DLL by itself but should rely on Unidrv for + // doing that + // + if (SUCCEEDED(hr)) + { + // + // Note: Current versions of Unidrv support MSXML6 hence plug-in should also support that and write its + // code in compliance with MSXML6 + // + hr = pHelper->CreateInstanceOfMSXMLObject(CLSID_MXNamespaceManager60, NULL, NULL, IID_IMXNamespaceManager, (void**)&m_pNSManager); + } + + // + // Get the Root Element of the document and store it in pRootElement. + // + if (SUCCEEDED(hr)) + { + hr = m_pRootDocument->get_documentElement(&m_pRootElement); + } + + if (FAILED(hr)) + { + if (m_pRootDocument) + { + m_pRootDocument->Release(); + m_pRootDocument = NULL; + } + + if (m_pRootElement) + { + m_pRootElement->Release(); + m_pRootElement = NULL; + } + + if (m_pNSManager) + { + m_pNSManager->Release(); + m_pNSManager = NULL; + } + } + + return hr; +} + +/*++ +Routine Name: + CreateFeatureNode + +Routine Description: + + Creates a new Feature Node + +Arguments: + pParent - parent node of the new feature node, if NULL, root is considered as parent + pszNamespaceURI - namesapce URI to which new node belongs + pszFeatureName - local name of the new feature node + ppFeatureNode - out pointer to newly created node + +Return Value: + HRESULT Completion status code + S_OK on success + E_* on failure + +--*/ + +HRESULT OEMPTXMLHandler::CreateFeatureNode( + _In_opt_ IXMLDOMElement *pParent, + _In_ PCWSTR pszNamespaceURI, + _In_ PCWSTR pszFeatureName, + _Out_opt_ IXMLDOMElement **ppFeatureNode + ) +{ + HRESULT hr = S_OK; + IXMLDOMElement *pNewElement = NULL; + BSTR qName = NULL; + + if (!pszFeatureName) + { + return E_INVALIDARG; + } + + if (!pParent) + { + pParent = m_pRootElement; + } + + + hr = CreateXMLElement(pParent, printschema::FEATURE_ELEMENT_NAME, printschema::FRAMEWORK_URI, &pNewElement); + + if (SUCCEEDED(hr)) + { + hr = CreateQName(pNewElement, pszNamespaceURI, pszFeatureName, &qName); + } + + if (SUCCEEDED(hr)) + { + + // The 'name' attibute node is not namespace qualified; it + // belongs to the namespace of its parent (feature/option) + // node. + + hr = CreateXMLAttribute(pNewElement, printschema::NAME_ATTRIBUTE_NAME, L"", qName); + } + + if (qName) + { + SysFreeString(qName); + qName = NULL; + } + + if (SUCCEEDED(hr) && ppFeatureNode) + { + *ppFeatureNode = pNewElement; + } + else if (pNewElement) + { + pNewElement->Release(); + } + + return hr; + +} + +/*++ +Routine Name: + CreateOptionNode + +Routine Description: + + Creates a new Option Node + +Arguments: + pParent - parent node of the new Option node + pszNamespaceURI - namesapce URI to which new node belongs + pszFeatureName - local name of the new Option node + ppOptionElement - out pointer to newly created node + +Return Value: + HRESULT Completion status code + S_OK on success + E_* on failure + +--*/ + +HRESULT OEMPTXMLHandler::CreateOptionNode( + _In_ IXMLDOMElement *pParent, + _In_ PCWSTR pszNamespaceURI, //print schema URI that corresponds to prefix "prn:" + _In_ PCWSTR pszOptionName, //"TopLeft" etc + _Out_opt_ IXMLDOMElement **ppOptionElement + ) +{ + HRESULT hr = S_OK; + IXMLDOMElement *pNewElement = NULL; + BSTR qName = NULL; + + if (!pParent) + { + return E_INVALIDARG; + } + + hr = CreateXMLElement(pParent, printschema::OPTION_ELEMENT_NAME, printschema::FRAMEWORK_URI, &pNewElement); + + if (SUCCEEDED(hr)) + { + hr = CreateQName(pNewElement, pszNamespaceURI, pszOptionName, &qName); + } + + if (SUCCEEDED(hr)) + { + // The 'name' attibute node is not namespace qualified; it + // belongs to the namespace of its parent (feature/option) + // node. + + hr = CreateXMLAttribute(pNewElement, printschema::NAME_ATTRIBUTE_NAME, L"", qName); + } + + if (qName) + { + SysFreeString(qName); + qName = NULL; + } + + if (SUCCEEDED(hr) && ppOptionElement) + { + *ppOptionElement = pNewElement; + } + else if (pNewElement) + { + pNewElement->Release(); + } + + return hr; +} + +/*++ +Routine Name: + CreateXMLElement + +Routine Description: + Generic method to create new XML element node + +Arguments: + + pParent - pointer to the parent node of the new nod eto be created, if NULL root of DOM tree is considered as parent + pszElementName - local name of the newly created element + pszNamespaceURI - namespace URI that the new element belongs to, the caller can only specify the namespace URI + and not the prefix + ppCreatedElement - double pointer to the newly created element returned by the procedure + +Return Value: + HRESULT Completion status code + S_OK - If the new element node is created successfully + E_* - on failure + +--*/ + +HRESULT OEMPTXMLHandler::CreateXMLElement( + _In_ IXMLDOMElement *pParent, + _In_ PCWSTR pszElementName, + _In_ PCWSTR pszNamespaceURI, + _Out_ IXMLDOMElement **ppCreatedElement + ) +{ + HRESULT hr = S_OK; + IXMLDOMNode *pNewNode = NULL; + BSTR bstrQName = NULL; + + if (!pParent || !pszElementName || !pszNamespaceURI || !ppCreatedElement) + { + return E_INVALIDARG; + } + + // + // create XML Qname + // + hr = CreateQName(pParent, pszNamespaceURI, pszElementName, &bstrQName); + + if (SUCCEEDED(hr)) + { + VARIANT nodeType; + VariantInit(&nodeType); + V_VT(&nodeType) = VT_I4; + V_I4(&nodeType) = NODE_ELEMENT; + hr = m_pRootDocument->createNode(nodeType, bstrQName, MSXMLSTR(pszNamespaceURI), &pNewNode); + if (SUCCEEDED(hr)) + VariantClear(&nodeType); + } + + if (SUCCEEDED(hr)) + hr = pParent->appendChild(pNewNode, NULL); + + + if (SUCCEEDED(hr)) + { + // + // we need to return Interface ptr to IXMLDOMElement. + // + hr = pNewNode->QueryInterface(IID_IXMLDOMElement, (void **)ppCreatedElement); + + // + // if interface is not supported, E_* will be returned in hr, + // we simply return that to the caller. + // + } + + if (pNewNode) + { + // + // release reference to local node Created since it is no longer being used + // + pNewNode->Release(); + } + + if (bstrQName) + { + SysFreeString(bstrQName); + bstrQName = NULL; + } + + return hr; + +} + +/*++ +Routine Name: + CreateQName + +Routine Description: + + Creates XML qname for given local name and namespace URI + Note: It is assumed that a prefix for given URI is already defined in root of DOM document + either by Unidrv or by plug-in itself. + Routine fails if it doesnot find a predefined prefix for given URI. + +Arguments: + pElement - context node + pszUri - Uri + pszLocalName - local name + pQName - a pointer to resultant qname string defined by the routine + +Return Value: + HRESULT Completion status code + + S_OK - On success + E_FAIL - on failure to create Qname + +--*/ +HRESULT OEMPTXMLHandler::CreateQName( + _In_ IXMLDOMElement *pElement, + _In_ PCWSTR pszUri, + _In_ PCWSTR pszLocalName, + _Out_ BSTR *pQName + ) +{ + HRESULT hr = S_OK; + BSTR bstrPrefixString = NULL; + size_t prefixLen = 0; + // Is it the default namespace? If so, don't stick a semicolon in the string + size_t localNameLen = 0; + + if (!pszUri || !pszLocalName || !pQName) + { + return E_INVALIDARG; + } + + *pQName = NULL; + + // + // See if a prefix is already defined for the given URI + // + + hr = getPrefix(pElement, pszUri, &bstrPrefixString); + + // + // It is possible that during validation the prefix might not + // already be defined if we're converting public features to GPD + // features. In that case, we need to add a definition for the + // feature namespace. + // + + if (S_FALSE == hr) + { + hr = declarePrefix(pElement, pszUri, NULL, &bstrPrefixString); + } + + if (SUCCEEDED(hr)) + { + // + // StrSafe function StringCchLength checks if the length of string is less than + // maximum length specified, and returns S_OK if the input string is non NULL and + // length is less that maximum length specified. + // It returns length of string EXCLUDING null terminator + // + hr = StringCchLength(pszLocalName, STR_MAX_CCH, &localNameLen); + } + + if (SUCCEEDED(hr)) + { + if (bstrPrefixString) + { + hr = StringCchLength(bstrPrefixString, STR_MAX_CCH, &prefixLen); + } + } + + if (SUCCEEDED(hr)) + { + if (prefixLen > 0) + { + // non-default namespace + + UINT cchLength = 0; + + if (SUCCEEDED(hr = SizeTAdd(prefixLen, localNameLen, &localNameLen)) && + SUCCEEDED(hr = SizeTAdd(localNameLen, 2, &localNameLen)) && + SUCCEEDED(hr = SizeTToUInt(localNameLen, &cchLength))) + { + + *pQName = SysAllocStringLen(NULL, cchLength); + + if (*pQName) + { + // we got a terminator character as part of SysAllocString. + hr = StringCchPrintf(*pQName, cchLength, L"%s:%s", bstrPrefixString, pszLocalName); + } + else + { + hr = E_OUTOFMEMORY; + } + } + } + else + { + // Default namespace ... + + UINT cchLength = 0; + + if (SUCCEEDED(hr = SizeTAdd(localNameLen, 1, &localNameLen)) && + SUCCEEDED(hr = SizeTToUInt(localNameLen, &cchLength))) + { + *pQName = SysAllocStringLen(NULL, cchLength); + + if (*pQName) + { + // we got a terminator character as part of SysAllocString. + hr = StringCchPrintf(*pQName, cchLength, L"%s", pszLocalName); + } + else + { + hr = E_OUTOFMEMORY; + } + } + } + } + + if (bstrPrefixString) + { + SysFreeString(bstrPrefixString); + bstrPrefixString = NULL; + } + + if (FAILED(hr)) + { + if (*pQName) + { + SysFreeString(*pQName); + *pQName = NULL; + } + } + + return hr; +} + +/*++ +Routine Name: + CreateXMLAttribute + +Routine Description: + Creates an attribute for the given XML element. + +Arguments: + + pElement - pointer to the element node to which an attribute is to be added + pszAttributeName - local name of the attribute + pszNamespaceURI - namespace URI to which the attribute belongs + pszAttributeValue - value of the attribute + +Return Value: + HRESULT Completion status code + S_OK - on success + E_* - on failure + +--*/ + +HRESULT OEMPTXMLHandler::CreateXMLAttribute( + _In_ IXMLDOMElement *pElement, + _In_ PCWSTR pszAttributeName, //"name=" + _In_ PCWSTR pszNamespaceURI, //"pt:" + _In_ PCWSTR pszAttributeValue //"prn:" + ) +{ + HRESULT hr = S_OK; + IXMLDOMAttribute *pNewAttribute = NULL ; + IXMLDOMNode *pNewNode = NULL ; + + if (!pElement || !pszAttributeName || ! pszNamespaceURI || !pszAttributeValue) + { + return E_INVALIDARG; + } + + VARIANT nodeType; + VariantInit(&nodeType); + V_VT(&nodeType) = VT_I4; + V_I4(&nodeType) = NODE_ATTRIBUTE; + hr = m_pRootDocument->createNode(nodeType, MSXMLSTR(pszAttributeName), MSXMLSTR(pszNamespaceURI), &pNewNode); + if (SUCCEEDED(hr)) + VariantClear(&nodeType); + + if (SUCCEEDED(hr)) + { + hr = pNewNode->QueryInterface(IID_IXMLDOMAttribute, (void **)&pNewAttribute); + } + + if (SUCCEEDED(hr)) + { + VARIANT attrType; + VariantInit(&attrType); + V_VT(&attrType) = VT_BSTR; + V_BSTR(&attrType) = SysAllocString(pszAttributeValue); + hr = pNewAttribute->put_value(attrType); + if (SUCCEEDED(hr)) + VariantClear(&attrType); + } + + if (SUCCEEDED(hr)) + { + hr = pElement->setAttributeNode(pNewAttribute, NULL); + } + + if (SUCCEEDED(hr)) + { + if (pNewAttribute) + { + pNewAttribute->Release(); + } + + } + else if (pNewAttribute) + pNewAttribute->Release(); + + if (pNewNode) + pNewNode->Release(); + + return hr; +} + +/*++ +Routine Name: + GetXMLElement +Routine Description: + Returns an XML element with given namespace URI and given attribute + +Arguments: + + pParent - Parent of node to be found + pszElementNamespaceURI - Namespace URI to which the element belongs + pszElementName - Local Name of the element + pszAttrNamespaceURI - Namespace URI to which the attribute of the element belongs + pszAttrName - local name of the element attribute + ppElement - out pointer to xml element so retrieved + +Return Value: + HRESULT Completion status code + S_OK - On Successfully locating XML node specified + S_FALSE - If the specified XML node is not found + E_* - On Failure + + Note: Since the module returns S_FALSE if the specified node is not found, the caller must be + careful to check hr status to be S_OK before proceeding, just checking for SUCCEEDED(hr) might + give wrong results + +--*/ +HRESULT OEMPTXMLHandler::GetXMLElement( + _In_ IXMLDOMElement *pParent, + _In_ PCWSTR pszElementNamespaceURI, + _In_ PCWSTR pszElementName, + _In_ PCWSTR pszAttrNamespaceURI, + _In_ PCWSTR pszAttrName, + _Outptr_result_maybenull_ IXMLDOMElement **ppElement + ) const +{ + HRESULT hr = S_OK; + LONG cChildren = 0; + IXMLDOMNodeList *pChildren = NULL; + + + if (!pParent || !pszElementNamespaceURI || !pszElementName || !pszAttrNamespaceURI || !pszAttrName) + { + return E_INVALIDARG; + } + + *ppElement = NULL; + + // + // Get a list of child nodes for the current DOM node + // + hr = pParent->get_childNodes(&pChildren); + + // + // Get number of child nodes + // + if (SUCCEEDED(hr)) + { + hr = pChildren->get_length(&cChildren); + } + + if (SUCCEEDED(hr)) + { + LONG i = 0; + BOOL bFound = FALSE; + + for(i = 0;i < cChildren && !bFound;i++) + { + IXMLDOMNode *pCurNode; + IXMLDOMElement *pCurElement = NULL; + + hr = pChildren->get_item(i, &pCurNode); + + if (SUCCEEDED(hr)) + { + hr = pCurNode->QueryInterface(IID_IXMLDOMElement, (void **)&pCurElement); + } + if (S_OK == hr) + { + BSTR bstrElementName = NULL; + BSTR bstrElementNamespaceURI = NULL; + + // + // retrieve element name and namespace URI + // + hr = pCurElement->get_baseName(&bstrElementName); + + if (SUCCEEDED(hr)) + { + hr = pCurElement->get_namespaceURI(&bstrElementNamespaceURI); + } + + if (SUCCEEDED(hr) && bstrElementNamespaceURI && bstrElementName) + { + + if (0 == wcscmp(bstrElementName, pszElementName) && 0 == wcscmp(bstrElementNamespaceURI, pszElementNamespaceURI)) + { + // + //check if element name matches + // + BSTR bstrAttrName = NULL; + BSTR bstrAttrNamespaceURI = NULL; + hr = GetXMLAttribute(pCurElement,&bstrAttrNamespaceURI,&bstrAttrName); + if (SUCCEEDED(hr) && bstrAttrName && bstrAttrNamespaceURI) + { + if (0 == wcscmp(bstrAttrName, pszAttrName) && 0 == wcscmp(pszAttrNamespaceURI, bstrAttrNamespaceURI)) + { + bFound = TRUE; + *ppElement = pCurElement; + (*ppElement)->AddRef(); + } + else + { + hr = S_FALSE; + } + } + + SysFreeString(bstrAttrName); + bstrAttrName = NULL; + + SysFreeString(bstrAttrNamespaceURI); + bstrAttrNamespaceURI = NULL; + } + } + + SysFreeString(bstrElementName); + bstrElementName = NULL; + + SysFreeString(bstrElementNamespaceURI); + bstrElementNamespaceURI = NULL; + + if (pCurElement) + { + pCurElement->Release(); + } + } + + if (pCurNode) + { + pCurNode->Release(); + } + } + } + + if (pChildren) + pChildren->Release(); + + if (SUCCEEDED(hr) && (*ppElement)) + { + hr = S_OK; + } + else + { + hr = S_FALSE; + } + + return hr; + +} + +/*++ +Routine Name: + GetXMLElementWithoutAttribute + +Routine Description: + Returns an XML element with given namespace URI. + +Arguments: + + pParent - Parent of node to be found + pszElementNamespaceURI - Namespace URI to which the element belongs + pszElementName - Local Name of the element + ppChildElement - out pointer to xml element so retrieved + +Return Value: + HRESULT Completion status code + S_OK - On Successfully locating XML node specified + S_FALSE - If the specified XML node is not found + E_* - On Failure + + Note: Since the module returns S_FALSE if the specified node is not found, the caller must be + careful to check hr status before proceeding, just checking for SUCCEEDED(hr) might + give wrong results + +--*/ +HRESULT OEMPTXMLHandler::GetXMLElementWithoutAttribute( + _In_ IXMLDOMElement *pContext, + _In_ PCWSTR pszElementNamespace, + _In_ PCWSTR pszElementName, + _Outptr_result_maybenull_ IXMLDOMElement **ppChildElement + ) const +{ + if (!pContext || !pszElementName || !pszElementNamespace || !ppChildElement) + { + return E_INVALIDARG; + } + + HRESULT hr = S_OK; + LONG cChildren = 0; + IXMLDOMNodeList *pContextChildren; + *ppChildElement = NULL; + + // + // Get the list of child nodes + // + hr = pContext->get_childNodes(&pContextChildren); + + if (SUCCEEDED(hr)) + hr = pContextChildren->get_length(&cChildren); + + if (SUCCEEDED(hr)) + { + for(LONG i = 0;i < cChildren && !(*ppChildElement);i++) + { + + IXMLDOMNode *pCurrentNode; + IXMLDOMElement *pCurrentElement; + hr = pContextChildren->get_item(i, &pCurrentNode); + + // + // See if its a DOM Element. Don't set hr here because we + // fully expect that not everything in the context is an element. + // + if (SUCCEEDED(hr) && S_OK == pCurrentNode->QueryInterface(IID_IXMLDOMElement, (void**)&pCurrentElement)) + { + BSTR pbstrBaseName = NULL; + BSTR pbstrNamespaceURI = NULL; + + hr = pCurrentElement->get_baseName(&pbstrBaseName); + + if (SUCCEEDED(hr)) + { + hr = pCurrentElement->get_namespaceURI(&pbstrNamespaceURI); + } + if (SUCCEEDED(hr) && + pbstrNamespaceURI && + pbstrBaseName && + 0 == wcscmp(pbstrNamespaceURI, pszElementNamespace) && + 0 == wcscmp(pbstrBaseName, pszElementName)) + { + *ppChildElement = pCurrentElement; + (*ppChildElement)->AddRef(); + } + + pCurrentElement->Release(); + + SysFreeString(pbstrBaseName); + pbstrBaseName = NULL; + + SysFreeString(pbstrNamespaceURI); + pbstrNamespaceURI = NULL; + } + + if (pCurrentNode) + { + pCurrentNode->Release(); + } + } + } + + if (pContextChildren) + { + pContextChildren->Release(); + } + + if (SUCCEEDED(hr)) + { + if (*ppChildElement) + { + hr = S_OK; + } + else + { + hr = S_FALSE; + } + } + + return hr; +} + +/*++ +Routine Name: + GetXMLAttribute + +Routine Description: + Returns an XML Attribute node with given namespace URI. + +Arguments: + + pParent - Parent of node to be found + pszAttrNamespaceURI - Namespace URI to which the attribute belongs + pszAttrName - Local Name of the attribute + ppChildElement - out pointer to xml node so retrieved + +Return Value: + HRESULT Completion status code + S_OK - On Success + E_* - On Failure + +--*/ +HRESULT OEMPTXMLHandler::GetXMLAttribute( + _In_ IXMLDOMElement *pElement, + _Outptr_result_maybenull_ BSTR *ppAttrNamespaceURI, + _Outptr_result_maybenull_ BSTR *ppAttrName + ) const +{ + HRESULT hr = S_OK; + IXMLDOMNamedNodeMap *pAttrMap = NULL; + IXMLDOMNode *pAttrNode = NULL; + + if (!pElement || !ppAttrNamespaceURI || !ppAttrName) + { + return E_INVALIDARG; + } + + *ppAttrNamespaceURI = NULL; + *ppAttrName = NULL; + + hr = pElement->get_attributes(&pAttrMap); + + if (SUCCEEDED(hr)) + { + hr = pAttrMap->getNamedItem(MSXMLSTR(printschema::NAME_ATTRIBUTE_NAME),&pAttrNode); + } + + if (S_OK == hr) + { + BSTR bstrAttrQName = NULL; + IXMLDOMAttribute *pAttribute = NULL; + + hr = pAttrNode->QueryInterface(IID_IXMLDOMAttribute, (void **)&pAttribute); + + if (SUCCEEDED(hr)) + hr = pAttribute->get_text(&bstrAttrQName); + + if (S_OK == hr && bstrAttrQName) + hr = getUri(pElement, bstrAttrQName, ppAttrNamespaceURI); + + if (S_OK == hr && bstrAttrQName) + hr = getLocalName(bstrAttrQName, ppAttrName); + + if (pAttribute) + pAttribute->Release(); + + if (bstrAttrQName) + { + SysFreeString(bstrAttrQName); + bstrAttrQName = NULL; + } + } + + if (pAttrMap) + pAttrMap->Release(); + if (pAttrNode) + pAttrNode->Release(); + + if (FAILED(hr)) + { + if (*ppAttrNamespaceURI) + { + SysFreeString(*ppAttrNamespaceURI); + *ppAttrNamespaceURI = NULL; + } + if (*ppAttrName) + { + SysFreeString(*ppAttrName); + *ppAttrName = NULL; + } + } + return hr; +} + +/*++ +Routine Name: + GetFeatureNode + +Routine Description: + + Returns the feature node with specified attribute under printschema namespace + +Arguments: + pParent - parent node of the feature node to be located + pszAttrNamespaceURI - namespace URI for the attribute node of given feature node + pszAttrName - attribute name for given feature node + ppElement - OUT pointer to feature node to be returned + +Return Value: + HRESULT Completion status code + S_OK - On Successfully locating Feature node + S_FALSE - If Feature node is not found + E_* - On Failure + + +--*/ +HRESULT OEMPTXMLHandler::GetFeatureNode( + _In_opt_ IXMLDOMElement *pParent, + _In_ PCWSTR pszAttrNamespaceURI, + _In_ PCWSTR pszAttrName, + _Out_ _When_(return == S_FALSE, _At_(*ppElement, _Post_maybenull_)) + _When_(return != S_FALSE, _At_(*ppElement, _Post_valid_)) + IXMLDOMElement **ppElement + ) const +{ + HRESULT hr = S_OK; + + // + // If no parent is specified, set root of DOM tree as parent + // + if (!pParent) + { + pParent = m_pRootElement; + } + + hr = GetXMLElement(pParent, printschema::FRAMEWORK_URI, printschema::FEATURE_ELEMENT_NAME, pszAttrNamespaceURI, pszAttrName, ppElement); + + return hr; +} + +/*++ +Routine Name: + GetOptionNode + +Routine Description: + + Returns the option node under printschema namespace + +Arguments: + pParent - parent node of the option node to be located + ppElement - OUT pointer to option node to be returned + +Return Value: + HRESULT Completion status code + S_OK - On Successfully locating Option node + S_FALSE - If Option node is not found + E_* - On Failure + +--*/ +HRESULT +OEMPTXMLHandler::GetOptionNode( + _In_ IXMLDOMElement *pParent, + _Outptr_result_maybenull_ IXMLDOMElement **ppElement + ) const +{ + return GetXMLElementWithoutAttribute(pParent, printschema::FRAMEWORK_URI, printschema::OPTION_ELEMENT_NAME, ppElement); +} + +/*++ + +Routine Name: + getLocalName +Routine Description: + Returns Local name for input XML Qname. + +Arguments: + pszQName - Qname for which local name is to be found out + ppbstrLocalName - OUT pointer to local name + +Return Value: + HRESULT Completion status code + S_OK - On Success + E_* - On Failure + +--*/ +HRESULT +OEMPTXMLHandler::getLocalName( + _In_ PCWSTR pszQName, + _Out_ BSTR *ppbstrLocalName + ) const +{ + HRESULT hr = S_OK; + + if (!pszQName || !ppbstrLocalName) + { + return E_INVALIDARG; + } + + *ppbstrLocalName = NULL; + + PCWSTR pszStartPos = wcschr(pszQName,L':'); + + if (pszStartPos) + { + pszStartPos++; + } + else + { + pszStartPos = pszQName; + } + + *ppbstrLocalName = SysAllocString(pszStartPos); + + if (!(*ppbstrLocalName)) + { + hr = E_OUTOFMEMORY; + } + + return hr; +} + + +/*++ +Routine Name: + getUri +Routine Description: + Returns namespace URI for given input Qname and in context of given XML DOM node. +Arguments: + pContext - Input XML DOM node for current context + pszQName - input qname + pbstrURI - OUT pointer to URI to be returned +Return Value: + + S_OK if found + S_FALSE if not found + E_OUTOFMEMORY if the string could not be allocated + E_INVALIDARG if a non-optional param is null. + +Notes: + + This routine assumes that the string has already been + validated, which should have happened in the managed code base. + The string should either be of the form "prefix:localname", + or "localname" + +--*/ +HRESULT +OEMPTXMLHandler::getUri( + IXMLDOMElement *pContext, + _In_ PCWSTR pszQName, + _Out_ BSTR *pbstrURI + ) const + +{ + HRESULT hr = S_OK; + BOOL bNodePushed = FALSE; + + if (!(pContext && pbstrURI && pszQName)) + { + return E_INVALIDARG; + } + + PWSTR pszSplitPos = (_TCHAR*) wcschr(pszQName, L':'); + INT cchUri = 0; + *pbstrURI = NULL; + + // + // if splitpos is null, then there is no namespace + // prefix, which means return the default namespace. + // + wchar_t wchSwapChar = L'\0'; + if (pszSplitPos) + { + wchSwapChar = *pszSplitPos; + *pszSplitPos = (wchar_t)0; + } + else + { + pszQName = L""; + } + + hr = m_pNSManager->pushNodeContext(pContext, TRUE); + + if (SUCCEEDED(hr)) + { + bNodePushed = TRUE; + // get the length first, then alloc the string +#pragma prefast(suppress:__WARNING_INVALID_PARAM_VALUE_1, "According to MSDN, it is acceptable to pass a NULL buffer to getURI.") + hr = m_pNSManager->getURI(pszQName, NULL, NULL, &cchUri); + } + + if (S_OK == hr) + { + if (SUCCEEDED(hr)) + { + // account for null terminator + cchUri += 1; + + *pbstrURI = SysAllocStringLen(NULL, cchUri); + if (!(*pbstrURI)) + { + hr = E_OUTOFMEMORY; + } + } + + if (SUCCEEDED(hr)) + { + hr = m_pNSManager->getURI(pszQName, NULL, *pbstrURI, &cchUri); + } + + if (pszSplitPos) + { + *pszSplitPos = wchSwapChar; + } + + if (FAILED(hr) && (*pbstrURI)) + { + SysFreeString(*pbstrURI); + *pbstrURI = NULL; + } + } + + if (bNodePushed) + { + hr = m_pNSManager->popContext(); + } + + return hr; +} + +/*++ + +Routine Name: + getPrefix +Routine Description: + + Returns predefined Prefix for the input namespace URI if one already exists + +Arguments: + pContext - Current context node + pszUri - namespace URI for which prefix is to be obtained + pbstrPrefix - prefix string to be returned, if NULL routine just checks for + existence of prefix + +Return Value: + HRESULT Completion status code + S_OK - on success + S_FALSE - on failure + +--*/ +HRESULT +OEMPTXMLHandler::getPrefix( + _In_ IXMLDOMElement *pContext, + _In_ PCWSTR pszUri, + _Outptr_opt_result_maybenull_ BSTR *pbstrPrefix + ) const +{ + HRESULT hr = S_OK; + BOOL bNodePushed = FALSE; + INT cchPrefix = 0; + + if (!pContext || !pszUri) + return E_INVALIDARG; + + if (pbstrPrefix) + { + *pbstrPrefix = NULL; + } + + //Push context "Deep" to get info abt all URI prefix mappings defined so far in the current DOM document + hr = m_pNSManager->pushNodeContext(pContext, TRUE); + + if (SUCCEEDED(hr)) + { + bNodePushed = TRUE; + + // get the length first, then alloc the string + + hr = m_pNSManager->getPrefix(pszUri, 0, NULL, &cchPrefix); + } + + + if (S_OK == hr && pbstrPrefix) + { + + *pbstrPrefix = NULL; + cchPrefix++; + + if (SUCCEEDED(hr)) + { + *pbstrPrefix = SysAllocStringLen(NULL, cchPrefix); + + if (!(*pbstrPrefix)) + hr = E_OUTOFMEMORY; + } + + if (SUCCEEDED(hr)) + { + hr = m_pNSManager->getPrefix(pszUri, 0, *pbstrPrefix, &cchPrefix); + + } + + if (FAILED(hr) && (*pbstrPrefix)) + { + SysFreeString(*pbstrPrefix); + *pbstrPrefix = NULL; + } + } + + // Note: MSXML NSManager returns S_FALSE for an undeclared URI, and E_FAIL for an undeclared + // prefix, hence it is safe to check for both here. + + if (E_FAIL == hr || S_FALSE == hr) + { + // NS manager didn't find the prefix. Tweak the result to S_FALSE + hr = S_FALSE; + } + + if (bNodePushed) + { + m_pNSManager->popContext(); + } + + return hr; +} + +/*++ + +Routine Name: + declarePrefix + +Routine Description: + + This declares a new prefix for a given URI. This routine will always generate a new + prefix definition, regardless of whether the URI is already defined. Use getPrefix + to prevent duplicate definitions of namespace URI prefixes. If the preferred prefix is + already in use or no preferred prefix is supplied the namespace will be declared using + a generated namespace name. + +Arguments: + pContext - The context in which you want to ensure that the prefix is properly declared + in. This is where we check to see if the prefix is already in use. However, if not + in use, the prefix will always be declared in the root of the document. This gaurantees + 2 things: The prefix is declared in the entire document (though it may be overridden + locally in other places), and the prefix has the expected meaning at the passed in pContext. + pszUri - The URI to associate with the prefix. + pszPreferredPrefix - prefix to use if not already defined, can be a BSTR or PCWSTR, either + is acceptable + pbstrNewPrefix - The actual prefix that was declared, which may be different from the + preferred prefix + +Return Value: + HRESULT Completion status code + S_OK - on success + S_FALSE - on failure + +--*/ +HRESULT +OEMPTXMLHandler::declarePrefix( + _In_ IXMLDOMElement *pContext, + _In_ PCWSTR pszUri, + _In_opt_ PCWSTR pszPreferredPrefix, + _Out_ BSTR *pbstrNewPrefix + ) +{ + HRESULT hr = S_OK; + + // These two strings are tied ... the second string is used to print the number over top of a + // copy of the first string, so chances are, if you change one, you need to change the other. + PCWSTR szPrefixChars = L"ns0000"; + PCWSTR szPrefixPrintfPattern = L"ns%.4X"; + + if (!(pContext && pszUri && pbstrNewPrefix)) + { + return E_INVALIDARG; + } + + *pbstrNewPrefix = NULL; + + // Check if the preferred prefix exists... + // + // If we got S_OK, the prefix exists, if we got E_*, bail out + // anyway. Only declare the prefix if we successfully decided + // it doesn't exist. + + if (pszPreferredPrefix) + { + INT unused = 0; + + if (SUCCEEDED(hr)) + { + hr = m_pNSManager->pushNodeContext(pContext, TRUE); + } + + if (SUCCEEDED(hr)) + { +#pragma prefast(suppress:__WARNING_INVALID_PARAM_VALUE_1, "According to MSDN, it is acceptable to pass a NULL buffer to getURI.") + hr = m_pNSManager->getURI(pszPreferredPrefix, NULL, NULL, &unused); + + // If the prefix is already defined, MSXML will return S_FALSE. In that + // case, we don't want to declare another namespace with the same prefix + if (S_FALSE != hr) + { + pszPreferredPrefix = NULL; + } + + hr = m_pNSManager->popContext(); + } + + if (SUCCEEDED(hr) && pszPreferredPrefix) + { + *pbstrNewPrefix = SysAllocStringLen(pszPreferredPrefix, (UINT) wcslen(pszPreferredPrefix)); + } + } + + // If we don't have a workable prefix, try to generate a namespace + // Namespaces are in the form of NSxxxx where the x's are hex digits, + // and there are sizeof(m_nextPrefix)*2 of them + if (SUCCEEDED(hr) && !(*pbstrNewPrefix)) + { + BOOL bFound = TRUE; + UINT cchLength = (UINT) wcslen(szPrefixChars); + *pbstrNewPrefix = SysAllocStringLen(NULL, cchLength); + if (!(*pbstrNewPrefix)) + { + hr = E_OUTOFMEMORY; + } + if (SUCCEEDED(hr)) + { + do + { + INT unused = 0; + + // We're really unlikely to hit this. If we do we probably + // have bigger problems. but put a reasonable cap on the + // generated namespaces anyway. + if (((UINT)m_dwNextIndex) >= (UINT)0xFFFF) + { + // We could reset the counter here, but it's very unlikely to + // help matters, and could end up costing tons of CPU time if + // caller ignored the error or retried. + hr = E_FAIL; + } + + if (SUCCEEDED(hr)) + { + // now fill in the real value. + hr = StringCchPrintf(*pbstrNewPrefix, cchLength+1, szPrefixPrintfPattern, (INT)m_dwNextIndex); + } + + if (SUCCEEDED(hr)) + { + // look up the URI associated with the prefix. +#pragma prefast(suppress:__WARNING_INVALID_PARAM_VALUE_1, "According to MSDN, it is acceptable to pass a NULL buffer to getURI.") + bFound = (S_OK == m_pNSManager->getURI(*pbstrNewPrefix, pContext, NULL, &unused)); + } + + m_dwNextIndex++; + + } while(SUCCEEDED(hr) && bFound); + + if (bFound) + { + SysFreeString(*pbstrNewPrefix); + *pbstrNewPrefix = NULL; + } + } + } + + if (SUCCEEDED(hr) && *pbstrNewPrefix) + { + // We'll always put declarations at the root + if (SUCCEEDED(hr)) + { + // Create the namespace declaration string + UINT cchDeclLength = (UINT)(wcslen(L"xmlns:") + wcslen(*pbstrNewPrefix)); + + BSTR bstrDecl = SysAllocStringLen(NULL, cchDeclLength); + if (!bstrDecl) + { + hr = E_OUTOFMEMORY; + } + + // Add the new declaration to the root of the document. This is important because + // we really don't want to re-declare the namespace at every element. Just starts + // to look really messy, and adds a lot of bloat. + if (SUCCEEDED(hr)) + { + hr = StringCchPrintf(bstrDecl, cchDeclLength+1, L"xmlns:%s", *pbstrNewPrefix); + } + + if (SUCCEEDED(hr)) + { + hr = CreateXMLAttribute(m_pRootElement, bstrDecl, L"", pszUri); + } + + SysFreeString(bstrDecl); + bstrDecl = NULL; + + // Explicitly let the namespace manager know about our prefix + + if (SUCCEEDED(hr)) + { + hr = m_pNSManager->declarePrefix(*pbstrNewPrefix, pszUri); + } + } + } + + if (FAILED(hr)) + { + SysFreeString(*pbstrNewPrefix); + *pbstrNewPrefix = NULL; + } + + return hr; +} + +/*++ +Routine Name: + DeleteFeatureNode +Routine Description: + + Deletes given input Feature node and all its children from DOM tree + +Arguments: + + pParent - Parent node of the XML DOM node to be deleted + pElement - XML DOM node to be deleted + +Return Value: + HRESULT Completion status code + S_OK - On Success + E_* - On failure +--*/ +HRESULT +OEMPTXMLHandler::DeleteFeatureNode( + _In_opt_ IXMLDOMNode *pParent, + _In_ IXMLDOMNode *pElement + ) +{ + HRESULT hr = S_OK; + + IXMLDOMNode *pRemovedElement = NULL; + + if (!pElement) + { + return E_INVALIDARG; + } + + // + // if no parent node specified assume root of DOM tree as parent + // + + if (!pParent) + { + pParent = m_pRootElement; + } + + // + // MSXML function removeChild removes the given child of the XML + // element and all its children, even the Attribute nodes defined + // for given element node if any are removed. Hence we do not need + // to worry about recursively removing all the children of the + // given node before removing it + // + + hr = pParent->removeChild(pElement, &pRemovedElement); + + if (pRemovedElement) + { + pRemovedElement->Release(); + } + + return hr ; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.hxx b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.hxx new file mode 100644 index 00000000..2767c282 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/PTPCPlPr/src/xmlhandler.hxx @@ -0,0 +1,162 @@ +// 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. +// +// Copyright 1998 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: xmlhandler.hxx +// +// +// PURPOSE: Helper Class that handles all functionality related to +// processing of input PrintTicket/PrintCapabilities XML document +// +// + +#pragma once + +// +// Print ticket handler class that performs all XML handling for the +// sample code +// + +class OEMPTXMLHandler +{ + +public: + + OEMPTXMLHandler(); + virtual ~OEMPTXMLHandler(); + + HRESULT SetRoot( + _In_ IXMLDOMDocument2 *pRoot, + _In_ IPrintCoreHelper *pHelper + ); + + // + // Node creation methods + // + + HRESULT CreateFeatureNode( + _In_opt_ IXMLDOMElement *pParent, + _In_ PCWSTR pszNamespaceURI, + _In_ PCWSTR pszFeatureName, + _Out_opt_ IXMLDOMElement **ppFeatureNode + ); + + HRESULT CreateOptionNode( + _In_ IXMLDOMElement *pParent, + _In_ PCWSTR pszNamespaceURI, + _In_ PCWSTR pszOptionName, + _Out_opt_ IXMLDOMElement **ppOptionElement + ); + + // + // Get methods + // + + HRESULT GetXMLAttribute( + _In_ IXMLDOMElement *pElement, + _Outptr_result_maybenull_ BSTR *pszAttrNamespaceURI, + _Outptr_result_maybenull_ BSTR *pszAttrName + ) const; + + HRESULT GetFeatureNode( + _In_opt_ IXMLDOMElement *pParent, + _In_ PCWSTR pszAttrNamespaceURI, + _In_ PCWSTR pszAttrName, + _Out_ _When_(return == S_FALSE, _At_(*ppElement, _Post_maybenull_)) + _When_(return != S_FALSE, _At_(*ppElement, _Post_valid_)) + IXMLDOMElement **ppElement + ) const; + + HRESULT GetOptionNode( + _In_ IXMLDOMElement *pParent, + _Outptr_result_maybenull_ IXMLDOMElement **ppElement + ) const; + + HRESULT DeleteFeatureNode( + _In_opt_ IXMLDOMNode *pParent, + _In_ IXMLDOMNode *pElement + ); + +private: + + IXMLDOMDocument2 *m_pRootDocument; + IXMLDOMElement *m_pRootElement; + IMXNamespaceManager *m_pNSManager; + DWORD m_dwNextIndex; + + HRESULT GetXMLElement( + _In_ IXMLDOMElement *pParent, + _In_ PCWSTR pszElementNamespaceURI, + _In_ PCWSTR pszElementName, + _In_ PCWSTR pszAttrNamespaceURI, + _In_ PCWSTR pszAttrName, + _Outptr_result_maybenull_ IXMLDOMElement **ppElement + ) const; + + HRESULT GetXMLElementWithoutAttribute( + _In_ IXMLDOMElement *pContext, + _In_ PCWSTR pszElementNamespaceURI, + _In_ PCWSTR pszElementName, + _Outptr_result_maybenull_ IXMLDOMElement **ppChildElement + ) const; + + HRESULT getPrefix( + _In_ IXMLDOMElement *pContext, + _In_ PCWSTR pszUri, + _Outptr_opt_result_maybenull_ BSTR *pbstrPrefix + ) const; + + HRESULT declarePrefix( + _In_ IXMLDOMElement *pContext, + _In_ LPCWSTR pszUri, + _In_opt_ LPCWSTR pszPreferredPrefix, + _Out_ BSTR *newPrefix + ); + + HRESULT CreateQName( + _In_ IXMLDOMElement *pElement, + _In_ PCWSTR pszUri, + _In_ PCWSTR pszLocalName, + _Out_ BSTR *pQName + ); + + // + // Adds attributes to existing XML element + // + + HRESULT CreateXMLAttribute( + _In_ IXMLDOMElement *pElement, + _In_ PCWSTR pszAttributeName, + _In_ PCWSTR pszNamespaceURI, + _In_ PCWSTR pszAttributeValue + ); + + // + // Creates new XML element node + // + HRESULT CreateXMLElement( + _In_ IXMLDOMElement *pParent, + _In_ PCWSTR pszElementName, + _In_ PCWSTR pszNamespaceURI, + _Out_ IXMLDOMElement **ppCreatedElement + ); + + // + // Helpers + // + HRESULT getLocalName( + _In_ PCWSTR pszQName, + _Out_ BSTR *ppbstrLocalName + ) const; + + HRESULT getUri( + IXMLDOMElement *pContext, + _In_ PCWSTR pszQName, + _Out_ BSTR *pbstrURI + ) const; + +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj new file mode 100644 index 00000000..cf56c5f6 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj @@ -0,0 +1,1066 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8} + $(MSBuildProjectName) + Win10 Debug + Win32 + {A7A17685-16BD-4A90-9E09-A46B09CF3A1F} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + SYNCSET + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;_DEBUG + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + SYNCSET.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj.Filters new file mode 100644 index 00000000..9737750a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SYNCSET.vcxproj.Filters @@ -0,0 +1,272 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {72226DBB-2FE2-4E91-99A5-A18952A112EB} + + + h;hpp;hxx;hm;inl;inc;xsd + {C3708A9B-9215-44CC-96A2-0C0B656486BF} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {D44A3AF2-69E5-4F32-BC8A-7636FB947722} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + Header Files + + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SyncSet.def b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SyncSet.def new file mode 100644 index 00000000..68bdffc0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/SyncSet.def @@ -0,0 +1,3 @@ +LIBRARY OEMUI +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.cpp b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.cpp new file mode 100644 index 00000000..f7a3d842 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.cpp @@ -0,0 +1,405 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.cpp +// +// PURPOSE: Debug functions. +// +// + +#include "precomp.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL DEFINES +//////////////////////////////////////////////////////// + +#define DEBUG_BUFFER_SIZE 1024 +#define PATH_SEPARATOR '\\' +#define MAX_LOOP 10 + +// Determine what level of debugging messages to eject. +#ifdef VERBOSE_MSG + #define DEBUG_LEVEL DBG_VERBOSE +#elif TERSE_MSG + #define DEBUG_LEVEL DBG_TERSE +#elif WARNING_MSG + #define DEBUG_LEVEL DBG_WARNING +#elif ERROR_MSG + #define DEBUG_LEVEL DBG_ERROR +#elif RIP_MSG + #define DEBUG_LEVEL DBG_RIP +#elif NO_DBG_MSG + #define DEBUG_LEVEL DBG_NONE +#else + #define DEBUG_LEVEL DBG_WARNING +#endif + + + +//////////////////////////////////////////////////////// +// EXTERNAL GLOBALS +//////////////////////////////////////////////////////// + +INT giDebugLevel = DEBUG_LEVEL; + + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static BOOL DebugMessageV(LPCSTR lpszMessage, va_list arglist); +static BOOL DebugMessageV(DWORD dwSize, LPCWSTR lpszMessage, va_list arglist); + + + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessageV +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// dwSize Size of temp buffer to hold formated string. +// +// lpszMessage Format string. +// +// arglist Variable argument list.. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +static BOOL DebugMessageV(LPCSTR lpszMessage, va_list arglist) +{ + DWORD dwSize = DEBUG_BUFFER_SIZE; + DWORD dwLoop = 0; + LPSTR lpszMsgBuf = NULL; + HRESULT hr; + + + // Parameter checking. + if( (NULL == lpszMessage) + || + (0 == dwSize) + ) + { + return FALSE; + } + + do + { + // Allocate memory for message buffer. + if(NULL != lpszMsgBuf) + { + delete[] lpszMsgBuf; + dwSize *= 2; + } + lpszMsgBuf = new CHAR[dwSize + 1]; + if(NULL == lpszMsgBuf) + { + return FALSE; + } + + hr = StringCbVPrintfA(lpszMsgBuf, (dwSize + 1) * sizeof(CHAR), lpszMessage, arglist); + + // Pass the variable parameters to wvsprintf to be formated. + } while (FAILED(hr) && (STRSAFE_E_INSUFFICIENT_BUFFER == hr) && (++dwLoop < MAX_LOOP) ); + + // Dump string to Debug output. + OutputDebugStringA(lpszMsgBuf); + + // Cleanup. + delete[] lpszMsgBuf; + + return SUCCEEDED(hr); +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessageV +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// dwSize Size of temp buffer to hold formated string. +// +// lpszMessage Format string. +// +// arglist Variable argument list.. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +static BOOL DebugMessageV(DWORD dwSize, LPCWSTR lpszMessage, va_list arglist) +{ + LPWSTR lpszMsgBuf; + HRESULT hResult; + + + // Parameter checking. + if( (NULL == lpszMessage) + || + (0 == dwSize) + ) + { + return FALSE; + } + + // Allocate memory for message buffer. + lpszMsgBuf = new WCHAR[dwSize + 1]; + if(NULL == lpszMsgBuf) + return FALSE; + + // Pass the variable parameters to wvsprintf to be formated. + hResult = StringCbVPrintfW(lpszMsgBuf, (dwSize + 1) * sizeof(WCHAR), lpszMessage, arglist); + + // Dump string to debug output. + OutputDebugStringW(lpszMsgBuf); + + // Clean up. + delete[] lpszMsgBuf; + + return SUCCEEDED(hResult); +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessage +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// lpszMessage Format string. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCSTR lpszMessage, ...) +{ + BOOL bResult; + va_list VAList; + + + // Pass the variable parameters to DebugMessageV for processing. + va_start(VAList, lpszMessage); + bResult = DebugMessageV(lpszMessage, VAList); + va_end(VAList); + + return bResult; +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessage +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// lpszMessage Format string. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCWSTR lpszMessage, ...) +{ + BOOL bResult; + va_list VAList; + + + // Pass the variable parameters to DebugMessageV to be processed. + va_start(VAList, lpszMessage); + bResult = DebugMessageV(MAX_PATH, lpszMessage, VAList); + va_end(VAList); + + return bResult; +} + +void Dump(PPUBLISHERINFO pPublisherInfo) +{ + VERBOSE(TEXT("pPublisherInfo:\r\n")); + if(NULL == pPublisherInfo) + { + VERBOSE(TEXT("\tpPublisherInfo is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tdwMode = %#x\r\n"), pPublisherInfo->dwMode); + VERBOSE(TEXT("\twMinoutlinePPEM = %d\r\n"), pPublisherInfo->wMinoutlinePPEM); + VERBOSE(TEXT("\twMaxbitmapPPEM = %d\r\n"), pPublisherInfo->wMaxbitmapPPEM); +} + +void Dump(POEMDMPARAM pOemDMParam) +{ + VERBOSE(TEXT("pOemDMParam:\r\n")); + if(NULL == pOemDMParam) + { + VERBOSE(TEXT("\tpOemDMParam is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pOemDMParam->cbSize); + VERBOSE(TEXT("\tpdriverobj = %#x\r\n"), pOemDMParam->pdriverobj); + VERBOSE(TEXT("\thPrinter = %#x\r\n"), pOemDMParam->hPrinter); + VERBOSE(TEXT("\thModule = %#x\r\n"), pOemDMParam->hModule); + VERBOSE(TEXT("\tpPublicDMIn = %#x\r\n"), pOemDMParam->pPublicDMIn); + VERBOSE(TEXT("\tpPublicDMOut = %#x\r\n"), pOemDMParam->pPublicDMOut); + VERBOSE(TEXT("\tpOEMDMIn = %#x\r\n"), pOemDMParam->pOEMDMIn); + VERBOSE(TEXT("\tpOEMDMOut = %#x\r\n"), pOemDMParam->pOEMDMOut); + VERBOSE(TEXT("\tcbBufSize = %d\r\n"), pOemDMParam->cbBufSize); +} + +void Dump(PPROPSHEETUI_INFO pPSUIInfo) +{ + VERBOSE(TEXT("pPSUIInfo:\r\n")); + if(NULL == pPSUIInfo) + { + VERBOSE(TEXT("\tpPSUIInfo is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pPSUIInfo->cbSize); + VERBOSE(TEXT("\tVersion = %#x\r\n"), pPSUIInfo->Version); + VERBOSE(TEXT("\tFlags = %#x\r\n"), pPSUIInfo->Flags); + VERBOSE(TEXT("\tReason = %d\r\n"), pPSUIInfo->Reason); + VERBOSE(TEXT("\thComPropSheet = %#x\r\n"), pPSUIInfo->hComPropSheet); + VERBOSE(TEXT("\tpfnComPropSheet = %#x\r\n"), pPSUIInfo->pfnComPropSheet); + VERBOSE(TEXT("\tlParamInit = %#x\r\n"), pPSUIInfo->lParamInit); + VERBOSE(TEXT("\tUserData = %#x\r\n"), pPSUIInfo->UserData); + VERBOSE(TEXT("\tResult = %#x\r\n"), pPSUIInfo->Result); +} + +void Dump(POPTITEM pOptItem) +{ + VERBOSE(TEXT("pOptItem:\r\n")); + if(NULL == pOptItem) + { + VERBOSE(TEXT("\tpOptItem is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pOptItem->cbSize); + VERBOSE(TEXT("\tLevel = %d\r\n"), pOptItem->Level); + VERBOSE(TEXT("\tDlgPageIdx = %d\r\n"), pOptItem->DlgPageIdx); + VERBOSE(TEXT("\tFlags = 0x%x\r\n"), pOptItem->Flags); + VERBOSE(TEXT("\tUserData = 0x%p\r\n"), pOptItem->UserData); + VERBOSE(TEXT("\tpName = %s\r\n"), pOptItem->pName ? pOptItem->pName : TEXT("")); + VERBOSE(TEXT("\tpSel = 0x%p\r\n"), pOptItem->pSel); + VERBOSE(TEXT("\tpExtChkBox = 0x%p\r\n"), pOptItem->pExtChkBox); + VERBOSE(TEXT("\tpExtChkBox = 0x%p\r\n"), pOptItem->pExtChkBox); + VERBOSE(TEXT("\tHelpIndex = 0x%x\r\n"), pOptItem->HelpIndex); + VERBOSE(TEXT("\tDMPubID = 0x%x\r\n"), pOptItem->DMPubID); + VERBOSE(TEXT("\tUserItemID = 0x%x\r\n"), pOptItem->UserItemID); + VERBOSE(TEXT("\twReserved = 0x%x\r\n"), pOptItem->wReserved); + VERBOSE(TEXT("\tpOIExt = 0x%p\r\n"), pOptItem->pOIExt); + + Dump(pOptItem->pOptType); +} + +void Dump(POPTTYPE pOptType) +{ + VERBOSE(TEXT("\tpOptType:\r\n")); + if(NULL == pOptType) + { + VERBOSE(TEXT("\t\tpOptType is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\t\tcbSize = %d\r\n"), pOptType->cbSize); + VERBOSE(TEXT("\t\tType = 0x%x\r\n"), pOptType->Type); + VERBOSE(TEXT("\t\tFlags = 0x%x\r\n"), pOptType->Flags); + VERBOSE(TEXT("\t\tCount = %d\r\n"), pOptType->Count); + VERBOSE(TEXT("\t\tCount = 0x%x\r\n"), pOptType->BegCtrlID); + VERBOSE(TEXT("\t\tStyle = 0x%x\r\n"), pOptType->Style); + + Dump(pOptType->pOptParam, pOptType->Count); +} + +void Dump(POPTPARAM pOptParam, WORD wCount) +{ + if(NULL == pOptParam) + { + VERBOSE(TEXT("\t\tpOptParam is NULL!\r\n")); + return; + } + + for(WORD wIndex = 0; wIndex < wCount; ++wIndex) + { + VERBOSE(TEXT("\t\tpOptParam[wIndex]:\r\n")); + VERBOSE(TEXT("\t\t\tcbSize = %d\r\n"), pOptParam[wIndex].cbSize); + VERBOSE(TEXT("\t\t\tFlags = 0x%x\r\n"), pOptParam[wIndex].Flags); + VERBOSE(TEXT("\t\t\tStyle = 0x%x\r\n"), pOptParam[wIndex].Style); + VERBOSE(TEXT("\t\t\tpData = 0x%p\r\n"), pOptParam[wIndex].pData); + VERBOSE(TEXT("\t\t\tIconID = 0x%p\r\n"), pOptParam[wIndex].IconID); + VERBOSE(TEXT("\t\t\tlParam = 0x%p\r\n"), pOptParam[wIndex].lParam); + } +} + + +PCSTR +StripDirPrefixA( + IN PCSTR pstrFilename + ) + +/*++ + +Routine Description: + + Strip the directory prefix off a filename (ANSI version) + +Arguments: + + pstrFilename - Pointer to filename string + +Return Value: + + Pointer to the last component of a filename (without directory prefix) + +--*/ + +{ + PCSTR pstr; + + pstr = strrchr(pstrFilename, PATH_SEPARATOR); + if (pstr) + return pstr + 1; + + return pstrFilename; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.h new file mode 100644 index 00000000..b4d57b0b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/debug.h @@ -0,0 +1,166 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. +// +// + +#pragma once + +// VC and Build use different debug defines. +// The following makes it so either will +// cause the inclusion of debugging code. +#if !defined(_DEBUG) && defined(DBG) + #define _DEBUG DBG +#elif defined(_DEBUG) && !defined(DBG) + #define DBG _DEBUG +#endif + + + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// + +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// VERBOSE(msg) +// Display a message if the current debug level is <= DBG_VERBOSE. +// +// TERSE(msg) +// Display a message if the current debug level is <= DBG_TERSE. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// ASSERTMSG(cond, msg) +// Verify a condition is true. If not, display a message and +// force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// These macros require extra parantheses for the msg argument +// example, ASSERTMSG(x > 0, ("x is less than 0\n")); +// WARNING(("App passed NULL pointer, ignoring...\n")); +// + +#define DBG_VERBOSE 1 +#define DBG_TERSE 2 +#define DBG_WARNING 3 +#define DBG_ERROR 4 +#define DBG_RIP 5 +#define DBG_NONE 6 + +#if DBG + + #define DebugMsg DebugMessage + + // + // Strip the directory prefix from a filename (ANSI version) + // + + PCSTR + StripDirPrefixA( + IN PCSTR pstrFilename + ); + + extern INT giDebugLevel; + + + #define DBGMSG(level, prefix, msg) { \ + if (giDebugLevel <= (level)) { \ + DebugMsg("%s %s (%d): ", prefix, StripDirPrefixA(__FILE__), __LINE__); \ + DebugMsg(msg); \ + } \ + } + + #define DBGPRINT(level, msg) { \ + if (giDebugLevel <= (level)) { \ + DebugMsg(msg); \ + } \ + } + + #define VERBOSE if(giDebugLevel <= DBG_VERBOSE) DebugMsg + #define TERSE if(giDebugLevel <= DBG_TERSE) DebugMsg + #define WARNING if(giDebugLevel <= DBG_WARNING) DebugMsg + #define ERR if(giDebugLevel <= DBG_ERROR) DebugMsg + + #define ASSERT(cond) { \ + if (! (cond)) { \ + RIP(("\n")); \ + } \ + } + + #define ASSERTMSG(cond, msg) { \ + if (! (cond)) { \ + RIP(msg); \ + } \ + } + + #define RIP(msg) { \ + DBGMSG(DBG_RIP, "RIP", msg); \ + DebugBreak(); \ + } + + +#else // !DBG + + #define DebugMsg NOP_FUNCTION + + #define VERBOSE NOP_FUNCTION + #define TERSE NOP_FUNCTION + #define WARNING NOP_FUNCTION + #define ERR NOP_FUNCTION + + #define ASSERT(cond) + + #define ASSERTMSG(cond, msg) + #define RIP(msg) + #define DBGMSG(level, prefix, msg) + #define DBGPRINT(level, msg) + +#endif + + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCSTR, ...); +BOOL DebugMessage(LPCWSTR, ...); +void Dump(PPUBLISHERINFO pPublisherInfo); +void Dump(POEMDMPARAM pOemDMParam); +void Dump(PPROPSHEETUI_INFO pPSUIInfo); +void Dump(POPTITEM pOptItem); +void Dump(POPTTYPE pOptType); +void Dump(POPTPARAM pOptParam, WORD wCount); + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.cpp new file mode 100644 index 00000000..2a19310c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.cpp @@ -0,0 +1,214 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + +#include "precomp.h" +#include "oemui.h" +#include "debug.h" +#include "devmode.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +// +//Performs operation on UI Plugins Private DevMode Members. +//Called via IOemUI::DevMode +// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR(ERRORTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); + VERBOSE(DLLTEXT("\tdwMode = %d, pOemDMParam = %#lx.\r\n"), dwMode, pOemDMParam); + + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + // + //The Method should return the size of the memory allocation needed to store the UI plugin Private DEVMODE. + // + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + // + //Should fill the Private DEVMODE with the default values. + // + case OEMDM_DEFAULT: + // + //OEM_DMEXTRAHEADER Members + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + + // + //Private members + // + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + + VERBOSE(DLLTEXT("pOEMDevOut after setting default values:\r\n")); + Dump(pOEMDevOut); + break; + + // + //The method should convert private DEVMODE members to the current version, if necessary. + // + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + // + //The method should validate the information contained in private DEVMODE members and merge validated values into a private DEVMODE structure containing default values + // + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + Dump(pOemDMParam); + + return S_OK; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) +{ + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR(ERRORTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n")); + VERBOSE(DLLTEXT("pOEMDevIn:\r\n")); + Dump(pOEMDevIn); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + } + + return TRUE; +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data, if not valid. + if(pOEMDevmode->dwDriverData > 100) + { + pOEMDevmode->dwDriverData = 0; + } + + // Set Advanced driver data, if not valid. + if(pOEMDevmode->dwAdvancedData > 100) + { + pOEMDevmode->dwAdvancedData = 0; + } + + return TRUE; +} + + +void Dump(PCOEMDEV pOEMDevmode) +{ + if( (NULL != pOEMDevmode) + && + (pOEMDevmode->dmOEMExtra.dwSize >= sizeof(OEMDEV)) + && + (OEM_SIGNATURE == pOEMDevmode->dmOEMExtra.dwSignature) + ) + { + VERBOSE(TEXT("\tdmOEMExtra.dwSize = %d\r\n"), pOEMDevmode->dmOEMExtra.dwSize); + VERBOSE(TEXT("\tdmOEMExtra.dwSignature = %#x\r\n"), pOEMDevmode->dmOEMExtra.dwSignature); + VERBOSE(TEXT("\tdmOEMExtra.dwVersion = %#x\r\n"), pOEMDevmode->dmOEMExtra.dwVersion); + VERBOSE(TEXT("\tdwDriverData = %#x\r\n"), pOEMDevmode->dwDriverData); + VERBOSE(TEXT("\tdwAdvancedData = %#x\r\n"), pOEMDevmode->dwAdvancedData); + } + else + { + ERR(ERRORTEXT("Dump(POEMDEV) unknown private OEM DEVMODE.\r\n")); + } +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.h new file mode 100644 index 00000000..e2f9c6b7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/devmode.h @@ -0,0 +1,57 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + + + + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +// +//Can add info to the private devmode bellow here. +//Note : +// This structure must be prefixed by OEM_DMEXTRAHEADER +// Your plug-in must implement the IPrintOemUI::DevMode method +// +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + DWORD dwDriverData; + DWORD dwAdvancedData; + + // + //Private DevMode Members + // + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); +void Dump(PCOEMDEV pOEMDevIn); + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/dllentry.cpp new file mode 100644 index 00000000..dcac51ef --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/dllentry.cpp @@ -0,0 +1,49 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "oemui.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.cpp b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.cpp new file mode 100644 index 00000000..9e77a228 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.cpp @@ -0,0 +1,26 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.cpp +// +// +// PURPOSE: File that contains all the globals. +// +// +#include "precomp.h" + +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.h new file mode 100644 index 00000000..b6c7d0ee --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/globals.h @@ -0,0 +1,22 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.h +// +// +// PURPOSE: Lists of globals declared in Globals.cpp. +// +// +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +extern HINSTANCE ghInstance; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.cpp new file mode 100644 index 00000000..493d36f7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.cpp @@ -0,0 +1,612 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.cpp +// +// PURPOSE: UI plug-in implementation. +// +// + +#include "precomp.h" + +#include "oemui.h" +#include "debug.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0 ; // Count of active components +static long g_cServerLocks = 0 ; // Count of locks + + + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI body +// +IOemUI::~IOemUI() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall IOemUI::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE(DLLTEXT("IOemUI:QueryInterface entry.\r\n\r\n")); + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IOemUI:Return pointer to IUnknown.\r\n\r\n")); + } + else if (iid == IID_IPrintOemUI) + { + *ppv = static_cast(this) ; + VERBOSE(DLLTEXT("IOemUI:Return pointer to IPrintOemUI.\r\n")); + } + else + { + *ppv = NULL ; + VERBOSE(DLLTEXT("IOemUI:No Interface. Return NULL.\r\n")); + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemUI::AddRef() +{ + VERBOSE(DLLTEXT("IOemUI:AddRef entry.\r\n")); + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemUI::Release() +{ + VERBOSE(DLLTEXT("IOemUI:Release entry.\r\n")); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// +//(Implamentation is required) Supplies a pointer to UNIDRIVE /PScript IPrintOemDriverUI +// +HRESULT __stdcall IOemUI::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE(DLLTEXT("IOemUI:PublishDriverInterface entry.\r\n")); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (m_pOEMHelp == NULL) + { + HRESULT hResult; + + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUI, (void** ) &(m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + +// +//(Implamentation is required) Returns the UI Plugin's identification information +// +HRESULT __stdcall IOemUI::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IOemUI::GetInfo(%d) entry.\r\r\n"), dwMode); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + WARNING(DLLTEXT("IOemUI::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER\r\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("IOemUI::GetInfo() exit insufficient buffer!\r\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IOemUI::GetInfo() exit mode not supported.\r\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(DLLTEXT("IOemUI::GetInfo() exit S_OK, (*pBuffer is %#x).\r\r\n"), *(PDWORD)pBuffer); + return S_OK; +} + + +// +//Performs operation on UI Plugins Private DevMode Members. +// +HRESULT __stdcall IOemUI::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE(DLLTEXT("IOemUI:DevMode(%d, %#x) entry.\r\n"), dwMode, pOemDMParam); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + + +// +//Allows UI Plugin to Modifiy Existing printer porp sheet and document property sheet page.. +// +HRESULT __stdcall IOemUI::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam) +{ + VERBOSE(DLLTEXT("IOemUI:CommonUIProp entry.\r\n")); + + // + //We want to keep this pointer so the we can modifie the data and OPTITEMS from the OEM plugin page. + // + m_OemSheetData.pOEMCUIParam = pOemCUIPParam; + return hrOEMPropertyPage(dwMode, pOemCUIPParam); +} + + +// +//Adds a New page to the device Documment property sheet. +// + +HRESULT __stdcall IOemUI::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:DocumentPropertySheets entry.\r\n")); + + return hrOEMDocumentPropertySheets(pPSUIInfo, lParam, m_pOEMHelp); +} + +// +//Adds a New page to the device printer property page. +// +HRESULT __stdcall IOemUI::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:DevicePropertySheets entry.\r\n")); + + // + //Store the This pointer in the OEMSHEETDATA + // + m_OemSheetData.pOEMHelp = m_pOEMHelp; + return hrOEMDevicePropertySheets(pPSUIInfo, lParam, &(m_OemSheetData)); +} + + +// +//Allows the UI plugin to spec Customized device capabilaties (TODO) +// +HRESULT __stdcall IOemUI::DeviceCapabilities( + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult) +{ + VERBOSE(DLLTEXT("IOemUI:DeviceCapabilities entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + return E_NOTIMPL; +} + + +// +//Allows the UI plugin to help determine if a print Job is printable. +// +HRESULT __stdcall IOemUI::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM) +{ + VERBOSE(DLLTEXT("IOemUI:DevQueryPrintEx entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + + +// +//Allows the UI Plugin to upgrade its dev options stored in the registry. +// +HRESULT __stdcall IOemUI::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo) +{ + VERBOSE(DLLTEXT("IOemUI:UpgradePrinter entry.\r\n")); + + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:PrinterEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:DriverEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +#define PROFILE_NAME L"OEMPROFILE.icm\0" + +HRESULT __stdcall IOemUI::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData) +{ + HRESULT Result = E_FAIL; + + VERBOSE(DLLTEXT("IOemUI:QueryColorProfile entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + if(QCP_DEVICEPROFILE == ulQueryMode) + { + if(NULL == pvProfileData) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + if(*pcbProfileData < sizeof(PROFILE_NAME)) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + Result = StringCbCopy((LPWSTR)pvProfileData, *pcbProfileData, PROFILE_NAME); + *pcbProfileData = sizeof(PROFILE_NAME); + *pflProfileData = QCP_PROFILEDISK; + + if(FAILED(Result)) + { + SetLastError(Result); + } + } + } + } + + return Result; +}; + +HRESULT __stdcall IOemUI::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:FontInstallerDlgProc entry.\r\n")); + + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI::UpdateExternalFonts( + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges) +{ + VERBOSE(DLLTEXT("IOemUI:UpdateExternalFonts entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this) ; + } + else + { + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + //DbgPrint(DLLTEXT("Class factory:\t\tCreate component.")) ; + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION ; + } + + // Create component. + IOemUI* pOemCB = new IOemUI ; + if (pOemCB == NULL) + { + return E_OUTOFMEMORY ; + } + // Get the requested interface. + HRESULT hr = pOemCB->QueryInterface(iid, ppv) ; + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release() ; + return hr ; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks) ; + } + else + { + InterlockedDecrement(&g_cServerLocks) ; + } + return S_OK ; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK ; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:Create class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE ; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF ; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY ; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv) ; + pFontCF->Release() ; + + return hr ; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.h new file mode 100644 index 00000000..6ec38f73 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/intrface.h @@ -0,0 +1,192 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.h +// +// PURPOSE: UI plug-in definition. +// +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI +// +class IOemUI: public IPrintOemUI +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + IOemUI() + { + m_cRef = 1; + m_pOEMHelp = NULL; + m_OemSheetData.pfnComPropSheet = NULL; + m_OemSheetData.pOEMCUIParam=NULL; + m_OemSheetData.hComPropSheet=INVALID_HANDLE_VALUE; + m_OemSheetData.hmyPlugin=INVALID_HANDLE_VALUE; + }; + + ~IOemUI(); + +protected: + LONG m_cRef; + IPrintOemDriverUI* m_pOEMHelp; + + // + //Used to link common ui in device settings tab and the OEM plugin tab. + // + OEMSHEETDATA m_OemSheetData; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oem.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oem.h new file mode 100644 index 00000000..daad3e27 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oem.h @@ -0,0 +1,24 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: oem.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debug.cpp. +// + +#pragma once + +//////////////////////////////////////////////////////// +// OEM Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.cpp b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.cpp new file mode 100644 index 00000000..5802a776 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.cpp @@ -0,0 +1,1099 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.cpp +// +// PURPOSE: Main file for OEM UI test module. +// + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + +typedef struct _tagCBUserData +{ + HANDLE hComPropSheet; + HANDLE hPropPage; + POEMUIPSPARAM pOEMUIParam; + PFNCOMPROPSHEET pfnComPropSheet; + +} CBUSERDATA, *PCBUSERDATA; + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); + +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam); +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam); + +void SetOEMUiState (HWND hDlg, POEMSHEETDATA pOEMSheetData); +void SetOEMCommonDataIntoOptItem (POEMSHEETDATA pOEMSheetData, _In_ PSTR PName, LONG Sel); +void ChangeOpItem (IPrintOemDriverUI *pIPrintOEMDrvUI, POEMUIOBJ pOEMObj, POPTITEM pOptItem, int iSel); +POPTITEM FindDrvOptItem (POPTITEM pDrvOptItems, DWORD dwItemCount, _In_ PSTR pKeyWordName, BYTE dmPubID = DMPUB_NONE); + +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems); +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems); +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams); +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource); + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM device or document property UI. +// Called via IOemUI::CommonUIProp +// +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hResult = S_OK; + + + VERBOSE(DLLTEXT("hrOEMPropertyPage(%d) entry.\r\n"), dwMode); + + // Validate parameters. + if( (OEMCUIP_DOCPROP != dwMode) + && + (OEMCUIP_PRNPROP != dwMode) + ) + { + ERR(ERRORTEXT("hrOEMPropertyPage() ERROR_INVALID_PARAMETER.\r\n")); + VERBOSE(DLLTEXT("\tdwMode = %d, pOEMUIParam = %#lx.\r\n"), dwMode, pOEMUIParam); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam); + break; + + case OEMCUIP_PRNPROP: + hResult = hrPrinterPropertyPage(dwMode, pOEMUIParam); + break; + + default: + // Should never reach this! + ERR(ERRORTEXT("hrOEMPropertyPage() Invalid dwMode, %d"), dwMode); + SetLastError(ERROR_INVALID_PARAMETER); + hResult = E_FAIL; + break; + } + + return hResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM document property UI. +// +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM document property UI. + pOEMUIParam->cOEMOptItems = 1; + VERBOSE(DLLTEXT("hrDocumentPropertyPage() requesting %d number of items.\r\n"), pOEMUIParam->cOEMOptItems); + } + else + { + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() fill out %d items.\r\n"), pOEMUIParam->cOEMOptItems); + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMDocUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_ADV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + // + //Setup the Optional Item + // + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + } + + return S_OK; +} + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM printer property UI. +// +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + // + //This is null the first time the interface is called. + // + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM printer property UI. + pOEMUIParam->cOEMOptItems = 1; + VERBOSE(DLLTEXT("hrPrinterPropertyPage() requesting %d number of items.\r\n"), pOEMUIParam->cOEMOptItems); + } + else + { + // + //This is the second time we are called Now setup the optional items. + // + DWORD dwError; + DWORD dwDeviceValue; + DWORD dwType; + DWORD dwNeeded; + + VERBOSE(DLLTEXT("hrPrinterPropertyPage() fill out %d items.\r\n"), pOEMUIParam->cOEMOptItems); + + // + //Add OEM Optitem to the Device + // + + // Get device settings value from printer. + dwError = GetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, &dwType, (PBYTE) &dwDeviceValue, + sizeof(dwDeviceValue), &dwNeeded); + if( (ERROR_SUCCESS != dwError) + || + (dwDeviceValue > 100) + ) + { + // Failed to get the device value or value is invalid, just use the default. + dwDeviceValue = 0; + } + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMPrinterUICallBack; + + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_DEV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = dwDeviceValue; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + // + //Setup the Optional Item + // + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + + + } + return S_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to Document property sheet. Called via IOemUI::DocumentPropertySheets +// +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, + IPrintOemDriverUI* pOEMHelp) +{ + LONG_PTR lResult = 0; + HRESULT hrResult = S_OK; + + VERBOSE(DLLTEXT("hrOEMDocumentPropertySheets() entry.\r\n")); + + UNREFERENCED_PARAMETER(pOEMHelp); + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() ERROR_INVALID_PARAMETER.\r\n")); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + DWORD dwSheets = 0; + PCBUSERDATA pUserData; + POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM) pPSUIInfo->lParamInit; + HANDLE hHeap = pOEMUIParam->hOEMHeap; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + COMPROPSHEETUI Sheet; + + + // Init property page. + memset(&Sheet, 0, sizeof(COMPROPSHEETUI)); + Sheet.cbSize = sizeof(COMPROPSHEETUI); + Sheet.Flags = CPSUIF_UPDATE_PERMISSION; + Sheet.hInstCaller = ghInstance; + Sheet.pCallerName = GetStringResource(hHeap, ghInstance, IDS_NAME); + Sheet.pHelpFile = NULL; + Sheet.pfnCallBack = OEMDocUICallBack2; + Sheet.pDlgPage = CPSUI_PDLGPAGE_TREEVIEWONLY; + Sheet.cOptItem = 1; + Sheet.IconID = IDI_CPSUI_PRINTER; + Sheet.pOptItemName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.CallerVersion = 0x100; + Sheet.OptItemVersion = 0x100; + + // Init user data. + pUserData = (PCBUSERDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CBUSERDATA)); + if (NULL == pUserData) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to allocate user data.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + pUserData->hComPropSheet = pPSUIInfo->hComPropSheet; + pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + pUserData->pOEMUIParam = pOEMUIParam; + Sheet.UserData = (ULONG_PTR) pUserData; + + // Create OptItems for page. + Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem); + if (NULL == Sheet.pOptItem) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to allocate OPTITEMs.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Initialize OptItems + Sheet.pOptItem[0].Level = 1; + Sheet.pOptItem[0].Flags = OPTIF_COLLAPSE; + Sheet.pOptItem[0].pName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.pOptItem[0].Sel = pOEMDev->dwDriverData; + + Sheet.pOptItem[0].pOptType = CreateOptType(hHeap, 2); + if (NULL == Sheet.pOptItem[0].pOptType) + { + ERR(ERRORTEXT("hrOEMDocumentPropertySheets() failed to allocate OPTTYPE.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // + //Set the UI prop of this OPTYPE item. + // + Sheet.pOptItem[0].pOptType->Type = TVOT_UDARROW; + Sheet.pOptItem[0].pOptType->pOptParam[1].IconID = 0; + Sheet.pOptItem[0].pOptType->pOptParam[1].lParam = 100; + + // Adds the property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PCOMPROPSHEETUI, + (LPARAM)&Sheet, (LPARAM)&dwSheets); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + +Exit: + + pPSUIInfo->Result = lResult; + return hrResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to printer property sheet. Called via IOemUI::DevicePropertySheets +// +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, POEMSHEETDATA pOemSheetData) +{ + LONG_PTR lResult = 0; + + + VERBOSE(DLLTEXT("hrOEMDevicePropertySheets(%#x, %#x) entry\r\n"), pPSUIInfo, lParam); + + // Validate parameters. + if( (NULL == pPSUIInfo) + + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR(ERRORTEXT("hrOEMDevicePropertySheets() ERROR_INVALID_PARAMETER.\r\n")); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + Dump(pPSUIInfo); + + + // Do action. + switch(pPSUIInfo->Reason) + { + + case PROPSHEETUI_REASON_INIT: + { + PROPSHEETPAGE Page; + + // Init property page. + memset(&Page, 0, sizeof(PROPSHEETPAGE)); + Page.dwSize = sizeof(PROPSHEETPAGE); + Page.dwFlags = PSP_DEFAULT; + Page.hInstance = ghInstance; + Page.pszTemplate = MAKEINTRESOURCE(IDD_DEVICE_PROPPAGE); + Page.pfnDlgProc = DevicePropPageProc; + + // + //This is the OEMPlugIN Sheets Shared Data. Use this Pointer to gain access to shared driver data + // + pOemSheetData->hComPropSheet = pPSUIInfo->hComPropSheet; + pOemSheetData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + Page.lParam = (LPARAM)pOemSheetData; + + // Add property sheets. + pOemSheetData->hmyPlugin = (HANDLE)(pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PROPSHEETPAGE, (LPARAM)&Page, 0)); + + VERBOSE(DLLTEXT("hrOEMDevicePropertySheets() pfnComPropSheet returned %d.\r\n"), pOemSheetData->hmyPlugin); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + + pPSUIInfo->Result = lResult; + return S_OK; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM printer property UI. +// +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + + VERBOSE(DLLTEXT("OEMPrinterUICallBack() entry, Reason is %d.\r\n"), pCallbackParam->Reason); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + { + DWORD dwDriverValue = pOEMUIParam->pOEMOptItems[0].Sel; + + // + // Store OptItems state in printer data. + // + SetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, REG_DWORD, (PBYTE) &dwDriverValue, sizeof(DWORD)); + } + break; + + // + //Because the plugin page is changing items in this CPSUI page we need to rinitalise the data on the page. + // + case CPSUICB_REASON_SETACTIVE: + return CPSUICB_ACTION_OPTIF_CHANGED; + break; + + default: + break; + } + + return lReturn; +} + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Call back for OEM device property UI. +// +// This OEM plugin page is using the OPTITEMS in the Device tab to store data. (Installabale Options) +// If you hide these option in the device tab and only access them from your UI you dont have to worry about sync the views. +// If you want the Options in both tabs you need to have a CPSUICALLBACK function defined for the Device tab. (OEMPrinterUICallBack) +// OEMPrinterUICallBack will return CPSUICB_ACTION_OPTIF_CHANGED; to indicate that some of the controls have change. Resulting in CPSUI to refresh the view. +// +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + + VERBOSE(DLLTEXT("DevicePropPageProc() entry, Reason is %d.\r\n"), uiMsg); + + POEMSHEETDATA pOEMSheetData = NULL; + LONG lState = 0; + DWORD fDataValid = 0; + WORD dlgControl = 0; + PSTR pControlName = NULL; + + + if ( uiMsg != WM_INITDIALOG ) + { + // + //Retrieves Application data storded by the call to SetWindowLongPtr. + // + pOEMSheetData = (POEMSHEETDATA)GetWindowLongPtr( hDlg, DWLP_USER); + + + if (!pOEMSheetData) + { + // + //Failed to get the OEM Prop Page Data Pointer. + // + ERR(ERRORTEXT("DevicePropPageProc : GetWindowLongPtr Failed (%d)\r\n"), GetLastError()); + return FALSE; + } + } + + switch (uiMsg) + { + case WM_INITDIALOG: + // + //PROPSHEETPAGE structure is passed to the dialog box procedure with a WM_INITDIALOG message. + //The lParam member is provided to allow you to pass application-specific information to the dialog box procedure + // + SetWindowLongPtr (hDlg, DWLP_USER, (LONG_PTR)((LPPROPSHEETPAGE)lParam)->lParam); + break; + + case WM_COMMAND: + switch(HIWORD(wParam)) + { + + case BN_CLICKED: + + // + //Change the UI to activate the apply button Send the prop dailog a change message. + // + PropSheet_Changed(GetParent(hDlg), hDlg); + + switch(LOWORD(wParam)) + { + + // + //USER modified OEM Controls on the plugin page. + // + case IDC_CHECK_DUPLPEX: + dlgControl = IDC_CHECK_DUPLPEX; + fDataValid = TRUE; + pControlName = (PSTR)DUPLEXUNIT; + break; + + case IDC_CHECK_HDRIVE: + dlgControl = IDC_CHECK_HDRIVE; + fDataValid = TRUE; + pControlName = (PSTR)PRINTERHDISK; + break; + + case IDC_CHECK_ENVFEEDER: + dlgControl = IDC_CHECK_ENVFEEDER; + fDataValid = TRUE; + pControlName = (PSTR)ENVFEEDER; + break; + + default: + fDataValid = 0; + break; + + } + + // + //If the Control is valid Get the ctrl state and UPdate the OPTITEM. + // + if ( fDataValid ) + { + lState = (LONG)(SendDlgItemMessage (hDlg, dlgControl, BM_GETSTATE, 0, 0) & 0x0003); + VERBOSE(DLLTEXT("DevicePropPageProc : Clicked dlgControl (%d)\r\n"), lState); + + // + //Saves the Data to the OPTITEMS in the device settings page. + // + SetOEMCommonDataIntoOptItem (pOEMSheetData, pControlName, lState); + } + break; + + + default: + return FALSE; + } + return TRUE; + + // + //Dailog is going to paint set up the UI controls to match the relavent OPTITEMS Data. + // + case WM_CTLCOLORDLG: + { + VERBOSE(DLLTEXT("DevicePropPageProc : WM_CTLCOLORDLG \r\n")); + SetOEMUiState (hDlg, pOEMSheetData); + } + return TRUE; + + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) // type of notification message + { + case PSN_SETACTIVE: + return TRUE; + break; + + case PSN_KILLACTIVE: + return TRUE; + break; + + case PSN_APPLY: + + // + //Calls ComPropSheet + //causes the ComPropSheet function to pass a specified result value to all PFNPROPSHEETUI-typed functions associated with a specified page and its parents + // + pOEMSheetData->pfnComPropSheet(pOEMSheetData->hComPropSheet, + CPSFUNC_SET_RESULT, + (LPARAM) pOEMSheetData->hmyPlugin, + (LPARAM)CPSUI_OK); + + // + //Accept the apply if the data was invalid and you are checking for this set PSNRET_INVALID | PSNRET_INVALID_NOCHANGEPAGE + //Disables the APPLY button and saves the Data. + // + PropSheet_UnChanged(GetParent(hDlg), hDlg); + SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PSNRET_NOERROR); + return TRUE; + break; + + // + // Need To undo the changes + // + case PSN_RESET: + break; + } + } + break; + } + + return FALSE; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Update the OEM page controls to match the Device settings page +// + +void SetOEMUiState (HWND hDlg, POEMSHEETDATA pOEMSheetData) +{ + LRESULT lstate = 0; + POEMCUIPPARAM pOEMCUIParam = NULL; + PUSERDATA pUserData = NULL; + POPTITEM pOptItem = NULL; + DWORD cDrvOptItems = 0; + + + if (pOEMSheetData->pOEMCUIParam) + { + pOEMCUIParam = pOEMSheetData->pOEMCUIParam; + cDrvOptItems = pOEMCUIParam->cDrvOptItems; + } + + // + //loop down the OPITEMS and retrieve the data that is needed from the control + //(all Optitesm are ref from DMPubID of the UserData->pKeyWordName) + // + for (DWORD i=0; i < cDrvOptItems; i++) + { + pOptItem = &(pOEMCUIParam->pDrvOptItems[i]); + if (pOptItem->UserData) + { + pUserData = (PUSERDATA)(pOptItem->UserData); + if ( pUserData->pKeyWordName ) + { + // + //Get the Selection of the OPITEM + // + if (pOptItem->Sel) + { + lstate = BST_CHECKED; + } + else + { + lstate = BST_UNCHECKED; + } + + // + //Update the Data in OEM Page to mactch the data in the Device Settings TAB. + //Send a message to the Cntrol to update its State. + // + + //Set the Duplex Option + if ( strcmp(pUserData->pKeyWordName, DUPLEXUNIT ) == 0 ) + { + SendDlgItemMessage (hDlg, IDC_CHECK_DUPLPEX, BM_SETCHECK, lstate, 0); + } + + //Set HardDrive Option + if ( strcmp (pUserData->pKeyWordName, PRINTERHDISK ) == 0 ) + { + SendDlgItemMessage (hDlg, IDC_CHECK_HDRIVE, BM_SETCHECK, lstate, 0); + } + + //Set the Env Feeder Option + if ( strcmp (pUserData->pKeyWordName, ENVFEEDER ) == 0 ) + { + SendDlgItemMessage (hDlg, IDC_CHECK_ENVFEEDER, BM_SETCHECK, lstate, 0); + } + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Save the OEM change into the correct OPTITEM. +// The UI data is been stored in the driver supplied OPTITEM +// +void SetOEMCommonDataIntoOptItem (POEMSHEETDATA pOEMSheetData, _In_ PSTR PName, LONG Sel) +{ + + VERBOSE(DLLTEXT("SetOEMCommonDataIntoOptItem (%S) \r\n"), PName); + + POEMCUIPPARAM pOEMCUIParam = pOEMSheetData->pOEMCUIParam; + POPTITEM pOptItem = NULL; + + // + //Find the OPTITEM that needs to be Updated. + // + pOptItem = FindDrvOptItem (pOEMCUIParam->pDrvOptItems, + pOEMCUIParam->cDrvOptItems, + PName, + DMPUB_NONE); + + if (pOptItem) + { + ChangeOpItem (pOEMSheetData->pOEMHelp, + pOEMCUIParam->poemuiobj, + pOptItem, + Sel); + } + else + { + ERR(ERRORTEXT("SetOEMCommonDataIntoOptItem Item Not Found OPTITEM(%S) \r\n"), PName); + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Help Change the data set in the OPTITEM +// +void ChangeOpItem (IPrintOemDriverUI *pIPrintOEMDrvUI, POEMUIOBJ pOEMUIObj, POPTITEM pOptItem, int iSel) +{ + HRESULT hRestult = S_OK; + + // + //Change the Item (Change which OPTPARAM is selected fot the required OPTTYPE) + // + pOptItem->Sel = iSel; + + // + //Set the Flag indicating it is changed + // + pOptItem->Flags |= OPTIF_CHANGED; + + // + //Update the Driver UI. (this updates the UI but it does not cause CPSUI to update the its pages), + //Look at OEMPrinterUICallBack to see how CPSUI pages are updated + //The IPrintOemDriverUI::DrvUpdateUISetting method is provided by the + //Unidrv and Pscript5 minidrivers so that user interface plug-ins can + //notify the driver of a modified user interface option. + // + hRestult = pIPrintOEMDrvUI->DrvUpdateUISetting((PVOID)pOEMUIObj, (PVOID)pOptItem, 0, OEMCUIP_PRNPROP); + + if (hRestult != S_OK) + { + ERR(ERRORTEXT("ChangeOpItem DrvUpdateUISetting FAILED \r\n") ); + } + +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Help Find a OPTITEM from the array based on USERDATA->pKeyWordName or DMPubID +// +POPTITEM FindDrvOptItem (POPTITEM pDrvOptItems, DWORD dwItemCount, _In_ PSTR pKeyWordName, BYTE dmPubID ) +{ + VERBOSE(DLLTEXT("FindDrvOptItem Looking (%S) (%d) \r\n"), pKeyWordName, dmPubID); + + POPTITEM pOptItem = NULL; + PUSERDATA pUserData = NULL; + + for (DWORD i=0; i < dwItemCount; i++) + { + // + //OPTITEM has valid data compare these now (Search on DMPubID) + // + if (pKeyWordName == NULL) + { + if (dmPubID == pDrvOptItems[i].DMPubID) + { + pOptItem = &(pDrvOptItems[i]); + break; + } + } + else + { + // + //(Search a printer freature pKeyWordName) + // + //For Common Printer Features the key name is set to a common non localised string + //Note the these are only ansi strings ie PSTR + // + if (pDrvOptItems[i].UserData) + { + pUserData = (PUSERDATA)pDrvOptItems[i].UserData; + if (pUserData->pKeyWordName) + { + // + //OPTITEM has valid data compare these now + // + if ( strcmp (pUserData->pKeyWordName, pKeyWordName) == 0) + { + pOptItem = &(pDrvOptItems[i]); + break; + } + } + } + } + } + + if (!pOptItem) + { + ERR(ERRORTEXT("FindDrvOptItem OPTITEM NOT Found \r\n") ); + } + + return pOptItem; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM document property UI. +// +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("OEMDocUICallBack() entry, Reason is %d.\r\n"), pCallbackParam->Reason); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Store OptItems state in DEVMODE. + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_KILLACTIVE: + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + // + //Refress the Data in the view and tell CPUSI that the data has changed by ret CPSUICB_ACTION_OPTIF_CHANGED + // + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pOEMUIParam->pOEMOptItems[0].Sel) != pOEMDev->dwAdvancedData) + { + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + pOEMUIParam->pOEMOptItems[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + PCBUSERDATA pUserData = (PCBUSERDATA) pCallbackParam->UserData; + POEMDEV pOEMDev = (POEMDEV) pUserData->pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("OEMDocUICallBack2() entry, Reason is %d.\r\n"), pCallbackParam->Reason); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + pUserData->pfnComPropSheet(pUserData->hComPropSheet, CPSFUNC_SET_RESULT, + (LPARAM)pUserData->hPropPage, + (LPARAM)CPSUI_OK); + break; + + case CPSUICB_REASON_KILLACTIVE: + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pCallbackParam->pOptItem[0].Sel) != pOEMDev->dwDriverData) + { + pCallbackParam->pOptItem[0].Sel = pOEMDev->dwDriverData; + pCallbackParam->pOptItem[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Creates and Initializes OptItems. +// +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems) +{ + POPTITEM pOptItems = NULL; + SIZE_T sizeOfOptItems = 0; + + // Compute the size of memory needed for the OptItems: + if (SUCCEEDED(SIZETMult(sizeof(OPTITEM), (SIZE_T)dwOptItems, &sizeOfOptItems))) + { + // Allocate memory for OptItems; + pOptItems = (POPTITEM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeOfOptItems); + if(NULL != pOptItems) + { + InitOptItems(pOptItems, dwOptItems); + } + else + { + ERR(ERRORTEXT("CreateOptItems() failed to allocate memory for OPTITEMs!\r\n")); + } + } + else + { + ERR(ERRORTEXT("CreateOptItems() failed to compute necessary memory size for OPTITEMs!\r\n")); + } + + return pOptItems; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems. +// +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems) +{ + VERBOSE(DLLTEXT("InitOptItems() entry.\r\n")); + + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for(DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OptType for OptItem. +// +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams) +{ + POPTTYPE pOptType = NULL; + + + VERBOSE(DLLTEXT("CreateOptType() entry.\r\n")); + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + if(NULL != pOptType) + { + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, wOptParams * sizeof(OPTPARAM)); + if(NULL != pOptType->pOptParam) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + ERR(ERRORTEXT("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n")); + + // Free allocated memory and return NULL. + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR(ERRORTEXT("CreateOptType() failed to allocated memory for OPTTYPE!\r\n")); + } + + return pOptType; +} + +//////////////////////////////////////////////////////////////////////////////////// +// +// Retrieves pointer to a String resource. +// +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource) +{ + int nResult; + DWORD dwSize = MAX_PATH; + PTSTR pszString = NULL; + + + VERBOSE(DLLTEXT("GetStringResource(%#x, %#x, %d) entered.\r\n"), hHeap, hModule, uResource); + + // Allocate buffer for string resource from heap; let the driver clean it up. + pszString = (PTSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(TCHAR)); + if(NULL != pszString) + { + // Load string resource; resize after loading so as not to waste memory. + nResult = LoadString((HMODULE)hModule, uResource, pszString, dwSize); + if(nResult > 0) + { + PTSTR pszTemp; + + + VERBOSE(DLLTEXT("LoadString() returned %d!\r\n"), nResult); + VERBOSE(DLLTEXT("String load was \"%s\".\r\n"), pszString); + + pszTemp = (PTSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszString, (nResult + 1) * sizeof(TCHAR)); + if(NULL != pszTemp) + { + pszString = pszTemp; + } + else + { + ERR(ERRORTEXT("GetStringResource() HeapReAlloc() of string retrieved failed! (Last Error was %d)\r\n"), GetLastError()); + } + } + else + { + ERR(ERRORTEXT("LoadString() returned %d! (Last Error was %d)\r\n"), nResult, GetLastError()); + ERR(ERRORTEXT("GetStringResource() failed to load string resource %d!\r\n"), uResource); + + pszString = NULL; + } + } + else + { + ERR(ERRORTEXT("GetStringResource() failed to allocate string buffer!\r\n")); + } + + return pszString; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.h new file mode 100644 index 00000000..1c07802f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.h @@ -0,0 +1,74 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for OEMUI Test Module. +// +// +#pragma once + +#include "OEM.H" +#include "DEVMODE.H" +#include "globals.h" + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + + +// OEM Signature and version. +#define PROP_TITLE L"OEM UI Page" +#define DLLTEXT(s) __TEXT("UI: ") __TEXT(s) + +// OEM UI Misc defines. +#define ERRORTEXT(s) __TEXT("ERROR ") DLLTEXT(s) + + +// Printer registry keys where OEM data is stored. +#define OEMUI_VALUE TEXT("OEMUI_VALUE") +#define OEMUI_DEVICE_VALUE TEXT("OEMUI_DEVICE_VALUE") + +// +//KeyWordNames for OPTITEMS (These are nonlocalised keywords assocaited with driver features. in the OPTITEMS) +// +const char DUPLEXUNIT[] = "DuplexUnit"; +const char ENVFEEDER[] = "EnvFeeder"; +const char PRINTERHDISK[] = "PrinterHardDisk"; + +// +//This structure is used to link the common pages and the OEM plugin page. +// +typedef struct _OEMSHEETDATA { + + // + //Any other OEM Data you may want to store. + // + + + // + //Hold Pointers you may need. + // + HANDLE hComPropSheet; //Handle to the Prop Sheet Parent Page Used when calling ComPropSheet + HANDLE hmyPlugin; //Handle to the OEM Plugin page. Page Used when calling ComPropSheet + PFNCOMPROPSHEET pfnComPropSheet; //Is the Pointer to ComPropSheet This is needed when APPLY is clicked (CPSFUNC_SET_RESULT) + + POEMCUIPPARAM pOEMCUIParam; //Holds links to the DEVMODE and OPTITEMS needed. + IPrintOemDriverUI* pOEMHelp; + +} OEMSHEETDATA, *POEMSHEETDATA; + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, IPrintOemDriverUI* pOEMHelp); +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, POEMSHEETDATA pOemSheetData); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.rc b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.rc new file mode 100644 index 00000000..e87badbe --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/oemui.rc @@ -0,0 +1,175 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "OEM UI Test Module." + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "OEMUI" + VALUE "LegalCopyright", "Copyright © 1998 - 2003 Microsoft Corp." + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "OEMUI.dll" + VALUE "ProductName", "Microsoft OEMUI" + VALUE "ProductVersion", "1.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DEVICE_PROPPAGE DIALOG 0, 0, 179, 113 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Device Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + GROUPBOX "Oem Install Options",IDC_STATIC,15,29,81,59 + LTEXT "OEM UI Controls",IDC_STATIC,55,14,68,11,WS_TABSTOP + CONTROL "Duplex Unit",IDC_CHECK_DUPLPEX,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,20,42,54,10 + CONTROL "Printer Hard Drive",IDC_CHECK_HDRIVE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,20,67,75,10 + CONTROL "Envelope Feeder",IDC_CHECK_ENVFEEDER,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,20,54,71,10 +END + +IDD_DOC_PROPPAGE DIALOG 0, 0, 210, 154 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Document Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Document Property Page",IDC_STATIC,60,73,108,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DEVICE_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 170 + TOPMARGIN, 8 + BOTTOMMARGIN, 106 + END + + IDD_DOC_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 203 + TOPMARGIN, 7 + BOTTOMMARGIN, 147 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_SECTION "OEM UI Added Item" + IDS_CALIBRATED "Printer has been calibrated." + IDS_NAME "OEM UI Customization DLL" + IDS_DEV_SECTION "Device Settings OEM UI Added Item" + IDS_ADV_SECTION "Advanced OEM UI Added Item" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precomp.h new file mode 100644 index 00000000..2d502998 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precomp.h @@ -0,0 +1,53 @@ +// +// +// PURPOSE: Header files that should be in the precompiled header. +// +// + +#pragma once + + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Safe integer functions to detect integer overflow/underflow conditions: +#include + +// Include this last to disallow +// unsafe string functions +#include + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/resource.h new file mode 100644 index 00000000..aacf0218 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/SyncSet/resource.h @@ -0,0 +1,28 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by oemui.rc +// +#define IDS_SECTION 1 +#define IDS_CALIBRATED 2 +#define IDS_NAME 3 +#define IDS_HELPFILE 4 +#define IDS_DEV_SECTION 5 +#define IDS_ADV_SECTION 10 +#define IDD_DEVICE_PROPPAGE 106 +#define IDD_DOC_PROPPAGE 107 +#define IDC_CALIBRATE 1001 +#define IDC_RADIO3 1004 +#define IDC_CHECK_DUPLPEX 1008 +#define IDC_CHECK_HDRIVE 1009 +#define IDC_CHECK_ENVFEEDER 1010 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/OEMUI.rc b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/OEMUI.rc new file mode 100644 index 00000000..a6491905 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/OEMUI.rc @@ -0,0 +1,169 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "OEM UI Test Module." + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "OEMUI" + VALUE "LegalCopyright", "Copyright © 1998 - 2003 Microsoft Corp." + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "OEMUI.dll" + VALUE "ProductName", "Microsoft OEMUI" + VALUE "ProductVersion", "1.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DEVICE_PROPPAGE DIALOG 0, 0, 179, 113 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Device Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Added Page",IDC_STATIC,55,14,68,11 + PUSHBUTTON "Calibrate",IDC_CALIBRATE,61,34,50,14 +END + +IDD_DOC_PROPPAGE DIALOG 0, 0, 210, 154 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Document Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Document Property Page",IDC_STATIC,60,73,108,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DEVICE_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 172 + TOPMARGIN, 8 + BOTTOMMARGIN, 106 + END + + IDD_DOC_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 203 + TOPMARGIN, 7 + BOTTOMMARGIN, 147 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_SECTION "OEM UI Added Item" + IDS_CALIBRATED "Printer has been calibrated." + IDS_NAME "OEM UI Customization DLL" + IDS_DEV_SECTION "Device Settings OEM UI Added Item" + IDS_ADV_SECTION "Advanced OEM UI Added Item" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUI.Manifest b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUI.Manifest new file mode 100644 index 00000000..bb48af65 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUI.Manifest @@ -0,0 +1,22 @@ + + + +Your app description here + + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj new file mode 100644 index 00000000..4abfd7bb --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj @@ -0,0 +1,1120 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {EA206DEA-26E6-4FD4-BF68-23F222C5E211} + $(MSBuildProjectName) + Win10 Debug + Win32 + {7ABB810D-F51B-46DA-8A6C-6883AF316932} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + ThemeUISmpl + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + + %(AdditionalOptions) -ignore:4049,4217 + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE;ISOLATION_AWARE_ENABLED + %(PreprocessorDefinitions);MANIFEST_RESOURCE=2 + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ThemeUISmpl.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj.Filters new file mode 100644 index 00000000..d8206354 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/ThemeUISmpl.vcxproj.Filters @@ -0,0 +1,327 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {18CF118F-704E-4B55-9621-B0D2F73CBFBE} + + + h;hpp;hxx;hm;inl;inc;xsd + {44047F2E-3DA5-4847-BAE3-6573B04506AF} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {695ECF76-7AFF-4B2D-A4E5-2138B4CC5B5A} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + Header Files + + + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp new file mode 100644 index 00000000..15234361 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.cpp @@ -0,0 +1,187 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + + +#include "precomp.h" +#include "oemui.h" +#include "debug.h" +#include "devmode.h" + + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// +//Performs operation on UI Plugins Private DevMode Members. +//Called via IOemUI::DevMode +// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR(DLLTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + // + //The Method should return the size of the memory allocation needed to store the UI plugin Private DEVMODE. + // + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + // + //Should fill the Private DEVMODE with the default values. + // + case OEMDM_DEFAULT: + // + //OEM_DMEXTRAHEADER Members + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + + // + //Private members + // + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + + VERBOSE(DLLTEXT("pOEMDevOut after setting default values:\r\n")); + break; + + // + //The method should convert private DEVMODE members to the current version, if necessary. + // + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + // + //The method should validate the information contained in private DEVMODE members and merge validated values into a private DEVMODE structure containing default values + // + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return S_OK; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) +{ + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR(DLLTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n")); + VERBOSE(DLLTEXT("pOEMDevIn:\r\n")); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + } + + return TRUE; +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data, if not valid. + if(pOEMDevmode->dwDriverData > 100) + { + pOEMDevmode->dwDriverData = 0; + } + + // Set Advanced driver data, if not valid. + if(pOEMDevmode->dwAdvancedData > 100) + { + pOEMDevmode->dwAdvancedData = 0; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.h new file mode 100644 index 00000000..b55fb016 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/devmode.h @@ -0,0 +1,55 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + + + + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +// +//Can add info to the private devmode bellow here. +//Note : +// This structure must be prefixed by OEM_DMEXTRAHEADER +// Your plug-in must implement the IPrintOemUI::DevMode method +// +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + DWORD dwDriverData; + DWORD dwAdvancedData; + + // + //Private DevMode Members + // + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/dllentry.cpp new file mode 100644 index 00000000..a7c846b7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/dllentry.cpp @@ -0,0 +1,66 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "oemui.h" +#include "fusutils.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + + // Store the module handle in case we need it later. + ghInstance = hInst; + + // NOTE: We don't create an Activation Context on module load, + // but on need of an Avtivation Context; the first time + // GetMyActivationContext() or CreateMyActivationContext() is called. + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + + // Release the Activation Context if we created one somewhere + // by calling GetMyActivationContext() or CreateMyActivationContext(); + if(INVALID_HANDLE_VALUE != ghActCtx) + { + ReleaseActCtx(ghActCtx); + ghActCtx = INVALID_HANDLE_VALUE; + } + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.cpp new file mode 100644 index 00000000..0f9bf2c3 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.cpp @@ -0,0 +1,118 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: fsutils.h +// +// +// PURPOSE: Fusion utilities +// + +#include "precomp.h" +#include "globals.h" +#include "fusutils.h" + +#define MAX_LOOP 10 + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +HANDLE GetMyActivationContext() +{ + // Make sure we've created our activation context. + CreateMyActivationContext(); + + // Return the global. + return ghActCtx; +} + + +BOOL CreateMyActivationContext() +{ + if(INVALID_HANDLE_VALUE != ghActCtx) + { + return TRUE; + } + + ghActCtx = CreateActivationContextFromResource(ghInstance, MAKEINTRESOURCE(MANIFEST_RESOURCE)); + + return (INVALID_HANDLE_VALUE != ghActCtx); +} + + + +HANDLE CreateActivationContextFromResource(HMODULE hModule, LPCTSTR pszResourceName) +{ + DWORD dwSize = MAX_PATH; + DWORD dwUsed = 0; + DWORD dwLoop; + PTSTR pszModuleName = NULL; + ACTCTX act; + HANDLE hActCtx = INVALID_HANDLE_VALUE; + + + // Get the name for the module that contains the manifest resource + // to create the Activation Context from. + dwLoop = 0; + do + { + // May need to allocate or re-alloc buffer for module name. + if(NULL != pszModuleName) + { + // Need to re-alloc bigger buffer. + + // First, delete old buffer. + delete[] pszModuleName; + + // Second, increase buffer alloc size. + dwSize <<= 1; + } + pszModuleName = new TCHAR[dwSize]; + if(NULL == pszModuleName) + { + goto Exit; + } + + // Try to get the module name. + dwUsed = GetModuleFileName(hModule, pszModuleName, dwSize); + + // Check to see if it failed. + if(0 == dwUsed) + { + goto Exit; + } + + // If dwUsed is equla to dwSize or larger, + // the buffer passed in wasn't big enough. + } while ( (dwUsed >= dwSize) && (++dwLoop < MAX_LOOP) ); + + // Now let's try to create an activation context + // from manifest resource. + ::ZeroMemory(&act, sizeof(act)); + act.cbSize = sizeof(act); + act.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; + act.lpResourceName = pszResourceName; + act.lpSource = pszModuleName; + + hActCtx = CreateActCtx(&act); + + +Exit: + + // + // Clean up. + // + + if(NULL != pszModuleName) + { + delete[] pszModuleName; + } + + return hActCtx; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.h new file mode 100644 index 00000000..2f79c522 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/fusutils.h @@ -0,0 +1,18 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: fsutils.h +// +// +// PURPOSE: Fusion utilities +// +#pragma once + +HANDLE GetMyActivationContext(); +BOOL CreateMyActivationContext(); +HANDLE CreateActivationContextFromResource(HMODULE hModule, LPCTSTR pszResourceName); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.cpp new file mode 100644 index 00000000..d2af1b8b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.cpp @@ -0,0 +1,29 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.cpp +// +// +// PURPOSE: File that contains all the globals. +// + +#include "precomp.h" +#include "globals.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; + +// Module's Activation Context from DLLEntry of process. +HANDLE ghActCtx = INVALID_HANDLE_VALUE; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.h new file mode 100644 index 00000000..a5a58cb8 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/globals.h @@ -0,0 +1,21 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.h +// +// +// PURPOSE: Lists of globals declared in Globals.cpp. +// +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +extern HINSTANCE ghInstance; // Module's Instance handle from DLLEntry of process. +extern HANDLE ghActCtx; // Module's Activation Context from DLLEntry of process. + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.cpp new file mode 100644 index 00000000..3b966a58 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.cpp @@ -0,0 +1,575 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Implementation of interface for PScript4, PScript5, Unidrv4, +// Unidrv5 UI plug-ins. +// + +#include "precomp.h" + +#include "oemui.h" +#include "debug.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0 ; // Count of active components +static long g_cServerLocks = 0 ; // Count of locks + + + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI body +// +IOemUI::~IOemUI() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall IOemUI::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE(DLLTEXT("IOemUI:QueryInterface entry.\r\n\r\n")); + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IOemUI:Return pointer to IUnknown.\r\n\r\n")); + } + else if (iid == IID_IPrintOemUI) + { + *ppv = static_cast(this) ; + VERBOSE(DLLTEXT("IOemUI:Return pointer to IPrintOemUI.\r\n")); + } + else + { + VERBOSE(DLLTEXT("IOemUI::QueryInterface interface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemUI::AddRef() +{ + VERBOSE(DLLTEXT("IOemUI:AddRef entry.\r\n")); + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemUI::Release() +{ + VERBOSE(DLLTEXT("IOemUI:Release entry.\r\n")); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +HRESULT __stdcall IOemUI::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE(DLLTEXT("IOemUI:PublishDriverInterface entry.\r\n")); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (m_pOEMHelp == NULL) + { + HRESULT hResult; + + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUI, (void** ) &(m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT __stdcall IOemUI::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IOemUI::GetInfo entry.\r\r\n")); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + WARNING(DLLTEXT("IOemUI::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER\r\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("IOemUI::GetInfo() exit insufficient buffer!\r\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IOemUI::GetInfo() exit mode not supported.\r\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(DLLTEXT("IOemUI::GetInfo() exit S_OK.\r\r\n")); + return S_OK; +} + +HRESULT __stdcall IOemUI::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE(DLLTEXT("IOemUI:DevMode entry.\r\n")); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IOemUI::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam) +{ + VERBOSE(DLLTEXT("IOemUI:CommonUIProp entry.\r\n")); + + return hrOEMPropertyPage(dwMode, pOemCUIPParam); +} + + +HRESULT __stdcall IOemUI::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:DocumentPropertySheets entry.\r\n")); + + return hrOEMDocumentPropertySheets(pPSUIInfo, lParam, m_pOEMHelp); +} + +HRESULT __stdcall IOemUI::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:DevicePropertySheets entry.\r\n")); + + return hrOEMDevicePropertySheets(pPSUIInfo, lParam); +} + +HRESULT __stdcall IOemUI::DeviceCapabilities( + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult) +{ + VERBOSE(DLLTEXT("IOemUI:DeviceCapabilities entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM) +{ + VERBOSE(DLLTEXT("IOemUI:DevQueryPrintEx entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo) +{ + VERBOSE(DLLTEXT("IOemUI:UpgradePrinter entry.\r\n")); + + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:PrinterEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:DriverEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +#define PROFILE_NAME L"OEMPROFILE.icm\0" + +HRESULT __stdcall IOemUI::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData) +{ + HRESULT Result = E_FAIL; + + + VERBOSE(DLLTEXT("IOemUI:QueryColorProfile entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + if(QCP_DEVICEPROFILE == ulQueryMode) + { + if(NULL == pvProfileData) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + if(*pcbProfileData < sizeof(PROFILE_NAME)) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + Result = StringCbCopy((LPWSTR)pvProfileData, *pcbProfileData, PROFILE_NAME); + *pcbProfileData = sizeof(PROFILE_NAME); + *pflProfileData = QCP_PROFILEDISK; + + if(FAILED(Result)) + { + SetLastError(Result); + } + } + } + } + + return Result; +}; + +HRESULT __stdcall IOemUI::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IOemUI:FontInstallerDlgProc entry.\r\n")); + + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI::UpdateExternalFonts( + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges) +{ + VERBOSE(DLLTEXT("IOemUI:UpdateExternalFonts entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this) ; + } + else + { + WARNING(DLLTEXT("IOemCF::QueryInterface interface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + //DbgPrint(DLLTEXT("Class factory:\t\tCreate component.")) ; + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION ; + } + + // Create component. + IOemUI* pOemCB = new IOemUI ; + if (pOemCB == NULL) + { + return E_OUTOFMEMORY ; + } + // Get the requested interface. + HRESULT hr = pOemCB->QueryInterface(iid, ppv) ; + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release() ; + return hr ; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks) ; + } + else + { + InterlockedDecrement(&g_cServerLocks) ; + } + return S_OK ; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK ; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:Create class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE ; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF ; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY ; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv) ; + pFontCF->Release() ; + + return hr ; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.h new file mode 100644 index 00000000..d9bdf3a2 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/intrface.h @@ -0,0 +1,179 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.h +// +// +// PURPOSE: Header of interface for PScript5 and Unidrv5 UI plug-in. +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI +// +class IOemUI: public IPrintOemUI +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + + IOemUI() { m_cRef = 1; m_pOEMHelp = NULL; }; + ~IOemUI(); + +protected: + LONG m_cRef; + IPrintOemDriverUI* m_pOEMHelp; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oem.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oem.h new file mode 100644 index 00000000..bf3d75f9 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oem.h @@ -0,0 +1,22 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: oem.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debug.cpp. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.cpp new file mode 100644 index 00000000..61f3d378 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.cpp @@ -0,0 +1,756 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.cpp +// +// +// PURPOSE: Main file for OEM UI test module. +// +// + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "fusutils.h" +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + +typedef struct _tagCBUserData +{ + HANDLE hComPropSheet; + HANDLE hPropPage; + POEMUIPSPARAM pOEMUIParam; + PFNCOMPROPSHEET pfnComPropSheet; + +} CBUSERDATA, *PCBUSERDATA; + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam); +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam); +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems); +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems); +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams); +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource); + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM device or document property UI. +// +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hResult = S_OK; + + + VERBOSE(DLLTEXT("hrOEMPropertyPage entry.\r\n")); + + // Validate parameters. + if( (OEMCUIP_DOCPROP != dwMode) + && + (OEMCUIP_PRNPROP != dwMode) + ) + { + ERR(DLLTEXT("hrOEMPropertyPage() ERROR_INVALID_PARAMETER.\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam); + break; + + case OEMCUIP_PRNPROP: + hResult = hrPrinterPropertyPage(dwMode, pOEMUIParam); + break; + + default: + // Should never reach this! + ERR(DLLTEXT("hrOEMPropertyPage() Invalid dwMode")); + SetLastError(ERROR_INVALID_PARAMETER); + hResult = E_FAIL; + break; + } + + return hResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM document property UI. +// +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM document property UI. + pOEMUIParam->cOEMOptItems = 1; + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() requesting items.\r\n")); + } + else + { + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() fill out items.\r\n")); + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMDocUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_ADV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + } + + return S_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM printer property UI. +// +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM printer property UI. + pOEMUIParam->cOEMOptItems = 1; + + VERBOSE(DLLTEXT("hrPrinterPropertyPage() requesting items.\r\n")); + } + else + { + DWORD dwError; + DWORD dwDeviceValue; + DWORD dwType; + DWORD dwNeeded; + + + VERBOSE(DLLTEXT("hrPrinterPropertyPage() fill out items.\r\n")); + + // Get device settings value from printer. + dwError = GetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, &dwType, (PBYTE) &dwDeviceValue, + sizeof(dwDeviceValue), &dwNeeded); + if( (ERROR_SUCCESS != dwError) + || + (dwDeviceValue > 100) + ) + { + // Failed to get the device value or value is invalid, just use the default. + dwDeviceValue = 0; + } + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMPrinterUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_DEV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = dwDeviceValue; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + } + + return S_OK; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to Document property sheet. +// +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, + IPrintOemDriverUI* pOEMHelp) +{ + LONG_PTR lResult = 0; + HRESULT hrResult = S_OK; + + VERBOSE(DLLTEXT("hrOEMDocumentPropertySheets() entry.\r\n")); + + UNREFERENCED_PARAMETER(pOEMHelp); + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR(DLLTEXT("hrOEMDocumentPropertySheets() ERROR_INVALID_PARAMETER.\r\n")); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + DWORD dwSheets = 0; + PCBUSERDATA pUserData; + POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM) pPSUIInfo->lParamInit; + HANDLE hHeap = pOEMUIParam->hOEMHeap; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + COMPROPSHEETUI Sheet; + + + // Init property page. + memset(&Sheet, 0, sizeof(COMPROPSHEETUI)); + Sheet.cbSize = sizeof(COMPROPSHEETUI); + Sheet.Flags = CPSUIF_UPDATE_PERMISSION; + Sheet.hInstCaller = ghInstance; + Sheet.pCallerName = GetStringResource(hHeap, ghInstance, IDS_NAME); + Sheet.pHelpFile = NULL; + Sheet.pfnCallBack = OEMDocUICallBack2; + Sheet.pDlgPage = CPSUI_PDLGPAGE_TREEVIEWONLY; + Sheet.cOptItem = 1; + Sheet.IconID = IDI_CPSUI_PRINTER; + Sheet.pOptItemName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.CallerVersion = 0x100; + Sheet.OptItemVersion = 0x100; + + // Init user data. + pUserData = (PCBUSERDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CBUSERDATA)); + if (NULL == pUserData) + { + ERR(DLLTEXT("hrOEMDocumentPropertySheets() failed to allocate user data.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + pUserData->hComPropSheet = pPSUIInfo->hComPropSheet; + pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + pUserData->pOEMUIParam = pOEMUIParam; + Sheet.UserData = (ULONG_PTR) pUserData; + + // Create OptItems for page. + Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem); + if (NULL == Sheet.pOptItem) + { + ERR(DLLTEXT("hrOEMDocumentPropertySheets() failed to allocate OPTITEMs.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Initialize OptItems + Sheet.pOptItem[0].Level = 1; + Sheet.pOptItem[0].Flags = OPTIF_COLLAPSE; + Sheet.pOptItem[0].pName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.pOptItem[0].Sel = pOEMDev->dwDriverData; + + Sheet.pOptItem[0].pOptType = CreateOptType(hHeap, 2); + if (NULL == Sheet.pOptItem[0].pOptType) + { + ERR(DLLTEXT("hrOEMDocumentPropertySheets() failed to allocate OPTTYPE.\r\n")); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + Sheet.pOptItem[0].pOptType->Type = TVOT_UDARROW; + Sheet.pOptItem[0].pOptType->pOptParam[1].IconID = 0; + Sheet.pOptItem[0].pOptType->pOptParam[1].lParam = 100; + + // NOTE: Don't need to do anything with Activation Contexts + // to get Themed UI, since Compstui will create this + // page using it's Activation Context which specifies + // comctl v6. + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PCOMPROPSHEETUI, + (LPARAM)&Sheet, (LPARAM)&dwSheets); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + +Exit: + + pPSUIInfo->Result = lResult; + return hrResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to printer property sheet. +// +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam) +{ + LONG_PTR lResult = 0; + + + VERBOSE(DLLTEXT("hrOEMDevicePropertySheets entry\r\n")); + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR(DLLTEXT("hrOEMDevicePropertySheets() ERROR_INVALID_PARAMETER.\r\n")); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + PROPSHEETPAGE Page; + + // Init property page. + memset(&Page, 0, sizeof(PROPSHEETPAGE)); + Page.dwSize = sizeof(PROPSHEETPAGE); + Page.dwFlags = PSP_DEFAULT; + Page.hInstance = ghInstance; + Page.pszTemplate = MAKEINTRESOURCE(IDD_DEVICE_PROPPAGE); + Page.pfnDlgProc = DevicePropPageProc; + Page.hActCtx = GetMyActivationContext(); + + // Set the flag to indicate that our PROPSHEETPAGE + // has an Activation Context. + // The Activation Context indicates with version of + // comctl for Compstui to create our PROPSHEETPAGE + // with. To get Themed UI we need to specify comctl v6. + if( (NULL != Page.hActCtx) && (INVALID_HANDLE_VALUE != Page.hActCtx)) + { + Page.dwFlags |= PSP_USEFUSIONCONTEXT; + } + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PROPSHEETPAGE, (LPARAM)&Page, 0); + + // NOTE: The Activation Context is released when the DLL is unloaded + // during DLL_PROCESS_DETACH. + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + + pPSUIInfo->Result = lResult; + return S_OK; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM printer property UI. +// +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + + VERBOSE(DLLTEXT("OEMPrinterUICallBack() entry.\r\n")); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + { + DWORD dwDriverValue = pOEMUIParam->pOEMOptItems[0].Sel; + + // Store OptItems state in printer data. + SetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, REG_DWORD, (PBYTE) &dwDriverValue, sizeof(DWORD)); + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Call back for OEM device property UI. +// +#pragma warning(push) +#pragma warning(disable:6262) // this method exceeds the default threshold for stack usage by a few bytes. +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uiMsg) + { + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + switch(LOWORD(wParam)) + { + case IDC_CALIBRATE: + // Just display a message that the printer is calibrated, + // since we don't acutally calibrate anything. + { + TCHAR szName[MAX_PATH]; + TCHAR szCalibrated[MAX_PATH]; + + + LoadString(ghInstance, IDS_NAME, szName, sizeof(szName)/sizeof(szName[0])); + LoadString(ghInstance, IDS_CALIBRATED, szCalibrated, sizeof(szCalibrated)/sizeof(szCalibrated[0])); + MessageBox(hDlg, szCalibrated, szName, MB_OK); + } + break; + } + break; + + default: + return FALSE; + } + return TRUE; + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) // type of notification message + { + case PSN_SETACTIVE: + break; + + case PSN_KILLACTIVE: + break; + + case PSN_APPLY: + break; + + case PSN_RESET: + break; + } + } + break; + } + + return FALSE; +} +#pragma warning(pop) + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM document property UI. +// +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + VERBOSE(DLLTEXT("OEMDocUICallBack() entry.\r\n")); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Store OptItems state in DEVMODE. + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_KILLACTIVE: + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pOEMUIParam->pOEMOptItems[0].Sel) != pOEMDev->dwAdvancedData) + { + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + pOEMUIParam->pOEMOptItems[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + PCBUSERDATA pUserData = (PCBUSERDATA) pCallbackParam->UserData; + POEMDEV pOEMDev = (POEMDEV) pUserData->pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("OEMDocUICallBack2() entry.\r\n")); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + pUserData->pfnComPropSheet(pUserData->hComPropSheet, CPSFUNC_SET_RESULT, + (LPARAM)pUserData->hPropPage, + (LPARAM)CPSUI_OK); + break; + + case CPSUICB_REASON_KILLACTIVE: + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pCallbackParam->pOptItem[0].Sel) != pOEMDev->dwDriverData) + { + pCallbackParam->pOptItem[0].Sel = pOEMDev->dwDriverData; + pCallbackParam->pOptItem[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Creates and Initializes OptItems. +// +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems) +{ + POPTITEM pOptItems = NULL; + SIZE_T sizeOfOptItems = 0; + + // Compute the size of memory needed for the OptItems: + if (SUCCEEDED(SIZETMult(sizeof(OPTITEM), (SIZE_T)dwOptItems, &sizeOfOptItems))) + { + // Allocate memory for OptItems; + pOptItems = (POPTITEM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeOfOptItems); + if(NULL != pOptItems) + { + InitOptItems(pOptItems, dwOptItems); + } + else + { + ERR(DLLTEXT("CreateOptItems() failed to allocate memory for OPTITEMs!\r\n")); + } + } + else + { + ERR(DLLTEXT("CreateOptItems() failed to compute necessary memory size for OPTITEMs!\r\n")); + } + + return pOptItems; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems. +// +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems) +{ + VERBOSE(DLLTEXT("InitOptItems() entry.\r\n")); + + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for(DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OptType for OptItem. +// +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams) +{ + POPTTYPE pOptType = NULL; + + + VERBOSE(DLLTEXT("CreateOptType() entry.\r\n")); + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + if(NULL != pOptType) + { + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, wOptParams * sizeof(OPTPARAM)); + if(NULL != pOptType->pOptParam) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + ERR(DLLTEXT("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n")); + + // Free allocated memory and return NULL. + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR(DLLTEXT("CreateOptType() failed to allocated memory for OPTTYPE!\r\n")); + } + + return pOptType; +} + +//////////////////////////////////////////////////////////////////////////////////// +// +// Retrieves pointer to a String resource. +// +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource) +{ + int nResult; + DWORD dwSize = MAX_PATH; + PTSTR pszString = NULL; + + + VERBOSE(DLLTEXT("GetStringResource entered.\r\n")); + + // Allocate buffer for string resource from heap; let the driver clean it up. + pszString = (PTSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(TCHAR)); + if(NULL != pszString) + { + // Load string resource; resize after loading so as not to waste memory. + nResult = LoadString((HMODULE)hModule, uResource, pszString, dwSize); + if(nResult > 0) + { + PTSTR pszTemp; + + pszTemp = (PTSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszString, (nResult + 1) * sizeof(TCHAR)); + if(NULL != pszTemp) + { + pszString = pszTemp; + } + else + { + ERR(DLLTEXT("GetStringResource() HeapReAlloc() of string retrieved failed!\r\n")); + } + } + else + { + ERR(DLLTEXT("GetStringResource() failed to load string resource!\r\n")); + + pszString = NULL; + } + } + else + { + ERR(DLLTEXT("GetStringResource() failed to allocate string buffer!\r\n")); + } + + return pszString; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.h new file mode 100644 index 00000000..0f392cc5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/oemui.h @@ -0,0 +1,45 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for OEMUI Test Module. +// + +#pragma once + +#include "OEM.H" +#include "DEVMODE.H" +#include "globals.h" + + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + + +// OEM Signature and version. +#define PROP_TITLE L"OEM UI Page" +#define DLLTEXT(s) "ThemeUI: " s + + +// Printer registry keys where OEM data is stored. +#define OEMUI_VALUE TEXT("OEMUI_VALUE") +#define OEMUI_DEVICE_VALUE TEXT("OEMUI_DEVICE_VALUE") + + + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, IPrintOemDriverUI* pOEMHelp); +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precomp.h new file mode 100644 index 00000000..0607fe55 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precomp.h @@ -0,0 +1,61 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.H +// +// +// PURPOSE: Common headers that don't change often +// + +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + +// Isolation define for using ComCtrl v6. +#ifndef ISOLATION_AWARE_ENABLED + #define ISOLATION_AWARE_ENABLED +#endif + + +// Required header files that shouldn't change often. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "COMPSTUI.H" +#include +#include +#include +#include +#include + +// Safe character string functions to detect buffer overrun conditions: +#include + +// Safe integer functions to detect integer overflow/underflow conditions: +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/resource.h new file mode 100644 index 00000000..71d3d3d6 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/resource.h @@ -0,0 +1,24 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by OEMUI.rc +// +#define IDS_SECTION 1 +#define IDS_CALIBRATED 2 +#define IDS_NAME 3 +#define IDS_DEV_SECTION 4 +#define IDS_DEVICE_SECTION 4 +#define IDS_ADV_SECTION 10 +#define IDD_DEVICE_PROPPAGE 106 +#define IDD_DOC_PROPPAGE 107 +#define IDC_CALIBRATE 1001 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1002 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/themeuismpl.def b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/themeuismpl.def new file mode 100644 index 00000000..8e60b60d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/ThemeUI/themeuismpl.def @@ -0,0 +1,3 @@ +LIBRARY ThemeUISmpl +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/WMarkPS.ini b/print/OEM Printer Customization Plug-in Samples/C++/WMarkPS.ini new file mode 100644 index 00000000..11176160 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/WMarkPS.ini @@ -0,0 +1,4 @@ +[OEMFiles] +OEMConfigFile1=WMARKUI.DLL +OEMDriverFile1=WMARKPS.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/WMarkUni.ini b/print/OEM Printer Customization Plug-in Samples/C++/WMarkUni.ini new file mode 100644 index 00000000..4ae540c4 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/WMarkUni.ini @@ -0,0 +1,5 @@ +[OEMFiles] +OEMConfigFile1=WMARKUNIUI.DLL +OEMDriverFile1=WMARKUNI.DLL + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap.gpd b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.gpd new file mode 100644 index 00000000..467e3e21 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.gpd @@ -0,0 +1,509 @@ +*GPDFileName: "bitmap.gpd" +*GPDFileVersion: "1.0" +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*ModelName: "Bitmap Driver" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 +*PrintRate: 16 +*PrintRateUnit: PPM +*PrintRatePPM: 16 + +*%****************************************************************************************** +*% Orientation +*%****************************************************************************************** +*Feature: Orientation +{ + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.8 + *Cmd: "" + } + } +} + +*%****************************************************************************************** +*% Input Bin +*%****************************************************************************************** +*Feature: InputBin +{ + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: AUTO + *Option: AUTO + { + *rcNameID: =AUTO_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "" + } + } + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "" + } + } +} + +*%****************************************************************************************** +*% Resolution +*%****************************************************************************************** +*Feature: Resolution +{ + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: Option2 + *Option: Option1 + { + *Name: "600 x 600" =DOTS_PER_INCH + *DPI: PAIR(600, 600) + *TextDPI: PAIR(600, 600) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "" } + *Command: CmdEndRaster { *Cmd : "" } + *Command: CmdSendBlockData { *Cmd : "" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "" + } + } + *Option: Option2 + { + *Name: "300 x 300" =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "" } + *Command: CmdEndRaster { *Cmd : "" } + *Command: CmdSendBlockData { *Cmd : "" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "" + } + } + *Option: Option3 + { + *Name: "150 x 150" =DOTS_PER_INCH + *DPI: PAIR(150, 150) + *TextDPI: PAIR(150, 150) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "" } + *Command: CmdEndRaster { *Cmd : "" } + *Command: CmdSendBlockData { *Cmd : "" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "" + } + } +} + +*%****************************************************************************************** +*% Paper Size +*%****************************************************************************************** +*Feature: PaperSize +{ + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9500, 12500) + *PrintableOrigin: PAIR(400, 400) + *CursorOrigin: PAIR(300, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9500, 12200) + *PrintableOrigin: PAIR(450, 300) + *CursorOrigin: PAIR(200, 12900) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 600) + *CursorOrigin: PAIR(180, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 900) + *CursorOrigin: PAIR(180, 16500) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 11500) + *PrintableOrigin: PAIR(300, 300) + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8300, 11500) + *PrintableOrigin: PAIR(200, 300) + *CursorOrigin: PAIR(200, 12300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(288, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(204, 13824) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + } + } + *Option: B5 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(7900, 11140) + *PrintableOrigin: PAIR(352, 300) + *CursorOrigin: PAIR(300, 100) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(7760, 11140) + *PrintableOrigin: PAIR(300, 400) + *CursorOrigin: PAIR(100, 11940) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "" + } + } + } + } +} + +*%****************************************************************************************** +*% Media Type +*%****************************************************************************************** +*Feature: MediaType +{ + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: PLAIN + *Option: PLAIN + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "" + } + } + *Option: TRANSPARENCY + { + *rcNameID: =TRANSPARENCY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "" + } + } +} + +*%****************************************************************************************** +*% Color Mode +*%****************************************************************************************** +*Feature: ColorMode +{ + *rcNameID: =COLOR_PRINTING_MODE_DISPLAY + *DefaultOption: 8bpp + *Option: Mono + { + *rcNameID: =MONO_DISPLAY + *DevNumOfPlanes: 0 + *DevBPP: 0 + *IPCallbackID: 1 + *Color?: FALSE + } + *Option: Color + { + *rcNameID: =COLOR_DISPLAY + *DevNumOfPlanes: 0 + *DevBPP: 0 + *DrvBPP: 4 + *IPCallbackID: 2 + *PaletteSize: 8 + *PaletteProgrammable?: TRUE + *Command: CmdEnableDRC { *Cmd: "" } + *Command: CmdDefinePaletteEntry { *Cmd : "" } + *Command: CmdSelectPaletteEntry { *Cmd : "" } + *Command: CmdSetSrcBmpWidth { *Cmd : "" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "" + } + } + *Option: 8bpp + { + *rcNameID: =8BPP_DISPLAY + *DevNumOfPlanes: 0 + *DevBPP: 0 + *DrvBPP: 8 + *IPCallbackID: 3 + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdEnableDRC { *Cmd : "" } + *Command: CmdDefinePaletteEntry { *Cmd : "" } + *Command: CmdSelectPaletteEntry { *Cmd : "" } + *Command: CmdSetSrcBmpWidth { *Cmd : "" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "" + } + } + *Option: 24bpp + { + *rcNameID: =24BPP_DISPLAY + *DevNumOfPlanes: 0 + *DevBPP: 0 + *DrvBPP: 24 + *IPCallbackID: 5 + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdEnableDRC { *Cmd : "" } + *Command: CmdDefinePaletteEntry { *Cmd : "" } + *Command: CmdSelectPaletteEntry { *Cmd : "" } + *Command: CmdSetSrcBmpWidth { *Cmd : "" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "" + } + } +} + +*%****************************************************************************************** +*% HalfTone +*%****************************************************************************************** +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} + +*%****************************************************************************************** +*% Duplex Unit +*%****************************************************************************************** +*Feature: DuplexUnit +{ + *rcNameID: 429 + *FeatureType: PRINTER_PROPERTY + *DefaultOption: FALSE + *Option: FALSE + { + *rcNameID: 444 + *DisabledFeatures: LIST(Duplex.VERTICAL, Duplex.HORIZONTAL) + } + *Option: TRUE + { + *rcNameID: 443 + } +} + +*%****************************************************************************************** +*% Duplex Type +*%****************************************************************************************** +*Feature: Duplex +{ + *rcNameID: =TWO_SIDED_PRINTING_DISPLAY + *DefaultOption: NONE + *Option: NONE + { + *rcNameID: =NONE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "" + } + } + *Option: VERTICAL + { + *rcNameID: =FLIP_ON_LONG_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "" + } + } + *Option: HORIZONTAL + { + *rcNameID: =FLIP_ON_SHORT_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "" + } + } +} + +*%****************************************************************************************** +*% Doc setup commands +*%****************************************************************************************** +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.7 + *Cmd: "" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.13 + *Cmd: "" +} + +*%****************************************************************************************** +*% Cursor and Page Commands +*%****************************************************************************************** +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT, RASTER, VECTOR) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*EjectPageWithFF?: TRUE +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*Command: CmdCR { *Cmd : "" } +*Command: CmdLF { *Cmd : "" } +*Command: CmdFF { *Cmd : "" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf new file mode 100644 index 00000000..247fb069 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf @@ -0,0 +1,118 @@ +; BITMAP.INF +; +; INF file for the base WDK sample +; +; Copyright 1999 - 2001 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Provider=%MS% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=6/07/2001,1.0.0.1 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Microsoft"=Microsoft, NTx86, NTamd64, NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Microsoft] +"Bitmap Driver" = BITMAP + +[Microsoft.NTx86] +"Bitmap Driver" = BITMAP + +[Microsoft.NTamd64] +"Bitmap Driver" = BITMAP + +[Microsoft.NTia64] +"Bitmap Driver" = BITMAP + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[BITMAP] +CopyFiles=@BITMAP.GPD +CopyFiles=@BITMAP.INI +CopyFiles=BMP +DataFile=BITMAP.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,UNIDRV_DATA + + +; Copy Sections +; +; Lists of files that are actually copied. These sections are referenced +; from the installer sections, above. Only create a section if it contains +; two or more files (if we only copy a single file, identify it in the +; installer section, using the @filename notation) or if it's a color +; profile (since the DestinationDirs can only handle sections, and not +; individual files). +; + +[BMP] +BITMAP.DLL + + +; +; Data Sections +; + +; These sections contain data that is shared between devices. +; + + + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMSample% + +[SourceDisksFiles.x86] +bitmap.dll = 100,bitmap\x86 + +[SourceDisksFiles.amd64] +bitmap.dll = 100,bitmap\amd64 + +[SourceDisksFiles.ia64] +bitmap.dll = 100,bitmap\ia64 + +[SourceDisksFiles] +BITMAP.GPD = 100 +BITMAP.INI = 100 + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +MS="Microsoft WDK Sample" diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap.ini b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.ini new file mode 100644 index 00000000..2388914c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.ini @@ -0,0 +1,5 @@ +[OEMFiles] +OEMDriverFile1=BITMAP.DLL + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.def b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.def new file mode 100644 index 00000000..1a4df55f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.def @@ -0,0 +1,4 @@ +LIBRARY bitmap +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.h b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.h new file mode 100644 index 00000000..ee068c02 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.h @@ -0,0 +1,81 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: BITMAP.H +// +// +// PURPOSE: Define the COemPDEV class which stores the private +// PDEV for the driver. +// + + +#pragma once + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +#define RGB_BLACK RGB(0, 0, 0) +#define RGB_WHITE RGB(255, 255, 255) + +class COemPDEV +{ +public: + COemPDEV(void) : + m_pfnDrvEndDoc(NULL), + pBufStart(NULL), + dwBufSize(0), + cPalColors(0), + hpalDefault(), + prgbq(NULL), + cbHeaderOffBits(0), + bHeadersFilled(FALSE), + bColorTable(FALSE) + { + memset(&bmFileHeader, 0, sizeof(bmFileHeader)); + memset(&bmInfoHeader, 0, sizeof(bmInfoHeader)); + } + + virtual ~COemPDEV(void) + { + } + + void InitializeDDITable(DRVENABLEDATA* pded) + { + UINT iDrvFn; + UINT cDrvFn = pded->c; + PDRVFN pDrvFn = pded->pdrvfn; + + for (iDrvFn = 0; iDrvFn < cDrvFn; ++iDrvFn, ++pDrvFn) + { + if (pDrvFn->iFunc == INDEX_DrvEndDoc) + { + m_pfnDrvEndDoc = (PFN_DrvEndDoc)(pDrvFn->pfn); + } + } + } + +public: + + PFN_DrvEndDoc m_pfnDrvEndDoc; // Unidrv function to call back into from the DDI hook + PBYTE pBufStart; // Pointer to start of buffer to hold the bitmap data + DWORD dwBufSize; // Buffer size + BITMAPFILEHEADER bmFileHeader; // BitmapFileHeader for each dump + BITMAPINFOHEADER bmInfoHeader; // BitmapInfoHeader for each dump + int cPalColors; // Count of colors in palette. + HPALETTE hpalDefault; // Default palette to pass to GDI. + _Field_size_(cPalColors) RGBQUAD * prgbq; // Color table + INT cbHeaderOffBits; // Offset to bits in the file + BOOL bHeadersFilled; // Flag to indicate if the header stuff has been filled + BOOL bColorTable; // Flag to indicate if color table needs to be dumped + +}; + +typedef COemPDEV* POEMPDEV; + +BOOL bGrowBuffer(POEMPDEV, DWORD); // Function to enlarge the buffer for holding the bitmap data +VOID vFreeBuffer(POEMPDEV); // Function to free the buffer for holding the bitmap data +BOOL bFillColorTable(POEMPDEV); // Function to fill the color table for the bitmap data diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.rc b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.rc new file mode 100644 index 00000000..737bba96 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.rc @@ -0,0 +1,110 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by DDK Support Team\0" + VALUE "CompanyName", "Microsoft Corp.\0" + VALUE "FileDescription", "Bitmap Driver Sample\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "BITMAP\0" + VALUE "LegalCopyright", "Copyright © 1998-2003\0" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation\0" + VALUE "OriginalFilename", "BITMAP.DLL\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Microsoft Bitmap Driver Sample\0" + VALUE "ProductVersion", "1.0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj new file mode 100644 index 00000000..d530f136 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj @@ -0,0 +1,1090 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {EDCCC34A-50DF-4894-B7B9-FC156F899947} + $(MSBuildProjectName) + Win10 Debug + Win32 + {64A7662C-5E32-41A7-939B-B51114210693} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + bitmap + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;gdi32.lib;umpdddi.lib;ole32.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + bitmap.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj.Filters new file mode 100644 index 00000000..a78a5c8a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.vcxproj.Filters @@ -0,0 +1,174 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {5A882741-1FD2-4D80-ACC9-DCFE8F90AD24} + + + h;hpp;hxx;hm;inl;inc;xsd + {A14D506D-8B56-426A-80B4-0CA6D7A24A0B} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {A8C3D9A5-36FC-4F1B-A9A6-605F3BD79ED7} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/ddihook.cpp b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/ddihook.cpp new file mode 100644 index 00000000..17984513 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/ddihook.cpp @@ -0,0 +1,114 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: DDIHook.cpp +// +// +// PURPOSE: Implementation of DDI Hook OEMEndDoc. This function +// dumps the buffered bitmap data out. +// + + +#include "precomp.h" +#include "bitmap.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// +// Function prototype is defined in printoem.h +// +BOOL APIENTRY +OEMEndDoc( + SURFOBJ *pso, + FLONG fl + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvEndDoc. + + DrvEndDoc is called by GDI when it has finished + sending a document to the driver for rendering. + + Please refer to DDK documentation for more details. + + This particular implementation of OEMEndDoc performs + the following operations: + - Dump the bitmap file header + - Dump the bitmap info header + - Dump the color table if one exists + - Dump the buffered bitmap data + - Free the memory for the data buffers + +Arguments: + + pso - Defines the surface object + flags - A set of flag bits + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + DWORD dwWritten; + INT cScans; + + if (pOemPDEV->pBufStart) + { + // Fill BitmapFileHeader + // + DWORD dwTotalBytes = pOemPDEV->cbHeaderOffBits + pOemPDEV->bmInfoHeader.biSizeImage; // File size + + pOemPDEV->bmFileHeader.bfType = 0x4d42; // Signature = 'BM' + pOemPDEV->bmFileHeader.bfSize = dwTotalBytes; // Bytes in whole file. + pOemPDEV->bmFileHeader.bfReserved1 = 0; + pOemPDEV->bmFileHeader.bfReserved2 = 0; + pOemPDEV->bmFileHeader.bfOffBits = pOemPDEV->cbHeaderOffBits; // Offset to bits in file. + + if (pOemPDEV->bColorTable) + pOemPDEV->bmFileHeader.bfOffBits += pOemPDEV->cPalColors * sizeof(ULONG); + + // Num of scanlines + // + cScans = pOemPDEV->bmInfoHeader.biHeight; + + // Flip the biHeight member so that it denotes top-down bitmap + // + pOemPDEV->bmInfoHeader.biHeight = cScans * -1; + + // Dump headers first + // + dwWritten = pDevObj->pDrvProcs->DrvWriteSpoolBuf(pDevObj, (void*)&(pOemPDEV->bmFileHeader), sizeof(BITMAPFILEHEADER)); + dwWritten = pDevObj->pDrvProcs->DrvWriteSpoolBuf(pDevObj, (void*)&(pOemPDEV->bmInfoHeader), sizeof(BITMAPINFOHEADER)); + if (pOemPDEV->bColorTable) + { + dwWritten = pDevObj->pDrvProcs->DrvWriteSpoolBuf(pDevObj, pOemPDEV->prgbq, pOemPDEV->cPalColors * sizeof(ULONG)); + LocalFree(pOemPDEV->prgbq); + } + + // Dump the data now + // + dwWritten = pDevObj->pDrvProcs->DrvWriteSpoolBuf(pDevObj, pOemPDEV->pBufStart, pOemPDEV->bmInfoHeader.biSizeImage); + + // Free memory for the data buffers + // + vFreeBuffer(pOemPDEV); + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvEndDoc)(pso, fl); +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.cpp new file mode 100644 index 00000000..7845d5c1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.cpp @@ -0,0 +1,132 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// +// PURPOSE: Helper functions for manipulating the DEVMODE. These are commonly +// shared by UI & rendering modules +// + + +#include "precomp.h" +#include "bitmap.h" +#include "debug.h" +#include "devmode.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +BOOL bConvertOEMDevmode( + PCOEMDEV pOEMDevIn, + POEMDEV pOEMDevOut + ) + +/*++ + +Routine Description: + + Converts private DEVMODE members to the + current version. + +Arguments: + + pOEMDevIn - pointer to OEM private devmode + pOEMDevOut - pointer to OEM private devmode + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR("ConvertOEMDevmode() invalid parameters.\r\n"); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + } + + return TRUE; +} + + +BOOL bMakeOEMDevmodeValid( + POEMDEV pOEMDevmode + ) + +/*++ + +Routine Description: + + Ensures that private OEM devmode members are valid. + +Arguments: + + pOEMDevmode - pointer to OEM private devmode + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data. + pOEMDevmode->dwDriverData = 0; + + return TRUE; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.h new file mode 100644 index 00000000..5f62454f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/devmode.h @@ -0,0 +1,37 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// + +#pragma once + +//////////////////////////////////////////////////////// +// OEM Private Devmode Definition +//////////////////////////////////////////////////////// + +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + BOOL dwDriverData; +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL bConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL bMakeOEMDevmodeValid(POEMDEV pOEMDevmode); + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/dllentry.cpp new file mode 100644 index 00000000..4483a741 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/dllentry.cpp @@ -0,0 +1,50 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// +// PURPOSE: Source module for DLL entry function(s). +// + + +#include "precomp.h" +#include "bitmap.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// + +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_PROCESS_DETACH: + break; + + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.cpp new file mode 100644 index 00000000..dcfdcd6f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.cpp @@ -0,0 +1,2048 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Interface for User Mode COM Customization DLL. +// + + +#include "precomp.h" + +#include "debug.h" +#include "devmode.h" +#include "bitmap.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// ================================================================== +// Internal Globals +// +static long g_cComponents; // Count of active components +static long g_cServerLocks; // Count of locks +// +// ================================================================== + +// ================================================================== +// The purpose of this array is to inform UNIDRV of the callbacks +// that are implemented in this driver. +// +// Note that there is *NO* order dependency in this array. New +// index values and their corresponding callbacks can be placed +// anywhere within the list as needed. +// +static const DRVFN s_aOemHookFuncs[] = +{ + {INDEX_DrvEndDoc, (PFN)OEMEndDoc} +}; + + +//////////////////////////////////////////////////////////////////////////////// +// +// COemUni2 body +// +COemUni2::COemUni2() +{ + m_cRef = 1; + + // Increment COM component count. + InterlockedIncrement(&g_cComponents); + + m_pOEMHelp = NULL; + +} + +COemUni2::~COemUni2() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall +COemUni2:: +QueryInterface( + const IID& iid, + void** ppv + ) +{ + + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + } + else if (iid == IID_IPrintOemUni2) + { + *ppv = static_cast(this); + } + else + { + WARNING("COemUni2::QueryInterface NULL. Returning E_NOINTERFACE.\r\n"); + + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall +COemUni2:: +AddRef( + VOID + ) +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +COemUni2:: +Release( + VOID + ) +{ + ULONG cRef = InterlockedDecrement(&m_cRef); + + if (cRef == 0) + { + delete this; + return 0; + } + return cRef; +} + +HRESULT __stdcall +COemUni2:: +CommandCallback( + PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::CommandCallback + + The IPrintOemUni::CommandCallback method is used + to provide dynamically generated printer commands + for Unidrv-supported printers. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + dwCallbackID - value representing the printer command's + *CallbackID attribute in the printer's generic printer + description (GPD) file. + dwCount - value representing the number of elements + in the array pointed to by pdwParams. Can be 0. + pdwParams - pointer to an array of DWORD-sized parameters + containing values specified by the printer commands + *Params attribute in the printer's GPD file. Can be NULL. + piResult - Receives a method-supplied result value. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pdwParams); + + *piResult = 0; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +Compression( + PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::Compression + + The IPrintOemUni::Compression method can be used + with Unidrv-supported printers to provide a customized + bitmap compression method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pInBuf - pointer to input scan line data. + pOutBuf - pointer to an output buffer to receive + compressed scan line data. + dwInLen - length of the input data. + dwOutLen - length of the output buffer. + piResult - Receives a method-supplied result value. If the + operation succeeds, this value should be the number + of compressed bytes, which must not be larger than + the value received for dwOutLen. If an error occurs, + or if the method cannot compress, the result value + should be -1. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pInBuf); + UNREFERENCED_PARAMETER(pOutBuf); + UNREFERENCED_PARAMETER(dwInLen); + UNREFERENCED_PARAMETER(dwOutLen); + UNREFERENCED_PARAMETER(piResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DevMode + + The IPrintOemUni::DevMode method, provided by + rendering plug-ins for Unidrv, performs operations + on private DEVMODE members. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DevMode method. + + The IPrintOemUni::DevMode method, provided by + rendering plug-ins for Unidrv, performs operations + on private DEVMODE members. When both UI and rendering + plug-ins are present in a driver, this functionality + should be factored out to be common to both modules, and + provide the same behavior. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - caller-supplied constant. Refer to the docs + for more information. + pOemDMParam - pointer to an OEMDMPARAM structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + )) + { + ERR("DevMode() ERROR_INVALID_PARAMETER.\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devmode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + case OEMDM_DEFAULT: + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + break; + + case OEMDM_CONVERT: + bConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + case OEMDM_MERGE: + bConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + bMakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +DisableDriver( + VOID + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DisableDriver + + The IPrintOemUni::DisableDriver method allows + a rendering plug-in for Unidrv to free resources + that were allocated by the plug-in's + IPrintOemUni::EnableDriver method. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DisableDriver method. + + The IPrintOemUni::DisableDriver method allows a rendering + plug-in for Unidrv to free resources that were allocated by the + plug-in's IPrintOemUni::EnableDriver method. This is the last + IPrintOemUni interface method that is called before the rendering + plug-in is unloaded. + + Please refer to DDK documentation for more details. + +Arguments: + + VOID + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + // Release reference to Printer Driver's interface. + // + if (this->m_pOEMHelp) + { + this->m_pOEMHelp->Release(); + this->m_pOEMHelp = NULL; + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +DisablePDEV( + PDEVOBJ pdevobj + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DisablePDEV + + The IPrintOemUni::DisablePDEV method allows a rendering + plug-in for Unidrv to delete the private PDEV structure that + was allocated by its IPrintOemUni::EnablePDEV method. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DisablePDEV method. + + The IPrintOemUni::DisablePDEV method performs the same types of + operations as the DrvDisablePDEV function. Its purpose is to allow a + rendering plug-in to delete the private PDEV structure that is pointed + to by the DEVOBJ structure's pdevOEM member. This PDEV structure + is one that was allocated by the plug-in's IPrintOemUni::EnablePDEV method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + // Release our COemPDEV instance created by the call to + // EnablePDEV. + // + POEMPDEV pOemPDEV = (POEMPDEV)pdevobj->pdevOEM; + delete pOemPDEV; + pOemPDEV = NULL; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +DownloadCharGlyph( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DownloadCharGlyph + + The IPrintOemUni::DownloadCharGlyph method enables a + rendering plug-in for Unidrv to send a character glyph for + a specified soft font to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + hGlyph - glyph handle. + pdwWidth - pointer to receive the method-supplied width of the character. + pdwResult - Receives a method-supplied value representing the amount + of printer memory, in bytes, required to store the character glyph. + If the operation fails, the returned value should be zero. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(hGlyph); + UNREFERENCED_PARAMETER(pdwWidth); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DownloadFontHeader( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DownloadFontHeader + + The IPrintOemUni::DownloadFontHeader method allows a + rendering plug-in for Unidrv to send a font's header + information to a printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pdwResult - Receives a method-supplied value representing the amount + of printer memory, in bytes, required to store the font header + information. If the operation fails, the returned value should be zero. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DriverDMS( + PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DriverDMS + + The IPrintOemUni::DriverDMS method allows a rendering + plug-in for Unidrv to indicate that it uses a device-managed + drawing surface instead of the default GDI-managed surface. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DriverDMS method. + + Please refer to DDK documentation for more details. For general info + on device managed surfaces and how to handle them, please refer to + the section titled "Handling Device-Managed Surfaces". + +Arguments: + + pDevObj - pointer to a DEVOBJ structure. + pBuffer - pointer to a buffer to receive method-specified flags. + cbSize - size, in bytes, of the buffer pointed to by pBuffer. + pcbNeeded - pointer to a location to receive the required + minimum pBuffer size. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pDevObj); + UNREFERENCED_PARAMETER(pBuffer); + UNREFERENCED_PARAMETER(cbSize); + UNREFERENCED_PARAMETER(pcbNeeded); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +EnableDriver( + DWORD dwDriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::EnableDriver + + The IPrintOemUni::EnableDriver method allows a rendering + plug-in for Unidrv to hook out some graphics DDI functions. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::EnableDriver method. + + The IPrintOemUni::EnableDriver method allows a rendering + plug-in to perform the same types of operations as the + DrvEnableDriver function. Like the DrvEnableDriver function, + the IPrintOemUni::EnableDriver method is responsible for + providing addresses of internally supported graphics DDI functions, + or DDI hook functions. + + The method should fill the supplied DRVENABLEDATA structure + and allocate an array of DRVFN structures. It should fill the + array with pointers to hooking functions, along with winddi.h-defined + index values that identify the hooked out graphics DDI functions. + + Please refer to DDK documentation for more details. + +Arguments: + + DriverVersion - interface version number. This value is + defined by PRINTER_OEMINTF_VERSION, in printoem.h. + cbSize - size, in bytes, of the structure pointed to by pded. + pded - pointer to a DRVENABLEDATA structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + UNREFERENCED_PARAMETER(dwDriverVersion); + UNREFERENCED_PARAMETER(cbSize); + + // We need to return the DDI functions that have been hooked + // in pded. Here we fill out the fields in pded. + // + pded->iDriverVersion = PRINTER_OEMINTF_VERSION; + pded->c = _countof(s_aOemHookFuncs); + pded->pdrvfn = (DRVFN *) s_aOemHookFuncs; + + // Even if nothing is done, need to return S_OK so + // that DisableDriver() will be called, which releases + // the reference to the Printer Driver's interface. + // + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +EnablePDEV( + PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::EnablePDEV + + The IPrintOemUni::EnablePDEV method allows a rendering + plug-in for Unidrv to create its own PDEV structure. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::EnablePDEV method. + + The IPrintOemUni::EnablePDEV method performs the same types + of operations as the DrvEnablePDEV function that is exported + by a printer graphics DLL. Its purpose is to allow a rendering + plug-in to create its own PDEV structure. For more information + about PDEV structures, see "Customized PDEV Structures" in the DDK docs. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pPrinterName - pointer to a text string representing the + logical address of the printer. + cPatterns - value representing the number of HSURF-typed + surface handles contained in the buffer pointed to by + phsurfPatterns. + phsurfPatterns - pointer to a buffer that is large enough to + contain cPatterns number of HSURF-typed surface handles. + The handles represent surface fill patterns. + cjGdiInfo - value representing the size of the structure pointed + to by pGdiInfo. + pGdiInfo - pointer to a GDIINFO structure. + cjDevInfo - value representing the size of the structure pointed + to by pDevInfo. + pDevInfo - pointer to a DEVINFO structure. + pded - pointer to a DRVENABLEDATA structure containing the + addresses of the printer driver's graphics DDI hooking functions. + pDevOem - Receives a method-supplied pointer to a private PDEV structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + If the operation fails, the method should call SetLastError to set an error code. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(cPatterns); + UNREFERENCED_PARAMETER(phsurfPatterns); + UNREFERENCED_PARAMETER(cjGdiInfo); + UNREFERENCED_PARAMETER(cjDevInfo); + + // Allocate an instance of our private PDEV. + // + POEMPDEV pOemPDEV = new COemPDEV(); + + if (NULL == pOemPDEV) + { + return E_FAIL; + } + + pOemPDEV->InitializeDDITable(pded); + + // Initializing private oempdev stuff + // + pOemPDEV->bHeadersFilled = FALSE; + pOemPDEV->bColorTable = FALSE; + pOemPDEV->cbHeaderOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + pOemPDEV->bmInfoHeader.biHeight = 0; + pOemPDEV->bmInfoHeader.biSizeImage = 0; + pOemPDEV->pBufStart = NULL; + pOemPDEV->dwBufSize = 0; + + // We create a BGR palette for 24bpp so that we can avoid color byte order manipulation + // + if (pGdiInfo->cBitsPixel == 24) + pDevInfo->hpalDefault = EngCreatePalette(PAL_BGR, 0, 0, 0, 0, 0); + + // Store the handle to the default palette so that we can fill the color table later + // + pOemPDEV->hpalDefault = pDevInfo->hpalDefault; + + *pDevOem = pOemPDEV; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +FilterGraphics( + PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::FilterGraphics + + The IPrintOemUni::FilterGraphics method can be used with + Unidrv-supported printers to modify scan line data and send + it to the spooler. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pBuf - pointer to a buffer containing scan line data to be printed. + dwLen - value representing the length, in bytes, of the data + pointed to by pBuf. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + DWORD dwResult; + + m_pOEMHelp->DrvWriteSpoolBuf(pdevobj, pBuf, dwLen, &dwResult); + + if (dwResult == dwLen) + return S_OK; + else + return S_FALSE; +} + +HRESULT __stdcall +COemUni2:: +GetImplementedMethod( + _In_ PSTR pMethodName + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::GetImplementedMethod + + The IPrintOemUni::GetImplementedMethod method is used by + Unidrv to determine which IPrintOemUni interface methods + have been implemented by a rendering plug-in. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::GetImplemented method. + + Please refer to DDK documentation for more details. + +Arguments: + + pMethodName - pointer to a string representing the name of an + IPrintOemUni interface method, such as "ImageProcessing" + for IPrintOemUni::ImageProcessing or "FilterGraphics" for + IPrintOemUni::FilterGraphics. + +Return Value: + + S_OK The operation succeeded (the specified method is implemented). + S_FALSE The operation failed (the specified method is not implemented). + + +--*/ + +{ + HRESULT Result = S_FALSE; + + // Unidrv only calls GetImplementedMethod for optional + // methods. The required methods are assumed to be + // supported. + + // Return S_OK for supported function (i.e. implemented), + // and S_FALSE for functions that aren't supported (i.e. not implemented). + switch (*pMethodName) + { + case 'C': + if (!strcmp(NAME_CommandCallback, pMethodName)) + { + Result = S_OK; + } + break; + case 'F': + if (!strcmp(NAME_FilterGraphics, pMethodName)) + { + Result = S_OK; + } + break; + case 'I': + if (!strcmp(NAME_ImageProcessing, pMethodName)) + { + Result = S_OK; + } + break; + } + + return Result; +} + +HRESULT __stdcall +COemUni2:: +GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::GetInfo + + A rendering plug-in's IPrintOemUni::GetInfo method returns + identification information. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::GetInfo method. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - Contains one of the following caller-supplied integer constants. + OEMGI_GETSIGNATURE - The method must return a unique four-byte + identification signature. The plug-in must also place this signature + in OPTITEM structures, as described in the description of the + OEMCUIPPARAM. structure's pOEMOptItems member. + OEMGI_GETVERSION - The method must return the user interface + plug-in's version number as a DWORD. The version format is + developer-defined. + pBuffer - pointer to memory allocated to receive the information specified + by dwInfo. + cbSize - size of the buffer pointed to by pBuffer. + pcbNeeded - pointer to a location to receive the number of bytes written + into the buffer pointed to by pBuffer. + +Return Value: + + S_OK The operation succeeded (the specified method is implemented). + S_FALSE The operation failed (the specified method is not implemented). + + +--*/ + +{ + PWSTR pszTag = L"COemUni2::GetInfo entry."; + switch(dwMode) + { + case OEMGI_GETSIGNATURE: pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETSIGNATURE]"; break; + case OEMGI_GETVERSION: pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETVERSION]"; break; + + } + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) ) ) + { + WARNING("COemUni2::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER.\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. If not, return error, and also ensure that + // the required buffer size is provided to the caller. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING("COemUni2::GetInfo() exit mode not supported.\r\n"); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +HalftonePattern( + PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::HalftonePattern + + The IPrintOemUni::HalftonePattern method can be used with + Unidrv-supported printers to create or modify a halftone + pattern before it is used in a halftoning operation. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pHTPattern - pointer to a buffer to receive the method-supplied + halftone pattern. Buffer size, in bytes, is: + (((dwHTPatternX * dwHTPatternY) + 3)/4) * 4 * dwHTNumPatterns. + dwHTPatternX - length, in pixels, of the halftone pattern, as specified + by the GPD file's *HTPatternSize attribute. + dwHTPatternY - height, in pixels, of the halftone pattern, as specified + by the GPD file's *HTPatternSize attribute. + dwHTNumPatterns - number of patterns, as specified by the GPD file's + *HTNumPatterns attribute. This can be 1 or 3. + dwCallbackID - value identifying the halftone method, as specified by + the GPD file's *HTCallbackID attribute. + pResource - pointer to a buffer containing a halftone pattern, as + specified by the GPD file's *rcHTPatternID attribute. This can be NULL. + dwResourceSize - size of the halftone pattern contained in the buffer + pointed to by pResource. This is zero if pResource is NULL. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pHTPattern); + UNREFERENCED_PARAMETER(dwHTPatternX); + UNREFERENCED_PARAMETER(dwHTPatternY); + UNREFERENCED_PARAMETER(dwHTNumPatterns); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(pResource); + UNREFERENCED_PARAMETER(dwResourceSize); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +ImageProcessing( + PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::ImageProcessing + + The IPrintOemUni::ImageProcessing method can be used with + Unidrv-supported printers to modify image bitmap data, in order + to perform color formatting or halftoning. The method can return + the modified bitmap to Unidrv or send it directly to the print spooler. + + Please refer to DDK documentation for more details. + + The algorithm for this particular implementation of ImageProcessing is as follows. + - If headers have not been filled as yet, fill them. + - We fill out only the info header and the color table here. The file header is filled + out in OEMEndDoc. + - The height and image size in the bitmap info header are updated every time + we enter ImageProcessing. + - Increase the size of the data buffer by the size of the current band. + - Copy over the data from the current band to the buffer. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pSrcBitmap - pointer to an input device-independent bitmap (DIB). + pBitmapInfoHeader - pointer to a BITMAPINFOHEADER structure + that describes the bitmap pointed to by pSrcBitmap. + pColorTable - pointer to a color table. Used only if the output format is + eight bits per pixel. + dwCallbackID - value assigned to the *IPCallbackID attribute of the + currently selected option for the ColorMode feature. + pIPParams - pointer to an IPPARAMS structure. + ppbResult - + If the method returns the converted DIB to Unidrv: + If the conversion succeeds, the method should return a + pointer to a buffer containing the converted DIB. + Otherwise it should return NULL. + If the method sends the converted DIB to the print spooler: + If the operation succeeds, the method should return TRUE. + Otherwise it should return FALSE. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pColorTable); + + POEMPDEV pOemPDEV = (POEMPDEV)pdevobj->pdevOEM; + + // We want to set ppbResult to NULL in case this function fails and returns E_FAIL + // + *ppbResult = NULL; + + // We want to keep track of the current offset from the start + // of the buffer before the size is increased. + // + DWORD dwBufOffset = pOemPDEV->dwBufSize; + + // We fill out the file header in OEMEndDoc. But for the info header, we take the easy route + // and copy the stuff from pBitmapInfoHeader. Only height and image size will be updated + // every time we enter ImageProcessing. + // + if (!pOemPDEV->bHeadersFilled) + { + ULONG ulMonoPalette[2] = { RGB_BLACK, RGB_WHITE, }; + + pOemPDEV->bHeadersFilled = TRUE; + pOemPDEV->bmInfoHeader.biSize = pBitmapInfoHeader->biSize; + pOemPDEV->bmInfoHeader.biPlanes = pBitmapInfoHeader->biPlanes; + pOemPDEV->bmInfoHeader.biBitCount = pBitmapInfoHeader->biBitCount; + pOemPDEV->bmInfoHeader.biCompression = pBitmapInfoHeader->biCompression; + pOemPDEV->bmInfoHeader.biXPelsPerMeter = pBitmapInfoHeader->biXPelsPerMeter; + pOemPDEV->bmInfoHeader.biYPelsPerMeter = pBitmapInfoHeader->biYPelsPerMeter; + pOemPDEV->bmInfoHeader.biClrUsed = pBitmapInfoHeader->biClrUsed; + pOemPDEV->bmInfoHeader.biClrImportant = pBitmapInfoHeader->biClrImportant; + pOemPDEV->bmInfoHeader.biWidth = pBitmapInfoHeader->biWidth; // We support only Portrait. So width is constant and needs to be updated only once. + + if (dwCallbackID != BMF_24BPP) // We need color table only if it is not 24bpp + { + DWORD cbMemAllocSize; + + pOemPDEV->bColorTable = TRUE; // Indicates that color table needs to be dumped at EndDoc time + + switch(dwCallbackID) + { + case BMF_1BPP: // 1 + pOemPDEV->cPalColors = 2; + + pOemPDEV->prgbq = NULL; + + // Call intsafe.h function to ensure there's no integer overflow or underflow + if (!SUCCEEDED(DWordMult(pOemPDEV->cPalColors, sizeof(RGBQUAD), &cbMemAllocSize)) || + (NULL == (pOemPDEV->prgbq = (RGBQUAD *)LocalAlloc(LPTR, cbMemAllocSize)))) + { + return E_FAIL; + } + + for (int i = 0; i < pOemPDEV->cPalColors; i++) + { + pOemPDEV->prgbq[i].rgbBlue = GetBValue(ulMonoPalette[i]); + pOemPDEV->prgbq[i].rgbGreen = GetGValue(ulMonoPalette[i]); + pOemPDEV->prgbq[i].rgbRed = GetRValue(ulMonoPalette[i]); + } + break; + case BMF_4BPP: // 2 + pOemPDEV->cPalColors = 16; + if (!bFillColorTable(pOemPDEV)) + return E_FAIL; + break; + case BMF_8BPP: // 3 + pOemPDEV->cPalColors = 256; + if (!bFillColorTable(pOemPDEV)) + return E_FAIL; + break; + } + } + + } + + // Keep track of the overall height and image size + // + pOemPDEV->bmInfoHeader.biHeight += pBitmapInfoHeader->biHeight; + pOemPDEV->bmInfoHeader.biSizeImage += pBitmapInfoHeader->biSizeImage; + + // Increase the buffer by the size of the current band + // + if (!bGrowBuffer(pOemPDEV, pBitmapInfoHeader->biSizeImage)) + return E_FAIL; + + if (!pIPParams->bBlankBand) // Non-blank band + { + CopyMemory((pOemPDEV->pBufStart + dwBufOffset), pSrcBitmap, pBitmapInfoHeader->biSizeImage); + } + else // For blanks bands, buffer blank scanlines + { + memset((pOemPDEV->pBufStart + dwBufOffset), 0xff, pBitmapInfoHeader->biSizeImage); + } + + // Set ppbResult to TRUE + // + *ppbResult = (LPBYTE)(INT_PTR)(TRUE); + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +MemoryUsage( + PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::MemoryUsage + + The IPrintOemUni::MemoryUsage method can be used with + Unidrv-supported printers to specify the amount of memory + required for use by a rendering plug-in's IPrintOemUni::ImageProcessing + method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pMemoryUsage - pointer to an OEMMEMORYUSAGE structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pMemoryUsage); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +OutputCharStr( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::OutputCharStr + + The IPrintOemUni::OutputCharStr method enables a rendering + plug-in to control the printing of font glyphs. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + dwType - value indicating the type of glyph specifier array + pointed to by pGlyph. Valid values are as follows: + TYPE_GLYPHHANDLE The pGlyph array elements are glyph + handles of type HGLYPH. + TYPE_GLYPHID The pGlyph array elements are glyph + identifiers of type DWORD. + dwCount - value representing the number of glyph specifiers in + the array pointed to by pGlyph. + pGlyph - pointer to an array of glyph specifiers, where the array + element type is indicated by dwType. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(dwType); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pGlyph); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +PublishDriverInterface( + IUnknown *pIUnknown + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::PublishDriverInterface + + The IPrintOemUni::PublishDriverInterface method allows a + rendering plug-in for Unidrv to obtain the Unidrv driver's + IPrintOemDriverUni interface. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::PublishDriverInterface method and the method + must return S_OK, or the driver will not call the plug-in's other + IPrintOemUni interface methods. + + Please refer to DDK documentation for more details. + +Arguments: + + pIUnknown - pointer to the IUnknown interface of the driver's + IPrintOemDriverUni COM interface. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + // Need to store pointer to Driver Helper functions, if we already haven't. + if (this->m_pOEMHelp == NULL) + { + HRESULT hResult; + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni, (void** ) &(this->m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + this->m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +ResetPDEV( + PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::ResetPDEV + + The IPrintOemUni::ResetPDEV method allows a rendering + plug-in for Unidrv to reset its PDEV structure. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::ResetPDEV method. + + + A rendering plug-in's IPrintOemUni::ResetPDEV method performs + the same types of operations as the DrvResetPDEV function. During + the processing of an application's call to the Platform SDK ResetDC + function, the IPrintOemUni::ResetPDEV method is called by Unidrv's + DrvResetPDEV function. For more information about when DrvResetPDEV + is called, see its description in the DDK docs. + + The rendering plug-in's private PDEV structure's address is contained + in the pdevOEM member of the DEVOBJ structure pointed to by pdevobjOld. + The IPrintOemUni::ResetPDEV method should use relevant members of this + old structure to fill in the new structure, which is referenced through pdevobjNew. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobjOld - pointer to a DEVOBJ structure containing current PDEV information. + pdevobjNew - pointer to a DEVOBJ structure into which the method should place + new PDEV information. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobjOld); + UNREFERENCED_PARAMETER(pdevobjNew); + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +SendFontCmd( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::SendFontCmd + + The IPrintOemUni::SendFontCmd method enables a rendering + plug-in to modify a printer's font selection command and then + send it to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pFInv - pointer to an FINVOCATION structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pFInv); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TextOutAsBitmap( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TextOutAsBitmap + + The IPrintOemUni::TextOutAsBitmap method allows a rendering + plug-in to create a bitmap image of a text string, in case a + downloadable font is not available. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to be written. + pstro - Defines the glyphs to be rendered and their positions + pfo - Specifies the font to be used + pco - Defines the clipping path + prclExtra - A NULL-terminated array of rectangles to be filled + prclOpaque - Specifies an opaque rectangle + pboFore - Defines the foreground brush + pboOpaque - Defines the opaque brush + pptlOrg - Pointer to POINT struct , defining th origin + mix - Specifies the foreground and background ROPs for pboFore + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pso); + UNREFERENCED_PARAMETER(pstro); + UNREFERENCED_PARAMETER(pfo); + UNREFERENCED_PARAMETER(pco); + UNREFERENCED_PARAMETER(prclExtra); + UNREFERENCED_PARAMETER(prclOpaque); + UNREFERENCED_PARAMETER(pboFore); + UNREFERENCED_PARAMETER(pboOpaque); + UNREFERENCED_PARAMETER(pptlOrg); + UNREFERENCED_PARAMETER(mix); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TTDownloadMethod( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TTDownloadMethod + + The IPrintOemUni::TTDownloadMethod method enables a rendering + plug-in to indicate the format that Unidrv should use for a specified + TrueType soft font. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pdwResult - Receives one of the following method-supplied constant values: + TTDOWNLOAD_BITMAP Unidrv should download the specified font as bitmaps. + TTDOWNLOAD_DONTCARE Unidrv can select the font format. + TTDOWNLOAD_GRAPHICS Unidrv should print TrueType fonts as graphics, + instead of downloading the font. + TTDOWNLOAD_TTOUTLINE Unidrv should download the specified font as outlines. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TTYGetInfo( + PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TTYGetInfo + + The IPrintOemUni::TTYGetInfo method enables a rendering plug-in + to supply Unidrv with information relevant to text-only printers. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + dwInfoIndex - constant identifying the type of information being requested. + The following constant values are defined: + OEMTTY_INFO_CODEPAGE - The pOutputBuf parameter points to a + DWORD in which the method should return the number of the + code page to be used. + OEMTTY_INFO_MARGINS - The pOutputBuf parameter points to a + RECT structure in which the method should return page margin + widths, in tenths of millimeters (for example, 20 represents 2 mm). + If the entire page is printable, all margin values must be 0. + OEMTTY_INFO_NUM_UFMS - The pOutputBuf parameter points to a + DWORD in which the method should return the number of resource + IDs of the UFMs for 10, 12, and 17 CPI fonts. To actually obtain + these resource IDs, perform a query using OEMTTY_INFO_UFM_IDS. + OEMTTY_INFO_UFM_IDS - The pOutputBuf parameter points to an array + of DWORDs of sufficient size to hold the number of resource IDs of + the UFMs for 10, 12, and 17 CPI fonts. (This number is obtained by + using OEMTTY_INFO_NUM_UFMS in a query.) The method should + return the resource IDs of the UFMs for 10,12, and 17 CPI fonts. + pOutputBuf - pointer to a buffer to receive the requested information. + dwSize - size, in bytes, of the buffer pointed to by pOutputBuf. + pcbcNeeded - pointer to a location to receive the number of bytes written into + the buffer pointed to by pOutputBuf. If the number of bytes required is + smaller than the number specified by dwSize, the method should supply + the required size and return E_FAIL. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwInfoIndex); + UNREFERENCED_PARAMETER(pOutputBuf); + UNREFERENCED_PARAMETER(dwSize); + UNREFERENCED_PARAMETER(pcbcNeeded); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +WritePrinter( + PDEVOBJ pdevobj, + PVOID pBuf, + DWORD cbBuffer, + PDWORD pcbWritten + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni2::WritePrinter + + The IPrintOemUni2::WritePrinter method, if supported, enables a + rendering plug-in to capture all output data generated by a Unidrv + driver. If this method is not supported, the output data would + otherwise be sent to the spooler in a call to the spooler's WritePrinter API. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pBuf - pointer to the first byte of an array of bytes that contains + the output data generated by the Unidrv driver. + cbBuffer - size, in bytes, of the array pointed to by pBuf. + pcbWritten - pointer to a DWORD value that receives the number + of bytes of data that were successfully sent to the plug-in. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pBuf); + UNREFERENCED_PARAMETER(cbBuffer); + UNREFERENCED_PARAMETER(pcbWritten); + + return E_NOTIMPL; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class COemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef)(THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release)(THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance)(THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + + STDMETHOD(LockServer)(THIS_ BOOL bLock); + + + // Constructor + COemCF(): m_cRef(1) { }; + + // Destructor + ~COemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall +COemCF:: +QueryInterface( + const IID& iid, + void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall +COemCF:: +AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +COemCF:: +Release() +{ +// ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall +COemCF:: +CreateInstance( + IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + // Create component. + COemUni2* pOemCP = new COemUni2; + if (pOemCP == NULL) + { + return E_OUTOFMEMORY; + } + + // Get the requested interface. + HRESULT hr = pOemCP->QueryInterface(iid, ppv); + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCP->Release(); + return hr; +} + +// LockServer +HRESULT __stdcall +COemCF:: +LockServer( + BOOL bLock + ) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + return S_OK; +} + + +// +// Registration functions +// + +// +// Can DLL unload now? +// +STDAPI DllCanUnloadNow(void) +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMRENDER) + { + ERR("DllGetClassObject:\tClass not available!\r\n"); + return CLASS_E_CLASSNOTAVAILABLE; + } + + // Create class factory. + COemCF* pFontCF = new COemCF; // Reference count set to 1 in constructor + if (pFontCF == NULL) + { + ERR("DllGetClassObject:\tOut of Memory!\r\n"); + return E_OUTOFMEMORY; + } + + // Get requested interface. + HRESULT hrResult = pFontCF->QueryInterface(iid, ppv); + pFontCF->Release(); + + return hrResult; +} + +BOOL +bGrowBuffer( + POEMPDEV pOemPDEV, + DWORD dwBufInc + ) + +/*++ + +Routine Description: + + Enlarge the buffer for holding the bitmap data + +Arguments: + + pOemPDEV - Pointer to the private PDEV structure + dwBufInc - Amount to enlarge the buffer by + +Return Value: + + TRUE if successful, FALSE if memory allocation fails + +--*/ + +{ + DWORD dwOldBufferSize; + PBYTE pNewBuffer; + + // Allocate a new buffer whose size is the size of the previous buffer plus the increment + // + dwOldBufferSize = pOemPDEV->pBufStart ? pOemPDEV->dwBufSize : 0; + pOemPDEV->dwBufSize = dwOldBufferSize + dwBufInc; + + if (NULL == (pNewBuffer = (PBYTE)LocalAlloc(LPTR, pOemPDEV->dwBufSize))) + { + WARNING("LocalAlloc failed!\n"); + + vFreeBuffer(pOemPDEV); + + return FALSE; + } + + if (pOemPDEV->pBufStart) // Growing an existing buffer + { + CopyMemory(pNewBuffer, pOemPDEV->pBufStart, dwOldBufferSize); + + LocalFree(pOemPDEV->pBufStart); + pOemPDEV->pBufStart = pNewBuffer; + } + else // First time allocation + { + pOemPDEV->pBufStart = pNewBuffer; + } + + return TRUE; +} + +VOID +vFreeBuffer( + POEMPDEV pOemPDEV + ) + +/*++ + +Routine Description: + + Free the buffer for holding the bitmap data + +Arguments: + + pOemPDEV - Pointer to the private PDEV structure + +Return Value: + + None +--*/ + +{ + if (pOemPDEV->pBufStart) + { + LocalFree(pOemPDEV->pBufStart); + + pOemPDEV->pBufStart = NULL; + pOemPDEV->dwBufSize = 0; + } +} + +BOOL +bFillColorTable( + POEMPDEV pOemPDEV + ) + +/*++ + +Routine Description: + + Fill the color table for the bitmap data. This function + obtains the entries in the default palette and fills the + RGBQUAD structure that represents the color table. + +Arguments: + + pOemPDEV - Pointer to the private PDEV structure + +Return Value: + + TRUE if successful, FALSE if memory allocation for the color table fails + +--*/ + +{ + PALETTEENTRY * pPaletteEntry; + UINT uiPalEntries; + INT iLastPalIndex = pOemPDEV->cPalColors - 1; + DWORD cbMemAllocSize; + + pOemPDEV->prgbq = NULL; + + // Call intsafe.h function to ensure there's no integer overflow or underflow + if (!SUCCEEDED(DWordMult(pOemPDEV->cPalColors, sizeof(RGBQUAD), &cbMemAllocSize)) || + (NULL == (pOemPDEV->prgbq = (RGBQUAD *)LocalAlloc(LPTR, cbMemAllocSize)))) + { + return FALSE; + } + + // Call intsafe.h function to ensure there's no integer overflow or underflow + if (!SUCCEEDED(DWordMult(pOemPDEV->cPalColors, sizeof(PALETTEENTRY), &cbMemAllocSize)) || + (NULL == (pPaletteEntry = (PALETTEENTRY *)LocalAlloc(LPTR, cbMemAllocSize)))) + { + return FALSE; + } + + uiPalEntries = GetPaletteEntries(pOemPDEV->hpalDefault, 0, pOemPDEV->cPalColors, pPaletteEntry); + + if (uiPalEntries == 0) + { + LocalFree(pPaletteEntry); + return FALSE; + } + + for (int i = 0; i < pOemPDEV->cPalColors; i++) + { + pOemPDEV->prgbq[i].rgbBlue = pPaletteEntry[i].peBlue; + pOemPDEV->prgbq[i].rgbGreen = pPaletteEntry[i].peGreen; + pOemPDEV->prgbq[i].rgbRed = pPaletteEntry[i].peRed; + } + + // Set the last index in the color table to white + // + pOemPDEV->prgbq[iLastPalIndex].rgbBlue = 0xff; + pOemPDEV->prgbq[iLastPalIndex].rgbGreen = 0xff; + pOemPDEV->prgbq[iLastPalIndex].rgbRed = 0xff; + + return TRUE; + +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.h new file mode 100644 index 00000000..7c992055 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/intrface.h @@ -0,0 +1,287 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.H +// +// +// PURPOSE: Define COM interface for User Mode Printer Customization DLL. +// + + +#pragma once + +///////////////////////////////////////////////////////// +// String Literals +///////////////////////////////////////////////////////// + + +CONST CHAR NAME_CommandCallback[] = "CommandCallback"; +CONST CHAR NAME_FilterGraphics[] = "FilterGraphics"; +CONST CHAR NAME_ImageProcessing[] = "ImageProcessing"; + + +//////////////////////////////////////////////////////////////////////////////// +// +// COemUni2 +// +// Interface for Unidrv OEM sample rendering module +// +class COemUni2 : public IPrintOemUni2 +{ +public: + // *** IUnknown methods *** + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release)(THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Method for getting the implemented methods. + // Returns S_OK if the given method is implemneted. + // Returns S_FALSE if the given method is notimplemneted. + // + + STDMETHOD(GetImplementedMethod)(THIS_ _In_ PSTR pMethodName); + + // + // Method for OEM to specify DDIs that have been hooked + // + + STDMETHOD(EnableDriver) (THIS_ DWORD DriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded); + + // + // Method to notify OEM plugin that it is no longer required + // + + STDMETHOD(DisableDriver) (THIS); + + // + // Method for OEM plugin to contruct its own PDEV + // + + STDMETHOD(EnablePDEV)(THIS_ PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem); + + // + // Method for OEM to free any resource associated with its PDEV + // + + STDMETHOD(DisablePDEV)(THIS_ PDEVOBJ pdevobj); + + // + // Method for OEM to transfer from old PDEV to new PDEV + // + + STDMETHOD(ResetPDEV)(THIS_ PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo)(THIS_ DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDriverDMS - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(DriverDMS)(THIS_ PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode)(THIS_ DWORD dwMode, + POEMDMPARAM pOemDMParam); + + // + // OEMCommandCallback - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(CommandCallback)(THIS_ PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult); + + // + // OEMImageProcessing - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(ImageProcessing)(THIS_ PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult); + + // + // OEMFilterGraphics - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(FilterGraphics)(THIS_ PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen); + // + // OEMCompression - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(Compression)(THIS_ PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult); + + // + // OEMHalftone - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(HalftonePattern)(THIS_ PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize); + + // + // OEMMemoryUsage - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(MemoryUsage)(THIS_ PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage); + + // + // OEMTTYGetInfo - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(TTYGetInfo)(THIS_ PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded); + + // + // OEMDownloadFontheader - UNIDRV only + // + + STDMETHOD(DownloadFontHeader)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMDownloadCharGlyph - UNIDRV only + // + + STDMETHOD(DownloadCharGlyph)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult); + + // + // OEMTTDownloadMethod - UNIDRV only + // + + STDMETHOD(TTDownloadMethod)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMOutputCharStr - UNIDRV only + // + + STDMETHOD(OutputCharStr)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph); + + // + // OEMSendFontCmd - UNIDRV only + // + + + STDMETHOD(SendFontCmd)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv); + + // + // OEMTextOutAsBitmap - UNIDRV only + // + + STDMETHOD(TextOutAsBitmap)(THIS_ SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix); + + // + // IPrintOemUni2 methods + // + + // + // Method for plugin to hook out spooler's WritePrinter API so it + // can get access to output data Universal driver is generating + // + // At DrvEnablePDEV time, Universal driver will call this function with + // pdevobj = NULL, pBuf = NULL, cbBuffer = 0 to detect if the plugin + // implements this function. Plugin should return S_OK to indicate it is + // implementing this function, or return E_NOTIMPL otherwise. + // + // In pcbWritten, plugins should return the number of bytes written to the + // spooler's WritePrinter function. Zero doesn't carry a special meaning, + // errors must be reported through the returned HRESULT. + // + + STDMETHOD(WritePrinter)(THIS_ PDEVOBJ pdevobj, + PVOID pBuf, + DWORD cbBuffer, + PDWORD pcbWritten); + + + COemUni2(); + ~COemUni2(); + +protected: + LONG m_cRef; + IPrintOemDriverUni* m_pOEMHelp; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/precomp.h new file mode 100644 index 00000000..d26e300b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/precomp.h @@ -0,0 +1,40 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.H +// +// +// PURPOSE: Required header files external to the current project +// that do not need to be recompiled frequently. +// + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/resource.h new file mode 100644 index 00000000..8e941820 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by OEMUNI.rc +// + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp.gpd b/print/OEM Printer Customization Plug-in Samples/C++/custhlp.gpd new file mode 100644 index 00000000..23c72bea --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp.gpd @@ -0,0 +1,563 @@ +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*ModelName: "OEM Unidrv Customization Sample" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 + +*%------------------------------------- +*%This is your OEM Custom Help file. +*%------------------------------------- +*HelpFile: "CUSTOMDRV.HLP" + +*PrintRate: 8 +*PrintRateUnit: PPM +*PrintRatePPM: 8 + +*Feature: Orientation +{ + *HelpIndex: 15001 + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l0O" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l1O" + } + } +} + +*%------------------------------------- +*%This Features std help is replaced with OEM help. +*%Note you need to have *HelpFile: def in the general section. +*%HelpIndex is OEM ref ID +*%------------------------------------- +*Feature: InputBin +{ + *HelpIndex: 15001 + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: UPPER + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l1H" + } + } +} +*Feature: Resolution +{ + *HelpIndex: 15001 + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: Option1 + *Option: Option1 + { + *Name: "300 x 300 " =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "<1B>%%-12345X" ++ "@PJL COMMENT HP Color LaserJet 5/5M " ++ "Version 0.56<0A>" ++ "@PJL SET RESOLUTION=300<0A>" ++ "@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } + *Option: Option2 + { + *Name: "150 x 150 " =DOTS_PER_INCH + *DPI: PAIR(150, 150) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "<1B>%%-12345X" ++ "@PJL COMMENT HP Color LaserJet 5/5M " ++ "Version 0.56<0A>" ++ "@PJL SET RESOLUTION=150<0A>" ++ "@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } +} + +*Feature: PaperSize +{ + *HelpIndex: 15001 + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *%(9600, 12648) +*% *PrintableArea: PAIR(9600, 12648) + *PrintableArea: PAIR(9564, 12600) +*% *PrintableArea: PAIR(5000,5000) + *PrintableOrigin: PAIR(300, 300) +*% *PrintableOrigin: PAIR(300, 500) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9600->9592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (12648->12640) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9592, 12640) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *%5760 -- 7560 + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t5760x7604Y" + } + } + *case: LANDSCAPE_CC90 + { + *%(9720, 12648) + *PrintableArea: PAIR(9760, 12688) + *PrintableOrigin: PAIR(200, 272) + *CursorOrigin: PAIR(200, 12960) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t7632x5880Y" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9540, 16248) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9600->9592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (16248->16240) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9592, 16240) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t5760x9864Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9760, 16288) + *PrintableOrigin: PAIR(200, 272) + *CursorOrigin: PAIR(200, 16560) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t9792x5880Y" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 12000) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (8100->8096) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (12000->11992) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(8096, 11992) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t4860x7344Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8200, 12080) + *PrintableOrigin: PAIR(240, 280) + *CursorOrigin: PAIR(200, 12360) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t7272x4980Y" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9324, 13476) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9324->9320) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (13476->13472) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9320, 13472) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t5594x8201Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9464, 13516) + *PrintableOrigin: PAIR(220, 272) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9464->9456) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (13516->13512) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9456, 13512) +*% Warning: the following printable origin X is adjusted (220->224) so it is divisible by the resolution X scale. + *PrintableOrigin: PAIR(224, 272) + } + } + *CursorOrigin: PAIR(200, 13788) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t8129x5714Y" + } + } + } + } + *Option: A3 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(13428, 19308) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (13428->13424) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (19308->19304) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(13424, 19304) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l27a8c1E<1B>*p0x0Y<1B>*c0t8057x11693Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(13588, 19368) + *PrintableOrigin: PAIR(200, 240) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (13588->13584) so it is divisible by the resolution X scale. + *PrintableArea: PAIR(13584, 19368) + } + } + *CursorOrigin: PAIR(200, 19608) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l27a8c1E<1B>*p0x0Y<1B>*c0t11621x8177Y" + } + } + } + } + *Option: TABLOID + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { +*% *PrintableArea: PAIR(12600, 19800) + *PrintableArea: PAIR(12540, 19740) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (12600->12592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (19800->19792) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(12592, 19792) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l6a8c1E<1B>*p0x0Y<1B>*c0t7560x12000Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(12600, 19800) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (12600->12592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (19800->19792) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(12592, 19792) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(200, 20100) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l6a8c1E<1B>*p0x0Y<1B>*c0t11880x7680Y" + } + } + } + } +} +*Feature: MediaType +{ + *HelpIndex: 15001 + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: STANDARD + *Option: STANDARD + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.14 + *Cmd: "<1B>&l0M" + } + } + *Option: TRANSPARENCY + { + *rcNameID: =TRANSPARENCY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.14 + *Cmd: "<1B>&l4M" + } + } +} +*Feature: ColorMode +{ + *rcNameID: =COLOR_PRINTING_MODE_DISPLAY + *HelpIndex: 12004 + *DefaultOption: 24bpp + *Option: 24bpp + { + *rcNameID: =24BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 24 + *DrvBPP: 24 + *Command: CmdEnableDRC { *Cmd : "<1B>*b3M" } + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" %d{PaletteIndexToProgram} ++ "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSetSrcBmpWidth { *Cmd : "<1B>*r" %d{RasterDataWidthInBytes / 3}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*l184O<1B>*v6W<0003080808081B>*v0a0b0c7i255a255b255c0I<1B>*" ++ "o3W<060400>" + } + } +} +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *HelpIndex: 12005 + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.5 + *Cmd: "<1B>&u300D<1B>*r0F" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "<1B>*b0M<0D>" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "<1B>E<1B>%%-12345X" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l" %d{NumOfCopies}"X" +} +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*Command: CmdXMoveAbsolute { *Cmd : "<1B>*p" %d{(DestX / 4) }"X" } +*Command: CmdXMoveRelRight { *Cmd : "<1B>*p+" %d[0,9600]{max_repeat((DestXRel / 4) )}"X" } +*Command: CmdXMoveRelLeft { *Cmd : "<1B>*p-" %d[0,9600]{max_repeat((DestXRel / 4) )}"X" } +*Command: CmdYMoveAbsolute { *Cmd : "<1B>*p" %d{(DestY / 4) }"Y" } +*Command: CmdYMoveRelDown { *Cmd : "<1B>*p+" %d[1,12600]{max_repeat((DestYRel / 4) )}"Y" } +*Command: CmdYMoveRelUp { *Cmd : "<1B>*p-" %d[1,12600]{max_repeat((DestYRel / 4) )}"Y" } +*Command: CmdCR { *Cmd : "<0D>" } +*Command: CmdLF { *Cmd : "<0A>" } +*Command: CmdFF { *Cmd : "<0C>" } +*Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" %d{PaletteIndexToProgram} ++ "I" } +*Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } +*Command: CmdBackSpace { *Cmd : "<08>" } +*Command: CmdUniDirectionOn { *Cmd : "<00>" } +*Command: CmdUniDirectionOff { *Cmd : "<00>" } +*Command: CmdPushCursor { *Cmd : "<1B>&f0S" } +*Command: CmdPopCursor { *Cmd : "<1B>&f1S" } +*Command: CmdSetSimpleRotation { *Cmd : "<1B>&a" %d{PrintDirInCCDegrees}"P" } +*EjectPageWithFF?: TRUE +*Command: CmdEnableTIFF4 { *Cmd : "<1B>*b2M" } +*Command: CmdDisableCompression { *Cmd : "<1B>*b0M" } +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*DefaultFont: 136 +*DefaultCTT: 0 +*CharPosition: BASELINE +*TTFSEnabled?: TRUE +*DeviceFonts: LIST(134,135,136,137,138,139,140,146,147,148,149,150,151,152,153,154, ++ 155,156,157,164,165,166,196,197,198,199,200,201,202,203,209,210, ++ 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, ++ 227,228,229,230) + +*MinFontID: 16534 +*MaxFontID: 32768 +*FontFormat: HPPCL_OUTLINE +*% When the %f format is implemented we can remove the /100 part of +*% CmdSelectFontHeight and CmdSelectFontWidth +*% NOTE: MasterUnits.x is hardcoded here! +*% NOTE: THIS dividing by 200 because I want to /100 and then /2 for now. +*% The number 60000 may look strange, but it's 1200/2 * 100. +*Command: CmdSelectFontHeight { *Cmd : "<1B>(s" %d{FontHeight}"V" } +*Command: CmdSelectFontWidth { *Cmd : "<1B>(s" %f{1200 / FontWidth}"H" } +*Command: CmdSetFontID { *Cmd : "<1B>*c" %d{NextFontID}"D" } +*Command: CmdSelectFontID { *Cmd : "<1B>(" %d{CurrentFontID}"X" } +*Command: CmdSetCharCode { *Cmd : "<1B>*c" %d{NextGlyph}"E" } +*Command: CmdUnderlineOn { *Cmd : "<1B>&dD" } +*Command: CmdUnderlineOff { *Cmd : "<1B>&d@" } +*Command: CmdWhiteTextOn { *Cmd : "<1B>*v1o1T" } +*Command: CmdWhiteTextOff { *Cmd : "<1B>*v0o0T" } +*MinGrayFill: 1 +*MaxGrayFill: 100 +*Command: CmdSetRectWidth { *Cmd : "<1B>*c" %d{(RectXSize / 4) }"A" } +*Command: CmdSetRectHeight { *Cmd : "<1B>*c" %d{(RectYSize / 4) }"B" } +*Command: CmdRectGrayFill { *Cmd : "<1B>*c" %d{GrayPercentage }"g2P" } +*Command: CmdRectWhiteFill { *Cmd : "<1B>*c1P" } +*Command: CmdRectBlackFill { *Cmd : "<1B>*c0P" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp.ini b/print/OEM Printer Customization Plug-in Samples/C++/custhlp.ini new file mode 100644 index 00000000..2e014201 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=CUSTHLP.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.def b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.def new file mode 100644 index 00000000..68bdffc0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.def @@ -0,0 +1,3 @@ +LIBRARY OEMUI +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj new file mode 100644 index 00000000..60f17f4c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj @@ -0,0 +1,1060 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {CA70C64A-75C8-48CD-9224-335C2ED689A6} + $(MSBuildProjectName) + Win10 Debug + Win32 + {67281069-E045-4DCB-82BF-17B46979B788} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + CUSTHLP + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + CUSTHLP.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj.Filters new file mode 100644 index 00000000..4c89a16e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/CUSTHLP.vcxproj.Filters @@ -0,0 +1,220 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {C7019300-D308-4256-B5E7-2CF8880D9E37} + + + h;hpp;hxx;hm;inl;inc;xsd + {8C99BD7D-E931-4BC0-810B-E56E2CE71883} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {B8E59174-9E39-4E27-A90D-17A011B16729} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.cnt b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.cnt new file mode 100644 index 00000000..4713a3b5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.cnt @@ -0,0 +1,3 @@ +:Base windows.HLP +1 Dialog Box Help +2 Information about this Help file=nocontent diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.h new file mode 100644 index 00000000..f49cbd14 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.h @@ -0,0 +1,11 @@ +// +// +// +// +////////////////////////////////////////////////////////////////// + +#define CUSDRV_HELPTOPIC_1 = 15001 +#define CUSDRV_HELPTOPIC_2 = 15002 +#define CUSDRV_HELPTOPIC_3 = 15003 +#define CUSDRV_HELPTOPIC_4 = 15004 + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.hpj b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.hpj new file mode 100644 index 00000000..2ccc18db --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.hpj @@ -0,0 +1,17 @@ +; This file is maintained by HCW. Do not modify this file directly. + +[OPTIONS] +COMPRESS=12 Hall Zeck +ERRORLOG=customdrv.err +LCID=0x409 0x0 0x0 ; English (United States) +REPORT=Yes +TITLE=Windows +CNT=customdrv.cnt +COPYRIGHT=%date +HLP=customdrv.hlp + +[FILES] +customdrv.rtf + +[MAP] +#include customdrv.h diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.rtf b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.rtf new file mode 100644 index 00000000..5ddf4b0e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/customhelp/customdrv.rtf @@ -0,0 +1,22 @@ +{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Times};}{\f30\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Times};} +{\f31\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Times};}{\f33\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Times};}{\f34\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Times};} +{\f35\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Times};}{\f36\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Times};}{\f37\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Times};}}{\colortbl;\red0\green0\blue0; +\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128; +\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;} +{\*\cs10 \additive Default Paragraph Font;}{\s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext15 endnote text;}{ +\s16\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext16 footnote text;}{\*\cs17 \additive \super \sbasedon10 footnote reference;}{\*\cs18 \additive \super +\sbasedon10 endnote reference;}{\*\cs19 \additive \fs16\cf0\up6 \sbasedon10 ExternalFN;}{\s20\ql \li0\ri0\widctlpar\tqc\tx4320\tqr\tx8640\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 +\sbasedon0 \snext20 header;}{\s21\ql \li0\ri0\widctlpar\tqc\tx4320\tqr\tx8640\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext21 footer;}}{\info{\author Craig Horsfield} +{\operator Craig Horsfield}{\creatim\yr2001\mo2\dy27\hr15\min6}{\revtim\yr2001\mo4\dy2\hr15\min7}{\version5}{\edmins3}{\nofpages3}{\nofwords17}{\nofchars100}{\*\company Microsoft}{\nofcharsws0}{\vern8269}} +\widowctrl\ftnbj\aendnotes\ftnnrlc\aftnnar\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale144\viewzk2\nolnhtadjtbl \fet0\sectd +\linex0\sectdefaultcl {\header \pard\plain \s20\ql \li0\ri0\widctlpar\tqc\tx4320\tqr\tx8640\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 { +\par }}{\footer \pard\plain \s21\ql \li0\ri0\widctlpar\tqc\tx4320\tqr\tx8640\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 { +\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}} +{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8 +\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 +\fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\cs19\fs16\up6 @{\footnote \pard\plain \s16\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\cs17\super @}{ + The following topics are for Custom options in the Custom Driver UI Plugin.}} #{\footnote \pard\plain \s16\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\cs17\super #}{ + CUSDRV_HELPTOPIC_1}}}{ Custom Topic 1 Help text contained in customdrv.rtf. +\par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\page }{\cs19\fs16\up6 #{\footnote \pard\plain \s16\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\cs17\super #}{ + CUSDRV_HELPTOPIC_2}}}{ Custom Topic 2 Help text contained in customdrv.rtf. }{\fs20 \page }{ +\par }} \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.cpp new file mode 100644 index 00000000..8dae1ed3 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.cpp @@ -0,0 +1,182 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + + +#include "precomp.h" +#include "oemui.h" +#include "debug.h" +#include "devmode.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// +//Performs operation on UI Plugins Private DevMode Members. +//Called via IOemUI::DevMode +// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR("DevMode() ERROR_INVALID_PARAMETER.\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + // + //The Method should return the size of the memory allocation needed to store the UI plugin Private DEVMODE. + // + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + // + //Should fill the Private DEVMODE with the default values. + // + case OEMDM_DEFAULT: + // + //OEM_DMEXTRAHEADER Members + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + + // + //Private members + // + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + break; + + // + //The method should convert private DEVMODE members to the current version, if necessary. + // + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + // + //The method should validate the information contained in private DEVMODE members and merge validated values into a private DEVMODE structure containing default values + // + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return S_OK; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) +{ + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR("ConvertOEMDevmode() invalid parameters.\r\n"); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n"); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + } + + return TRUE; +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data, if not valid. + if(pOEMDevmode->dwDriverData > 100) + { + pOEMDevmode->dwDriverData = 0; + } + + // Set Advanced driver data, if not valid. + if(pOEMDevmode->dwAdvancedData > 100) + { + pOEMDevmode->dwAdvancedData = 0; + } + + return TRUE; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.h new file mode 100644 index 00000000..fe594658 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/devmode.h @@ -0,0 +1,46 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// PURPOSE: The plug-in private devmode, common data types, and +// external function prototypes for devmode functions. +// + +#pragma once + + +// +//Can add info to the private devmode bellow here. +//Note : +// This structure must be prefixed by OEM_DMEXTRAHEADER +// Your plug-in must implement the IPrintOemUI::DevMode method +// +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + DWORD dwDriverData; + DWORD dwAdvancedData; + + // + //Private DevMode Members + // + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/dllentry.cpp new file mode 100644 index 00000000..287c0617 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/dllentry.cpp @@ -0,0 +1,49 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "oemui.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_PROCESS_DETACH: + break; + + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.cpp b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.cpp new file mode 100644 index 00000000..c41a27e4 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.cpp @@ -0,0 +1,25 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.cpp +// +// +// PURPOSE: File that contains all the globals. +// + +#include "precomp.h" +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.h new file mode 100644 index 00000000..b9d707a0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/globals.h @@ -0,0 +1,22 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.h +// +// PURPOSE: Lists of globals declared in Globals.cpp. +// + + +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +extern HINSTANCE ghInstance; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.cpp new file mode 100644 index 00000000..2a1278cc --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.cpp @@ -0,0 +1,562 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.cpp +// +// PURPOSE: Implementation of OEMGetInfo and OEMDevMode. Shared by all Unidrv +// OEM test dll's. +// + +#include "precomp.h" + +#include "oemui.h" +#include "debug.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0; // Count of active components +static long g_cServerLocks = 0; // Count of locks + + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI body +// +IOemUI::~IOemUI() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + ASSERT(0 == m_cRef); +} + +HRESULT __stdcall IOemUI::QueryInterface(const IID& iid, void** ppv) +{ + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + } + else if (iid == IID_IPrintOemUI) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall IOemUI::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemUI::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// +// (Implementation is required) Supplies a pointer to UNIDRIVE /PScript IPrintOemDriverUI +// +HRESULT __stdcall IOemUI::PublishDriverInterface( + IUnknown *pIUnknown) +{ + // Need to store pointer to Driver Helper functions, if we already haven't. + if (m_pOEMHelp == NULL) + { + HRESULT hResult; + + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUI, (void** ) &(m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + +// +//(Implementation is required) Returns the UI Plugin's identification information +// +HRESULT __stdcall IOemUI::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + WARNING("IOemUI::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER\r\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING("IOemUI::GetInfo() exit insufficient buffer!\r\r\n"); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING("IOemUI::GetInfo() exit mode not supported.\r\r\n"); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + return S_OK; +} + + +// +//Performs operation on UI Plugins Private DevMode Members. +// +HRESULT __stdcall IOemUI::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + return hrOEMDevMode(dwMode, pOemDMParam); +} + + +// +//Allows UI Plugin to Modifiy Existing printer porp sheet and document property sheet page.. +// +HRESULT __stdcall IOemUI::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam) +{ + return hrOEMPropertyPage(dwMode, pOemCUIPParam); +} + + +// +//Adds a New page to the device Documment property sheet. +// + +HRESULT __stdcall IOemUI::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + return hrOEMDocumentPropertySheets(pPSUIInfo, lParam, m_pOEMHelp); +} + +// +//Adds a New page to the device printer property page. +// +HRESULT __stdcall IOemUI::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + return hrOEMDevicePropertySheets(pPSUIInfo, lParam); +} + + +// +//Allows the UI plugin to spec Customized device capabilaties (TODO) +// +HRESULT __stdcall IOemUI::DeviceCapabilities( + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult) +{ + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + return E_NOTIMPL; +} + + +// +//Allows the UI plugin to help determine if a print Job is printable. +// +HRESULT __stdcall IOemUI::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM) +{ + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + + +// +//Allows the UI Plugin to upgrade its dev options stored in the registry. +// +HRESULT __stdcall IOemUI::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo) +{ + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam) +{ + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam) +{ + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +HRESULT __stdcall IOemUI::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData) +{ + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + HRESULT Result = E_FAIL; + static const WCHAR PROFILE_NAME[] = L"OEMPROFILE.icm\0"; + + if(QCP_DEVICEPROFILE == ulQueryMode) + { + if(NULL == pvProfileData) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + if(*pcbProfileData < sizeof(PROFILE_NAME)) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + Result = StringCbCopy((LPWSTR)pvProfileData, *pcbProfileData, PROFILE_NAME); + *pcbProfileData = sizeof(PROFILE_NAME); + *pflProfileData = QCP_PROFILEDISK; + + if(FAILED(Result)) + { + SetLastError(Result); + } + } + } + } + + return Result; +}; + +HRESULT __stdcall IOemUI::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam) +{ + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI::UpdateExternalFonts( + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges) +{ + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + // Create component. + IOemUI* pOemCB = new IOemUI; + if (pOemCB == NULL) + { + return E_OUTOFMEMORY; + } + // Get the requested interface. + HRESULT hr = pOemCB->QueryInterface(iid, ppv); + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release(); + return hr; +} + +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + return S_OK; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv); + pFontCF->Release(); + + return hr; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.h new file mode 100644 index 00000000..1cc44e3a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/intrface.h @@ -0,0 +1,182 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.h +// +// PURPOSE: Declaration of class that implements the UI plug-in class +// + + +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI +// +class IOemUI: public IPrintOemUI +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IPrintOemUI methods *** + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + + IOemUI() { m_cRef = 1; m_pOEMHelp = NULL; }; + ~IOemUI(); + +protected: + LONG m_cRef; + IPrintOemDriverUI* m_pOEMHelp; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.cpp b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.cpp new file mode 100644 index 00000000..2bc8cc32 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.cpp @@ -0,0 +1,960 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.cpp +// +// +// PURPOSE: Main file for OEM UI test module. +// + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + +typedef struct _tagCBUserData +{ + HANDLE hComPropSheet; + HANDLE hPropPage; + POEMUIPSPARAM pOEMUIParam; + PFNCOMPROPSHEET pfnComPropSheet; + +} CBUSERDATA, *PCBUSERDATA; + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam); +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam); +static BOOL AddCustomUIHelp (HANDLE hPrinter, HANDLE hHeap, HANDLE hModule, POPTITEM pOptItem, DWORD HelpIndex, DWORD HelpFile); +static POIEXT CreateOIExt(HANDLE hHeap); +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems); +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems); +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams); +static PTSTR GetHelpFile (HANDLE hPrinter, HANDLE hHeap, HANDLE hModule, UINT uResource); +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource); +LPBYTE WrapGetPrinterDriver (HANDLE hHeap, HANDLE hPrinter, DWORD dwLevel); + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM device or document property UI. +// Called via IOemUI::CommonUIProp +// +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hResult = S_OK; + + // Validate parameters. + if( (OEMCUIP_DOCPROP != dwMode) + && + (OEMCUIP_PRNPROP != dwMode) + ) + { + ERR("hrOEMPropertyPage() ERROR_INVALID_PARAMETER.\r\n"); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam); + break; + + case OEMCUIP_PRNPROP: + hResult = hrPrinterPropertyPage(dwMode, pOEMUIParam); + break; + + default: + // Should never reach this! + ERR("hrOEMPropertyPage() Invalid dwMode"); + SetLastError(ERROR_INVALID_PARAMETER); + hResult = E_FAIL; + break; + } + + return hResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM document property UI. +// +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM document property UI. + pOEMUIParam->cOEMOptItems = 1; + } + else + { + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMDocUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_ADV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + + pOEMUIParam->pOEMOptItems[0].pOptType= CreateOptType(pOEMUIParam->hOEMHeap, 2); + + // + //Setup the Optional Item + // + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + + + // + //Allows You to apply Customised help to this Control. + // + //Notes: + // You must use a fully qualified path for pHelpFile + // OPTITEM Flags member must have OPTIF_HAS_POIEXT flag set. This indicates that the data in OIEXT is valid. + // OPTITEM is allocated on the Heap see (AddCustomUIHelp, GetHelpFile, CreateOIExt) + // + AddCustomUIHelp (pOEMUIParam->hPrinter, + pOEMUIParam->hOEMHeap, + pOEMUIParam->hModule, + &(pOEMUIParam->pOEMOptItems[0]), + CUSDRV_HELPTOPIC_2, IDS_HELPFILE); + } + + return S_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM printer property UI. +// +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM printer property UI. + pOEMUIParam->cOEMOptItems = 1; + } + else + { + // + //This is the second time we are called Now setup the optional items. + // + DWORD dwError; + DWORD dwDeviceValue; + DWORD dwType; + DWORD dwNeeded; + + // Get device settings value from printer. + dwError = GetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, &dwType, (PBYTE) &dwDeviceValue, + sizeof(dwDeviceValue), &dwNeeded); + if( (ERROR_SUCCESS != dwError) + || + (dwDeviceValue > 100) + ) + { + // Failed to get the device value or value is invalid, just use the default. + dwDeviceValue = 0; + } + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMPrinterUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_DEV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = dwDeviceValue; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + // + //Setup the Optional Item + // + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + + // + //Allows You to apply Customised help to this Control + // + AddCustomUIHelp (pOEMUIParam->hPrinter, + pOEMUIParam->hOEMHeap, + pOEMUIParam->hModule, + &(pOEMUIParam->pOEMOptItems[0]), + CUSDRV_HELPTOPIC_1, + IDS_HELPFILE); + } + return S_OK; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to Document property sheet. Called via IOemUI::DocumentPropertySheets +// +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, + IPrintOemDriverUI* pOEMHelp) +{ + UNREFERENCED_PARAMETER(pOEMHelp); + + LONG_PTR lResult = 0; + HRESULT hrResult = S_OK; + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR("hrOEMDocumentPropertySheets() ERROR_INVALID_PARAMETER.\r\n"); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + DWORD dwSheets = 0; + PCBUSERDATA pUserData; + POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM) pPSUIInfo->lParamInit; + HANDLE hHeap = pOEMUIParam->hOEMHeap; + HANDLE hModule = pOEMUIParam->hModule; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + COMPROPSHEETUI Sheet; + + + // Init property page. + memset(&Sheet, 0, sizeof(COMPROPSHEETUI)); + Sheet.cbSize = sizeof(COMPROPSHEETUI); + Sheet.Flags = CPSUIF_UPDATE_PERMISSION; + Sheet.hInstCaller = ghInstance; + Sheet.pCallerName = GetStringResource(hHeap, ghInstance, IDS_NAME); + Sheet.pHelpFile = NULL; + Sheet.pfnCallBack = OEMDocUICallBack2; + Sheet.pDlgPage = CPSUI_PDLGPAGE_TREEVIEWONLY; + Sheet.cOptItem = 1; + Sheet.IconID = IDI_CPSUI_PRINTER; + Sheet.pOptItemName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.CallerVersion = 0x100; + Sheet.OptItemVersion = 0x100; + + // Init user data. + pUserData = (PCBUSERDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CBUSERDATA)); + if (NULL == pUserData) + { + ERR("hrOEMDocumentPropertySheets() failed to allocate user data.\r\n"); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + pUserData->hComPropSheet = pPSUIInfo->hComPropSheet; + pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + pUserData->pOEMUIParam = pOEMUIParam; + Sheet.UserData = (ULONG_PTR) pUserData; + + // Create OptItems for page. + Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem); + if (NULL == Sheet.pOptItem) + { + ERR("hrOEMDocumentPropertySheets() failed to allocate OPTITEMs.\r\n"); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Initialize OptItems + Sheet.pOptItem[0].Level = 1; + Sheet.pOptItem[0].Flags = OPTIF_COLLAPSE; + Sheet.pOptItem[0].pName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.pOptItem[0].Sel = pOEMDev->dwDriverData; + + Sheet.pOptItem[0].pOptType = CreateOptType(hHeap, 2); + if (NULL == Sheet.pOptItem[0].pOptType) + { + ERR("hrOEMDocumentPropertySheets() failed to allocate OPTTYPE.\r\n"); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // + //Set the UI prop of this OPTYPE item. + // + Sheet.pOptItem[0].pOptType->Type = TVOT_UDARROW; + Sheet.pOptItem[0].pOptType->pOptParam[1].IconID = 0; + Sheet.pOptItem[0].pOptType->pOptParam[1].lParam = 100; + + // + //Allows You to apply Customised help to this Control. + //See Function : AddCustomUIHelp, For more details on implamentation. + // + AddCustomUIHelp (pOEMUIParam->hPrinter, + hHeap, + hModule, + &(Sheet.pOptItem[0]), + CUSDRV_HELPTOPIC_1, + IDS_HELPFILE); + + // Adds the property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PCOMPROPSHEETUI, + (LPARAM)&Sheet, (LPARAM)&dwSheets); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + +Exit: + + pPSUIInfo->Result = lResult; + return hrResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to printer property sheet. Called via IOemUI::DevicePropertySheets +// +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam) +{ + LONG_PTR lResult = 0; + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR("hrOEMDevicePropertySheets() ERROR_INVALID_PARAMETER.\r\n"); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + PROPSHEETPAGE Page; + + // Init property page. + memset(&Page, 0, sizeof(PROPSHEETPAGE)); + Page.dwSize = sizeof(PROPSHEETPAGE); + Page.dwFlags = PSP_DEFAULT; + Page.hInstance = ghInstance; + Page.pszTemplate = MAKEINTRESOURCE(IDD_DEVICE_PROPPAGE); + Page.pfnDlgProc = DevicePropPageProc; + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PROPSHEETPAGE, (LPARAM)&Page, 0); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + + pPSUIInfo->Result = lResult; + return S_OK; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM printer property UI. +// +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + { + DWORD dwDriverValue = pOEMUIParam->pOEMOptItems[0].Sel; + + // Store OptItems state in printer data. + SetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, REG_DWORD, (PBYTE) &dwDriverValue, sizeof(DWORD)); + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Call back for OEM device property UI. +// +#pragma warning(push) +#pragma warning( disable : 6262 ) // 2 MAX_PATH strings exceeds the stack size by a few bytes. +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uiMsg) + { + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + switch(LOWORD(wParam)) + { + case IDC_CALIBRATE: + // Simulate printer calibration by displaying a message that the + // printer has been calibrated. + { + TCHAR szName[MAX_PATH]; + TCHAR szCalibrated[MAX_PATH]; + + LoadString(ghInstance, IDS_NAME, szName, sizeof(szName)/sizeof(szName[0])); + LoadString(ghInstance, IDS_CALIBRATED, szCalibrated, sizeof(szCalibrated)/sizeof(szCalibrated[0])); + MessageBox(hDlg, szCalibrated, szName, MB_OK); + } + break; + } + break; + + default: + return FALSE; + } + return TRUE; + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) // type of notification message + { + case PSN_SETACTIVE: + break; + + case PSN_KILLACTIVE: + break; + + case PSN_APPLY: + break; + + case PSN_RESET: + break; + } + } + break; + } + + return FALSE; +} +#pragma warning(pop) + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM document property UI. +// +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Store OptItems state in DEVMODE. + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_KILLACTIVE: + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pOEMUIParam->pOEMOptItems[0].Sel) != pOEMDev->dwAdvancedData) + { + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + pOEMUIParam->pOEMOptItems[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + PCBUSERDATA pUserData = (PCBUSERDATA) pCallbackParam->UserData; + POEMDEV pOEMDev = (POEMDEV) pUserData->pOEMUIParam->pOEMDM; + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + pUserData->pfnComPropSheet(pUserData->hComPropSheet, CPSFUNC_SET_RESULT, + (LPARAM)pUserData->hPropPage, + (LPARAM)CPSUI_OK); + break; + + case CPSUICB_REASON_KILLACTIVE: + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pCallbackParam->pOptItem[0].Sel) != pOEMDev->dwDriverData) + { + pCallbackParam->pOptItem[0].Sel = pOEMDev->dwDriverData; + pCallbackParam->pOptItem[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Creates and Initializes OptItems. +// +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems) +{ + POPTITEM pOptItems = NULL; + DWORD cbMemAllocSize; + + // Allocate memory for OptItems; + + // Call intsafe.h function to ensure there's no integer overflow or underflow + if (SUCCEEDED(DWordMult(sizeof(OPTITEM), dwOptItems, &cbMemAllocSize)) && + (NULL != (pOptItems = (POPTITEM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, cbMemAllocSize)))) + { + InitOptItems(pOptItems, dwOptItems); + } + else + { + ERR("CreateOptItems() failed to allocate memory for OPTITEMs!\r\n"); + } + + return pOptItems; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems. +// +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems) +{ + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for(DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds Custom help top a OPTTYPE UI item. +// +// Note : +// The OPTITEM member HelpIndex must be set the the correct HELP ID number. +// HelpIndex is the index that you assigned in the hlp file to this item of help. +// The OPTITEM, pOIExt member must point to a valid OIEXT structure. +// The phelpfile is member of OIEXT must have the fully qualified path to the driver file. +// +// +// It is also possible to overide common help items in UNIDRIVE via the HelpIndex in the GPD. +// For further information on using HelpIndex in the GPD see the relavent section in the DDK +// It is not possible to custimse help however via the PPD. The OPTITEM must be modified in the OEM Plugin. +// +static BOOL AddCustomUIHelp (HANDLE hPrinter, HANDLE hHeap, HANDLE hModule, + POPTITEM pOptItem, DWORD HelpIndex, DWORD HelpFile) +{ + POIEXT pOIExt = NULL; + + // + //Allocate a new OIEXT structure on the heap + // + if (pOptItem->pOIExt == NULL) + { + pOptItem->pOIExt = CreateOIExt(hHeap); + } + + if ( pOptItem->pOIExt == NULL ) + { + ERR("AddCustomUIHelp() Error Allocation Failed.\r\n"); + return FALSE; + } + + pOIExt = pOptItem->pOIExt; + + // + //Set to the full absolute path of the driver file. + //(It should be in the Printer Driver Directrory in most cases) + //This String needs to be allocated on the heap (The Driver will clean it up). + // + pOIExt->pHelpFile = GetHelpFile (hPrinter, hHeap, hModule, HelpFile); + + // + //Set to show tha there is a valid OIEXT structure and data + // + pOptItem->Flags |= OPTIF_HAS_POIEXT; + + // + //This needs to be set if you have ansi strings in your help file. (NOTE!) + // + //pOiExt->Flags |= OIEXTF_ANSI_STRING; + + // + //Add the help this the index in the .hlp file. + // + pOptItem->HelpIndex = HelpIndex; + + return TRUE; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OIEXT for OptItem. +// +static POIEXT CreateOIExt(HANDLE hHeap) +{ + + POIEXT pOiExt = NULL; + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOiExt = (POIEXT) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OIEXT)); + if(NULL != pOiExt) + { + // + // Initialize OPTTYPE. (These members are setup by AddCustomUIHelp) + // + pOiExt->cbSize = sizeof(OIEXT); + pOiExt->Flags = 0; + pOiExt->hInstCaller = NULL; + pOiExt->pHelpFile = NULL; + } + + return pOiExt; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OptType for OptItem. +// +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams) +{ + POPTTYPE pOptType = NULL; + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + if(NULL != pOptType) + { + DWORD cbMemAllocSize; + + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + + // Call intsafe.h function to ensure there's no integer overflow or underflow + if (SUCCEEDED(DWordMult(wOptParams, sizeof(OPTPARAM), &cbMemAllocSize)) && + (NULL != (pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, cbMemAllocSize)))) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + ERR("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n"); + + // Free allocated memory and return NULL. + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR("CreateOptType() failed to allocated memory for OPTTYPE!\r\n"); + } + + return pOptType; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates space on the heap and gets the help file name from the resource file. +// Note you need to allocate this on the heap so that it stays allocated as long as the driver UI is loaded. +// The OPTITEM->pOIExt ref this data. +// +static PTSTR GetHelpFile (HANDLE hPrinter, HANDLE hHeap, HANDLE hModule, UINT uResource) +{ + + DWORD nResult = 0; + DWORD dwSize = MAX_PATH; + PTSTR pszString = NULL; + PTSTR pszTemp = NULL; + PDRIVER_INFO_2 pDriverInfo = NULL; + + // + // Allocate buffer for string resource from heap; + // + pszTemp = (PTSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(TCHAR)); + pDriverInfo = (PDRIVER_INFO_2)WrapGetPrinterDriver (hHeap, hPrinter, 2); + + // + //Get the Full Driver Dir from pDriverPath it must include the \version\ + // + if(NULL != pszTemp && pDriverInfo && pDriverInfo->pDriverPath) + { + HRESULT hCopy; + + hCopy = StringCchCopy(pszTemp, dwSize, pDriverInfo->pDriverPath); + if(FAILED(hCopy)) + { + ERR("StringCchCopy() failed to copy driver path to temp buffer!\r\n"); + } + pszString = _tcsrchr (pszTemp, _T('\\') ) + 1; + } + + // + //The Help file is installed with the driver in the version drictory. + // + if(NULL != pszString) + { + // + //The Buffer size is in characters for the unicode version of LoadString + // + nResult = LoadString((HMODULE)hModule, uResource, pszString, (int)(dwSize - _tcslen(pszTemp)) ); + } + else + { + ERR("GetStringResource() failed to allocate string buffer!\r\n"); + } + + if(nResult > 0) + { + // + //Reallocate this so that we don't waist space on the heap (free any non used heap in MAX_PATH) + // + pszString = (PTSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszTemp, (_tcslen(pszTemp) + 1) * sizeof(TCHAR)); + if(NULL == pszString) + { + pszTemp = pszString; + ERR("GetStringResource() HeapReAlloc() of string retrieved failed!\r\n"); + } + } + else + { + ERR("LoadString() failed!"); + pszString = NULL; + } + + // + //Clean up the Driverinfo that was allocated. It is not needed. (Always free this it is only temp data) + // + if (pDriverInfo) + { + HeapFree(hHeap, 0, pDriverInfo); + } + + return pszString; +} + +//////////////////////////////////////////////////////////////////////////////////// +// +// Retrieves pointer to a String resource. +// +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource) +{ + int nResult; + DWORD dwSize = MAX_PATH; + PTSTR pszString = NULL; + + // Allocate buffer for string resource from heap; let the driver clean it up. + pszString = (PTSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(TCHAR)); + if(NULL != pszString) + { + // Load string resource; resize after loading so as not to waste memory. + nResult = LoadString((HMODULE)hModule, uResource, pszString, dwSize); + if(nResult > 0) + { + PTSTR pszTemp; + + pszTemp = (PTSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszString, (nResult + 1) * sizeof(TCHAR)); + if(NULL != pszTemp) + { + pszString = pszTemp; + } + else + { + ERR("GetStringResource() HeapReAlloc() of string retrieved failed!\r\n"); + } + } + else + { + ERR("LoadString() failed!\r\n"); + pszString = NULL; + } + } + else + { + ERR("GetStringResource() failed to allocate string buffer!\r\n"); + } + + return pszString; +} + + +//////////////////////////////////////////////////////////////////////////////////// +// +// Wrapper to help retrive the PrinterDriverInfo, +// Note the MEM is orphaned by this call on success +// + +LPBYTE WrapGetPrinterDriver (HANDLE hHeap, HANDLE hPrinter, DWORD dwLevel) +{ + // + //Get the PrinterINFO so that we know where the driver help file is. + // + BOOL bGet = TRUE; + DWORD dwNeeded = 0; + LPBYTE pBuffer = NULL; + + bGet = GetPrinterDriver(hPrinter, NULL, dwLevel, pBuffer, 0, &dwNeeded); + + if(!bGet && GetLastError() == ERROR_INSUFFICIENT_BUFFER ) + { + SetLastError(ERROR_SUCCESS); // clear the previous result to prevent noise + pBuffer = (LPBYTE)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, dwNeeded); + } + + if (pBuffer) + { + bGet = GetPrinterDriver(hPrinter, NULL, dwLevel, pBuffer, dwNeeded, &dwNeeded); + } + + if(!bGet || !pBuffer) + { + if (pBuffer) + { + HeapFree(hHeap, 0, pBuffer); + pBuffer = NULL; + } + + ERR("GetPrinterDriver() failed."); + } + + return pBuffer; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.h new file mode 100644 index 00000000..2fc12cba --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.h @@ -0,0 +1,47 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.H +// +// PURPOSE: Define common data types, and external function prototypes +// for property sheet handling. +// + + +#pragma once + +#include "DEVMODE.H" +#include "globals.h" + +//////////////////////////////////////////////////////// +// Custom Help Defines +//////////////////////////////////////////////////////// + +#define CUSDRV_HELPTOPIC_1 15001 +#define CUSDRV_HELPTOPIC_2 15002 + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + +// OEM Signature and version. +#define PROP_TITLE L"OEM UI Page" +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +// Printer registry keys where OEM data is stored. +#define OEMUI_VALUE TEXT("OEMUI_VALUE") +#define OEMUI_DEVICE_VALUE TEXT("OEMUI_DEVICE_VALUE") + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, IPrintOemDriverUI* pOEMHelp); +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.rc b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.rc new file mode 100644 index 00000000..e4d28716 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/oemui.rc @@ -0,0 +1,170 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "OEM UI Test Module." + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "OEMUI" + VALUE "LegalCopyright", "Copyright © 1998 - 2003 Microsoft Corp." + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "OEMUI.dll" + VALUE "ProductName", "Microsoft OEMUI" + VALUE "ProductVersion", "1.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DEVICE_PROPPAGE DIALOG 0, 0, 179, 113 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Device Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Added Page",IDC_STATIC,55,14,68,11 + PUSHBUTTON "Calibrate",IDC_CALIBRATE,61,34,50,14 +END + +IDD_DOC_PROPPAGE DIALOG 0, 0, 210, 154 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Document Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Document Property Page",IDC_STATIC,60,73,108,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DEVICE_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 172 + TOPMARGIN, 8 + BOTTOMMARGIN, 106 + END + + IDD_DOC_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 203 + TOPMARGIN, 7 + BOTTOMMARGIN, 147 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_SECTION "OEM UI Added Item" + IDS_CALIBRATED "Printer has been calibrated." + IDS_NAME "OEM UI Customization DLL" + IDS_HELPFILE "CUSTOMDRV.HLP" + IDS_DEV_SECTION "Device Settings OEM UI Added Item" + IDS_ADV_SECTION "Advanced OEM UI Added Item" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/precomp.h new file mode 100644 index 00000000..ef4615ad --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/precomp.h @@ -0,0 +1,54 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: PRECOMP.H +// +// PURPOSE: Optimize compilation of headers that do not change frequently +// + +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/custhlp/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/resource.h new file mode 100644 index 00000000..9c7732fe --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/custhlp/resource.h @@ -0,0 +1,23 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: resource.h +// +// PURPOSE: Defines resources IDs for localizable resources. +// + + +#define IDS_SECTION 1 +#define IDS_CALIBRATED 2 +#define IDS_NAME 3 +#define IDS_HELPFILE 4 +#define IDS_DEV_SECTION 5 +#define IDS_ADV_SECTION 10 +#define IDD_DEVICE_PROPPAGE 106 +#define IDD_DOC_PROPPAGE 107 +#define IDC_CALIBRATE 1001 + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.gpd b/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.gpd new file mode 100644 index 00000000..20e4d472 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.gpd @@ -0,0 +1,520 @@ +*GPDFileName: "gdlsmpl.gpd" +*GPDFileVersion: "1.0" +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*ModelName: "OEM Unidrv GDL Sample" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 +*PrintRate: 16 +*PrintRateUnit: PPM +*PrintRatePPM: 16 + +*% +*% This line indicates which file the GDL parser should use to find Bidi information. +*% This is also the same file that will be parser when querying the GDL via +*% IPrintCoreHelperUni. GDL is compatible with GPD syntax, and this can be the driver's +*% GPD file, whis is what this sample does. +*% +*BidiQueryFile: "gdlsmpl.gpd" + + +*%****************************************************************************************** +*% Orientation +*%****************************************************************************************** +*Feature: Orientation +{ + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l0O" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.8 + *Cmd: "<1B>&l1O" + } + } +} + +*%****************************************************************************************** +*% Input Bin +*%****************************************************************************************** +*Feature: InputBin +{ + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: AUTO + *Option: AUTO + { + *rcNameID: =AUTO_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l0H" + } + } + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l1H" + } + } +} + +*%****************************************************************************************** +*% Resolution +*%****************************************************************************************** +*Feature: Resolution +{ + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: 300dpi + *Option: 300dpi + { + *Name: "300 x 300" =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=300<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } +} + +*%****************************************************************************************** +*% HP-GL/2 Graphics Support +*%****************************************************************************************** +*Ifdef: WINNT_51 +*Personality: =PERSONALITY_HPGL2 +*Feature: GraphicsMode +{ + *rcNameID: =GRAPHICSMODE_DISPLAY + *DefaultOption: HPGL2MODE + *Option: HPGL2MODE + { + *rcNameID: =GRAPHICSMODE_HPGL2_DISPLAY + } + *Option: RASTERMODE + { + *rcNameID: =GRAPHICSMODE_RASTER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.5 + *Cmd: "@PJL SET LIMAGEENHANCE=OFF<0A>" + } + } +} +*Endif: + +*%****************************************************************************************** +*% Paper Size +*%****************************************************************************************** +*Feature: PaperSize +{ + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1028 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9500, 12500) + *PrintableOrigin: PAIR(400, 400) + *CursorOrigin: PAIR(300, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t5260x7704Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9500, 12200) + *PrintableOrigin: PAIR(450, 300) + *CursorOrigin: PAIR(200, 12900) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t7332x5880Y" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1692 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 600) + *CursorOrigin: PAIR(180, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t5880x8900Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 900) + *CursorOrigin: PAIR(180, 16500) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t8900x5880Y" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4109 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 11500) + *PrintableOrigin: PAIR(300, 300) + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t4860x7344Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8300, 11500) + *PrintableOrigin: PAIR(200, 300) + *CursorOrigin: PAIR(200, 12300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t7272x4980Y" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4249 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(288, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t5594x8201Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(204, 13824) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t8129x5714Y" + } + } + } + } + *Option: B5 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 3198 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(7900, 11140) + *PrintableOrigin: PAIR(352, 300) + *CursorOrigin: PAIR(300, 100) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t4970x7040Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(7760, 11140) + *PrintableOrigin: PAIR(300, 400) + *CursorOrigin: PAIR(100, 11940) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t6780x4970Y" + } + } + } + } +} + +*%****************************************************************************************** +*% Outputbin +*%****************************************************************************************** + + +*Feature: OutputBin +{ + *rcNameID: =OUTPUTBIN_DISPLAY + *HelpIndex: 12006 + *DefaultOption: Option1 + *Option: Option1 + { + *% Auto Select + *Name: "default" + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "@PJL SET OUTBIN=OPTIONALOUTBIN2<0A>@PJL SET FINISH=NONE<0A>" + } + } + *Option: Option14 + { + *% Stacker + *Name: "stacker" *% Stacker + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "@PJL SET OUTBIN=OPTIONALOUTBIN2<0A>@PJL SET FINISH=NONE<0A>" + } + } +} + + +*%****************************************************************************************** +*% Media Type +*%****************************************************************************************** +*Feature: MediaType +{ + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: PLAIN + *Option: PLAIN + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n6WdPlain" + } + } + *Option: TRANSPARENCY + { + *rcNameID: =TRANSPARENCY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n13WdTransparency" + } + } +} + + + +*%****************************************************************************************** +*% HalfTone +*%****************************************************************************************** +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} + +*%****************************************************************************************** +*% Memory +*% +*% Note: Unidrv uses the font memory information to estimate when it needs to stop +*% downloading fonts for a page, and thus driver writers should err on the conservative +*% side. Otherwise, printers will generate "out of memory" device errors for pages with +*% a large number of fonts / unique glyphs. +*%****************************************************************************************** +*Feature: Memory +{ + *rcNameID: =PRINTER_MEMORY_DISPLAY + *DefaultOption: 32768KB + *Option: 16384KB + { + *Name: "16MB" + *MemoryConfigKB: PAIR(16384, 13950) + } + *Option: 32768KB + { + *Name: "32MB" + *MemoryConfigKB: PAIR(32768, 28350) + } +} + +*%****************************************************************************************** +*% Page Protect +*%****************************************************************************************** +*Feature: PageProtect +{ + *rcNameID: =PAGE_PROTECTION_DISPLAY + *DefaultOption: OFF + *Option: ON + { + *rcNameID: =ON_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=LETTER<0A>" + } + } + *Option: OFF + { + *rcNameID: =OFF_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=OFF<0A>" + } + } +} + +*%****************************************************************************************** +*% Doc setup commands +*%****************************************************************************************** +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.7 + *Cmd: "<1B>&u1200D<1B>*r0F" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "<1B>*b0M<0D>" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "<1B>E<1B>%%-12345X@PJL<20>LPORTROTATE<0A><1B>%%-12345X" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.13 + *Cmd: "<1B>&l" %d{NumOfCopies}"X" +} + +*%****************************************************************************************** +*% Cursor, Page and Color Commands +*%****************************************************************************************** +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT, RASTER, VECTOR) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*Command: CmdXMoveAbsolute { *Cmd : "<1B>*p" %d{(DestX) }"X" } +*Command: CmdXMoveRelRight { *Cmd : "<1B>*p+" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdXMoveRelLeft { *Cmd : "<1B>*p-" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdYMoveAbsolute { *Cmd : "<1B>*p" %d{(DestY) }"Y" } +*Command: CmdYMoveRelDown { *Cmd : "<1B>*p+" %d{(DestYRel) }"Y" } +*Command: CmdYMoveRelUp { *Cmd : "<1B>*p-" %d{(DestYRel) }"Y" } +*Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } +*Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } +*Command: CmdCR { *Cmd : "<0D>" } +*Command: CmdLF { *Cmd : "<0A>" } +*Command: CmdFF { *Cmd : "<0C>" } +*Command: CmdBackSpace { *Cmd : "<08>" } +*Command: CmdUniDirectionOn { *Cmd : "<00>" } +*Command: CmdUniDirectionOff { *Cmd : "<00>" } +*Command: CmdPushCursor { *Cmd : "<1B>&f0S" } +*Command: CmdPopCursor { *Cmd : "<1B>&f1S" } +*Command: CmdSetSimpleRotation { *Cmd : "<1B>&a" %d{PrintDirInCCDegrees}"P" } +*EjectPageWithFF?: TRUE +*Command: CmdEnableTIFF4 { *Cmd : "<1B>*b2M" } +*Command: CmdDisableCompression { *Cmd : "<1B>*b0M" } +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*%****************************************************************************************** +*% Font Descriptions and Commands +*%****************************************************************************************** +*DefaultFont: 136 +*DefaultCTT: 0 +*CharPosition: BASELINE +*DeviceFonts: LIST(136,138,146,147,148,149,150,151,152,153,154,155,156,157, ++ 163,164,165,166,196,197,198,199,200,201,202,203,209,210, ++ 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, ++ 227,228,229,230) +*MinFontID: 16534 +*MaxFontID: 32768 +*FontFormat: HPPCL_OUTLINE +*Command: CmdSetFontID { *Cmd : "<1B>*c" %d{NextFontID}"D" } +*Command: CmdSelectFontID { *Cmd : "<1B>(" %d{CurrentFontID}"X" } +*Command: CmdSetCharCode { *Cmd : "<1B>*c" %d{NextGlyph}"E" } +*Command: CmdUnderlineOn { *Cmd : "<1B>&dD" } +*Command: CmdUnderlineOff { *Cmd : "<1B>&d@" } +*Command: CmdWhiteTextOn { *Cmd : "<1B>*v1o1T" } +*Command: CmdWhiteTextOff { *Cmd : "<1B>*v0o0T" } + + +*%******************************************************************************************** +*%* Vector Commands. +*%******************************************************************************************** +*MinGrayFill: 1 +*MaxGrayFill: 100 +*Command: CmdSetRectWidth { *Cmd : "<1B>*c" %d{(RectXSize) }"A" } +*Command: CmdSetRectHeight { *Cmd : "<1B>*c" %d{(RectYSize) }"B" } +*Command: CmdRectGrayFill { *Cmd : "<1B>*c" %d{GrayPercentage }"g2P" } +*Command: CmdRectWhiteFill { *Cmd : "<1B>*c1P" } +*Command: CmdRectBlackFill { *Cmd : "<1B>*c0P" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.inf b/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.inf new file mode 100644 index 00000000..c57b08b1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.inf @@ -0,0 +1,99 @@ + +; GDLSMPL.INF +; +; INF file for the GDL sample +; +; Copyright 1999 - 2006 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Provider=%FABRIKAM% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=01/01/2006,1.0.0.1 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Fabrikam"=Fabrikam,NTx86,NTamd64,NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Fabrikam.NTx86] +"GDL Sample" = GDLSMPL + +[Fabrikam.NTamd64] +"GDL Sample" = GDLSMPL + +[Fabrikam.NTia64] +"GDL Sample" = GDLSMPL + + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[GDLSMPL] +CopyFiles=@GDLSMPL.GPD +CopyFiles=@GDLSMPL.INI +CopyFiles=@GDLSMPL.DLL +DataFile=GDLSMPL.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,UNIDRV_DATA + + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMSample% + +[SourceDisksFiles.X86] +GDLSMPL.dll = 100,x86 + +[SourceDisksFiles.amd64] +GDLSMPL.dll = 100,amd64 + +[SourceDisksFiles.IA64] +GDLSMPL.dll = 100,ia64 + +[SourceDisksFiles] +GDLSMPL.GPD = 100 +GDLSMPL.INI = 100 + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +FABRIKAM="Fabrikam Print Driver (Microsoft DDK Sample)" +OEMSample="GDL Sample" + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.ini b/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.ini new file mode 100644 index 00000000..dd46570f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/res/gdlsmpl.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=GDLSMPL.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj new file mode 100644 index 00000000..8b4e5189 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj @@ -0,0 +1,1084 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D} + $(MSBuildProjectName) + Win10 Debug + Win32 + {54379D65-81DC-4846-87B8-91904DFAD95D} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + GDLSMPL + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(AdditionalIncludeDirectories) + + + %(AdditionalIncludeDirectories) + MultiThreaded + MultiThreadedDebug + + + %(AdditionalIncludeDirectories) + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib;msxml6.lib + GDLSMPL.def + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj.Filters new file mode 100644 index 00000000..6031427f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/GDLSMPL.vcxproj.Filters @@ -0,0 +1,134 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {AA9642FD-4376-4AA6-BEBD-F068AD5C8036} + + + h;hpp;hxx;hm;inl;inc;xsd + {C5C6C5CD-8656-4525-B00D-B1F5AEFAA986} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {7600E0E1-C09C-435F-9EE5-6AE7AF0E62AA} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.cpp new file mode 100644 index 00000000..0654e1b5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.cpp @@ -0,0 +1,251 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: devmode.cpp +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// +//-------------------------------------------------------------------------- + +#include "precomp.h" + +#include "debug.h" +#include "devmode.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +BOOL +ConvertOEMDevmode( + _In_ PCOEMDEV pOEMDevIn, + _Inout_ POEMDEV pOEMDevOut + ); + +BOOL +MakeOEMDevmodeValid( + _Out_ POEMDEV pOEMDevmode + ); + +//+--------------------------------------------------------------------------- +// +// Member: +// ::hrOEMDevMode +// +// Synopsis: +// Performs operation on UI Plugins Private DevMode Members. +// Called via IOemUI::DevMode +// +// Returns: +// S_OK or E_FAIL. For more detailed failure info, +// check GetLastError +// +// Last error: +// ERROR_INVALID_PARAMETER +// +// +//---------------------------------------------------------------------------- +HRESULT +hrOEMDevMode( + DWORD dwMode, + // Indicates which operation should be performed + _Inout_ POEMDMPARAM pOemDMParam + // contains various data structures needed by this + // routine. The usage of this struct is determined by + // the dwMode flag. + ) +{ + HRESULT hr = S_OK; + // Return value. + + // + // Verify parameters. + // + if ((NULL == pOemDMParam) || + ((OEMDM_SIZE != dwMode) && + (OEMDM_DEFAULT != dwMode) && + (OEMDM_CONVERT != dwMode) && + (OEMDM_MERGE != dwMode))) + { + ERR("DevMode() ERROR_INVALID_PARAMETER.\r\n"); + + SetLastError(ERROR_INVALID_PARAMETER); + hr = E_FAIL; + } + else + { + POEMDEV pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn;; + // Pointer to the supplied OEM devmode data, if applicable + // based on dwMode. + + POEMDEV pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut;; + // Pointer to the DEVMODE data that this routine is + // expected to configure, if applicable based on dwMode. + + switch (dwMode) + { + // + // The Method should return the size of the memory allocation + // needed to store the UI plugin Private DEVMODE. + // + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + // + //Should fill the Private DEVMODE with the default values. + // + case OEMDM_DEFAULT: + // + //OEM_DMEXTRAHEADER Members + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + break; + + // + // The method should convert private DEVMODE members to + // the current version, if necessary. + // + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + // + // The method should validate the information contained in private + // DEVMODE members and merge validated values into a private + // DEVMODE structure containing default values + // + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + } + + return hr; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::ConvertOEMDevmode +// +// Synopsis: +// confirm that the private DEVMODE being passed in is data that +// this driver recognizes, read the settings from the input +// OEM DEVMODE data, and write them to pOEMDevOut. +// +// Returns: +// True unless the routine was called with null pointers +// +// +//---------------------------------------------------------------------------- +BOOL +ConvertOEMDevmode( + _In_ PCOEMDEV pOEMDevIn, + // Caller supplied DEVMODE that we are attempting to read + _Inout_ POEMDEV pOEMDevOut + // OEM private DEVMODE configured by this routine based on the settings + // in pOEMDevIn + ) +{ + if ((NULL == pOEMDevIn) || + (NULL == pOEMDevOut)) + { + ERR("ConvertOEMDevmode() invalid parameters.\r\n"); + return FALSE; + } + + // + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + // + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + // + // Copy the old structure in to the new using which ever size is the + // smaller. Devmode maybe from newer Devmode (not likely since there + // is only one), or Devmode maybe a newer Devmode, in which case it + // maybe larger, but the first part of the structure should be the same. + // + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get + // added to the end. + // + memcpy(pOEMDevOut, + pOEMDevIn, + __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + + // + // If the plug-in is capable of recognizing multiple versions of it's + // private DEVMODE data add custom handling here to support it. + // + } + else + { + WARNING("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n"); + + // + // The private DEVMODE data is not something that this plug-in understands, + // so use defaults. + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + + return TRUE; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::MakeOEMDevmodeValid +// +// Synopsis: +// Force the OEM devmode settings to valid values. +// +// Returns: +// True if the OEMDEV was configured, else FALSE. Only return false if +// the parameter is NULL. +// +// +//---------------------------------------------------------------------------- +BOOL +MakeOEMDevmodeValid( + _Out_ POEMDEV pOEMDevmode + // OEM DEVMODE data to modify + ) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // + // Assumption: pOEMDevmode is large enough to contain OEMDEV structure. + // + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + return TRUE; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.h new file mode 100644 index 00000000..791b1a20 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/devmode.h @@ -0,0 +1,52 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: devmode.h +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +//-------------------------------------------------------------------------- + +#pragma once + +#define OEM_SIGNATURE 'GDLS' +#define OEM_VERSION 0x00000001L + +// +// OEM private DEVMODE data structure. This gets included in the DEVMODE +// used by Unidrv. +// +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + // This structure MUST be prefixed by OEM_DMEXTRAHEADER + + // + // Add private DevMode members here, after the standard header + // information. + // + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + +// +// Prototypes +// + +HRESULT +hrOEMDevMode( + DWORD dwMode, + _Inout_ POEMDMPARAM pOemDMParam + ); + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.cpp b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.cpp new file mode 100644 index 00000000..6d8fd195 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.cpp @@ -0,0 +1,856 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: gdlsmpl.cpp +// +// PURPOSE: Implementation of interface for Unidrv5 UI plug-ins. +// +//-------------------------------------------------------------------------- + +#include "precomp.h" + +#include "debug.h" +#include "devmode.h" +#include "intrface.h" +#include "gdlsmpl.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//-------------------------------------------------------------------------- +// Globals +//-------------------------------------------------------------------------- + +HINSTANCE ghInstance = NULL; + // Module's Instance handle from DLLEntry of process. + + +//-------------------------------------------------------------------------- +// Internal Globals +//-------------------------------------------------------------------------- + +static long g_cComponents = 0; + // Count of active components + +static long g_cServerLocks = 0; + // Count of locks + + +//-------------------------------------------------------------------------- +// Local helper functions +//-------------------------------------------------------------------------- +BOOL __stdcall +DebugPrint( + LPCWSTR pszMessage, + // Format string for the error message + ... + // args specified in the format string. + ) +{ + va_list arglist; + // varargs list for processing the '...' parameter. + + WCHAR szMsgBuf[MAX_PATH] = {0}; + // Use a stack error buffer so that we don't need to + // allocate in the failure path. + + HRESULT hResult; + // Result from formatting the string. + + if (NULL == pszMessage) + { + return FALSE; + } + + // Pass the variable parameters to wvsprintf to be formated. + va_start(arglist, pszMessage); + hResult = StringCbVPrintfW(szMsgBuf, MAX_PATH*sizeof(szMsgBuf[0]), pszMessage, arglist); + va_end(arglist); + + // Dump string to debug output. + OutputDebugStringW(szMsgBuf); + + return SUCCEEDED(hResult); +} + + +//-------------------------------------------------------------------------- +// Class factory for the Plug-In object +//-------------------------------------------------------------------------- +class COemCF : public IClassFactory +{ +public: + + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ + REFIID riid, + LPVOID FAR* ppvObj + ); + + STDMETHOD_(ULONG,AddRef) (THIS); + + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // IClassFactory methods + STDMETHOD(CreateInstance) (THIS_ + _In_opt_ LPUNKNOWN pUnkOuter, + _In_ REFIID riid, + _Outptr_ LPVOID FAR* ppvObject + ); + + STDMETHOD(LockServer) (THIS_ + BOOL bLock + ); + + // Class-specific methods. + COemCF(): m_cRef(1) { }; + + ~COemCF() { }; + +protected: + LONG m_cRef; + +}; + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::DllMain +// +// Synopsis: +// Dll's main routine, called when new +// threads or processes reference the module +// +// Returns: +// TRUE. Currently has no failure paths. Return false if the module +// cannot be properly initialized. +// +// Notes: +// the caller of this routine holds a process-wide lock preventing more +// than one module from being initialized at a time. In general, +// plug-ins should do as little as possible in this routine to avoid +// stalling other threads that may need to load modules. Also, calling +// any function that would, in-turn, cause another module to be loaded +// could result in a deadlock. +// +// +//---------------------------------------------------------------------------- +extern "C" BOOL +WINAPI DllMain( + HINSTANCE hInst, + WORD wReason, + LPVOID lpReserved + ) +{ + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_PROCESS_DETACH: + break; + + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// ::DllCanUnloadNow +// +// Synopsis: +// Can the DLL be unloaded from memory? Answers no if any objects are +// still allocated, or if the server has been locked. +// +// To avoid leaving OEM DLL still in memory when Unidrv or Pscript +// drivers are unloaded, Unidrv and Pscript driver ignore the return +// value of DllCanUnloadNow of the OEM DLL, and always call FreeLibrary +// on the OEMDLL. +// +// If the plug-in spins off a working thread that also uses this DLL, +// the thread needs to call LoadLibrary and FreeLibraryAndExitThread, +// otherwise it may crash after Unidrv or Pscript calls FreeLibrary. +// +// Returns: +// S_OK if the DLL can be unloaded safely, otherwise S_FALSE +// +// +//---------------------------------------------------------------------------- +STDAPI DllCanUnloadNow() +{ + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::DllGetClassObject +// +// Synopsis: +// Retrieve the class factory object for the indicated class. +// +// Returns: +// CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, or S_OK. +// +// Notes: +// +// +//---------------------------------------------------------------------------- +STDAPI +DllGetClassObject( + _In_ CONST CLSID& clsid, + // GUID of the class object that the caller wants a class factory for + _In_ CONST IID& iid, + // Interface ID to provide in ppv + _Outptr_ VOID** ppv + // out pointer to the interface requested. + ) +{ + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // + // Can we create this component? + // + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + // + // Create class factory. + // Reference count set to 1 in Constructor + // + COemCF* pGDLSampleClassFactory = new COemCF; + if (pGDLSampleClassFactory == NULL) + { + return E_OUTOFMEMORY; + } + + // + // Get requested interface. + // + HRESULT hr = pGDLSampleClassFactory->QueryInterface(iid, ppv); + pGDLSampleClassFactory->Release(); + + return hr; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::QueryInterface +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemCF::QueryInterface( + CONST IID& iid, + VOID** ppv + ) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::AddRef +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +ULONG __stdcall +COemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::Release +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +COemCF::Release() +{ + assert(0 != m_cRef); + + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + } + return cRef; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::CreateInstance +// +// Synopsis: +// Attempt to create an object that implements the specified interface. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemCF::CreateInstance( + _In_opt_ IUnknown* pUnknownOuter, + _In_ CONST IID& iid, + _Outptr_ VOID** ppv + ) +{ + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // + // Cannot aggregate. + // + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + HRESULT hr = S_OK; + + if (iid == IID_IUnknown || + iid == IID_IPrintOemUI2) + { + // + // Create component. + // + COemUI2* pOemCB = new COemUI2; + if (pOemCB == NULL) + { + hr = E_OUTOFMEMORY; + } + else + { + // + // Get the requested interface. + // + hr = pOemCB->QueryInterface(iid, ppv); + + // + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + // + pOemCB->Release(); + } + } + else + { + hr = E_NOINTERFACE; + } + + return hr; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::LockServer +// +// Synopsis: +// Locking the server holds the objects server in memory, so that new +// instances of objects can be created more quickly. +// +// Returns: +// S_OK +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemCF::LockServer( + BOOL bLock + // If true, increment the lock count, otherwise decrement the lock + // count. + ) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + + return S_OK; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2 (destructor) +// +// Synopsis: +// Release the helper interface, as well as any other resources that +// the plug-in is holding onto. +// +// Returns: +// +// Notes: +// +// +//---------------------------------------------------------------------------- +COemUI2::~COemUI2() +{ + // + // Make sure that helper interface is released. + // + if(NULL != m_pCoreHelper) + { + m_pCoreHelper->Release(); + m_pCoreHelper = NULL; + } + + // + // If this instance of the object is being deleted, then the reference + // count should be zero. + // + assert(0 == m_cRef); +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::PublishDriverInterface +// +// Synopsis: +// This routine is called by the core driver to supply objects to the +// plug-in which the plug-in can use to implement various features. +// +// This implementation requires an object that IPrintCoreHelper interface +// from the core driver to implement full UI replacement. If the object +// passed in is the one desired, this routine will return S_OK, otherwise +// it will return E_FAIL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::PublishDriverInterface( + IUnknown *pIUnknown + ) +{ + HRESULT hr = S_OK; + + // + // Save a pointer to the IPrintCoreHelperUni interface. This will allow + // the plug-in to access it's GDL file (which can be it's GPD file as well) + // + if (m_pCoreHelper == NULL) + { + hr = pIUnknown->QueryInterface(IID_IPrintCoreHelperUni, (VOID**) &(m_pCoreHelper)); + + if (!SUCCEEDED(hr)) + { + m_pCoreHelper = NULL; + hr = E_FAIL; + } + } + + return hr; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::GetInfo +// +// Synopsis: +// Most of this routine is a standard implementation common to most +// plug-ins. Of particular note in this sample is that to get a handle +// the IPrintCoreHelper plug-in in the PublishDriverInterface callback, +// this routine must return OEMPUBLISH_IPRINTCOREHELPER in the out +// parameter when the mode is OEMGI_GETREQUESTEDHELPERINTERFACES. +// +// Returns: +// S_OK for supported modes, E_FAIL for everything else. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::GetInfo( + DWORD dwMode, + // The mode indicates what information is being requested by the + // core driver. + _Out_writes_bytes_(cbSize) PVOID pBuffer, + // The output buffer is the location into which the requested info + // should be written + DWORD cbSize, + // The size of the output buffer. + PDWORD pcbNeeded + // If the size of the buffer is insufficient, use this parameter + // to indicate to the core driver how much space is required. + ) +{ + HRESULT hrResult = S_OK; + + // + // Validate parameters. OEMGI_GETPUBLISHERINFO is excluded from this + // list because that GetInfo mode applies only to PScript rendering plug-ins. + // + if ((NULL == pcbNeeded) || + ((OEMGI_GETSIGNATURE != dwMode) && + (OEMGI_GETVERSION != dwMode) && + (OEMGI_GETREQUESTEDHELPERINTERFACES != dwMode))) + { + WARNING("COemUI2::GetInfo() exit pcbNeeded is NULL or mode is not supported\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // + // Set expected buffer size and number of bytes written. + // + *pcbNeeded = sizeof(DWORD); + + // + // Check buffer size is sufficient. + // + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING("COemUI2::GetInfo() exit insufficient buffer!\r\n"); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + hrResult = E_FAIL; + } + else + { + switch(dwMode) + { + // + // OEM DLL Signature + // + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // + // OEM DLL version + // + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // + // The UI is asking whether the plug-in uses the IPrintCoreHelper based + // helper object. Indicate that the plug-in does need this object. + // + case OEMGI_GETREQUESTEDHELPERINTERFACES: + *(PDWORD)pBuffer = 0; + *(PDWORD)pBuffer |= OEMPUBLISH_IPRINTCOREHELPER; + break; + + // + // dwMode not supported. + // + default: + // + // Set written bytes to zero since nothing was written. + // + WARNING("COemUI2::GetInfo() exit mode not supported.\r\n"); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + hrResult = E_FAIL; + } + } + + return hrResult; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DevMode +// +// Synopsis: +// This routine operates in various modes to manage the private DEVMODE. +// This sample does not provide much by way of illustration of how to +// handle OEM settings in the private DEVMODE. See the sample OEMUI for +// a more in-depth look at this routine. The function hrOEMDevMode in +// devmode.cpp also provides more information on how to handle the various +// modes. +// +// Returns: +// S_OK on success, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DevMode( + DWORD dwMode, + // The operation that should be performed + POEMDMPARAM pOemDMParam + // The input & output DEVMODEs, including pointers to the public & + // private DEVMODE data. + ) +{ + return hrOEMDevMode(dwMode, pOemDMParam); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DocumentPropertySheets +// +// Synopsis: +// Show the GPD version in the debugger whenever the +// printing preferences UI is shown. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ) +{ + UNREFERENCED_PARAMETER(pPSUIInfo); + UNREFERENCED_PARAMETER(lParam); + + this->DbgShowGPDVersion(); + + return S_OK; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DbgShowGPDVersion +// +// Synopsis: +// Display the GPD version in the debugger using a GDL snapshot & MSXML 6 +// To make this work on versions of Windows prior to Windows Vista, change +// references to MSXML 6 with MSXML 3. +// +// +//---------------------------------------------------------------------------- +HRESULT +COemUI2::DbgShowGPDVersion() +{ + HRESULT hr; + IXMLDOMDocument2 *pDOMSnapshot = NULL; + IXMLDOMNode *pVersionNode = NULL; + + // + // Get a DOM representation of the snapshot using MSXML 3 + // + hr = LoadGDLSnapshot(&pDOMSnapshot); + + if (hr == REGDB_E_CLASSNOTREG) + { + DebugPrint(L"COemUI2::PublishHelperInterface: MSXML 6.0 not registered, GDL version lookup disabled\r\n"); + } + + // + // Find the GDL node that contains the GPDFileVersion. This should return a single XML DOM Element. + // + if (SUCCEEDED(hr)) + { + hr = pDOMSnapshot->selectSingleNode((BSTR)TEXT("//gdl:SnapshotRoot/gdl:GDL_ATTRIBUTE[@Name=\"*GPDFileVersion\"]"), &pVersionNode); + } + + // + // If the node was found, write the version information to the debugger. + // It's content is represented as CDATA in the XML, but MSXML will + // normalize that to a regular string when it parses the XML. + // + if (SUCCEEDED(hr) && pVersionNode) + { + VARIANT varVersionString; + + // + // Get DefaultOption name + // + hr = pVersionNode->get_nodeTypedValue(&varVersionString); + + if (SUCCEEDED(hr)) + { + DebugPrint(L"COemUI2::PublishHelperInterface: GDL Version: %s\r\n", varVersionString.bstrVal); + } + + VariantClear(&varVersionString); + } + + if (pDOMSnapshot) + { + pDOMSnapshot->Release(); + pDOMSnapshot = NULL; + } + + return hr; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::LoadGDLSnapshot +// +// Synopsis: +// Load the GDL snapshot from IPrintCoreHelperUni into a DOM object, +// and set appropriate properties on the DOM to prepare it for use +// with xpath queries. +// +// +//---------------------------------------------------------------------------- +HRESULT +COemUI2::LoadGDLSnapshot( + _Out_ IXMLDOMDocument2 **ppDOMSnapshot + ) +{ + HRESULT hr = S_OK; + IStream *pSnapshotStream = NULL; + VARIANT_BOOL loadResult = 0; + + if (!ppDOMSnapshot) + { + return E_INVALIDARG; + } + + (*ppDOMSnapshot) = NULL; + + hr = m_pCoreHelper->CreateDefaultGDLSnapshot(0, &pSnapshotStream); + + if (SUCCEEDED(hr)) + { + // + // Create DOM document + // + hr = m_pCoreHelper->CreateInstanceOfMSXMLObject(CLSID_DOMDocument60, + NULL, + CLSCTX_INPROC_SERVER, + IID_IXMLDOMDocument2, + (LPVOID *)ppDOMSnapshot); + } + + if (SUCCEEDED(hr)) + { + VARIANT streamVar; + + VariantInit(&streamVar); + V_VT(&streamVar) = VT_UNKNOWN; + V_UNKNOWN(&streamVar) = pSnapshotStream; + pSnapshotStream->AddRef(); + + // + // Load the snapshot into the DOM document + // + (*ppDOMSnapshot)->put_async(VARIANT_FALSE); + (*ppDOMSnapshot)->put_validateOnParse(VARIANT_FALSE); + (*ppDOMSnapshot)->put_resolveExternals(VARIANT_FALSE); + + hr = (*ppDOMSnapshot)->load(streamVar, &loadResult); + + VariantClear(&streamVar); + } + + // + // If the DOM fails to load, the HRESULT will be S_FALSE, so explicitly + // look for S_OK. + // + if (hr == S_OK) + { + // + // Set the namespaces that should be available for xpath queries later. + // + BSTR bstrDefNameSpace = SysAllocString(TEXT("xmlns:gdl=\"http://schemas.microsoft.com/2002/print/gdl/1.0\"")); + + if (!bstrDefNameSpace) + { + hr = E_OUTOFMEMORY; + } + + if (SUCCEEDED(hr)) + { + VARIANT varDefNameSpace; + + VariantInit(&varDefNameSpace); + varDefNameSpace.vt = VT_BSTR; + varDefNameSpace.bstrVal = bstrDefNameSpace; + + hr = (*ppDOMSnapshot)->setProperty((BSTR)TEXT("SelectionNamespaces"), varDefNameSpace); + SysFreeString(bstrDefNameSpace); + } + } + else + { + hr = E_FAIL; + } + + if (FAILED(hr) && *ppDOMSnapshot) + { + (*ppDOMSnapshot)->Release(); + (*ppDOMSnapshot) = NULL; + } + + if (pSnapshotStream) + { + pSnapshotStream->Release(); + pSnapshotStream = NULL; + } + + return hr; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.def b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.def new file mode 100644 index 00000000..d9534de1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.def @@ -0,0 +1,18 @@ +; +; 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. +; +; Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +; +; Abstract: +; +; This file contains a listing of all of the methods to be exported +; from the DLL, as well as rules for how to name the exports. +; + +LIBRARY GDLSMPL + +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.h b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.h new file mode 100644 index 00000000..77ba7647 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.h @@ -0,0 +1,79 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: gdlsmpl.h +// +// PURPOSE: COM implementation of a UI module that uses GDL. CAbstractOemUI2 +// is defined in intrface.h, and contains a default implementation of +// all optional interface methods. +// +//-------------------------------------------------------------------------- + +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +extern HINSTANCE ghInstance; + // Module's Instance handle from DLLEntry of process. + +class COemUI2: public CAbstractOemUI2 +{ +public: + + COemUI2() : + m_pCoreHelper(NULL) + {} + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + STDMETHOD(GetInfo) (THIS_ + DWORD dwMode, + _Out_writes_bytes_(cbSize) PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam); + + // + // OEMDocumentPropertySheets + // + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + virtual ~COemUI2(); + +protected: + + HRESULT + DbgShowGPDVersion(); + + HRESULT + LoadGDLSnapshot( + _Out_ IXMLDOMDocument2 **ppDOMSnapshot + ); + + IPrintCoreHelperUni* m_pCoreHelper; + // Pointer to the helper interface introduced in Windows Vista. +}; + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.rc b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.rc new file mode 100644 index 00000000..5cd078df --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/gdlsmpl.rc @@ -0,0 +1,106 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: gdlsmpl.rc +// +// PURPOSE: Resource script containing all localizable strings for this +// module +// +//-------------------------------------------------------------------------- + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Developed by Microsoft Corp." + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "GDL Sample Printer UI Module" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "GDLSMPL" + VALUE "LegalCopyright", "Copyright © 1998 - 2006 Microsoft Corp." + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "GDLSMPL.dll" + VALUE "ProductName", "Microsoft GDL Sample Driver" + VALUE "ProductVersion", "1.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.cpp new file mode 100644 index 00000000..d399712d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.cpp @@ -0,0 +1,559 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// PURPOSE: Generic abstract base class useful for creating implementation +// of interface for Unidrv5 UI plug-ins. This base class +// implements all methods which have a standard implementation +// and / or are optional. Non-optional mathods are pure virtual +// in this base class. +// +//-------------------------------------------------------------------------- + +#include "precomp.h" + +#include "debug.h" +#include "devmode.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::QueryInterface +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::QueryInterface( + CONST IID& iid, + VOID** ppv + ) +{ + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + } + else if (iid == IID_IPrintOemUI2) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::AddRef +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +ULONG __stdcall +CAbstractOemUI2::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::Release +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +CAbstractOemUI2::Release() +{ + ASSERT(0 != m_cRef); + + ULONG cRef = InterlockedDecrement(&m_cRef); + + if (0 == cRef) + { + delete this; + return 0; + + } + + return cRef; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::HideStandardUI +// +// Synopsis: +// This routine is critical to supporting full UI replacement. This +// routine allows the plug-in to disable Unidrv's (or PScript's) standard +// UI panels. If this returns E_NOTIMPL, the panel isn't hidden. If +// this routine returns S_OK, Unidrv will not display any UI for the +// specified mode. If this returns E_NOTIMPL, Unidrv will display it's +// standard UI. +// +// Returns: +// S_OK to hide the indicated UI if desired, otherwise E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::HideStandardUI( + DWORD dwMode + // document property sheets, printer property sheets, or possibly + // something not yet defined. + ) +{ + UNREFERENCED_PARAMETER(dwMode); + + return E_NOTIMPL; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::DocumentPropertySheets +// +// Synopsis: +// A plug-in may optionally add property sheets. If the plug-in has +// chosen to hide the standard UI, then it would instead provide +// replacements for the standard property sheets. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ) +{ + UNREFERENCED_PARAMETER(pPSUIInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::DevicePropertySheets +// +// Synopsis: +// A plug-in may optionally add property sheets. If the plug-in has +// chosen to hide the standard UI, then it would instead provide +// replacements for the standard property sheets. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ) +{ + UNREFERENCED_PARAMETER(pPSUIInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::CommonUIProp +// +// Synopsis: +// This routine is used to interact with the Unidrv-supplied +// property sheet pages. Since this plug-in implements full-UI +// replacement, those property sheet pages are disabled, and this +// routine does not need to do anything. +// +// Returns: +// S_OK +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ) +{ + UNREFERENCED_PARAMETER(dwMode); + UNREFERENCED_PARAMETER(pOemCUIPParam); + + return E_NOTIMPL; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::DeviceCapabilities +// +// Synopsis: +// This routine can be used to replace the Unidrv's device capabilities +// handling. In this implementation, no custom capabilities handling is +// provided. +// +// Returns: +// E_FAIL +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::DeviceCapabilities( + _Inout_ POEMUIOBJ poemuiobj, + // OEM settings & information + _In_ HANDLE hPrinter, + // Handle to the printer that the capabilities are being requested for + _In_ PWSTR pDeviceName, + // Name of the device / driver + WORD wCapability, + // The DC_ ID indicating which capability was requested. + _Out_ PVOID pOutput, + // Buffer to write requested information to. + _In_ PDEVMODE pPublicDM, + // Pointer to the public DEVMODE representing the settings to get + // capabilities with respect to. + _In_ PVOID pOEMDM, + // OEM private DEVMODE settings. + DWORD dwOld, + // Result from previous plug-in call to this routine. + _Out_ DWORD *dwResult + // Result of this call. If there are multiple UI plug-ins, this + // result is passed to the next one as dwOld + ) +{ + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + // + // Do nothing. Let Unidrv handle the device capabilities processing. + // + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::DevQueryPrintEx +// +// Synopsis: +// This routine is used to determine print job compatibility with the +// current driver. The plug-in can supplement Unidrv's handling of this +// routine. If Unidrv determines that a job can be printed on the current +// printer it will call this routine to ask the plug-in whether it can +// also handle the current job. If Unidrv determines that the job cannot +// be printed, it will not call the plug-in. Additionally, XPS drivers +// built on the Unidrv and PScript UI modules may not recieve this call- +// back. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ) +{ + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::UpgradePrinter +// +// Synopsis: +// Use this callback to upgrade any settings from previous versions +// that are stored in the registry by the plug-in Not applicabe to +// this sample. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ) +{ + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::PrinterEvent +// +// Synopsis: +// Perform any special processing needed when various events occur to the +// print queue. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ) +{ + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::DriverEvent +// +// Synopsis: +// Notifies the plug-in of changes or events relevant to the driver, +// such as installing and upgrading. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ) +{ + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::QueryColorProfile +// +// Synopsis: +// This routine can be implemented to provide a color profile from the +// driver. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData + ) +{ + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(ulQueryMode); + UNREFERENCED_PARAMETER(pvProfileData); + UNREFERENCED_PARAMETER(pcbProfileData); + UNREFERENCED_PARAMETER(pflProfileData); + + return E_NOTIMPL; +}; + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::FontInstallerDlgProc +// +// Synopsis: +// Plug-ins can use this method to replace Unidrv's provided soft-font +// installer dialog. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ) +{ + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::UpdateExternalFonts +// +// Synopsis: +// This routine is used to notify the UI of any changes to installed +// font cartridges, primarily for supporting soft-font UI replacement. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::UpdateExternalFonts( + _In_ HANDLE hPrinter, + _In_ HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ) +{ + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::QueryJobAttributes +// +// Synopsis: +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::QueryJobAttributes( + HANDLE hPrinter, + PDEVMODE pDevmode, + DWORD dwLevel, + LPBYTE lpAttributeInfo + ) +{ + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDevmode); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(lpAttributeInfo); + + return E_NOTIMPL; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CAbstractOemUI2::DocumentEvent +// +// Synopsis: +// Perform any special processing needed at various points in time while +// a job is printing. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +CAbstractOemUI2::DocumentEvent( + HANDLE hPrinter, + HDC hdc, + INT iEsc, + ULONG cbIn, + PVOID pbIn, + ULONG cbOut, + PVOID pbOut, + PINT piResult + ) +{ + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hdc); + UNREFERENCED_PARAMETER(iEsc); + UNREFERENCED_PARAMETER(cbIn); + UNREFERENCED_PARAMETER(pbIn); + UNREFERENCED_PARAMETER(cbOut); + UNREFERENCED_PARAMETER(pbOut); + UNREFERENCED_PARAMETER(piResult); + + return E_NOTIMPL; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.h new file mode 100644 index 00000000..07e1175c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/intrface.h @@ -0,0 +1,212 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.h +// +// PURPOSE: Defines a class with default implementations of the UI +// interface plug=-in methods that are optional. +// +//-------------------------------------------------------------------------- + +#pragma once + +class CAbstractOemUI2: public IPrintOemUI2 +{ +public: + // + // *** IUnknown methods *** + // + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown) = 0; + + // + // Get OEM dll related information + // + STDMETHOD(GetInfo) (THIS_ + DWORD dwMode, + _Out_writes_bytes_(cbSize) PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) = 0; + + // + // OEMDevMode + // + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) = 0; + + // + // OEMCommonUIProp + // + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + STDMETHOD(DeviceCapabilities) (THIS_ + _Inout_ POEMUIOBJ poemuiobj, + _In_ HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + _Out_ PVOID pOutput, + _In_ PDEVMODE pPublicDM, + _In_ PVOID pOEMDM, + DWORD dwOld, + _Out_ DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + STDMETHOD( QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + STDMETHOD(UpdateExternalFonts) (THIS_ + _In_ HANDLE hPrinter, + _In_ HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + // + // IPrintOemUI2 methods + // + + // + // QueryJobAttributes + // + STDMETHOD(QueryJobAttributes) (THIS_ + HANDLE hPrinter, + PDEVMODE pDevmode, + DWORD dwLevel, + LPBYTE lpAttributeInfo + ); + + // + // Hide Standard UI + // + STDMETHOD(HideStandardUI) (THIS_ + DWORD dwMode + ); + + // + // DocumentEvent + // + STDMETHOD(DocumentEvent) (THIS_ + HANDLE hPrinter, + HDC hdc, + INT iEsc, + ULONG cbIn, + PVOID pbIn, + ULONG cbOut, + PVOID pbOut, + PINT piResult + ); + + CAbstractOemUI2() + { + m_cRef = 1; + }; + + virtual ~CAbstractOemUI2() {}; + +protected: + + LONG m_cRef; + // reference count of this object + +}; + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precomp.h new file mode 100644 index 00000000..0533325f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precomp.h @@ -0,0 +1,62 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2006 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.h +// +// PURPOSE: Header files that should be in the precompiled header. +// +//-------------------------------------------------------------------------- + +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// +// These files should always be last in your include list. +// +#include +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/gdl/src/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oem.gpd b/print/OEM Printer Customization Plug-in Samples/C++/oem.gpd new file mode 100644 index 00000000..2621cbb1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oem.gpd @@ -0,0 +1,704 @@ +*GPDFileName: "oem.gpd" +*GPDFileVersion: "1.0" +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*Include: "ttfsub.gpd" +*ModelName: "OEM Unidrv Customization Sample" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 +*PrintRate: 16 +*PrintRateUnit: PPM +*PrintRatePPM: 16 + +*%****************************************************************************************** +*% Orientation +*%****************************************************************************************** +*Feature: Orientation +{ + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l0O" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.8 + *Cmd: "<1B>&l1O" + } + } +} + +*%****************************************************************************************** +*% Input Bin +*%****************************************************************************************** +*Feature: InputBin +{ + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: AUTO + *Option: AUTO + { + *rcNameID: =AUTO_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l0H" + } + } + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l1H" + } + } +} + +*%****************************************************************************************** +*% Resolution +*%****************************************************************************************** +*Feature: Resolution +{ + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: Option2 + *Option: Option1 + { + *Name: "600 x 600" =DOTS_PER_INCH + *DPI: PAIR(600, 600) + *TextDPI: PAIR(600, 600) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=600<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t600R" + } + } + *Option: Option2 + { + *Name: "300 x 300" =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=300<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } + *Option: Option3 + { + *Name: "150 x 150" =DOTS_PER_INCH + *DPI: PAIR(150, 150) + *TextDPI: PAIR(150, 150) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=150<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t150R" + } + } +} + +*%****************************************************************************************** +*% HP-GL/2 Graphics Support +*%****************************************************************************************** +*Ifdef: WINNT_51 +*Personality: =PERSONALITY_HPGL2 +*Feature: GraphicsMode +{ + *rcNameID: =GRAPHICSMODE_DISPLAY + *DefaultOption: RASTERMODE + *Option: HPGL2MODE + { + *rcNameID: =GRAPHICSMODE_HPGL2_DISPLAY + } + *Option: RASTERMODE + { + *rcNameID: =GRAPHICSMODE_RASTER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "@PJL SET LIMAGEENHANCE=OFF<0A>" + } + } +} +*Endif: + +*%****************************************************************************************** +*% Paper Size +*%****************************************************************************************** +*Feature: PaperSize +{ + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1028 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9500, 12500) + *PrintableOrigin: PAIR(400, 400) + *CursorOrigin: PAIR(300, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t5260x7704Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9500, 12200) + *PrintableOrigin: PAIR(450, 300) + *CursorOrigin: PAIR(200, 12900) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t7332x5880Y" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1692 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 600) + *CursorOrigin: PAIR(180, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t5880x8900Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 900) + *CursorOrigin: PAIR(180, 16500) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t8900x5880Y" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4109 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 11500) + *PrintableOrigin: PAIR(300, 300) + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t4860x7344Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8300, 11500) + *PrintableOrigin: PAIR(200, 300) + *CursorOrigin: PAIR(200, 12300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t7272x4980Y" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4249 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(288, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t5594x8201Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(204, 13824) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t8129x5714Y" + } + } + } + } + *Option: B5 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 3198 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(7900, 11140) + *PrintableOrigin: PAIR(352, 300) + *CursorOrigin: PAIR(300, 100) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t4970x7040Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(7760, 11140) + *PrintableOrigin: PAIR(300, 400) + *CursorOrigin: PAIR(100, 11940) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t6780x4970Y" + } + } + } + } +} + +*%****************************************************************************************** +*% Media Type +*%****************************************************************************************** +*Feature: MediaType +{ + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: PLAIN + *Option: PLAIN + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n6WdPlain" + } + } + *Option: TRANSPARENCY + { + *rcNameID: =TRANSPARENCY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n13WdTransparency" + } + } +} + +*%****************************************************************************************** +*% Color Mode +*%****************************************************************************************** +*Feature: ColorMode +{ + *rcNameID: =COLOR_PRINTING_MODE_DISPLAY + *DefaultOption: 24bpp + *Option: Mono + { + *rcNameID: =MONO_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 1 + *Color?: FALSE + } + *Option: Color + { + *rcNameID: =COLOR_DISPLAY + *DevNumOfPlanes: 3 + *DevBPP: 1 + *DrvBPP: 4 + EXTERN_GLOBAL: *RasterSendAllData?: TRUE + *ColorPlaneOrder: LIST(CYAN, MAGENTA, YELLOW) + *Command: CmdSendCyanData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"V" } + *Command: CmdSendMagentaData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"V" } + *Command: CmdSendYellowData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelectBlackColor { *Cmd : "<1B>*v7S" } + *Command: CmdSelectRedColor { *Cmd : "<1B>*v6S" } + *Command: CmdSelectGreenColor { *Cmd : "<1B>*v5S" } + *Command: CmdSelectYellowColor { *Cmd : "<1B>*v4S" } + *Command: CmdSelectBlueColor { *Cmd : "<1B>*v3S" } + *Command: CmdSelectMagentaColor { *Cmd : "<1B>*v2S" } + *Command: CmdSelectCyanColor { *Cmd : "<1B>*v1S" } + *Command: CmdSelectWhiteColor { *Cmd : "<1B>*v0S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*r-3U" + } + } + *Option: 8bpp + { + *rcNameID: =8BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 8 + *DrvBPP: 8 + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*t0I<1B>*l184O<1B>*v6W<000108080808>" + } + } + *Option: 24bpp + { + *rcNameID: =24BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 24 + *DrvBPP: 24 + *Command: CmdEnableDRC { *Cmd : "<1B>*b3M" } + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSetSrcBmpWidth { *Cmd : "<1B>*r" %d{RasterDataWidthInBytes / 3}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*l184O<1B>*v6W<0003080808081B>*v0a0b0c7i255a255b255c0I<1B>*" ++ "o3W<060400>" + } + } +} + +*%****************************************************************************************** +*% HalfTone +*%****************************************************************************************** +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} + +*%****************************************************************************************** +*% Memory +*% +*% Note: Unidrv uses the font memory information to estimate when it needs to stop +*% downloading fonts for a page, and thus driver writers should err on the conservative +*% side. Otherwise, printers will generate "out of memory" device errors for pages with +*% a large number of fonts / unique glyphs. +*%****************************************************************************************** +*Feature: Memory +{ + *rcNameID: =PRINTER_MEMORY_DISPLAY + *DefaultOption: 32768KB + *Option: 4096KB + { + *Name: "4MB" + *MemoryConfigKB: PAIR(4096, 6750) + } + *Option: 8192KB + { + *Name: "8MB" + *MemoryConfigKB: PAIR(8192, 10350) + } + *Option: 16384KB + { + *Name: "16MB" + *MemoryConfigKB: PAIR(16384, 13950) + } + *Option: 24576KB + { + *Name: "24MB" + *MemoryConfigKB: PAIR(24576, 21150) + } + *Option: 32768KB + { + *Name: "32MB" + *MemoryConfigKB: PAIR(32768, 28350) + } + *Option: 49152KB + { + *Name: "48MB" + *MemoryConfigKB: PAIR(49152, 43050) + } + *Option: 65536KB + { + *Name: "64MB" + *MemoryConfigKB: PAIR(65536, 57150) + } + *Option: 98304KB + { + *Name: "96MB" + *MemoryConfigKB: PAIR(98304, 85950) + } + *Option: 102400KB + { + *Name: "100MB" + *MemoryConfigKB: PAIR(102400, 89700) + } + *Option: 114688KB + { + *Name: "112MB" + *MemoryConfigKB: PAIR(114688, 100550) + } + *Option: 131072KB + { + *Name: "128MB" + *MemoryConfigKB: PAIR(131072, 116250) + } +} + +*%****************************************************************************************** +*% Duplex Unit +*%****************************************************************************************** +*Feature: DuplexUnit +{ + *rcNameID: 429 + *FeatureType: PRINTER_PROPERTY + *DefaultOption: FALSE + *Option: FALSE + { + *rcNameID: 444 + *DisabledFeatures: LIST(Duplex.VERTICAL, Duplex.HORIZONTAL) + } + *Option: TRUE + { + *rcNameID: 443 + } +} + +*%****************************************************************************************** +*% Duplex Type +*%****************************************************************************************** +*Feature: Duplex +{ + *rcNameID: =TWO_SIDED_PRINTING_DISPLAY + *DefaultOption: NONE + *Option: NONE + { + *rcNameID: =NONE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l0S" + } + } + *Option: VERTICAL + { + *rcNameID: =FLIP_ON_LONG_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l1S" + } + } + *Option: HORIZONTAL + { + *rcNameID: =FLIP_ON_SHORT_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l2S" + } + } +} + +*%****************************************************************************************** +*% Page Protect +*%****************************************************************************************** +*Feature: PageProtect +{ + *rcNameID: =PAGE_PROTECTION_DISPLAY + *DefaultOption: OFF + *Option: ON + { + *rcNameID: =ON_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=LETTER<0A>" + } + } + *Option: OFF + { + *rcNameID: =OFF_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=OFF<0A>" + } + } +} + +*%****************************************************************************************** +*% Doc setup commands +*%****************************************************************************************** +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.7 + *Cmd: "<1B>&u1200D<1B>*r0F" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "<1B>*b0M<0D>" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "<1B>E<1B>%%-12345X@PJL<20>LPORTROTATE<0A><1B>%%-12345X" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.13 + *Cmd: "<1B>&l" %d{NumOfCopies}"X" +} + +*%****************************************************************************************** +*% Cursor, Page and Color Commands +*%****************************************************************************************** +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT, RASTER, VECTOR) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*Command: CmdXMoveAbsolute { *Cmd : "<1B>*p" %d{(DestX) }"X" } +*Command: CmdXMoveRelRight { *Cmd : "<1B>*p+" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdXMoveRelLeft { *Cmd : "<1B>*p-" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdYMoveAbsolute { *Cmd : "<1B>*p" %d{(DestY) }"Y" } +*Command: CmdYMoveRelDown { *Cmd : "<1B>*p+" %d{(DestYRel) }"Y" } +*Command: CmdYMoveRelUp { *Cmd : "<1B>*p-" %d{(DestYRel) }"Y" } +*Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } +*Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } +*Command: CmdCR { *Cmd : "<0D>" } +*Command: CmdLF { *Cmd : "<0A>" } +*Command: CmdFF { *Cmd : "<0C>" } +*Command: CmdBackSpace { *Cmd : "<08>" } +*Command: CmdUniDirectionOn { *Cmd : "<00>" } +*Command: CmdUniDirectionOff { *Cmd : "<00>" } +*Command: CmdPushCursor { *Cmd : "<1B>&f0S" } +*Command: CmdPopCursor { *Cmd : "<1B>&f1S" } +*Command: CmdSetSimpleRotation { *Cmd : "<1B>&a" %d{PrintDirInCCDegrees}"P" } +*EjectPageWithFF?: TRUE +*Command: CmdEnableTIFF4 { *Cmd : "<1B>*b2M" } +*Command: CmdDisableCompression { *Cmd : "<1B>*b0M" } +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*%****************************************************************************************** +*% Font Descriptions and Commands +*%****************************************************************************************** +*TTFSEnabled?: TRUE +*DefaultFont: 136 +*DefaultCTT: 0 +*CharPosition: BASELINE +*DeviceFonts: LIST(136,138,146,147,148,149,150,151,152,153,154,155,156,157, ++ 163,164,165,166,196,197,198,199,200,201,202,203,209,210, ++ 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, ++ 227,228,229,230) +*MinFontID: 16534 +*MaxFontID: 32768 +*switch: Resolution +{ + *case: Option1 + { + *FontFormat: HPPCL_OUTLINE + } + *case: Option2 + { + *FontFormat: HPPCL_OUTLINE + } + *case: Option3 + { + *FontFormat: HPPCL_RES + } +} +*Command: CmdSetFontID { *Cmd : "<1B>*c" %d{NextFontID}"D" } +*Command: CmdSelectFontID { *Cmd : "<1B>(" %d{CurrentFontID}"X" } +*Command: CmdSetCharCode { *Cmd : "<1B>*c" %d{NextGlyph}"E" } +*Command: CmdUnderlineOn { *Cmd : "<1B>&dD" } +*Command: CmdUnderlineOff { *Cmd : "<1B>&d@" } +*Command: CmdWhiteTextOn { *Cmd : "<1B>*v1o1T" } +*Command: CmdWhiteTextOff { *Cmd : "<1B>*v0o0T" } + + +*%******************************************************************************************** +*%* Vector Commands. +*%******************************************************************************************** +*MinGrayFill: 1 +*MaxGrayFill: 100 +*Command: CmdSetRectWidth { *Cmd : "<1B>*c" %d{(RectXSize) }"A" } +*Command: CmdSetRectHeight { *Cmd : "<1B>*c" %d{(RectYSize) }"B" } +*Command: CmdRectGrayFill { *Cmd : "<1B>*c" %d{GrayPercentage }"g2P" } +*Command: CmdRectWhiteFill { *Cmd : "<1B>*c1P" } +*Command: CmdRectBlackFill { *Cmd : "<1B>*c0P" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oem.ppd b/print/OEM Printer Customization Plug-in Samples/C++/oem.ppd new file mode 100644 index 00000000..bbc93432 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oem.ppd @@ -0,0 +1,431 @@ +*PPD-Adobe: "4.3" +*% Adobe Systems PostScript(R) Printer Description File +*% Copyright (c) 2003 Microsoft Corp. All rights reserved. + +*FormatVersion: "4.3" +*FileVersion: "2.0" +*LanguageEncoding: ISOLatin1 +*LanguageVersion: English +*Product: "(MS OEM Customization)" +*PSVersion: "(2015.105) 9" +*Manufacturer: "Microsoft" +*ModelName: "Microsoft PS5 OEM Customization" +*ShortNickName: "MS PS5 Oem Customization" +*NickName: "MS PS5 Oem Customization" +*PCFileName: "PS5OEM.PPD" + +*% === Installable Options =========== +*OpenGroup: InstallableOptions/Options Installed + +*OpenUI *InstalledMemory/Memory Configuration: PickOne +*DefaultInstalledMemory: 24Meg +*InstalledMemory 24Meg/Standard 24 MB RAM: "" +*InstalledMemory 28Meg/28 MB Total RAM: "" +*InstalledMemory 40Meg/40 MB Total RAM: "" +*InstalledMemory 44Meg/44 MB Total RAM: "" +*InstalledMemory 56Meg/56 MB Total RAM: "" +*InstalledMemory 72Meg/72 MB Total RAM: "" +*CloseUI: *InstalledMemory + +*CloseGroup: InstallableOptions + +*% === Constraints =================== + + +*% === Basic Device Capabilities ============ + +*LanguageLevel: "2" +*Protocols: BCP + +*FreeVM: "5500000" +*VMOption 24Meg/Standard 24 MB RAM: "5500000" +*VMOption 28Meg/28 MB Total RAM: "8000000" +*VMOption 40Meg/40 MB Total RAM: "5400000" +*VMOption 44Meg/44 MB Total RAM: "8000000" +*VMOption 56Meg/56 MB Total RAM: "17400000" +*VMOption 72Meg/72 MB Total RAM: "3800000" + +*ColorDevice: True +*DefaultColorSpace: CMYK +*AccurateScreensSupport: True +*SuggestedJobTimeout: "0" +*SuggestedWaitTimeout: "300" +*SuggestedManualFeedTimeout: "60" +*End +*TTRasterizer: Type42 +*?TTRasterizer: " + save + 42 /FontType resourcestatus + { pop pop (Type42)} {pop pop (None)} ifelse = flush + restore" +*End + +*Emulators: hpgl +*StartEmulator_hpgl: "currentfile /hpgl statusdict /emulate get exec " +*StopEmulator_hpgl: "<1B7F>0" + +*FileSystem: True +*?FileSystem: " + save false + (%disk?%) + { currentdevparams dup /Writeable known + { /Writeable get {pop true} if } {pop} ifelse + } 10 string /IODevice resourceforall + {(True)}{(False)} ifelse = flush + restore" +*End +*Throughput: "14" +*Password: "(0)" +*ExitServer: " + count 0 eq + { false } { true exch startjob } ifelse + not + { (WARNING: Cannot modify initial VM.) = + (Missing or invalid password.) = + (Please contact the author of this software.) = flush quit + } if" +*End +*Reset: " + count 0 eq + { false } { true exch startjob } ifelse + not + { (WARNING: Cannot reset printer.) = + (Missing or invalid password.) = + (Please contact the author of this software.) = flush quit + } if + systemdict /quit get exec + (WARNING : Printer Reset Failed.) = flush" +*End + +*DefaultResolution: 600x600dpi +*?Resolution: " + save currentpagedevice + /HWResolution get + aload pop exch ( ) cvs print (x) print ( ) cvs print (dpi) + = flush + restore" +*End + +*% Halftone Information ================= + +*DefaultHalftoneType: 9 +*ScreenFreq: "60.0" +*ScreenAngle: "0.0" +*DefaultScreenProc: Null +*ScreenProc Null: "{}" + +*DefaultTransfer: Null +*Transfer Null: "{ }" +*Transfer Null.Inverse: "{ 1 exch sub }" + + +*% Tray Selection ============ + +*OpenUI *InputSlot: PickOne +*OrderDependency: 10 AnySetup *InputSlot +*DefaultInputSlot: Paper +*InputSlot Upper: " + (<<) cvx exec + /MediaPosition 0 + /MediaType null + /TraySwitch false + /ManualFeed false + (>>) cvx exec setpagedevice" +*End +*InputSlot Middle: " + (<<) cvx exec + /MediaPosition 1 + /MediaType null + /TraySwitch false + /ManualFeed false + (>>) cvx exec setpagedevice" +*End +*InputSlot Lower: " + (<<) cvx exec + /MediaPosition 2 + /MediaType null + /TraySwitch false + /ManualFeed false + (>>) cvx exec setpagedevice" +*End +*InputSlot Paper: " + (<<) cvx exec + /MediaPosition null + /MediaType (Paper) + /TraySwitch true + /ManualFeed false + (>>) cvx exec setpagedevice" +*End +*InputSlot Transparency: " + (<<) cvx exec + /MediaPosition null + /MediaType (Transparency) + /TraySwitch true + /ManualFeed false + (>>) cvx exec setpagedevice" +*End +*InputSlot ManualPaper/Manual Paper: " + (<<) cvx exec + /MediaPosition null + /MediaType (Paper) + /TraySwitch false + /ManualFeed true + (>>) cvx exec setpagedevice" +*End +*InputSlot ManualTransparency/Manual Transparency: " + (<<) cvx exec + /MediaPosition null + /MediaType (Transparency) + /TraySwitch false + /ManualFeed true + (>>) cvx exec setpagedevice" +*End +*?InputSlot: " + save + currentpagedevice /MediaPosition get + dup null eq + { pop currentpagedevice /MediaType get + dup null eq + { pop (Upper) } + { dup (Paper) eq + { pop currentpagedevice /ManualFeed get + { (ManualPaper) } + { (Paper) } ifelse + } + { + (Transparency) eq + { currentpagedevice /ManualFeed get + { (ManualTransparency) } + { (Transparency) } ifelse + } + { (Unknown) } ifelse + } ifelse + } ifelse + } + { + dup 0 eq + { pop (Upper) } + { dup 1 eq + { pop (Middle) } + { 2 eq + { (Lower) } + { (Unknown) } ifelse + } ifelse + } ifelse + } ifelse + = flush restore" +*End +*CloseUI: *InputSlot + +*% Paper Handling =================== + +*% Use these entries to set paper size most of the time, unless there is +*% specific reason to use PageRegion. +*OpenUI *PageSize: PickOne +*OrderDependency: 20 AnySetup *PageSize +*DefaultPageSize: Letter +*PageSize Letter: "(<<) cvx exec /PageSize [612 792] /ImagingBBox null + (>>) cvx exec setpagedevice" +*End +*PageSize Legal: "(<<) cvx exec /PageSize [612 1008] /ImagingBBox null + (>>) cvx exec setpagedevice" +*End +*PageSize A4: "(<<) cvx exec /PageSize [595 842] /ImagingBBox null + (>>) cvx exec setpagedevice" +*End +*?PageSize: " + save currentpagedevice /PageSize get aload pop + 2 copy gt {exch} if (Unknown) + (<<) cvx exec + [612 792] (Letter) + [612 1008] (Legal) + [595 842] (A4) (>>) cvx exec + { exch aload pop 4 index sub abs 5 le exch 5 index sub abs 5 le and + { exch pop exit } { pop } ifelse + } bind forall = flush pop pop + restore" +*End +*CloseUI: *PageSize + +*% These entries will set up the frame buffer. Usually used with manual feed. +*OpenUI *PageRegion: PickOne +*OrderDependency: 30 AnySetup *PageRegion +*DefaultPageRegion: Letter +*PageRegion Letter: "(<<) cvx exec /PageSize [612 792] /ImagingBBox null + (>>) cvx exec setpagedevice" +*End +*PageRegion Legal: "(<<) cvx exec /PageSize [612 1008] /ImagingBBox null + (>>) cvx exec setpagedevice" +*End +*PageRegion A4: "(<<) cvx exec /PageSize [595 842] /ImagingBBox null + (>>) cvx exec setpagedevice" +*End +*CloseUI: *PageRegion + +*% The following entries provide information about specific paper keywords. +*DefaultImageableArea: Letter +*ImageableArea Letter: "10.32 15.9 601.68 776.22" +*ImageableArea Legal: "10.32 16.3801 601.68 991.74" +*ImageableArea A4: "13.44 14.46 581.76 828.54" +*?ImageableArea: " + save + /cvp { ( ) cvs print ( ) print } bind def + /upperright {10000 mul floor 10000 div} bind def + /lowerleft {10000 mul ceiling 10000 div} bind def + newpath clippath pathbbox + 4 -2 roll exch 2 {lowerleft cvp} repeat + exch 2 {upperright cvp} repeat flush + restore" +*End + +*% These provide the physical dimensions of the paper (by keyword) +*DefaultPaperDimension: Letter +*PaperDimension Letter: "612 792" +*PaperDimension Legal: "612 1008" +*PaperDimension A4: "595 842" + +*RequiresPageRegion All: True + +*% Print Quality Selection =================== + +*OpenUI *OutputMode/Print Quality: PickOne +*OrderDependency: 50 AnySetup *OutputMode +*DefaultOutputMode: Standard +*OutputMode Fast/Fast Color 600x600 dpi: " + (<<) cvx exec + /HWResolution [600 600] + /ProcessColorModel /DeviceCMY + (>>) cvx exec setpagedevice" +*End +*OutputMode Standard/Standard 600x600 dpi: " + (<<) cvx exec + /HWResolution [600 600] + /ProcessColorModel /DeviceCMYK + (>>) cvx exec setpagedevice" +*End +*OutputMode Enhanced/Enhanced 1200x600 dpi: " + (<<) cvx exec + /HWResolution [1200 600] + /ProcessColorModel /DeviceCMYK + (>>) cvx exec setpagedevice" +*End +*OutputMode Premium/Premium 1200x1200 dpi: " + (<<) cvx exec + /HWResolution [1200 1200] + /ProcessColorModel /DeviceCMYK + (>>) cvx exec setpagedevice" +*End +*?OutputMode: " + save + currentpagedevice /ProcessColorModel get /DeviceCMY eq + { (Fast) } + { currentpagedevice /HWResolution get + aload pop 1200 eq + { pop (Premium) } + { 1200 eq + { (Enhanced) } + { (Standard) } ifelse + } ifelse + } ifelse + = flush restore" +*End +*CloseUI: *OutputMode + +*OpenUI *OutputOrder/Output Order: PickOne +*OrderDependency: 60 AnySetup *OutputOrder +*DefaultOutputOrder: Reverse +*OutputOrder Normal/Face Down: " + (<<) cvx exec + /OutputFaceUp false + (>>) cvx exec setpagedevice" +*End +*OutputOrder Reverse/Face Up: " + (<<) cvx exec + /OutputFaceUp true + (>>) cvx exec setpagedevice" +*End +*?OutputOrder: " + save + currentpagedevice /OutputFaceUp get {(Reverse)}{(Normal)}ifelse + = flush restore" +*End +*CloseUI: *OutputOrder + +*OpenUI *Collate/Quick Collate: Boolean +*OrderDependency: 70 AnySetup *Collate +*DefaultCollate: False +*Collate False: " + (<<) cvx exec + /Collate false + (>>) cvx exec setpagedevice" +*End +*Collate True: " + (<<) cvx exec + /Collate true + (>>) cvx exec setpagedevice" +*End +*?Collate: " + save + currentpagedevice /Collate get {(True)}{(False)}ifelse + = flush restore" +*End +*CloseUI: *Collate + + +*% Font Information ===================== +*DefaultFont: Courier +*Font Courier: Standard "(002.003)" Standard ROM +*Font Courier-Bold: Standard "(002.003)" Standard ROM +*Font Courier-BoldOblique: Standard "(002.003)" Standard ROM +*Font Courier-Oblique: Standard "(002.003)" Standard ROM +*Font Helvetica: Standard "(001.006)" Standard ROM +*Font Helvetica-Bold: Standard "(001.007)" Standard ROM +*Font Helvetica-BoldOblique: Standard "(001.007)" Standard ROM +*Font Helvetica-Condensed: Standard "(001.001)" Standard ROM +*Font Helvetica-Condensed-Bold: Standard "(001.002)" Standard ROM +*Font Helvetica-Condensed-BoldObl: Standard "(001.002)" Standard ROM +*Font Helvetica-Condensed-Oblique: Standard "(001.001)" Standard ROM +*Font Helvetica-Narrow: Standard "(001.006)" Standard ROM +*Font Helvetica-Narrow-Bold: Standard "(001.007)" Standard ROM +*Font Helvetica-Narrow-BoldOblique: Standard "(001.007)" Standard ROM +*Font Helvetica-Narrow-Oblique: Standard "(001.006)" Standard ROM +*Font Helvetica-Oblique: Standard "(001.006)" Standard ROM +*Font Symbol: Special "(001.007)" Special ROM +*Font Times-Bold: Standard "(001.007)" Standard ROM +*Font Times-BoldItalic: Standard "(001.009)" Standard ROM +*Font Times-Italic: Standard "(001.007)" Standard ROM +*Font Times-Roman: Standard "(001.007)" Standard ROM +*Font ZapfChancery-MediumItalic: Standard "(001.006)" Standard ROM +*Font ZapfDingbats: Special "(001.004)" Special ROM +*?FontQuery: " + save + { count 1 gt + { exch dup 127 string cvs (/) print print (:) print + /Font resourcestatus {pop pop (Yes)} {(No)} ifelse = + } { exit } ifelse + } bind loop + (*) = flush restore" +*End + +*?FontList: " + save (*) {cvn ==} 128 string /Font resourceforall + (*) = flush restore" +*End + +*DefaultColorSep: ProcessBlack.60lpi.600x600dpi/60 lpi / 600x600 dpi + +*% For 60 lpi / 600x600dpi ================================ + +*ColorSepScreenAngle ProcessBlack.60lpi.600x600dpi/60 lpi / 600x600 dpi: "0.0" +*ColorSepScreenAngle CustomColor.60lpi.600x600dpi/60 lpi / 600x600 dpi: "0.0" +*ColorSepScreenAngle ProcessCyan.60lpi.600x600dpi/60 lpi / 600x600 dpi: "0.0" +*ColorSepScreenAngle ProcessMagenta.60lpi.600x600dpi/60 lpi / 600x600 dpi: "0.0" +*ColorSepScreenAngle ProcessYellow.60lpi.600x600dpi/60 lpi / 600x600 dpi: "0.0" + +*ColorSepScreenFreq ProcessBlack.60lpi.600x600dpi/60 lpi / 600x600 dpi: "60.0" +*ColorSepScreenFreq CustomColor.60lpi.600x600dpi/60 lpi / 600x600 dpi: "60.0" +*ColorSepScreenFreq ProcessCyan.60lpi.600x600dpi/60 lpi / 600x600 dpi: "60.0" +*ColorSepScreenFreq ProcessMagenta.60lpi.600x600dpi/60 lpi / 600x600 dpi: "60.0" +*ColorSepScreenFreq ProcessYellow.60lpi.600x600dpi/60 lpi / 600x600 dpi: "60.0" + +*% end of PPD file for MS PS5 OEM Custimization diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf b/print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf new file mode 100644 index 00000000..28bf2207 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf @@ -0,0 +1,219 @@ + +; OEMDLL.INF +; +; INF file for OEM DLL Customization samples +; +; Copyright 1999-2003 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Provider=%MS% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=6/07/2001,1.0.0.1 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Microsoft"=Microsoft, NTamd64, NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Microsoft] +"PostScript WaterMark Sample" = INSTALL_WATERMARK.PS +"Unidrv WaterMark Sample" = INSTALL_WATERMARK.UNI +"OEM PostScript Customization Sample" = INSTALL_OEMPS +"OEM Unidrv Customization Sample" = INSTALL_OEMUNI +"OEM UI Customization Sample (PS)" = INSTALL_OEMUI.PS +"OEM UI Customization Sample (Unidrv)" = INSTALL_OEMUI.UNI + +[Microsoft.NTamd64] +"PostScript WaterMark Sample" = INSTALL_WATERMARK.PS +"Unidrv WaterMark Sample" = INSTALL_WATERMARK.UNI +"OEM PostScript Customization Sample" = INSTALL_OEMPS +"OEM Unidrv Customization Sample" = INSTALL_OEMUNI +"OEM UI Customization Sample (PS)" = INSTALL_OEMUI.PS +"OEM UI Customization Sample (Unidrv)" = INSTALL_OEMUI.UNI + +[Microsoft.NTia64] +"PostScript WaterMark Sample" = INSTALL_WATERMARK.PS +"Unidrv WaterMark Sample" = INSTALL_WATERMARK.UNI +"OEM PostScript Customization Sample" = INSTALL_OEMPS +"OEM Unidrv Customization Sample" = INSTALL_OEMUNI +"OEM UI Customization Sample (PS)" = INSTALL_OEMUI.PS +"OEM UI Customization Sample (Unidrv)" = INSTALL_OEMUI.UNI + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[INSTALL_WATERMARK.PS] +CopyFiles=@OEM.PPD +CopyFiles=@WMARKPS.INI +CopyFiles=WMARKPS +DataFile=OEM.PPD +DataSection=PSCRIPT_DATA +Include=NTPRINT.INF +Needs=PSCRIPT.OEM,PSCRIPT_DATA + + +[INSTALL_WATERMARK.UNI] +CopyFiles=@OEM.GPD +CopyFiles=@WMARKUNI.INI +CopyFiles=WMARKUNI +DataFile=OEM.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,TTFSUB.OEM,UNIDRV_DATA + +[INSTALL_OEMPS] +CopyFiles=@OEM.PPD +CopyFiles=@OEMPS.INI +CopyFiles=OEMPS +DataFile=OEM.PPD +DataSection=PSCRIPT_DATA +Include=NTPRINT.INF +Needs=PSCRIPT.OEM,PSCRIPT_DATA + +[INSTALL_OEMUNI] +CopyFiles=@OEM.GPD +CopyFiles=@OEMUNI.INI +CopyFiles=OEMUNI +DataFile=OEM.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,TTFSUB.OEM,UNIDRV_DATA + +[INSTALL_OEMUI.PS] +CopyFiles=@OEM.PPD +CopyFiles=@OEMUI.INI +CopyFiles=OEMUI +DataFile=OEM.PPD +DataSection=PSCRIPT_DATA +Include=NTPRINT.INF +Needs=PSCRIPT.OEM,PSCRIPT_DATA + +[INSTALL_OEMUI.UNI] +CopyFiles=@OEM.GPD +CopyFiles=@OEMUI.INI +CopyFiles=OEMUI +DataFile=OEM.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,TTFSUB.OEM,UNIDRV_DATA + + + +; Copy Sections +; +; Lists of files that are actually copied. These sections are referenced +; from the installer sections, above. Only create a section if it contains +; two or more files (if we only copy a single file, identify it in the +; installer section, using the @filename notation) or if it's a color +; profile (since the DestinationDirs can only handle sections, and not +; individual files). +; + +[WMARKPS] +WMARKPS.DLL +WMARKUI.DLL + +[WMARKUNI] +WMARKUNI.DLL +WMARKUNIUI.DLL + +[OEMPS] +OEMPS.DLL + +[OEMUI] +OEMUI.DLL + +[OEMUNI] +OEMUNI.DLL + + +; +; Data Sections +; + +; These sections contain data that is shared between devices. +; + + + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMSample% + +[SourceDisksFiles.x86] +oemps.dll = 100,OEMPS\x86 +oemui.dll = 100,OEMUI\x86 +oemuni.dll = 100,OEMUNI\x86 +wmarkps.dll = 100,WaterMark\x86 +wmarkuni.dll = 100,WaterMarkUni\x86 +wmarkuniui.dll = 100,WaterMarkUni\x86 +wmarkui.dll = 100,WaterMark\x86 + +[SourceDisksFiles.amd64] +oemps.dll = 100,OEMPS\amd64 +oemui.dll = 100,OEMUI\amd64 +oemuni.dll = 100,OEMUNI\amd64 +wmarkps.dll = 100,WaterMark\amd64 +wmarkuni.dll = 100,WaterMarkUni\amd64 +wmarkuniui.dll = 100,WaterMarkUni\amd64 +wmarkui.dll = 100,WaterMark\amd64 + +[SourceDisksFiles.ia64] +oemps.dll = 100,OEMPS\ia64 +oemui.dll = 100,OEMUI\ia64 +oemuni.dll = 100,OEMUNI\ia64 +wmarkps.dll = 100,WaterMark\ia64 +wmarkuni.dll = 100,WaterMarkUni\ia64 +wmarkuniui.dll = 100,WaterMarkUni\ia64 +wmarkui.dll = 100,WaterMark\ia64 + +[SourceDisksFiles] +OEM.PPD = 100 +OEM.GPD = 100 +WMARKPS.INI = 100 +WMARKUNI.INI = 100 +OEMPS.INI = 100 +OEMUNI.INI = 100 +OEMUI.INI = 100 + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +MS="Microsoft DDK Sample" +OEMSample="OEM DLL Print samples" + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemdll.sln b/print/OEM Printer Customization Plug-in Samples/C++/oemdll.sln new file mode 100644 index 00000000..2d0d56ed --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemdll.sln @@ -0,0 +1,809 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 +MinimumVisualStudioVersion = 12.0 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bitmap", "Bitmap", "{EFB5E861-A892-49B4-BA05-38F6F5F42D48}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Custhlp", "Custhlp", "{F3DB5340-C664-40EB-986F-2A48790AEDC5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{EC75B371-D09D-4D95-9816-3429B6D3806B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Gdl", "Gdl", "{A6BA54B0-ADB8-4032-8C4B-770474042B09}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Oemprean", "Oemprean", "{E7B7C6C6-5396-42D3-9BDE-DFAC86D0AFE3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Oemps", "Oemps", "{80510096-C37F-488D-A426-E3BA4B1A1600}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Oemui", "Oemui", "{35933BA0-56E6-4DD4-84E9-C8AADAA19AFA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Oemuni", "Oemuni", "{7AC217E4-4DB5-414C-A39F-B783020E43AA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PSUIRep", "PSUIRep", "{03A523F4-091A-416B-97B5-A84FA1B1D3EE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{CCF8F861-A2C2-4C28-AB19-29CC47C6D560}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PTPCPlPr", "PTPCPlPr", "{F8AB36BA-6C96-42BA-90F5-378D3B73634C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SyncSet", "SyncSet", "{C52A574A-6122-48EB-875C-07CE190B0808}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ThemeUI", "ThemeUI", "{F3C654B9-A286-494E-8558-3A2526D52A37}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{C4BCC65A-6423-4569-A1D6-AAA82CE821A9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Uniuirep", "Uniuirep", "{1BA35560-35CD-4E6E-8B67-AD7ED043874A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wmarkps", "Wmarkps", "{9F8B052F-1649-4F54-ABE9-42E51AFB32AA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Watermark", "Watermark", "{575FCB22-ADB3-4025-8F23-040500F6C11A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wmarkui", "Wmarkui", "{2A597978-AD6A-41D0-9B97-CC1B69CE054A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wmarkui", "Wmarkui", "{D0C95EA5-D23F-44E6-91C3-2BA65CE3991E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Watermarkuni", "Watermarkuni", "{5A8A1EF7-4454-43F3-8A69-484AF81D0771}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Wmarkuni", "Wmarkuni", "{90BABB1D-0FDD-4A9A-BA18-3319FF12363B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bitmap", "bitmap\bitmap.vcxproj", "{EDCCC34A-50DF-4894-B7B9-FC156F899947}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CUSTHLP", "custhlp\CUSTHLP.vcxproj", "{CA70C64A-75C8-48CD-9224-335C2ED689A6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GDLSMPL", "gdl\src\GDLSMPL.vcxproj", "{F0118F7B-9DF5-49FC-B4FF-951C54033F3D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "oemprean", "oemprean\oemprean.vcxproj", "{D5E225D5-EEEA-45FD-AD07-E4678C542E1A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OEMPS", "oemps\OEMPS.vcxproj", "{9F374241-B8F9-45D3-B163-7E84E8E22C1F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OEMUI", "oemui\OEMUI.vcxproj", "{452209BF-AEB7-457D-956B-90CDE70CED7D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OEMUNI", "oemuni\OEMUNI.vcxproj", "{B0F13767-2056-47FC-B37B-41D7E339900B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PSUIREP", "PSUIRep\PSUIREP.vcxproj", "{5D63CD51-110C-41B7-B8B0-6AB27398690B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PTPCPLPR", "PTPCPlPr\src\PTPCPLPR.vcxproj", "{CED613CF-6666-43FC-9414-02AFBDA83A34}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SYNCSET", "SyncSet\SYNCSET.vcxproj", "{60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ThemeUISmpl", "ThemeUI\ThemeUISmpl.vcxproj", "{EA206DEA-26E6-4FD4-BF68-23F222C5E211}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UNIUIREP", "uniuirep\src\UNIUIREP.vcxproj", "{7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WMARKPS", "watermark\wmarkps\WMARKPS.vcxproj", "{4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WMARKUI", "watermark\wmarkui\WMARKUI.vcxproj", "{BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WMARKUNIUI", "watermarkuni\wmarkui\WMARKUNIUI.vcxproj", "{1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WMARKUNI", "watermarkuni\wmarkuni\WMARKUNI.vcxproj", "{866141A6-4989-41D7-9409-4A5A73B535B0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Win10 Debug|ARM64 = Win10 Debug|ARM64 + Win10 Debug|Win32 = Win10 Debug|Win32 + Win10 Debug|x64 = Win10 Debug|x64 + Win10 Release|ARM64 = Win10 Release|ARM64 + Win10 Release|Win32 = Win10 Release|Win32 + Win10 Release|x64 = Win10 Release|x64 + Win7 Debug|ARM64 = Win7 Debug|ARM64 + Win7 Debug|Win32 = Win7 Debug|Win32 + Win7 Debug|x64 = Win7 Debug|x64 + Win7 Release|ARM64 = Win7 Release|ARM64 + Win7 Release|Win32 = Win7 Release|Win32 + Win7 Release|x64 = Win7 Release|x64 + Win8 Debug|ARM64 = Win8 Debug|ARM64 + Win8 Debug|Win32 = Win8 Debug|Win32 + Win8 Debug|x64 = Win8 Debug|x64 + Win8 Release|ARM64 = Win8 Release|ARM64 + Win8 Release|Win32 = Win8 Release|Win32 + Win8 Release|x64 = Win8 Release|x64 + Win8.1 Debug|ARM64 = Win8.1 Debug|ARM64 + Win8.1 Debug|Win32 = Win8.1 Debug|Win32 + Win8.1 Debug|x64 = Win8.1 Debug|x64 + Win8.1 Release|ARM64 = Win8.1 Release|ARM64 + Win8.1 Release|Win32 = Win8.1 Release|Win32 + Win8.1 Release|x64 = Win8.1 Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {EDCCC34A-50DF-4894-B7B9-FC156F899947}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {CA70C64A-75C8-48CD-9224-335C2ED689A6}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {9F374241-B8F9-45D3-B163-7E84E8E22C1F}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {452209BF-AEB7-457D-956B-90CDE70CED7D}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {B0F13767-2056-47FC-B37B-41D7E339900B}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {5D63CD51-110C-41B7-B8B0-6AB27398690B}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {CED613CF-6666-43FC-9414-02AFBDA83A34}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {EA206DEA-26E6-4FD4-BF68-23F222C5E211}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Debug|ARM64.ActiveCfg = Win10 Debug|ARM64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Debug|ARM64.Build.0 = Win10 Debug|ARM64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Debug|Win32.ActiveCfg = Win10 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Debug|Win32.Build.0 = Win10 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Debug|x64.ActiveCfg = Win10 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Debug|x64.Build.0 = Win10 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Release|ARM64.ActiveCfg = Win10 Release|ARM64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Release|ARM64.Build.0 = Win10 Release|ARM64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Release|Win32.ActiveCfg = Win10 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Release|Win32.Build.0 = Win10 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Release|x64.ActiveCfg = Win10 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win10 Release|x64.Build.0 = Win10 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Debug|ARM64.ActiveCfg = Win7 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Debug|x64.Build.0 = Win7 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Release|ARM64.ActiveCfg = Win7 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Release|Win32.Build.0 = Win7 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Release|x64.ActiveCfg = Win7 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win7 Release|x64.Build.0 = Win7 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Debug|ARM64.ActiveCfg = Win8 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Debug|x64.Build.0 = Win8 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Release|ARM64.ActiveCfg = Win8 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Release|Win32.Build.0 = Win8 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Release|x64.ActiveCfg = Win8 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8 Release|x64.Build.0 = Win8 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Debug|ARM64.ActiveCfg = Win8.1 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Release|ARM64.ActiveCfg = Win8.1 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64 + {866141A6-4989-41D7-9409-4A5A73B535B0}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {EC75B371-D09D-4D95-9816-3429B6D3806B} = {A6BA54B0-ADB8-4032-8C4B-770474042B09} + {CCF8F861-A2C2-4C28-AB19-29CC47C6D560} = {F8AB36BA-6C96-42BA-90F5-378D3B73634C} + {C4BCC65A-6423-4569-A1D6-AAA82CE821A9} = {1BA35560-35CD-4E6E-8B67-AD7ED043874A} + {9F8B052F-1649-4F54-ABE9-42E51AFB32AA} = {575FCB22-ADB3-4025-8F23-040500F6C11A} + {2A597978-AD6A-41D0-9B97-CC1B69CE054A} = {575FCB22-ADB3-4025-8F23-040500F6C11A} + {D0C95EA5-D23F-44E6-91C3-2BA65CE3991E} = {5A8A1EF7-4454-43F3-8A69-484AF81D0771} + {90BABB1D-0FDD-4A9A-BA18-3319FF12363B} = {5A8A1EF7-4454-43F3-8A69-484AF81D0771} + {EDCCC34A-50DF-4894-B7B9-FC156F899947} = {EFB5E861-A892-49B4-BA05-38F6F5F42D48} + {CA70C64A-75C8-48CD-9224-335C2ED689A6} = {F3DB5340-C664-40EB-986F-2A48790AEDC5} + {F0118F7B-9DF5-49FC-B4FF-951C54033F3D} = {EC75B371-D09D-4D95-9816-3429B6D3806B} + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A} = {E7B7C6C6-5396-42D3-9BDE-DFAC86D0AFE3} + {9F374241-B8F9-45D3-B163-7E84E8E22C1F} = {80510096-C37F-488D-A426-E3BA4B1A1600} + {452209BF-AEB7-457D-956B-90CDE70CED7D} = {35933BA0-56E6-4DD4-84E9-C8AADAA19AFA} + {B0F13767-2056-47FC-B37B-41D7E339900B} = {7AC217E4-4DB5-414C-A39F-B783020E43AA} + {5D63CD51-110C-41B7-B8B0-6AB27398690B} = {03A523F4-091A-416B-97B5-A84FA1B1D3EE} + {CED613CF-6666-43FC-9414-02AFBDA83A34} = {CCF8F861-A2C2-4C28-AB19-29CC47C6D560} + {60E61442-4E2A-41A1-BC70-EDC0B8DC4EB8} = {C52A574A-6122-48EB-875C-07CE190B0808} + {EA206DEA-26E6-4FD4-BF68-23F222C5E211} = {F3C654B9-A286-494E-8558-3A2526D52A37} + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16} = {C4BCC65A-6423-4569-A1D6-AAA82CE821A9} + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5} = {9F8B052F-1649-4F54-ABE9-42E51AFB32AA} + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE} = {2A597978-AD6A-41D0-9B97-CC1B69CE054A} + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62} = {D0C95EA5-D23F-44E6-91C3-2BA65CE3991E} + {866141A6-4989-41D7-9409-4A5A73B535B0} = {90BABB1D-0FDD-4A9A-BA18-3319FF12363B} + EndGlobalSection +EndGlobal diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean.gpd b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.gpd new file mode 100644 index 00000000..3328de18 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.gpd @@ -0,0 +1,706 @@ +*GPDFileName: "oemprean.gpd" +*GPDFileVersion: "1.0" +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*Include: "ttfsub.gpd" +*ModelName: "OEM Pre-Analysis sample" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 +*PrintRate: 16 +*PrintRateUnit: PPM +*PrintRatePPM: 16 + +*PreAnalysisOptions: 8 + +*%****************************************************************************************** +*% Orientation +*%****************************************************************************************** +*Feature: Orientation +{ + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l0O" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.8 + *Cmd: "<1B>&l1O" + } + } +} + +*%****************************************************************************************** +*% Input Bin +*%****************************************************************************************** +*Feature: InputBin +{ + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: AUTO + *Option: AUTO + { + *rcNameID: =AUTO_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l0H" + } + } + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l1H" + } + } +} + +*%****************************************************************************************** +*% Resolution +*%****************************************************************************************** +*Feature: Resolution +{ + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: Option2 + *Option: Option1 + { + *Name: "600 x 600" =DOTS_PER_INCH + *DPI: PAIR(600, 600) + *TextDPI: PAIR(600, 600) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=600<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t600R" + } + } + *Option: Option2 + { + *Name: "300 x 300" =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=300<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } + *Option: Option3 + { + *Name: "150 x 150" =DOTS_PER_INCH + *DPI: PAIR(150, 150) + *TextDPI: PAIR(150, 150) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=150<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t150R" + } + } +} + +*%****************************************************************************************** +*% HP-GL/2 Graphics Support +*%****************************************************************************************** +*Ifdef: WINNT_51 +*Personality: =PERSONALITY_HPGL2 +*Feature: GraphicsMode +{ + *rcNameID: =GRAPHICSMODE_DISPLAY + *DefaultOption: RASTERMODE + *Option: HPGL2MODE + { + *rcNameID: =GRAPHICSMODE_HPGL2_DISPLAY + } + *Option: RASTERMODE + { + *rcNameID: =GRAPHICSMODE_RASTER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "@PJL SET LIMAGEENHANCE=OFF<0A>" + } + } +} +*Endif: + +*%****************************************************************************************** +*% Paper Size +*%****************************************************************************************** +*Feature: PaperSize +{ + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1028 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9500, 12500) + *PrintableOrigin: PAIR(400, 400) + *CursorOrigin: PAIR(300, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t5260x7704Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9500, 12200) + *PrintableOrigin: PAIR(450, 300) + *CursorOrigin: PAIR(200, 12900) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t7332x5880Y" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1692 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 600) + *CursorOrigin: PAIR(180, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t5880x8900Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 900) + *CursorOrigin: PAIR(180, 16500) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t8900x5880Y" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4109 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 11500) + *PrintableOrigin: PAIR(300, 300) + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t4860x7344Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8300, 11500) + *PrintableOrigin: PAIR(200, 300) + *CursorOrigin: PAIR(200, 12300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t7272x4980Y" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4249 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(288, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t5594x8201Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(204, 13824) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t8129x5714Y" + } + } + } + } + *Option: B5 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 3198 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(7900, 11140) + *PrintableOrigin: PAIR(352, 300) + *CursorOrigin: PAIR(300, 100) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t4970x7040Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(7760, 11140) + *PrintableOrigin: PAIR(300, 400) + *CursorOrigin: PAIR(100, 11940) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t6780x4970Y" + } + } + } + } +} + +*%****************************************************************************************** +*% Media Type +*%****************************************************************************************** +*Feature: MediaType +{ + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: PLAIN + *Option: PLAIN + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n6WdPlain" + } + } + *Option: TRANSPARENCY + { + *rcNameID: =TRANSPARENCY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n13WdTransparency" + } + } +} + +*%****************************************************************************************** +*% Color Mode +*%****************************************************************************************** +*Feature: ColorMode +{ + *rcNameID: =COLOR_PRINTING_MODE_DISPLAY + *DefaultOption: 24bpp + *Option: Mono + { + *rcNameID: =MONO_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 1 + *Color?: FALSE + } + *Option: Color + { + *rcNameID: =COLOR_DISPLAY + *DevNumOfPlanes: 3 + *DevBPP: 1 + *DrvBPP: 4 + EXTERN_GLOBAL: *RasterSendAllData?: TRUE + *ColorPlaneOrder: LIST(CYAN, MAGENTA, YELLOW) + *Command: CmdSendCyanData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"V" } + *Command: CmdSendMagentaData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"V" } + *Command: CmdSendYellowData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelectBlackColor { *Cmd : "<1B>*v7S" } + *Command: CmdSelectRedColor { *Cmd : "<1B>*v6S" } + *Command: CmdSelectGreenColor { *Cmd : "<1B>*v5S" } + *Command: CmdSelectYellowColor { *Cmd : "<1B>*v4S" } + *Command: CmdSelectBlueColor { *Cmd : "<1B>*v3S" } + *Command: CmdSelectMagentaColor { *Cmd : "<1B>*v2S" } + *Command: CmdSelectCyanColor { *Cmd : "<1B>*v1S" } + *Command: CmdSelectWhiteColor { *Cmd : "<1B>*v0S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*r-3U" + } + } + *Option: 8bpp + { + *rcNameID: =8BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 8 + *DrvBPP: 8 + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*t0I<1B>*l184O<1B>*v6W<000108080808>" + } + } + *Option: 24bpp + { + *rcNameID: =24BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 24 + *DrvBPP: 24 + *Command: CmdEnableDRC { *Cmd : "<1B>*b3M" } + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSetSrcBmpWidth { *Cmd : "<1B>*r" %d{RasterDataWidthInBytes / 3}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*l184O<1B>*v6W<0003080808081B>*v0a0b0c7i255a255b255c0I<1B>*" ++ "o3W<060400>" + } + } +} + +*%****************************************************************************************** +*% HalfTone +*%****************************************************************************************** +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} + +*%****************************************************************************************** +*% Memory +*% +*% Note: Unidrv uses the font memory information to estimate when it needs to stop +*% downloading fonts for a page, and thus driver writers should err on the conservative +*% side. Otherwise, printers will generate "out of memory" device errors for pages with +*% a large number of fonts / unique glyphs. +*%****************************************************************************************** +*Feature: Memory +{ + *rcNameID: =PRINTER_MEMORY_DISPLAY + *DefaultOption: 32768KB + *Option: 4096KB + { + *Name: "4MB" + *MemoryConfigKB: PAIR(4096, 6750) + } + *Option: 8192KB + { + *Name: "8MB" + *MemoryConfigKB: PAIR(8192, 10350) + } + *Option: 16384KB + { + *Name: "16MB" + *MemoryConfigKB: PAIR(16384, 13950) + } + *Option: 24576KB + { + *Name: "24MB" + *MemoryConfigKB: PAIR(24576, 21150) + } + *Option: 32768KB + { + *Name: "32MB" + *MemoryConfigKB: PAIR(32768, 28350) + } + *Option: 49152KB + { + *Name: "48MB" + *MemoryConfigKB: PAIR(49152, 43050) + } + *Option: 65536KB + { + *Name: "64MB" + *MemoryConfigKB: PAIR(65536, 57150) + } + *Option: 98304KB + { + *Name: "96MB" + *MemoryConfigKB: PAIR(98304, 85950) + } + *Option: 102400KB + { + *Name: "100MB" + *MemoryConfigKB: PAIR(102400, 89700) + } + *Option: 114688KB + { + *Name: "112MB" + *MemoryConfigKB: PAIR(114688, 100550) + } + *Option: 131072KB + { + *Name: "128MB" + *MemoryConfigKB: PAIR(131072, 116250) + } +} + +*%****************************************************************************************** +*% Duplex Unit +*%****************************************************************************************** +*Feature: DuplexUnit +{ + *rcNameID: 429 + *FeatureType: PRINTER_PROPERTY + *DefaultOption: FALSE + *Option: FALSE + { + *rcNameID: 444 + *DisabledFeatures: LIST(Duplex.VERTICAL, Duplex.HORIZONTAL) + } + *Option: TRUE + { + *rcNameID: 443 + } +} + +*%****************************************************************************************** +*% Duplex Type +*%****************************************************************************************** +*Feature: Duplex +{ + *rcNameID: =TWO_SIDED_PRINTING_DISPLAY + *DefaultOption: NONE + *Option: NONE + { + *rcNameID: =NONE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l0S" + } + } + *Option: VERTICAL + { + *rcNameID: =FLIP_ON_LONG_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l1S" + } + } + *Option: HORIZONTAL + { + *rcNameID: =FLIP_ON_SHORT_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l2S" + } + } +} + +*%****************************************************************************************** +*% Page Protect +*%****************************************************************************************** +*Feature: PageProtect +{ + *rcNameID: =PAGE_PROTECTION_DISPLAY + *DefaultOption: OFF + *Option: ON + { + *rcNameID: =ON_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=LETTER<0A>" + } + } + *Option: OFF + { + *rcNameID: =OFF_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=OFF<0A>" + } + } +} + +*%****************************************************************************************** +*% Doc setup commands +*%****************************************************************************************** +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.7 + *Cmd: "<1B>&u1200D<1B>*r0F" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "<1B>*b0M<0D>" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "<1B>E<1B>%%-12345X@PJL<20>LPORTROTATE<0A><1B>%%-12345X" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.13 + *Cmd: "<1B>&l" %d{NumOfCopies}"X" +} + +*%****************************************************************************************** +*% Cursor, Page and Color Commands +*%****************************************************************************************** +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT, RASTER, VECTOR) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*Command: CmdXMoveAbsolute { *Cmd : "<1B>*p" %d{(DestX) }"X" } +*Command: CmdXMoveRelRight { *Cmd : "<1B>*p+" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdXMoveRelLeft { *Cmd : "<1B>*p-" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdYMoveAbsolute { *Cmd : "<1B>*p" %d{(DestY) }"Y" } +*Command: CmdYMoveRelDown { *Cmd : "<1B>*p+" %d{(DestYRel) }"Y" } +*Command: CmdYMoveRelUp { *Cmd : "<1B>*p-" %d{(DestYRel) }"Y" } +*Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } +*Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } +*Command: CmdCR { *Cmd : "<0D>" } +*Command: CmdLF { *Cmd : "<0A>" } +*Command: CmdFF { *Cmd : "<0C>" } +*Command: CmdBackSpace { *Cmd : "<08>" } +*Command: CmdUniDirectionOn { *Cmd : "<00>" } +*Command: CmdUniDirectionOff { *Cmd : "<00>" } +*Command: CmdPushCursor { *Cmd : "<1B>&f0S" } +*Command: CmdPopCursor { *Cmd : "<1B>&f1S" } +*Command: CmdSetSimpleRotation { *Cmd : "<1B>&a" %d{PrintDirInCCDegrees}"P" } +*EjectPageWithFF?: TRUE +*Command: CmdEnableTIFF4 { *Cmd : "<1B>*b2M" } +*Command: CmdDisableCompression { *Cmd : "<1B>*b0M" } +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*%****************************************************************************************** +*% Font Descriptions and Commands +*%****************************************************************************************** +*TTFSEnabled?: TRUE +*DefaultFont: 136 +*DefaultCTT: 0 +*CharPosition: BASELINE +*DeviceFonts: LIST(136,138,146,147,148,149,150,151,152,153,154,155,156,157, ++ 163,164,165,166,196,197,198,199,200,201,202,203,209,210, ++ 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, ++ 227,228,229,230) +*MinFontID: 16534 +*MaxFontID: 32768 +*switch: Resolution +{ + *case: Option1 + { + *FontFormat: HPPCL_OUTLINE + } + *case: Option2 + { + *FontFormat: HPPCL_OUTLINE + } + *case: Option3 + { + *FontFormat: HPPCL_RES + } +} +*Command: CmdSetFontID { *Cmd : "<1B>*c" %d{NextFontID}"D" } +*Command: CmdSelectFontID { *Cmd : "<1B>(" %d{CurrentFontID}"X" } +*Command: CmdSetCharCode { *Cmd : "<1B>*c" %d{NextGlyph}"E" } +*Command: CmdUnderlineOn { *Cmd : "<1B>&dD" } +*Command: CmdUnderlineOff { *Cmd : "<1B>&d@" } +*Command: CmdWhiteTextOn { *Cmd : "<1B>*v1o1T" } +*Command: CmdWhiteTextOff { *Cmd : "<1B>*v0o0T" } + + +*%******************************************************************************************** +*%* Vector Commands. +*%******************************************************************************************** +*MinGrayFill: 1 +*MaxGrayFill: 100 +*Command: CmdSetRectWidth { *Cmd : "<1B>*c" %d{(RectXSize) }"A" } +*Command: CmdSetRectHeight { *Cmd : "<1B>*c" %d{(RectYSize) }"B" } +*Command: CmdRectGrayFill { *Cmd : "<1B>*c" %d{GrayPercentage }"g2P" } +*Command: CmdRectWhiteFill { *Cmd : "<1B>*c1P" } +*Command: CmdRectBlackFill { *Cmd : "<1B>*c0P" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean.htm b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.htm new file mode 100644 index 00000000..87662eb5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.htm @@ -0,0 +1,514 @@ + + + + + + + + +OEMPREAN SAMPLE + + + + + + + +
+ +

OEMPREAN SAMPLE

+ +

 

+ +

Summary

+ +

This +sample illustrates how you can leverage the preanalysis feature in Unidrv. This +sample is built upon the redesigned version of the oemuni sample.

+ +

 

+ +

When +preanalysis is enabled in the GPD, Unidrv defines the surface as a banding +surface but causes the first playback to be of the entire page. Unidrv does +this by setting the GDI clip window to the entire page. Unidrv allows all +drawing commands to be hooked but returns before any drawing can be done. On +the following passes Unidrv resets the clip window back to the original band +size and bands normally. In order to enable this feature in the GPD, specify +the following GPD parameter: “*PreAnalysisOptions: 8”.

+ +

 

+ +

The OEM +rendering plug-in is required to hook both DrvStartBanding and DrvNextBand when +this mode is enabled in the GPD. The OEM rendering plug-in must test the pptl +parameter of the DrvStartBanding call to determine whether preanalysis has been +enabled on this page. If the pptl parameter is NULL, then preanalysis has been +enabled. The pptl parameter can be used by Unidrv since it has no meaning at +this point. This parameter has not been updated with the band position and for +preanalysis the band position is always be set to 0, 0. If the pptl parameter +is NULL, then the OEM rendering plug-in should consider all drawing calls up to +the first call to DrvNextBand to be part of preanalysis. During this phase no +drawing onto the surface is allowed. You should be aware that after +preanalysis, you might get more calls than you saw in the normal rendering, +because primitives that cross band boundaries yield two or more DDI calls after +the preanalysis pass.

+ +

 

+ +

The +sample uses the bPreAnalysis flag in the OEMPDEV structure to denote whether a +particular pass is the preanalysis pass or the actual rendering pass. If the +bPreAnalysis flag is set, it indicates that the current pass is the preanalysis +pass. The sample implements all of the drawing function hooks in ddihook.cpp. +The sample uses the OEMStartBanding and OEMNextBand functions, to respectively +set and reset the bPreAnalysis flag. The sample also uses the DBG_CLIPOBJ debug +macro function to dump the bounds of the clipping rectangle available for +preanalysis in each of the drawing functions during the preanalysis pass. To +view all of the debug output in the debugger, you must set the debug level to +VERBOSE. The rest of the sample is identical to the oemuni sample that +illustrates a basic OEM rendering plug-in.

+ +

 

+ +

Note that +the surface used during preanalysis might differ from the surface passed in +during the rendering pass. Also note that during the preanalysis pass, although +Unidrv calls the hooked drawing functions, it returns before any drawing is +done. For this reason you should not perform any drawing on the surface during +the preanalysis pass. All other preanalysis tasks should be performed during +this pass. For example, certain printers need to handle black objects that +intersect with color objects differently from black objects that appear by +themselves. Other printers might need to halftone StretchBlt objects +differently from BitBlt objects. Basically, the plug-in can analyze the objects +on the page. A final point to note is that during the preanalysis pass, drawing +functions should not call back into Unidrv. When the bPreAnalysis flag is set, +the sample returns without calling back into Unidrv.

+ +

 

+ +

Note that +this sample will not build with the Windows 2000 build environment. This +version of the sample implements the IPrintOemUni2 interface which is available +only on Windows XP and later. The table shown below will help identify which +operating systems this sample will build/work on.

+ +

 

+ +

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Operating System

+
+

Can sample be built in the OS?

+
+

Does sample work in the OS?

+
+

Can sample be used in a production environment + for the OS?

+
+

Windows + codenamed Longhorn

+
+

Yes

+
+

Yes

+
+

No

+
+

Windows + Server 2003

+
+

Yes

+
+

No

+
+

No

+
+

Windows + XP

+
+

Yes

+
+

No

+
+

No

+
+

Windows + 2000

+
+

No

+
+

No

+
+

No

+
+

Windows + Me

+
+

No

+
+

No

+
+

No

+
+

Windows + 98 SE

+
+

No

+
+

No

+
+

No

+
+ +

 

+ +

 

+ +

Building the sample

+ +

To build +the samples, run “build –cZ” from +the directory. The resulting DLL will be placed in the appropriate platform directory +(i.e. i386 or Alpha). To create a version with verbose debug output, add _DEBUG +to the compile defines in the sources file.

+ +

 

+ +

Installing the sample

+ +

After +building the sample, you can install it using the Add Printer Wizard and +supplying the INF that is part of the sample when you are prompted for an INF +in the wizard. The Unidrv binaries required for this driver need not be copied +to the local directory containing oemdll.inf.

+ +

 

+ +

Resources

+ +

For the +latest release of the Windows Device Driver Development Kit, see http://www.microsoft.com/whdc/ddk/winddk.mspx.

+ +

 

+ +

If you +have questions on using or adapting this sample for your project, you can +either contact Microsoft Technical +Support or post your questions in the Microsoft +driver development newsgroup.

+ +

 

+ +

 

+ +

File Manifest

+ +

 

+ +

Root:

+ +

 

+ +

Files                       Description

+ +

readme.htm             The documentation for this sample +(this file).

+ +

oemprean.gpd          The generic GPD file for this sample.

+ +

oemprean.inf            The printer INF that will install +this sample once it is built.

+ +

oemprean.ini            The printer ini file that specifies +the OEM customization DLLs for this sample.

+ +

 

+ +

 

+ +

OEMPREAN directory:

+ +

 

+ +

Files                       Description

+ +

ddihook.cpp             Source module for DDI Hook routines +for the rendering plug-in. (OEMBitBlt, OEMStrokePath, OEMTextOut, OEMNextBand +etc.)

+ +

ddihook.h                Source module that defines the +constants used to control DDI hooking. (IMPL_ALPHABLEND, IMPL_BITBLT, +IMPL_NEXTBAND etc.)

+ +

debug.cpp               Source module that contains the +debugging functions. (COemUniDbg::vDumpSURFOBJ, COemUniDbg::vDumpSTROBJ etc.)

+ +

debug.h                  The header file for the debug +module defined in debug.cpp. (Definition of the COemUniDbg class)

+ +

devmode.cpp           Source module that contains +implementation of the OEM Devmode functions. (hrOEMDevmode, bConvertOEMDevmode +etc.)

+ +

devmode.h              The header for devmode.cpp.

+ +

dllentry.cpp             Source module for DLL entry +functions. (DllMain)

+ +

enable.cpp              Source module that contains the +enable routines for the rendering plug-in. (OEMEnableDriver, OEMEnablePDEV, +OEMDisableDriver etc.)

+ +

intrface.cpp             Source module that implements the +OEM COM printer customization rendering plug-in interface. +(COemUni2::ImageProcessing, COemUni2::FilterGraphics etc.)

+ +

intrface.h                The header for intrface.cpp that +defines the COM interface for the rendering plug-in. (Definition of the +COemUni2 class)

+ +

makefile                  The generic makefile for +building the code sample.

+ +

oemprean.def           The file that lists the exported +functions for the sample.

+ +

oemprean.h             The header file that defines the +PDEV class for the sample. (Definition and implementation of the COemPDEV +class)

+ +

oemprean.rc            The resources file for the rendering +plugin’s resources.

+ +

precomp.h               The header that includes the +headers to precompile.

+ +

resource.h               The header file the resources +file.

+ +

sources                   The generic sources file for building +the code sample.

+ +

 

+ +
+ + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf new file mode 100644 index 00000000..a7c90e24 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf @@ -0,0 +1,117 @@ +; OEMPREAN.INF +; +; INF file for the OEM pre-analysis WDK sample +; +; Copyright 1999 - 2001 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Provider=%MS% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=6/07/2001,1.0.0.1 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Microsoft"=Microsoft, NTx86, NTamd64, NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Microsoft] +"OEM Pre-Analysis sample" = OEM_PREAN + +[Microsoft.NTx86] +"OEM Pre-Analysis sample" = OEM_PREAN + +[Microsoft.NTamd64] +"OEM Pre-Analysis sample" = OEM_PREAN + +[Microsoft.NTia64] +"OEM Pre-Analysis sample" = OEM_PREAN + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[OEM_PREAN] +CopyFiles=@OEMPREAN.GPD +CopyFiles=@OEMPREAN.INI +CopyFiles=OEMPREAN +DataFile=OEMPREAN.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,TTFSUB.OEM,UNIDRV_DATA + + +; Copy Sections +; +; Lists of files that are actually copied. These sections are referenced +; from the installer sections, above. Only create a section if it contains +; two or more files (if we only copy a single file, identify it in the +; installer section, using the @filename notation) or if it's a color +; profile (since the DestinationDirs can only handle sections, and not +; individual files). +; + +[OEMPREAN] +OEMPREAN.DLL + +; +; Data Sections +; + +; These sections contain data that is shared between devices. +; + + + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMSample% + +[SourceDisksFiles.x86] +oemprean.dll = 100,oemprean\x86 + +[SourceDisksFiles.amd64] +oemprean.dll = 100,oemprean\amd64 + +[SourceDisksFiles.ia64] +oemprean.dll = 100,oemprean\ia64 + +[SourceDisksFiles] +OEMPREAN.GPD = 100 +OEMPREAN.INI = 100 + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +MS="Microsoft WDK Sample" diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean.ini b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.ini new file mode 100644 index 00000000..ad5eed92 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.ini @@ -0,0 +1,4 @@ +[OEMFiles] +OEMDriverFile1=OEMPREAN.DLL + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/ddihook.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/ddihook.cpp new file mode 100644 index 00000000..b3843090 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/ddihook.cpp @@ -0,0 +1,2069 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: DDIHook.cpp +// +// +// PURPOSE: DDI Hook routines for User Mode COM Customization DLL. +// +// This module implements the following functions defined in printoem.h: +// OEMCopyBits +// OEMBitBlt +// OEMStretchBlt +// OEMDitherColor +// OEMStretchBltROP +// OEMPlgBlt +// OEMPaint +// OEMRealizeBrush +// OEMStrokePath +// OEMFillPath +// OEMStrokeAndFillPath +// OEMLineTo +// OEMAlphaBlend +// OEMGradientFill +// OEMTransparentBlt +// OEMTextOut +// OEMQueryFont +// OEMQueryFontTree +// OEMQueryFontData +// OEMFontManagement +// OEMQueryAdvanceWidths +// OEMGetGlyphMode +// OEMStartDoc +// OEMEndDoc +// OEMStartPage +// OEMSendPage +// OEMStartBanding +// OEMNextBand +// OEMEscape +// +// History: +// 06/24/03 xxx created. +// +// + +#include "precomp.h" +#include "oemprean.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +BOOL APIENTRY +OEMCopyBits( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + POINTL *pptlSrc + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvCopyBits. + + DrvCopyBits translates between device-managed + raster surfaces and GDI standard-format bitmaps. + GDI will call DrvCopyBits when it needs to copy from + one surface to another and at least one of the + surfaces is device-managed. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Points to the Dstination surface + psoSrc - Points to the source surface + pxlo - XLATEOBJ provided by the engine + pco - Defines a clipping region on the Dstination surface + pxlo - Defines the translation of color indices + between the source and target surfaces + prclDst - Defines the area to be modified + pptlSrc - Defines the upper-left corner of the source rectangle + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMCopyBits entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMCopyBits: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMCopyBits: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvCopyBits)(psoDst, + psoSrc, + pco, + pxlo, + prclDst, + pptlSrc); +} + +BOOL APIENTRY +OEMBitBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + POINTL *pptlSrc, + POINTL *pptlMask, + BRUSHOBJ *pbo, + POINTL *pptlBrush, + ROP4 rop4 + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvBitBlt. + + DrvBitBlt provides general bit-block transfer capabilities + between device-managed surfaces, between GDI-managed + standard-format bitmaps, or between a device-managed + surface and a GDI-managed standard-format bitmap. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Describes the target surface + psoSrc - Describes the source surface + psoMask - Describes the mask for rop4 + pco - Limits the area to be modified + pxlo - Specifies how color indices are translated + between the source and target surfaces + prclDst - Defines the area to be modified + pptlSrc - Defines the upper left corner of the source rectangle + pptlMask - Defines which pixel in the mask corresponds to + the upper left corner of the source rectangle + pbo - Defines the pattern for bitblt + pptlBrush - Defines the origin of the brush in the Dstination surface + rop4 - ROP code that defines how the mask, pattern, source, and + Dstination pixels are combined to write to the Dstination surface + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMBitBlt entry."); + + DBG_SURFOBJ(DBG_VERBOSE, L"psoDst", psoDst); + DBG_SURFOBJ(DBG_VERBOSE, L"psoSrc", psoSrc); + DBG_SURFOBJ(DBG_VERBOSE, L"psoMask", psoMask); + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + DBG_XLATEOBJ(DBG_VERBOSE, L"pxlo", pxlo); + DBG_RECTL(DBG_VERBOSE, L"prclDst", prclDst); + DBG_POINTL(DBG_VERBOSE, L"pptlSrc", pptlSrc); + DBG_POINTL(DBG_VERBOSE, L"pptlMask", pptlMask); + DBG_BRUSHOBJ(DBG_VERBOSE, L"pbo", pbo); + DBG_POINTL(DBG_VERBOSE, L"pptlBrush", pptlBrush); + VERBOSE(TEXT("\nrop4: %#x\r\n\n"), rop4); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMBitBlt: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMBitBlt: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvBitBlt)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + prclDst, + pptlSrc, + pptlMask, + pbo, + pptlBrush, + rop4); +} + +BOOL APIENTRY +OEMStretchBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDst, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStretchBlt. + + DrvStretchBlt provides stretching bit-block transfer + capabilities between any combination of device-managed + and GDI-managed surfaces. DrvStretchBlt enables the + device driver to write to GDI bitmaps, especially when the + driver can do halftoning. This function allows the same + halftoning algorithm to be applied to GDI bitmaps and + device surfaces. This function can be provided to handle + only certain forms of stretching, such as by integer multiples. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Defines the surface on which to draw + psoSrc - Defines the source for blt operation + psoMask - Defines a surface that provides a mask for the source + pco - Limits the area to be modified on the Dstination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + pca - Defines color adjustment values to be applied to the source bitmap + pptlHTOrg - Specifies the origin of the halftone brush + prclDst - Defines the area to be modified on the Dstination surface + prclSrc - Defines the area to be copied from the source surface + pptlMask - Specifies which pixel in the given mask corresponds to + the upper left pixel in the source rectangle + iMode - Specifies how source pixels are combined to get output pixels + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMStretchBlt entry."); + + DBG_SURFOBJ(DBG_VERBOSE, L"psoDst", psoDst); + DBG_SURFOBJ(DBG_VERBOSE, L"psoSrc", psoSrc); + DBG_SURFOBJ(DBG_VERBOSE, L"psoMask", psoMask); + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + DBG_XLATEOBJ(DBG_VERBOSE, L"pxlo", pxlo); + DBG_COLORADJUSTMENT(DBG_VERBOSE, L"pca", pca); + DBG_POINTL(DBG_VERBOSE, L"pptlHTOrg", pptlHTOrg); + DBG_RECTL(DBG_VERBOSE, L"prclDst", prclDst); + DBG_RECTL(DBG_VERBOSE, L"prclSrc", prclSrc); + DBG_POINTL(DBG_VERBOSE, L"pptlMask", pptlMask); + VERBOSE(TEXT("\niMode: %#x\r\n\n"), iMode); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMStretchBlt: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMStretchBlt: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStretchBlt)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDst, + prclSrc, + pptlMask, + iMode); +} + +ULONG APIENTRY +OEMDitherColor( + DHPDEV dhpdev, + ULONG iMode, + ULONG rgbColor, + ULONG *pulDither + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvDitherColor. + + DrvDitherColor requests the device to create a + brush dithered against a device palette. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - DHPDEV passed, it is our pDEV + iMode - Not used + rgbColor - Solid rgb color to be used + pulDither - buffer to put the halftone brush. + +Return Value: + + Returns halftone method. + + DCR_DRIVER if the dither values have been calculated by the driver. + DCR_SOLID if the engine should use the best solid color approximation of the color. + DCR_HALFTONE if the engine should create a halftone approximation for the driver. + +--*/ + +{ + VERBOSE(L"OEMDitherColor entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvDitherColor)(dhpdev, + iMode, + rgbColor, + pulDither); +} + +BOOL APIENTRY +OEMStretchBltROP( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDst, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode, + BRUSHOBJ *pbo, + ROP4 rop4 + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStretchBltROP. + + DrvStretchBltROP performs a stretching bit-block transfer + using a ROP. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Specifies the target surface + psoSrc - Specifies the source surface + psoMask - Specifies the mask surface + pco - Limits the area to be modified + pxlo - Specifies how color indices are translated + between the source and target surfaces + pca - Defines color adjustment values to be applied to the source bitmap + pptlHTOrg - Specifies the halftone origin + prclDst - Area to be modified on the destination surface + prclSrc - Rectangle area on the source surface + pptlMask - Defines which pixel in the mask corresponds to + the upper left corner of the source rectangle + iMode - Specifies how source pixels are combined to get output pixels + pbo - Defines the pattern for bitblt + rop4 - ROP code that defines how the mask, pattern, source, and + destination pixels are combined on the destination surface + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMStretchBltROP entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMStretchBltROP: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMStretchBltROP: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStretchBltROP)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDst, + prclSrc, + pptlMask, + iMode, + pbo, + rop4); +} + +BOOL APIENTRY +OEMPlgBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlBrushOrg, + POINTFIX *pptfixDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) +/*++ + +Routine Description: + + Implementation of DDI hook for DrvPlgBlt. + + DrvPlgBlt provides rotate bit-block transfer capabilities between + combinations of device-managed and GDI-managed surfaces. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Defines the surface on which to draw + psoSrc - Defines the source for blt operation + psoMask - Defines a surface that provides a mask for the source + pco - Limits the area to be modified on the Dstination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + pca - Defines color adjustment values to be applied to the source bitmap + pptlBrushOrg - Specifies the origin of the halftone brush + pptfixDest - Defines the area to be modified on the Dstination surface + prclSrc - Defines the area to be copied from the source surface + pptlMask - Specifies which pixel in the given mask corresponds to + the upper left pixel in the source rectangle + iMode - Specifies how source pixels are combined to get output pixels + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMPlgBlt entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMPlgBlt: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMPlgBlt: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvPlgBlt)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlBrushOrg, + pptfixDest, + prclSrc, + pptlMask, + iMode); +} + +BOOL APIENTRY +OEMPaint( + SURFOBJ *pso, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + MIX mix + ) +/*++ + +Routine Description: + + Implementation of DDI hook for DrvPaint. + + DrvPaint is an obsolete function. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to draw + pco - Limits the area to be modified on the Dstination + pbo - Points to a BRUSHOBJ which defined the pattern and colors to fill with + pptlBrushOrg - Specifies the origin of the halftone brush + mix - Defines the foreground and background raster operations to use for + the brush + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMPaint entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMPaint: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMPaint: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvPaint)(pso, + pco, + pbo, + pptlBrushOrg, + mix); +} + +BOOL APIENTRY +OEMRealizeBrush( + BRUSHOBJ *pbo, + SURFOBJ *psoTarget, + SURFOBJ *psoPattern, + SURFOBJ *psoMask, + XLATEOBJ *pxlo, + ULONG iHatch + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvRealizeBrush. + + DrvRealizeBrush requests that the driver realize a specified brush + for a specified surface. To realize a brush, the driver converts a + GDI brush into a form that can be used internally. A realized brush + contains device-specific information needed by the device to + accelerate drawing using the brush. The driver's realization of a brush + is written into the buffer allocated by a call to BRUSHOBJ_pvAllocRBrush. + + Please refer to DDK documentation for more details. + +Arguments: + + pbo - BRUSHOBJ to be realized + psoTarget - Defines the surface for which the brush is to be realized + psoPattern - Defines the pattern for the brush + psoMask - Transparency mask for the brush + pxlo - Defines the interpretration of colors in the pattern + iHatch - Specifies whether psoPattern is one of the hatch brushes + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMRealizeBrush entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoTarget->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvRealizeBrush)(pbo, + psoTarget, + psoPattern, + psoMask, + pxlo, + iHatch); +} + +BOOL APIENTRY +OEMStrokePath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + LINEATTRS *plineattrs, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStrokePath. + + DrvStrokePath strokes a path when called by GDI. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Identifies the surface on which to draw + ppo - Defines the path to be stroked + pco - Defines the clipping path + pxo - Specifies the world to device coordinate transformation + pbo - Specifies the brush to be used when drawing the path + pptlBrushOrg - Defines the brush origin + plineattrs - Defines the line attributes + mix - Specifies how to combine the brush with the destination + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE(L"OEMStrokePath entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMStrokePath: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMStrokePath: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStrokePath)(pso, + ppo, + pco, + pxo, + pbo, + pptlBrushOrg, + plineattrs, + mix); +} + +BOOL APIENTRY +OEMFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + MIX mix, + FLONG flOptions + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvFillPath. + + DrvFillPath is an optional entry point to handle the filling of closed paths. + GDI can call DrvFillPath to fill a path on a device-managed surface. + When deciding whether to call this function, GDI compares the fill + requirements with the following flags in the flGraphicsCaps member of + the DEVINFO structure: GCAPS_BEZIERS, GCAPS_ALTERNATEFILL, + and GCAPS_WINDINGFILL. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to draw. + ppo - Defines the path to be filled + pco - Defines the clipping path + pbo - Defines the pattern and colors to fill with + pptlBrushOrg - Defines the brush origin + mix - Defines the foreground and background ROPs to use for the brush + flOptions - Whether to use zero-winding or odd-even rule + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE(L"OEMFillPath entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMFillPath: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMFillPath: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvFillPath)(pso, + ppo, + pco, + pbo, + pptlBrushOrg, + mix, + flOptions); +} + +BOOL APIENTRY +OEMStrokeAndFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pboStroke, + LINEATTRS *plineattrs, + BRUSHOBJ *pboFill, + POINTL *pptlBrushOrg, + MIX mixFill, + FLONG flOptions + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStrokeAndFillPath. + + DrvStrokeAndFillPath strokes and fills a path concurrently. + The driver can return FALSE if the path or the clipping is too + complex for the device to handle; in that case, GDI converts + to a simpler call. For example, if the device driver has set the + GCAPS_BEZIERS flag in the flGraphicsCaps member of the + DEVINFO structure and then receives a path with Bezier curves, + it can return FALSE; GDI will then convert the Bezier curves to + lines and call DrvStrokeAndFillPath again. If the device driver + returns FALSE again, GDI will further simplify the call, making + calls to DrvStrokePath and DrvFillPath, or to DrvBitBlt, depending + on the mix and width of the lines making up the path. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Describes the surface on which to draw + ppo - Describes the path to be filled + pco - Defines the clipping path + pxo - Specifies the world to device coordinate transformation + pboStroke - Specifies the brush to use when stroking the path + plineattrs - Specifies the line attributes + pboFill - Specifies the brush to use when filling the path + pptlBrushOrg - Specifies the brush origin for both brushes + mixFill - Specifies the foreground and background ROPs to use + for the fill brush + flOptions - Whether to use zero-winding or odd-even rule + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE(L"OEMStrokeAndFillPath entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMStrokeAndFillPath: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMStrokeAndFillPath: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStrokeAndFillPath)(pso, + ppo, + pco, + pxo, + pboStroke, + plineattrs, + pboFill, + pptlBrushOrg, + mixFill, + flOptions); +} + +BOOL APIENTRY +OEMLineTo( + SURFOBJ *pso, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + LONG x1, + LONG y1, + LONG x2, + LONG y2, + RECTL *prclBounds, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvLineTo. + + DrvLineTo draws a single, solid, integer-only cosmetic line. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Describes the surface on which to draw + pco - Defines the clipping path + pbo - Defines the brush used to draw the line + x1,y1 - Specifies the line's starting point + x2,y2 - Specifies the line's ending point + prclBounds - Defines a rectangle that bounds the unclipped line. + mix - Specifies the foreground and background ROP + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE(L"OEMLineTo entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMLineTo: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMLineTo: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvLineTo)(pso, + pco, + pbo, + x1, + y1, + x2, + y2, + prclBounds, + mix); +} + +BOOL APIENTRY +OEMAlphaBlend( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDest, + RECTL *prclSrc, + BLENDOBJ *pBlendObj + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvAlphaBlend. + + DrvAlphaBlend provides bit-block transfer capabilities with alpha blending. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDest - Defines the surface on which to draw + psoSrc - Defines the source + pco - Limits the area to be modified on the Destination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + prclDest - Defines the area to be modified on the Destination surface + prclSrc - Defines the area to be copied from the source surface + BlendFunction - Specifies the blend function to be used + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMAlphaBlend entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDest->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMAlphaBlend: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMAlphaBlend: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvAlphaBlend)(psoDest, + psoSrc, + pco, + pxlo, + prclDest, + prclSrc, + pBlendObj); +} + +BOOL APIENTRY +OEMGradientFill( + SURFOBJ *psoDest, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + TRIVERTEX *pVertex, + ULONG nVertex, + PVOID pMesh, + ULONG nMesh, + RECTL *prclExtents, + POINTL *pptlDitherOrg, + ULONG ulMode + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvGradientFill. + + DrvGradientFill shades the specified primitives. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDest - Defines the surface on which to draw + pco - Limits the area to be modified on the Destination + pxlo - Should be ignored by the driver + pVertex - Pointer to an array of TRIVERTEX structures, + with each entry containing position and color information + nVertex - Specifies the number of TRIVERTEX structures in the + array to which pVertex points + pMesh - Pointer to an array of structures that define the connectivity + of the TRIVERTEX elements to which pVertex points + nMesh - Specifies the number of elements in the array to which + pMesh points + prclExtents - Pointer to a RECTL structure that defines the area in + which the gradient drawing is to occur + pptlDitherOrg - Pointer to a POINTL structure that defines the origin + on the surface for dithering + ulMode - Specifies the current drawing mode and how to interpret + the array to which pMesh points + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMGradientFill entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDest->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMGradientFill: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMGradientFill: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvGradientFill)(psoDest, + pco, + pxlo, + pVertex, + nVertex, + pMesh, + nMesh, + prclExtents, + pptlDitherOrg, + ulMode); +} + +BOOL APIENTRY +OEMTransparentBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + RECTL *prclSrc, + ULONG iTransColor, + ULONG ulReserved + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvTransparentBlt. + + DrvTransparentBlt provides bit-block transfer capabilities with + transparency. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Defines the surface on which to draw + psoSrc - Defines the source + pco - Limits the area to be modified on the Destination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + prclDst - Defines the area to be modified on the Destination surface + prclSrc - Defines the area to be copied from the source surface + iTransColor - Specifies the transparent color + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMTransparentBlt entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMTransparentBlt: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMTransparentBlt: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvTransparentBlt)(psoDst, + psoSrc, + pco, + pxlo, + prclDst, + prclSrc, + iTransColor, + ulReserved); +} + +BOOL APIENTRY +OEMTextOut( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvTextOut. + + DrvTextOut is the entry point from GDI that calls for the + driver to render a set of glyphs at specified positions. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to be written. + pstro - Defines the glyphs to be rendered and their positions + pfo - Specifies the font to be used + pco - Defines the clipping path + prclExtra - A NULL-terminated array of rectangles to be filled + prclOpaque - Specifies an opaque rectangle + pboFore - Defines the foreground brush + pboOpaque - Defines the opaque brush + pptlOrg - Pointer to POINT struct , defining th origin + mix - Specifies the foreground and background ROPs for pboFore + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMTextOut entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + DBG_SURFOBJ(DBG_VERBOSE, L"pso", pso); + DBG_STROBJ(DBG_VERBOSE, L"pstro", pstro); + DBG_FONTOBJ(DBG_VERBOSE, L"pfo", pfo); + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + DBG_BRUSHOBJ(DBG_VERBOSE, L"pboFore", pboFore); + DBG_BRUSHOBJ(DBG_VERBOSE, L"pboOpaque", pboOpaque); + + if (pOemPDEV->bPreAnalysis) + { + VERBOSE(TEXT("OEMTextOut: Begin pre-analysis...\r\n")); + + // Since the bPreAnalysis flag is set, this indicates that the current pass is the pre-analysis pass. + // Perform any pre-analysis tasks here. Note that the surface used during pre-analysis might + // differ from the surface passed in during the rendering pass. + + // Dump the bounds of the clip window available for pre-analysis. + DBG_CLIPOBJ(DBG_VERBOSE, L"pco", pco); + + // Although unidrv calls the hooked drawing functions, it will return before any drawing is done. + // So we should not perform any drawing on the surface. But all other pre-analysis tasks should + // be performed here. For example, certain printers need to handle black objects differently if + // they intersect with any color objects versus being stand alone. Another task could be to halftone + // stretchblt objects differently from bitblt objects. Basically, the plug-in can analyze the objects on the page. + + // During the pre-analysis pass, drawing functions should not call back into Unidrv. + // So we return here. + VERBOSE(TEXT("OEMTextOut: End pre-analysis...\r\n")); + + return TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvTextOut)(pso, + pstro, + pfo, + pco, + prclExtra, + prclOpaque, + pboFore, + pboOpaque, + pptlOrg, + mix); +} + +PIFIMETRICS APIENTRY +OEMQueryFont( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG_PTR *pid + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryFont. + + DrvQueryFont is used by GDI to get the IFIMETRICS structure + for a given font. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + iFile - Identifies the driver font file + iFace - One-based index of the driver font + pid - Points to a LONG variable for returning an identifier + which GDI will pass to DrvFree + +Return Value: + + Pointer to an IFIMETRICS structure for the given font. + NULL if there is an error + +--*/ + +{ + VERBOSE(L"OEMQueryFont entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryFont)(dhpdev, + iFile, + iFace, + pid); +} + +PVOID APIENTRY +OEMQueryFontTree( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG iMode, + ULONG_PTR *pid + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryFontTree. + + DrvQueryFontTree provides GDI with a pointer to a structure that + defines one of the following: + - A mapping from Unicode to glyph handles, including glyph variants + - A mapping of kerning pairs to kerning handles + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + iFile - Identifies the driver font file + iFace - One-based index of the driver font + iMode - Specifies the type of information to be provided + pid - Points to a LONG variable for returning an identifier + which GDI will pass to DrvFree + +Return Value: + + Pointer to the structure requested based on iMode. + NULL if there is an error + +--*/ + +{ + VERBOSE(L"OEMQueryFontTree entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryFontTree)(dhpdev, + iFile, + iFace, + iMode, + pid); +} + +LONG APIENTRY +OEMQueryFontData( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH hg, + GLYPHDATA *pgd, + _Out_writes_bytes_(cjSize) PVOID pv, + ULONG cjSize + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryFontData. + + DrvQueryFontData retrieves information about a realized font. + GDI provides a pointer to an array of glyph or kerning handles, + and the driver returns information about the glyphs or kerning + pairs. The driver can assume that all handles in the array are valid. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + pfo - Points to a FONTOBJ structure + iMode - Type of information requested + hg - A glyph handle + pgd - Points to a GLYPHDATA structure + pv - Points to output buffer + cjSize - Size of output buffer + +Return Value: + + Depends on iMode. FD_ERROR if there is an error + +--*/ + +{ + VERBOSE(L"OEMQueryFontData entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryFontData)(dhpdev, + pfo, + iMode, + hg, + pgd, + pv, + cjSize); +} + +ULONG APIENTRY +OEMFontManagement( + SURFOBJ *pso, + FONTOBJ *pfo, + ULONG iMode, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvFontManagement. + + Is this function valid for Unidrv drivers? + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Points to a SURFOBJ structure + pfo - Points to a FONTOBJ structure + iMode - Escape number + cjIn - Size of input buffer + pvIn - Points to input buffer + cjOut - Size of output buffer + pvOut - Points to output buffer + +Return Value: + + 0x00000001 to 0x7fffffff for success + 0x80000000 to 0xffffffff for failure + 0 if the specified escape number if not supported + +--*/ + +{ + VERBOSE(L"OEMFontManagement entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvFontManagement)(pso, + pfo, + iMode, + cjIn, + pvIn, + cjOut, + pvOut); +} + +BOOL APIENTRY +OEMQueryAdvanceWidths( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + _In_reads_(cGlyphs) HGLYPH *phg, + _Out_writes_bytes_(cGlyphs*sizeof(USHORT)) PVOID pvWidths, + ULONG cGlyphs + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryAdvanceWidths. + + DrvQueryAdvanceWidths returns character advance widths + for a specified set of glyphs. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + pfo - Points to a FONTOBJ structure + iMode - Type of information to be provided + phg - Points to an array of HGLYPHs for which the driver will + provide character advance widths + pvWidths - Points to a buffer for returning width data + cGlyphs - Number of glyphs in the phg array + +Return Value: + + Depends on iMode + +--*/ + +{ + VERBOSE(L"OEMQueryAdvanceWidths entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryAdvanceWidths)(dhpdev, + pfo, + iMode, + phg, + pvWidths, + cGlyphs); +} + +ULONG APIENTRY +OEMGetGlyphMode( + DHPDEV dhpdev, + FONTOBJ *pfo + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvGetGlyphMode. + + DrvGetGlyphMode tells GDI how to cache glyph information. + GDI calls a driver's DrvGetGlyphMode routine to determine the + range of font information that should be cached for a particular + font; that is, DrvGetGlyphMode determines what GDI stores in + its font cache. A device that caches fonts on its own should return + FO_HGLYPHS to minimize the storage requirements for the font. + GDI calls DrvGetGlyphMode for each font realization. For example, + a driver might want to download outlines for point sizes larger than + 12 point, but raster images for smaller fonts. However, GDI reserves + the right to refuse this request. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + pfo - Points to a FONTOBJ structure + +Return Value: + + The glyph mode or FO_GLYPHMODE, which is the default. + +--*/ + +{ + VERBOSE(L"OEMGetGlyphMode entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvGetGlyphMode)(dhpdev, + pfo); +} + +BOOL APIENTRY +OEMStartDoc( + SURFOBJ *pso, + _In_ PWSTR pwszDocName, + DWORD dwJobId + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStartDoc. + + DrvStartDoc is called by GDI when it is ready to + start sending a document to the driver for rendering. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + pDocName - Specifies a Unicode document name + jobId - Identifies the print job + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMStartDoc entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStartDoc)(pso, + pwszDocName, + dwJobId); +} + +BOOL APIENTRY +OEMEndDoc( + SURFOBJ *pso, + FLONG fl + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvEndDoc. + + DrvEndDoc is called by GDI when it has finished + sending a document to the driver for rendering. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + flags - A set of flag bits + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMEndDoc entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvEndDoc)(pso, + fl); +} + +BOOL APIENTRY +OEMStartPage( + SURFOBJ *pso + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStartPage. + + DrvStartPage is called by GDI when it is ready to + start sending the contents of a physical page to the + driver for rendering. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMStartPage entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStartPage)(pso); +} + +BOOL APIENTRY +OEMSendPage( + SURFOBJ *pso + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvSendPage. + + DrvSendPage is called by GDI when it has finished + drawing a physical page, so the driver can send + the page to the printer. + + Please refer to DDK documentation for more details. + + NOTE: OEMSendPage will not be called in any driver that enables + pre-analysis. But the reason we implement this is that the driver + might be pushed to a down-level client and thereby have to run + without pre-analysis support. In this case, it might have to support + OEMSendPage. + +Arguments: + + pso - Defines the surface object + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMSendPage entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvSendPage)(pso); +} + +BOOL APIENTRY +OEMStartBanding( + SURFOBJ *pso, + POINTL *pptl + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStartBanding. + + DrvStartBanding is called by GDI when it is ready to start + sending bands of a physical page to the driver for rendering. + Note: DrvStartBanding is called to prepare the driver + for banding, call only once per page (not at everyband!!) + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + pptl - Pointer to origin of next band (to return to GDI) + +Return Value: + + Fill out pptl to contain the origin of the first band + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMStartBanding entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + DBG_POINTL(DBG_VERBOSE, L"pptl", pptl); + + if (pptl == NULL) + { + VERBOSE(TEXT("OEMStartBanding: Start of OEM Pre-analysis pass...\r\n")); + VERBOSE(TEXT("\tOEM Pre-analysis pass...no drawing on surface in this pass.\r\n")); + pOemPDEV->bPreAnalysis = TRUE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStartBanding)(pso, + pptl); +} + +BOOL APIENTRY +OEMNextBand( + SURFOBJ *pso, + POINTL *pptl + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvNextBand. + + DrvNextBand is called by GDI when it has finished + drawing a band for a physical page, so the driver + can send the band to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + pptl - Pointer to origin of next band (to return to GDI) + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"OEMNextBand entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + DBG_POINTL(DBG_VERBOSE, L"pptl", pptl); + + if (pOemPDEV->bPreAnalysis) + { + // + // First call into OEMNextBand indicates end of pre-analysis path. + // + VERBOSE(TEXT("OEMNextBand: End of OEM Pre-analysis pass...\r\n")); + pOemPDEV->bPreAnalysis = FALSE; + } + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvNextBand)(pso, + pptl); +} + +ULONG APIENTRY +OEMEscape( + SURFOBJ *pso, + ULONG iEsc, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) + +/*++ + +Routine Description: + + Implementation of DDI entry point DrvEscape. + + DrvEscape is used for retrieving information from a device + that is not available in a device-independent device driver + interface; the particular query depends on the value of the + iEsc parameter. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Describes the surface the call is directed to + iEsc - Specifies a query + cjIn - Specifies the size in bytes of the buffer pointed to by pvIn + pvIn - Points to input data buffer + cjOut - Specifies the size in bytes of the buffer pointed to by pvOut + pvOut - Points to the output buffer + +Return Value: + + Depends on the query specified by iEsc parameter. + + Zero if the function specified by the query is not supported. + +--*/ + +{ + VERBOSE(L"OEMEscape entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvEscape)(pso, + iEsc, + cjIn, + pvIn, + cjOut, + pvOut); +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.cpp new file mode 100644 index 00000000..f1807066 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.cpp @@ -0,0 +1,1503 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.cpp +// +// PURPOSE: Implementation of the debug functions. +// +// +// History: +// 06/28/03 xxx created. +// +// + +#include "precomp.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// INTERNAL DEFINES +//////////////////////////////////////////////////////// + +#define DEBUG_BUFFER_SIZE 1024 +#define PATH_SEPARATOR '\\' + +//////////////////////////////////////////////////////// +// EXTERNAL GLOBALS +//////////////////////////////////////////////////////// + +#ifdef DBG + +INT giDebugLevel = DEBUG_LEVEL; + + +PCWSTR +EnsureLabel( + _In_opt_ PCWSTR pszInLabel, + _In_ PCWSTR pszDefLabel + ) + +/*++ + +Routine Description: + + This function checks if pszInLabel is valid. If not, it returns + pszDefLabel else pszInLabel is returned. + +Arguments: + + pszInLabel - custom label string passed in with the call to the dump function + pszDefLabel - default label string in case custom label string is not valid + +Return Value: + + pszInLabel if it is valid, else pszDefLabel + +--*/ + +{ + // By design, pszDefLabel is assumed to be a valid, non-empty + // string (since it is supplied internally). + // + if (!pszInLabel || !*pszInLabel) + { + // The caller supplied a NULL string or empty string; + // supply the internal default. + // + return pszDefLabel; + } + + return pszInLabel; +} + +BOOL OEMDebugMessage( + LPCWSTR lpszMessage, + ... + ) + +/*++ + +Routine Description: + + Outputs variable argument debug string. + +Arguments: + + dwSize - size of temp buffer to hold formatted string + lpszMessage - format string + arglist - Variable argument list... + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + va_list VAList; + HRESULT hResult; + + // Parameter checking. + if( NULL == lpszMessage) + { + return FALSE; + } + + LPWSTR lpszMsgBuf = new WCHAR[DEBUG_BUFFER_SIZE]; + if(NULL == lpszMsgBuf) + return FALSE; + + va_start(VAList, lpszMessage); + // Pass the variable parameters to wvsprintf to be formatted. + hResult = StringCchVPrintfW(lpszMsgBuf, DEBUG_BUFFER_SIZE, lpszMessage, VAList); + va_end(VAList); + + // Dump string to debug output. + OutputDebugStringW(lpszMsgBuf); + + // Clean up. + delete[] lpszMsgBuf; + + return SUCCEEDED(hResult); +} + +PCSTR +StripDirPrefixA( + IN PCSTR pstrFilename + ) + +/*++ + +Routine Description: + + Strip the directory prefix off a filename (ANSI version) + +Arguments: + + pstrFilename - Pointer to filename string + +Return Value: + + Pointer to the last component of a filename (without directory prefix) + +--*/ + +{ + PCSTR pstr; + + pstr = strrchr(pstrFilename, PATH_SEPARATOR); + if (pstr) + return pstr + 1; + + return pstrFilename; +} + +void +vDumpFlags( + DWORD dwFlags, + PDBG_FLAGS pDebugFlags + ) + +/*++ + +Routine Description: + + Dumps the combination of flags in members such as + pso->fjBitmap, pstro->flAccel, pfo->flFontType etc. + +Arguments: + + dwFlags - combined value of the relevant member + Example values are pso->fjBitmap, pstro->flAccel + pDebugFlags - structure containing the different possible values + that can be combined in dwFlags + +Return Value: + + NONE + +--*/ + +{ + DWORD dwFound = 0; + BOOL bFirstFlag = FALSE; + + OEMDebugMessage(L"%#x [", dwFlags); + + // Traverse through the list of flags to see if any match + // + for ( ; pDebugFlags->dwFlag; ++pDebugFlags) + { + if(dwFlags & pDebugFlags->dwFlag) + { + if (!bFirstFlag) + { + OEMDebugMessage(L"%s", pDebugFlags->pszFlag); + bFirstFlag = TRUE; + } + else + { + OEMDebugMessage(L" | %s", pDebugFlags->pszFlag); + } + dwFound |= pDebugFlags->dwFlag; + } + } + + OEMDebugMessage(L"]"); + + // + // Check if there are extra bits set that we don't understand. + // + if(dwFound != dwFlags) + { + OEMDebugMessage(L" ", dwFlags & ~dwFound); + } + + OEMDebugMessage(L"\r\n"); +} + +void +vDumpOemDMParam( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + POEMDMPARAM pOemDMParam + ) + +/*++ + +Routine Description: + + Dumps the members of a OEMDMPARAM structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pOemDMParam - pointer to the OEMDMPARAM strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pOemDMParam"); + + // Return if strct to be dumped is invalid + // + if (!pOemDMParam) + { + OEMDebugMessage(L"\npOemDMParam [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\npOemDMParam [%s]: %#x\r\n", pszLabel, pOemDMParam); + OEMDebugMessage(L"\tcbSize = %d\r\n", pOemDMParam->cbSize); + OEMDebugMessage(L"\tpdriverobj = %#x\r\n", pOemDMParam->pdriverobj); + OEMDebugMessage(L"\thPrinter = %#x\r\n", pOemDMParam->hPrinter); + OEMDebugMessage(L"\thModule = %#x\r\n", pOemDMParam->hModule); + OEMDebugMessage(L"\tpPublicDMIn = %#x\r\n", pOemDMParam->pPublicDMIn); + OEMDebugMessage(L"\tpPublicDMOut = %#x\r\n", pOemDMParam->pPublicDMOut); + OEMDebugMessage(L"\tpOEMDMIn = %#x\r\n", pOemDMParam->pOEMDMIn); + OEMDebugMessage(L"\tpOEMDMOut = %#x\r\n", pOemDMParam->pOEMDMOut); + OEMDebugMessage(L"\tcbBufSize = %d\r\n", pOemDMParam->cbBufSize); + + OEMDebugMessage(L"\n"); + +} + +#if DBG + DBG_FLAGS gafdSURFOBJ_fjBitmap[] = { + { L"BMF_TOPDOWN", BMF_TOPDOWN}, + { L"BMF_NOZEROINIT", BMF_NOZEROINIT}, + { L"BMF_DONTCACHE", BMF_DONTCACHE}, + { L"BMF_USERMEM", BMF_USERMEM}, + { L"BMF_KMSECTION", BMF_KMSECTION}, + { L"BMF_NOTSYSMEM", BMF_NOTSYSMEM}, + { L"BMF_WINDOW_BLT", BMF_WINDOW_BLT}, + {NULL, 0} // The NULL entry is important +// { L"BMF_UMPDMEM", BMF_UMPDMEM}, +// { L"BMF_RESERVED", BMF_RESERVED}, + }; +#else + DBG_FLAGS gafdSURFOBJ_fjBitmap[] = { + {NULL, 0} + }; +#endif + +void +vDumpSURFOBJ( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + SURFOBJ *pso + ) + +/*++ + +Routine Description: + + Dumps the members of a SURFOBJ structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pso - pointer to the SURFOBJ strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pso"); + + // Return if strct to be dumped is invalid + // + if (!pso) + { + OEMDebugMessage(L"\nSURFOBJ [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nSURFOBJ [%s]: %#x\r\n", pszLabel, pso); + OEMDebugMessage(L"\tdhSurf: %#x\r\n", pso->dhsurf); + OEMDebugMessage(L"\thSurf: %#x\r\n", pso->hsurf); + OEMDebugMessage(L"\tdhpdev: %#x\r\n", pso->dhpdev); + OEMDebugMessage(L"\thdev: %#x\r\n", pso->hdev); + OEMDebugMessage(L"\tsizlBitmap: [%ld x %ld]\r\n", pso->sizlBitmap.cx, pso->sizlBitmap.cy); + OEMDebugMessage(L"\tcjBits: %ld\r\n", pso->cjBits); + OEMDebugMessage(L"\tpvBits: %#x\r\n", pso->pvBits); + OEMDebugMessage(L"\tpvScan0: %#x\r\n", pso->pvScan0); + OEMDebugMessage(L"\tlDelta: %ld\r\n", pso->lDelta); + OEMDebugMessage(L"\tiUniq: %ld\r\n", pso->iUniq); + + PWSTR psziBitmapFormat = L"0"; + switch (pso->iBitmapFormat) + { + case BMF_1BPP : psziBitmapFormat = L"BMF_1BPP" ; break; + case BMF_4BPP : psziBitmapFormat = L"BMF_4BPP" ; break; + case BMF_8BPP : psziBitmapFormat = L"BMF_8BPP" ; break; + case BMF_16BPP: psziBitmapFormat = L"BMF_16BPP"; break; + case BMF_24BPP: psziBitmapFormat = L"BMF_24BPP"; break; + case BMF_32BPP: psziBitmapFormat = L"BMF_32BPP"; break; + case BMF_4RLE : psziBitmapFormat = L"BMF_4RLE" ; break; + case BMF_8RLE : psziBitmapFormat = L"BMF_8RLE" ; break; + case BMF_JPEG : psziBitmapFormat = L"BMF_JPEG" ; break; + case BMF_PNG : psziBitmapFormat = L"BMF_PNG " ; break; + } + OEMDebugMessage(L"\tiBitmapFormat: %s\r\n", psziBitmapFormat); + + PWSTR psziType = L"0"; + switch (pso->iType) + { + case STYPE_BITMAP : psziType = L"STYPE_BITMAP" ; break; + case STYPE_DEVBITMAP: psziType = L"STYPE_DEVBITMAP"; break; + case STYPE_DEVICE : psziType = L"STYPE_DEVICE" ; break; + } + OEMDebugMessage(L"\tiType: %s\r\n", psziType); + + OEMDebugMessage(L"\tfjBitmap: "); + if (STYPE_BITMAP == pso->iType) + vDumpFlags(pso->fjBitmap, gafdSURFOBJ_fjBitmap); + else + OEMDebugMessage(L"IGNORE\r\n"); + + OEMDebugMessage(L"\n"); + +} + +#if DBG + DBG_FLAGS gafdSTROBJ_flAccel[] = { + { L"SO_FLAG_DEFAULT_PLACEMENT", SO_FLAG_DEFAULT_PLACEMENT}, + { L"SO_HORIZONTAL", SO_HORIZONTAL}, + { L"SO_VERTICAL", SO_VERTICAL}, + { L"SO_REVERSED", SO_REVERSED}, + { L"SO_ZERO_BEARINGS", SO_ZERO_BEARINGS}, + { L"SO_CHAR_INC_EQUAL_BM_BASE", SO_CHAR_INC_EQUAL_BM_BASE}, + { L"SO_MAXEXT_EQUAL_BM_SIDE", SO_MAXEXT_EQUAL_BM_SIDE}, + { L"SO_DO_NOT_SUBSTITUTE_DEVICE_FONT", SO_DO_NOT_SUBSTITUTE_DEVICE_FONT}, + { L"SO_GLYPHINDEX_TEXTOUT", SO_GLYPHINDEX_TEXTOUT}, + { L"SO_ESC_NOT_ORIENT", SO_ESC_NOT_ORIENT}, + { L"SO_DXDY", SO_DXDY}, + { L"SO_CHARACTER_EXTRA", SO_CHARACTER_EXTRA}, + { L"SO_BREAK_EXTRA", SO_BREAK_EXTRA}, + {NULL, 0} // The NULL entry is important + }; +#else + DBG_FLAGS gafdSTROBJ_flAccel[] = { + {NULL, 0} + }; +#endif + +void +vDumpSTROBJ( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + STROBJ *pstro + ) + +/*++ + +Routine Description: + + Dumps the members of a STROBJ structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pstro - pointer to the STROBJ strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pstro"); + + // Return if strct to be dumped is invalid + // + if (!pstro) + { + OEMDebugMessage(L"\nSTROBJ [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nSTROBJ [%s]: %#x\r\n", pszLabel, pstro); + OEMDebugMessage(L"\tcGlyphs: %ld\r\n", pstro->cGlyphs); + OEMDebugMessage(L"\tflAccel: "); + vDumpFlags(pstro->flAccel, gafdSTROBJ_flAccel); + OEMDebugMessage(L"\tulCharInc: %ld\r\n", pstro->ulCharInc); + OEMDebugMessage(L"\trclBkGround: (%ld, %ld) (%ld, %ld)\r\n", pstro->rclBkGround.left, pstro->rclBkGround.top, pstro->rclBkGround.right, pstro->rclBkGround.bottom); + if (!pstro->pgp) + OEMDebugMessage(L"\tpgp: NULL\r\n"); + else + OEMDebugMessage(L"\tpgp: %#x\r\n", pstro->pgp); + OEMDebugMessage(L"\tpwszOrg: \"%s\"\r\n", pstro->pwszOrg); + + OEMDebugMessage(L"\n"); + +} + +#if DBG + DBG_FLAGS gafdFONTOBJ_flFontType[] = { + { L"FO_TYPE_RASTER", FO_TYPE_RASTER}, + { L"FO_TYPE_DEVICE", FO_TYPE_DEVICE}, + { L"FO_TYPE_TRUETYPE", FO_TYPE_TRUETYPE}, + { L"FO_TYPE_OPENTYPE", 0x8}, + { L"FO_SIM_BOLD", FO_SIM_BOLD}, + { L"FO_SIM_ITALIC", FO_SIM_ITALIC}, + { L"FO_EM_HEIGHT", FO_EM_HEIGHT}, + { L"FO_GRAY16", FO_GRAY16}, + { L"FO_NOGRAY16", FO_NOGRAY16}, + { L"FO_CFF", FO_CFF}, + { L"FO_POSTSCRIPT", FO_POSTSCRIPT}, + { L"FO_MULTIPLEMASTER", FO_MULTIPLEMASTER}, + { L"FO_VERT_FACE", FO_VERT_FACE}, + { L"FO_DBCS_FONT", FO_DBCS_FONT}, + {NULL, 0} // The NULL entry is important + }; +#else + DBG_FLAGS gafdFONTOBJ_flFontType[] = { + {NULL, 0} + }; +#endif + +void +vDumpFONTOBJ( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + FONTOBJ *pfo + ) + +/*++ + +Routine Description: + + Dumps the members of a FONTOBJ structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pfo - pointer to the FONTOBJ strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pfo"); + + // Return if strct to be dumped is invalid + // + if (!pfo) + { + OEMDebugMessage(L"\nFONTOBJ [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nFONTOBJ [%s]: %#x\r\n", pszLabel, pfo); + OEMDebugMessage(L"\tiUniq: %ld\r\n", pfo->iUniq); + OEMDebugMessage(L"\tiFace: %ld\r\n", pfo->iFace); + OEMDebugMessage(L"\tcxMax: %ld\r\n", pfo->cxMax); + OEMDebugMessage(L"\tflFontType: "); + vDumpFlags(pfo->flFontType, gafdFONTOBJ_flFontType); + OEMDebugMessage(L"\tiTTUniq: %#x\r\n", pfo->iTTUniq); + OEMDebugMessage(L"\tiFile: %#x\r\n", pfo->iFile); + OEMDebugMessage(L"\tsizLogResPpi: [%ld x %ld]\r\n", pfo->sizLogResPpi.cx, pfo->sizLogResPpi.cy); + OEMDebugMessage(L"\tulStyleSize: %ld\r\n", pfo->ulStyleSize); + if (!pfo->pvConsumer) + OEMDebugMessage(L"\tpvConsumer: NULL\r\n"); + else + OEMDebugMessage(L"\tpvConsumer: %#x\r\n", pfo->pvConsumer); + if (!pfo->pvProducer) + OEMDebugMessage(L"\tpvProducer: NULL\r\n"); + else + OEMDebugMessage(L"\tpvProducer: %#x\r\n", pfo->pvProducer); + + OEMDebugMessage(L"\n"); + +} + +void +vDumpCLIPOBJ( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + CLIPOBJ *pco + ) + +/*++ + +Routine Description: + + Dumps the members of a CLIPOBJ structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pco - pointer to the CLIPOBJ strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pco"); + + // Return if strct to be dumped is invalid + // + if (!pco) + { + OEMDebugMessage(L"\nCLIPOBJ [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nCLIPOBJ [%s]: %#x\r\n", pszLabel, pco); + OEMDebugMessage(L"\tiUniq: %ld\r\n", pco->iUniq); + OEMDebugMessage(L"\trclBounds: (%ld, %ld) (%ld, %ld)\r\n", pco->rclBounds.left, pco->rclBounds.top, pco->rclBounds.right, pco->rclBounds.bottom); + + PWSTR psziDComplexity = L"Unknown iDComplexity."; + switch (pco->iDComplexity ) + { + case DC_COMPLEX: psziDComplexity = L"DC_COMPLEX"; break; + case DC_RECT: psziDComplexity = L"DC_RECT"; break; + case DC_TRIVIAL: psziDComplexity = L"DC_TRIVIAL"; break; + } + OEMDebugMessage(L"\tiDComplexity: %s\r\n", psziDComplexity); + + PWSTR psziFComplexity = L"0"; + switch (pco->iFComplexity) + { + case FC_COMPLEX: psziFComplexity = L"FC_COMPLEX"; break; + case FC_RECT: psziFComplexity = L"FC_RECT"; break; + case FC_RECT4: psziFComplexity = L"FC_RECT4"; break; + } + OEMDebugMessage(L"\tiFComplexity: %s\r\n", psziFComplexity); + + PWSTR psziMode = L"0"; + switch (pco->iMode) + { + case TC_PATHOBJ: psziMode = L"TC_PATHOBJ"; break; + case TC_RECTANGLES: psziMode = L"TC_RECTANGLES"; break; + } + OEMDebugMessage(L"\tiMode: %s\r\n", psziMode); + + PWSTR pszfjOptions = L"0"; + switch (pco->fjOptions) + { + case OC_BANK_CLIP: pszfjOptions = L"TC_PATHOBJ"; break; + } + OEMDebugMessage(L"\tfjOptions: %s\r\n", pszfjOptions); + + OEMDebugMessage(L"\n"); +} + +#if DBG + DBG_FLAGS gafdBRUSHOBJ_flColorType[] = { + { L"BR_CMYKCOLOR", BR_CMYKCOLOR}, + { L"BR_DEVICE_ICM", BR_DEVICE_ICM}, + { L"BR_HOST_ICM", BR_HOST_ICM}, + {NULL, 0} // The NULL entry is important + }; +#else + DBG_FLAGS gafdBRUSHOBJ_flColorType[] = { + {NULL, 0} + }; +#endif + +void +vDumpBRUSHOBJ( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + BRUSHOBJ *pbo + ) + +/*++ + +Routine Description: + + Dumps the members of a BRUSHOBJ structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pbo - pointer to the BRUSHOBJ strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pbo"); + + // Return if strct to be dumped is invalid + // + if (!pbo) + { + OEMDebugMessage(L"\nBRUSHOBJ [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nBRUSHOBJ [%s]: %#x\r\n", pszLabel, pbo); + OEMDebugMessage(L"\tiSolidColor: %#x\r\n", pbo->iSolidColor); + OEMDebugMessage(L"\tpvRbrush: %#x\r\n", pbo->pvRbrush); + OEMDebugMessage(L"\tflColorType: "); + vDumpFlags(pbo->flColorType, gafdBRUSHOBJ_flColorType); + + OEMDebugMessage(L"\n"); +} + +#if DBG + DBG_FLAGS gafdGDIINFO_flHTFlags[] = { + { L"HT_FLAG_8BPP_CMY332_MASK", HT_FLAG_8BPP_CMY332_MASK}, + { L"HT_FLAG_ADDITIVE_PRIMS", HT_FLAG_ADDITIVE_PRIMS}, + { L"HT_FLAG_DO_DEVCLR_XFORM", HT_FLAG_DO_DEVCLR_XFORM}, + { L"HT_FLAG_HAS_BLACK_DYE", HT_FLAG_HAS_BLACK_DYE}, + { L"HT_FLAG_HIGH_INK_ABSORPTION", HT_FLAG_HIGH_INK_ABSORPTION}, + { L"HT_FLAG_HIGHER_INK_ABSORPTION", HT_FLAG_HIGHER_INK_ABSORPTION}, + { L"HT_FLAG_HIGHEST_INK_ABSORPTION", HT_FLAG_HIGHEST_INK_ABSORPTION}, + { L"HT_FLAG_INK_ABSORPTION_IDX0", HT_FLAG_INK_ABSORPTION_IDX0}, + { L"HT_FLAG_INK_ABSORPTION_IDX1", HT_FLAG_INK_ABSORPTION_IDX1}, + { L"HT_FLAG_INK_ABSORPTION_IDX2", HT_FLAG_INK_ABSORPTION_IDX2}, + { L"HT_FLAG_INK_ABSORPTION_IDX3", HT_FLAG_INK_ABSORPTION_IDX3}, + { L"HT_FLAG_INK_HIGH_ABSORPTION", HT_FLAG_INK_HIGH_ABSORPTION}, + { L"HT_FLAG_LOW_INK_ABSORPTION", HT_FLAG_LOW_INK_ABSORPTION}, + { L"HT_FLAG_LOWER_INK_ABSORPTION", HT_FLAG_LOWER_INK_ABSORPTION}, + { L"HT_FLAG_LOWEST_INK_ABSORPTION", HT_FLAG_LOWEST_INK_ABSORPTION}, + { L"HT_FLAG_OUTPUT_CMY", HT_FLAG_OUTPUT_CMY}, + { L"HT_FLAG_PRINT_DRAFT_MODE", HT_FLAG_PRINT_DRAFT_MODE}, + { L"HT_FLAG_SQUARE_DEVICE_PEL", HT_FLAG_SQUARE_DEVICE_PEL}, + { L"HT_FLAG_USE_8BPP_BITMASK", HT_FLAG_USE_8BPP_BITMASK}, + { L"HT_FLAG_NORMAL_INK_ABSORPTION", HT_FLAG_NORMAL_INK_ABSORPTION}, +// { L"HT_FLAG_INVERT_8BPP_BITMASK_IDX", HT_FLAG_INVERT_8BPP_BITMASK_IDX}, + {NULL, 0} // The NULL entry is important + }; +#else + DBG_FLAGS gafdGDIINFO_flHTFlags[] = { + {NULL, 0} + }; +#endif + +void +vDumpGDIINFO( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + GDIINFO *pGdiInfo + ) + +/*++ + +Routine Description: + + Dumps the members of a GDIINFO structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pGdiInfo - pointer to the GDIINFO strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pGdiInfo"); + + // Return if strct to be dumped is invalid + // + if (!pGdiInfo) + { + OEMDebugMessage(L"\nGDIINFO [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nGDIINFO [%s]: %#x\r\n", pszLabel, pGdiInfo); + OEMDebugMessage(L"\tulVersion: %#x\r\n", pGdiInfo->ulVersion); + + PWSTR pszulTechnology = L"???"; + switch (pGdiInfo->ulTechnology) + { + case DT_PLOTTER: pszulTechnology = L"DT_PLOTTER"; break; + case DT_RASDISPLAY: pszulTechnology = L"DT_RASDISPLAY"; break; + case DT_RASPRINTER: pszulTechnology = L"DT_RASPRINTER"; break; + case DT_RASCAMERA: pszulTechnology = L"DT_RASCAMERA"; break; + case DT_CHARSTREAM: pszulTechnology = L"DT_CHARSTREAM"; break; + } + OEMDebugMessage(L"\tulTechnology: %ld [%s]\r\n", pGdiInfo->ulTechnology, pszulTechnology); + + OEMDebugMessage(L"\tulHorzSize: %ld\r\n", pGdiInfo->ulHorzSize); + OEMDebugMessage(L"\tulVertSize: %ld\r\n", pGdiInfo->ulVertSize); + OEMDebugMessage(L"\tulHorzRes: %ld\r\n", pGdiInfo->ulHorzRes); + OEMDebugMessage(L"\tulVertRes: %ld\r\n", pGdiInfo->ulVertRes); + OEMDebugMessage(L"\tcBitsPixel: %ld\r\n", pGdiInfo->cBitsPixel); + OEMDebugMessage(L"\tcPlanes: %ld\r\n", pGdiInfo->cPlanes); + OEMDebugMessage(L"\tulNumColors: %ld\r\n", pGdiInfo->ulNumColors); + OEMDebugMessage(L"\tflRaster: %#x\r\n", pGdiInfo->flRaster); + OEMDebugMessage(L"\tulLogPixelsX: %ld\r\n", pGdiInfo->ulLogPixelsX); + OEMDebugMessage(L"\tulLogPixelsY: %ld\r\n", pGdiInfo->ulLogPixelsY); + + PWSTR pszTextCaps = L"Text scrolling through DrvBitBlt/DrvCopyBits"; + if (TC_SCROLLBLT == (pGdiInfo->flTextCaps & TC_SCROLLBLT)) + { + pszTextCaps = L"Text scrolling through DrvTextOut"; + } + OEMDebugMessage(L"\tflTextCaps: %s\n", pszTextCaps); + + OEMDebugMessage(L"\tulDACRed: %#x\r\n", pGdiInfo->ulDACRed); + OEMDebugMessage(L"\tulDACGreen: %#x\r\n", pGdiInfo->ulDACGreen); + OEMDebugMessage(L"\tulDACBlue: %#x\r\n", pGdiInfo->ulDACBlue); + OEMDebugMessage(L"\tulAspectX: %ld\r\n", pGdiInfo->ulAspectX); + OEMDebugMessage(L"\tulAspectY: %ld\r\n", pGdiInfo->ulAspectY); + OEMDebugMessage(L"\tulAspectXY: %ld\r\n", pGdiInfo->ulAspectXY); + OEMDebugMessage(L"\txStyleStep: %ld\r\n", pGdiInfo->xStyleStep); + OEMDebugMessage(L"\tyStyleStep: %ld\r\n", pGdiInfo->yStyleStep); + OEMDebugMessage(L"\tdenStyleStep: %ld\r\n", pGdiInfo->denStyleStep); + OEMDebugMessage(L"\tptlPhysOffset: (%ld, %ld)\r\n", pGdiInfo->ptlPhysOffset.x, pGdiInfo->ptlPhysOffset.y); + OEMDebugMessage(L"\tszlPhysSize: (%ld, %ld)\r\n", pGdiInfo->szlPhysSize.cx, pGdiInfo->szlPhysSize.cy); + OEMDebugMessage(L"\tulNumPalReg: %ld\r\n", pGdiInfo->ulNumPalReg); + OEMDebugMessage(L"\tulDevicePelsDPI: %ld\r\n", pGdiInfo->ulDevicePelsDPI); + + PWSTR pszPrimaryOrder = L"???"; + switch(pGdiInfo->ulPrimaryOrder) + { + case PRIMARY_ORDER_ABC: pszPrimaryOrder = L"PRIMARY_ORDER_ABC [RGB/CMY]"; break; + case PRIMARY_ORDER_ACB: pszPrimaryOrder = L"PRIMARY_ORDER_ACB [RBG/CYM]"; break; + case PRIMARY_ORDER_BAC: pszPrimaryOrder = L"PRIMARY_ORDER_BAC [GRB/MCY]"; break; + case PRIMARY_ORDER_BCA: pszPrimaryOrder = L"PRIMARY_ORDER_BCA [GBR/MYC]"; break; + case PRIMARY_ORDER_CBA: pszPrimaryOrder = L"PRIMARY_ORDER_CBA [BGR/YMC]"; break; + case PRIMARY_ORDER_CAB: pszPrimaryOrder = L"PRIMARY_ORDER_CAB [BRG/YCM]"; break; + } + OEMDebugMessage(L"\tulPrimaryOrder: %s\n", pszPrimaryOrder); + + PWSTR pszHTPat = L"???"; + switch(pGdiInfo->ulHTPatternSize) + { + case HT_PATSIZE_2x2 : pszHTPat = L"HT_PATSIZE_2x2 "; break; + case HT_PATSIZE_2x2_M : pszHTPat = L"HT_PATSIZE_2x2_M"; break; + case HT_PATSIZE_4x4 : pszHTPat = L"HT_PATSIZE_4x4"; break; + case HT_PATSIZE_4x4_M : pszHTPat = L"HT_PATSIZE_4x4_M"; break; + case HT_PATSIZE_6x6 : pszHTPat = L"HT_PATSIZE_6x6"; break; + case HT_PATSIZE_6x6_M : pszHTPat = L"HT_PATSIZE_6x6_M"; break; + case HT_PATSIZE_8x8 : pszHTPat = L"HT_PATSIZE_8x8"; break; + case HT_PATSIZE_8x8_M : pszHTPat = L"HT_PATSIZE_8x8_M"; break; + case HT_PATSIZE_10x10 : pszHTPat = L"HT_PATSIZE_10x10"; break; + case HT_PATSIZE_10x10_M : pszHTPat = L"HT_PATSIZE_10x10_M"; break; + case HT_PATSIZE_12x12 : pszHTPat = L"HT_PATSIZE_12x12"; break; + case HT_PATSIZE_12x12_M : pszHTPat = L"HT_PATSIZE_12x12_M"; break; + case HT_PATSIZE_14x14 : pszHTPat = L"HT_PATSIZE_14x14"; break; + case HT_PATSIZE_14x14_M : pszHTPat = L"HT_PATSIZE_14x14_M"; break; + case HT_PATSIZE_16x16 : pszHTPat = L"HT_PATSIZE_16x16"; break; + case HT_PATSIZE_16x16_M : pszHTPat = L"HT_PATSIZE_16x16_M"; break; + case HT_PATSIZE_SUPERCELL : pszHTPat = L"HT_PATSIZE_SUPERCELL"; break; + case HT_PATSIZE_SUPERCELL_M : pszHTPat = L"HT_PATSIZE_SUPERCELL_M"; break; + case HT_PATSIZE_USER : pszHTPat = L"HT_PATSIZE_USER"; break; +// case HT_PATSIZE_MAX_INDEX : pszHTPat = L"HT_PATSIZE_MAX_INDEX"; break; +// case HT_PATSIZE_DEFAULT : pszHTPat = L"HT_PATSIZE_DEFAULT"; break; + } + OEMDebugMessage(L"\tulHTPatternSize: %s\n", pszHTPat); + + PWSTR pszHTOutputFormat = L"???"; + switch(pGdiInfo->ulHTOutputFormat) + { + case HT_FORMAT_1BPP : pszHTOutputFormat = L"HT_FORMAT_1BPP"; break; + case HT_FORMAT_4BPP : pszHTOutputFormat = L"HT_FORMAT_4BPP"; break; + case HT_FORMAT_4BPP_IRGB : pszHTOutputFormat = L"HT_FORMAT_4BPP_IRGB"; break; + case HT_FORMAT_8BPP : pszHTOutputFormat = L"HT_FORMAT_8BPP"; break; + case HT_FORMAT_16BPP : pszHTOutputFormat = L"HT_FORMAT_16BPP"; break; + case HT_FORMAT_24BPP : pszHTOutputFormat = L"HT_FORMAT_24BPP"; break; + case HT_FORMAT_32BPP : pszHTOutputFormat = L"HT_FORMAT_32BPP"; break; + } + OEMDebugMessage(L"\tulHTOutputFormat: %s\n", pszHTOutputFormat); + + OEMDebugMessage(L"\tflHTFlags: "); + vDumpFlags(pGdiInfo->flHTFlags, gafdGDIINFO_flHTFlags); + OEMDebugMessage(L"\tulVRefresh: %ld\r\n", pGdiInfo->ulVRefresh); + OEMDebugMessage(L"\tulBltAlignment: %ld\r\n", pGdiInfo->ulBltAlignment); + OEMDebugMessage(L"\tulPanningHorzRes: %ld\r\n", pGdiInfo->ulPanningHorzRes); + OEMDebugMessage(L"\tulPanningVertRes: %ld\r\n", pGdiInfo->ulPanningVertRes); + OEMDebugMessage(L"\txPanningAlignment: %ld\r\n", pGdiInfo->xPanningAlignment); + OEMDebugMessage(L"\tyPanningAlignment: %ld\r\n", pGdiInfo->yPanningAlignment); + OEMDebugMessage(L"\tcxHTPat: %ld\r\n", pGdiInfo->cxHTPat); + OEMDebugMessage(L"\tcyHTPat: %ld\r\n", pGdiInfo->cyHTPat); + OEMDebugMessage(L"\tpHTPatA: %#x\r\n", pGdiInfo->pHTPatA); + OEMDebugMessage(L"\tpHTPatB: %#x\r\n", pGdiInfo->pHTPatB); + OEMDebugMessage(L"\tpHTPatC: %#x\r\n", pGdiInfo->pHTPatC); + OEMDebugMessage(L"\tflShadeBlend: %#x\r\n", pGdiInfo->flShadeBlend); + + PWSTR pszPhysPixChars = L"???"; + switch(pGdiInfo->ulPhysicalPixelCharacteristics) + { + case PPC_DEFAULT: pszPhysPixChars = L"PPC_DEFAULT"; break; + case PPC_BGR_ORDER_HORIZONTAL_STRIPES: pszPhysPixChars = L"PPC_BGR_ORDER_HORIZONTAL_STRIPES"; break; + case PPC_BGR_ORDER_VERTICAL_STRIPES: pszPhysPixChars = L"PPC_BGR_ORDER_VERTICAL_STRIPES"; break; + case PPC_RGB_ORDER_HORIZONTAL_STRIPES: pszPhysPixChars = L"PPC_RGB_ORDER_HORIZONTAL_STRIPES"; break; + case PPC_RGB_ORDER_VERTICAL_STRIPES: pszPhysPixChars = L"PPC_RGB_ORDER_VERTICAL_STRIPES"; break; + case PPC_UNDEFINED: pszPhysPixChars = L"PPC_UNDEFINED"; break; + } + OEMDebugMessage(L"\tulPhysicalPixelCharacteristics: %s\n", pszPhysPixChars); + + PWSTR pszPhysPixGamma = L"???"; + switch(pGdiInfo->ulPhysicalPixelGamma) + { + case PPG_DEFAULT: pszPhysPixGamma = L"PPG_DEFAULT"; break; + case PPG_SRGB : pszPhysPixGamma = L"PPG_SRGB"; break; + } + OEMDebugMessage(L"\tulPhysicalPixelGamma: %s\n", pszPhysPixGamma); + + OEMDebugMessage(L"\n"); +} + +#if DBG + DBG_FLAGS gafdDEVINFO_flGraphicsCaps[] = { + { L"GCAPS_BEZIERS", GCAPS_BEZIERS}, + { L"GCAPS_GEOMETRICWIDE", GCAPS_GEOMETRICWIDE}, + { L"GCAPS_ALTERNATEFILL", GCAPS_ALTERNATEFILL}, + { L"GCAPS_WINDINGFILL", GCAPS_WINDINGFILL}, + { L"GCAPS_HALFTONE", GCAPS_HALFTONE}, + { L"GCAPS_COLOR_DITHER", GCAPS_COLOR_DITHER}, + { L"GCAPS_HORIZSTRIKE", GCAPS_HORIZSTRIKE}, + { L"GCAPS_VERTSTRIKE", GCAPS_VERTSTRIKE}, + { L"GCAPS_OPAQUERECT", GCAPS_OPAQUERECT}, + { L"GCAPS_VECTORFONT", GCAPS_VECTORFONT}, + { L"GCAPS_MONO_DITHER", GCAPS_MONO_DITHER}, + { L"GCAPS_ASYNCCHANGE", GCAPS_ASYNCCHANGE}, + { L"GCAPS_ASYNCMOVE", GCAPS_ASYNCMOVE}, + { L"GCAPS_DONTJOURNAL", GCAPS_DONTJOURNAL}, + { L"GCAPS_DIRECTDRAW", GCAPS_DIRECTDRAW}, + { L"GCAPS_ARBRUSHOPAQUE", GCAPS_ARBRUSHOPAQUE}, + { L"GCAPS_PANNING", GCAPS_PANNING}, + { L"GCAPS_PALMANAGED", GCAPS_PALMANAGED}, + { L"GCAPS_DITHERONREALIZE", GCAPS_DITHERONREALIZE}, + { L"GCAPS_NO64BITMEMACCESS", GCAPS_NO64BITMEMACCESS}, + { L"GCAPS_FORCEDITHER", GCAPS_FORCEDITHER}, + { L"GCAPS_GRAY16", GCAPS_GRAY16}, + { L"GCAPS_ICM", GCAPS_ICM}, + { L"GCAPS_CMYKCOLOR", GCAPS_CMYKCOLOR}, + { L"GCAPS_LAYERED", GCAPS_LAYERED}, + { L"GCAPS_ARBRUSHTEXT", GCAPS_ARBRUSHTEXT}, + { L"GCAPS_SCREENPRECISION", GCAPS_SCREENPRECISION}, + { L"GCAPS_FONT_RASTERIZER", GCAPS_FONT_RASTERIZER}, + { L"GCAPS_NUP", GCAPS_NUP}, + {NULL, 0} // The NULL entry is important + }; + + DBG_FLAGS gafdDEVINFO_flGraphicsCaps2[] = { + { L"GCAPS2_JPEGSRC", GCAPS2_JPEGSRC}, + { L"GCAPS2_xxxx", GCAPS2_xxxx}, + { L"GCAPS2_PNGSRC", GCAPS2_PNGSRC}, + { L"GCAPS2_CHANGEGAMMARAMP", GCAPS2_CHANGEGAMMARAMP}, + { L"GCAPS2_ALPHACURSOR", GCAPS2_ALPHACURSOR}, + { L"GCAPS2_SYNCFLUSH", GCAPS2_SYNCFLUSH}, + { L"GCAPS2_SYNCTIMER", GCAPS2_SYNCTIMER}, + { L"GCAPS2_ICD_MULTIMON", GCAPS2_ICD_MULTIMON}, + { L"GCAPS2_MOUSETRAILS", GCAPS2_MOUSETRAILS}, + { L"GCAPS2_REMOTEDRIVER", GCAPS2_REMOTEDRIVER}, + {NULL, 0} // The NULL entry is important + }; +#else + DBG_FLAGS gafdDEVINFO_flGraphicsCaps[] = { + {NULL, 0} + }; + + DBG_FLAGS gafdDEVINFO_flGraphicsCaps2[] = { + {NULL, 0} + }; +#endif + +void +vDumpDEVINFO( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + DEVINFO *pDevInfo + ) + +/*++ + +Routine Description: + + Dumps the members of a DEVINFO structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pDevInfo - pointer to the DEVINFO strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pDevInfo"); + + // Return if strct to be dumped is invalid + // + if (!pDevInfo) + { + OEMDebugMessage(L"\nDEVINFO [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nDEVINFO [%s]: %#x\r\n", pszLabel, pDevInfo); + OEMDebugMessage(L"\tflGraphicsCaps: "); + vDumpFlags(pDevInfo->flGraphicsCaps, gafdDEVINFO_flGraphicsCaps); + OEMDebugMessage(L"\tcFonts: %ld\r\n", pDevInfo->cFonts); + + PWSTR psziDitherFormat = L"0"; + switch (pDevInfo->iDitherFormat) + { + case BMF_1BPP : psziDitherFormat = L"BMF_1BPP" ; break; + case BMF_4BPP : psziDitherFormat = L"BMF_4BPP" ; break; + case BMF_8BPP : psziDitherFormat = L"BMF_8BPP" ; break; + case BMF_16BPP: psziDitherFormat = L"BMF_16BPP"; break; + case BMF_24BPP: psziDitherFormat = L"BMF_24BPP"; break; + case BMF_32BPP: psziDitherFormat = L"BMF_32BPP"; break; + case BMF_4RLE : psziDitherFormat = L"BMF_4RLE" ; break; + case BMF_8RLE : psziDitherFormat = L"BMF_8RLE" ; break; + case BMF_JPEG : psziDitherFormat = L"BMF_JPEG" ; break; + case BMF_PNG : psziDitherFormat = L"BMF_PNG " ; break; + } + OEMDebugMessage(L"\tiDitherFormat: %s\r\n", psziDitherFormat); + + OEMDebugMessage(L"\tcxDither: %ld\r\n", pDevInfo->cxDither); + OEMDebugMessage(L"\tcyDither: %ld\r\n", pDevInfo->cyDither); + OEMDebugMessage(L"\thpalDefault: %#x\r\n", pDevInfo->hpalDefault); + OEMDebugMessage(L"\tflGraphicsCaps2: "); + vDumpFlags(pDevInfo->flGraphicsCaps2, gafdDEVINFO_flGraphicsCaps2); + + OEMDebugMessage(L"\n"); +} + +void +vDumpBitmapInfoHeader( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + BITMAPINFOHEADER *pBitmapInfoHeader + ) + +/*++ + +Routine Description: + + Dumps the members of a BITMAPINFOHEADER structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pBitmapInfoHeader - pointer to the BITMAPINFOHEADER strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pBitmapInfoHeader"); + + // Return if strct to be dumped is invalid + // + if (!pBitmapInfoHeader) + { + OEMDebugMessage(L"\nBITMAPINFOHEADER [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nBITMAPINFOHEADER [%s]: %#x\r\n", pszLabel, pBitmapInfoHeader); + OEMDebugMessage(L"\tbiSize: %ld\r\n", pBitmapInfoHeader->biSize); + OEMDebugMessage(L"\tbiWidth: %ld\r\n", pBitmapInfoHeader->biWidth); + OEMDebugMessage(L"\tbiHeight: %ld\r\n", pBitmapInfoHeader->biHeight); + OEMDebugMessage(L"\tbiPlanes: %ld\r\n", pBitmapInfoHeader->biPlanes); + OEMDebugMessage(L"\tbiBitCount: %ld\r\n", pBitmapInfoHeader->biBitCount); + + PWSTR pszbiCompression = L"0"; + switch (pBitmapInfoHeader->biCompression) + { + case BI_RGB : pszbiCompression = L"BI_RGB" ; break; + case BI_RLE8 : pszbiCompression = L"BI_RLE8" ; break; + case BI_RLE4 : pszbiCompression = L"BI_RLE4" ; break; + case BI_BITFIELDS: pszbiCompression = L"BI_BITFIELDS"; break; + case BI_JPEG : pszbiCompression = L"BI_JPEG" ; break; + case BI_PNG : pszbiCompression = L"BI_PNG " ; break; + } + OEMDebugMessage(L"\tbiCompression: %s\r\n", pszbiCompression); + + OEMDebugMessage(L"\tbiSizeImage: %ld\r\n", pBitmapInfoHeader->biSizeImage); + OEMDebugMessage(L"\tbiXPelsPerMeter: %ld\r\n", pBitmapInfoHeader->biXPelsPerMeter); + OEMDebugMessage(L"\tbiYPelsPerMeter: %ld\r\n", pBitmapInfoHeader->biYPelsPerMeter); + OEMDebugMessage(L"\tbiClrUsed: %ld\r\n", pBitmapInfoHeader->biClrUsed); + OEMDebugMessage(L"\tbiClrImportant: %ld\r\n", pBitmapInfoHeader->biClrImportant); + + OEMDebugMessage(L"\n"); +} + +void +vDumpPOINTL( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + POINTL *pptl + ) + +/*++ + +Routine Description: + + Dumps the members of a POINTL structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pptl - pointer to the POINTL strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pptl"); + + // Return if strct to be dumped is invalid + // + if (!pptl) + { + OEMDebugMessage(L"\nPOINTL [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nPOINTL [%s]: %#x (%ld, %ld)\r\n", pszLabel, pptl, pptl->x, pptl->y); + + OEMDebugMessage(L"\n"); +} + +void +vDumpRECTL( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + RECTL *prcl + ) + +/*++ + +Routine Description: + + Dumps the members of a RECTL structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + prcl - pointer to the RECTL strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"prcl"); + + // Return if strct to be dumped is invalid + // + if (!prcl) + { + OEMDebugMessage(L"\nRECTL [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nRECTL [%s]: %#x (%ld, %ld) (%ld, %ld)\r\n", pszLabel, prcl, prcl->left, prcl->top, prcl->right, prcl->bottom); + + OEMDebugMessage(L"\n"); +} + +#if DBG + DBG_FLAGS gafdXLATEOBJ_flXlate[] = { + { L"XO_DEVICE_ICM", XO_DEVICE_ICM}, + { L"XO_FROM_CMYK", XO_FROM_CMYK}, + { L"XO_HOST_ICM", XO_HOST_ICM}, + { L"XO_TABLE", XO_TABLE}, + { L"XO_TO_MONO", XO_TO_MONO}, + { L"XO_TRIVIAL", XO_TRIVIAL}, + {NULL, 0} // The NULL entry is important + }; +#else + DBG_FLAGS gafdXLATEOBJ_flXlate[] = { + {NULL, 0} + }; +#endif + +void +vDumpXLATEOBJ( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + XLATEOBJ *pxlo + ) + +/*++ + +Routine Description: + + Dumps the members of a XLATEOBJ structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pxlo - pointer to the XLATEOBJ strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pxlo"); + + // Return if strct to be dumped is invalid + // + if (!pxlo) + { + OEMDebugMessage(L"\nXLATEOBJ [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nXLATEOBJ [%s]: %#x\r\n", pszLabel, pxlo); + OEMDebugMessage(L"\tiUniq: %ld\r\n", pxlo->iUniq); + OEMDebugMessage(L"\tflXlate: "); + vDumpFlags(pxlo->flXlate, gafdXLATEOBJ_flXlate); + OEMDebugMessage(L"\tiSrcType: %ld [obsolete]\r\n", pxlo->iSrcType); + OEMDebugMessage(L"\tiDstType: %ld [obsolete]\r\n", pxlo->iDstType); + OEMDebugMessage(L"\tcEntries: %ld\r\n", pxlo->cEntries); + if (pxlo->pulXlate) + OEMDebugMessage(L"\tpulXlate: %#x [%ld]\r\n", pxlo->pulXlate, *pxlo->pulXlate); + else + OEMDebugMessage(L"\tpulXlate: %#x\r\n", pxlo->pulXlate); + + OEMDebugMessage(L"\n"); +} + +#if DBG + DBG_FLAGS gafdCOLORADJUSTMENT_caFlags[] = { + { L"CA_NEGATIVE", CA_NEGATIVE}, + { L"CA_LOG_FILTER", CA_LOG_FILTER}, + {NULL, 0} // The NULL entry is important + }; +#else + DBG_FLAGS gafdCOLORADJUSTMENT_caFlags[] = { + {NULL, 0} + }; +#endif + +void +vDumpCOLORADJUSTMENT( + INT iDebugLevel, + _In_ PWSTR pszInLabel, + COLORADJUSTMENT *pca + ) + +/*++ + +Routine Description: + + Dumps the members of a COLORADJUSTMENT structure. + +Arguments: + + iDebugLevel - desired output debug level + pszInLabel - output label string + pca - pointer to the COLORADJUSTMENT strct to be dumped + +Return Value: + + NONE + +--*/ + +{ + // Check if the debug level is appropriate + // + if (iDebugLevel < giDebugLevel) + { + // Nothing to output here + // + return; + } + + // Prepare the label string + // + PCWSTR pszLabel = EnsureLabel(pszInLabel, L"pca"); + + // Return if strct to be dumped is invalid + // + if (!pca) + { + OEMDebugMessage(L"\nCOLORADJUSTMENT [%s]: NULL\r\n", pszLabel); + + // Nothing else to output + // + return; + } + + // Format the data + // + OEMDebugMessage(L"\nCOLORADJUSTMENT [%s]: %#x\r\n", pszLabel, pca); + OEMDebugMessage(L"\tcaSize: %#x\r\n", pca->caSize); + OEMDebugMessage(L"\tcaFlags: "); + if (pca->caFlags) + vDumpFlags(pca->caFlags, gafdCOLORADJUSTMENT_caFlags); + else + OEMDebugMessage(L"NULL\r\n"); + + PWSTR pszcaIlluminantIndex = L"0"; + switch (pca->caIlluminantIndex) + { + case ILLUMINANT_DEVICE_DEFAULT: pszcaIlluminantIndex = L"ILLUMINANT_DEVICE_DEFAULT" ; break; + case ILLUMINANT_A: pszcaIlluminantIndex = L"ILLUMINANT_A [Tungsten lamp]" ; break; + case ILLUMINANT_B: pszcaIlluminantIndex = L"ILLUMINANT_B [Noon sunlight]" ; break; + case ILLUMINANT_C: pszcaIlluminantIndex = L"ILLUMINANT_C [NTSC daylight]" ; break; + case ILLUMINANT_D50: pszcaIlluminantIndex = L"ILLUMINANT_D50 [Normal print]" ; break; + case ILLUMINANT_D55: pszcaIlluminantIndex = L"ILLUMINANT_D55 [Bond paper print]" ; break; + case ILLUMINANT_D65: pszcaIlluminantIndex = L"ILLUMINANT_D65 [Standard daylight]" ; break; + case ILLUMINANT_D75: pszcaIlluminantIndex = L"ILLUMINANT_D75 [Northern daylight]" ; break; + case ILLUMINANT_F2: pszcaIlluminantIndex = L"ILLUMINANT_F2 [Cool white lamp]" ; break; + } + OEMDebugMessage(L"\tcaIlluminantIndex: %s\r\n", pszcaIlluminantIndex); + + OEMDebugMessage(L"\tcaRedGamma: %d\r\n", (int)pca->caRedGamma); + OEMDebugMessage(L"\tcaGreenGamma: %d\r\n", (int)pca->caGreenGamma); + OEMDebugMessage(L"\tcaBlueGamma: %d\r\n", (int)pca->caBlueGamma); + OEMDebugMessage(L"\tcaReferenceBlack: %d\r\n", (int)pca->caReferenceBlack); + OEMDebugMessage(L"\tcaReferenceWhite: %d\r\n", (int)pca->caReferenceWhite); + OEMDebugMessage(L"\tcaContrast: %d\r\n", (int)pca->caContrast); + OEMDebugMessage(L"\tcaBrightness: %d\r\n", (int)pca->caBrightness); + OEMDebugMessage(L"\tcaColorfulness: %d\r\n", (int)pca->caColorfulness); + OEMDebugMessage(L"\tcaRedGreenTint: %d\r\n", (int)pca->caRedGreenTint); + + OEMDebugMessage(L"\n"); +} + +#endif + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.h new file mode 100644 index 00000000..2b488890 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/debug.h @@ -0,0 +1,215 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// +// History: +// 06/28/03 xxx created. +// +// + +#pragma once + +#include "devmode.h" + +// VC and Build use different debug defines. +// The following makes it so either will +// cause the inclusion of debugging code. +#if !defined(_DEBUG) && defined(DBG) + #define _DEBUG DBG +#elif defined(_DEBUG) && !defined(DBG) + #define DBG _DEBUG +#endif + + + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// VERBOSE(msg) +// Display a message if the current debug level is <= DBG_VERBOSE. +// +// TERSE(msg) +// Display a message if the current debug level is <= DBG_TERSE. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// ASSERTMSG(cond, msg) +// Verify a condition is true. If not, display a message and +// force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// These macros require extra parantheses for the msg argument +// example, ASSERTMSG(x > 0, ("x is less than 0\n")); +// WARNING(("App passed NULL pointer, ignoring...\n")); +// + +#define DBG_VERBOSE 1 +#define DBG_TERSE 2 +#define DBG_WARNING 3 +#define DBG_ERROR 4 +#define DBG_RIP 5 +#define DBG_NONE 6 + +// +// Determine what level of debugging messages to emit. +// This can be set in the sources file, or omitted +// completely +// +#ifdef VERBOSE_MSG + #define DEBUG_LEVEL DBG_VERBOSE +#elif TERSE_MSG + #define DEBUG_LEVEL DBG_TERSE +#elif WARNING_MSG + #define DEBUG_LEVEL DBG_WARNING +#elif ERROR_MSG + #define DEBUG_LEVEL DBG_ERROR +#elif RIP_MSG + #define DEBUG_LEVEL DBG_RIP +#elif NO_DBG_MSG + #define DEBUG_LEVEL DBG_NONE +#else + #define DEBUG_LEVEL DBG_WARNING +#endif + + +#if DBG + + extern INT giDebugLevel; + + #define DBGMSG(level, prefix, msg) { \ + if (giDebugLevel <= (level)) { \ + OEMDebugMessage(L"%s %s (%d): ", prefix, StripDirPrefixA(__FILE__), __LINE__); \ + OEMDebugMessage(msg); \ + } \ + } + + #define VERBOSE if(giDebugLevel <= DBG_VERBOSE) OEMDebugMessage + #define TERSE if(giDebugLevel <= DBG_TERSE) OEMDebugMessage + #define WARNING if(giDebugLevel <= DBG_WARNING) OEMDebugMessage + #define ERR if(giDebugLevel <= DBG_ERROR) OEMDebugMessage + + #define DBG_OEMDMPARAM(iDbgLvl, szLabel, pobj) {vDumpOemDMParam(iDbgLvl, szLabel, pobj);} + #define DBG_SURFOBJ(iDbgLvl, szLabel, pobj) {vDumpSURFOBJ(iDbgLvl, szLabel, pobj);} + #define DBG_STROBJ(iDbgLvl, szLabel, pobj) {vDumpSTROBJ(iDbgLvl, szLabel, pobj);} + #define DBG_FONTOBJ(iDbgLvl, szLabel, pobj) {vDumpFONTOBJ(iDbgLvl, szLabel, pobj);} + #define DBG_CLIPOBJ(iDbgLvl, szLabel, pobj) {vDumpCLIPOBJ(iDbgLvl, szLabel, pobj);} + #define DBG_BRUSHOBJ(iDbgLvl, szLabel, pobj) {vDumpBRUSHOBJ(iDbgLvl, szLabel, pobj);} + #define DBG_GDIINFO(iDbgLvl, szLabel, pobj) {vDumpGDIINFO(iDbgLvl, szLabel, pobj);} + #define DBG_DEVINFO(iDbgLvl, szLabel, pobj) {vDumpDEVINFO(iDbgLvl, szLabel, pobj);} + #define DBG_BMPINFO(iDbgLvl, szLabel, pobj) {vDumpBitmapInfoHeader(iDbgLvl, szLabel, pobj);} + #define DBG_POINTL(iDbgLvl, szLabel, pobj) {vDumpPOINTL(iDbgLvl, szLabel, pobj);} + #define DBG_RECTL(iDbgLvl, szLabel, pobj) {vDumpRECTL(iDbgLvl, szLabel, pobj);} + #define DBG_XLATEOBJ(iDbgLvl, szLabel, pobj) {vDumpXLATEOBJ(iDbgLvl, szLabel, pobj);} + #define DBG_COLORADJUSTMENT(iDbgLvl, szLabel, pobj) {vDumpCOLORADJUSTMENT(iDbgLvl, szLabel, pobj);} + + #define ASSERT(cond) \ + { \ + if (! (cond)) \ + { \ + RIP((L"\n")); \ + } \ + } + + #define ASSERTMSG(cond, msg) \ + { \ + if (! (cond)) { \ + RIP(msg); \ + } \ + } + + #define RIP(msg) \ + { \ + DBGMSG(DBG_RIP, L"RIP", msg); \ + DebugBreak(); \ + } + + typedef struct DBG_FLAGS { + LPWSTR pszFlag; + DWORD dwFlag; + } *PDBG_FLAGS; + + BOOL OEMDebugMessage(LPCWSTR, ...); + void vDumpOemDMParam(INT iDebugLevel, _In_ PWSTR pszInLabel, POEMDMPARAM pOemDMParam); + void vDumpSURFOBJ(INT iDebugLevel, _In_ PWSTR pszInLabel, SURFOBJ *pso); + void vDumpSTROBJ(INT iDebugLevel, _In_ PWSTR pszInLabel, STROBJ *pstro); + void vDumpFONTOBJ(INT iDebugLevel, _In_ PWSTR pszInLabel, FONTOBJ *pfo); + void vDumpCLIPOBJ(INT iDebugLevel, _In_ PWSTR pszInLabel, CLIPOBJ *pco); + void vDumpBRUSHOBJ(INT iDebugLevel, _In_ PWSTR pszInLabel, BRUSHOBJ *pbo); + void vDumpGDIINFO(INT iDebugLevel, _In_ PWSTR pszInLabel, GDIINFO *pGdiInfo); + void vDumpDEVINFO(INT iDebugLevel, _In_ PWSTR pszInLabel, DEVINFO *pDevInfo); + void vDumpBitmapInfoHeader(INT iDebugLevel, _In_ PWSTR pszInLabel, PBITMAPINFOHEADER pBitmapInfoHeader); + void vDumpPOINTL(INT iDebugLevel, _In_ PWSTR pszInLabel, POINTL *pptl); + void vDumpRECTL(INT iDebugLevel, _In_ PWSTR pszInLabel, RECTL *prcl); + void vDumpXLATEOBJ(INT iDebugLevel, _In_ PWSTR pszInLabel, XLATEOBJ *pxlo); + void vDumpCOLORADJUSTMENT(INT iDebugLevel, _In_ PWSTR pszInLabel, COLORADJUSTMENT *pca); + + BOOL OEMRealDebugMessage(DWORD dwSize, LPCWSTR lpszMessage, va_list arglist); + PCSTR StripDirPrefixA(IN PCSTR pstrFilename); + void vDumpFlags(DWORD dwFlags, PDBG_FLAGS pDebugFlags); + +#else // !DBG + + #define DebugMsg NOP_FUNCTION + + #define VERBOSE NOP_FUNCTION + #define TERSE NOP_FUNCTION + #define WARNING NOP_FUNCTION + #define ERR NOP_FUNCTION + + #define DBG_OEMDMPARAM(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_OEMDEVMODE(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_SURFOBJ(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_STROBJ(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_FONTOBJ(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_CLIPOBJ(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_BRUSHOBJ(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_GDIINFO(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_DEVINFO(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_BMPINFO(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_POINTL(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_RECTL(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_XLATEOBJ(iDbgLvl, szLabel, pobj) NOP_FUNCTION + #define DBG_COLORADJUSTMENT(iDbgLvl, szLabel, pobj) NOP_FUNCTION + + #define ASSERT(cond) + + #define ASSERTMSG(cond, msg) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.cpp new file mode 100644 index 00000000..92ca5dd9 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.cpp @@ -0,0 +1,229 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// +// History: +// 06/24/03 xxx created. +// +// + +#include "precomp.h" +#include "oemprean.h" +#include "debug.h" +#include "devmode.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +HRESULT hrOEMDevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DevMode. + hrOEMDevMode is called by IPrintOemUni::DevMode + which is defined in intrface.cpp. + + The IPrintOemUni::DevMode method, provided by + rendering plug-ins for Unidrv, performs operations + on private DEVMODE members. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - caller-supplied constant. Refer to the docs + for more information. + pOemDMParam - pointer to an OEMDMPARAM structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + +--*/ + +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + VERBOSE(L"hrOEMDevMode entry."); + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + )) + { + ERR(ERRORTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); + ERR(DLLTEXT("\tdwMode = %d, pOemDMParam = %#lx.\r\n"), dwMode, pOemDMParam); + + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devmode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + case OEMDM_DEFAULT: + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + break; + + case OEMDM_CONVERT: + bConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + case OEMDM_MERGE: + bConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + bMakeOEMDevmodeValid(pOEMDevOut); + break; + } + DBG_OEMDMPARAM(DBG_VERBOSE, L"pOemDMParam", pOemDMParam); + + return S_OK; +} + + +BOOL bConvertOEMDevmode( + PCOEMDEV pOEMDevIn, + POEMDEV pOEMDevOut + ) + +/*++ + +Routine Description: + + Converts private DEVMODE members to the + current version. + +Arguments: + + pOEMDevIn - pointer to OEM private devmode + pOEMDevOut - pointer to OEM private devmode + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE(L"bConvertOEMDevmode entry."); + + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR(ERRORTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE(TEXT("Converting private OEM Devmode.\r\n")); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + VERBOSE(TEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + } + + return TRUE; +} + + +BOOL bMakeOEMDevmodeValid( + POEMDEV pOEMDevmode + ) + +/*++ + +Routine Description: + + Ensures that private OEM devmode members are valid. + +Arguments: + + pOEMDevmode - pointer to OEM private devmode + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data. + pOEMDevmode->dwDriverData = 0; + + return TRUE; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.h new file mode 100644 index 00000000..05f98204 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/devmode.h @@ -0,0 +1,43 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +// History: +// 06/24/03 xxx created. +// +// + +#pragma once + + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + BOOL dwDriverData; +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + +///////////////////////////////////////////////////////// +// Prototypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL bConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL bMakeOEMDevmodeValid(POEMDEV pOEMDevmode); + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/dllentry.cpp new file mode 100644 index 00000000..412f9446 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/dllentry.cpp @@ -0,0 +1,58 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// +// PURPOSE: Source module for DLL entry function(s). +// +// History: +// 06/24/03 xxx created. +// +// + +#include "precomp.h" +#include "oemprean.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// + +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + VERBOSE(L"DllMain entry."); + + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(TEXT("Process attach.\r\n")); + break; + + case DLL_THREAD_ATTACH: + VERBOSE(TEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(TEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(TEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.cpp new file mode 100644 index 00000000..9c102afc --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.cpp @@ -0,0 +1,1819 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Interface for User Mode COM Customization DLL. +// +// +// Functions: +// IPrintOemUni2 interface functions +// COemCF class factory +// Registration functions: DllCanUnloadNow, DllGetClassObject +// +// History: +// 06/26/03 xxx created. +// +// + +#include "precomp.h" +#include +#include + +#include "oemprean.h" +#include "debug.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// ================================================================== +// Internal Globals +// +static long g_cComponents; // Count of active components +static long g_cServerLocks; // Count of locks +// +// ================================================================== + +// ================================================================== +// The purpose of this array is to inform UNIDRV of the callbacks +// that are implemented in this driver. +// +// Note that there is *NO* order dependency in this array. New +// index values and their corresponding callbacks can be placed +// anywhere within the list as needed. +// +static const DRVFN s_aOemHookFuncs[] = +{ + // The following are defined in ddihook.cpp. + // + {INDEX_DrvAlphaBlend, (PFN)OEMAlphaBlend}, + {INDEX_DrvBitBlt, (PFN)OEMBitBlt}, + {INDEX_DrvCopyBits, (PFN)OEMCopyBits}, + {INDEX_DrvDitherColor, (PFN)OEMDitherColor}, + {INDEX_DrvFillPath, (PFN)OEMFillPath}, + {INDEX_DrvFontManagement, (PFN)OEMFontManagement}, + {INDEX_DrvGetGlyphMode, (PFN)OEMGetGlyphMode}, + {INDEX_DrvGradientFill, (PFN)OEMGradientFill}, + {INDEX_DrvLineTo, (PFN)OEMLineTo}, + {INDEX_DrvPaint, (PFN)OEMPaint}, + {INDEX_DrvPlgBlt, (PFN)OEMPlgBlt}, + {INDEX_DrvQueryAdvanceWidths, (PFN)OEMQueryAdvanceWidths}, + {INDEX_DrvQueryFont, (PFN)OEMQueryFont}, + {INDEX_DrvQueryFontData, (PFN)OEMQueryFontData}, + {INDEX_DrvQueryFontTree, (PFN)OEMQueryFontTree}, + {INDEX_DrvRealizeBrush, (PFN)OEMRealizeBrush}, + {INDEX_DrvStretchBlt, (PFN)OEMStretchBlt}, + {INDEX_DrvStretchBltROP, (PFN)OEMStretchBltROP}, + {INDEX_DrvStrokeAndFillPath, (PFN)OEMStrokeAndFillPath}, + {INDEX_DrvStrokePath, (PFN)OEMStrokePath}, + {INDEX_DrvTextOut, (PFN)OEMTextOut}, + {INDEX_DrvTransparentBlt, (PFN)OEMTransparentBlt}, + {INDEX_DrvStartDoc, (PFN)OEMStartDoc}, + {INDEX_DrvEndDoc, (PFN)OEMEndDoc}, + {INDEX_DrvStartPage, (PFN)OEMStartPage}, + {INDEX_DrvSendPage, (PFN)OEMSendPage}, + {INDEX_DrvStartBanding, (PFN)OEMStartBanding}, + {INDEX_DrvNextBand, (PFN)OEMNextBand}, + {INDEX_DrvEscape, (PFN)OEMEscape} +}; + + +//////////////////////////////////////////////////////////////////////////////// +// +// COemUni2 body +// +COemUni2::COemUni2() +{ + m_cRef = 1; + + // Increment COM component count. + InterlockedIncrement(&g_cComponents); + + m_pOEMHelp = NULL; + +} + +COemUni2::~COemUni2() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall +COemUni2:: +QueryInterface( + const IID& iid, + void** ppv + ) +{ + VERBOSE(L"COemUni2::QueryInterface() entry."); + + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("COemUni2::QueryInterface IUnknown.\r\n")); + } + else if (iid == IID_IPrintOemUni2) + { + VERBOSE(DLLTEXT("COemUni2::QueryInterface IPrintOemUni2.\r\n")); + + *ppv = static_cast(this); + } + else + { + WARNING(DLLTEXT("COemUni2::QueryInterface NULL. Returning E_NOINTERFACE.\r\n")); + + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall +COemUni2:: +AddRef( + VOID + ) +{ + VERBOSE(L"COemUni2::AddRef() entry."); + + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +COemUni2:: +Release( + VOID + ) +{ + VERBOSE(L"COemUni2::Release() entry."); + ULONG cRef = InterlockedDecrement(&m_cRef); + + if (cRef == 0) + { + delete this; + return 0; + } + return cRef; +} + +HRESULT __stdcall +COemUni2:: +CommandCallback( + PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::CommandCallback + + The IPrintOemUni::CommandCallback method is used + to provide dynamically generated printer commands + for Unidrv-supported printers. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + dwCallbackID - value representing the printer command's + *CallbackID attribute in the printer's generic printer + description (GPD) file. + dwCount - value representing the number of elements + in the array pointed to by pdwParams. Can be 0. + pdwParams - pointer to an array of DWORD-sized parameters + containing values specified by the printer commands + *Params attribute in the printer's GPD file. Can be NULL. + piResult - Receives a method-supplied result value. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::CommandCallback() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pdwParams); + + *piResult = 0; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +Compression( + PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::Compression + + The IPrintOemUni::Compression method can be used + with Unidrv-supported printers to provide a customized + bitmap compression method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pInBuf - pointer to input scan line data. + pOutBuf - pointer to an output buffer to receive + compressed scan line data. + dwInLen - length of the input data. + dwOutLen - length of the output buffer. + piResult - Receives a method-supplied result value. If the + operation succeeds, this value should be the number + of compressed bytes, which must not be larger than + the value received for dwOutLen. If an error occurs, + or if the method cannot compress, the result value + should be -1. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::Compression() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pInBuf); + UNREFERENCED_PARAMETER(pOutBuf); + UNREFERENCED_PARAMETER(dwInLen); + UNREFERENCED_PARAMETER(dwOutLen); + UNREFERENCED_PARAMETER(piResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DevMode + + The IPrintOemUni::DevMode method, provided by + rendering plug-ins for Unidrv, performs operations + on private DEVMODE members. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DevMode method. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - caller-supplied constant. Refer to the docs + for more information. + pOemDMParam - pointer to an OEMDMPARAM structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE(L"COemUni2:DevMode entry."); + + DBG_OEMDMPARAM(DBG_VERBOSE, L"pOemDMParam", pOemDMParam); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall +COemUni2:: +DisableDriver( + VOID + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DisableDriver + + The IPrintOemUni::DisableDriver method allows a rendering + plug-in for Unidrv to free resources that were allocated by the + plug-in's IPrintOemUni::EnableDriver method. This is the last + IPrintOemUni interface method that is called before the rendering + plug-in is unloaded. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DisableDriver method. + + Please refer to DDK documentation for more details. + +Arguments: + + VOID + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE(L"COemUni2::DisableDriver() entry."); + + // Release reference to Printer Driver's interface. + // + if (this->m_pOEMHelp) + { + this->m_pOEMHelp->Release(); + this->m_pOEMHelp = NULL; + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +DisablePDEV( + PDEVOBJ pdevobj + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DisablePDEV + + The IPrintOemUni::DisablePDEV method performs the same types of + operations as the DrvDisablePDEV function. Its purpose is to allow a + rendering plug-in to delete the private PDEV structure that is pointed + to by the DEVOBJ structure's pdevOEM member. This PDEV structure + is one that was allocated by the plug-in's IPrintOemUni::EnablePDEV method. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DisablePDEV method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE(L"COemUni2::DisablePDEV() entry."); + + POEMPDEV pOemPDEV = static_cast(pdevobj->pdevOEM); + delete pOemPDEV; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +DownloadCharGlyph( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DownloadCharGlyph + + The IPrintOemUni::DownloadCharGlyph method enables a + rendering plug-in for Unidrv to send a character glyph for + a specified soft font to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + hGlyph - glyph handle. + pdwWidth - pointer to receive the method-supplied width of the character. + pdwResult - Receives a method-supplied value representing the amount + of printer memory, in bytes, required to store the character glyph. + If the operation fails, the returned value should be zero. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::DownloadCharGlyph() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(hGlyph); + UNREFERENCED_PARAMETER(pdwWidth); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DownloadFontHeader( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DownloadFontHeader + + The IPrintOemUni::DownloadFontHeader method allows a + rendering plug-in for Unidrv to send a font's header + information to a printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pdwResult - Receives a method-supplied value representing the amount + of printer memory, in bytes, required to store the font header + information. If the operation fails, the returned value should be zero. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::DownloadFontHeader() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DriverDMS( + PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DriverDMS + + The IPrintOemUni::DriverDMS method allows a rendering + plug-in for Unidrv to indicate that it uses a device-managed + drawing surface instead of the default GDI-managed surface. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DriverDMS method. + + Please refer to DDK documentation for more details. For general info + on device managed surfaces and how to handle them, please refer to + the section titled "Handling Device-Managed Surfaces". + +Arguments: + + pDevObj - pointer to a DEVOBJ structure. + pBuffer - pointer to a buffer to receive method-specified flags. + cbSize - size, in bytes, of the buffer pointed to by pBuffer. + pcbNeeded - pointer to a location to receive the required + minimum pBuffer size. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE(L"COemUni2::DriverDMS() entry."); + + UNREFERENCED_PARAMETER(pDevObj); + UNREFERENCED_PARAMETER(pBuffer); + UNREFERENCED_PARAMETER(cbSize); + UNREFERENCED_PARAMETER(pcbNeeded); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +EnableDriver( + DWORD dwDriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::EnableDriver + + The IPrintOemUni::EnableDriver method allows a rendering + plug-in for Unidrv to hook out some graphics DDI functions. + + The IPrintOemUni::EnableDriver method allows a rendering + plug-in to perform the same types of operations as the + DrvEnableDriver function. Like the DrvEnableDriver function, + the IPrintOemUni::EnableDriver method is responsible for + providing addresses of internally supported graphics DDI functions, + or DDI hook functions. + + The method should fill the supplied DRVENABLEDATA structure + and allocate an array of DRVFN structures. It should fill the + array with pointers to hooking functions, along with winddi.h-defined + index values that identify the hooked out graphics DDI functions. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::EnableDriver method. + + Please refer to DDK documentation for more details. + +Arguments: + + DriverVersion - interface version number. This value is + defined by PRINTER_OEMINTF_VERSION, in printoem.h. + cbSize - size, in bytes, of the structure pointed to by pded. + pded - pointer to a DRVENABLEDATA structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + UNREFERENCED_PARAMETER(dwDriverVersion); + UNREFERENCED_PARAMETER(cbSize); + + VERBOSE(L"COemUni2::EnableDriver() entry."); + + pded->iDriverVersion = PRINTER_OEMINTF_VERSION; + pded->c = sizeof(s_aOemHookFuncs) / sizeof(DRVFN); + pded->pdrvfn = (DRVFN *) s_aOemHookFuncs; + + // Even if nothing is done, need to return S_OK so + // that DisableDriver() will be called, which releases + // the reference to the Printer Driver's interface. + // + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +EnablePDEV( + PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *ppDevOem + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::EnablePDEV + + The IPrintOemUni::EnablePDEV method performs the same types + of operations as the DrvEnablePDEV function that is exported + by a printer graphics DLL. Its purpose is to allow a rendering + plug-in to create its own PDEV structure. For more information + about PDEV structures, see "Customized PDEV Structures" in the DDK docs. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::EnablePDEV method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pPrinterName - pointer to a text string representing the + logical address of the printer. + cPatterns - value representing the number of HSURF-typed + surface handles contained in the buffer pointed to by + phsurfPatterns. + phsurfPatterns - pointer to a buffer that is large enough to + contain cPatterns number of HSURF-typed surface handles. + The handles represent surface fill patterns. + cjGdiInfo - value representing the size of the structure pointed + to by pGdiInfo. + pGdiInfo - pointer to a GDIINFO structure. + cjDevInfo - value representing the size of the structure pointed + to by pDevInfo. + pDevInfo - pointer to a DEVINFO structure. + pded - pointer to a DRVENABLEDATA structure containing the + addresses of the printer driver's graphics DDI hooking functions. + pDevOem - Receives a method-supplied pointer to a private PDEV structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + If the operation fails, the method should call SetLastError to set an error code. + + +--*/ + +{ + VERBOSE(L"COemUni2::EnablePDEV() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(cPatterns); + UNREFERENCED_PARAMETER(phsurfPatterns); + UNREFERENCED_PARAMETER(cjGdiInfo); + UNREFERENCED_PARAMETER(cjDevInfo); + + #ifndef DBG + UNREFERENCED_PARAMETER(pGdiInfo); + UNREFERENCED_PARAMETER(pDevInfo); + #endif + + // Allocate an instance of our private PDEV. + // + POEMPDEV pOemPDEV = new COemPDEV(); + *ppDevOem = pOemPDEV; + + if (NULL == pOemPDEV) + { + return E_FAIL; + } + + pOemPDEV->InitializeDDITable(pded); + + DBG_GDIINFO(DBG_VERBOSE, L"pGdiInfo", pGdiInfo); + DBG_DEVINFO(DBG_VERBOSE, L"pDevInfo", pDevInfo); + + pOemPDEV->bPreAnalysis = FALSE; // Initialize the pre-analysis flag + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +FilterGraphics( + PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::FilterGraphics + + The IPrintOemUni::FilterGraphics method can be used with + Unidrv-supported printers to modify scan line data and send + it to the spooler. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pBuf - pointer to a buffer containing scan line data to be printed. + dwLen - value representing the length, in bytes, of the data + pointed to by pBuf. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + DWORD dwResult; + + VERBOSE(L"COemUni2::FilterGraphics() entry."); + + m_pOEMHelp->DrvWriteSpoolBuf(pdevobj, pBuf, dwLen, &dwResult); + + if (dwResult == dwLen) + return S_OK; + else + return S_FALSE; +} + +HRESULT __stdcall +COemUni2:: +GetImplementedMethod( + _In_ PSTR pMethodName + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::GetImplementedMethod + + The IPrintOemUni::GetImplementedMethod method is used by + Unidrv to determine which IPrintOemUni interface methods + have been implemented by a rendering plug-in. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::GetImplemented method. + + Please refer to DDK documentation for more details. + +Arguments: + + pMethodName - pointer to a string representing the name of an + IPrintOemUni interface method, such as "ImageProcessing" + for IPrintOemUni::ImageProcessing or "FilterGraphics" for + IPrintOemUni::FilterGraphics. + +Return Value: + + S_OK The operation succeeded (the specified method is implemented). + S_FALSE The operation failed (the specified method is not implemented). + + +--*/ + +{ + HRESULT Result = S_FALSE; + + VERBOSE(L"COemUni2::GetImplementedMethod() entry."); + VERBOSE(TEXT("\tCOemUni2::%hs: "), pMethodName); + + // Unidrv only calls GetImplementedMethod for optional + // methods. The required methods are assumed to be + // supported. + + // Return S_OK for supported function (i.e. implemented), + // and S_FALSE for functions that aren't supported (i.e. not implemented). + switch (*pMethodName) + { + case 'C': + if (!strcmp(NAME_CommandCallback, pMethodName)) + { + Result = S_OK; + } + break; + case 'F': + if (!strcmp(NAME_FilterGraphics, pMethodName)) + { + Result = S_OK; + } + break; + } + + VERBOSE(Result == S_OK ? TEXT("Supported\r\n") : TEXT("NOT supported\r\n")); + + return Result; +} + +HRESULT __stdcall +COemUni2:: +GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::GetInfo + + A rendering plug-in's IPrintOemUni::GetInfo method returns + identification information. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::GetInfo method. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - Contains one of the following caller-supplied integer constants. + OEMGI_GETSIGNATURE - The method must return a unique four-byte + identification signature. The plug-in must also place this signature + in OPTITEM structures, as described in the description of the + OEMCUIPPARAM. structure's pOEMOptItems member. + OEMGI_GETVERSION - The method must return the user interface + plug-in's version number as a DWORD. The version format is + developer-defined. + pBuffer - pointer to memory allocated to receive the information specified + by dwInfo. + cbSize - size of the buffer pointed to by pBuffer. + pcbNeeded - pointer to a location to receive the number of bytes written + into the buffer pointed to by pBuffer. + +Return Value: + + S_OK The operation succeeded (the specified method is implemented). + S_FALSE The operation failed (the specified method is not implemented). + + +--*/ + +{ + PWSTR pszTag = L"COemUni2::GetInfo entry."; + + switch(dwMode) + { + case OEMGI_GETSIGNATURE: + pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETSIGNATURE]"; + break; + case OEMGI_GETVERSION: + pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETVERSION]"; + break; + } + + VERBOSE(pszTag); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) ) ) + { + WARNING(DLLTEXT("COemUni2::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER.\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + VERBOSE(TEXT("COemUni2::GetInfo() exit insufficient buffer!\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("COemUni2::GetInfo() exit mode not supported.\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(TEXT("COemUni2::GetInfo() exit S_OK, (*pBuffer is %#x).\r\n"), *(PDWORD)pBuffer); + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +HalftonePattern( + PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::HalftonePattern + + The IPrintOemUni::HalftonePattern method can be used with + Unidrv-supported printers to create or modify a halftone + pattern before it is used in a halftoning operation. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pHTPattern - pointer to a buffer to receive the method-supplied + halftone pattern. Buffer size, in bytes, is: + (((dwHTPatternX * dwHTPatternY) + 3)/4) * 4 * dwHTNumPatterns. + dwHTPatternX - length, in pixels, of the halftone pattern, as specified + by the GPD file's *HTPatternSize attribute. + dwHTPatternY - height, in pixels, of the halftone pattern, as specified + by the GPD file's *HTPatternSize attribute. + dwHTNumPatterns - number of patterns, as specified by the GPD file's + *HTNumPatterns attribute. This can be 1 or 3. + dwCallbackID - value identifying the halftone method, as specified by + the GPD file's *HTCallbackID attribute. + pResource - pointer to a buffer containing a halftone pattern, as + specified by the GPD file's *rcHTPatternID attribute. This can be NULL. + dwResourceSize - size of the halftone pattern contained in the buffer + pointed to by pResource. This is zero if pResource is NULL. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::HalftonePattern() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pHTPattern); + UNREFERENCED_PARAMETER(dwHTPatternX); + UNREFERENCED_PARAMETER(dwHTPatternY); + UNREFERENCED_PARAMETER(dwHTNumPatterns); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(pResource); + UNREFERENCED_PARAMETER(dwResourceSize); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +ImageProcessing( + PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::ImageProcessing + + The IPrintOemUni::ImageProcessing method can be used with + Unidrv-supported printers to modify image bitmap data, in order + to perform color formatting or halftoning. The method can return + the modified bitmap to Unidrv or send it directly to the print spooler. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pSrcBitmap - pointer to an input device-independent bitmap (DIB). + pBitmapInfoHeader - pointer to a BITMAPINFOHEADER structure + that describes the bitmap pointed to by pSrcBitmap. + pColorTable - pointer to a color table. Used only if the output format is + eight bits per pixel. + dwCallbackID - value assigned to the *IPCallbackID attribute of the + currently selected option for the ColorMode feature. + pIPParams - pointer to an IPPARAMS structure. + ppbResult - + If the method returns the converted DIB to Unidrv: + If the conversion succeeds, the method should return a + pointer to a buffer containing the converted DIB. + Otherwise it should return NULL. + If the method sends the converted DIB to the print spooler: + If the operation succeeds, the method should return TRUE. + Otherwise it should return FALSE. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::ImageProcessing() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pSrcBitmap); + UNREFERENCED_PARAMETER(pBitmapInfoHeader); + UNREFERENCED_PARAMETER(pColorTable); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(pIPParams); + UNREFERENCED_PARAMETER(ppbResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +MemoryUsage( + PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::MemoryUsage + + The IPrintOemUni::MemoryUsage method can be used with + Unidrv-supported printers to specify the amount of memory + required for use by a rendering plug-in's IPrintOemUni::ImageProcessing + method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pMemoryUsage - pointer to an OEMMEMORYUSAGE structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::MemoryUsage() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pMemoryUsage); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +OutputCharStr( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::OutputCharStr + + The IPrintOemUni::OutputCharStr method enables a rendering + plug-in to control the printing of font glyphs. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + dwType - value indicating the type of glyph specifier array + pointed to by pGlyph. Valid values are as follows: + TYPE_GLYPHHANDLE The pGlyph array elements are glyph + handles of type HGLYPH. + TYPE_GLYPHID The pGlyph array elements are glyph + identifiers of type DWORD. + dwCount - value representing the number of glyph specifiers in + the array pointed to by pGlyph. + pGlyph - pointer to an array of glyph specifiers, where the array + element type is indicated by dwType. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::OutputCharStr() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(dwType); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pGlyph); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +PublishDriverInterface( + IUnknown *pIUnknown + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::PublishDriverInterface + + The IPrintOemUni::PublishDriverInterface method allows a + rendering plug-in for Unidrv to obtain the Unidrv driver's + IPrintOemDriverUni interface. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::PublishDriverInterface method and the method + must return S_OK, or the driver will not call the plug-in's other + IPrintOemUni interface methods. + + Please refer to DDK documentation for more details. + +Arguments: + + pIUnknown - pointer to the IUnknown interface of the driver's + IPrintOemDriverUni COM interface. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE(L"COemUni2::PublishDriverInterface() entry."); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (this->m_pOEMHelp == NULL) + { + HRESULT hResult; + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni, (void** ) &(this->m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + this->m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +ResetPDEV( + PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::ResetPDEV + + A rendering plug-in's IPrintOemUni::ResetPDEV method performs + the same types of operations as the DrvResetPDEV function. During + the processing of an application's call to the Platform SDK ResetDC + function, the IPrintOemUni::ResetPDEV method is called by Unidrv's + DrvResetPDEV function. For more information about when DrvResetPDEV + is called, see its description in the DDK docs. + + The rendering plug-in's private PDEV structure's address is contained + in the pdevOEM member of the DEVOBJ structure pointed to by pdevobjOld. + The IPrintOemUni::ResetPDEV method should use relevant members of this + old structure to fill in the new structure, which is referenced through pdevobjNew. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::ResetPDEV method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobjOld - pointer to a DEVOBJ structure containing current PDEV information. + pdevobjNew - pointer to a DEVOBJ structure into which the method should place + new PDEV information. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE(L"COemUni2::ResetPDEV() entry."); + + UNREFERENCED_PARAMETER(pdevobjOld); + UNREFERENCED_PARAMETER(pdevobjNew); + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +SendFontCmd( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::SendFontCmd + + The IPrintOemUni::SendFontCmd method enables a rendering + plug-in to modify a printer's font selection command and then + send it to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pFInv - pointer to an FINVOCATION structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::SendFontCmd() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pFInv); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TextOutAsBitmap( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TextOutAsBitmap + + The IPrintOemUni::TextOutAsBitmap method allows a rendering + plug-in to create a bitmap image of a text string, in case a + downloadable font is not available. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to be written. + pstro - Defines the glyphs to be rendered and their positions + pfo - Specifies the font to be used + pco - Defines the clipping path + prclExtra - A NULL-terminated array of rectangles to be filled + prclOpaque - Specifies an opaque rectangle + pboFore - Defines the foreground brush + pboOpaque - Defines the opaque brush + pptlOrg - Pointer to POINT struct , defining th origin + mix - Specifies the foreground and background ROPs for pboFore + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::TextOutAsBitmap() entry."); + + UNREFERENCED_PARAMETER(pso); + UNREFERENCED_PARAMETER(pstro); + UNREFERENCED_PARAMETER(pfo); + UNREFERENCED_PARAMETER(pco); + UNREFERENCED_PARAMETER(prclExtra); + UNREFERENCED_PARAMETER(prclOpaque); + UNREFERENCED_PARAMETER(pboFore); + UNREFERENCED_PARAMETER(pboOpaque); + UNREFERENCED_PARAMETER(pptlOrg); + UNREFERENCED_PARAMETER(mix); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TTDownloadMethod( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TTDownloadMethod + + The IPrintOemUni::TTDownloadMethod method enables a rendering + plug-in to indicate the format that Unidrv should use for a specified + TrueType soft font. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pdwResult - Receives one of the following method-supplied constant values: + TTDOWNLOAD_BITMAP Unidrv should download the specified font as bitmaps. + TTDOWNLOAD_DONTCARE Unidrv can select the font format. + TTDOWNLOAD_GRAPHICS Unidrv should print TrueType fonts as graphics, + instead of downloading the font. + TTDOWNLOAD_TTOUTLINE Unidrv should download the specified font as outlines. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::TTDownloadMethod() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TTYGetInfo( + PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TTYGetInfo + + The IPrintOemUni::TTYGetInfo method enables a rendering plug-in + to supply Unidrv with information relevant to text-only printers. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + dwInfoIndex - constant identifying the type of information being requested. + The following constant values are defined: + OEMTTY_INFO_CODEPAGE - The pOutputBuf parameter points to a + DWORD in which the method should return the number of the + code page to be used. + OEMTTY_INFO_MARGINS - The pOutputBuf parameter points to a + RECT structure in which the method should return page margin + widths, in tenths of millimeters (for example, 20 represents 2 mm). + If the entire page is printable, all margin values must be 0. + OEMTTY_INFO_NUM_UFMS - The pOutputBuf parameter points to a + DWORD in which the method should return the number of resource + IDs of the UFMs for 10, 12, and 17 CPI fonts. To actually obtain + these resource IDs, perform a query using OEMTTY_INFO_UFM_IDS. + OEMTTY_INFO_UFM_IDS - The pOutputBuf parameter points to an array + of DWORDs of sufficient size to hold the number of resource IDs of + the UFMs for 10, 12, and 17 CPI fonts. (This number is obtained by + using OEMTTY_INFO_NUM_UFMS in a query.) The method should + return the resource IDs of the UFMs for 10,12, and 17 CPI fonts. + pOutputBuf - pointer to a buffer to receive the requested information. + dwSize - size, in bytes, of the buffer pointed to by pOutputBuf. + pcbcNeeded - pointer to a location to receive the number of bytes written into + the buffer pointed to by pOutputBuf. If the number of bytes required is + smaller than the number specified by dwSize, the method should supply + the required size and return E_FAIL. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::TTYGetInfo() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwInfoIndex); + UNREFERENCED_PARAMETER(pOutputBuf); + UNREFERENCED_PARAMETER(dwSize); + UNREFERENCED_PARAMETER(pcbcNeeded); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +WritePrinter( + PDEVOBJ pdevobj, + PVOID pBuf, + DWORD cbBuffer, + PDWORD pcbWritten + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni2::WritePrinter + + The IPrintOemUni2::WritePrinter method, if supported, enables a + rendering plug-in to capture all output data generated by a Unidrv + driver. If this method is not supported, the output data would + otherwise be sent to the spooler in a call to the spooler's WritePrinter API. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pBuf - pointer to the first byte of an array of bytes that contains + the output data generated by the Unidrv driver. + cbBuffer - size, in bytes, of the array pointed to by pBuf. + pcbWritten - pointer to a DWORD value that receives the number + of bytes of data that were successfully sent to the plug-in. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE(L"COemUni2::WritePrinter() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pBuf); + UNREFERENCED_PARAMETER(cbBuffer); + UNREFERENCED_PARAMETER(pcbWritten); + + return E_NOTIMPL; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class COemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef)(THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release)(THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance)(THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer)(THIS_ BOOL bLock); + + + // Constructor + COemCF(): m_cRef(1) { }; + + // Destructor + ~COemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall +COemCF:: +QueryInterface( + const IID& iid, + void** ppv) +{ + VERBOSE(L"COemCF::QueryInterface entry."); + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; +#if DBG && defined(USERMODE_DRIVER) + TCHAR szOutput[80] = {0}; + StringFromGUID2(iid, szOutput, _countof(szOutput)); // can not fail! + VERBOSE(TEXT("COemCF::QueryInterface %s not supported.\r\n"), szOutput); +#endif + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall +COemCF:: +AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +COemCF:: +Release() +{ +// ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall +COemCF:: +CreateInstance( + IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + VERBOSE(L"Class factory:Create component."); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + // Create component. + COemUni2* pOemCP = new COemUni2; + if (pOemCP == NULL) + { + return E_OUTOFMEMORY; + } + + // Get the requested interface. + HRESULT hr = pOemCP->QueryInterface(iid, ppv); + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCP->Release(); + return hr; +} + +// LockServer +HRESULT __stdcall +COemCF:: +LockServer( + BOOL bLock + ) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + return S_OK; +} + + +// +// Registration functions +// + +// +// Can DLL unload now? +// +STDAPI DllCanUnloadNow(void) +{ + VERBOSE(L"DllCanUnloadNow entry."); + + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv + ) +{ + VERBOSE(L"DllGetClassObject:\tCreate class factory."); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMRENDER) + { + ERR(ERRORTEXT("DllGetClassObject:\tClass not available!\r\n")); + return CLASS_E_CLASSNOTAVAILABLE; + } + + // Create class factory. + COemCF* pFontCF = new COemCF; // Reference count set to 1 in constructor + if (pFontCF == NULL) + { + ERR(ERRORTEXT("DllGetClassObject:\tOut of Memory!\r\n")); + return E_OUTOFMEMORY; + } + + // Get requested interface. + HRESULT hrResult = pFontCF->QueryInterface(iid, ppv); + pFontCF->Release(); + + return hrResult; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.h new file mode 100644 index 00000000..28b2a82f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/intrface.h @@ -0,0 +1,288 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.H +// +// +// PURPOSE: Define COM interface for User Mode Printer Customization DLL. +// +// History: +// 06/26/03 xxx created. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// String Literals +///////////////////////////////////////////////////////// + +CONST CHAR NAME_CommandCallback[] = "CommandCallback"; +CONST CHAR NAME_FilterGraphics[] = "FilterGraphics"; + +//////////////////////////////////////////////////////////////////////////////// +// +// COemUni2 +// +// Interface for Unidrv OEM sample rendering module +// +class COemUni2 : public IPrintOemUni2 +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Method for getting the implemented methods. + // Returns S_OK if the given method is implemneted. + // Returns S_FALSE if the given method is notimplemneted. + // + + STDMETHOD(GetImplementedMethod)(THIS_ _In_ PSTR pMethodName); + + // + // Method for OEM to specify DDIs that have been hooked + // + + STDMETHOD(EnableDriver) (THIS_ DWORD DriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded); + + // + // Method to notify OEM plugin that it is no longer required + // + + STDMETHOD(DisableDriver) (THIS); + + // + // Method for OEM plugin to contruct its own PDEV + // + + STDMETHOD(EnablePDEV)(THIS_ PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem); + + // + // Method for OEM to free any resource associated with its PDEV + // + + STDMETHOD(DisablePDEV)(THIS_ PDEVOBJ pdevobj); + + // + // Method for OEM to transfer from old PDEV to new PDEV + // + + STDMETHOD(ResetPDEV)(THIS_ PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo)(THIS_ DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDriverDMS - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(DriverDMS)(THIS_ PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode)(THIS_ DWORD dwMode, + POEMDMPARAM pOemDMParam); + + // + // OEMCommandCallback - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(CommandCallback)(THIS_ PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult); + + // + // OEMImageProcessing - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(ImageProcessing)(THIS_ PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult); + + // + // OEMFilterGraphics - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(FilterGraphics)(THIS_ PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen); + // + // OEMCompression - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(Compression)(THIS_ PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult); + + // + // OEMHalftone - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(HalftonePattern)(THIS_ PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize); + + // + // OEMMemoryUsage - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(MemoryUsage)(THIS_ PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage); + + // + // OEMTTYGetInfo - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(TTYGetInfo)(THIS_ PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded); + + // + // OEMDownloadFontheader - UNIDRV only + // + + STDMETHOD(DownloadFontHeader)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMDownloadCharGlyph - UNIDRV only + // + + STDMETHOD(DownloadCharGlyph)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult); + + // + // OEMTTDownloadMethod - UNIDRV only + // + + STDMETHOD(TTDownloadMethod)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMOutputCharStr - UNIDRV only + // + + STDMETHOD(OutputCharStr)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph); + + // + // OEMSendFontCmd - UNIDRV only + // + + + STDMETHOD(SendFontCmd)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv); + + // + // OEMTextOutAsBitmap - UNIDRV only + // + + STDMETHOD(TextOutAsBitmap)(THIS_ SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix); + + // + // IPrintOemUni2 methods + // + + // + // Method for plugin to hook out spooler's WritePrinter API so it + // can get access to output data Universal driver is generating + // + // At DrvEnablePDEV time, Universal driver will call this function with + // pdevobj = NULL, pBuf = NULL, cbBuffer = 0 to detect if the plugin + // implements this function. Plugin should return S_OK to indicate it is + // implementing this function, or return E_NOTIMPL otherwise. + // + // In pcbWritten, plugins should return the number of bytes written to the + // spooler's WritePrinter function. Zero doesn't carry a special meaning, + // errors must be reported through the returned HRESULT. + // + + STDMETHOD(WritePrinter)(THIS_ PDEVOBJ pdevobj, + PVOID pBuf, + DWORD cbBuffer, + PDWORD pcbWritten); + + + COemUni2(); + ~COemUni2(); + +protected: + LONG m_cRef; + IPrintOemDriverUni* m_pOEMHelp; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.def b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.def new file mode 100644 index 00000000..a9534822 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.def @@ -0,0 +1,3 @@ +LIBRARY OEMPREAN +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.h b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.h new file mode 100644 index 00000000..f8fa44a7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.h @@ -0,0 +1,259 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUNI.H +// +// +// PURPOSE: Define the COemPDEV class which stores the private +// PDEV for the driver. +// +// +// Functions: +// COemPDEV constructor and destructor +// COemPDEV::InitializeDDITable +// COemPDEV::_SavePFN +// COemPDEV::_ResetPointers +// +// History: +// 06/24/03 xxx created. +// +// + +#pragma once + +#include "debug.h" + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +#define DLLTEXT(s) TEXT("OEMUNI: ") TEXT(s) +#define ERRORTEXT(s) TEXT("ERROR ") DLLTEXT(s) + +class COemPDEV +{ +public: + __stdcall COemPDEV(void) + { + + // Note that since our parent has AddRef'd the UNIDRV interface, + // we don't do so here since our scope is identical to our + // parent. + // + + VERBOSE(L"In COemPDEV constructor..."); + + _ResetPointers(); + } + + __stdcall ~COemPDEV(void) + { + VERBOSE(L"In COemPDEV destructor..."); + } + + void __stdcall InitializeDDITable(DRVENABLEDATA* pded) + { + VERBOSE(L"COemPDEV::InitializeDDITable entry."); + + UINT iDrvFn; + UINT cDrvFn = pded->c; + PDRVFN pDrvFn = pded->pdrvfn; + + for (iDrvFn = 0; iDrvFn < cDrvFn; ++iDrvFn, ++pDrvFn) + { + _SavePFN(pDrvFn->iFunc, pDrvFn->pfn); + } + } + +private: + + void __stdcall _SavePFN(ULONG uFunc, PFN pfn) + { + + // Note: if a "pass-through" driver is being constructed, then + // there is nothing for this method to do. So, to keep the + // compiler from complaining about a switch with no case + // statements, but which has a default statement, we surround + // the entire construct with preprocessor controls. + // + switch(uFunc) + { + // The following are the page/band related DDI hooks. + // + + case INDEX_DrvStartDoc: + m_pfnDrvStartDoc = (PFN_DrvStartDoc)pfn; + break; + case INDEX_DrvEndDoc: + m_pfnDrvEndDoc = (PFN_DrvEndDoc)pfn; + break; + case INDEX_DrvStartPage: + m_pfnDrvStartPage = (PFN_DrvStartPage)pfn; + break; + case INDEX_DrvSendPage: + m_pfnDrvSendPage = (PFN_DrvSendPage)pfn; + break; + case INDEX_DrvStartBanding: + m_pfnDrvStartBanding = (PFN_DrvStartBanding)pfn; + break; + case INDEX_DrvNextBand: + m_pfnDrvNextBand = (PFN_DrvNextBand)pfn; + break; + case INDEX_DrvEscape: + m_pfnDrvEscape = (PFN_DrvEscape)pfn; + break; + + // The following are the drawing related DDI hooks. + // + case INDEX_DrvAlphaBlend: + m_pfnDrvAlphaBlend = (PFN_DrvAlphaBlend)pfn; + break; + case INDEX_DrvBitBlt: + m_pfnDrvBitBlt = (PFN_DrvBitBlt)pfn; + break; + case INDEX_DrvCopyBits: + m_pfnDrvCopyBits = (PFN_DrvCopyBits)pfn; + break; + case INDEX_DrvDitherColor: + m_pfnDrvDitherColor = (PFN_DrvDitherColor)pfn; + break; + case INDEX_DrvFillPath: + m_pfnDrvFillPath = (PFN_DrvFillPath)pfn; + break; + case INDEX_DrvFontManagement: + m_pfnDrvFontManagement = (PFN_DrvFontManagement)pfn; + break; + case INDEX_DrvGetGlyphMode: + m_pfnDrvGetGlyphMode = (PFN_DrvGetGlyphMode)pfn; + break; + case INDEX_DrvGradientFill: + m_pfnDrvGradientFill = (PFN_DrvGradientFill)pfn; + break; + case INDEX_DrvLineTo: + m_pfnDrvLineTo = (PFN_DrvLineTo)pfn; + break; + case INDEX_DrvPaint: + m_pfnDrvPaint = (PFN_DrvPaint)pfn; + break; + case INDEX_DrvPlgBlt: + m_pfnDrvPlgBlt = (PFN_DrvPlgBlt)pfn; + break; + case INDEX_DrvQueryAdvanceWidths: + m_pfnDrvQueryAdvanceWidths = (PFN_DrvQueryAdvanceWidths)pfn; + break; + case INDEX_DrvQueryFont: + m_pfnDrvQueryFont = (PFN_DrvQueryFont)pfn; + break; + case INDEX_DrvQueryFontData: + m_pfnDrvQueryFontData = (PFN_DrvQueryFontData)pfn; + break; + case INDEX_DrvQueryFontTree: + m_pfnDrvQueryFontTree = (PFN_DrvQueryFontTree)pfn; + break; + case INDEX_DrvRealizeBrush: + m_pfnDrvRealizeBrush = (PFN_DrvRealizeBrush)pfn; + break; + case INDEX_DrvStretchBlt: + m_pfnDrvStretchBlt = (PFN_DrvStretchBlt)pfn; + break; + case INDEX_DrvStretchBltROP: + m_pfnDrvStretchBltROP = (PFN_DrvStretchBltROP)pfn; + break; + case INDEX_DrvStrokeAndFillPath: + m_pfnDrvStrokeAndFillPath = (PFN_DrvStrokeAndFillPath)pfn; + break; + case INDEX_DrvStrokePath: + m_pfnDrvStrokePath = (PFN_DrvStrokePath)pfn; + break; + case INDEX_DrvTextOut: + m_pfnDrvTextOut = (PFN_DrvTextOut)pfn; + break; + case INDEX_DrvTransparentBlt: + m_pfnDrvTransparentBlt = (PFN_DrvTransparentBlt)pfn; + break; + + } // switch(uFunc) + } + + void __stdcall _ResetPointers(void) + { + m_pfnDrvAlphaBlend = NULL; + m_pfnDrvBitBlt = NULL; + m_pfnDrvCopyBits = NULL; + m_pfnDrvDitherColor = NULL; + m_pfnDrvEndDoc = NULL; + m_pfnDrvEscape = NULL; + m_pfnDrvFillPath = NULL; + m_pfnDrvFontManagement = NULL; + m_pfnDrvGetGlyphMode = NULL; + m_pfnDrvGradientFill = NULL; + m_pfnDrvLineTo = NULL; + m_pfnDrvNextBand = NULL; + m_pfnDrvPaint = NULL; + m_pfnDrvPlgBlt = NULL; + m_pfnDrvQueryAdvanceWidths = NULL; + m_pfnDrvQueryFont = NULL; + m_pfnDrvQueryFontData = NULL; + m_pfnDrvQueryFontTree = NULL; + m_pfnDrvRealizeBrush = NULL; + m_pfnDrvSendPage = NULL; + m_pfnDrvStartBanding = NULL; + m_pfnDrvStartDoc = NULL; + m_pfnDrvStartPage = NULL; + m_pfnDrvStretchBlt = NULL; + m_pfnDrvStretchBltROP = NULL; + m_pfnDrvStrokeAndFillPath = NULL; + m_pfnDrvStrokePath = NULL; + m_pfnDrvTextOut = NULL; + m_pfnDrvTransparentBlt = NULL; + } + +public: + + // Unidrv function pointers so that we can punt + // back from the DDI hooks + // + PFN_DrvAlphaBlend m_pfnDrvAlphaBlend; + PFN_DrvBitBlt m_pfnDrvBitBlt; + PFN_DrvCopyBits m_pfnDrvCopyBits; + PFN_DrvDitherColor m_pfnDrvDitherColor; + PFN_DrvEndDoc m_pfnDrvEndDoc; + PFN_DrvEscape m_pfnDrvEscape; + PFN_DrvFillPath m_pfnDrvFillPath; + PFN_DrvFontManagement m_pfnDrvFontManagement; + PFN_DrvGetGlyphMode m_pfnDrvGetGlyphMode; + PFN_DrvGradientFill m_pfnDrvGradientFill; + PFN_DrvLineTo m_pfnDrvLineTo; + PFN_DrvNextBand m_pfnDrvNextBand; + PFN_DrvPaint m_pfnDrvPaint; + PFN_DrvPlgBlt m_pfnDrvPlgBlt; + PFN_DrvQueryAdvanceWidths m_pfnDrvQueryAdvanceWidths; + PFN_DrvQueryFont m_pfnDrvQueryFont; + PFN_DrvQueryFontData m_pfnDrvQueryFontData; + PFN_DrvQueryFontTree m_pfnDrvQueryFontTree; + PFN_DrvRealizeBrush m_pfnDrvRealizeBrush; + PFN_DrvSendPage m_pfnDrvSendPage; + PFN_DrvStartBanding m_pfnDrvStartBanding; + PFN_DrvStartDoc m_pfnDrvStartDoc; + PFN_DrvStartPage m_pfnDrvStartPage; + PFN_DrvStretchBlt m_pfnDrvStretchBlt; + PFN_DrvStretchBltROP m_pfnDrvStretchBltROP; + PFN_DrvStrokeAndFillPath m_pfnDrvStrokeAndFillPath; + PFN_DrvStrokePath m_pfnDrvStrokePath; + PFN_DrvTextOut m_pfnDrvTextOut; + PFN_DrvTransparentBlt m_pfnDrvTransparentBlt; + + /*******************************************/ + /* */ + /* Add any custom PDEV members here */ + /* */ + /*******************************************/ + + BOOL bPreAnalysis; // Indicates if a current pass is the pre-analysis pass + +}; +typedef COemPDEV* POEMPDEV; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.rc b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.rc new file mode 100644 index 00000000..875705f1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.rc @@ -0,0 +1,110 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by DDK Support Team\0" + VALUE "CompanyName", "Microsoft Corp.\0" + VALUE "FileDescription", "OEM Pre-Analysis Sample\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "OEMPREAN\0" + VALUE "LegalCopyright", "Copyright © 1998-2003\0" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation\0" + VALUE "OriginalFilename", "OEMPREAN.DLL\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Microsoft OEMPREAN\0" + VALUE "ProductVersion", "1.0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj new file mode 100644 index 00000000..b1ff3191 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj @@ -0,0 +1,1096 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {D5E225D5-EEEA-45FD-AD07-E4678C542E1A} + $(MSBuildProjectName) + Win10 Debug + Win32 + {179B20BC-0106-4AEE-814D-8E6C0FD66347} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + oemprean + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + oemprean.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj.Filters new file mode 100644 index 00000000..eae4ad4e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/oemprean.vcxproj.Filters @@ -0,0 +1,177 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {846460B0-CFA8-4A48-BE85-411A0055B60C} + + + h;hpp;hxx;hm;inl;inc;xsd + {B95DE626-65CE-4B7F-A90F-6094DB24D175} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {3E039E41-E6A5-4CB3-8B97-DBE76450B55B} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/precomp.h new file mode 100644 index 00000000..3bfba083 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/precomp.h @@ -0,0 +1,49 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.h +// +// PURPOSE: Consolidate common headers that do not change frequently. +// +// History: +// 06/24/03 xxx created. +// +// + +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + +// Required header files that shouldn't change often. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/resource.h new file mode 100644 index 00000000..8e941820 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by OEMUNI.rc +// + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps.ini b/print/OEM Printer Customization Plug-in Samples/C++/oemps.ini new file mode 100644 index 00000000..7ad0e62a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMDriverFile1=OEMPS.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.rc b/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.rc new file mode 100644 index 00000000..49008d4c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.rc @@ -0,0 +1,109 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team\0" + VALUE "CompanyName", "Microsoft Corp.\0" + VALUE "FileDescription", "OEM Customization Sample\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "OEMPS\0" + VALUE "LegalCopyright", "Copyright © 1998-2003\0" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation\0" + VALUE "OriginalFilename", "OEMPS.DLL\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Microsoft OEMPS\0" + VALUE "ProductVersion", "1.0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj new file mode 100644 index 00000000..c30249a8 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj @@ -0,0 +1,1096 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {9F374241-B8F9-45D3-B163-7E84E8E22C1F} + $(MSBuildProjectName) + Win10 Debug + Win32 + {143DF0A4-9C2F-48FB-A070-C9D9465D83B2} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + OEMPS + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + OEMPS.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj.Filters new file mode 100644 index 00000000..6935f366 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/OEMPS.vcxproj.Filters @@ -0,0 +1,220 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {CFF33BBA-FC87-4E95-B9C5-476E1462EEBF} + + + h;hpp;hxx;hm;inl;inc;xsd + {9BFF3627-E67C-4BAB-A7A6-BCE2D1B5C993} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {87727098-2810-47BA-A965-219906793BC2} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/command.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemps/command.cpp new file mode 100644 index 00000000..06e049c9 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/command.cpp @@ -0,0 +1,278 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: command.cpp +// +// PURPOSE: Source module for OEM customized Command(s). +// + +#include "precomp.h" +#include "oemps.h" +#include "debug.h" +#include "command.h" +#include "resource.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal String Literals +//////////////////////////////////////////////////////// + +const CHAR TEST_BEGINSTREAM[] = "%%Test: Before begin stream\r\n"; +const CHAR TEST_PSADOBE[] = "%%Test: Before %!PS-Adobe\r\n"; +const CHAR TEST_PAGESATEND[] = "%%Test: Replace driver's %%PagesAtend\r\n"; +const CHAR TEST_PAGES[] = "%%Test: Replace driver's %%Pages: (atend)\r\n"; +const CHAR TEST_DOCUMENTPROCESSCOLORS[] = "%%Test: Replace driver's %%DocumentProcessColors: (atend)\r\n"; +const CHAR TEST_COMMENTS[] = "%%Test: Before %%EndComments\r\n"; +const CHAR TEST_DEFAULTS[] = "%%Test: Before %%BeginDefaults and %%EndDefaults\r\n"; +const CHAR TEST_BEGINPROLOG[] = "%%Test: After %%BeginProlog\r\n"; +const CHAR TEST_ENDPROLOG[] = "%%Test: Before %%EndProlog\r\n"; +const CHAR TEST_BEGINSETUP[] = "%%Test: After %%BeginSetup\r\n"; +const CHAR TEST_ENDSETUP[] = "%%Test: Before %%EndSetup\r\n"; +const CHAR TEST_BEGINPAGESETUP[] = "%%Test: After %%BeginPageSetup\r\n"; +const CHAR TEST_ENDPAGESETUP[] = "%%Test: Before %%EndpageSetup\r\n"; +const CHAR TEST_PAGETRAILER[] = "%%Test: After %%PageTrailer\r\n"; +const CHAR TEST_TRAILER[] = "%%Test: After %%Trailer\r\n"; +const CHAR TEST_PAGENUMBER[] = "%%Test: Replace driver's %%Page:\r\n"; +const CHAR TEST_PAGEORDER[] = "%%Test: Replace driver's %%PageOrder:\r\n"; +const CHAR TEST_ORIENTATION[] = "%%Test: Replace driver's %%Orientation:\r\n"; +const CHAR TEST_BOUNDINGBOX[] = "%%Test: Replace driver's %%BoundingBox:\r\n"; +const CHAR TEST_DOCNEEDEDRES[] = "%%Test: Append to driver's %%DocumentNeededResourc\r\n"; +const CHAR TEST_DOCSUPPLIEDRES[] = "%%Test: Append to driver's %%DocumentSuppliedResou\r\n"; +const CHAR TEST_EOF[] = "%%Test: After %%EOF\r\n"; +const CHAR TEST_ENDSTREAM[] = "%%Test: After the last byte of job stream\r\n"; +const CHAR TEST_DOCUMENTPROCESSCOLORSATEND[] = "%%Test: DocumentProcessColorsAtend\r\n"; +const CHAR TEST_VMSAVE[] = "%%Test: %%VMSave\r\n"; +const CHAR TEST_VMRESTORE[] = "%%Test: %%VMRestore\r\n"; +const CHAR TEST_PLATECOLOR[] = "%%Test: %%PlateColor:\r\n"; +const CHAR TEST_SHOWPAGE[] = "%%Test: %%SowPage:\r\n"; +const CHAR TEST_PAGEBBOX[] = "%%Test: %%PageBox:\r\n"; +const CHAR TEST_ENDPAGECOMMENTS[] = "%%Test: %%EndPageComments:\r\n"; + + +//////////////////////////////////////////////////////////////////////////////////// +// The PSCRIPT driver calls this OEM function at specific points during output +// generation. This gives the OEM DLL an opportunity to insert code fragments +// at specific injection points in the driver's code. It should use +// DrvWriteSpoolBuf for generating any output it requires. + +HRESULT PSCommand(PDEVOBJ pdevobj, DWORD dwIndex, PVOID pData, DWORD cbSize, + IPrintOemDriverPS* pOEMHelp, PDWORD pdwReturn) +{ + PCSTR pProcedure = NULL; + DWORD dwLen = 0; + DWORD dwSize = 0; + HRESULT hResult = E_FAIL; + + VERBOSE("Entering OEMCommand...\r\n"); + + UNREFERENCED_PARAMETER(cbSize); + UNREFERENCED_PARAMETER(pData); + + switch (dwIndex) + { + case PSINJECT_BEGINSTREAM: + VERBOSE("OEMCommand PSINJECT_BEGINSTREAM\n"); + pProcedure = TEST_BEGINSTREAM; + break; + + case PSINJECT_PSADOBE: + VERBOSE("OEMCommand PSINJECT_PSADOBE\n"); + pProcedure = TEST_PSADOBE; + break; + + case PSINJECT_PAGESATEND: + VERBOSE("OEMCommand PSINJECT_PAGESATEND\n"); + pProcedure = TEST_PAGESATEND; + break; + + case PSINJECT_PAGES: + VERBOSE("OEMCommand PSINJECT_PAGES\n"); + pProcedure = TEST_PAGES; + break; + + case PSINJECT_DOCNEEDEDRES: + VERBOSE("OEMCommand PSINJECT_DOCNEEDEDRES\n"); + pProcedure = TEST_DOCNEEDEDRES; + break; + + case PSINJECT_DOCSUPPLIEDRES: + VERBOSE("OEMCommand PSINJECT_DOCSUPPLIEDRES\n"); + pProcedure = TEST_DOCSUPPLIEDRES; + break; + + case PSINJECT_PAGEORDER: + VERBOSE("OEMCommand PSINJECT_PAGEORDER\n"); + pProcedure = TEST_PAGEORDER; + break; + + case PSINJECT_ORIENTATION: + VERBOSE("OEMCommand PSINJECT_ORIENTATION\n"); + pProcedure = TEST_ORIENTATION; + break; + + case PSINJECT_BOUNDINGBOX: + VERBOSE("OEMCommand PSINJECT_BOUNDINGBOX\n"); + pProcedure = TEST_BOUNDINGBOX; + break; + + case PSINJECT_DOCUMENTPROCESSCOLORS: + VERBOSE("OEMCommand PSINJECT_DOCUMENTPROCESSCOLORS\n"); + pProcedure = TEST_DOCUMENTPROCESSCOLORS; + break; + + case PSINJECT_COMMENTS: + VERBOSE("OEMCommand PSINJECT_COMMENTS\n"); + pProcedure = TEST_COMMENTS; + break; + + case PSINJECT_BEGINDEFAULTS: + VERBOSE("OEMCommand PSINJECT_BEGINDEFAULTS\n"); + pProcedure = TEST_DEFAULTS; + break; + + case PSINJECT_ENDDEFAULTS: + VERBOSE("OEMCommand PSINJECT_BEGINDEFAULTS\n"); + pProcedure = TEST_DEFAULTS; + break; + + case PSINJECT_BEGINPROLOG: + VERBOSE("OEMCommand PSINJECT_BEGINPROLOG\n"); + pProcedure = TEST_BEGINPROLOG; + break; + + case PSINJECT_ENDPROLOG: + VERBOSE("OEMCommand PSINJECT_ENDPROLOG\n"); + pProcedure = TEST_ENDPROLOG; + break; + + case PSINJECT_BEGINSETUP: + VERBOSE("OEMCommand PSINJECT_BEGINSETUP\n"); + pProcedure = TEST_BEGINSETUP; + break; + + case PSINJECT_ENDSETUP: + VERBOSE("OEMCommand PSINJECT_ENDSETUP\n"); + pProcedure = TEST_ENDSETUP; + break; + + case PSINJECT_BEGINPAGESETUP: + VERBOSE("OEMCommand PSINJECT_BEGINPAGESETUP\n"); + pProcedure = TEST_BEGINPAGESETUP; + break; + + case PSINJECT_ENDPAGESETUP: + VERBOSE("OEMCommand PSINJECT_ENDPAGESETUP\n"); + pProcedure = TEST_ENDPAGESETUP; + break; + + case PSINJECT_PAGETRAILER: + VERBOSE("OEMCommand PSINJECT_PAGETRAILER\n"); + pProcedure = TEST_PAGETRAILER; + break; + + case PSINJECT_TRAILER: + VERBOSE("OEMCommand PSINJECT_TRAILER\n"); + pProcedure = TEST_TRAILER; + break; + + case PSINJECT_PAGENUMBER: + VERBOSE("OEMCommand PSINJECT_PAGENUMBER\n"); + pProcedure = TEST_PAGENUMBER; + break; + + case PSINJECT_EOF: + VERBOSE("OEMCommand PSINJECT_EOF\n"); + pProcedure = TEST_EOF; + break; + + case PSINJECT_ENDSTREAM: + VERBOSE("OEMCommand PSINJECT_ENDSTREAM\n"); + pProcedure = TEST_ENDSTREAM; + break; + + case PSINJECT_DOCUMENTPROCESSCOLORSATEND: + VERBOSE("OEMCommand PSINJECT_DOCUMENTPROCESSCOLORSATEND\n"); + pProcedure = TEST_DOCUMENTPROCESSCOLORSATEND; + break; + + case PSINJECT_VMSAVE: + VERBOSE("OEMCommand PSINJECT_VMSAVE\n"); + pProcedure = TEST_VMSAVE; + break; + + case PSINJECT_VMRESTORE: + VERBOSE("OEMCommand PSINJECT_VMRESTORE\n"); + pProcedure = TEST_VMRESTORE; + break; + + case PSINJECT_PLATECOLOR: + VERBOSE("OEMCommand PSINJECT_PLATECOLOR\n"); + pProcedure = TEST_PLATECOLOR; + break; + + case PSINJECT_SHOWPAGE: + VERBOSE("OEMCommand PSINJECT_SHOWPAGE\n"); + pProcedure = TEST_SHOWPAGE; + break; + + case PSINJECT_PAGEBBOX: + VERBOSE("OEMCommand PSINJECT_PAGEBBOX\n"); + pProcedure = TEST_PAGEBBOX; + break; + + case PSINJECT_ENDPAGECOMMENTS: + VERBOSE("OEMCommand PSINJECT_ENDPAGECOMMENTS\n"); + pProcedure = TEST_ENDPAGECOMMENTS; + break; + + default: + ERR("Undefined PSCommand!\r\n"); + *pdwReturn = ERROR_NOT_SUPPORTED; + return E_NOTIMPL; + } + + // INVARIANT: should have injection string. + + if(NULL != pProcedure) + { + // Write PostScript to spool file. + dwLen = (DWORD)strlen(pProcedure); + if (dwLen > 0) + { + hResult = pOEMHelp->DrvWriteSpoolBuf(pdevobj, const_cast(pProcedure), dwLen, &dwSize); + } + + // Set return values. + if(SUCCEEDED(hResult) && (dwLen == dwSize)) + { + *pdwReturn = ERROR_SUCCESS; + } + else + { + // Return a meaningful + // error value. + *pdwReturn = GetLastError(); + if(ERROR_SUCCESS == *pdwReturn) + { + *pdwReturn = ERROR_WRITE_FAULT; + } + + // Make sure we return failure + // if the write didn't succeded. + if(SUCCEEDED(hResult)) + { + hResult = HRESULT_FROM_WIN32(*pdwReturn); + } + } + } + + return hResult; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/command.h b/print/OEM Printer Customization Plug-in Samples/C++/oemps/command.h new file mode 100644 index 00000000..e18cdfac --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/command.h @@ -0,0 +1,24 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Command.h +// +// +// PURPOSE: Declare the function that handles custom +// processing of commands. +// + +#pragma once + +///////////////////////////////////////////////////////// +// Prototypes +///////////////////////////////////////////////////////// + +HRESULT PSCommand(PDEVOBJ, DWORD, PVOID, DWORD, IPrintOemDriverPS*, PDWORD); + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/ddihook.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemps/ddihook.cpp new file mode 100644 index 00000000..e14d9cdd --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/ddihook.cpp @@ -0,0 +1,1049 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: DDIHook.cpp +// +// +// PURPOSE: DDI Hook routines for User Mode COM Customization DLL. +// + +#include "precomp.h" +#include "debug.h" +#include "oemps.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +// +// OEMBitBlt +// + +BOOL APIENTRY +OEMBitBlt( + SURFOBJ *psoTrg, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclTrg, + POINTL *pptlSrc, + POINTL *pptlMask, + BRUSHOBJ *pbo, + POINTL *pptlBrush, + ROP4 rop4 + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMBitBlt() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoTrg->dhpdev; + + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvBitBlt)(poempdev->pfnPS[UD_DrvBitBlt])) ( + psoTrg, + psoSrc, + psoMask, + pco, + pxlo, + prclTrg, + pptlSrc, + pptlMask, + pbo, + pptlBrush, + rop4)); + +} + +// +// OEMStretchBlt +// + +BOOL APIENTRY +OEMStretchBlt( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMStretchBlt() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + + // + // turn around to call PS + // + + return (((PFN_DrvStretchBlt)(poempdev->pfnPS[UD_DrvStretchBlt])) ( + psoDest, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDest, + prclSrc, + pptlMask, + iMode)); + +} + + +// +// OEMCopyBits +// + +BOOL APIENTRY +OEMCopyBits( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDest, + POINTL *pptlSrc + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMCopyBits() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvCopyBits)(poempdev->pfnPS[UD_DrvCopyBits])) ( + psoDest, + psoSrc, + pco, + pxlo, + prclDest, + pptlSrc)); + +} + +// +// OEMTextOut +// + +BOOL APIENTRY +OEMTextOut( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMTextOut() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvTextOut)(poempdev->pfnPS[UD_DrvTextOut])) ( + pso, + pstro, + pfo, + pco, + prclExtra, + prclOpaque, + pboFore, + pboOpaque, + pptlOrg, + mix)); + +} + +// +// OEMStrokePath +// + +BOOL APIENTRY +OEMStrokePath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + LINEATTRS *plineattrs, + MIX mix + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMStokePath() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvStrokePath)(poempdev->pfnPS[UD_DrvStrokePath])) ( + pso, + ppo, + pco, + pxo, + pbo, + pptlBrushOrg, + plineattrs, + mix)); + +} + +// +// OEMFillPath +// + +BOOL APIENTRY +OEMFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + MIX mix, + FLONG flOptions + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMFillPath() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvFillPath)(poempdev->pfnPS[UD_DrvFillPath])) ( + pso, + ppo, + pco, + pbo, + pptlBrushOrg, + mix, + flOptions)); + +} + +// +// OEMStrokeAndFillPath +// + +BOOL APIENTRY +OEMStrokeAndFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pboStroke, + LINEATTRS *plineattrs, + BRUSHOBJ *pboFill, + POINTL *pptlBrushOrg, + MIX mixFill, + FLONG flOptions + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMStrokeAndFillPath() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvStrokeAndFillPath)(poempdev->pfnPS[UD_DrvStrokeAndFillPath])) ( + pso, + ppo, + pco, + pxo, + pboStroke, + plineattrs, + pboFill, + pptlBrushOrg, + mixFill, + flOptions)); + +} + +// +// OEMRealizeBrush +// + +BOOL APIENTRY +OEMRealizeBrush( + BRUSHOBJ *pbo, + SURFOBJ *psoTarget, + SURFOBJ *psoPattern, + SURFOBJ *psoMask, + XLATEOBJ *pxlo, + ULONG iHatch + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMRealizeBrush() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoTarget->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvRealizeBrush)(poempdev->pfnPS[UD_DrvRealizeBrush])) ( + pbo, + psoTarget, + psoPattern, + psoMask, + pxlo, + iHatch)); + +} + +// +// OEMStartPage +// + +BOOL APIENTRY +OEMStartPage( + SURFOBJ *pso + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMStartPage() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvStartPage)(poempdev->pfnPS[UD_DrvStartPage]))(pso)); + +} + +#define OEM_TESTSTRING "The DDICMDCB DLL adds this line of text." + +// +// OEMSendPage +// + +BOOL APIENTRY +OEMSendPage( + SURFOBJ *pso + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMSendPage() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // print a line of text, just for testing + // + if (pso->iType == STYPE_BITMAP) + { + pdevobj->pDrvProcs->DrvXMoveTo(pdevobj, 0, 0); + pdevobj->pDrvProcs->DrvYMoveTo(pdevobj, 0, 0); + pdevobj->pDrvProcs->DrvWriteSpoolBuf(pdevobj, OEM_TESTSTRING, + sizeof(OEM_TESTSTRING)); + } + + // + // turn around to call PS + // + + return (((PFN_DrvSendPage)(poempdev->pfnPS[UD_DrvSendPage]))(pso)); + +} + +// +// OEMEscape +// + +ULONG APIENTRY +OEMEscape( + SURFOBJ *pso, + ULONG iEsc, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMEscape() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvEscape)(poempdev->pfnPS[UD_DrvEscape])) ( + pso, + iEsc, + cjIn, + pvIn, + cjOut, + pvOut)); + +} + +// +// OEMStartDoc +// + +BOOL APIENTRY +OEMStartDoc( + SURFOBJ *pso, + _In_ PWSTR pwszDocName, + DWORD dwJobId + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMStartDoc() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvStartDoc)(poempdev->pfnPS[UD_DrvStartDoc])) ( + pso, + pwszDocName, + dwJobId)); + +} + +// +// OEMEndDoc +// + +BOOL APIENTRY +OEMEndDoc( + SURFOBJ *pso, + FLONG fl + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMEndDoc() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvEndDoc)(poempdev->pfnPS[UD_DrvEndDoc])) ( + pso, + fl)); + +} + +//////// +// NOTE: +// OEM DLL needs to hook out the following six font related DDI calls only +// if it enumerates additional fonts beyond what's in the GPD file. +// And if it does, it needs to take care of its own fonts for all font DDI +// calls and DrvTextOut call. +/////// + +// +// OEMQueryFont +// + +PIFIMETRICS APIENTRY +OEMQueryFont( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG_PTR *pid + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMQueryFont() entry.\r\n"); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvQueryFont)(poempdev->pfnPS[UD_DrvQueryFont])) ( + dhpdev, + iFile, + iFace, + pid)); + +} + +// +// OEMQueryFontTree +// + +PVOID APIENTRY +OEMQueryFontTree( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG iMode, + ULONG_PTR *pid + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMQueryFontTree() entry.\r\n"); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvQueryFontTree)(poempdev->pfnPS[UD_DrvQueryFontTree])) ( + dhpdev, + iFile, + iFace, + iMode, + pid)); + +} + +// +// OEMQueryFontData +// + +LONG APIENTRY +OEMQueryFontData( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH hg, + GLYPHDATA *pgd, + _Out_writes_bytes_(cjSize) PVOID pv, + ULONG cjSize + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMQueryFontData() entry.\r\n"); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS if this is not the font that OEM enumerated. + // + + return (((PFN_DrvQueryFontData)(poempdev->pfnPS[UD_DrvQueryFontData])) ( + dhpdev, + pfo, + iMode, + hg, + pgd, + pv, + cjSize)); + +} + +// +// OEMQueryAdvanceWidths +// + +BOOL APIENTRY +OEMQueryAdvanceWidths( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + _In_reads_(cGlyphs) HGLYPH *phg, + _Out_writes_bytes_(cGlyphs*sizeof(USHORT)) PVOID pvWidths, + ULONG cGlyphs + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMQueryAdvanceWidths() entry.\r\n"); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS if this is not the font that OEM enumerated. + // + + return (((PFN_DrvQueryAdvanceWidths) + (poempdev->pfnPS[UD_DrvQueryAdvanceWidths])) ( + dhpdev, + pfo, + iMode, + phg, + pvWidths, + cGlyphs)); + +} + +// +// OEMFontManagement +// + +ULONG APIENTRY +OEMFontManagement( + SURFOBJ *pso, + FONTOBJ *pfo, + ULONG iMode, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMFontManagement() entry.\r\n"); + + // + // Note that PS will not call OEM DLL for iMode==QUERYESCSUPPORT. + // So pso is not NULL for sure. + // + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS if this is not the font that OEM enumerated. + // + + return (((PFN_DrvFontManagement)(poempdev->pfnPS[UD_DrvFontManagement])) ( + pso, + pfo, + iMode, + cjIn, + pvIn, + cjOut, + pvOut)); + +} + +// +// OEMGetGlyphMode +// + +ULONG APIENTRY +OEMGetGlyphMode( + DHPDEV dhpdev, + FONTOBJ *pfo + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMGetGlyphMode() entry.\r\n"); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS if this is not the font that OEM enumerated. + // + + return (((PFN_DrvGetGlyphMode)(poempdev->pfnPS[UD_DrvGetGlyphMode])) ( + dhpdev, + pfo)); + +} + + +// +// OEMStretchBltROP +// + +BOOL APIENTRY +OEMStretchBltROP( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode, + BRUSHOBJ *pbo, + ROP4 rop4 + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMStretchBltROP() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvStretchBltROP)(poempdev->pfnPS[UD_DrvStretchBltROP])) ( + psoDest, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDest, + prclSrc, + pptlMask, + iMode, + pbo, + rop4 + )); + + +} + +// +// OEMPlgBlt +// + +BOOL APIENTRY +OEMPlgBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlBrushOrg, + POINTFIX *pptfixDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMPlgBlt() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoDst->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvPlgBlt)(poempdev->pfnPS[UD_DrvPlgBlt])) ( + psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlBrushOrg, + pptfixDest, + prclSrc, + pptlMask, + iMode)); + +} + +// +// OEMAlphaBlend +// + +BOOL APIENTRY +OEMAlphaBlend( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDest, + RECTL *prclSrc, + BLENDOBJ *pBlendObj + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMAlphaBlend() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvAlphaBlend)(poempdev->pfnPS[UD_DrvAlphaBlend])) ( + psoDest, + psoSrc, + pco, + pxlo, + prclDest, + prclSrc, + pBlendObj + )); + +} + +// +// OEMGradientFill +// + +BOOL APIENTRY +OEMGradientFill( + SURFOBJ *psoDest, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + TRIVERTEX *pVertex, + ULONG nVertex, + PVOID pMesh, + ULONG nMesh, + RECTL *prclExtents, + POINTL *pptlDitherOrg, + ULONG ulMode + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMGradientFill() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvGradientFill)(poempdev->pfnPS[UD_DrvGradientFill])) ( + psoDest, + pco, + pxlo, + pVertex, + nVertex, + pMesh, + nMesh, + prclExtents, + pptlDitherOrg, + ulMode + )); + +} + +BOOL APIENTRY +OEMTransparentBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + RECTL *prclSrc, + ULONG iTransColor, + ULONG ulReserved + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMTransparentBlt() entry.\r\n"); + + pdevobj = (PDEVOBJ)psoDst->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvTransparentBlt)(poempdev->pfnPS[UD_DrvTransparentBlt])) ( + psoDst, + psoSrc, + pco, + pxlo, + prclDst, + prclSrc, + iTransColor, + ulReserved + )); + +} + +HANDLE APIENTRY +OEMIcmCreateColorTransform( + DHPDEV dhpdev, + LPLOGCOLORSPACEW pLogColorSpace, + _In_reads_bytes_opt_(cjSourceProfile) PVOID pvSourceProfile, + ULONG cjSourceProfile, + _In_reads_bytes_(cjDestProfile) PVOID pvDestProfile, + ULONG cjDestProfile, + _In_reads_bytes_opt_(cjTargetProfile) PVOID pvTargetProfile, + ULONG cjTargetProfile, + DWORD dwReserved + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMCreateColorTransform() entry.\r\n"); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvIcmCreateColorTransform)(poempdev->pfnPS[UD_DrvIcmCreateColorTransform])) ( + dhpdev, + pLogColorSpace, + pvSourceProfile, + cjSourceProfile, + pvDestProfile, + cjDestProfile, + pvTargetProfile, + cjTargetProfile, + dwReserved + )); + +} + +BOOL APIENTRY +OEMIcmDeleteColorTransform( + DHPDEV dhpdev, + HANDLE hcmXform + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMDeleteColorTransform() entry.\r\n"); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvIcmDeleteColorTransform)(poempdev->pfnPS[UD_DrvIcmDeleteColorTransform])) ( + dhpdev, + hcmXform + )); + +} + +BOOL APIENTRY +OEMQueryDeviceSupport( + SURFOBJ *pso, + XLATEOBJ *pxlo, + XFORMOBJ *pxo, + ULONG iType, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE("OEMQueryDeviceSupport() entry.\r\n"); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call PS + // + + return (((PFN_DrvQueryDeviceSupport)(poempdev->pfnPS[UD_DrvQueryDeviceSupport])) ( + pso, + pxlo, + pxo, + iType, + cjIn, + pvIn, + cjOut, + pvOut + )); +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/oemps/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.cpp new file mode 100644 index 00000000..3e66faeb --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.cpp @@ -0,0 +1,151 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + +#include "precomp.h" +#include "oemps.h" +#include "debug.h" +#include "devmode.h" + + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR("DevMode() ERROR_INVALID_PARAMETER.\r\n"); + + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + case OEMDM_DEFAULT: + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + break; + + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return S_OK; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) +{ + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR("ConvertOEMDevmode() invalid parameters.\r\n"); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE("Converting private OEM Devmode.\r\n"); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n"); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + } + + return TRUE; +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data. + pOEMDevmode->dwDriverData = 0; + + return TRUE; +} + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.h new file mode 100644 index 00000000..3cf13641 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/devmode.h @@ -0,0 +1,44 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + BOOL dwDriverData; + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + +///////////////////////////////////////////////////////// +// Prototypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); +void Dump(PCOEMDEV pOEMDevIn); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemps/dllentry.cpp new file mode 100644 index 00000000..d9851eff --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/dllentry.cpp @@ -0,0 +1,50 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "oemps.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE("Process attach.\r\n"); + break; + + case DLL_THREAD_ATTACH: + VERBOSE("Thread attach.\r\n"); + break; + + case DLL_PROCESS_DETACH: + VERBOSE("Process detach.\r\n"); + break; + + case DLL_THREAD_DETACH: + VERBOSE("Thread detach.\r\n"); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.cpp new file mode 100644 index 00000000..34f0914c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.cpp @@ -0,0 +1,632 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Interface for User Mode COM Customization DLL. +// + +#include "precomp.h" + +#include "debug.h" + +#include "devmode.h" +#include "oemps.h" +#include "command.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents; // Count of active components +static long g_cServerLocks; // Count of locks + +//////////////////////////////////////////////////////// +// Internal Constants +//////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////// +// Warning: the following array order must match the +// order in enum ENUMHOOKS. +/////////////////////////////////////////////////////// +static const DRVFN OEMHookFuncs[] = +{ + { INDEX_DrvRealizeBrush, (PFN) OEMRealizeBrush }, + { INDEX_DrvCopyBits, (PFN) OEMCopyBits }, + { INDEX_DrvBitBlt, (PFN) OEMBitBlt }, + { INDEX_DrvStretchBlt, (PFN) OEMStretchBlt }, + { INDEX_DrvTextOut, (PFN) OEMTextOut }, + { INDEX_DrvStrokePath, (PFN) OEMStrokePath }, + { INDEX_DrvFillPath, (PFN) OEMFillPath }, + { INDEX_DrvStrokeAndFillPath, (PFN) OEMStrokeAndFillPath }, + { INDEX_DrvStartPage, (PFN) OEMStartPage }, + { INDEX_DrvSendPage, (PFN) OEMSendPage }, + { INDEX_DrvEscape, (PFN) OEMEscape }, + { INDEX_DrvStartDoc, (PFN) OEMStartDoc }, + { INDEX_DrvEndDoc, (PFN) OEMEndDoc }, + { INDEX_DrvQueryFont, (PFN) OEMQueryFont }, + { INDEX_DrvQueryFontTree, (PFN) OEMQueryFontTree }, + { INDEX_DrvQueryFontData, (PFN) OEMQueryFontData }, + { INDEX_DrvQueryAdvanceWidths, (PFN) OEMQueryAdvanceWidths }, + { INDEX_DrvFontManagement, (PFN) OEMFontManagement }, + { INDEX_DrvGetGlyphMode, (PFN) OEMGetGlyphMode }, + { INDEX_DrvStretchBltROP, (PFN) OEMStretchBltROP }, + { INDEX_DrvPlgBlt, (PFN) OEMPlgBlt }, + { INDEX_DrvTransparentBlt, (PFN) OEMTransparentBlt }, + { INDEX_DrvAlphaBlend, (PFN) OEMAlphaBlend }, + { INDEX_DrvGradientFill, (PFN) OEMGradientFill }, + { INDEX_DrvIcmCreateColorTransform, (PFN) OEMIcmCreateColorTransform }, + { INDEX_DrvIcmDeleteColorTransform, (PFN) OEMIcmDeleteColorTransform }, + { INDEX_DrvQueryDeviceSupport, (PFN) OEMQueryDeviceSupport }, +}; + + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemPS body +// +IOemPS::IOemPS() : m_cRef(1) +{ + VERBOSE("IOemPS::IOemPS() entered.\r\n"); + + // Increment COM component count. + InterlockedIncrement(&g_cComponents); + + m_pOEMHelp = NULL; + + VERBOSE("IOemPS::IOemPS() leaving.\r\n"); +} + + +IOemPS::~IOemPS() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); + + // Decrement COM compontent count. + InterlockedDecrement(&g_cComponents); +} + + +HRESULT __stdcall IOemPS::QueryInterface(const IID& iid, void** ppv) +{ + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE("IOemPS::QueryInterface IUnknown.\r\n"); + } + else if (iid == IID_IPrintOemPS) + { + *ppv = static_cast(this); + VERBOSE("IOemPS::QueryInterface IPrintOemPs.\r\n"); + } + else + { + VERBOSE("IOemPS::QueryInterface (interface not supported).\r\n"); + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall IOemPS::AddRef() +{ + VERBOSE("IOemPS::AddRef() entry.\r\n"); + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemPS::Release() +{ + VERBOSE("IOemPS::Release() entry.\r\n"); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + + +HRESULT __stdcall IOemPS::GetInfo ( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE("IOemPS::GetInfo(%d) entry.\r\n"); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + ERR("IOemPS::GetInfo() exit pcbNeeded is NULL!\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size. + if(OEMGI_GETPUBLISHERINFO != dwMode) + { + *pcbNeeded = sizeof(DWORD); + } + else + { + *pcbNeeded = sizeof(PUBLISHERINFO); + return E_FAIL; + } + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + ERR("IOemPS::GetInfo() exit insufficient buffer!\r\n"); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + case OEMGI_GETPUBLISHERINFO: + case OEMGI_GETREQUESTEDHELPERINTERFACES: + default: + // Set written bytes to zero since nothing was written. + ERR("IOemPS::GetInfo() exit, mode not supported.\r\n"); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + return S_OK; +} + +HRESULT __stdcall IOemPS::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE("IOemPS::PublishDriverInterface() entry.\r\n"); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (this->m_pOEMHelp == NULL) + { + HRESULT hResult; + + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverPS, (void** ) &(this->m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + this->m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + + +HRESULT __stdcall IOemPS::EnableDriver(DWORD dwDriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded) +{ + VERBOSE("IOemPS::EnableDriver() entry.\r\n"); + + UNREFERENCED_PARAMETER(dwDriverVersion); + UNREFERENCED_PARAMETER(cbSize); + + // List DDI functions that are hooked. + pded->iDriverVersion = PRINTER_OEMINTF_VERSION; + pded->c = sizeof(OEMHookFuncs) / sizeof(DRVFN); + pded->pdrvfn = (DRVFN *) OEMHookFuncs; + + // Even if nothing is done, need to return S_OK so + // that DisableDriver() will be called, which releases + // the reference to the Printer Driver's interface. + // If error occurs, return E_FAIL. + return S_OK; +} + +HRESULT __stdcall IOemPS::DisableDriver(VOID) +{ + VERBOSE("IOemPS::DisaleDriver() entry.\r\n"); + + // Release reference to Printer Driver's interface. + if (this->m_pOEMHelp) + { + this->m_pOEMHelp->Release(); + this->m_pOEMHelp = NULL; + } + + return S_OK; +} + +HRESULT __stdcall IOemPS::DisablePDEV( + PDEVOBJ pdevobj) +{ + VERBOSE("IOemPS::DisablePDEV() entry.\r\n"); + + // + // Free memory for OEMPDEV and any memory block that hangs off OEMPDEV. + // + assert(NULL != pdevobj->pdevOEM); + delete pdevobj->pdevOEM; + + return S_OK; +}; + +HRESULT __stdcall IOemPS::EnablePDEV( + PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem) +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(cPatterns); + UNREFERENCED_PARAMETER(phsurfPatterns); + UNREFERENCED_PARAMETER(cjGdiInfo); + UNREFERENCED_PARAMETER(pGdiInfo); + UNREFERENCED_PARAMETER(cjDevInfo); + UNREFERENCED_PARAMETER(pDevInfo); + + VERBOSE("IOemPS::EnablePDEV() entry.\r\n"); + + POEMPDEV poempdev; + INT i, j; + DWORD dwDDIIndex; + PDRVFN pdrvfn; + + // + // Allocate the OEMDev + // + poempdev = new OEMPDEV; + if (NULL == poempdev) + { + return E_FAIL; + } + + // + // Fill in OEMDEV + // + + for (i = 0; i < MAX_DDI_HOOKS; i++) + { + // + // search through PS's hooks and locate the function ptr + // + dwDDIIndex = OEMHookFuncs[i].iFunc; + for (j = pded->c, pdrvfn = pded->pdrvfn; j > 0; j--, pdrvfn++) + { + if (dwDDIIndex == pdrvfn->iFunc) + { + poempdev->pfnPS[i] = pdrvfn->pfn; + break; + } + } + if (j == 0) + { + // + // Didn't find the hook. This could mean PS doesn't hook this DDI but allows OEMs to hook it out. + // + poempdev->pfnPS[i] = NULL; + } + + } + + *pDevOem = (POEMPDEV) poempdev; + + return S_OK; +} + + +HRESULT __stdcall IOemPS::ResetPDEV( + PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew) +{ + UNREFERENCED_PARAMETER(pdevobjOld); + UNREFERENCED_PARAMETER(pdevobjNew); + + VERBOSE("IOemPS::ResetPDEV() entry.\r\n"); + + // + // If any information from the previous PDEV needs to be preserved, + // copy it in this function. + // + + return TRUE; +} + + +HRESULT __stdcall IOemPS::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE("IOemPS:DevMode entry.\n"); + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IOemPS::Command( + PDEVOBJ pdevobj, + DWORD dwIndex, + PVOID pData, + DWORD cbSize, + OUT DWORD *pdwResult) +{ + HRESULT hResult = E_NOTIMPL; + + + VERBOSE("IOemPS::Command() entry.\r\n"); + hResult = PSCommand(pdevobj, dwIndex, pData, cbSize, m_pOEMHelp, pdwResult); + + return hResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(); + ~IOemCF(); + +protected: + long m_cRef; +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +IOemCF::IOemCF() : m_cRef(1) +{ + VERBOSE("IOemCF::IOemCF() entered.\r\n"); +} + +IOemCF::~IOemCF() +{ + VERBOSE("IOemCF::~IOemCF() entered.\r\n"); + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE("IOemCF::QueryInterface entered.\r\n"); + + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + WARNING("IOemCF::QueryInterface (interface not supported).\r\n"); + *ppv = NULL; + return E_NOINTERFACE; + } + + reinterpret_cast(*ppv)->AddRef(); + + VERBOSE("IOemCF::QueryInterface leaving.\r\n"); + + return S_OK; +} + +ULONG __stdcall IOemCF::AddRef() +{ + VERBOSE("IOemCF::AddRef() called.\r\n"); + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + VERBOSE("IOemCF::Release() called.\r\n"); + + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + VERBOSE("Class factory: Create component.\r\n"); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + WARNING("Class factory: non-Null pUnknownOuter.\r\n"); + + return CLASS_E_NOAGGREGATION; + } + + // Create component. + IOemPS* pOemCP = new IOemPS; + if (pOemCP == NULL) + { + ERR("Class factory: failed to allocate IOemPS.\r\n"); + + return E_OUTOFMEMORY; + } + + // Get the requested interface. + HRESULT hr = pOemCP->QueryInterface(iid, ppv); + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCP->Release(); + return hr; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + VERBOSE("IOemCF::LockServer entered.\r\n"); + + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + + VERBOSE("IOemCF::LockServer() leaving.\r\n"); + return S_OK; +} + + +// +// Registration functions +// + +// +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + VERBOSE("DllCanUnloadNow entered.\r\n"); + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE("DllGetClassObject: Create class factory entered.\r\n"); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMRENDER) + { + WARNING("DllGetClassObject: doesn't support clsid!\r\n"); + return CLASS_E_CLASSNOTAVAILABLE; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + WARNING("DllGetClassObject: memory allocation failed!\r\n"); + return E_OUTOFMEMORY; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv); + pFontCF->Release(); + + return hr; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.h new file mode 100644 index 00000000..87b00473 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/intrface.h @@ -0,0 +1,119 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.H +// +// +// PURPOSE: Define COM interface for User Mode Printer Customization DLL. +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemPS +// +// Interface for PostScript OEM sample rendering module +// +class IOemPS : public IPrintOemPS +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IPrintOemPS methods *** + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Method for OEM to specify DDI hook out + // + + STDMETHOD(EnableDriver) (THIS_ DWORD DriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded); + + // + // Method to notify OEM plugin that it is no longer required + // + + STDMETHOD(DisableDriver) (THIS); + + // + // Method for OEM to contruct its own PDEV + // + + STDMETHOD(EnablePDEV) (THIS_ PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem); + + // + // Method for OEM to free any resource associated with its PDEV + // + + STDMETHOD(DisablePDEV) (THIS_ PDEVOBJ pdevobj); + + // + // Method for OEM to transfer from old PDEV to new PDEV + // + + STDMETHOD(ResetPDEV) (THIS_ PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew); + + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, + POEMDMPARAM pOemDMParam); + + // + // OEMCommand - PSCRIPT only, return E_NOTIMPL on Unidrv + // + + STDMETHOD(Command) (THIS_ PDEVOBJ pdevobj, + DWORD dwIndex, + PVOID pData, + DWORD cbSize, + OUT DWORD *pdwResult); + + IOemPS(); + ~IOemPS(); + +protected: + + long m_cRef; + + IPrintOemDriverPS* m_pOEMHelp; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.def b/print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.def new file mode 100644 index 00000000..9992eb3e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.def @@ -0,0 +1,3 @@ +LIBRARY OEMPS +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.h b/print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.h new file mode 100644 index 00000000..4fc07721 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/oemps.h @@ -0,0 +1,76 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMPS.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for oemps.cpp. +// +#pragma once + + +/////////////////////////////////////////////////////// +// Warning: the following enum order must match the +// order in OEMHookFuncs[]. +/////////////////////////////////////////////////////// +typedef enum tag_Hooks { + UD_DrvRealizeBrush, + UD_DrvCopyBits, + UD_DrvBitBlt, + UD_DrvStretchBlt, + UD_DrvTextOut, + UD_DrvStrokePath, + UD_DrvFillPath, + UD_DrvStrokeAndFillPath, + UD_DrvStartPage, + UD_DrvSendPage, + UD_DrvEscape, + UD_DrvStartDoc, + UD_DrvEndDoc, + UD_DrvQueryFont, + UD_DrvQueryFontTree, + UD_DrvQueryFontData, + UD_DrvQueryAdvanceWidths, + UD_DrvFontManagement, + UD_DrvGetGlyphMode, + UD_DrvStretchBltROP, + UD_DrvPlgBlt, + UD_DrvTransparentBlt, + UD_DrvAlphaBlend, + UD_DrvGradientFill, + UD_DrvIcmCreateColorTransform, + UD_DrvIcmDeleteColorTransform, + UD_DrvQueryDeviceSupport, + + MAX_DDI_HOOKS, + +} ENUMHOOKS; + + +typedef struct _OEMPDEV { + // + // define whatever needed, such as working buffers, tracking information, + // etc. + // + // This test DLL hooks out every drawing DDI. So it needs to remember + // PS's hook function pointer so it call back. + // + PFN pfnPS[MAX_DDI_HOOKS]; + + // + // define whatever needed, such as working buffers, tracking information, + // etc. + // + DWORD dwReserved[1]; + +} OEMPDEV, *POEMPDEV; + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/oemps/precomp.h new file mode 100644 index 00000000..4efe4e6f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/precomp.h @@ -0,0 +1,47 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.h +// +// PURPOSE: Header files that should be in the precompiled header. +// +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + +// Required header files that shouldn't change often. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemps/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemps/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/oemps/resource.h new file mode 100644 index 00000000..48f784ad --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemps/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by OEMPS.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui.ini b/print/OEM Printer Customization Plug-in Samples/C++/oemui.ini new file mode 100644 index 00000000..6324a104 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=OEMUI.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.def b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.def new file mode 100644 index 00000000..68bdffc0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.def @@ -0,0 +1,3 @@ +LIBRARY OEMUI +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.rc b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.rc new file mode 100644 index 00000000..c9968413 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.rc @@ -0,0 +1,169 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "OEM UI Test Module." + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "OEMUI" + VALUE "LegalCopyright", "Copyright © 1998 - 2003 Microsoft Corp." + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "OEMUI.dll" + VALUE "ProductName", "Microsoft OEMUI" + VALUE "ProductVersion", "1.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DEVICE_PROPPAGE DIALOG 0, 0, 179, 113 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Device Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Added Page",IDC_STATIC,55,14,68,11 + PUSHBUTTON "Calibrate",IDC_CALIBRATE,61,34,50,14 +END + +IDD_DOC_PROPPAGE DIALOG 0, 0, 210, 154 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Document Property Page" +FONT 8, "MS Shell Dialog" +BEGIN + LTEXT "OEM UI Document Property Page",IDC_STATIC,60,73,108,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DEVICE_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 172 + TOPMARGIN, 8 + BOTTOMMARGIN, 106 + END + + IDD_DOC_PROPPAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 203 + TOPMARGIN, 7 + BOTTOMMARGIN, 147 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_SECTION "OEM UI Added Item" + IDS_CALIBRATED "Printer has been calibrated." + IDS_NAME "OEM UI Customization DLL" + IDS_DEV_SECTION "Device Settings OEM UI Added Item" + IDS_ADV_SECTION "Advanced OEM UI Added Item" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj new file mode 100644 index 00000000..7c5e5bcc --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj @@ -0,0 +1,1042 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {452209BF-AEB7-457D-956B-90CDE70CED7D} + $(MSBuildProjectName) + Win10 Debug + Win32 + {84C69391-30E8-404B-B0F2-7C88DEB2A456} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + OEMUI + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);kernel32.lib;user32.lib;winspool.lib;ole32.lib;advapi32.lib;uuid.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + OEMUI.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj.Filters new file mode 100644 index 00000000..07492222 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/OEMUI.vcxproj.Filters @@ -0,0 +1,220 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {03B02FF3-CA63-4469-8907-F08C69CCE4DC} + + + h;hpp;hxx;hm;inl;inc;xsd + {5AE6A39D-71A9-44D0-B561-2746C654DA3B} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {C46C5ADA-08FD-4FA4-829D-1007F014DC71} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/oemui/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.cpp new file mode 100644 index 00000000..dd9ff650 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.cpp @@ -0,0 +1,182 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + +#include "precomp.h" +#include "debug.h" +#include "devmode.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// +//Performs operation on UI Plugins Private DevMode Members. +//Called via IOemUI::DevMode +// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR("DevMode() ERROR_INVALID_PARAMETER.\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + // + //The Method should return the size of the memory allocation needed to store the UI plugin Private DEVMODE. + // + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + // + //Should fill the Private DEVMODE with the default values. + // + case OEMDM_DEFAULT: + // + //OEM_DMEXTRAHEADER Members + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + + // + //Private members + // + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + break; + + // + //The method should convert private DEVMODE members to the current version, if necessary. + // + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + // + //The method should validate the information contained in private DEVMODE members and merge validated values into a private DEVMODE structure containing default values + // + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return S_OK; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) +{ + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR("ConvertOEMDevmode() invalid parameters.\r\n"); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE("Converting private OEM Devmode.\r\n"); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n"); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + pOEMDevOut->dwAdvancedData = 0; + } + + return TRUE; +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data, if not valid. + if(pOEMDevmode->dwDriverData > 100) + { + pOEMDevmode->dwDriverData = 0; + } + + // Set Advanced driver data, if not valid. + if(pOEMDevmode->dwAdvancedData > 100) + { + pOEMDevmode->dwAdvancedData = 0; + } + + return TRUE; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.h new file mode 100644 index 00000000..3dcbba25 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/devmode.h @@ -0,0 +1,52 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// + +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +// +// This structure must be prefixed by OEM_DMEXTRAHEADER +// Plug-ins must implement the IPrintOemUI::DevMode method +// +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + DWORD dwDriverData; + DWORD dwAdvancedData; + + // + //Private DevMode Members + // + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemui/dllentry.cpp new file mode 100644 index 00000000..0823030c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/dllentry.cpp @@ -0,0 +1,49 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "debug.h" +#include "globals.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE("Process attach.\r\n"); + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + VERBOSE("Thread attach.\r\n"); + break; + + case DLL_PROCESS_DETACH: + VERBOSE("Process detach.\r\n"); + break; + + case DLL_THREAD_DETACH: + VERBOSE("Thread detach.\r\n"); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.cpp new file mode 100644 index 00000000..40cfbbc2 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.cpp @@ -0,0 +1,22 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.cpp +// +// PURPOSE: File that contains all the globals. +// + +#include "precomp.h" +#include "globals.h" + + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.h b/print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.h new file mode 100644 index 00000000..c809fdc6 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/globals.h @@ -0,0 +1,17 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.h +// +// PURPOSE: Lists of globals declared in Globals.cpp. +// + +#pragma once + +// Module's Instance handle from DLLEntry of process. +extern HINSTANCE ghInstance; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.cpp new file mode 100644 index 00000000..a05b4643 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.cpp @@ -0,0 +1,567 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// PURPOSE: Implementation of interface for PScript5 and Unidrv UI plug-ins. +// + +#include "precomp.h" + +#include "debug.h" +#include "devmode.h" +#include "oemui.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0 ; // Count of active components +static long g_cServerLocks = 0 ; // Count of locks + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI body +// +IOemUI::~IOemUI() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall IOemUI::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE("IOemUI:QueryInterface entry.\r\n\r\n"); + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE("IOemUI:Return pointer to IUnknown.\r\n\r\n"); + } + else if (iid == IID_IPrintOemUI) + { + *ppv = static_cast(this) ; + VERBOSE("IOemUI:Return pointer to IPrintOemUI.\r\n"); + } + else + { + VERBOSE("IOemUI::QueryInterface IID not supported.\r\n"); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemUI::AddRef() +{ + VERBOSE("IOemUI:AddRef entry.\r\n"); + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemUI::Release() +{ + VERBOSE("IOemUI:Release entry.\r\n"); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +HRESULT __stdcall IOemUI::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE("IOemUI:PublishDriverInterface entry.\r\n"); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (m_pOEMHelp == NULL) + { + HRESULT hResult; + + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUI, (void** ) &(m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT __stdcall IOemUI::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE("IOemUI::GetInfo entry.\r\r\n"); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + WARNING("IOemUI::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER\r\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING("IOemUI::GetInfo() exit insufficient buffer!\r\r\n"); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING("IOemUI::GetInfo() exit mode not supported.\r\r\n"); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE("IOemUI::GetInfo() exit S_OK\r\n"); + return S_OK; +} + +HRESULT __stdcall IOemUI::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE("IOemUI:DevMode entry.\r\n"); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IOemUI::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam) +{ + VERBOSE("IOemUI:CommonUIProp entry.\r\n"); + + return hrOEMPropertyPage(dwMode, pOemCUIPParam); +} + + +HRESULT __stdcall IOemUI::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE("IOemUI:DocumentPropertySheets entry.\r\n"); + + return hrOEMDocumentPropertySheets(pPSUIInfo, lParam, m_pOEMHelp); +} + +HRESULT __stdcall IOemUI::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE("IOemUI:DevicePropertySheets entry.\r\n"); + + return hrOEMDevicePropertySheets(pPSUIInfo, lParam); +} + +HRESULT __stdcall IOemUI::DeviceCapabilities( + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult) +{ + VERBOSE("IOemUI:DeviceCapabilities entry.\r\n"); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM) +{ + VERBOSE("IOemUI:DevQueryPrintEx entry.\r\n"); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo) +{ + VERBOSE("IOemUI:UpgradePrinter entry.\r\n"); + + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam) +{ + VERBOSE("IOemUI:PrinterEvent entry.\r\n"); + + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IOemUI::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam) +{ + VERBOSE("IOemUI:DriverEvent entry.\r\n"); + + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +#define PROFILE_NAME L"OEMPROFILE.icm\0" + +HRESULT __stdcall IOemUI::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData) +{ + HRESULT Result = E_FAIL; + + VERBOSE("IOemUI:QueryColorProfile entry.\r\n"); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + if(QCP_DEVICEPROFILE == ulQueryMode) + { + if(NULL == pvProfileData) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + if(*pcbProfileData < sizeof(PROFILE_NAME)) + { + *pcbProfileData = sizeof(PROFILE_NAME); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } + else + { + Result = StringCbCopy((LPWSTR)pvProfileData, *pcbProfileData, PROFILE_NAME); + *pcbProfileData = sizeof(PROFILE_NAME); + *pflProfileData = QCP_PROFILEDISK; + + if(FAILED(Result)) + { + SetLastError(Result); + } + } + } + } + + return Result; +}; + +HRESULT __stdcall IOemUI::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam) +{ + VERBOSE("IOemUI:FontInstallerDlgProc entry.\r\n"); + + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IOemUI::UpdateExternalFonts( + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges) +{ + VERBOSE("IOemUI:UpdateExternalFonts entry.\r\n"); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) STDMETHOD_(ULONG,Release)(THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this) ; + } + else + { + VERBOSE("IOemCF::QueryInterface IID not supported.\r\n"); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION ; + } + + // Create component. + IOemUI* pOemCB = new IOemUI ; + if (pOemCB == NULL) + { + return E_OUTOFMEMORY ; + } + // Get the requested interface. + HRESULT hr = pOemCB->QueryInterface(iid, ppv) ; + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release() ; + return hr ; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks) ; + } + else + { + InterlockedDecrement(&g_cServerLocks) ; + } + return S_OK ; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK ; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE("DllGetClassObject:Create class factory.\r\n"); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE ; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF ; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY ; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv) ; + pFontCF->Release() ; + + return hr ; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.h new file mode 100644 index 00000000..3ae5c07c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/intrface.h @@ -0,0 +1,178 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Header of interface for PScript5 & Unidrv UI plug-ins. +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IOemUI +// +class IOemUI: public IPrintOemUI +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) STDMETHOD_(ULONG,Release)(THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + + IOemUI() { m_cRef = 1; m_pOEMHelp = NULL; }; + ~IOemUI(); + +protected: + LONG m_cRef; + IPrintOemDriverUI* m_pOEMHelp; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.cpp new file mode 100644 index 00000000..421fa9d0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.cpp @@ -0,0 +1,737 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.cpp +// +// PURPOSE: Main file for OEM UI test module. +// + +#include "precomp.h" + +#include "debug.h" +#include "resource.h" +#include "globals.h" +#include "devmode.h" +#include "oemui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + +typedef struct _tagCBUserData +{ + HANDLE hComPropSheet; + HANDLE hPropPage; + POEMUIPSPARAM pOEMUIParam; + PFNCOMPROPSHEET pfnComPropSheet; + +} CBUSERDATA, *PCBUSERDATA; + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam); +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam); +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems); +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems); +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams); +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource); + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM device or document property UI. +// +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hResult = S_OK; + + VERBOSE("hrOEMPropertyPage entry.\r\n"); + + // Validate parameters. + if( (OEMCUIP_DOCPROP != dwMode) + && + (OEMCUIP_PRNPROP != dwMode) + ) + { + ERR("hrOEMPropertyPage() ERROR_INVALID_PARAMETER.\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam); + break; + + case OEMCUIP_PRNPROP: + hResult = hrPrinterPropertyPage(dwMode, pOEMUIParam); + break; + + default: + // Should never reach this! + ERR("hrOEMPropertyPage() Invalid dwMode"); + SetLastError(ERROR_INVALID_PARAMETER); + hResult = E_FAIL; + break; + } + + return hResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM document property UI. +// +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM document property UI. + pOEMUIParam->cOEMOptItems = 1; + + VERBOSE("hrDocumentPropertyPage() requesting items.\r\n"); + } + else + { + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + VERBOSE("hrDocumentPropertyPage() fill out items.\r\n"); + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMDocUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_ADV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + } + + return S_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM printer property UI. +// +static HRESULT hrPrinterPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + UNREFERENCED_PARAMETER(dwMode); + + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM printer property UI. + pOEMUIParam->cOEMOptItems = 1; + + VERBOSE("hrPrinterPropertyPage() requesting items.\r\n"); + } + else + { + DWORD dwError; + DWORD dwDeviceValue; + DWORD dwType; + DWORD dwNeeded; + + + VERBOSE("hrPrinterPropertyPage() fill out items.\r\n"); + + // Get device settings value from printer. + dwError = GetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, &dwType, (PBYTE) &dwDeviceValue, + sizeof(dwDeviceValue), &dwNeeded); + if( (ERROR_SUCCESS != dwError) + || + (dwDeviceValue > 100) + ) + { + // Failed to get the device value or value is invalid, just use the default. + dwDeviceValue = 0; + } + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMPrinterUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // New section. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, pOEMUIParam->hModule, IDS_DEV_SECTION); + pOEMUIParam->pOEMOptItems[0].Sel = dwDeviceValue; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].lParam = 100; + } + + return S_OK; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to Document property sheet. +// +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, + IPrintOemDriverUI* pOEMHelp) +{ + LONG_PTR lResult = 0; + HRESULT hrResult = S_OK; + + VERBOSE("hrOEMDocumentPropertySheets() entry.\r\n"); + + UNREFERENCED_PARAMETER(pOEMHelp); + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR("hrOEMDocumentPropertySheets() ERROR_INVALID_PARAMETER.\r\n"); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + DWORD dwSheets = 0; + PCBUSERDATA pUserData = NULL; + POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM) pPSUIInfo->lParamInit; + HANDLE hHeap = pOEMUIParam->hOEMHeap; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + COMPROPSHEETUI Sheet; + + + // Init property page. + memset(&Sheet, 0, sizeof(COMPROPSHEETUI)); + Sheet.cbSize = sizeof(COMPROPSHEETUI); + Sheet.Flags = CPSUIF_UPDATE_PERMISSION; + Sheet.hInstCaller = ghInstance; + Sheet.pCallerName = GetStringResource(hHeap, ghInstance, IDS_NAME); + Sheet.pHelpFile = NULL; + Sheet.pfnCallBack = OEMDocUICallBack2; + Sheet.pDlgPage = CPSUI_PDLGPAGE_TREEVIEWONLY; + Sheet.cOptItem = 1; + Sheet.IconID = IDI_CPSUI_PRINTER; + Sheet.pOptItemName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.CallerVersion = 0x100; + Sheet.OptItemVersion = 0x100; + + // Init user data. + pUserData = (PCBUSERDATA) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CBUSERDATA)); + if (NULL == pUserData) + { + ERR("hrOEMDocumentPropertySheets() failed to allocate user data.\r\n"); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + pUserData->hComPropSheet = pPSUIInfo->hComPropSheet; + pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + pUserData->pOEMUIParam = pOEMUIParam; + Sheet.UserData = (ULONG_PTR) pUserData; + + // Create OptItems for page. + Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem); + if (NULL == Sheet.pOptItem) + { + ERR("hrOEMDocumentPropertySheets() failed to allocate OPTITEMs.\r\n"); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // Initialize OptItems + Sheet.pOptItem[0].Level = 1; + Sheet.pOptItem[0].Flags = OPTIF_COLLAPSE; + Sheet.pOptItem[0].pName = GetStringResource(hHeap, ghInstance, IDS_SECTION); + Sheet.pOptItem[0].Sel = pOEMDev->dwDriverData; + + Sheet.pOptItem[0].pOptType = CreateOptType(hHeap, 2); + if (NULL == Sheet.pOptItem[0].pOptType) + { + ERR("hrOEMDocumentPropertySheets() failed to allocate OPTTYPE.\r\n"); + + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + Sheet.pOptItem[0].pOptType->Type = TVOT_UDARROW; + Sheet.pOptItem[0].pOptType->pOptParam[1].IconID = 0; + Sheet.pOptItem[0].pOptType->pOptParam[1].lParam = 100; + + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PCOMPROPSHEETUI, + (LPARAM)&Sheet, (LPARAM)&dwSheets); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + +Exit: + + pPSUIInfo->Result = lResult; + return hrResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Adds property page to printer property sheet. +// +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam) +{ + LONG_PTR lResult = 0; + + VERBOSE("hrOEMDevicePropertySheets entry\r\n"); + + // Validate parameters. + if( (NULL == pPSUIInfo) + || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version) + ) + { + ERR("hrOEMDevicePropertySheets() ERROR_INVALID_PARAMETER.\r\n"); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Do action. + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + PROPSHEETPAGE Page; + + // Init property page. + memset(&Page, 0, sizeof(PROPSHEETPAGE)); + Page.dwSize = sizeof(PROPSHEETPAGE); + Page.dwFlags = PSP_DEFAULT; + Page.hInstance = ghInstance; + Page.pszTemplate = MAKEINTRESOURCE(IDD_DEVICE_PROPPAGE); + Page.pfnDlgProc = DevicePropPageProc; + + // Add property sheets. + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, CPSFUNC_ADD_PROPSHEETPAGE, (LPARAM)&Page, 0); + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER) lParam; + + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // No icon + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam; + + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + + pPSUIInfo->Result = lResult; + return S_OK; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM printer property UI. +// +LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + + VERBOSE("OEMPrinterUICallBack() entry.\r\n"); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + { + DWORD dwDriverValue = pOEMUIParam->pOEMOptItems[0].Sel; + + // Store OptItems state in printer data. + SetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, REG_DWORD, (PBYTE) &dwDriverValue, sizeof(DWORD)); + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Call back for OEM device property UI. +// +#pragma warning(push) +#pragma warning( disable : 6262 ) // 2 MAX_PATH strings exceeds the default prefast stack size warning threshold by a few bytes. +INT_PTR CALLBACK DevicePropPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uiMsg) + { + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + switch(LOWORD(wParam)) + { + case IDC_CALIBRATE: + // Just display a message that the printer is calibrated, + // since we don't acutally calibrate anything. + { + TCHAR szName[MAX_PATH]; + TCHAR szCalibrated[MAX_PATH]; + + + LoadString(ghInstance, IDS_NAME, szName, sizeof(szName)/sizeof(szName[0])); + LoadString(ghInstance, IDS_CALIBRATED, szCalibrated, sizeof(szCalibrated)/sizeof(szCalibrated[0])); + MessageBox(hDlg, szCalibrated, szName, MB_OK); + } + break; + } + break; + + default: + return FALSE; + } + return TRUE; + + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) // type of notification message + { + case PSN_SETACTIVE: + break; + + case PSN_KILLACTIVE: + break; + + case PSN_APPLY: + break; + + case PSN_RESET: + break; + } + } + break; + } + + return FALSE; +} +#pragma warning(pop) + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM document property UI. +// +LONG APIENTRY OEMDocUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE("OEMDocUICallBack() entry\r\n"); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Update UI item data. + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + break; + + case CPSUICB_REASON_KILLACTIVE: + // Update devmode if settings have changed. + if(pOEMDev->dwAdvancedData != (DWORD)(pOEMUIParam->pOEMOptItems[0].Sel)) + { + // Update OEM Devmode driver data. + pOEMDev->dwAdvancedData = pOEMUIParam->pOEMOptItems[0].Sel; + } + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pOEMUIParam->pOEMOptItems[0].Sel) != pOEMDev->dwAdvancedData) + { + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->dwAdvancedData; + pOEMUIParam->pOEMOptItems[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +LONG APIENTRY OEMDocUICallBack2(PCPSUICBPARAM pCallbackParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + PCBUSERDATA pUserData = (PCBUSERDATA) pCallbackParam->UserData; + POEMDEV pOEMDev = (POEMDEV) pUserData->pOEMUIParam->pOEMDM; + + + VERBOSE("OEMDocUICallBack2() entry.\r\n"); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Update OEM devmode driver data. + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + pUserData->pfnComPropSheet(pUserData->hComPropSheet, CPSFUNC_SET_RESULT, + (LPARAM)pUserData->hPropPage, + (LPARAM)CPSUI_OK); + break; + + case CPSUICB_REASON_KILLACTIVE: + if(pOEMDev->dwDriverData != (DWORD)(pCallbackParam->pOptItem[0].Sel)) + { + // Update OEM devmode driver data. + pOEMDev->dwDriverData = pCallbackParam->pOptItem[0].Sel; + } + break; + + case CPSUICB_REASON_SETACTIVE: + if((DWORD)(pCallbackParam->pOptItem[0].Sel) != pOEMDev->dwDriverData) + { + pCallbackParam->pOptItem[0].Sel = pOEMDev->dwDriverData; + pCallbackParam->pOptItem[0].Flags |= OPTIF_CHANGED; + lReturn = CPSUICB_ACTION_OPTIF_CHANGED; + } + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Creates and Initializes OptItems. +// +static POPTITEM CreateOptItems(HANDLE hHeap, DWORD dwOptItems) +{ + POPTITEM pOptItems = NULL; + + + // Allocate memory for OptItems; + pOptItems = (POPTITEM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTITEM) * dwOptItems); + if(NULL != pOptItems) + { + InitOptItems(pOptItems, dwOptItems); + } + else + { + ERR("CreateOptItems() failed to allocate memory for OPTITEMs!\r\n"); + } + + return pOptItems; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems. +// +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems) +{ + VERBOSE("InitOptItems() entry.\r\n"); + + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for(DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OptType for OptItem. +// +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams) +{ + POPTTYPE pOptType = NULL; + + + VERBOSE("CreateOptType() entry.\r\n"); + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + if(NULL != pOptType) + { + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, wOptParams * sizeof(OPTPARAM)); + if(NULL != pOptType->pOptParam) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + ERR("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n"); + + // Free allocated memory and return NULL. + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR("CreateOptType() failed to allocated memory for OPTTYPE!\r\n"); + } + + return pOptType; +} + +//////////////////////////////////////////////////////////////////////////////////// +// +// Retrieves pointer to a String resource. +// +static PTSTR GetStringResource(HANDLE hHeap, HANDLE hModule, UINT uResource) +{ + int nResult; + DWORD dwSize = MAX_PATH; + PTSTR pszString = NULL; + + VERBOSE("GetStringResource entered.\r\n"); + + // Allocate buffer for string resource from heap; let the driver clean it up. + pszString = (PTSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(TCHAR)); + if(NULL != pszString) + { + // Load string resource; resize after loading so as not to waste memory. + nResult = LoadString((HMODULE)hModule, uResource, pszString, dwSize); + if(nResult > 0) + { + PTSTR pszTemp; + + pszTemp = (PTSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszString, (nResult + 1) * sizeof(TCHAR)); + if(NULL != pszTemp) + { + pszString = pszTemp; + } + else + { + ERR("GetStringResource() HeapReAlloc() of string retrieved failed!\r\n"); + } + } + else + { + ERR("LoadString() failed.\r\n"); + ERR("GetStringResource() failed to load string resource !\r\n"); + + pszString = NULL; + } + } + else + { + ERR("GetStringResource() failed to allocate string buffer!\r\n"); + } + + return pszString; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.h b/print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.h new file mode 100644 index 00000000..b584893e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/oemui.h @@ -0,0 +1,37 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUI.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for OEMUI Test Module. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + +// OEM Signature and version. +#define PROP_TITLE L"OEM UI Page" + +// Printer registry keys where OEM data is stored. +#define OEMUI_VALUE TEXT("OEMUI_VALUE") +#define OEMUI_DEVICE_VALUE TEXT("OEMUI_DEVICE_VALUE") + + + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +HRESULT hrOEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam, IPrintOemDriverUI* pOEMHelp); +HRESULT hrOEMDevicePropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam); + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/oemui/precomp.h new file mode 100644 index 00000000..1f73e0ad --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/precomp.h @@ -0,0 +1,52 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: pecomp.H +// +// PURPOSE: Optimize compilation of headers that don't change frequently. +// +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemui/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemui/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/oemui/resource.h new file mode 100644 index 00000000..71d3d3d6 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemui/resource.h @@ -0,0 +1,24 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by OEMUI.rc +// +#define IDS_SECTION 1 +#define IDS_CALIBRATED 2 +#define IDS_NAME 3 +#define IDS_DEV_SECTION 4 +#define IDS_DEVICE_SECTION 4 +#define IDS_ADV_SECTION 10 +#define IDD_DEVICE_PROPPAGE 106 +#define IDD_DOC_PROPPAGE 107 +#define IDC_CALIBRATE 1001 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1002 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni.ini b/print/OEM Printer Customization Plug-in Samples/C++/oemuni.ini new file mode 100644 index 00000000..399b2f9b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMDriverFile1=OEMUNI.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.def b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.def new file mode 100644 index 00000000..be2aaf17 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.def @@ -0,0 +1,3 @@ +LIBRARY OEMUNI +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.h b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.h new file mode 100644 index 00000000..6df79055 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.h @@ -0,0 +1,234 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: OEMUNI.H +// +// +// PURPOSE: Define the COemPDEV class which stores the private +// PDEV for the driver. +// + +#pragma once + +class COemPDEV +{ +public: + __stdcall COemPDEV(void) + { + + // Note that since our parent has AddRef'd the UNIDRV interface, + // we don't do so here since our scope is identical to our + // parent. + // + + VERBOSE("In COemPDEV constructor..."); + + _ResetPointers(); + } + + __stdcall ~COemPDEV(void) + { + VERBOSE("In COemPDEV destructor..."); + } + + void __stdcall InitializeDDITable(DRVENABLEDATA* pded) + { + VERBOSE("COemPDEV::InitializeDDITable entry."); + + UINT iDrvFn; + UINT cDrvFn = pded->c; + PDRVFN pDrvFn = pded->pdrvfn; + + for (iDrvFn = 0; iDrvFn < cDrvFn; ++iDrvFn, ++pDrvFn) + { + _SavePFN(pDrvFn->iFunc, pDrvFn->pfn); + } + } + +private: + + void __stdcall _SavePFN(ULONG uFunc, PFN pfn) + { + + // Note: if a "pass-through" driver is being constructed, then + // there is nothing for this method to do. So, to keep the + // compiler from complaining about a switch with no case + // statements, but which has a default statement, we surround + // the entire construct with preprocessor controls. + // + switch(uFunc) + { + // The following are the drawing related DDI hooks. + // + case INDEX_DrvAlphaBlend: + m_pfnDrvAlphaBlend = (PFN_DrvAlphaBlend)pfn; + break; + case INDEX_DrvBitBlt: + m_pfnDrvBitBlt = (PFN_DrvBitBlt)pfn; + break; + case INDEX_DrvCopyBits: + m_pfnDrvCopyBits = (PFN_DrvCopyBits)pfn; + break; + case INDEX_DrvDitherColor: + m_pfnDrvDitherColor = (PFN_DrvDitherColor)pfn; + break; + case INDEX_DrvFillPath: + m_pfnDrvFillPath = (PFN_DrvFillPath)pfn; + break; + case INDEX_DrvFontManagement: + m_pfnDrvFontManagement = (PFN_DrvFontManagement)pfn; + break; + case INDEX_DrvGetGlyphMode: + m_pfnDrvGetGlyphMode = (PFN_DrvGetGlyphMode)pfn; + break; + case INDEX_DrvGradientFill: + m_pfnDrvGradientFill = (PFN_DrvGradientFill)pfn; + break; + case INDEX_DrvLineTo: + m_pfnDrvLineTo = (PFN_DrvLineTo)pfn; + break; + case INDEX_DrvPaint: + m_pfnDrvPaint = (PFN_DrvPaint)pfn; + break; + case INDEX_DrvPlgBlt: + m_pfnDrvPlgBlt = (PFN_DrvPlgBlt)pfn; + break; + case INDEX_DrvQueryAdvanceWidths: + m_pfnDrvQueryAdvanceWidths = (PFN_DrvQueryAdvanceWidths)pfn; + break; + case INDEX_DrvQueryFont: + m_pfnDrvQueryFont = (PFN_DrvQueryFont)pfn; + break; + case INDEX_DrvQueryFontData: + m_pfnDrvQueryFontData = (PFN_DrvQueryFontData)pfn; + break; + case INDEX_DrvQueryFontTree: + m_pfnDrvQueryFontTree = (PFN_DrvQueryFontTree)pfn; + break; + case INDEX_DrvRealizeBrush: + m_pfnDrvRealizeBrush = (PFN_DrvRealizeBrush)pfn; + break; + case INDEX_DrvStretchBlt: + m_pfnDrvStretchBlt = (PFN_DrvStretchBlt)pfn; + break; + case INDEX_DrvStretchBltROP: + m_pfnDrvStretchBltROP = (PFN_DrvStretchBltROP)pfn; + break; + case INDEX_DrvStrokeAndFillPath: + m_pfnDrvStrokeAndFillPath = (PFN_DrvStrokeAndFillPath)pfn; + break; + case INDEX_DrvStrokePath: + m_pfnDrvStrokePath = (PFN_DrvStrokePath)pfn; + break; + case INDEX_DrvTextOut: + m_pfnDrvTextOut = (PFN_DrvTextOut)pfn; + break; + case INDEX_DrvTransparentBlt: + m_pfnDrvTransparentBlt = (PFN_DrvTransparentBlt)pfn; + break; + // The following are the page/band related DDI hooks. + // + case INDEX_DrvStartDoc: + m_pfnDrvStartDoc = (PFN_DrvStartDoc)pfn; + break; + case INDEX_DrvEndDoc: + m_pfnDrvEndDoc = (PFN_DrvEndDoc)pfn; + break; + case INDEX_DrvStartPage: + m_pfnDrvStartPage = (PFN_DrvStartPage)pfn; + break; + case INDEX_DrvSendPage: + m_pfnDrvSendPage = (PFN_DrvSendPage)pfn; + break; + case INDEX_DrvStartBanding: + m_pfnDrvStartBanding = (PFN_DrvStartBanding)pfn; + break; + case INDEX_DrvNextBand: + m_pfnDrvNextBand = (PFN_DrvNextBand)pfn; + break; + case INDEX_DrvEscape: + m_pfnDrvEscape = (PFN_DrvEscape)pfn; + break; + } // switch(uFunc) + } + + void __stdcall _ResetPointers(void) + { + m_pfnDrvAlphaBlend = NULL; + m_pfnDrvBitBlt = NULL; + m_pfnDrvCopyBits = NULL; + m_pfnDrvDitherColor = NULL; + m_pfnDrvEndDoc = NULL; + m_pfnDrvEscape = NULL; + m_pfnDrvFillPath = NULL; + m_pfnDrvFontManagement = NULL; + m_pfnDrvGetGlyphMode = NULL; + m_pfnDrvGradientFill = NULL; + m_pfnDrvLineTo = NULL; + m_pfnDrvNextBand = NULL; + m_pfnDrvPaint = NULL; + m_pfnDrvPlgBlt = NULL; + m_pfnDrvQueryAdvanceWidths = NULL; + m_pfnDrvQueryFont = NULL; + m_pfnDrvQueryFontData = NULL; + m_pfnDrvQueryFontTree = NULL; + m_pfnDrvRealizeBrush = NULL; + m_pfnDrvSendPage = NULL; + m_pfnDrvStartBanding = NULL; + m_pfnDrvStartDoc = NULL; + m_pfnDrvStartPage = NULL; + m_pfnDrvStretchBlt = NULL; + m_pfnDrvStretchBltROP = NULL; + m_pfnDrvStrokeAndFillPath = NULL; + m_pfnDrvStrokePath = NULL; + m_pfnDrvTextOut = NULL; + m_pfnDrvTransparentBlt = NULL; + } + +public: + + // Unidrv function pointers so that we can punt + // back from the DDI hooks + // + PFN_DrvAlphaBlend m_pfnDrvAlphaBlend; + PFN_DrvBitBlt m_pfnDrvBitBlt; + PFN_DrvCopyBits m_pfnDrvCopyBits; + PFN_DrvDitherColor m_pfnDrvDitherColor; + PFN_DrvEndDoc m_pfnDrvEndDoc; + PFN_DrvEscape m_pfnDrvEscape; + PFN_DrvFillPath m_pfnDrvFillPath; + PFN_DrvFontManagement m_pfnDrvFontManagement; + PFN_DrvGetGlyphMode m_pfnDrvGetGlyphMode; + PFN_DrvGradientFill m_pfnDrvGradientFill; + PFN_DrvLineTo m_pfnDrvLineTo; + PFN_DrvNextBand m_pfnDrvNextBand; + PFN_DrvPaint m_pfnDrvPaint; + PFN_DrvPlgBlt m_pfnDrvPlgBlt; + PFN_DrvQueryAdvanceWidths m_pfnDrvQueryAdvanceWidths; + PFN_DrvQueryFont m_pfnDrvQueryFont; + PFN_DrvQueryFontData m_pfnDrvQueryFontData; + PFN_DrvQueryFontTree m_pfnDrvQueryFontTree; + PFN_DrvRealizeBrush m_pfnDrvRealizeBrush; + PFN_DrvSendPage m_pfnDrvSendPage; + PFN_DrvStartBanding m_pfnDrvStartBanding; + PFN_DrvStartDoc m_pfnDrvStartDoc; + PFN_DrvStartPage m_pfnDrvStartPage; + PFN_DrvStretchBlt m_pfnDrvStretchBlt; + PFN_DrvStretchBltROP m_pfnDrvStretchBltROP; + PFN_DrvStrokeAndFillPath m_pfnDrvStrokeAndFillPath; + PFN_DrvStrokePath m_pfnDrvStrokePath; + PFN_DrvTextOut m_pfnDrvTextOut; + PFN_DrvTransparentBlt m_pfnDrvTransparentBlt; + + /*******************************************/ + /* */ + /* Add any custom PDEV members here */ + /* */ + /*******************************************/ + +}; +typedef COemPDEV* POEMPDEV; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.rc b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.rc new file mode 100644 index 00000000..6a21e8d3 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.rc @@ -0,0 +1,110 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by DDK Support Team\0" + VALUE "CompanyName", "Microsoft Corp.\0" + VALUE "FileDescription", "OEM Customization Sample\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "OEMUNI\0" + VALUE "LegalCopyright", "Copyright © 1998-2003\0" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation\0" + VALUE "OriginalFilename", "OEMUNI.DLL\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Microsoft OEMUNI\0" + VALUE "ProductVersion", "1.0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj new file mode 100644 index 00000000..eeeac176 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj @@ -0,0 +1,1090 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {B0F13767-2056-47FC-B37B-41D7E339900B} + $(MSBuildProjectName) + Win10 Debug + Win32 + {96600CA6-8E9E-4691-ACB9-0225A5B57563} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + OEMUNI + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;USERMODE_DRIVER + %(AdditionalIncludeDirectories);.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;winspool.lib;user32.lib;ole32.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + OEMUNI.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj.Filters new file mode 100644 index 00000000..8287cc90 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/OEMUNI.vcxproj.Filters @@ -0,0 +1,174 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {25BB1250-6D65-4A18-B7D2-D29AB885B616} + + + h;hpp;hxx;hm;inl;inc;xsd + {C1A83E63-7DD3-4CAD-9079-BA272CB24B89} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {6B77C327-966D-4CD1-AC7A-EB5A773904D2} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + Header Files + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/ddihook.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/ddihook.cpp new file mode 100644 index 00000000..48922ae6 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/ddihook.cpp @@ -0,0 +1,1670 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: DDIHook.cpp +// +// PURPOSE: DDI Hook routines for User Mode COM Customization DLL. This module +// implements the following methods defined in printoem.h +// OEMCopyBits +// OEMBitBlt +// OEMStretchBlt +// OEMDitherColor +// OEMStretchBltROP +// OEMPlgBlt +// OEMPaint +// OEMRealizeBrush +// OEMStrokePath +// OEMFillPath +// OEMStrokeAndFillPath +// OEMLineTo +// OEMAlphaBlend +// OEMGradientFill +// OEMTransparentBlt +// OEMTextOut +// OEMQueryFont +// OEMQueryFontTree +// OEMQueryFontData +// OEMFontManagement +// OEMQueryAdvanceWidths +// OEMGetGlyphMode +// OEMStartDoc +// OEMEndDoc +// OEMStartPage +// OEMSendPage +// OEMStartBanding +// OEMNextBand +// OEMEscape +// + +#include "precomp.h" +#include "debug.h" +#include "devmode.h" +#include "oemuni.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +BOOL APIENTRY +OEMCopyBits( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + POINTL *pptlSrc + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvCopyBits. + + DrvCopyBits translates between device-managed + raster surfaces and GDI standard-format bitmaps. + GDI will call DrvCopyBits when it needs to copy from + one surface to another and at least one of the + surfaces is device-managed. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Points to the Dstination surface + psoSrc - Points to the source surface + pxlo - XLATEOBJ provided by the engine + pco - Defines a clipping region on the Dstination surface + pxlo - Defines the translation of color indices + between the source and target surfaces + prclDst - Defines the area to be modified + pptlSrc - Defines the upper-left corner of the source rectangle + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMCopyBits entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvCopyBits)(psoDst, + psoSrc, + pco, + pxlo, + prclDst, + pptlSrc); +} + +BOOL APIENTRY +OEMBitBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + POINTL *pptlSrc, + POINTL *pptlMask, + BRUSHOBJ *pbo, + POINTL *pptlBrush, + ROP4 rop4 + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvBitBlt. + + DrvBitBlt provides general bit-block transfer capabilities + between device-managed surfaces, between GDI-managed + standard-format bitmaps, or between a device-managed + surface and a GDI-managed standard-format bitmap. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Describes the target surface + psoSrc - Describes the source surface + psoMask - Describes the mask for rop4 + pco - Limits the area to be modified + pxlo - Specifies how color indices are translated + between the source and target surfaces + prclDst - Defines the area to be modified + pptlSrc - Defines the upper left corner of the source rectangle + pptlMask - Defines which pixel in the mask corresponds to + the upper left corner of the source rectangle + pbo - Defines the pattern for bitblt + pptlBrush - Defines the origin of the brush in the Dstination surface + rop4 - ROP code that defines how the mask, pattern, source, and + Dstination pixels are combined to write to the Dstination surface + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMBitBlt entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvBitBlt)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + prclDst, + pptlSrc, + pptlMask, + pbo, + pptlBrush, + rop4); +} + +BOOL APIENTRY +OEMStretchBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDst, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStretchBlt. + + DrvStretchBlt provides stretching bit-block transfer + capabilities between any combination of device-managed + and GDI-managed surfaces. DrvStretchBlt enables the + device driver to write to GDI bitmaps, especially when the + driver can do halftoning. This function allows the same + halftoning algorithm to be applied to GDI bitmaps and + device surfaces. This function can be provided to handle + only certain forms of stretching, such as by integer multiples. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Defines the surface on which to draw + psoSrc - Defines the source for blt operation + psoMask - Defines a surface that provides a mask for the source + pco - Limits the area to be modified on the Dstination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + pca - Defines color adjustment values to be applied to the source bitmap + pptlHTOrg - Specifies the origin of the halftone brush + prclDst - Defines the area to be modified on the Dstination surface + prclSrc - Defines the area to be copied from the source surface + pptlMask - Specifies which pixel in the given mask corresponds to + the upper left pixel in the source rectangle + iMode - Specifies how source pixels are combined to get output pixels + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMStretchBlt entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStretchBlt)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDst, + prclSrc, + pptlMask, + iMode); +} + +ULONG APIENTRY +OEMDitherColor( + DHPDEV dhpdev, + ULONG iMode, + ULONG rgbColor, + ULONG *pulDither + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvDitherColor. + + DrvDitherColor requests the device to create a + brush dithered against a device palette. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - DHPDEV passed, it is our pDEV + iMode - Not used + rgbColor - Solid rgb color to be used + pulDither - buffer to put the halftone brush. + +Return Value: + + Returns halftone method. + + DCR_DRIVER if the dither values have been calculated by the driver. + DCR_SOLID if the engine should use the best solid color approximation of the color. + DCR_HALFTONE if the engine should create a halftone approximation for the driver. + +--*/ + +{ + VERBOSE("OEMDitherColor entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvDitherColor)(dhpdev, + iMode, + rgbColor, + pulDither); +} + +BOOL APIENTRY +OEMStretchBltROP( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDst, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode, + BRUSHOBJ *pbo, + ROP4 rop4 + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStretchBltROP. + + DrvStretchBltROP performs a stretching bit-block transfer + using a ROP. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Specifies the target surface + psoSrc - Specifies the source surface + psoMask - Specifies the mask surface + pco - Limits the area to be modified + pxlo - Specifies how color indices are translated + between the source and target surfaces + pca - Defines color adjustment values to be applied to the source bitmap + pptlHTOrg - Specifies the halftone origin + prclDst - Area to be modified on the destination surface + prclSrc - Rectangle area on the source surface + pptlMask - Defines which pixel in the mask corresponds to + the upper left corner of the source rectangle + iMode - Specifies how source pixels are combined to get output pixels + pbo - Defines the pattern for bitblt + rop4 - ROP code that defines how the mask, pattern, source, and + destination pixels are combined on the destination surface + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMStretchBltROP entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStretchBltROP)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDst, + prclSrc, + pptlMask, + iMode, + pbo, + rop4); +} + +BOOL APIENTRY +OEMPlgBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlBrushOrg, + POINTFIX *pptfixDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) +/*++ + +Routine Description: + + Implementation of DDI hook for DrvPlgBlt. + + DrvPlgBlt provides rotate bit-block transfer capabilities between + combinations of device-managed and GDI-managed surfaces. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Defines the surface on which to draw + psoSrc - Defines the source for blt operation + psoMask - Defines a surface that provides a mask for the source + pco - Limits the area to be modified on the Dstination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + pca - Defines color adjustment values to be applied to the source bitmap + pptlBrushOrg - Specifies the origin of the halftone brush + pptfixDest - Defines the area to be modified on the Dstination surface + prclSrc - Defines the area to be copied from the source surface + pptlMask - Specifies which pixel in the given mask corresponds to + the upper left pixel in the source rectangle + iMode - Specifies how source pixels are combined to get output pixels + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMPlgBlt entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvPlgBlt)(psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlBrushOrg, + pptfixDest, + prclSrc, + pptlMask, + iMode); +} + +BOOL APIENTRY +OEMPaint( + SURFOBJ *pso, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + MIX mix + ) +/*++ + +Routine Description: + + Implementation of DDI hook for DrvPaint. + + DrvPaint is an obsolete function. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to draw + pco - Limits the area to be modified on the Dstination + pbo - Points to a BRUSHOBJ which defined the pattern and colors to fill with + pptlBrushOrg - Specifies the origin of the halftone brush + mix - Defines the foreground and background raster operations to use for + the brush + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMPaint entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvPaint)(pso, + pco, + pbo, + pptlBrushOrg, + mix); +} + +BOOL APIENTRY +OEMRealizeBrush( + BRUSHOBJ *pbo, + SURFOBJ *psoTarget, + SURFOBJ *psoPattern, + SURFOBJ *psoMask, + XLATEOBJ *pxlo, + ULONG iHatch + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvRealizeBrush. + + DrvRealizeBrush requests that the driver realize a specified brush + for a specified surface. To realize a brush, the driver converts a + GDI brush into a form that can be used internally. A realized brush + contains device-specific information needed by the device to + accelerate drawing using the brush. The driver's realization of a brush + is written into the buffer allocated by a call to BRUSHOBJ_pvAllocRBrush. + + Please refer to DDK documentation for more details. + +Arguments: + + pbo - BRUSHOBJ to be realized + psoTarget - Defines the surface for which the brush is to be realized + psoPattern - Defines the pattern for the brush + psoMask - Transparency mask for the brush + pxlo - Defines the interpretration of colors in the pattern + iHatch - Specifies whether psoPattern is one of the hatch brushes + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMRealizeBrush entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoTarget->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvRealizeBrush)(pbo, + psoTarget, + psoPattern, + psoMask, + pxlo, + iHatch); +} + +BOOL APIENTRY +OEMStrokePath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + LINEATTRS *plineattrs, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStrokePath. + + DrvStrokePath strokes a path when called by GDI. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Identifies the surface on which to draw + ppo - Defines the path to be stroked + pco - Defines the clipping path + pxo - Specifies the world to device coordinate transformation + pbo - Specifies the brush to be used when drawing the path + pptlBrushOrg - Defines the brush origin + plineattrs - Defines the line attributes + mix - Specifies how to combine the brush with the destination + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE("OEMStrokePath entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStrokePath)(pso, + ppo, + pco, + pxo, + pbo, + pptlBrushOrg, + plineattrs, + mix); +} + +BOOL APIENTRY +OEMFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + MIX mix, + FLONG flOptions + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvFillPath. + + DrvFillPath is an optional entry point to handle the filling of closed paths. + GDI can call DrvFillPath to fill a path on a device-managed surface. + When deciding whether to call this function, GDI compares the fill + requirements with the following flags in the flGraphicsCaps member of + the DEVINFO structure: GCAPS_BEZIERS, GCAPS_ALTERNATEFILL, + and GCAPS_WINDINGFILL. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to draw. + ppo - Defines the path to be filled + pco - Defines the clipping path + pbo - Defines the pattern and colors to fill with + pptlBrushOrg - Defines the brush origin + mix - Defines the foreground and background ROPs to use for the brush + flOptions - Whether to use zero-winding or odd-even rule + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE("OEMFillPath entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvFillPath)(pso, + ppo, + pco, + pbo, + pptlBrushOrg, + mix, + flOptions); +} + +BOOL APIENTRY +OEMStrokeAndFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pboStroke, + LINEATTRS *plineattrs, + BRUSHOBJ *pboFill, + POINTL *pptlBrushOrg, + MIX mixFill, + FLONG flOptions + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStrokeAndFillPath. + + DrvStrokeAndFillPath strokes and fills a path concurrently. + The driver can return FALSE if the path or the clipping is too + complex for the device to handle; in that case, GDI converts + to a simpler call. For example, if the device driver has set the + GCAPS_BEZIERS flag in the flGraphicsCaps member of the + DEVINFO structure and then receives a path with Bezier curves, + it can return FALSE; GDI will then convert the Bezier curves to + lines and call DrvStrokeAndFillPath again. If the device driver + returns FALSE again, GDI will further simplify the call, making + calls to DrvStrokePath and DrvFillPath, or to DrvBitBlt, depending + on the mix and width of the lines making up the path. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Describes the surface on which to draw + ppo - Describes the path to be filled + pco - Defines the clipping path + pxo - Specifies the world to device coordinate transformation + pboStroke - Specifies the brush to use when stroking the path + plineattrs - Specifies the line attributes + pboFill - Specifies the brush to use when filling the path + pptlBrushOrg - Specifies the brush origin for both brushes + mixFill - Specifies the foreground and background ROPs to use + for the fill brush + flOptions - Whether to use zero-winding or odd-even rule + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE("OEMStrokeAndFillPath entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStrokeAndFillPath)(pso, + ppo, + pco, + pxo, + pboStroke, + plineattrs, + pboFill, + pptlBrushOrg, + mixFill, + flOptions); +} + +BOOL APIENTRY +OEMLineTo( + SURFOBJ *pso, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + LONG x1, + LONG y1, + LONG x2, + LONG y2, + RECTL *prclBounds, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvLineTo. + + DrvLineTo draws a single, solid, integer-only cosmetic line. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Describes the surface on which to draw + pco - Defines the clipping path + pbo - Defines the brush used to draw the line + x1,y1 - Specifies the line's starting point + x2,y2 - Specifies the line's ending point + prclBounds - Defines a rectangle that bounds the unclipped line. + mix - Specifies the foreground and background ROP + +Return Value: + + TRUE if successful + FALSE if driver cannot handle the path + DDI_ERROR if there is an error + +--*/ + +{ + VERBOSE("OEMLineTo entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvLineTo)(pso, + pco, + pbo, + x1, + y1, + x2, + y2, + prclBounds, + mix); +} + +BOOL APIENTRY +OEMAlphaBlend( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDest, + RECTL *prclSrc, + BLENDOBJ *pBlendObj + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvAlphaBlend. + + DrvAlphaBlend provides bit-block transfer capabilities with alpha blending. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDest - Defines the surface on which to draw + psoSrc - Defines the source + pco - Limits the area to be modified on the Destination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + prclDest - Defines the area to be modified on the Destination surface + prclSrc - Defines the area to be copied from the source surface + BlendFunction - Specifies the blend function to be used + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMAlphaBlend entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDest->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvAlphaBlend)(psoDest, + psoSrc, + pco, + pxlo, + prclDest, + prclSrc, + pBlendObj); +} + +BOOL APIENTRY +OEMGradientFill( + SURFOBJ *psoDest, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + TRIVERTEX *pVertex, + ULONG nVertex, + PVOID pMesh, + ULONG nMesh, + RECTL *prclExtents, + POINTL *pptlDitherOrg, + ULONG ulMode + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvGradientFill. + + DrvGradientFill shades the specified primitives. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDest - Defines the surface on which to draw + pco - Limits the area to be modified on the Destination + pxlo - Should be ignored by the driver + pVertex - Pointer to an array of TRIVERTEX structures, + with each entry containing position and color information + nVertex - Specifies the number of TRIVERTEX structures in the + array to which pVertex points + pMesh - Pointer to an array of structures that define the connectivity + of the TRIVERTEX elements to which pVertex points + nMesh - Specifies the number of elements in the array to which + pMesh points + prclExtents - Pointer to a RECTL structure that defines the area in + which the gradient drawing is to occur + pptlDitherOrg - Pointer to a POINTL structure that defines the origin + on the surface for dithering + ulMode - Specifies the current drawing mode and how to interpret + the array to which pMesh points + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMGradientFill entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDest->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvGradientFill)(psoDest, + pco, + pxlo, + pVertex, + nVertex, + pMesh, + nMesh, + prclExtents, + pptlDitherOrg, + ulMode); +} + +BOOL APIENTRY +OEMTransparentBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + RECTL *prclSrc, + ULONG iTransColor, + ULONG ulReserved + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvTransparentBlt. + + DrvTransparentBlt provides bit-block transfer capabilities with + transparency. + + Please refer to DDK documentation for more details. + +Arguments: + + psoDst - Defines the surface on which to draw + psoSrc - Defines the source + pco - Limits the area to be modified on the Destination + pxlo - Specifies how color dwIndexes are to be translated + between the source and target surfaces + prclDst - Defines the area to be modified on the Destination surface + prclSrc - Defines the area to be copied from the source surface + iTransColor - Specifies the transparent color + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMTransparentBlt entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)psoDst->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvTransparentBlt)(psoDst, + psoSrc, + pco, + pxlo, + prclDst, + prclSrc, + iTransColor, + ulReserved); +} + +BOOL APIENTRY +OEMTextOut( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvTextOut. + + DrvTextOut is the entry point from GDI that calls for the + driver to render a set of glyphs at specified positions. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to be written. + pstro - Defines the glyphs to be rendered and their positions + pfo - Specifies the font to be used + pco - Defines the clipping path + prclExtra - A NULL-terminated array of rectangles to be filled + prclOpaque - Specifies an opaque rectangle + pboFore - Defines the foreground brush + pboOpaque - Defines the opaque brush + pptlOrg - Pointer to POINT struct , defining th origin + mix - Specifies the foreground and background ROPs for pboFore + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMTextOut entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvTextOut)(pso, + pstro, + pfo, + pco, + prclExtra, + prclOpaque, + pboFore, + pboOpaque, + pptlOrg, + mix); +} + +PIFIMETRICS APIENTRY +OEMQueryFont( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG_PTR *pid + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryFont. + + DrvQueryFont is used by GDI to get the IFIMETRICS structure + for a given font. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + iFile - Identifies the driver font file + iFace - One-based index of the driver font + pid - Points to a LONG variable for returning an identifier + which GDI will pass to DrvFree + +Return Value: + + Pointer to an IFIMETRICS structure for the given font. + NULL if there is an error + +--*/ + +{ + VERBOSE("OEMQueryFont entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryFont)(dhpdev, + iFile, + iFace, + pid); +} + +PVOID APIENTRY +OEMQueryFontTree( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG iMode, + ULONG_PTR *pid + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryFontTree. + + DrvQueryFontTree provides GDI with a pointer to a structure that + defines one of the following: + - A mapping from Unicode to glyph handles, including glyph variants + - A mapping of kerning pairs to kerning handles + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + iFile - Identifies the driver font file + iFace - One-based index of the driver font + iMode - Specifies the type of information to be provided + pid - Points to a LONG variable for returning an identifier + which GDI will pass to DrvFree + +Return Value: + + Pointer to the structure requested based on iMode. + NULL if there is an error + +--*/ + +{ + VERBOSE("OEMQueryFontTree entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryFontTree)(dhpdev, + iFile, + iFace, + iMode, + pid); +} + +LONG APIENTRY +OEMQueryFontData( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH hg, + GLYPHDATA *pgd, + _Out_writes_bytes_(cjSize) PVOID pv, + ULONG cjSize + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryFontData. + + DrvQueryFontData retrieves information about a realized font. + GDI provides a pointer to an array of glyph or kerning handles, + and the driver returns information about the glyphs or kerning + pairs. The driver can assume that all handles in the array are valid. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + pfo - Points to a FONTOBJ structure + iMode - Type of information requested + hg - A glyph handle + pgd - Points to a GLYPHDATA structure + pv - Points to output buffer + cjSize - Size of output buffer + +Return Value: + + Depends on iMode. FD_ERROR if there is an error + +--*/ + +{ + VERBOSE("OEMQueryFontData entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryFontData)(dhpdev, + pfo, + iMode, + hg, + pgd, + pv, + cjSize); +} + +ULONG APIENTRY +OEMFontManagement( + SURFOBJ *pso, + FONTOBJ *pfo, + ULONG iMode, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvFontManagement. + + Is this function valid for Unidrv drivers? + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Points to a SURFOBJ structure + pfo - Points to a FONTOBJ structure + iMode - Escape number + cjIn - Size of input buffer + pvIn - Points to input buffer + cjOut - Size of output buffer + pvOut - Points to output buffer + +Return Value: + + 0x00000001 to 0x7fffffff for success + 0x80000000 to 0xffffffff for failure + 0 if the specified escape number if not supported + +--*/ + +{ + VERBOSE("OEMFontManagement entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvFontManagement)(pso, + pfo, + iMode, + cjIn, + pvIn, + cjOut, + pvOut); +} + +BOOL APIENTRY +OEMQueryAdvanceWidths( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + _In_reads_(cGlyphs) HGLYPH *phg, + _Out_writes_bytes_(cGlyphs*sizeof(USHORT)) PVOID pvWidths, + ULONG cGlyphs + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvQueryAdvanceWidths. + + DrvQueryAdvanceWidths returns character advance widths + for a specified set of glyphs. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + pfo - Points to a FONTOBJ structure + iMode - Type of information to be provided + phg - Points to an array of HGLYPHs for which the driver will + provide character advance widths + pvWidths - Points to a buffer for returning width data + cGlyphs - Number of glyphs in the phg array + +Return Value: + + Depends on iMode + +--*/ + +{ + VERBOSE("OEMQueryAdvanceWidths entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvQueryAdvanceWidths)(dhpdev, + pfo, + iMode, + phg, + pvWidths, + cGlyphs); +} + +ULONG APIENTRY +OEMGetGlyphMode( + DHPDEV dhpdev, + FONTOBJ *pfo + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvGetGlyphMode. + + DrvGetGlyphMode tells GDI how to cache glyph information. + GDI calls a driver's DrvGetGlyphMode routine to determine the + range of font information that should be cached for a particular + font; that is, DrvGetGlyphMode determines what GDI stores in + its font cache. A device that caches fonts on its own should return + FO_HGLYPHS to minimize the storage requirements for the font. + GDI calls DrvGetGlyphMode for each font realization. For example, + a driver might want to download outlines for point sizes larger than + 12 point, but raster images for smaller fonts. However, GDI reserves + the right to refuse this request. + + Please refer to DDK documentation for more details. + +Arguments: + + dhpdev - Driver device handle + pfo - Points to a FONTOBJ structure + +Return Value: + + The glyph mode or FO_GLYPHMODE, which is the default. + +--*/ + +{ + VERBOSE("OEMGetGlyphMode entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvGetGlyphMode)(dhpdev, + pfo); +} + +BOOL APIENTRY +OEMStartDoc( + SURFOBJ *pso, + _In_ PWSTR pwszDocName, + DWORD dwJobId + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStartDoc. + + DrvStartDoc is called by GDI when it is ready to + start sending a document to the driver for rendering. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + pDocName - Specifies a Unicode document name + jobId - Identifies the print job + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMStartDoc entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStartDoc)(pso, + pwszDocName, + dwJobId); +} + +BOOL APIENTRY +OEMEndDoc( + SURFOBJ *pso, + FLONG fl + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvEndDoc. + + DrvEndDoc is called by GDI when it has finished + sending a document to the driver for rendering. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + flags - A set of flag bits + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMEndDoc entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvEndDoc)(pso, + fl); +} + +BOOL APIENTRY +OEMStartPage( + SURFOBJ *pso + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStartPage. + + DrvStartPage is called by GDI when it is ready to + start sending the contents of a physical page to the + driver for rendering. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMStartPage entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStartPage)(pso); +} + +BOOL APIENTRY +OEMSendPage( + SURFOBJ *pso + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvSendPage. + + DrvSendPage is called by GDI when it has finished + drawing a physical page, so the driver can send + the page to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMSendPage entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvSendPage)(pso); +} + +BOOL APIENTRY +OEMStartBanding( + SURFOBJ *pso, + POINTL *pptl + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvStartBanding. + + DrvStartBanding is called by GDI when it is ready to start + sending bands of a physical page to the driver for rendering. + Note: DrvStartBanding is called to prepare the driver + for banding, call only once per page (not at everyband!!) + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + pptl - Pointer to origin of next band (to return to GDI) + +Return Value: + + Fill out pptl to contain the origin of the first band + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMStartBanding entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvStartBanding)(pso, + pptl); +} + +BOOL APIENTRY +OEMNextBand( + SURFOBJ *pso, + POINTL *pptl + ) + +/*++ + +Routine Description: + + Implementation of DDI hook for DrvNextBand. + + DrvNextBand is called by GDI when it has finished + drawing a band for a physical page, so the driver + can send the band to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface object + pptl - Pointer to origin of next band (to return to GDI) + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("OEMNextBand entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvNextBand)(pso, + pptl); +} + +ULONG APIENTRY +OEMEscape( + SURFOBJ *pso, + ULONG iEsc, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) + +/*++ + +Routine Description: + + Implementation of DDI entry point DrvEscape. + + DrvEscape is used for retrieving information from a device + that is not available in a device-independent device driver + interface; the particular query depends on the value of the + iEsc parameter. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Describes the surface the call is directed to + iEsc - Specifies a query + cjIn - Specifies the size in bytes of the buffer pointed to by pvIn + pvIn - Points to input data buffer + cjOut - Specifies the size in bytes of the buffer pointed to by pvOut + pvOut - Points to the output buffer + +Return Value: + + Depends on the query specified by iEsc parameter. + + Zero if the function specified by the query is not supported. + +--*/ + +{ + VERBOSE("OEMEscape entry."); + + PDEVOBJ pDevObj = (PDEVOBJ)pso->dhpdev; + POEMPDEV pOemPDEV = (POEMPDEV)pDevObj->pdevOEM; + + // Punt call back to UNIDRV. + // + return (pOemPDEV->m_pfnDrvEscape)(pso, + iEsc, + cjIn, + pvIn, + cjOut, + pvOut); +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.cpp new file mode 100644 index 00000000..6196a054 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.cpp @@ -0,0 +1,222 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + +#include "precomp.h" + +#include "resource.h" +#include "devmode.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +HRESULT hrOEMDevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DevMode. + hrOEMDevMode is called by IPrintOemUni::DevMode + which is defined in intrface.cpp. + + The IPrintOemUni::DevMode method, provided by + rendering plug-ins for Unidrv, performs operations + on private DEVMODE members. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - caller-supplied constant. Refer to the docs + for more information. + pOemDMParam - pointer to an OEMDMPARAM structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + +--*/ + +{ + POEMDEV pOEMDevIn; + POEMDEV pOEMDevOut; + + VERBOSE("hrOEMDevMode entry."); + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + )) + { + ERR("DevMode() ERROR_INVALID_PARAMETER.\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devmode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + case OEMDM_DEFAULT: + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + break; + + case OEMDM_CONVERT: + bConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + case OEMDM_MERGE: + bConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + bMakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return S_OK; +} + + +BOOL bConvertOEMDevmode( + PCOEMDEV pOEMDevIn, + POEMDEV pOEMDevOut + ) + +/*++ + +Routine Description: + + Converts private DEVMODE members to the + current version. + +Arguments: + + pOEMDevIn - pointer to OEM private devmode + pOEMDevOut - pointer to OEM private devmode + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + VERBOSE("bConvertOEMDevmode entry."); + + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR("ConvertOEMDevmode() invalid parameters.\r\n"); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE("Converting private OEM Devmode.\r\n"); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->dwDriverData = 0; + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + VERBOSE("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n"); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->dwDriverData = 0; + } + + return TRUE; +} + + +BOOL bMakeOEMDevmodeValid( + POEMDEV pOEMDevmode + ) + +/*++ + +Routine Description: + + Ensures that private OEM devmode members are valid. + +Arguments: + + pOEMDevmode - pointer to OEM private devmode + +Return Value: + + TRUE if successful, FALSE if there is an error + +--*/ + +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // Set driver data. + pOEMDevmode->dwDriverData = 0; + + return TRUE; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.h new file mode 100644 index 00000000..02af4909 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/devmode.h @@ -0,0 +1,43 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// + +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + BOOL dwDriverData; +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL bConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL bMakeOEMDevmodeValid(POEMDEV pOEMDevmode); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/dllentry.cpp new file mode 100644 index 00000000..8ed3e0e7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/dllentry.cpp @@ -0,0 +1,55 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" + +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// + +// DllMain isn't called/used for kernel mode version. +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + VERBOSE("DllMain entry."); + + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE("Process attach.\r\n"); + break; + + case DLL_THREAD_ATTACH: + VERBOSE("Thread attach.\r\n"); + break; + + case DLL_PROCESS_DETACH: + VERBOSE("Process detach.\r\n"); + break; + + case DLL_THREAD_DETACH: + VERBOSE("Thread detach.\r\n"); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.cpp new file mode 100644 index 00000000..8d87053f --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.cpp @@ -0,0 +1,1797 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// PURPOSE: Interface for User Mode COM Customization DLL. +// + +#include "precomp.h" +#include "resource.h" +#include "devmode.h" +#include "debug.h" +#include "oemuni.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +// ================================================================== +// Internal Globals +// +static long g_cComponents; // Count of active components +static long g_cServerLocks; // Count of locks +// +// ================================================================== + +// ================================================================== +// The purpose of this array is to inform UNIDRV of the callbacks +// that are implemented in this driver. +// +// Note that there is *NO* order dependency in this array. New +// index values and their corresponding callbacks can be placed +// anywhere within the list as needed. +// +static const DRVFN s_aOemHookFuncs[] = +{ + // The following are declared in printoem.h and defined in ddihook.cpp. + {INDEX_DrvAlphaBlend, (PFN)OEMAlphaBlend}, + {INDEX_DrvBitBlt, (PFN)OEMBitBlt}, + {INDEX_DrvCopyBits, (PFN)OEMCopyBits}, + {INDEX_DrvDitherColor, (PFN)OEMDitherColor}, + {INDEX_DrvFillPath, (PFN)OEMFillPath}, + {INDEX_DrvFontManagement, (PFN)OEMFontManagement}, + {INDEX_DrvGetGlyphMode, (PFN)OEMGetGlyphMode}, + {INDEX_DrvGradientFill, (PFN)OEMGradientFill}, + {INDEX_DrvLineTo, (PFN)OEMLineTo}, + {INDEX_DrvPaint, (PFN)OEMPaint}, + {INDEX_DrvPlgBlt, (PFN)OEMPlgBlt}, + {INDEX_DrvQueryAdvanceWidths, (PFN)OEMQueryAdvanceWidths}, + {INDEX_DrvQueryFont, (PFN)OEMQueryFont}, + {INDEX_DrvQueryFontData, (PFN)OEMQueryFontData}, + {INDEX_DrvQueryFontTree, (PFN)OEMQueryFontTree}, + {INDEX_DrvRealizeBrush, (PFN)OEMRealizeBrush}, + {INDEX_DrvStretchBlt, (PFN)OEMStretchBlt}, + {INDEX_DrvStretchBltROP, (PFN)OEMStretchBltROP}, + {INDEX_DrvStrokeAndFillPath, (PFN)OEMStrokeAndFillPath}, + {INDEX_DrvStrokePath, (PFN)OEMStrokePath}, + {INDEX_DrvTextOut, (PFN)OEMTextOut}, + {INDEX_DrvTransparentBlt, (PFN)OEMTransparentBlt}, + {INDEX_DrvStartDoc, (PFN)OEMStartDoc}, + {INDEX_DrvEndDoc, (PFN)OEMEndDoc}, + {INDEX_DrvStartPage, (PFN)OEMStartPage}, + {INDEX_DrvSendPage, (PFN)OEMSendPage}, + {INDEX_DrvStartBanding, (PFN)OEMStartBanding}, + {INDEX_DrvNextBand, (PFN)OEMNextBand}, + {INDEX_DrvEscape, (PFN)OEMEscape} +}; + +//////////////////////////////////////////////////////////////////////////////// +// +// COemUni2 body +// +COemUni2::COemUni2() +{ + m_cRef = 1; + + // Increment COM component count. + InterlockedIncrement(&g_cComponents); + + m_pOEMHelp = NULL; +} + +COemUni2::~COemUni2() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + +HRESULT __stdcall +COemUni2:: +QueryInterface( + const IID& iid, + void** ppv + ) +{ + VERBOSE("COemUni2::QueryInterface() entry."); + + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE("COemUni2::QueryInterface IUnknown.\r\n"); + } + else if (iid == IID_IPrintOemUni2) + { + VERBOSE("COemUni2::QueryInterface IPrintOemUni2.\r\n"); + + *ppv = static_cast(this); + } + else + { + WARNING("COemUni2::QueryInterface NULL. Returning E_NOINTERFACE.\r\n"); + + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall +COemUni2:: +AddRef( + VOID + ) +{ + VERBOSE("COemUni2::AddRef() entry."); + + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +COemUni2:: +Release( + VOID + ) +{ + VERBOSE("COemUni2::Release() entry."); + ULONG cRef = InterlockedDecrement(&m_cRef); + + if (cRef == 0) + { + delete this; + return 0; + } + return cRef; +} + +HRESULT __stdcall +COemUni2:: +CommandCallback( + PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::CommandCallback + + The IPrintOemUni::CommandCallback method is used + to provide dynamically generated printer commands + for Unidrv-supported printers. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + dwCallbackID - value representing the printer command's + *CallbackID attribute in the printer's generic printer + description (GPD) file. + dwCount - value representing the number of elements + in the array pointed to by pdwParams. Can be 0. + pdwParams - pointer to an array of DWORD-sized parameters + containing values specified by the printer commands + *Params attribute in the printer's GPD file. Can be NULL. + piResult - Receives a method-supplied result value. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::CommandCallback() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pdwParams); + + *piResult = 0; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +Compression( + PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::Compression + + The IPrintOemUni::Compression method can be used + with Unidrv-supported printers to provide a customized + bitmap compression method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pInBuf - pointer to input scan line data. + pOutBuf - pointer to an output buffer to receive + compressed scan line data. + dwInLen - length of the input data. + dwOutLen - length of the output buffer. + piResult - Receives a method-supplied result value. If the + operation succeeds, this value should be the number + of compressed bytes, which must not be larger than + the value received for dwOutLen. If an error occurs, + or if the method cannot compress, the result value + should be -1. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::Compression() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pInBuf); + UNREFERENCED_PARAMETER(pOutBuf); + UNREFERENCED_PARAMETER(dwInLen); + UNREFERENCED_PARAMETER(dwOutLen); + UNREFERENCED_PARAMETER(piResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DevMode + + The IPrintOemUni::DevMode method, provided by + rendering plug-ins for Unidrv, performs operations + on private DEVMODE members. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DevMode method. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - caller-supplied constant. Refer to the docs + for more information. + pOemDMParam - pointer to an OEMDMPARAM structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE("COemUni2:DevMode entry."); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall +COemUni2:: +DisableDriver( + VOID + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DisableDriver + + The IPrintOemUni::DisableDriver method allows a rendering + plug-in for Unidrv to free resources that were allocated by the + plug-in's IPrintOemUni::EnableDriver method. This is the last + IPrintOemUni interface method that is called before the rendering + plug-in is unloaded. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DisableDriver method. + + Please refer to DDK documentation for more details. + +Arguments: + + VOID + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE("COemUni2::DisableDriver() entry."); + + // Release reference to Printer Driver's interface. + // + if (this->m_pOEMHelp) + { + this->m_pOEMHelp->Release(); + this->m_pOEMHelp = NULL; + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +DisablePDEV( + PDEVOBJ pdevobj + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DisablePDEV + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DisablePDEV method. + + The IPrintOemUni::DisablePDEV method performs the same types of + operations as the DrvDisablePDEV function. Its purpose is to allow a + rendering plug-in to delete the private PDEV structure that is pointed + to by the DEVOBJ structure's pdevOEM member. This PDEV structure + is one that was allocated by the plug-in's IPrintOemUni::EnablePDEV method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE("COemUni2::DisablePDEV() entry."); + + POEMPDEV pOemPDEV = (POEMPDEV)pdevobj->pdevOEM; + delete pOemPDEV; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +DownloadCharGlyph( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DownloadCharGlyph + + The IPrintOemUni::DownloadCharGlyph method enables a + rendering plug-in for Unidrv to send a character glyph for + a specified soft font to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + hGlyph - glyph handle. + pdwWidth - pointer to receive the method-supplied width of the character. + pdwResult - Receives a method-supplied value representing the amount + of printer memory, in bytes, required to store the character glyph. + If the operation fails, the returned value should be zero. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::DownloadCharGlyph() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(hGlyph); + UNREFERENCED_PARAMETER(pdwWidth); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DownloadFontHeader( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DownloadFontHeader + + The IPrintOemUni::DownloadFontHeader method allows a + rendering plug-in for Unidrv to send a font's header + information to a printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pdwResult - Receives a method-supplied value representing the amount + of printer memory, in bytes, required to store the font header + information. If the operation fails, the returned value should be zero. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::DownloadFontHeader() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +DriverDMS( + PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::DriverDMS + + The IPrintOemUni::DriverDMS method allows a rendering + plug-in for Unidrv to indicate that it uses a device-managed + drawing surface instead of the default GDI-managed surface. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::DriverDMS method. + + Please refer to DDK documentation for more details. For general info + on device managed surfaces and how to handle them, please refer to + the section titled "Handling Device-Managed Surfaces". + +Arguments: + + pDevObj - pointer to a DEVOBJ structure. + pBuffer - pointer to a buffer to receive method-specified flags. + cbSize - size, in bytes, of the buffer pointed to by pBuffer. + pcbNeeded - pointer to a location to receive the required + minimum pBuffer size. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE("COemUni2::DriverDMS() entry."); + + UNREFERENCED_PARAMETER(pDevObj); + UNREFERENCED_PARAMETER(pBuffer); + UNREFERENCED_PARAMETER(cbSize); + UNREFERENCED_PARAMETER(pcbNeeded); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +EnableDriver( + DWORD dwDriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::EnableDriver + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::EnableDriver method. + + The IPrintOemUni::EnableDriver method allows a rendering + plug-in to perform the same types of operations as the + DrvEnableDriver function. Like the DrvEnableDriver function, + the IPrintOemUni::EnableDriver method is responsible for + providing addresses of internally supported graphics DDI functions, + or DDI hook functions. + + The method should fill the supplied DRVENABLEDATA structure + and allocate an array of DRVFN structures. It should fill the + array with pointers to hooking functions, along with winddi.h-defined + index values that identify the hooked out graphics DDI functions. + + Please refer to DDK documentation for more details. + +Arguments: + + DriverVersion - interface version number. This value is + defined by PRINTER_OEMINTF_VERSION, in printoem.h. + cbSize - size, in bytes, of the structure pointed to by pded. + pded - pointer to a DRVENABLEDATA structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE("COemUni2::EnableDriver() entry."); + + UNREFERENCED_PARAMETER(dwDriverVersion); + UNREFERENCED_PARAMETER(cbSize); + + // We need to return the DDI functions that have been hooked + // in pded. Here we fill out the fields in pded. + // + pded->iDriverVersion = PRINTER_OEMINTF_VERSION; + pded->c = sizeof(s_aOemHookFuncs) / sizeof(DRVFN); + pded->pdrvfn = (DRVFN *) s_aOemHookFuncs; + + // Even if nothing is done, need to return S_OK so + // that DisableDriver() will be called, which releases + // the reference to the Printer Driver's interface. + // + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +EnablePDEV( + PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::EnablePDEV + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::EnablePDEV method. + + The IPrintOemUni::EnablePDEV method performs the same types + of operations as the DrvEnablePDEV function that is exported + by a printer graphics DLL. Its purpose is to allow a rendering + plug-in to create its own PDEV structure. For more information + about PDEV structures, see "Customized PDEV Structures" in the DDK docs. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pPrinterName - pointer to a text string representing the + logical address of the printer. + cPatterns - value representing the number of HSURF-typed + surface handles contained in the buffer pointed to by + phsurfPatterns. + phsurfPatterns - pointer to a buffer that is large enough to + contain cPatterns number of HSURF-typed surface handles. + The handles represent surface fill patterns. + cjGdiInfo - value representing the size of the structure pointed + to by pGdiInfo. + pGdiInfo - pointer to a GDIINFO structure. + cjDevInfo - value representing the size of the structure pointed + to by pDevInfo. + pDevInfo - pointer to a DEVINFO structure. + pded - pointer to a DRVENABLEDATA structure containing the + addresses of the printer driver's graphics DDI hooking functions. + pDevOem - Receives a method-supplied pointer to a private PDEV structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + If the operation fails, the method should call SetLastError to set an error code. + + +--*/ + +{ + VERBOSE("COemUni2::EnablePDEV() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(cPatterns); + UNREFERENCED_PARAMETER(phsurfPatterns); + UNREFERENCED_PARAMETER(cjGdiInfo); + UNREFERENCED_PARAMETER(cjDevInfo); + UNREFERENCED_PARAMETER(pDevInfo); + UNREFERENCED_PARAMETER(pGdiInfo); + + // Allocate an instance of our private PDEV. + // + POEMPDEV pOemPDEV = new COemPDEV(); + + if (NULL == pOemPDEV) + { + return NULL; + } + + pOemPDEV->InitializeDDITable(pded); + + *pDevOem = pOemPDEV; + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +FilterGraphics( + PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::FilterGraphics + + The IPrintOemUni::FilterGraphics method can be used with + Unidrv-supported printers to modify scan line data and send + it to the spooler. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pBuf - pointer to a buffer containing scan line data to be printed. + dwLen - value representing the length, in bytes, of the data + pointed to by pBuf. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + DWORD dwResult; + + VERBOSE("COemUni2::FilterGraphics() entry."); + + m_pOEMHelp->DrvWriteSpoolBuf(pdevobj, pBuf, dwLen, &dwResult); + + if (dwResult == dwLen) + return S_OK; + else + return S_FALSE; +} + +HRESULT __stdcall +COemUni2:: +GetImplementedMethod( + _In_ PSTR pMethodName + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::GetImplementedMethod + + The IPrintOemUni::GetImplementedMethod method is used by + Unidrv to determine which IPrintOemUni interface methods + have been implemented by a rendering plug-in. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::GetImplemented method. + + Please refer to DDK documentation for more details. + +Arguments: + + pMethodName - pointer to a string representing the name of an + IPrintOemUni interface method, such as "ImageProcessing" + for IPrintOemUni::ImageProcessing or "FilterGraphics" for + IPrintOemUni::FilterGraphics. + +Return Value: + + S_OK The operation succeeded (the specified method is implemented). + S_FALSE The operation failed (the specified method is not implemented). + + +--*/ + +{ + HRESULT Result = S_FALSE; + + VERBOSE("COemUni2::GetImplementedMethod() entry."); + + // Unidrv only calls GetImplementedMethod for optional + // methods. The required methods are assumed to be + // supported. + + // Return S_OK for supported function (i.e. implemented), + // and S_FALSE for functions that aren't supported (i.e. not implemented). + switch (*pMethodName) + { + case 'C': + if (!strcmp(NAME_CommandCallback, pMethodName)) + { + Result = S_OK; + } + break; + case 'F': + if (!strcmp(NAME_FilterGraphics, pMethodName)) + { + Result = S_OK; + } + break; + } + + return Result; +} + +HRESULT __stdcall +COemUni2:: +GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::GetInfo + + A rendering plug-in's IPrintOemUni::GetInfo method returns + identification information. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::GetInfo method. + + Please refer to DDK documentation for more details. + +Arguments: + + dwMode - Contains one of the following caller-supplied integer constants. + OEMGI_GETSIGNATURE - The method must return a unique four-byte + identification signature. The plug-in must also place this signature + in OPTITEM structures, as described in the description of the + OEMCUIPPARAM. structure's pOEMOptItems member. + OEMGI_GETVERSION - The method must return the user interface + plug-in's version number as a DWORD. The version format is + developer-defined. + pBuffer - pointer to memory allocated to receive the information specified + by dwInfo. + cbSize - size of the buffer pointed to by pBuffer. + pcbNeeded - pointer to a location to receive the number of bytes written + into the buffer pointed to by pBuffer. + +Return Value: + + S_OK The operation succeeded (the specified method is implemented). + S_FALSE The operation failed (the specified method is not implemented). + + +--*/ + +{ + PWSTR pszTag = L"COemUni2::GetInfo entry."; + switch(dwMode) + { + case OEMGI_GETSIGNATURE: + pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETSIGNATURE]"; + break; + case OEMGI_GETVERSION: + pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETVERSION]"; + break; + + } + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) ) ) + { + WARNING("COemUni2::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER.\r\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + VERBOSE("COemUni2::GetInfo() exit insufficient buffer!\r\n"); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING("COemUni2::GetInfo() exit mode not supported.\r\n"); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +HalftonePattern( + PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::HalftonePattern + + The IPrintOemUni::HalftonePattern method can be used with + Unidrv-supported printers to create or modify a halftone + pattern before it is used in a halftoning operation. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pHTPattern - pointer to a buffer to receive the method-supplied + halftone pattern. Buffer size, in bytes, is: + (((dwHTPatternX * dwHTPatternY) + 3)/4) * 4 * dwHTNumPatterns. + dwHTPatternX - length, in pixels, of the halftone pattern, as specified + by the GPD file's *HTPatternSize attribute. + dwHTPatternY - height, in pixels, of the halftone pattern, as specified + by the GPD file's *HTPatternSize attribute. + dwHTNumPatterns - number of patterns, as specified by the GPD file's + *HTNumPatterns attribute. This can be 1 or 3. + dwCallbackID - value identifying the halftone method, as specified by + the GPD file's *HTCallbackID attribute. + pResource - pointer to a buffer containing a halftone pattern, as + specified by the GPD file's *rcHTPatternID attribute. This can be NULL. + dwResourceSize - size of the halftone pattern contained in the buffer + pointed to by pResource. This is zero if pResource is NULL. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::HalftonePattern() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pHTPattern); + UNREFERENCED_PARAMETER(dwHTPatternX); + UNREFERENCED_PARAMETER(dwHTPatternY); + UNREFERENCED_PARAMETER(dwHTNumPatterns); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(pResource); + UNREFERENCED_PARAMETER(dwResourceSize); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +ImageProcessing( + PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::ImageProcessing + + The IPrintOemUni::ImageProcessing method can be used with + Unidrv-supported printers to modify image bitmap data, in order + to perform color formatting or halftoning. The method can return + the modified bitmap to Unidrv or send it directly to the print spooler. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pSrcBitmap - pointer to an input device-independent bitmap (DIB). + pBitmapInfoHeader - pointer to a BITMAPINFOHEADER structure + that describes the bitmap pointed to by pSrcBitmap. + pColorTable - pointer to a color table. Used only if the output format is + eight bits per pixel. + dwCallbackID - value assigned to the *IPCallbackID attribute of the + currently selected option for the ColorMode feature. + pIPParams - pointer to an IPPARAMS structure. + ppbResult - + If the method returns the converted DIB to Unidrv: + If the conversion succeeds, the method should return a + pointer to a buffer containing the converted DIB. + Otherwise it should return NULL. + If the method sends the converted DIB to the print spooler: + If the operation succeeds, the method should return TRUE. + Otherwise it should return FALSE. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::ImageProcessing() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pSrcBitmap); + UNREFERENCED_PARAMETER(pBitmapInfoHeader); + UNREFERENCED_PARAMETER(pColorTable); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(pIPParams); + UNREFERENCED_PARAMETER(ppbResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +MemoryUsage( + PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::MemoryUsage + + The IPrintOemUni::MemoryUsage method can be used with + Unidrv-supported printers to specify the amount of memory + required for use by a rendering plug-in's IPrintOemUni::ImageProcessing + method. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pMemoryUsage - pointer to an OEMMEMORYUSAGE structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::MemoryUsage() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pMemoryUsage); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +OutputCharStr( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::OutputCharStr + + The IPrintOemUni::OutputCharStr method enables a rendering + plug-in to control the printing of font glyphs. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + dwType - value indicating the type of glyph specifier array + pointed to by pGlyph. Valid values are as follows: + TYPE_GLYPHHANDLE The pGlyph array elements are glyph + handles of type HGLYPH. + TYPE_GLYPHID The pGlyph array elements are glyph + identifiers of type DWORD. + dwCount - value representing the number of glyph specifiers in + the array pointed to by pGlyph. + pGlyph - pointer to an array of glyph specifiers, where the array + element type is indicated by dwType. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::OutputCharStr() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(dwType); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pGlyph); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +PublishDriverInterface( + IUnknown *pIUnknown + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::PublishDriverInterface + + The IPrintOemUni::PublishDriverInterface method allows a + rendering plug-in for Unidrv to obtain the Unidrv driver's + IPrintOemDriverUni interface. + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::PublishDriverInterface method and the method + must return S_OK, or the driver will not call the plug-in's other + IPrintOemUni interface methods. + + Please refer to DDK documentation for more details. + +Arguments: + + pIUnknown - pointer to the IUnknown interface of the driver's + IPrintOemDriverUni COM interface. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE("COemUni2::PublishDriverInterface() entry."); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (this->m_pOEMHelp == NULL) + { + HRESULT hResult; + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni, (void** ) &(this->m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + this->m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +ResetPDEV( + PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::ResetPDEV + + A rendering plug-in for Unidrv MUST implement the + IPrintOemUni::ResetPDEV method. + + A rendering plug-in's IPrintOemUni::ResetPDEV method performs + the same types of operations as the DrvResetPDEV function. During + the processing of an application's call to the Platform SDK ResetDC + function, the IPrintOemUni::ResetPDEV method is called by Unidrv's + DrvResetPDEV function. For more information about when DrvResetPDEV + is called, see its description in the DDK docs. + + The rendering plug-in's private PDEV structure's address is contained + in the pdevOEM member of the DEVOBJ structure pointed to by pdevobjOld. + The IPrintOemUni::ResetPDEV method should use relevant members of this + old structure to fill in the new structure, which is referenced through pdevobjNew. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobjOld - pointer to a DEVOBJ structure containing current PDEV information. + pdevobjNew - pointer to a DEVOBJ structure into which the method should place + new PDEV information. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + + +--*/ + +{ + VERBOSE("COemUni2::ResetPDEV() entry."); + + UNREFERENCED_PARAMETER(pdevobjOld); + UNREFERENCED_PARAMETER(pdevobjNew); + + return S_OK; +} + +HRESULT __stdcall +COemUni2:: +SendFontCmd( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::SendFontCmd + + The IPrintOemUni::SendFontCmd method enables a rendering + plug-in to modify a printer's font selection command and then + send it to the printer. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pFInv - pointer to an FINVOCATION structure. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::SendFontCmd() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pFInv); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TextOutAsBitmap( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TextOutAsBitmap + + The IPrintOemUni::TextOutAsBitmap method allows a rendering + plug-in to create a bitmap image of a text string, in case a + downloadable font is not available. + + Please refer to DDK documentation for more details. + +Arguments: + + pso - Defines the surface on which to be written. + pstro - Defines the glyphs to be rendered and their positions + pfo - Specifies the font to be used + pco - Defines the clipping path + prclExtra - A NULL-terminated array of rectangles to be filled + prclOpaque - Specifies an opaque rectangle + pboFore - Defines the foreground brush + pboOpaque - Defines the opaque brush + pptlOrg - Pointer to POINT struct , defining th origin + mix - Specifies the foreground and background ROPs for pboFore + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::TextOutAsBitmap() entry."); + + UNREFERENCED_PARAMETER(pso); + UNREFERENCED_PARAMETER(pstro); + UNREFERENCED_PARAMETER(pfo); + UNREFERENCED_PARAMETER(pco); + UNREFERENCED_PARAMETER(prclExtra); + UNREFERENCED_PARAMETER(prclOpaque); + UNREFERENCED_PARAMETER(pboFore); + UNREFERENCED_PARAMETER(pboOpaque); + UNREFERENCED_PARAMETER(pptlOrg); + UNREFERENCED_PARAMETER(mix); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TTDownloadMethod( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TTDownloadMethod + + The IPrintOemUni::TTDownloadMethod method enables a rendering + plug-in to indicate the format that Unidrv should use for a specified + TrueType soft font. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pUFObj - pointer to a UNIFONTOBJ structure. + pdwResult - Receives one of the following method-supplied constant values: + TTDOWNLOAD_BITMAP Unidrv should download the specified font as bitmaps. + TTDOWNLOAD_DONTCARE Unidrv can select the font format. + TTDOWNLOAD_GRAPHICS Unidrv should print TrueType fonts as graphics, + instead of downloading the font. + TTDOWNLOAD_TTOUTLINE Unidrv should download the specified font as outlines. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::TTDownloadMethod() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +TTYGetInfo( + PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni::TTYGetInfo + + The IPrintOemUni::TTYGetInfo method enables a rendering plug-in + to supply Unidrv with information relevant to text-only printers. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + dwInfoIndex - constant identifying the type of information being requested. + The following constant values are defined: + OEMTTY_INFO_CODEPAGE - The pOutputBuf parameter points to a + DWORD in which the method should return the number of the + code page to be used. + OEMTTY_INFO_MARGINS - The pOutputBuf parameter points to a + RECT structure in which the method should return page margin + widths, in tenths of millimeters (for example, 20 represents 2 mm). + If the entire page is printable, all margin values must be 0. + OEMTTY_INFO_NUM_UFMS - The pOutputBuf parameter points to a + DWORD in which the method should return the number of resource + IDs of the UFMs for 10, 12, and 17 CPI fonts. To actually obtain + these resource IDs, perform a query using OEMTTY_INFO_UFM_IDS. + OEMTTY_INFO_UFM_IDS - The pOutputBuf parameter points to an array + of DWORDs of sufficient size to hold the number of resource IDs of + the UFMs for 10, 12, and 17 CPI fonts. (This number is obtained by + using OEMTTY_INFO_NUM_UFMS in a query.) The method should + return the resource IDs of the UFMs for 10,12, and 17 CPI fonts. + pOutputBuf - pointer to a buffer to receive the requested information. + dwSize - size, in bytes, of the buffer pointed to by pOutputBuf. + pcbcNeeded - pointer to a location to receive the number of bytes written into + the buffer pointed to by pOutputBuf. If the number of bytes required is + smaller than the number specified by dwSize, the method should supply + the required size and return E_FAIL. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::TTYGetInfo() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwInfoIndex); + UNREFERENCED_PARAMETER(pOutputBuf); + UNREFERENCED_PARAMETER(dwSize); + UNREFERENCED_PARAMETER(pcbcNeeded); + + return E_NOTIMPL; +} + +HRESULT __stdcall +COemUni2:: +WritePrinter( + PDEVOBJ pdevobj, + PVOID pBuf, + DWORD cbBuffer, + PDWORD pcbWritten + ) + +/*++ + +Routine Description: + + Implementation of IPrintOemUni2::WritePrinter + + The IPrintOemUni2::WritePrinter method, if supported, enables a + rendering plug-in to capture all output data generated by a Unidrv + driver. If this method is not supported, the output data would + otherwise be sent to the spooler in a call to the spooler's WritePrinter API. + + Please refer to DDK documentation for more details. + +Arguments: + + pdevobj - pointer to a DEVOBJ structure. + pBuf - pointer to the first byte of an array of bytes that contains + the output data generated by the Unidrv driver. + cbBuffer - size, in bytes, of the array pointed to by pBuf. + pcbWritten - pointer to a DWORD value that receives the number + of bytes of data that were successfully sent to the plug-in. + +Return Value: + + S_OK The operation succeeded. + E_FAIL The operation failed. + E_NOTIMPL The method is not implemented. + + +--*/ + +{ + VERBOSE("COemUni2::WritePrinter() entry."); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pBuf); + UNREFERENCED_PARAMETER(cbBuffer); + UNREFERENCED_PARAMETER(pcbWritten); + + return E_NOTIMPL; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class COemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + // + + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef)(THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release)(THIS); + + // *** IClassFactory methods *** + // + STDMETHOD(CreateInstance)(THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer)(THIS_ BOOL bLock); + + + // Constructor + // + COemCF(): m_cRef(1) { }; + + // Destructor + // + ~COemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall +COemCF:: +QueryInterface( + const IID& iid, + void** ppv) +{ + VERBOSE("COemCF::QueryInterface entry."); + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + VERBOSE("COemCF::QueryInterface IID not supported.\r\n"); + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall +COemCF:: +AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall +COemCF:: +Release() +{ + assert(0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + } + return cRef; +} + +// IClassFactory implementation +// +HRESULT __stdcall +COemCF:: +CreateInstance( + IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + VERBOSE("Class factory:Create component."); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + // + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + // Create component. + // + COemUni2* pOemCP = new COemUni2; + if (pOemCP == NULL) + { + return E_OUTOFMEMORY; + } + + // Get the requested interface. + // + HRESULT hr = pOemCP->QueryInterface(iid, ppv); + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + // + pOemCP->Release(); + return hr; +} + +// LockServer +// +HRESULT __stdcall +COemCF:: +LockServer( + BOOL bLock + ) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + return S_OK; +} + + +// +// Registration functions +// + +// +// Can DLL unload now? +// +STDAPI DllCanUnloadNow(void) +{ + VERBOSE("DllCanUnloadNow entry."); + + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE("DllGetClassObject:\tCreate class factory."); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + // + if (clsid != CLSID_OEMRENDER) + { + ERR("DllGetClassObject:\tClass not available!\r\n"); + return CLASS_E_CLASSNOTAVAILABLE; + } + + // Create class factory. + // + COemCF* pFontCF = new COemCF; // Reference count set to 1 in constructor + if (pFontCF == NULL) + { + ERR("DllGetClassObject:\tOut of Memory!\r\n"); + return E_OUTOFMEMORY; + } + + // Get requested interface. + // + HRESULT hrResult = pFontCF->QueryInterface(iid, ppv); + pFontCF->Release(); + + return hrResult; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.h new file mode 100644 index 00000000..771a42c7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/intrface.h @@ -0,0 +1,283 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.H +// +// +// PURPOSE: Define COM interface for User Mode Printer Customization DLL. +// + +#pragma once + +///////////////////////////////////////////////////////// +// String Literals +///////////////////////////////////////////////////////// + +CONST CHAR NAME_CommandCallback[] = "CommandCallback"; +CONST CHAR NAME_FilterGraphics[] = "FilterGraphics"; + +//////////////////////////////////////////////////////////////////////////////// +// +// COemUni2 +// +// Interface for Unidrv OEM sample rendering module +// +class COemUni2 : public IPrintOemUni2 +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Method for getting the implemented methods. + // Returns S_OK if the given method is implemneted. + // Returns S_FALSE if the given method is notimplemneted. + // + + STDMETHOD(GetImplementedMethod)(THIS_ _In_ PSTR pMethodName); + + // + // Method for OEM to specify DDIs that have been hooked + // + + STDMETHOD(EnableDriver) (THIS_ DWORD DriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded); + + // + // Method to notify OEM plugin that it is no longer required + // + + STDMETHOD(DisableDriver) (THIS); + + // + // Method for OEM plugin to contruct its own PDEV + // + + STDMETHOD(EnablePDEV)(THIS_ PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem); + + // + // Method for OEM to free any resource associated with its PDEV + // + + STDMETHOD(DisablePDEV)(THIS_ PDEVOBJ pdevobj); + + // + // Method for OEM to transfer from old PDEV to new PDEV + // + + STDMETHOD(ResetPDEV)(THIS_ PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo)(THIS_ DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDriverDMS - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(DriverDMS)(THIS_ PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode)(THIS_ DWORD dwMode, + POEMDMPARAM pOemDMParam); + + // + // OEMCommandCallback - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(CommandCallback)(THIS_ PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult); + + // + // OEMImageProcessing - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(ImageProcessing)(THIS_ PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult); + + // + // OEMFilterGraphics - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(FilterGraphics)(THIS_ PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen); + // + // OEMCompression - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(Compression)(THIS_ PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult); + + // + // OEMHalftone - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(HalftonePattern)(THIS_ PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize); + + // + // OEMMemoryUsage - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(MemoryUsage)(THIS_ PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage); + + // + // OEMTTYGetInfo - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(TTYGetInfo)(THIS_ PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded); + + // + // OEMDownloadFontheader - UNIDRV only + // + + STDMETHOD(DownloadFontHeader)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMDownloadCharGlyph - UNIDRV only + // + + STDMETHOD(DownloadCharGlyph)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult); + + // + // OEMTTDownloadMethod - UNIDRV only + // + + STDMETHOD(TTDownloadMethod)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMOutputCharStr - UNIDRV only + // + + STDMETHOD(OutputCharStr)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph); + + // + // OEMSendFontCmd - UNIDRV only + // + + + STDMETHOD(SendFontCmd)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv); + + // + // OEMTextOutAsBitmap - UNIDRV only + // + + STDMETHOD(TextOutAsBitmap)(THIS_ SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix); + + // + // IPrintOemUni2 methods + // + + // + // Method for plugin to hook out spooler's WritePrinter API so it + // can get access to output data Universal driver is generating + // + // At DrvEnablePDEV time, Universal driver will call this function with + // pdevobj = NULL, pBuf = NULL, cbBuffer = 0 to detect if the plugin + // implements this function. Plugin should return S_OK to indicate it is + // implementing this function, or return E_NOTIMPL otherwise. + // + // In pcbWritten, plugins should return the number of bytes written to the + // spooler's WritePrinter function. Zero doesn't carry a special meaning, + // errors must be reported through the returned HRESULT. + // + + STDMETHOD(WritePrinter)(THIS_ PDEVOBJ pdevobj, + PVOID pBuf, + DWORD cbBuffer, + PDWORD pcbWritten); + + + COemUni2(); + ~COemUni2(); + +protected: + LONG m_cRef; + IPrintOemDriverUni* m_pOEMHelp; +}; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/precomp.h new file mode 100644 index 00000000..89396205 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/precomp.h @@ -0,0 +1,36 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Precomp.h +// +// PURPOSE: Header files that should be in the precompiled header. +// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +// This should always be included last +#include + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemuni/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/resource.h new file mode 100644 index 00000000..8e941820 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemuni/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by OEMUNI.rc +// + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/psuirep.ini b/print/OEM Printer Customization Plug-in Samples/C++/psuirep.ini new file mode 100644 index 00000000..74fbd433 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/psuirep.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=PSUIREP.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/syncset.gpd b/print/OEM Printer Customization Plug-in Samples/C++/syncset.gpd new file mode 100644 index 00000000..39f7a0e2 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/syncset.gpd @@ -0,0 +1,654 @@ +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*ModelName: "OEM CUSTOM SAMPLE SYNC DATA IN UI" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 + +*PrintRate: 8 +*PrintRateUnit: PPM +*PrintRatePPM: 8 + +*Feature: Orientation +{ + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l0O" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l1O" + } + } +} +*Feature: InputBin +{ + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: UPPER + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l1H" + } + } +} +*Feature: Resolution +{ + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: Option1 + *Option: Option1 + { + *Name: "300 x 300 " =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "<1B>%%-12345X" ++ "@PJL COMMENT HP Color LaserJet 5/5M " ++ "Version 0.56<0A>" ++ "@PJL SET RESOLUTION=300<0A>" ++ "@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } + *Option: Option2 + { + *Name: "150 x 150 " =DOTS_PER_INCH + *DPI: PAIR(150, 150) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "<1B>%%-12345X" ++ "@PJL COMMENT HP Color LaserJet 5/5M " ++ "Version 0.56<0A>" ++ "@PJL SET RESOLUTION=150<0A>" ++ "@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } +} + +*Feature: PaperSize +{ + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *%(9600, 12648) +*% *PrintableArea: PAIR(9600, 12648) + *PrintableArea: PAIR(9564, 12600) +*% *PrintableArea: PAIR(5000,5000) + *PrintableOrigin: PAIR(300, 300) +*% *PrintableOrigin: PAIR(300, 500) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9600->9592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (12648->12640) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9592, 12640) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *%5760 -- 7560 + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t5760x7604Y" + } + } + *case: LANDSCAPE_CC90 + { + *%(9720, 12648) + *PrintableArea: PAIR(9760, 12688) + *PrintableOrigin: PAIR(200, 272) + *CursorOrigin: PAIR(200, 12960) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t7632x5880Y" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9540, 16248) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9600->9592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (16248->16240) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9592, 16240) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t5760x9864Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9760, 16288) + *PrintableOrigin: PAIR(200, 272) + *CursorOrigin: PAIR(200, 16560) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t9792x5880Y" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 12000) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (8100->8096) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (12000->11992) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(8096, 11992) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t4860x7344Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8200, 12080) + *PrintableOrigin: PAIR(240, 280) + *CursorOrigin: PAIR(200, 12360) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t7272x4980Y" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9324, 13476) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9324->9320) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (13476->13472) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9320, 13472) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t5594x8201Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9464, 13516) + *PrintableOrigin: PAIR(220, 272) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (9464->9456) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (13516->13512) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(9456, 13512) +*% Warning: the following printable origin X is adjusted (220->224) so it is divisible by the resolution X scale. + *PrintableOrigin: PAIR(224, 272) + } + } + *CursorOrigin: PAIR(200, 13788) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t8129x5714Y" + } + } + } + } + *Option: A3 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(13428, 19308) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (13428->13424) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (19308->19304) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(13424, 19304) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l27a8c1E<1B>*p0x0Y<1B>*c0t8057x11693Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(13588, 19368) + *PrintableOrigin: PAIR(200, 240) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (13588->13584) so it is divisible by the resolution X scale. + *PrintableArea: PAIR(13584, 19368) + } + } + *CursorOrigin: PAIR(200, 19608) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l27a8c1E<1B>*p0x0Y<1B>*c0t11621x8177Y" + } + } + } + } + *Option: TABLOID + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *switch: Orientation + { + *case: PORTRAIT + { +*% *PrintableArea: PAIR(12600, 19800) + *PrintableArea: PAIR(12540, 19740) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (12600->12592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (19800->19792) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(12592, 19792) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l6a8c1E<1B>*p0x0Y<1B>*c0t7560x12000Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(12600, 19800) + *PrintableOrigin: PAIR(300, 300) + *switch: Resolution + { + *case: Option2 + { +*% Warning: the following printable width is adjusted (12600->12592) so it is divisible by the resolution X scale. +*% Warning: the following printable length is adjusted (19800->19792) so it is divisible by the resolution Y scale. + *PrintableArea: PAIR(12592, 19792) +*% Warning: the following printable origin X is adjusted (300->304) so it is divisible by the resolution X scale. +*% Warning: the following printable origin Y is adjusted (300->304) so it is divisible by the resolution Y scale. + *PrintableOrigin: PAIR(304, 304) + } + } + *CursorOrigin: PAIR(200, 20100) + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l6a8c1E<1B>*p0x0Y<1B>*c0t11880x7680Y" + } + } + } + } +} +*Feature: MediaType +{ + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: STANDARD + *Option: STANDARD + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.14 + *Cmd: "<1B>&l0M" + } + } + *Option: TRANSPARENCY + { + *rcNameID: =TRANSPARENCY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.14 + *Cmd: "<1B>&l4M" + } + } +} +*Feature: ColorMode +{ + *rcNameID: =COLOR_PRINTING_MODE_DISPLAY + *HelpIndex: 12004 + *DefaultOption: 24bpp + *Option: 24bpp + { + *rcNameID: =24BPP_DISPLAY + *DevNumOfPlanes: 1 + *DevBPP: 24 + *DrvBPP: 24 + *Command: CmdEnableDRC { *Cmd : "<1B>*b3M" } + *PaletteSize: 256 + *PaletteProgrammable? : TRUE + *Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" %d{PaletteIndexToProgram} ++ "I" } + *Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } + *Command: CmdSetSrcBmpWidth { *Cmd : "<1B>*r" %d{RasterDataWidthInBytes / 3}"S" } + *Command: CmdSelect + { + *Order: PAGE_SETUP.16 + *Cmd: "<1B>*v1N<1B>*v1O<1B>*l184O<1B>*v6W<0003080808081B>*v0a0b0c7i255a255b255c0I<1B>*" ++ "o3W<060400>" + } + } +} +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *HelpIndex: 12005 + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} + +*%------------------------------------------------------------------------- +*% Duplex +*%------------------------------------------------------------------------- +*Feature: Duplex +{ + *rcNameID: =TWO_SIDED_PRINTING_DISPLAY + *DefaultOption: NONE + *Option: NONE + { + *rcNameID: =NONE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.9 + *Cmd: "<1B>&l0S" + } + } + *Option: VERTICAL + { + *rcNameID: =FLIP_ON_LONG_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l1S" + + } + } + *Option: HORIZONTAL + { + *rcNameID: =FLIP_ON_SHORT_EDGE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.10 + *Cmd: "<1B>&l2S" + } + } +} + +*%------------------------------------------------------------------------- +*% Installable Option - Duplex Unit +*% IMPORTANT NOTE: The OEM extension assumes that this feature's keyname is +*% "DuplexUnit" and the options are "TRUE" and "FALSE" +*%------------------------------------------------------------------------- +*Feature: DuplexUnit +{ + *Name: "Optional Duplex Unit" *% Duplex Unit + *HelpIndex: 12004 + *FeatureType: PRINTER_PROPERTY + *DefaultOption: FALSE + *Option: FALSE + { + *Name: "Not Installed" + *DisabledFeatures: LIST(Duplex) + } + *Option: TRUE + { + *Name: "Installed" + } +} + + +*%------------------------------------------------------------------------- +*% Installable Option - Envelope Feeder +*% IMPORTANT NOTE: The OEM extension assumes that this feature's keyname is +*% "EnvFeeder" and the options are "TRUE" and "FALSE" +*%------------------------------------------------------------------------- +*Feature: EnvFeeder +{ + *Name: "Envelope Feeder" + *HelpIndex: 12000 + *FeatureType: PRINTER_PROPERTY + *DefaultOption: FALSE + *Option: FALSE + { + *Name: "Not Installed" + } + *Option: TRUE + { + *Name: "Installed" + } +} + + +*%------------------------------------------------------------------------- +*% Installable Option - PrinterHardDisk +*% IMPORTANT NOTE: The OEM extension assumes that this feature's keyname is +*% "PrinterHardDisk" and the options are "TRUE" and "FALSE" +*%------------------------------------------------------------------------- +*Feature: PrinterHardDisk +{ + *Name: "Printer Hard-Disk" *% Printer Hard-Disk + *HelpIndex: 12002 + *FeatureType: PRINTER_PROPERTY + *DefaultOption: FALSE + *Option: FALSE + { + *Name: "Not Installed" + *%*Constraints: LIST(JobRetention.Option2, JobRetention.Option4) + } + *Option: TRUE + { + *Name: "Installed" + } +} + + + +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.5 + *Cmd: "<1B>&u300D<1B>*r0F" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "<1B>*b0M<0D>" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "<1B>E<1B>%%-12345X" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l" %d{NumOfCopies}"X" +} +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*Command: CmdXMoveAbsolute { *Cmd : "<1B>*p" %d{(DestX / 4) }"X" } +*Command: CmdXMoveRelRight { *Cmd : "<1B>*p+" %d[0,9600]{max_repeat((DestXRel / 4) )}"X" } +*Command: CmdXMoveRelLeft { *Cmd : "<1B>*p-" %d[0,9600]{max_repeat((DestXRel / 4) )}"X" } +*Command: CmdYMoveAbsolute { *Cmd : "<1B>*p" %d{(DestY / 4) }"Y" } +*Command: CmdYMoveRelDown { *Cmd : "<1B>*p+" %d[1,12600]{max_repeat((DestYRel / 4) )}"Y" } +*Command: CmdYMoveRelUp { *Cmd : "<1B>*p-" %d[1,12600]{max_repeat((DestYRel / 4) )}"Y" } +*Command: CmdCR { *Cmd : "<0D>" } +*Command: CmdLF { *Cmd : "<0A>" } +*Command: CmdFF { *Cmd : "<0C>" } +*Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" %d{PaletteIndexToProgram} ++ "I" } +*Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } +*Command: CmdBackSpace { *Cmd : "<08>" } +*Command: CmdUniDirectionOn { *Cmd : "<00>" } +*Command: CmdUniDirectionOff { *Cmd : "<00>" } +*Command: CmdPushCursor { *Cmd : "<1B>&f0S" } +*Command: CmdPopCursor { *Cmd : "<1B>&f1S" } +*Command: CmdSetSimpleRotation { *Cmd : "<1B>&a" %d{PrintDirInCCDegrees}"P" } +*EjectPageWithFF?: TRUE +*Command: CmdEnableTIFF4 { *Cmd : "<1B>*b2M" } +*Command: CmdDisableCompression { *Cmd : "<1B>*b0M" } +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*DefaultFont: 136 +*DefaultCTT: 0 +*CharPosition: BASELINE +*TTFSEnabled?: TRUE +*DeviceFonts: LIST(134,135,136,137,138,139,140,146,147,148,149,150,151,152,153,154, ++ 155,156,157,164,165,166,196,197,198,199,200,201,202,203,209,210, ++ 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, ++ 227,228,229,230) + +*MinFontID: 16534 +*MaxFontID: 32768 +*FontFormat: HPPCL_OUTLINE +*% When the %f format is implemented we can remove the /100 part of +*% CmdSelectFontHeight and CmdSelectFontWidth +*% NOTE: MasterUnits.x is hardcoded here! +*% NOTE: THIS dividing by 200 because I want to /100 and then /2 for now. +*% The number 60000 may look strange, but it's 1200/2 * 100. +*Command: CmdSelectFontHeight { *Cmd : "<1B>(s" %d{FontHeight}"V" } +*Command: CmdSelectFontWidth { *Cmd : "<1B>(s" %f{1200 / FontWidth}"H" } +*Command: CmdSetFontID { *Cmd : "<1B>*c" %d{NextFontID}"D" } +*Command: CmdSelectFontID { *Cmd : "<1B>(" %d{CurrentFontID}"X" } +*Command: CmdSetCharCode { *Cmd : "<1B>*c" %d{NextGlyph}"E" } +*Command: CmdUnderlineOn { *Cmd : "<1B>&dD" } +*Command: CmdUnderlineOff { *Cmd : "<1B>&d@" } +*Command: CmdWhiteTextOn { *Cmd : "<1B>*v1o1T" } +*Command: CmdWhiteTextOff { *Cmd : "<1B>*v0o0T" } +*MinGrayFill: 1 +*MaxGrayFill: 100 +*Command: CmdSetRectWidth { *Cmd : "<1B>*c" %d{(RectXSize / 4) }"A" } +*Command: CmdSetRectHeight { *Cmd : "<1B>*c" %d{(RectYSize / 4) }"B" } +*Command: CmdRectGrayFill { *Cmd : "<1B>*c" %d{GrayPercentage }"g2P" } +*Command: CmdRectWhiteFill { *Cmd : "<1B>*c1P" } +*Command: CmdRectBlackFill { *Cmd : "<1B>*c0P" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/syncset.ini b/print/OEM Printer Customization Plug-in Samples/C++/syncset.ini new file mode 100644 index 00000000..11e9f7b0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/syncset.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=SYNCSET.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/themeui.ini b/print/OEM Printer Customization Plug-in Samples/C++/themeui.ini new file mode 100644 index 00000000..c3c9d2c9 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/themeui.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=ThemeUISmpl.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf b/print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf new file mode 100644 index 00000000..189db3ce --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf @@ -0,0 +1,133 @@ + +; UISAMPLES.INF +; +; INF file for OEM DLL UI samples +; +; Copyright 2001-2003 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Provider=%MS% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=6/07/2001,1.0.0.1 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Microsoft"=Microsoft, NTamd64, NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Microsoft] +"OEM Custom UI Plugin" = SYNCSET.UNI +"OEM Custom Help" = CUSTHELP.UNI + +[Microsoft.NTamd64] +"OEM Custom UI Plugin" = SYNCSET.UNI +"OEM Custom Help" = CUSTHELP.UNI + +[Microsoft.NTia64] +"OEM Custom UI Plugin" = SYNCSET.UNI +"OEM Custom Help" = CUSTHELP.UNI + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[SYNCSET.UNI] +CopyFiles=@SYNCSET.GPD +CopyFiles=@SYNCSET.INI +CopyFiles=SYNCSET +DataFile=SYNCSET.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,UNIDRV_DATA + +[CUSTHELP.UNI] +CopyFiles=@custhlp.gpd +CopyFiles=@custhlp.INI +CopyFiles=CUSTHLP +DataFile=custhlp.gpd +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,UNIDRV_DATA + + +; Copy Sections +; +; Lists of files that are actually copied. These sections are referenced +; from the installer sections, above. Only create a section if it contains +; two or more files (if we only copy a single file, identify it in the +; installer section, using the @filename notation) or if it's a color +; profile (since the DestinationDirs can only handle sections, and not +; individual files). +; + +[SYNCSET] +SYNCSET.DLL + +[CUSTHLP] +CUSTOMDRV.HLP +CUSTHLP.DLL + + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMUISample% + +[SourceDisksFiles.x86] +CUSTHLP.DLL = 100,CustHlp\x86 +SYNCSET.DLL = 100,SyncSet\x86 + +[SourceDisksFiles.amd64] +CUSTHLP.DLL = 100,CustHlp\amd64 +SYNCSET.DLL = 100,SyncSet\amd64 + +[SourceDisksFiles.ia64] +CUSTHLP.DLL = 100,CustHlp\ia64 +SYNCSET.DLL = 100,SyncSet\ia64 + +[SourceDisksFiles] +SYNCSET.GPD = 100 +custhlp.gpd = 100 +CUSTHLP.ini = 100 +SYNCSET.ini = 100 +CUSTOMDRV.hlp = 100 + + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +MS="Microsoft DDK Sample" +OEMUISample="OEM DLL Print UI Samples" + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.gpd b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.gpd new file mode 100644 index 00000000..f376bfe7 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.gpd @@ -0,0 +1,559 @@ +*GPDFileName: "uniuirep.gpd" +*GPDFileVersion: "1.0" +*GPDSpecVersion: "1.0" +*Include: "StdNames.gpd" +*ModelName: "OEM Unidrv Full UI Replacement Sample" +*MasterUnits: PAIR(1200, 1200) +*ResourceDLL: "unires.dll" +*PrinterType: PAGE +*MaxCopies: 99 +*PrintRate: 16 +*PrintRateUnit: PPM +*PrintRatePPM: 16 + +*%****************************************************************************************** +*% Orientation +*%****************************************************************************************** +*Feature: Orientation +{ + *rcNameID: =ORIENTATION_DISPLAY + *DefaultOption: PORTRAIT + *Option: PORTRAIT + { + *rcNameID: =PORTRAIT_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.6 + *Cmd: "<1B>&l0O" + } + } + *Option: LANDSCAPE_CC90 + { + *rcNameID: =LANDSCAPE_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.8 + *Cmd: "<1B>&l1O" + } + } +} + +*%****************************************************************************************** +*% Input Bin +*%****************************************************************************************** +*Feature: InputBin +{ + *rcNameID: =PAPER_SOURCE_DISPLAY + *DefaultOption: AUTO + *Option: AUTO + { + *rcNameID: =AUTO_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l0H" + } + } + *Option: UPPER + { + *rcNameID: =UPPER_TRAY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.11 + *Cmd: "<1B>&l1H" + } + } +} + +*%****************************************************************************************** +*% Resolution +*%****************************************************************************************** +*Feature: Resolution +{ + *rcNameID: =RESOLUTION_DISPLAY + *DefaultOption: 300dpi + *Option: 600dpi + { + *Name: "600 x 600" =DOTS_PER_INCH + *DPI: PAIR(600, 600) + *TextDPI: PAIR(600, 600) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED,TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=600<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t600R" + } + } + *Option: 300dpi + { + *Name: "300 x 300" =DOTS_PER_INCH + *DPI: PAIR(300, 300) + *TextDPI: PAIR(300, 300) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=300<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t300R" + } + } + *Option: 150dpi + { + *Name: "150 x 150" =DOTS_PER_INCH + *DPI: PAIR(150, 150) + *TextDPI: PAIR(150, 150) + *MinStripBlankPixels: 32 + EXTERN_GLOBAL: *StripBlanks: LIST(ENCLOSED, TRAILING) + *SpotDiameter: 100 + *Command: CmdBeginRaster { *Cmd : "<1B>*v7S<1B>*r1A" } + *Command: CmdEndRaster { *Cmd : "<1B>*rC" } + *Command: CmdSendBlockData { *Cmd : "<1B>*b" %d{NumOfDataBytes}"W" } + *Command: CmdSelect + { + *Order: DOC_SETUP.7 + *Cmd: "@PJL SET RESOLUTION=150<0A>@PJL ENTER LANGUAGE=PCL<0A0D1B>E<1B>*t150R" + } + } +} + +*%****************************************************************************************** +*% HP-GL/2 Graphics Support +*%****************************************************************************************** +*Ifdef: WINNT_51 +*Personality: =PERSONALITY_HPGL2 +*Feature: GraphicsMode +{ + *rcNameID: =GRAPHICSMODE_DISPLAY + *DefaultOption: HPGL2MODE + *Option: HPGL2MODE + { + *rcNameID: =GRAPHICSMODE_HPGL2_DISPLAY + } + *Option: RASTERMODE + { + *rcNameID: =GRAPHICSMODE_RASTER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.5 + *Cmd: "@PJL SET LIMAGEENHANCE=OFF<0A>" + } + } +} +*Endif: + +*%****************************************************************************************** +*% Paper Size +*%****************************************************************************************** +*Feature: PaperSize +{ + *rcNameID: =PAPER_SIZE_DISPLAY + *DefaultOption: LETTER + *Option: LETTER + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1028 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9500, 12500) + *PrintableOrigin: PAIR(400, 400) + *CursorOrigin: PAIR(300, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t5260x7704Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9500, 12200) + *PrintableOrigin: PAIR(450, 300) + *CursorOrigin: PAIR(200, 12900) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l2a8c1E<1B>*p0x0Y<1B>*c0t7332x5880Y" + } + } + } + } + *Option: LEGAL + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 1692 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 600) + *CursorOrigin: PAIR(180, 300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t5880x8900Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9000, 15500) + *PrintableOrigin: PAIR(400, 900) + *CursorOrigin: PAIR(180, 16500) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l3a8c1E<1B>*p0x0Y<1B>*c0t8900x5880Y" + } + } + } + } + *Option: EXECUTIVE + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4109 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(8100, 11500) + *PrintableOrigin: PAIR(300, 300) + *CursorOrigin: PAIR(300, 200) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t4860x7344Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(8300, 11500) + *PrintableOrigin: PAIR(200, 300) + *CursorOrigin: PAIR(200, 12300) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l1a8c1E<1B>*p0x0Y<1B>*c0t7272x4980Y" + } + } + } + } + *Option: A4 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 4249 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(288, 180) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t5594x8201Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(9100, 13200) + *PrintableOrigin: PAIR(400, 300) + *CursorOrigin: PAIR(204, 13824) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l26a8c1E<1B>*p0x0Y<1B>*c0t8129x5714Y" + } + } + } + } + *Option: B5 + { + *rcNameID: =RCID_DMPAPER_SYSTEM_NAME + *PageProtectMem: 3198 + *switch: Orientation + { + *case: PORTRAIT + { + *PrintableArea: PAIR(7900, 11140) + *PrintableOrigin: PAIR(352, 300) + *CursorOrigin: PAIR(300, 100) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t4970x7040Y" + } + } + *case: LANDSCAPE_CC90 + { + *PrintableArea: PAIR(7760, 11140) + *PrintableOrigin: PAIR(300, 400) + *CursorOrigin: PAIR(100, 11940) + *Command: CmdSelect + { + *Order: DOC_SETUP.12 + *Cmd: "<1B>&l12a8c1E<1B>*p0x0Y<1B>*c0t6780x4970Y" + } + } + } + } +} + +*%****************************************************************************************** +*% Outputbin +*%****************************************************************************************** + + +*Feature: OutputBin +{ + *rcNameID: =OUTPUTBIN_DISPLAY + *HelpIndex: 12006 + *DefaultOption: Option1 + *Option: Option1 + { + *% Auto Select + *Name: "default" + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "@PJL SET OUTBIN=OPTIONALOUTBIN2<0A>@PJL SET FINISH=NONE<0A>" + } + } + *Option: Option14 + { + *% Stacker + *Name: "stacker" *% Stacker + *Command: CmdSelect + { + *Order: DOC_SETUP.4 + *Cmd: "@PJL SET OUTBIN=OPTIONALOUTBIN2<0A>@PJL SET FINISH=NONE<0A>" + } + } +} + + +*%****************************************************************************************** +*% Media Type +*%****************************************************************************************** +*Feature: MediaType +{ + *rcNameID: =MEDIA_TYPE_DISPLAY + *DefaultOption: PLAIN + *Option: PLAIN + { + *rcNameID: =PLAIN_PAPER_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n6WdPlain" + } + } + *Option: TRANSPARENCY + { + *rcNameID: =TRANSPARENCY_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.15 + *Cmd: "<1B>&n13WdTransparency" + } + } +} + + + +*%****************************************************************************************** +*% HalfTone +*%****************************************************************************************** +*Feature: Halftone +{ + *rcNameID: =HALFTONING_DISPLAY + *DefaultOption: HT_PATSIZE_AUTO + *Option: HT_PATSIZE_AUTO + { + *rcNameID: =HT_AUTO_SELECT_DISPLAY + } + *Option: HT_PATSIZE_SUPERCELL_M + { + *rcNameID: =HT_SUPERCELL_DISPLAY + } + *Option: HT_PATSIZE_6x6_M + { + *rcNameID: =HT_DITHER6X6_DISPLAY + } + *Option: HT_PATSIZE_8x8_M + { + *rcNameID: =HT_DITHER8X8_DISPLAY + } +} + +*%****************************************************************************************** +*% Memory +*% +*% Note: Unidrv uses the font memory information to estimate when it needs to stop +*% downloading fonts for a page, and thus driver writers should err on the conservative +*% side. Otherwise, printers will generate "out of memory" device errors for pages with +*% a large number of fonts / unique glyphs. +*%****************************************************************************************** +*Feature: Memory +{ + *rcNameID: =PRINTER_MEMORY_DISPLAY + *DefaultOption: 32768KB + *Option: 16384KB + { + *Name: "16MB" + *MemoryConfigKB: PAIR(16384, 13950) + } + *Option: 32768KB + { + *Name: "32MB" + *MemoryConfigKB: PAIR(32768, 28350) + } +} + +*%****************************************************************************************** +*% Page Protect +*%****************************************************************************************** +*Feature: PageProtect +{ + *rcNameID: =PAGE_PROTECTION_DISPLAY + *DefaultOption: OFF + *Option: ON + { + *rcNameID: =ON_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=LETTER<0A>" + } + } + *Option: OFF + { + *rcNameID: =OFF_DISPLAY + *Command: CmdSelect + { + *Order: DOC_SETUP.1 + *Cmd: "<1B>%%-12345X@PJL SET PAGEPROTECT=OFF<0A>" + } + } +} + +*%****************************************************************************************** +*% Doc setup commands +*%****************************************************************************************** +*Command: CmdStartDoc +{ + *Order: DOC_SETUP.7 + *Cmd: "<1B>&u1200D<1B>*r0F" +} +*Command: CmdStartPage +{ + *Order: PAGE_SETUP.1 + *Cmd: "<1B>*b0M<0D>" +} +*Command: CmdEndJob +{ + *Order: JOB_FINISH.1 + *Cmd: "<1B>E<1B>%%-12345X@PJL<20>LPORTROTATE<0A><1B>%%-12345X" +} +*Command: CmdCopies +{ + *Order: DOC_SETUP.13 + *Cmd: "<1B>&l" %d{NumOfCopies}"X" +} + +*%****************************************************************************************** +*% Cursor, Page and Color Commands +*%****************************************************************************************** +*RotateCoordinate?: TRUE +*RotateRaster?: TRUE +*RotateFont?: TRUE +*TextCaps: LIST(TC_CR_90,TC_UA_ABLE) +*MemoryUsage: LIST(FONT, RASTER, VECTOR) +*CursorXAfterCR: AT_PRINTABLE_X_ORIGIN +*BadCursorMoveInGrxMode: LIST(X_PORTRAIT,Y_LANDSCAPE) +*XMoveThreshold: 0 +*YMoveThreshold: 0 +*XMoveUnit: 300 +*YMoveUnit: 300 +*Command: CmdXMoveAbsolute { *Cmd : "<1B>*p" %d{(DestX) }"X" } +*Command: CmdXMoveRelRight { *Cmd : "<1B>*p+" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdXMoveRelLeft { *Cmd : "<1B>*p-" %d[0,9600]{max_repeat((DestXRel) )}"X" } +*Command: CmdYMoveAbsolute { *Cmd : "<1B>*p" %d{(DestY) }"Y" } +*Command: CmdYMoveRelDown { *Cmd : "<1B>*p+" %d{(DestYRel) }"Y" } +*Command: CmdYMoveRelUp { *Cmd : "<1B>*p-" %d{(DestYRel) }"Y" } +*Command: CmdDefinePaletteEntry { *Cmd : "<1B>*v" %d{RedValue}"a" %d{GreenValue}"b" %d{BlueValue}"c" ++ %d{PaletteIndexToProgram} "I" } +*Command: CmdSelectPaletteEntry { *Cmd : "<1B>*v" %d{CurrentPaletteIndex}"S" } +*Command: CmdCR { *Cmd : "<0D>" } +*Command: CmdLF { *Cmd : "<0A>" } +*Command: CmdFF { *Cmd : "<0C>" } +*Command: CmdBackSpace { *Cmd : "<08>" } +*Command: CmdUniDirectionOn { *Cmd : "<00>" } +*Command: CmdUniDirectionOff { *Cmd : "<00>" } +*Command: CmdPushCursor { *Cmd : "<1B>&f0S" } +*Command: CmdPopCursor { *Cmd : "<1B>&f1S" } +*Command: CmdSetSimpleRotation { *Cmd : "<1B>&a" %d{PrintDirInCCDegrees}"P" } +*EjectPageWithFF?: TRUE +*Command: CmdEnableTIFF4 { *Cmd : "<1B>*b2M" } +*Command: CmdDisableCompression { *Cmd : "<1B>*b0M" } +*OutputDataFormat: H_BYTE +*OptimizeLeftBound?: TRUE +*CursorXAfterSendBlockData: AT_GRXDATA_ORIGIN +*CursorYAfterSendBlockData: AUTO_INCREMENT + +*%****************************************************************************************** +*% Font Descriptions and Commands +*%****************************************************************************************** +*DefaultFont: 136 +*DefaultCTT: 0 +*CharPosition: BASELINE +*DeviceFonts: LIST(136,138,146,147,148,149,150,151,152,153,154,155,156,157, ++ 163,164,165,166,196,197,198,199,200,201,202,203,209,210, ++ 211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226, ++ 227,228,229,230) +*MinFontID: 16534 +*MaxFontID: 32768 +*switch: Resolution +{ + *case: 600dpi + { + *FontFormat: HPPCL_OUTLINE + } + *case: 300dpi + { + *FontFormat: HPPCL_OUTLINE + } + *case: 150dpi + { + *FontFormat: HPPCL_RES + } +} +*Command: CmdSetFontID { *Cmd : "<1B>*c" %d{NextFontID}"D" } +*Command: CmdSelectFontID { *Cmd : "<1B>(" %d{CurrentFontID}"X" } +*Command: CmdSetCharCode { *Cmd : "<1B>*c" %d{NextGlyph}"E" } +*Command: CmdUnderlineOn { *Cmd : "<1B>&dD" } +*Command: CmdUnderlineOff { *Cmd : "<1B>&d@" } +*Command: CmdWhiteTextOn { *Cmd : "<1B>*v1o1T" } +*Command: CmdWhiteTextOff { *Cmd : "<1B>*v0o0T" } + + +*%******************************************************************************************** +*%* Vector Commands. +*%******************************************************************************************** +*MinGrayFill: 1 +*MaxGrayFill: 100 +*Command: CmdSetRectWidth { *Cmd : "<1B>*c" %d{(RectXSize) }"A" } +*Command: CmdSetRectHeight { *Cmd : "<1B>*c" %d{(RectYSize) }"B" } +*Command: CmdRectGrayFill { *Cmd : "<1B>*c" %d{GrayPercentage }"g2P" } +*Command: CmdRectWhiteFill { *Cmd : "<1B>*c1P" } +*Command: CmdRectBlackFill { *Cmd : "<1B>*c0P" } diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.inf b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.inf new file mode 100644 index 00000000..df4505b6 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.inf @@ -0,0 +1,99 @@ + +; UNIUIREP.INF +; +; INF file for the base DDK sample +; +; Copyright 1999 - 2001 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Provider=%MS% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=06/07/2001,1.0.0.1 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Microsoft"=Microsoft,NTx86,NTamd64,NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Microsoft.NTx86] +"Unidrv Full UI Replacement Sample" = UNIUIREP + +[Microsoft.NTamd64] +"Unidrv Full UI Replacement Sample" = UNIUIREP + +[Microsoft.NTia64] +"Unidrv Full UI Replacement Sample" = UNIUIREP + + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[UNIUIREP] +CopyFiles=@UNIUIREP.GPD +CopyFiles=@UNIUIREP.INI +CopyFiles=@UNIUIREP.DLL +DataFile=UNIUIREP.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,UNIDRV_DATA + + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMSample% + +[SourceDisksFiles.X86] +uniuirep.dll = 100,x86 + +[SourceDisksFiles.amd64] +uniuirep.dll = 100,amd64 + +[SourceDisksFiles.IA64] +uniuirep.dll = 100,ia64 + +[SourceDisksFiles] +uniuirep.GPD = 100 +uniuirep.INI = 100 + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +MS="Microsoft DDK Sample" +OEMSample="Full UI Replacement Sample" + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.ini b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.ini new file mode 100644 index 00000000..55701ada --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/res/uniuirep.ini @@ -0,0 +1,3 @@ +[OEMFiles] +OEMConfigFile1=UNIUIREP.DLL + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.cpp b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.cpp new file mode 100644 index 00000000..f2663bc0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.cpp @@ -0,0 +1,1991 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: Features.cpp +// +// PURPOSE: Implements wrapper classes for managing the features & +// options supported by the driver. +// +//-------------------------------------------------------------------------- + +#include "precomp.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal Defines and Macros +//////////////////////////////////////////////////////// + +// +// TAG the identifies feature OPTITEM data stuct. +// +#define FEATURE_OPTITEM_TAG 'FETR' + + +//////////////////////////////////////////////////////// +// Type Definitions +//////////////////////////////////////////////////////// +// +// Struct used to identify OPTITEM as feature OPTITEM and to map back +// from an OPTITEM to the feature. +// +typedef struct _tagFeatureOptItemData +{ + DWORD dwSize; + DWORD dwTag; + PCSTR pszFeatureKeyword; + CFeature *pFeature; + +} FEATUREOPTITEMDATA, *PFEATUREOPTITEMDATA; + +// +// Mapping of feature names to keywords +// +static CONST KEYWORDMAP gkmFeatureMap[] = +{ + {"RESDLL", NULL, IDS_RESDLL, OEMCUIP_PRNPROP}, + {"InputBin", TEXT("COMPSTUI.DLL"), IDS_CPSUI_SOURCE, OEMCUIP_DOCPROP}, + {"Orientation", TEXT("COMPSTUI.DLL"), IDS_CPSUI_ORIENTATION, OEMCUIP_DOCPROP}, + {"Resolution", TEXT("COMPSTUI.DLL"), IDS_CPSUI_RESOLUTION, OEMCUIP_DOCPROP}, + {"GraphicsMode", NULL, IDS_GRAPHICS_MODE, OEMCUIP_DOCPROP}, + {"PaperSize", TEXT("COMPSTUI.DLL"), IDS_CPSUI_FORMNAME, OEMCUIP_DOCPROP}, + {"MediaType", TEXT("COMPSTUI.DLL"), IDS_CPSUI_MEDIA, OEMCUIP_DOCPROP}, + {"ColorMode", TEXT("COMPSTUI.DLL"), IDS_CPSUI_COLOR_APPERANCE, OEMCUIP_DOCPROP}, + {"Halftone", TEXT("COMPSTUI.DLL"), IDS_CPSUI_HALFTONE, OEMCUIP_DOCPROP}, + {"DuplexUnit", NULL, IDS_DUPLEX_UNIT, OEMCUIP_PRNPROP}, + {"Duplex", TEXT("COMPSTUI.DLL"), IDS_CPSUI_DUPLEX, OEMCUIP_DOCPROP}, + {"Memory", NULL, IDS_INSTALLED_MEMORY, OEMCUIP_PRNPROP}, + {"OutputBin", TEXT("COMPSTUI.DLL"), IDS_CPSUI_OUTPUTBIN, OEMCUIP_DOCPROP}, + {"PageProtect", TEXT("COMPSTUI.DLL"), IDS_CPSUI_PAGEPROTECT, OEMCUIP_PRNPROP}, + {"%PagePerSheet", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP, OEMCUIP_DOCPROP}, + {"%PageOrder", TEXT("COMPSTUI.DLL"), IDS_CPSUI_PAGEORDER, OEMCUIP_DOCPROP}, + {"%PagesPerSheetOrdering", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_DIRECTION, OEMCUIP_DOCPROP}, + {"%PagesPerSheetBorder", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_BORDER, OEMCUIP_DOCPROP}, + {"%TextAsGraphics", NULL, IDS_TEXT_ASGRX, OEMCUIP_DOCPROP}, + {"%MetafileSpooling", NULL, IDS_METAFILE_SPOOLING, OEMCUIP_DOCPROP} +}; + +// +// Number of elements in the feature map table. +// +static const NUM_FEATURE_MAP = (sizeof(gkmFeatureMap)/sizeof(gkmFeatureMap[0])); + +// +// Mapping of option names to resources. A more complete driver would parse +// this mapping from the GDL file, rather than use hard-coded mappings. +// +static CONST KEYWORDMAP gkmOptionMap[] = +{ + {"ON", TEXT("COMPSTUI.DLL"), IDS_CPSUI_ON, 0}, + {"OFF", TEXT("COMPSTUI.DLL"), IDS_CPSUI_OFF, 0}, + {"NONE", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NONE, 0}, + {"None", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NONE, 0}, + {"True", TEXT("COMPSTUI.DLL"), IDS_CPSUI_TRUE, 0}, + {"False", TEXT("COMPSTUI.DLL"), IDS_CPSUI_FALSE, 0,}, + {"PORTRAIT", TEXT("COMPSTUI.DLL"), IDS_CPSUI_PORTRAIT, 0}, + {"LANDSCAPE", TEXT("COMPSTUI.DLL"), IDS_CPSUI_LANDSCAPE, 0}, + {"LANDSCAPE_CC90", TEXT("COMPSTUI.DLL"), IDS_CPSUI_ROT_LAND, 0}, + {"FORMSOURCE", TEXT("COMPSTUI.DLL"), IDS_CPSUI_FORMSOURCE, 0}, + {"UPPER", TEXT("COMPSTUI.DLL"), IDS_CPSUI_UPPER_TRAY, 0}, + {"AUTO", TEXT("COMPSTUI.DLL"), IDS_CPSUI_PRINTFLDSETTING, 0}, + {"Auto", TEXT("COMPSTUI.DLL"), IDS_CPSUI_PRINTFLDSETTING, 0}, + {"PLAIN", TEXT("COMPSTUI.DLL"), IDS_CPSUI_STANDARD, 0}, + {"TRANSPARENCY", TEXT("COMPSTUI.DLL"), IDS_CPSUI_TRANSPARENCY, 0}, + {"HORIZONTAL", TEXT("COMPSTUI.DLL"), IDS_CPSUI_HORIZONTAL, 0}, + {"VERTICAL", TEXT("COMPSTUI.DLL"), IDS_CPSUI_VERTICAL, 0}, + {"FrontToBack", TEXT("COMPSTUI.DLL"), IDS_CPSUI_FRONTTOBACK, 0}, + {"BackToFront", TEXT("COMPSTUI.DLL"), IDS_CPSUI_BACKTOFRONT, 0}, + {"1", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_NORMAL, 0}, + {"2", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_TWOUP, 0}, + {"4", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_FOURUP, 0}, + {"6", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_SIXUP, 0}, + {"9", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_NINEUP, 0}, + {"16", TEXT("COMPSTUI.DLL"), IDS_CPSUI_NUP_SIXTEENUP, 0}, + {"Booklet", TEXT("COMPSTUI.DLL"), IDS_CPSUI_BOOKLET, 0}, + {"RightThenDown", TEXT("COMPSTUI.DLL"), IDS_CPSUI_RIGHT_THEN_DOWN, 0}, + {"DownThenRight", TEXT("COMPSTUI.DLL"), IDS_CPSUI_DOWN_THEN_RIGHT, 0}, + {"LeftThenDown", TEXT("COMPSTUI.DLL"), IDS_CPSUI_LEFT_THEN_DOWN, 0}, + {"DownThenLeft", TEXT("COMPSTUI.DLL"), IDS_CPSUI_DOWN_THEN_LEFT, 0}, + {"UniresDLL", NULL, IDS_UNIRESDLL, 0}, + {"600dpi", NULL, IDS_RESOLUTION_600_DPI, 0}, + {"300dpi", NULL, IDS_RESOLUTION_300_DPI, 0}, + {"150dpi", NULL, IDS_RESOLUTION_150_DPI, 0}, + {"RASTERMODE", NULL, IDS_RASTERMODE, 0}, + {"HPGL2MODE", NULL, IDS_HPGL2MODE, 0}, + {"LETTER", NULL, IDS_PAPERSIZE_LETTER, 0}, + {"LEGAL", NULL, IDS_PAPERSIZE_LEGAL, 0}, + {"EXECUTIVE", NULL, IDS_PAPERSIZE_EXECUTIVE, 0}, + {"A4", NULL, IDS_PAPERSIZE_A4, 0}, + {"B5", NULL, IDS_PAPERSIZE_B5, 0}, + {"Mono", NULL, IDS_COLORMODE_MONO, 0}, + {"Color", TEXT("COMPSTUI.DLL"), IDS_CPSUI_COLOR_APPERANCE, 0}, + {"24bpp", NULL, IDS_COLORMODE_24BPP, 0}, + {"8bpp", NULL, IDS_COLORMODE_8BPP, 0}, + {"HT_PATSIZE_AUTO", NULL, IDS_HALFTONE_AUTO, 0}, + {"HT_PATSIZE_SUPERCELL_M", NULL, IDS_HALFTONE_SUPERCELL_M, 0}, + {"HT_PATSIZE_6x6_M", NULL, IDS_HALFTONE_6x6_M, 0}, + {"HT_PATSIZE_8x8_M", NULL, IDS_HALFTONE_8x8_M, 0}, + {"Option1", NULL, IDS_OUTBIN_DEFAULT, 0}, + {"Option14", NULL, IDS_OUTBIN_STACKER, 0}, + {"EnvTray", NULL, IDS_UIREP_ENVTRAY, 0}, + {"Automatic", NULL, IDS_TTDL_DEFAULT, 0}, + {"Outline", NULL, IDS_TTDL_TYPE1, 0}, + {"Bitmap", NULL, IDS_TTDL_TYPE3, 0}, + {"NativeTrueType", NULL, IDS_TTDL_TYPE42, 0}, + {"16384KB", NULL, IDS_MEMORY_STD, 0}, + {"32768KB", NULL, IDS_MEMORY_UPGRADE, 0} +}; + +// +// Number of elements in the option map table. +// +static const NUM_OPTION_MAP = (sizeof(gkmOptionMap)/sizeof(gkmOptionMap[0])); + +// +// Fall-back mapping for any feature or option that doesn't +// have a pre-defined display name. +// +KEYWORDMAP gDefaultMapping = {"", NULL, IDS_MISSINGNAME, OEMCUIP_DOCPROP}; + + +//+--------------------------------------------------------------------------- +// +// Member: +// COption::Acquire +// +// Synopsis: +// Load the option information as described in the mapping. +// +// +//---------------------------------------------------------------------------- +HRESULT +COption::Acquire( + HANDLE hHeap, + PCKEYWORDMAP pMapping + ) +{ + m_pMapping = pMapping; + m_hHeap = hHeap; + + return GetDisplayNameFromMapping(hHeap, m_pMapping, &m_pszDisplayName); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeaturePairs::ClearPair( +// +// Synopsis: +// Remove a feature-option pair entry from the set of feature / option +// pairs. +// +// +//---------------------------------------------------------------------------- +VOID +CFeaturePairs::ClearPair( + size_t iIndex + // Index of the feature-option pair to be removed. + ) +{ + if (m_pData[iIndex].pszFeature) + { + free((VOID*)m_pData[iIndex].pszFeature); + m_pData[iIndex].pszFeature = NULL; + } + + if (m_pData[iIndex].pszOption) + { + free((VOID*)m_pData[iIndex].pszOption); + m_pData[iIndex].pszOption = NULL; + } +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeaturePairs Constructor +// +// Synopsis: +// Create a feature-pairs object containing cElements entries, and +// initialize them all to NULL. +// +// +//---------------------------------------------------------------------------- +CFeaturePairs::CFeaturePairs( + size_t cElements + // number of elements to remove. + ) +{ + m_pData = NULL; + size_t cbFeatureOptions = 0; + m_cElements = 0; + + if (SUCCEEDED(SizeTMult(cElements, sizeof(PRINT_FEATURE_OPTION), &cbFeatureOptions))) + { + m_pData = new PRINT_FEATURE_OPTION[cElements]; + + if (m_pData) + { + m_cElements = cElements; + memset(m_pData, 0, cbFeatureOptions); + } + } +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeaturePairs destructor +// +// Synopsis: +// Release any memory used by this object +// +// +//---------------------------------------------------------------------------- +CFeaturePairs::~CFeaturePairs() +{ + if (m_pData) + { + for (size_t iPair = 0; iPair < m_cElements; iPair++) + { + ClearPair(iPair); + } + + delete m_pData; + } +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeaturePairs::SetPair +// +// Synopsis: +// Set the pair at the specified index to the specified value. Each +// pair represents a feature and a currently selected option for that +// feature. +// +// Returns: +// S_OK +// E_OUTOFMEMORY +// E_INVALIDARG if the index is out of of bounds. +// +// +//---------------------------------------------------------------------------- +HRESULT +CFeaturePairs::SetPair( + size_t iIndex, + // Index of the entry to set. + PCSTR pcszFeature, + // The name of the feature. This doesn't + // hold a pointer to the string passed in. + PCSTR pcszOption + // The name of the option. This doesn't + // hold a pointer to the string passed in. + ) +{ + + if (iIndex > m_cElements || !pcszFeature || !pcszOption) + { + return E_INVALIDARG; + } + + // + // Deferred error result from failed constructor... + // + if (!m_pData) + { + return E_OUTOFMEMORY; + } + + // + // Configure the data elements + // + m_pData[iIndex].pszFeature = new CHAR[strlen(pcszFeature)+1]; + m_pData[iIndex].pszOption = new CHAR[strlen(pcszOption)+1]; + + if (m_pData[iIndex].pszFeature && m_pData[iIndex].pszOption) + { + memcpy((PSTR)m_pData[iIndex].pszFeature, pcszFeature, (strlen(pcszFeature)+1)); + memcpy((PSTR)m_pData[iIndex].pszOption, pcszOption, (strlen(pcszOption)+1)); + return S_OK; + } + else + { + return E_OUTOFMEMORY; + } +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature::Clear +// +// Synopsis: +// Reset the option collection information to it's state before otions +// were acquired. +// +// +//---------------------------------------------------------------------------- + +VOID +CFeature::Clear() +{ + if (m_pOptions != NULL) + { + delete [] m_pOptions; + m_pOptions = NULL; + } + + if (m_pszDisplayName != NULL && !IS_INTRESOURCE(m_pszDisplayName)) + { + HeapFree(m_hHeap, 0, m_pszDisplayName); + } + + m_dwOptions = 0; + m_Sel = 0; + m_pszFeature = NULL; + m_hHeap = NULL; + m_pOptions = NULL; + m_pMapping = &gDefaultMapping; + m_pszDisplayName = NULL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature (constructor) +// +// Synopsis: +// Initialize the option collection to a default state. Does +// not acquire the options from the GPD / helper. +// +// +//---------------------------------------------------------------------------- +CFeature::CFeature() : + m_dwOptions(0), + m_Sel(0), + m_pszFeature(NULL), + m_hHeap(NULL), + m_pOptions(NULL), + m_pMapping(&gDefaultMapping), + m_pszDisplayName(NULL) +{ +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature (destructor) +// +// Synopsis: +// Clean up any memory we're holding. +// +// +//---------------------------------------------------------------------------- +CFeature::~CFeature() +{ + Clear(); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature::Acquire +// +// Synopsis: +// Populate the options in the collection using the +// supplied helper to acquire options for the specified +// feature. +// +// Returns: +// S_OK on success, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT +CFeature::Acquire( + _In_ HANDLE hHeap, + // The heap to make allocations from + _In_ IPrintCoreHelper* pHelper, + // Pointer to the Unidrv supplied helper object + _In_ PCSTR pszFeature + // The name of the feature to read settings for. + ) +{ + VERBOSE(DLLTEXT("CFeature::Acquire entry.")); + + HRESULT hrResult = S_OK; + PCSTR *ppszOptions = NULL; + + // + // Don't retreive the Options again if we already got them. + // + if ((m_dwOptions > 0) && + (m_pszFeature != NULL) && + !lstrcmpA(m_pszFeature, pszFeature)) + { + WARNING(DLLTEXT("CFeature::Acquire: Already have options for feature %hs. Returning S_OK.\r\n"), m_pszFeature); + return S_OK; + } + + // + // Save the heap handle for use later, such as freeing memory at destruction. + // + m_hHeap = hHeap; + + // + // Store Keyword string. + // + m_pszFeature = pszFeature; + + // + // Get or build a keyword mapping entry that + // maps from keyword to info such as display name & + // whether the feature is a device setting or document + // setting. + // + m_pMapping = GetKeywordMapping(gkmFeatureMap, NUM_FEATURE_MAP, pszFeature); + + // + // Get the display name for this feature + // + hrResult = GetDisplayNameFromMapping(hHeap, m_pMapping, &m_pszDisplayName); + + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("CFeature::Acquire: Failed to get display name for feature %hs with error code 0x%x!\r\n"), + pszFeature, + hrResult); + goto Exit; + } + + // + // Enumerate Options. + // + hrResult = pHelper->EnumOptions(m_pszFeature, + &ppszOptions, + &m_dwOptions + ); + + // + // Make sure we got the option list. + // Can't do anything more with out it. + // + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("CFeature::Acquire: Failed to enumerate options for feature %hs. (hrResult = 0x%x)\r\n"), m_pszFeature, hrResult); + goto Exit; + } + + // + // Build COption + // + m_pOptions = new COption[m_dwOptions]; + + if (m_pOptions == NULL) + { + ERR(ERRORTEXT("COption::Acquire: Failed to allocate memory for option info array!\r\n")); + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // + // For each option, build and/or get useful info like display name etc. + // + for (DWORD dwIndex = 0; dwIndex < m_dwOptions; dwIndex++) + { + PCKEYWORDMAP pMapping = + GetKeywordMapping(gkmOptionMap, NUM_OPTION_MAP, ppszOptions[dwIndex]); + + // + // Get or build a keyword mapping entry that + // maps from keyword to info such as display name, + // icon, option type etc. which we can't get from + // the helper interface + // + hrResult = m_pOptions[dwIndex].Acquire(m_hHeap, + pMapping); + + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("CFeature::Acquire: Failed to load information for option %hs of feature %hs with error code 0x%x!\r\n"), + ppszOptions[dwIndex], + m_pszFeature, + hrResult); + goto Exit; + } + } + + // + // Get current option selection. + // + if(SUCCEEDED(hrResult) && m_dwOptions > 0) + { + hrResult = RefreshSelection(pHelper); + } + +Exit: + + // + // Cleanup if weren't successful + // + if (!SUCCEEDED(hrResult)) + { + Clear(); + } + + return hrResult; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature::GetOption +// +// Synopsis: +// Get a reference to the description of the option at the specified index. +// +// Returns: +// A pointer to the requested option if available, otherwise NULL. +// +// +//---------------------------------------------------------------------------- +CONST COption * +CFeature::GetOption( + DWORD dwIndex + // Index of the option for which the display name is requested. + ) const +{ + VERBOSE(DLLTEXT("CFeature::GetOption entry.")); + + if ((dwIndex >= m_dwOptions) || (m_pOptions == NULL)) + { + ERR(ERRORTEXT("CFeature::GetOption: Invalid parameters!\r\n")); + return NULL; + } + + return &(m_pOptions[dwIndex]); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature::FindOption +// +// Synopsis: +// Find the index of the option with the specified keyword. If no such +// option exists, this routine returns the specified result instead. +// +// +//---------------------------------------------------------------------------- +_Success_(return != FALSE) BOOL +CFeature::FindOption( + _In_ PCSTR pszOption, + // The name of the option to look for + _Out_ DWORD *pdwOption + // The index of the default option to use if the name isn't found + ) const +{ + VERBOSE(DLLTEXT("CFeature::FindOption entry.")); + + BOOL bFound = FALSE; + + // + // Validate parameters + // + if (pszOption == NULL || + pdwOption == NULL) + { + return FALSE; + } + + // + // Walk the option keyword looking for a match. + // + for(DWORD dwIndex = 0; !bFound && (dwIndex < m_dwOptions); dwIndex++) + { + bFound = !lstrcmpA(pszOption, m_pOptions[dwIndex].GetKeyword()); + + if(bFound) + { + *pdwOption = dwIndex; + } + } + + return bFound; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature::InitOptItem +// +// Synopsis: +// Configure the provided OPTITEM with the options in this collection. +// +// Returns: +// +// Notes: +// +// +//---------------------------------------------------------------------------- +HRESULT +CFeature::InitOptItem( + _In_ HANDLE hHeap, + // The heap to allocate memory from. + _Inout_ POPTITEM pOptItem + // The optitem struct being initialized. + ) +{ + VERBOSE(DLLTEXT("CFeature::InitOptItem entry.")); + + HRESULT hrResult = S_OK; + + // + // Add feature OPTITEM data to OPTITEM to facilitate saving + // selection changes + // + PFEATUREOPTITEMDATA pData = + (PFEATUREOPTITEMDATA)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(FEATUREOPTITEMDATA)); + + if (pData == NULL) + { + ERR(ERRORTEXT("CFeatureCollection::InitOptItem: Failed to allocated memory for feature OPTITEM data.")); + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // + // Configure the callback data structure + // + pData->dwSize = sizeof(FEATUREOPTITEMDATA); + pData->dwTag = FEATURE_OPTITEM_TAG; + pData->pszFeatureKeyword = this->GetKeyword(); + pData->pFeature = this; + + // + // Configure the optitem + // + pOptItem->UserData = (ULONG_PTR)pData; + pOptItem->pName = const_cast(this->GetDisplayName()); + pOptItem->Sel = m_Sel; + + // + // If there's only 1 option, mark the feature as disabled. + // + if (GetCount() > 1) + { + pOptItem->Flags = 0; + } + else + { + pOptItem->Flags |= OPTIF_DISABLED; + } + + // + // Only create options if there are options defined + // for this feature. + // + if (GetCount() > 0) + { + // + // Allocate memory for feature options. + // + pOptItem->pOptType = CreateOptType(hHeap, (WORD)GetCount()); + + if (pOptItem->pOptType == NULL) + { + ERR(ERRORTEXT("CFeature::InitOptItem: Failed to allocate OPTTYPEs for OPTITEM %hs!\r\n"), + this->GetKeyword()); + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // + // Set OPTTYPE type & display string for each OPTPARAM in the ot + // + pOptItem->pOptType->Type = TVOT_COMBOBOX; + + for (DWORD dwIndex = 0; dwIndex < GetCount(); dwIndex++) + { + pOptItem->pOptType->pOptParam[dwIndex].pData = const_cast(this->GetOption(dwIndex)->GetDisplayName()); + } + } + +Exit: + + return hrResult; + +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeature::RefreshSelection +// +// Synopsis: +// Synchronize the currently selected option with the option +// that Unidrvui recognizes as being selected. +// +// Returns: +// S_OK on success, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT +CFeature::RefreshSelection( + _In_ IPrintCoreHelper *pHelper + // Pointer to the Unidrv supplied helper object + ) +{ + VERBOSE(DLLTEXT("CFeature::RefreshSelection entry.")); + + PCSTR pszSel = NULL; + HRESULT hrResult = S_OK; + + // + // Get current option selection. + // + hrResult = pHelper->GetOption(NULL, 0, m_pszFeature, &pszSel); + + if(SUCCEEDED(hrResult)) + { + if (!FindOption(pszSel, &m_Sel)) + { + // + // The option name should always match something in the option + // array. If for some reason that's not the case, default + // back to option 0. + // + WARNING(ERRORTEXT("CFeature::RefreshSelection: Failed to find selected option!\r\n")); + m_Sel = 0; + } + } + else if(hrResult == E_FAIL) + { + // + // GetOption fails with E_FAIL when trying to read document- + // sticky options if the printer preferences is being shown. + // Hide the error & default the selection. The feature won't + // be shown in the UI. + // + m_Sel = 0; + hrResult = S_OK; + } + + return hrResult; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeatureCollection::Clear +// +// Synopsis: +// Release any memory associated with this feature collection and reset +// values to defaults. +// +// +//---------------------------------------------------------------------------- +VOID +CFeatureCollection::Clear() +{ + // + // feature info array allocated with new so + // that each of the constructors for CFeature + // will be called. + // + if (m_pFeatures) + { + delete [] m_pFeatures; + } + + // + // Re-initialize + // + m_dwFeatures = 0; + m_dwDocFeatures = 0; + m_dwPrintFeatures = 0; + m_hHeap = NULL; + m_pFeatures = NULL; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeatureCollection::GetModelessIndex +// +// Synopsis: +// Get the absolute index of the feature, assuming the index provided is +// for the specified mode. This if there are three features, +// +// DocFeature1 +// DocFeature2 +// PrinterFeature1 +// +// If this routine is called with index 0, and mode OEMCUIP_PRNPROP, +// it will return the absolute index of the first printer-sticky feature, +// which in this case would be 2 (remember, the first index is 0). +// +// +//---------------------------------------------------------------------------- +DWORD +CFeatureCollection::GetModelessIndex( + DWORD dwIndex, + // The index relative to the specified mode. + DWORD dwMode + // The mode for which the index applies. See synopsis above for + // a more detailed explanation of mode. + ) const +{ + DWORD dwCount = 0; + + switch(dwMode) + { + // + // Number of features, all modes + // + case 0: + dwCount = dwIndex; + break; + + case OEMCUIP_DOCPROP: + case OEMCUIP_PRNPROP: + // + // Walk the feature list looking for the nth feature + // with matching mode + // + for (dwCount = 0; dwCount < m_dwFeatures; dwCount++) + { + // + // Count down to the feature we want + // Only countdown for matching modes + // + if (dwMode == m_pFeatures[dwCount].GetMode()) + { + if (dwIndex == 0) + { + break; + } + else + { + --dwIndex; + } + } + } + break; + } + + return dwCount; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeatureCollection (constructor) +// +// Synopsis: +// +// +//---------------------------------------------------------------------------- +CFeatureCollection::CFeatureCollection() : + m_dwFeatures(0), + m_dwDocFeatures(0), + m_dwPrintFeatures(0), + m_hHeap(NULL), + m_pFeatures(NULL) +{ +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeatureCollection (destructor) +// +// Synopsis: +// Release all resources held by this object +// +// +//---------------------------------------------------------------------------- +CFeatureCollection::~CFeatureCollection() +{ + // + // Clean up class. + // + Clear(); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeatureCollection::Acquire +// +// Synopsis: +// Load all of the features supported by unidrv as well as those specified +// in the GPD using the provided helper object +// +// Returns: +// S_OK on success else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT +CFeatureCollection::Acquire( + HANDLE hHeap, + // The heap from which any allocations should be made + IPrintCoreHelper *pHelper + // The helper object that provides access to the core driver features. + ) +{ + VERBOSE(DLLTEXT("CFeatureCollection::Acquire entry.")); + + HRESULT hrResult = S_OK; + + PCSTR *ppszKeywords = NULL; + // String list that points to each feature keyword + + // + // Don't retreive the Features again if we already got them. + // + if (m_dwFeatures > 0) + { + WARNING(DLLTEXT("CFeatureCollection::Acquire: Features have already been enumerated. Returning S_OK.\r\n")); + return S_OK; + } + + // Save the heap handle for use later, such as freeing memory at destruction. + m_hHeap = hHeap; + + // Enumerate features. + hrResult = pHelper->EnumFeatures(&ppszKeywords, &m_dwFeatures); + + if (FAILED(hrResult)) + { + ERR(ERRORTEXT("CFeatureCollection::Acquire() failed to enumerate features. (hrResult = 0x%x)\r\n"), hrResult); + } + else + { + // + // Build Feature information + // + m_pFeatures = new CFeature[m_dwFeatures]; + + if (m_pFeatures == NULL) + { + ERR(ERRORTEXT("CFeatureCollection::Acquire: Failed to allocate feature info array!\r\n")); + hrResult = E_OUTOFMEMORY; + } + + // + // For each feature, build/get feature info + // + for (DWORD dwIndex = 0; SUCCEEDED(hrResult) && dwIndex < m_dwFeatures ; dwIndex++) + { + // + // Get options for each feature + // Note: Some features don't have options, the HRESULT will be E_NOTIMPL for these + // + hrResult = m_pFeatures[dwIndex].Acquire(hHeap, + pHelper, + ppszKeywords[dwIndex]); + + if (!SUCCEEDED(hrResult) && (hrResult != E_NOTIMPL)) + { + ERR(ERRORTEXT("CFeatureCollection::Acquire: Failed to get options for feature %hs with error code 0x%x!\r\n"), + ppszKeywords[dwIndex], + hrResult); + } + + // + // Keep track of mode counts + // + if (SUCCEEDED(hrResult)) + { + switch(m_pFeatures[dwIndex].GetMode()) + { + case OEMCUIP_DOCPROP: + ++m_dwDocFeatures; + break; + + case OEMCUIP_PRNPROP: + ++m_dwPrintFeatures; + break; + + default: + ERR(ERRORTEXT("CFeatureCollection::Acquire: Unknown stickiness for feature %hs!\r\n"), + ppszKeywords[dwIndex]); + break; + } + } + } + } + + // + // Clean up if we weren't successful + // + if (FAILED(hrResult)) + { + Clear(); + } + + return hrResult; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeatureCollection::GetCount +// +// Synopsis: +// Get the number of features in the collection. +// +// +//---------------------------------------------------------------------------- +DWORD +CFeatureCollection::GetCount( + DWORD dwMode + // Should this routine count the doc-sticky features, printer sticky + // features, or both? + ) CONST +{ + DWORD dwCount = 0; + + switch(dwMode) + { + case 0: + dwCount = m_dwFeatures; + break; + + case OEMCUIP_DOCPROP: + dwCount = m_dwDocFeatures; + break; + + case OEMCUIP_PRNPROP: + dwCount = m_dwPrintFeatures; + break; + } + + return dwCount; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// CFeatureCollection::GetFeature +// +// Synopsis: +// Get the options for the feature at the specified index. +// +// +//---------------------------------------------------------------------------- +CFeature* +CFeatureCollection::GetFeature( + DWORD dwIndex, + // The index of the feature to look up. + DWORD dwMode + // The mode associated with the feature index. + ) const +{ + // + // Validate parameters + // + if ((dwIndex >= GetCount(dwMode)) || (m_pFeatures == NULL)) + { + return NULL; + } + + // + // Get internal index + // + dwIndex = GetModelessIndex(dwIndex, dwMode); + + // + // Return options pointer + // + return &(m_pFeatures[dwIndex]); +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::GetDisplayNameFromMapping +// +// Synopsis: +// Load the string resource associated with the specified mapping entry. +// +// Returns: +// S_OK on success, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT +GetDisplayNameFromMapping( + _In_ HANDLE hHeap, + // The heap to perform allocations from + _In_ PCKEYWORDMAP pMapping, + // The mapping element for the element. Could be a feature or option. + _Out_ PWSTR *ppszDisplayName + // The location where this routine supplies the display name to the + // caller. + ) +{ + HMODULE hModule = NULL; + HRESULT hrResult = S_OK; + + VERBOSE(DLLTEXT("GetDisplayNameFromMapping entry.")); + + if ((hHeap == NULL) || (pMapping == NULL) || (ppszDisplayName == NULL)) + { + return E_INVALIDARG; + } + + // + // Check for simple case of returning INT resource + // + if (pMapping->pwszModule == NULL) + { + // + // Just need to do MAKEINTRESOURCE on the resource ID and return + // + *ppszDisplayName = MAKEINTRESOURCE(pMapping->uDisplayNameID); + } + else + { + // + // We need to get the module name if we aren't loading the + // resource from this module (pwszModule != NULL). As an + // optimization, we assume that the module has already been loaded, + // since the only cases currently are this module, driver ui and compstui.dll. + // + hModule = GetModuleHandle(pMapping->pwszModule); + + if (hModule == NULL) + { + DWORD dwError = GetLastError(); + + ERR(ERRORTEXT("GetDisplayNameFromMapping: Failed to load module %s with error code %d!\r\n"), + pMapping->pwszModule, + dwError); + + hrResult = HRESULT_FROM_WIN32(dwError); + + // + // In case last error wasn't set correctly, force it to an error value. + // + if (SUCCEEDED(hrResult)) + { + hrResult = E_FAIL; + } + } + + // + // Get the string resource + // + if (SUCCEEDED(hrResult)) + { + hrResult = GetStringResource(hHeap, hModule, pMapping->uDisplayNameID, ppszDisplayName); + if (FAILED(hrResult)) + { + ERR(ERRORTEXT("GetDisplayNameFromMapping: Failed to load string with error code 0x%x!\r\n"), hrResult); + } + } + } + + return hrResult; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// ::GetKeywordMapping +// +// Synopsis: +// Find the mapping in the provided table associated with the specified +// keyword. This routine can be used to look up both feature & option +// mappings. +// +// Returns: +// The requested mapping on success, otherwise NULL. +// +// +//---------------------------------------------------------------------------- +PCKEYWORDMAP +GetKeywordMapping( + _In_reads_(dwMapSize) PCKEYWORDMAP pKeywordMap, + // The mapping table to search in + DWORD dwMapSize, + // Number of elements in the mapping table. + PCSTR pszKeyword + // Keyword to look for in the table. + ) +{ + BOOL bFound = FALSE; + PCKEYWORDMAP pMapping = &gDefaultMapping; + + if ((pKeywordMap != NULL) && (pszKeyword != NULL)) + { + // + // Walk mapping array for matching keyword + // + for (DWORD dwIndex = 0; !bFound && (dwIndex < dwMapSize); dwIndex++) + { + bFound = !lstrcmpA(pszKeyword, pKeywordMap[dwIndex].pszKeyword); + + if (bFound) + { + pMapping = pKeywordMap + dwIndex; + } + } + } + + return pMapping; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// ::IsFeatureOptItem +// +// Synopsis: +// Test if an OPTITEM is an OPTITEM for a feature. +// +// Returns: +// TRUE if the OPTITEM represents a feature, else FALSE. +// +// +//---------------------------------------------------------------------------- +BOOL +IsFeatureOptItem( + POPTITEM pOptItem + // The otitem to check + ) +{ + BOOL bRet = FALSE; + PFEATUREOPTITEMDATA pData = NULL; + + + // Make sure pointers are NULL. + if( (NULL == pOptItem) + || + (NULL == pOptItem->UserData) + ) + { + // + // INVARIANT: can't be feature OPTITEM, since one of + // the necessary pointer are NULL. + // + + return FALSE; + } + + // For convienience, assign to pointer to feature OPTITEM data. + pData = (PFEATUREOPTITEMDATA)(pOptItem->UserData); + + // Check size and tag. + bRet = (sizeof(FEATUREOPTITEMDATA) == pData->dwSize) + && + (FEATURE_OPTITEM_TAG == pData->dwTag); + + return bRet; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::SaveFeatureOptItems +// +// Synopsis: +// Walks array of OPTITEMs saving each feature OPTITEM +// that has changed. +// +// Returns: +// S_OK on success, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT +SaveFeatureOptItems( + HANDLE hHeap, + // The heap to perform allocations from + IPrintCoreHelper* pHelper, + // Pointer to the Unidrv supplied helper object + HWND hWnd, + // The current window object. Used as the parent of any model dialogs / + // message boxes displayed from this routine. + _In_reads_(dwItems) POPTITEM pOptItem, + // The option items to save + DWORD dwItems + // The number of optitems in the array + ) +{ + VERBOSE(DLLTEXT("SaveFeatureOptItems entry.")); + + DWORD dwPairsWritten = 0; + DWORD dwResult = 0; + HRESULT hrResult = S_OK; + CFeaturePairs *pPairs = NULL; + + // + // Validate parameters + // + if (!(hHeap && pHelper && pOptItem)) + { + ERR(ERRORTEXT("SaveFeatureOptItems: Invalid arguments!\r\n")); + return E_INVALIDARG; + } + + // + // Get feature option pairs to save + // + hrResult = GetChangedFeatureOptions(pOptItem, dwItems, &pPairs); + + if(FAILED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems: Failed to get changed feature option pairs! (error code 0x%x)\r\n"), + hrResult); + } + + // + // Only update options if something changed. + // + if (SUCCEEDED(hrResult) && + pPairs && + pPairs->GetElementCount() > 0) + { + + // + // Set the change feature options. + // For the first SetOptions() call, don't have the + // core driver UI resolve conflicts, so we can + // prompt user for automatic resolution or let + // them do the conflict resolving. + // + hrResult = pHelper->SetOptions(NULL, + 0, + FALSE, + pPairs->GetData(), + (DWORD)pPairs->GetElementCount(), + &dwPairsWritten, + &dwResult); + + if(FAILED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems: SetOptions failed with dwResult = %d! (hrResult = 0x%x)\r\n"), + dwResult, + hrResult); + } + else if(SETOPTIONS_RESULT_CONFLICT_REMAINED == dwResult) + { + // + // SetOptions succeeded, but there was a conflict in the selected + // options that was not resolved. Ask the user if they'd like the + // plug-in to resolve the conflict for them. + // + int nRet; + CONST PRINT_FEATURE_OPTION *pConflicts; + DWORD dwConflicts; + PWSTR pszMessage = NULL; + + hrResult = GetStringResource(hHeap, ghInstance, IDS_CONSTRAINT_CONFLICT, &pszMessage); + if(FAILED(hrResult)) + { + ERR(ERRORTEXT("SaveFeatureOptItems: Failed to load conflict resource string (error code 0x%x)\r\n"), + hrResult); + } + + // + // INVARIANT: constraint conflict, options weren't saved. + // + // Get list of all features that have conflict. + // + if (SUCCEEDED(hrResult)) + { + hrResult = GetFirstConflictingFeature(pHelper, + pOptItem, + dwItems, + &pConflicts, + &dwConflicts); + + if (SUCCEEDED(hrResult) && dwConflicts == 0) + { + hrResult = E_FAIL; + ERR(ERRORTEXT("SaveFeatureOptItems: Driver indicated conflict, but didn't provide conflicting options!\r\n")); + } + + if(FAILED(hrResult)) + { + ERR(ERRORTEXT("GetFirstConflictingFeature failed!")); + } + } + + if (SUCCEEDED(hrResult)) + { + // + // Display simple message box with prompt + // + nRet = MessageBox(hWnd, + pszMessage, + L"UI Replacement Test", + MB_YESNO | MB_ICONWARNING); + + // + // Check to see how user wants to resolve conflict + // + if(nRet == IDYES) + { + // + // Let core driver resolve conflict resolution + // + hrResult = pHelper->SetOptions(NULL, + 0, + TRUE, + pPairs->GetData(), + (DWORD)pPairs->GetElementCount(), + &dwPairsWritten, + &dwResult); + + // + // Conflict resolution requires refreshing current option + // selection for each feature, since selection may have + // changed because of conflict resolution. + // + if (SUCCEEDED(hrResult)) + { + RefreshOptItemSelection(pHelper, pOptItem, dwItems); + } + } + + // + // Return failure if there are still conflicts + // + if(dwResult == SETOPTIONS_RESULT_CONFLICT_REMAINED) + { + ERR(ERRORTEXT("SaveFeatureOptItems: Conflicts still exist even after calling core driver to resolve them!")); + hrResult = E_FAIL; + } + } + + if(pszMessage != NULL) + { + HeapFree(hHeap, 0, pszMessage); + } + } + } + + // + // Clean up + // + + if (pPairs) + { + delete pPairs; + } + + return hrResult; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// GetChangedFeatureOptions +// +// Synopsis: +// Creates a collection of all of the features that have changed in the +// provided collection of OPTITEMs +// +// Returns: +// S_OK on success, else E_*. +// +// Notes: +// if no settings have been changed, the routine may return S_OK +// and *ppPairs == NULL. +// +// +//---------------------------------------------------------------------------- +HRESULT +GetChangedFeatureOptions( + _In_reads_(dwItems) POPTITEM pOptItem, + // The array of optitems to search through + DWORD dwItems, + // The number of optitems in the provided array + _Outptr_result_maybenull_ CFeaturePairs **ppPairs + // feature / option keyword pairs describing the options that + // have changed. + ) +{ + VERBOSE(DLLTEXT("GetChangedFeatureOptions entry.")); + + DWORD dwCount = 0; + DWORD dwChanged = 0; + HRESULT hrResult = S_OK; + CFeaturePairs *pPairs; + + *ppPairs = NULL; + + // + // Walk OPTITEM array looking or changed options, + // and calculating size needed for multi-sz buffer. + // + for (dwCount = 0; dwCount < dwItems; dwCount++) + { + // + // Just go to next item if this OPTITEM hasn't + // changed or isn't a feature OPTITEM + // + if ((OPTIF_CHANGEONCE & pOptItem[dwCount].Flags) && + IsFeatureOptItem(&(pOptItem[dwCount])) + ) + { + ++dwChanged; + } + } + + // + // Don't need to do anything more if no feature options changed. + // + if(dwChanged != 0) + { + pPairs = new CFeaturePairs(dwChanged); + + if (pPairs == NULL || + pPairs->GetElementCount() == 0 + ) + { + ERR(ERRORTEXT("GetChangedFeatureOptions: Failed to allocate feature-option array!\r\n")); + hrResult = E_OUTOFMEMORY; + + if ( pPairs ) + { + delete pPairs; + pPairs = NULL; + } + + } + + // + // Build array of feature option pairs that changed + // + for (dwCount = 0; + SUCCEEDED(hrResult) && (dwCount < dwItems) && dwChanged; + dwCount++) + { + // + // Just go to next item if this OPTITEM hasn't + // changed or isn't a feature OPTITEM + // + if((OPTIF_CHANGEONCE & pOptItem[dwCount].Flags) && + IsFeatureOptItem(&(pOptItem[dwCount])) + ) + { + // + // For convienience, assign to pointer to feature OPTITEM data + // + PFEATUREOPTITEMDATA pData = (PFEATUREOPTITEMDATA)(pOptItem[dwCount].UserData); + + // + // Add feature option pair + // + PCSTR pszOption = GetOptionKeywordFromOptItem(&pOptItem[dwCount]); + + if (pszOption != NULL) + { + --dwChanged; + hrResult = pPairs->SetPair(dwChanged, pData->pszFeatureKeyword, pszOption); + } + } + } + + if(SUCCEEDED(hrResult)) + { + *ppPairs = pPairs; + } + else if (pPairs) + { + delete pPairs; + } + } + + return hrResult; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::GetOptionKeywordFromOptItem +// +// Synopsis: +// Returns pointer to option keyword for a feature OPTITEM +// +// Returns: +// The requested string on success, otherwise NULL +// +// +//---------------------------------------------------------------------------- +PCSTR +GetOptionKeywordFromOptItem( + POPTITEM pOptItem + // The opt item from which the keyword shoudl be read + ) +{ + VERBOSE(DLLTEXT("GetOptionKeywordFromOptItem entry.")); + + PCSTR pszOption = NULL; + + // + // Validate parameters + // + if(!IsFeatureOptItem(pOptItem)) + { + ERR(ERRORTEXT("GetOptionKeywordFromOptItem: Invalid parameter!\r\n")); + } + else if(pOptItem->pOptType->Type != TVOT_COMBOBOX) + { + ERR(ERRORTEXT("GetOptionKeywordFromOptItem: OPTTYPE type %d number of OPTPARAMS not handled!\r\n"), + pOptItem->pOptType->Type); + } + else + { + // + // Option selection is based on type of OPTTYPE + // + PFEATUREOPTITEMDATA pData = ((PFEATUREOPTITEMDATA)(pOptItem->UserData)); + CONST COption *pOption = pData->pFeature->GetOption((DWORD)pOptItem->Sel); + + if (pOption) + { + pszOption = pOption->GetKeyword(); + } + else + { + ERR(ERRORTEXT("GetOptionKeywordFromOptItem: Invalid option index %d!\r\n"), (DWORD)pOptItem->Sel); + } + } + + return pszOption; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::RefreshOptItemSelection +// +// Synopsis: +// For each feature update the currently selected option with the value +// that the core driver has selected. This is useful for updating the +// UI after resolving constraints. +// +// Returns: +// S_OK on success, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT +RefreshOptItemSelection( + IPrintCoreHelper *pHelper, + // Pointer to the Unidrv supplied helper object + _In_reads_(dwItems) POPTITEM pOptItems, + // An array of options to update + DWORD dwItems + // The number of options in the provided array + ) +{ + HRESULT hrResult = S_OK; + PFEATUREOPTITEMDATA pData = NULL; + + // + // Walk OPTITEM array refreshing feature OPTITEMs + // + for (DWORD dwCount = 0; dwCount < dwItems; dwCount++) + { + // + // Just go to next item if this OPTITEM isn't a feature OPTITEM + // + if (!IsFeatureOptItem(pOptItems + dwCount)) + { + continue; + } + + // + // For convienience, assign to pointer to feature OPTITEM data + // + pData = (PFEATUREOPTITEMDATA)(pOptItems[dwCount].UserData); + + // + // Refresh COption selection + // + pData->pFeature->RefreshSelection(pHelper); + + // + // Assign COption selection to OPTITEM selection + // + pOptItems[dwCount].Sel = pData->pFeature->GetSelection(); + } + + return hrResult; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// ::GetFirstConflictingFeature +// +// Synopsis: +// Finds the first features that it finds to be in conflict with one +// another and supplies those features in the ppConstraints parameter +// +// Returns: +// S_OK on success, else E_*. Note that this routine can succeed even +// if no features are in conflict. In that case, *ppConstraints will +// be NULL. +// +// +//---------------------------------------------------------------------------- +HRESULT +GetFirstConflictingFeature( + IPrintCoreHelper *pHelper, + // Pointer to the Unidrv supplied helper object + _In_reads_(dwItems) POPTITEM pOptItem, + // The array of options to look for a conflict in + DWORD dwItems, + // The number of options in the array + CONST PRINT_FEATURE_OPTION **ppConstraints, + // If any constraints are found, supplies pairs of + // feature / option keywords to the caller indicating + // which options cannot be used together. + DWORD *pdwConstraints + // The number of constrained options + ) +{ + VERBOSE(DLLTEXT("GetFirstConflictingFeature entry.")); + + DWORD dwCount = 0; + HRESULT hrResult = S_OK; + PCSTR pszOptionKeyword = NULL; + + *ppConstraints = NULL; + + // + // Walk OPTITEM array looking for changed options that are in conflict + // + for (dwCount = 0; dwCount < dwItems; dwCount++) + { + // + // Just go to next item if this OPTITEM hasn't + // changed or isn't a feature OPTITEM + // + if(!(OPTIF_CHANGEONCE & pOptItem[dwCount].Flags) || + !IsFeatureOptItem(&(pOptItem[dwCount])) + ) + { + continue; + } + + PFEATUREOPTITEMDATA pData = (PFEATUREOPTITEMDATA)(pOptItem[dwCount].UserData); + + // + // Init conflict record if this feature is in conflict + // + pszOptionKeyword = GetOptionKeywordFromOptItem(&pOptItem[dwCount]); + + if (pszOptionKeyword != NULL) + { + // + // Get reason for conflict + // + hrResult = pHelper->WhyConstrained(NULL, + 0, + pData->pszFeatureKeyword, + pszOptionKeyword, + ppConstraints, + pdwConstraints); + + if (FAILED(hrResult)) + { + ERR(ERRORTEXT("GetConflictingFeatures: Failed to get reason for feature %hs option %hs constraint! (hrResult = 0x%x)\r\n"), + pData->pszFeatureKeyword, + pszOptionKeyword, + hrResult); + break; + } + + if (*pdwConstraints > 0) + { + break; + } + } + } + + return hrResult; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// CreateOptType +// +// Synopsis: +// Allocates and initializes OptType for OptItem & OPTPARAMs for the +// options under that struct. +// +// Returns: +// A newly allocated POPTYPE from the specified heap on success, else +// NULL. +// +// +//---------------------------------------------------------------------------- +POPTTYPE +CreateOptType( + HANDLE hHeap, + // heap to allocate the type from. + WORD wOptParams + // The number of options available for this feature. + ) +{ + VERBOSE(DLLTEXT("CreateOptType entry.")); + + POPTTYPE pOptType = NULL; + // out parameter containing the allocated type struct & array of options. + + // + // Allocate memory from the heap for the OPTTYPE; the driver will take + // care of clean up. + // + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + + if(NULL != pOptType) + { + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, + HEAP_ZERO_MEMORY, + wOptParams * sizeof(OPTPARAM)); + + if(NULL != pOptType->pOptParam) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + // Free allocated memory and return NULL. + ERR(ERRORTEXT("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n")); + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR(ERRORTEXT("CreateOptType() failed to allocated memory for OPTTYPE!\r\n")); + } + + return pOptType; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::GetStringResource +// +// Synopsis: +// Load a string from the resource section of hte specied module. +// +// Returns: +// S_OK on failure, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT +GetStringResource( + _In_ HANDLE hHeap, + // Heap to allocate space for the resource from. + _In_ HMODULE hModule, + // Module to load the resource from + UINT uResource, + // resource ID + _Out_ PWSTR *ppszString + // out pointer to string resource loaded. + ) +{ + VERBOSE(DLLTEXT("GetStringResource entry.")); + + HRESULT hr = S_OK; + + // + // Allocate buffer for string resource from heap; + // let the driver clean it up. + // + *ppszString = NULL; + *ppszString = (PTSTR) HeapAlloc(hHeap, + HEAP_ZERO_MEMORY, + MAX_PATH * sizeof(TCHAR)); + + if(NULL != *ppszString) + { + // + // Load string resource; resize after loading so + // as not to waste memory. + // + INT nResult = LoadString(hModule, + uResource, + *ppszString, + MAX_PATH); + + if( nResult > 0) + { + PWSTR pszTemp = (PWSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, *ppszString, (nResult + 1) * sizeof(WCHAR)); + + if (NULL != pszTemp) + { + *ppszString = pszTemp; + } + else + { + // + // a realloc failure doesn't free the original string, so + // re-alloc failing in this case is not critical. + // + VERBOSE(ERRORTEXT("GetStringResource() HeapReAlloc() of string retrieved failed! (Last Error was %d)\r\n"), GetLastError()); + } + } + else + { + ERR(ERRORTEXT("LoadString() returned %d! (Last Error was %d)\r\n"), nResult, GetLastError()); + ERR(ERRORTEXT("GetStringResource() failed to load string resource %d!\r\n"), uResource); + HeapFree(hHeap, 0, *ppszString); + *ppszString = NULL; + hr = E_FAIL; + } + } + else + { + ERR(ERRORTEXT("GetStringResource() failed to allocate string buffer!\r\n")); + hr = E_OUTOFMEMORY; + } + + return hr; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.h b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.h new file mode 100644 index 00000000..adab6eec --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/Features.h @@ -0,0 +1,388 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: Features.h +// +// PURPOSE: Defines wrapper class for WinXP PS Features and Options. +// +//-------------------------------------------------------------------------- + +#pragma once + +//////////////////////////////////////////////////////// +// Type Definitions +//////////////////////////////////////////////////////// + +// +// Struct used to map keyword to information +// such as display name and stickiness. +// +typedef struct _tagKeywordMap +{ + PCSTR pszKeyword; + PCWSTR pwszModule; + UINT uDisplayNameID; + DWORD dwMode; + +} KEYWORDMAP, *PKEYWORDMAP; + +typedef CONST KEYWORDMAP *PCKEYWORDMAP; + + +//////////////////////////////////////////////////////// +// Class Definitions +//////////////////////////////////////////////////////// + + +// +// Option Infomation +// +class COption +{ +private: + PCKEYWORDMAP m_pMapping; + PWSTR m_pszDisplayName; + HANDLE m_hHeap; + +public: + COption() + : + m_pMapping(NULL), + m_pszDisplayName(NULL), + m_hHeap(NULL) + { + } + + virtual ~COption() + { + if (m_hHeap && m_pszDisplayName && !IS_INTRESOURCE(m_pszDisplayName)) + { + HeapFree(m_hHeap, 0, m_pszDisplayName); + } + } + + HRESULT + Acquire( + HANDLE hHeap, + PCKEYWORDMAP pMapping + ); + + CONST PCWSTR + GetDisplayName() CONST + { + return m_pszDisplayName; + } + + CONST PCSTR + GetKeyword() CONST + { + if (m_pMapping) + { + return m_pMapping->pszKeyword; + } + else + { + return NULL; + } + } +}; + + +// +// Class wrapper and container for Core Driver Feature +// Options. +// +class CFeature +{ +private: + + PCKEYWORDMAP m_pMapping; + + PWSTR m_pszDisplayName; + + DWORD m_dwOptions; + // Count of the number of options contained for an instance of the class. + + PCSTR m_pszFeature; + // Pointer to the feature for which the enumerated options belong. + + HANDLE m_hHeap; + // Heap to do allocations from. + + COption *m_pOptions; + // Array of info about each option for a feature + + DWORD m_Sel; + // An optitem selection is indicated either with a pointer or an + // index. Since combo-boxes use indices, and this custom UI only + // generates combo boxes, this class always uses an index to + // indicate the current selection. + +public: + + CFeature(); + + virtual ~CFeature(); + + // + // Populate Options list for specified keyword. + // + HRESULT + Acquire( + _In_ HANDLE hHeap, + _In_ IPrintCoreHelper* pHelper, + _In_ PCSTR pszFeature + ); + + // + // Returns number of feature options contained in class instance. + // + DWORD + GetCount() const {return m_dwOptions;} + + // + // Return nth option. + // + CONST COption * + GetOption( + DWORD dwIndex + ) const; + + + // + // Get the currently selected option index. + // + LONG + GetSelection() + { + return m_Sel; + } + + // + // Find option with matching keyword string. + // + _Success_(return != FALSE) BOOL + FindOption( + _In_ PCSTR pszOption, + _Out_ DWORD *pdwOption + ) const; + + // + // Initializes options portion of OPTITEM. + // + HRESULT + InitOptItem( + _In_ HANDLE hHeap, + _Inout_ POPTITEM pOptItem + ); + + // + // Refresh option selection. + // + HRESULT + RefreshSelection( + _In_ IPrintCoreHelper* pHelper + ); + + CONST PCWSTR + GetDisplayName() + { + return m_pszDisplayName; + } + + CONST PCSTR + GetKeyword() + { + return m_pszFeature; + } + + DWORD + GetMode() + { + return m_pMapping->dwMode; + } + +private: + + VOID + Clear(); +}; + + +// +// Class wrapper and container for Core Driver Features. +// +class CFeatureCollection +{ +private: + + DWORD m_dwFeatures; + // Count of the number of features. + + DWORD m_dwDocFeatures; + // Count of the number of document sticky features + + DWORD m_dwPrintFeatures; + // Count of the number of printer sticky features. + + HANDLE m_hHeap; + // Heap to do allocations from. + + CFeature *m_pFeatures; + // Array of feature information about each of the enumerate features. + +public: + + CFeatureCollection(); + virtual ~CFeatureCollection(); + + // + // Populates the Feature list + // + HRESULT Acquire( + HANDLE hHeap, + IPrintCoreHelper* pHelper + ); + + // + // Returns number of features contained in class instance. + // + DWORD GetCount( + DWORD dwMode = 0 + ) const; + + // Returns pointer to option class for nth feature. + // + CFeature* GetFeature( + DWORD wIndex, + DWORD dwMode = 0 + ) const; + +private: + + VOID Clear(); + + DWORD GetModelessIndex( + DWORD dwIndex, + DWORD dwMode + ) const; +}; + + +class CFeaturePairs +{ +private: + + PRINT_FEATURE_OPTION * m_pData; + size_t m_cElements; + + VOID + ClearPair( + size_t iIndex + ); + +public: + + CFeaturePairs(size_t cElements); + + ~CFeaturePairs(); + + HRESULT + SetPair( + size_t iIndex, + PCSTR pcszFeature, + PCSTR pcszOption + ); + + PRINT_FEATURE_OPTION * + GetData() + { + return m_pData; + } + + size_t + GetElementCount() + { + return m_cElements; + } +}; + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT +GetDisplayNameFromMapping( + _In_ HANDLE hHeap, + _In_ PCKEYWORDMAP pMapping, + _Out_ PWSTR *ppszDisplayName + ); + +PCKEYWORDMAP +GetKeywordMapping( + _In_reads_(dwMapSize) PCKEYWORDMAP pKeywordMap, + DWORD dwMapSize, + PCSTR pszKeyword + ); + +BOOL +IsFeatureOptItem( + POPTITEM pOptItem + ); + +HRESULT +SaveFeatureOptItems( + HANDLE hHeap, + IPrintCoreHelper* pHelper, + HWND hWnd, + _In_reads_(dwItems) POPTITEM pOptItem, + DWORD dwItems + ); + +HRESULT +GetChangedFeatureOptions( + _In_reads_(dwItems) POPTITEM pOptItem, + DWORD dwItems, + _Outptr_result_maybenull_ CFeaturePairs **ppPairs + ); + +PCSTR +GetOptionKeywordFromOptItem( + POPTITEM pOptItem + ); + +HRESULT +RefreshOptItemSelection( + IPrintCoreHelper* pHelper, + _In_reads_(dwItems) POPTITEM pOptItems, + DWORD dwItems + ); + +HRESULT +GetFirstConflictingFeature( + IPrintCoreHelper *pHelper, + _In_reads_(dwItems) POPTITEM pOptItem, + DWORD dwItems, + CONST PRINT_FEATURE_OPTION **pConstraints, + DWORD *pdwConstraints + ); + +POPTTYPE +CreateOptType( + HANDLE hHeap, + WORD wOptParams + ); + +HRESULT +GetStringResource( + _In_ HANDLE hHeap, + _In_ HMODULE hModule, + UINT uResource, + _Out_ PWSTR *ppszString + ); diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj new file mode 100644 index 00000000..e7dfa837 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj @@ -0,0 +1,1066 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {7C66BD86-A7CA-4F53-A5B2-9361A6B80E16} + $(MSBuildProjectName) + Win10 Debug + Win32 + {B571A415-8077-4F31-891E-02760FE89ED2} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + UNIUIREP + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + + + %(AdditionalDependencies);gdi32.lib;kernel32.lib;user32.lib;winspool.lib;ole32.lib;oleaut32.lib;advapi32.lib;uuid.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + UNIUIREP.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj.Filters new file mode 100644 index 00000000..359932e0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/UNIUIREP.vcxproj.Filters @@ -0,0 +1,223 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {7212E25C-3AC4-4F4D-A600-63E91A451AD6} + + + h;hpp;hxx;hm;inl;inc;xsd + {72D49995-C0D7-4527-9A60-C2A300B80E2B} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {B53D0C7F-CD45-4EC5-893D-05FBEE34246B} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + Header Files + + + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.cpp b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.cpp new file mode 100644 index 00000000..f7a3d842 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.cpp @@ -0,0 +1,405 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.cpp +// +// PURPOSE: Debug functions. +// +// + +#include "precomp.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL DEFINES +//////////////////////////////////////////////////////// + +#define DEBUG_BUFFER_SIZE 1024 +#define PATH_SEPARATOR '\\' +#define MAX_LOOP 10 + +// Determine what level of debugging messages to eject. +#ifdef VERBOSE_MSG + #define DEBUG_LEVEL DBG_VERBOSE +#elif TERSE_MSG + #define DEBUG_LEVEL DBG_TERSE +#elif WARNING_MSG + #define DEBUG_LEVEL DBG_WARNING +#elif ERROR_MSG + #define DEBUG_LEVEL DBG_ERROR +#elif RIP_MSG + #define DEBUG_LEVEL DBG_RIP +#elif NO_DBG_MSG + #define DEBUG_LEVEL DBG_NONE +#else + #define DEBUG_LEVEL DBG_WARNING +#endif + + + +//////////////////////////////////////////////////////// +// EXTERNAL GLOBALS +//////////////////////////////////////////////////////// + +INT giDebugLevel = DEBUG_LEVEL; + + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +static BOOL DebugMessageV(LPCSTR lpszMessage, va_list arglist); +static BOOL DebugMessageV(DWORD dwSize, LPCWSTR lpszMessage, va_list arglist); + + + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessageV +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// dwSize Size of temp buffer to hold formated string. +// +// lpszMessage Format string. +// +// arglist Variable argument list.. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +static BOOL DebugMessageV(LPCSTR lpszMessage, va_list arglist) +{ + DWORD dwSize = DEBUG_BUFFER_SIZE; + DWORD dwLoop = 0; + LPSTR lpszMsgBuf = NULL; + HRESULT hr; + + + // Parameter checking. + if( (NULL == lpszMessage) + || + (0 == dwSize) + ) + { + return FALSE; + } + + do + { + // Allocate memory for message buffer. + if(NULL != lpszMsgBuf) + { + delete[] lpszMsgBuf; + dwSize *= 2; + } + lpszMsgBuf = new CHAR[dwSize + 1]; + if(NULL == lpszMsgBuf) + { + return FALSE; + } + + hr = StringCbVPrintfA(lpszMsgBuf, (dwSize + 1) * sizeof(CHAR), lpszMessage, arglist); + + // Pass the variable parameters to wvsprintf to be formated. + } while (FAILED(hr) && (STRSAFE_E_INSUFFICIENT_BUFFER == hr) && (++dwLoop < MAX_LOOP) ); + + // Dump string to Debug output. + OutputDebugStringA(lpszMsgBuf); + + // Cleanup. + delete[] lpszMsgBuf; + + return SUCCEEDED(hr); +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessageV +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// dwSize Size of temp buffer to hold formated string. +// +// lpszMessage Format string. +// +// arglist Variable argument list.. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +static BOOL DebugMessageV(DWORD dwSize, LPCWSTR lpszMessage, va_list arglist) +{ + LPWSTR lpszMsgBuf; + HRESULT hResult; + + + // Parameter checking. + if( (NULL == lpszMessage) + || + (0 == dwSize) + ) + { + return FALSE; + } + + // Allocate memory for message buffer. + lpszMsgBuf = new WCHAR[dwSize + 1]; + if(NULL == lpszMsgBuf) + return FALSE; + + // Pass the variable parameters to wvsprintf to be formated. + hResult = StringCbVPrintfW(lpszMsgBuf, (dwSize + 1) * sizeof(WCHAR), lpszMessage, arglist); + + // Dump string to debug output. + OutputDebugStringW(lpszMsgBuf); + + // Clean up. + delete[] lpszMsgBuf; + + return SUCCEEDED(hResult); +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessage +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// lpszMessage Format string. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCSTR lpszMessage, ...) +{ + BOOL bResult; + va_list VAList; + + + // Pass the variable parameters to DebugMessageV for processing. + va_start(VAList, lpszMessage); + bResult = DebugMessageV(lpszMessage, VAList); + va_end(VAList); + + return bResult; +} + + +////////////////////////////////////////////////////////////////////////// +// Function: DebugMessage +// +// Description: Outputs variable argument debug string. +// +// +// Parameters: +// +// lpszMessage Format string. +// +// +// Returns: +// +// +// Comments: +// +// +////////////////////////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCWSTR lpszMessage, ...) +{ + BOOL bResult; + va_list VAList; + + + // Pass the variable parameters to DebugMessageV to be processed. + va_start(VAList, lpszMessage); + bResult = DebugMessageV(MAX_PATH, lpszMessage, VAList); + va_end(VAList); + + return bResult; +} + +void Dump(PPUBLISHERINFO pPublisherInfo) +{ + VERBOSE(TEXT("pPublisherInfo:\r\n")); + if(NULL == pPublisherInfo) + { + VERBOSE(TEXT("\tpPublisherInfo is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tdwMode = %#x\r\n"), pPublisherInfo->dwMode); + VERBOSE(TEXT("\twMinoutlinePPEM = %d\r\n"), pPublisherInfo->wMinoutlinePPEM); + VERBOSE(TEXT("\twMaxbitmapPPEM = %d\r\n"), pPublisherInfo->wMaxbitmapPPEM); +} + +void Dump(POEMDMPARAM pOemDMParam) +{ + VERBOSE(TEXT("pOemDMParam:\r\n")); + if(NULL == pOemDMParam) + { + VERBOSE(TEXT("\tpOemDMParam is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pOemDMParam->cbSize); + VERBOSE(TEXT("\tpdriverobj = %#x\r\n"), pOemDMParam->pdriverobj); + VERBOSE(TEXT("\thPrinter = %#x\r\n"), pOemDMParam->hPrinter); + VERBOSE(TEXT("\thModule = %#x\r\n"), pOemDMParam->hModule); + VERBOSE(TEXT("\tpPublicDMIn = %#x\r\n"), pOemDMParam->pPublicDMIn); + VERBOSE(TEXT("\tpPublicDMOut = %#x\r\n"), pOemDMParam->pPublicDMOut); + VERBOSE(TEXT("\tpOEMDMIn = %#x\r\n"), pOemDMParam->pOEMDMIn); + VERBOSE(TEXT("\tpOEMDMOut = %#x\r\n"), pOemDMParam->pOEMDMOut); + VERBOSE(TEXT("\tcbBufSize = %d\r\n"), pOemDMParam->cbBufSize); +} + +void Dump(PPROPSHEETUI_INFO pPSUIInfo) +{ + VERBOSE(TEXT("pPSUIInfo:\r\n")); + if(NULL == pPSUIInfo) + { + VERBOSE(TEXT("\tpPSUIInfo is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pPSUIInfo->cbSize); + VERBOSE(TEXT("\tVersion = %#x\r\n"), pPSUIInfo->Version); + VERBOSE(TEXT("\tFlags = %#x\r\n"), pPSUIInfo->Flags); + VERBOSE(TEXT("\tReason = %d\r\n"), pPSUIInfo->Reason); + VERBOSE(TEXT("\thComPropSheet = %#x\r\n"), pPSUIInfo->hComPropSheet); + VERBOSE(TEXT("\tpfnComPropSheet = %#x\r\n"), pPSUIInfo->pfnComPropSheet); + VERBOSE(TEXT("\tlParamInit = %#x\r\n"), pPSUIInfo->lParamInit); + VERBOSE(TEXT("\tUserData = %#x\r\n"), pPSUIInfo->UserData); + VERBOSE(TEXT("\tResult = %#x\r\n"), pPSUIInfo->Result); +} + +void Dump(POPTITEM pOptItem) +{ + VERBOSE(TEXT("pOptItem:\r\n")); + if(NULL == pOptItem) + { + VERBOSE(TEXT("\tpOptItem is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\tcbSize = %d\r\n"), pOptItem->cbSize); + VERBOSE(TEXT("\tLevel = %d\r\n"), pOptItem->Level); + VERBOSE(TEXT("\tDlgPageIdx = %d\r\n"), pOptItem->DlgPageIdx); + VERBOSE(TEXT("\tFlags = 0x%x\r\n"), pOptItem->Flags); + VERBOSE(TEXT("\tUserData = 0x%p\r\n"), pOptItem->UserData); + VERBOSE(TEXT("\tpName = %s\r\n"), pOptItem->pName ? pOptItem->pName : TEXT("")); + VERBOSE(TEXT("\tpSel = 0x%p\r\n"), pOptItem->pSel); + VERBOSE(TEXT("\tpExtChkBox = 0x%p\r\n"), pOptItem->pExtChkBox); + VERBOSE(TEXT("\tpExtChkBox = 0x%p\r\n"), pOptItem->pExtChkBox); + VERBOSE(TEXT("\tHelpIndex = 0x%x\r\n"), pOptItem->HelpIndex); + VERBOSE(TEXT("\tDMPubID = 0x%x\r\n"), pOptItem->DMPubID); + VERBOSE(TEXT("\tUserItemID = 0x%x\r\n"), pOptItem->UserItemID); + VERBOSE(TEXT("\twReserved = 0x%x\r\n"), pOptItem->wReserved); + VERBOSE(TEXT("\tpOIExt = 0x%p\r\n"), pOptItem->pOIExt); + + Dump(pOptItem->pOptType); +} + +void Dump(POPTTYPE pOptType) +{ + VERBOSE(TEXT("\tpOptType:\r\n")); + if(NULL == pOptType) + { + VERBOSE(TEXT("\t\tpOptType is NULL!\r\n")); + return; + } + VERBOSE(TEXT("\t\tcbSize = %d\r\n"), pOptType->cbSize); + VERBOSE(TEXT("\t\tType = 0x%x\r\n"), pOptType->Type); + VERBOSE(TEXT("\t\tFlags = 0x%x\r\n"), pOptType->Flags); + VERBOSE(TEXT("\t\tCount = %d\r\n"), pOptType->Count); + VERBOSE(TEXT("\t\tCount = 0x%x\r\n"), pOptType->BegCtrlID); + VERBOSE(TEXT("\t\tStyle = 0x%x\r\n"), pOptType->Style); + + Dump(pOptType->pOptParam, pOptType->Count); +} + +void Dump(POPTPARAM pOptParam, WORD wCount) +{ + if(NULL == pOptParam) + { + VERBOSE(TEXT("\t\tpOptParam is NULL!\r\n")); + return; + } + + for(WORD wIndex = 0; wIndex < wCount; ++wIndex) + { + VERBOSE(TEXT("\t\tpOptParam[wIndex]:\r\n")); + VERBOSE(TEXT("\t\t\tcbSize = %d\r\n"), pOptParam[wIndex].cbSize); + VERBOSE(TEXT("\t\t\tFlags = 0x%x\r\n"), pOptParam[wIndex].Flags); + VERBOSE(TEXT("\t\t\tStyle = 0x%x\r\n"), pOptParam[wIndex].Style); + VERBOSE(TEXT("\t\t\tpData = 0x%p\r\n"), pOptParam[wIndex].pData); + VERBOSE(TEXT("\t\t\tIconID = 0x%p\r\n"), pOptParam[wIndex].IconID); + VERBOSE(TEXT("\t\t\tlParam = 0x%p\r\n"), pOptParam[wIndex].lParam); + } +} + + +PCSTR +StripDirPrefixA( + IN PCSTR pstrFilename + ) + +/*++ + +Routine Description: + + Strip the directory prefix off a filename (ANSI version) + +Arguments: + + pstrFilename - Pointer to filename string + +Return Value: + + Pointer to the last component of a filename (without directory prefix) + +--*/ + +{ + PCSTR pstr; + + pstr = strrchr(pstrFilename, PATH_SEPARATOR); + if (pstr) + return pstr + 1; + + return pstrFilename; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.h new file mode 100644 index 00000000..b4d57b0b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/debug.h @@ -0,0 +1,166 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. +// +// + +#pragma once + +// VC and Build use different debug defines. +// The following makes it so either will +// cause the inclusion of debugging code. +#if !defined(_DEBUG) && defined(DBG) + #define _DEBUG DBG +#elif defined(_DEBUG) && !defined(DBG) + #define DBG _DEBUG +#endif + + + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// + +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// VERBOSE(msg) +// Display a message if the current debug level is <= DBG_VERBOSE. +// +// TERSE(msg) +// Display a message if the current debug level is <= DBG_TERSE. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// ASSERTMSG(cond, msg) +// Verify a condition is true. If not, display a message and +// force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// These macros require extra parantheses for the msg argument +// example, ASSERTMSG(x > 0, ("x is less than 0\n")); +// WARNING(("App passed NULL pointer, ignoring...\n")); +// + +#define DBG_VERBOSE 1 +#define DBG_TERSE 2 +#define DBG_WARNING 3 +#define DBG_ERROR 4 +#define DBG_RIP 5 +#define DBG_NONE 6 + +#if DBG + + #define DebugMsg DebugMessage + + // + // Strip the directory prefix from a filename (ANSI version) + // + + PCSTR + StripDirPrefixA( + IN PCSTR pstrFilename + ); + + extern INT giDebugLevel; + + + #define DBGMSG(level, prefix, msg) { \ + if (giDebugLevel <= (level)) { \ + DebugMsg("%s %s (%d): ", prefix, StripDirPrefixA(__FILE__), __LINE__); \ + DebugMsg(msg); \ + } \ + } + + #define DBGPRINT(level, msg) { \ + if (giDebugLevel <= (level)) { \ + DebugMsg(msg); \ + } \ + } + + #define VERBOSE if(giDebugLevel <= DBG_VERBOSE) DebugMsg + #define TERSE if(giDebugLevel <= DBG_TERSE) DebugMsg + #define WARNING if(giDebugLevel <= DBG_WARNING) DebugMsg + #define ERR if(giDebugLevel <= DBG_ERROR) DebugMsg + + #define ASSERT(cond) { \ + if (! (cond)) { \ + RIP(("\n")); \ + } \ + } + + #define ASSERTMSG(cond, msg) { \ + if (! (cond)) { \ + RIP(msg); \ + } \ + } + + #define RIP(msg) { \ + DBGMSG(DBG_RIP, "RIP", msg); \ + DebugBreak(); \ + } + + +#else // !DBG + + #define DebugMsg NOP_FUNCTION + + #define VERBOSE NOP_FUNCTION + #define TERSE NOP_FUNCTION + #define WARNING NOP_FUNCTION + #define ERR NOP_FUNCTION + + #define ASSERT(cond) + + #define ASSERTMSG(cond, msg) + #define RIP(msg) + #define DBGMSG(level, prefix, msg) + #define DBGPRINT(level, msg) + +#endif + + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +BOOL DebugMessage(LPCSTR, ...); +BOOL DebugMessage(LPCWSTR, ...); +void Dump(PPUBLISHERINFO pPublisherInfo); +void Dump(POEMDMPARAM pOemDMParam); +void Dump(PPROPSHEETUI_INFO pPSUIInfo); +void Dump(POPTITEM pOptItem); +void Dump(POPTTYPE pOptType); +void Dump(POPTPARAM pOptParam, WORD wCount); + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.cpp new file mode 100644 index 00000000..1f872cde --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.cpp @@ -0,0 +1,255 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: devmode.cpp +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// +//-------------------------------------------------------------------------- + +#include "precomp.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +BOOL +ConvertOEMDevmode( + _In_ PCOEMDEV pOEMDevIn, + _Inout_ POEMDEV pOEMDevOut + ); + +BOOL +MakeOEMDevmodeValid( + _Out_ POEMDEV pOEMDevmode + ); + +//+--------------------------------------------------------------------------- +// +// Member: +// ::hrOEMDevMode +// +// Synopsis: +// Performs operation on UI Plugins Private DevMode Members. +// Called via IOemUI::DevMode +// +// Returns: +// S_OK or E_FAIL. For more detailed failure info, +// check GetLastError +// +// Last error: +// ERROR_INVALID_PARAMETER +// +// +//---------------------------------------------------------------------------- +HRESULT +hrOEMDevMode( + DWORD dwMode, + // Indicates which operation should be performed + _Inout_ POEMDMPARAM pOemDMParam + // contains various data structures needed by this + // routine. The usage of this struct is determined by + // the dwMode flag. + ) +{ + VERBOSE(DLLTEXT("hrOEMDevMode entry.")); + + HRESULT hr = S_OK; + // Return value. + + // + // Verify parameters. + // + if ((NULL == pOemDMParam) || + ((OEMDM_SIZE != dwMode) && + (OEMDM_DEFAULT != dwMode) && + (OEMDM_CONVERT != dwMode) && + (OEMDM_MERGE != dwMode))) + { + ERR(ERRORTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); + ERR(DLLTEXT("\tdwMode = %d, pOemDMParam = %#lx.\r\n"), dwMode, pOemDMParam); + + SetLastError(ERROR_INVALID_PARAMETER); + hr = E_FAIL; + } + else + { + POEMDEV pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn;; + // Pointer to the supplied OEM devmode data, if applicable + // based on dwMode. + + POEMDEV pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut;; + // Pointer to the DEVMODE data that this routine is + // expected to configure, if applicable based on dwMode. + + switch (dwMode) + { + // + // The Method should return the size of the memory allocation + // needed to store the UI plugin Private DEVMODE. + // + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + // + //Should fill the Private DEVMODE with the default values. + // + case OEMDM_DEFAULT: + // + //OEM_DMEXTRAHEADER Members + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + break; + + // + // The method should convert private DEVMODE members to + // the current version, if necessary. + // + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + // + // The method should validate the information contained in private + // DEVMODE members and merge validated values into a private + // DEVMODE structure containing default values + // + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + } + + return hr; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::ConvertOEMDevmode +// +// Synopsis: +// confirm that the private DEVMODE being passed in is data that +// this driver recognizes, read the settings from the input +// OEM DEVMODE data, and write them to pOEMDevOut. +// +// Returns: +// True unless the routine was called with null pointers +// +// +//---------------------------------------------------------------------------- +BOOL +ConvertOEMDevmode( + _In_ PCOEMDEV pOEMDevIn, + // Caller supplied DEVMODE that we are attempting to read + _Inout_ POEMDEV pOEMDevOut + // OEM private DEVMODE configured by this routine based on the settings + // in pOEMDevIn + ) +{ + VERBOSE(DLLTEXT("ConvertOEMDevmode entry.")); + + if ((NULL == pOEMDevIn) || + (NULL == pOEMDevOut)) + { + ERR(ERRORTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); + return FALSE; + } + + // + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + // + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n")); + + // + // Copy the old structure in to the new using which ever size is the + // smaller. Devmode maybe from newer Devmode (not likely since there + // is only one), or Devmode maybe a newer Devmode, in which case it + // maybe larger, but the first part of the structure should be the same. + // + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get + // added to the end. + // + memcpy(pOEMDevOut, + pOEMDevIn, + __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + + // + // If the plug-in is capable of recognizing multiple versions of it's + // private DEVMODE data add custom handling here to support it. + // + } + else + { + WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); + + // + // The private DEVMODE data is not something that this plug-in understands, + // so use defaults. + // + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + + return TRUE; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::MakeOEMDevmodeValid +// +// Synopsis: +// Force the OEM devmode settings to valid values. +// +// Returns: +// True if the OEMDEV was configured, else FALSE. Only return false if +// the parameter is NULL. +// +// +//---------------------------------------------------------------------------- +BOOL +MakeOEMDevmodeValid( + _Out_ POEMDEV pOEMDevmode + // OEM DEVMODE data to modify + ) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // + // Assumption: pOEMDevmode is large enough to contain OEMDEV structure. + // + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + return TRUE; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.h new file mode 100644 index 00000000..342ce190 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/devmode.h @@ -0,0 +1,48 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: devmode.h +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +//-------------------------------------------------------------------------- + +#pragma once + +// +// OEM private DEVMODE data structure. This gets included in the DEVMODE +// used by Unidrv. +// +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + // This structure MUST be prefixed by OEM_DMEXTRAHEADER + + // + // Add private DevMode members here, after the standard header + // information. + // + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + +// +// ProtoTypes +// + +HRESULT +hrOEMDevMode( + DWORD dwMode, + _Inout_ POEMDMPARAM pOemDMParam + ); + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/dllentry.cpp new file mode 100644 index 00000000..3160dfb4 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/dllentry.cpp @@ -0,0 +1,82 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// PURPOSE: Source module for DLL entry function(s). +// +//-------------------------------------------------------------------------- + +#include "precomp.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::DllMain +// +// Synopsis: +// Dll's main routine, called when new +// threads or processes reference the module +// +// Returns: +// TRUE. Currently has no failure paths. Return false if the module +// cannot be properly initialized. +// +// Notes: +// The caller of this routine holds a process-wide lock preventing more +// than one module from being initialized at a time. In general, +// plug-ins should do as little as possible in this routine to avoid +// stalling other threads that may need to load modules. Also, calling +// any function that would, in-turn, cause another module to be loaded +// could result in a deadlock. +// +// +//---------------------------------------------------------------------------- +BOOL +WINAPI DllMain( + HINSTANCE hInst, + WORD wReason, + LPVOID lpReserved + ) +{ + VERBOSE(DLLTEXT("DllMain entry.")); + + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.cpp new file mode 100644 index 00000000..5513741e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.cpp @@ -0,0 +1,1151 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// PURPOSE: Implementation of interface for PScript5, Unidrv5 UI plug-ins. +// +//-------------------------------------------------------------------------- + +#include "precomp.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//-------------------------------------------------------------------------- +// Globals +//-------------------------------------------------------------------------- + +HINSTANCE ghInstance = NULL; + // Module's Instance handle from DLLEntry of process. + + +//-------------------------------------------------------------------------- +// Internal Globals +//-------------------------------------------------------------------------- + +static long g_cComponents = 0; + // Count of active components + +static long g_cServerLocks = 0; + // Count of locks + + +//-------------------------------------------------------------------------- +// Class factory for the Plug-In object +//-------------------------------------------------------------------------- +class COemCF : public IClassFactory +{ +public: + + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ + REFIID riid, + _COM_Outptr_ LPVOID FAR* ppvObj + ); + + STDMETHOD_(ULONG,AddRef) (THIS); + STDMETHOD_(ULONG,Release) (THIS); + + // IClassFactory methods + STDMETHOD(CreateInstance) (THIS_ + _In_opt_ LPUNKNOWN pUnkOuter, + _In_ REFIID riid, + _COM_Outptr_ LPVOID FAR* ppvObject + ); + + STDMETHOD(LockServer) (THIS_ + BOOL bLock + ); + + // Class-specific methods. + COemCF(): m_cRef(1) { }; + + ~COemCF() { }; + +protected: + LONG m_cRef; + +}; + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::DllCanUnloadNow +// +// Synopsis: +// Can the DLL be unloaded from memory? Answers no if any objects are +// still allocated, or if the server has been locked. +// +// To avoid leaving OEM DLL still in memory when Unidrv or Pscript +// drivers are unloaded, Unidrv and Pscript driver ignore the return +// value of DllCanUnloadNow of the OEM DLL, and always call FreeLibrary +// on the OEMDLL. +// +// If the plug-in spins off a working thread that also uses this DLL, +// the thread needs to call LoadLibrary and FreeLibraryAndExitThread, +// otherwise it may crash after Unidrv or Pscript calls FreeLibrary. +// +// Returns: +// S_OK if the DLL can be unloaded safely, otherwise S_FALSE +// +// +//---------------------------------------------------------------------------- +STDAPI DllCanUnloadNow() +{ + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::DllGetClassObject +// +// Synopsis: +// Retrieve the class factory object for the indicated class. +// +// Returns: +// CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, or S_OK. +// +// Notes: +// +// +//---------------------------------------------------------------------------- +STDAPI +DllGetClassObject( + _In_ CONST CLSID& clsid, + // GUID of the class object that the caller wants a class factory + // for + _In_ CONST IID& iid, + // Interface ID to provide in ppv + _Outptr_ VOID** ppv + // out pointer to the interface requested. + ) +{ + VERBOSE(DLLTEXT("DllGetClassObject:Create class factory.")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // + // Can we create this component? + // + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + // + // Create class factory. + // Reference count set to 1 in Constructor + // + COemCF* pUIReplacementCF = new COemCF; + if (pUIReplacementCF == NULL) + { + return E_OUTOFMEMORY; + } + + // + // Get requested interface. + // + HRESULT hr = pUIReplacementCF->QueryInterface(iid, ppv); + pUIReplacementCF->Release(); + + return hr; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::QueryInterface +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemCF::QueryInterface( + CONST IID& iid, + _COM_Outptr_ VOID** ppv + ) +{ + VERBOSE(DLLTEXT("COemCF::QueryInterface entry.")); + + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::AddRef +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +ULONG __stdcall +COemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::Release +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +ULONG __stdcall +COemCF::Release() +{ + assert(0 != m_cRef); + + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + } + return cRef; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::CreateInstance +// +// Synopsis: +// Attempt to create an object that implements the specified interface. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemCF::CreateInstance( + _In_opt_ IUnknown* pUnknownOuter, + _In_ CONST IID& iid, + _COM_Outptr_ VOID** ppv + ) +{ + VERBOSE(DLLTEXT("COemCF::CreateInstance entry.")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // + // Cannot aggregate. + // + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + HRESULT hr = S_OK; + + if (iid == IID_IUnknown || + iid == IID_IPrintOemUI2) + { + VERBOSE(DLLTEXT("COemCF::IID_IUnknown\r\n")); + + // + // Create component. + // + COemUI2* pOemCB = new COemUI2; + if (pOemCB == NULL) + { + hr = E_OUTOFMEMORY; + } + else + { + // + // Get the requested interface. + // + hr = pOemCB->QueryInterface(iid, ppv); + + // + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + // + pOemCB->Release(); + } + } + else + { + hr = E_NOINTERFACE; + } + + return hr; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemCF::LockServer +// +// Synopsis: +// Locking the server holds the objects server in memory, so that new +// instances of objects can be created more quickly. +// +// Returns: +// S_OK +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemCF::LockServer( + BOOL bLock + // If true, increment the lock count, otherwise decrement the lock + // count. + ) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + + return S_OK; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2 (destructor) +// +// Synopsis: +// Release the helper interface, as well as any other resources that +// the plug-in is holding onto. +// +// Returns: +// +// Notes: +// +// +//---------------------------------------------------------------------------- +COemUI2::~COemUI2() +{ + // + // Make sure that helper interface is released. + // + if(NULL != m_pCoreHelper) + { + m_pCoreHelper->Release(); + m_pCoreHelper = NULL; + } + + // + // If this instance of the object is being deleted, then the reference + // count should be zero. + // + assert(0 == m_cRef); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::QueryInterface +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::QueryInterface( + CONST IID& iid, + _COM_Outptr_ VOID** ppv + ) +{ + VERBOSE(DLLTEXT("COemUI2::QueryInterface entry.")); + + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("COemUI2::QueryInterface - Return pointer to IUnknown.\r\n")); + } + else if (iid == IID_IPrintOemUI2) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("COemUI2::QueryInterface - Return pointer to IPrintOemUI.\r\n")); + } + else + { +#if DBG + TCHAR szOutput[80] = {0}; + StringFromGUID2(iid, szOutput, _countof(szOutput)); // can not fail! + VERBOSE(DLLTEXT("COemUI2::QueryInterface %s not supported.\r\n"), szOutput); +#endif + + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::AddRef +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +ULONG __stdcall +COemUI2::AddRef() +{ + VERBOSE(DLLTEXT("COemUI2::AddRef entry.")); + + return InterlockedIncrement(&m_cRef); +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::Release +// +// Synopsis: +// Standard COM IUnknown implementation. +// +// +//---------------------------------------------------------------------------- +ULONG __stdcall +COemUI2::Release() +{ + VERBOSE(DLLTEXT("COemUI2::Release entry.")); + + assert(0 != m_cRef); + + ULONG cRef = InterlockedDecrement(&m_cRef); + + if (0 == cRef) + { + delete this; + return 0; + + } + + return cRef; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::PublishDriverInterface +// +// Synopsis: +// This routine is called by the core driver to supply objects to the +// plug-in which the plug-in can use to implement various features. +// +// This implementation requires an object that IPrintCoreHelper interface +// from the core driver to implement full UI replacement. If the object +// passed in is the one desired, this routine will return S_OK, otherwise +// it will return E_FAIL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::PublishDriverInterface( + IUnknown *pIUnknown + ) +{ + VERBOSE(DLLTEXT("COemUI2::PublishDriverInterface entry.")); + + HRESULT hrResult = S_OK; + + // + // Determine whether the published object is the helper interface + // introduced in Vista to support full UI replacement. + // + if (m_pCoreHelper == NULL) + { + hrResult = pIUnknown->QueryInterface(IID_IPrintCoreHelper, (VOID**) &(m_pCoreHelper)); + + if (!SUCCEEDED(hrResult)) + { + m_pCoreHelper = NULL; + hrResult = E_FAIL; + } + } + + return hrResult; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::GetInfo +// +// Synopsis: +// Most of this routine is a standard implementation common to most +// plug-ins. Of particular note in this sample is that to get a handle +// the IPrintCoreHelper plug-in in the PublishDriverInterface callback, +// this routine must return OEMPUBLISH_IPRINTCOREHELPER in the out +// parameter when the mode is OEMGI_GETREQUESTEDHELPERINTERFACES. +// +// Returns: +// S_OK for supported modes, E_FAIL for everything else. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::GetInfo( + _In_ DWORD dwMode, + // The mode indicates what information is being requested by the + // core driver. + _Out_writes_bytes_to_(cbSize, *pcbNeeded) PVOID pBuffer, + // The output buffer is the location into which the requested info + // should be written + _In_ DWORD cbSize, + // The size of the output buffer. + _Out_ PDWORD pcbNeeded + // If the size of the buffer is insufficient, use this parameter + // to indicate to the core driver how much space is required. + ) +{ + HRESULT hrResult = S_OK; + +#if DBG + PWSTR pszTag; + + switch(dwMode) + { + case OEMGI_GETSIGNATURE: pszTag = L"COemUI2::GetInfo entry. [OEMGI_GETSIGNATURE]"; break; + case OEMGI_GETVERSION: pszTag = L"COemUI2::GetInfo entry. [OEMGI_GETVERSION]"; break; + case OEMGI_GETREQUESTEDHELPERINTERFACES: pszTag = L"COemUI2::GetInfo entry. [OEMGI_GETREQUESTEDHELPERINTERFACES]"; break; + default: pszTag = L"COemUI2::GetInfo entry."; break; + } + + VERBOSE(pszTag); +#endif + + // + // Validate parameters. OEMGI_GETPUBLISHERINFO is excluded from this + // list because that GetInfo mode applies only to PScript rendering plug-ins. + // + if ((NULL == pcbNeeded) || + ((OEMGI_GETSIGNATURE != dwMode) && + (OEMGI_GETVERSION != dwMode) && + (OEMGI_GETREQUESTEDHELPERINTERFACES != dwMode))) + { + WARNING(DLLTEXT("COemUI2::GetInfo() exit pcbNeeded is NULL or mode is not supported\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // + // Set expected buffer size and number of bytes written. + // + *pcbNeeded = sizeof(DWORD); + + // + // Check buffer size is sufficient. + // + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("COemUI2::GetInfo() exit insufficient buffer!\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + hrResult = E_FAIL; + } + else + { + switch(dwMode) + { + // + // OEM DLL Signature + // + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // + // OEM DLL version + // + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // + // New core helper interface support + // + case OEMGI_GETREQUESTEDHELPERINTERFACES: + *(PDWORD)pBuffer = 0; + *(PDWORD)pBuffer |= OEMPUBLISH_IPRINTCOREHELPER; + break; + + // + // dwMode not supported. + // + default: + // Set written bytes to zero since nothing was written. + // + WARNING(DLLTEXT("COemUI2::GetInfo() exit mode not supported.\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + hrResult = E_FAIL; + } + } + + return hrResult; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DevMode +// +// Synopsis: +// This routine operates in various modes to manage the private DEVMODE. +// This sample does not provide much by way of illustration of how to +// handle OEM settings in the private DEVMODE. See the sample OEMUI for +// a more in-depth look at this routine. The function hrOEMDevMode in +// devmode.cpp also provides more information on how to handle the various +// modes. +// +// Returns: +// S_OK on success, else E_* +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DevMode( + DWORD dwMode, + // The operation that should be performed + POEMDMPARAM pOemDMParam + // The input & output DEVMODEs, including pointers to the public & + // private DEVMODE data. + ) +{ + VERBOSE(DLLTEXT("COemUI2::Devmode entry.")); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::HideStandardUI +// +// Synopsis: +// This routine is critical to supporting full UI replacement. This +// routine allows the plug-in to disable Unidrv's (or PScript's) standard +// UI panels. If this returns E_NOTIMPL, the panel isn't hidden. If +// this routine returns S_OK, Unidrv will not display any UI for the +// specified mode. If this returns E_NOTIMPL, Unidrv will display it's +// standard UI. +// +// Returns: +// S_OK to hide the indicated UI if desired, otherwise E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::HideStandardUI( + DWORD dwMode + // document property sheets, printer property sheets, or possibly + // something not yet defined. + ) +{ + VERBOSE(DLLTEXT("COemUI2::HideStandardUI entry.")); + + HRESULT hrResult = E_NOTIMPL; + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + case OEMCUIP_PRNPROP: + hrResult = S_OK; + break; + default: + // If we don't recognize the mode, assume that we don't want to hide + // the UI provided by Unidrv. + hrResult = E_NOTIMPL; + } + + return hrResult; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DocumentPropertySheets +// +// Synopsis: +// See function hrOEMDocumentPropertySheets in uniuirep.cpp. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ) +{ + VERBOSE(DLLTEXT("COemUI2::DocumentPropertySheets entry.")); + + return hrCommonPropSheetMethod(pPSUIInfo, lParam, m_pCoreHelper, &m_Features, OEMCUIP_DOCPROP); +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DevicePropertySheets +// +// Synopsis: +// See function hrOEMDevicePropertySheets in uniuirep.cpp +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ) +{ + VERBOSE(DLLTEXT("COemUI2::DevicePropertySheets entry.")); + + return hrCommonPropSheetMethod(pPSUIInfo, lParam, m_pCoreHelper, &m_Features, OEMCUIP_PRNPROP); +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::CommonUIProp +// +// Synopsis: +// This routine is used to interact with the Unidrv-supplied +// property sheet pages. Since this plug-in implements full-UI +// replacement, those property sheet pages are disabled, and this +// routine does not need to do anything. +// +// Returns: +// S_OK +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ) +{ + VERBOSE(DLLTEXT("COemUI2::CommonUIProp entry.")); + + UNREFERENCED_PARAMETER(dwMode); + UNREFERENCED_PARAMETER(pOemCUIPParam); + + return S_OK; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DeviceCapabilities +// +// Synopsis: +// This routine can be used to replace the Unidrvs device capabilities +// handling. In this implementation, no custom capabilities handling is +// provided. +// +// Returns: +// E_FAIL +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DeviceCapabilities( + _Inout_ POEMUIOBJ poemuiobj, + // OEM settings & information + _In_ HANDLE hPrinter, + // Handle to the printer that the capabilities are being requested for + _In_ PWSTR pDeviceName, + // Name of the device / driver + _In_ WORD wCapability, + // The DC_ ID indicating which capability was requested. + _Out_writes_(_Inexpressible_("varies with wCapability")) PVOID pOutput, + // Buffer to write requested information to. + _In_ PDEVMODE pPublicDM, + // Pointer to the public DEVMODE representing the settings to get + // capabilities with respect to. + _In_ PVOID pOEMDM, + // OEM private DEVMODE settings. + _In_ DWORD dwOld, + // Result from previous plug-in call to this routine. + _Out_ DWORD *dwResult + // Result of this call. If there are multiple UI plug-ins, this + // result is passed to the next one as dwOld + ) +{ + VERBOSE(DLLTEXT("COemUI2::DeviceCapabilities entry.")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + // + // Do nothing. Let Unidrv handle the device capabilities processing. + // + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DevQueryPrintEx +// +// Synopsis: +// This routine is used to determine print job compatibility with the +// current driver. The plug-in can supplement Unidrv's handling of this +// routine. If Unidrv determines that a job can be printed on the current +// printer it will call this routine to ask the plug-in whether it can +// also handle the current job. If Unidrv determines that the job cannot +// be printed, it will not call the plug-in. Additionally, XPS drivers +// built on the Unidrv and PScript UI modules may not recieve this call- +// back. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ) +{ + VERBOSE(DLLTEXT("COemUI2::DevQueryPrintEx entry.")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::UpgradePrinter +// +// Synopsis: +// Use this callback to upgrade any settings from previous versions +// that are stored in the registry by the plug-in Not applicabe to +// this sample. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::UpgradePrinter( + _In_ DWORD dwLevel, + _At_((PDRIVER_UPGRADE_INFO_1)pDriverUpgradeInfo, _In_) PBYTE pDriverUpgradeInfo + ) +{ + VERBOSE(DLLTEXT("COemUI2::UpgradePrinter entry.")); + + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::PrinterEvent +// +// Synopsis: +// Perform any special processing needed when various events occur to the +// print queue. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::PrinterEvent( + _In_ PWSTR pPrinterName, + _In_ INT iDriverEvent, + _In_ DWORD dwFlags, + _In_ LPARAM lParam + ) +{ + VERBOSE(DLLTEXT("COemUI2::PrinterEvent entry.")); + + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DriverEvent +// +// Synopsis: +// Notifies the plug-in of changes or events relevant to the driver, +// such as installing and upgrading. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DriverEvent( + _In_ DWORD dwDriverEvent, + _In_ DWORD dwLevel, + _In_reads_(_Inexpressible_("varies")) LPBYTE pDriverInfo, + _In_ LPARAM lParam + ) +{ + VERBOSE(DLLTEXT("COemUI2::DriverEvent entry.")); + + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::QueryColorProfile +// +// Synopsis: +// This routine can be implemented to provide a color profile from the +// driver. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData + ) +{ + VERBOSE(DLLTEXT("COemUI2::QueryColorProfile entry.")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(ulQueryMode); + UNREFERENCED_PARAMETER(pvProfileData); + UNREFERENCED_PARAMETER(pcbProfileData); + UNREFERENCED_PARAMETER(pflProfileData); + + return E_NOTIMPL; +}; + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::FontInstallerDlgProc +// +// Synopsis: +// Plug-ins can use this method to replace Unidrv's provided soft-font +// installer dialog. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ) +{ + VERBOSE(DLLTEXT("COemUI2::FontInstallerDlgProc entry.")); + + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::UpdateExternalFonts +// +// Synopsis: +// This routine is used to notify the UI of any changes to installed +// font cartridges, primarily for supporting soft-font UI replacement. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::UpdateExternalFonts( + _In_ HANDLE hPrinter, + _In_ HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ) +{ + VERBOSE(DLLTEXT("COemUI2::UpdateExternalFonts entry.")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//+--------------------------------------------------------------------------- +// +// Member: +// +// Synopsis: +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::QueryJobAttributes( + _In_ HANDLE hPrinter, + _In_ PDEVMODE pDevmode, + _In_range_(1, 4) DWORD dwLevel, + _In_reads_(_Inexpressible_("varies")) LPBYTE lpAttributeInfo + ) +{ + VERBOSE(DLLTEXT("COemUI2::QueryJobAttributes entry.")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDevmode); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(lpAttributeInfo); + + return E_NOTIMPL; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// COemUI2::DocumentEvent +// +// Synopsis: +// Perform any special processing needed at various points in time while +// a job is printing. +// +// Implementation of this routine is optional. To indicate that the +// plug-in does not support this call, return E_NOTIMPL. +// +// +//---------------------------------------------------------------------------- +HRESULT __stdcall +COemUI2::DocumentEvent( + HANDLE hPrinter, + HDC hdc, + INT iEsc, + ULONG cbIn, + PVOID pbIn, + ULONG cbOut, + PVOID pbOut, + PINT piResult + ) +{ + VERBOSE(DLLTEXT("COemUI2::DocumentEvent entry.")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hdc); + UNREFERENCED_PARAMETER(iEsc); + UNREFERENCED_PARAMETER(cbIn); + UNREFERENCED_PARAMETER(pbIn); + UNREFERENCED_PARAMETER(cbOut); + UNREFERENCED_PARAMETER(pbOut); + UNREFERENCED_PARAMETER(piResult); + + return E_NOTIMPL; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.h new file mode 100644 index 00000000..09a61f4a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/intrface.h @@ -0,0 +1,222 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.h +// +// PURPOSE: Define COM interface for User Mode Printer Customization DLL. +// +//-------------------------------------------------------------------------- + +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +extern HINSTANCE ghInstance; + // Module's Instance handle from DLLEntry of process. + +class COemUI2: public IPrintOemUI2 +{ +public: + // + // *** IUnknown methods *** + // + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, _COM_Outptr_ LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + STDMETHOD(GetInfo) (THIS_ + _In_ DWORD dwMode, + _Out_writes_bytes_to_(cbSize, *pcbNeeded) PVOID pBuffer, + _In_ DWORD cbSize, + _Out_ PDWORD pcbNeeded); + + // + // OEMDevMode + // + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam); + + // + // OEMCommonUIProp + // + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + STDMETHOD(DeviceCapabilities) (THIS_ + _Inout_ POEMUIOBJ poemuiobj, + _In_ HANDLE hPrinter, + _In_ PWSTR pDeviceName, + _In_ WORD wCapability, + _Out_writes_(_Inexpressible_("varies with wCapability")) PVOID pOutput, + _In_ PDEVMODE pPublicDM, + _In_ PVOID pOEMDM, + _In_ DWORD dwOld, + _Out_ DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + STDMETHOD(UpgradePrinter) (THIS_ + _In_ DWORD dwLevel, + _At_((PDRIVER_UPGRADE_INFO_1)pDriverUpgradeInfo, _In_) PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + _In_ INT iDriverEvent, + _In_ DWORD dwFlags, + _In_ LPARAM lParam + ); + + // + // OEMDriverEvent + // + STDMETHOD(DriverEvent)(THIS_ + _In_ DWORD dwDriverEvent, + _In_ DWORD dwLevel, + _In_reads_(_Inexpressible_("varies")) LPBYTE pDriverInfo, + _In_ LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + STDMETHOD( QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + STDMETHOD(UpdateExternalFonts) (THIS_ + _In_ HANDLE hPrinter, + _In_ HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + // + // IPrintOemUI2 methods + // + + // + // QueryJobAttributes + // + STDMETHOD(QueryJobAttributes) (THIS_ + _In_ HANDLE hPrinter, + _In_ PDEVMODE pDevmode, + _In_range_(1, 4) DWORD dwLevel, + _In_reads_(_Inexpressible_("varies")) LPBYTE lpAttributeInfo + ); + + // + // Hide Standard UI + // + STDMETHOD(HideStandardUI) (THIS_ + DWORD dwMode + ); + + // + // DocumentEvent + // + STDMETHOD(DocumentEvent) (THIS_ + HANDLE hPrinter, + HDC hdc, + INT iEsc, + ULONG cbIn, + PVOID pbIn, + ULONG cbOut, + PVOID pbOut, + PINT piResult + ); + + COemUI2() + { + m_cRef = 1; + m_pCoreHelper = NULL; + }; + + virtual ~COemUI2(); + +protected: + + LONG m_cRef; + // reference count of this object + + IPrintCoreHelper* m_pCoreHelper; + // Pointer to the helper interface introduced in Windows Vista. + + CFeatureCollection m_Features; + // Collection of features advertised as supported by the helper + // interface. +}; + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precomp.h new file mode 100644 index 00000000..cf24303c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precomp.h @@ -0,0 +1,68 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.h +// +// PURPOSE: Header files that should be in the precompiled header. +// +//-------------------------------------------------------------------------- + +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "resource.h" +#include "devmode.h" +#include "Features.h" +#include "uniuirep.h" +#include "debug.h" +#include "intrface.h" + +#include + +// Include this file after any other standard include files +// to disallow unsafe string handling functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/resource.h new file mode 100644 index 00000000..d7eda884 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/resource.h @@ -0,0 +1,57 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// Used by uirepplug.rc. Keep this in sync with the definitions in that file. +// +//-------------------------------------------------------------------------- + +// +//{{NO_DEPENDENCIES}} +// +#define IDS_SECTION 1 +#define IDS_NAME 3 +#define IDS_DEVICE_SETTINGS_NAME 4 +#define IDS_CONSTRAINT_CONFLICT 5 +#define IDD_DOC_PROPPAGE 107 +#define IDS_METAFILE_SPOOLING 419 +#define IDS_TEXT_ASGRX 431 +#define IDS_TTDL_DEFAULT 460 +#define IDS_TTDL_TYPE1 461 +#define IDS_TTDL_TYPE3 462 +#define IDS_TTDL_TYPE42 463 +#define IDS_MISSINGNAME 464 +#define IDS_RESDLL 700 +#define IDS_GRAPHICS_MODE 701 +#define IDS_DUPLEX_UNIT 702 +#define IDS_UNIRESDLL 707 +#define IDS_RESOLUTION_600_DPI 708 +#define IDS_RESOLUTION_300_DPI 709 +#define IDS_RESOLUTION_150_DPI 710 +#define IDS_RASTERMODE 711 +#define IDS_HPGL2MODE 712 +#define IDS_PAPERSIZE_LETTER 713 +#define IDS_PAPERSIZE_LEGAL 714 +#define IDS_PAPERSIZE_EXECUTIVE 715 +#define IDS_PAPERSIZE_A4 716 +#define IDS_PAPERSIZE_B5 717 +#define IDS_COLORMODE_MONO 718 +#define IDS_COLORMODE_24BPP 719 +#define IDS_COLORMODE_8BPP 720 +#define IDS_HALFTONE_AUTO 721 +#define IDS_HALFTONE_SUPERCELL_M 722 +#define IDS_HALFTONE_6x6_M 723 +#define IDS_HALFTONE_8x8_M 724 +#define IDS_UIREP_ENVTRAY 728 +#define IDS_OUTBIN_STACKER 735 +#define IDS_OUTBIN_DEFAULT 736 +#define IDS_MEMORY_STD 737 +#define IDS_MEMORY_UPGRADE 738 +#define IDS_INSTALLED_MEMORY 739 + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.cpp b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.cpp new file mode 100644 index 00000000..d75e3215 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.cpp @@ -0,0 +1,492 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: uniuirep.cpp +// +// PURPOSE: This module handles COMPSTUI initialization and +// callback behavior. +// +//-------------------------------------------------------------------------- + + +#include "precomp.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + +typedef struct _tagCBUserData +{ + HANDLE hComPropSheet; + HANDLE hPropPage; + POEMUIPSPARAM pOEMUIParam; + PFNCOMPROPSHEET pfnComPropSheet; + IPrintCoreHelper* pHelper; + BOOL bPermission; + +} CBUSERDATA, *PCBUSERDATA; + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +LONG APIENTRY +OEMCommonUICallBack( + _In_ PCPSUICBPARAM pCallbackParam + ); + +POPTITEM +CreateOptItems( + HANDLE hHeap, + DWORD dwOptItems + ); + + +//+--------------------------------------------------------------------------- +// +// Member: +// ::hrCommonPropSheetMethod +// +// Synopsis: +// Adds property page to printer property sheet. +// +// Returns: +// S_OK on success, E_FAIL on failure. Sets LastError. +// +// +//---------------------------------------------------------------------------- +HRESULT +hrCommonPropSheetMethod( + PPROPSHEETUI_INFO pPSUIInfo, + // Property sheet information, including + // the reason for calling this function. + LPARAM lParam, + // Optional parameter. Value is determined + // by the reason member of pPSUIInfo. + IPrintCoreHelper* pHelper, + // Pointer to the helper interface used to control + // settings described in the GPD + CFeatureCollection* pFeatures, + // Collection of all features that we're supporting + // in our custom UI. + DWORD dwMode + // Should our sheet show device or document features? + ) +{ + LONG_PTR lResult = TRUE; + // result supplied to COMPSTUI via pPSUIInfo + + HRESULT hrResult = S_OK; + // Result returned to the immediate caller. + + VERBOSE(DLLTEXT("hrCommonPropSheetMethod entry.")); + + // + // Validate parameters. + // + if ((NULL == pPSUIInfo) || + (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version)) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod() ERROR_INVALID_PARAMETER.\r\n")); + + // + // Return invalid parameter error. + // + SetLastError(ERROR_INVALID_PARAMETER); + hrResult = E_FAIL; + goto Exit; + } + + Dump(pPSUIInfo); + + // + // Do action. + // + switch(pPSUIInfo->Reason) + { + case PROPSHEETUI_REASON_INIT: + { + WORD wFeatures = 0; + DWORD dwSheets = 0; + PCBUSERDATA pUserData = NULL; + POEMUIPSPARAM pOEMUIParam = (POEMUIPSPARAM)pPSUIInfo->lParamInit; + BOOL bPermission = 0; + HANDLE hHeap = pOEMUIParam->hOEMHeap; + COMPROPSHEETUI Sheet; + + // + // If the user doesn't have permission to change settings, + // make a note of it so we can disable controls later. + // + if (dwMode == OEMCUIP_PRNPROP) + { + bPermission = ((pOEMUIParam->dwFlags & DPS_NOPERMISSION)==0); + } + else + { + bPermission = ((pOEMUIParam->dwFlags & DM_NOPERMISSION)==0); + } + + // + // Make sure that we have the core driver features + // + hrResult = pFeatures->Acquire(hHeap, pHelper); + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Failed to load core driver features! (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + + // + // Wait until after the call to Acquire to read the number of features. + // + wFeatures = (WORD)pFeatures->GetCount(dwMode); + + // + // Init device settings replacement page + // + memset(&Sheet, 0, sizeof(COMPROPSHEETUI)); + Sheet.cbSize = sizeof(COMPROPSHEETUI); + Sheet.Flags = bPermission ? CPSUIF_UPDATE_PERMISSION : 0; + Sheet.hInstCaller = ghInstance; + Sheet.pHelpFile = NULL; + Sheet.pfnCallBack = OEMCommonUICallBack; + Sheet.cOptItem = wFeatures; + Sheet.IconID = IDI_CPSUI_PRINTER; + Sheet.CallerVersion = 0x100; + Sheet.OptItemVersion = 0x100; + + // + // Initialize mode-specific fields + // + if (dwMode == OEMCUIP_PRNPROP) + { + // + // Use a DlgPage structure to set the text in the tab + // in the printer propertues view. + // + DLGPAGE DlgPage; + memset(&DlgPage, 0, sizeof(DLGPAGE)); + DlgPage.cbSize = sizeof(DLGPAGE); + DlgPage.DlgTemplateID = DP_STD_TREEVIEWPAGE; + + // + // Get device settings display name + // + hrResult = GetStringResource(hHeap, ghInstance, IDS_DEVICE_SETTINGS_NAME, &DlgPage.pTabName); + + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Failed to get tab name! (hrResult = 0x%x)\r\n"), + hrResult); + goto Exit; + } + Sheet.pDlgPage = &DlgPage; + Sheet.cDlgPage = 1; + } + else + { + // + // printing preferences settings + // + Sheet.pDlgPage = CPSUI_PDLGPAGE_TREEVIEWONLY; + } + + // + // Get caller name + // + hrResult = GetStringResource(hHeap, ghInstance, IDS_NAME, &Sheet.pCallerName); + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Failed to get caller name! (hrResult = 0x%x)\r\n"), hrResult); + goto Exit; + } + + // + // Get section name + // + hrResult = GetStringResource(hHeap, ghInstance, IDS_SECTION, &Sheet.pOptItemName); + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Failed to get section name! (hrResult = 0x%x)\r\n"), hrResult); + goto Exit; + } + + // + // Init user data. + // + pUserData = (PCBUSERDATA)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(CBUSERDATA)); + + if (pUserData == NULL) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Failed to allocate user data!\r\n")); + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + pUserData->hComPropSheet = pPSUIInfo->hComPropSheet; + pUserData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet; + pUserData->pOEMUIParam = pOEMUIParam; + pUserData->pHelper = pHelper; + pUserData->bPermission = bPermission; + Sheet.UserData = (ULONG_PTR)pUserData; + + // + // Create OptItems for page. + // + Sheet.pOptItem = CreateOptItems(hHeap, Sheet.cOptItem); + + if (Sheet.pOptItem == NULL) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Failed to allocate OPTITEMS!\r\n")); + hrResult = E_OUTOFMEMORY; + goto Exit; + } + + // + // Add core driver features + // + for (DWORD wIndex = 0; wIndex < wFeatures; wIndex++) + { + // + // Initialize level and basic state for feature + // + Sheet.pOptItem[wIndex].Level = 1; + Sheet.pOptItem[wIndex].Flags = OPTIF_COLLAPSE; + CFeature *pFeature = pFeatures->GetFeature(wIndex, dwMode); + + if (pFeature == NULL) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Feature not found or features not initialized!\r\n")); + hrResult = E_UNEXPECTED; + goto Exit; + } + + // + // Get OPTITEM for this feature + // + hrResult = pFeature->InitOptItem(hHeap, Sheet.pOptItem + wIndex); + + if (!SUCCEEDED(hrResult)) + { + ERR(ERRORTEXT("hrCommonPropSheetMethod: Failed to get OPTITEM for feature %s\r\n"), pFeature->GetKeyword()); + goto Exit; + } + + } + + // + // Add property sheets. + // + lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet, + CPSFUNC_ADD_PCOMPROPSHEETUI, + (LPARAM)&Sheet, + (LPARAM)&dwSheets); + + + if (!lResult) + { + ERR(DLLTEXT("hrCommonPropSheetMethod() pfnComPropSheet returned %d.\r\n"), lResult); + ERR(ERRORTEXT("ComPropSheet failed! Failed to add device settings tab!\n")); + } + } + break; + + case PROPSHEETUI_REASON_GET_INFO_HEADER: + { + // + // Set header title + // + PPROPSHEETUI_INFO_HEADER pHeader = (PPROPSHEETUI_INFO_HEADER)lParam; + pHeader->pTitle = (LPTSTR)PROP_TITLE; + lResult = TRUE; + } + break; + + case PROPSHEETUI_REASON_GET_ICON: + // + // No icon + // + lResult = 0; + break; + + case PROPSHEETUI_REASON_SET_RESULT: + { + PSETRESULT_INFO pInfo = (PSETRESULT_INFO)lParam; + lResult = pInfo->Result; + } + break; + + case PROPSHEETUI_REASON_DESTROY: + lResult = TRUE; + break; + } + + pPSUIInfo->Result = lResult; + +Exit: + + return hrResult; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// OEMCommonUICallBack +// +// Synopsis: +// Callback function to handle changes to the feature list panel +// added by this plug-in to the document properties UI. +// +// Returns: +// CPSUICB_ACTION_NONE if nothing further needs done. +// CPSUICB_ACTION_NO_APPLY_EXIT if settings changes were aborted +// +// +//---------------------------------------------------------------------------- +LONG APIENTRY +OEMCommonUICallBack( + _In_ PCPSUICBPARAM pCallbackParam + // struct containing all of the relevant callback parameters, + // including the reason that the callback is being made. + ) +{ + VERBOSE(DLLTEXT("OEMCommonUICallBack entry.")); + + WORD wItems = pCallbackParam->cOptItem; + LONG lReturn = CPSUICB_ACTION_NONE; + POPTITEM pOptItem = pCallbackParam->pOptItem; + PCBUSERDATA pUserData = (PCBUSERDATA) pCallbackParam->UserData; + HANDLE hHeap = pUserData->pOEMUIParam->hOEMHeap; + HRESULT hrResult = S_OK; + + VERBOSE(DLLTEXT("Reason = %d"), pCallbackParam->Reason); + + // + // If user has no permission to change anything, then simply + // return without any action + // + if (!pUserData->bPermission && + (pCallbackParam->Reason != CPSUICB_REASON_ABOUT)) + { + WARNING(DLLTEXT("OEMCommonUICallBack: User does not have appropriate permission!\r\n")); + lReturn = CPSUICB_ACTION_NONE; + } + else + { + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + if (wItems > 0) + { + // + // Save features if hiding std UI + // + hrResult = SaveFeatureOptItems(hHeap, + pUserData->pHelper, + pCallbackParam->hDlg, + pOptItem, + wItems); + + if (!SUCCEEDED(hrResult)) + { + // + // Return that we didn't save changes. + // NOTE: It is upto SaveFeatureOptItems() to display any + // UI for failure + // + lReturn = CPSUICB_ACTION_NO_APPLY_EXIT; + } + else + { + pUserData->pfnComPropSheet(pUserData->hComPropSheet, + CPSFUNC_SET_RESULT, + (LPARAM)pUserData->hPropPage, + (LPARAM)CPSUI_OK); + } + } + break; + + case CPSUICB_REASON_KILLACTIVE: + // + // This active property sheet page is changing, and this page is + // going inactive. + // + break; + + case CPSUICB_REASON_SETACTIVE: + // + // This property sheet page is about to become the active page. + // + default: + break; + } + } + + return lReturn; +} + + +//+--------------------------------------------------------------------------- +// +// Member: +// +// Synopsis: +// Creates and Initializes OptItems. +// +// Returns: +// Pointer to an array of optitems on success, else +// NULL on failure. +// +// +//---------------------------------------------------------------------------- +POPTITEM +CreateOptItems( + HANDLE hHeap, + // Heap to allocate data from + DWORD dwOptItems + // Number of opt items to allocate. + ) +{ + VERBOSE(DLLTEXT("CreateOptItems entry.")); + + POPTITEM pOptItems = NULL; + // OPTITEMs to be returned to caller. + + ULONG cbOptItems = 0; + // Number of bytes needed for optitems. + + // Allocate memory for OptItems. + if (SUCCEEDED(ULongMult( sizeof(OPTITEM), dwOptItems, &cbOptItems)) && + (pOptItems = (POPTITEM)HeapAlloc(hHeap, HEAP_ZERO_MEMORY, cbOptItems)) != NULL) + { + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for (DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } + } + else + { + ERR(ERRORTEXT("CreateOptItems() failed to allocate memory for OPTITEMs!\r\n")); + } + + return pOptItems; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.def b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.def new file mode 100644 index 00000000..bf87f4c2 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.def @@ -0,0 +1,18 @@ +; +; 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. +; +; Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +; +; Abstract: +; +; This file contains a listing of all of the methods to be exported +; from the DLL, as well as rules for how to name the exports. +; + +LIBRARY UIREPPLUG + +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.h b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.h new file mode 100644 index 00000000..52980245 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.h @@ -0,0 +1,55 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: UNIUIREP.H +// +// PURPOSE: Define common data types, and external function prototypes +// for UI replacement sample. +// +//-------------------------------------------------------------------------- + +#pragma once + +#define DLLTEXT(s) TEXT("[UIREPPLUG] ") TEXT(s) +#define FUNCTEXT(s) _T(__FUNCTION__) TEXT(s) +#define ERRORTEXT(s) TEXT("ERROR ") DLLTEXT(s) + +// +// OEM Signature is used to identify the +// private DEVMODE portion to mitigate against +// data corruption. Replace this with a unique string +// for your organization. +// +#define OEM_SIGNATURE 'UIRP' +#define OEM_VERSION 0x00000001L + +// +// OEM Signature and version. +// +#define PROP_TITLE L"UIRepPlug Page" + +// +// Printer registry keys where OEM data is stored. +// +#define UIREPPLUG_VALUE TEXT("UIREPPLUG_VALUE") +#define UIREPPLUG_DEVICE_VALUE TEXT("UIREPPLUG_DEVICE_VALUE") + +// +// Method prototypes +// + +HRESULT +hrCommonPropSheetMethod( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam, + IPrintCoreHelper* pHelper, + CFeatureCollection* pFeatures, + DWORD dwMode + ); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.rc b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.rc new file mode 100644 index 00000000..67cad8ae --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/uniuirep/src/uniuirep.rc @@ -0,0 +1,192 @@ +//+-------------------------------------------------------------------------- +// +// 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. +// +// Copyright 1997 - 2005 Microsoft Corporation. All Rights Reserved. +// +// FILE: uniuirep.rc +// +// PURPOSE: Resource script containing all localizable strings for this +// module +// +//-------------------------------------------------------------------------- + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "UI Replacement PrintTicket Plugin." + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "UIREPPLUG" + VALUE "LegalCopyright", "Copyright © 1998 - 2005 Microsoft Corp." + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "UIREPPLUG.dll" + VALUE "ProductName", "Microsoft UIREPPLUG" + VALUE "ProductVersion", "1.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_SECTION "UIRepPlug Added Item" + IDS_NAME "UI Replacement PrintTicket Plugin" + IDS_DEVICE_SETTINGS_NAME "Device Settings" + IDS_CONSTRAINT_CONFLICT "There are one or more conflicting settings.\r\nDo you want driver to automatically resolve conflicts?" +END + +STRINGTABLE +BEGIN + IDS_RESDLL "Resource DLL" + IDS_GRAPHICS_MODE "Graphics Mode" + IDS_DUPLEX_UNIT "Duplex Unit" +END + +STRINGTABLE +BEGIN + IDS_UNIRESDLL "unires.dll" + IDS_RESOLUTION_600_DPI "600 x 600 dots per inch" + IDS_RESOLUTION_300_DPI "300 x 300 dots per inch" + IDS_RESOLUTION_150_DPI "150 x 150 dots per inch" + IDS_RASTERMODE "Raster mode" + IDS_HPGL2MODE "HPGL2 mode" + IDS_PAPERSIZE_LETTER "Letter" + IDS_PAPERSIZE_LEGAL "Legal" + IDS_PAPERSIZE_EXECUTIVE "Executive" + IDS_PAPERSIZE_A4 "A4" + IDS_PAPERSIZE_B5 "B5" + IDS_COLORMODE_MONO "Monochrome" + IDS_COLORMODE_24BPP "24 bits per pixel" + IDS_MISSINGNAME "" +END + +STRINGTABLE +BEGIN + IDS_COLORMODE_8BPP "8 bits per pixel" + IDS_HALFTONE_AUTO "Auto Select" + IDS_HALFTONE_SUPERCELL_M "Super Cell" + IDS_HALFTONE_6x6_M "Dither 6x6" + IDS_HALFTONE_8x8_M "Dither 8x8" + IDS_UIREP_ENVTRAY "Envelope Feeder Tray" + IDS_INSTALLED_MEMORY "Device Memory" + IDS_MEMORY_STD "Standard Memory" + IDS_MEMORY_UPGRADE "16MB Upgrade" + +END + +STRINGTABLE +BEGIN + IDS_OUTBIN_STACKER "Stacker" + IDS_OUTBIN_DEFAULT "Default" +END + +STRINGTABLE +BEGIN + IDS_METAFILE_SPOOLING "Advanced Printing Features" + IDS_TEXT_ASGRX "Print Optimizations" +END + +STRINGTABLE +BEGIN + IDS_TTDL_DEFAULT "Automatic" + IDS_TTDL_TYPE1 "Outline" + IDS_TTDL_TYPE3 "Bitmap" + IDS_TTDL_TYPE42 "Native TrueType" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.cpp new file mode 100644 index 00000000..71ffc11d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.cpp @@ -0,0 +1,229 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + +// This file is wrapped in fdevmode.cpp in other parts of the watermark sample. +// The appropriate precompiled header should be included there. +// #include "precomp.h + +#include "debug.h" +#include "devmode.h" + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + HRESULT hResult = S_OK; + POEMDEV pOEMDevIn = NULL; + POEMDEV pOEMDevOut = NULL; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR(DLLTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); + + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + case OEMDM_DEFAULT: + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->bEnabled = WATER_MARK_DEFAULT_ENABLED; + pOEMDevOut->dfRotate = WATER_MARK_DEFAULT_ROTATION; + pOEMDevOut->dwFontSize = WATER_MARK_DEFAULT_FONTSIZE; + pOEMDevOut->crTextColor = WATER_MARK_DEFAULT_COLOR; + hResult = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT); + break; + + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return hResult; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) +{ + HRESULT hCopy = S_OK; + + + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR(DLLTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n")); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->bEnabled = WATER_MARK_DEFAULT_ENABLED; + pOEMDevOut->dfRotate = WATER_MARK_DEFAULT_ROTATION; + pOEMDevOut->dwFontSize = WATER_MARK_DEFAULT_FONTSIZE; + pOEMDevOut->crTextColor = WATER_MARK_DEFAULT_COLOR; + hCopy = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT); + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->bEnabled = WATER_MARK_DEFAULT_ENABLED; + pOEMDevOut->dfRotate = WATER_MARK_DEFAULT_ROTATION; + pOEMDevOut->dwFontSize = WATER_MARK_DEFAULT_FONTSIZE; + pOEMDevOut->crTextColor = WATER_MARK_DEFAULT_COLOR; + hCopy = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT); + } + + return SUCCEEDED(hCopy); +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // bEnable should be either TRUE or FALSE. + if( (TRUE != pOEMDevmode->bEnabled) + && + (FALSE != pOEMDevmode->bEnabled) + ) + { + pOEMDevmode->bEnabled = WATER_MARK_DEFAULT_ENABLED; + } + + // dfRotate should be between 0 and 360 inclusive. + if( (0 > pOEMDevmode->dfRotate) + || + (360 < pOEMDevmode->dfRotate) + ) + { + pOEMDevmode->dfRotate = WATER_MARK_DEFAULT_ROTATION; + } + + // dwFontSize should be 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, or 72. + if(!IsValidFontSize(pOEMDevmode->dwFontSize)) + { + pOEMDevmode->dwFontSize = WATER_MARK_DEFAULT_FONTSIZE; + } + + // The high byte of the hi word should be zero. + if(0 != HIBYTE(HIWORD(pOEMDevmode->crTextColor))) + { + pOEMDevmode->crTextColor = WATER_MARK_DEFAULT_COLOR; + } + + // Make sure that water mark string is terminated. + pOEMDevmode->szWaterMark[WATER_MARK_TEXT_SIZE - 1] = L'\0'; + + return TRUE; +} + + +BOOL IsValidFontSize(DWORD dwFontSize) +{ + BOOL bValid = FALSE; + + + switch(dwFontSize) + { + case 8: + case 9: + case 10: + case 11: + case 12: + case 14: + case 16: + case 18: + case 20: + case 22: + case 24: + case 26: + case 28: + case 36: + case 48: + case 72: + bValid = TRUE; + break; + + default: + ERR(DLLTEXT("IsValidFontSize() found invalid font size\r\n")); + break; + } + + return bValid; +} + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.h new file mode 100644 index 00000000..f9df1f26 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/devmode.h @@ -0,0 +1,56 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + +#define WATER_MARK_TEXT_SIZE 128 +#define WATER_MARK_DEFAULT_ENABLED TRUE +#define WATER_MARK_DEFAULT_ROTATION 30 +#define WATER_MARK_DEFAULT_FONTSIZE 28 +#define WATER_MARK_DEFAULT_COLOR RGB(230, 230, 230) +#define WATER_MARK_DEFAULT_TEXT L"WaterMark" + + + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + BOOL bEnabled; + DOUBLE dfRotate; + DWORD dwFontSize; + COLORREF crTextColor; + WCHAR szWaterMark[WATER_MARK_TEXT_SIZE]; + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); +BOOL IsValidFontSize(DWORD dwFontSize); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/oem.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/oem.h new file mode 100644 index 00000000..f9615579 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/common/oem.h @@ -0,0 +1,24 @@ +// 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. +// +// Copyright 1997- 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: oem.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debug.cpp. +// + +#pragma once + + +//////////////////////////////////////////////////////// +// OEM Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj new file mode 100644 index 00000000..47a5db53 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj @@ -0,0 +1,1090 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {4B90E6E4-34B2-460F-9BF7-D75B5334F2E5} + $(MSBuildProjectName) + Win10 Debug + Win32 + {37DC3583-1F5D-4DB4-A930-535E9C096174} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + WMARKPS + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + WMARKPS.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj.Filters new file mode 100644 index 00000000..7e7da8cc --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMARKPS.vcxproj.Filters @@ -0,0 +1,137 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {7E7CEB8F-7E3D-4FBB-AEBE-D62B0C9D9B2E} + + + h;hpp;hxx;hm;inl;inc;xsd + {88C3214E-2B6E-4482-A2B8-16CD0E6A9A3A} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {3A0703EF-8A1F-4955-8F7E-0765109DEBF0} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.def b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.def new file mode 100644 index 00000000..fcfcd598 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.def @@ -0,0 +1,3 @@ +LIBRARY WMARKPS +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.rc b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.rc new file mode 100644 index 00000000..9653478a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/WMarkPS.rc @@ -0,0 +1,130 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// PSCRIPT +// + +IDR_WATERMARK_DRAW RC_PSCRIPT drawmark.ps +IDR_WATERMARK_PROLOGUE RC_PSCRIPT wmark.ps + +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team\0" + VALUE "CompanyName", "Microsoft Corp.\0" + VALUE "FileDescription", "OEM Customization Water Mark Sample\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "WMarkPS\0" + VALUE "LegalCopyright", "Copyright © 1998-2003\0" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation\0" + VALUE "OriginalFilename", "WMarkPS.DLL\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Microsoft WaterMark\0" + VALUE "ProductVersion", "1.0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.cpp new file mode 100644 index 00000000..e4758d1c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.cpp @@ -0,0 +1,410 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: command.cpp +// +// PURPOSE: Source module for OEM customized Command(s). +// + +#include "precomp.h" +#include "wmarkps.h" +#include "debug.h" +#include "command.h" +#include "resource.h" + + + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +///////////////////////////////////////////////////////// +// Internal Macros & Defines +///////////////////////////////////////////////////////// + +// Macros to convert from Windows RGB to PostScript RGB +#define GetPS2Color(dw) ((dw) / 255.0) +#define GetPS2RValue(cr) (GetPS2Color(GetRValue(cr))) +#define GetPS2GValue(cr) (GetPS2Color(GetGValue(cr))) +#define GetPS2BValue(cr) (GetPS2Color(GetBValue(cr))) + + +// Initial buffer size +#define INITIAL_BUFFER_SIZE 16 + + +// String format defines characters +#define FORMAT_DELIM '!' +#define FORMAT_STRING_ANSI 's' +#define FORMAT_STRING_UNICODE 'S' +#define FORMAT_CHAR '%' + + +// Loop limiter. +#define MAX_LOOP 10 + + +///////////////////////////////////////////////////////// +// Internal ProtoTypes +///////////////////////////////////////////////////////// + +static PSTR GetPostScriptResource(HMODULE hModule, LPCTSTR pszResource, PDWORD pdwSize); +static PSTR CreateWaterMarkProlog(HMODULE hModule, PDWORD pdwSize, _In_ LPWSTR pszWaterMark, + DWORD dwFontSize, _In_ LPSTR pszColor, _In_ LPSTR pszAngle); +static PSTR DoWaterMarkProlog(HMODULE hModule, POEMDEV pOemDevmode, PDWORD pdwSize); +static DWORD FormatResource(_In_ LPSTR pszResource, _Out_ LPSTR *ppszProlog, ...); + + +//////////////////////////////////////////////////////////////////////////////////// +// The PSCRIPT driver calls this OEM function at specific points during output +// generation. This gives the OEM DLL an opportunity to insert code fragments +// at specific injection points in the driver's code. It should use +// DrvWriteSpoolBuf for generating any output it requires. + +HRESULT PSCommand(PDEVOBJ pdevobj, DWORD dwIndex, PVOID pData, DWORD cbSize, + IPrintOemDriverPS* pOEMHelp, PDWORD pdwReturn) +{ + BOOL bFreeProcedure = FALSE; + PSTR pProcedure = NULL; + DWORD dwLen = 0; + DWORD dwSize = 0; + HRESULT hResult = E_FAIL; + + VERBOSE(DLLTEXT("Entering OEMCommand...\r\n")); + + UNREFERENCED_PARAMETER(pData); + UNREFERENCED_PARAMETER(cbSize); + + switch (dwIndex) + { + case PSINJECT_BEGINPROLOG: + { + POEMDEV pOemDevmode = (POEMDEV) pdevobj->pOEMDM; + + + VERBOSE(DLLTEXT("OEMCommand PSINJECT_BEGINPROLOG\r\n")); + + // Only do Water Mark PS prolog injection if Water Mark is enabled. + if(pOemDevmode->bEnabled) + { + pProcedure = DoWaterMarkProlog((HMODULE) pdevobj->hOEM, pOemDevmode, &dwSize); + bFreeProcedure = (NULL != pProcedure); + } + } + break; + + case PSINJECT_BEGINPAGESETUP: + { + POEMDEV pOemDevmode = (POEMDEV) pdevobj->pOEMDM; + + + VERBOSE(DLLTEXT("OEMCommand PSINJECT_BEGINPAGESETUP\r\n")); + + // Only do Water Mark PS page injection if Water Mark is enabled. + if(pOemDevmode->bEnabled) + { + pProcedure = GetPostScriptResource((HMODULE) pdevobj->hOEM, MAKEINTRESOURCE(IDR_WATERMARK_DRAW), &dwSize); + } + } + break; + + default: + VERBOSE(DLLTEXT("PSCommand Default...\r\n")); + *pdwReturn = ERROR_NOT_SUPPORTED; + return E_NOTIMPL; + } + + if(NULL != pProcedure) + { + // Write PostScript to spool file. + dwLen = (DWORD)strlen(pProcedure); + if (dwLen > 0) + { + hResult = pOEMHelp->DrvWriteSpoolBuf(pdevobj, pProcedure, dwLen, &dwSize); + } + + // Set return values. + if(SUCCEEDED(hResult) && (dwLen == dwSize)) + { + *pdwReturn = ERROR_SUCCESS; + } + else + { + // Try to return meaningful + // error value. + *pdwReturn = GetLastError(); + if(ERROR_SUCCESS == *pdwReturn) + { + *pdwReturn = ERROR_WRITE_FAULT; + } + + // Make sure we return failure + // if the write didn't succeded. + if(SUCCEEDED(hResult)) + { + hResult = HRESULT_FROM_WIN32(*pdwReturn); + } + } + + if(bFreeProcedure) + { + // INVARIANT: pProcedure was created with 'new' and needs to be freed. + delete[] pProcedure; + } + } + else + { + // pProcedure will be NULL if water mark isn't enabled. + *pdwReturn = ERROR_NOT_SUPPORTED; + hResult = E_NOTIMPL; + } + + // dwLen should always equal dwSize. + ASSERT(dwLen == dwSize); + + return hResult; +} + + +//////////////////////////////////////////////////////////////////////////////////// +// +// Retrieves pointer to a PostScript resource. +// +static PSTR GetPostScriptResource(HMODULE hModule, LPCTSTR pszResource, PDWORD pdwSize) +{ + PSTR pszPostScript = NULL; + HRSRC hFind = NULL; + HGLOBAL hResource = NULL; + + + VERBOSE(DLLTEXT("GetPostScriptResource() entered.\r\n")); + + // pszResource and pdwSize Parameters should not be NULL. + assert(NULL != pszResource); + assert(NULL != pdwSize); + + // Load PostScript resource. + hFind = FindResource(hModule, pszResource, MAKEINTRESOURCE(RC_PSCRIPT)); + //hFind = FindResource(hModule, pszResource, TEXT("PSCRIPT")); + if(NULL != hFind) + { + hResource = LoadResource(hModule, hFind); + if(NULL != hResource) + { + pszPostScript = (PSTR) LockResource(hResource); + *pdwSize = SizeofResource(hModule, hFind); + } + else + { + ERR(DLLTEXT("ERROR: Failed to load PSCRIPT resource!\r\n")); + } + } + else + { + ERR(DLLTEXT("ERROR: Failed to find PSCRIPT resource!\r\n")); + } + + // Should have found the PScript resource. + ASSERT(NULL != pszPostScript); + + return pszPostScript; +} + + +//////////////////////////////////////////////////////////////////////////////////// +// +// Formats Water Mark prolog with parameter. +// +static PSTR CreateWaterMarkProlog(HMODULE hModule, PDWORD pdwSize, _In_ LPWSTR pszWaterMark, + DWORD dwFontSize, _In_ LPSTR pszColor, _In_ LPSTR pszAngle) +{ + PSTR pszProlog = NULL; + PSTR pszResource = NULL; + + // Parameters that are pointers should not be NULL! + if (NULL == pdwSize || + NULL == pszWaterMark || + NULL == pszColor || + NULL == pszAngle) + { + ERR(DLLTEXT("CreateWaterMarkProlog: Invalid argument\r\n")); + return NULL; + } + + // Get Water Mark prolog resource. + pszResource = GetPostScriptResource(hModule, MAKEINTRESOURCE(IDR_WATERMARK_PROLOGUE), pdwSize); + + // Allocate and format the Water Mark Prolog with the correct values. + if(NULL != pszResource) + { + *pdwSize = FormatResource(pszResource, &pszProlog, pszWaterMark, dwFontSize, pszColor, pszAngle); + } + else + { + ERR(DLLTEXT("CreateWaterMarkProlog: Failed to get resource\r\n")); + } + + return pszProlog; +} + + +//////////////////////////////////////////////////////////////////////////////////// +// +// Does the pre-formating of parameters before calling the routine +// that creates the prolog. +// +static PSTR DoWaterMarkProlog(HMODULE hModule, POEMDEV pOemDevmode, PDWORD pdwSize) +{ + PSTR pszProlog = NULL; + + // Parameters should not be NULL. + if (NULL == hModule || + NULL == pOemDevmode || + NULL == pdwSize) + { + ERR(DLLTEXT("CreateWaterMarkProlog: Invalid argument\r\n")); + return NULL; + } + + // Only do prolog if Water Mark is enabled. + if(pOemDevmode->bEnabled) + { + CHAR szColor[INITIAL_BUFFER_SIZE] = "\0"; + DWORD dwAngleSize = INITIAL_BUFFER_SIZE; + LPSTR pszAngle = NULL; + + // Format angle as a string. + do + { + if(NULL != pszAngle) + { + delete[] pszAngle; + dwAngleSize *= 2; + } + pszAngle = new CHAR[dwAngleSize]; + + } while( (NULL != pszAngle) + && + (dwAngleSize < 1024) + && + (FAILED(StringCbPrintfA(pszAngle, dwAngleSize, "%.1f", pOemDevmode->dfRotate)) ) + ); + + if(NULL != pszAngle) + { + // Format text color as string. + if(FAILED(StringCbPrintfA(szColor, sizeof(szColor), + "%1.2f %1.2f %1.2f", + GetPS2RValue(pOemDevmode->crTextColor), + GetPS2GValue(pOemDevmode->crTextColor), + GetPS2BValue(pOemDevmode->crTextColor)))) + { + ERR(DLLTEXT("DoWaterMarkProlog() failed to create PostScript color string for water mark.")); + } + + // Create Water Mark prolog. + pszProlog = CreateWaterMarkProlog(hModule, pdwSize, pOemDevmode->szWaterMark, + pOemDevmode->dwFontSize, szColor, pszAngle); + + // Angle string is no longer needed. + delete[] pszAngle; + } + } + + return pszProlog; +} + + +//////////////////////////////////////////////////////////////////////////////////// +// +// Formats Resource. +// +static DWORD FormatResource(_In_ LPSTR pszResource, _Out_ LPSTR *ppszBuffer, ...) +{ + DWORD dwSize = (DWORD)strlen(pszResource) + MAX_PATH; + DWORD dwLoop = 0; + va_list vaList; + HRESULT hResult = E_FAIL; + + + va_start(vaList, ppszBuffer); + + // *ppszBuffer should be NULL when passed in. + *ppszBuffer = NULL; + + // Allocate and format the string. + do { + + if(NULL != *ppszBuffer) + { + delete[] *ppszBuffer; + } + *ppszBuffer = new CHAR[dwSize]; + if(NULL == *ppszBuffer) + { + goto Cleanup; + } + + hResult = StringCbVPrintfA(*ppszBuffer, dwSize, pszResource, vaList); + + if(STRSAFE_E_INSUFFICIENT_BUFFER == hResult) + { + dwSize *= 2; + } + + } while ( FAILED(hResult) && (dwLoop++ < MAX_LOOP)); + +Cleanup: + + // Check to see if we hit error. + if(FAILED(hResult)) + { + if(NULL != *ppszBuffer) + { + delete[] *ppszBuffer; + *ppszBuffer = NULL; + } + } + + va_end(vaList); + + if(*ppszBuffer) + { + DWORD dwToReturn = 0; + + if(SUCCEEDED(SIZETToDWord(strlen(*ppszBuffer), &dwToReturn))) + { + return dwToReturn; + } + } + return 0; +} + + +DWORD CharSize(DWORD dwValue, DWORD dwBase) +{ + DWORD dwSize = 1; + + + // Make sure taht base is more than 2. + if(dwBase < 2) + { + return dwSize; + } + + // Loop until dwValue is less than dwBase, + // dividing by dwBase each time. + while(dwValue >= dwBase) + { + dwValue /= dwBase; + ++dwSize; + } + + return dwSize; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.h new file mode 100644 index 00000000..4b74bd77 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/command.h @@ -0,0 +1,22 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Command.h +// +// +// PURPOSE: Define common data types, and external function prototypes +// for OEM Command function(s). +// +#pragma once + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT PSCommand(PDEVOBJ, DWORD, PVOID, DWORD, IPrintOemDriverPS*, PDWORD pdwReturn); + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/dllentry.cpp new file mode 100644 index 00000000..3aa73908 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/dllentry.cpp @@ -0,0 +1,54 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// +// PURPOSE: Source module for DLL entry function(s). +// +// + +#include "precomp.h" +#include "wmarkps.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// + +// DllMain isn't called/used for kernel mode version. +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/drawmark.ps b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/drawmark.ps new file mode 100644 index 00000000..4e0fa74e Binary files /dev/null and b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/drawmark.ps differ diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/fdevmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/fdevmode.cpp new file mode 100644 index 00000000..e7e2d472 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/fdevmode.cpp @@ -0,0 +1,20 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: fDevmode.cpp +// +// +// PURPOSE: Place holder file for devmode functions. +// + +#include "precomp.h" +#include "wmarkps.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +#include diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.cpp new file mode 100644 index 00000000..5e892275 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.cpp @@ -0,0 +1,491 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Interface for User Mode COM Customization DLL. +// +// +#pragma once + +#include "precomp.h" + +#include "wmarkps.h" +#include "debug.h" +#include "command.h" +#include "intrface.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0; // Count of active components +static long g_cServerLocks = 0; // Count of locks + + +//////////////////////////////////////////////////////////////////////////////// +// +// IWaterMarkPS body +// +IWaterMarkPS::~IWaterMarkPS() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + + +HRESULT __stdcall IWaterMarkPS::QueryInterface(const IID& iid, void** ppv) +{ + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IWaterMarkPS::QueryInterface IUnknown.\r\n")); + } + else if (iid == IID_IPrintOemPS) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IWaterMarkPS::QueryInterface IPrintOemPs.\r\n")); + } + else + { +#if DBG && defined(USERMODE_DRIVER) + TCHAR szOutput[80] = {0}; + StringFromGUID2(iid, szOutput, _countof(szOutput)); // can not fail! + VERBOSE(DLLTEXT("IWaterMarkPS::QueryInterface interface not supported.\r\n")); +#endif + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall IWaterMarkPS::AddRef() +{ + VERBOSE(DLLTEXT("IWaterMarkPS::AddRef() entry.\r\n")); + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IWaterMarkPS::Release() +{ + VERBOSE(DLLTEXT("IWaterMarkPS::Release() entry.\r\n")); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + + +HRESULT __stdcall IWaterMarkPS::GetInfo ( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IWaterMarkPS::GetInfo entry.\r\n")); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + VERBOSE(DLLTEXT("IWaterMarkPS::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size. + if(OEMGI_GETPUBLISHERINFO != dwMode) + { + *pcbNeeded = sizeof(DWORD); + } + else + { + *pcbNeeded = sizeof(PUBLISHERINFO); + return E_FAIL; + } + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("IWaterMarkPS::GetInfo() exit insufficient buffer!\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + case OEMGI_GETPUBLISHERINFO: + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IWaterMarkPS::GetInfo() exit mode not supported.\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + return S_OK; +} + +HRESULT __stdcall IWaterMarkPS::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE(DLLTEXT("IWaterMarkPS::PublishDriverInterface() entry.\r\n")); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (this->m_pOEMHelp == NULL) + { + HRESULT hResult; + + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverPS, (void** ) &(this->m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + this->m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + + +HRESULT __stdcall IWaterMarkPS::EnableDriver(DWORD dwDriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded) +{ + VERBOSE(DLLTEXT("IWaterMarkPS::EnableDriver() entry.\r\n")); + + UNREFERENCED_PARAMETER(dwDriverVersion); + UNREFERENCED_PARAMETER(cbSize); + UNREFERENCED_PARAMETER(pded); + + // Need to return S_OK so that DisableDriver() will be called, which Releases + // the reference to the Printer Driver's interface. + // If error occurs, return E_FAIL. + return S_OK; +} + +HRESULT __stdcall IWaterMarkPS::DisableDriver(VOID) +{ + VERBOSE(DLLTEXT("IWaterMarkPS::DisaleDriver() entry.\r\n")); + + // Release reference to Printer Driver's interface. + if (this->m_pOEMHelp) + { + this->m_pOEMHelp->Release(); + this->m_pOEMHelp = NULL; + } + + return S_OK; +} + +HRESULT __stdcall IWaterMarkPS::DisablePDEV( + PDEVOBJ pdevobj) +{ + VERBOSE(DLLTEXT("IWaterMarkPS::DisablePDEV() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IWaterMarkPS::EnablePDEV( + PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem) +{ + VERBOSE(DLLTEXT("IWaterMarkPS::EnablePDEV() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(cPatterns); + UNREFERENCED_PARAMETER(phsurfPatterns); + UNREFERENCED_PARAMETER(cjGdiInfo); + UNREFERENCED_PARAMETER(pGdiInfo); + UNREFERENCED_PARAMETER(cjDevInfo); + UNREFERENCED_PARAMETER(pDevInfo); + UNREFERENCED_PARAMETER(pded); + UNREFERENCED_PARAMETER(pDevOem); + + return E_NOTIMPL; +} + + +HRESULT __stdcall IWaterMarkPS::ResetPDEV( + PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew) +{ + VERBOSE(DLLTEXT("IWaterMarkPS::ResetPDEV() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobjOld); + UNREFERENCED_PARAMETER(pdevobjNew); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkPS::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE(DLLTEXT("IWaterMarkPS:DevMode entry.\n")); + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IWaterMarkPS::Command( + PDEVOBJ pdevobj, + DWORD dwIndex, + PVOID pData, + DWORD cbSize, + OUT DWORD *pdwResult) +{ + HRESULT hResult = E_NOTIMPL; + + + VERBOSE(DLLTEXT("IWaterMarkPS::Command() entry.\r\n")); + hResult = PSCommand(pdevobj, dwIndex, pData, cbSize, m_pOEMHelp, pdwResult); + + return hResult; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + VERBOSE(DLLTEXT("IOemCF::QueryInterface interface not supported.\r\n")); + *ppv = NULL; + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + //VERBOSE(DLLTEXT("Class factory:\t\tCreate component.")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + // Create component. + IWaterMarkPS* pOemCP = new IWaterMarkPS; + if (pOemCP == NULL) + { + return E_OUTOFMEMORY; + } + + // Get the requested interface. + HRESULT hr = pOemCP->QueryInterface(iid, ppv); + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCP->Release(); + return hr; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + return S_OK; +} + + +// +// Registration functions +// + +// +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + VERBOSE(DLLTEXT("DllCanUnloadNow entered.\r\n")); + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:\tCreate class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMRENDER) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv); + pFontCF->Release(); + + return hr; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.h new file mode 100644 index 00000000..7a4a3c84 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/intrface.h @@ -0,0 +1,116 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.H +// +// +// PURPOSE: Define COM interface for User Mode Printer Customization DLL. +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IWaterMarkPS +// +// Interface for PostScript OEM sample rendering module +// +class IWaterMarkPS : public IPrintOemPS +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Method for OEM to specify DDI hook out + // + + STDMETHOD(EnableDriver) (THIS_ DWORD DriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded); + + // + // Method to notify OEM plugin that it is no longer required + // + + STDMETHOD(DisableDriver) (THIS); + + // + // Method for OEM to contruct its own PDEV + // + + STDMETHOD(EnablePDEV) (THIS_ PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem); + + // + // Method for OEM to free any resource associated with its PDEV + // + + STDMETHOD(DisablePDEV) (THIS_ PDEVOBJ pdevobj); + + // + // Method for OEM to transfer from old PDEV to new PDEV + // + + STDMETHOD(ResetPDEV) (THIS_ PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew); + + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, + POEMDMPARAM pOemDMParam); + + // + // OEMCommand - PSCRIPT only, return E_NOTIMPL on Unidrv + // + + STDMETHOD(Command) (THIS_ PDEVOBJ pdevobj, + DWORD dwIndex, + PVOID pData, + DWORD cbSize, + OUT DWORD *pdwResult); + + // + + IWaterMarkPS() { m_cRef = 1; m_pOEMHelp = NULL; }; + ~IWaterMarkPS(); + +protected: + LONG m_cRef; + IPrintOemDriverPS* m_pOEMHelp; +}; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precomp.h new file mode 100644 index 00000000..1c44a730 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precomp.h @@ -0,0 +1,51 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.h +// +// PURPOSE: Header files that should be in the precompiled header. + +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Safe integer functions to detect integer overflow/underflow conditions: +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/resource.h new file mode 100644 index 00000000..819dbd98 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by WMarkPS.rc +// +#define IDR_WATERMARK_PROLOGUE 1 +#define IDR_WATERMARK_DRAW 2 +#define RC_PSCRIPT 0x5053 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 102 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmark.ps b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmark.ps new file mode 100644 index 00000000..e9200e65 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmark.ps @@ -0,0 +1,33 @@ +userdict /DrawWaterMark { +userdict begin +/Watermark (%ls) def +/FontSize %d def +/Font /Helvetica def +/WaterMarkColor {%s setrgbcolor} bind def +/Angle %s def + +gsave +initgraphics + +Angle rotate + +clippath +pathbbox /MaxY exch def /MaxX exch def /MinY exch def /MinX exch def + +Font findfont FontSize scalefont setfont +/MarkLen Watermark stringwidth pop 1.20 mul def +WaterMarkColor + +MinY FontSize MaxY +{ + MinX MarkLen MaxX + { + 1 index moveto Watermark show + } for + pop +} bind for +grestore +end +} bind put + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmarkps.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmarkps.h new file mode 100644 index 00000000..d16c6581 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkps/wmarkps.h @@ -0,0 +1,25 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: WMarkPS.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debug.cpp. +// +#pragma once + +#include +#include + + +//////////////////////////////////////////////////////// +// OEM Defines +//////////////////////////////////////////////////////// + +#define DLLTEXT(s) "WMARKPS: " s + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj new file mode 100644 index 00000000..323f5446 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj @@ -0,0 +1,1096 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {BE3E261C-4EF8-4BC2-AAD2-49F1292512CE} + $(MSBuildProjectName) + Win10 Debug + Win32 + {975265B8-77E8-4C62-AD5A-C554605BE6DF} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + WMARKUI + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + WMARKUI.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj.Filters new file mode 100644 index 00000000..d5115804 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/WMARKUI.vcxproj.Filters @@ -0,0 +1,140 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {0B03BE39-8181-4B6F-B5BE-004CA8F13B55} + + + h;hpp;hxx;hm;inl;inc;xsd + {F94EBF1D-EB81-461D-9960-95F6ABDC92C2} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {43EA5B9C-BE86-4C59-BE80-7DAF38D33EEE} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/dllentry.cpp new file mode 100644 index 00000000..ae16c921 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/dllentry.cpp @@ -0,0 +1,52 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// +// PURPOSE: Source module for DLL entry function(s). +// + + +#include "precomp.h" +#include "wmarkui.h" +#include "debug.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/fdevmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/fdevmode.cpp new file mode 100644 index 00000000..bc8d4b6e --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/fdevmode.cpp @@ -0,0 +1,21 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: fDevmode.cpp +// +// +// PURPOSE: Place holder file for devmode functions. +// + + +#include "precomp.h" +#include "wmarkui.h" + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +#include diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.cpp new file mode 100644 index 00000000..39f8e57a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.cpp @@ -0,0 +1,27 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.cpp +// +// +// PURPOSE: File that contains all the globals. +// + +#pragma once +#include "precomp.h" +#include "wmarkui.h" + + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.h new file mode 100644 index 00000000..5472f514 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/globals.h @@ -0,0 +1,22 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.h +// +// +// PURPOSE: Lists of globals declared in Globals.cpp. +// + +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +extern HINSTANCE ghInstance; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.cpp new file mode 100644 index 00000000..d610f46d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.cpp @@ -0,0 +1,522 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.cpp +// +// PURPOSE: Implement the UI interface plug-in +// + +#include "precomp.h" + +#include "wmarkui.h" +#include "debug.h" +#include "intrface.h" + + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0 ; // Count of active components +static long g_cServerLocks = 0 ; // Count of locks + + + +//////////////////////////////////////////////////////////////////////////////// +// +// IWaterMarkUI body +// +HRESULT __stdcall IWaterMarkUI::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:QueryInterface entry.\r\n\r\n")); + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IWaterMarkUI:Return pointer to IUnknown.\r\n\r\n")); + } + else if (iid == IID_IPrintOemUI) + { + *ppv = static_cast(this) ; + VERBOSE(DLLTEXT("IWaterMarkUI:Return pointer to IPrintOemUI.\r\n")); + } + else + { + VERBOSE(DLLTEXT("IWaterMarkUI::QueryInterface: interface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IWaterMarkUI::AddRef() +{ + VERBOSE(DLLTEXT("IWaterMarkUI:AddRef entry.\r\n")); + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IWaterMarkUI::Release() +{ + VERBOSE(DLLTEXT("IWaterMarkUI:Release entry.\r\n")); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +HRESULT __stdcall IWaterMarkUI::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:PublishDriverInterface entry.\r\n")); + + UNREFERENCED_PARAMETER(pIUnknown); + + // Don't use the DriverInterface, so don't store it. + + return S_OK; +} + +HRESULT __stdcall IWaterMarkUI::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IWaterMarkUI::GetInfo entry.\r\r\n")); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + VERBOSE(DLLTEXT("IWaterMarkUI::GetInfo() exit pcbNeeded is NULL!\r\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("IWaterMarkUI::GetInfo() exit insufficient buffer!\r\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IWaterMarkUI::GetInfo() exit mode not supported.\r\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(DLLTEXT("IWaterMarkUI::GetInfo() exit S_OK.\r\r\n")); + return S_OK; +} + +HRESULT __stdcall IWaterMarkUI::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DevMode entry.\r\n")); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IWaterMarkUI::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:CommonUIProp entry.\r\n")); + + return hrOEMPropertyPage(dwMode, pOemCUIPParam); +} + + +HRESULT __stdcall IWaterMarkUI::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DocumentPropertySheets entry.\r\n")); + + UNREFERENCED_PARAMETER(pPSUIInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DevicePropertySheets entry.\r\n")); + + UNREFERENCED_PARAMETER(pPSUIInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DeviceCapabilities( + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DeviceCapabilities entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DevQueryPrintEx entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:UpgradePrinter entry.\r\n")); + + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:PrinterEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DriverEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +HRESULT __stdcall IWaterMarkUI::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:QueryColorProfile entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(ulQueryMode); + UNREFERENCED_PARAMETER(pvProfileData); + UNREFERENCED_PARAMETER(pcbProfileData); + UNREFERENCED_PARAMETER(pflProfileData); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IWaterMarkUI::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:FontInstallerDlgProc entry.\r\n")); + + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IWaterMarkUI::UpdateExternalFonts( + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:UpdateExternalFonts entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this) ; + } + else + { + WARNING(DLLTEXT("IOemCF::QueryInterface: interface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + //DbgPrint(DLLTEXT("Class factory:\t\tCreate component.")) ; + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION ; + } + + // Create component. + IWaterMarkUI* pOemCB = new IWaterMarkUI ; + if (pOemCB == NULL) + { + return E_OUTOFMEMORY ; + } + // Get the requested interface. + HRESULT hr = pOemCB->QueryInterface(iid, ppv) ; + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release() ; + return hr ; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks) ; + } + else + { + InterlockedDecrement(&g_cServerLocks) ; + } + return S_OK ; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK ; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:Create class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE ; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF ; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY ; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv) ; + pFontCF->Release() ; + + return hr ; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.h new file mode 100644 index 00000000..cccfce7d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/intrface.h @@ -0,0 +1,177 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: intrface.H +// +// PURPOSE: Define the UI interface plug-in +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IWaterMarkUI +// +class IWaterMarkUI: public IPrintOemUI +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + + IWaterMarkUI() { m_cRef = 1; }; + ~IWaterMarkUI() { }; + +protected: + LONG m_cRef; +}; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precomp.h new file mode 100644 index 00000000..e861cd21 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precomp.h @@ -0,0 +1,50 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.h +// +// PURPOSE: Header files that should be in the precompiled header. + +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "WINDDIUI.H" +#include +#include +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/resource.h new file mode 100644 index 00000000..5993d40c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/resource.h @@ -0,0 +1,24 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by wmarkui.rc +// +#define IDS_WATERMARK 1 +#define IDS_TEXT 2 +#define IDS_FONTSIZE 3 +#define IDS_ANGLE 4 +#define IDS_COLOR 5 +#define IDS_GRAY 6 +#define IDS_RED 7 +#define IDS_GREEN 8 +#define IDS_BLUE 9 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.cpp new file mode 100644 index 00000000..c09e47c6 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.cpp @@ -0,0 +1,590 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: WMarkUI.cpp +// +// +// PURPOSE: Main file for OEM UI test module. +// +// + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "wmarkui.h" + + +// This indicates to Prefast that this is a usermode driver file. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +LONG APIENTRY OEMUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems); +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams); +static DWORD FontSizeToIndex(DWORD dwFontSize); +static DWORD FontIndexToSize(DWORD dwIndex); +static DWORD TextColorToIndex(COLORREF crTextColor); +static COLORREF IndexToTextColor(DWORD dwIndex); +static PTSTR GetStringResource(HANDLE hHeap, HMODULE hModule, UINT uResource); + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM device or document property UI. +// +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hResult = S_OK; + + + VERBOSE(DLLTEXT("hrOEMPropertyPage entry.\r\n")); + + // Validate parameters. + if( (OEMCUIP_DOCPROP != dwMode) + && + (OEMCUIP_PRNPROP != dwMode) + ) + { + ERR(DLLTEXT("hrOEMPropertyPage() ERROR_INVALID_PARAMETER.\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam); + break; + + case OEMCUIP_PRNPROP: + // Don't have any Printer Proptery UI. + hResult = E_NOTIMPL; + break; + + default: + // Should never reach this! + ERR(DLLTEXT("hrOEMPropertyPage() Invalid dwMode")); + SetLastError(ERROR_INVALID_PARAMETER); + hResult = E_FAIL; + break; + } + + return hResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM device or document property UI. +// +LONG APIENTRY OEMUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("OEMUICallBack() entry.\r\n")); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Store OptItems state in DEVMODE. + pOEMDev->bEnabled = !pOEMUIParam->pOEMOptItems[0].Sel; + if(FAILED(StringCbCopyW(pOEMDev->szWaterMark, sizeof(pOEMDev->szWaterMark), (LPWSTR)pOEMUIParam->pOEMOptItems[1].pSel))) + { + ERR(DLLTEXT("OEMUICallBack() failed to copy water mark text\r\n")); + } + pOEMDev->dwFontSize = FontIndexToSize(pOEMUIParam->pOEMOptItems[2].Sel); + pOEMDev->dfRotate = (DOUBLE) pOEMUIParam->pOEMOptItems[3].Sel; + pOEMDev->crTextColor = IndexToTextColor(pOEMUIParam->pOEMOptItems[4].Sel); + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM document property UI. +// +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM document property UI. + pOEMUIParam->cOEMOptItems = 5; + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() requesting items.\r\n")); + } + else if(dwMode == OEMCUIP_DOCPROP) + { + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() fill out items.\r\n")); + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // Water Mark Section Name. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_WATERMARK); + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->bEnabled ? 0 : 1; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_COMBOBOX; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[0].pData = L"Enabled"; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[0].IconID = IDI_CPSUI_ON; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].pData = L"Disabled"; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = IDI_CPSUI_OFF; + + + // WaterMark Text. + pOEMUIParam->pOEMOptItems[1].Level = 2; + pOEMUIParam->pOEMOptItems[1].Flags = 0; + pOEMUIParam->pOEMOptItems[1].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_TEXT); + pOEMUIParam->pOEMOptItems[1].pSel = (LPTSTR) HeapAlloc(pOEMUIParam->hOEMHeap, HEAP_ZERO_MEMORY, MAX_PATH * sizeof(WCHAR)); + if (pOEMUIParam->pOEMOptItems[1].pSel == NULL) + { + ERR(DLLTEXT("hrDocumentPropertyPage() failed to copy water mark text\r\n")); + return E_OUTOFMEMORY; + } + + if(FAILED(StringCbCopyW((LPWSTR)pOEMUIParam->pOEMOptItems[1].pSel, MAX_PATH * sizeof(WCHAR), pOEMDev->szWaterMark))) + { + ERR(DLLTEXT("hrDocumentPropertyPage() failed to copy water mark text\r\n")); + } + + pOEMUIParam->pOEMOptItems[1].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[1].pOptType->Type = TVOT_EDITBOX; + pOEMUIParam->pOEMOptItems[1].pOptType->pOptParam[1].IconID = sizeof(((POEMDEV)NULL)->szWaterMark)/sizeof(WCHAR); + + + // WaterMark Font Size. + pOEMUIParam->pOEMOptItems[2].Level = 2; + pOEMUIParam->pOEMOptItems[2].Flags = 0; + pOEMUIParam->pOEMOptItems[2].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_FONTSIZE); + pOEMUIParam->pOEMOptItems[2].Sel = FontSizeToIndex(pOEMDev->dwFontSize); + + pOEMUIParam->pOEMOptItems[2].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 16); + + pOEMUIParam->pOEMOptItems[2].pOptType->Type = TVOT_COMBOBOX; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[0].pData = L"8"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[1].pData = L"9"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[2].pData = L"10"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[3].pData = L"11"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[4].pData = L"12"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[5].pData = L"14"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[6].pData = L"16"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[7].pData = L"18"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[8].pData = L"20"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[9].pData = L"22"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[10].pData = L"24"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[11].pData = L"26"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[12].pData = L"28"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[13].pData = L"36"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[14].pData = L"48"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[15].pData = L"72"; + + + // WaterMark Angle. + pOEMUIParam->pOEMOptItems[3].Level = 2; + pOEMUIParam->pOEMOptItems[3].Flags = 0; + pOEMUIParam->pOEMOptItems[3].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_ANGLE); + pOEMUIParam->pOEMOptItems[3].Sel = (LONG) pOEMDev->dfRotate; + + pOEMUIParam->pOEMOptItems[3].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[3].pOptType->Type = TVOT_UDARROW; + pOEMUIParam->pOEMOptItems[3].pOptType->pOptParam[1].IconID = 0; + pOEMUIParam->pOEMOptItems[3].pOptType->pOptParam[1].lParam = 360; + + + // WaterMark Color. + pOEMUIParam->pOEMOptItems[4].Level = 2; + pOEMUIParam->pOEMOptItems[4].Flags = 0; + pOEMUIParam->pOEMOptItems[4].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_COLOR); + pOEMUIParam->pOEMOptItems[4].Sel = TextColorToIndex(pOEMDev->crTextColor); + + pOEMUIParam->pOEMOptItems[4].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 4); + + pOEMUIParam->pOEMOptItems[4].pOptType->Type = TVOT_COMBOBOX; + pOEMUIParam->pOEMOptItems[4].pOptType->pOptParam[0].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_GRAY); + pOEMUIParam->pOEMOptItems[4].pOptType->pOptParam[1].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_RED); + pOEMUIParam->pOEMOptItems[4].pOptType->pOptParam[2].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_GREEN); + pOEMUIParam->pOEMOptItems[4].pOptType->pOptParam[3].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_BLUE); + } + + return S_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems. +// +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems) +{ + VERBOSE(DLLTEXT("InitOptItems() entry.\r\n")); + + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for(DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OptType for OptItem. +// +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams) +{ + POPTTYPE pOptType = NULL; + + + VERBOSE(DLLTEXT("CreateOptType() entry.\r\n")); + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + if(NULL != pOptType) + { + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, wOptParams * sizeof(OPTPARAM)); + if(NULL != pOptType->pOptParam) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + ERR(DLLTEXT("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n")); + + // Free allocated memory and return NULL. + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR(DLLTEXT("CreateOptType() failed to allocated memory for OPTTYPE!\r\n")); + } + + return pOptType; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts Font point size to index in combo box. +// +static DWORD FontSizeToIndex(DWORD dwFontSize) +{ + DWORD dwIndex; + + + switch(dwFontSize) + { + case 8: + dwIndex = 0; + break; + + case 9: + dwIndex = 1; + break; + + case 10: + dwIndex = 2; + break; + + case 11: + dwIndex = 3; + break; + + case 12: + dwIndex = 4; + break; + + case 14: + dwIndex = 5; + break; + + case 16: + dwIndex = 6; + break; + + case 18: + dwIndex = 7; + break; + + case 20: + dwIndex = 8; + break; + + case 22: + dwIndex = 9; + break; + + case 24: + dwIndex = 10; + break; + + case 26: + dwIndex = 11; + break; + + default: + case 28: + dwIndex = 12; + break; + + case 36: + dwIndex = 13; + break; + + case 48: + dwIndex = 14; + break; + + case 72: + dwIndex = 15; + break; + } + + + return dwIndex; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts Font combo box index to font point size. +// +static DWORD FontIndexToSize(DWORD dwIndex) +{ + DWORD dwFontSize = 0; + + + switch(dwIndex) + { + case 0: + dwFontSize = 8; + break; + + case 1: + dwFontSize = 9; + break; + + case 2: + dwFontSize = 10; + break; + + case 3: + dwFontSize = 11; + break; + + case 4: + dwFontSize = 12; + break; + + case 5: + dwFontSize = 14; + break; + + case 6: + dwFontSize = 16; + break; + + case 7: + dwFontSize = 18; + break; + + case 8: + dwFontSize = 20; + break; + + case 9: + dwFontSize = 22; + break; + + case 10: + dwFontSize = 24; + break; + + case 11: + dwFontSize = 26; + break; + + case 12: + dwFontSize = 28; + break; + + case 13: + dwFontSize = 36; + break; + + case 14: + dwFontSize = 48; + break; + + case 15: + dwFontSize = 72; + break; + } + + return dwFontSize; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts text color to combo box index. +// +static DWORD TextColorToIndex(COLORREF crTextColor) +{ + DWORD dwIndex; + + + // The color is what ever color is dominate. If none are, then it is gray. + if( (GetRValue(crTextColor) > GetGValue(crTextColor)) + && + (GetGValue(crTextColor) >= GetBValue(crTextColor)) + ) + { + // Set index to red. + dwIndex = 1; + } + else if( (GetRValue(crTextColor) < GetGValue(crTextColor)) + && + (GetGValue(crTextColor) > GetBValue(crTextColor)) + ) + { + // Set index to green. + dwIndex = 2; + } + else if( (GetRValue(crTextColor) <= GetGValue(crTextColor)) + && + (GetGValue(crTextColor) < GetBValue(crTextColor)) + ) + { + // Set index to blue. + dwIndex = 3; + } + else + { + // Set index to gray. + dwIndex = 0; + } + + return dwIndex; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts text combo box index to text color. +// +static COLORREF IndexToTextColor(DWORD dwIndex) +{ + COLORREF crTextColor; + + // Map index to desired text color. + // We just support 4 colors in the UI: Red, Green, Blue, and gray. + // The rendering module is capable of using any color for the Water Mark Text. + switch(dwIndex) + { + case 1: + // Color is red. + crTextColor = RGB(255, 216, 216); + break; + + case 2: + // Color is green. + crTextColor = RGB(216, 255, 216); + break; + + case 3: + // Color is blue. + crTextColor = RGB(216, 216, 255); + break; + + default: + case 0: + // Color is gray. + crTextColor = WATER_MARK_DEFAULT_COLOR; + break; + } + + return crTextColor; +} + +//////////////////////////////////////////////////////////////////////////////////// +// +// Retrieves pointer to a String resource. +// +static PTSTR GetStringResource(HANDLE hHeap, HMODULE hModule, UINT uResource) +{ + int nResult; + DWORD dwSize = MAX_PATH; + PTSTR pszString = NULL; + + + VERBOSE(DLLTEXT("GetStringResource() entered.\r\n")); + + // Allocate buffer for string resource from heap; let the driver clean it up. + pszString = (PTSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(TCHAR)); + if(NULL != pszString) + { + PTSTR pTemp; + + // Load string resource; resize after loading so as not to waste memory. + nResult = LoadString(hModule, uResource, pszString, dwSize); + pTemp = (PTSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszString, (nResult + 1) * sizeof(TCHAR)); + if(NULL != pTemp) + { + pszString = pTemp; + } + } + else + { + ERR(DLLTEXT("GetStringResource() failed to allocate string buffer!\r\n")); + } + + return pszString; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.def b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.def new file mode 100644 index 00000000..8bea2782 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.def @@ -0,0 +1,3 @@ +LIBRARY WMARKUI +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.h b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.h new file mode 100644 index 00000000..909056be --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.h @@ -0,0 +1,35 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: WMarkUI.H +// +// PURPOSE: Define common data types, and external function prototypes +// for WaterMark UI. +// +#pragma once + +#include +#include +#include "globals.h" + + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + + +// OEM Signature and version. +#define PROP_TITLE L"WaterMark UI Page" +#define DLLTEXT(s) "WMARKUI: " s + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.rc b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.rc new file mode 100644 index 00000000..3ac11d52 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermark/wmarkui/wmarkui.rc @@ -0,0 +1,128 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team\0" + VALUE "CompanyName", "Microsoft Corp.\0" + VALUE "FileDescription", "WaterMark UI\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "WMarkUI\0" + VALUE "LegalCopyright", "Copyright © 1998-2003\0" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation\0" + VALUE "OriginalFilename", "WMarkUI.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "Microsoft WaterMark\0" + VALUE "ProductVersion", "1.0\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_WATERMARK "Water Mark" + IDS_TEXT "Text" + IDS_FONTSIZE "Font Size" + IDS_ANGLE "Angle" + IDS_COLOR "Color" + IDS_GRAY "Gray" + IDS_RED "Red" + IDS_GREEN "Green" + IDS_BLUE "Blue" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/debug.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/debug.h new file mode 100644 index 00000000..0414569c --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/debug.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Debug.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debugging functions. Also defines the various debug macros. +// +// + +#pragma once + +///////////////////////////////////////////////////////// +// Macros +///////////////////////////////////////////////////////// +// +// These macros are used for debugging purposes. They expand +// to white spaces on a free build. Here is a brief description +// of what they do and how they are used: +// +// giDebugLevel +// Global variable which set the current debug level to control +// the amount of debug messages emitted. +// +// WARNING(msg) +// Display a message if the current debug level is <= DBG_WARNING. +// The message format is: WRN filename (linenumber): message +// +// ERR(msg) +// Similiar to WARNING macro above - displays a message +// if the current debug level is <= DBG_ERROR. +// +// ASSERT(cond) +// Verify a condition is true. If not, force a breakpoint. +// +// RIP(msg) +// Display a message and force a breakpoint. +// +// Usage: +// WARNING("App passed NULL pointer, ignoring...\n"); +// + +#define DBG_VERBOSE 0 +#define DBG_WARNING 1 +#define DBG_ERROR 2 +#define DBG_NONE 3 + +// VC and Build use different debug defines. +#if defined (DBG) || defined (_DEBUG) + + // __declspec(selectany) ensures that even if this is defined in multiple compilation + // modules, they will all resolve to the same symbol in the linked DLL + __declspec(selectany) INT giDebugLevel = 2; + + #define STRINGIZE(x) #x + #define QUOTE(x) STRINGIZE(x) + #define FILE_AND_LINE __FILE__ "@" QUOTE(__LINE__) + + #define VERBOSE(msg) { if(giDebugLevel <= DBG_VERBOSE) OutputDebugStringA( FILE_AND_LINE ": " msg); } + #define WARNING(msg) { if(giDebugLevel <= DBG_WARNING) OutputDebugStringA( FILE_AND_LINE ": Warning: " msg); } + #define ERR(msg) { if(giDebugLevel <= DBG_ERROR) OutputDebugStringA(FILE_AND_LINE ": Error:" msg); } + #define ASSERT(cond) { if (!(cond)) RIP("\n"); } + #define RIP(msg) { OutputDebugStringA(FILE_AND_LINE ": Error (not recoverable): " msg); DebugBreak(); } + +#else // !DBG + + #define VERBOSE(msg) + #define WARNING(msg) + #define ERR(msg) + #define ASSERT(cond) + #define RIP(msg) + +#endif + + + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.cpp new file mode 100644 index 00000000..328d6fb4 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.cpp @@ -0,0 +1,216 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.cpp +// +// PURPOSE: Implementation of Devmode functions shared with OEM UI and OEM rendering modules. +// + +// This file is wrapped in fdebug.cpp in other parts of the watermark sample. +// The appropriate precompiled header should be included there. +// #include "precomp.h +#include "debug.h" +#include "devmode.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam) +{ + HRESULT hResult = S_OK; + POEMDEV pOEMDevIn = NULL; + POEMDEV pOEMDevOut = NULL; + + + // Verify parameters. + if( (NULL == pOemDMParam) + || + ( (OEMDM_SIZE != dwMode) + && + (OEMDM_DEFAULT != dwMode) + && + (OEMDM_CONVERT != dwMode) + && + (OEMDM_MERGE != dwMode) + ) + ) + { + ERR(DLLTEXT("DevMode() ERROR_INVALID_PARAMETER.\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Cast generic (i.e. PVOID) to OEM private devomode pointer type. + pOEMDevIn = (POEMDEV) pOemDMParam->pOEMDMIn; + pOEMDevOut = (POEMDEV) pOemDMParam->pOEMDMOut; + + switch(dwMode) + { + case OEMDM_SIZE: + pOemDMParam->cbBufSize = sizeof(OEMDEV); + break; + + case OEMDM_DEFAULT: + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->bWmarkEnabled = WATER_MARK_DEFAULT_ENABLED; + pOEMDevOut->dwWmarkFontSize = WATER_MARK_DEFAULT_FONTSIZE; + pOEMDevOut->crWmarkTextColor = WATER_MARK_DEFAULT_COLOR; + hResult = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT); + break; + + case OEMDM_CONVERT: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + break; + + case OEMDM_MERGE: + ConvertOEMDevmode(pOEMDevIn, pOEMDevOut); + MakeOEMDevmodeValid(pOEMDevOut); + break; + } + + return hResult; +} + + +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut) +{ + HRESULT hCopy = S_OK; + + + if( (NULL == pOEMDevIn) + || + (NULL == pOEMDevOut) + ) + { + ERR(DLLTEXT("ConvertOEMDevmode() invalid parameters.\r\n")); + return FALSE; + } + + // Check OEM Signature, if it doesn't match ours, + // then just assume DMIn is bad and use defaults. + if(pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature) + { + VERBOSE(DLLTEXT("Converting private OEM Devmode.\r\n")); + + // Set the devmode defaults so that anything the isn't copied over will + // be set to the default value. + pOEMDevOut->bWmarkEnabled = WATER_MARK_DEFAULT_ENABLED; + pOEMDevOut->dwWmarkFontSize = WATER_MARK_DEFAULT_FONTSIZE; + pOEMDevOut->crWmarkTextColor = WATER_MARK_DEFAULT_COLOR; + hCopy = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT); + + // Copy the old structure in to the new using which ever size is the smaller. + // Devmode maybe from newer Devmode (not likely since there is only one), or + // Devmode maybe a newer Devmode, in which case it maybe larger, + // but the first part of the structure should be the same. + + // DESIGN ASSUMPTION: the private DEVMODE structure only gets added to; + // the fields that are in the DEVMODE never change only new fields get added to the end. + + memcpy(pOEMDevOut, pOEMDevIn, __min(pOEMDevOut->dmOEMExtra.dwSize, pOEMDevIn->dmOEMExtra.dwSize)); + + // Re-fill in the size and version fields to indicated + // that the DEVMODE is the current private DEVMODE version. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + } + else + { + WARNING(DLLTEXT("Unknown DEVMODE signature, pOEMDMIn ignored.\r\n")); + + // Don't know what the input DEVMODE is, so just use defaults. + pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION; + pOEMDevOut->bWmarkEnabled = WATER_MARK_DEFAULT_ENABLED; + pOEMDevOut->dwWmarkFontSize = WATER_MARK_DEFAULT_FONTSIZE; + pOEMDevOut->crWmarkTextColor = WATER_MARK_DEFAULT_COLOR; + hCopy = StringCbCopyW(pOEMDevOut->szWaterMark, sizeof(pOEMDevOut->szWaterMark), WATER_MARK_DEFAULT_TEXT); + } + + return SUCCEEDED(hCopy); +} + + +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode) +{ + if(NULL == pOEMDevmode) + { + return FALSE; + } + + // ASSUMPTION: pOEMDevmode is large enough to contain OEMDEV structure. + + // Make sure that dmOEMExtra indicates the current OEMDEV structure. + pOEMDevmode->dmOEMExtra.dwSize = sizeof(OEMDEV); + pOEMDevmode->dmOEMExtra.dwSignature = OEM_SIGNATURE; + pOEMDevmode->dmOEMExtra.dwVersion = OEM_VERSION; + + // bEnable should be either TRUE or FALSE. + if( (TRUE != pOEMDevmode->bWmarkEnabled) + && + (FALSE != pOEMDevmode->bWmarkEnabled) + ) + { + pOEMDevmode->bWmarkEnabled = WATER_MARK_DEFAULT_ENABLED; + } + + + // dwWmarkFontSize should be 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, or 72. + if(!IsValidFontSize(pOEMDevmode->dwWmarkFontSize)) + { + pOEMDevmode->dwWmarkFontSize = WATER_MARK_DEFAULT_FONTSIZE; + } + + // The high byte of the hi word should be zero. + if(0 != HIBYTE(HIWORD(pOEMDevmode->crWmarkTextColor))) + { + pOEMDevmode->crWmarkTextColor = WATER_MARK_DEFAULT_COLOR; + } + + // Make sure that water mark string is terminated. + pOEMDevmode->szWaterMark[WATER_MARK_TEXT_SIZE - 1] = L'\0'; + + return TRUE; +} + + +BOOL IsValidFontSize(DWORD dwWmarkFontSize) +{ + BOOL bValid = FALSE; + + + switch(dwWmarkFontSize) + { + case 8: + case 9: + case 10: + case 11: + case 12: + case 14: + case 16: + case 18: + case 20: + case 22: + case 24: + case 26: + case 28: + case 36: + case 48: + case 72: + bValid = TRUE; + break; + + default: + ERR(DLLTEXT("IsValidFontSize() found invalid font size\r\n")); + break; + } + + return bValid; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.h new file mode 100644 index 00000000..de7ee919 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/devmode.h @@ -0,0 +1,52 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Devmode.h +// +// PURPOSE: Define common data types, and external function prototypes +// for devmode functions. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Devmode Defines +//////////////////////////////////////////////////////// + +#define WATER_MARK_TEXT_SIZE 128 +#define WATER_MARK_DEFAULT_ENABLED TRUE +#define WATER_MARK_DEFAULT_FONTSIZE 28 +#define WATER_MARK_DEFAULT_COLOR RGB(230, 230, 230) +#define WATER_MARK_DEFAULT_TEXT L"WaterMark" + + + +//////////////////////////////////////////////////////// +// OEM Devmode Type Definitions +//////////////////////////////////////////////////////// + +typedef struct tagOEMDEV +{ + OEM_DMEXTRAHEADER dmOEMExtra; + BOOL bWmarkEnabled; + DWORD dwWmarkFontSize; + COLORREF crWmarkTextColor; + WCHAR szWaterMark[WATER_MARK_TEXT_SIZE]; + +} OEMDEV, *POEMDEV; + +typedef const OEMDEV *PCOEMDEV; + + + +///////////////////////////////////////////////////////// +// ProtoTypes +///////////////////////////////////////////////////////// + +HRESULT hrOEMDevMode(DWORD dwMode, POEMDMPARAM pOemDMParam); +BOOL ConvertOEMDevmode(PCOEMDEV pOEMDevIn, POEMDEV pOEMDevOut); +BOOL MakeOEMDevmodeValid(POEMDEV pOEMDevmode); +BOOL IsValidFontSize(DWORD dwWmarkFontSize); diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/oem.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/oem.h new file mode 100644 index 00000000..d63814ad --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/common/oem.h @@ -0,0 +1,23 @@ +// 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. +// +// Copyright 1997- 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: oem.H +// +// PURPOSE: Define common data types, and external function prototypes +// for debug.cpp. +// +#pragma once + +//////////////////////////////////////////////////////// +// OEM Defines +//////////////////////////////////////////////////////// + +#define OEM_SIGNATURE 'MSFT' +#define OEM_VERSION 0x00000001L + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj new file mode 100644 index 00000000..4e88c6a9 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj @@ -0,0 +1,1150 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {1D0BAFC7-C244-4EC1-9DE3-5AC3937DDD62} + $(MSBuildProjectName) + Win10 Debug + Win32 + {39C728EB-3DCE-45B1-BC93-76678BB2A0A6} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + WMARKUNIUI + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + true + Level4 + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(PreprocessorDefinitions);USERMODE_DRIVER;_UNICODE;UNICODE + %(AdditionalIncludeDirectories);..\common;. + + + %(AdditionalDependencies);kernel32.lib;user32.lib;ole32.lib;advapi32.lib;uuid.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + %(AdditionalOptions) /ignore:4070 + WMARKUNIUI.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj.Filters new file mode 100644 index 00000000..660c3ddf --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/WMARKUNIUI.vcxproj.Filters @@ -0,0 +1,140 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {6078E9AC-04DC-4263-AA1A-9501916D09D2} + + + h;hpp;hxx;hm;inl;inc;xsd + {0E5A51EE-1609-4F50-8955-63F7D0C1A20E} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {C5E399CF-1AAE-4A3D-B806-84CCA8D9930D} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/dllentry.cpp new file mode 100644 index 00000000..f4769ff4 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/dllentry.cpp @@ -0,0 +1,52 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "wmarkui.h" +#include "debug.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + ghInstance = hInst; + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/fdevmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/fdevmode.cpp new file mode 100644 index 00000000..c82072c5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/fdevmode.cpp @@ -0,0 +1,21 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: fDevmode.cpp +// +// +// PURPOSE: Place holder file for devmode functions. +// + +#include "precomp.h" +#include "wmarkui.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.cpp new file mode 100644 index 00000000..dd0ea334 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.cpp @@ -0,0 +1,26 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.cpp +// +// +// PURPOSE: File that contains all the globals. +// + +#include "precomp.h" +#include "wmarkui.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +HINSTANCE ghInstance = NULL; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.h new file mode 100644 index 00000000..eac586c2 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/globals.h @@ -0,0 +1,21 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Globals.h +// +// +// PURPOSE: Lists of globals declared in Globals.cpp. +// +// +#pragma once + +/////////////////////////////////////// +// Globals +/////////////////////////////////////// + +// Module's Instance handle from DLLEntry of process. +extern HINSTANCE ghInstance; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.cpp new file mode 100644 index 00000000..cc8cceae --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.cpp @@ -0,0 +1,525 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Interface for User Mode COM Customization DLL. +// + +#include "precomp.h" + +#include "wmarkui.h" +#include "debug.h" +#include "intrface.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0 ; // Count of active components +static long g_cServerLocks = 0 ; // Count of locks + + + +//////////////////////////////////////////////////////////////////////////////// +// +// IWaterMarkUI body +// +HRESULT __stdcall IWaterMarkUI::QueryInterface(const IID& iid, void** ppv) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:QueryInterface entry.\r\n\r\n")); + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IWaterMarkUI:Return pointer to IUnknown.\r\n\r\n")); + } + else if (iid == IID_IPrintOemUI) + { + *ppv = static_cast(this) ; + VERBOSE(DLLTEXT("IWaterMarkUI:Return pointer to IPrintOemUI.\r\n")); + } + else + { + VERBOSE(DLLTEXT("IWaterMarkUI::QueryInterface: interface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IWaterMarkUI::AddRef() +{ + VERBOSE(DLLTEXT("IWaterMarkUI:AddRef entry.\r\n")); + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IWaterMarkUI::Release() +{ + VERBOSE(DLLTEXT("IWaterMarkUI:Release entry.\r\n")); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +HRESULT __stdcall IWaterMarkUI::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:PublishDriverInterface entry.\r\n")); + + UNREFERENCED_PARAMETER(pIUnknown); + + // Don't use the DriverInterface, so don't store it. + + return S_OK; +} + +HRESULT __stdcall IWaterMarkUI::GetInfo( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IWaterMarkUI::GetInfo entry.\r\r\n")); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + VERBOSE(DLLTEXT("IWaterMarkUI::GetInfo() exit pcbNeeded is NULL!\r\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size and number of bytes written. + *pcbNeeded = sizeof(DWORD); + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + WARNING(DLLTEXT("IWaterMarkUI::GetInfo() exit insufficient buffer!\r\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IWaterMarkUI::GetInfo() exit mode not supported.\r\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(DLLTEXT("IWaterMarkUI::GetInfo() exit S_OK.\r\r\n")); + return S_OK; +} + +HRESULT __stdcall IWaterMarkUI::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DevMode entry.\r\n")); + + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IWaterMarkUI::CommonUIProp( + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:CommonUIProp entry.\r\n")); + + return hrOEMPropertyPage(dwMode, pOemCUIPParam); +} + + +HRESULT __stdcall IWaterMarkUI::DocumentPropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DocumentPropertySheets entry.\r\n")); + + UNREFERENCED_PARAMETER(pPSUIInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DevicePropertySheets( + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DevicePropertySheets entry.\r\n")); + + UNREFERENCED_PARAMETER(pPSUIInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DeviceCapabilities( + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DeviceCapabilities entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(pDeviceName); + UNREFERENCED_PARAMETER(wCapability); + UNREFERENCED_PARAMETER(pOutput); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(dwOld); + UNREFERENCED_PARAMETER(dwResult); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DevQueryPrintEx( + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DevQueryPrintEx entry.\r\n")); + + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pDQPInfo); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::UpgradePrinter( + DWORD dwLevel, + PBYTE pDriverUpgradeInfo) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:UpgradePrinter entry.\r\n")); + + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverUpgradeInfo); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::PrinterEvent( + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:PrinterEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(iDriverEvent); + UNREFERENCED_PARAMETER(dwFlags); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWaterMarkUI::DriverEvent( + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:DriverEvent entry.\r\n")); + + UNREFERENCED_PARAMETER(dwDriverEvent); + UNREFERENCED_PARAMETER(dwLevel); + UNREFERENCED_PARAMETER(pDriverInfo); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + + +HRESULT __stdcall IWaterMarkUI::QueryColorProfile( + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulQueryMode, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:QueryColorProfile entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(poemuiobj); + UNREFERENCED_PARAMETER(pPublicDM); + UNREFERENCED_PARAMETER(pOEMDM); + UNREFERENCED_PARAMETER(ulQueryMode); + UNREFERENCED_PARAMETER(pvProfileData); + UNREFERENCED_PARAMETER(pcbProfileData); + UNREFERENCED_PARAMETER(pflProfileData); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IWaterMarkUI::FontInstallerDlgProc( + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:FontInstallerDlgProc entry.\r\n")); + + UNREFERENCED_PARAMETER(hWnd); + UNREFERENCED_PARAMETER(usMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + + return E_NOTIMPL; +}; + +HRESULT __stdcall IWaterMarkUI::UpdateExternalFonts( + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges) +{ + VERBOSE(DLLTEXT("IWaterMarkUI:UpdateExternalFonts entry.\r\n")); + + UNREFERENCED_PARAMETER(hPrinter); + UNREFERENCED_PARAMETER(hHeap); + UNREFERENCED_PARAMETER(pwstrCartridges); + + return E_NOTIMPL; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this) ; + } + else + { + WARNING(DLLTEXT("IOemCF::QueryInterface: interface not supported.\r\n")); + *ppv = NULL ; + return E_NOINTERFACE ; + } + reinterpret_cast(*ppv)->AddRef() ; + return S_OK ; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef) ; +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + //DbgPrint(DLLTEXT("Class factory:\t\tCreate component.")) ; + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION ; + } + + // Create component. + IWaterMarkUI* pOemCB = new IWaterMarkUI ; + if (pOemCB == NULL) + { + return E_OUTOFMEMORY ; + } + // Get the requested interface. + HRESULT hr = pOemCB->QueryInterface(iid, ppv) ; + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCB->Release() ; + return hr ; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks) ; + } + else + { + InterlockedDecrement(&g_cServerLocks) ; + } + return S_OK ; +} + +/////////////////////////////////////////////////////////// +// +// Exported functions +// + + +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK ; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:Create class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMUI) + { + return CLASS_E_CLASSNOTAVAILABLE ; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF ; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY ; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv) ; + pFontCF->Release() ; + + return hr ; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.h new file mode 100644 index 00000000..7f1ebad8 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/intrface.h @@ -0,0 +1,178 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.H +// +// PURPOSE: Define COM interface for User Mode Printer UI plug-in. +// +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// +// IWaterMarkUI +// +class IWaterMarkUI: public IPrintOemUI +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, PVOID pBuffer, DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, POEMDMPARAM pOemDMParam) ; + + // + // OEMCommonUIProp + // + + STDMETHOD(CommonUIProp) (THIS_ + DWORD dwMode, + POEMCUIPPARAM pOemCUIPParam + ); + + // + // OEMDocumentPropertySheets + // + + STDMETHOD(DocumentPropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + // + // OEMDevicePropertySheets + // + + STDMETHOD(DevicePropertySheets) (THIS_ + PPROPSHEETUI_INFO pPSUIInfo, + LPARAM lParam + ); + + + // + // OEMDevQueryPrintEx + // + + STDMETHOD(DevQueryPrintEx) (THIS_ + POEMUIOBJ poemuiobj, + PDEVQUERYPRINT_INFO pDQPInfo, + PDEVMODE pPublicDM, + PVOID pOEMDM + ); + + // + // OEMDeviceCapabilities + // + + STDMETHOD(DeviceCapabilities) (THIS_ + POEMUIOBJ poemuiobj, + HANDLE hPrinter, + _In_ PWSTR pDeviceName, + WORD wCapability, + PVOID pOutput, + PDEVMODE pPublicDM, + PVOID pOEMDM, + DWORD dwOld, + DWORD *dwResult + ); + + // + // OEMUpgradePrinter + // + + STDMETHOD(UpgradePrinter) (THIS_ + DWORD dwLevel, + PBYTE pDriverUpgradeInfo + ); + + // + // OEMPrinterEvent + // + + STDMETHOD(PrinterEvent) (THIS_ + _In_ PWSTR pPrinterName, + INT iDriverEvent, + DWORD dwFlags, + LPARAM lParam + ); + + // + // OEMDriverEvent + // + + STDMETHOD(DriverEvent)(THIS_ + DWORD dwDriverEvent, + DWORD dwLevel, + LPBYTE pDriverInfo, + LPARAM lParam + ); + + // + // OEMQueryColorProfile + // + + STDMETHOD(QueryColorProfile) (THIS_ + HANDLE hPrinter, + POEMUIOBJ poemuiobj, + PDEVMODE pPublicDM, + PVOID pOEMDM, + ULONG ulReserved, + VOID *pvProfileData, + ULONG *pcbProfileData, + FLONG *pflProfileData); + + // + // OEMFontInstallerDlgProc + // + + STDMETHOD(FontInstallerDlgProc) (THIS_ + HWND hWnd, + UINT usMsg, + WPARAM wParam, + LPARAM lParam + ); + // + // UpdateExternalFonts + // + + STDMETHOD(UpdateExternalFonts) (THIS_ + HANDLE hPrinter, + HANDLE hHeap, + _In_ PWSTR pwstrCartridges + ); + + + IWaterMarkUI() { m_cRef = 1; }; + ~IWaterMarkUI() { }; + +protected: + LONG m_cRef; +}; + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precomp.h new file mode 100644 index 00000000..644d21cd --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precomp.h @@ -0,0 +1,54 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.H +// +// +// PURPOSE: Optimize compilation of headers that don't change frequently. +// +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "WINDDIUI.H" +#include +#include +#include + + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/resource.h new file mode 100644 index 00000000..22c03be5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/resource.h @@ -0,0 +1,26 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by wmarkui.rc +// +#define IDS_WATERMARK 1 +#define IDS_TEXT 2 +#define IDS_FONTSIZE 3 +#define IDS_COLOR 5 +#define IDS_GRAY 6 +#define IDS_RED 7 +#define IDS_GREEN 8 +#define IDS_BLUE 9 +#define IDS_ENBLED 10 +#define IDS_ENABLED 10 +#define IDS_DISABLED 11 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.cpp new file mode 100644 index 00000000..fb875d30 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.cpp @@ -0,0 +1,594 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: WMarkUI.cpp +// +// +// PURPOSE: Main file for OEM UI test module. +// +// + +#include "precomp.h" +#include "resource.h" +#include "debug.h" +#include "wmarkui.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + + +//////////////////////////////////////////////////////// +// INTERNAL MACROS and DEFINES +//////////////////////////////////////////////////////// + + + +//////////////////////////////////////////////////////// +// INTERNAL PROTOTYPES +//////////////////////////////////////////////////////// + +LONG APIENTRY OEMUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam); +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems); +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams); +static DWORD FontSizeToIndex(DWORD dwWmarkFontSize); +static DWORD FontIndexToSize(DWORD dwIndex); +static DWORD TextColorToIndex(COLORREF crWmarkTextColor); +static COLORREF IndexToTextColor(DWORD dwIndex); +static PTSTR GetStringResource(HANDLE hHeap, HMODULE hModule, UINT uResource); + + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM device or document property UI. +// +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + HRESULT hResult = S_OK; + + + VERBOSE(DLLTEXT("hrOEMPropertyPage entry.\r\n")); + + // Validate parameters. + if( (OEMCUIP_DOCPROP != dwMode) + && + (OEMCUIP_PRNPROP != dwMode) + ) + { + ERR(DLLTEXT("hrOEMPropertyPage() ERROR_INVALID_PARAMETER.\r\n")); + + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + switch(dwMode) + { + case OEMCUIP_DOCPROP: + hResult = hrDocumentPropertyPage(dwMode, pOEMUIParam); + break; + + case OEMCUIP_PRNPROP: + // Don't have any Printer Proptery UI. + hResult = E_NOTIMPL; + break; + + default: + // Should never reach this! + ERR(DLLTEXT("hrOEMPropertyPage() Invalid dwMode")); + SetLastError(ERROR_INVALID_PARAMETER); + hResult = E_FAIL; + break; + } + + return hResult; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// OptItems call back for OEM device or document property UI. +// +LONG APIENTRY OEMUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam) +{ + LONG lReturn = CPSUICB_ACTION_NONE; + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("OEMUICallBack() entry.\r\n")); + + switch(pCallbackParam->Reason) + { + case CPSUICB_REASON_APPLYNOW: + // Store OptItems state in DEVMODE. + pOEMDev->bWmarkEnabled = !pOEMUIParam->pOEMOptItems[0].Sel; + if(FAILED(StringCbCopyW(pOEMDev->szWaterMark, sizeof(pOEMDev->szWaterMark), (LPWSTR)pOEMUIParam->pOEMOptItems[1].pSel))) + { + ERR(DLLTEXT("OEMUICallBack() failed to copy water mark text\r\n")); + } + pOEMDev->dwWmarkFontSize = FontIndexToSize(pOEMUIParam->pOEMOptItems[2].Sel); + pOEMDev->crWmarkTextColor = IndexToTextColor(pOEMUIParam->pOEMOptItems[3].Sel); + break; + + default: + break; + } + + return lReturn; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems to display OEM document property UI. +// +static HRESULT hrDocumentPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam) +{ + if ( NULL == pOEMUIParam || NULL == pOEMUIParam->pOEMDM ) + { + ERR(DLLTEXT("hrDocumentPropertyPage() ERROR_INVALID_PARAMETER.\r\n")); + // Return invalid parameter error. + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + if(NULL == pOEMUIParam->pOEMOptItems) + { + // Fill in the number of OptItems to create for OEM document property UI. + pOEMUIParam->cOEMOptItems = 4; + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() requesting items.\r\n")); + } + else if(dwMode == OEMCUIP_DOCPROP) + { + POEMDEV pOEMDev = (POEMDEV) pOEMUIParam->pOEMDM; + + + VERBOSE(DLLTEXT("hrDocumentPropertyPage() fill out items.\r\n")); + + // Init UI Callback reference. + pOEMUIParam->OEMCUIPCallback = OEMUICallBack; + + // Init OEMOptItmes. + InitOptItems(pOEMUIParam->pOEMOptItems, pOEMUIParam->cOEMOptItems); + + // Fill out tree view items. + + // Water Mark Section Name. + pOEMUIParam->pOEMOptItems[0].Level = 1; + pOEMUIParam->pOEMOptItems[0].Flags = OPTIF_COLLAPSE; + pOEMUIParam->pOEMOptItems[0].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_WATERMARK); + pOEMUIParam->pOEMOptItems[0].Sel = pOEMDev->bWmarkEnabled ? 0 : 1; + + pOEMUIParam->pOEMOptItems[0].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[0].pOptType->Type = TVOT_COMBOBOX; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[0].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_ENABLED); + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[0].IconID = IDI_CPSUI_ON; + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_DISABLED); + pOEMUIParam->pOEMOptItems[0].pOptType->pOptParam[1].IconID = IDI_CPSUI_OFF; + + + // WaterMark Text. + pOEMUIParam->pOEMOptItems[1].Level = 2; + pOEMUIParam->pOEMOptItems[1].Flags = 0; + pOEMUIParam->pOEMOptItems[1].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_TEXT); + pOEMUIParam->pOEMOptItems[1].pSel = (LPTSTR) HeapAlloc(pOEMUIParam->hOEMHeap, HEAP_ZERO_MEMORY, MAX_PATH * sizeof(WCHAR)); + if (pOEMUIParam->pOEMOptItems[1].pSel == NULL) + { + ERR(DLLTEXT("hrDocumentPropertyPage() failed to copy water mark text\r\n")); + return E_OUTOFMEMORY; + } + + if(FAILED(StringCbCopyW((LPWSTR)pOEMUIParam->pOEMOptItems[1].pSel, MAX_PATH * sizeof(WCHAR), pOEMDev->szWaterMark))) + { + ERR(DLLTEXT("hrDocumentPropertyPage() failed to copy water mark text \r\n")); + } + + pOEMUIParam->pOEMOptItems[1].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 2); + + pOEMUIParam->pOEMOptItems[1].pOptType->Type = TVOT_EDITBOX; + pOEMUIParam->pOEMOptItems[1].pOptType->pOptParam[1].IconID = sizeof(((POEMDEV)NULL)->szWaterMark)/sizeof(WCHAR); + + + // WaterMark Font Size. + pOEMUIParam->pOEMOptItems[2].Level = 2; + pOEMUIParam->pOEMOptItems[2].Flags = 0; + pOEMUIParam->pOEMOptItems[2].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_FONTSIZE); + pOEMUIParam->pOEMOptItems[2].Sel = FontSizeToIndex(pOEMDev->dwWmarkFontSize); + + pOEMUIParam->pOEMOptItems[2].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 16); + + pOEMUIParam->pOEMOptItems[2].pOptType->Type = TVOT_COMBOBOX; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[0].pData = L"8"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[1].pData = L"9"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[2].pData = L"10"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[3].pData = L"11"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[4].pData = L"12"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[5].pData = L"14"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[6].pData = L"16"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[7].pData = L"18"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[8].pData = L"20"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[9].pData = L"22"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[10].pData = L"24"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[11].pData = L"26"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[12].pData = L"28"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[13].pData = L"36"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[14].pData = L"48"; + pOEMUIParam->pOEMOptItems[2].pOptType->pOptParam[15].pData = L"72"; + + + // WaterMark Color. + pOEMUIParam->pOEMOptItems[3].Level = 2; + pOEMUIParam->pOEMOptItems[3].Flags = 0; + pOEMUIParam->pOEMOptItems[3].pName = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_COLOR); + pOEMUIParam->pOEMOptItems[3].Sel = TextColorToIndex(pOEMDev->crWmarkTextColor); + + pOEMUIParam->pOEMOptItems[3].pOptType = CreateOptType(pOEMUIParam->hOEMHeap, 4); + + pOEMUIParam->pOEMOptItems[3].pOptType->Type = TVOT_COMBOBOX; + pOEMUIParam->pOEMOptItems[3].pOptType->pOptParam[0].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_GRAY); + pOEMUIParam->pOEMOptItems[3].pOptType->pOptParam[1].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_RED); + pOEMUIParam->pOEMOptItems[3].pOptType->pOptParam[2].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_GREEN); + pOEMUIParam->pOEMOptItems[3].pOptType->pOptParam[3].pData = GetStringResource(pOEMUIParam->hOEMHeap, ghInstance, IDS_BLUE); + } + + return S_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Initializes OptItems. +// +static void InitOptItems(POPTITEM pOptItems, DWORD dwOptItems) +{ + VERBOSE(DLLTEXT("InitOptItems() entry.\r\n")); + + // Zero out memory. + memset(pOptItems, 0, sizeof(OPTITEM) * dwOptItems); + + // Set each OptItem's size, and Public DM ID. + for(DWORD dwCount = 0; dwCount < dwOptItems; dwCount++) + { + pOptItems[dwCount].cbSize = sizeof(OPTITEM); + pOptItems[dwCount].DMPubID = DMPUB_NONE; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Allocates and initializes OptType for OptItem. +// +static POPTTYPE CreateOptType(HANDLE hHeap, WORD wOptParams) +{ + POPTTYPE pOptType = NULL; + + + VERBOSE(DLLTEXT("CreateOptType() entry.\r\n")); + + // Allocate memory from the heap for the OPTTYPE; the driver will take care of clean up. + pOptType = (POPTTYPE) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, sizeof(OPTTYPE)); + if(NULL != pOptType) + { + // Initialize OPTTYPE. + pOptType->cbSize = sizeof(OPTTYPE); + pOptType->Count = wOptParams; + + // Allocate memory from the heap for the OPTPARAMs for the OPTTYPE. + pOptType->pOptParam = (POPTPARAM) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, wOptParams * sizeof(OPTPARAM)); + if(NULL != pOptType->pOptParam) + { + // Initialize the OPTPARAMs. + for(WORD wCount = 0; wCount < wOptParams; wCount++) + { + pOptType->pOptParam[wCount].cbSize = sizeof(OPTPARAM); + } + } + else + { + ERR(DLLTEXT("CreateOptType() failed to allocated memory for OPTPARAMs!\r\n")); + + // Free allocated memory and return NULL. + HeapFree(hHeap, 0, pOptType); + pOptType = NULL; + } + } + else + { + ERR(DLLTEXT("CreateOptType() failed to allocated memory for OPTTYPE!\r\n")); + } + + return pOptType; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts Font point size to index in combo box. +// +static DWORD FontSizeToIndex(DWORD dwWmarkFontSize) +{ + DWORD dwIndex; + + + switch(dwWmarkFontSize) + { + case 8: + dwIndex = 0; + break; + + case 9: + dwIndex = 1; + break; + + case 10: + dwIndex = 2; + break; + + case 11: + dwIndex = 3; + break; + + case 12: + dwIndex = 4; + break; + + case 14: + dwIndex = 5; + break; + + case 16: + dwIndex = 6; + break; + + case 18: + dwIndex = 7; + break; + + case 20: + dwIndex = 8; + break; + + case 22: + dwIndex = 9; + break; + + case 24: + dwIndex = 10; + break; + + case 26: + dwIndex = 11; + break; + + case 36: + dwIndex = 13; + break; + + case 48: + dwIndex = 14; + break; + + case 72: + dwIndex = 15; + break; + + case 28: + default: + dwIndex = 12; + break; + } + + return dwIndex; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts Font combo box index to font point size. +// +static DWORD FontIndexToSize(DWORD dwIndex) +{ + DWORD dwWmarkFontSize; + + switch(dwIndex) + { + case 0: + dwWmarkFontSize = 8; + break; + + case 1: + dwWmarkFontSize = 9; + break; + + case 2: + dwWmarkFontSize = 10; + break; + + case 3: + dwWmarkFontSize = 11; + break; + + case 4: + dwWmarkFontSize = 12; + break; + + case 5: + dwWmarkFontSize = 14; + break; + + case 6: + dwWmarkFontSize = 16; + break; + + case 7: + dwWmarkFontSize = 18; + break; + + case 8: + dwWmarkFontSize = 20; + break; + + case 9: + dwWmarkFontSize = 22; + break; + + case 10: + dwWmarkFontSize = 24; + break; + + case 11: + dwWmarkFontSize = 26; + break; + + case 13: + dwWmarkFontSize = 36; + break; + + case 14: + dwWmarkFontSize = 48; + break; + + case 15: + dwWmarkFontSize = 72; + break; + + case 12: + default: + dwWmarkFontSize = 28; + break; + } + + return dwWmarkFontSize; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts text color to combo box index. +// +static DWORD TextColorToIndex(COLORREF crWmarkTextColor) +{ + DWORD dwIndex; + + + // The color is what ever color is dominate. If none are, then it is gray. + if( (GetRValue(crWmarkTextColor) > GetGValue(crWmarkTextColor)) + && + (GetGValue(crWmarkTextColor) >= GetBValue(crWmarkTextColor)) + ) + { + // Set index to red. + dwIndex = 1; + } + else if( (GetRValue(crWmarkTextColor) < GetGValue(crWmarkTextColor)) + && + (GetGValue(crWmarkTextColor) > GetBValue(crWmarkTextColor)) + ) + { + // Set index to green. + dwIndex = 2; + } + else if( (GetRValue(crWmarkTextColor) <= GetGValue(crWmarkTextColor)) + && + (GetGValue(crWmarkTextColor) < GetBValue(crWmarkTextColor)) + ) + { + // Set index to blue. + dwIndex = 3; + } + else + { + // Set index to gray. + dwIndex = 0; + } + + return dwIndex; +} + +//////////////////////////////////////////////////////////////////////////////// +// +// Converts text combo box index to text color. +// +static COLORREF IndexToTextColor(DWORD dwIndex) +{ + COLORREF crWmarkTextColor; + + // Map index to desired text color. + // We just support 4 colors in the UI: Red, Green, Blue, and gray. + // The rendering module is capable of using any color for the Water Mark Text. + switch(dwIndex) + { + case 1: + // Color is red. + crWmarkTextColor = RGB(255, 216, 216); + break; + + case 2: + // Color is green. + crWmarkTextColor = RGB(216, 255, 216); + break; + + case 3: + // Color is blue. + crWmarkTextColor = RGB(216, 216, 255); + break; + + default: + case 0: + // Color is gray. + crWmarkTextColor = WATER_MARK_DEFAULT_COLOR; + break; + } + + return crWmarkTextColor; +} + +//////////////////////////////////////////////////////////////////////////////////// +// +// Retrieves pointer to a String resource. +// +static PTSTR GetStringResource(HANDLE hHeap, HMODULE hModule, UINT uResource) +{ + int nResult; + DWORD dwSize = MAX_PATH; + PTSTR pszString = NULL; + + + VERBOSE(DLLTEXT("GetStringResource() entered.\r\n")); + + // Allocate buffer for string resource from heap; let the driver clean it up. + pszString = (PTSTR) HeapAlloc(hHeap, HEAP_ZERO_MEMORY, dwSize * sizeof(TCHAR)); + if(NULL != pszString) + { + PTSTR pTemp; + + // Load string resource; resize after loading so as not to waste memory. + nResult = LoadString(hModule, uResource, pszString, dwSize); + if (0 == nResult) + { + ERR(DLLTEXT("GetStringResource() failed to load the the string resource!\r\n")); + HeapFree(hHeap, 0, pszString); + pszString=NULL; + } + else + { + pTemp = (PTSTR) HeapReAlloc(hHeap, HEAP_ZERO_MEMORY, pszString, (nResult + 1) * sizeof(TCHAR)); + if(NULL != pTemp) + { + pszString = pTemp; + } + } + } + else + { + ERR(DLLTEXT("GetStringResource() failed to allocate string buffer!\r\n")); + } + + return pszString; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.h new file mode 100644 index 00000000..ca19064a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.h @@ -0,0 +1,37 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: WMarkUI.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for WaterMark UI. +// +#pragma once + +#include +#include +#include "globals.h" + + +//////////////////////////////////////////////////////// +// OEM UI Defines +//////////////////////////////////////////////////////// + + +// OEM Signature and version. +#define PROP_TITLE L"WaterMark UI Page" +#define DLLTEXT(s) "WMARKUI: " s + +//////////////////////////////////////////////////////// +// Prototypes +//////////////////////////////////////////////////////// + +HRESULT hrOEMPropertyPage(DWORD dwMode, POEMCUIPPARAM pOEMUIParam); + + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.rc b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.rc new file mode 100644 index 00000000..44358b9a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkui.rc @@ -0,0 +1,124 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Windows Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "WaterMarkUni UI" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "WMarkUniUI" + VALUE "LegalCopyright", "Copyright © 1998-2003" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "WMarkUniUI.dll" + VALUE "ProductName", "Microsoft WaterMark" + VALUE "ProductVersion", "1.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_WATERMARK "Water Mark" + IDS_TEXT "Text" + IDS_FONTSIZE "Font Size" + IDS_COLOR "Color" + IDS_GRAY "Gray" + IDS_RED "Red" + IDS_GREEN "Green" + IDS_BLUE "Blue" + IDS_ENABLED "Enabled" + IDS_DISABLED "Disabled" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkuniui.def b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkuniui.def new file mode 100644 index 00000000..26c192f9 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkui/wmarkuniui.def @@ -0,0 +1,3 @@ +LIBRARY WMARKUI +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj new file mode 100644 index 00000000..0ad2b890 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj @@ -0,0 +1,1090 @@ + + + + + Win10 Debug + ARM64 + + + Win10 Debug + Win32 + + + Win10 Debug + x64 + + + Win10 Release + ARM64 + + + Win10 Release + Win32 + + + Win10 Release + x64 + + + Win8.1 Debug + Win32 + + + Win8 Debug + Win32 + + + Win7 Debug + Win32 + + + Win8.1 Release + Win32 + + + Win8 Release + Win32 + + + Win7 Release + Win32 + + + Win8.1 Debug + x64 + + + Win8 Debug + x64 + + + Win7 Debug + x64 + + + Win8.1 Release + x64 + + + Win8 Release + x64 + + + Win7 Release + x64 + + + + {866141A6-4989-41D7-9409-4A5A73B535B0} + $(MSBuildProjectName) + Win10 Debug + Win32 + {FF810DA7-AF7F-4167-9078-A43C6CA46E83} + + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + False + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + False + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + Win7 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Win8 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + WindowsV6.3 + True + + WindowsApplicationForDrivers8.1 + DynamicLibrary + + + Windows10 + True + + WindowsApplicationForDrivers10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + WMARKUNI + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + true + Level4 + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(PreprocessorDefinitions);KERNEL_MODE;_UNICODE;UNICODE;OEMCOM;USERMODE_DRIVER + %(AdditionalIncludeDirectories);..\common;.. + + + %(AdditionalDependencies);uuid.lib;kernel32.lib;user32.lib;ole32.lib + + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0603 + 0x06030000 + + + 0x0A00 + 0x0A000000 + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + WMARKUNI.def + + + + + + + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Use + $(IntDir)\precomp.h.pch + + + ;%(AdditionalIncludeDirectories) + precomp.h + Create + $(IntDir)\precomp.h.pch + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj.Filters b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj.Filters new file mode 100644 index 00000000..480c5f75 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/WMARKUNI.vcxproj.Filters @@ -0,0 +1,137 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {0906BEFF-05C5-43D6-A8A8-56287C3F1FDD} + + + h;hpp;hxx;hm;inl;inc;xsd + {33052901-7C1C-4E06-A9A5-0FDB9BE8B947} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {F0995942-2A83-43B2-B61A-69B8DFE2E12D} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + Header Files + + + + + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/ddihook.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/ddihook.cpp new file mode 100644 index 00000000..36615fac --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/ddihook.cpp @@ -0,0 +1,1226 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: DDIHook.cpp +// +// +// PURPOSE: DDI Hook routines for User Mode COM Customization DLL. +// +// + +#include "precomp.h" +#include "debug.h" +#include "wmarkuni.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +// Loop limiter. +#define MAX_LOOP 10 + +void RenderWaterMark(PDEVOBJ pdevobj); +static DWORD FormatResource(_In_ LPSTR pszResource, _Out_ LPSTR *ppszBuffer, ...); +// +// OEMBitBlt +// + + + +BOOL APIENTRY +OEMBitBlt( + SURFOBJ *psoTrg, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclTrg, + POINTL *pptlSrc, + POINTL *pptlMask, + BRUSHOBJ *pbo, + POINTL *pptlBrush, + ROP4 rop4 + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMBitBlt() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoTrg->dhpdev; + + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvBitBlt)(poempdev->pfnUnidrv[UD_DrvBitBlt])) ( + psoTrg, + psoSrc, + psoMask, + pco, + pxlo, + prclTrg, + pptlSrc, + pptlMask, + pbo, + pptlBrush, + rop4)); + +} + +// +// OEMStretchBlt +// + +BOOL APIENTRY +OEMStretchBlt( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMStretchBlt() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + + // + // turn around to call Unidrv + // + + return (((PFN_DrvStretchBlt)(poempdev->pfnUnidrv[UD_DrvStretchBlt])) ( + psoDest, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDest, + prclSrc, + pptlMask, + iMode)); + +} + +// +// OEMCopyBits +// + +BOOL APIENTRY +OEMCopyBits( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDest, + POINTL *pptlSrc + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMCopyBits() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvCopyBits)(poempdev->pfnUnidrv[UD_DrvCopyBits])) ( + psoDest, + psoSrc, + pco, + pxlo, + prclDest, + pptlSrc)); + +} + +// +// OEMTextOut +// + +BOOL APIENTRY +OEMTextOut( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMTextOut() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvTextOut)(poempdev->pfnUnidrv[UD_DrvTextOut])) ( + pso, + pstro, + pfo, + pco, + prclExtra, + prclOpaque, + pboFore, + pboOpaque, + pptlOrg, + mix)); + +} + +// +// OEMStrokePath +// + +BOOL APIENTRY +OEMStrokePath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + LINEATTRS *plineattrs, + MIX mix + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMStokePath() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvStrokePath)(poempdev->pfnUnidrv[UD_DrvStrokePath])) ( + pso, + ppo, + pco, + pxo, + pbo, + pptlBrushOrg, + plineattrs, + mix)); + +} + +// +// OEMFillPath +// + +BOOL APIENTRY +OEMFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + MIX mix, + FLONG flOptions + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMFillPath() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvFillPath)(poempdev->pfnUnidrv[UD_DrvFillPath])) ( + pso, + ppo, + pco, + pbo, + pptlBrushOrg, + mix, + flOptions)); + +} + +// +// OEMStrokeAndFillPath +// + +BOOL APIENTRY +OEMStrokeAndFillPath( + SURFOBJ *pso, + PATHOBJ *ppo, + CLIPOBJ *pco, + XFORMOBJ *pxo, + BRUSHOBJ *pboStroke, + LINEATTRS *plineattrs, + BRUSHOBJ *pboFill, + POINTL *pptlBrushOrg, + MIX mixFill, + FLONG flOptions + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMStrokeAndFillPath() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvStrokeAndFillPath)(poempdev->pfnUnidrv[UD_DrvStrokeAndFillPath])) ( + pso, + ppo, + pco, + pxo, + pboStroke, + plineattrs, + pboFill, + pptlBrushOrg, + mixFill, + flOptions)); + +} + +// +// OEMRealizeBrush +// + +BOOL APIENTRY +OEMRealizeBrush( + BRUSHOBJ *pbo, + SURFOBJ *psoTarget, + SURFOBJ *psoPattern, + SURFOBJ *psoMask, + XLATEOBJ *pxlo, + ULONG iHatch + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMRealizeBrush() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoTarget->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvRealizeBrush)(poempdev->pfnUnidrv[UD_DrvRealizeBrush])) ( + pbo, + psoTarget, + psoPattern, + psoMask, + pxlo, + iHatch)); +} + +// +// OEMStartPage +// + +BOOL APIENTRY +OEMStartPage( + SURFOBJ *pso + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMStartPage() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // turn around to call Unidrv + // + + return (((PFN_DrvStartPage)(poempdev->pfnUnidrv[UD_DrvStartPage]))(pso)); + +} + +#define OEM_TESTSTRING "The DDICMDCB DLL adds this line of text." + +// +// OEMSendPage +// + +BOOL APIENTRY +OEMSendPage( + SURFOBJ *pso + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMSendPage() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + POEMDEV pOemDevmode = (POEMDEV) pdevobj->pOEMDM; + if(pOemDevmode && pOemDevmode->bWmarkEnabled) + { + RenderWaterMark(pdevobj); + } + // + // print a line of text, just for testing + // + if (pso->iType == STYPE_BITMAP) + { + pdevobj->pDrvProcs->DrvXMoveTo(pdevobj, 0, 0); + pdevobj->pDrvProcs->DrvYMoveTo(pdevobj, 0, 0); + pdevobj->pDrvProcs->DrvWriteSpoolBuf(pdevobj, OEM_TESTSTRING, + sizeof(OEM_TESTSTRING)); + } + + // + // turn around to call Unidrv + // + + return (((PFN_DrvSendPage)(poempdev->pfnUnidrv[UD_DrvSendPage]))(pso)); + +} + +// +// OEMEscape +// + +ULONG APIENTRY +OEMEscape( + SURFOBJ *pso, + ULONG iEsc, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMEscape() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvEscape)(poempdev->pfnUnidrv[UD_DrvEscape])) ( + pso, + iEsc, + cjIn, + pvIn, + cjOut, + pvOut)); + +} + +// +// OEMStartDoc +// + +BOOL APIENTRY +OEMStartDoc( + SURFOBJ *pso, + _In_ PWSTR pwszDocName, + DWORD dwJobId + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMStartDoc() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvStartDoc)(poempdev->pfnUnidrv[UD_DrvStartDoc])) ( + pso, + pwszDocName, + dwJobId)); + +} + +// +// OEMEndDoc +// + +BOOL APIENTRY +OEMEndDoc( + SURFOBJ *pso, + FLONG fl + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMEndDoc() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvEndDoc)(poempdev->pfnUnidrv[UD_DrvEndDoc])) ( + pso, + fl)); + +} + +//////// +// NOTE: +// OEM DLL needs to hook out the following six font related DDI calls only +// if it enumerates additional fonts beyond what's in the GPD file. +// And if it does, it needs to take care of its own fonts for all font DDI +// calls and DrvTextOut call. +/////// + +// +// OEMQueryFont +// + +PIFIMETRICS APIENTRY +OEMQueryFont( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG_PTR *pid + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMQueryFont() entry.\r\n")); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvQueryFont)(poempdev->pfnUnidrv[UD_DrvQueryFont])) ( + dhpdev, + iFile, + iFace, + pid)); + +} + +// +// OEMQueryFontTree +// + +PVOID APIENTRY +OEMQueryFontTree( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG iMode, + ULONG_PTR *pid + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMQueryFontTree() entry.\r\n")); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvQueryFontTree)(poempdev->pfnUnidrv[UD_DrvQueryFontTree])) ( + dhpdev, + iFile, + iFace, + iMode, + pid)); + +} + +// +// OEMQueryFontData +// + +LONG APIENTRY +OEMQueryFontData( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH hg, + GLYPHDATA *pgd, + _Out_writes_bytes_(cjSize) PVOID pv, + ULONG cjSize + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMQueryFontData() entry.\r\n")); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv if this is not the font that OEM enumerated. + // + + return (((PFN_DrvQueryFontData)(poempdev->pfnUnidrv[UD_DrvQueryFontData])) ( + dhpdev, + pfo, + iMode, + hg, + pgd, + pv, + cjSize)); + +} + +// +// OEMQueryAdvanceWidths +// + +BOOL APIENTRY +OEMQueryAdvanceWidths( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + _In_reads_(cGlyphs) HGLYPH *phg, + _Out_writes_bytes_(cGlyphs*sizeof(USHORT)) PVOID pvWidths, + ULONG cGlyphs + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMQueryAdvanceWidths() entry.\r\n")); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv if this is not the font that OEM enumerated. + // + + return (((PFN_DrvQueryAdvanceWidths) + (poempdev->pfnUnidrv[UD_DrvQueryAdvanceWidths])) ( + dhpdev, + pfo, + iMode, + phg, + pvWidths, + cGlyphs)); + +} + +// +// OEMFontManagement +// + +ULONG APIENTRY +OEMFontManagement( + SURFOBJ *pso, + FONTOBJ *pfo, + ULONG iMode, + ULONG cjIn, + _In_reads_bytes_(cjIn) PVOID pvIn, + ULONG cjOut, + _Out_writes_bytes_(cjOut) PVOID pvOut + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMFontManagement() entry.\r\n")); + + // + // Note that Unidrv will not call OEM DLL for iMode==QUERYESCSUPPORT. + // So pso is not NULL for sure. + // + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv if this is not the font that OEM enumerated. + // + + return (((PFN_DrvFontManagement)(poempdev->pfnUnidrv[UD_DrvFontManagement])) ( + pso, + pfo, + iMode, + cjIn, + pvIn, + cjOut, + pvOut)); + +} + +// +// OEMGetGlyphMode +// + +ULONG APIENTRY +OEMGetGlyphMode( + DHPDEV dhpdev, + FONTOBJ *pfo + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMGetGlyphMode() entry.\r\n")); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv if this is not the font that OEM enumerated. + // + + return (((PFN_DrvGetGlyphMode)(poempdev->pfnUnidrv[UD_DrvGetGlyphMode])) ( + dhpdev, + pfo)); + +} + +BOOL APIENTRY +OEMNextBand( + SURFOBJ *pso, + POINTL *pptl + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMNextBand() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvNextBand)(poempdev->pfnUnidrv[UD_DrvNextBand])) ( + pso, + pptl)); + +} + +BOOL APIENTRY +OEMStartBanding( + SURFOBJ *pso, + POINTL *pptl + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMStartBanding() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + POEMDEV pOemDevmode = (POEMDEV) pdevobj->pOEMDM; + if(pOemDevmode->bWmarkEnabled) + { + RenderWaterMark(pdevobj); + } + + // + // turn around to call Unidrv + // + + return (((PFN_DrvStartBanding)(poempdev->pfnUnidrv[UD_DrvStartBanding])) ( + pso, + pptl)); + + +} + +ULONG APIENTRY +OEMDitherColor( + DHPDEV dhpdev, + ULONG iMode, + ULONG rgbColor, + ULONG *pulDither + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMDitherColor() entry.\r\n")); + + pdevobj = (PDEVOBJ)dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvDitherColor)(poempdev->pfnUnidrv[UD_DrvDitherColor])) ( + dhpdev, + iMode, + rgbColor, + pulDither)); + +} + +BOOL APIENTRY +OEMPaint( + SURFOBJ *pso, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + POINTL *pptlBrushOrg, + MIX mix + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMPaint() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvPaint)(poempdev->pfnUnidrv[UD_DrvPaint])) ( + pso, + pco, + pbo, + pptlBrushOrg, + mix)); + +} + +BOOL APIENTRY +OEMLineTo( + SURFOBJ *pso, + CLIPOBJ *pco, + BRUSHOBJ *pbo, + LONG x1, + LONG y1, + LONG x2, + LONG y2, + RECTL *prclBounds, + MIX mix + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMLineTo() entry.\r\n")); + + pdevobj = (PDEVOBJ)pso->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvLineTo)(poempdev->pfnUnidrv[UD_DrvLineTo])) ( + pso, + pco, + pbo, + x1, + y1, + x2, + y2, + prclBounds, + mix)); + +} + + +// +// OEMStretchBltROP +// + +BOOL APIENTRY +OEMStretchBltROP( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlHTOrg, + RECTL *prclDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode, + BRUSHOBJ *pbo, + ROP4 rop4 + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMStretchBltROP() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvStretchBltROP)(poempdev->pfnUnidrv[UD_DrvStretchBltROP])) ( + psoDest, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlHTOrg, + prclDest, + prclSrc, + pptlMask, + iMode, + pbo, + rop4 + )); + + +} + +// +// OEMPlgBlt +// + +BOOL APIENTRY +OEMPlgBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + SURFOBJ *psoMask, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + COLORADJUSTMENT *pca, + POINTL *pptlBrushOrg, + POINTFIX *pptfixDest, + RECTL *prclSrc, + POINTL *pptlMask, + ULONG iMode + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMPlgBlt() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoDst->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvPlgBlt)(poempdev->pfnUnidrv[UD_DrvPlgBlt])) ( + psoDst, + psoSrc, + psoMask, + pco, + pxlo, + pca, + pptlBrushOrg, + pptfixDest, + prclSrc, + pptlMask, + iMode)); + +} + +// +// OEMAlphaBlend +// + +BOOL APIENTRY +OEMAlphaBlend( + SURFOBJ *psoDest, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDest, + RECTL *prclSrc, + BLENDOBJ *pBlendObj + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMAlphaBlend() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvAlphaBlend)(poempdev->pfnUnidrv[UD_DrvAlphaBlend])) ( + psoDest, + psoSrc, + pco, + pxlo, + prclDest, + prclSrc, + pBlendObj + )); + +} + +// +// OEMGradientFill +// + +BOOL APIENTRY +OEMGradientFill( + SURFOBJ *psoDest, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + TRIVERTEX *pVertex, + ULONG nVertex, + PVOID pMesh, + ULONG nMesh, + RECTL *prclExtents, + POINTL *pptlDitherOrg, + ULONG ulMode + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMGradientFill() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoDest->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvGradientFill)(poempdev->pfnUnidrv[UD_DrvGradientFill])) ( + psoDest, + pco, + pxlo, + pVertex, + nVertex, + pMesh, + nMesh, + prclExtents, + pptlDitherOrg, + ulMode + )); + +} + +BOOL APIENTRY +OEMTransparentBlt( + SURFOBJ *psoDst, + SURFOBJ *psoSrc, + CLIPOBJ *pco, + XLATEOBJ *pxlo, + RECTL *prclDst, + RECTL *prclSrc, + ULONG iTransColor, + ULONG ulReserved + ) +{ + PDEVOBJ pdevobj; + POEMPDEV poempdev; + + VERBOSE(DLLTEXT("OEMTransparentBlt() entry.\r\n")); + + pdevobj = (PDEVOBJ)psoDst->dhpdev; + poempdev = (POEMPDEV)pdevobj->pdevOEM; + + // + // turn around to call Unidrv + // + + return (((PFN_DrvTransparentBlt)(poempdev->pfnUnidrv[UD_DrvTransparentBlt])) ( + psoDst, + psoSrc, + pco, + pxlo, + prclDst, + prclSrc, + iTransColor, + ulReserved + )); + +} + +void RenderWaterMark(PDEVOBJ pdevobj) +{ + POEMDEV pOemDevmode = (POEMDEV) pdevobj->pOEMDM; + // We have a programmable palette. See GPD file for PaletteProgrammable option. + // We are programming color index 8 to the new color and selectiing it with the PJL code "\xv%da%db%dc8I\xib*v8S". + // In the font selection code, we are selecting the arial font (4148)"\x1b(19U\x1b(s4148t0b0s%dv1P" + // Cursor position is hard coded to but you it can also be made dependent on user input. + // PCL5 can print in 0,90,180 and 270 degrees. So Vertical can also be supported. + // The \x1b*v7S after the watermark sets the foreground color back to black + + /* + //Note we can push and pop the cursor position if needed. + Push/Pop Cursor position + \x1b&f0S //push + \x1b&f1S //pop + */ + + PSTR pszBuffer = NULL; + char str_wmark[]="\x1b*v%da%db%dc8I\x1b*v8S\x1b(19U\x1b(s4148t0b0s%dv1P\x1b*p1000Y\x1b*p750X%ls\x1b*v7S"; + DWORD dwLen= FormatResource (str_wmark, + &pszBuffer, + GetRValue(pOemDevmode->crWmarkTextColor), + GetGValue(pOemDevmode->crWmarkTextColor), + GetBValue(pOemDevmode->crWmarkTextColor), + pOemDevmode->dwWmarkFontSize,pOemDevmode->szWaterMark); + + if ( dwLen != 0 ) + { + pdevobj->pDrvProcs->DrvWriteSpoolBuf(pdevobj, pszBuffer, dwLen); + } + + if ( pszBuffer ) + { + delete[]pszBuffer; + pszBuffer = NULL; + } +} + + +DWORD +FormatResource( + _In_ LPSTR pszResource, + _Out_ LPSTR *ppszBuffer, + ...) +{ + DWORD dwBufferSize = 0; + DWORD dwLoop = 0; + va_list vaList; + HRESULT hResult = S_OK; + + if ( NULL == pszResource || + NULL == ppszBuffer ) + { + hResult = E_INVALIDARG; + return 0; + } + + + if ( SUCCEEDED(hResult) ) + { + dwBufferSize = (DWORD)strlen(pszResource) + MAX_PATH; + + va_start(vaList, ppszBuffer); + + // *ppszBuffer should be NULL when passed in. + *ppszBuffer = NULL; + + // Allocate and format the string. + do { + + if(NULL != *ppszBuffer) + { + delete[] *ppszBuffer; + } + *ppszBuffer = new CHAR[dwBufferSize]; + if(NULL == *ppszBuffer) + { + hResult = E_OUTOFMEMORY; + goto Cleanup; + } + + hResult = StringCbVPrintfA(*ppszBuffer, dwBufferSize, pszResource, vaList); + + if(STRSAFE_E_INSUFFICIENT_BUFFER == hResult) + { + dwBufferSize *= 2; + } + + } while ( FAILED(hResult) && (dwLoop++ < MAX_LOOP)); + } + +Cleanup: + + // Check to see if we hit error. + if(FAILED(hResult)) + { + if(NULL != *ppszBuffer) + { + delete[] *ppszBuffer; + *ppszBuffer = NULL; + } + } + + va_end(vaList); + + if ( *ppszBuffer ) + { + DWORD dwToReturn = 0; + + if (SUCCEEDED(SIZETToDWord(strlen(*ppszBuffer), &dwToReturn))) + { + return dwToReturn; + } + } + return 0; +} diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/dllentry.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/dllentry.cpp new file mode 100644 index 00000000..5230f243 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/dllentry.cpp @@ -0,0 +1,51 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: dllentry.cpp +// +// PURPOSE: Source module for DLL entry function(s). +// + +#include "precomp.h" +#include "wmarkuni.h" +#include "debug.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +/////////////////////////////////////////////////////////// +// +// DLL entry point +// +BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(lpReserved); + + switch(wReason) + { + case DLL_PROCESS_ATTACH: + VERBOSE(DLLTEXT("Process attach.\r\n")); + break; + + case DLL_THREAD_ATTACH: + VERBOSE(DLLTEXT("Thread attach.\r\n")); + break; + + case DLL_PROCESS_DETACH: + VERBOSE(DLLTEXT("Process detach.\r\n")); + break; + + case DLL_THREAD_DETACH: + VERBOSE(DLLTEXT("Thread detach.\r\n")); + break; + } + + return TRUE; +} + + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/fdevmode.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/fdevmode.cpp new file mode 100644 index 00000000..c32e0bcb --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/fdevmode.cpp @@ -0,0 +1,22 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: fDevmode.cpp +// +// +// PURPOSE: Place holder file for devmode functions. +// + +#include "precomp.h" +#include "wmarkuni.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + + +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.cpp new file mode 100644 index 00000000..5688cb8d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.cpp @@ -0,0 +1,950 @@ +// 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. +// +// Copyright 1998 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.cpp +// +// +// PURPOSE: Interface for User Mode COM Customization DLL. +// + +#include "precomp.h" + +#include "wmarkuni.h" +#include "debug.h" +#include "intrface.h" +#include "name.h" + +// indicate to prefast that this is a user-mode component. +_Analysis_mode_(_Analysis_code_type_user_driver_); + +//////////////////////////////////////////////////////// +// Internal Globals +//////////////////////////////////////////////////////// + +static long g_cComponents = 0; // Count of active components +static long g_cServerLocks = 0; // Count of locks + +//////////////////////////////////////////////////////// +// Internal Constants +//////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////// +// Warning: the following array order must match the +// order in enum ENUMHOOKS. +/////////////////////////////////////////////////////// + +static const DRVFN OEMHookFuncs[] = +{ + { INDEX_DrvRealizeBrush, (PFN) OEMRealizeBrush }, + { INDEX_DrvDitherColor, (PFN) OEMDitherColor }, + { INDEX_DrvCopyBits, (PFN) OEMCopyBits }, + { INDEX_DrvBitBlt, (PFN) OEMBitBlt }, + { INDEX_DrvStretchBlt, (PFN) OEMStretchBlt }, + { INDEX_DrvTextOut, (PFN) OEMTextOut }, + { INDEX_DrvStrokePath, (PFN) OEMStrokePath }, + { INDEX_DrvFillPath, (PFN) OEMFillPath }, + { INDEX_DrvStrokeAndFillPath, (PFN) OEMStrokeAndFillPath }, + { INDEX_DrvPaint, (PFN) OEMPaint }, + { INDEX_DrvLineTo, (PFN) OEMLineTo }, + { INDEX_DrvStartPage, (PFN) OEMStartPage }, + { INDEX_DrvSendPage, (PFN) OEMSendPage }, + { INDEX_DrvEscape, (PFN) OEMEscape }, + { INDEX_DrvStartDoc, (PFN) OEMStartDoc }, + { INDEX_DrvEndDoc, (PFN) OEMEndDoc }, + { INDEX_DrvNextBand, (PFN) OEMNextBand }, + { INDEX_DrvStartBanding, (PFN) OEMStartBanding }, + { INDEX_DrvQueryFont, (PFN) OEMQueryFont }, + { INDEX_DrvQueryFontTree, (PFN) OEMQueryFontTree }, + { INDEX_DrvQueryFontData, (PFN) OEMQueryFontData }, + { INDEX_DrvQueryAdvanceWidths, (PFN) OEMQueryAdvanceWidths }, + { INDEX_DrvFontManagement, (PFN) OEMFontManagement }, + { INDEX_DrvGetGlyphMode, (PFN) OEMGetGlyphMode }, + { INDEX_DrvStretchBltROP, (PFN) OEMStretchBltROP }, + { INDEX_DrvPlgBlt, (PFN) OEMPlgBlt }, + { INDEX_DrvTransparentBlt, (PFN) OEMTransparentBlt }, + { INDEX_DrvAlphaBlend, (PFN) OEMAlphaBlend }, + { INDEX_DrvGradientFill, (PFN) OEMGradientFill }, +}; + +//////////////////////////////////////////////////////////////////////////////// +// +// IWmarkUni body +// +IWmarkUni::~IWmarkUni() +{ + // Make sure that helper interface is released. + if(NULL != m_pOEMHelp) + { + m_pOEMHelp->Release(); + m_pOEMHelp = NULL; + } + + // If this instance of the object is being deleted, then the reference + // count should be zero. + assert(0 == m_cRef); +} + + +HRESULT __stdcall IWmarkUni::QueryInterface(const IID& iid, void** ppv) +{ + if (iid == IID_IUnknown) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IWmarkUni::QueryInterface IUnknown.\r\n")); + } + else if (iid == IID_IPrintOemUni) + { + *ppv = static_cast(this); + VERBOSE(DLLTEXT("IWmarkUni::QueryInterface IPrintOemUni.\r\n")); + } + else + { + *ppv = NULL; + VERBOSE(DLLTEXT("IWmarkUni::QueryInterface interface not supported.\r\n")); + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall IWmarkUni::AddRef() +{ + VERBOSE(DLLTEXT("IWmarkUni::AddRef() entry.\r\n")); + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IWmarkUni::Release() +{ + VERBOSE(DLLTEXT("IWmarkUni::Release() entry.\r\n")); + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + + +HRESULT __stdcall IWmarkUni::GetInfo ( + DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IWmarkUni::GetInfo entry.\r\n")); + + // Validate parameters. + if( (NULL == pcbNeeded) + || + ( (OEMGI_GETSIGNATURE != dwMode) + && + (OEMGI_GETVERSION != dwMode) + && + (OEMGI_GETPUBLISHERINFO != dwMode) + ) + ) + { + WARNING(DLLTEXT("IWmarkUni::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER.\r\n")); + SetLastError(ERROR_INVALID_PARAMETER); + return E_FAIL; + } + + // Set expected buffer size. + if(OEMGI_GETPUBLISHERINFO != dwMode) + { + *pcbNeeded = sizeof(DWORD); + } + else + { + *pcbNeeded = sizeof(PUBLISHERINFO); + return E_FAIL; + } + + // Check buffer size is sufficient. + if((cbSize < *pcbNeeded) || (NULL == pBuffer)) + { + VERBOSE(DLLTEXT("IWmarkUni::GetInfo() exit insufficient buffer!\r\n")); + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return E_FAIL; + } + + switch(dwMode) + { + // OEM DLL Signature + case OEMGI_GETSIGNATURE: + *(PDWORD)pBuffer = OEM_SIGNATURE; + break; + + // OEM DLL version + case OEMGI_GETVERSION: + *(PDWORD)pBuffer = OEM_VERSION; + break; + + // dwMode not supported. + case OEMGI_GETPUBLISHERINFO: + default: + // Set written bytes to zero since nothing was written. + WARNING(DLLTEXT("IWmarkUni::GetInfo() exit mode not supported.\r\n")); + *pcbNeeded = 0; + SetLastError(ERROR_NOT_SUPPORTED); + return E_FAIL; + } + + VERBOSE(DLLTEXT("IWmarkUni::GetInfo() exit S_OK.\r\n")); + + return S_OK; +} + +HRESULT __stdcall IWmarkUni::PublishDriverInterface( + IUnknown *pIUnknown) +{ + VERBOSE(DLLTEXT("IWmarkUni::PublishDriverInterface() entry.\r\n")); + + // Need to store pointer to Driver Helper functions, if we already haven't. + if (this->m_pOEMHelp == NULL) + { + HRESULT hResult; + + + // Get Interface to Helper Functions. + hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni, (void** ) &(this->m_pOEMHelp)); + + if(!SUCCEEDED(hResult)) + { + // Make sure that interface pointer reflects interface query failure. + this->m_pOEMHelp = NULL; + + return E_FAIL; + } + } + + return S_OK; +} + + +HRESULT __stdcall IWmarkUni::EnableDriver( + DWORD dwDriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded) +{ + VERBOSE(DLLTEXT("IWmarkUni::EnableDriver() entry.\r\n")); + + UNREFERENCED_PARAMETER(dwDriverVersion); + UNREFERENCED_PARAMETER(cbSize); + + // List DDI functions that are hooked. + pded->iDriverVersion = PRINTER_OEMINTF_VERSION; + pded->c = sizeof(OEMHookFuncs) / sizeof(DRVFN); + pded->pdrvfn = (DRVFN *) OEMHookFuncs; + + // Even if nothing is done, need to return S_OK so + // that DisableDriver() will be called, which releases + // the reference to the Printer Driver's interface. + // If error occurs, return E_FAIL. + return S_OK; +} + +HRESULT __stdcall IWmarkUni::DisableDriver(VOID) +{ + VERBOSE(DLLTEXT("IWmarkUni::DisaleDriver() entry.\r\n")); + + // Release reference to Printer Driver's interface. + if (this->m_pOEMHelp) + { + this->m_pOEMHelp->Release(); + this->m_pOEMHelp = NULL; + } + + return S_OK; +} + +HRESULT __stdcall IWmarkUni::DisablePDEV( + PDEVOBJ pdevobj) +{ + VERBOSE(DLLTEXT("IWmarkUni::DisablePDEV() entry.\r\n")); + + assert(NULL != pdevobj->pdevOEM); + delete pdevobj->pdevOEM; + + return S_OK; +}; + +HRESULT __stdcall IWmarkUni::EnablePDEV( + PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem) +{ + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pPrinterName); + UNREFERENCED_PARAMETER(cPatterns); + UNREFERENCED_PARAMETER(phsurfPatterns); + UNREFERENCED_PARAMETER(cjGdiInfo); + UNREFERENCED_PARAMETER(pGdiInfo); + UNREFERENCED_PARAMETER(cjDevInfo); + UNREFERENCED_PARAMETER(pDevInfo); + + VERBOSE(DLLTEXT("IWmarkUni::EnablePDEV() entry.\r\n")); + + POEMPDEV poempdev; + INT i, j; + DWORD dwDDIIndex; + PDRVFN pdrvfn; + + // + // Allocate the OEMDev + // + poempdev = new OEMPDEV; + if (NULL == poempdev) + { + return NULL; + } + + // + // Fill in OEMDEV + // + + for (i = 0; i < MAX_DDI_HOOKS; i++) + { + // + // search through Unidrv's hooks and locate the function ptr + // + dwDDIIndex = OEMHookFuncs[i].iFunc; + for (j = pded->c, pdrvfn = pded->pdrvfn; j > 0; j--, pdrvfn++) + { + if (dwDDIIndex == pdrvfn->iFunc) + { + poempdev->pfnUnidrv[i] = pdrvfn->pfn; + break; + } + } + if (j == 0) + { + // + // Didn't find the hook. This could mean Unidrv doesn't hook this DDI but allows OEMs to hook it out. + // + poempdev->pfnUnidrv[i] = NULL; + } + + } + + *pDevOem = (POEMPDEV) poempdev; + + return (NULL != *pDevOem ? S_OK : E_FAIL); +} + + +HRESULT __stdcall IWmarkUni::ResetPDEV( + PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew) +{ + VERBOSE(DLLTEXT("IWmarkUni::ResetPDEV() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobjOld); + UNREFERENCED_PARAMETER(pdevobjNew); + + return S_OK; +} + + +HRESULT __stdcall IWmarkUni::DevMode( + DWORD dwMode, + POEMDMPARAM pOemDMParam) +{ + VERBOSE(DLLTEXT("IWmarkUni:DevMode entry.\n")); + return hrOEMDevMode(dwMode, pOemDMParam); +} + +HRESULT __stdcall IWmarkUni::GetImplementedMethod(_In_ PSTR pMethodName) +{ + HRESULT Result = S_FALSE; + + + VERBOSE(DLLTEXT("IWmarkUni::GetImplementedMethod() entry.\r\n")); + + // Unidrv only calls GetImplementedMethod for optional + // methods. The required methods are assumed to be + // supported. + + // Return S_OK for supported function (i.e. implemented), + // and S_FALSE for functions that aren't supported (i.e. not implemented). + switch (*pMethodName) + { + case 'C': + if (!strcmp(NAME_CommandCallback, pMethodName)) + { + Result = S_OK; + } + else if (!strcmp(NAME_Compression, pMethodName)) + { + Result = S_FALSE; + } + break; + + case 'D': + if (!strcmp(NAME_DownloadFontHeader, pMethodName)) + { + Result = S_FALSE; + } + else if (!strcmp(NAME_DownloadCharGlyph, pMethodName)) + { + Result = S_FALSE; + } + break; + + case 'F': + if (!strcmp(NAME_FilterGraphics, pMethodName)) + { + Result = S_OK; + } + break; + + case 'H': + if (!strcmp(NAME_HalftonePattern, pMethodName)) + { + Result = S_FALSE; + } + break; + + case 'I': + if (!strcmp(NAME_ImageProcessing, pMethodName)) + { + Result = S_OK; + } + break; + + case 'M': + if (!strcmp(NAME_MemoryUsage, pMethodName)) + { + Result = S_FALSE; + } + break; + + case 'O': + if (!strcmp(NAME_OutputCharStr, pMethodName)) + { + Result = S_FALSE; + } + break; + + case 'S': + if (!strcmp(NAME_SendFontCmd, pMethodName)) + { + Result = S_FALSE; + } + break; + + case 'T': + if (!strcmp(NAME_TextOutAsBitmap, pMethodName)) + { + Result = S_FALSE; + } + else if (!strcmp(NAME_TTDownloadMethod, pMethodName)) + { + Result = S_FALSE; + } + else if (!strcmp(NAME_TTYGetInfo, pMethodName)) + { + Result = S_FALSE; + } + break; + + case 'W': + if(!strcmp(NAME_WritePrinter, pMethodName)) + { + Result = S_FALSE; + } + break; + } + + return Result; +} + +HRESULT __stdcall IWmarkUni::CommandCallback( + PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult) +{ + VERBOSE(DLLTEXT("IWmarkUni::CommandCallback() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pdwParams); + + *piResult = 0; + + return S_OK; +} + +HRESULT __stdcall IWmarkUni::ImageProcessing( + PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult) +{ + VERBOSE(DLLTEXT("IWmarkUni::ImageProcessing() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pSrcBitmap); + UNREFERENCED_PARAMETER(pBitmapInfoHeader); + UNREFERENCED_PARAMETER(pColorTable); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(pIPParams); + UNREFERENCED_PARAMETER(ppbResult); + + return S_OK; +} + +HRESULT __stdcall IWmarkUni::FilterGraphics( + PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen) +{ + DWORD dwResult; + VERBOSE(DLLTEXT("IWmarkUni::FilterGraphis() entry.\r\n")); + m_pOEMHelp->DrvWriteSpoolBuf(pdevobj, pBuf, dwLen, &dwResult); + + if (dwResult == dwLen) + return S_OK; + else + return E_FAIL; +} + +HRESULT __stdcall IWmarkUni::Compression( + PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult) +{ + VERBOSE(DLLTEXT("IWmarkUni::Compression() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pInBuf); + UNREFERENCED_PARAMETER(pOutBuf); + UNREFERENCED_PARAMETER(dwInLen); + UNREFERENCED_PARAMETER(dwOutLen); + UNREFERENCED_PARAMETER(piResult); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + + +HRESULT __stdcall IWmarkUni::HalftonePattern( + PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize) +{ + VERBOSE(DLLTEXT("IWmarkUni::HalftonePattern() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pHTPattern); + UNREFERENCED_PARAMETER(dwHTPatternX); + UNREFERENCED_PARAMETER(dwHTPatternY); + UNREFERENCED_PARAMETER(dwHTNumPatterns); + UNREFERENCED_PARAMETER(dwCallbackID); + UNREFERENCED_PARAMETER(pResource); + UNREFERENCED_PARAMETER(dwResourceSize); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::MemoryUsage( + PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage) +{ + VERBOSE(DLLTEXT("IWmarkUni::MemoryUsage() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pMemoryUsage); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::DownloadFontHeader( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult) +{ + VERBOSE(DLLTEXT("IWmarkUni::DownloadFontHeader() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::DownloadCharGlyph( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult) +{ + VERBOSE(DLLTEXT("IWmarkUni::DownloadCharGlyph() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(hGlyph); + UNREFERENCED_PARAMETER(pdwWidth); + UNREFERENCED_PARAMETER(pdwResult); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::TTDownloadMethod( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult) +{ + VERBOSE(DLLTEXT("IWmarkUni::TTDownloadMethod() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pdwResult); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::OutputCharStr( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph) +{ + VERBOSE(DLLTEXT("IWmarkUni::OutputCharStr() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(dwType); + UNREFERENCED_PARAMETER(dwCount); + UNREFERENCED_PARAMETER(pGlyph); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::SendFontCmd( + PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv) +{ + VERBOSE(DLLTEXT("IWmarkUni::SendFontCmd() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(pUFObj); + UNREFERENCED_PARAMETER(pFInv); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::DriverDMS( + PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded) +{ + VERBOSE(DLLTEXT("IWmarkUni::DriverDMS() entry.\r\n")); + + UNREFERENCED_PARAMETER(pDevObj); + UNREFERENCED_PARAMETER(pBuffer); + UNREFERENCED_PARAMETER(cbSize); + UNREFERENCED_PARAMETER(pcbNeeded); + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::TextOutAsBitmap( + SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix) +{ + VERBOSE(DLLTEXT("IWmarkUni::TextOutAsBitmap() entry.\r\n")); + + UNREFERENCED_PARAMETER(pso); + UNREFERENCED_PARAMETER(pstro); + UNREFERENCED_PARAMETER(pfo); + UNREFERENCED_PARAMETER(pco); + UNREFERENCED_PARAMETER(prclExtra); + UNREFERENCED_PARAMETER(prclOpaque); + UNREFERENCED_PARAMETER(pboFore); + UNREFERENCED_PARAMETER(pboOpaque); + UNREFERENCED_PARAMETER(pptlOrg); + UNREFERENCED_PARAMETER(mix); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + +HRESULT __stdcall IWmarkUni::TTYGetInfo( + PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded) +{ + VERBOSE(DLLTEXT("IWmarkUni::TTYGetInfo() entry.\r\n")); + + UNREFERENCED_PARAMETER(pdevobj); + UNREFERENCED_PARAMETER(dwInfoIndex); + UNREFERENCED_PARAMETER(pOutputBuf); + UNREFERENCED_PARAMETER(dwSize); + UNREFERENCED_PARAMETER(pcbcNeeded); + + // When implemented, the return from GetImplementedMethod + // for this method name must be S_OK. + + return E_NOTIMPL; +} + + +//////////////////////////////////////////////////////////////////////////////// +// +// oem class factory +// +class IOemCF : public IClassFactory +{ +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // *** IClassFactory methods *** + STDMETHOD(CreateInstance) (THIS_ + LPUNKNOWN pUnkOuter, + REFIID riid, + LPVOID FAR* ppvObject); + STDMETHOD(LockServer) (THIS_ BOOL bLock); + + + // Constructor + IOemCF(): m_cRef(1) { }; + ~IOemCF() { }; + +protected: + LONG m_cRef; + +}; + +/////////////////////////////////////////////////////////// +// +// Class factory body +// +HRESULT __stdcall IOemCF::QueryInterface(const IID& iid, void** ppv) +{ + if ((iid == IID_IUnknown) || (iid == IID_IClassFactory)) + { + *ppv = static_cast(this); + } + else + { + *ppv = NULL; + VERBOSE(DLLTEXT("IOemCF::QueryInterface interface not supported.\r\n")); + return E_NOINTERFACE; + } + reinterpret_cast(*ppv)->AddRef(); + return S_OK; +} + +ULONG __stdcall IOemCF::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +_At_(this, __drv_freesMem(object)) +ULONG __stdcall IOemCF::Release() +{ + ASSERT( 0 != m_cRef); + ULONG cRef = InterlockedDecrement(&m_cRef); + if (0 == cRef) + { + delete this; + + } + return cRef; +} + +// IClassFactory implementation +HRESULT __stdcall IOemCF::CreateInstance(IUnknown* pUnknownOuter, + const IID& iid, + void** ppv) +{ + //VERBOSE(DLLTEXT("Class factory:\t\tCreate component.")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Cannot aggregate. + if (pUnknownOuter != NULL) + { + return CLASS_E_NOAGGREGATION; + } + + // Create component. + IWmarkUni* pOemCP = new IWmarkUni; + if (pOemCP == NULL) + { + return E_OUTOFMEMORY; + } + + // Get the requested interface. + HRESULT hr = pOemCP->QueryInterface(iid, ppv); + + // Release the IUnknown pointer. + // (If QueryInterface failed, component will delete itself.) + pOemCP->Release(); + return hr; +} + +// LockServer +HRESULT __stdcall IOemCF::LockServer(BOOL bLock) +{ + if (bLock) + { + InterlockedIncrement(&g_cServerLocks); + } + else + { + InterlockedDecrement(&g_cServerLocks); + } + return S_OK; +} + + +// +// Registration functions +// + +// +// Can DLL unload now? +// +STDAPI DllCanUnloadNow() +{ + // + // To avoid leaving OEM DLL still in memory when Unidrv or Pscript drivers + // are unloaded, Unidrv and Pscript driver ignore the return value of + // DllCanUnloadNow of the OEM DLL, and always call FreeLibrary on the OEMDLL. + // + // If OEM DLL spins off a working thread that also uses the OEM DLL, the + // thread needs to call LoadLibrary and FreeLibraryAndExitThread, otherwise + // it may crash after Unidrv or Pscript calls FreeLibrary. + // + + VERBOSE(DLLTEXT("DllCanUnloadNow entered.\r\n")); + + if ((g_cComponents == 0) && (g_cServerLocks == 0)) + { + return S_OK; + } + else + { + return S_FALSE; + } +} + +// +// Get class factory +// +STDAPI DllGetClassObject( + _In_ REFCLSID clsid, + _In_ REFIID iid, + _Outptr_ LPVOID* ppv) +{ + VERBOSE(DLLTEXT("DllGetClassObject:\tCreate class factory.\r\n")); + + if (ppv == NULL) + { + return E_POINTER; + } + *ppv = NULL; + + // Can we create this component? + if (clsid != CLSID_OEMRENDER) + { + return CLASS_E_CLASSNOTAVAILABLE; + } + + // Create class factory. + IOemCF* pFontCF = new IOemCF; // Reference count set to 1 + // in constructor + if (pFontCF == NULL) + { + return E_OUTOFMEMORY; + } + + // Get requested interface. + HRESULT hr = pFontCF->QueryInterface(iid, ppv); + pFontCF->Release(); + + return hr; +} + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.h new file mode 100644 index 00000000..a87f5ba4 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/intrface.h @@ -0,0 +1,254 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Intrface.H +// +// +// PURPOSE: Define COM interface for User Mode Printer Customization DLL. +// +#pragma once + + +//////////////////////////////////////////////////////////////////////////////// +// +// IWmarkUni +// +// Interface for Unidrv OEM sample rendering module +// +class IWmarkUni : public IPrintOemUni +{ +public: +public: + // *** IUnknown methods *** + + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj); + + STDMETHOD_(ULONG,AddRef) (THIS); + + // the _At_ tag here tells prefast that once release + // is called, the memory should not be considered leaked + _At_(this, __drv_freesMem(object)) + STDMETHOD_(ULONG,Release) (THIS); + + // + // Method for publishing Driver interface. + // + STDMETHOD(PublishDriverInterface)(THIS_ IUnknown *pIUnknown); + + // + // Method for getting the implemented methods. + // Returns S_OK if the given method is implemneted. + // Returns S_FALSE if the given method is notimplemneted. + // + + STDMETHOD(GetImplementedMethod)(THIS_ _In_ PSTR pMethodName); + + // + // Method for OEM to specify DDI hook out + // + + STDMETHOD(EnableDriver) (THIS_ DWORD DriverVersion, + DWORD cbSize, + PDRVENABLEDATA pded); + + // + // Method to notify OEM plugin that it is no longer required + // + + STDMETHOD(DisableDriver) (THIS); + + // + // Method for OEM to contruct its own PDEV + // + + STDMETHOD(EnablePDEV) (THIS_ PDEVOBJ pdevobj, + _In_ PWSTR pPrinterName, + ULONG cPatterns, + HSURF *phsurfPatterns, + ULONG cjGdiInfo, + GDIINFO *pGdiInfo, + ULONG cjDevInfo, + DEVINFO *pDevInfo, + DRVENABLEDATA *pded, + OUT PDEVOEM *pDevOem); + + // + // Method for OEM to free any resource associated with its PDEV + // + + STDMETHOD(DisablePDEV) (THIS_ PDEVOBJ pdevobj); + + // + // Method for OEM to transfer from old PDEV to new PDEV + // + + STDMETHOD(ResetPDEV) (THIS_ PDEVOBJ pdevobjOld, + PDEVOBJ pdevobjNew); + + // + // Get OEM dll related information + // + + STDMETHOD(GetInfo) (THIS_ DWORD dwMode, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDriverDMS - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(DriverDMS)(THIS_ PVOID pDevObj, + PVOID pBuffer, + DWORD cbSize, + PDWORD pcbNeeded); + + // + // OEMDevMode + // + + STDMETHOD(DevMode) (THIS_ DWORD dwMode, + POEMDMPARAM pOemDMParam); + + // + // OEMCommandCallback - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(CommandCallback)(THIS_ PDEVOBJ pdevobj, + DWORD dwCallbackID, + DWORD dwCount, + PDWORD pdwParams, + OUT INT *piResult); + + // + // OEMImageProcessing - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(ImageProcessing)(THIS_ PDEVOBJ pdevobj, + PBYTE pSrcBitmap, + PBITMAPINFOHEADER pBitmapInfoHeader, + PBYTE pColorTable, + DWORD dwCallbackID, + PIPPARAMS pIPParams, + OUT PBYTE *ppbResult); + + // + // OEMFilterGraphics - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(FilterGraphics) (THIS_ PDEVOBJ pdevobj, + PBYTE pBuf, + DWORD dwLen); + // + // OEMCompression - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(Compression)(THIS_ PDEVOBJ pdevobj, + PBYTE pInBuf, + PBYTE pOutBuf, + DWORD dwInLen, + DWORD dwOutLen, + OUT INT *piResult); + + // + // OEMHalftone - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(HalftonePattern) (THIS_ PDEVOBJ pdevobj, + PBYTE pHTPattern, + DWORD dwHTPatternX, + DWORD dwHTPatternY, + DWORD dwHTNumPatterns, + DWORD dwCallbackID, + PBYTE pResource, + DWORD dwResourceSize); + + // + // OEMMemoryUsage - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(MemoryUsage) (THIS_ PDEVOBJ pdevobj, + POEMMEMORYUSAGE pMemoryUsage); + + // + // OEMTTYGetInfo - UNIDRV only, return E_NOTIMPL on Pscript + // + + STDMETHOD(TTYGetInfo)(THIS_ PDEVOBJ pdevobj, + DWORD dwInfoIndex, + PVOID pOutputBuf, + DWORD dwSize, + DWORD *pcbcNeeded); + + // + // OEMDownloadFontheader - UNIDRV only + // + + STDMETHOD(DownloadFontHeader)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMDownloadCharGlyph - UNIDRV only + // + + STDMETHOD(DownloadCharGlyph)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + HGLYPH hGlyph, + PDWORD pdwWidth, + OUT DWORD *pdwResult); + + // + // OEMTTDownloadMethod - UNIDRV only + // + + STDMETHOD(TTDownloadMethod)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + OUT DWORD *pdwResult); + + // + // OEMOutputCharStr - UNIDRV only + // + + STDMETHOD(OutputCharStr)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + DWORD dwType, + DWORD dwCount, + PVOID pGlyph); + + // + // OEMSendFontCmd - UNIDRV only + // + + + STDMETHOD(SendFontCmd)(THIS_ PDEVOBJ pdevobj, + PUNIFONTOBJ pUFObj, + PFINVOCATION pFInv); + + // + // OEMTextOutAsBitmap - UNIDRV only + // + + STDMETHOD(TextOutAsBitmap)(THIS_ SURFOBJ *pso, + STROBJ *pstro, + FONTOBJ *pfo, + CLIPOBJ *pco, + RECTL *prclExtra, + RECTL *prclOpaque, + BRUSHOBJ *pboFore, + BRUSHOBJ *pboOpaque, + POINTL *pptlOrg, + MIX mix); + + + IWmarkUni() { m_cRef = 1; m_pOEMHelp = NULL; }; + ~IWmarkUni(); + +protected: + LONG m_cRef; + IPrintOemDriverUni* m_pOEMHelp; +}; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/name.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/name.h new file mode 100644 index 00000000..3018823b --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/name.h @@ -0,0 +1,34 @@ +// 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. +// +// Copyright 1996 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: Name.H +// +// +// PURPOSE: Define string literals for interface funcion names. +// +#pragma once + +///////////////////////////////////////////////////////// +// String Leterals +///////////////////////////////////////////////////////// + + +CONST CHAR NAME_CommandCallback[] = "CommandCallback"; +CONST CHAR NAME_Compression[] = "Compression"; +CONST CHAR NAME_DownloadCharGlyph[] = "DownloadCharGlyph"; +CONST CHAR NAME_DownloadFontHeader[] = "DownloadFontHeader"; +CONST CHAR NAME_FilterGraphics[] = "FilterGraphics"; +CONST CHAR NAME_HalftonePattern[] = "HalftonePattern"; +CONST CHAR NAME_ImageProcessing[] = "ImageProcessing"; +CONST CHAR NAME_MemoryUsage[] = "MemoryUsage"; +CONST CHAR NAME_OutputCharStr[] = "OutputCharStr"; +CONST CHAR NAME_SendFontCmd[] = "SendFontCmd"; +CONST CHAR NAME_TextOutAsBitmap[] = "TextOutAsBitmap"; +CONST CHAR NAME_TTDownloadMethod[] = "TTDownloadMethod"; +CONST CHAR NAME_TTYGetInfo[] = "TTYGetInfo"; +CONST CHAR NAME_WritePrinter[] = "WritePrinter"; + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precomp.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precomp.h new file mode 100644 index 00000000..48078a7d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precomp.h @@ -0,0 +1,53 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: precomp.H +// +// +// PURPOSE: Optimize compilation of headers that don't change frequently. +// +#pragma once + +// Necessary for compiling under VC. +#if(!defined(WINVER) || (WINVER < 0x0500)) + #undef WINVER + #define WINVER 0x0500 +#endif +#if(!defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0500 +#endif + + + +// Required header files that shouldn't change often. + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Safe integer functions to detect integer overflow/underflow conditions: +#include + +// StrSafe.h needs to be included last +// to disallow unsafe string functions. +#include + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precompsrc.cpp b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precompsrc.cpp new file mode 100644 index 00000000..5944cf51 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/precompsrc.cpp @@ -0,0 +1 @@ +#include "precomp.h" \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/resource.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/resource.h new file mode 100644 index 00000000..35637c60 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by WMARKUNI.rc +// + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.def b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.def new file mode 100644 index 00000000..86e376e8 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.def @@ -0,0 +1,3 @@ +LIBRARY WMARKUNI +EXPORTS DllGetClassObject PRIVATE + DllCanUnloadNow PRIVATE diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.h b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.h new file mode 100644 index 00000000..87415a42 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.h @@ -0,0 +1,82 @@ +// 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. +// +// Copyright 1997 - 2003 Microsoft Corporation. All Rights Reserved. +// +// FILE: WMARKUNI.H +// +// +// PURPOSE: Define common data types, and external function prototypes +// for debug.cpp. +// +#pragma once + +#include "OEM.H" +#include "DEVMODE.H" + + +//////////////////////////////////////////////////////// +// OEM Defines +//////////////////////////////////////////////////////// + +#define DLLTEXT(s) "WMARKUNI: " s + +/////////////////////////////////////////////////////// +// Warning: the following enum order must match the +// order in OEMHookFuncs[]. +/////////////////////////////////////////////////////// +typedef enum tag_Hooks { + UD_DrvRealizeBrush, + UD_DrvDitherColor, + UD_DrvCopyBits, + UD_DrvBitBlt, + UD_DrvStretchBlt, + UD_DrvTextOut, + UD_DrvStrokePath, + UD_DrvFillPath, + UD_DrvStrokeAndFillPath, + UD_DrvPaint, + UD_DrvLineTo, + UD_DrvStartPage, + UD_DrvSendPage, + UD_DrvEscape, + UD_DrvStartDoc, + UD_DrvEndDoc, + UD_DrvNextBand, + UD_DrvStartBanding, + UD_DrvQueryFont, + UD_DrvQueryFontTree, + UD_DrvQueryFontData, + UD_DrvQueryAdvanceWidths, + UD_DrvFontManagement, + UD_DrvGetGlyphMode, + UD_DrvStretchBltROP, + UD_DrvPlgBlt, + UD_DrvTransparentBlt, + UD_DrvAlphaBlend, + UD_DrvGradientFill, + + MAX_DDI_HOOKS, + +} ENUMHOOKS; + + +typedef struct _OEMPDEV { + // + // define whatever needed, such as working buffers, tracking information, + // etc. + // + // This test DLL hooks out every drawing DDI. So it needs to remember + // Unidrv's hook function pointer so it call back. + // + PFN pfnUnidrv[MAX_DDI_HOOKS]; + + // + // define whatever needed, such as working buffers, tracking information, + // etc. + // + DWORD dwReserved[1]; + +} OEMPDEV, *POEMPDEV; diff --git a/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.rc b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.rc new file mode 100644 index 00000000..54b0f627 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/watermarkuni/wmarkuni/wmarkuni.rc @@ -0,0 +1,104 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Written by Printing & Imaging Team" + VALUE "CompanyName", "Microsoft Corp." + VALUE "FileDescription", "Watermark Unidriver Sample" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "OEMPS" + VALUE "LegalCopyright", "Copyright © 1998-2003" + VALUE "LegalTrademarks", "Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation" + VALUE "OriginalFilename", "WMARKUNI.DLL" + VALUE "ProductName", "Microsoft WMARKUNI" + VALUE "ProductVersion", "1.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/print/OEM Printer Customization Plug-in Samples/C++/winxp.inf b/print/OEM Printer Customization Plug-in Samples/C++/winxp.inf new file mode 100644 index 00000000..43fe3e21 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/C++/winxp.inf @@ -0,0 +1,139 @@ +; Winxp.INF +; +; INF file for OEM DLL Print UI Replacement sample +; +; Copyright 2001-2003 Microsoft Corporation + + +[Version] +Signature="$Windows NT$" +Provider=%MS% +LayoutFile=ntprint.inf +ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} +Class=Printer +DriverVer=6/07/2001,1.0.0.1 + +; +; Manufacturer section. +; +; This section lists all of the manufacturers +; that we will display in the Dialog box +; +[Manufacturer] +"Microsoft"=Microsoft, NTamd64, NTia64 + +; +; Model sections. +; +; Each section here corresponds with an entry listed in the +; [Manufacturer] section, above. The models will be displayed in the order +; that they appear in the INF file. +; + +[Microsoft] +"Themed OEM UI (Unidrv)" = THEMEUI.UNI +"Themed OEM UI (PScript5)" = THEMEUI.PS +"PS Standard UI Replacement" = PSUIREP.PS + +[Microsoft.NTamd64] +"Themed OEM UI (Unidrv)" = THEMEUI.UNI +"Themed OEM UI (PScript5)" = THEMEUI.PS +"PS Standard UI Replacement" = PSUIREP.PS + +[Microsoft.NTia64] +"Themed OEM UI (Unidrv)" = THEMEUI.UNI +"Themed OEM UI (PScript5)" = THEMEUI.PS +"PS Standard UI Replacement" = PSUIREP.PS + +; +; Installer Sections +; +; These sections control file installation, and reference all files that +; need to be copied. The section name will be assumed to be the driver +; file, unless there is an explicit DriverFile section listed. +; + +[THEMEUI.UNI] +CopyFiles=@OEM.GPD +CopyFiles=@THEMEUI.INI +CopyFiles=THEMEUI +DataFile=OEM.GPD +DataSection=UNIDRV_DATA +Include=NTPRINT.INF +Needs=UNIDRV.OEM,TTFSUB.OEM,UNIDRV_DATA + +[THEMEUI.PS] +CopyFiles=@OEM.PPD +CopyFiles=@THEMEUI.INI +CopyFiles=THEMEUI +DataFile=OEM.PPD +DataSection=PSCRIPT_DATA +Include=NTPRINT.INF +Needs=PSCRIPT.OEM,PSCRIPT_DATA + +[PSUIREP.PS] +CopyFiles=@OEM.PPD +CopyFiles=@PSUIREP.INI +CopyFiles=PSUIREP +DataFile=OEM.PPD +DataSection=PSCRIPT_DATA +Include=NTPRINT.INF +Needs=PSCRIPT.OEM,PSCRIPT_DATA + + +; Copy Sections +; +; Lists of files that are actually copied. These sections are referenced +; from the installer sections, above. Only create a section if it contains +; two or more files (if we only copy a single file, identify it in the +; installer section, using the @filename notation) or if it's a color +; profile (since the DestinationDirs can only handle sections, and not +; individual files). +; + +[THEMEUI] +ThemeUISmpl.DLL + +[PSUIREP] +PSUIREP.DLL + + +; +; Location of source files not in Layout.inf. +; + +[SourceDisksNames] +100 = %OEMRepUISample% + +[SourceDisksFiles.x86] +THEMEUISmpl.DLL = 100,ThemeUI\x86 +PSUIREP.DLL = 100,PSUIRep\x86 + +[SourceDisksFiles.amd64] +THEMEUISmpl.DLL = 100,ThemeUI\amd64 +PSUIREP.DLL = 100,PSUIRep\amd64 + +[SourceDisksFiles.ia64] +THEMEUISmpl.DLL = 100,ThemeUI\ia64 +PSUIREP.DLL = 100,PSUIRep\ia64 + +[SourceDisksFiles] +OEM.PPD = 100 +OEM.GPD = 100 +THEMEUI.INI = 100 +PSUIREP.INI = 100 + +; +; Call SetupSetDirectoryId with 66000 to set the target directory at runtime +; (depending on which environment drivers are getting installed) +; + +[DestinationDirs] +DefaultDestDir=66000 + +; +; Localizable Strings +; +[Strings] +MS="Microsoft DDK Sample" +OEMRepUISample="OEM DLL Print UI Replacement sample" diff --git a/print/OEM Printer Customization Plug-in Samples/README.md b/print/OEM Printer Customization Plug-in Samples/README.md new file mode 100644 index 00000000..1d6a8ac5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/README.md @@ -0,0 +1,87 @@ +# OEM Printer Customization Plug-in Samples + +The OEMDLL samples are an illustration of OEM customization plug-ins. The BITMAP, OEMPS, OEMUI, OEMUNI, OEMPREAN, CUSTHLP, SyncSet, ThemeUI, PSUIRep, and Watermark samples do not affect the printer output. They are only examples of how to build OEM Customization DLLs of various types. + +The following samples are included as part of this sample set: + +| Sample | Description | +|--------|-------------| +| BITMAP | a Unidrv-based bitmap rendering plug-in. This sample demonstrates how to write a Unidrv-based rendering plug-in that functions as a bitmap driver. The sample is based on the redesigned version of the OEMUNI sample. | +| CUSTHLP | An OEM help-customization plug-in. This sample demonstrates adding OEM help to your customization plug-in and how to replace standard Microsoft supplied help with customized help. | +| OEMPREAN | illustrates how you can leverage the pre-analysis feature in Unidrv. This sample is built on the redesigned version of the OEMUNI sample. | +| OEMPS | A PostScript rendering plug-in. This sample demonstrates how to write a PostScript-based rendering plug-in. | +| OEMUI | A user interface plug-in (both PostScript and Unidrv flavors are available). The OEMUI sample demonstrates common UI tasks such as adding additional elements to the UI (that is, items and pages). | +| OEMUNI | A user interface plug-in (both PostScript and Unidrv flavors are available). The OEMUI sample demonstrates common UI tasks such as adding additional elements to the UI (that is, items and pages). | +| PSUIREP | A PostScript UI replacement sample. This sample demonstrates how to completely replace the standard printer driver UI for PostScript driver plug-ins. | +| PTPCPIPR | The Unidrv Plug-in for Print Ticket Provider Interface sample contains a functional Unidrv configuration plug-in that implements the IPrintOemPrintTicketProvider interface. You can use this code as a starting point for developing new driver plug-ins that support PrintTicket functionality. | +| SYNCSET | A synchronization plug-in. This sample demonstrates how to synchronize driver settings between the OEM customization page and the standard device settings page. | +| THEMEUI | A theming plug-in. This sample demonstrates how to use theming (that is, comctl v6) for printer driver UI. | +| UNIUIREP | This Universal Printer Driver (Unidrv) UI plugin sample shows how to fully replace Unidrv's standard UI and how to use the new IPrintCoreHelper interface to enumerate GDP features/options, enumerate constraints, get/set Unidrv settings, and create a GDL snapshot. | +| WATERMARK | Demonstrates how to produce customizable watermark page simulation by controlling PostScript injected in the printing stream. The components of the sample include a PostScript-based rendering module in conjunction with a UI module. The rendering module is responsible for the injection of the modified PostScript into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and rendering modules. | +| WATERMARKUNI | Demonstrates how to produce customizable watermark page simulation by controlling PCL data injected in the printing stream. The components of the sample include a UNIDRV-based rendering module in conjunction with a UI module. The rendering module is responsible for the injection of the PCL data into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and rendering modules. This sample works only if you have a page printer that has its own fonts. It doesn't download any fonts nor convert fonts to bitmap. | + +For information about how to develop a plug-in for customizing the print driver UI, see COM Interfaces for UI Plug-Ins. +**Note** The OEMDLL samples are for the v3 print driver model only. +**Note** +To build this sample, you can use Microsoft Visual Studio 2013 (Express, Professional, or Ultimate) and Windows Driver Kit (WDK) 8.1 Update. You can get Visual Studio 2013 and WDK 8.1 Update here. +You can also build this sample with Visual Studio 2013 (Professional or Ultimate) and Windows Driver Kit (WDK) 8.1. +For Windows Driver Kit (WDK) 8 samples, download the WDK 8 samples pack. The samples in the WDK 8 samples pack will build only with Microsoft Visual Studio Professional 2012 (Professional or Ultimate) and WDK 8. + +Operating system requirements +Client +Windows 7 +Server +Windows Server 2008 R2 +Build the sample +To build a driver solution using Windows 8.1 driver kit (Windows Driver Kit (WDK)) and Visual Studio 2013, perform the following steps. +1. Open the solution file in Visual Studio 2013 +2. Add all non-binary files (usually located in the \install directory of the sample) to the Package project +a. In the Solution Explorer, right click Driver Files +b. Select Add, then click Existing Item +c. Navigate to the location to which you downloaded the sample, and select all the files in the install directory, or the equivalent set of non-binary files such as INFs, INIs, GPD, PPD files, etc. +d. Click Add +3. Configure these files to be added into the driver package +a. In the Solution Explorer, right click the Package project and select Properties +b. In the left pane, click Configuration Properties > Driver Install > Package Files. +c. In the right pane, use the ellipsis button (...) to browse to the set of files that needs to be added to the driver package. All the data files that you added in Step 2-c, except the INF file, should be added. +Note This configuration is per-architecture, so this configuration must be repeated for each architecture that will be built. +d. Click OK +4. Open the INF file and edit it to match the built output +a. Open the INF file +b. In the Version section, add a reference to a catalog file like this: CatalogFile=XpsDrvSmpl.cat +c. In the SourceDisksFiles section, change the location of the DLL files you are building, to =1. This indicates that there is no architecture specific directory in this driver. If you ship multiple architectures simultaneously, you will need to collate the driver INF manually. + +At this point, Visual Studio 2013 will be able to build a driver package and output the files to disk. In order to configure driver signing and deployment, see Developing, Testing, and Deploying Drivers. +For more information about how to build a driver solution using Microsoft Visual Studio, see Building a Driver. +Run the sample +Installation +After building the samples, you can install them by using the Add Printer Wizard. Select the local printer, click Have Disk, and point to the directory that contains the relevant INF (oemdll.inf, bitmap.inf, oemprean.inf, and so on) file. +Design and Operation +BITMAP + +This sample includes the following features: +The supported ColorMode options in the bitmap driver's GPD are monochrome, 4bpp, 8bpp, and 24bpp. +The bitmap driver implements the IPrintOemUni::ImageProcessing callback to access bitmap data one band at a time. The driver's implementation of ImageProcessing buffers the band data every time it is called. The function is also responsible for filling the BITMAPINFOHEADER and COLORTABLE structures that are necessary for dumping the data out to a bitmap file. +The bitmap driver implements the OEMEndDoc DDI hook to dump the buffered bitmap data to the spooler at the end of the print job. The driver's implementation of OEMEndDoc dumps the headers first and then the buffered data. +The GrowBuffer helper function is called every time the buffer needs to be enlarged to hold the bitmap data. +The bitmap driver renders multi-page documents into a single large output bitmap file. +This sample has the following limitations: +The plug-in does not support landscape orientation although the option exists in the GPD. +In 24bpp mode, documents larger than three pages will produce an extremely large bitmap (.bmp) file. Although the output is correct, you might not be able to view it because of memory limitations in the bitmap viewer. + +OEMPREAN +When preanalysis is enabled in the GPD (for more details about preanalysis, see the WDK documentation), Unidrv defines the surface as a banding surface but causes the first playback (that is, the first band) to be of the entire page. Unidrv performs this definition by setting the GDI clip window to the entire page. Unidrv enables all drawing commands to be hooked but returns before any drawing can be done. On the subsequent passes, Unidrv resets the clip window back to the original band size and bands normally. +In order for plugins to also take part in preanalysis, they can enable OEM preanalysis by specifying the "*PreAnalysisOptions: 8" parameter in the GPD. The OEM rendering plug-in must hook both DrvStartBanding and DrvNextBand when this mode is enabled in the GPD. The OEM rendering plug-in must test the pptl parameter of the OEMStartBanding call to determine whether preanalysis has been enabled on this page. If the pptl parameter is NULL, preanalysis has been enabled, and the OEM rendering plug-in should consider all drawing calls up to the first call to OEMNextBand to be part of preanalysis. +During these preanalysis phase drawing calls, the plug-in should not draw on the surface. The plug-in should also not call back into unidrv. You should use this phase only for analysis of the objects on the page. For example, certain printers need to handle black objects that intersect with color objects differently from black objects that appear by themselves. Other printers might need to halftone StretchBlt objects differently from BitBlt objects. +You should be aware that after preanalysis, you might get more calls than you saw in the normal rendering, because primitives that cross band boundaries yield two or more DDI calls after the preanalysis pass. +The sample uses the bPreAnalysis flag in the OEMPDEV structure to denote whether a particular pass is the preanalysis pass or the actual rendering pass. If the bPreAnalysis flag is set, it indicates that the current pass is the preanalysis pass. The sample implements all of the drawing function hooks in Ddihook.cpp. The sample uses the OEMStartBanding and OEMNextBand functions to respectively set and reset the bPreAnalysis flag. The sample also uses the DBG_CLIPOBJ debug macro function to dump the bounds of the clipping rectangle available for preanalysis in each of the drawing functions during the preanalysis pass. To view all of the debug output in the debugger, you must set the debug level to VERBOSE. The rest of the sample is identical to the Oemuni sample that illustrates a basic OEM rendering plug-in. +Note that the surface used during preanalysis might differ from the surface passed in during the rendering pass. +PTPCPIPR +This sample is an educational example that illustrates the basic functionality that a Unidrv plug-in for the IPrintOemPrintTicketProvider interface should implement. +The primary functionality of the plug-in is to support the PhotoPrintingIntent PrintSchema keyword. The PhotoPrintingIntent keyword is designed to provide a mechanism for photo printers to support enhancements that are specific to photo printing. An application or the user (through the print UI) can then specify whether a particular print job is a photo-printing job, in which case the device can apply appropriate enhancements. +The intent setting is communicated to the device driver in a PrintTicket. The actual enhancements made are device-specific, and as such, the driver has to map the high-level intent setting into specific output settings, like resolution or bpp. This plug-in sample demonstrates the conversion. +The plug-in implements the ExpandIntentOptions method of the IPrintOemPrintTicketProvider interface. This method is called with an input print-ticket. The plug-in checks if the print-ticket contains a photo-printing intent setting, and if so, removes the setting, while instead adding to the print-ticket output settings as mentioned above. The code sample uses MSXML6 for all PrintTicket XML handling. +UINUIREP +This sample shows how a plug-in for a Unidrv-based driver can replace the default UI. It provides new property sheets for the printer property and printing preferences pages. +Use this sample as an example of implementing full UI replacement in a Unidrv-based plugin. It also demonstrates the use of the new IPrintCoreHelper interface. +This sample is only provided for educational purposes and should not be used in a production environment. \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/description.html b/print/OEM Printer Customization Plug-in Samples/description.html new file mode 100644 index 00000000..4f819aa9 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/description.html @@ -0,0 +1,430 @@ + + + + + + + OEM Printer Customization Plug-in Samples + + + + + + +
+

OEM Printer Customization Plug-in Samples

+
+
+
+
+ +
+ printer, Windows Driver +
+
+
+ +
+ Printing +
+
+
+ +
+ Desktop +
+
+
+ +
+ +
+
+
+ +
en-US
+
+
+ +
4/2/2014
+
+
+ + +
+ +
+
+ + + +
+ +
+

The OEMDLL samples are an illustration of OEM customization plug-ins. The BITMAP, OEMPS, OEMUI, OEMUNI, OEMPREAN, CUSTHLP, SyncSet, ThemeUI, PSUIRep, and Watermark samples do not affect the printer output. They are only examples of how to build OEM Customization + DLLs of various types.

+

The following samples are included as part of this sample set:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SampleDescription
+

BITMAP

+
+

a Unidrv-based bitmap rendering plug-in. This sample demonstrates how to write a Unidrv-based rendering plug-in that functions as a bitmap driver. The sample is based on the redesigned version of the OEMUNI sample. +

+
+

CUSTHLP

+
+

An OEM help-customization plug-in. This sample demonstrates adding OEM help to your customization plug-in and how to replace standard Microsoft supplied help with customized help. +

+
+

OEMPREAN

+
+

illustrates how you can leverage the pre-analysis feature in Unidrv. This sample is built on the redesigned version of the OEMUNI sample. +

+
+

OEMPS

+
+

A PostScript rendering plug-in. This sample demonstrates how to write a PostScript-based rendering plug-in.

+
+

OEMUI

+
+

A user interface plug-in (both PostScript and Unidrv flavors are available). The OEMUI sample demonstrates common UI tasks such as adding additional elements to the UI (that is, items and pages). +

+
+

OEMUNI

+
+

A user interface plug-in (both PostScript and Unidrv flavors are available). The OEMUI sample demonstrates common UI tasks such as adding additional elements to the UI (that is, items and pages). +

+
+

PSUIREP

+
+

A PostScript UI replacement sample. This sample demonstrates how to completely replace the standard printer driver UI for PostScript driver plug-ins. +

+
+

PTPCPIPR

+
+

The Unidrv Plug-in for Print Ticket Provider Interface sample contains a functional Unidrv configuration plug-in that implements the IPrintOemPrintTicketProvider interface. You can use this code as a starting point for developing new driver plug-ins that + support PrintTicket functionality.

+
+

SYNCSET

+
+

A synchronization plug-in. This sample demonstrates how to synchronize driver settings between the OEM customization page and the standard device settings page. +

+
+

THEMEUI

+
+

A theming plug-in. This sample demonstrates how to use theming (that is, comctl v6) for printer driver UI.

+
+

UNIUIREP

+
+

This Universal Printer Driver (Unidrv) UI plugin sample shows how to fully replace Unidrv's standard UI and how to use the new IPrintCoreHelper interface to enumerate GDP features/options, enumerate constraints, get/set Unidrv settings, and create a GDL + snapshot.

+
+

WATERMARK

+
+

Demonstrates how to produce customizable watermark page simulation by controlling PostScript injected in the printing stream. The components of the sample include a PostScript-based rendering module in conjunction with a UI module. The rendering module is + responsible for the injection of the modified PostScript into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and + rendering modules.

+
+

WATERMARKUNI

+
+

Demonstrates how to produce customizable watermark page simulation by controlling PCL data injected in the printing stream. The components of the sample include a UNIDRV-based rendering module in conjunction with a UI module. The rendering module is responsible + for the injection of the PCL data into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and rendering modules. This + sample works only if you have a page printer that has its own fonts. It doesn't download any fonts nor convert fonts to bitmap. +

+
+

For information about how to develop a plug-in for customizing the print driver UI, see + +COM Interfaces for UI Plug-Ins.

+

Note  The OEMDLL samples are for the v3 print driver model only.

+

Note  

+

To build this sample, you can use Microsoft Visual Studio 2013 (Express, Professional, or Ultimate) and Windows Driver Kit (WDK) 8.1 Update. You can get Visual Studio 2013 and WDK 8.1 Update +here.

+

You can also build this sample with Visual Studio 2013 (Professional or Ultimate) and +Windows Driver Kit (WDK) 8.1.

+

For Windows Driver Kit (WDK) 8 samples, download the +WDK 8 samples pack. The samples in the WDK 8 samples pack will build only with Microsoft Visual Studio Professional 2012 (Professional or Ultimate) and WDK 8.

+

+

Operating system requirements

+ + + + + + + + + + + +
Client
Windows 7
Server
Windows Server 2008 R2
+

Build the sample

+

To build a driver solution using Windows 8.1 driver kit (Windows Driver Kit (WDK)) and Visual Studio 2013, perform the following steps.

+
+

1. Open the solution file in Visual Studio 2013

+
+

2. Add all non-binary files (usually located in the \install directory of the sample) to the Package project

+
+

a. In the Solution Explorer, right click Driver Files

+
+

b. Select Add, then click Existing Item

+
+

c. Navigate to the location to which you downloaded the sample, and select all the files in the install directory, or the equivalent set of non-binary files such as INFs, INIs, GPD, PPD files, etc.

+
+

d. Click Add

+
+
+

3. Configure these files to be added into the driver package

+
+

a. In the Solution Explorer, right click the Package project and select +Properties

+
+

b. In the left pane, click Configuration Properties > Driver Install > +Package Files.

+
+

c. In the right pane, use the ellipsis button (...) to browse to the set of files that needs to be added to the driver package. All the data files that you added in +Step 2-c, except the INF file, should be added.

+

Note  This configuration is per-architecture, so this configuration must be repeated for each architecture that will be built.

+
d. Click OK
+
+

4. Open the INF file and edit it to match the built output

+
+

a. Open the INF file

+
+

b. In the Version section, add a reference to a catalog file like this: CatalogFile=XpsDrvSmpl.cat +

+
+

c. In the SourceDisksFiles section, change the location of the DLL files you are building, to =1. This indicates that there is no architecture specific directory in this driver. If you ship multiple architectures simultaneously, you will need to collate + the driver INF manually.

+
+
+

+

At this point, Visual Studio 2013 will be able to build a driver package and output the files to disk. In order to configure driver signing and deployment, see + +Developing, Testing, and Deploying Drivers.

+

For more information about how to build a driver solution using Microsoft Visual Studio, see +Building a Driver.

+

Run the sample

+

Installation

+

After building the samples, you can install them by using the Add Printer Wizard. Select the local printer, click +Have Disk, and point to the directory that contains the relevant INF (oemdll.inf, bitmap.inf, oemprean.inf, and so on) file. +

+

Design and Operation

+

BITMAP

+

+

This sample includes the following features:

+
    +
  • The supported ColorMode options in the bitmap driver's GPD are monochrome, 4bpp, 8bpp, and 24bpp. +
  • The bitmap driver implements the IPrintOemUni::ImageProcessing callback to access bitmap data one band at a time. The driver's implementation of ImageProcessing buffers the band data every time it is called. The function is also responsible for filling + the BITMAPINFOHEADER and COLORTABLE structures that are necessary for dumping the data out to a bitmap file. +
  • The bitmap driver implements the OEMEndDoc DDI hook to dump the buffered bitmap data to the spooler at the end of the print job. The driver's implementation of OEMEndDoc dumps the headers first and then the buffered data. +
  • The GrowBuffer helper function is called every time the buffer needs to be enlarged to hold the bitmap data. +
  • The bitmap driver renders multi-page documents into a single large output bitmap file. +
+

This sample has the following limitations:

+
    +
  • The plug-in does not support landscape orientation although the option exists in the GPD. +
  • In 24bpp mode, documents larger than three pages will produce an extremely large bitmap (.bmp) file. Although the output is correct, you might not be able to view it because of memory limitations in the bitmap viewer. +
+

+

OEMPREAN

+

When preanalysis is enabled in the GPD (for more details about preanalysis, see the WDK documentation), Unidrv defines the surface as a banding surface but causes the first playback (that is, the first band) to be of the entire page. Unidrv performs this + definition by setting the GDI clip window to the entire page. Unidrv enables all drawing commands to be hooked but returns before any drawing can be done. On the subsequent passes, Unidrv resets the clip window back to the original band size and bands normally.

+

In order for plugins to also take part in preanalysis, they can enable OEM preanalysis by specifying the "*PreAnalysisOptions: 8" parameter in the GPD. The OEM rendering plug-in must hook both DrvStartBanding and DrvNextBand when this mode is enabled in + the GPD. The OEM rendering plug-in must test the pptl parameter of the OEMStartBanding call to determine whether preanalysis has been enabled on this page. If the pptl parameter is NULL, preanalysis has been enabled, and the OEM rendering plug-in should consider + all drawing calls up to the first call to OEMNextBand to be part of preanalysis. +

+

During these preanalysis phase drawing calls, the plug-in should not draw on the surface. The plug-in should also not call back into unidrv. You should use this phase only for analysis of the objects on the page. For example, certain printers need to handle + black objects that intersect with color objects differently from black objects that appear by themselves. Other printers might need to halftone StretchBlt objects differently from BitBlt objects. +

+

You should be aware that after preanalysis, you might get more calls than you saw in the normal rendering, because primitives that cross band boundaries yield two or more DDI calls after the preanalysis pass. +

+

The sample uses the bPreAnalysis flag in the OEMPDEV structure to denote whether a particular pass is the preanalysis pass or the actual rendering pass. If the bPreAnalysis flag is set, it indicates that the current pass is the preanalysis pass. The sample + implements all of the drawing function hooks in Ddihook.cpp. The sample uses the OEMStartBanding and OEMNextBand functions to respectively set and reset the bPreAnalysis flag. The sample also uses the DBG_CLIPOBJ debug macro function to dump the bounds of + the clipping rectangle available for preanalysis in each of the drawing functions during the preanalysis pass. To view all of the debug output in the debugger, you must set the debug level to VERBOSE. The rest of the sample is identical to the Oemuni sample + that illustrates a basic OEM rendering plug-in.

+

Note that the surface used during preanalysis might differ from the surface passed in during the rendering pass. +

+

PTPCPIPR

+

This sample is an educational example that illustrates the basic functionality that a Unidrv plug-in for the IPrintOemPrintTicketProvider interface should implement. +

+

The primary functionality of the plug-in is to support the PhotoPrintingIntent PrintSchema keyword. The PhotoPrintingIntent keyword is designed to provide a mechanism for photo printers to support enhancements that are specific to photo printing. An application + or the user (through the print UI) can then specify whether a particular print job is a photo-printing job, in which case the device can apply appropriate enhancements. +

+

The intent setting is communicated to the device driver in a PrintTicket. The actual enhancements made are device-specific, and as such, the driver has to map the high-level intent setting into specific output settings, like resolution or bpp. This plug-in + sample demonstrates the conversion.

+

The plug-in implements the ExpandIntentOptions method of the IPrintOemPrintTicketProvider interface. This method is called with an input print-ticket. The plug-in checks if the print-ticket contains a photo-printing intent setting, and if so, removes the + setting, while instead adding to the print-ticket output settings as mentioned above. The code sample uses MSXML6 for all PrintTicket XML handling.

+

UINUIREP

+

This sample shows how a plug-in for a Unidrv-based driver can replace the default UI. It provides new property sheets for the printer property and printing preferences pages.

+

Use this sample as an example of implementing full UI replacement in a Unidrv-based plugin. It also demonstrates the use of the new IPrintCoreHelper interface. +

+

This sample is only provided for educational purposes and should not be used in a production environment. +

+
+ +
+ + +
+ + diff --git a/print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css b/print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css new file mode 100644 index 00000000..526e88c5 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css @@ -0,0 +1,295 @@ +/*Global*/ +h1 { + font-size: 36px; + font-family: 'Segoe UI Light'; + color: #707070; + font-weight: normal; + margin-bottom: 17px !important; +} + +h2, h3, h4, h5, h6, #searchPage h3 { + font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important; + font-weight:normal; + color: #2A2A2A !important; +} + +a, a:link, a:visited { + color: #0095c4; +} + +body { + color:#707070; +} + +.profile-usercard { + color:#707070 !important; +} + +/*temporary setting to override msdn_windows.css +can remove once conflicting settings are removed from that file*/ + + +.LocalNavigation, .LocalNavigation .TabOn, .LocalNavigation .TabOn:hover, .LocalNavigation .TabOff, .LocalNavigation .TabOff a:hover { + display: block; + background-color:transparent !important; + color: #0095c4; +} + +.LocalNavigation .TabOff a { +color:#707070 ; +} + +/*End Global*/ + +.EyebrowContainer +{ + margin-bottom: 0 !important; +} + +#sideNav +{ + width: 215px !important; +} + #sideNav #contributeSection { + padding: 0 0 67px 0; + } +#searchPage #mainContentContainer +{ + margin-right:0 !important; + margin-left:243px !important; +} + +#searchPage .dirSubHeading h2 +{ + font-size: 14px !important; + font-weight: normal !important; + color: #454545 !important; + line-height: 1.45; +} + +#searchPage #directoryListFooter, #searchPage #Pager { + font-size: 14px; +} + +#searchPage h2, #searchPage h3 +{ + font-size: 1.25em !important; +} + +#sideNav #contributeSection h3, .sidebar #contributeSection h3, #contributeSection h3 +{ + font-size: 1.65em !important; +} +.subMenu > h2 +{ + font-family: 'Segoe UI Light','Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important; + font-weight:normal; + font-size:30px; + margin: 15px 10px 5px 0; + padding-bottom:0px; +} + +.itemRow { +} + .itemRow .itemBody, .itemRow .itemInfo { + padding: 18px 17px 20px 0; + font-size: 14px; + line-height: 1.45em; + } + + .itemRow .itemTitle { + font-weight: normal; + } + + .itemRow .summaryBox{ + color: #454545; + } + + .Samples #MainContent .itemRow .itemTitle a { + font-weight: 600 !important; + line-height: 1.45; + } + #MainContent a.officialMicrosoftLabel + { + color: #ACACAC; + } + + +.tabContents { + border-top-width:0px; +} + +#UploadPage { + margin: 0px 0px 0px 10px; +} + #UploadPage h1 { + padding: 0; + font-size: 22px; + } + #UploadPage h2 { + color:#F39700 !important; + } + + #UploadPage #uploadPageInstruction { + margin-top:10px; + } + + #UploadPage fieldset { + margin-left:0px; + } + + #UploadPage fieldset h2 { + font-weight:normal; + } + + #UploadPage fieldset#uploadsForm{ + margin-top:25px; + } + + #UploadPage fieldset#summary textarea { + margin-left:0px; + } + + #UploadPage .projectTypeChoice > div { + height: 250px; + } + +#sideNav { +} + + #sideNav .section h3 { + background-color: transparent; + + } + + #sideNav .section UL LI { + border-bottom-width: 0px; + } + + #sideNav .section form > div { + border-bottom: none; + color: #707070; + } + #sideNav .section ul li > div.itemCount + { + color: #707070; + } + + #sideNav .contributeAction a { + padding-bottom: 5px; + } + +#searchPage { +} + + #searchPage h2, #searchPage h3 { + text-transform:none; + background-color:transparent; + font-weight:normal; + font-size:1.2em; + } + + #searchPage .browseFilterBar { + background-color:transparent; + border-width:0px; + font-weight:normal; + } + +#requestsPage { + padding-top:15px; +} + + #requestsPage .tabHeaders { + overflow: visible; + } + + #requestsPage #requestsList { + border: none; + } + + #requestsPage h2, #requestsPage h3 { + text-transform:none; + background-color:transparent; + font-weight:normal; + font-size:1.2em; + } + +#extraActions { +} + #extraActions .section + { + margin-bottom: 10px; + } + #extraActions .section a + { + font-weight:normal; + } + + #extraActions #contributeSection div img { + width:0px; + } + + +#projectPage { +} + + #projectPage .projectTitle { + color: #707070; + margin: 5px 0px 15px 0px; + } + + #projectPage h2.projectSummary, #projectPage #projectInfo, #projectPage .tabHeaders { + font-size: 14px !important; + line-height: 1.45em; + color: #454545 !important; + font-weight: normal !important; + } + + #projectPage #projectInfo a { + color: #00749e; + } + + #projectPage #Downloads a, #projectPage #Downloads label { + font-size: 14px; + } + + #projectPage #reportAbuse { + font-size: 1em; + } + + #projectPage #publishBar a, #projectPage #publishBar a:visited { + color: #0095c4; + font-weight: normal; + } + + #projectPage #Collections .bevelButton{ + background-color: #F8F8F8; + color: #0095C4; + border: 1px solid #707070; + } + + #projectPage #DiscussionsTabPane .threadHeader .title { + font-weight:bold !important; + color:Black !important;#F8F8F8; + font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important; + } + + #projectPage .sidebar .section .titleBar h3 { + font-weight:normal; + font-size:1.2em; + } + +#LocalNav { +} + + #LocalNav.HeaderTabs { + margin-left:11px; + } + +#searchPage .dirSubHeading h1 +{ + margin-bottom:17px !important; +} + + + diff --git a/print/OEM Printer Customization Plug-in Samples/description/Brand.css b/print/OEM Printer Customization Plug-in Samples/description/Brand.css new file mode 100644 index 00000000..65dcfb8d --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/description/Brand.css @@ -0,0 +1,3615 @@ +#BodyBackground +{ + min-width:0px; +} + +#JelloExpander, .IE7 #JelloExpander, .IE8 #JelloExpander, .IE9 #JelloExpander +{ + padding-left:0px; + padding-right:0px; +} + +#JelloSizer +{ + margin: 0 auto; + max-width: 0px; + padding: 0; + width: 100%; +} + +/* Global Styles */ +body +{ + font-size:0.75em; +} + +h1 +{ + font-size: 36px; + font-family: 'Segoe UI', Tahoma, Helvetica, Sans-Serif; + color: #000; + font-weight: normal; + padding-top:4px; + margin-bottom: 17px; + line-height: 1.3; + +} + +h2, h3, h4, h5, h6 +{ + font-family: 'Segoe UI Semibold', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; + color:#2a2a2a; + font-weight:normal; +} + +a, a:link, a:visited { + color: #00749E; +} +a:hover { + color: #0095c4; + text-decoration:none; +} + +/*---------- Masthead -----------*/ + +.NetworkLogo a { + display: none; +} + +/*-------- Start Advertisment --------*/ + +.advertisment { + padding-top:5px; +} + +/*-------- End Advertisment --------*/ + + +/*-------- Start LocalTabs Page --------*/ +#GalleriesNavigation { + float: right; +} + +.LocalNavigation +{ + display:block; + overflow: auto; + width: auto; +} + .LocalNavigation .HeaderTabs { + width: auto; + } + .LocalNavigation .TabOff a { + color:#333; + } + + .LocalNavigation .TabOff a:hover { + background-color:#E0E7EC; + margin-top: 1px; + padding: 4px 6px; + } + + .LocalNavigation #notificationLink span { + color:Red; + font-weight:bold; + } + + +/*-------- End LocalTabs Page --------*/ + +/*-------- Start SubMenu Page --------*/ + +.subMenu +{ + margin: 0 0 10px 0; + color: #FFFFFF; + overflow: hidden; +} + +.subMenu a, .subMenu span +{ + margin: 5px 5px 0 5px; +} + +.subMenu > h2 +{ + float: left; + margin: 7px 15px 0 0; + vertical-align: middle; + color: #666; + padding-bottom: 5px; +} + +.subMenu .advancedSearchLink +{ + float: left; + margin: 9px 0 0 15px; +} + + + +.subMenu .uploadLink +{ + float: right; + margin: 5px 5px 0 0; + padding: 0 0 0 30px; + height: 24px; + background: url('../Common/smalluploadicon.png') no-repeat 10px 0; + color: #0066E1; + cursor: pointer; +} + +.subMenu #searchBoxContainer +{ + float: left; + width: 400px; + padding: 3px 50px; +} + +/*-------- End SubMenu Page --------*/ + +/*-------- Start SearchBox --------*/ + +div.searchbox +{ + overflow:auto; + width:450px; + margin:26px 0 14px 0; +} + +.srchbox +{ + width: 100%; + background-color: #dedfe1; + color: #999; + padding: 0px 2px; + height: 25px; + table-layout: auto; + margin-bottom:5px; +} + + + +.srchbox #searchImageCell input +{ + background: transparent url('searchButton.png') no-repeat 0 0; + width: 20px; + height: 20px; + padding-left: 1px; + margin-top: 3px; +} + + +.srchbox #searchImageCell +{ + text-align: right; + padding: 0px; + vertical-align: middle; +} + +.IE7 .srchbox #searchImageCell +{ + padding:2px 2px 0 0; +} + +.srchbox #searchImageCell input +{ +} + + +table.srchbox +{ + table-layout: fixed; +} + +.srchbox .stxtcell +{ + padding-right: 4px; + width:90%; +} + +.srchbox .stxtcell > input +{ + margin-right: 4px; + height: 26px; + line-height:26px; + width: 100%; + padding: 0px; + padding-left: 4px; + padding-top: 2px; + border: none; + font-style: normal !important; + outline: none; + background-color: transparent; +} + +.IE7 .srchbox .stxtcell > input +{ + height: 20px; +} + +.srchbox .stxtcell > input.stxtinptpassive +{ + color: #AAA; + font-style: normal !important; +} + +/*-------- End SearchBox --------*/ + + +/*-------- Start Search Page --------*/ + + +#searchPage #mainContentContainer +{ + margin: 0 0 0 243px; +} +#searchPage #directoryContent { + border-left: 3px solid #eee; + margin-left: -20px; + padding-left: 20px; +} +#searchPage .browseFilterBar, #dashboardPage .browseFilterBar +{ + padding: 5px 0 6px 0; + +} + + #searchPage .browseFilterBar a, #dashboardPage .browseFilterBar a + { + font-weight:normal; + } + + #searchPage .browseFilterBar .browseSort, #dashboardPage .browseFilterBar .browseSort + { + float:right; + } + + #searchPage .browseBreadcrumb + { + padding-top:3px; + } + + #searchPage .browseFilterBar .browseSort select, #dashboardPage .browseFilterBar .browseSort select + { + height:20px; + } + + #searchPage .browseFilterBar .browseSort img, #dashboardPage .browseFilterBar .browseSort img + { + vertical-align:text-top; + } + +#searchPage h2, #searchPage h3 +{ + font-size: 1.25em; + padding: 2px 0 3px 3px; +} + +#searchPage h2 +{ + display:inline; + clear:none; +} + + #dashboardsearchbox + { + width:420px; + margin:0; + float:left; + } + +/*-------- End Search Page --------*/ + +/*-------- Begin Requests Page --------*/ + +#requestsPage { + color:#666; +} + + #requestsPage h1 { + clear:none; + } + #requestsPage h2, #requestsPage h3 + { + font-size: 1.25em; + } + + #requestsPage h2 + { + display:inline; + clear:none; + } + + #requestsPage h3 + { + padding: 2px 0 3px 3px; + } + + #requestsPage #mainContentContainer + { + margin: 0 0 0 243px; + } + + #requestsPage #mainContentWrapper { + float:left; + width:100%; + } + #requestsPage #mainContent { + position:relative; + } + + #requestsPage #mainContent .subtitle{ + margin-bottom:5px; + } + + #requestsPage #requestsFilterBar { + margin-top: 10px; + overflow: auto; + } + + #requestsPage #requestsFilterBar .requestsCrumb { + float: left; + margin:10px 0 10px 10px; + } + #requestsPage #requestsFilterBar .requestsSort { + float: right; + margin:10px 0 10px 0; + } + + #requestsPage #Pager { + text-align: center; + padding-top: .75em; + padding-bottom: .75em; + } + + #requestsPage #requestsRss { + float: right; + margin: 2px 0 0 3px; + cursor: pointer; + } + + .IE7 #requestsPage #requestsList { + padding-top: 10px; + margin-top:5px; + } + + #requestsPage #requestsList .noResults { + padding: 10px 0; + } + + +/*-------- End Requests Page --------*/ + +/*-------- Begin Request List Item --------*/ +.requestlistitem td +{ + padding: .9em 0 .9em .5em; +} + .requestlistitem .votebox + { + + text-align:center; + } + + .requestlistitem .voteboxcontainer + { + vertical-align:top; + width: 75px; + } + + .requestlistitem #votelabel + { + border-width:1px; + border-bottom-style:solid; + } + + #myRequestsTab #votenumber, + #requestsPage #votenumber + { + background-color: #777; + padding: 6px 10px; + color: #fff; + margin-bottom: 5px; + font-size: 1.6em; + } + + #myRequestsTab .votelink, + #requestsPage .votelink + { + font-weight:bold; + background-color: #eee; + padding: 5px 0; + width: 75px; + float: left; + } + + #myRequestsTab .needvote, + #requestsPage .needvote + { + font-weight:bold; + } + + #myRequestsTab .alreadyvoted, #myRequestsTab .resolved + #requestsPage .alreadyvoted, #requestsPage .resolved + { + font-weight:bold; + color: #666; + } + + .requestlistitem .linkform + { + width:100%; + float:right; + margin-top:15px; + } + + .requestlistitem .requesttitle + { + font-weight:600; + margin-bottom:3px; + } + + .requestlistitem .requester + { + margin-bottom:3px; + } + + .requestlistitem .hidden + { + display:none; + } + + .requestlistitem .requestSummary div + { + margin-bottom:0.25em; + } + + .requestlistitem .requestSummary + { + line-height: 1.45em; + width: 80%; + } + .requestlistitem .requestInfo + { + padding:1.2em 0 0 2.5em; + vertical-align:top; + width:15%; + line-height: 1.45em; + } + + .requestlinks > td + { + padding-bottom: 16px; + } + + .requestlinks div + { + float:right; + } + + .requestlistitem .textbox + { + width:95%; + } + + + +/*-------- End Request List Item --------*/ + + +/*-------- Begin New Request Form --------*/ +#newrequest { + margin-top:5px; + background:#F8F8F8; + border-width:1px; + border-style:solid; + border-color:#E8E8E8; + padding:5px; +} + +#newrequest > div:first-child { + font-weight:bold; +} + +#newrequest .itemheading { + margin-top:5px; +} + +#newrequest textarea { + width:95%; +} + +#newrequest .field-validation-error { + display:block; + color:Red; + font-weight:bold; +} +#newrequest #submit { + margin-top:5px; +} + +/*-------- End New Request Form --------*/ + +/*-------- Request Description Page ------*/ + +.reqDescPage #mainContent { + overflow: auto; +} +.reqDescPage #header { + float: left; + width: 100%; +} + +.reqDescPage { + color: #000 !important; +} + +.reqDescPage #sideNav { + background-color: #fff; +} + +.reqDescPage #header td { + vertical-align: bottom; +} + +.reqDescPage #header #votenumber { + width: 50px; + padding: 6px 12px; + text-align: center; + float: left; +} + +.reqDescPage #header .requestTitle { + margin: 0 0 5px 10px; + width: 85%; +} + +.reqDescPage #header .requestTitle h1 { + margin-bottom: 0px; + font-size: 2em; +} + +.reqDescPage #headerLinks { + +} + +.reqDescPage .votelink +{ + text-align: center; + float: left; +} + +#requestsPage #headerLinks .assignlink +{ + font-weight:bold; + background-color: #eee; + padding: 5px 10px; + float: left; + margin-left: 10px; +} + +.reqDescPage #projectInfo { + clear: both; +} + +.reqDescPage #solutions { + clear: both; + padding-top: 30px; +} + +.reqDescPage .solutionItems { + clear: both; +} + +.reqDescPage .solutionHeader { + border-bottom: 1px solid #ccc; +} + +.reqDescPage .solutionAddContainer { + padding-top: 15px; + float: left; +} + +.reqDescPage #SubmittedProjectLinkUrl { + width: 400px; +} + +.reqDescPage .solutionItem { + margin-top: 25px; + padding: 0 5px 5px 0; + float: left; +} +.reqDescPage .solutionItemDetails { + float: left; + width: 535px; +} + +.reqDescPage .solutionItemLinks { + margin-top: 10px; + clear: both; + float: left; + width: 100%; +} + +.reqDescPage .solutionItemLinks a { + float: left; + margin-right: 10px; + font-weight:bold; + background-color: #eee; + padding: 5px 10px; +} + +.reqDescPage .solutionItem .itemTitle { + font-size: 1.2em; + padding-bottom: 5px; +} + +.reqDescPage .tagsContainer label { + display: none; +} + +.reqDescPage .solutionItem .summaryBox { + padding: .25em 0 .25em 0; + clear: both; + line-height: 1.45; +} + +.reqDescPage .solutionsection { + float: left; + margin-left: 20px; +} +.reqDescPage .completedSolution { + font-size: 1.25em; + padding-top: 4px; +} + +.reqDescPage .requestDescriptionCont, .reqDescPage .requestDicussions { + padding-top: 30px; + clear: both; + overflow: auto; +} + +.reqDescPage .requestDescription { + padding-top: 10px; + line-height: 1.45; +} + +.reqDescPage .requestDicussionsAsk { + padding: 10px 0; +} + +.reqDescPage .watermark { + color:Gray; + } + + +/*-------- Begin Extra Actions Section --------*/ +#extraActions +{ + float: right; + width: 300px; + vertical-align: top; +} + + #extraActions .section + { + padding: 0 0 10px 0; + overflow:auto; + } + + #extraActions .section a + { + font-weight:bold; + } +/*-------- End Extra Actions Section --------*/ + +/*-------- Begin Contribute --------*/ + + +#contributeSection a +{ + font-size:1.1em; +} + +#contributeSection, #sideNav #contributeSection h3, .sidebar #contributeSection h3, #contributeSection h3 +{ + background-color:#fff; + margin: 0 0 9px 0; + padding-left: 0px; +} + +#sideNav #contributeSection h3, .sidebar #contributeSection h3, #contributeSection h3 +{ + font-size:1.65em; + margin-top:42px; +} + +#sideNav #contributeSection, #contributeSection +{ + padding:0 0 41px 0; +} + +#projectPage .sidebar #contributeSection +{ + margin: 10px 0 10px 0; + padding:0 0 5px 0; + +} + +#sideNav #contributeSection > div, .sidebar #contributeSection > div, #contributeSection > div +{ + padding: 0 0 2px 0; + overflow:auto; +} + +#sideNav #contributeSection img, #contributeSection img +{ + float: left; + width: 25px; +} + +#sideNav #contributeSection .contributeAction, .sidebar #contributeSection .contributeAction, #contributeSection .contributeAction +{ + padding:17px 0 0 0; +} + + #contributeSection .contributeAction img + { + background-color:#00749e; + margin-right:9px; + } + + #contributeSection .contributeAction img:hover + { + background-color:#0095C4; + } + + #contributeSection .contributeAction a + { + display:block; + line-height: 1.8; + } + +#uploadLink, #exclamationLink, #myContributionsLink +{ + display:block; + line-height: 1.8; +} + +#myContributionsLink span +{ + color: red; +} + +#feedbackLink +{ + background: url("FeedbackIcon.png") no-repeat; + width: 40px; + height: 40px; +} + +.itemRow .affiliationLink, #editorPicksSection .affiliationLink +{ + background: url("../common/MicrosoftLogo.png") no-repeat; + width: 82px; + height: 18px; +} + + +#contributeSection a+div +{ + +} + +.IE7 #contributeSection a+div +{ + float:left; +} +/*-------- End Contribute --------*/ + + +/*-------- Begin Directory List Footer --------*/ + +#directoryListFooter { + padding:5px; + margin-top:10px; + margin-bottom:10px; + border:1px solid #E6E6E6; + background-color:#F8F8F8; + width:438px; +} + +#directoryListFooter h4 +{ + font-size:1em; +} + +/*-------- End Directory List Footer --------*/ + +/*-------- Begin Editors Picks --------*/ +#editorPicksSection ul +{ + padding-left:0px; + line-height:135%; +} + + #editorPicksSection ul li + { + clear: left; + padding-top: 10px; + list-style:none; + } + #editorPicksSection ul li:first-child { + padding-top: 0; + } + + #editorPicksSection a { + font-weight: normal !important; + } + + #editorPicksSection ul li .thumbnail + { + float: left; + padding: 3px; + max-width: 60px; + } + + #editorPicksSection ul li .thumbnail img { + max-width: 60px; + } +/*-------- End Editors Picks --------*/ + +/*-------- Begin Side Nav Section --------*/ + +#sideNav +{ + width: 215px; + margin-left: 0; + vertical-align: top; + float: left; +} + + #sideNav #sideNavHeader + { + margin-bottom: 10px; + padding-left: 12px; + } + + #sideNav #sideNavHeader a + { + margin-right:3px; + } + + #sideNav .section + { + padding: 0 10px 18px 0px; + } + #sideNav .section h3 + { + + padding: 2px 0 3px 3px; + } + + #sideNav .section ul + { + } + + #sideNav .section ul li + { + padding: 4px 0 2px; + margin-left: 3px; + margin-right: 3px; + } + + + #sideNav .section form > div + { + padding: 4px 0 0 0; + border-bottom: none; + margin: 0 3px 0 3px; + color: #3A3E43; + } + .IE8 #sideNav .section ul li > div.itemText + { + word-wrap: break-word; + width: 225px; + } + #sideNav .section ul li > div.itemCount + { + color: #3A3E43; + } + #sideNav .section a + { + font-weight: normal; + } + + #sideNav .section a:hover + { + text-decoration: underline; + } + +/*-------- End Side Nav Section --------*/ + + + +/*-------- Start Dashboard Page --------*/ + +#dashboardPage { + padding-top:5px; + clear:both; +} +#dashboardPage .contributions .tabContents { + padding: 5px 5px 10px 0; + clear:both; +} + #dashboardPage .contributions .noContributions { + clear:both; + } +#dashboardPage #mainContentWrapper { + float:left; + width:100%; +} + +#dashboardPage #detailsSection { + float:left; + margin-left:-100%; + width:240px; + padding: 0 0 18px 10px; +} + +.IE7 #dashboardPage #detailsSection { + width:auto; + min-width: 300px; + max-width: 300px; +} +.IE7 #dashboardPage #detailsSection .itemBar { + width: 270px; +} + +#dashboardPage #detailsSection h3 { + word-wrap:break-word; +} + +#dashboardPage #mainContent { + margin:0 0 0 250px; + position:relative; +} + +#dashboardPage .dashboardEvenRow +{ + background-color: #ececec; +} +#dashboardPage .dashboardPadding +{ + padding-bottom: 4px; +} +#dashboardPage .dashboardCell +{ + width: 100%; + vertical-align: top; + padding: 1em 0.5em 0.5em 0.5em; + word-wrap: break-word; +} +#dashboardPage .projectManagement +{ + width: 24em; + padding: 0em 1em 0em 1em; + vertical-align: top; + text-align: right; + float: right; +} + +#dashboardPage #subscriptionsLink +{ + position:absolute; + right:5px; +} + +#dashboardPage .itemDelete +{ + vertical-align:top; + padding-top:.8em; + width:30px; +} + +#dashboardPage .itemDeleteText +{ + border-style:solid; + border-width:thin; + border-collapse:collapse; + padding-bottom:2px; + padding-left:4px; + padding-right:4px; + color:Gray +} + +#dashboardPage #myRequestsTab .requestTabHeaders +{ + font-weight:normal; + border-bottom: solid 1px #CCC; + padding-bottom: 10px; + padding-top: 10px; + float: left; + width: 100%; +} + +#dashboardPage #myRequestsTab .requestTabHeaders div:first-child +{ + border: 0; +} + +#dashboardPage #myRequestsTab .requestTabHeaders div +{ + padding: 2px 9px 3px 9px; + font-size: 0.9em; + line-height: 125%; + color:#00749E; + border-left: solid 1px #555; + cursor: pointer; + float: left; + text-align: center; +} + +#dashboardPage #myRequestsTab .requestTabHeaders div.currentRequest +{ + background-color:#fff; + cursor: default; + border-bottom:none; + margin-bottom:-2px; + color:#000; +} + +#dashboardPage #myRequestsTab .requestTabHeaders div.currentRequest a { + color: #000; +} + + +#dashboardPage #myRequestsTab .requestTabHeaders div a +{ + text-decoration:none; +} + +#dashboardPage #myRequestsTab .requestTabContents +{ + clear: both; +} + +#dashboardPage #myRequestsTab .requestTabContents .noResults { + padding-top: 20px; +} + +/*-------- End Dashboard Page --------*/ + +/*-------- Start Upload Page --------*/ + +#UploadPage +{ + margin-left:10px; + max-width:925px; +} + + #UploadPage .watermark { + color:Gray; + } + + #UploadPage .projectTypeChoice { + } + + #UploadPage .projectTypeChoice > div { + padding: 20px 10px 20px 10px; + border: 1px solid darkgrey; + cursor: pointer; + height: 200px; + float: left; + } + + #UploadPage .projectTypeChoice > div + div + { + margin: 0 0 0 5px; + } + + #UploadPage .projectTypeChoice div.current + { + background-color: #E9E9E9; + cursor: default; + } + + #UploadPage .projectTypeChoice div.choice { + font-size: large; + font-weight: bold; + padding: 0 0 10px 0; + } + + #UploadPage .projectTypeChoice div.description { + padding: 0 0 0 17px; + } + + #UploadPage .projectTypeChoice #genericSampleUploadDescription { + padding-top: 5px; + } + + #UploadPage .projectTypeChoice #genericSampleUploadDescription .logos { + overflow: auto; + } + + #UploadPage .projectTypeChoice #genericSampleUploadDescription .vslogo { + background: url(../samples/vslogo.png) no-repeat; + width: 125px; + height: 18px; + } + + #UploadPage .projectTypeChoice #genericSampleUploadDescription .javalogo { + background: url(../samples/javalogo.png) no-repeat; + width: 33px; + height: 60px; + float: left; + } + + #UploadPage .projectTypeChoice #genericSampleUploadDescription .phplogo { + background: url(../samples/phplogo.png) no-repeat; + width: 65px; + height: 35px; + float: left; + margin: 15px 0 0 10px; + } + + #UploadPage .projectTypeChoice #genericSampleUploadDescription .nodejslogo { + background: url(../samples/nodejslogo.png) no-repeat; + width: 90px; + height: 25px; + float: left; + margin: 18px 0 0 10px; + } + + #UploadPage .projectTypeChoice #genericSampleUploadDescription > div+div { + margin-top: 10px; + } + + #UploadPage .projectTypeContents { + clear: left; + padding: 10px 0 0 0; + } + + #UploadPage .projectTypeContents .instruction > div+div { + padding-top: 5px; + } + #UploadPage #libraryContainer { + margin: 5px 0 0 0; + display: none; + } + #UploadPage fieldset + { + margin: 10px 0 30px 5px; + } + + #UploadPage fieldset > * + { + margin-left:10px; + } + + #UploadPage .fieldsetStyleContainer { + margin: 10px 0 0 5px; + } + + #UploadPage fieldset h2, + #UploadPage .fieldsetStyleContainer h2 + { + font-family: 'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif; + font-size: 17px; + font-weight: bold; + color: #3A3E43; + border-bottom: 2px solid #EFEFEF; + width: 100%; + padding-bottom: 3px; + margin-left:0px; + margin-bottom:8px; + } + + .IE7 #UploadPage fieldset h2, + .IE7 #UploadPage .fieldsetStyleContainer h2 + { + margin-left:-10px; + } + + #UploadPage fieldset .field-validation-error + { + clear:left; + display:block; + margin-top:4px; + } + + #UploadPage fieldset .required + { + margin-left: 3px; + } + + #UploadPage fieldset .instruction, + #UploadPage .fieldsetStyleContainer .description, + #UploadPage .fieldsetStyleContainer .instruction + { + color: #3A3E43; + margin:0 0 10px 0; + } + + #UploadPage fieldset .faqLink + { + margin: 0 0 10px 0; + } + + #UploadPage fieldset label + { + display:block; + } + + #UploadPage fieldset input[type=text] + { + width:60%; + } + + #UploadPage fieldset input[type=checkbox] + { + float:left; + clear:left; + margin-right:5px; + } + + #UploadPage fieldset input[type=radio] + { + float:left; + clear:left; + margin-right:5px; + } + + #UploadPage fieldset#richDescription textarea + { + width:70%; + height:600px; + } + + #UploadPage fieldset#summary textarea + { + width:60%; + height:100px; + margin-top: 10px; + margin-left: -30px; + } + + .IE #UploadPage fieldset#summary textarea, .IE9 #UploadPage fieldset#summary textarea + { + margin-left: -30px; + overflow: auto; + } + + .FF #UploadPage fieldset#summary textarea + { + margin-left: -30px; + } + + #UploadPage fieldset#summary #SummaryReadOnly + { + width:60%; + margin-top: 10px; + padding-top: 5px; + color: #909082; + } + + #UploadPage fieldset#summary #SummaryCharCount + { + width:60%; + text-align: right; + } + + #UploadPage fieldset#options label + { + margin-bottom:10px; + } + + #UploadPage fieldset#license label + { + margin-bottom:10px; + } + + #UploadPage input[type="text"].tagInput, #UploadPage input[type="text"].listInput + { + width:40%; + float:left; + } + + #UploadPage .addedTags, #UploadPage .addedProjects + { + margin-bottom:15px; + width: 500px; + + } + #UploadPage .addedTags .tag, #UploadPage .addedProjects .projectTitle + { + position:relative; + overflow:hidden; + } + + #UploadPage .addedTags .tag label, #UploadPage .addedProjects .projectTitle label + { + float:left; + width: 450px; + } + + #UploadPage .addedTags .tag a, #UploadPage .addedProjects .projectTitle a + { + position:absolute; + text-align:right; + right:0px; + } + + .fileManager .fileUploadProgressIndicator + { + width: 500px; + } + + .fileManager .uploadProcessingWarning { + margin-top: 5px; + } + + .fileManager .fileUploadProgressIndicator .throbber + { + font-weight: bold; + background: url('./progressIndicatorWhite.gif') no-repeat 10px 0; + padding: 7px 10px 5px 60px; + height: 25px; + margin-left: -10px; + } + + .fileManager #uploadFrame, .fileManager .uploadFrame + { + width:100%; + } + + .fileManager .addLabel + a + { + margin-left:25px; + } + + .fileManager fieldset label { + display: block; + } + + .fileManager .unlocalizedFiles { + color:#808080; + } + + .fileManager .filesContainer + { + margin-bottom:15px; + width: 500px; + + } + + .fileManager .filesContainer .file + { + position:relative; + overflow:hidden; + } + + .fileManager .filesContainer .file .title { + border-bottom: 1px solid #000000; + padding-bottom: 3px; + margin-top: 10px; + margin-bottom: 10px; + } + + .fileManager .filesContainer .file .title .manageLinks + { + float: right; + } + + .fileManager .filesContainer .file .version { + padding: 0 0 20px 10px; + } + + .fileManager .filesContainer .file .version label { + float: left; + font-weight: bold; + } + + .fileManager .filesContainer .file .version span { + float: left; + margin-left: 5px; + } + + .fileManager .filesContainer .file .language { + clear: left; + padding: 0 0 5px 10px; + } + + .fileManager .filesContainer .file .language label { + font-weight: bold; + } + + .fileManager .filesContainer .file .language label + label { + font-weight: normal; + padding-left: 10px; + } + + .fileManager .filesContainer .file .language div { + padding-left: 20px; + } + + .file .requirements { + clear: left; + padding: 0 0 0 10px; + } + + .file .requirements label { + font-weight: bold; + } + + .file .requirements > div { + padding-left: 20px; + } + + .file .requirements .requirementsContent { + padding-top: 5px; + padding-bottom: 10px; + } + + .file .requirements .requirementsContent label { + font-style: italic; + font-weight: normal; + } + + .file .requirements .requirementsContent > div + { + margin-bottom:4px; + position:relative; + } + + .requirementsContent .requirementsRemove { + float:right; + position:absolute; + right:0px; + } + + .requirements .requirementsAddError { + color:#ff0000; + } + + .requirements .reqBrowseButton { + margin-left : 10px; + } + + #UploadPage fieldset .requirements input[type="text"] { + margin-right: 10px; + width: 70%; + } + + .reqBrowsefade + { + position: absolute; + background-color: #aaaaaa; + } + .reqBrowse + { + background-color: #f4f4f4; + border:1px solid #000000; + -border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + padding:15px; + position: absolute; + display: block; + } + + .reqBrowsebuttons + { + text-align:right; + position:absolute; + right:10px; + bottom:5px; + } + .reqBrowsebuttons > button + { + color: Blue; + border: none; + background: none; + font-weight: bold; + cursor:pointer; + } + + .reqBrowseclose + { + display:none; + } + + .reqBrowseDialog + { + width: 700px; + clear:both; + overflow:hidden; + padding-bottom: 20px; + } + + .reqBrowseDialog > h2 + { + border-bottom: 1px solid #000000; + padding-bottom: 5px; + } + .reqBrowseDialog > p + { + margin: 15px 0 15px 0; + } + + .reqBrowseSearchCont + { + width: 100%; + background: white; + padding: 0px 2px; + -moz-border-radius: 2px; + border-radius: 2px; + border: 1px solid #888; + margin-bottom: 5px; + height: 29px; + } + .reqBrowseSearchCont .rbboxcont + { + width:90%; + float:left; + margin-top: 2px; + } + + .reqBrowseSearchCont input + { + border:none; + outline:none; + border-color: transparent; + } + .reqBrowseSearchBox + { + margin-right: 4px; + height: 20px; + line-height: 20px; + width: 100%; + padding-left: 4px; + padding-top: 2px; + } + + .reqBrowseSearchBoxDefault + { + color: #AAA; + } + .reqBrowseSearchCont .rbbtncont + { + float: right; + margin-top: 4px; + } + .reqBrowseSearchBtn + { + background: transparent url('searchButton.png') no-repeat 0 0; + width: 22px; + height: 22px; + float:left; + cursor:pointer; + } + + .reqBrowseTabs + { + border-bottom: 5px solid #E8E8E8; + margin:3px 0; + overflow:auto; + } + + .reqBrowseTabs .reqBrowseTabsR + { + color:#fff !important; + } + + .reqBrowseTabs .reqBrowseTabsHighlight + { + color:#000 !important; + background-color:#E8E8E8; + } + + .reqBrowseTabs a + { + padding:5px 12px; + color:#fff; + background-color:#888; + font-weight:bold; + float:left; + margin: 0 4px 0px 0; + } + + .reqBrowsePager td + { + text-align:center; + } + .reqBrowseDialog #Pager + { + margin: 5px 0 15px 0; + } + + .reqBrowseContent + { + height:310px; + overflow:auto; + clear:both; + position:relative; + } + + .reqBrowsePager + { + width:700px; + margin:0 auto; + } + + .reqBrowseContentError + { + color:#ff0000; + margin:5px; + } + .reqBrowseContent .requirementItem + { + border-bottom: 2px solid #E8E8E8; + padding: 4px 0 6px 0; + overflow:auto; + } + .reqBrowseContent .section1 + { + float:left; + width:75%; + padding-left:25px; + position:relative; + } + + .reqBrowseContent .section1 input + { + position:absolute; + left:0px; + } + + .reqBrowseContent .title + { + font-weight:bold; + } + .reqBrowseContent .section2 + { + float:right; + } + + + .progressIndicatorfade + { + position: absolute; + background-color: #FFFFFF; + } + .progressIndicator + { + background-color: #f4f4f4; + border: 1px solid #000000; + -border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + padding: 15px; + position: absolute; + display: block; + max-width: 70%; + max-height: 70%; + } + #progressIndicator .progressIndicatorclose + { + display: none; + } + + #progressIndicatorContent + { + font-weight: bold; + padding: 7px 10px 0 10px; + height: 25px; + } + + +/*-------- End Upload Page --------*/ + +/* --- + --- Homepage --- + --- */ +p +{ + margin: 0 0 1px 0; +} +#homePageHeader +{ + float: left; + margin-bottom: 1em; + width: 100%; +} + +.tagline { + font-size: x-small; + position: relative; + top: -11px; +} + +.welcomeInfo +{ + float: left; + width: 700px; +} +.welcomeInfo h2 +{ + font-size: 16px; +} +.welcomeInfo p +{ + margin: 5px 0 0 0; +} + +#siteActions > div +{ + border: 1px solid #BBBBBB; + padding: 15px 5px 0 65px; + height: 55px; + background-repeat: no-repeat; + background-position: 10px 10px; +} +#siteActions a, #siteActions p +{ + margin-top: 5px; +} + +#siteActions .label a +{ + font-size: 1.25em; + font-weight: bold; + margin-bottom: 3px; +} + +#myGalleryBox +{ + background-image: url("MyGalleryIcon.png"); +} + +#findActions +{ + float: right; + padding: 10px; + width: 225px; + height: 50px; + border: 1px solid #BBBBBB; + margin: 0 10px 0 0; +} + +#findBox div:first-child +{ + margin: 0 0 5px 0; + font-weight: bold; +} + +#legalDisclaimer +{ + margin: 0 0 10px; + color: #798072; + font-size: 0.8em; +} + +#siteActions +{ + float: right; + width: 200px; +} +#siteActions > div +{ + margin-bottom: 10px; +} +.homePageProjects +{ + width: 100%; + float: left; +} +.homePageProjects > div +{ + padding-left: 1.5em; +} +.homePageProjects > div:first-child +{ + padding-left: 0; +} + +.homePageProjects .projectList ul +{ + padding: 0; + margin: 0; +} +.homePageProjects li +{ + margin-top: .5em; + padding-bottom: 0.5em; + list-style-type: none; +} +.homePageProjects .itemRow a, .homePageProjects .itemRow a:hover +{ + color: #0054A6; +} + +.projectList > a:first-child +{ + margin-left: 1px; + float: right; +} +.projectList > a, .projectList > a:hover +{ + color: #5BAEDB; +} +.projectListTitle +{ + height: 27px; + font-size: 16px; + font-weight: bold; + line-height: 125%; + background: #E8E8E8; + padding: 5px 5px 5px 25px; +} +.homePageListPager +{ + text-align: right; + margin-bottom: -.5em; +} + +.recentlyAddedProjects +{ + float: left; + width: 32%; +} +.mostPopularProjects +{ + float: right; + width: 32%; +} +.highestRankedProjects +{ + overflow: hidden; +} +* html .highestRankedProjects +{ + float: left; +} +* html .highestRankedProjects > div +{ + width: 100%; +} + +#Pager +{ + text-align:left; +} + +/* Impromptu warning style */ +.ipWarningfade +{ + position: absolute; + background-color: #aaaaaa; +} +div.ipWarning +{ + width: 400px; + position: absolute; + border-radius: 10px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + padding: 20px 0 20px 20px; + background-color: #FCE5E6; + border: solid 2px #EE1F25; +} +.ipWarningcontainer +{ + font-weight: bold; +} +.ipWarningclose +{ + display: none; +} +.ipWarningmessage div +{ + position: relative; +} +.ipWarningmessage div div + div +{ + text-align: center; + padding-right: 20px; +} +.ipWarningmessage div div:first-child div +{ + margin-left: 50px; +} +.ipWarningmessage div div:first-child img +{ + position: absolute; + margin: -20px 0 0 0; + top: 35%; +} +.ipWarningbuttons +{ + text-align: center; + margin: 20px 0 0 0; +} +.ipWarning button +{ + padding: 4px 8px 4px 8px; + margin: 2px; + font-weight: bold; + border: solid 1px #A6A3A6; + color: #FFFFFF; + background: #B8BABC; + filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#B8BABC',EndColorStr='#949699'); +} + +#eyebrow +{ + width: 100%; +} +#siteMessage .unsupportedLocale { + margin: 10px 0 0 243px; + border: solid 1px #CCC; + background: #FCFEC5; + padding: 5px; +} + +#Footer +{ + width: 100%; + height: auto; +} + +.clear +{ + clear: both; +} + +#buildVersion +{ + clear: both; + margin-left: auto; + margin-right: auto; + padding-right: 26px; + padding-top: 8px; + text-align: right; +} + +#page +{ + clear: both; + padding-top: 10px; +} + +#page h1 +{ + padding: 10px 0px; +} + +#ownerBar +{ + background: #EFEFEF; + border: 2px solid #7FCBF5; + text-align: left; + color: Black; + margin: 10px 0 20px 0; + padding: 5px; + word-spacing: 0px; + font-size: medium; +} + +#ownerBar a +{ + color: Blue; + padding: 0 5px 0 5px; +} + + + + +/*-------- Start Tab Control --------*/ + +.tabHeaders +{ + font-weight:normal; + border-bottom: solid 1px #CCC; + float: left; + width: 100%; +} + +.tabHeaders div +{ + padding: 7px 19px 8px 19px; + font-size: 0.9em; + line-height: 125%; + color:#00749E; + cursor: pointer; + float: left; + text-align: center; +} + +.tabHeaders div.current +{ + background-color:#fff; + cursor: default; + border: 1px solid #CCC; + border-bottom:none; + margin-bottom:-2px; + color:#000; +} + +.tabHeaders div a +{ + text-decoration:none; +} + +.tabContents +{ + clear: both; +} + +#MainContent .tabHeaders div.current a +{ + color:#000; +} + +.tabContents div.current +{ + display: block; +} +/*-------- End Tab Control --------*/ + +.itemContainer +{ + width: 100%; +} +.itemRow .itemTitle +{ + padding-bottom: 5px; + font-size:1.1em; + font-weight: bold; +} + +.itemRow .itemBody, .itemRow .itemInfo +{ + padding:15px 17px 16px 0; +} +.itemRow .itemDescription +{ + overflow: hidden; + max-height: 80px; +} +.itemRow .itemBody +{ + vertical-align: top; + line-height: 1.4; +} +.itemRow .itemBody a.officialMicrosoftLabel +{ + color: #ACACAC; +} +.itemRow .itemInfo +{ + vertical-align: top; + padding-left: .5em; + line-height: 1.4; + width: 10em; + text-align:right; +} + +.IE7 .itemRow .itemInfo +{ + width:11em; +} + +.itemRow .itemInfo .ratingStars +{ + float: left; +} +.itemRow .itemInfo .ratingCount +{ + padding: 0 0 0 5px; + float: left; +} +.itemRow .ratingInfo +{ + text-align: center; +} + +.itemRow .affiliationLink, #editorPicksSection .affiliationLink +{ + position: relative; + top: 3px; +} + +#editorPicksSection a.officialMicrosoftLabel +{ + color: #ACACAC; +} + +.itemRow .tagsContainer label { + display:none; +} + +.editorPickedItem +{ + background-color:#F8F8F8; +} + +.editorPickedText +{ + font-size:1.25em; + padding-bottom:2px; +} +.editorPickedItem > td +{ + border-top:6px solid #fff; +} + +.dirSubHeading +{ + margin-bottom:15px; +} + +#searchPage .dirSubHeading h2 +{ + line-height:1.4; + font-size:1.1em; +} + +#searchPage .dirSubHeading h2 span +{ + padding-top:5px; + display:block; +} + +#searchPage .dirSubHeading h1, #searchPage .dirSubHeading h2 +{ + clear:none; + padding-left:0px; +} + +.dirSubHeading .dirSubLinks +{ + font-size:1.2em; + padding-top:5px; +} + + +.summaryBox +{ + padding: .25em 0 .25em 0; + clear: both; + line-height:1.45; +} + +/*-------- Start Rating Stars --------*/ + +.RatingStar +{ + width: 11px; + height: 11px; + padding: 0 8px 0 0; + background-position: center; + float: left; +} + +.FilledRatingStar, .HalfRatingStar, .EmptyRatingStar, .FilledRatingStarHover +{ + width: 11px; + height: 11px; + padding: 0px 1px 0px 0px; + margin-top: 2px; +} + +.FilledRatingStar +{ + background: url(../samples/fullStar.png) no-repeat; +} + +.ownerRating .FilledRatingStar +{ + background: url(../samples/fullStar.png) no-repeat; +} + +.FilledRatingStarHover +{ + background: url(../samples/fullStarHover.png) no-repeat; + +} + +.HalfRatingStar +{ + background: url(../samples/halfStar.png) no-repeat; + +} + +.EmptyRatingStar +{ + background: url(../samples/emptyStar.png) no-repeat; + +} + +.EditStarMode .RatingStar +{ + cursor: pointer; +} + + + +/*-------- End Rating Stars --------*/ + +.discussionFormTable +{ + width: 100%; + table-layout: fixed; +} + + +#ReviewsTabPane .seeAllLink, #DiscussionsTabPane .seeAllLink +{ + margin-top: 10px; + text-align: center; +} + +/*-------- Start DiscussionsTab --------*/ + +.threadActions +{ + text-align: right; + margin-top: 10px; + float: right; +} + +#DiscussionsTabPane .reply, #DiscussionsTabPane .toggleDiscussion +{ + cursor: pointer; +} + + +#defaultDicussionText, #newDiscussion +{ + padding-top: 10px; +} +#DiscussionsTabPane .posts +{ + display: block; +} +#DiscussionsTabPane .threadHeader .left +{ + float: left; +} +#DiscussionsTabPane .threadHeader .right +{ + float: right; +} +#DiscussionsTabPane .normal +{ + font-weight: normal; +} + +#DiscussionsTabPane .threadHeader +{ + position: relative; + background-color: #ECECEC; + padding: 4px 10px 4px 10px; +} + +#DiscussionsTabPane .threadHeader .title +{ + color: #000000; + font-weight: bold; + margin-bottom: .7em; +} +#DiscussionsTabPane .threadHeader .label +{ + color: #000000; +} +#DiscussionsTabPane .postMeta +{ + color: #666666; +} +#DiscussionsTabPane .threadHeader .value +{ + font-weight: bold; + color: #000000; +} + +#DiscussionsTabPane .reply +{ + font-weight: normal; + cursor: hand; +} + +#DiscussionsTabPane ul li +{ + list-style-type: none; + list-style-image: none; + padding-bottom: 10px; +} + +#DiscussionsTabPane ul +{ + padding-left: 0px; + margin-left: 0px; + padding-right: 2px; +} + +.IE #reviewList .right +{ + margin-right: -1em; +} + +#newDiscussion +{ + margin: 0 0 15px 0; +} +#newDiscussion #Title +{ + width: 50%; +} +#newDiscussion textarea +{ + width: 99%; + height: 10em; +} + +#DiscussionsTabPane +{ + margin-left: 0px; + padding: 0 1em 1em 1em; +} + + +.postMeta +{ + float: right; +} + +.postReply +{ + cursor: hand; + float: right; + font-weight: bold; +} + +.postSaveReply +{ + display: none; +} + +.postSaveReply textarea +{ + width: 99%; + margin-bottom: 4px; + height: 8em; +} + +.toggleDiscussion +{ + cursor: hand; +} + +.saveReplyErrorMessage +{ + display: none; + margin: 0 0 4px 0; + color: Red; + font-weight: bold; +} + +#discussionListItem .avatar +{ + float: left; + padding: 5px; + vertical-align: middle; +} + +#discussionListItem .discussion +{ + margin-left: 55px; + padding: 0 5px 5px 5px; + vertical-align: top; +} + +.IE7 #discussionListItem .avatar +{ + margin-top: 15px; +} + + +/*-------- End DiscussionsTab --------*/ + + +.flotChart +{ + height: 300px; +} + +#projectMenuBarTop +{ + padding: 10px 0 20px 0; + font-weight: bold; + font-size: 25px; +} +.dayHeader +{ + font-weight: bold; +} + +/*-------- Start StatsPage --------*/ +#statsPage +{ + border: none; + background-color: Transparent; + margin-top: 1em; +} + +#statsPage .rangeBox +{ + padding: 5px; + background-color: #ECECEC; + border: solid 1px #C2C2C2; + float: left; +} +#statsPage .statBox +{ + margin-top: 1em; + margin-bottom: 10px; + overflow: hidden; + display: none; +} +#statsPage .statBox h3 +{ + font-size: 1.1em; + display: inline; +} + +#statsPage #statMessage +{ + margin-top: 1em; + display: none; +} + +#statsPage #statDownloadBox img { + float: left; +} + +#statsPage .statDownloadLink { + padding-left: 5px; + vertical-align: middle; +} + +#pointTooltip +{ + border: solid #000000 1px; + height: 35px; + background-color: #EEEEEE; + position: absolute; + display: none; + text-align: center; + padding: 9px; + border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + z-index: 1000; + white-space: nowrap; +} + +.flotChart +{ + height: 300px; +} + +/*-------- End StatsPage --------*/ + + +/***************************************************************/ +/* TagAutoComplete Styles */ +/***************************************************************/ +.AutoCompletePanel +{ + font-size: 95%; + border: solid .1em #999; + background-color: #f0f0f0; + padding: .15em; +} + +.AutoCompletePanel div.Row +{ + color: #000; + cursor: pointer; + background-color: transparent; + padding: .15em .25em; + text-align: left; +} + +.AutoCompletePanel div.Selected +{ + color: #fff; + background-color: #6D6D6D; +} + + +/*-------- Start Subscription Form --------*/ + +#subscribeForm +{ + background-color: #D3D3D1; + border: 1px solid #000000; + -border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + padding: 15px; + position: absolute; + display: block; +} + +#subscribeForm .subscribeFormbuttons +{ + text-align: right; + margin-top: 10px; +} +#subscribeForm .subscribeFormbuttons > button +{ + color: Blue; + border: none; + background: none; + font-weight: bold; + cursor: pointer; +} + +#subscribeForm .subscribeFormclose +{ + display: none; +} + +#subscribeForm table +{ + margin-bottom: 15px; +} + +#subscribeForm table th +{ + text-align: left; + font-weight: bold; + border-bottom: 1px solid #000000; +} + +#subscribeForm table td +{ + padding: 5px 10px 5px 20px; +} + +#subscribeForm .rowHeading td +{ + font-weight: bold; + border-bottom: 1px solid #FFFFFF; +} + +#subscribeForm table tr td:first-child +{ + padding: 5px 40px 5px 0; +} + + +/*-------- End Subscription Form --------*/ + +/*-------- Start Tag Browser --------*/ + +.tagBrowserfade +{ + position: absolute; + background-color: #aaaaaa; +} +#tagBrowser +{ + background-color: #f4f4f4; + border:1px solid #000000; + -border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + padding:15px; + position: absolute; + display: block; +} + +#tagBrowser .tagBrowserbuttons +{ + text-align:right; + margin-top: 10px; +} +#tagBrowser .tagBrowserbuttons > button +{ + color: Blue; + border: none; + background: none; + font-weight: bold; + cursor:pointer; +} + +#tagBrowser .tagBrowserclose +{ + display:none; +} + +.tagBrowserContainer { + width: 450px; +} + +.tagBrowserContainer h2 { + border-bottom: 1px solid #000000; + padding-bottom: 5px; +} +.tagBrowserContainer > p { + margin: 15px 0 15px 0; +} + +.tagBrowserContainer .tags { + margin: 5px; + height: 225px; + overflow-y: scroll; +} + + +/*-------- End Tag Browser --------*/ + +/*-------- Start List Filter Box --------*/ + +div#filterInputBox +{ + overflow:auto; + min-width:225px; +} + +.filterBox +{ + width: 100%; + background: #FFFFFF; + padding: 0px 2px; + height: 25px; + -moz-border-radius: 2px; + border-radius: 2px; + border: 1px solid #888888; + table-layout: auto; + margin-bottom:5px; +} + + .filterBox #filterImageCell + { + text-align: right; + padding: 0px; + vertical-align: middle; + } + + .IE7 .filterBox #filterImageCell + { + padding:2px 2px 0 0; + } + + .filterBox #filterImg + { + background: transparent url('searchButton.png') no-repeat 0 0; + width: 22px; + height: 22px; + } + +table.filterBox +{ + table-layout: fixed; +} + + .filterBox .stxtcell + { + padding-right: 4px; + width:90%; + } + + .filterBox .stxtcell > input + { + margin-right: 4px; + height: 26px; + line-height:26px; + width: 100%; + padding: 0px; + padding-left: 4px; + padding-top: 2px; + border: none; + } + + .IE7 .filterBox .stxtcell > input + { + height: 20px; + } + + .filterBox .stxtcell > input.stxtinptpassive + { + color: #ACACAC; + } + +/*-------- End List Filter Box --------*/ + +/*-------- Start Notifications --------*/ + +#notificationsSummaryBox +{ + font-weight: bold; + padding: .5em; +} + + +.notificationsByDay, .notifications +{ + /*list-style: none;*/ +} + +.dayHeader +{ + border-bottom: 1px solid silver; + margin-top: 1em; + padding-bottom: .5em; +} + +.notifications +{ + margin-top: .5em; +} + +ul.notifications li +{ + line-height: 1.5em; +} + +ul.notifications li.unread +{ + font-weight: bold; +} + +ul.notifications li ol, ul.notifications li ul +{ + margin-left: 1.5em; +} + +/*-------- End Notifications --------*/ + +/*-------- Start ProjectDetailsPage --------*/ + +#projectPage #projectInfo +{ + position: relative; + margin-top: 5px; + height: 100%; +} +#projectInfo .section +{ + float: left; + margin-bottom: 0px; + height: 100%; +} + + #projectInfo .section .itemBar, #projectInfo .section .itemBarLong + { + clear: both; + padding: 7px 0 7px 0; + overflow:auto; + } + + #projectInfo .section .itemBarLong:first-child + { + padding-top:3px; + } + + .IE7 #projectInfo .section .itemBar, .IE7 #projectInfo .section .itemBarLong + { + padding-top: 5px; + } + + #projectInfo .section .itemBar > label, #projectInfo .section .itemBarLong > label + { + width: 130px; + float: left; + } + + #projectInfo .section .itemBar div#yourRating { + float:left; + } + + #projectInfo .section .itemBar div.RatingStar { + margin:2px 1px 0 0; + } + + #projectInfo .section .itemBar div#RatingCount { + padding: 0 0 0 3px; + } + + #projectInfo .section .itemBar .ratingsWithCountContainer img { + vertical-align:top; + float:left; + padding-right: 4px; + } + + #projectInfo .section .itemBar > span, #projectInfo .section .itemBarLong > span, #projectPage .section .itemBar > div + { + float: left; + } + + #projectInfo .section .itemBar, #projectInfo .section .itemBarLong { + width: 100%; + } + + #projectInfo .section .itemBar > span { + float: none; + } + + #projectInfo .section .itemBar > span .shareThisItem { + white-space: nowrap; + } + + #projectInfo .section .itemBarLong div + { + margin-left: 130px; + padding: 0; + } + + #projectInfo .section .viewonlinecont + { + background-color:#d3d3d3; + padding:5px 10px; + margin-top:10px; + float:left; + font-weight:bold; + } + +#projectInfo #sectionLeft +{ + width: 50%; +} +#projectInfo #sectionRight +{ + width: 50%; +} +.IE7 #projectInfo #sectionRight +{ + width: auto; +} + +#projectPage h2.projectSummary +{ + font-weight:normal; + font-size: 1.1em; + margin-bottom: 11px; + line-height:1.4; + word-wrap: break-word; +} + +.IE7 #projectPage h2.projectSummary +{ + font-family: 'Segoe UI' , 'Lucida Grande' ,Verdana,Arial,Helvetica,sans-serif; +} + +.IE #projectPage .projectTitle, .IE9 #projectPage .projectTitle +{ + width: 100%; +} + +#projectPage #reportAbuse +{ + float: left; + font-size: x-small; +} + +#projectPage .hiddenSidebar { + display: none; +} + +#projectPage .fullProjectBody { + margin-left:-275px; +} + +.IE8 #projectPage #userCard { + float: left; + height: auto; +} + +#projectPage #userCard .avatar img { + max-width: 100px; + max-height: 100px; +} + +#projectDetails +{ + overflow:hidden; +} + +#projectBody +{ + width: 100%; + overflow:hidden; +} + + #projectDetails > div:first-child + { + margin: 5px 0 0 260px; + } + + #projectBody > div:first-child + { + margin: 20px 0 0 260px; + } + + .IE7 #projectContent .tabHeaders + { + overflow:hidden; + margin-bottom:-20px; + } + +#projectPage .sidebar +{ + float: left; + width: 215px; + margin-right: -250px; +} + + #projectPage .sidebar .section + { + margin: 20px 0 10px 0; + } + + #projectPage .sidebar .section .titleBar h3 + { + padding: 0 0 2px 0; + } + + #projectPage .sidebar .section .itemBarRight + { + min-height: 21px; + position: relative; + padding-top: 5px; + } + + #projectPage .sidebar .section .titleBar + { + margin-bottom: 5px; + } + + #projectPage .sidebar .section .authorItem + { + padding: 0 0 5px 10px; + } + + #projectPage .sidebar .section .authorItem a + { + display:block; + float:left; + max-width:170px; + } + + #projectPage .sidebar .section .authorItem > div + { + float:right; + } + + #projectPage .sidebar #advertisement + { + margin-top: 20px; + } + + #projectPage .sidebar #advertisement .label + { + text-align: center; + } + + #projectPage .sidebar #moreFromAuthor + { + width:225px; + margin: 20px 0 10px 0; + float:left; + } + + #projectPage .sidebar #moreFromAuthor .bottomBar { + padding: 5px 0px 5px 25px; + text-align: right; + } + +#projectPage #Collections { + min-height:22px; + min-width:169px; +} + +#projectPage #Collections .bevelButton { + background-color: #8CC63F; +} + +#projectPage .bevelButton +{ + font-weight: bold; + border-radius: 3px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + color: white; + padding: 2px 10px 3px; + text-align: center; +} + +#projectPage #DiscussionsTabPane .bevelButton +{ + font-weight: normal; + color: black; + padding: 1px 10px 1px; +} + +#projectPage #Downloads { + padding: 0 0 8px 0; + float: left; +} + #projectPage #Downloads > div:first-child { + float: left; + margin: 15px 0 0 0; + height:35px; + line-height:1.6; + width: 130px; + } + #projectPage #Downloads label + { + font-size:1.25em; + } + #projectPage #Downloads input + { + min-width: 100px; + padding: 3px 10px 3px 10px; + margin: 3px 10px 0 10px; + font-weight: bold; + float: left; + } + + #projectPage #Downloads .button + { + background-color:#007494; + color:#fff; + padding:5px 15px; + margin: 15px 15px 0 0; + float:left; + } + + #projectPage #Downloads .button:hover + { + background-color:#0095c4; + text-decoration:none; + } + +#projectPage #projectBody .attachments { + margin: 0 0 15px 0; +} + + #projectPage #projectBody .attachments label { + float: left; + } + + #projectPage #projectBody .attachments .files a, #projectPage #projectBody .attachments .files span { + float: left; + padding: 0 5px 0 5px; + } + +#publishBar +{ + border: 1px solid #707070; + background-color: #F8F8F8; + margin-top: 10px; +} + +.linehighlight { + background-color: #fff000; +} + +#sourceItem { + height: 610px; +} + #sourceItem > div:first-child { + padding: 20px 5px 0 15px; + font-weight: bold; + } + #sourceItem > div+div { + height: 560px; + padding: 10px; + overflow: auto; + } + #sourceItem .copyCode { + font-weight: normal; + margin: 0 15px 0 0; + float: right; + } + +.sourceList { + height: 600px; + padding: 5px; + border-top: 1px solid #CCC; + margin-top: -1px; +} + + .sourceList .sourceListTabHeader + { + margin:20px 10px; + } + .sourceList .sourceListTabs + { + margin-bottom:20px; + border-bottom: 1px solid #CCC; + float:left; + width:100%; + } + .sourceList .sourceListTabs .languageTab { + padding:5px 10px 5px 10px; + font-weight: bold; + float: left; + margin: 0 3px 0px 0; + color:#00749E; + } + .sourceList .sourceListTabs .languageTab:hover + { + color: #0095C4; + } + + .sourceList .sourceListTabs .selectedLanguage { + background-color: #fff; + color: #000; + border: 1px solid #ccc; + border-bottom:none; + margin-bottom:-2px; + } + + .sourceList .sourceListTabs .unselectedLanguage { + cursor: pointer; + } + + .sourceList .endTabs { + clear: both; + } + + .sourceList .sourceListContent { + padding-top: 5px; + } + + +.sbfc, +.sbfe +{ + white-space: nowrap; + text-indent: 20px; + cursor: pointer; + padding: .2em 0em .2em 0em; + background-repeat: no-repeat; + background-position: left center; + font-weight: bold; + text-decoration: none !important; +} + +.sbfc +{ + background-image: url(../samples/node_closed.gif); +} + +.sbfe +{ + white-space: nowrap; + background-image: url(../samples/node_opened.gif); +} + +.ndbf +{ + white-space: nowrap; + text-indent:20px; +} + +.sbf +{ + white-space: nowrap; + background: url(../samples/bullet.gif) no-repeat 4px -1px; + cursor: pointer; + text-indent: 20px; + white-space: nowrap; + padding: .1em 0em .1em 0em; +} + +.sbsf, +.sbf:hover +{ + color: #000; + text-decoration: none !important; + +} + +.sbsf +{ + color: #000 !important; + background-color: rgb(232, 232, 232); +} + +.sbf:hover +{ + color: #ce8b10; +} + +/*-------- Translate --------*/ +.translatePage { + width: 900px; +} +.translatePage .fileManager { + margin-bottom:20px; +} +.translatePage .fileManager h4 { + margin-top:10px; +} +.translatePage #formContainer { + width: 100%; +} +.translatePage .formLabel { + width: 300px; + padding: 5px; +} + .translatePage .textInput { + width: 425px; +} +.translatePage TEXTAREA.richText { + height: 600px; + width: 620px; +} +.translatePage TEXTAREA.unadornedEditor { + height: 600px; +} +.translatePage .formWideLabel, .translatePage .richText { + padding: 5px; +} +.translatePage .formWideLabel, .translatePage .unadornedEditor { + width: 750px; + padding: 5px; +} +.translatePage #languageSelection { + margin: 15px; + display: inline-block; +} + +.translateTab, .translateTabSelected { + font-weight: bold; + float: left; + text-align: center; + margin: 10px; + padding: 7px; + background: #E8E8E8; + white-space: nowrap; + cursor: pointer; +} + +.translateTabSelected +{ + color: White; + background: Gray; +} + +.translateTabSelected .translateLabel, .translateTab .translateLabel +{ + white-space: nowrap; + float: left; + padding: 0 5px 0 5px; +} + +.translateTab #deleteLanguage, .translateTab #moreLanguages +{ + padding-left: 10px; +} + +.translateLabel #deleteLanguage { + color: #FFFFFF; +} +/*-------- End Translate --------*/ +/*-------- Begin Eula --------*/ + + +#eulaPagefade +{ + position: absolute; + background-color: #FFFFFF; +} + +#eulaPage +{ + background-color: #f4f4f4; + border: 1px solid #000000; + -border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + padding: 15px; + display: block; + max-width: 70%; +} + +#eulaPage .eulaPageclose +{ + text-align: right; +} + +#eulaPage .eulaPagemessage +{ + overflow: auto; + max-height: 350px; +} + + #eulaPage .eulaPagemessage h1 + { + margin: 0 0 5px 0; + } + +#eulaPage .eulaPagebuttons +{ + text-align: right; + margin-top: 10px; +} +#eulaPage .eulaPagebuttons > button +{ + color: Blue; + border: none; + background: none; + font-weight: bold; + cursor: pointer; +} + + + #eulaPage #eula #documentText + { + line-height: normal; + } + +/*-------- End DocumentView --------*/ +/*-------- Begin FAQ --------*/ + +#FAQPage #TableOfContents h2 +{ + padding: 5px; + border-bottom: 2px solid #EFEFEF; + margin: 0 0 10px 0; + max-width: 70%; +} + +#FAQPage .FAQSection +{ + padding: 10px 0px; + width: 70%; +} + + #FAQPage .FAQSection h2 + { + padding: 5px; + border-bottom: 2px solid #EFEFEF; + } + + #FAQPage .FAQSection h3 + { + padding: 5px; + } + + #FAQPage .FAQSection ul, #FAQPage .FAQSection ol + { + margin: 0; + } + + #FAQPage .FAQSection #description > div + { + overflow: auto; + padding-left: 10px; + } + + #FAQPage .FAQSection #description img + { + float: left; + } + + #FAQPage .FAQSection #description div > div + { + padding-top: 10px; + float: left; + } + + #FAQPage .FAQSection > div > div + { + padding: 0 15px; + } + + #FAQPage #Reputation th, #FAQPage #Reputation td + { + padding-left: 20px; + } + +/*-------- End FAQ --------*/ +/*-------- Begin DocumentView --------*/ + +#documentView #documentText +{ + line-height: normal; +} + +/*-------- End DocumentView --------*/ + +.Opera wbr:after +{ + content: "\00200B"; +} + + +.IE9 wbr:after +{ + content: "\00200B"; +} + +.IE8 wbr { + width: 0px; + display: inline-block; + overflow: hidden; +} + +/*-------- Begin FileManager --------*/ + +.uploadControlNoError + { + height:30px + } +.uploadControlWithError + { + height:80px; + } +/*-------- End FileManager --------*/ + +/*-------- Begin User Card --------*/ +#userCard .titleBar { + border-bottom: solid 5px #E8E8E8; + margin: 10px 0 5px 0; +} + #userCard .titleBar h3 + { + font-size: 1.0em; + font-weight: bold; + line-height: 125%; + padding: 0 0 2px 0; + } + +#userCard .userFeed { + float: right; +} + +#userCard .bio { + max-width:300px; + white-space: normal; +} + +#userCard .avatar +{ + padding: 5px 5px 10px 5px; + margin: 0 0 3px 0; + text-align: center; +} + +#userCard .itemBar { + padding: 5px; +} + + #userCard .itemBar label + { + float: left; + } + + #userCard .itemBar label+span { + display: block; + margin-left: 100px; + } + +#userCard .collapsableSidebar { + clear:both; + width:100%; + margin-top: 5px; +} + +/* Profile Overrides */ +#userCard +{ + padding: 0 0 10px 0 +} + +#userCard .profile-usercard +{ + width:225px; +} + +#userCard .profile-usercard, #userCard .profile-inline, #userCard .profile-inline-header +{ + border:0px; + background-color:#fff; +} + +#userCard .profile-userimage-large +{ + margin-bottom:10px; + border:none; + width:auto; + height:auto; +} + +#userCard .profile-inline .profile-inline-header-details +{ + width:100%; + display:block; + clear:both; + margin-left:0px; +} + + + +/*-------- End User Card --------*/ +/*-------- Begin Description Progress Meter --------*/ + +#descriptionProgressMeter { + float: right; + border-top: 1px solid #DADADA; + border-left: 1px solid #DADADA; + width: 210px; + padding-left: 7px; +} + + #descriptionProgressMeter h4 { + font-weight: bold; + } + + #descriptionProgressMeter #progressGraphic { + border: 1px solid #888888; + width: 205px; + margin: 10px 0; + background-color: #E9E9E9; + padding: 1px 0 0 1px; + } + + #descriptionProgressMeter #progressGraphic div { + background-image: url("../common/progress_meter.png"); + padding-left: 5px; + } + + #descriptionProgressMeter #progressText { + font-weight: bold; + margin: 5px 0; + + } + + #descriptionProgressMeter #goodDescriptionText p+p { + padding: 5px 0; + } + + #descriptionProgressMeter #goodDescriptionText > div { + margin-top: 5px; + width: 150px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + overflow: auto; + } + + #descriptionProgressMeter #goodDescriptionText div img { + float: left; + } + + #descriptionProgressMeter #goodDescriptionText div div { + margin: 7px 0 5px 10px; + } + +/*-------- End Description Progress Indicator --------*/ + +/*-------- Start Sample Pack Tab View --------*/ +.SamplePackTab #headerBar +{ + padding: 15px 5px 20px 5px; + font-weight: bold +} + .SamplePackTab #headerBar .reportCount + { + padding-top: 2px; + } + .SamplePackTab #headerBar .samplePackSort + { + float: right; + color: #666; + } +/*-------- End Sample Pack Tab View --------*/ \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/description/Combined.css b/print/OEM Printer Customization Plug-in Samples/description/Combined.css new file mode 100644 index 00000000..e69de29b diff --git a/print/OEM Printer Customization Plug-in Samples/description/Galleries.css b/print/OEM Printer Customization Plug-in Samples/description/Galleries.css new file mode 100644 index 00000000..52bf19b1 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/description/Galleries.css @@ -0,0 +1,417 @@ +/* *************************************************** +Galleries.css - Common Structure + +This is where we define common layout for structures that are truly close to common across the different +Galleries sites. To make sure this works we need to follow certain conventions. + +1. Define each logical structure in its own section with its own comment block that gives the section +a Name, Description and defines the root element if one exists (i.e #someElement). Also, mark the closing block. + +2. Indent styles in a section to represent if it is a child of a previous element. +i.e. #someDiv{ + } + #someDiv ul { + } + +3. Do not include brand specific information here like colors and fonts unless they are *really* common. + +4. If there is an element that you know will be overridden in each brand stylesheet still include it here with an empty definition. +This will aid in knowing what section to override and what selectors to use. + +i.e. #someSction a { + } + +5. When you add a new section also update the Table of Contents below so that we have a quick overview of the sections + + *****************************************************/ + +/**************************************************** +Table of Contents + + Global - global classes + + FileAttachmentDisplay - The list of attached files under the editor + Eyebrow - The breadcrumb control at the top of the master page + Pager - The common paging control, used for browsing pages of search results + Profile User Card - Elements in the profile usercard control + SideNav - The navigation side bar that contains the search filters + + +*****************************************************/ + +/******************************** +Name: Global +Root: none +Description: truly global classes +********************************/ +body { + text-align: left; + direction: ltr; +} + +img.rss { + background: url(../../../GlobalResources/Images/Rss.png) no-repeat; + background-position: 0px 0px; + height: 17px; + width: 17px; +} +/* End Global Section */ + +/******************************** +Name: FileAttachmentDisplay +Root: #fileAttachmentDisplay +Description: The list of attached files under the editor +********************************/ +#fileAttachmentDisplay { +} + #fileAttachmentDisplay .attachment { + margin-right: 10px; + float: left; + } + + #fileAttachmentDisplay .attachment .displayAttachment { + padding: 0px 0 13px 0; + float: left; + } + + #fileAttachmentDisplay .attachment .removeAttachment { + background-image: url('/Content/Common/delete.png'); + display: block; + width: 16px; + height: 16px; + float: left; + } +/* End FileAttachmentDisplay Section */ + + +/******************************** +Name: Eyebrow +Root: .EyebrowContainer +Description: The breadcrumb control at the top of the master page +********************************/ +.EyebrowContainer { +} + .EyebrowContainer div.EyebrowElement{ + display:inline; + } + + .EyebrowContainer .EyebrowElement{ + font-weight:normal + } + .EyebrowContainer .EyebrowLeafLink{ + color:#000; + } +/* End Eyebrow Section */ + +/******************************** +Name: Pager +Root: #Pager +Description: The common paging control, used for browsing pages of search results +********************************/ +#Pager { +} + #Pager div{ + display:inline; + } +/* End Pager Section */ + +/******************************** + +Name: Profile User Card +Root: #dashboardPage #userCard +Description: Elements in the profile usercard control + +********************************/ + #dashboardPage #userCard .profile-usercard-inline { + margin: 5px 0 10px 0; + } + + /* #dashboardPage #userCard .profile-usercard { + width: 288px; + } +/* End Profile User Card Section */ + +/******************************** + +Name: Discussion +Root: #DiscussionsTabPane +Description: Defines the layout of the dicussion + + +********************************/ +#DiscussionsTabPane { +} + + #DiscussionsTabPane .itemHidden + { + background: lightgrey; + } + + #discussionListItem { + } + + .discussion .postActions + { + float: right; + } + + #discussionListItem .postItem + { + white-space: pre-wrap; + word-wrap: break-word; + font-size:1em; + } + +/* End Discussion Section */ + + +/******************************** + +Name: SearchDefaultLocale +Root: .searchDefaultLocale +Description: Defines the layout of the include english result checkbox on the Browse Page + + +********************************/ +.searchDefaultLocale +{ + float: right; + margin: 20px 0 0 5px; +} + .searchDefaultLocale input + { + vertical-align:top; + } + .searchDefaultLocale span + { + margin-left: -3px; + } +/*-------- End SearchDefaultLocale --------*/ + + +/******************************** + +Name: SideNav +Root: #sideNav +Description: Defines the layout of the naviation elements on the side of the Browse Page + These represent the different filters like Code Language, Category and Tag + + +********************************/ + +#sideNav { + width: 250px; + vertical-align:top; +} + #sideNav h3 { + } + + #sideNav .section { + padding: 0 0 10px 0; + position: relative; + } + + #sideNav .section a { + } + + #sideNav .section a:hover { + } + + #sideNav .section > div { + padding:5px 5px 5px 0; + line-height:150%; + } + + #sideNav .section ul { + list-style-type:none; + padding:0px; + margin:0px; + } + + #sideNav .section ul li { + position: relative; + padding: 5px 5px 5px 0; + } + + #sideNav .section ul li .selectedFilter { + float: left; + padding-right: 5px; + } + + #sideNav .section div.itemCount { + float: right; + } + + #sideNav .section form input[ type = "checkbox"] { + margin: 0px 4px 0px 0px; + vertical-align: middle; + } +/* End SideNav Section */ + +/*----------- Contribution Logos *******/ +.contributionLogo { + float: left; + position: relative; + margin-right: 6px; +} + +.logo_visualstudio { + background: transparent url('../common/logos/visualstudio.png') no-repeat; + width: 23px; + height: 12px; + margin-top: 3px; +} +.logo_allinonecode { + background: transparent url('../common/logos/1code.png') no-repeat; + width: 14px; + height: 16px; +} +.logo_exchange { + background: transparent url('../common/logos/exchange.png') no-repeat; + width: 14px; + height: 16px; +} +.logo_ie { + background: transparent url('../common/logos/ie.png') no-repeat; + width: 16px; + height: 16px; +} +.logo_office { + background: transparent url('../common/logos/office.png') no-repeat; + width: 17px; + height: 16px; +} +.logo_windows { + background: transparent url('../common/logos/windows.png') no-repeat; + width: 17px; + height: 16px; + } +.logo_azure { + background: transparent url('../common/logos/windowsazuredark.png') no-repeat; + width: 16px; + height: 16px; +} + +.logo_windowsphone { + background: transparent url('../common/logos/windowsphone.png') no-repeat; + width: 16px; + height: 16px; + } + + .contributionLogoTip { + position: absolute; + display: none; + border: solid 1px #CCC; + color: #333; + background-color: #F0F0F0; + font-size: 11px; + font-family: "Segoe UI",Sans-Serif; + box-shadow: 3px 3px 5px #888; + -moz-box-shadow: 3px 3px 5px #888; + z-index: 1003; + padding: 5px; + min-width: 250px; + } + +/*----------- End Contribution Logos *******/ + +.clear +{ + clear: both; +} + +.customcontributionLogoTip { + position: absolute; + display: none; + border: solid 1px #CCC; + background-color: white; + color: #333; + font-size: 11px; + font-family: "Segoe UI",Sans-Serif; + box-shadow: 3px 3px 5px #888; + -moz-box-shadow: 3px 3px 5px #888; + z-index: 1004; + padding: 5px; + min-width: 250px; +} + +.customcontributionTittle { + font-size: 14px; + margin-left: 90px; +} + +.customcontributionDiscription { + font-size: 13px; + margin: 10px 5px; + text-align: justify; +} + +.customcontribution { + float: left; + position: relative; + margin-right: 6px; +} + +.customcontributionLink { + margin-left: 5px; +} + +.customcontributionlogo { + float: left; + padding: 0 10px; + margin: 0; + width: 70px; + height: 70px; + background-repeat: no-repeat; +} + + +.logo_azure_large { + background-image: url('../common/logos/windowsazure_large.png'); +} +.logo_visualstudio_large { + background-image: url('../common/logos/visualstudio_large.png'); +} +.logo_exchange_large { + background-image: url('../common/logos/exchange_large.png'); +} +.logo_ie_large { + background-image: url('../common/logos/ie_large.png'); +} +.logo_office_large { + background-image: url('../common/logos/office_large.png'); +} +.logo_windows_large { + background-image: url('../common/logos/windows_large.png'); +} +.logo_windowsphone_large { + background-image: url('../common/logos/windowsphone_large.png'); +} + +/* Custome Header */ +.dirSubHeading .windowssdk .container +{ + background: #00BCF2 url('wpappsbackground.png') no-repeat; + color: #575757; + padding: 20px 10px 50px 225px; +} + +.dirSubHeading .windowssdk .container h1, .dirSubHeading .windowssdk .container h2 { + color: #575757 !important; +} + +.dirSubHeading .windowssdk .container p { + margin: 28px 0 0 0 !important; +} + +.dirSubHeading .windowssdk .container a { + background-color: #575757; + color: #FFFFFF !important; + cursor: pointer; + font-size: 16px; + font-family: 'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif; + padding: 11px; +} + + + diff --git a/print/OEM Printer Customization Plug-in Samples/description/Layout.css b/print/OEM Printer Customization Plug-in Samples/description/Layout.css new file mode 100644 index 00000000..625f7776 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/description/Layout.css @@ -0,0 +1,147 @@ +#container { + min-height: 768px; +} + +#leftSubHeaderContainer +{ + margin-top:20px; +} + +#title h1 +{ + font-size:25px; +} + +#subtitle h2 +{ + font-size:15px; +} + +#subtitle +{ + margin-left:10px; +} + + +#formContainer +{ + margin-left:10px; + margin-top:30px; +} + +.formLabel +{ + float:left; + width: 250px; +} + +.formRow +{ + clear:both; + padding: 10px 0 10px 10px; +} + + +.formRecaptchaRow +{ + clear:both; + float:left; + margin-top:20px; + margin-left:10px; + margin-bottom:20px; +} + +.formSubmitRow +{ + clear:both; + margin-top:20px; + margin-left:300px; + margin-bottom:20px; +} + +.formControl { + width:300px; + float:left; +} +.formControl .textInput +{ + width:300px; +} + +.formControl textarea +{ + width:425px; + height:100px; +} + +.formControl .tag +{ + width:425px; +} + +.formControl .richText +{ + margin-top:10px; + width:500px; + height:440px; +} + +.formWideLabel +{ + width:500px; +} + +.formBigLabel +{ + margin-top:20px; + font-size:20px; +} + +.formControlBelow +{ + clear:both; + margin-top:10px; + width:500px; +} + +.required +{ + color: Red; +} +.helpText +{ + color: #9D9D9D; + font-style: italic; +} + +#agreementSummary +{ + clear:both; + margin-top:10px; + width:800px; +} + +.field-validation-error, .validation-summary-errors +{ + color: #FF0000; + font-weight: bold; +} + +.tinyMCETemplate { + position: relative; + left: 400px; + width: 300px; + max-height: 300px; + overflow: auto; +} + +.IE6 .tinyMCETemplate { + left: 25px; +} + +.ownerBar { + padding: 5px; +} +.ownerBar .ownerBarOptions { + float: right; +} diff --git a/print/OEM Printer Customization Plug-in Samples/description/dc96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css b/print/OEM Printer Customization Plug-in Samples/description/dc96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css new file mode 100644 index 00000000..e69de29b diff --git a/print/OEM Printer Customization Plug-in Samples/description/iframedescription.css b/print/OEM Printer Customization Plug-in Samples/description/iframedescription.css new file mode 100644 index 00000000..9abc9cdb --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/description/iframedescription.css @@ -0,0 +1,179 @@ +body { + color: #000000; + font-family: 'Segoe UI',Verdana,Arial; + font-size: 0.813em; + font-style: normal; + word-wrap: break-word; +} + +/*BEGIN HEADERS*/ +.h1, h1 { + color: #3A3E43; + font-family: 'Segoe UI',Verdana,Arial; + font-size: 1.4em; + font-weight: bold; + margin: 0; +} + +.h2, h2 { + color: #3A3E43; + font-family: 'Segoe UI',Verdana,Arial; + font-size: 1.2em; + font-weight: bold; +} +.h3, h3 { + color: #3A3E43; + font-family: 'Segoe UI',Verdana,Arial; + font-size: 1.077em; + font-weight: bold; +} +.h4, h4 { + color: #3A3E43; + font-family: 'Segoe UI',Verdana,Arial; + font-size: 1em; + font-weight: bold; +} +h4.subHeading { + margin-bottom: 7px; + margin-top: 13px; +} +/*END HEADERS*/ + +/*BEGIN LINKS*/ +a:link { + color: #00749E; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} +a:visited { + color: #960BB4; + text-decoration: none; +} +a:focus { + outline: 1px dotted #000000; +} + +a.libraryLink:link { + text-decoration:none; + border-bottom:1px dotted; +} + +/*END LINKS*/ + +/*BEGIN IMAGES*/ +img { + border: 0 none; +} +/*END IMAGES*/ + +/*BEGIN TABLE*/ +.title table { + color: #000000; + font-family: 'Segoe UI',Verdana,Arial; + font-size: 1.077em; + font-style: normal; +} +table { + border-collapse: collapse; +} + +table, table th, table td { + border:1px solid #BBBBBB; +} +/*END TABLE*/ + +/*BEGIN LIST*/ +ul { + list-style-type: disc; + margin-left:40px; + padding-left: 0; +} +ul li { + padding-bottom: 10px; +} +ol { + margin-left:40px; + padding-left: 0; +} +ol li { + padding-bottom: 10px; +} +/*END LIST*/ + +.scriptcode { + position: relative; + padding: 8px 8px 8px 8px; + background: #FFFFFF; + font-size: 12px; + line-height: 125%; + font-weight:normal; +} +.scriptcode pre +{ + white-space: pre-wrap !important; /* css-3 */ + word-wrap: break-word !important; /* Internet Explorer 5.5+ */ + margin:0 0 10px 0 !important; + padding: 10px; + border-top: solid 2px #D0D2D2; + border-bottom: solid 2px #D0D2D2; + border-left: solid 1px #D0D2D2; + border-right: solid 1px #D0D2D2; +} + +.scriptcode .title { + color:#E66A38; + font-size: 12px; + font-weight:bold; + margin: 0; + min-height: 23px; +} +.scriptcode .title > span:first-child { + border-left: solid 1px #D0D2D2; +} +.scriptcode .title > span { + padding: 4px 8px 4px 8px; + display: inline-block; + border-top: 1px solid #D0D2D2; + border-right: 1px solid #D0D2D2; + border-collapse: collapse; + text-align: center; + background: white; +} +.scriptcode .title > span.otherTab { + color: #1364C4; + background: #EFF5FF; + cursor: pointer; +} + +.scriptcode .hidden { + display: none !important; + visibility: hidden !important; +} + +.scriptcode .copyCode { + padding: 8px 2px 0 2px !important; + margin-right: 15px; + position: absolute !important; + right: 0 !important; + top: 17px; + display:block !important; + background: #FFFFFF; +} +.scriptcode .pluginLinkHolder { + display: none; +} +.scriptcode .pluginEditHolderLink { + display: none; +} + +.Opera wbr +{ + display: inline-block; +} + +.IE9 wbr:after +{ +content: "\00200B"; +} diff --git a/print/OEM Printer Customization Plug-in Samples/description/offline.js b/print/OEM Printer Customization Plug-in Samples/description/offline.js new file mode 100644 index 00000000..f5d07c8a --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/description/offline.js @@ -0,0 +1,52 @@ +var Galleries = Galleries || { }; + +(function() { + + function findElem(parent, tagName, className) { + var elemToSearch = (parent) ? parent : document.body; + var tagMatch = elemToSearch.getElementsByTagName(tagName); + var evaluator = function(elem) { + return (className) ? (elem.className.indexOf(className) > -1) : true; + }; + + return findArrayElem(tagMatch, evaluator); + } + + function findArrayElem(array, evaluator) { + var newArray = new Array(); + for (var count = 0; count < array.length; count++) { + if (evaluator(array[count])) { + newArray.push(array[count]); + } + } + return newArray; + } + + function iterateElem(elems, delegate) { + for(var count = 0; count < elems.length; count++) { + delegate(count, elems[count]); + } + } + + function isHidden(elem) { + return (elem.offsetHeight === 0 && elem.offsetWidth === 0) || elem.style && elem.style.display === "none"; + } + + function onWindowLoad(callback) { + attachEventHandler(null, 'load', callback); + } + + function attachEventHandler(elem, event, callback) { + var elemToAttach = (elem) ? elem : window; + if (document.addEventListener) { + elemToAttach.addEventListener(event, callback, false); + } else if ( document.attachEvent ) { + elemToAttach.attachEvent('on' + event, callback); + } + } + + Galleries.findElem = findElem; + Galleries.iterateElem = iterateElem; + Galleries.attachEventHandler = attachEventHandler; + Galleries.onWindowLoad = onWindowLoad; +})(); \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/license.rtf b/print/OEM Printer Customization Plug-in Samples/license.rtf new file mode 100644 index 00000000..690a7ad0 --- /dev/null +++ b/print/OEM Printer Customization Plug-in Samples/license.rtf @@ -0,0 +1,25 @@ +{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 MS Shell Dlg;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs16\f2\cf0 \cf0\ql{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par} +{\fs40\f2 {\ltrch MICROSOFT LIMITED PUBLIC LICENSE version 1.1}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 \line {\ltrch ----------------------}\line \li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch This license governs use of code marked as \ldblquote sample\rdblquote or \ldblquote example\rdblquote available on this web site without a license agreement, as provided under the section above titled \ldblquote NOTICE SPECIFIC TO SOFTWARE AVAILABLE ON THIS WEB SITE.\rdblquote If you use such code (the \ldblquote software\rdblquote ), you accept this license. If you do not accept the license, do not use the software.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch 1. Definitions}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch The terms \ldblquote reproduce,\rdblquote \ldblquote reproduction,\rdblquote \ldblquote derivative works,\rdblquote and \ldblquote distribution\rdblquote have the same meaning here as under U.S. copyright law. }\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch A \ldblquote contribution\rdblquote is the original software, or any additions or changes to the software.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch A \ldblquote contributor\rdblquote is any person that distributes its contribution under this license.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch \ldblquote Licensed patents\rdblquote are a contributor\rquote s patent claims that read directly on its contribution.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch 2. Grant of Rights}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (A) Copyright Grant - Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (B) Patent Grant - Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch 3. Conditions and Limitations}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (A) No Trademark License- This license does not grant you rights to use any contributors\rquote name, logo, or trademarks.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (E) The software is licensed \ldblquote as-is.\rdblquote You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 {\ltrch (F) Platform Limitation - The licenses granted in sections 2(A) and 2(B) extend only to the software or derivative works that you create that run directly on a Microsoft Windows operating system product, Microsoft run-time technology (such as the .NET Framework or Silverlight), or Microsoft application platform (such as Microsoft Office or Microsoft Dynamics).}\li0\ri0\sa0\sb0\fi0\ql\par} +{\f2 \line \li0\ri0\sa0\sb0\fi0\ql\par} +} +} \ No newline at end of file -- cgit v1.3.1 From c079e3e34fef7ff67e144125db9a15432a81e89e Mon Sep 17 00:00:00 2001 From: Mike Fenelon Date: Thu, 24 Aug 2017 12:09:45 -0700 Subject: Convert the HTML description page to MarkDown README.md --- .../README.md | 89 +- .../description.html | 430 --- .../19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css | 295 -- .../description/Brand.css | 3615 -------------------- .../description/Combined.css | 0 .../description/Galleries.css | 417 --- .../description/Layout.css | 147 - ...c96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css | 0 .../description/iframedescription.css | 179 - .../description/offline.js | 52 - 10 files changed, 46 insertions(+), 5178 deletions(-) delete mode 100644 print/OEM Printer Customization Plug-in Samples/description.html delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/Brand.css delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/Combined.css delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/Galleries.css delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/Layout.css delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/dc96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/iframedescription.css delete mode 100644 print/OEM Printer Customization Plug-in Samples/description/offline.js diff --git a/print/OEM Printer Customization Plug-in Samples/README.md b/print/OEM Printer Customization Plug-in Samples/README.md index 1d6a8ac5..b8e0c108 100644 --- a/print/OEM Printer Customization Plug-in Samples/README.md +++ b/print/OEM Printer Customization Plug-in Samples/README.md @@ -20,68 +20,71 @@ The following samples are included as part of this sample set: | WATERMARK | Demonstrates how to produce customizable watermark page simulation by controlling PostScript injected in the printing stream. The components of the sample include a PostScript-based rendering module in conjunction with a UI module. The rendering module is responsible for the injection of the modified PostScript into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and rendering modules. | | WATERMARKUNI | Demonstrates how to produce customizable watermark page simulation by controlling PCL data injected in the printing stream. The components of the sample include a UNIDRV-based rendering module in conjunction with a UI module. The rendering module is responsible for the injection of the PCL data into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and rendering modules. This sample works only if you have a page printer that has its own fonts. It doesn't download any fonts nor convert fonts to bitmap. | -For information about how to develop a plug-in for customizing the print driver UI, see COM Interfaces for UI Plug-Ins. +For information about how to develop a plug-in for customizing the print driver UI, see [COM Interfaces for UI Plug-Ins](https://docs.microsoft.com/en-us/windows-hardware/drivers/print/com-interfaces-for-ui-plug-ins). **Note** The OEMDLL samples are for the v3 print driver model only. -**Note** -To build this sample, you can use Microsoft Visual Studio 2013 (Express, Professional, or Ultimate) and Windows Driver Kit (WDK) 8.1 Update. You can get Visual Studio 2013 and WDK 8.1 Update here. +**Note** +To build this sample, you can use Microsoft Visual Studio 2017 (Community, Professional, or Enterprise) and Windows Driver Kit (WDK) 10. You can get Visual Studio 2017 [here](https://www.visualstudio.com) and WDK 10 [here](https://developer.microsoft.com/en-us/windows/hardware/download-kits-windows-hardware-development). You can also build this sample with Visual Studio 2013 (Professional or Ultimate) and Windows Driver Kit (WDK) 8.1. For Windows Driver Kit (WDK) 8 samples, download the WDK 8 samples pack. The samples in the WDK 8 samples pack will build only with Microsoft Visual Studio Professional 2012 (Professional or Ultimate) and WDK 8. -Operating system requirements -Client -Windows 7 -Server -Windows Server 2008 R2 -Build the sample -To build a driver solution using Windows 8.1 driver kit (Windows Driver Kit (WDK)) and Visual Studio 2013, perform the following steps. -1. Open the solution file in Visual Studio 2013 +## Operating system requirements +Client - Windows 7 or later +Server - Windows Server 2008 R2 or later + +## Build the sample +To build a driver solution using Windows 10 driver kit (Windows Driver Kit (WDK)) and Visual Studio 2017, perform the following steps. +1. Open the solution file in Visual Studio 2017 2. Add all non-binary files (usually located in the \install directory of the sample) to the Package project -a. In the Solution Explorer, right click Driver Files -b. Select Add, then click Existing Item +a. In the **Solution Explorer**, right click **Driver Files** +b. Select **Add**, then click **Existing Item** c. Navigate to the location to which you downloaded the sample, and select all the files in the install directory, or the equivalent set of non-binary files such as INFs, INIs, GPD, PPD files, etc. -d. Click Add +d. Click **Add** 3. Configure these files to be added into the driver package -a. In the Solution Explorer, right click the Package project and select Properties -b. In the left pane, click Configuration Properties > Driver Install > Package Files. -c. In the right pane, use the ellipsis button (...) to browse to the set of files that needs to be added to the driver package. All the data files that you added in Step 2-c, except the INF file, should be added. -Note This configuration is per-architecture, so this configuration must be repeated for each architecture that will be built. -d. Click OK +a. In the **Solution Explorer**, right click the Package project and select **Properties** +b. In the left pane, click **Configuration Properties** > **Driver Install** > **Package Files**. +c. In the right pane, use the ellipsis button (...) to browse to the set of files that needs to be added to the driver package. All the data files that you added in **Step 2-c**, except the INF file, should be added. +**Note** This configuration is per-architecture, so this configuration must be repeated for each architecture that will be built. +d. Click **OK** 4. Open the INF file and edit it to match the built output a. Open the INF file -b. In the Version section, add a reference to a catalog file like this: CatalogFile=XpsDrvSmpl.cat +b. In the Version section, add a reference to a catalog file that matches the .INF name like this: CatalogFile=XpsDrvSmpl.cat c. In the SourceDisksFiles section, change the location of the DLL files you are building, to =1. This indicates that there is no architecture specific directory in this driver. If you ship multiple architectures simultaneously, you will need to collate the driver INF manually. -At this point, Visual Studio 2013 will be able to build a driver package and output the files to disk. In order to configure driver signing and deployment, see Developing, Testing, and Deploying Drivers. -For more information about how to build a driver solution using Microsoft Visual Studio, see Building a Driver. -Run the sample -Installation +At this point, Visual Studio 2017 will be able to build a driver package and output the files to disk. In order to configure driver signing and deployment, see [Developing, Testing, and Deploying Drivers](https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/). +For more information about how to build a driver solution using Microsoft Visual Studio, see [Building a Driver](https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/building-a-driver). +## Run the sample +### Installation After building the samples, you can install them by using the Add Printer Wizard. Select the local printer, click Have Disk, and point to the directory that contains the relevant INF (oemdll.inf, bitmap.inf, oemprean.inf, and so on) file. -Design and Operation -BITMAP +## Design and Operation +### BITMAP This sample includes the following features: -The supported ColorMode options in the bitmap driver's GPD are monochrome, 4bpp, 8bpp, and 24bpp. -The bitmap driver implements the IPrintOemUni::ImageProcessing callback to access bitmap data one band at a time. The driver's implementation of ImageProcessing buffers the band data every time it is called. The function is also responsible for filling the BITMAPINFOHEADER and COLORTABLE structures that are necessary for dumping the data out to a bitmap file. -The bitmap driver implements the OEMEndDoc DDI hook to dump the buffered bitmap data to the spooler at the end of the print job. The driver's implementation of OEMEndDoc dumps the headers first and then the buffered data. -The GrowBuffer helper function is called every time the buffer needs to be enlarged to hold the bitmap data. -The bitmap driver renders multi-page documents into a single large output bitmap file. +- The supported ColorMode options in the bitmap driver's GPD are monochrome, 4bpp, 8bpp, and 24bpp. +- The bitmap driver implements the IPrintOemUni::ImageProcessing callback to access bitmap data one band at a time. The driver's implementation of ImageProcessing buffers the band data every time it is called. The function is also responsible for filling the BITMAPINFOHEADER and COLORTABLE structures that are necessary for dumping the data out to a bitmap file. +- The bitmap driver implements the OEMEndDoc DDI hook to dump the buffered bitmap data to the spooler at the end of the print job. The driver's implementation of OEMEndDoc dumps the headers first and then the buffered data. +- The GrowBuffer helper function is called every time the buffer needs to be enlarged to hold the bitmap data. +- The bitmap driver renders multi-page documents into a single large output bitmap file. + This sample has the following limitations: -The plug-in does not support landscape orientation although the option exists in the GPD. -In 24bpp mode, documents larger than three pages will produce an extremely large bitmap (.bmp) file. Although the output is correct, you might not be able to view it because of memory limitations in the bitmap viewer. +- The plug-in does not support landscape orientation although the option exists in the GPD. +- In 24bpp mode, documents larger than three pages will produce an extremely large bitmap (.bmp) file. Although the output is correct, you might not be able to view it because of memory limitations in the bitmap viewer. -OEMPREAN +### OEMPREAN When preanalysis is enabled in the GPD (for more details about preanalysis, see the WDK documentation), Unidrv defines the surface as a banding surface but causes the first playback (that is, the first band) to be of the entire page. Unidrv performs this definition by setting the GDI clip window to the entire page. Unidrv enables all drawing commands to be hooked but returns before any drawing can be done. On the subsequent passes, Unidrv resets the clip window back to the original band size and bands normally. -In order for plugins to also take part in preanalysis, they can enable OEM preanalysis by specifying the "*PreAnalysisOptions: 8" parameter in the GPD. The OEM rendering plug-in must hook both DrvStartBanding and DrvNextBand when this mode is enabled in the GPD. The OEM rendering plug-in must test the pptl parameter of the OEMStartBanding call to determine whether preanalysis has been enabled on this page. If the pptl parameter is NULL, preanalysis has been enabled, and the OEM rendering plug-in should consider all drawing calls up to the first call to OEMNextBand to be part of preanalysis. -During these preanalysis phase drawing calls, the plug-in should not draw on the surface. The plug-in should also not call back into unidrv. You should use this phase only for analysis of the objects on the page. For example, certain printers need to handle black objects that intersect with color objects differently from black objects that appear by themselves. Other printers might need to halftone StretchBlt objects differently from BitBlt objects. + +In order for plugins to also take part in preanalysis, they can enable OEM preanalysis by specifying the `"*PreAnalysisOptions: 8"` parameter in the GPD. The OEM rendering plug-in must hook both `DrvStartBanding` and `DrvNextBand` when this mode is enabled in the GPD. The OEM rendering plug-in must test the `pptl` parameter of the `OEMStartBanding` call to determine whether preanalysis has been enabled on this page. If the `pptl` parameter is `NULL`, preanalysis has been enabled, and the OEM rendering plug-in should consider all drawing calls up to the first call to `OEMNextBand` to be part of preanalysis. + +During these preanalysis phase drawing calls, the plug-in should not draw on the surface. The plug-in should also not call back into unidrv. You should use this phase only for analysis of the objects on the page. For example, certain printers need to handle black objects that intersect with color objects differently from black objects that appear by themselves. Other printers might need to halftone `StretchBlt` objects differently from `BitBlt` objects. You should be aware that after preanalysis, you might get more calls than you saw in the normal rendering, because primitives that cross band boundaries yield two or more DDI calls after the preanalysis pass. -The sample uses the bPreAnalysis flag in the OEMPDEV structure to denote whether a particular pass is the preanalysis pass or the actual rendering pass. If the bPreAnalysis flag is set, it indicates that the current pass is the preanalysis pass. The sample implements all of the drawing function hooks in Ddihook.cpp. The sample uses the OEMStartBanding and OEMNextBand functions to respectively set and reset the bPreAnalysis flag. The sample also uses the DBG_CLIPOBJ debug macro function to dump the bounds of the clipping rectangle available for preanalysis in each of the drawing functions during the preanalysis pass. To view all of the debug output in the debugger, you must set the debug level to VERBOSE. The rest of the sample is identical to the Oemuni sample that illustrates a basic OEM rendering plug-in. -Note that the surface used during preanalysis might differ from the surface passed in during the rendering pass. -PTPCPIPR -This sample is an educational example that illustrates the basic functionality that a Unidrv plug-in for the IPrintOemPrintTicketProvider interface should implement. +The sample uses the `bPreAnalysis` flag in the OEMPDEV structure to denote whether a particular pass is the preanalysis pass or the actual rendering pass. If the `bPreAnalysis` flag is set, it indicates that the current pass is the preanalysis pass. The sample implements all of the drawing function hooks in Ddihook.cpp. The sample uses the `OEMStartBanding` and `OEMNextBand` functions to respectively set and reset the `bPreAnalysis` flag. The sample also uses the `DBG_CLIPOBJ` debug macro function to dump the bounds of the clipping rectangle available for preanalysis in each of the drawing functions during the preanalysis pass. To view all of the debug output in the debugger, you must set the debug level to VERBOSE. The rest of the sample is identical to the Oemuni sample that illustrates a basic OEM rendering plug-in. +**Note** that the surface used during preanalysis might differ from the surface passed in during the rendering pass. + +### PTPCPIPR +This sample is an educational example that illustrates the basic functionality that a Unidrv plug-in for the `IPrintOemPrintTicketProvider` interface should implement. The primary functionality of the plug-in is to support the PhotoPrintingIntent PrintSchema keyword. The PhotoPrintingIntent keyword is designed to provide a mechanism for photo printers to support enhancements that are specific to photo printing. An application or the user (through the print UI) can then specify whether a particular print job is a photo-printing job, in which case the device can apply appropriate enhancements. The intent setting is communicated to the device driver in a PrintTicket. The actual enhancements made are device-specific, and as such, the driver has to map the high-level intent setting into specific output settings, like resolution or bpp. This plug-in sample demonstrates the conversion. -The plug-in implements the ExpandIntentOptions method of the IPrintOemPrintTicketProvider interface. This method is called with an input print-ticket. The plug-in checks if the print-ticket contains a photo-printing intent setting, and if so, removes the setting, while instead adding to the print-ticket output settings as mentioned above. The code sample uses MSXML6 for all PrintTicket XML handling. -UINUIREP +The plug-in implements the `ExpandIntentOptions` method of the `IPrintOemPrintTicketProvider` interface. This method is called with an input print-ticket. The plug-in checks if the print-ticket contains a photo-printing intent setting, and if so, removes the setting, while instead adding to the print-ticket output settings as mentioned above. The code sample uses MSXML6 for all PrintTicket XML handling. +### UINUIREP This sample shows how a plug-in for a Unidrv-based driver can replace the default UI. It provides new property sheets for the printer property and printing preferences pages. -Use this sample as an example of implementing full UI replacement in a Unidrv-based plugin. It also demonstrates the use of the new IPrintCoreHelper interface. +Use this sample as an example of implementing full UI replacement in a Unidrv-based plugin. It also demonstrates the use of the new `IPrintCoreHelper` interface. This sample is only provided for educational purposes and should not be used in a production environment. \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/description.html b/print/OEM Printer Customization Plug-in Samples/description.html deleted file mode 100644 index 4f819aa9..00000000 --- a/print/OEM Printer Customization Plug-in Samples/description.html +++ /dev/null @@ -1,430 +0,0 @@ - - - - - - - OEM Printer Customization Plug-in Samples - - - - - - -
-

OEM Printer Customization Plug-in Samples

-
-
-
-
- -
- printer, Windows Driver -
-
-
- -
- Printing -
-
-
- -
- Desktop -
-
-
- -
- -
-
-
- -
en-US
-
-
- -
4/2/2014
-
-
- - -
- -
-
- - - -
- -
-

The OEMDLL samples are an illustration of OEM customization plug-ins. The BITMAP, OEMPS, OEMUI, OEMUNI, OEMPREAN, CUSTHLP, SyncSet, ThemeUI, PSUIRep, and Watermark samples do not affect the printer output. They are only examples of how to build OEM Customization - DLLs of various types.

-

The following samples are included as part of this sample set:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SampleDescription
-

BITMAP

-
-

a Unidrv-based bitmap rendering plug-in. This sample demonstrates how to write a Unidrv-based rendering plug-in that functions as a bitmap driver. The sample is based on the redesigned version of the OEMUNI sample. -

-
-

CUSTHLP

-
-

An OEM help-customization plug-in. This sample demonstrates adding OEM help to your customization plug-in and how to replace standard Microsoft supplied help with customized help. -

-
-

OEMPREAN

-
-

illustrates how you can leverage the pre-analysis feature in Unidrv. This sample is built on the redesigned version of the OEMUNI sample. -

-
-

OEMPS

-
-

A PostScript rendering plug-in. This sample demonstrates how to write a PostScript-based rendering plug-in.

-
-

OEMUI

-
-

A user interface plug-in (both PostScript and Unidrv flavors are available). The OEMUI sample demonstrates common UI tasks such as adding additional elements to the UI (that is, items and pages). -

-
-

OEMUNI

-
-

A user interface plug-in (both PostScript and Unidrv flavors are available). The OEMUI sample demonstrates common UI tasks such as adding additional elements to the UI (that is, items and pages). -

-
-

PSUIREP

-
-

A PostScript UI replacement sample. This sample demonstrates how to completely replace the standard printer driver UI for PostScript driver plug-ins. -

-
-

PTPCPIPR

-
-

The Unidrv Plug-in for Print Ticket Provider Interface sample contains a functional Unidrv configuration plug-in that implements the IPrintOemPrintTicketProvider interface. You can use this code as a starting point for developing new driver plug-ins that - support PrintTicket functionality.

-
-

SYNCSET

-
-

A synchronization plug-in. This sample demonstrates how to synchronize driver settings between the OEM customization page and the standard device settings page. -

-
-

THEMEUI

-
-

A theming plug-in. This sample demonstrates how to use theming (that is, comctl v6) for printer driver UI.

-
-

UNIUIREP

-
-

This Universal Printer Driver (Unidrv) UI plugin sample shows how to fully replace Unidrv's standard UI and how to use the new IPrintCoreHelper interface to enumerate GDP features/options, enumerate constraints, get/set Unidrv settings, and create a GDL - snapshot.

-
-

WATERMARK

-
-

Demonstrates how to produce customizable watermark page simulation by controlling PostScript injected in the printing stream. The components of the sample include a PostScript-based rendering module in conjunction with a UI module. The rendering module is - responsible for the injection of the modified PostScript into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and - rendering modules.

-
-

WATERMARKUNI

-
-

Demonstrates how to produce customizable watermark page simulation by controlling PCL data injected in the printing stream. The components of the sample include a UNIDRV-based rendering module in conjunction with a UI module. The rendering module is responsible - for the injection of the PCL data into the printing stream. This sample demonstrates the required COM interfaces, required functions with sample code and how to use the OEM's private DEVMODE section to communicate between the UI and rendering modules. This - sample works only if you have a page printer that has its own fonts. It doesn't download any fonts nor convert fonts to bitmap. -

-
-

For information about how to develop a plug-in for customizing the print driver UI, see - -COM Interfaces for UI Plug-Ins.

-

Note  The OEMDLL samples are for the v3 print driver model only.

-

Note  

-

To build this sample, you can use Microsoft Visual Studio 2013 (Express, Professional, or Ultimate) and Windows Driver Kit (WDK) 8.1 Update. You can get Visual Studio 2013 and WDK 8.1 Update -here.

-

You can also build this sample with Visual Studio 2013 (Professional or Ultimate) and -Windows Driver Kit (WDK) 8.1.

-

For Windows Driver Kit (WDK) 8 samples, download the -WDK 8 samples pack. The samples in the WDK 8 samples pack will build only with Microsoft Visual Studio Professional 2012 (Professional or Ultimate) and WDK 8.

-

-

Operating system requirements

- - - - - - - - - - - -
Client
Windows 7
Server
Windows Server 2008 R2
-

Build the sample

-

To build a driver solution using Windows 8.1 driver kit (Windows Driver Kit (WDK)) and Visual Studio 2013, perform the following steps.

-
-

1. Open the solution file in Visual Studio 2013

-
-

2. Add all non-binary files (usually located in the \install directory of the sample) to the Package project

-
-

a. In the Solution Explorer, right click Driver Files

-
-

b. Select Add, then click Existing Item

-
-

c. Navigate to the location to which you downloaded the sample, and select all the files in the install directory, or the equivalent set of non-binary files such as INFs, INIs, GPD, PPD files, etc.

-
-

d. Click Add

-
-
-

3. Configure these files to be added into the driver package

-
-

a. In the Solution Explorer, right click the Package project and select -Properties

-
-

b. In the left pane, click Configuration Properties > Driver Install > -Package Files.

-
-

c. In the right pane, use the ellipsis button (...) to browse to the set of files that needs to be added to the driver package. All the data files that you added in -Step 2-c, except the INF file, should be added.

-

Note  This configuration is per-architecture, so this configuration must be repeated for each architecture that will be built.

-
d. Click OK
-
-

4. Open the INF file and edit it to match the built output

-
-

a. Open the INF file

-
-

b. In the Version section, add a reference to a catalog file like this: CatalogFile=XpsDrvSmpl.cat -

-
-

c. In the SourceDisksFiles section, change the location of the DLL files you are building, to =1. This indicates that there is no architecture specific directory in this driver. If you ship multiple architectures simultaneously, you will need to collate - the driver INF manually.

-
-
-

-

At this point, Visual Studio 2013 will be able to build a driver package and output the files to disk. In order to configure driver signing and deployment, see - -Developing, Testing, and Deploying Drivers.

-

For more information about how to build a driver solution using Microsoft Visual Studio, see -Building a Driver.

-

Run the sample

-

Installation

-

After building the samples, you can install them by using the Add Printer Wizard. Select the local printer, click -Have Disk, and point to the directory that contains the relevant INF (oemdll.inf, bitmap.inf, oemprean.inf, and so on) file. -

-

Design and Operation

-

BITMAP

-

-

This sample includes the following features:

-
    -
  • The supported ColorMode options in the bitmap driver's GPD are monochrome, 4bpp, 8bpp, and 24bpp. -
  • The bitmap driver implements the IPrintOemUni::ImageProcessing callback to access bitmap data one band at a time. The driver's implementation of ImageProcessing buffers the band data every time it is called. The function is also responsible for filling - the BITMAPINFOHEADER and COLORTABLE structures that are necessary for dumping the data out to a bitmap file. -
  • The bitmap driver implements the OEMEndDoc DDI hook to dump the buffered bitmap data to the spooler at the end of the print job. The driver's implementation of OEMEndDoc dumps the headers first and then the buffered data. -
  • The GrowBuffer helper function is called every time the buffer needs to be enlarged to hold the bitmap data. -
  • The bitmap driver renders multi-page documents into a single large output bitmap file. -
-

This sample has the following limitations:

-
    -
  • The plug-in does not support landscape orientation although the option exists in the GPD. -
  • In 24bpp mode, documents larger than three pages will produce an extremely large bitmap (.bmp) file. Although the output is correct, you might not be able to view it because of memory limitations in the bitmap viewer. -
-

-

OEMPREAN

-

When preanalysis is enabled in the GPD (for more details about preanalysis, see the WDK documentation), Unidrv defines the surface as a banding surface but causes the first playback (that is, the first band) to be of the entire page. Unidrv performs this - definition by setting the GDI clip window to the entire page. Unidrv enables all drawing commands to be hooked but returns before any drawing can be done. On the subsequent passes, Unidrv resets the clip window back to the original band size and bands normally.

-

In order for plugins to also take part in preanalysis, they can enable OEM preanalysis by specifying the "*PreAnalysisOptions: 8" parameter in the GPD. The OEM rendering plug-in must hook both DrvStartBanding and DrvNextBand when this mode is enabled in - the GPD. The OEM rendering plug-in must test the pptl parameter of the OEMStartBanding call to determine whether preanalysis has been enabled on this page. If the pptl parameter is NULL, preanalysis has been enabled, and the OEM rendering plug-in should consider - all drawing calls up to the first call to OEMNextBand to be part of preanalysis. -

-

During these preanalysis phase drawing calls, the plug-in should not draw on the surface. The plug-in should also not call back into unidrv. You should use this phase only for analysis of the objects on the page. For example, certain printers need to handle - black objects that intersect with color objects differently from black objects that appear by themselves. Other printers might need to halftone StretchBlt objects differently from BitBlt objects. -

-

You should be aware that after preanalysis, you might get more calls than you saw in the normal rendering, because primitives that cross band boundaries yield two or more DDI calls after the preanalysis pass. -

-

The sample uses the bPreAnalysis flag in the OEMPDEV structure to denote whether a particular pass is the preanalysis pass or the actual rendering pass. If the bPreAnalysis flag is set, it indicates that the current pass is the preanalysis pass. The sample - implements all of the drawing function hooks in Ddihook.cpp. The sample uses the OEMStartBanding and OEMNextBand functions to respectively set and reset the bPreAnalysis flag. The sample also uses the DBG_CLIPOBJ debug macro function to dump the bounds of - the clipping rectangle available for preanalysis in each of the drawing functions during the preanalysis pass. To view all of the debug output in the debugger, you must set the debug level to VERBOSE. The rest of the sample is identical to the Oemuni sample - that illustrates a basic OEM rendering plug-in.

-

Note that the surface used during preanalysis might differ from the surface passed in during the rendering pass. -

-

PTPCPIPR

-

This sample is an educational example that illustrates the basic functionality that a Unidrv plug-in for the IPrintOemPrintTicketProvider interface should implement. -

-

The primary functionality of the plug-in is to support the PhotoPrintingIntent PrintSchema keyword. The PhotoPrintingIntent keyword is designed to provide a mechanism for photo printers to support enhancements that are specific to photo printing. An application - or the user (through the print UI) can then specify whether a particular print job is a photo-printing job, in which case the device can apply appropriate enhancements. -

-

The intent setting is communicated to the device driver in a PrintTicket. The actual enhancements made are device-specific, and as such, the driver has to map the high-level intent setting into specific output settings, like resolution or bpp. This plug-in - sample demonstrates the conversion.

-

The plug-in implements the ExpandIntentOptions method of the IPrintOemPrintTicketProvider interface. This method is called with an input print-ticket. The plug-in checks if the print-ticket contains a photo-printing intent setting, and if so, removes the - setting, while instead adding to the print-ticket output settings as mentioned above. The code sample uses MSXML6 for all PrintTicket XML handling.

-

UINUIREP

-

This sample shows how a plug-in for a Unidrv-based driver can replace the default UI. It provides new property sheets for the printer property and printing preferences pages.

-

Use this sample as an example of implementing full UI replacement in a Unidrv-based plugin. It also demonstrates the use of the new IPrintCoreHelper interface. -

-

This sample is only provided for educational purposes and should not be used in a production environment. -

-
- -
- - -
- - diff --git a/print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css b/print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css deleted file mode 100644 index 526e88c5..00000000 --- a/print/OEM Printer Customization Plug-in Samples/description/19eccd10-9a4c-4ebc-a240-2680a581332eBrand.css +++ /dev/null @@ -1,295 +0,0 @@ -/*Global*/ -h1 { - font-size: 36px; - font-family: 'Segoe UI Light'; - color: #707070; - font-weight: normal; - margin-bottom: 17px !important; -} - -h2, h3, h4, h5, h6, #searchPage h3 { - font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important; - font-weight:normal; - color: #2A2A2A !important; -} - -a, a:link, a:visited { - color: #0095c4; -} - -body { - color:#707070; -} - -.profile-usercard { - color:#707070 !important; -} - -/*temporary setting to override msdn_windows.css -can remove once conflicting settings are removed from that file*/ - - -.LocalNavigation, .LocalNavigation .TabOn, .LocalNavigation .TabOn:hover, .LocalNavigation .TabOff, .LocalNavigation .TabOff a:hover { - display: block; - background-color:transparent !important; - color: #0095c4; -} - -.LocalNavigation .TabOff a { -color:#707070 ; -} - -/*End Global*/ - -.EyebrowContainer -{ - margin-bottom: 0 !important; -} - -#sideNav -{ - width: 215px !important; -} - #sideNav #contributeSection { - padding: 0 0 67px 0; - } -#searchPage #mainContentContainer -{ - margin-right:0 !important; - margin-left:243px !important; -} - -#searchPage .dirSubHeading h2 -{ - font-size: 14px !important; - font-weight: normal !important; - color: #454545 !important; - line-height: 1.45; -} - -#searchPage #directoryListFooter, #searchPage #Pager { - font-size: 14px; -} - -#searchPage h2, #searchPage h3 -{ - font-size: 1.25em !important; -} - -#sideNav #contributeSection h3, .sidebar #contributeSection h3, #contributeSection h3 -{ - font-size: 1.65em !important; -} -.subMenu > h2 -{ - font-family: 'Segoe UI Light','Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important; - font-weight:normal; - font-size:30px; - margin: 15px 10px 5px 0; - padding-bottom:0px; -} - -.itemRow { -} - .itemRow .itemBody, .itemRow .itemInfo { - padding: 18px 17px 20px 0; - font-size: 14px; - line-height: 1.45em; - } - - .itemRow .itemTitle { - font-weight: normal; - } - - .itemRow .summaryBox{ - color: #454545; - } - - .Samples #MainContent .itemRow .itemTitle a { - font-weight: 600 !important; - line-height: 1.45; - } - #MainContent a.officialMicrosoftLabel - { - color: #ACACAC; - } - - -.tabContents { - border-top-width:0px; -} - -#UploadPage { - margin: 0px 0px 0px 10px; -} - #UploadPage h1 { - padding: 0; - font-size: 22px; - } - #UploadPage h2 { - color:#F39700 !important; - } - - #UploadPage #uploadPageInstruction { - margin-top:10px; - } - - #UploadPage fieldset { - margin-left:0px; - } - - #UploadPage fieldset h2 { - font-weight:normal; - } - - #UploadPage fieldset#uploadsForm{ - margin-top:25px; - } - - #UploadPage fieldset#summary textarea { - margin-left:0px; - } - - #UploadPage .projectTypeChoice > div { - height: 250px; - } - -#sideNav { -} - - #sideNav .section h3 { - background-color: transparent; - - } - - #sideNav .section UL LI { - border-bottom-width: 0px; - } - - #sideNav .section form > div { - border-bottom: none; - color: #707070; - } - #sideNav .section ul li > div.itemCount - { - color: #707070; - } - - #sideNav .contributeAction a { - padding-bottom: 5px; - } - -#searchPage { -} - - #searchPage h2, #searchPage h3 { - text-transform:none; - background-color:transparent; - font-weight:normal; - font-size:1.2em; - } - - #searchPage .browseFilterBar { - background-color:transparent; - border-width:0px; - font-weight:normal; - } - -#requestsPage { - padding-top:15px; -} - - #requestsPage .tabHeaders { - overflow: visible; - } - - #requestsPage #requestsList { - border: none; - } - - #requestsPage h2, #requestsPage h3 { - text-transform:none; - background-color:transparent; - font-weight:normal; - font-size:1.2em; - } - -#extraActions { -} - #extraActions .section - { - margin-bottom: 10px; - } - #extraActions .section a - { - font-weight:normal; - } - - #extraActions #contributeSection div img { - width:0px; - } - - -#projectPage { -} - - #projectPage .projectTitle { - color: #707070; - margin: 5px 0px 15px 0px; - } - - #projectPage h2.projectSummary, #projectPage #projectInfo, #projectPage .tabHeaders { - font-size: 14px !important; - line-height: 1.45em; - color: #454545 !important; - font-weight: normal !important; - } - - #projectPage #projectInfo a { - color: #00749e; - } - - #projectPage #Downloads a, #projectPage #Downloads label { - font-size: 14px; - } - - #projectPage #reportAbuse { - font-size: 1em; - } - - #projectPage #publishBar a, #projectPage #publishBar a:visited { - color: #0095c4; - font-weight: normal; - } - - #projectPage #Collections .bevelButton{ - background-color: #F8F8F8; - color: #0095C4; - border: 1px solid #707070; - } - - #projectPage #DiscussionsTabPane .threadHeader .title { - font-weight:bold !important; - color:Black !important;#F8F8F8; - font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif !important; - } - - #projectPage .sidebar .section .titleBar h3 { - font-weight:normal; - font-size:1.2em; - } - -#LocalNav { -} - - #LocalNav.HeaderTabs { - margin-left:11px; - } - -#searchPage .dirSubHeading h1 -{ - margin-bottom:17px !important; -} - - - diff --git a/print/OEM Printer Customization Plug-in Samples/description/Brand.css b/print/OEM Printer Customization Plug-in Samples/description/Brand.css deleted file mode 100644 index 65dcfb8d..00000000 --- a/print/OEM Printer Customization Plug-in Samples/description/Brand.css +++ /dev/null @@ -1,3615 +0,0 @@ -#BodyBackground -{ - min-width:0px; -} - -#JelloExpander, .IE7 #JelloExpander, .IE8 #JelloExpander, .IE9 #JelloExpander -{ - padding-left:0px; - padding-right:0px; -} - -#JelloSizer -{ - margin: 0 auto; - max-width: 0px; - padding: 0; - width: 100%; -} - -/* Global Styles */ -body -{ - font-size:0.75em; -} - -h1 -{ - font-size: 36px; - font-family: 'Segoe UI', Tahoma, Helvetica, Sans-Serif; - color: #000; - font-weight: normal; - padding-top:4px; - margin-bottom: 17px; - line-height: 1.3; - -} - -h2, h3, h4, h5, h6 -{ - font-family: 'Segoe UI Semibold', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; - color:#2a2a2a; - font-weight:normal; -} - -a, a:link, a:visited { - color: #00749E; -} -a:hover { - color: #0095c4; - text-decoration:none; -} - -/*---------- Masthead -----------*/ - -.NetworkLogo a { - display: none; -} - -/*-------- Start Advertisment --------*/ - -.advertisment { - padding-top:5px; -} - -/*-------- End Advertisment --------*/ - - -/*-------- Start LocalTabs Page --------*/ -#GalleriesNavigation { - float: right; -} - -.LocalNavigation -{ - display:block; - overflow: auto; - width: auto; -} - .LocalNavigation .HeaderTabs { - width: auto; - } - .LocalNavigation .TabOff a { - color:#333; - } - - .LocalNavigation .TabOff a:hover { - background-color:#E0E7EC; - margin-top: 1px; - padding: 4px 6px; - } - - .LocalNavigation #notificationLink span { - color:Red; - font-weight:bold; - } - - -/*-------- End LocalTabs Page --------*/ - -/*-------- Start SubMenu Page --------*/ - -.subMenu -{ - margin: 0 0 10px 0; - color: #FFFFFF; - overflow: hidden; -} - -.subMenu a, .subMenu span -{ - margin: 5px 5px 0 5px; -} - -.subMenu > h2 -{ - float: left; - margin: 7px 15px 0 0; - vertical-align: middle; - color: #666; - padding-bottom: 5px; -} - -.subMenu .advancedSearchLink -{ - float: left; - margin: 9px 0 0 15px; -} - - - -.subMenu .uploadLink -{ - float: right; - margin: 5px 5px 0 0; - padding: 0 0 0 30px; - height: 24px; - background: url('../Common/smalluploadicon.png') no-repeat 10px 0; - color: #0066E1; - cursor: pointer; -} - -.subMenu #searchBoxContainer -{ - float: left; - width: 400px; - padding: 3px 50px; -} - -/*-------- End SubMenu Page --------*/ - -/*-------- Start SearchBox --------*/ - -div.searchbox -{ - overflow:auto; - width:450px; - margin:26px 0 14px 0; -} - -.srchbox -{ - width: 100%; - background-color: #dedfe1; - color: #999; - padding: 0px 2px; - height: 25px; - table-layout: auto; - margin-bottom:5px; -} - - - -.srchbox #searchImageCell input -{ - background: transparent url('searchButton.png') no-repeat 0 0; - width: 20px; - height: 20px; - padding-left: 1px; - margin-top: 3px; -} - - -.srchbox #searchImageCell -{ - text-align: right; - padding: 0px; - vertical-align: middle; -} - -.IE7 .srchbox #searchImageCell -{ - padding:2px 2px 0 0; -} - -.srchbox #searchImageCell input -{ -} - - -table.srchbox -{ - table-layout: fixed; -} - -.srchbox .stxtcell -{ - padding-right: 4px; - width:90%; -} - -.srchbox .stxtcell > input -{ - margin-right: 4px; - height: 26px; - line-height:26px; - width: 100%; - padding: 0px; - padding-left: 4px; - padding-top: 2px; - border: none; - font-style: normal !important; - outline: none; - background-color: transparent; -} - -.IE7 .srchbox .stxtcell > input -{ - height: 20px; -} - -.srchbox .stxtcell > input.stxtinptpassive -{ - color: #AAA; - font-style: normal !important; -} - -/*-------- End SearchBox --------*/ - - -/*-------- Start Search Page --------*/ - - -#searchPage #mainContentContainer -{ - margin: 0 0 0 243px; -} -#searchPage #directoryContent { - border-left: 3px solid #eee; - margin-left: -20px; - padding-left: 20px; -} -#searchPage .browseFilterBar, #dashboardPage .browseFilterBar -{ - padding: 5px 0 6px 0; - -} - - #searchPage .browseFilterBar a, #dashboardPage .browseFilterBar a - { - font-weight:normal; - } - - #searchPage .browseFilterBar .browseSort, #dashboardPage .browseFilterBar .browseSort - { - float:right; - } - - #searchPage .browseBreadcrumb - { - padding-top:3px; - } - - #searchPage .browseFilterBar .browseSort select, #dashboardPage .browseFilterBar .browseSort select - { - height:20px; - } - - #searchPage .browseFilterBar .browseSort img, #dashboardPage .browseFilterBar .browseSort img - { - vertical-align:text-top; - } - -#searchPage h2, #searchPage h3 -{ - font-size: 1.25em; - padding: 2px 0 3px 3px; -} - -#searchPage h2 -{ - display:inline; - clear:none; -} - - #dashboardsearchbox - { - width:420px; - margin:0; - float:left; - } - -/*-------- End Search Page --------*/ - -/*-------- Begin Requests Page --------*/ - -#requestsPage { - color:#666; -} - - #requestsPage h1 { - clear:none; - } - #requestsPage h2, #requestsPage h3 - { - font-size: 1.25em; - } - - #requestsPage h2 - { - display:inline; - clear:none; - } - - #requestsPage h3 - { - padding: 2px 0 3px 3px; - } - - #requestsPage #mainContentContainer - { - margin: 0 0 0 243px; - } - - #requestsPage #mainContentWrapper { - float:left; - width:100%; - } - #requestsPage #mainContent { - position:relative; - } - - #requestsPage #mainContent .subtitle{ - margin-bottom:5px; - } - - #requestsPage #requestsFilterBar { - margin-top: 10px; - overflow: auto; - } - - #requestsPage #requestsFilterBar .requestsCrumb { - float: left; - margin:10px 0 10px 10px; - } - #requestsPage #requestsFilterBar .requestsSort { - float: right; - margin:10px 0 10px 0; - } - - #requestsPage #Pager { - text-align: center; - padding-top: .75em; - padding-bottom: .75em; - } - - #requestsPage #requestsRss { - float: right; - margin: 2px 0 0 3px; - cursor: pointer; - } - - .IE7 #requestsPage #requestsList { - padding-top: 10px; - margin-top:5px; - } - - #requestsPage #requestsList .noResults { - padding: 10px 0; - } - - -/*-------- End Requests Page --------*/ - -/*-------- Begin Request List Item --------*/ -.requestlistitem td -{ - padding: .9em 0 .9em .5em; -} - .requestlistitem .votebox - { - - text-align:center; - } - - .requestlistitem .voteboxcontainer - { - vertical-align:top; - width: 75px; - } - - .requestlistitem #votelabel - { - border-width:1px; - border-bottom-style:solid; - } - - #myRequestsTab #votenumber, - #requestsPage #votenumber - { - background-color: #777; - padding: 6px 10px; - color: #fff; - margin-bottom: 5px; - font-size: 1.6em; - } - - #myRequestsTab .votelink, - #requestsPage .votelink - { - font-weight:bold; - background-color: #eee; - padding: 5px 0; - width: 75px; - float: left; - } - - #myRequestsTab .needvote, - #requestsPage .needvote - { - font-weight:bold; - } - - #myRequestsTab .alreadyvoted, #myRequestsTab .resolved - #requestsPage .alreadyvoted, #requestsPage .resolved - { - font-weight:bold; - color: #666; - } - - .requestlistitem .linkform - { - width:100%; - float:right; - margin-top:15px; - } - - .requestlistitem .requesttitle - { - font-weight:600; - margin-bottom:3px; - } - - .requestlistitem .requester - { - margin-bottom:3px; - } - - .requestlistitem .hidden - { - display:none; - } - - .requestlistitem .requestSummary div - { - margin-bottom:0.25em; - } - - .requestlistitem .requestSummary - { - line-height: 1.45em; - width: 80%; - } - .requestlistitem .requestInfo - { - padding:1.2em 0 0 2.5em; - vertical-align:top; - width:15%; - line-height: 1.45em; - } - - .requestlinks > td - { - padding-bottom: 16px; - } - - .requestlinks div - { - float:right; - } - - .requestlistitem .textbox - { - width:95%; - } - - - -/*-------- End Request List Item --------*/ - - -/*-------- Begin New Request Form --------*/ -#newrequest { - margin-top:5px; - background:#F8F8F8; - border-width:1px; - border-style:solid; - border-color:#E8E8E8; - padding:5px; -} - -#newrequest > div:first-child { - font-weight:bold; -} - -#newrequest .itemheading { - margin-top:5px; -} - -#newrequest textarea { - width:95%; -} - -#newrequest .field-validation-error { - display:block; - color:Red; - font-weight:bold; -} -#newrequest #submit { - margin-top:5px; -} - -/*-------- End New Request Form --------*/ - -/*-------- Request Description Page ------*/ - -.reqDescPage #mainContent { - overflow: auto; -} -.reqDescPage #header { - float: left; - width: 100%; -} - -.reqDescPage { - color: #000 !important; -} - -.reqDescPage #sideNav { - background-color: #fff; -} - -.reqDescPage #header td { - vertical-align: bottom; -} - -.reqDescPage #header #votenumber { - width: 50px; - padding: 6px 12px; - text-align: center; - float: left; -} - -.reqDescPage #header .requestTitle { - margin: 0 0 5px 10px; - width: 85%; -} - -.reqDescPage #header .requestTitle h1 { - margin-bottom: 0px; - font-size: 2em; -} - -.reqDescPage #headerLinks { - -} - -.reqDescPage .votelink -{ - text-align: center; - float: left; -} - -#requestsPage #headerLinks .assignlink -{ - font-weight:bold; - background-color: #eee; - padding: 5px 10px; - float: left; - margin-left: 10px; -} - -.reqDescPage #projectInfo { - clear: both; -} - -.reqDescPage #solutions { - clear: both; - padding-top: 30px; -} - -.reqDescPage .solutionItems { - clear: both; -} - -.reqDescPage .solutionHeader { - border-bottom: 1px solid #ccc; -} - -.reqDescPage .solutionAddContainer { - padding-top: 15px; - float: left; -} - -.reqDescPage #SubmittedProjectLinkUrl { - width: 400px; -} - -.reqDescPage .solutionItem { - margin-top: 25px; - padding: 0 5px 5px 0; - float: left; -} -.reqDescPage .solutionItemDetails { - float: left; - width: 535px; -} - -.reqDescPage .solutionItemLinks { - margin-top: 10px; - clear: both; - float: left; - width: 100%; -} - -.reqDescPage .solutionItemLinks a { - float: left; - margin-right: 10px; - font-weight:bold; - background-color: #eee; - padding: 5px 10px; -} - -.reqDescPage .solutionItem .itemTitle { - font-size: 1.2em; - padding-bottom: 5px; -} - -.reqDescPage .tagsContainer label { - display: none; -} - -.reqDescPage .solutionItem .summaryBox { - padding: .25em 0 .25em 0; - clear: both; - line-height: 1.45; -} - -.reqDescPage .solutionsection { - float: left; - margin-left: 20px; -} -.reqDescPage .completedSolution { - font-size: 1.25em; - padding-top: 4px; -} - -.reqDescPage .requestDescriptionCont, .reqDescPage .requestDicussions { - padding-top: 30px; - clear: both; - overflow: auto; -} - -.reqDescPage .requestDescription { - padding-top: 10px; - line-height: 1.45; -} - -.reqDescPage .requestDicussionsAsk { - padding: 10px 0; -} - -.reqDescPage .watermark { - color:Gray; - } - - -/*-------- Begin Extra Actions Section --------*/ -#extraActions -{ - float: right; - width: 300px; - vertical-align: top; -} - - #extraActions .section - { - padding: 0 0 10px 0; - overflow:auto; - } - - #extraActions .section a - { - font-weight:bold; - } -/*-------- End Extra Actions Section --------*/ - -/*-------- Begin Contribute --------*/ - - -#contributeSection a -{ - font-size:1.1em; -} - -#contributeSection, #sideNav #contributeSection h3, .sidebar #contributeSection h3, #contributeSection h3 -{ - background-color:#fff; - margin: 0 0 9px 0; - padding-left: 0px; -} - -#sideNav #contributeSection h3, .sidebar #contributeSection h3, #contributeSection h3 -{ - font-size:1.65em; - margin-top:42px; -} - -#sideNav #contributeSection, #contributeSection -{ - padding:0 0 41px 0; -} - -#projectPage .sidebar #contributeSection -{ - margin: 10px 0 10px 0; - padding:0 0 5px 0; - -} - -#sideNav #contributeSection > div, .sidebar #contributeSection > div, #contributeSection > div -{ - padding: 0 0 2px 0; - overflow:auto; -} - -#sideNav #contributeSection img, #contributeSection img -{ - float: left; - width: 25px; -} - -#sideNav #contributeSection .contributeAction, .sidebar #contributeSection .contributeAction, #contributeSection .contributeAction -{ - padding:17px 0 0 0; -} - - #contributeSection .contributeAction img - { - background-color:#00749e; - margin-right:9px; - } - - #contributeSection .contributeAction img:hover - { - background-color:#0095C4; - } - - #contributeSection .contributeAction a - { - display:block; - line-height: 1.8; - } - -#uploadLink, #exclamationLink, #myContributionsLink -{ - display:block; - line-height: 1.8; -} - -#myContributionsLink span -{ - color: red; -} - -#feedbackLink -{ - background: url("FeedbackIcon.png") no-repeat; - width: 40px; - height: 40px; -} - -.itemRow .affiliationLink, #editorPicksSection .affiliationLink -{ - background: url("../common/MicrosoftLogo.png") no-repeat; - width: 82px; - height: 18px; -} - - -#contributeSection a+div -{ - -} - -.IE7 #contributeSection a+div -{ - float:left; -} -/*-------- End Contribute --------*/ - - -/*-------- Begin Directory List Footer --------*/ - -#directoryListFooter { - padding:5px; - margin-top:10px; - margin-bottom:10px; - border:1px solid #E6E6E6; - background-color:#F8F8F8; - width:438px; -} - -#directoryListFooter h4 -{ - font-size:1em; -} - -/*-------- End Directory List Footer --------*/ - -/*-------- Begin Editors Picks --------*/ -#editorPicksSection ul -{ - padding-left:0px; - line-height:135%; -} - - #editorPicksSection ul li - { - clear: left; - padding-top: 10px; - list-style:none; - } - #editorPicksSection ul li:first-child { - padding-top: 0; - } - - #editorPicksSection a { - font-weight: normal !important; - } - - #editorPicksSection ul li .thumbnail - { - float: left; - padding: 3px; - max-width: 60px; - } - - #editorPicksSection ul li .thumbnail img { - max-width: 60px; - } -/*-------- End Editors Picks --------*/ - -/*-------- Begin Side Nav Section --------*/ - -#sideNav -{ - width: 215px; - margin-left: 0; - vertical-align: top; - float: left; -} - - #sideNav #sideNavHeader - { - margin-bottom: 10px; - padding-left: 12px; - } - - #sideNav #sideNavHeader a - { - margin-right:3px; - } - - #sideNav .section - { - padding: 0 10px 18px 0px; - } - #sideNav .section h3 - { - - padding: 2px 0 3px 3px; - } - - #sideNav .section ul - { - } - - #sideNav .section ul li - { - padding: 4px 0 2px; - margin-left: 3px; - margin-right: 3px; - } - - - #sideNav .section form > div - { - padding: 4px 0 0 0; - border-bottom: none; - margin: 0 3px 0 3px; - color: #3A3E43; - } - .IE8 #sideNav .section ul li > div.itemText - { - word-wrap: break-word; - width: 225px; - } - #sideNav .section ul li > div.itemCount - { - color: #3A3E43; - } - #sideNav .section a - { - font-weight: normal; - } - - #sideNav .section a:hover - { - text-decoration: underline; - } - -/*-------- End Side Nav Section --------*/ - - - -/*-------- Start Dashboard Page --------*/ - -#dashboardPage { - padding-top:5px; - clear:both; -} -#dashboardPage .contributions .tabContents { - padding: 5px 5px 10px 0; - clear:both; -} - #dashboardPage .contributions .noContributions { - clear:both; - } -#dashboardPage #mainContentWrapper { - float:left; - width:100%; -} - -#dashboardPage #detailsSection { - float:left; - margin-left:-100%; - width:240px; - padding: 0 0 18px 10px; -} - -.IE7 #dashboardPage #detailsSection { - width:auto; - min-width: 300px; - max-width: 300px; -} -.IE7 #dashboardPage #detailsSection .itemBar { - width: 270px; -} - -#dashboardPage #detailsSection h3 { - word-wrap:break-word; -} - -#dashboardPage #mainContent { - margin:0 0 0 250px; - position:relative; -} - -#dashboardPage .dashboardEvenRow -{ - background-color: #ececec; -} -#dashboardPage .dashboardPadding -{ - padding-bottom: 4px; -} -#dashboardPage .dashboardCell -{ - width: 100%; - vertical-align: top; - padding: 1em 0.5em 0.5em 0.5em; - word-wrap: break-word; -} -#dashboardPage .projectManagement -{ - width: 24em; - padding: 0em 1em 0em 1em; - vertical-align: top; - text-align: right; - float: right; -} - -#dashboardPage #subscriptionsLink -{ - position:absolute; - right:5px; -} - -#dashboardPage .itemDelete -{ - vertical-align:top; - padding-top:.8em; - width:30px; -} - -#dashboardPage .itemDeleteText -{ - border-style:solid; - border-width:thin; - border-collapse:collapse; - padding-bottom:2px; - padding-left:4px; - padding-right:4px; - color:Gray -} - -#dashboardPage #myRequestsTab .requestTabHeaders -{ - font-weight:normal; - border-bottom: solid 1px #CCC; - padding-bottom: 10px; - padding-top: 10px; - float: left; - width: 100%; -} - -#dashboardPage #myRequestsTab .requestTabHeaders div:first-child -{ - border: 0; -} - -#dashboardPage #myRequestsTab .requestTabHeaders div -{ - padding: 2px 9px 3px 9px; - font-size: 0.9em; - line-height: 125%; - color:#00749E; - border-left: solid 1px #555; - cursor: pointer; - float: left; - text-align: center; -} - -#dashboardPage #myRequestsTab .requestTabHeaders div.currentRequest -{ - background-color:#fff; - cursor: default; - border-bottom:none; - margin-bottom:-2px; - color:#000; -} - -#dashboardPage #myRequestsTab .requestTabHeaders div.currentRequest a { - color: #000; -} - - -#dashboardPage #myRequestsTab .requestTabHeaders div a -{ - text-decoration:none; -} - -#dashboardPage #myRequestsTab .requestTabContents -{ - clear: both; -} - -#dashboardPage #myRequestsTab .requestTabContents .noResults { - padding-top: 20px; -} - -/*-------- End Dashboard Page --------*/ - -/*-------- Start Upload Page --------*/ - -#UploadPage -{ - margin-left:10px; - max-width:925px; -} - - #UploadPage .watermark { - color:Gray; - } - - #UploadPage .projectTypeChoice { - } - - #UploadPage .projectTypeChoice > div { - padding: 20px 10px 20px 10px; - border: 1px solid darkgrey; - cursor: pointer; - height: 200px; - float: left; - } - - #UploadPage .projectTypeChoice > div + div - { - margin: 0 0 0 5px; - } - - #UploadPage .projectTypeChoice div.current - { - background-color: #E9E9E9; - cursor: default; - } - - #UploadPage .projectTypeChoice div.choice { - font-size: large; - font-weight: bold; - padding: 0 0 10px 0; - } - - #UploadPage .projectTypeChoice div.description { - padding: 0 0 0 17px; - } - - #UploadPage .projectTypeChoice #genericSampleUploadDescription { - padding-top: 5px; - } - - #UploadPage .projectTypeChoice #genericSampleUploadDescription .logos { - overflow: auto; - } - - #UploadPage .projectTypeChoice #genericSampleUploadDescription .vslogo { - background: url(../samples/vslogo.png) no-repeat; - width: 125px; - height: 18px; - } - - #UploadPage .projectTypeChoice #genericSampleUploadDescription .javalogo { - background: url(../samples/javalogo.png) no-repeat; - width: 33px; - height: 60px; - float: left; - } - - #UploadPage .projectTypeChoice #genericSampleUploadDescription .phplogo { - background: url(../samples/phplogo.png) no-repeat; - width: 65px; - height: 35px; - float: left; - margin: 15px 0 0 10px; - } - - #UploadPage .projectTypeChoice #genericSampleUploadDescription .nodejslogo { - background: url(../samples/nodejslogo.png) no-repeat; - width: 90px; - height: 25px; - float: left; - margin: 18px 0 0 10px; - } - - #UploadPage .projectTypeChoice #genericSampleUploadDescription > div+div { - margin-top: 10px; - } - - #UploadPage .projectTypeContents { - clear: left; - padding: 10px 0 0 0; - } - - #UploadPage .projectTypeContents .instruction > div+div { - padding-top: 5px; - } - #UploadPage #libraryContainer { - margin: 5px 0 0 0; - display: none; - } - #UploadPage fieldset - { - margin: 10px 0 30px 5px; - } - - #UploadPage fieldset > * - { - margin-left:10px; - } - - #UploadPage .fieldsetStyleContainer { - margin: 10px 0 0 5px; - } - - #UploadPage fieldset h2, - #UploadPage .fieldsetStyleContainer h2 - { - font-family: 'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif; - font-size: 17px; - font-weight: bold; - color: #3A3E43; - border-bottom: 2px solid #EFEFEF; - width: 100%; - padding-bottom: 3px; - margin-left:0px; - margin-bottom:8px; - } - - .IE7 #UploadPage fieldset h2, - .IE7 #UploadPage .fieldsetStyleContainer h2 - { - margin-left:-10px; - } - - #UploadPage fieldset .field-validation-error - { - clear:left; - display:block; - margin-top:4px; - } - - #UploadPage fieldset .required - { - margin-left: 3px; - } - - #UploadPage fieldset .instruction, - #UploadPage .fieldsetStyleContainer .description, - #UploadPage .fieldsetStyleContainer .instruction - { - color: #3A3E43; - margin:0 0 10px 0; - } - - #UploadPage fieldset .faqLink - { - margin: 0 0 10px 0; - } - - #UploadPage fieldset label - { - display:block; - } - - #UploadPage fieldset input[type=text] - { - width:60%; - } - - #UploadPage fieldset input[type=checkbox] - { - float:left; - clear:left; - margin-right:5px; - } - - #UploadPage fieldset input[type=radio] - { - float:left; - clear:left; - margin-right:5px; - } - - #UploadPage fieldset#richDescription textarea - { - width:70%; - height:600px; - } - - #UploadPage fieldset#summary textarea - { - width:60%; - height:100px; - margin-top: 10px; - margin-left: -30px; - } - - .IE #UploadPage fieldset#summary textarea, .IE9 #UploadPage fieldset#summary textarea - { - margin-left: -30px; - overflow: auto; - } - - .FF #UploadPage fieldset#summary textarea - { - margin-left: -30px; - } - - #UploadPage fieldset#summary #SummaryReadOnly - { - width:60%; - margin-top: 10px; - padding-top: 5px; - color: #909082; - } - - #UploadPage fieldset#summary #SummaryCharCount - { - width:60%; - text-align: right; - } - - #UploadPage fieldset#options label - { - margin-bottom:10px; - } - - #UploadPage fieldset#license label - { - margin-bottom:10px; - } - - #UploadPage input[type="text"].tagInput, #UploadPage input[type="text"].listInput - { - width:40%; - float:left; - } - - #UploadPage .addedTags, #UploadPage .addedProjects - { - margin-bottom:15px; - width: 500px; - - } - #UploadPage .addedTags .tag, #UploadPage .addedProjects .projectTitle - { - position:relative; - overflow:hidden; - } - - #UploadPage .addedTags .tag label, #UploadPage .addedProjects .projectTitle label - { - float:left; - width: 450px; - } - - #UploadPage .addedTags .tag a, #UploadPage .addedProjects .projectTitle a - { - position:absolute; - text-align:right; - right:0px; - } - - .fileManager .fileUploadProgressIndicator - { - width: 500px; - } - - .fileManager .uploadProcessingWarning { - margin-top: 5px; - } - - .fileManager .fileUploadProgressIndicator .throbber - { - font-weight: bold; - background: url('./progressIndicatorWhite.gif') no-repeat 10px 0; - padding: 7px 10px 5px 60px; - height: 25px; - margin-left: -10px; - } - - .fileManager #uploadFrame, .fileManager .uploadFrame - { - width:100%; - } - - .fileManager .addLabel + a - { - margin-left:25px; - } - - .fileManager fieldset label { - display: block; - } - - .fileManager .unlocalizedFiles { - color:#808080; - } - - .fileManager .filesContainer - { - margin-bottom:15px; - width: 500px; - - } - - .fileManager .filesContainer .file - { - position:relative; - overflow:hidden; - } - - .fileManager .filesContainer .file .title { - border-bottom: 1px solid #000000; - padding-bottom: 3px; - margin-top: 10px; - margin-bottom: 10px; - } - - .fileManager .filesContainer .file .title .manageLinks - { - float: right; - } - - .fileManager .filesContainer .file .version { - padding: 0 0 20px 10px; - } - - .fileManager .filesContainer .file .version label { - float: left; - font-weight: bold; - } - - .fileManager .filesContainer .file .version span { - float: left; - margin-left: 5px; - } - - .fileManager .filesContainer .file .language { - clear: left; - padding: 0 0 5px 10px; - } - - .fileManager .filesContainer .file .language label { - font-weight: bold; - } - - .fileManager .filesContainer .file .language label + label { - font-weight: normal; - padding-left: 10px; - } - - .fileManager .filesContainer .file .language div { - padding-left: 20px; - } - - .file .requirements { - clear: left; - padding: 0 0 0 10px; - } - - .file .requirements label { - font-weight: bold; - } - - .file .requirements > div { - padding-left: 20px; - } - - .file .requirements .requirementsContent { - padding-top: 5px; - padding-bottom: 10px; - } - - .file .requirements .requirementsContent label { - font-style: italic; - font-weight: normal; - } - - .file .requirements .requirementsContent > div - { - margin-bottom:4px; - position:relative; - } - - .requirementsContent .requirementsRemove { - float:right; - position:absolute; - right:0px; - } - - .requirements .requirementsAddError { - color:#ff0000; - } - - .requirements .reqBrowseButton { - margin-left : 10px; - } - - #UploadPage fieldset .requirements input[type="text"] { - margin-right: 10px; - width: 70%; - } - - .reqBrowsefade - { - position: absolute; - background-color: #aaaaaa; - } - .reqBrowse - { - background-color: #f4f4f4; - border:1px solid #000000; - -border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - padding:15px; - position: absolute; - display: block; - } - - .reqBrowsebuttons - { - text-align:right; - position:absolute; - right:10px; - bottom:5px; - } - .reqBrowsebuttons > button - { - color: Blue; - border: none; - background: none; - font-weight: bold; - cursor:pointer; - } - - .reqBrowseclose - { - display:none; - } - - .reqBrowseDialog - { - width: 700px; - clear:both; - overflow:hidden; - padding-bottom: 20px; - } - - .reqBrowseDialog > h2 - { - border-bottom: 1px solid #000000; - padding-bottom: 5px; - } - .reqBrowseDialog > p - { - margin: 15px 0 15px 0; - } - - .reqBrowseSearchCont - { - width: 100%; - background: white; - padding: 0px 2px; - -moz-border-radius: 2px; - border-radius: 2px; - border: 1px solid #888; - margin-bottom: 5px; - height: 29px; - } - .reqBrowseSearchCont .rbboxcont - { - width:90%; - float:left; - margin-top: 2px; - } - - .reqBrowseSearchCont input - { - border:none; - outline:none; - border-color: transparent; - } - .reqBrowseSearchBox - { - margin-right: 4px; - height: 20px; - line-height: 20px; - width: 100%; - padding-left: 4px; - padding-top: 2px; - } - - .reqBrowseSearchBoxDefault - { - color: #AAA; - } - .reqBrowseSearchCont .rbbtncont - { - float: right; - margin-top: 4px; - } - .reqBrowseSearchBtn - { - background: transparent url('searchButton.png') no-repeat 0 0; - width: 22px; - height: 22px; - float:left; - cursor:pointer; - } - - .reqBrowseTabs - { - border-bottom: 5px solid #E8E8E8; - margin:3px 0; - overflow:auto; - } - - .reqBrowseTabs .reqBrowseTabsR - { - color:#fff !important; - } - - .reqBrowseTabs .reqBrowseTabsHighlight - { - color:#000 !important; - background-color:#E8E8E8; - } - - .reqBrowseTabs a - { - padding:5px 12px; - color:#fff; - background-color:#888; - font-weight:bold; - float:left; - margin: 0 4px 0px 0; - } - - .reqBrowsePager td - { - text-align:center; - } - .reqBrowseDialog #Pager - { - margin: 5px 0 15px 0; - } - - .reqBrowseContent - { - height:310px; - overflow:auto; - clear:both; - position:relative; - } - - .reqBrowsePager - { - width:700px; - margin:0 auto; - } - - .reqBrowseContentError - { - color:#ff0000; - margin:5px; - } - .reqBrowseContent .requirementItem - { - border-bottom: 2px solid #E8E8E8; - padding: 4px 0 6px 0; - overflow:auto; - } - .reqBrowseContent .section1 - { - float:left; - width:75%; - padding-left:25px; - position:relative; - } - - .reqBrowseContent .section1 input - { - position:absolute; - left:0px; - } - - .reqBrowseContent .title - { - font-weight:bold; - } - .reqBrowseContent .section2 - { - float:right; - } - - - .progressIndicatorfade - { - position: absolute; - background-color: #FFFFFF; - } - .progressIndicator - { - background-color: #f4f4f4; - border: 1px solid #000000; - -border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - padding: 15px; - position: absolute; - display: block; - max-width: 70%; - max-height: 70%; - } - #progressIndicator .progressIndicatorclose - { - display: none; - } - - #progressIndicatorContent - { - font-weight: bold; - padding: 7px 10px 0 10px; - height: 25px; - } - - -/*-------- End Upload Page --------*/ - -/* --- - --- Homepage --- - --- */ -p -{ - margin: 0 0 1px 0; -} -#homePageHeader -{ - float: left; - margin-bottom: 1em; - width: 100%; -} - -.tagline { - font-size: x-small; - position: relative; - top: -11px; -} - -.welcomeInfo -{ - float: left; - width: 700px; -} -.welcomeInfo h2 -{ - font-size: 16px; -} -.welcomeInfo p -{ - margin: 5px 0 0 0; -} - -#siteActions > div -{ - border: 1px solid #BBBBBB; - padding: 15px 5px 0 65px; - height: 55px; - background-repeat: no-repeat; - background-position: 10px 10px; -} -#siteActions a, #siteActions p -{ - margin-top: 5px; -} - -#siteActions .label a -{ - font-size: 1.25em; - font-weight: bold; - margin-bottom: 3px; -} - -#myGalleryBox -{ - background-image: url("MyGalleryIcon.png"); -} - -#findActions -{ - float: right; - padding: 10px; - width: 225px; - height: 50px; - border: 1px solid #BBBBBB; - margin: 0 10px 0 0; -} - -#findBox div:first-child -{ - margin: 0 0 5px 0; - font-weight: bold; -} - -#legalDisclaimer -{ - margin: 0 0 10px; - color: #798072; - font-size: 0.8em; -} - -#siteActions -{ - float: right; - width: 200px; -} -#siteActions > div -{ - margin-bottom: 10px; -} -.homePageProjects -{ - width: 100%; - float: left; -} -.homePageProjects > div -{ - padding-left: 1.5em; -} -.homePageProjects > div:first-child -{ - padding-left: 0; -} - -.homePageProjects .projectList ul -{ - padding: 0; - margin: 0; -} -.homePageProjects li -{ - margin-top: .5em; - padding-bottom: 0.5em; - list-style-type: none; -} -.homePageProjects .itemRow a, .homePageProjects .itemRow a:hover -{ - color: #0054A6; -} - -.projectList > a:first-child -{ - margin-left: 1px; - float: right; -} -.projectList > a, .projectList > a:hover -{ - color: #5BAEDB; -} -.projectListTitle -{ - height: 27px; - font-size: 16px; - font-weight: bold; - line-height: 125%; - background: #E8E8E8; - padding: 5px 5px 5px 25px; -} -.homePageListPager -{ - text-align: right; - margin-bottom: -.5em; -} - -.recentlyAddedProjects -{ - float: left; - width: 32%; -} -.mostPopularProjects -{ - float: right; - width: 32%; -} -.highestRankedProjects -{ - overflow: hidden; -} -* html .highestRankedProjects -{ - float: left; -} -* html .highestRankedProjects > div -{ - width: 100%; -} - -#Pager -{ - text-align:left; -} - -/* Impromptu warning style */ -.ipWarningfade -{ - position: absolute; - background-color: #aaaaaa; -} -div.ipWarning -{ - width: 400px; - position: absolute; - border-radius: 10px; - -moz-border-radius: 10px; - -webkit-border-radius: 10px; - padding: 20px 0 20px 20px; - background-color: #FCE5E6; - border: solid 2px #EE1F25; -} -.ipWarningcontainer -{ - font-weight: bold; -} -.ipWarningclose -{ - display: none; -} -.ipWarningmessage div -{ - position: relative; -} -.ipWarningmessage div div + div -{ - text-align: center; - padding-right: 20px; -} -.ipWarningmessage div div:first-child div -{ - margin-left: 50px; -} -.ipWarningmessage div div:first-child img -{ - position: absolute; - margin: -20px 0 0 0; - top: 35%; -} -.ipWarningbuttons -{ - text-align: center; - margin: 20px 0 0 0; -} -.ipWarning button -{ - padding: 4px 8px 4px 8px; - margin: 2px; - font-weight: bold; - border: solid 1px #A6A3A6; - color: #FFFFFF; - background: #B8BABC; - filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#B8BABC',EndColorStr='#949699'); -} - -#eyebrow -{ - width: 100%; -} -#siteMessage .unsupportedLocale { - margin: 10px 0 0 243px; - border: solid 1px #CCC; - background: #FCFEC5; - padding: 5px; -} - -#Footer -{ - width: 100%; - height: auto; -} - -.clear -{ - clear: both; -} - -#buildVersion -{ - clear: both; - margin-left: auto; - margin-right: auto; - padding-right: 26px; - padding-top: 8px; - text-align: right; -} - -#page -{ - clear: both; - padding-top: 10px; -} - -#page h1 -{ - padding: 10px 0px; -} - -#ownerBar -{ - background: #EFEFEF; - border: 2px solid #7FCBF5; - text-align: left; - color: Black; - margin: 10px 0 20px 0; - padding: 5px; - word-spacing: 0px; - font-size: medium; -} - -#ownerBar a -{ - color: Blue; - padding: 0 5px 0 5px; -} - - - - -/*-------- Start Tab Control --------*/ - -.tabHeaders -{ - font-weight:normal; - border-bottom: solid 1px #CCC; - float: left; - width: 100%; -} - -.tabHeaders div -{ - padding: 7px 19px 8px 19px; - font-size: 0.9em; - line-height: 125%; - color:#00749E; - cursor: pointer; - float: left; - text-align: center; -} - -.tabHeaders div.current -{ - background-color:#fff; - cursor: default; - border: 1px solid #CCC; - border-bottom:none; - margin-bottom:-2px; - color:#000; -} - -.tabHeaders div a -{ - text-decoration:none; -} - -.tabContents -{ - clear: both; -} - -#MainContent .tabHeaders div.current a -{ - color:#000; -} - -.tabContents div.current -{ - display: block; -} -/*-------- End Tab Control --------*/ - -.itemContainer -{ - width: 100%; -} -.itemRow .itemTitle -{ - padding-bottom: 5px; - font-size:1.1em; - font-weight: bold; -} - -.itemRow .itemBody, .itemRow .itemInfo -{ - padding:15px 17px 16px 0; -} -.itemRow .itemDescription -{ - overflow: hidden; - max-height: 80px; -} -.itemRow .itemBody -{ - vertical-align: top; - line-height: 1.4; -} -.itemRow .itemBody a.officialMicrosoftLabel -{ - color: #ACACAC; -} -.itemRow .itemInfo -{ - vertical-align: top; - padding-left: .5em; - line-height: 1.4; - width: 10em; - text-align:right; -} - -.IE7 .itemRow .itemInfo -{ - width:11em; -} - -.itemRow .itemInfo .ratingStars -{ - float: left; -} -.itemRow .itemInfo .ratingCount -{ - padding: 0 0 0 5px; - float: left; -} -.itemRow .ratingInfo -{ - text-align: center; -} - -.itemRow .affiliationLink, #editorPicksSection .affiliationLink -{ - position: relative; - top: 3px; -} - -#editorPicksSection a.officialMicrosoftLabel -{ - color: #ACACAC; -} - -.itemRow .tagsContainer label { - display:none; -} - -.editorPickedItem -{ - background-color:#F8F8F8; -} - -.editorPickedText -{ - font-size:1.25em; - padding-bottom:2px; -} -.editorPickedItem > td -{ - border-top:6px solid #fff; -} - -.dirSubHeading -{ - margin-bottom:15px; -} - -#searchPage .dirSubHeading h2 -{ - line-height:1.4; - font-size:1.1em; -} - -#searchPage .dirSubHeading h2 span -{ - padding-top:5px; - display:block; -} - -#searchPage .dirSubHeading h1, #searchPage .dirSubHeading h2 -{ - clear:none; - padding-left:0px; -} - -.dirSubHeading .dirSubLinks -{ - font-size:1.2em; - padding-top:5px; -} - - -.summaryBox -{ - padding: .25em 0 .25em 0; - clear: both; - line-height:1.45; -} - -/*-------- Start Rating Stars --------*/ - -.RatingStar -{ - width: 11px; - height: 11px; - padding: 0 8px 0 0; - background-position: center; - float: left; -} - -.FilledRatingStar, .HalfRatingStar, .EmptyRatingStar, .FilledRatingStarHover -{ - width: 11px; - height: 11px; - padding: 0px 1px 0px 0px; - margin-top: 2px; -} - -.FilledRatingStar -{ - background: url(../samples/fullStar.png) no-repeat; -} - -.ownerRating .FilledRatingStar -{ - background: url(../samples/fullStar.png) no-repeat; -} - -.FilledRatingStarHover -{ - background: url(../samples/fullStarHover.png) no-repeat; - -} - -.HalfRatingStar -{ - background: url(../samples/halfStar.png) no-repeat; - -} - -.EmptyRatingStar -{ - background: url(../samples/emptyStar.png) no-repeat; - -} - -.EditStarMode .RatingStar -{ - cursor: pointer; -} - - - -/*-------- End Rating Stars --------*/ - -.discussionFormTable -{ - width: 100%; - table-layout: fixed; -} - - -#ReviewsTabPane .seeAllLink, #DiscussionsTabPane .seeAllLink -{ - margin-top: 10px; - text-align: center; -} - -/*-------- Start DiscussionsTab --------*/ - -.threadActions -{ - text-align: right; - margin-top: 10px; - float: right; -} - -#DiscussionsTabPane .reply, #DiscussionsTabPane .toggleDiscussion -{ - cursor: pointer; -} - - -#defaultDicussionText, #newDiscussion -{ - padding-top: 10px; -} -#DiscussionsTabPane .posts -{ - display: block; -} -#DiscussionsTabPane .threadHeader .left -{ - float: left; -} -#DiscussionsTabPane .threadHeader .right -{ - float: right; -} -#DiscussionsTabPane .normal -{ - font-weight: normal; -} - -#DiscussionsTabPane .threadHeader -{ - position: relative; - background-color: #ECECEC; - padding: 4px 10px 4px 10px; -} - -#DiscussionsTabPane .threadHeader .title -{ - color: #000000; - font-weight: bold; - margin-bottom: .7em; -} -#DiscussionsTabPane .threadHeader .label -{ - color: #000000; -} -#DiscussionsTabPane .postMeta -{ - color: #666666; -} -#DiscussionsTabPane .threadHeader .value -{ - font-weight: bold; - color: #000000; -} - -#DiscussionsTabPane .reply -{ - font-weight: normal; - cursor: hand; -} - -#DiscussionsTabPane ul li -{ - list-style-type: none; - list-style-image: none; - padding-bottom: 10px; -} - -#DiscussionsTabPane ul -{ - padding-left: 0px; - margin-left: 0px; - padding-right: 2px; -} - -.IE #reviewList .right -{ - margin-right: -1em; -} - -#newDiscussion -{ - margin: 0 0 15px 0; -} -#newDiscussion #Title -{ - width: 50%; -} -#newDiscussion textarea -{ - width: 99%; - height: 10em; -} - -#DiscussionsTabPane -{ - margin-left: 0px; - padding: 0 1em 1em 1em; -} - - -.postMeta -{ - float: right; -} - -.postReply -{ - cursor: hand; - float: right; - font-weight: bold; -} - -.postSaveReply -{ - display: none; -} - -.postSaveReply textarea -{ - width: 99%; - margin-bottom: 4px; - height: 8em; -} - -.toggleDiscussion -{ - cursor: hand; -} - -.saveReplyErrorMessage -{ - display: none; - margin: 0 0 4px 0; - color: Red; - font-weight: bold; -} - -#discussionListItem .avatar -{ - float: left; - padding: 5px; - vertical-align: middle; -} - -#discussionListItem .discussion -{ - margin-left: 55px; - padding: 0 5px 5px 5px; - vertical-align: top; -} - -.IE7 #discussionListItem .avatar -{ - margin-top: 15px; -} - - -/*-------- End DiscussionsTab --------*/ - - -.flotChart -{ - height: 300px; -} - -#projectMenuBarTop -{ - padding: 10px 0 20px 0; - font-weight: bold; - font-size: 25px; -} -.dayHeader -{ - font-weight: bold; -} - -/*-------- Start StatsPage --------*/ -#statsPage -{ - border: none; - background-color: Transparent; - margin-top: 1em; -} - -#statsPage .rangeBox -{ - padding: 5px; - background-color: #ECECEC; - border: solid 1px #C2C2C2; - float: left; -} -#statsPage .statBox -{ - margin-top: 1em; - margin-bottom: 10px; - overflow: hidden; - display: none; -} -#statsPage .statBox h3 -{ - font-size: 1.1em; - display: inline; -} - -#statsPage #statMessage -{ - margin-top: 1em; - display: none; -} - -#statsPage #statDownloadBox img { - float: left; -} - -#statsPage .statDownloadLink { - padding-left: 5px; - vertical-align: middle; -} - -#pointTooltip -{ - border: solid #000000 1px; - height: 35px; - background-color: #EEEEEE; - position: absolute; - display: none; - text-align: center; - padding: 9px; - border-radius: 4px; - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - z-index: 1000; - white-space: nowrap; -} - -.flotChart -{ - height: 300px; -} - -/*-------- End StatsPage --------*/ - - -/***************************************************************/ -/* TagAutoComplete Styles */ -/***************************************************************/ -.AutoCompletePanel -{ - font-size: 95%; - border: solid .1em #999; - background-color: #f0f0f0; - padding: .15em; -} - -.AutoCompletePanel div.Row -{ - color: #000; - cursor: pointer; - background-color: transparent; - padding: .15em .25em; - text-align: left; -} - -.AutoCompletePanel div.Selected -{ - color: #fff; - background-color: #6D6D6D; -} - - -/*-------- Start Subscription Form --------*/ - -#subscribeForm -{ - background-color: #D3D3D1; - border: 1px solid #000000; - -border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - padding: 15px; - position: absolute; - display: block; -} - -#subscribeForm .subscribeFormbuttons -{ - text-align: right; - margin-top: 10px; -} -#subscribeForm .subscribeFormbuttons > button -{ - color: Blue; - border: none; - background: none; - font-weight: bold; - cursor: pointer; -} - -#subscribeForm .subscribeFormclose -{ - display: none; -} - -#subscribeForm table -{ - margin-bottom: 15px; -} - -#subscribeForm table th -{ - text-align: left; - font-weight: bold; - border-bottom: 1px solid #000000; -} - -#subscribeForm table td -{ - padding: 5px 10px 5px 20px; -} - -#subscribeForm .rowHeading td -{ - font-weight: bold; - border-bottom: 1px solid #FFFFFF; -} - -#subscribeForm table tr td:first-child -{ - padding: 5px 40px 5px 0; -} - - -/*-------- End Subscription Form --------*/ - -/*-------- Start Tag Browser --------*/ - -.tagBrowserfade -{ - position: absolute; - background-color: #aaaaaa; -} -#tagBrowser -{ - background-color: #f4f4f4; - border:1px solid #000000; - -border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - padding:15px; - position: absolute; - display: block; -} - -#tagBrowser .tagBrowserbuttons -{ - text-align:right; - margin-top: 10px; -} -#tagBrowser .tagBrowserbuttons > button -{ - color: Blue; - border: none; - background: none; - font-weight: bold; - cursor:pointer; -} - -#tagBrowser .tagBrowserclose -{ - display:none; -} - -.tagBrowserContainer { - width: 450px; -} - -.tagBrowserContainer h2 { - border-bottom: 1px solid #000000; - padding-bottom: 5px; -} -.tagBrowserContainer > p { - margin: 15px 0 15px 0; -} - -.tagBrowserContainer .tags { - margin: 5px; - height: 225px; - overflow-y: scroll; -} - - -/*-------- End Tag Browser --------*/ - -/*-------- Start List Filter Box --------*/ - -div#filterInputBox -{ - overflow:auto; - min-width:225px; -} - -.filterBox -{ - width: 100%; - background: #FFFFFF; - padding: 0px 2px; - height: 25px; - -moz-border-radius: 2px; - border-radius: 2px; - border: 1px solid #888888; - table-layout: auto; - margin-bottom:5px; -} - - .filterBox #filterImageCell - { - text-align: right; - padding: 0px; - vertical-align: middle; - } - - .IE7 .filterBox #filterImageCell - { - padding:2px 2px 0 0; - } - - .filterBox #filterImg - { - background: transparent url('searchButton.png') no-repeat 0 0; - width: 22px; - height: 22px; - } - -table.filterBox -{ - table-layout: fixed; -} - - .filterBox .stxtcell - { - padding-right: 4px; - width:90%; - } - - .filterBox .stxtcell > input - { - margin-right: 4px; - height: 26px; - line-height:26px; - width: 100%; - padding: 0px; - padding-left: 4px; - padding-top: 2px; - border: none; - } - - .IE7 .filterBox .stxtcell > input - { - height: 20px; - } - - .filterBox .stxtcell > input.stxtinptpassive - { - color: #ACACAC; - } - -/*-------- End List Filter Box --------*/ - -/*-------- Start Notifications --------*/ - -#notificationsSummaryBox -{ - font-weight: bold; - padding: .5em; -} - - -.notificationsByDay, .notifications -{ - /*list-style: none;*/ -} - -.dayHeader -{ - border-bottom: 1px solid silver; - margin-top: 1em; - padding-bottom: .5em; -} - -.notifications -{ - margin-top: .5em; -} - -ul.notifications li -{ - line-height: 1.5em; -} - -ul.notifications li.unread -{ - font-weight: bold; -} - -ul.notifications li ol, ul.notifications li ul -{ - margin-left: 1.5em; -} - -/*-------- End Notifications --------*/ - -/*-------- Start ProjectDetailsPage --------*/ - -#projectPage #projectInfo -{ - position: relative; - margin-top: 5px; - height: 100%; -} -#projectInfo .section -{ - float: left; - margin-bottom: 0px; - height: 100%; -} - - #projectInfo .section .itemBar, #projectInfo .section .itemBarLong - { - clear: both; - padding: 7px 0 7px 0; - overflow:auto; - } - - #projectInfo .section .itemBarLong:first-child - { - padding-top:3px; - } - - .IE7 #projectInfo .section .itemBar, .IE7 #projectInfo .section .itemBarLong - { - padding-top: 5px; - } - - #projectInfo .section .itemBar > label, #projectInfo .section .itemBarLong > label - { - width: 130px; - float: left; - } - - #projectInfo .section .itemBar div#yourRating { - float:left; - } - - #projectInfo .section .itemBar div.RatingStar { - margin:2px 1px 0 0; - } - - #projectInfo .section .itemBar div#RatingCount { - padding: 0 0 0 3px; - } - - #projectInfo .section .itemBar .ratingsWithCountContainer img { - vertical-align:top; - float:left; - padding-right: 4px; - } - - #projectInfo .section .itemBar > span, #projectInfo .section .itemBarLong > span, #projectPage .section .itemBar > div - { - float: left; - } - - #projectInfo .section .itemBar, #projectInfo .section .itemBarLong { - width: 100%; - } - - #projectInfo .section .itemBar > span { - float: none; - } - - #projectInfo .section .itemBar > span .shareThisItem { - white-space: nowrap; - } - - #projectInfo .section .itemBarLong div - { - margin-left: 130px; - padding: 0; - } - - #projectInfo .section .viewonlinecont - { - background-color:#d3d3d3; - padding:5px 10px; - margin-top:10px; - float:left; - font-weight:bold; - } - -#projectInfo #sectionLeft -{ - width: 50%; -} -#projectInfo #sectionRight -{ - width: 50%; -} -.IE7 #projectInfo #sectionRight -{ - width: auto; -} - -#projectPage h2.projectSummary -{ - font-weight:normal; - font-size: 1.1em; - margin-bottom: 11px; - line-height:1.4; - word-wrap: break-word; -} - -.IE7 #projectPage h2.projectSummary -{ - font-family: 'Segoe UI' , 'Lucida Grande' ,Verdana,Arial,Helvetica,sans-serif; -} - -.IE #projectPage .projectTitle, .IE9 #projectPage .projectTitle -{ - width: 100%; -} - -#projectPage #reportAbuse -{ - float: left; - font-size: x-small; -} - -#projectPage .hiddenSidebar { - display: none; -} - -#projectPage .fullProjectBody { - margin-left:-275px; -} - -.IE8 #projectPage #userCard { - float: left; - height: auto; -} - -#projectPage #userCard .avatar img { - max-width: 100px; - max-height: 100px; -} - -#projectDetails -{ - overflow:hidden; -} - -#projectBody -{ - width: 100%; - overflow:hidden; -} - - #projectDetails > div:first-child - { - margin: 5px 0 0 260px; - } - - #projectBody > div:first-child - { - margin: 20px 0 0 260px; - } - - .IE7 #projectContent .tabHeaders - { - overflow:hidden; - margin-bottom:-20px; - } - -#projectPage .sidebar -{ - float: left; - width: 215px; - margin-right: -250px; -} - - #projectPage .sidebar .section - { - margin: 20px 0 10px 0; - } - - #projectPage .sidebar .section .titleBar h3 - { - padding: 0 0 2px 0; - } - - #projectPage .sidebar .section .itemBarRight - { - min-height: 21px; - position: relative; - padding-top: 5px; - } - - #projectPage .sidebar .section .titleBar - { - margin-bottom: 5px; - } - - #projectPage .sidebar .section .authorItem - { - padding: 0 0 5px 10px; - } - - #projectPage .sidebar .section .authorItem a - { - display:block; - float:left; - max-width:170px; - } - - #projectPage .sidebar .section .authorItem > div - { - float:right; - } - - #projectPage .sidebar #advertisement - { - margin-top: 20px; - } - - #projectPage .sidebar #advertisement .label - { - text-align: center; - } - - #projectPage .sidebar #moreFromAuthor - { - width:225px; - margin: 20px 0 10px 0; - float:left; - } - - #projectPage .sidebar #moreFromAuthor .bottomBar { - padding: 5px 0px 5px 25px; - text-align: right; - } - -#projectPage #Collections { - min-height:22px; - min-width:169px; -} - -#projectPage #Collections .bevelButton { - background-color: #8CC63F; -} - -#projectPage .bevelButton -{ - font-weight: bold; - border-radius: 3px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - color: white; - padding: 2px 10px 3px; - text-align: center; -} - -#projectPage #DiscussionsTabPane .bevelButton -{ - font-weight: normal; - color: black; - padding: 1px 10px 1px; -} - -#projectPage #Downloads { - padding: 0 0 8px 0; - float: left; -} - #projectPage #Downloads > div:first-child { - float: left; - margin: 15px 0 0 0; - height:35px; - line-height:1.6; - width: 130px; - } - #projectPage #Downloads label - { - font-size:1.25em; - } - #projectPage #Downloads input - { - min-width: 100px; - padding: 3px 10px 3px 10px; - margin: 3px 10px 0 10px; - font-weight: bold; - float: left; - } - - #projectPage #Downloads .button - { - background-color:#007494; - color:#fff; - padding:5px 15px; - margin: 15px 15px 0 0; - float:left; - } - - #projectPage #Downloads .button:hover - { - background-color:#0095c4; - text-decoration:none; - } - -#projectPage #projectBody .attachments { - margin: 0 0 15px 0; -} - - #projectPage #projectBody .attachments label { - float: left; - } - - #projectPage #projectBody .attachments .files a, #projectPage #projectBody .attachments .files span { - float: left; - padding: 0 5px 0 5px; - } - -#publishBar -{ - border: 1px solid #707070; - background-color: #F8F8F8; - margin-top: 10px; -} - -.linehighlight { - background-color: #fff000; -} - -#sourceItem { - height: 610px; -} - #sourceItem > div:first-child { - padding: 20px 5px 0 15px; - font-weight: bold; - } - #sourceItem > div+div { - height: 560px; - padding: 10px; - overflow: auto; - } - #sourceItem .copyCode { - font-weight: normal; - margin: 0 15px 0 0; - float: right; - } - -.sourceList { - height: 600px; - padding: 5px; - border-top: 1px solid #CCC; - margin-top: -1px; -} - - .sourceList .sourceListTabHeader - { - margin:20px 10px; - } - .sourceList .sourceListTabs - { - margin-bottom:20px; - border-bottom: 1px solid #CCC; - float:left; - width:100%; - } - .sourceList .sourceListTabs .languageTab { - padding:5px 10px 5px 10px; - font-weight: bold; - float: left; - margin: 0 3px 0px 0; - color:#00749E; - } - .sourceList .sourceListTabs .languageTab:hover - { - color: #0095C4; - } - - .sourceList .sourceListTabs .selectedLanguage { - background-color: #fff; - color: #000; - border: 1px solid #ccc; - border-bottom:none; - margin-bottom:-2px; - } - - .sourceList .sourceListTabs .unselectedLanguage { - cursor: pointer; - } - - .sourceList .endTabs { - clear: both; - } - - .sourceList .sourceListContent { - padding-top: 5px; - } - - -.sbfc, -.sbfe -{ - white-space: nowrap; - text-indent: 20px; - cursor: pointer; - padding: .2em 0em .2em 0em; - background-repeat: no-repeat; - background-position: left center; - font-weight: bold; - text-decoration: none !important; -} - -.sbfc -{ - background-image: url(../samples/node_closed.gif); -} - -.sbfe -{ - white-space: nowrap; - background-image: url(../samples/node_opened.gif); -} - -.ndbf -{ - white-space: nowrap; - text-indent:20px; -} - -.sbf -{ - white-space: nowrap; - background: url(../samples/bullet.gif) no-repeat 4px -1px; - cursor: pointer; - text-indent: 20px; - white-space: nowrap; - padding: .1em 0em .1em 0em; -} - -.sbsf, -.sbf:hover -{ - color: #000; - text-decoration: none !important; - -} - -.sbsf -{ - color: #000 !important; - background-color: rgb(232, 232, 232); -} - -.sbf:hover -{ - color: #ce8b10; -} - -/*-------- Translate --------*/ -.translatePage { - width: 900px; -} -.translatePage .fileManager { - margin-bottom:20px; -} -.translatePage .fileManager h4 { - margin-top:10px; -} -.translatePage #formContainer { - width: 100%; -} -.translatePage .formLabel { - width: 300px; - padding: 5px; -} - .translatePage .textInput { - width: 425px; -} -.translatePage TEXTAREA.richText { - height: 600px; - width: 620px; -} -.translatePage TEXTAREA.unadornedEditor { - height: 600px; -} -.translatePage .formWideLabel, .translatePage .richText { - padding: 5px; -} -.translatePage .formWideLabel, .translatePage .unadornedEditor { - width: 750px; - padding: 5px; -} -.translatePage #languageSelection { - margin: 15px; - display: inline-block; -} - -.translateTab, .translateTabSelected { - font-weight: bold; - float: left; - text-align: center; - margin: 10px; - padding: 7px; - background: #E8E8E8; - white-space: nowrap; - cursor: pointer; -} - -.translateTabSelected -{ - color: White; - background: Gray; -} - -.translateTabSelected .translateLabel, .translateTab .translateLabel -{ - white-space: nowrap; - float: left; - padding: 0 5px 0 5px; -} - -.translateTab #deleteLanguage, .translateTab #moreLanguages -{ - padding-left: 10px; -} - -.translateLabel #deleteLanguage { - color: #FFFFFF; -} -/*-------- End Translate --------*/ -/*-------- Begin Eula --------*/ - - -#eulaPagefade -{ - position: absolute; - background-color: #FFFFFF; -} - -#eulaPage -{ - background-color: #f4f4f4; - border: 1px solid #000000; - -border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - padding: 15px; - display: block; - max-width: 70%; -} - -#eulaPage .eulaPageclose -{ - text-align: right; -} - -#eulaPage .eulaPagemessage -{ - overflow: auto; - max-height: 350px; -} - - #eulaPage .eulaPagemessage h1 - { - margin: 0 0 5px 0; - } - -#eulaPage .eulaPagebuttons -{ - text-align: right; - margin-top: 10px; -} -#eulaPage .eulaPagebuttons > button -{ - color: Blue; - border: none; - background: none; - font-weight: bold; - cursor: pointer; -} - - - #eulaPage #eula #documentText - { - line-height: normal; - } - -/*-------- End DocumentView --------*/ -/*-------- Begin FAQ --------*/ - -#FAQPage #TableOfContents h2 -{ - padding: 5px; - border-bottom: 2px solid #EFEFEF; - margin: 0 0 10px 0; - max-width: 70%; -} - -#FAQPage .FAQSection -{ - padding: 10px 0px; - width: 70%; -} - - #FAQPage .FAQSection h2 - { - padding: 5px; - border-bottom: 2px solid #EFEFEF; - } - - #FAQPage .FAQSection h3 - { - padding: 5px; - } - - #FAQPage .FAQSection ul, #FAQPage .FAQSection ol - { - margin: 0; - } - - #FAQPage .FAQSection #description > div - { - overflow: auto; - padding-left: 10px; - } - - #FAQPage .FAQSection #description img - { - float: left; - } - - #FAQPage .FAQSection #description div > div - { - padding-top: 10px; - float: left; - } - - #FAQPage .FAQSection > div > div - { - padding: 0 15px; - } - - #FAQPage #Reputation th, #FAQPage #Reputation td - { - padding-left: 20px; - } - -/*-------- End FAQ --------*/ -/*-------- Begin DocumentView --------*/ - -#documentView #documentText -{ - line-height: normal; -} - -/*-------- End DocumentView --------*/ - -.Opera wbr:after -{ - content: "\00200B"; -} - - -.IE9 wbr:after -{ - content: "\00200B"; -} - -.IE8 wbr { - width: 0px; - display: inline-block; - overflow: hidden; -} - -/*-------- Begin FileManager --------*/ - -.uploadControlNoError - { - height:30px - } -.uploadControlWithError - { - height:80px; - } -/*-------- End FileManager --------*/ - -/*-------- Begin User Card --------*/ -#userCard .titleBar { - border-bottom: solid 5px #E8E8E8; - margin: 10px 0 5px 0; -} - #userCard .titleBar h3 - { - font-size: 1.0em; - font-weight: bold; - line-height: 125%; - padding: 0 0 2px 0; - } - -#userCard .userFeed { - float: right; -} - -#userCard .bio { - max-width:300px; - white-space: normal; -} - -#userCard .avatar -{ - padding: 5px 5px 10px 5px; - margin: 0 0 3px 0; - text-align: center; -} - -#userCard .itemBar { - padding: 5px; -} - - #userCard .itemBar label - { - float: left; - } - - #userCard .itemBar label+span { - display: block; - margin-left: 100px; - } - -#userCard .collapsableSidebar { - clear:both; - width:100%; - margin-top: 5px; -} - -/* Profile Overrides */ -#userCard -{ - padding: 0 0 10px 0 -} - -#userCard .profile-usercard -{ - width:225px; -} - -#userCard .profile-usercard, #userCard .profile-inline, #userCard .profile-inline-header -{ - border:0px; - background-color:#fff; -} - -#userCard .profile-userimage-large -{ - margin-bottom:10px; - border:none; - width:auto; - height:auto; -} - -#userCard .profile-inline .profile-inline-header-details -{ - width:100%; - display:block; - clear:both; - margin-left:0px; -} - - - -/*-------- End User Card --------*/ -/*-------- Begin Description Progress Meter --------*/ - -#descriptionProgressMeter { - float: right; - border-top: 1px solid #DADADA; - border-left: 1px solid #DADADA; - width: 210px; - padding-left: 7px; -} - - #descriptionProgressMeter h4 { - font-weight: bold; - } - - #descriptionProgressMeter #progressGraphic { - border: 1px solid #888888; - width: 205px; - margin: 10px 0; - background-color: #E9E9E9; - padding: 1px 0 0 1px; - } - - #descriptionProgressMeter #progressGraphic div { - background-image: url("../common/progress_meter.png"); - padding-left: 5px; - } - - #descriptionProgressMeter #progressText { - font-weight: bold; - margin: 5px 0; - - } - - #descriptionProgressMeter #goodDescriptionText p+p { - padding: 5px 0; - } - - #descriptionProgressMeter #goodDescriptionText > div { - margin-top: 5px; - width: 150px; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - overflow: auto; - } - - #descriptionProgressMeter #goodDescriptionText div img { - float: left; - } - - #descriptionProgressMeter #goodDescriptionText div div { - margin: 7px 0 5px 10px; - } - -/*-------- End Description Progress Indicator --------*/ - -/*-------- Start Sample Pack Tab View --------*/ -.SamplePackTab #headerBar -{ - padding: 15px 5px 20px 5px; - font-weight: bold -} - .SamplePackTab #headerBar .reportCount - { - padding-top: 2px; - } - .SamplePackTab #headerBar .samplePackSort - { - float: right; - color: #666; - } -/*-------- End Sample Pack Tab View --------*/ \ No newline at end of file diff --git a/print/OEM Printer Customization Plug-in Samples/description/Combined.css b/print/OEM Printer Customization Plug-in Samples/description/Combined.css deleted file mode 100644 index e69de29b..00000000 diff --git a/print/OEM Printer Customization Plug-in Samples/description/Galleries.css b/print/OEM Printer Customization Plug-in Samples/description/Galleries.css deleted file mode 100644 index 52bf19b1..00000000 --- a/print/OEM Printer Customization Plug-in Samples/description/Galleries.css +++ /dev/null @@ -1,417 +0,0 @@ -/* *************************************************** -Galleries.css - Common Structure - -This is where we define common layout for structures that are truly close to common across the different -Galleries sites. To make sure this works we need to follow certain conventions. - -1. Define each logical structure in its own section with its own comment block that gives the section -a Name, Description and defines the root element if one exists (i.e #someElement). Also, mark the closing block. - -2. Indent styles in a section to represent if it is a child of a previous element. -i.e. #someDiv{ - } - #someDiv ul { - } - -3. Do not include brand specific information here like colors and fonts unless they are *really* common. - -4. If there is an element that you know will be overridden in each brand stylesheet still include it here with an empty definition. -This will aid in knowing what section to override and what selectors to use. - -i.e. #someSction a { - } - -5. When you add a new section also update the Table of Contents below so that we have a quick overview of the sections - - *****************************************************/ - -/**************************************************** -Table of Contents - - Global - global classes - - FileAttachmentDisplay - The list of attached files under the editor - Eyebrow - The breadcrumb control at the top of the master page - Pager - The common paging control, used for browsing pages of search results - Profile User Card - Elements in the profile usercard control - SideNav - The navigation side bar that contains the search filters - - -*****************************************************/ - -/******************************** -Name: Global -Root: none -Description: truly global classes -********************************/ -body { - text-align: left; - direction: ltr; -} - -img.rss { - background: url(../../../GlobalResources/Images/Rss.png) no-repeat; - background-position: 0px 0px; - height: 17px; - width: 17px; -} -/* End Global Section */ - -/******************************** -Name: FileAttachmentDisplay -Root: #fileAttachmentDisplay -Description: The list of attached files under the editor -********************************/ -#fileAttachmentDisplay { -} - #fileAttachmentDisplay .attachment { - margin-right: 10px; - float: left; - } - - #fileAttachmentDisplay .attachment .displayAttachment { - padding: 0px 0 13px 0; - float: left; - } - - #fileAttachmentDisplay .attachment .removeAttachment { - background-image: url('/Content/Common/delete.png'); - display: block; - width: 16px; - height: 16px; - float: left; - } -/* End FileAttachmentDisplay Section */ - - -/******************************** -Name: Eyebrow -Root: .EyebrowContainer -Description: The breadcrumb control at the top of the master page -********************************/ -.EyebrowContainer { -} - .EyebrowContainer div.EyebrowElement{ - display:inline; - } - - .EyebrowContainer .EyebrowElement{ - font-weight:normal - } - .EyebrowContainer .EyebrowLeafLink{ - color:#000; - } -/* End Eyebrow Section */ - -/******************************** -Name: Pager -Root: #Pager -Description: The common paging control, used for browsing pages of search results -********************************/ -#Pager { -} - #Pager div{ - display:inline; - } -/* End Pager Section */ - -/******************************** - -Name: Profile User Card -Root: #dashboardPage #userCard -Description: Elements in the profile usercard control - -********************************/ - #dashboardPage #userCard .profile-usercard-inline { - margin: 5px 0 10px 0; - } - - /* #dashboardPage #userCard .profile-usercard { - width: 288px; - } -/* End Profile User Card Section */ - -/******************************** - -Name: Discussion -Root: #DiscussionsTabPane -Description: Defines the layout of the dicussion - - -********************************/ -#DiscussionsTabPane { -} - - #DiscussionsTabPane .itemHidden - { - background: lightgrey; - } - - #discussionListItem { - } - - .discussion .postActions - { - float: right; - } - - #discussionListItem .postItem - { - white-space: pre-wrap; - word-wrap: break-word; - font-size:1em; - } - -/* End Discussion Section */ - - -/******************************** - -Name: SearchDefaultLocale -Root: .searchDefaultLocale -Description: Defines the layout of the include english result checkbox on the Browse Page - - -********************************/ -.searchDefaultLocale -{ - float: right; - margin: 20px 0 0 5px; -} - .searchDefaultLocale input - { - vertical-align:top; - } - .searchDefaultLocale span - { - margin-left: -3px; - } -/*-------- End SearchDefaultLocale --------*/ - - -/******************************** - -Name: SideNav -Root: #sideNav -Description: Defines the layout of the naviation elements on the side of the Browse Page - These represent the different filters like Code Language, Category and Tag - - -********************************/ - -#sideNav { - width: 250px; - vertical-align:top; -} - #sideNav h3 { - } - - #sideNav .section { - padding: 0 0 10px 0; - position: relative; - } - - #sideNav .section a { - } - - #sideNav .section a:hover { - } - - #sideNav .section > div { - padding:5px 5px 5px 0; - line-height:150%; - } - - #sideNav .section ul { - list-style-type:none; - padding:0px; - margin:0px; - } - - #sideNav .section ul li { - position: relative; - padding: 5px 5px 5px 0; - } - - #sideNav .section ul li .selectedFilter { - float: left; - padding-right: 5px; - } - - #sideNav .section div.itemCount { - float: right; - } - - #sideNav .section form input[ type = "checkbox"] { - margin: 0px 4px 0px 0px; - vertical-align: middle; - } -/* End SideNav Section */ - -/*----------- Contribution Logos *******/ -.contributionLogo { - float: left; - position: relative; - margin-right: 6px; -} - -.logo_visualstudio { - background: transparent url('../common/logos/visualstudio.png') no-repeat; - width: 23px; - height: 12px; - margin-top: 3px; -} -.logo_allinonecode { - background: transparent url('../common/logos/1code.png') no-repeat; - width: 14px; - height: 16px; -} -.logo_exchange { - background: transparent url('../common/logos/exchange.png') no-repeat; - width: 14px; - height: 16px; -} -.logo_ie { - background: transparent url('../common/logos/ie.png') no-repeat; - width: 16px; - height: 16px; -} -.logo_office { - background: transparent url('../common/logos/office.png') no-repeat; - width: 17px; - height: 16px; -} -.logo_windows { - background: transparent url('../common/logos/windows.png') no-repeat; - width: 17px; - height: 16px; - } -.logo_azure { - background: transparent url('../common/logos/windowsazuredark.png') no-repeat; - width: 16px; - height: 16px; -} - -.logo_windowsphone { - background: transparent url('../common/logos/windowsphone.png') no-repeat; - width: 16px; - height: 16px; - } - - .contributionLogoTip { - position: absolute; - display: none; - border: solid 1px #CCC; - color: #333; - background-color: #F0F0F0; - font-size: 11px; - font-family: "Segoe UI",Sans-Serif; - box-shadow: 3px 3px 5px #888; - -moz-box-shadow: 3px 3px 5px #888; - z-index: 1003; - padding: 5px; - min-width: 250px; - } - -/*----------- End Contribution Logos *******/ - -.clear -{ - clear: both; -} - -.customcontributionLogoTip { - position: absolute; - display: none; - border: solid 1px #CCC; - background-color: white; - color: #333; - font-size: 11px; - font-family: "Segoe UI",Sans-Serif; - box-shadow: 3px 3px 5px #888; - -moz-box-shadow: 3px 3px 5px #888; - z-index: 1004; - padding: 5px; - min-width: 250px; -} - -.customcontributionTittle { - font-size: 14px; - margin-left: 90px; -} - -.customcontributionDiscription { - font-size: 13px; - margin: 10px 5px; - text-align: justify; -} - -.customcontribution { - float: left; - position: relative; - margin-right: 6px; -} - -.customcontributionLink { - margin-left: 5px; -} - -.customcontributionlogo { - float: left; - padding: 0 10px; - margin: 0; - width: 70px; - height: 70px; - background-repeat: no-repeat; -} - - -.logo_azure_large { - background-image: url('../common/logos/windowsazure_large.png'); -} -.logo_visualstudio_large { - background-image: url('../common/logos/visualstudio_large.png'); -} -.logo_exchange_large { - background-image: url('../common/logos/exchange_large.png'); -} -.logo_ie_large { - background-image: url('../common/logos/ie_large.png'); -} -.logo_office_large { - background-image: url('../common/logos/office_large.png'); -} -.logo_windows_large { - background-image: url('../common/logos/windows_large.png'); -} -.logo_windowsphone_large { - background-image: url('../common/logos/windowsphone_large.png'); -} - -/* Custome Header */ -.dirSubHeading .windowssdk .container -{ - background: #00BCF2 url('wpappsbackground.png') no-repeat; - color: #575757; - padding: 20px 10px 50px 225px; -} - -.dirSubHeading .windowssdk .container h1, .dirSubHeading .windowssdk .container h2 { - color: #575757 !important; -} - -.dirSubHeading .windowssdk .container p { - margin: 28px 0 0 0 !important; -} - -.dirSubHeading .windowssdk .container a { - background-color: #575757; - color: #FFFFFF !important; - cursor: pointer; - font-size: 16px; - font-family: 'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif; - padding: 11px; -} - - - diff --git a/print/OEM Printer Customization Plug-in Samples/description/Layout.css b/print/OEM Printer Customization Plug-in Samples/description/Layout.css deleted file mode 100644 index 625f7776..00000000 --- a/print/OEM Printer Customization Plug-in Samples/description/Layout.css +++ /dev/null @@ -1,147 +0,0 @@ -#container { - min-height: 768px; -} - -#leftSubHeaderContainer -{ - margin-top:20px; -} - -#title h1 -{ - font-size:25px; -} - -#subtitle h2 -{ - font-size:15px; -} - -#subtitle -{ - margin-left:10px; -} - - -#formContainer -{ - margin-left:10px; - margin-top:30px; -} - -.formLabel -{ - float:left; - width: 250px; -} - -.formRow -{ - clear:both; - padding: 10px 0 10px 10px; -} - - -.formRecaptchaRow -{ - clear:both; - float:left; - margin-top:20px; - margin-left:10px; - margin-bottom:20px; -} - -.formSubmitRow -{ - clear:both; - margin-top:20px; - margin-left:300px; - margin-bottom:20px; -} - -.formControl { - width:300px; - float:left; -} -.formControl .textInput -{ - width:300px; -} - -.formControl textarea -{ - width:425px; - height:100px; -} - -.formControl .tag -{ - width:425px; -} - -.formControl .richText -{ - margin-top:10px; - width:500px; - height:440px; -} - -.formWideLabel -{ - width:500px; -} - -.formBigLabel -{ - margin-top:20px; - font-size:20px; -} - -.formControlBelow -{ - clear:both; - margin-top:10px; - width:500px; -} - -.required -{ - color: Red; -} -.helpText -{ - color: #9D9D9D; - font-style: italic; -} - -#agreementSummary -{ - clear:both; - margin-top:10px; - width:800px; -} - -.field-validation-error, .validation-summary-errors -{ - color: #FF0000; - font-weight: bold; -} - -.tinyMCETemplate { - position: relative; - left: 400px; - width: 300px; - max-height: 300px; - overflow: auto; -} - -.IE6 .tinyMCETemplate { - left: 25px; -} - -.ownerBar { - padding: 5px; -} -.ownerBar .ownerBarOptions { - float: right; -} diff --git a/print/OEM Printer Customization Plug-in Samples/description/dc96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css b/print/OEM Printer Customization Plug-in Samples/description/dc96e5d0-205a-4f07-963c-0adecf31d9c1Combined.css deleted file mode 100644 index e69de29b..00000000 diff --git a/print/OEM Printer Customization Plug-in Samples/description/iframedescription.css b/print/OEM Printer Customization Plug-in Samples/description/iframedescription.css deleted file mode 100644 index 9abc9cdb..00000000 --- a/print/OEM Printer Customization Plug-in Samples/description/iframedescription.css +++ /dev/null @@ -1,179 +0,0 @@ -body { - color: #000000; - font-family: 'Segoe UI',Verdana,Arial; - font-size: 0.813em; - font-style: normal; - word-wrap: break-word; -} - -/*BEGIN HEADERS*/ -.h1, h1 { - color: #3A3E43; - font-family: 'Segoe UI',Verdana,Arial; - font-size: 1.4em; - font-weight: bold; - margin: 0; -} - -.h2, h2 { - color: #3A3E43; - font-family: 'Segoe UI',Verdana,Arial; - font-size: 1.2em; - font-weight: bold; -} -.h3, h3 { - color: #3A3E43; - font-family: 'Segoe UI',Verdana,Arial; - font-size: 1.077em; - font-weight: bold; -} -.h4, h4 { - color: #3A3E43; - font-family: 'Segoe UI',Verdana,Arial; - font-size: 1em; - font-weight: bold; -} -h4.subHeading { - margin-bottom: 7px; - margin-top: 13px; -} -/*END HEADERS*/ - -/*BEGIN LINKS*/ -a:link { - color: #00749E; - text-decoration: none; -} -a:hover { - text-decoration: underline; -} -a:visited { - color: #960BB4; - text-decoration: none; -} -a:focus { - outline: 1px dotted #000000; -} - -a.libraryLink:link { - text-decoration:none; - border-bottom:1px dotted; -} - -/*END LINKS*/ - -/*BEGIN IMAGES*/ -img { - border: 0 none; -} -/*END IMAGES*/ - -/*BEGIN TABLE*/ -.title table { - color: #000000; - font-family: 'Segoe UI',Verdana,Arial; - font-size: 1.077em; - font-style: normal; -} -table { - border-collapse: collapse; -} - -table, table th, table td { - border:1px solid #BBBBBB; -} -/*END TABLE*/ - -/*BEGIN LIST*/ -ul { - list-style-type: disc; - margin-left:40px; - padding-left: 0; -} -ul li { - padding-bottom: 10px; -} -ol { - margin-left:40px; - padding-left: 0; -} -ol li { - padding-bottom: 10px; -} -/*END LIST*/ - -.scriptcode { - position: relative; - padding: 8px 8px 8px 8px; - background: #FFFFFF; - font-size: 12px; - line-height: 125%; - font-weight:normal; -} -.scriptcode pre -{ - white-space: pre-wrap !important; /* css-3 */ - word-wrap: break-word !important; /* Internet Explorer 5.5+ */ - margin:0 0 10px 0 !important; - padding: 10px; - border-top: solid 2px #D0D2D2; - border-bottom: solid 2px #D0D2D2; - border-left: solid 1px #D0D2D2; - border-right: solid 1px #D0D2D2; -} - -.scriptcode .title { - color:#E66A38; - font-size: 12px; - font-weight:bold; - margin: 0; - min-height: 23px; -} -.scriptcode .title > span:first-child { - border-left: solid 1px #D0D2D2; -} -.scriptcode .title > span { - padding: 4px 8px 4px 8px; - display: inline-block; - border-top: 1px solid #D0D2D2; - border-right: 1px solid #D0D2D2; - border-collapse: collapse; - text-align: center; - background: white; -} -.scriptcode .title > span.otherTab { - color: #1364C4; - background: #EFF5FF; - cursor: pointer; -} - -.scriptcode .hidden { - display: none !important; - visibility: hidden !important; -} - -.scriptcode .copyCode { - padding: 8px 2px 0 2px !important; - margin-right: 15px; - position: absolute !important; - right: 0 !important; - top: 17px; - display:block !important; - background: #FFFFFF; -} -.scriptcode .pluginLinkHolder { - display: none; -} -.scriptcode .pluginEditHolderLink { - display: none; -} - -.Opera wbr -{ - display: inline-block; -} - -.IE9 wbr:after -{ -content: "\00200B"; -} diff --git a/print/OEM Printer Customization Plug-in Samples/description/offline.js b/print/OEM Printer Customization Plug-in Samples/description/offline.js deleted file mode 100644 index f5d07c8a..00000000 --- a/print/OEM Printer Customization Plug-in Samples/description/offline.js +++ /dev/null @@ -1,52 +0,0 @@ -var Galleries = Galleries || { }; - -(function() { - - function findElem(parent, tagName, className) { - var elemToSearch = (parent) ? parent : document.body; - var tagMatch = elemToSearch.getElementsByTagName(tagName); - var evaluator = function(elem) { - return (className) ? (elem.className.indexOf(className) > -1) : true; - }; - - return findArrayElem(tagMatch, evaluator); - } - - function findArrayElem(array, evaluator) { - var newArray = new Array(); - for (var count = 0; count < array.length; count++) { - if (evaluator(array[count])) { - newArray.push(array[count]); - } - } - return newArray; - } - - function iterateElem(elems, delegate) { - for(var count = 0; count < elems.length; count++) { - delegate(count, elems[count]); - } - } - - function isHidden(elem) { - return (elem.offsetHeight === 0 && elem.offsetWidth === 0) || elem.style && elem.style.display === "none"; - } - - function onWindowLoad(callback) { - attachEventHandler(null, 'load', callback); - } - - function attachEventHandler(elem, event, callback) { - var elemToAttach = (elem) ? elem : window; - if (document.addEventListener) { - elemToAttach.addEventListener(event, callback, false); - } else if ( document.attachEvent ) { - elemToAttach.attachEvent('on' + event, callback); - } - } - - Galleries.findElem = findElem; - Galleries.iterateElem = iterateElem; - Galleries.attachEventHandler = attachEventHandler; - Galleries.onWindowLoad = onWindowLoad; -})(); \ No newline at end of file -- cgit v1.3.1 From c55397f675ffbb3b3fe11dcfa2d5686e36bc7f05 Mon Sep 17 00:00:00 2001 From: Mike Fenelon Date: Thu, 24 Aug 2017 16:00:36 -0700 Subject: Fixup INF files with ARM64 tags --- .../C++/bitmap.inf | 8 +++++++- .../C++/oemdll.inf | 19 ++++++++++++++++++- .../C++/oemprean.inf | 8 +++++++- .../C++/uisamples.inf | 10 +++++++++- .../C++/winxp.inf | 11 ++++++++++- .../README.md | 6 ++++-- 6 files changed, 55 insertions(+), 7 deletions(-) diff --git a/print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf index 247fb069..e189a41d 100644 --- a/print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf +++ b/print/OEM Printer Customization Plug-in Samples/C++/bitmap.inf @@ -20,7 +20,7 @@ DriverVer=6/07/2001,1.0.0.1 ; that we will display in the Dialog box ; [Manufacturer] -"Microsoft"=Microsoft, NTx86, NTamd64, NTia64 +"Microsoft"=Microsoft, NTx86, NTamd64, NTia64, NTarm64 ; ; Model sections. @@ -42,6 +42,9 @@ DriverVer=6/07/2001,1.0.0.1 [Microsoft.NTia64] "Bitmap Driver" = BITMAP +[Microsoft.NTarm64] +"Bitmap Driver" = BITMAP + ; ; Installer Sections ; @@ -99,6 +102,9 @@ bitmap.dll = 100,bitmap\amd64 [SourceDisksFiles.ia64] bitmap.dll = 100,bitmap\ia64 +[SourceDisksFiles.arm64] +bitmap.dll = 100,bitmap\arm64 + [SourceDisksFiles] BITMAP.GPD = 100 BITMAP.INI = 100 diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf b/print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf index 28bf2207..0acf810b 100644 --- a/print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemdll.inf @@ -21,7 +21,7 @@ DriverVer=6/07/2001,1.0.0.1 ; that we will display in the Dialog box ; [Manufacturer] -"Microsoft"=Microsoft, NTamd64, NTia64 +"Microsoft"=Microsoft, NTamd64, NTia64, NTarm64 ; ; Model sections. @@ -55,6 +55,14 @@ DriverVer=6/07/2001,1.0.0.1 "OEM UI Customization Sample (PS)" = INSTALL_OEMUI.PS "OEM UI Customization Sample (Unidrv)" = INSTALL_OEMUI.UNI +[Microsoft.NTarm64] +"PostScript WaterMark Sample" = INSTALL_WATERMARK.PS +"Unidrv WaterMark Sample" = INSTALL_WATERMARK.UNI +"OEM PostScript Customization Sample" = INSTALL_OEMPS +"OEM Unidrv Customization Sample" = INSTALL_OEMUNI +"OEM UI Customization Sample (PS)" = INSTALL_OEMUI.PS +"OEM UI Customization Sample (Unidrv)" = INSTALL_OEMUI.UNI + ; ; Installer Sections ; @@ -191,6 +199,15 @@ wmarkuni.dll = 100,WaterMarkUni\ia64 wmarkuniui.dll = 100,WaterMarkUni\ia64 wmarkui.dll = 100,WaterMark\ia64 +[SourceDisksFiles.arm64] +oemps.dll = 100,OEMPS\arm64 +oemui.dll = 100,OEMUI\arm64 +oemuni.dll = 100,OEMUNI\arm64 +wmarkps.dll = 100,WaterMark\arm64 +wmarkuni.dll = 100,WaterMarkUni\arm64 +wmarkuniui.dll = 100,WaterMarkUni\arm64 +wmarkui.dll = 100,WaterMark\arm64 + [SourceDisksFiles] OEM.PPD = 100 OEM.GPD = 100 diff --git a/print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf index a7c90e24..f3c014e5 100644 --- a/print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf +++ b/print/OEM Printer Customization Plug-in Samples/C++/oemprean.inf @@ -20,7 +20,7 @@ DriverVer=6/07/2001,1.0.0.1 ; that we will display in the Dialog box ; [Manufacturer] -"Microsoft"=Microsoft, NTx86, NTamd64, NTia64 +"Microsoft"=Microsoft, NTx86, NTamd64, NTia64, NTarm64 ; ; Model sections. @@ -42,6 +42,9 @@ DriverVer=6/07/2001,1.0.0.1 [Microsoft.NTia64] "OEM Pre-Analysis sample" = OEM_PREAN +[Microsoft.NTarm64] +"OEM Pre-Analysis sample" = OEM_PREAN + ; ; Installer Sections ; @@ -98,6 +101,9 @@ oemprean.dll = 100,oemprean\amd64 [SourceDisksFiles.ia64] oemprean.dll = 100,oemprean\ia64 +[SourceDisksFiles.arm64] +oemprean.dll = 100,oemprean\arm64 + [SourceDisksFiles] OEMPREAN.GPD = 100 OEMPREAN.INI = 100 diff --git a/print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf b/print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf index 189db3ce..280386e1 100644 --- a/print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf +++ b/print/OEM Printer Customization Plug-in Samples/C++/uisamples.inf @@ -21,7 +21,7 @@ DriverVer=6/07/2001,1.0.0.1 ; that we will display in the Dialog box ; [Manufacturer] -"Microsoft"=Microsoft, NTamd64, NTia64 +"Microsoft"=Microsoft, NTamd64, NTia64, NTarm64 ; ; Model sections. @@ -43,6 +43,10 @@ DriverVer=6/07/2001,1.0.0.1 "OEM Custom UI Plugin" = SYNCSET.UNI "OEM Custom Help" = CUSTHELP.UNI +[Microsoft.NTarm64] +"OEM Custom UI Plugin" = SYNCSET.UNI +"OEM Custom Help" = CUSTHELP.UNI + ; ; Installer Sections ; @@ -107,6 +111,10 @@ SYNCSET.DLL = 100,SyncSet\amd64 CUSTHLP.DLL = 100,CustHlp\ia64 SYNCSET.DLL = 100,SyncSet\ia64 +[SourceDisksFiles.arm64] +CUSTHLP.DLL = 100,CustHlp\arm64 +SYNCSET.DLL = 100,SyncSet\arm64 + [SourceDisksFiles] SYNCSET.GPD = 100 custhlp.gpd = 100 diff --git a/print/OEM Printer Customization Plug-in Samples/C++/winxp.inf b/print/OEM Printer Customization Plug-in Samples/C++/winxp.inf index 43fe3e21..9ca95169 100644 --- a/print/OEM Printer Customization Plug-in Samples/C++/winxp.inf +++ b/print/OEM Printer Customization Plug-in Samples/C++/winxp.inf @@ -20,7 +20,7 @@ DriverVer=6/07/2001,1.0.0.1 ; that we will display in the Dialog box ; [Manufacturer] -"Microsoft"=Microsoft, NTamd64, NTia64 +"Microsoft"=Microsoft, NTamd64, NTia64, NTarm64 ; ; Model sections. @@ -45,6 +45,11 @@ DriverVer=6/07/2001,1.0.0.1 "Themed OEM UI (PScript5)" = THEMEUI.PS "PS Standard UI Replacement" = PSUIREP.PS +[Microsoft.NTarm64] +"Themed OEM UI (Unidrv)" = THEMEUI.UNI +"Themed OEM UI (PScript5)" = THEMEUI.PS +"PS Standard UI Replacement" = PSUIREP.PS + ; ; Installer Sections ; @@ -117,6 +122,10 @@ PSUIREP.DLL = 100,PSUIRep\amd64 THEMEUISmpl.DLL = 100,ThemeUI\ia64 PSUIREP.DLL = 100,PSUIRep\ia64 +[SourceDisksFiles.arm64] +THEMEUISmpl.DLL = 100,ThemeUI\arm64 +PSUIREP.DLL = 100,PSUIRep\arm64 + [SourceDisksFiles] OEM.PPD = 100 OEM.GPD = 100 diff --git a/print/OEM Printer Customization Plug-in Samples/README.md b/print/OEM Printer Customization Plug-in Samples/README.md index b8e0c108..17609b92 100644 --- a/print/OEM Printer Customization Plug-in Samples/README.md +++ b/print/OEM Printer Customization Plug-in Samples/README.md @@ -39,16 +39,18 @@ a. In the **Solution Explorer**, right click **Driver Files** b. Select **Add**, then click **Existing Item** c. Navigate to the location to which you downloaded the sample, and select all the files in the install directory, or the equivalent set of non-binary files such as INFs, INIs, GPD, PPD files, etc. d. Click **Add** + 3. Configure these files to be added into the driver package a. In the **Solution Explorer**, right click the Package project and select **Properties** b. In the left pane, click **Configuration Properties** > **Driver Install** > **Package Files**. c. In the right pane, use the ellipsis button (...) to browse to the set of files that needs to be added to the driver package. All the data files that you added in **Step 2-c**, except the INF file, should be added. **Note** This configuration is per-architecture, so this configuration must be repeated for each architecture that will be built. -d. Click **OK** +d. Click **OK** + 4. Open the INF file and edit it to match the built output a. Open the INF file b. In the Version section, add a reference to a catalog file that matches the .INF name like this: CatalogFile=XpsDrvSmpl.cat -c. In the SourceDisksFiles section, change the location of the DLL files you are building, to =1. This indicates that there is no architecture specific directory in this driver. If you ship multiple architectures simultaneously, you will need to collate the driver INF manually. +c. In the SourceDisksFiles section, change the location of the DLL files you are building, to =1. This indicates that there is no architecture specific directory in this driver. If you ship multiple architectures simultaneously, you will need to collate the driver INF manually. At this point, Visual Studio 2017 will be able to build a driver package and output the files to disk. In order to configure driver signing and deployment, see [Developing, Testing, and Deploying Drivers](https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/). For more information about how to build a driver solution using Microsoft Visual Studio, see [Building a Driver](https://docs.microsoft.com/en-us/windows-hardware/drivers/develop/building-a-driver). -- cgit v1.3.1 From 0ee60f8f25486045aed0bf4b47a483b000c9cf98 Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Thu, 24 Aug 2017 20:04:35 -0700 Subject: VSTS 12737998 --- README.md | 4 ++++ audio/sysvad/README.md | 9 +++++++++ avstream/avscamera/README.md | 9 +++++++++ avstream/avshws/README.md | 9 +++++++++ avstream/avssamp/README.md | 9 +++++++++ avstream/samplemft0/README.md | 9 +++++++++ biometrics/README.md | 10 ++++++++++ bluetooth/bthecho/README.md | 9 +++++++++ bluetooth/serialhcibus/README.md | 9 +++++++++ filesys/cdfs/README.md | 10 ++++++++++ filesys/fastfat/README.md | 11 +++++++++++ filesys/miniFilter/MetadataManager/README.md | 10 ++++++++++ filesys/miniFilter/NameChanger/README.md | 10 ++++++++++ filesys/miniFilter/avscan/README.md | 10 ++++++++++ filesys/miniFilter/cancelSafe/README.md | 10 ++++++++++ filesys/miniFilter/cdo/README.md | 10 ++++++++++ filesys/miniFilter/change/README.md | 10 ++++++++++ filesys/miniFilter/ctx/README.md | 10 ++++++++++ filesys/miniFilter/delete/README.md | 9 +++++++++ filesys/miniFilter/minispy/README.md | 10 ++++++++++ filesys/miniFilter/nullFilter/README.md | 9 +++++++++ filesys/miniFilter/passThrough/README.md | 10 ++++++++++ filesys/miniFilter/scanner/README.md | 10 ++++++++++ filesys/miniFilter/simrep/README.md | 10 ++++++++++ filesys/miniFilter/swapBuffers/README.md | 10 ++++++++++ general/DCHU/README.md | 10 ++++++++++ general/PLX9x5x/README.md | 10 ++++++++++ general/SystemDma/wdm/README.md | 10 ++++++++++ general/cancel/README.md | 10 ++++++++++ general/echo/kmdf/README.md | 10 ++++++++++ general/echo/umdf/README.md | 10 ++++++++++ general/echo/umdf2/README.md | 9 +++++++++ general/echo/umdfSocketEcho/README.md | 10 ++++++++++ general/event/README.md | 10 ++++++++++ general/filehistory/README.md | 10 ++++++++++ general/installwdf/README.md | 10 ++++++++++ general/ioctl/kmdf/README.md | 10 ++++++++++ general/ioctl/wdm/README.md | 10 ++++++++++ general/obcallback/README.md | 10 ++++++++++ general/pcidrv/README.md | 10 ++++++++++ general/perfcounters/kcs/README.md | 10 ++++++++++ general/registry/regfltr/README.md | 10 ++++++++++ general/toaster/toastDrv/README.md | 10 ++++++++++ general/toaster/toastpkg/README.md | 14 ++++++++++++-- general/toaster/umdf2/README.md | 10 ++++++++++ general/tracing/SystemTraceControl/README.md | 10 ++++++++++ general/tracing/evntdrv/README.md | 10 ++++++++++ general/tracing/tracedriver/README.md | 10 ++++++++++ general/umdfSkeleton/README.md | 10 ++++++++++ gpio/samples/README.md | 10 ++++++++++ hid/firefly/README.md | 10 ++++++++++ hid/hclient/README.md | 10 ++++++++++ hid/hidusbfx2/README.md | 11 +++++++++++ hid/vhidmini2/README.md | 11 ++++++++++- input/hiddigi/SynapticsTouch/README.md | 19 ++++++++++--------- input/kbfiltr/README.md | 10 ++++++++++ input/layout/README.md | 10 ++++++++++ input/moufiltr/README.md | 10 ++++++++++ 58 files changed, 568 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 190349c2..67fc57bd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ + + # Driver samples for Windows 10 These are the official Microsoft Windows Driver Kit (WDK) team driver code samples for Windows 10. They provide a foundation for Universal Windows driver support of all hardware form factors, from phones to desktop PCs. Use these samples with Visual Studio 2015 and Windows Driver Kit (WDK) 10. diff --git a/audio/sysvad/README.md b/audio/sysvad/README.md index 9dfc0193..8a5c7709 100644 --- a/audio/sysvad/README.md +++ b/audio/sysvad/README.md @@ -1,3 +1,12 @@ + + SysVAD Virtual Audio Device Driver Sample ======================================== diff --git a/avstream/avscamera/README.md b/avstream/avscamera/README.md index e6f79be6..ef956c88 100644 --- a/avstream/avscamera/README.md +++ b/avstream/avscamera/README.md @@ -1,3 +1,12 @@ + + AvsCamera: AVStream Camera Sample Driver ======================================== The AvsCamera sample provides a pin-centric AVStream capture driver for a simulated front and back camera. The driver performs simulated captures at 320x240 or 640x480 in RGB24, RGB32, YUY2 and NV12 formats at various frame rates. The purpose of the sample is to demonstrate how to write a fully functional AVStream camera driver. diff --git a/avstream/avshws/README.md b/avstream/avshws/README.md index 240f9b6c..19019304 100644 --- a/avstream/avshws/README.md +++ b/avstream/avshws/README.md @@ -1,3 +1,12 @@ + + AVStream simulated hardware sample driver (Avshws) ================================================== diff --git a/avstream/avssamp/README.md b/avstream/avssamp/README.md index 6188c5b3..979dda3c 100644 --- a/avstream/avssamp/README.md +++ b/avstream/avssamp/README.md @@ -1,3 +1,12 @@ + + AVStream filter-centric simulated capture sample driver (Avssamp) ================================================================= diff --git a/avstream/samplemft0/README.md b/avstream/samplemft0/README.md index 7f6e50f6..42f23db4 100644 --- a/avstream/samplemft0/README.md +++ b/avstream/samplemft0/README.md @@ -1,3 +1,12 @@ + + Driver MFT Sample ================= diff --git a/biometrics/README.md b/biometrics/README.md index 0a366501..102a94b8 100644 --- a/biometrics/README.md +++ b/biometrics/README.md @@ -1,3 +1,13 @@ + + + Windows Biometric Driver Samples (UMDF Version 1) ================================================= diff --git a/bluetooth/bthecho/README.md b/bluetooth/bthecho/README.md index 6c1a7a2f..be465a7e 100644 --- a/bluetooth/bthecho/README.md +++ b/bluetooth/bthecho/README.md @@ -1,3 +1,12 @@ + + Bluetooth Echo L2CAP Profile Driver =================================== diff --git a/bluetooth/serialhcibus/README.md b/bluetooth/serialhcibus/README.md index 45f56512..9fc965b6 100644 --- a/bluetooth/serialhcibus/README.md +++ b/bluetooth/serialhcibus/README.md @@ -1,3 +1,12 @@ + + Bluetooth Serial HCI Bus Driver =============================== diff --git a/filesys/cdfs/README.md b/filesys/cdfs/README.md index 601b22bf..cbe8e4c4 100644 --- a/filesys/cdfs/README.md +++ b/filesys/cdfs/README.md @@ -1,3 +1,13 @@ + + + CDFS File System Driver ======================= diff --git a/filesys/fastfat/README.md b/filesys/fastfat/README.md index c5ef6b75..801e3f73 100644 --- a/filesys/fastfat/README.md +++ b/filesys/fastfat/README.md @@ -1,3 +1,14 @@ + + + + fastfat File System Driver ========================== diff --git a/filesys/miniFilter/MetadataManager/README.md b/filesys/miniFilter/MetadataManager/README.md index 6df7bd91..2c56f719 100644 --- a/filesys/miniFilter/MetadataManager/README.md +++ b/filesys/miniFilter/MetadataManager/README.md @@ -1,3 +1,13 @@ + + + Metadata Manager File System Minifilter Driver ============================================== diff --git a/filesys/miniFilter/NameChanger/README.md b/filesys/miniFilter/NameChanger/README.md index 9a2e9929..71b857ef 100644 --- a/filesys/miniFilter/NameChanger/README.md +++ b/filesys/miniFilter/NameChanger/README.md @@ -1,3 +1,13 @@ + + + NameChanger File System Minifilter Driver ========================================= diff --git a/filesys/miniFilter/avscan/README.md b/filesys/miniFilter/avscan/README.md index 31954fec..d1159670 100644 --- a/filesys/miniFilter/avscan/README.md +++ b/filesys/miniFilter/avscan/README.md @@ -1,3 +1,13 @@ + + + AvScan File System Minifilter Driver ==================================== diff --git a/filesys/miniFilter/cancelSafe/README.md b/filesys/miniFilter/cancelSafe/README.md index c8cacf28..3e4c7b06 100644 --- a/filesys/miniFilter/cancelSafe/README.md +++ b/filesys/miniFilter/cancelSafe/README.md @@ -1,3 +1,13 @@ + + + CancelSafe File System Minifilter Driver ======================================== diff --git a/filesys/miniFilter/cdo/README.md b/filesys/miniFilter/cdo/README.md index 4f37890f..4a0fb6d9 100644 --- a/filesys/miniFilter/cdo/README.md +++ b/filesys/miniFilter/cdo/README.md @@ -1,3 +1,13 @@ + + + CDO File System Minifilter Driver ================================= diff --git a/filesys/miniFilter/change/README.md b/filesys/miniFilter/change/README.md index 6d541083..3e4af1db 100644 --- a/filesys/miniFilter/change/README.md +++ b/filesys/miniFilter/change/README.md @@ -1,3 +1,13 @@ + + + Change File System Minifilter Driver ==================================== diff --git a/filesys/miniFilter/ctx/README.md b/filesys/miniFilter/ctx/README.md index 7609985a..326c9221 100644 --- a/filesys/miniFilter/ctx/README.md +++ b/filesys/miniFilter/ctx/README.md @@ -1,3 +1,13 @@ + + + Ctx File System Minifilter Driver ================================= diff --git a/filesys/miniFilter/delete/README.md b/filesys/miniFilter/delete/README.md index ad60db1a..b56eded0 100644 --- a/filesys/miniFilter/delete/README.md +++ b/filesys/miniFilter/delete/README.md @@ -1,3 +1,12 @@ + + Delete File System Minifilter Driver ==================================== diff --git a/filesys/miniFilter/minispy/README.md b/filesys/miniFilter/minispy/README.md index ca3749d3..075675b7 100644 --- a/filesys/miniFilter/minispy/README.md +++ b/filesys/miniFilter/minispy/README.md @@ -1,3 +1,13 @@ + + + Minispy File System Minifilter Driver ===================================== diff --git a/filesys/miniFilter/nullFilter/README.md b/filesys/miniFilter/nullFilter/README.md index 06d825eb..e0c2ff2e 100644 --- a/filesys/miniFilter/nullFilter/README.md +++ b/filesys/miniFilter/nullFilter/README.md @@ -1,3 +1,12 @@ + + NullFilter File System Minifilter Driver ======================================== diff --git a/filesys/miniFilter/passThrough/README.md b/filesys/miniFilter/passThrough/README.md index 91230df5..7400c146 100644 --- a/filesys/miniFilter/passThrough/README.md +++ b/filesys/miniFilter/passThrough/README.md @@ -1,3 +1,13 @@ + + + PassThrough File System Minifilter Driver ========================================= diff --git a/filesys/miniFilter/scanner/README.md b/filesys/miniFilter/scanner/README.md index 46009e9a..eb9d2bcd 100644 --- a/filesys/miniFilter/scanner/README.md +++ b/filesys/miniFilter/scanner/README.md @@ -1,3 +1,13 @@ + + + Scanner File System Minifilter Driver ===================================== diff --git a/filesys/miniFilter/simrep/README.md b/filesys/miniFilter/simrep/README.md index fcf31965..df02b1f5 100644 --- a/filesys/miniFilter/simrep/README.md +++ b/filesys/miniFilter/simrep/README.md @@ -1,3 +1,13 @@ + + + SimRep File System Minifilter Driver ==================================== diff --git a/filesys/miniFilter/swapBuffers/README.md b/filesys/miniFilter/swapBuffers/README.md index e57b38a5..f2c48181 100644 --- a/filesys/miniFilter/swapBuffers/README.md +++ b/filesys/miniFilter/swapBuffers/README.md @@ -1,3 +1,13 @@ + + + SwapBuffer File System Minifilter Driver ======================================== diff --git a/general/DCHU/README.md b/general/DCHU/README.md index df571af6..7311db0c 100644 --- a/general/DCHU/README.md +++ b/general/DCHU/README.md @@ -1,3 +1,13 @@ + + + # Driver package installation toolkit for universal drivers This sample illustrates the DCHU principles of universal driver design. The sample uses the [OSR FX2 learning kit](http://store.osr.com/product/osr-usb-fx2-learning-kit-v2/). For a detailed code walkthrough, see [Universal Driver Scenarios](https://docs.microsoft.com/windows-hardware/drivers/develop/universal-driver-scenarios). diff --git a/general/PLX9x5x/README.md b/general/PLX9x5x/README.md index a706b7d0..e665839b 100644 --- a/general/PLX9x5x/README.md +++ b/general/PLX9x5x/README.md @@ -1,3 +1,13 @@ + + + PLX9x5x PCI Driver ================== diff --git a/general/SystemDma/wdm/README.md b/general/SystemDma/wdm/README.md index a077fe8d..ad7d9dbc 100644 --- a/general/SystemDma/wdm/README.md +++ b/general/SystemDma/wdm/README.md @@ -1,3 +1,13 @@ + + + System DMA ========== diff --git a/general/cancel/README.md b/general/cancel/README.md index 2a1be648..491ef673 100644 --- a/general/cancel/README.md +++ b/general/cancel/README.md @@ -1,3 +1,13 @@ + + + Cancel-Safe IRP Queue Sample ============================ diff --git a/general/echo/kmdf/README.md b/general/echo/kmdf/README.md index 3b89850c..2ed4518a 100644 --- a/general/echo/kmdf/README.md +++ b/general/echo/kmdf/README.md @@ -1,3 +1,13 @@ + + + KMDF Echo Sample ================ diff --git a/general/echo/umdf/README.md b/general/echo/umdf/README.md index e2123cd3..af4818d4 100644 --- a/general/echo/umdf/README.md +++ b/general/echo/umdf/README.md @@ -1,3 +1,13 @@ + + + Echo Sample (UMDF Version 1) ============================ diff --git a/general/echo/umdf2/README.md b/general/echo/umdf2/README.md index ba3ffa36..a9ec9e76 100644 --- a/general/echo/umdf2/README.md +++ b/general/echo/umdf2/README.md @@ -1,3 +1,12 @@ + + Echo Sample (UMDF Version 2) ============================ diff --git a/general/echo/umdfSocketEcho/README.md b/general/echo/umdfSocketEcho/README.md index 06819a47..26cd5a7e 100644 --- a/general/echo/umdfSocketEcho/README.md +++ b/general/echo/umdfSocketEcho/README.md @@ -1,3 +1,13 @@ + + + UMDF SocketEcho Sample (UMDF Version 1) ======================================= diff --git a/general/event/README.md b/general/event/README.md index c091af5a..68da1666 100644 --- a/general/event/README.md +++ b/general/event/README.md @@ -1,3 +1,13 @@ + + + Hardware Event Sample ===================== diff --git a/general/filehistory/README.md b/general/filehistory/README.md index 3e29b08e..7ed723d8 100644 --- a/general/filehistory/README.md +++ b/general/filehistory/README.md @@ -1,3 +1,13 @@ + + + File History Sample ================== diff --git a/general/installwdf/README.md b/general/installwdf/README.md index 429957d5..df9e8445 100644 --- a/general/installwdf/README.md +++ b/general/installwdf/README.md @@ -1,3 +1,13 @@ + + + WDF Installation Package ======================== diff --git a/general/ioctl/kmdf/README.md b/general/ioctl/kmdf/README.md index c9a10365..9c3d80d4 100644 --- a/general/ioctl/kmdf/README.md +++ b/general/ioctl/kmdf/README.md @@ -1,3 +1,13 @@ + + + Non-PnP Driver Sample ==================== diff --git a/general/ioctl/wdm/README.md b/general/ioctl/wdm/README.md index fcbf71f2..e9e2e57d 100644 --- a/general/ioctl/wdm/README.md +++ b/general/ioctl/wdm/README.md @@ -1,3 +1,13 @@ + + + IOCTL ===== diff --git a/general/obcallback/README.md b/general/obcallback/README.md index ca4069a2..37326565 100644 --- a/general/obcallback/README.md +++ b/general/obcallback/README.md @@ -1,3 +1,13 @@ + + + ObCallback Callback Registration Driver ======================================= diff --git a/general/pcidrv/README.md b/general/pcidrv/README.md index 04bf35b5..2fa15558 100644 --- a/general/pcidrv/README.md +++ b/general/pcidrv/README.md @@ -1,3 +1,13 @@ + + + PCIDRV - WDF Driver for PCI Device ================================== diff --git a/general/perfcounters/kcs/README.md b/general/perfcounters/kcs/README.md index 1cbd3ac0..2e7553e5 100644 --- a/general/perfcounters/kcs/README.md +++ b/general/perfcounters/kcs/README.md @@ -1,3 +1,13 @@ + + + Kernel Counter Sample (Kcs) =========================== diff --git a/general/registry/regfltr/README.md b/general/registry/regfltr/README.md index 9e5a0740..40fe7011 100644 --- a/general/registry/regfltr/README.md +++ b/general/registry/regfltr/README.md @@ -1,3 +1,13 @@ + + + RegFltr Sample Driver ===================== diff --git a/general/toaster/toastDrv/README.md b/general/toaster/toastDrv/README.md index 326d40a9..4a29ff7d 100644 --- a/general/toaster/toastDrv/README.md +++ b/general/toaster/toastDrv/README.md @@ -1,3 +1,13 @@ + + + Toaster Sample Driver ===================== The Toaster collection is an iterative series of samples that demonstrate fundamental aspects of Windows driver development for both Kernel-Mode Driver Framework (KMDF) and User-Mode Driver Framework (UMDF) version 1. diff --git a/general/toaster/toastpkg/README.md b/general/toaster/toastpkg/README.md index 326d40a9..a4763177 100644 --- a/general/toaster/toastpkg/README.md +++ b/general/toaster/toastpkg/README.md @@ -1,5 +1,15 @@ -Toaster Sample Driver -===================== + + + +Toaster Package Sample Driver +============================= The Toaster collection is an iterative series of samples that demonstrate fundamental aspects of Windows driver development for both Kernel-Mode Driver Framework (KMDF) and User-Mode Driver Framework (UMDF) version 1. All the samples work with a hypothetical toaster bus, over which toaster devices can be connected to a PC. diff --git a/general/toaster/umdf2/README.md b/general/toaster/umdf2/README.md index 9dcdd158..75cf882b 100644 --- a/general/toaster/umdf2/README.md +++ b/general/toaster/umdf2/README.md @@ -1,3 +1,13 @@ + + + Toaster Sample (UMDF Version 2) =============================== The Toaster (UMDF version 2) sample is an iterative series of samples that demonstrate fundamental aspects of Windows driver development. diff --git a/general/tracing/SystemTraceControl/README.md b/general/tracing/SystemTraceControl/README.md index eb044ddb..b45ae788 100644 --- a/general/tracing/SystemTraceControl/README.md +++ b/general/tracing/SystemTraceControl/README.md @@ -1,3 +1,13 @@ + + + SystemTraceProvider =================== diff --git a/general/tracing/evntdrv/README.md b/general/tracing/evntdrv/README.md index 4e64ecae..41359ad1 100644 --- a/general/tracing/evntdrv/README.md +++ b/general/tracing/evntdrv/README.md @@ -1,3 +1,13 @@ + + + Eventdrv ======== diff --git a/general/tracing/tracedriver/README.md b/general/tracing/tracedriver/README.md index 064fb133..358053a1 100644 --- a/general/tracing/tracedriver/README.md +++ b/general/tracing/tracedriver/README.md @@ -1,3 +1,13 @@ + + + Tracedrv ======== diff --git a/general/umdfSkeleton/README.md b/general/umdfSkeleton/README.md index 923f44df..85d384f5 100644 --- a/general/umdfSkeleton/README.md +++ b/general/umdfSkeleton/README.md @@ -1,3 +1,13 @@ + + + UMDF Driver Skeleton Sample (UMDF Version 1) ============================================ diff --git a/gpio/samples/README.md b/gpio/samples/README.md index dcf5ca64..ba05c2f6 100644 --- a/gpio/samples/README.md +++ b/gpio/samples/README.md @@ -1,3 +1,13 @@ + + + GPIO Sample Drivers =================== diff --git a/hid/firefly/README.md b/hid/firefly/README.md index 306d816f..cd526150 100644 --- a/hid/firefly/README.md +++ b/hid/firefly/README.md @@ -1,3 +1,13 @@ + + + KMDF filter driver for a HID device =================================== Firefly is a KMDF-based filter driver for a HID device. Along with illustrating how to write a filter driver, this sample shows how to use remote I/O target interfaces to open a HID collection in kernel-mode and send IOCTL requests to set and get feature reports, as well as how an application can use WMI interfaces to send commands to a filter driver. diff --git a/hid/hclient/README.md b/hid/hclient/README.md index b98902fe..192f4f90 100644 --- a/hid/hclient/README.md +++ b/hid/hclient/README.md @@ -1,3 +1,13 @@ + + + HClient sample application ========================== diff --git a/hid/hidusbfx2/README.md b/hid/hidusbfx2/README.md index bd0b88a9..20eb2001 100644 --- a/hid/hidusbfx2/README.md +++ b/hid/hidusbfx2/README.md @@ -1,3 +1,14 @@ + + + + HIDUSBFX2 sample driver ======================= The HIDUSBFX2 sample driver (hidusbfx2.sys) demonstrates how to map a non-HID USB device to a HID device. diff --git a/hid/vhidmini2/README.md b/hid/vhidmini2/README.md index 7679a849..bd6ea894 100644 --- a/hid/vhidmini2/README.md +++ b/hid/vhidmini2/README.md @@ -1,4 +1,13 @@ -HID Minidriver Sample (UMDF V2) + + +HID Minidriver Sample (UMDF version 2) ====================================== The *HID minidriver* sample demonstrates how to write a HID minidriver using User-Mode Driver Framework (UMDF). diff --git a/input/hiddigi/SynapticsTouch/README.md b/input/hiddigi/SynapticsTouch/README.md index df0347d2..6fb9b5ee 100644 --- a/input/hiddigi/SynapticsTouch/README.md +++ b/input/hiddigi/SynapticsTouch/README.md @@ -1,3 +1,13 @@ + + + Synaptics Touch Sample ====================== @@ -17,15 +27,6 @@ Related technologies [Windows Pointer Device](http://msdn.microsoft.com/en-us/library/windows/hardware/jj151570) -##System requirements -------------------- -**Client:** Windows 10 Technical Preview - -**Server:** Windows 10 Technical Preview - -**Phone:** Windows 10 Technical Preview - - File Manifest ------------- diff --git a/input/kbfiltr/README.md b/input/kbfiltr/README.md index 9942ec40..f570c5cb 100644 --- a/input/kbfiltr/README.md +++ b/input/kbfiltr/README.md @@ -1,3 +1,13 @@ + + + Keyboard Input WDF Filter Driver (Kbfiltr) ========================================== diff --git a/input/layout/README.md b/input/layout/README.md index 341c8ade..d998e379 100644 --- a/input/layout/README.md +++ b/input/layout/README.md @@ -1,3 +1,13 @@ + + + Keyboard Layout Samples ======================= diff --git a/input/moufiltr/README.md b/input/moufiltr/README.md index e0cc32c5..6cf5c585 100644 --- a/input/moufiltr/README.md +++ b/input/moufiltr/README.md @@ -1,3 +1,13 @@ + + + Mouse Input WDF Filter Driver (Moufiltr) ======================================== The Moufiltr sample is an example of a mouse input filter driver. -- cgit v1.3.1 From 389bdb217d54112d96b40bc967f86b17a605bed6 Mon Sep 17 00:00:00 2001 From: Tim Felser Date: Fri, 25 Aug 2017 16:42:50 +0200 Subject: Added a new command "removeall" Just like "findall" corresponds to "find" this new command acts like "remove" but it will also remove non-present devices. So it is easy to remove all instances of an USB driver. --- setup/devcon/cmds.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ setup/devcon/msg.mc | 21 +++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/setup/devcon/cmds.cpp b/setup/devcon/cmds.cpp index 1af49c5c..0002b393 100644 --- a/setup/devcon/cmds.cpp +++ b/setup/devcon/cmds.cpp @@ -1551,6 +1551,78 @@ Return Value: return failcode; } +int cmdRemoveAll(_In_ LPCTSTR BaseName, _In_opt_ LPCTSTR Machine, _In_ DWORD Flags, _In_ int argc, _In_reads_(argc) PTSTR argv[]) +/*++ + +Routine Description: + +REMOVEALL +remove devices +like remove, but also remove not-present devices + +Arguments: + +BaseName - name of executable +Machine - machine name, must be NULL +argc/argv - remaining parameters + +Return Value: + +EXIT_xxxx + +--*/ +{ + GenericContext context; + TCHAR strRemove[80]; + TCHAR strReboot[80]; + TCHAR strFail[80]; + int failcode = EXIT_FAIL; + + UNREFERENCED_PARAMETER(Flags); + + if (!argc) { + // + // arguments required + // + return EXIT_USAGE; + } + if (Machine) { + // + // must be local machine as we need to involve class/co installers + // + return EXIT_USAGE; + } + if (!LoadString(NULL, IDS_REMOVED, strRemove, ARRAYSIZE(strRemove))) { + return EXIT_FAIL; + } + if (!LoadString(NULL, IDS_REMOVED_REBOOT, strReboot, ARRAYSIZE(strReboot))) { + return EXIT_FAIL; + } + if (!LoadString(NULL, IDS_REMOVE_FAILED, strFail, ARRAYSIZE(strFail))) { + return EXIT_FAIL; + } + + context.reboot = FALSE; + context.count = 0; + context.strReboot = strReboot; + context.strSuccess = strRemove; + context.strFail = strFail; + failcode = EnumerateDevices(BaseName, Machine, 0, argc, argv, RemoveCallback, &context); + + if (failcode == EXIT_OK) { + + if (!context.count) { + FormatToStream(stdout, MSG_REMOVE_TAIL_NONE); + } else if (!context.reboot) { + FormatToStream(stdout, MSG_REMOVE_TAIL, context.count); + } else { + FormatToStream(stdout, MSG_REMOVE_TAIL_REBOOT, context.count); + failcode = EXIT_REBOOT; + } + } + return failcode; +} + int cmdRescan(_In_ LPCTSTR BaseName, _In_opt_ LPCTSTR Machine, _In_ DWORD Flags, _In_ int argc, _In_reads_(argc) PTSTR argv[]) /*++ @@ -2389,6 +2461,7 @@ DispatchEntry DispatchTable[] = { { TEXT("listclass"), cmdListClass, MSG_LISTCLASS_SHORT, MSG_LISTCLASS_LONG }, { TEXT("reboot"), cmdReboot, MSG_REBOOT_SHORT, MSG_REBOOT_LONG }, { TEXT("remove"), cmdRemove, MSG_REMOVE_SHORT, MSG_REMOVE_LONG }, + { TEXT("removeall"), cmdRemoveAll, MSG_REMOVEALL_SHORT, MSG_REMOVEALL_LONG }, { TEXT("rescan"), cmdRescan, MSG_RESCAN_SHORT, MSG_RESCAN_LONG }, { TEXT("resources"), cmdResources, MSG_RESOURCES_SHORT, MSG_RESOURCES_LONG }, { TEXT("restart"), cmdRestart, MSG_RESTART_SHORT, MSG_RESTART_LONG }, diff --git a/setup/devcon/msg.mc b/setup/devcon/msg.mc index a3c677e9..ca348bde 100644 --- a/setup/devcon/msg.mc +++ b/setup/devcon/msg.mc @@ -811,6 +811,27 @@ MessageId=61204 SymbolicName=MSG_REMOVE_TAIL Language=English %1!u! device(s) were removed. . +MessageId=61205 SymbolicName=MSG_REMOVEALL_LONG +Language=English +Devcon Removeall Command +Removes devices with the specified hardware or instance ID, including devices +that are not currently attached. Valid only on the local computer. +(To reboot when necesary, Include -r .) +%1 [-r] %2 [...] +%1 [-r] %2 = [...] + Specifies a device setup class. +Examples of : + * - All devices + ISAPNP\PNP0501 - Hardware ID + *PNP* - Hardware ID with wildcards (* matches anything) + @ISAPNP\*\* - Instance ID with wildcards (@ prefixes instance ID) + '*PNP0501 - Hardware ID with apostrophe (' prefixes literal match - matches exactly as typed, + including the asterisk.) +. +MessageId=61206 SymbolicName=MSG_REMOVEALL_SHORT +Language=English +%1!-20s! Remove devices, including those that are not currently attached. +. ;// ;// RESCAN -- cgit v1.3.1 From 806725d560858c2018611fc4e7693d56bb2d29d5 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 25 Aug 2017 13:45:41 -0700 Subject: Remove gallery.xml --- sensors/ADXL345Acc/Gallery.xml | 161 --------------------- sensors/Activity/Gallery.xml | 160 --------------------- sensors/CustomSensors/Gallery.xml | 168 ---------------------- sensors/Pedometer/Gallery.xml | 160 --------------------- sensors/SimpleDeviceOrientationSensor/Gallery.xml | 160 --------------------- 5 files changed, 809 deletions(-) delete mode 100644 sensors/ADXL345Acc/Gallery.xml delete mode 100644 sensors/Activity/Gallery.xml delete mode 100644 sensors/CustomSensors/Gallery.xml delete mode 100644 sensors/Pedometer/Gallery.xml delete mode 100644 sensors/SimpleDeviceOrientationSensor/Gallery.xml diff --git a/sensors/ADXL345Acc/Gallery.xml b/sensors/ADXL345Acc/Gallery.xml deleted file mode 100644 index 2d3eabf5..00000000 --- a/sensors/ADXL345Acc/Gallery.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - - ADXL345Accelerometer - - - - - - - - - - - - -

The ADXL345Accelerometer sample shows how to write a UMDF v2 driver to control an ADXL345 accelerometer chip.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
- - -
- -

To install the sample driver, follow these steps:

- - Ensure that the driver builds without errors. - Ensure the appropriate hardware resources have been assigned in the ACPI table using ASL. A device node with HWID ACPI\ADXL345Acc should be created. - Copy the DLL and INF files to a separate folder. - Enter the command "devcon.exe update ADXL345Acc.inf ACPI\ADXL345Acc" to install the driver on an existing device node. You can find the devcon.exe program in the tools\devcon folder where you installed the WDK. - -
-
-
- File manifest - -

The following source files are in the src\Sensors\ADXL345Acc folder and are used to build the ADXL345Acc.dll and ADXL345Acc.inf files.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileDescription
-

device.h, device.cpp

-
-

Implements the driver's WDF PnP event callbacks and helper methods

-
-

client.cpp

-
-

Implements the driver's callback functions from the class extension to the ADXL345 accelerometer.

-
-

driver.h, driver.cpp

-
-

WDF driver entry event callbacks and helper methods

-
-

ADXL345.h

-
-

Device specific definitions.

-
-

makefile.inc

-
-

Defines custom build actions. Includes the conversion of the .INX file into a .INF file.

-
-

SensorsTrace.h

-
-

Implementation the sensor traces files.

-
-

ADXL345Acc.ctl

-
-

Declaration of driver's tracing GUID

-
-

ADXL345Acc.inx

-
-

Describes the installation of the driver. The build process converts this into a .INF.

-
-
-
-
-
-
- - - - - -
diff --git a/sensors/Activity/Gallery.xml b/sensors/Activity/Gallery.xml deleted file mode 100644 index bb6e792a..00000000 --- a/sensors/Activity/Gallery.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - Activity - - - - - - - - - - - - -

The activity sensor sample shows how to write a UMDF v2 driver to control a virtual activity sensor.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
- - -
- -

To install the sample driver, follow these steps:

- - Ensure that the driver builds without errors. - Copy the DLL and INF files to a separate folder. - Enter the command "devcon.exe update Activity.inf ACPI\<HWID>" to install the driver on an existing device node. You can find the devcon.exe program in the tools\devcon folder where you installed the WDK. - -
-
-
- File manifest - -

The following source files are in the src\Sensors\Activity folder and are used to build the Activity.dll and Activity.inf files.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileDescription
-

device.h, device.cpp

-
-

Implements the driver's WDF PnP event callbacks and helper methods

-
-

client.cpp

-
-

Implements the driver's callback functions from the class extension to activity sensors.

-
-

driver.h, driver.cpp

-
-

WDF driver entry event callbacks and helper methods

-
-

hardwaresimulator.h, hardwaresimulator.cpp

-
-

Hardware simulator implementation

-
-

makefile.inc

-
-

Defines custom build actions. Includes the conversion of the .INX file into a .INF file.

-
-

SensorsTrace.h

-
-

Implementation the sensor traces files.

-
-

Activity.ctl

-
-

Declaration of driver's tracing GUID

-
-

Activity.inx

-
-

Describes the installation of the driver. The build process converts this into a .INF.

-
-
-
-
-
-
- - - - - -
diff --git a/sensors/CustomSensors/Gallery.xml b/sensors/CustomSensors/Gallery.xml deleted file mode 100644 index 8f84093a..00000000 --- a/sensors/CustomSensors/Gallery.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - - - CustomSensors - - - - - - - - - - - - -

The CustomSensors sample shows how to write a UMDF v2 driver to control a virtual CO2 sensor.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
- - -
- -

To install the sample driver, follow these steps:

- - Ensure that the driver builds without errors. - Copy the DLL and INF files to a separate folder. - Enter the command "devcon.exe update CustomSensors.inf ACPI\<HWID>" to install the driver on an existing device node. You can find the devcon.exe program in the tools\devcon folder where you installed the WDK. - -
-
-
- File manifest - -

The following source files are in the src\Sensors\CustomSensors folder and are used to build the CustomSensors.dll and CustomSensors.inf files.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileDescription
-

device.h, device.cpp

-
-

Implements the driver's WDF PnP event callbacks and helper methods

-
-

client.cpp

-
-

Implements the driver's callback functions from the class extension to custom sensors.

-
-

driver.h, driver.cpp

-
-

WDF driver entry event callbacks and helper methods

-
-

hardwaresimulator.h, hardwaresimulator.cpp

-
-

Hardware simulator implementation

-
-

makefile.inc

-
-

Defines custom build actions. Includes the conversion of the .INX file into a .INF file.

-
-

SensorsTrace.h

-
-

Implementation the sensor traces files.

-
-

CustomSensors.ctl

-
-

Declaration of driver's tracing GUID

-
-

CustomSensor.inx

-
-

Describes the installation of the driver. The build process converts this into a .INF.

-
-

Trace.h

-
-

Sets up WPP tracing.

-
-
-
-
-
-
- - - - - -
diff --git a/sensors/Pedometer/Gallery.xml b/sensors/Pedometer/Gallery.xml deleted file mode 100644 index ba572bcf..00000000 --- a/sensors/Pedometer/Gallery.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - Pedometer - - - - - - - - - - - - -

The Pedometer sample shows how to write a UMDF v2 driver to control a virtual Pedometer sensor.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
- - -
- -

To install the sample driver, follow these steps:

- - Ensure that the driver builds without errors. - Copy the DLL and INF files to a separate folder. - Enter the command "devcon.exe update Pedometer.inf ACPI\<HWID>" to install the driver on an existing device node. You can find the devcon.exe program in the tools\devcon folder where you installed the WDK. - -
-
-
- File manifest - -

The following source files are in the src\Sensors\Pedometer folder and are used to build the Pedometer.dll and Pedometer.inf files.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileDescription
-

device.h, device.cpp

-
-

Implements the driver's WDF PnP event callbacks and helper methods

-
-

client.cpp

-
-

Implements the driver's callback functions from the class extension to pedometer sensors.

-
-

driver.h, driver.cpp

-
-

WDF driver entry event callbacks and helper methods

-
-

hardwaresimulator.h, hardwaresimulator.cpp

-
-

Hardware simulator implementation

-
-

makefile.inc

-
-

Defines custom build actions. Includes the conversion of the .INX file into a .INF file.

-
-

SensorsTrace.h

-
-

Implementation the sensor traces files.

-
-

Pedometer.ctl

-
-

Declaration of driver's tracing GUID

-
-

Pedometer.inx

-
-

Describes the installation of the driver. The build process converts this into a .INF.

-
-
-
-
-
-
- - - - - -
diff --git a/sensors/SimpleDeviceOrientationSensor/Gallery.xml b/sensors/SimpleDeviceOrientationSensor/Gallery.xml deleted file mode 100644 index 8fbb8b8c..00000000 --- a/sensors/SimpleDeviceOrientationSensor/Gallery.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - SimpleDeviceOrientationSensor - - - - - - - - - - - - -

The SimpleDeviceOrientationSensor sample shows how to write a UMDF v2 sensor driver to output Simple Device Orientation values.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
- - -
- -

To install the sample driver, follow these steps:

- - Ensure that the driver builds without errors. - Copy the DLL and INF files to a separate folder. - Enter the command "devcon.exe update SimpleDeviceOrientationSensor.inf ACPI\<HWID>" to install the driver on an existing device node. You can find the devcon.exe program in the tools\devcon folder where you installed the WDK. - -
-
-
- File manifest - -

The following source files are in the src\Sensors\SimpleDeviceOrientationSensor folder and are used to build the SimpleDeviceOrientationSensor.dll and SimpleDeviceOrientationSensor.inf files.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileDescription
-

device.h, device.cpp

-
-

Implements the driver's WDF PnP event callbacks and helper methods

-
-

client.cpp

-
-

Implements the driver's callback functions from the class extension to simple device orientation sensors.

-
-

driver.h, driver.cpp

-
-

WDF driver entry event callbacks and helper methods

-
-

hardwaresimulator.h, hardwaresimulator.cpp

-
-

Hardware simulator implementation

-
-

makefile.inc

-
-

Defines custom build actions. Includes the conversion of the .INX file into a .INF file.

-
-

SensorsTrace.h

-
-

Implementation the sensor traces files.

-
-

SimpleDeviceOrientationSensor.ctl

-
-

Declaration of driver's tracing GUID

-
-

SimpleDeviceOrientationSensor.inx

-
-

Describes the installation of the driver. The build process converts this into a .INF.

-
-
-
-
-
-
- - - - - -
-- cgit v1.3.1 From 112a28423dea2f79402bc20d1cad07afe4f69e22 Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Fri, 25 Aug 2017 14:50:13 -0700 Subject: VSTS 12737998 --- network/config/bindview/README.md | 10 ++++++++++ network/modem/fakemodem/README.md | 9 +++++++++ network/ndis/extension/README.md | 10 ++++++++++ network/ndis/filter/README.md | 10 ++++++++++ network/ndis/mux/README.md | 10 ++++++++++ network/ndis/ndisprot/6x/README.md | 16 +++++++++++++--- network/ndis/ndisprot_kmdf/README.md | 17 ++++++++++++++--- network/ndis/netvmini/6x/README.md | 10 ++++++++++ network/radio/HidSwitchDriverSample/README.md | 10 ++++++++++ network/radio/RadioManagerSample/README.md | 10 ++++++++++ network/trans/WFPSampler/README.md | 10 ++++++++++ network/trans/ddproxy/README.md | 10 ++++++++++ network/trans/inspect/README.md | 10 ++++++++++ network/trans/msnmntr/README.md | 10 ++++++++++ network/trans/stmedit/README.md | 10 ++++++++++ network/wsk/echosrv/README.md | 10 ++++++++++ nfc/Simulator/README.md | 10 ++++++++++ nfp/net/README.md | 10 ++++++++++ pofx/PEP/README.md | 10 ++++++++++ pofx/UMDF2/README.md | 10 ++++++++++ pofx/WDF/README.md | 10 ++++++++++ pos/drivers/MagneticStripeReader/README.md | 10 ++++++++++ pos/drivers/barcodescanner/README.md | 10 ++++++++++ print/SampleOpenXPS/README.md | 10 ++++++++++ print/SampleXPS/README.md | 10 ++++++++++ print/SimplePipelineFilter/README.md | 10 ++++++++++ print/XPSDrvSmpl/README.md | 10 ++++++++++ print/XpsRasFilter/README.md | 11 +++++++++++ print/autoconfig/README.md | 10 ++++++++++ print/cpsuisam/README.md | 10 ++++++++++ .../PrinterExtensionSample/README.md | 10 ++++++++++ .../v4PrintDriver-ConstraintScript/README.md | 10 ++++++++++ .../v4PrintDriver-HostBasedSampleDriver/README.md | 11 +++++++++++ .../v4PrintDriver-USBMon-Bidi-Extension/README.md | 10 ++++++++++ .../v4PrintDriver-WSDMon-Bidi-Extension/README.md | 10 ++++++++++ 35 files changed, 358 insertions(+), 6 deletions(-) diff --git a/network/config/bindview/README.md b/network/config/bindview/README.md index 01e1cd8d..b239b700 100644 --- a/network/config/bindview/README.md +++ b/network/config/bindview/README.md @@ -1,3 +1,13 @@ + + + Bindview Network Configuration Utility ====================================== diff --git a/network/modem/fakemodem/README.md b/network/modem/fakemodem/README.md index b79071cb..3734a95a 100644 --- a/network/modem/fakemodem/README.md +++ b/network/modem/fakemodem/README.md @@ -1,3 +1,12 @@ + + Fakemodem Driver ================ diff --git a/network/ndis/extension/README.md b/network/ndis/extension/README.md index dc3b6b92..df154559 100644 --- a/network/ndis/extension/README.md +++ b/network/ndis/extension/README.md @@ -1,3 +1,13 @@ + + + Hyper-V Extensible Switch extension filter driver ================================================= diff --git a/network/ndis/filter/README.md b/network/ndis/filter/README.md index ac1bc67c..274287bc 100644 --- a/network/ndis/filter/README.md +++ b/network/ndis/filter/README.md @@ -1,3 +1,13 @@ + + + NDIS 6.0 Filter Driver ====================== diff --git a/network/ndis/mux/README.md b/network/ndis/mux/README.md index 0a545a3a..cf9a112c 100644 --- a/network/ndis/mux/README.md +++ b/network/ndis/mux/README.md @@ -1,3 +1,13 @@ + + + NDIS MUX Intermediate Driver and Notify Object ============================================== diff --git a/network/ndis/ndisprot/6x/README.md b/network/ndis/ndisprot/6x/README.md index 55843a0c..211a8721 100644 --- a/network/ndis/ndisprot/6x/README.md +++ b/network/ndis/ndisprot/6x/README.md @@ -1,7 +1,17 @@ -NDIS Connection-less Protocol Driver Sample -=========================================== + -This sample demonstrates a connection-less NDIS 6.0 protocol.The driver supports sending and receiving raw Ethernet frames using `ReadFile`/`WriteFile` calls from user-mode. It only receives frames with a specific EtherType field. As an NDIS protocol, it illustrates how to establish and tear down bindings to Ethernet adapters, i.e. those that export medium type **NdisMedium802\_3**. It shows how to set a packet filter, send and receive data, and handle plug-and-play events. + +NDIS Connection-less Protocol WDM Driver Sample +=============================================== + +This sample demonstrates a connection-less NDIS 6.0 protocol WDM driver. The driver supports sending and receiving raw Ethernet frames using `ReadFile`/`WriteFile` calls from user-mode. It only receives frames with a specific EtherType field. As an NDIS protocol, it illustrates how to establish and tear down bindings to Ethernet adapters, i.e. those that export medium type **NdisMedium802\_3**. It shows how to set a packet filter, send and receive data, and handle plug-and-play events. ### INSTALLATION diff --git a/network/ndis/ndisprot_kmdf/README.md b/network/ndis/ndisprot_kmdf/README.md index 0da2ae31..0f2ceb23 100644 --- a/network/ndis/ndisprot_kmdf/README.md +++ b/network/ndis/ndisprot_kmdf/README.md @@ -1,6 +1,17 @@ -Connection-less NDIS 6.0 Sample Protocol Driver -=============================================== -This sample demonstrates a connection-less NDIS 6.0 protocol driver. + + + +Connection-less NDIS 6.0 Protocol KMDF Sample Driver +==================================================== + +This sample demonstrates a connection-less NDIS 6.0 protocol KMDF driver. The driver supports sending and receiving raw Ethernet frames using ReadFile/WriteFile calls from user-mode. As an NDIS protocol, it illustrates how to establish and tear down bindings to Ethernet adapters, i.e. those that export medium type *NdisMedium802\_3*. It shows how to set a packet filter, send and receive data, and handle plug-and-play events. diff --git a/network/ndis/netvmini/6x/README.md b/network/ndis/netvmini/6x/README.md index 76020b5d..023e1674 100644 --- a/network/ndis/netvmini/6x/README.md +++ b/network/ndis/netvmini/6x/README.md @@ -1,3 +1,13 @@ + + + NDIS Virtual Miniport Driver ============================ diff --git a/network/radio/HidSwitchDriverSample/README.md b/network/radio/HidSwitchDriverSample/README.md index 5f4fdd81..9726babf 100644 --- a/network/radio/HidSwitchDriverSample/README.md +++ b/network/radio/HidSwitchDriverSample/README.md @@ -1,3 +1,13 @@ + + + Radio Switch Test Driver for OSR USB-FX2 Development Board ========================================================== diff --git a/network/radio/RadioManagerSample/README.md b/network/radio/RadioManagerSample/README.md index e391e051..3cac53e9 100644 --- a/network/radio/RadioManagerSample/README.md +++ b/network/radio/RadioManagerSample/README.md @@ -1,3 +1,13 @@ + + + Windows Radio Management Sample =============================== diff --git a/network/trans/WFPSampler/README.md b/network/trans/WFPSampler/README.md index d23c2554..84621bcd 100644 --- a/network/trans/WFPSampler/README.md +++ b/network/trans/WFPSampler/README.md @@ -1,3 +1,13 @@ + + + Windows Filtering Platform Sample ================================= diff --git a/network/trans/ddproxy/README.md b/network/trans/ddproxy/README.md index a9e1d427..45a122d9 100644 --- a/network/trans/ddproxy/README.md +++ b/network/trans/ddproxy/README.md @@ -1,3 +1,13 @@ + + + Windows Filtering Platform Packet Modification Sample ===================================================== diff --git a/network/trans/inspect/README.md b/network/trans/inspect/README.md index 4f28598c..2c197c4f 100644 --- a/network/trans/inspect/README.md +++ b/network/trans/inspect/README.md @@ -1,3 +1,13 @@ + + + Windows Filtering Platform Traffic Inspection Sample ==================================================== diff --git a/network/trans/msnmntr/README.md b/network/trans/msnmntr/README.md index fcc9c420..14127cbc 100644 --- a/network/trans/msnmntr/README.md +++ b/network/trans/msnmntr/README.md @@ -1,3 +1,13 @@ + + + Windows Filtering Platform MSN Messenger Monitor Sample ======================================================= diff --git a/network/trans/stmedit/README.md b/network/trans/stmedit/README.md index 0c434b07..67905639 100644 --- a/network/trans/stmedit/README.md +++ b/network/trans/stmedit/README.md @@ -1,3 +1,13 @@ + + + Windows Filtering Platform Stream Edit Sample ============================================= diff --git a/network/wsk/echosrv/README.md b/network/wsk/echosrv/README.md index 8b93db2d..96cc02d5 100644 --- a/network/wsk/echosrv/README.md +++ b/network/wsk/echosrv/README.md @@ -1,3 +1,13 @@ + + + WSK TCP Echo Server =================== diff --git a/nfc/Simulator/README.md b/nfc/Simulator/README.md index dfdeaa7c..17b3bdac 100644 --- a/nfc/Simulator/README.md +++ b/nfc/Simulator/README.md @@ -1,3 +1,13 @@ + + + NFC Simulator Driver Sample =========================== This sample demonstrates how to use User-Mode Driver Framework (UMDF) to write a Near-Field Communication (NFC) universal driver along with best practices. diff --git a/nfp/net/README.md b/nfp/net/README.md index aeb2c630..5f9c670b 100644 --- a/nfp/net/README.md +++ b/nfp/net/README.md @@ -1,3 +1,13 @@ + + + Near-Field Proximity Sample Driver (UMDF Version 1) =================================================== diff --git a/pofx/PEP/README.md b/pofx/PEP/README.md index 41bef908..079dbec6 100644 --- a/pofx/PEP/README.md +++ b/pofx/PEP/README.md @@ -1,3 +1,13 @@ + + + PEP ACPI Sample =============== diff --git a/pofx/UMDF2/README.md b/pofx/UMDF2/README.md index db47b385..78cf1f40 100644 --- a/pofx/UMDF2/README.md +++ b/pofx/UMDF2/README.md @@ -1,3 +1,13 @@ + + + Power Framework (PoFx) Sample (UMDF Version 2) ============================================== diff --git a/pofx/WDF/README.md b/pofx/WDF/README.md index 2f8009c3..7915dbd7 100644 --- a/pofx/WDF/README.md +++ b/pofx/WDF/README.md @@ -1,3 +1,13 @@ + + + KMDF Power Framework (PoFx) Sample ================================== diff --git a/pos/drivers/MagneticStripeReader/README.md b/pos/drivers/MagneticStripeReader/README.md index 5530f60c..4e8d8088 100644 --- a/pos/drivers/MagneticStripeReader/README.md +++ b/pos/drivers/MagneticStripeReader/README.md @@ -1,3 +1,13 @@ + + + Magnetic Stripe Reader Driver Sample ==================================== This sample serves as a template for creating a new Magnetic Stripe Reader driver. diff --git a/pos/drivers/barcodescanner/README.md b/pos/drivers/barcodescanner/README.md index 8df934b3..f6d7926b 100644 --- a/pos/drivers/barcodescanner/README.md +++ b/pos/drivers/barcodescanner/README.md @@ -1,3 +1,13 @@ + + + Barcode Scanner Driver Sample ==================================== This sample serves as a template for creating a new Barcode Scanner driver. diff --git a/print/SampleOpenXPS/README.md b/print/SampleOpenXPS/README.md index a50148e4..f939583f 100644 --- a/print/SampleOpenXPS/README.md +++ b/print/SampleOpenXPS/README.md @@ -1,3 +1,13 @@ + + + OpenXPS Documents Print Sample ============================== diff --git a/print/SampleXPS/README.md b/print/SampleXPS/README.md index 18a242bb..b1c39d3e 100644 --- a/print/SampleXPS/README.md +++ b/print/SampleXPS/README.md @@ -1,3 +1,13 @@ + + + XPS Documents Print Sample ========================== diff --git a/print/SimplePipelineFilter/README.md b/print/SimplePipelineFilter/README.md index 06f17b61..c7a92e48 100644 --- a/print/SimplePipelineFilter/README.md +++ b/print/SimplePipelineFilter/README.md @@ -1,3 +1,13 @@ + + + Print Pipeline Simple Filter ============================ diff --git a/print/XPSDrvSmpl/README.md b/print/XPSDrvSmpl/README.md index f90ae5cf..7c75a314 100644 --- a/print/XPSDrvSmpl/README.md +++ b/print/XPSDrvSmpl/README.md @@ -1,3 +1,13 @@ + + + XPSDrv Driver and Filter Sample =============================== diff --git a/print/XpsRasFilter/README.md b/print/XpsRasFilter/README.md index a742f66c..344c6bf9 100644 --- a/print/XpsRasFilter/README.md +++ b/print/XpsRasFilter/README.md @@ -1,3 +1,14 @@ + + + + XPS Rasterization Filter Service Sample ======================================= diff --git a/print/autoconfig/README.md b/print/autoconfig/README.md index e4642008..38a442e2 100644 --- a/print/autoconfig/README.md +++ b/print/autoconfig/README.md @@ -1,3 +1,13 @@ + + + Print auto-configuration sample =============================== diff --git a/print/cpsuisam/README.md b/print/cpsuisam/README.md index a4fddfb9..b289ad82 100644 --- a/print/cpsuisam/README.md +++ b/print/cpsuisam/README.md @@ -1,3 +1,13 @@ + + + Common Property Sheet UI Sample =============================== diff --git a/print/v4PrintDriverSamples/PrinterExtensionSample/README.md b/print/v4PrintDriverSamples/PrinterExtensionSample/README.md index ca5f6837..c76f31d8 100644 --- a/print/v4PrintDriverSamples/PrinterExtensionSample/README.md +++ b/print/v4PrintDriverSamples/PrinterExtensionSample/README.md @@ -1,3 +1,13 @@ + + + Printer Extension Sample ======================== diff --git a/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/README.md b/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/README.md index 71a6f72b..f0f64424 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/README.md +++ b/print/v4PrintDriverSamples/v4PrintDriver-ConstraintScript/README.md @@ -1,3 +1,13 @@ + + + Print Driver Constraints Sample =============================== diff --git a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/README.md b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/README.md index 6d3b77d0..09fdd30c 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/README.md +++ b/print/v4PrintDriverSamples/v4PrintDriver-HostBasedSampleDriver/README.md @@ -1,3 +1,14 @@ + + + + USB Host-Based Print Driver Sample ================================== diff --git a/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/README.md b/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/README.md index 294dee1e..cebf8145 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/README.md +++ b/print/v4PrintDriverSamples/v4PrintDriver-USBMon-Bidi-Extension/README.md @@ -1,3 +1,13 @@ + + + Print Driver USB Monitor and Bidi Sample ======================================== diff --git a/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/README.md b/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/README.md index 6556ab25..385002c0 100644 --- a/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/README.md +++ b/print/v4PrintDriverSamples/v4PrintDriver-WSDMon-Bidi-Extension/README.md @@ -1,3 +1,13 @@ + + + WSDMon Bidi Extension Sample ============================ -- cgit v1.3.1 From 037d71513ccc6149d3ec6633c7c5574df7903e86 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 25 Aug 2017 14:58:26 -0700 Subject: Add Fusion Sensor sample --- sensors/Fusion/Device.h | 199 +++++++ sensors/Fusion/Driver.h | 19 + sensors/Fusion/FusionSensor.ctl | 1 + sensors/Fusion/FusionSensor.def | 6 + sensors/Fusion/FusionSensor.inx | Bin 0 -> 4990 bytes sensors/Fusion/FusionSensor.sln | 28 + sensors/Fusion/FusionSensor.vcxproj | 203 +++++++ sensors/Fusion/FusionSensor.vcxproj.Filters | 43 ++ sensors/Fusion/HardwareSimulator.h | 60 +++ sensors/Fusion/SensorsTrace.h | 102 ++++ sensors/Fusion/client.cpp | 789 ++++++++++++++++++++++++++++ sensors/Fusion/device.cpp | 729 +++++++++++++++++++++++++ sensors/Fusion/driver.cpp | 76 +++ sensors/Fusion/hardwaresimulator.cpp | 277 ++++++++++ sensors/Fusion/readme.md | 3 + 15 files changed, 2535 insertions(+) create mode 100644 sensors/Fusion/Device.h create mode 100644 sensors/Fusion/Driver.h create mode 100644 sensors/Fusion/FusionSensor.ctl create mode 100644 sensors/Fusion/FusionSensor.def create mode 100644 sensors/Fusion/FusionSensor.inx create mode 100644 sensors/Fusion/FusionSensor.sln create mode 100644 sensors/Fusion/FusionSensor.vcxproj create mode 100644 sensors/Fusion/FusionSensor.vcxproj.Filters create mode 100644 sensors/Fusion/HardwareSimulator.h create mode 100644 sensors/Fusion/SensorsTrace.h create mode 100644 sensors/Fusion/client.cpp create mode 100644 sensors/Fusion/device.cpp create mode 100644 sensors/Fusion/driver.cpp create mode 100644 sensors/Fusion/hardwaresimulator.cpp create mode 100644 sensors/Fusion/readme.md diff --git a/sensors/Fusion/Device.h b/sensors/Fusion/Device.h new file mode 100644 index 00000000..1bd39606 --- /dev/null +++ b/sensors/Fusion/Device.h @@ -0,0 +1,199 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved +// +//Abstract: +// +// This module contains the type definitions for the client +// driver's device callback class. +// +//Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#pragma once + +#include +#include +#include + +#include "SensorsTrace.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define SENSOR_POOL_TAG_FUSIONSENSOR 'esuF' + +#define FusionSensor_Default_MinDataInterval_Ms (16) // 60Hz +#define FusionSensor_Default_DataInterval (100) // 10Hz +#define FusionSensor_Quarternion_Maximum (1.0f) +#define FusionSensor_Quarternion_Minimum (-1.0f) +#define FusionSensor_Quarternion_Resolution ((FusionSensor_Quarternion_Maximum-FusionSensor_Quarternion_Minimum)/65536) + + +// TODO: Customize the following 5 lines based on the hardware being used +#define GyrFakeDevice_Minimum_DegreesPerSecond (-2000.0f) +#define GyrFakeDevice_Maximum_DegreesPerSecond (2000.0f) +#define GyrFakeDevice_Precision (65536.0f) // 65536 = 2^16, 16 bit data +#define GyrFakeDevice_Range_DegreesPerSecond (GyrFakeDevice_Maximum_DegreesPerSecond - GyrFakeDevice_Minimum_DegreesPerSecond) +#define GyrFakeDevice_Resolution_DegreesPerSecond (GyrFakeDevice_Range_DegreesPerSecond / GyrFakeDevice_Precision) + +// TODO: Customize the following 3 lines based on the hardware being used +#define AccFakeDevice_Axis_Resolution (4.0f / 65536.0f) // in delta g +#define AccFakeDevice_Axis_Minimum (-2.0f) // in g +#define AccFakeDevice_Axis_Maximum (2.0f) // in g + +// Sensor Common Properties +typedef enum +{ + SENSOR_PROPERTY_STATE = 0, + SENSOR_PROPERTY_MIN_INTERVAL, + SENSOR_PROPERTY_MAX_DATAFIELDSIZE, + SENSOR_PROPERTY_SENSOR_TYPE, + SENSOR_PROPERTY_USE_GYRO, + SENSOR_PROPERTIES_COUNT +} SENSOR_COMMON_PROPERTIES_INDEX; + +// Sensor Enumeration Properties +typedef enum +{ + SENSOR_TYPE_GUID = 0, + SENSOR_MANUFACTURER, + SENSOR_MODEL, + SENSOR_PERSISTENT_UNIQUEID, + SENSOR_ISPRIMARY, + SENSOR_ENUMERATION_PROPERTIES_COUNT +} SENSOR_ENUMERATION_PROPERTIES_INDEX; + +// Accelerometer related data-field Properties +typedef enum +{ + SENSOR_ACC_RESOLUTION = 0, + SENSOR_ACC_MIN_RANGE, + SENSOR_ACC_MAX_RANGE, + SENSOR_ACC_DATA_FIELD_PROPERTY_COUNT +} SENSOR_ACC_DATA_FIELD_PROPERTY_INDEX; + +// Gyroscope related data-field Properties +typedef enum +{ + SENSOR_GYR_RESOLUTION = 0, + SENSOR_GYR_MIN_RANGE, + SENSOR_GYR_MAX_RANGE, + SENSOR_GYR_DATA_FIELD_PROPERTY_COUNT +} SENSOR_GYR_DATA_FIELD_PROPERTY_INDEX; + +// Supported Data +typedef enum +{ + FUSIONSENSOR_DATA_TIMESTAMP = 0, + FUSIONSENSOR_DATA_QUATERNION_W, + FUSIONSENSOR_DATA_QUATERNION_X, + FUSIONSENSOR_DATA_QUATERNION_Y, + FUSIONSENSOR_DATA_QUATERNION_Z, + FUSIONSENSOR_DATA_ACCURACY, + FUSIONSENSOR_DATA_DECLINATION_ANGLE, + FUSIONSENSOR_DATA_COUNT +} FUSIONSENSOR_DATA_INDEX; + +typedef enum +{ + FUSIONSENSOR_THRESHOLD_ROTATION_ANGLE = 0, + FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_X, + FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_Y, + FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_Z, + FUSIONSENSOR_THRESHOLD_ROTATION_RATE_X, + FUSIONSENSOR_THRESHOLD_ROTATION_RATE_Y, + FUSIONSENSOR_THRESHOLD_ROTATION_RATE_Z, + FUSIONSENSOR_THRESHOLD_COUNT +} FUSIONSENSOR_THRESHOLD_INDEX; + +typedef struct FusionSensorSample +{ + FILETIME Timestamp; + QUATERNION Quaternion; + ULONG Accuracy; + FLOAT DeclinationAngle; +} FusionSensorSample, *PFusionSensorSample; + +// +// Fusion Threshold +// +typedef struct _FusThreshold +{ + FLOAT RotationAngle; + VEC3D LinearAcceleration; + VEC3D RotationRate; +} FusThreshold, *PFusThreshold; + +typedef class FusionSensorDevice +{ +private: + // Simulator + WDFOBJECT m_SimulatorInstance; + + // WDF + WDFDEVICE m_FxDevice; + SENSOROBJECT m_SensorInstance; + WDFWAITLOCK m_Lock; + WDFTIMER m_Timer; + + // Sensor operation + BOOLEAN m_PoweredOn; + BOOLEAN m_Started; + ULONG m_Interval; + + BOOLEAN m_FirstSample; + ULONG m_StartTime; + ULONGLONG m_SampleCount; + + FusThreshold m_CachedThresholds; + + FusionSensorSample m_LastSample; + + // Sensor Specific Properties + PSENSOR_COLLECTION_LIST m_pEnumerationProperties; + PSENSOR_COLLECTION_LIST m_pProperties; + PSENSOR_PROPERTY_LIST m_pSupportedDataFields; + PSENSOR_COLLECTION_LIST m_pAccDataFieldProperties; // Accelerometer related datafield properties + PSENSOR_COLLECTION_LIST m_pGyrDataFieldProperties; // Gyroscope related datafield properties + PSENSOR_COLLECTION_LIST m_pThresholds; + PSENSOR_COLLECTION_LIST m_pData; + +public: + // WDF callbacks + static EVT_WDF_DRIVER_DEVICE_ADD OnDeviceAdd; + static EVT_WDF_DEVICE_PREPARE_HARDWARE OnPrepareHardware; + static EVT_WDF_DEVICE_RELEASE_HARDWARE OnReleaseHardware; + static EVT_WDF_DEVICE_D0_ENTRY OnD0Entry; + static EVT_WDF_DEVICE_D0_EXIT OnD0Exit; + static EVT_WDF_TIMER OnTimerExpire; + + // CLX callbacks + static EVT_SENSOR_DRIVER_START_SENSOR OnStart; + static EVT_SENSOR_DRIVER_STOP_SENSOR OnStop; + static EVT_SENSOR_DRIVER_GET_SUPPORTED_DATA_FIELDS OnGetSupportedDataFields; + static EVT_SENSOR_DRIVER_GET_PROPERTIES OnGetProperties; + static EVT_SENSOR_DRIVER_GET_DATA_FIELD_PROPERTIES OnGetDataFieldProperties; + static EVT_SENSOR_DRIVER_GET_DATA_INTERVAL OnGetDataInterval; + static EVT_SENSOR_DRIVER_SET_DATA_INTERVAL OnSetDataInterval; + static EVT_SENSOR_DRIVER_GET_DATA_THRESHOLDS OnGetDataThresholds; + static EVT_SENSOR_DRIVER_SET_DATA_THRESHOLDS OnSetDataThresholds; + static EVT_SENSOR_DRIVER_DEVICE_IO_CONTROL OnIoControl; + +private: + + NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj); + NTSTATUS GetData(); + +} FusionSensorDevice, *PFusionSensorDevice; + +// Set up accessor function to retrieve device context +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FusionSensorDevice, GetFusionSensorContextFromSensorInstance); + +#define FusionSensorDevice_StepCount_Resolution (1) +#define FusionSensorDevice_StepCount_Minimum (0) +#define FusionSensorDevice_StepCount_Maximum (0xFFFFFFFF) diff --git a/sensors/Fusion/Driver.h b/sensors/Fusion/Driver.h new file mode 100644 index 00000000..46153894 --- /dev/null +++ b/sensors/Fusion/Driver.h @@ -0,0 +1,19 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved +// +//Abstract: +// +// This module contains the type definitions for the FusionSensor sample driver's +// driver callback class. +// +//Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#pragma once + +WDF_EXTERN_C_START + +DRIVER_INITIALIZE DriverEntry; +EVT_WDF_DRIVER_UNLOAD OnDriverUnload; + +WDF_EXTERN_C_END \ No newline at end of file diff --git a/sensors/Fusion/FusionSensor.ctl b/sensors/Fusion/FusionSensor.ctl new file mode 100644 index 00000000..54959227 --- /dev/null +++ b/sensors/Fusion/FusionSensor.ctl @@ -0,0 +1 @@ +0E08A3BA,F045,44EE,B00C,292C91C5F95A FusionSensorTraceGuid diff --git a/sensors/Fusion/FusionSensor.def b/sensors/Fusion/FusionSensor.def new file mode 100644 index 00000000..f49a363a --- /dev/null +++ b/sensors/Fusion/FusionSensor.def @@ -0,0 +1,6 @@ +; FusionSensor.def : Declares the module parameters. + +LIBRARY FusionSensor + +EXPORTS + diff --git a/sensors/Fusion/FusionSensor.inx b/sensors/Fusion/FusionSensor.inx new file mode 100644 index 00000000..1c562304 Binary files /dev/null and b/sensors/Fusion/FusionSensor.inx differ diff --git a/sensors/Fusion/FusionSensor.sln b/sensors/Fusion/FusionSensor.sln new file mode 100644 index 00000000..39ab0322 --- /dev/null +++ b/sensors/Fusion/FusionSensor.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0 +MinimumVisualStudioVersion = 12.0 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FusionSensor", "FusionSensor.vcxproj", "{2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Debug|Win32.ActiveCfg = Debug|Win32 + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Debug|Win32.Build.0 = Debug|Win32 + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Release|Win32.ActiveCfg = Release|Win32 + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Release|Win32.Build.0 = Release|Win32 + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Debug|x64.ActiveCfg = Debug|x64 + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Debug|x64.Build.0 = Debug|x64 + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Release|x64.ActiveCfg = Release|x64 + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/sensors/Fusion/FusionSensor.vcxproj b/sensors/Fusion/FusionSensor.vcxproj new file mode 100644 index 00000000..f7a68e66 --- /dev/null +++ b/sensors/Fusion/FusionSensor.vcxproj @@ -0,0 +1,203 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {2D98FAA6-F523-420D-9F3A-480CD7C3F9CA} + $(MSBuildProjectName) + 2 + Debug + Win32 + {63E5D8E2-D2E3-4B7E-9F5A-78DA39FA9BED} + + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + + $(IntDir) + + + + + + + + + + + + + + + + true + true + FusionSensor + sensorstrace.h + + + $(InfArch) + true + .\$(IntDir)\FusionSensor.inf + + + + FusionSensor + + + FusionSensor + + + FusionSensor + + + FusionSensor + AllRules.ruleset + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + FusionSensor.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + FusionSensor.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + FusionSensor.def + + + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + true + Level4 + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + Sync + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(PreprocessorDefinitions);_UNICODE;UNICODE;WPP_MACRO_USE_KM_VERSION_FOR_UM + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);$(DDK_INC_PATH)\sensors\1.1;$(SDK_INC_PATH)\sensors\1.1 + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib + FusionSensor.def + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sensors/Fusion/FusionSensor.vcxproj.Filters b/sensors/Fusion/FusionSensor.vcxproj.Filters new file mode 100644 index 00000000..a5ed8ef6 --- /dev/null +++ b/sensors/Fusion/FusionSensor.vcxproj.Filters @@ -0,0 +1,43 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {47BC76FB-31D6-4043-A1F0-24C8EE1EC77D} + + + h;hpp;hxx;hm;inl;inc;xsd + {822384CB-A39F-4A21-8529-34A65C4CE181} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {C6D84098-A64B-429D-8EE2-D8ED8C5BF2FE} + + + inf;inv;inx;mof;mc; + {A379ED39-5FF0-4DB2-A773-BDEA4FB77D87} + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Driver Files + + + \ No newline at end of file diff --git a/sensors/Fusion/HardwareSimulator.h b/sensors/Fusion/HardwareSimulator.h new file mode 100644 index 00000000..67e56436 --- /dev/null +++ b/sensors/Fusion/HardwareSimulator.h @@ -0,0 +1,60 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved +// +//Abstract: +// +// This module contains the type definitions for the FusionSensor sample driver +// hardware simulator. +// +//Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#pragma once + +#include +#include + +#include "SensorsTrace.h" +#include + +#include "Device.h" + +#define SIMULATOR_HARDWARE_INTERVAL_MS (1000) // 1 second interval in milliseconds + +typedef enum SIMULATOR_STATE +{ + SimulatorState_NotInitialized = 0, + SimulatorState_Initialized, + SimulatorState_Started +} SIMULATOR_STATE; + +typedef class HardwareSimulator +{ +private: + WDFTIMER m_Timer; + ULONG m_Index; + WDFWAITLOCK m_Lock; + SIMULATOR_STATE m_State; + WDFOBJECT m_SimulatorInstance; + BOOLEAN m_HasReset; + +public: + HardwareSimulator(); + ~HardwareSimulator(); + + // WDF callbacks + static EVT_WDF_TIMER OnTimerExpire; + + static NTSTATUS Initialize(_In_ WDFDEVICE Device, _Out_ WDFOBJECT *SimulatorInstance); + NTSTATUS Cleanup(); + NTSTATUS Start(); + NTSTATUS Stop(); + NTSTATUS GetSample(_Out_ FusionSensorSample *Sample); + +private: + NTSTATUS InitializeInternal(_In_ WDFOBJECT SimulatorInstance); +} HardwareSimulator, *PHardwareSimulator; + + +// Set up accessor function to retrieve device context +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(HardwareSimulator, GetHardwareSimulatorContextFromInstance); diff --git a/sensors/Fusion/SensorsTrace.h b/sensors/Fusion/SensorsTrace.h new file mode 100644 index 00000000..8b3b8769 --- /dev/null +++ b/sensors/Fusion/SensorsTrace.h @@ -0,0 +1,102 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved +// +//Abstract: +// +// Header file for the debug tracing related function defintions and macros. +// +//Environment: +// +// User mode + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +// Define the tracing flags. +// +// Tracing GUID - 0E08A3BA-F045-44EE-B00C-292C91C5F95A + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID( \ + FusionSensorTraceGuid, (0E08A3BA,F045,44EE,B00C,292C91C5F95A), \ + WPP_DEFINE_BIT(EntryExit) \ + WPP_DEFINE_BIT(DataFlow) \ + WPP_DEFINE_BIT(Verbose) \ + WPP_DEFINE_BIT(Information) \ + WPP_DEFINE_BIT(Warning) \ + WPP_DEFINE_BIT(Error) \ + WPP_DEFINE_BIT(Fatal) \ + WPP_DEFINE_BIT(DriverStatus) \ + ) + +#define WPP_FLAG_LEVEL_LOGGER(flag, level) WPP_LEVEL_LOGGER(flag) + +#define WPP_FLAG_LEVEL_ENABLED(flag, level) (WPP_LEVEL_ENABLED(flag) && WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) + +#define WPP_LEVEL_FLAGS_LOGGER(level,flags) WPP_LEVEL_LOGGER(flags) + +#define WPP_LEVEL_FLAGS_ENABLED(level, flags) (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= level) + +// This comment block is scanned by the trace preprocessor to define our +// Trace function. +// +// begin_wpp config +// +// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); +// +// FUNC TraceFatal{LEVEL=TRACE_LEVEL_FATAL,FLAGS=Fatal}(MSG,...); +// FUNC TraceError{LEVEL=TRACE_LEVEL_ERROR,FLAGS=Error}(MSG,...); +// FUNC TraceWarning{LEVEL=TRACE_LEVEL_WARNING,FLAGS=Warning}(MSG,...); +// FUNC TraceInformation{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=Information}(MSG,...); +// FUNC TraceVerbose{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=Verbose}(MSG,...); +// FUNC TracePerformance{PERF=DUMMY,LEVEL=TRACE_LEVEL_PERF}(FLAGS,MSG,...); +// +// FUNC TraceData{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=DataFlow}(MSG,...); +// +// FUNC TraceDriverStatus{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=DriverStatus}(MSG,...); +// +// end_wpp + + + +// SENSOR ------------------------------------------------------------------------------------------------ + +// MACRO: SENSOR_FunctionEnter +// +// begin_wpp config +// USEPREFIX (SENSOR_FunctionEnter, "%!STDPREFIX! SENSOR %!FUNC! FunctionEnter"); +// FUNC SENSOR_FunctionEnter{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(...); +// end_wpp + + +// MACRO: SENSOR_FunctionExit +// +// begin_wpp config +// USEPREFIX (SENSOR_FunctionExit, "%!STDPREFIX! SENSOR %!FUNC! FunctionExit: %!STATUS!", __status); +// FUNC SENSOR_FunctionExit{LEVEL=TRACE_LEVEL_VERBOSE,FLAGS=EntryExit}(SENSOREXIT); +// end_wpp +#define WPP_LEVEL_FLAGS_SENSOREXIT_ENABLED(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_ENABLED(LEVEL, FLAGS) +#define WPP_LEVEL_FLAGS_SENSOREXIT_LOGGER(LEVEL, FLAGS, status) WPP_LEVEL_FLAGS_LOGGER(LEVEL, FLAGS) + +#define WPP_LEVEL_FLAGS_SENSOREXIT_PRE(LEVEL, FLAGS, status) { \ + NTSTATUS __status = status; +#define WPP_LEVEL_FLAGS_SENSOREXIT_POST(LEVEL, FLAGS, status) /*TraceMessage()*/; \ + } + + + +// WPP Recorder ------------------------------------------------------------------------------------------- +// +// The following two macros are required to enable WPP Recorder functionality for clients of the Sensor Class Extension +// +#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_FILTER(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_FILTER(LEVEL, FLAGS) +#define WPP_RECORDER_LEVEL_FLAGS_SENSOREXIT_ARGS(LEVEL, FLAGS, status) WPP_RECORDER_LEVEL_FLAGS_ARGS(LEVEL, FLAGS) + + +#ifdef __cplusplus +} +#endif + + diff --git a/sensors/Fusion/client.cpp b/sensors/Fusion/client.cpp new file mode 100644 index 00000000..686b4197 --- /dev/null +++ b/sensors/Fusion/client.cpp @@ -0,0 +1,789 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved. +// +//Abstract: +// +// This module contains the implementation of driver callback function +// from clx to FusionSensor. +// +//Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Device.h" +#include "HardwareSimulator.h" + +#include +#include + +#include "Client.tmh" + +// This routine is called by worker thread to read a single sample, compare threshold +// and push it back to CLX. It simulates hardware thresholding by only generating data +// when the change of data is greater than threshold. +NTSTATUS +FusionSensorDevice::GetData( +) +{ + // TODO: Remove the HardwareSimulator code in your final driver. The HardwareSimulator is only used for the purpose of demonstrating how sensor driver samples work. + PHardwareSimulator pSimulator = GetHardwareSimulatorContextFromInstance(m_SimulatorInstance); + BOOLEAN DataReady = FALSE; + NTSTATUS Status = STATUS_SUCCESS; + FusionSensorSample Sample = {}; + + SENSOR_FunctionEnter(); + + if (nullptr == pSimulator) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetHardwareSimulatorContextFromInstance failed %!STATUS!", Status); + goto Exit; + } + + // TODO: In this case, we are calling into the HardwareSimulator code to get some simulated data. + // In a real driver (which either communicates with real hardware or some other drivers), this call should be replaced by some + // logic to get data comming from the hardware/other drivers. The "Sample" variable is expected to contain actual data from here on. + Status = pSimulator->GetSample(&Sample); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! GetSample failed %!STATUS!", Status); + goto Exit; + } + + if (FALSE != m_FirstSample) + { + Status = GetPerformanceTime(&m_StartTime); + if (!NT_SUCCESS(Status)) + { + m_StartTime = 0; + TraceError("FUS %!FUNC! GetPerformanceTime failed %!STATUS!", Status); + } + + m_SampleCount = 0; + + DataReady = TRUE; + } + else + { + // Compare the change of data to threshold, and only push the data back to + // clx if the change exceeds threshold. + + CQUATERNION Quaternion = Sample.Quaternion; + FLOAT RotationAngle = Quaternion.ToAngleAxis(nullptr) * RadToDegRatio; + + CQUATERNION LastQuaternion = m_LastSample.Quaternion; + FLOAT LastRotationAngle = LastQuaternion.ToAngleAxis(nullptr) * RadToDegRatio; + + TraceData("FUS %!FUNC! Rotation Angle: new=%f, old=%f", RotationAngle, LastRotationAngle); + + if ((abs(RotationAngle - LastRotationAngle) >= m_CachedThresholds.RotationAngle)) + { + DataReady = TRUE; + } + } + + if (FALSE != DataReady) + { + // update last sample + m_LastSample.Quaternion = Sample.Quaternion; + m_LastSample.Accuracy = Sample.Accuracy; + m_LastSample.DeclinationAngle = Sample.DeclinationAngle; + + // push to clx + InitPropVariantFromFileTime(&m_LastSample.Timestamp, &(m_pData->List[FUSIONSENSOR_DATA_TIMESTAMP].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.W, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_W].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.X, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_X].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.Y, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_Y].Value)); + InitPropVariantFromFloat(m_LastSample.Quaternion.Z, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_Z].Value)); + InitPropVariantFromUInt32(m_LastSample.Accuracy, &(m_pData->List[FUSIONSENSOR_DATA_ACCURACY].Value)); + InitPropVariantFromFloat(m_LastSample.DeclinationAngle, &(m_pData->List[FUSIONSENSOR_DATA_DECLINATION_ANGLE].Value)); + + + SensorsCxSensorDataReady(m_SensorInstance, m_pData); + m_FirstSample = FALSE; + } + else + { + Status = STATUS_DATA_NOT_ACCEPTED; + TraceInformation("FUS %!FUNC! Data did NOT meet the threshold"); + } + + SENSOR_FunctionExit(Status); + +Exit: + return Status; +} + + + +// This callback is called when interval wait time has expired and driver is ready +// to collect new sample. The callback reads current value, compare value to threshold, +// pushes it up to CLX framework, and schedule next wake up time. +VOID +FusionSensorDevice::OnTimerExpire( + _In_ WDFTIMER Timer // WDF timer object + ) +{ + PFusionSensorDevice pDevice = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + pDevice = GetFusionSensorContextFromSensorInstance(WdfTimerGetParentObject(Timer)); + if (nullptr == pDevice) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetFusionSensorContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // Get data and push to clx + WdfWaitLockAcquire(pDevice->m_Lock, NULL); + Status = pDevice->GetData(); + if (!NT_SUCCESS(Status) && Status != STATUS_DATA_NOT_ACCEPTED) + { + TraceError("FUS %!FUNC! GetData Failed %!STATUS!", Status); + } + WdfWaitLockRelease(pDevice->m_Lock); + + // Schedule next wake up time + if (FALSE != pDevice->m_PoweredOn && + FALSE != pDevice->m_Started) + { + LONGLONG WaitTimeHundredNanoseconds = 0; // in unit of 100ns + + if (0 == pDevice->m_StartTime) + { + // in case we fail to get sensor start time, use static wait time + WaitTimeHundredNanoseconds = WDF_REL_TIMEOUT_IN_MS(pDevice->m_Interval); + } + else + { + ULONG CurrentTimeMs = 0; + + // dynamically calculate wait time to avoid jitter + Status = GetPerformanceTime (&CurrentTimeMs); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! GetPerformanceTime %!STATUS!", Status); + WaitTimeHundredNanoseconds = WDF_REL_TIMEOUT_IN_MS(pDevice->m_Interval); + } + else + { + pDevice->m_SampleCount++; + if (CurrentTimeMs > (pDevice->m_StartTime + (pDevice->m_Interval * (pDevice->m_SampleCount + 1)))) + { + // If we skipped two or more beats, reschedule the timer with a zero due time to catch up on missing samples + WaitTimeHundredNanoseconds = 0; + } + else + { + WaitTimeHundredNanoseconds = (pDevice->m_StartTime + + (pDevice->m_Interval * (pDevice->m_SampleCount + 1))) - CurrentTimeMs; + } + WaitTimeHundredNanoseconds = WDF_REL_TIMEOUT_IN_MS(WaitTimeHundredNanoseconds); + } + } + WdfTimerStart(pDevice->m_Timer, WaitTimeHundredNanoseconds); + } + +Exit: + + SENSOR_FunctionExit(Status); +} + + + +// Called by Sensor CLX to begin continuously sampling the sensor. +NTSTATUS +FusionSensorDevice::OnStart( + _In_ SENSOROBJECT SensorInstance // Sensor device object + ) +{ + PHardwareSimulator pSimulator = nullptr; + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Sensor(0x%p) parameter is invalid. Failed %!STATUS!", SensorInstance, Status); + goto Exit; + } + + // Get the simulator context + pSimulator = GetHardwareSimulatorContextFromInstance(pDevice->m_SimulatorInstance); + if (nullptr == pSimulator) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetHardwareSimulatorContextFromInstance failed %!STATUS!", Status); + } + + if (NT_SUCCESS(Status)) + { + // Start the simulator + pSimulator->Start(); + + pDevice->m_FirstSample = TRUE; + + // Start polling + + pDevice->m_Started = TRUE; + + InitPropVariantFromUInt32(SensorState_Active, + &(pDevice->m_pProperties->List[SENSOR_PROPERTY_STATE].Value)); + + // Start the sample polling timer. + // + // Note: The polling timer is configured to allow for the first sample to be reported immediately. + // Some hardware may want to delay the first sample report a little to account for hardware start time. + WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(FusionSensor_Default_MinDataInterval_Ms)); + } +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +// Called by Sensor CLX to stop continuously sampling the sensor. +NTSTATUS +FusionSensorDevice::OnStop( + _In_ SENSOROBJECT SensorInstance // Sensor device object + ) +{ + PHardwareSimulator pSimulator = nullptr; + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Sensor(0x%p) parameter is invalid. Failed %!STATUS!", SensorInstance, Status); + goto Exit; + } + + // Stop polling + pDevice->m_Started = FALSE; + + // Waiting for the callback to complete, then stopping the timer + WdfTimerStop(pDevice->m_Timer, TRUE); + + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_PROPERTY_STATE].Value)); + + // Stop the simulator + pSimulator = GetHardwareSimulatorContextFromInstance(pDevice->m_SimulatorInstance); + if (nullptr == pSimulator) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetHardwareSimulatorContextFromInstance failed %!STATUS!", Status); + goto Exit; + } + + pSimulator->Stop(); + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + +// Called by Sensor CLX to get supported data fields. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +NTSTATUS +FusionSensorDevice::OnGetSupportedDataFields( + _In_ SENSOROBJECT SensorInstance, // Sensor device object + _Inout_opt_ PSENSOR_PROPERTY_LIST pFields, // Pointer to a list of supported properties + _Out_ PULONG pSize // Number of bytes for the list of supported properties + ) +{ + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (nullptr == pFields) + { + // Just return size + *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; + } + else + { + if (pFields->AllocatedSizeInBytes < pDevice->m_pSupportedDataFields->AllocatedSizeInBytes) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out data + Status = PropertiesListCopy(pFields, pDevice->m_pSupportedDataFields); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropertiesListCopy failed %!STATUS!", Status); + goto Exit; + } + + *pSize = pDevice->m_pSupportedDataFields->AllocatedSizeInBytes; + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +// Called by Sensor CLX to get sensor properties. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +NTSTATUS +FusionSensorDevice::OnGetProperties( + _In_ SENSOROBJECT SensorInstance, // Sensor device object + _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, // Pointer to a list of sensor properties + _Out_ PULONG pSize // Number of bytes for the list of sensor properties + ) +{ + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (nullptr == pProperties) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); + } + else + { + if (pProperties->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pProperties)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall(pProperties, pDevice->m_pProperties); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pProperties); + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + +// Called by Sensor CLX to get data field properties. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +NTSTATUS +FusionSensorDevice::OnGetDataFieldProperties( + _In_ SENSOROBJECT SensorInstance, // Sensor device object + _In_ const PROPERTYKEY *DataField, // Pointer to the propertykey of requested property + _Inout_opt_ PSENSOR_COLLECTION_LIST pProperties, // Pointer to a list of sensor properties + _Out_ PULONG pSize // Number of bytes for the list of sensor properties + ) +{ + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize || nullptr == DataField) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + + if ((*DataField == PKEY_SensorData_LinearAccelerationX_Gs) || + (*DataField == PKEY_SensorData_LinearAccelerationY_Gs) || + (*DataField == PKEY_SensorData_LinearAccelerationZ_Gs)) + { + // Linear Acceleration + if (nullptr == pProperties) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pAccDataFieldProperties); + } + else + { + if (pProperties->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pAccDataFieldProperties)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall(pProperties, pDevice->m_pAccDataFieldProperties); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pAccDataFieldProperties); + } + } + else if ((*DataField == PKEY_SensorData_CorrectedAngularVelocityX_DegreesPerSecond) || + (*DataField == PKEY_SensorData_CorrectedAngularVelocityY_DegreesPerSecond) || + (*DataField == PKEY_SensorData_CorrectedAngularVelocityZ_DegreesPerSecond)) + { + // Rotation Rate + if (nullptr == pProperties) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pGyrDataFieldProperties); + } + else + { + if (pProperties->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pGyrDataFieldProperties)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall(pProperties, pDevice->m_pGyrDataFieldProperties); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pGyrDataFieldProperties); + } + } + else + { + Status = STATUS_NOT_SUPPORTED; + TraceError("FUS %!FUNC! Fusion sensor does NOT have properties for this data field. Failed %!STATUS!", Status); + goto Exit; + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + SENSOR_FunctionExit(Status); + return Status; +} + + + +// Called by Sensor CLX to get sampling rate of the sensor. +NTSTATUS +FusionSensorDevice::OnGetDataInterval( + _In_ SENSOROBJECT SensorInstance, // Sensor device object + _Out_ PULONG DataRateMs // Sampling rate in ms + ) +{ + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Sensor(0x%p) parameter is invalid. Failed %!STATUS!", SensorInstance, Status); + goto Exit; + } + + if (nullptr == DataRateMs) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! DataRateMs(0x%p) parameter is invalid. Failed %!STATUS!", DataRateMs, Status); + goto Exit; + } + + *DataRateMs = pDevice->m_Interval; + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +// Called by Sensor CLX to set sampling rate of the sensor. +NTSTATUS +FusionSensorDevice::OnSetDataInterval( + _In_ SENSOROBJECT SensorInstance, // Sensor device object + _In_ ULONG DataRateMs // Sampling rate in ms + ) +{ + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Sensor(0x%p) parameter is invalid. Failed %!STATUS!", SensorInstance, Status); + goto Exit; + } + + if (FusionSensor_Default_MinDataInterval_Ms > DataRateMs) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! DataRateMs(%d) parameter is smaller than the minimum data interval. Failed %!STATUS!", DataRateMs, Status); + goto Exit; + } + + pDevice->m_Interval = DataRateMs; + + // reschedule sample to return as soon as possible if it's started + if (FALSE != pDevice->m_Started) + { + pDevice->m_Started = FALSE; + WdfTimerStop(pDevice->m_Timer, TRUE); + + pDevice->m_Started = TRUE; + pDevice->m_FirstSample = TRUE; + WdfTimerStart(pDevice->m_Timer, WDF_REL_TIMEOUT_IN_MS(FusionSensor_Default_MinDataInterval_Ms)); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +// Called by Sensor CLX to get data thresholds. The typical usage is to call +// this function once with buffer pointer as NULL to acquire the required size +// for the buffer, allocate buffer, then call the function again to retrieve +// sensor information. +NTSTATUS +FusionSensorDevice::OnGetDataThresholds( + _In_ SENSOROBJECT SensorInstance, // Sensor device object + _Inout_opt_ PSENSOR_COLLECTION_LIST pThresholds, // Pointer to a list of sensor thresholds + _Out_ PULONG pSize // Number of bytes for the list of sensor thresholds + ) +{ + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == pDevice || nullptr == pSize) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Invalid parameters! %!STATUS!", Status); + goto Exit; + } + + if (nullptr == pThresholds) + { + // Just return size + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); + } + else + { + if (pThresholds->AllocatedSizeInBytes < + CollectionsListGetMarshalledSize(pDevice->m_pThresholds)) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! Buffer is too small. Failed %!STATUS!", Status); + goto Exit; + } + + // Fill out all data + Status = CollectionsListCopyAndMarshall(pThresholds, pDevice->m_pThresholds); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! CollectionsListCopyAndMarshall failed %!STATUS!", Status); + goto Exit; + } + + *pSize = CollectionsListGetMarshalledSize(pDevice->m_pThresholds); + } + +Exit: + if (!NT_SUCCESS(Status)) + { + *pSize = 0; + } + + SENSOR_FunctionExit(Status); + + return Status; +} + + + +// Called by Sensor CLX to set data thresholds. +NTSTATUS +FusionSensorDevice::OnSetDataThresholds( + _In_ SENSOROBJECT SensorInstance, // Sensor device object + _In_ PSENSOR_COLLECTION_LIST pThresholds // Pointer to a list of sensor thresholds + ) +{ + ULONG Element; + BOOLEAN IsLocked = FALSE; + PFusionSensorDevice pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (pDevice == nullptr) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! Sensor(0x%p) parameter is invalid. Failed %!STATUS!", SensorInstance, Status); + goto Exit; + } + + WdfWaitLockAcquire(pDevice->m_Lock, NULL); + IsLocked = TRUE; + + for (Element = 0; Element < pThresholds->Count; Element++) + { + Status = PropKeyFindKeySetPropVariant(pDevice->m_pThresholds, + &(pThresholds->List[Element].Key), + TRUE, + &(pThresholds->List[Element].Value)); + if (!NT_SUCCESS(Status)) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! FusionSensor driver does NOT have threshold for this data field. Failed %!STATUS!", Status); + goto Exit; + } + } + + // Get data thresholds + Status = PropKeyFindKeyGetFloat(pDevice->m_pThresholds, + &PKEY_SensorData_RotationAngle_Degrees, + &(pDevice->m_CachedThresholds.RotationAngle)); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropKeyFindKeyGetFloat for rotation angle failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(pDevice->m_pThresholds, + &PKEY_SensorData_LinearAccelerationX_Gs, + &(pDevice->m_CachedThresholds.LinearAcceleration.X)); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropKeyFindKeyGetFloat for linear acceleration X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(pDevice->m_pThresholds, + &PKEY_SensorData_LinearAccelerationY_Gs, + &(pDevice->m_CachedThresholds.LinearAcceleration.Y)); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropKeyFindKeyGetFloat for linear acceleration Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(pDevice->m_pThresholds, + &PKEY_SensorData_LinearAccelerationZ_Gs, + &(pDevice->m_CachedThresholds.LinearAcceleration.Z)); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropKeyFindKeyGetFloat for linear acceleration Z failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(pDevice->m_pThresholds, + &PKEY_SensorData_CorrectedAngularVelocityX_DegreesPerSecond, + &(pDevice->m_CachedThresholds.RotationRate.X)); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropKeyFindKeyGetFloat for rotation rate X failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(pDevice->m_pThresholds, + &PKEY_SensorData_CorrectedAngularVelocityY_DegreesPerSecond, + &(pDevice->m_CachedThresholds.RotationRate.Y)); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropKeyFindKeyGetFloat for rotation rate Y failed! %!STATUS!", Status); + goto Exit; + } + + Status = PropKeyFindKeyGetFloat(pDevice->m_pThresholds, + &PKEY_SensorData_CorrectedAngularVelocityZ_DegreesPerSecond, + &(pDevice->m_CachedThresholds.RotationRate.Z)); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! PropKeyFindKeyGetFloat for rotation rate Z failed! %!STATUS!", Status); + goto Exit; + } + +Exit: + if (FALSE != IsLocked) + { + WdfWaitLockRelease(pDevice->m_Lock); + IsLocked = FALSE; + } + SENSOR_FunctionExit(Status); + return Status; +} + + +// Called by Sensor CLX to handle IOCTLs that clx does not support +NTSTATUS +FusionSensorDevice::OnIoControl( + _In_ SENSOROBJECT /*SensorInstance*/, // WDF queue object + _In_ WDFREQUEST /*Request*/, // WDF request object + _In_ size_t /*OutputBufferLength*/, // number of bytes to retrieve from output buffer + _In_ size_t /*InputBufferLength*/, // number of bytes to retrieve from input buffer + _In_ ULONG /*IoControlCode*/ // IOCTL control code + ) +{ + NTSTATUS Status = STATUS_NOT_SUPPORTED; + + SENSOR_FunctionEnter(); + + SENSOR_FunctionExit(Status); + return Status; +} \ No newline at end of file diff --git a/sensors/Fusion/device.cpp b/sensors/Fusion/device.cpp new file mode 100644 index 00000000..0ac6e042 --- /dev/null +++ b/sensors/Fusion/device.cpp @@ -0,0 +1,729 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved. +// +//Abstract: +// +// This module contains the implementation of WDF callback functions +// for FusionSensor driver. +// +//Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Device.h" +#include "HardwareSimulator.h" + +#include "Device.tmh" + +// FusionSensor Unique ID +// {997335D7-A71C-4C89-9D95-58EAEF917C6A} +// +// TODO: The unique ID below must be set per sensor. A different GUID must be provided for each sensor. Please generate a new GUID. +DEFINE_GUID(GUID_FusionSensorDevice_UniqueID, + 0x997335d7, 0xa71c, 0x4c89, 0x9d, 0x95, 0x58, 0xea, 0xef, 0x91, 0x7c, 0x6a); + + +// This routine initializes the sensor to its default properties +NTSTATUS +FusionSensorDevice::Initialize( + _In_ WDFDEVICE Device, // WDFDEVICE object + _In_ SENSOROBJECT SensorInstance // SENSOROBJECT for each sensor instance + ) +{ + ULONG Size = 0; + WDF_OBJECT_ATTRIBUTES MemoryAttributes; + WDFMEMORY MemoryHandle = NULL; + FILETIME Time = {}; + WDF_OBJECT_ATTRIBUTES TimerAttributes; + WDF_TIMER_CONFIG TimerConfig; + NTSTATUS Status = STATUS_SUCCESS; + PHardwareSimulator pSimulator = nullptr; + + SENSOR_FunctionEnter(); + + // Store device and instance + m_FxDevice = Device; + m_SensorInstance = SensorInstance; + m_Started = FALSE; + + // TODO: Remove the HardwareSimulator code in your final driver. The HardwareSimulator is only used for the purpose of demonstrating how sensor driver samples work. + // Initialize the FusionSensor simulator + Status = HardwareSimulator::Initialize(Device, &m_SimulatorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! HardwareSimulator::Initialize failed %!STATUS!", Status); + goto Exit; + } + + pSimulator = GetHardwareSimulatorContextFromInstance(m_SimulatorInstance); + if (nullptr == pSimulator) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetHardwareSimulatorContextFromInstance failed %!STATUS!", Status); + goto Exit; + } + + // Create Lock + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! WdfWaitLockCreate failed %!STATUS!", Status); + goto Exit; + } + + // Create timer object for polling sensor samples + WDF_TIMER_CONFIG_INIT(&TimerConfig, FusionSensorDevice::OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SensorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + + // + // Sensor Enumeration Properties + // + { + Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ENUMERATION_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSOR_POOL_TAG_FUSIONSENSOR, + Size, + &MemoryHandle, + (PVOID*)&m_pEnumerationProperties); + if (!NT_SUCCESS(Status) || m_pEnumerationProperties == nullptr) + { + TraceError("FUS %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pEnumerationProperties, Size); + m_pEnumerationProperties->Count = SENSOR_ENUMERATION_PROPERTIES_COUNT; + + m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Key = DEVPKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Orientation, + &(m_pEnumerationProperties->List[SENSOR_TYPE_GUID].Value)); + + m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Key = DEVPKEY_Sensor_Manufacturer; + InitPropVariantFromString(L"TODO-Set-Manufacturer", + &(m_pEnumerationProperties->List[SENSOR_MANUFACTURER].Value)); + + m_pEnumerationProperties->List[SENSOR_MODEL].Key = DEVPKEY_Sensor_Model; + InitPropVariantFromString(L"Sample fusion sensor", + &(m_pEnumerationProperties->List[SENSOR_MODEL].Value)); + + m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Key = DEVPKEY_Sensor_PersistentUniqueId; + InitPropVariantFromCLSID(GUID_FusionSensorDevice_UniqueID, + &(m_pEnumerationProperties->List[SENSOR_PERSISTENT_UNIQUEID].Value)); + + m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Key = DEVPKEY_Sensor_IsPrimary; + InitPropVariantFromBoolean(FALSE, + &(m_pEnumerationProperties->List[SENSOR_ISPRIMARY].Value)); + } + + // + // Supported Data-Fields + // + { + Size = SENSOR_PROPERTY_LIST_SIZE(FUSIONSENSOR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSOR_POOL_TAG_FUSIONSENSOR, + Size, + &MemoryHandle, + (PVOID*)&m_pSupportedDataFields); + if (!NT_SUCCESS(Status) || m_pSupportedDataFields == nullptr) + { + TraceError("FUS %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_PROPERTY_LIST_INIT(m_pSupportedDataFields, Size); + m_pSupportedDataFields->Count = FUSIONSENSOR_DATA_COUNT; + + m_pSupportedDataFields->List[FUSIONSENSOR_DATA_TIMESTAMP] = PKEY_SensorData_Timestamp; + m_pSupportedDataFields->List[FUSIONSENSOR_DATA_QUATERNION_W] = PKEY_SensorData_QuaternionW; + m_pSupportedDataFields->List[FUSIONSENSOR_DATA_QUATERNION_X] = PKEY_SensorData_QuaternionX; + m_pSupportedDataFields->List[FUSIONSENSOR_DATA_QUATERNION_Y] = PKEY_SensorData_QuaternionY; + m_pSupportedDataFields->List[FUSIONSENSOR_DATA_QUATERNION_Z] = PKEY_SensorData_QuaternionZ; + m_pSupportedDataFields->List[FUSIONSENSOR_DATA_ACCURACY] = PKEY_SensorData_MagnetometerAccuracy; + m_pSupportedDataFields->List[FUSIONSENSOR_DATA_DECLINATION_ANGLE] = PKEY_SensorData_DeclinationAngle_Degrees; + } + + // + // Data + // + { + Size = SENSOR_COLLECTION_LIST_SIZE(FUSIONSENSOR_DATA_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSOR_POOL_TAG_FUSIONSENSOR, + Size, + &MemoryHandle, + (PVOID*)&m_pData); + if (!NT_SUCCESS(Status) || m_pData == nullptr) + { + TraceError("FUS %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pData, Size); + m_pData->Count = FUSIONSENSOR_DATA_COUNT; + + m_pData->List[FUSIONSENSOR_DATA_TIMESTAMP].Key = PKEY_SensorData_Timestamp; + GetSystemTimePreciseAsFileTime(&Time); + InitPropVariantFromFileTime(&Time, &(m_pData->List[FUSIONSENSOR_DATA_TIMESTAMP].Value)); + + m_pData->List[FUSIONSENSOR_DATA_QUATERNION_W].Key = PKEY_SensorData_QuaternionW; + InitPropVariantFromFloat(0.0, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_W].Value)); + + m_pData->List[FUSIONSENSOR_DATA_QUATERNION_X].Key = PKEY_SensorData_QuaternionX; + InitPropVariantFromFloat(0.0, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_X].Value)); + + m_pData->List[FUSIONSENSOR_DATA_QUATERNION_Y].Key = PKEY_SensorData_QuaternionY; + InitPropVariantFromFloat(0.0, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_Y].Value)); + + m_pData->List[FUSIONSENSOR_DATA_QUATERNION_Z].Key = PKEY_SensorData_QuaternionZ; + InitPropVariantFromFloat(0.0, &(m_pData->List[FUSIONSENSOR_DATA_QUATERNION_Z].Value)); + + m_pData->List[FUSIONSENSOR_DATA_ACCURACY].Key = PKEY_SensorData_MagnetometerAccuracy; + InitPropVariantFromUInt32(Unknown, &(m_pData->List[FUSIONSENSOR_DATA_ACCURACY].Value)); + + // Declination angle is optional, it will be computed by the system if not present. + m_pData->List[FUSIONSENSOR_DATA_DECLINATION_ANGLE].Key = PKEY_SensorData_DeclinationAngle_Degrees; + InitPropVariantFromFloat(0.0, &(m_pData->List[FUSIONSENSOR_DATA_DECLINATION_ANGLE].Value)); + } + + // + // Sensor Properties + // + { + m_Interval = FusionSensor_Default_DataInterval; + + Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_PROPERTIES_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSOR_POOL_TAG_FUSIONSENSOR, + Size, + &MemoryHandle, + (PVOID*)&m_pProperties); + if (!NT_SUCCESS(Status) || m_pProperties == nullptr) + { + TraceError("FUS %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pProperties, Size); + m_pProperties->Count = SENSOR_PROPERTIES_COUNT; + + m_pProperties->List[SENSOR_PROPERTY_STATE].Key = PKEY_Sensor_State; + InitPropVariantFromUInt32(SensorState_Initializing, + &(m_pProperties->List[SENSOR_PROPERTY_STATE].Value)); + + m_pProperties->List[SENSOR_PROPERTY_MIN_INTERVAL].Key = PKEY_Sensor_MinimumDataInterval_Ms; + InitPropVariantFromUInt32(FusionSensor_Default_MinDataInterval_Ms, + &(m_pProperties->List[SENSOR_PROPERTY_MIN_INTERVAL].Value)); + + m_pProperties->List[SENSOR_PROPERTY_MAX_DATAFIELDSIZE].Key = PKEY_Sensor_MaximumDataFieldSize_Bytes; + InitPropVariantFromUInt32(CollectionsListGetMarshalledSize(m_pData), + &(m_pProperties->List[SENSOR_PROPERTY_MAX_DATAFIELDSIZE].Value)); + + m_pProperties->List[SENSOR_PROPERTY_SENSOR_TYPE].Key = PKEY_Sensor_Type; + InitPropVariantFromCLSID(GUID_SensorType_Orientation, + &(m_pProperties->List[SENSOR_PROPERTY_SENSOR_TYPE].Value)); + + m_pProperties->List[SENSOR_PROPERTY_USE_GYRO].Key = PKEY_OrientationSensor_GyroscopeUsed; + InitPropVariantFromBoolean(FALSE, &(m_pProperties->List[SENSOR_PROPERTY_USE_GYRO].Value)); + } + + // + // Accelerometer related data field properties + // + { + Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_ACC_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSOR_POOL_TAG_FUSIONSENSOR, + Size, + &MemoryHandle, + (PVOID*)&m_pAccDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pAccDataFieldProperties == nullptr) + { + TraceError("FUS %!FUNC! Fusion sensor WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pAccDataFieldProperties, Size); + m_pAccDataFieldProperties->Count = SENSOR_ACC_DATA_FIELD_PROPERTY_COUNT; + + m_pAccDataFieldProperties->List[SENSOR_ACC_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat((float)AccFakeDevice_Axis_Resolution, + &(m_pAccDataFieldProperties->List[SENSOR_ACC_RESOLUTION].Value)); + + m_pAccDataFieldProperties->List[SENSOR_ACC_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(AccFakeDevice_Axis_Minimum, + &(m_pAccDataFieldProperties->List[SENSOR_ACC_MIN_RANGE].Value)); + + m_pAccDataFieldProperties->List[SENSOR_ACC_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(AccFakeDevice_Axis_Maximum, + &(m_pAccDataFieldProperties->List[SENSOR_ACC_MAX_RANGE].Value)); + + } + + // + // Gyroscope related data field properties + // + { + Size = SENSOR_COLLECTION_LIST_SIZE(SENSOR_GYR_DATA_FIELD_PROPERTY_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSOR_POOL_TAG_FUSIONSENSOR, + Size, + &MemoryHandle, + (PVOID*)&m_pGyrDataFieldProperties); + if (!NT_SUCCESS(Status) || m_pGyrDataFieldProperties == nullptr) + { + TraceError("FUS %!FUNC! Fusion sensor WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pGyrDataFieldProperties, Size); + m_pGyrDataFieldProperties->Count = SENSOR_GYR_DATA_FIELD_PROPERTY_COUNT; + + m_pGyrDataFieldProperties->List[SENSOR_GYR_RESOLUTION].Key = PKEY_SensorDataField_Resolution; + InitPropVariantFromFloat(GyrFakeDevice_Resolution_DegreesPerSecond, + &(m_pGyrDataFieldProperties->List[SENSOR_GYR_RESOLUTION].Value)); + + m_pGyrDataFieldProperties->List[SENSOR_GYR_MIN_RANGE].Key = PKEY_SensorDataField_RangeMinimum; + InitPropVariantFromFloat(GyrFakeDevice_Minimum_DegreesPerSecond, + &(m_pGyrDataFieldProperties->List[SENSOR_GYR_MIN_RANGE].Value)); + + m_pGyrDataFieldProperties->List[SENSOR_GYR_MAX_RANGE].Key = PKEY_SensorDataField_RangeMaximum; + InitPropVariantFromFloat(GyrFakeDevice_Maximum_DegreesPerSecond, + &(m_pGyrDataFieldProperties->List[SENSOR_GYR_MAX_RANGE].Value)); + } + + // + // Set default threshold + // + { + Size = SENSOR_COLLECTION_LIST_SIZE(FUSIONSENSOR_THRESHOLD_COUNT); + + MemoryHandle = NULL; + WDF_OBJECT_ATTRIBUTES_INIT(&MemoryAttributes); + MemoryAttributes.ParentObject = SensorInstance; + Status = WdfMemoryCreate(&MemoryAttributes, + PagedPool, + SENSOR_POOL_TAG_FUSIONSENSOR, + Size, + &MemoryHandle, + (PVOID*)&m_pThresholds); + if (!NT_SUCCESS(Status) || m_pThresholds == nullptr) + { + TraceError("FUS %!FUNC! WdfMemoryCreate failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_COLLECTION_LIST_INIT(m_pThresholds, Size); + m_pThresholds->Count = FUSIONSENSOR_THRESHOLD_COUNT; + + m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_ANGLE].Key = PKEY_SensorData_RotationAngle_Degrees; + InitPropVariantFromFloat(0.0, &(m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_ANGLE].Value)); + + m_pThresholds->List[FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_X].Key = PKEY_SensorData_LinearAccelerationX_Gs; + InitPropVariantFromFloat(0.0, &(m_pThresholds->List[FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_X].Value)); + + m_pThresholds->List[FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_Y].Key = PKEY_SensorData_LinearAccelerationY_Gs; + InitPropVariantFromFloat(0.0, &(m_pThresholds->List[FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_Y].Value)); + + m_pThresholds->List[FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_Z].Key = PKEY_SensorData_LinearAccelerationZ_Gs; + InitPropVariantFromFloat(0.0, &(m_pThresholds->List[FUSIONSENSOR_THRESHOLD_LINEAR_ACCELERATION_Z].Value)); + + m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_RATE_X].Key = PKEY_SensorData_CorrectedAngularVelocityX_DegreesPerSecond; + InitPropVariantFromFloat(0.0, &(m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_RATE_X].Value)); + + m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_RATE_Y].Key = PKEY_SensorData_CorrectedAngularVelocityY_DegreesPerSecond; + InitPropVariantFromFloat(0.0, &(m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_RATE_Y].Value)); + + m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_RATE_Z].Key = PKEY_SensorData_CorrectedAngularVelocityZ_DegreesPerSecond; + InitPropVariantFromFloat(0.0, &(m_pThresholds->List[FUSIONSENSOR_THRESHOLD_ROTATION_RATE_Z].Value)); + + ZeroMemory(&m_CachedThresholds, sizeof(m_CachedThresholds)); + } + + ZeroMemory(&m_LastSample, sizeof(m_LastSample)); + + // Set default threshold + m_FirstSample = TRUE; + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +// This routine is the AddDevice entry point for the FusionSensor client +// driver. This routine is called by the framework in response to AddDevice +// call from the PnP manager. It will create and initialize the device object +// to represent a new instance of the sensor client. +NTSTATUS +FusionSensorDevice::OnDeviceAdd( + _In_ WDFDRIVER /*Driver*/, // Supplies a handle to the driver object created in DriverEntry + _Inout_ PWDFDEVICE_INIT pDeviceInit // Supplies a pointer to a framework-allocated WDFDEVICE_INIT structure + ) +{ + WDF_PNPPOWER_EVENT_CALLBACKS Callbacks; + WDFDEVICE Device = nullptr; + WDF_OBJECT_ATTRIBUTES FdoAttributes; + ULONG Flag = 0; + SENSOR_CONTROLLER_CONFIG SensorConfig; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + WDF_OBJECT_ATTRIBUTES_INIT(&FdoAttributes); + + // Initialize FDO attributes and set up file object with sensor extension + Status = SensorsCxDeviceInitConfig(pDeviceInit, &FdoAttributes, Flag); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! SensorsCxDeviceInitConfig failed %!STATUS!", Status); + goto Exit; + } + + // Register the PnP callbacks with the framework. + WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&Callbacks); + Callbacks.EvtDevicePrepareHardware = FusionSensorDevice::OnPrepareHardware; + Callbacks.EvtDeviceReleaseHardware = FusionSensorDevice::OnReleaseHardware; + Callbacks.EvtDeviceD0Entry = FusionSensorDevice::OnD0Entry; + Callbacks.EvtDeviceD0Exit = FusionSensorDevice::OnD0Exit; + + WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &Callbacks); + + // Call the framework to create the device + Status = WdfDeviceCreate(&pDeviceInit, &FdoAttributes, &Device); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! WdfDeviceCreate failed %!STATUS!", Status); + goto Exit; + } + + // Register CLX callback function pointers + SENSOR_CONTROLLER_CONFIG_INIT(&SensorConfig); + SensorConfig.DriverIsPowerPolicyOwner = WdfUseDefault; + + SensorConfig.EvtSensorStart = FusionSensorDevice::OnStart; + SensorConfig.EvtSensorStop = FusionSensorDevice::OnStop; + SensorConfig.EvtSensorGetSupportedDataFields = FusionSensorDevice::OnGetSupportedDataFields; + SensorConfig.EvtSensorGetDataInterval = FusionSensorDevice::OnGetDataInterval; + SensorConfig.EvtSensorSetDataInterval = FusionSensorDevice::OnSetDataInterval; + SensorConfig.EvtSensorGetDataFieldProperties = FusionSensorDevice::OnGetDataFieldProperties; + SensorConfig.EvtSensorGetDataThresholds = FusionSensorDevice::OnGetDataThresholds; + SensorConfig.EvtSensorSetDataThresholds = FusionSensorDevice::OnSetDataThresholds; + SensorConfig.EvtSensorGetProperties = FusionSensorDevice::OnGetProperties; + SensorConfig.EvtSensorDeviceIoControl = FusionSensorDevice::OnIoControl; + + // Set up power capabilities and IO queues + Status = SensorsCxDeviceInitialize(Device, &SensorConfig); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! SensorsCxDeviceInitialize failed %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +// This routine is called by the framework when the PnP manager sends an +// IRP_MN_START_DEVICE request to the driver stack. This routine is +// responsible for performing operations that are necessary to make the +// driver's device operational (for e.g. mapping the hardware resources +// into memory). +NTSTATUS +FusionSensorDevice::OnPrepareHardware( + _In_ WDFDEVICE Device, // Supplies a handle to the framework device object + _In_ WDFCMRESLIST /*ResourcesRaw*/, // Supplies a handle to a collection of framework resource + // objects. This collection identifies the raw (bus-relative) hardware + // resources that have been assigned to the device. + _In_ WDFCMRESLIST /*ResourcesTranslated*/) // Supplies a handle to a collection of framework + // resource objects. This collection identifies the translated + // (system-physical) hardware resources that have been assigned to the + // device. The resources appear from the CPU's point of view. +{ + PFusionSensorDevice pDevice = nullptr; + WDF_OBJECT_ATTRIBUTES SensorAttr = {}; + SENSOR_CONFIG SensorConfig = {}; + SENSOROBJECT SensorInstance = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // Construct sensor instance + + // Create WDFOBJECT for the sensor + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&SensorAttr, FusionSensorDevice); + + // Register sensor instance with clx + + Status = SensorsCxSensorCreate(Device, &SensorAttr, &SensorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! SensorsCxSensorCreate failed %!STATUS!", Status); + goto Exit; + } + + pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + if (nullptr == pDevice) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetFusionSensorContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // Device initialization + + Status = pDevice->Initialize(Device, SensorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! Initialize device object failed %!STATUS!", Status); + goto Exit; + } + + SENSOR_CONFIG_INIT(&SensorConfig); + SensorConfig.pEnumerationList = pDevice->m_pEnumerationProperties; + Status = SensorsCxSensorInitialize(SensorInstance, &SensorConfig); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! SensorsCxSensorInitialize failed %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + + return Status; +} + + + +// This routine is called by the framework when the PnP manager is revoking +// ownership of our resources. This may be in response to either +// IRP_MN_STOP_DEVICE or IRP_MN_REMOVE_DEVICE. This routine is responsible for +// performing cleanup of resources allocated in PrepareHardware callback. +// This callback is invoked before passing the request down to the lower driver. +// This routine will also be invoked by the framework if the prepare hardware +// callback returns a failure. +// +// Argument: +// Device: IN: Supplies a handle to the framework device object +// ResourcesTranslated: IN: Supplies a handle to a collection of framework +// resource objects. This collection identifies the translated +// (system-physical) hardware resources that have been assigned to the +// device. The resources appear from the CPU's point of view. +// +// Return Value: +// NTSTATUS code +//------------------------------------------------------------------------------ +NTSTATUS +FusionSensorDevice::OnReleaseHardware( + _In_ WDFDEVICE Device, // Supplies a handle to the framework device object + _In_ WDFCMRESLIST /*ResourcesTranslated*/) // Supplies a handle to a collection of framework + // resource objects. This collection identifies the translated + // (system-physical) hardware resources that have been assigned to the + // device. The resources appear from the CPU's point of view. +{ + PHardwareSimulator pSimulator = nullptr; + PFusionSensorDevice pDevice = nullptr; + SENSOROBJECT SensorInstance = nullptr; + ULONG SensorInstanceCount = 1; // only expect 1 sensor instance + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // Get sensor instance + Status = SensorsCxDeviceGetSensorList(Device, &SensorInstance, &SensorInstanceCount); + if (!NT_SUCCESS(Status) || + 0 == SensorInstanceCount || + NULL == SensorInstance) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! GetFusionSensorContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // TODO: Remove the HardwareSimulator code in your final driver. The HardwareSimulator is only used for the purpose of demonstrating how sensor driver samples work. + pSimulator = GetHardwareSimulatorContextFromInstance(pDevice->m_SimulatorInstance); + if (nullptr == pSimulator) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetHardwareSimulatorContextFromInstance failed %!STATUS!", Status); + goto Exit; + } + + + // Delete lock + if (NULL != pDevice->m_Lock) + { + WdfObjectDelete(pDevice->m_Lock); + pDevice->m_Lock = NULL; + } + + // Cleanup the FusionSensor simulator + pSimulator->Cleanup(); + + // Delete hardware simulator instance + if (NULL != pDevice->m_SimulatorInstance) + { + WdfObjectDelete(pDevice->m_SimulatorInstance); + pDevice->m_SimulatorInstance = NULL; + } + + // Delete sensor instance + if (NULL != pDevice->m_SensorInstance) + { + WdfObjectDelete(pDevice->m_SensorInstance); + } + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +// This routine is invoked by the framework to program the device to goto +// D0, which is the working state. The framework invokes callback every +// time the hardware needs to be (re-)initialized. This includes after +// IRP_MN_START_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE, +// and IRP_MN_SET_POWER-D0. +NTSTATUS +FusionSensorDevice::OnD0Entry( + _In_ WDFDEVICE Device, // Supplies a handle to the framework device object + _In_ WDF_POWER_DEVICE_STATE /*PreviousState*/) // WDF_POWER_DEVICE_STATE-typed enumerator that identifies + // the device power state that the device was in before this transition to D0 +{ + PFusionSensorDevice pDevice; + SENSOROBJECT SensorInstance = NULL; + ULONG SensorInstanceCount = 1; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // Get sensor instance + Status = SensorsCxDeviceGetSensorList(Device, &SensorInstance, &SensorInstanceCount); + if (!NT_SUCCESS(Status) || + 0 == SensorInstanceCount || + NULL == SensorInstance) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! GetFusionSensorContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // + // Power on sensor + // + pDevice->m_PoweredOn = TRUE; + InitPropVariantFromUInt32(SensorState_Idle, + &(pDevice->m_pProperties->List[SENSOR_PROPERTY_STATE].Value)); + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} + + + +// This routine is invoked by the framework to program the device to go into +// a certain Dx state. The framework invokes callback every the the device is +// leaving the D0 state, which happens when the device is stopped, when it is +// removed, and when it is powered off. +NTSTATUS +FusionSensorDevice::OnD0Exit( + _In_ WDFDEVICE Device, // Supplies a handle to the framework device object + _In_ WDF_POWER_DEVICE_STATE /*TargetState*/) // Supplies the device power state which the device will be put + // in once the callback is complete +{ + PFusionSensorDevice pDevice; + SENSOROBJECT SensorInstance = NULL; + ULONG SensorInstanceCount = 1; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + // Get sensor instance + Status = SensorsCxDeviceGetSensorList(Device, &SensorInstance, &SensorInstanceCount); + if (!NT_SUCCESS(Status) || + 0 == SensorInstanceCount || + NULL == SensorInstance) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! SensorsCxDeviceGetSensorList failed %!STATUS!", Status); + goto Exit; + } + + pDevice = GetFusionSensorContextFromSensorInstance(SensorInstance); + if (nullptr == pDevice) + { + Status = STATUS_INVALID_PARAMETER; + TraceError("FUS %!FUNC! GetFusionSensorContextFromSensorInstance failed %!STATUS!", Status); + goto Exit; + } + + // + // Power on sensor + // + pDevice->m_PoweredOn = FALSE; + +Exit: + SENSOR_FunctionExit(Status); + return Status; +} diff --git a/sensors/Fusion/driver.cpp b/sensors/Fusion/driver.cpp new file mode 100644 index 00000000..1fd117f3 --- /dev/null +++ b/sensors/Fusion/driver.cpp @@ -0,0 +1,76 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved. +// +//Abstract: +// +// This module contains the implementation of entry and exit point of FusionSensor sample driver. +// +//Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "Device.h" +#include "Driver.h" + +#include "Driver.tmh" + + + +// This routine is the driver initialization entry point. +NTSTATUS +DriverEntry( + _In_ PDRIVER_OBJECT DriverObject, // Pointer to the driver object created by the I/O manager + _In_ PUNICODE_STRING RegistryPath // Pointer to the driver specific registry key + ) +{ + WDF_DRIVER_CONFIG DriverConfig; + NTSTATUS Status = STATUS_SUCCESS; + + // Initialize WPP Tracing + WPP_INIT_TRACING(DriverObject, NULL); + + SENSOR_FunctionEnter(); + + DriverConfig.DriverPoolTag = SENSOR_POOL_TAG_FUSIONSENSOR; + + // Initialize the driver configuration structure. + WDF_DRIVER_CONFIG_INIT(&DriverConfig, FusionSensorDevice::OnDeviceAdd); + DriverConfig.EvtDriverUnload = OnDriverUnload; + + // Create a framework driver object to represent our driver. + Status = WdfDriverCreate(DriverObject, + RegistryPath, + WDF_NO_OBJECT_ATTRIBUTES, + &DriverConfig, + WDF_NO_HANDLE); + + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! WdfDriverCreate failed: %!STATUS!", Status); + goto Exit; + } + +Exit: + SENSOR_FunctionExit(Status); + + return Status; +} + + + +// This routine is called when the driver unloads. +VOID +OnDriverUnload( + _In_ WDFDRIVER Driver // Driver object + ) +{ + SENSOR_FunctionEnter(); + + SENSOR_FunctionExit(STATUS_SUCCESS); + + // WPP_CLEANUP doesn't actually use the Driver parameter + // So we need to set it as unreferenced. + UNREFERENCED_PARAMETER(Driver); + WPP_CLEANUP(WdfDriverWdmGetDriverObject(Driver)); + + return; +} \ No newline at end of file diff --git a/sensors/Fusion/hardwaresimulator.cpp b/sensors/Fusion/hardwaresimulator.cpp new file mode 100644 index 00000000..b498defb --- /dev/null +++ b/sensors/Fusion/hardwaresimulator.cpp @@ -0,0 +1,277 @@ +//Copyright (C) Microsoft Corporation, All Rights Reserved. +// +//Abstract: +// +// This module contains the implementation of the FusionSensor sample driver +// hardware simulator. +// +//Environment: +// +// Windows User-Mode Driver Framework (UMDF) + +#include "HardwareSimulator.h" + +#include "HardwareSimulator.tmh" + +#include "Device.h" + +// Simulated FusionSensor data +// The simulation data represent the FusionSensor data for a user walking and running at different paces +// Since the simulator is designed to report a sample every second, +// each line in the table represents 1 second of data +const FusionSensorSample SimulatorData[] = { +// 1: Timestamp +// 2: Quaternion; +// 3: Accuracy; +// 4: DeclinationAngle; +// +// 1 | 2 | 3 | 4 | + { {},{ 0.6118738f, 0.1390667f, 0.136009f, 0.7658455f }, MagnetometerAccuracy_Unknown, 17.1f }, + { {},{ 0.6174188f, 0.1399692f, 0.1338535f, 0.7625271f }, MagnetometerAccuracy_Approximate, 17.1f }, + { {},{ 0.6028171f, 0.1740682f, 0.1788765f, 0.7570137f }, MagnetometerAccuracy_High, 17.1f }, + { {},{ 0.4333673f, 0.05344541f, 0.06945555f, 0.8965058f }, MagnetometerAccuracy_High, 17.1f }, +}; + +HardwareSimulator::HardwareSimulator() : + m_HasReset(TRUE), + m_Index(0), + m_Lock(NULL), + m_State(SimulatorState_NotInitialized), + m_SimulatorInstance(NULL), + m_Timer(NULL) +{ +} + +HardwareSimulator::~HardwareSimulator() +{ +} + +// This static routine performs simulator initialization. The routine creates a +// timer object that periodically updates the m_Index location +NTSTATUS +HardwareSimulator::Initialize( + _In_ WDFDEVICE Device, // WDF device representing the sensor + _Out_ WDFOBJECT *SimulatorInstance) // Instance of the WDF object for the simulator +{ + PHardwareSimulator pSimulator = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + WDF_OBJECT_ATTRIBUTES HardwareSimulatorAttributes = {}; + + SENSOR_FunctionEnter(); + + // Create WDFOBJECT for the hardware simulator + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&HardwareSimulatorAttributes, HardwareSimulator); + HardwareSimulatorAttributes.ParentObject = Device; + + Status = WdfObjectCreate(&HardwareSimulatorAttributes, SimulatorInstance); + if (!NT_SUCCESS(Status)) + { + TraceError("FUS %!FUNC! WdfObjectCreate failed %!STATUS!", Status); + goto Exit; + } + + pSimulator = GetHardwareSimulatorContextFromInstance(*SimulatorInstance); + if (nullptr == pSimulator) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetHardwareSimulatorContextFromInstance failed %!STATUS!", Status); + goto Exit; + } + + pSimulator->InitializeInternal(*SimulatorInstance); + +Exit: + + SENSOR_FunctionExit(Status); + + return Status; +} + + +// Internal routine to perform simulator initialization +NTSTATUS +HardwareSimulator::InitializeInternal( + _In_ WDFOBJECT SimulatorInstance) // Instance of the WDF object for the simulator +{ + NTSTATUS Status = STATUS_SUCCESS; + WDF_OBJECT_ATTRIBUTES TimerAttributes = {}; + WDF_TIMER_CONFIG TimerConfig = {}; + + SENSOR_FunctionEnter(); + + // Only initialize the simulator if it is in the "not initialized" state + if (SimulatorState_NotInitialized == m_State) + { + // Create sample Lock + Status = WdfWaitLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &m_Lock); + if (!NT_SUCCESS(Status)) + { + m_Lock = NULL; + + TraceError("FUS %!FUNC! WdfWaitLockCreate for m_Lock failed %!STATUS!", Status); + goto Exit; + } + + // Create a timer object for simulation updates + WDF_TIMER_CONFIG_INIT(&TimerConfig, HardwareSimulator::OnTimerExpire); + WDF_OBJECT_ATTRIBUTES_INIT(&TimerAttributes); + TimerAttributes.ParentObject = SimulatorInstance; + TimerAttributes.ExecutionLevel = WdfExecutionLevelPassive; + + Status = WdfTimerCreate(&TimerConfig, &TimerAttributes, &m_Timer); + if (!NT_SUCCESS(Status)) + { + m_Timer = NULL; + + TraceError("FUS %!FUNC! WdfTimerCreate failed %!STATUS!", Status); + goto Exit; + } + + // Set the simulator state to "initialized" + m_State = SimulatorState_Initialized; + m_SimulatorInstance = SimulatorInstance; + } + +Exit: + if (!NT_SUCCESS(Status) && NULL != m_Lock) + { + WdfObjectDelete(m_Lock); + m_Lock = NULL; + } + + SENSOR_FunctionExit(Status); + + return Status; +} + + +// This routine perform a simulator cleanup +NTSTATUS +HardwareSimulator::Cleanup() +{ + NTSTATUS status = STATUS_SUCCESS; + + if (SimulatorState_Started == m_State) + { + Stop(); + } + + // Delete lock + if (NULL != m_Lock) + { + WdfObjectDelete(m_Lock); + m_Lock = NULL; + } + + // Set the simulator state to "not initialized" + m_State = SimulatorState_NotInitialized; + + return status; +} + + +// This routine starts the simulator +NTSTATUS +HardwareSimulator::Start() +{ + NTSTATUS status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (SimulatorState_Initialized == m_State) + { + WdfTimerStart(m_Timer, WDF_REL_TIMEOUT_IN_MS(SIMULATOR_HARDWARE_INTERVAL_MS)); + m_State = SimulatorState_Started; + } + + SENSOR_FunctionExit(status); + + return status; +} + + +// This routine stops the simulator +NTSTATUS +HardwareSimulator::Stop() +{ + NTSTATUS status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (SimulatorState_Started == m_State) + { + WdfTimerStop(m_Timer, TRUE); + m_State = SimulatorState_Initialized; + } + + SENSOR_FunctionExit(status); + + return status; +} + + +// This callback is called when the simulator wait time has expired and the simulator +// is ready to switch to the next sample. The callback updates the sample index and +// schedules the next wake up time. +VOID +HardwareSimulator::OnTimerExpire( + _In_ WDFTIMER Timer) // WDF timer object +{ + HardwareSimulator *pSimulator = nullptr; + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + pSimulator = GetHardwareSimulatorContextFromInstance(WdfTimerGetParentObject(Timer)); + if (nullptr == pSimulator) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! GetHardwareSimulatorContextFromInstance failed %!STATUS!", Status); + } + + if (NT_SUCCESS(Status)) + { + // Increment the sample index, roll over if the index reach the end of the array + WdfWaitLockAcquire(pSimulator->m_Lock, NULL); + pSimulator->m_Index++; + pSimulator->m_Index = pSimulator->m_Index % ARRAYSIZE(SimulatorData); + + WdfWaitLockRelease(pSimulator->m_Lock); + + WdfTimerStart(pSimulator->m_Timer, WDF_REL_TIMEOUT_IN_MS(SIMULATOR_HARDWARE_INTERVAL_MS)); + } + + SENSOR_FunctionExit(Status); +} + + +// This routine returns the current sample from the driver at the current m_Index +// location +NTSTATUS +HardwareSimulator::GetSample( + _Out_ FusionSensorSample *Sample) // FusionSensor sample +{ + NTSTATUS Status = STATUS_SUCCESS; + + SENSOR_FunctionEnter(); + + if (nullptr == Sample) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + TraceError("FUS %!FUNC! Sample parameter is null"); + } + + if (NT_SUCCESS(Status)) + { + WdfWaitLockAcquire(m_Lock, NULL); + *Sample = SimulatorData[m_Index]; + + WdfWaitLockRelease(m_Lock); + + GetSystemTimePreciseAsFileTime(&Sample->Timestamp); + } + + SENSOR_FunctionExit(Status); + + return Status; +} diff --git a/sensors/Fusion/readme.md b/sensors/Fusion/readme.md new file mode 100644 index 00000000..3a4bb2bf --- /dev/null +++ b/sensors/Fusion/readme.md @@ -0,0 +1,3 @@ +### Fusion Sensor Driver Sample + +The FusionSensor sample shows how to write a UMDF v2 driver to control a virtual FusionSensor sensor. \ No newline at end of file -- cgit v1.3.1 From 8b505c949ca8133219adbfce912c6dbb726f2895 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 25 Aug 2017 15:11:28 -0700 Subject: Add readmes to samples --- sensors/ADXL345Acc/readme.md | 3 +++ sensors/Activity/readme.md | 3 +++ sensors/CustomSensors/readme.md | 3 +++ sensors/Pedometer/readme.md | 3 +++ sensors/SensorsComboDriver/readme.md | 3 +++ sensors/SimpleDeviceOrientationSensor/readme.md | 3 +++ 6 files changed, 18 insertions(+) create mode 100644 sensors/ADXL345Acc/readme.md create mode 100644 sensors/Activity/readme.md create mode 100644 sensors/CustomSensors/readme.md create mode 100644 sensors/Pedometer/readme.md create mode 100644 sensors/SensorsComboDriver/readme.md create mode 100644 sensors/SimpleDeviceOrientationSensor/readme.md diff --git a/sensors/ADXL345Acc/readme.md b/sensors/ADXL345Acc/readme.md new file mode 100644 index 00000000..d60e78cd --- /dev/null +++ b/sensors/ADXL345Acc/readme.md @@ -0,0 +1,3 @@ +### ADXL345 Accelerometer Sample Driver + +The ADXL345Accelerometer sample shows how to write a UMDF v2 driver to control an ADXL345 accelerometer chip. \ No newline at end of file diff --git a/sensors/Activity/readme.md b/sensors/Activity/readme.md new file mode 100644 index 00000000..3456b263 --- /dev/null +++ b/sensors/Activity/readme.md @@ -0,0 +1,3 @@ +### Activity Sensor Driver Sample + +The Activity sample shows how to write a UMDF v2 driver to control an activity sensor. \ No newline at end of file diff --git a/sensors/CustomSensors/readme.md b/sensors/CustomSensors/readme.md new file mode 100644 index 00000000..c5125de7 --- /dev/null +++ b/sensors/CustomSensors/readme.md @@ -0,0 +1,3 @@ +### Custom Sensor Driver Sample + +The CustomSensor sample shows how to write a UMDF v2 driver to control a custom sensor. \ No newline at end of file diff --git a/sensors/Pedometer/readme.md b/sensors/Pedometer/readme.md new file mode 100644 index 00000000..092bca57 --- /dev/null +++ b/sensors/Pedometer/readme.md @@ -0,0 +1,3 @@ +### Pedometer Sensor Sample + +The Pedometer sample shows how to write a UMDF v2 driver to control a virtual Pedometer sensor. \ No newline at end of file diff --git a/sensors/SensorsComboDriver/readme.md b/sensors/SensorsComboDriver/readme.md new file mode 100644 index 00000000..80fca3d7 --- /dev/null +++ b/sensors/SensorsComboDriver/readme.md @@ -0,0 +1,3 @@ +# Sensors Combo Driver Sample + +The sensors combo driver sensor sample shows how to write UMDF v2 drivers to control various types of virtual sensors such as Ambient Light, Barometer, Gyroscope, Magnetometer, Geomagnetic, Gravity Vector, Proximity, Linear Accelerometer and Relative Fusion. \ No newline at end of file diff --git a/sensors/SimpleDeviceOrientationSensor/readme.md b/sensors/SimpleDeviceOrientationSensor/readme.md new file mode 100644 index 00000000..b4fa4580 --- /dev/null +++ b/sensors/SimpleDeviceOrientationSensor/readme.md @@ -0,0 +1,3 @@ +### Simple Device Orientation Sensor Sample + +The SimpleDeviceOrientationSensor sample shows how to write a UMDF v2 sensor driver to output Simple Device Orientation values. \ No newline at end of file -- cgit v1.3.1 From 7306c1456b4b6bf82560af70b9e104c874051ee9 Mon Sep 17 00:00:00 2001 From: Matthew Montera Date: Fri, 25 Aug 2017 17:35:47 -0700 Subject: Many changes Went through PR --- .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp | 499 ++++++++++++--------- .../osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h | 66 ++- .../osrfx2_DCHU_usersvc/SampleService.cpp | 61 +-- .../osrfx2_DCHU_usersvc/SampleService.h | 13 + 4 files changed, 337 insertions(+), 302 deletions(-) diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp index 6484f834..a02ac24a 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.cpp @@ -81,32 +81,31 @@ GetDevicePath( ) { HRESULT hr = E_FAIL; - BOOL Return = FALSE; - CONFIGRET Status = CR_SUCCESS; + CONFIGRET cr = CR_SUCCESS; PWSTR DeviceInterfaceList = NULL; ULONG DeviceInterfaceListLength = 0; PWSTR NextInterface; - // - // Determine if there are any interfaces that match the OSRFX2 device. - // - Status = CM_Get_Device_Interface_List_Size(&DeviceInterfaceListLength, - InterfaceGuid, - NULL, - CM_GET_DEVICE_INTERFACE_LIST_PRESENT); + // + // Determine if there are any interfaces that match the OSRFX2 device. + // + cr = CM_Get_Device_Interface_List_Size(&DeviceInterfaceListLength, + InterfaceGuid, + NULL, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); - if (Status != CR_SUCCESS) + if (cr != CR_SUCCESS) { WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", - CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); - goto clean0; + CM_MapCrToWin32Err(cr, ERROR_FILE_NOT_FOUND)); + goto cleanup; } if (DeviceInterfaceListLength < 1) { WriteToErrorLog(L"CM_Get_DeviceInterface_List_Size", - CM_MapCrToWin32Err(Status, ERROR_EMPTY)); - goto clean0; + CM_MapCrToWin32Err(cr, ERROR_EMPTY)); + goto cleanup; } DeviceInterfaceList = (PWSTR)malloc(DeviceInterfaceListLength * sizeof(WCHAR)); @@ -115,22 +114,20 @@ GetDevicePath( { WriteToEventLog(L"Failed to allocate memory for the device interface list", TRACE_LEVEL_ERROR); - goto clean0; + goto cleanup; } - ZeroMemory(DeviceInterfaceList, DeviceInterfaceListLength * sizeof(WCHAR)); + cr = CM_Get_Device_Interface_List(InterfaceGuid, + NULL, + DeviceInterfaceList, + DeviceInterfaceListLength, + CM_GET_DEVICE_INTERFACE_LIST_PRESENT); - Status = CM_Get_Device_Interface_List(InterfaceGuid, - NULL, - DeviceInterfaceList, - DeviceInterfaceListLength, - CM_GET_DEVICE_INTERFACE_LIST_PRESENT); - - if (Status != CR_SUCCESS) + if (cr != CR_SUCCESS) { WriteToErrorLog(L"CM_Get_Device_Interface_List", - CM_MapCrToWin32Err(Status, ERROR_FILE_NOT_FOUND)); - goto clean0; + CM_MapCrToWin32Err(cr, ERROR_FILE_NOT_FOUND)); + goto cleanup; } if (*DeviceInterfaceList == UNICODE_NULL) @@ -139,11 +136,11 @@ GetDevicePath( TRACE_LEVEL_ERROR); } - // - // This sample only expects one interface for the OSRFX2 device. For other - // devices, though, it maybe necessary to sift through the interfaces - // from CM_Get_Device_Interface_List in order to find the correct device. - // + // + // This sample only expects one interface for the OSRFX2 device. For other + // devices, though, it maybe necessary to sift through the interfaces + // from CM_Get_Device_Interface_List in order to find the correct device. + // NextInterface = DeviceInterfaceList + wcslen(DeviceInterfaceList) + 1; if (*NextInterface != UNICODE_NULL) @@ -158,22 +155,17 @@ GetDevicePath( if (FAILED(hr)) { WriteToErrorLog(L"StringCchCopy", HRESULT_CODE(hr)); - goto clean0; + goto cleanup; } -clean0: +cleanup: if (DeviceInterfaceList != NULL) { free(DeviceInterfaceList); } - if (Status == CR_SUCCESS) - { - Return = TRUE; - } - - return Return; + return (cr == CR_SUCCESS); } @@ -199,21 +191,21 @@ _Success_(return != INVALID_HANDLE_VALUE) HANDLE OpenDevice( _In_ BOOL Synchronous -) + ) { - HANDLE DeviceHandle; + HANDLE DeviceHandle = INVALID_HANDLE_VALUE; WCHAR DeviceName[MAX_DEVPATH_LENGTH]; if (!GetDevicePath((LPGUID)&GUID_DEVINTERFACE_OSRUSBFX2, DeviceName, sizeof(DeviceName) / sizeof(DeviceName[0]))) { - return INVALID_HANDLE_VALUE; + goto cleanup; } - // - // Open a handle to the interface. - // + // + // Open a handle to the interface. + // if (Synchronous) { DeviceHandle = CreateFile(DeviceName, @@ -244,6 +236,8 @@ OpenDevice( WriteToEventLog(L"Opened Device Successfully", TRACE_LEVEL_INFORMATION); } +cleanup: + return DeviceHandle; } @@ -265,7 +259,7 @@ Return Value: --*/ DWORD InterfaceArrivalAction( - _In_ PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { DWORD Err = ERROR_SUCCESS; @@ -304,7 +298,7 @@ InterfaceArrivalAction( cleanup: - LeaveCriticalSection(&Context->Lock); + LeaveCriticalSection(&Context->Lock); return Err; } @@ -320,13 +314,13 @@ Arguments: hNotify - The notification that fired the callback - hContext - The callback context + hContext - The callback context - Action - The type of notification + Action - The type of notification - EventData - Additional information about the callback + EventData - Additional information about the callback - EventDataSize - The size of EventData + EventDataSize - The size of EventData Return Value: @@ -343,15 +337,15 @@ InterfaceCallback( ) { DWORD Err = ERROR_SUCCESS; - PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + PDEVICE_CONTEXT Context = (PDEVICE_CONTEXT)hContext; - // - // Validate Context. - // - if (Context == NULL) - { - goto cleanup; - } + // + // Validate Context. + // + if (Context == NULL) + { + goto cleanup; + } if (Action == CM_NOTIFY_ACTION_DEVICEINTERFACEARRIVAL) { @@ -369,7 +363,7 @@ cleanup: Routine Description: Registers the service for notifications using the notification handle in - Context. + Context. Arguments: @@ -382,17 +376,17 @@ Return Value: --*/ DWORD RegisterInterfaceNotifications( - _In_ PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { DWORD Err = ERROR_SUCCESS; CONFIGRET cr; CM_NOTIFY_FILTER NotifyFilter = {0}; - if (Context == NULL) - { - goto cleanup; - } + if (Context == NULL) + { + goto cleanup; + } ZeroMemory(&NotifyFilter, sizeof(NotifyFilter)); NotifyFilter.cbSize = sizeof(NotifyFilter); @@ -422,7 +416,7 @@ cleanup: Routine Description: Unregister for interface notifications. Note, this routine deadlocks - when called from an interface callback. + when called from an interface callback. Arguments: @@ -435,7 +429,7 @@ Return Value: --*/ DWORD UnregisterInterfaceNotifications( - PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { CONFIGRET cr; @@ -468,7 +462,7 @@ Return Value: --*/ DWORD DeviceQueryRemoveAction( - _In_ PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { DWORD Err = ERROR_SUCCESS; @@ -496,16 +490,16 @@ DeviceQueryRemoveAction( Routine Description: This callback avoids a deadlock when unregistering device notifications. - Rather than calling CM_Unregister_Notification from the callback, the - callback gives that work to a separate thread to avoid deadlock. + Rather than calling CM_Unregister_Notification from the callback, the + callback gives that work to a separate thread to avoid deadlock. Arguments: - Instance - The thread's callback instance + Instance - The thread's callback instance hContext - The callback context - pWork - The thread handle + pWork - The thread handle Return Value: @@ -520,7 +514,7 @@ UnregisterWorkerThreadCallback( _Inout_ PTP_WORK pWork ) { - PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; + PDEVICE_CONTEXT Context = (PDEVICE_CONTEXT)hContext; EnterCriticalSection(&Context->Lock); @@ -548,7 +542,7 @@ Routine Description: Arguments: - hNotify - The notification that spurred this callback + hNotify - The notification that spurred this callback Context - The callback context @@ -559,8 +553,8 @@ Return Value: --*/ DWORD DeviceQueryRemoveFailedAction( - HCMNOTIFICATION hNotify, - PHANDLE_CONTEXT Context + _In_ HCMNOTIFICATION hNotify, + _In_ PDEVICE_CONTEXT Context ) { DWORD Err = ERROR_SUCCESS; @@ -576,32 +570,32 @@ DeviceQueryRemoveFailedAction( // // Unregister the device callback, and then close the handle // - if (!Context->Unregister) - { - Context->Unregister = TRUE; - SubmitThreadpoolWork(Context->Work); - } + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } LeaveCriticalSection(&Context->Lock); - // - // Wait for the callback and then re-register the device - // - WaitForThreadpoolWorkCallbacks(Context->Work, FALSE); + // + // Wait for the callback and then re-register the device + // + WaitForThreadpoolWorkCallbacks(Context->Work, FALSE); - EnterCriticalSection(&Context->Lock); + EnterCriticalSection(&Context->Lock); - if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) - { - Context->DeviceInterfaceHandle = OpenDevice(FALSE); - } + if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + { + Context->DeviceInterfaceHandle = OpenDevice(FALSE); + } - if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) - { - RegisterDeviceNotifications(Context); - } + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + RegisterDeviceNotifications(Context); + } - LeaveCriticalSection(&Context->Lock); + LeaveCriticalSection(&Context->Lock); return Err; } @@ -626,11 +620,11 @@ Return Value: --*/ DWORD DeviceRemovePendingAction( - HCMNOTIFICATION hNotify, - PHANDLE_CONTEXT Context + _In_ HCMNOTIFICATION hNotify, + _In_ PDEVICE_CONTEXT Context ) { - DWORD Err = ERROR_SUCCESS; + DWORD Err = ERROR_SUCCESS; EnterCriticalSection(&Context->Lock); @@ -643,11 +637,11 @@ DeviceRemovePendingAction( // // Unregister the device callback, and then close the handle // - if (!Context->Unregister) - { - Context->Unregister = TRUE; - SubmitThreadpoolWork(Context->Work); - } + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } LeaveCriticalSection(&Context->Lock); @@ -674,11 +668,11 @@ Return Value: --*/ DWORD DeviceRemoveCompleteAction( - HCMNOTIFICATION hNotify, - PHANDLE_CONTEXT Context + _In_ HCMNOTIFICATION hNotify, + _In_ PDEVICE_CONTEXT Context ) { - DWORD Err = ERROR_SUCCESS; + DWORD Err = ERROR_SUCCESS; EnterCriticalSection(&Context->Lock); @@ -691,11 +685,11 @@ DeviceRemoveCompleteAction( // // Unregister the device callback, and then close the handle // - if (!Context->Unregister) - { - Context->Unregister = TRUE; - SubmitThreadpoolWork(Context->Work); - } + if (!Context->Unregister) + { + Context->Unregister = TRUE; + SubmitThreadpoolWork(Context->Work); + } LeaveCriticalSection(&Context->Lock); @@ -715,11 +709,11 @@ Arguments: hContext - The callback context - Action - The type of callback + Action - The type of callback - EventData - Additional information about this callback + EventData - Additional information about this callback - EventDataSize - The size of EventData + EventDataSize - The size of EventData Return Value: @@ -733,39 +727,37 @@ DeviceCallback( _In_ CM_NOTIFY_ACTION Action, _In_ PCM_NOTIFY_EVENT_DATA EventData, _In_ DWORD EventDataSize -) + ) { - DWORD Err = ERROR_SUCCESS; - PHANDLE_CONTEXT Context = (PHANDLE_CONTEXT)hContext; - - // - // Validate Context. - // - if (Context == NULL) - { - goto cleanup; - } - - switch (Action) - { + DWORD Err = ERROR_SUCCESS; + PDEVICE_CONTEXT Context = (PDEVICE_CONTEXT)hContext; - case CM_NOTIFY_ACTION_DEVICEQUERYREMOVE: - DeviceQueryRemoveAction(Context); - break; + // + // Validate Context. + // + if (Context == NULL) + { + goto cleanup; + } - case CM_NOTIFY_ACTION_DEVICEQUERYREMOVEFAILED: - DeviceQueryRemoveFailedAction(hNotify, Context); - break; + switch (Action) + { + case CM_NOTIFY_ACTION_DEVICEQUERYREMOVE: + DeviceQueryRemoveAction(Context); + break; - case CM_NOTIFY_ACTION_DEVICEREMOVEPENDING: - DeviceRemovePendingAction(hNotify, Context); - break; + case CM_NOTIFY_ACTION_DEVICEQUERYREMOVEFAILED: + DeviceQueryRemoveFailedAction(hNotify, Context); + break; - case CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE: - DeviceRemoveCompleteAction(hNotify, Context); - break; + case CM_NOTIFY_ACTION_DEVICEREMOVEPENDING: + DeviceRemovePendingAction(hNotify, Context); + break; - } + case CM_NOTIFY_ACTION_DEVICEREMOVECOMPLETE: + DeviceRemoveCompleteAction(hNotify, Context); + break; + } cleanup: @@ -790,10 +782,10 @@ Return Value: --*/ DWORD RegisterDeviceNotifications( - _In_ PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { - DWORD Err = ERROR_SUCCESS; + DWORD Err = ERROR_SUCCESS; CONFIGRET cr; CM_NOTIFY_FILTER NotifyFilter = {0}; @@ -813,7 +805,7 @@ RegisterDeviceNotifications( goto cleanup; } - Context->Unregister = FALSE; + Context->Unregister = FALSE; cleanup: @@ -838,10 +830,10 @@ Return Value: --*/ DWORD UnregisterDeviceNotifications( - PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { - DWORD Err = ERROR_SUCCESS; + DWORD Err = ERROR_SUCCESS; CONFIGRET cr; if (Context->DeviceNotificationHandle != NULL) @@ -865,7 +857,7 @@ UnregisterDeviceNotifications( Routine Description: - Initialize the given PHANDLE_CONTEXT. + Initialize the given PDEVICE_CONTEXT. Arguments: @@ -878,39 +870,49 @@ Return Value: --*/ DWORD InitializeContext( - _Out_ PHANDLE_CONTEXT* Context + _Out_ PDEVICE_CONTEXT *Context ) { - DWORD Err = ERROR_SUCCESS; + DWORD Err = ERROR_SUCCESS; + BOOL LockInitialized = FALSE; + BOOL LockEntered = FALSE; + BOOL InterfaceNotificationsInitialized = FALSE; + BOOL DeviceNotificationsInitialized = FALSE; + PDEVICE_CONTEXT DeviceContext; - *Context = (PHANDLE_CONTEXT)malloc(sizeof(HANDLE_CONTEXT)); + DeviceContext = (PDEVICE_CONTEXT)malloc(sizeof(DEVICE_CONTEXT)); - if (*Context == NULL) + if (DeviceContext == NULL) { Err = ERROR_OUTOFMEMORY; goto cleanup; } - (*Context)->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + DeviceContext->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + DeviceContext->LockEnabled = FALSE; + DeviceContext->InterfaceNotificationsEnabled = FALSE; + DeviceContext->DeviceNotificationsEnabled = FALSE; - InitializeCriticalSection(&(*Context)->Lock); + InitializeCriticalSection(&DeviceContext->Lock); + DeviceContext->LockEnabled = TRUE; - (*Context)->Work = CreateThreadpoolWork(UnregisterWorkerThreadCallback, (PVOID)(*Context), NULL); + DeviceContext->Work = CreateThreadpoolWork(UnregisterWorkerThreadCallback, (PVOID)DeviceContext, NULL); - if ((*Context)->Work == NULL) + if (DeviceContext->Work == NULL) { - WriteToErrorLog(L"Could not create worker thread callback", ERROR_OUTOFMEMORY); + Err = GetLastError(); + WriteToErrorLog(L"Could not create worker thread callback", Err); goto cleanup; } - (*Context)->DeviceNotificationHandle = NULL; - (*Context)->InterfaceNotificationHandle = NULL; + DeviceContext->DeviceNotificationHandle = NULL; + DeviceContext->InterfaceNotificationHandle = NULL; // // Register for device interface events to open and close the handle to // the interface. // - Err = RegisterInterfaceNotifications(*Context); + Err = RegisterInterfaceNotifications(DeviceContext); if (Err != ERROR_SUCCESS) { @@ -918,27 +920,33 @@ InitializeContext( goto cleanup; } - EnterCriticalSection(&(*Context)->Lock); + DeviceContext->InterfaceNotificationsEnabled = TRUE; + + EnterCriticalSection(&DeviceContext->Lock); + LockEntered = TRUE; // // The interface may already have arrived while registering for - // notifications. + // notifications. The lock could be moved earlier, but for sample + // purposes this is the proper way to initialize notifications. // - if ((*Context)->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) + if (DeviceContext->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) { - (*Context)->DeviceInterfaceHandle = OpenDevice(FALSE); + DeviceContext->DeviceInterfaceHandle = OpenDevice(FALSE); } - if ((*Context)->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) - { - Err = RegisterDeviceNotifications(*Context); + if (DeviceContext->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + { + Err = RegisterDeviceNotifications(DeviceContext); - if (Err != ERROR_SUCCESS) - { - WriteToErrorLog(L"Could not register device notifications", Err); - goto cleanup; - } - } + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not register device notifications", Err); + goto cleanup; + } + + DeviceContext->DeviceNotificationsEnabled = TRUE; + } // // If OpenDevice ends up returning INVALID_HANDLE_VALUE, that's fine @@ -947,7 +955,18 @@ InitializeContext( cleanup: - LeaveCriticalSection(&(*Context)->Lock); + if (LockEntered) + { + LeaveCriticalSection(&DeviceContext->Lock); + } + + *Context = DeviceContext; + DeviceContext = NULL; + + if (DeviceContext != NULL) + { + CloseContext(DeviceContext); + } return Err; } @@ -957,7 +976,7 @@ cleanup: Routine Description: - Clean up the given PHANDLE_CONTEXT. + Clean up the given PDEVICE_CONTEXT. Arguments: @@ -970,80 +989,83 @@ Return Value: --*/ DWORD CloseContext( - _In_ PHANDLE_CONTEXT* Context + _In_ PDEVICE_CONTEXT Context ) { - DWORD Err = ERROR_SUCCESS; + DWORD Err = ERROR_SUCCESS; BOOL Unregister = FALSE; - if ((Context == NULL) || - (*Context == NULL)) - { - // - // Nothing to remove. - // - goto cleanup; - } + if (Context == NULL) + { + // + // Nothing to remove. + // + goto cleanup; + } - EnterCriticalSection(&(*Context)->Lock); + EnterCriticalSection(&Context->Lock); - if (!(*Context)->Unregister) + if (!Context->Unregister) { // // Unregister from the callback here. // Unregister = TRUE; - (*Context)->Unregister = TRUE; + Context->Unregister = TRUE; } - LeaveCriticalSection(&(*Context)->Lock); - - // - // Unregister from the interface first, so that re-appearance of the interface - // doesn't cause us to register device events again. - // - Err = UnregisterInterfaceNotifications(*Context); + LeaveCriticalSection(&Context->Lock); - if (Err != ERROR_SUCCESS) + // + // Unregister from the interface first, so that re-appearance of the interface + // doesn't cause us to register device events again. + // + if (Context->InterfaceNotificationsEnabled) { - WriteToErrorLog(L"Could not unregister interface notifications", Err); + Err = UnregisterInterfaceNotifications(Context); + + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not unregister interface notifications", Err); + } } if (Unregister) { - Err = UnregisterDeviceNotifications(*Context); + if (Context->DeviceNotificationsEnabled) + { + Err = UnregisterDeviceNotifications(Context); - if (Err != ERROR_SUCCESS) - { - WriteToErrorLog(L"Could not unregister device notifications", Err); - } + if (Err != ERROR_SUCCESS) + { + WriteToErrorLog(L"Could not unregister device notifications", Err); + } + } } else { - WaitForThreadpoolWorkCallbacks((*Context)->Work, FALSE); + WaitForThreadpoolWorkCallbacks(Context->Work, FALSE); } - // - // No need to lock here, UnregisterDeviceNotifications will wait for all - // outstanding callbacks before returning. - // - if ((*Context)->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) + // + // No need to lock here, UnregisterDeviceNotifications will wait for all + // outstanding callbacks before returning. + // + if (Context->DeviceInterfaceHandle != INVALID_HANDLE_VALUE) { - CloseHandle((*Context)->DeviceInterfaceHandle); + CloseHandle(Context->DeviceInterfaceHandle); - (*Context)->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; + Context->DeviceInterfaceHandle = INVALID_HANDLE_VALUE; } - if ((*Context)->Work != NULL) + if (Context->Work != NULL) { - CloseThreadpoolWork((*Context)->Work); + CloseThreadpoolWork(Context->Work); } - DeleteCriticalSection(&(*Context)->Lock); - - free(*Context); + DeleteCriticalSection(&Context->Lock); - *Context = NULL; + free(Context); cleanup: @@ -1067,7 +1089,7 @@ Return Value: --*/ DWORD ClearAllBars( - _In_ PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { DWORD Err = ERROR_SUCCESS; @@ -1112,7 +1134,7 @@ Return Value: --*/ DWORD LightNextBar( - _In_ PHANDLE_CONTEXT Context + _In_ PDEVICE_CONTEXT Context ) { DWORD Err = ERROR_SUCCESS; @@ -1146,5 +1168,50 @@ LightNextBar( cleanup: + return Err; +} + +/*++ + +Routine Description: + + Lights the next bar on the OSRFX2 device. + +Arguments: + + Context - The device context + +Return Value: + + A Win32 error code. + +--*/ +DWORD +ControlDevice( + _In_ PDEVICE_CONTEXT Context + ) +{ + DWORD Err = ERROR_SUCCESS; + + EnterCriticalSection(&Context->Lock); + + Err = ClearAllBars(Context); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + + Err = LightNextBar(Context); + + if (Err != ERROR_SUCCESS) + { + goto cleanup; + } + +cleanup: + + LeaveCriticalSection(&Context->Lock); + return Err; } \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h index ecdfa4ad..3b8be711 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/Main.h @@ -50,14 +50,17 @@ DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, #pragma warning(disable:4201) // nameless struct/union #pragma warning(disable:4214) // bit field types other than int -typedef struct _HANDLE_CONTEXT { +typedef struct _DEVICE_CONTEXT { HANDLE DeviceInterfaceHandle; CRITICAL_SECTION Lock; + BOOL LockEnabled; PTP_WORK Work; BOOL Unregister; - HCMNOTIFICATION InterfaceNotificationHandle; - HCMNOTIFICATION DeviceNotificationHandle; -} HANDLE_CONTEXT, *PHANDLE_CONTEXT; + HCMNOTIFICATION InterfaceNotificationHandle; + BOOL InterfaceNotificationsEnabled; + HCMNOTIFICATION DeviceNotificationHandle; + BOOL DeviceNotificationsEnabled; +} DEVICE_CONTEXT, *PDEVICE_CONTEXT; // // Define the structures that will be used by the IOCTL @@ -201,73 +204,56 @@ typedef struct _SWITCH_STATE { Routine Description: - Sets the variables in this service to their default values. - -Arguments: - - VOID - -Return Value: - - VOID - ---*/ -VOID SetVariables(VOID); - - -/*++ - -Routine Description: - - Opens up the OSR USB FX2 device handle. +Lights the next bar on the OSRFX2 device. Arguments: - Synchronous - Whether or not this device should be - opened for synchronous access +Context - The device context Return Value: - The handle to the OSR USB FX2 device. +A Win32 error code. --*/ -HANDLE OpenDevice(_In_ BOOL Synchronous); +DWORD +ControlDevice(PDEVICE_CONTEXT Context); /*++ Routine Description: - Turns off all of the bar graph lights on the OSR USB FX2 device. + Sets the variables in this service to their default values. Arguments: - DeviceHandle - The handle to the OSR USB FX2 device. + VOID Return Value: VOID --*/ -DWORD ClearAllBars(PHANDLE_CONTEXT Context); +VOID SetVariables(VOID); /*++ Routine Description: - Lights the next bar on the OSR USB FX2 device. + Opens up the OSR USB FX2 device handle. Arguments: - DeviceHandle - The handle to the OSR USB FX2 device. + Synchronous - Whether or not this device should be + opened for synchronous access Return Value: -VOID + The handle to the OSR USB FX2 device. --*/ -DWORD LightNextBar(PHANDLE_CONTEXT Context); +HANDLE OpenDevice(_In_ BOOL Synchronous); /*++ @@ -285,7 +271,7 @@ Return Value: A Win32 error code. --*/ -DWORD RegisterDeviceNotifications(PHANDLE_CONTEXT Context); +DWORD RegisterDeviceNotifications(PDEVICE_CONTEXT Context); /*++ @@ -303,14 +289,14 @@ Return Value: A Win32 error code. --*/ -DWORD UnregisterDeviceNotifications(PHANDLE_CONTEXT Context); +DWORD UnregisterDeviceNotifications(PDEVICE_CONTEXT Context); /*++ Routine Description: -Initialize the given PHANDLE_CONTEXT. +Initialize the given PDEVICE_CONTEXT. Arguments: @@ -321,14 +307,14 @@ Return Value: A Win32 error code. --*/ -DWORD InitializeContext(PHANDLE_CONTEXT* Context); +DWORD InitializeContext(PDEVICE_CONTEXT* Context); /*++ Routine Description: -Clean up the given PHANDLE_CONTEXT. +Clean up the given PDEVICE_CONTEXT. Arguments: @@ -339,4 +325,4 @@ Return Value: A Win32 error code. --*/ -DWORD CloseContext(PHANDLE_CONTEXT* Context); \ No newline at end of file +DWORD CloseContext(PDEVICE_CONTEXT Context); \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp index 5a59319b..fd3d497f 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.cpp @@ -29,16 +29,6 @@ Environment: #include "ThreadPool.h" #pragma endregion -// -// Variables used for device notifications should normally be local. However, -// we must use a global variable here since there is a potential race condition -// when the service needs to restart during device installation that could -// cause the service to prevent the device from being restarted as well. So, -// this variable is global so that the services OnStart and OnStart method can -// handle its creation and destruction. -// -PHANDLE_CONTEXT Context; - /*++ Routine Description: @@ -151,21 +141,23 @@ CSampleService::OnStart( PWSTR *Argv ) { + __debugbreak(); + // // Log a service start message to the Application log. // WriteToEventLog(L"SampleService in OnStart", EVENTLOG_INFORMATION_TYPE); - // - // Set up any variables the service needs. - // - SetVariables(); + // + // Set up any variables the service needs. + // + SetVariables(); - // - // Set up the context, and register for notifications. - // - InitializeContext(&Context); + // + // Set up the context, and register for notifications. + // + InitializeContext(&m_Context); // // Queue the main service function for execution in a worker thread. @@ -193,8 +185,6 @@ Return Value: VOID CSampleService::ServiceWorkerThread() { - DWORD Err = ERROR_SUCCESS; - // // Periodically check if the service is stopping. // @@ -204,28 +194,7 @@ CSampleService::ServiceWorkerThread() // Perform main service function here... // - // - // Wait for the device to arrive. - // - if (Context->DeviceInterfaceHandle == INVALID_HANDLE_VALUE) - { - ::Sleep(2000); - continue; - } - - Err = ClearAllBars(Context); - - if (Err != ERROR_SUCCESS) - { - continue; - } - - Err = LightNextBar(Context); - - if (Err != ERROR_SUCCESS) - { - continue; - } + ControlDevice(m_Context); ::Sleep(2000); // Simulate some lengthy operations. } @@ -278,8 +247,8 @@ CSampleService::OnStop() throw GetLastError(); } - // - // Clean up the context after the worker thread has finished. - // - CloseContext(&Context); + // + // Clean up the context after the worker thread has finished. + // + CloseContext(m_Context); } \ No newline at end of file diff --git a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h index eee8a609..73be42e9 100644 --- a/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h +++ b/general/DCHU/osrfx2_DCHU_base/osrfx2_DCHU_usersvc/SampleService.h @@ -171,4 +171,17 @@ private: // The handle to wait for a stop event. // HANDLE m_hStoppedEvent; + + // + // The device context to manage notifications with. + // + // NOTE: + // Variables used for device notifications should normally be local. However, + // we must use a global variable here since there is a potential race condition + // when the service needs to restart during device installation that could + // cause the service to prevent the device from being restarted. So, this + // variable is global so that the service's OnStart and OnStart method can + // handle its creation and destruction. + // + PDEVICE_CONTEXT m_Context; }; \ No newline at end of file -- cgit v1.3.1 From 13ca5b69d2a1b20e5cfa8ecc94bfea9ece8aaa9a Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Fri, 25 Aug 2017 20:51:02 -0700 Subject: VSTS 12737998 --- sd/miniport/sdhc/README.md | 12 +++++++++++- sd/sdiomars/README.md | 10 ++++++++++ security/elam/README.md | 10 ++++++++++ serial/VirtualSerial/README.md | 10 ++++++++++ serial/VirtualSerial2/README.md | 10 ++++++++++ serial/serenum/README.md | 10 ++++++++++ serial/serial/README.md | 10 ++++++++++ setup/devcon/README.md | 10 ++++++++++ simbatt/README.md | 12 +++++++++++- smartcrd/README.md | 10 ++++++++++ spb/SkeletonI2C/README.md | 12 +++++++++++- spb/SpbTestTool/README.md | 10 ++++++++++ storage/class/cdrom/README.md | 10 ++++++++++ storage/class/classpnp/README.md | 10 ++++++++++ storage/class/disk/README.md | 10 ++++++++++ storage/filters/addfilter/README.md | 10 ++++++++++ storage/iscsi/README.md | 10 ++++++++++ storage/miniports/lsi_u3/README.md | 10 ++++++++++ storage/miniports/storahci/README.md | 10 ++++++++++ storage/msdsm/README.md | 10 ++++++++++ storage/ramdisk/README.md | 10 ++++++++++ storage/sfloppy/README.md | 10 ++++++++++ storage/tools/spti/README.md | 10 ++++++++++ 23 files changed, 233 insertions(+), 3 deletions(-) diff --git a/sd/miniport/sdhc/README.md b/sd/miniport/sdhc/README.md index b5c35093..a1e81cde 100644 --- a/sd/miniport/sdhc/README.md +++ b/sd/miniport/sdhc/README.md @@ -1,5 +1,15 @@ + + + Standard SD Host Controller Miniport -=================== +==================================== This is a sample for a Secure Digital (SD) Host Controller miniport driver. The driver works in conjunction with sdport.sys, which implements SD/SDIO/eMMC protocol and WDM interfaces, to provide the host register interface. diff --git a/sd/sdiomars/README.md b/sd/sdiomars/README.md index 322ac5a4..2f248936 100644 --- a/sd/sdiomars/README.md +++ b/sd/sdiomars/README.md @@ -1,3 +1,13 @@ + + + Storage SDIO Driver =================== diff --git a/security/elam/README.md b/security/elam/README.md index 927dc32d..bbd5b772 100644 --- a/security/elam/README.md +++ b/security/elam/README.md @@ -1,3 +1,13 @@ + + + Early Launch Anti-Malware Driver ================================ diff --git a/serial/VirtualSerial/README.md b/serial/VirtualSerial/README.md index 2b1bc513..59d9afb6 100644 --- a/serial/VirtualSerial/README.md +++ b/serial/VirtualSerial/README.md @@ -1,3 +1,13 @@ + + + Virtual serial driver sample ============================ diff --git a/serial/VirtualSerial2/README.md b/serial/VirtualSerial2/README.md index 3c5baf78..81405d15 100644 --- a/serial/VirtualSerial2/README.md +++ b/serial/VirtualSerial2/README.md @@ -1,3 +1,13 @@ + + + Virtual serial driver sample ============================ diff --git a/serial/serenum/README.md b/serial/serenum/README.md index 7b28ae46..c4690bbf 100644 --- a/serial/serenum/README.md +++ b/serial/serenum/README.md @@ -1,3 +1,13 @@ + + + Serenum sample ============== diff --git a/serial/serial/README.md b/serial/serial/README.md index de76bfb3..583e9cae 100644 --- a/serial/serial/README.md +++ b/serial/serial/README.md @@ -1,3 +1,13 @@ + + + Serial Port Driver ================== diff --git a/setup/devcon/README.md b/setup/devcon/README.md index b559f0f1..60e79702 100644 --- a/setup/devcon/README.md +++ b/setup/devcon/README.md @@ -1,3 +1,13 @@ + + + Device Console (DevCon) Tool ============================ diff --git a/simbatt/README.md b/simbatt/README.md index e52e7d40..24332b56 100644 --- a/simbatt/README.md +++ b/simbatt/README.md @@ -1,3 +1,13 @@ -SimBatt: Battery Battery Driver Sample + + + +SimBatt: Simulated Battery Driver Sample ====================================== SimBatt is simulated battery device driver, this source code is intended to demonstrate implementation of Windows battery driver interfaces. This is a KMDF based sample. You may use this sample as a starting point to implement a battery miniport specific to your needs. \ No newline at end of file diff --git a/smartcrd/README.md b/smartcrd/README.md index d9454735..c3b5ca74 100644 --- a/smartcrd/README.md +++ b/smartcrd/README.md @@ -1,3 +1,13 @@ + + + PCMCIA Smart Card Driver ======================== diff --git a/spb/SkeletonI2C/README.md b/spb/SkeletonI2C/README.md index 4522af7c..2e639a9d 100644 --- a/spb/SkeletonI2C/README.md +++ b/spb/SkeletonI2C/README.md @@ -1,5 +1,15 @@ + + + Skeleton I2C Sample Driver -========================= +========================== The SkeletonI2C sample demonstrates how to design a KMDF controller driver for Windows that conforms to the [simple peripheral bus](http://msdn.microsoft.com/en-us/library/windows/hardware/hh450903) (SPB) device driver interface (DDI). SPB is an abstraction for low-speed serial buses (for example, I2C and SPI) that allows peripheral drivers to be developed for cross-platform use without any knowledge of the underlying bus hardware or device connections. While this sample implements an empty I2C driver, it could just as easily be the starting point for an SPI driver with only minor modifications. diff --git a/spb/SpbTestTool/README.md b/spb/SpbTestTool/README.md index d7c9eb2e..fbee4e70 100644 --- a/spb/SpbTestTool/README.md +++ b/spb/SpbTestTool/README.md @@ -1,3 +1,13 @@ + + + SpbTestTool =========== diff --git a/storage/class/cdrom/README.md b/storage/class/cdrom/README.md index 187ca63b..92ddf79b 100644 --- a/storage/class/cdrom/README.md +++ b/storage/class/cdrom/README.md @@ -1,3 +1,13 @@ + + + CDROM Storage Class Driver ========================== diff --git a/storage/class/classpnp/README.md b/storage/class/classpnp/README.md index c3a893ba..ec3c0e9b 100644 --- a/storage/class/classpnp/README.md +++ b/storage/class/classpnp/README.md @@ -1,3 +1,13 @@ + + + ClassPnP Storage Class Driver Library ===================================== diff --git a/storage/class/disk/README.md b/storage/class/disk/README.md index 1acd4ed5..c4032547 100644 --- a/storage/class/disk/README.md +++ b/storage/class/disk/README.md @@ -1,3 +1,13 @@ + + + Disk Class Driver ================= diff --git a/storage/filters/addfilter/README.md b/storage/filters/addfilter/README.md index 3981aa20..8d3084c4 100644 --- a/storage/filters/addfilter/README.md +++ b/storage/filters/addfilter/README.md @@ -1,3 +1,13 @@ + + + AddFilter Storage Filter Tool ============================= diff --git a/storage/iscsi/README.md b/storage/iscsi/README.md index 8bfb6982..320e1206 100644 --- a/storage/iscsi/README.md +++ b/storage/iscsi/README.md @@ -1,3 +1,13 @@ + + + iSCSI WMI Client ================ diff --git a/storage/miniports/lsi_u3/README.md b/storage/miniports/lsi_u3/README.md index 2e7950ea..2ca91c64 100644 --- a/storage/miniports/lsi_u3/README.md +++ b/storage/miniports/lsi_u3/README.md @@ -1,3 +1,13 @@ + + + LSI\_U3 StorPort Miniport Driver ================================ diff --git a/storage/miniports/storahci/README.md b/storage/miniports/storahci/README.md index 7705ebd5..ed65a9ff 100644 --- a/storage/miniports/storahci/README.md +++ b/storage/miniports/storahci/README.md @@ -1,3 +1,13 @@ + + + StorAhci StorPort Miniport Driver ================================= diff --git a/storage/msdsm/README.md b/storage/msdsm/README.md index d43f1b68..599dc963 100644 --- a/storage/msdsm/README.md +++ b/storage/msdsm/README.md @@ -1,3 +1,13 @@ + + + Multipath I/O (MPIO) DSM Sample =============================== diff --git a/storage/ramdisk/README.md b/storage/ramdisk/README.md index 66e97691..83e0bae1 100644 --- a/storage/ramdisk/README.md +++ b/storage/ramdisk/README.md @@ -1,3 +1,13 @@ + + + RAMDisk Storage Driver Sample ============================= diff --git a/storage/sfloppy/README.md b/storage/sfloppy/README.md index be7bd211..a48c6230 100644 --- a/storage/sfloppy/README.md +++ b/storage/sfloppy/README.md @@ -1,3 +1,13 @@ + + + Super Floppy (sfloppy) Storage Class Driver =========================================== diff --git a/storage/tools/spti/README.md b/storage/tools/spti/README.md index 0d9ad39a..10037d01 100644 --- a/storage/tools/spti/README.md +++ b/storage/tools/spti/README.md @@ -1,3 +1,13 @@ + + + SCSI Pass-Through Interface Tool ================================ -- cgit v1.3.1 From db44fd903e44b470e6429f9b9ef761b1269cb1bd Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Sun, 27 Aug 2017 00:29:46 -0700 Subject: VSTS 12737998 --- thermal/simsensor/README.md | 10 ++++++++++ thermal/thermalclient/README.md | 10 ++++++++++ tools/sdv/samples/DV-FailDriver-WDM/README.md | 10 ++++++++++ tools/sdv/samples/SDV-FailDriver-KMDF/README.md | 10 ++++++++++ tools/sdv/samples/SDV-FailDriver-NDIS/README.md | 10 ++++++++++ tools/sdv/samples/SDV-FailDriver-STORPORT/README.md | 10 ++++++++++ tools/sdv/samples/SDV-FailDriver-WDM/README.md | 10 ++++++++++ usb/UcmCxUcsi/README.md | 10 ++++++++++ usb/UcmTcpciCxClientSample/README.md | 10 ++++++++++ usb/kmdf_enumswitches/README.md | 10 ++++++++++ usb/kmdf_fx2/README.md | 10 ++++++++++ usb/ufxclientsample/README.md | 12 +++++++++++- usb/umdf2_fx2/README.md | 11 ++++++++++- usb/umdf_filter_kmdf/README.md | 10 ++++++++++ usb/umdf_filter_umdf/README.md | 10 ++++++++++ usb/umdf_fx2/README.md | 10 ++++++++++ usb/usbsamp/README.md | 10 ++++++++++ usb/usbview/README.md | 10 ++++++++++ usb/wdf_osrfx2_lab/README.md | 10 ++++++++++ 19 files changed, 191 insertions(+), 2 deletions(-) diff --git a/thermal/simsensor/README.md b/thermal/simsensor/README.md index 668c5b56..a2537ce5 100644 --- a/thermal/simsensor/README.md +++ b/thermal/simsensor/README.md @@ -1,3 +1,13 @@ + + + SimSensor: Simulated Temperature Sensor Sample Driver ===================================================== diff --git a/thermal/thermalclient/README.md b/thermal/thermalclient/README.md index 47f8a2f6..e5812871 100644 --- a/thermal/thermalclient/README.md +++ b/thermal/thermalclient/README.md @@ -1,3 +1,13 @@ + + + SimThermalClient: Simulated Thermal Client Sample Driver ======================================================== diff --git a/tools/sdv/samples/DV-FailDriver-WDM/README.md b/tools/sdv/samples/DV-FailDriver-WDM/README.md index aade7dd9..9851ff31 100644 --- a/tools/sdv/samples/DV-FailDriver-WDM/README.md +++ b/tools/sdv/samples/DV-FailDriver-WDM/README.md @@ -1,3 +1,13 @@ + + + DV-FailDriver-WDM ================= diff --git a/tools/sdv/samples/SDV-FailDriver-KMDF/README.md b/tools/sdv/samples/SDV-FailDriver-KMDF/README.md index ce2b381c..6d4d71cd 100644 --- a/tools/sdv/samples/SDV-FailDriver-KMDF/README.md +++ b/tools/sdv/samples/SDV-FailDriver-KMDF/README.md @@ -1,3 +1,13 @@ + + + SDV-FailDriver-KMDF =================== diff --git a/tools/sdv/samples/SDV-FailDriver-NDIS/README.md b/tools/sdv/samples/SDV-FailDriver-NDIS/README.md index 5903ad29..eaf5dc56 100644 --- a/tools/sdv/samples/SDV-FailDriver-NDIS/README.md +++ b/tools/sdv/samples/SDV-FailDriver-NDIS/README.md @@ -1,3 +1,13 @@ + + + SDV-FailDriver-NDIS =================== diff --git a/tools/sdv/samples/SDV-FailDriver-STORPORT/README.md b/tools/sdv/samples/SDV-FailDriver-STORPORT/README.md index 8611e51d..600b0023 100644 --- a/tools/sdv/samples/SDV-FailDriver-STORPORT/README.md +++ b/tools/sdv/samples/SDV-FailDriver-STORPORT/README.md @@ -1,3 +1,13 @@ + + + SDV-FailDriver-STORPORT ======================= diff --git a/tools/sdv/samples/SDV-FailDriver-WDM/README.md b/tools/sdv/samples/SDV-FailDriver-WDM/README.md index 49a69753..a32fbcf5 100644 --- a/tools/sdv/samples/SDV-FailDriver-WDM/README.md +++ b/tools/sdv/samples/SDV-FailDriver-WDM/README.md @@ -1,3 +1,13 @@ + + + SDV-FailDriver-WDM ================== diff --git a/usb/UcmCxUcsi/README.md b/usb/UcmCxUcsi/README.md index dc6b865d..3ebd5d5d 100644 --- a/usb/UcmCxUcsi/README.md +++ b/usb/UcmCxUcsi/README.md @@ -1,3 +1,13 @@ + + + # UcmTcpciCx Port Controller Client Driver This is a sample driver that shows how to create a Windows USB Type-C port controller driver using the USB Connector Manager class extension driver (UcmCx). The sample is a driver for an embedded controller which is complient with the [USB Type-C Connector System Software Interface (UCSI)](http://www.intel.com/content/www/us/en/io/universal-serial-bus/usb-type-c-ucsi-spec.html). diff --git a/usb/UcmTcpciCxClientSample/README.md b/usb/UcmTcpciCxClientSample/README.md index d3fd73ec..02d043bf 100644 --- a/usb/UcmTcpciCxClientSample/README.md +++ b/usb/UcmTcpciCxClientSample/README.md @@ -1,3 +1,13 @@ + + + # UcmTcpciCx Port Controller Client Driver This is a skeleton sample driver that shows how to create a Windows USB Type-C port controller driver using the USB Connector Manager Type-C Port Controller Interface class extension driver (UcmTcpciCx). UcmTcpciCx is currently only availble using the Windows Insider program - documentation for UcmTcpciCx will be available at the next release of Windows. diff --git a/usb/kmdf_enumswitches/README.md b/usb/kmdf_enumswitches/README.md index d6a7ee9f..dda67616 100644 --- a/usb/kmdf_enumswitches/README.md +++ b/usb/kmdf_enumswitches/README.md @@ -1,3 +1,13 @@ + + + Sample KMDF Bus Driver for OSR USB-FX2 ====================================== diff --git a/usb/kmdf_fx2/README.md b/usb/kmdf_fx2/README.md index 0bf65d1d..68666660 100644 --- a/usb/kmdf_fx2/README.md +++ b/usb/kmdf_fx2/README.md @@ -1,3 +1,13 @@ + + + Sample KMDF Function Driver for OSR USB-FX2 =========================================== diff --git a/usb/ufxclientsample/README.md b/usb/ufxclientsample/README.md index ec39fd35..54a2f69f 100644 --- a/usb/ufxclientsample/README.md +++ b/usb/ufxclientsample/README.md @@ -1,4 +1,14 @@ -USB Function Client Driver + + + +USB Function Client Driver ========================== This is a skeleton sample driver that shows how to create a Windows USB function controller driver using the USB function class extension driver (UFX). diff --git a/usb/umdf2_fx2/README.md b/usb/umdf2_fx2/README.md index 0d98a5ce..bc2cfba5 100644 --- a/usb/umdf2_fx2/README.md +++ b/usb/umdf2_fx2/README.md @@ -1,3 +1,12 @@ + + Sample Function Driver for OSR USB-FX2 (UMDF Version 2) ======================================================= @@ -55,7 +64,7 @@ Build the sample using MSBuild As an alternative to building the driver sample in Visual Studio, you can build it in a Visual Studio Command Prompt window. In Visual Studio, on the **Tools** menu, choose **Visual Studio Command Prompt**. In the Visual Studio Command Prompt window, navigate to the folder that has the solution file, umdf2echo.sln. Use the MSBuild command to build the solution. Here is an example: -**msbuild /p:configuration=”Win8 Release” /p:platform=”Win32” umdf2\_fx2.sln** +**msbuild /p:configuration=�Win8 Release� /p:platform=�Win32� umdf2\_fx2.sln** For more information about using MSBuild to build a driver package, see [Building a Driver](http://msdn.microsoft.com/en-us/library/windows/hardware/ff554644). diff --git a/usb/umdf_filter_kmdf/README.md b/usb/umdf_filter_kmdf/README.md index ecc62acd..5eaf3347 100644 --- a/usb/umdf_filter_kmdf/README.md +++ b/usb/umdf_filter_kmdf/README.md @@ -1,3 +1,13 @@ + + + Sample UMDF Filter above KMDF Function Driver for OSR USB-FX2 (UMDF Version 1) ============================================================================== diff --git a/usb/umdf_filter_umdf/README.md b/usb/umdf_filter_umdf/README.md index b0c7970f..f4d3dc26 100644 --- a/usb/umdf_filter_umdf/README.md +++ b/usb/umdf_filter_umdf/README.md @@ -1,3 +1,13 @@ + + + Sample UMDF Filter above UMDF Function Driver for OSR USB-FX2 (UMDF Version 1) ============================================================================== diff --git a/usb/umdf_fx2/README.md b/usb/umdf_fx2/README.md index 2f7f1ded..4b707cbe 100644 --- a/usb/umdf_fx2/README.md +++ b/usb/umdf_fx2/README.md @@ -1,3 +1,13 @@ + + + Sample UMDF Function Driver for OSR USB-FX2 (UMDF Version 1) ============================================================ diff --git a/usb/usbsamp/README.md b/usb/usbsamp/README.md index 8d9d4d9d..30f46c17 100644 --- a/usb/usbsamp/README.md +++ b/usb/usbsamp/README.md @@ -1,3 +1,13 @@ + + + Usbsamp Generic USB Driver ========================== diff --git a/usb/usbview/README.md b/usb/usbview/README.md index cd117f82..fe1bbbb1 100644 --- a/usb/usbview/README.md +++ b/usb/usbview/README.md @@ -1,3 +1,13 @@ + + + USBView sample application ========================== diff --git a/usb/wdf_osrfx2_lab/README.md b/usb/wdf_osrfx2_lab/README.md index 6940418f..faba87fa 100644 --- a/usb/wdf_osrfx2_lab/README.md +++ b/usb/wdf_osrfx2_lab/README.md @@ -1,3 +1,13 @@ + + + WDF Sample Driver Learning Lab for OSR USB-FX2 ============================================== -- cgit v1.3.1 From 53bcc426c1870374bf941424ddf8b85b745079fd Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Sun, 27 Aug 2017 16:17:45 -0700 Subject: VSTS 12737998 --- video/KMDOD/README.md | 9 +++++++++ video/pixlib/README.md | 10 ++++++++++ wia/README.md | 12 +++++++++++- wmi/wmiacpi/README.md | 10 ++++++++++ wmi/wmisamp/README.md | 10 ++++++++++ wpd/WpdBasicHardwareDriver/README.md | 10 ++++++++++ wpd/WpdHelloWorldDriver/README.md | 10 ++++++++++ wpd/WpdMultiTransportDriver/README.md | 10 ++++++++++ wpd/WpdServiceSampleDriver/README.md | 16 +++++++++++----- wpd/WpdWudfSampleDriver/README.md | 10 ++++++++++ 10 files changed, 101 insertions(+), 6 deletions(-) diff --git a/video/KMDOD/README.md b/video/KMDOD/README.md index 5e005256..6c724af7 100644 --- a/video/KMDOD/README.md +++ b/video/KMDOD/README.md @@ -1,3 +1,12 @@ + + Kernel mode display-only miniport driver (KMDOD) sample ======================================================= diff --git a/video/pixlib/README.md b/video/pixlib/README.md index b7667909..81258ab7 100644 --- a/video/pixlib/README.md +++ b/video/pixlib/README.md @@ -1,3 +1,13 @@ + + + PixLib sample ============= diff --git a/wia/README.md b/wia/README.md index 9d74b0d5..75df38c3 100644 --- a/wia/README.md +++ b/wia/README.md @@ -1,4 +1,14 @@ -Windows Image Acquisition (WIA) Driver Samples + + + +Windows Image Acquisition (WIA) Driver Samples ============================================== The Windows Image Acquisition driver sample set contains samples and test tools for Windows Image Acquisition (WIA), a driver architecture and user interface for acquiring images from still image devices such as scanners. diff --git a/wmi/wmiacpi/README.md b/wmi/wmiacpi/README.md index b2057e16..75b3ef9e 100644 --- a/wmi/wmiacpi/README.md +++ b/wmi/wmiacpi/README.md @@ -1,3 +1,13 @@ + + + WMI ACPI Sample =============== diff --git a/wmi/wmisamp/README.md b/wmi/wmisamp/README.md index b32c2b04..63f41048 100644 --- a/wmi/wmisamp/README.md +++ b/wmi/wmisamp/README.md @@ -1,3 +1,13 @@ + + + Sample KMDF Driver Implementing a WMI Data Provider =================================================== diff --git a/wpd/WpdBasicHardwareDriver/README.md b/wpd/WpdBasicHardwareDriver/README.md index 523d6022..cf1b6dc7 100644 --- a/wpd/WpdBasicHardwareDriver/README.md +++ b/wpd/WpdBasicHardwareDriver/README.md @@ -1,3 +1,13 @@ + + + WPD Basic Hardware Sample Driver (UMDF Version 1) ================================================= diff --git a/wpd/WpdHelloWorldDriver/README.md b/wpd/WpdHelloWorldDriver/README.md index 0bf883bd..e63159e3 100644 --- a/wpd/WpdHelloWorldDriver/README.md +++ b/wpd/WpdHelloWorldDriver/README.md @@ -1,3 +1,13 @@ + + + WPDHelloWorld sample driver for portable devices ================================================ diff --git a/wpd/WpdMultiTransportDriver/README.md b/wpd/WpdMultiTransportDriver/README.md index 4e277f0a..81e6bf30 100644 --- a/wpd/WpdMultiTransportDriver/README.md +++ b/wpd/WpdMultiTransportDriver/README.md @@ -1,3 +1,13 @@ + + + WPD multi-transport sample driver ================================= diff --git a/wpd/WpdServiceSampleDriver/README.md b/wpd/WpdServiceSampleDriver/README.md index 4e277f0a..d946d59d 100644 --- a/wpd/WpdServiceSampleDriver/README.md +++ b/wpd/WpdServiceSampleDriver/README.md @@ -1,11 +1,17 @@ -WPD multi-transport sample driver -================================= + -The WpdMultiTransportDriver sample demonstrates how you could extend the WpdHelloWorldDriver for a device that supports multiple transports. A transport is a protocol over which a portable device communicates with a computer. Example transports include Internet Protocol (IP), Bluetooth, and USB. -A number of portable devices now support multiple transports. For example, a number of cell phones support both Bluetooth and USB. Windows supports a multitransport driver model that ensures that only one node appears for each device. +WPD service sample driver +================================= -For a complete description of this sample and its underlying code and functionality, refer to the [WPD MultiTransport Driver](http://msdn.microsoft.com/en-us/library/windows/hardware/ff597709) description in the Windows Driver Kit documentation. +Demonstrates how to extend the WpdHelloWorldDriver sample so that it supports a simulated device with a Contacts device service. Related topics -------------- diff --git a/wpd/WpdWudfSampleDriver/README.md b/wpd/WpdWudfSampleDriver/README.md index 3d2f449b..f325d5da 100644 --- a/wpd/WpdWudfSampleDriver/README.md +++ b/wpd/WpdWudfSampleDriver/README.md @@ -1,3 +1,13 @@ + + + WPD WUDF sample driver ====================== -- cgit v1.3.1 From d07ec2fd46b1150747ed584a9a1987dd2b24e3d8 Mon Sep 17 00:00:00 2001 From: NabilFates Date: Mon, 28 Aug 2017 10:53:22 -0700 Subject: Update README.md --- general/DCHU/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/general/DCHU/README.md b/general/DCHU/README.md index df571af6..58277b0c 100644 --- a/general/DCHU/README.md +++ b/general/DCHU/README.md @@ -19,9 +19,9 @@ To install these driver packages, make sure that the target machine is in Test M Then, use `pnputil /i /a ` to install each of the three driver packages. They should be installed in the following order: - * `osrfx2_DCHU_base` - * `osrfx2_DCHU_extension` - * `osrfx2_DCHU_component` +* `osrfx2_DCHU_base` +* `osrfx2_DCHU_extension` +* `osrfx2_DCHU_component` Technically the order of `osrfx2_DCHU_extension` and `osrfx2_DCHU_component` doesn't matter, but the software within `osrfx2_DCHU_component` will read the registry set by the extension to show that an extension INF's settings are applied *after* the base INF's. - \ No newline at end of file + -- cgit v1.3.1 From ad6e2c1ee8d7d53b80646461f96ee95af2ccf298 Mon Sep 17 00:00:00 2001 From: NabilFates Date: Mon, 28 Aug 2017 11:10:49 -0700 Subject: Update osrfx2_DCHU_extension.inx --- .../osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx index 660e5049..702a176c 100644 --- a/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx +++ b/general/DCHU/osrfx2_DCHU_extension_loose/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx @@ -22,7 +22,7 @@ Signature = "$WINDOWS NT$" Class = Extension ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} Provider = %ManufacturerName% -ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} +ExtensionId = {zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz} ; replace with your own GUID CatalogFile = osrfx2_DCHU_extension.cat DriverVer = 05/16/2017,15.14.36.721 @@ -51,4 +51,4 @@ ComponentIds=VID_045e&PID_94ab [Strings] ManufacturerName = "Contoso" -OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" \ No newline at end of file +OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" -- cgit v1.3.1 From 5afc248a8d0e15e5f198f3404a23d696103fcfa2 Mon Sep 17 00:00:00 2001 From: NabilFates Date: Mon, 28 Aug 2017 11:11:10 -0700 Subject: Update osrfx2_DCHU_extension.inx --- .../osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx index d6bc7e00..570cd389 100644 --- a/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx +++ b/general/DCHU/osrfx2_DCHU_extension_tight/osrfx2_DCHU_extension/osrfx2_DCHU_extension.inx @@ -22,7 +22,7 @@ Signature = "$WINDOWS NT$" Class = Extension ClassGuid = {e2f84ce7-8efa-411c-aa69-97454ca4cb57} Provider = %ManufacturerName% -ExtensionId = {3846ad8c-dd27-433d-ab89-453654cd542a} +ExtensionId = {zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz} ; replace with your own GUID CatalogFile = osrfx2_DCHU_extension.cat DriverVer = 05/16/2017,15.14.36.721 @@ -52,4 +52,4 @@ ComponentIds=VID_045e&PID_94ab [Strings] ManufacturerName = "Contoso" -OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" \ No newline at end of file +OsrFx2.ExtensionDesc = "OsrFx2 DCHU Device Extension" -- cgit v1.3.1 From 91785e7a059151525d90fcae378a9590a946cd6b Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 30 Aug 2017 11:12:04 -0700 Subject: Remove coinstaller references to sensors inf files --- sensors/ADXL345Acc/ADXL345Acc.inx | Bin 5282 -> 4986 bytes sensors/Activity/Activity.inx | Bin 5078 -> 4790 bytes sensors/CustomSensors/CustomSensors.inx | Bin 5352 -> 5054 bytes sensors/Pedometer/Pedometer.inx | Bin 5130 -> 4840 bytes sensors/SensorsComboDriver/SensorsComboDriver.inx | Bin 5638 -> 5262 bytes .../SimpleDeviceOrientationSensor.inx | Bin 6302 -> 5972 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/sensors/ADXL345Acc/ADXL345Acc.inx b/sensors/ADXL345Acc/ADXL345Acc.inx index 763a75e8..14ae5aad 100644 Binary files a/sensors/ADXL345Acc/ADXL345Acc.inx and b/sensors/ADXL345Acc/ADXL345Acc.inx differ diff --git a/sensors/Activity/Activity.inx b/sensors/Activity/Activity.inx index 91c32a5c..01f2fd3b 100644 Binary files a/sensors/Activity/Activity.inx and b/sensors/Activity/Activity.inx differ diff --git a/sensors/CustomSensors/CustomSensors.inx b/sensors/CustomSensors/CustomSensors.inx index 6a0ec8cc..fb73ab41 100644 Binary files a/sensors/CustomSensors/CustomSensors.inx and b/sensors/CustomSensors/CustomSensors.inx differ diff --git a/sensors/Pedometer/Pedometer.inx b/sensors/Pedometer/Pedometer.inx index f9cb099f..bb6cb2a2 100644 Binary files a/sensors/Pedometer/Pedometer.inx and b/sensors/Pedometer/Pedometer.inx differ diff --git a/sensors/SensorsComboDriver/SensorsComboDriver.inx b/sensors/SensorsComboDriver/SensorsComboDriver.inx index 50326f48..36389fad 100644 Binary files a/sensors/SensorsComboDriver/SensorsComboDriver.inx and b/sensors/SensorsComboDriver/SensorsComboDriver.inx differ diff --git a/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx b/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx index 6c61d4e6..6dbbf7be 100644 Binary files a/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx and b/sensors/SimpleDeviceOrientationSensor/SimpleDeviceOrientationSensor.inx differ -- cgit v1.3.1 From bf166f46e1e61f47487631912f211797b2a40bb7 Mon Sep 17 00:00:00 2001 From: Matthew Montera Date: Wed, 30 Aug 2017 13:30:12 -0700 Subject: Update README Updated README to reflect new package structure --- general/DCHU/README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/general/DCHU/README.md b/general/DCHU/README.md index 92d7e76f..290ceff7 100644 --- a/general/DCHU/README.md +++ b/general/DCHU/README.md @@ -16,22 +16,26 @@ There are three Visual Studio solutions in this sample. Each one represents a s * `osrfx2_DCHU_base` : The driver for the OSR FX2 Learning Kit. This includes the device driver, an upper filter driver for the device (a no-op), a Win32 User Service that controls lights on the device, and a console app that can control the device. -* `osrfx2_DCHU_extension`: An extension driver for the OSR FX2 device. This extension modifies some registry settings originally specified by the base driver (`osrfx2_DCHU_base`). +* `osrfx2_DCHU_extension_loose`: An extension INF for the OSR FX2 device. This extension modifies some registry settings originally specified by the base driver (`osrfx2_DCHU_base`) and also uses AddComponent to create a Software Component. There is also a component INF project that would be a separate submission to DevCenter, which runs some simple software. These two projects are loosely coupled, and can be installed in any order on the machine. -* `osrfx2_DCHU_component`: A Software Component that installs on a device that the base driver package's INF (`osrfx2_DCHU_base.inf`) creates using the [INF AddComponent Directive](https://docs.microsoft.com/windows-hardware/drivers/install/inf-addcomponent-directive). This Software Component executes a legacy .exe to install a file in the `C:\Program Files\...` directory that reads the OSR FX2 device's registry settings applied in the base driver package's INF (`osrfx2_DCHU_base.inf`) +* `osrfx2_DCHU_extension_tight`: An extension INF for the OSR FX2 device. This extension mimics the behavior of `osrfx2_DCHU_extension_loose`; however, it does so in a tightly coupled manner. Using CopyINF, both the extension and component INF are placed into one driver package (and one submission to DevCenter). Here there is less flexibility with the base/component/extension relationship, but it ensures that the component INF is applied at the same time as the extension. + +Both `osrfx2_DCHU_extension_loose` and `osrfx2_DCHU_extension_tight` provide the same functionality, so installing both on the same OSR FX2 device is unnecessary. They are intended to show a different way to use extension and component INF's depending on a project's needs. + +NOTE: osrfx2_DCHU_extension_tight will not currently build on Windows 10 version 1703. You will see an error saying that the directive CopyINF does not work from extension INFs. This has been fixed for the Windows 10 Fall Creators Update. Each of these solutions can be built with the latest WDK on Visual Studio 2015. Additionally, you can also download a [Universal Windows Platform app (UWP)](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomCapability) that controls the OSR FX2 Learning Kit's device. To learn how to pair a UWP app with a device, see [Hardware access for Universal Windows Platform apps](https://docs.microsoft.com/windows-hardware/drivers/devapps/hardware-access-for-universal-windows-platform-apps) -The app and the contents of this sample can coexist, but on Windows 10, version 1703, to build the app with Visual Studio 2017, the computer cannot have the WDK installed. +The app and the contents of this sample can coexist, but on Windows 10 version 1703, to build the app with Visual Studio 2017, the computer cannot have the WDK installed. To install these driver packages, make sure that the target machine is in Test Mode, using `bcdedit /set testsigning on`. -Then, use `pnputil /i /a ` to install each of the three driver packages. They should +Then, use `pnputil /i /a ` to install each of the desired driver packages. They should be installed in the following order: * `osrfx2_DCHU_base` * `osrfx2_DCHU_extension` -* `osrfx2_DCHU_component` +* [`osrfx2_DCHU_component`] Technically the order of `osrfx2_DCHU_extension` and `osrfx2_DCHU_component` doesn't matter, but the software within `osrfx2_DCHU_component` will read the registry set by the extension to show that an extension INF's settings are applied *after* the base INF's. -- cgit v1.3.1 From 1a69aaaf45d7978bf00e17aeba8d4f028e138c4c Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Wed, 30 Aug 2017 15:31:01 -0700 Subject: Added metadata to sensor README.md files. --- sensors/ADXL345Acc/readme.md | 13 +++++++++++-- sensors/Activity/readme.md | 11 ++++++++++- sensors/CustomSensors/readme.md | 13 +++++++++++-- sensors/Fusion/readme.md | 11 ++++++++++- sensors/Pedometer/readme.md | 11 ++++++++++- sensors/SensorsComboDriver/readme.md | 9 +++++++++ sensors/SimpleDeviceOrientationSensor/readme.md | 11 ++++++++++- 7 files changed, 71 insertions(+), 8 deletions(-) diff --git a/sensors/ADXL345Acc/readme.md b/sensors/ADXL345Acc/readme.md index d60e78cd..3d49e89f 100644 --- a/sensors/ADXL345Acc/readme.md +++ b/sensors/ADXL345Acc/readme.md @@ -1,3 +1,12 @@ -### ADXL345 Accelerometer Sample Driver + -The ADXL345Accelerometer sample shows how to write a UMDF v2 driver to control an ADXL345 accelerometer chip. \ No newline at end of file +# ADXL345 Accelerometer Sample Driver + +The ADXL345 accelerometer sample shows how to write a UMDF v2 driver to control an ADXL345 accelerometer chip. diff --git a/sensors/Activity/readme.md b/sensors/Activity/readme.md index 3456b263..7c9292e0 100644 --- a/sensors/Activity/readme.md +++ b/sensors/Activity/readme.md @@ -1,3 +1,12 @@ -### Activity Sensor Driver Sample + + +# Activity Sensor Driver Sample The Activity sample shows how to write a UMDF v2 driver to control an activity sensor. \ No newline at end of file diff --git a/sensors/CustomSensors/readme.md b/sensors/CustomSensors/readme.md index c5125de7..4f58fd68 100644 --- a/sensors/CustomSensors/readme.md +++ b/sensors/CustomSensors/readme.md @@ -1,3 +1,12 @@ -### Custom Sensor Driver Sample + -The CustomSensor sample shows how to write a UMDF v2 driver to control a custom sensor. \ No newline at end of file +# Custom Sensor Driver Sample + +The CustomSensor sample shows how to write a UMDF v2 driver to control a custom sensor. diff --git a/sensors/Fusion/readme.md b/sensors/Fusion/readme.md index 3a4bb2bf..a93f9195 100644 --- a/sensors/Fusion/readme.md +++ b/sensors/Fusion/readme.md @@ -1,3 +1,12 @@ -### Fusion Sensor Driver Sample + + +# Fusion Sensor Driver Sample The FusionSensor sample shows how to write a UMDF v2 driver to control a virtual FusionSensor sensor. \ No newline at end of file diff --git a/sensors/Pedometer/readme.md b/sensors/Pedometer/readme.md index 092bca57..fcf6c82f 100644 --- a/sensors/Pedometer/readme.md +++ b/sensors/Pedometer/readme.md @@ -1,3 +1,12 @@ -### Pedometer Sensor Sample + + +# Pedometer Sensor Sample The Pedometer sample shows how to write a UMDF v2 driver to control a virtual Pedometer sensor. \ No newline at end of file diff --git a/sensors/SensorsComboDriver/readme.md b/sensors/SensorsComboDriver/readme.md index 80fca3d7..9c8e4c67 100644 --- a/sensors/SensorsComboDriver/readme.md +++ b/sensors/SensorsComboDriver/readme.md @@ -1,3 +1,12 @@ + + # Sensors Combo Driver Sample The sensors combo driver sensor sample shows how to write UMDF v2 drivers to control various types of virtual sensors such as Ambient Light, Barometer, Gyroscope, Magnetometer, Geomagnetic, Gravity Vector, Proximity, Linear Accelerometer and Relative Fusion. \ No newline at end of file diff --git a/sensors/SimpleDeviceOrientationSensor/readme.md b/sensors/SimpleDeviceOrientationSensor/readme.md index b4fa4580..7a1e39f7 100644 --- a/sensors/SimpleDeviceOrientationSensor/readme.md +++ b/sensors/SimpleDeviceOrientationSensor/readme.md @@ -1,3 +1,12 @@ -### Simple Device Orientation Sensor Sample + + +# Simple Device Orientation Sensor Sample The SimpleDeviceOrientationSensor sample shows how to write a UMDF v2 sensor driver to output Simple Device Orientation values. \ No newline at end of file -- cgit v1.3.1 From c296df11dfbbcc2dfd72e5b7f17f88df4b9c00b2 Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Wed, 30 Aug 2017 15:32:16 -0700 Subject: Update FWLINK. --- filesys/miniFilter/cdo/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filesys/miniFilter/cdo/README.md b/filesys/miniFilter/cdo/README.md index 4a0fb6d9..2c0a03fa 100644 --- a/filesys/miniFilter/cdo/README.md +++ b/filesys/miniFilter/cdo/README.md @@ -4,7 +4,7 @@ language: cpp category: FileSystem description: An example of using a control device object (CDO) with a minifilter. - samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId= + samplefwlink: http://go.microsoft.com/fwlink/p/?LinkId=617646 ---> -- cgit v1.3.1 From 1f4ef4b3c7c137f19990cb98f0895ac5b9a0fa35 Mon Sep 17 00:00:00 2001 From: NabilFates Date: Tue, 12 Sep 2017 14:37:39 -0700 Subject: Update README.md Fixing typo --- general/DCHU/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/general/DCHU/README.md b/general/DCHU/README.md index 290ceff7..bf74d451 100644 --- a/general/DCHU/README.md +++ b/general/DCHU/README.md @@ -35,7 +35,7 @@ be installed in the following order: * `osrfx2_DCHU_base` * `osrfx2_DCHU_extension` -* [`osrfx2_DCHU_component`] +* `osrfx2_DCHU_component` Technically the order of `osrfx2_DCHU_extension` and `osrfx2_DCHU_component` doesn't matter, but the software within `osrfx2_DCHU_component` will read the registry set by the extension to show that an extension INF's settings are applied *after* the base INF's. -- cgit v1.3.1 From 96b567f49ef5c445d09f4fef0752da83024c6968 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Mon, 18 Sep 2017 01:33:03 -0700 Subject: Include headers from current folder --- .../PhoneAudioSample/PhoneAudioSample.vcxproj | 26 +- audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj | 26 +- audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj | 24 +- .../TabletAudioSample/TabletAudioSample.vcxproj | 26 +- audio/sysvad/common.cpp | 2 + bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj | 26 +- general/filehistory/exe/fhsetup.vcxproj | 26 +- general/perfcounters/kcs/kcs.vcxproj | 4 +- .../SystemTraceControl/SystemTraceControl.vcxproj | 8 +- hid/hidusbfx2/sys/driver.c | 10 +- hid/hidusbfx2/sys/hid.c | 112 +- hid/hidusbfx2/sys/usb.c | 26 +- network/radio/HidSwitchDriverSample/driver.c | 10 +- network/radio/HidSwitchDriverSample/hid.c | 10 +- network/radio/HidSwitchDriverSample/usb.c | 12 +- network/wlan/WDI/PLATFORM/NDIS6/SDIO/sdio.vcxproj | 6 +- network/wlan/WDI/PLATFORM/NDIS6/WDI_Cmds.c | 1112 ++++++++++---------- network/wlan/WDI/PLATFORM/NDIS6/WDI_Common.c | 540 +++++----- print/XPSDrvSmpl/src/common/pshndlr.cpp | 6 +- print/XPSDrvSmpl/src/common/ptquerybld.cpp | 13 +- print/XPSDrvSmpl/src/common/wmpthndlr.cpp | 4 +- print/XPSDrvSmpl/src/filters/color/cmimg.cpp | 2 +- print/XPSDrvSmpl/src/filters/color/dictionary.cpp | 2 +- print/XPSDrvSmpl/src/filters/color/profman.cpp | 2 +- print/XPSDrvSmpl/src/filters/common/ptmanage.cpp | 22 +- print/XPSDrvSmpl/src/filters/nup/nupsax.cpp | 6 +- print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp | 2 +- print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp | 3 +- sd/sdiomars/mars.vcxproj | 26 +- security/elam/elamsample.c | 2 +- sensors/Activity/Device.h | 4 +- sensors/CustomSensors/Device.h | 4 +- sensors/CustomSensors/HardwareSimulator.h | 2 +- sensors/Fusion/Device.h | 4 - sensors/Pedometer/Device.h | 2 +- sensors/Pedometer/HardwareSimulator.h | 2 +- .../SensorsComboDriver/SensorsComboDriver.vcxproj | 6 +- sensors/SimpleDeviceOrientationSensor/Device.h | 2 +- .../HardwareSimulator.h | 2 +- smartcrd/pscr/Pscr.vcxproj | 26 +- storage/class/classpnp/src/srblib.c | 2 +- storage/miniports/lsi_u3/src/lsi_u3.inf | Bin 5998 -> 6022 bytes storage/msdsm/src/intrface.c | 56 +- usb/UcmCxUcsi/UcmCxUcsi.vcxproj | 3 +- .../sys/kmdf_enumswitches.vcxproj | 26 +- usb/kmdf_fx2/driver/osrusbfx2.vcxproj | 26 +- usb/umdf2_fx2/driver/osrusbfx2um.vcxproj | 26 +- usb/umdf_filter_kmdf/kmdf_driver/osrusbfx2.vcxproj | 26 +- wpd/WpdHelloWorldDriver/WpdHelloWorldDriver.inx | 1 + .../WpdMultiTransportDriver.inx | 1 + .../WpdServiceSampleDriver.inx | 1 + wpd/WpdWudfSampleDriver/WpdWudfSampleDriver.inx | Bin 4018 -> 4074 bytes 52 files changed, 1154 insertions(+), 1164 deletions(-) diff --git a/audio/sysvad/PhoneAudioSample/PhoneAudioSample.vcxproj b/audio/sysvad/PhoneAudioSample/PhoneAudioSample.vcxproj index f140a088..cf608ab0 100644 --- a/audio/sysvad/PhoneAudioSample/PhoneAudioSample.vcxproj +++ b/audio/sysvad/PhoneAudioSample/PhoneAudioSample.vcxproj @@ -83,19 +83,19 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\portcls.lib;$(DDK_LIB_PATH)\stdunk.lib;$(DDK_LIB_PATH)\libcntpr.lib - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. true Level4 %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE @@ -105,19 +105,19 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\portcls.lib;$(DDK_LIB_PATH)\stdunk.lib;$(DDK_LIB_PATH)\libcntpr.lib - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. true Level4 %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE @@ -127,19 +127,19 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\portcls.lib;$(DDK_LIB_PATH)\stdunk.lib;$(DDK_LIB_PATH)\libcntpr.lib - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. true Level4 %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE @@ -149,19 +149,19 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\portcls.lib;$(DDK_LIB_PATH)\stdunk.lib;$(DDK_LIB_PATH)\libcntpr.lib - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. true Level4 %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);.. + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..;. %(PreprocessorDefinitions);_WIN32;UNICODE;_UNICODE;PC_IMPLEMENTATION %(PreprocessorDefinitions);DEBUG_LEVEL=DEBUGLVL_TERSE @@ -301,4 +301,4 @@ - \ No newline at end of file + diff --git a/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj b/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj index 563f6375..9737729a 100644 --- a/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj +++ b/audio/sysvad/SwapAPO/APO/SwapAPO.vcxproj @@ -134,18 +134,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib @@ -158,18 +158,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib @@ -182,18 +182,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib @@ -206,18 +206,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib @@ -247,4 +247,4 @@ - \ No newline at end of file + diff --git a/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj b/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj index 68fd57b6..ee3db3f6 100644 --- a/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj +++ b/audio/sysvad/SwapAPO/DelayAPO/DelayAPO.vcxproj @@ -134,18 +134,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib @@ -158,18 +158,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib @@ -182,18 +182,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib @@ -206,18 +206,18 @@ true Level4 %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(PreprocessorDefinitions);_WINDLL;_USRDLL;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\ + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);..\inc;..\..\;. %(AdditionalDependencies);Kernel32.lib;ole32.lib;oleaut32.lib;advapi32.lib;user32.lib;uuid.lib;AudioBaseProcessingObjectV140.lib;audiomediatypecrt.lib;AudioEng.lib diff --git a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj index 8efc42cf..48c5665e 100644 --- a/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj +++ b/audio/sysvad/TabletAudioSample/TabletAudioSample.vcxproj @@ -185,7 +185,7 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. 4595;%(DisableSpecificWarnings) @@ -193,12 +193,12 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. @@ -208,7 +208,7 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. 4595;%(DisableSpecificWarnings) @@ -216,12 +216,12 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. @@ -231,7 +231,7 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. 4595;%(DisableSpecificWarnings) @@ -239,12 +239,12 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. @@ -254,7 +254,7 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. 4595;%(DisableSpecificWarnings) @@ -262,12 +262,12 @@ %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. %(PreprocessorDefinitions);_USE_WAVERT_;SYSVAD_BTH_BYPASS %(PreprocessorDefinitions);_USE_SingleComponentMultiFxStates - %(AdditionalIncludeDirectories);..\EndpointsCommon + %(AdditionalIncludeDirectories);..\EndpointsCommon;. @@ -296,4 +296,4 @@ - \ No newline at end of file + diff --git a/audio/sysvad/common.cpp b/audio/sysvad/common.cpp index 2aadb5e6..a4c8f5e2 100644 --- a/audio/sysvad/common.cpp +++ b/audio/sysvad/common.cpp @@ -4281,6 +4281,7 @@ BthHfpDevice::GetBthHfpCodecId(_Out_ UCHAR * CodecId) ASSERT(CodecId != NULL); +#if !defined(NTDDI_WIN10_RS3) typedef enum _HFP_BYPASS_CODEC_ID_VERSION { REQ_HFP_BYPASS_CODEC_ID_V1 = 1, } HFP_BYPASS_CODEC_ID_VERSION, *PHFP_BYPASS_CODEC_ID_VERSION; @@ -4288,6 +4289,7 @@ BthHfpDevice::GetBthHfpCodecId(_Out_ UCHAR * CodecId) typedef struct _HFP_BYPASS_CODEC_ID_V1 { UCHAR CodecId; } HFP_BYPASS_CODEC_ID_V1, *PHFP_BYPASS_CODEC_ID_V1; +#endif NTSTATUS ntStatus = STATUS_SUCCESS; diff --git a/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj b/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj index 1aa3a43c..6319ca83 100644 --- a/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj +++ b/bluetooth/serialhcibus/WDK/SerialBusWdk.vcxproj @@ -103,11 +103,11 @@
- %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES true Level4 @@ -115,7 +115,7 @@ - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES @@ -124,11 +124,11 @@ - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES true Level4 @@ -136,7 +136,7 @@ - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES @@ -145,11 +145,11 @@ - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES true Level4 @@ -157,7 +157,7 @@ - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES @@ -166,11 +166,11 @@ - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES true Level4 @@ -178,7 +178,7 @@ - %(AdditionalIncludeDirectories);..\ + %(AdditionalIncludeDirectories);..\;. %(PreprocessorDefinitions);RESHUB_USE_HELPER_ROUTINES @@ -201,4 +201,4 @@ - \ No newline at end of file + diff --git a/general/filehistory/exe/fhsetup.vcxproj b/general/filehistory/exe/fhsetup.vcxproj index fdb347e1..e6e78377 100644 --- a/general/filehistory/exe/fhsetup.vcxproj +++ b/general/filehistory/exe/fhsetup.vcxproj @@ -97,15 +97,15 @@ Level4 Sync %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(AdditionalDependencies);shell32.lib;shlwapi.lib;Ole32.lib;Oleaut32.lib;User32.lib;fhsvcctl.lib @@ -117,15 +117,15 @@ Level4 Sync %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(AdditionalDependencies);shell32.lib;shlwapi.lib;Ole32.lib;Oleaut32.lib;User32.lib;fhsvcctl.lib @@ -137,15 +137,15 @@ Level4 Sync %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(AdditionalDependencies);shell32.lib;shlwapi.lib;Ole32.lib;Oleaut32.lib;User32.lib;fhsvcctl.lib @@ -157,15 +157,15 @@ Level4 Sync %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(PreprocessorDefinitions);UNICODE;_UNICODE - %(AdditionalIncludeDirectories);$(SDK_INC_PATH) + %(AdditionalIncludeDirectories);$(SDK_INC_PATH);. %(AdditionalDependencies);shell32.lib;shlwapi.lib;Ole32.lib;Oleaut32.lib;User32.lib;fhsvcctl.lib @@ -187,4 +187,4 @@ - \ No newline at end of file + diff --git a/general/perfcounters/kcs/kcs.vcxproj b/general/perfcounters/kcs/kcs.vcxproj index 5f30eb23..e97abb07 100644 --- a/general/perfcounters/kcs/kcs.vcxproj +++ b/general/perfcounters/kcs/kcs.vcxproj @@ -151,7 +151,7 @@ $([System.IO.Path]::GetDirectoryName($(ProjectDir)\$(IntDir))) - + @@ -170,4 +170,4 @@ - \ No newline at end of file + diff --git a/general/tracing/SystemTraceControl/SystemTraceControl.vcxproj b/general/tracing/SystemTraceControl/SystemTraceControl.vcxproj index 7669ebaa..1d635e7e 100644 --- a/general/tracing/SystemTraceControl/SystemTraceControl.vcxproj +++ b/general/tracing/SystemTraceControl/SystemTraceControl.vcxproj @@ -26,22 +26,22 @@ Application true - v140 + WindowsApplicationForDrivers10.0 Application false - v140 + WindowsApplicationForDrivers10.0 Application true - v140 + WindowsApplicationForDrivers10.0 Application false - v140 + WindowsApplicationForDrivers10.0 diff --git a/hid/hidusbfx2/sys/driver.c b/hid/hidusbfx2/sys/driver.c index 825c803f..5ec4a441 100644 --- a/hid/hidusbfx2/sys/driver.c +++ b/hid/hidusbfx2/sys/driver.c @@ -26,7 +26,7 @@ Revision History: --*/ -#include +#include "hidusbfx2.h" #if defined(EVENT_TRACING) // @@ -110,7 +110,7 @@ Return Value: if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDriverCreate failed with status 0x%x\n", status); - + WPP_CLEANUP(DriverObject); } @@ -160,7 +160,7 @@ Return Value: "HidFx2EvtDeviceAdd called\n"); // - // Tell framework this is a filter driver. Filter drivers by default are + // Tell framework this is a filter driver. Filter drivers by default are // not power policy owners. This works well for this driver because // HIDclass driver is the power policy owner for HID minidrivers. // @@ -202,7 +202,7 @@ Return Value: } devContext = GetDeviceContext(hDevice); - + WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel); queueConfig.EvtIoInternalDeviceControl = HidFx2EvtInternalDeviceControl; @@ -246,7 +246,7 @@ Return Value: } // - // Create a timer to handle debouncing of switchpack + // Create a timer to handle debouncing of switchpack // WDF_TIMER_CONFIG_INIT( &timerConfig, diff --git a/hid/hidusbfx2/sys/hid.c b/hid/hidusbfx2/sys/hid.c index 362ed515..423e1131 100644 --- a/hid/hidusbfx2/sys/hid.c +++ b/hid/hidusbfx2/sys/hid.c @@ -28,7 +28,7 @@ Revision History: #define USE_HARDCODED_HID_REPORT_DESCRIPTOR -#include +#include "hidusbfx2.h" #if defined(EVENT_TRACING) #include "hid.tmh" @@ -53,7 +53,7 @@ HidFx2EvtInternalDeviceControl( Routine Description: - This event is called when the framework receives + This event is called when the framework receives IRP_MJ_INTERNAL DEVICE_CONTROL requests from the system. Arguments: @@ -90,7 +90,7 @@ Return Value: TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, "%s, Queue:0x%p, Request:0x%p\n", DbgHidInternalIoctlString(IoControlCode), - Queue, + Queue, Request ); @@ -139,14 +139,14 @@ Return Value: if(!NT_SUCCESS(status)){ TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, "WdfRequestForwardToIoQueue failed with status: 0x%x\n", status); - + WdfRequestComplete(Request, status); } return; // -// This feature is only supported on WinXp and later. Compiling in W2K +// This feature is only supported on WinXp and later. Compiling in W2K // build environment will fail without this conditional preprocessor statement. // case IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST: @@ -154,16 +154,16 @@ Return Value: // // Hidclass sends this IOCTL for devices that have opted-in for Selective // Suspend feature. This feature is enabled by adding a registry value - // "SelectiveSuspendEnabled" = 1 in the hardware key through inf file - // (see hidusbfx2.inf). Since hidclass is the power policy owner for - // this stack, it controls when to send idle notification and when to - // cancel it. This IOCTL is passed to USB stack. USB stack pends it. + // "SelectiveSuspendEnabled" = 1 in the hardware key through inf file + // (see hidusbfx2.inf). Since hidclass is the power policy owner for + // this stack, it controls when to send idle notification and when to + // cancel it. This IOCTL is passed to USB stack. USB stack pends it. // USB stack completes the request when it determines that the device is - // idle. Hidclass's idle notification callback get called that requests a - // wait-wake Irp and subsequently powers down the device. - // The device is powered-up either when a handle is opened for the PDOs + // idle. Hidclass's idle notification callback get called that requests a + // wait-wake Irp and subsequently powers down the device. + // The device is powered-up either when a handle is opened for the PDOs // exposed by hidclass, or when usb stack completes wait - // wake request. In the first case, hidclass cancels the notification + // wake request. In the first case, hidclass cancels the notification // request (pended with usb stack), cancels wait-wake Irp and powers up // the device. In the second case, an external wake event triggers completion // of wait-wake irp and powering up of device. @@ -173,10 +173,10 @@ Return Value: if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, "SendIdleNotification failed with status: 0x%x\n", status); - + WdfRequestComplete(Request, status); - } - + } + return; case IOCTL_HID_SET_FEATURE: @@ -187,7 +187,7 @@ Return Value: status = HidFx2SetFeature(Request); WdfRequestComplete(Request, status); return; - + case IOCTL_HID_GET_FEATURE: // // Get a HID class feature report from a top-level collection of @@ -248,7 +248,7 @@ Routine Description Arguments: - Request - Wdf Request + Request - Wdf Request Return Value: @@ -268,7 +268,7 @@ Return Value: TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "HidFx2SetFeature Enter\n"); device = WdfIoQueueGetDevice(WdfRequestGetIoQueue(Request)); - + WDF_REQUEST_PARAMETERS_INIT(¶ms); WdfRequestGetParameters(Request, ¶ms); @@ -276,7 +276,7 @@ Return Value: // IOCTL_HID_SET_FEATURE & IOCTL_HID_GET_FEATURE are not METHOD_NIEHTER // IOCTLs. So you cannot retreive UserBuffer from the IRP using Wdf // function. As a result we have to escape out to WDM to get the UserBuffer - // directly from the IRP. + // directly from the IRP. // if (params.Parameters.DeviceIoControl.InputBufferLength < sizeof(HID_XFER_PACKET)) { status = STATUS_BUFFER_TOO_SMALL; @@ -321,15 +321,15 @@ Return Value: if (transferPacket->reportId == SEVEN_SEGMENT_REPORT_ID) { status = SendVendorCommand( - device, + device, HIDFX2_SET_7SEGMENT_DISPLAY, - &featureUsage + &featureUsage ); } else if (transferPacket->reportId == BARGRAPH_REPORT_ID) { status = SendVendorCommand( - device, + device, HIDFX2_SET_BARGRAPH_DISPLAY, &featureUsage ); @@ -360,7 +360,7 @@ Routine Description Arguments: - Request - Wdf Request + Request - Wdf Request BytesReturned - Size of buffer returned for the request @@ -383,7 +383,7 @@ Return Value: *BytesReturned = 0; device = WdfIoQueueGetDevice(WdfRequestGetIoQueue(Request)); - + WDF_REQUEST_PARAMETERS_INIT(¶ms); WdfRequestGetParameters(Request, ¶ms); @@ -391,7 +391,7 @@ Return Value: // IOCTL_HID_SET_FEATURE & IOCTL_HID_GET_FEATURE are not METHOD_NIEHTER // IOCTLs. So you cannot retreive UserBuffer from the IRP using Wdf // function. As a result we have to escape out to WDM to get the UserBuffer - // directly from the IRP. + // directly from the IRP. // if (params.Parameters.DeviceIoControl.OutputBufferLength < sizeof(HID_XFER_PACKET)) { status = STATUS_BUFFER_TOO_SMALL; @@ -431,15 +431,15 @@ Return Value: if (transferPacket->reportId == SEVEN_SEGMENT_REPORT_ID) { status = GetVendorData( - device, + device, HIDFX2_READ_7SEGMENT_DISPLAY, - &featureReport->FeatureData + &featureReport->FeatureData ); } else if (transferPacket->reportId == BARGRAPH_REPORT_ID) { status = GetVendorData( - device, + device, HIDFX2_READ_BARGRAPH_DISPLAY, &featureReport->FeatureData ); @@ -473,7 +473,7 @@ Routine Description Arguments: - Request - Wdf Request + Request - Wdf Request Return Value: @@ -487,7 +487,7 @@ Return Value: WDF_MEMORY_DESCRIPTOR memDesc; WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket; WDF_REQUEST_SEND_OPTIONS sendOptions; - + PAGED_CODE(); TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "SendVendorCommand Enter\n"); @@ -495,7 +495,7 @@ Return Value: pDevContext = GetDeviceContext(Device); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, - "SendVendorCommand: Command:0x%x, data: 0x%x\n", + "SendVendorCommand: Command:0x%x, data: 0x%x\n", VendorCommand, *CommandData); // @@ -503,7 +503,7 @@ Return Value: // // Send the I/O with a timeout. We do that because we send the // I/O in the context of the user thread and if it gets stuck, it would - // prevent the user process from existing. + // prevent the user process from existing. // WDF_REQUEST_SEND_OPTIONS_INIT(&sendOptions, WDF_REQUEST_SEND_OPTION_TIMEOUT); @@ -535,7 +535,7 @@ Return Value: TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, "SendtVendorCommand: Failed to set Segment Display state - 0x%x \n", status); - } + } TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "SendVendorCommand Exit\n"); @@ -557,7 +557,7 @@ Routine Description Arguments: - Request - Wdf Request + Request - Wdf Request Return Value: @@ -571,7 +571,7 @@ Return Value: WDF_MEMORY_DESCRIPTOR memDesc; WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket; WDF_REQUEST_SEND_OPTIONS sendOptions; - + PAGED_CODE(); TraceEvents(TRACE_LEVEL_VERBOSE, DBG_IOCTL, "GetVendorData Enter\n"); @@ -579,7 +579,7 @@ Return Value: pDevContext = GetDeviceContext(Device); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, - "GetVendorData: Command:0x%x, data: 0x%x\n", + "GetVendorData: Command:0x%x, data: 0x%x\n", VendorCommand, *CommandData); // @@ -587,7 +587,7 @@ Return Value: // // Send the I/O with a timeout. We do that because we send the // I/O in the context of the user thread and if it gets stuck, it would - // prevent the user process from existing. + // prevent the user process from existing. // WDF_REQUEST_SEND_OPTIONS_INIT(&sendOptions, WDF_REQUEST_SEND_OPTION_TIMEOUT); @@ -619,11 +619,11 @@ Return Value: TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, "GetVendorData: Failed to get state - 0x%x \n", status); - } + } else { TraceEvents(TRACE_LEVEL_INFORMATION, DBG_IOCTL, - "GetVendorData: Command:0x%x, data after command: 0x%x\n", + "GetVendorData: Command:0x%x, data after command: 0x%x\n", VendorCommand, *CommandData); } @@ -642,7 +642,7 @@ HidFx2GetHidDescriptor( Routine Description: - Finds the HID descriptor and copies it into the buffer provided by the + Finds the HID descriptor and copies it into the buffer provided by the Request. Arguments: @@ -668,7 +668,7 @@ Return Value: // // This IOCTL is METHOD_NEITHER so WdfRequestRetrieveOutputMemory - // will correctly retrieve buffer from Irp->UserBuffer. + // will correctly retrieve buffer from Irp->UserBuffer. // Remember that HIDCLASS provides the buffer in the Irp->UserBuffer // field irrespective of the ioctl buffer type. However, framework is very // strict about type checking. You cannot get Irp->UserBuffer by using @@ -683,7 +683,7 @@ Return Value: } // - // Use hardcoded "HID Descriptor" + // Use hardcoded "HID Descriptor" // bytesToCopy = G_DefaultHidDescriptor.bLength; @@ -691,9 +691,9 @@ Return Value: status = STATUS_INVALID_DEVICE_STATE; TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, "G_DefaultHidDescriptor is zero, 0x%x\n", status); - return status; + return status; } - + status = WdfMemoryCopyFromBuffer(memory, 0, // Offset (PVOID) &G_DefaultHidDescriptor, @@ -749,7 +749,7 @@ Return Value: // // This IOCTL is METHOD_NEITHER so WdfRequestRetrieveOutputMemory - // will correctly retrieve buffer from Irp->UserBuffer. + // will correctly retrieve buffer from Irp->UserBuffer. // Remember that HIDCLASS provides the buffer in the Irp->UserBuffer // field irrespective of the ioctl buffer type. However, framework is very // strict about type checking. You cannot get Irp->UserBuffer by using @@ -772,9 +772,9 @@ Return Value: status = STATUS_INVALID_DEVICE_STATE; TraceEvents(TRACE_LEVEL_ERROR, DBG_IOCTL, "G_DefaultHidDescriptor's reportLenght is zero, 0x%x\n", status); - return status; + return status; } - + status = WdfMemoryCopyFromBuffer(memory, 0, (PVOID) G_DefaultReportDescriptor, @@ -828,7 +828,7 @@ Return Value: // // This IOCTL is METHOD_NEITHER so WdfRequestRetrieveOutputMemory - // will correctly retrieve buffer from Irp->UserBuffer. + // will correctly retrieve buffer from Irp->UserBuffer. // Remember that HIDCLASS provides the buffer in the Irp->UserBuffer // field irrespective of the ioctl buffer type. However, framework is very // strict about type checking. You cannot get Irp->UserBuffer by using @@ -890,7 +890,7 @@ Return Value: BOOLEAN sendStatus = FALSE; WDF_REQUEST_SEND_OPTIONS options; WDFIOTARGET nextLowerDriver; - WDFDEVICE device; + WDFDEVICE device; PIO_STACK_LOCATION currentIrpStack = NULL; IO_STACK_LOCATION nextIrpStack; @@ -900,7 +900,7 @@ Return Value: // // Convert the request to corresponding USB Idle notification request // - if (currentIrpStack->Parameters.DeviceIoControl.InputBufferLength < + if (currentIrpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO)) { status = STATUS_BUFFER_TOO_SMALL; @@ -909,7 +909,7 @@ Return Value: return status; } - ASSERT(sizeof(HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO) + ASSERT(sizeof(HID_SUBMIT_IDLE_NOTIFICATION_CALLBACK_INFO) == sizeof(USB_IDLE_CALLBACK_INFO)); #pragma warning(suppress :4127) // conditional expression is constant warning @@ -925,15 +925,15 @@ Return Value: // prepare next stack location // RtlZeroMemory(&nextIrpStack, sizeof(IO_STACK_LOCATION)); - + nextIrpStack.MajorFunction = currentIrpStack->MajorFunction; nextIrpStack.Parameters.DeviceIoControl.InputBufferLength = currentIrpStack->Parameters.DeviceIoControl.InputBufferLength; nextIrpStack.Parameters.DeviceIoControl.Type3InputBuffer = currentIrpStack->Parameters.DeviceIoControl.Type3InputBuffer; - nextIrpStack.Parameters.DeviceIoControl.IoControlCode = + nextIrpStack.Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION; - nextIrpStack.DeviceObject = + nextIrpStack.DeviceObject = WdfIoTargetWdmGetTargetDeviceObject(WdfDeviceGetIoTarget(device)); // @@ -954,7 +954,7 @@ Return Value: ); nextLowerDriver = WdfDeviceGetIoTarget(device); - + sendStatus = WdfRequestSend( Request, nextLowerDriver, diff --git a/hid/hidusbfx2/sys/usb.c b/hid/hidusbfx2/sys/usb.c index 50f1a03b..676d92d6 100644 --- a/hid/hidusbfx2/sys/usb.c +++ b/hid/hidusbfx2/sys/usb.c @@ -26,7 +26,7 @@ Revision History: --*/ -#include +#include "hidusbfx2.h" #if defined(EVENT_TRACING) #include "usb.tmh" @@ -84,7 +84,7 @@ Return Value: "HidFx2EvtDevicePrepareHardware Enter\n"); devContext = GetDeviceContext(Device); - + // // Create a WDFUSBDEVICE object. WdfUsbTargetDeviceCreate obtains the // USB device descriptor and the first USB configuration descriptor from @@ -95,8 +95,8 @@ Return Value: // object. The driver cannot change this parent, and the ParentObject // member or the WDF_OBJECT_ATTRIBUTES structure must be NULL. // - // We only create device the first time PrepareHardware is called. If - // the device is restarted by pnp manager for resource rebalance, we + // We only create device the first time PrepareHardware is called. If + // the device is restarted by pnp manager for resource rebalance, we // will use the same device handle but then select the interfaces again // because the USB stack could reconfigure the device on restart. // @@ -104,7 +104,7 @@ Return Value: status = WdfUsbTargetDeviceCreate(Device, WDF_NO_OBJECT_ATTRIBUTES, &devContext->UsbDevice); - + if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "WdfUsbTargetDeviceCreate failed 0x%x\n", status); @@ -113,7 +113,7 @@ Return Value: // // TODO: If you are fetching configuration descriptor from device for - // selecting a configuration or to parse other descriptors, call + // selecting a configuration or to parse other descriptors, call // HidFx2ValidateConfigurationDescriptor // to do basic validation on the descriptors before you access them. // @@ -332,7 +332,7 @@ Return Value: ); return; } - + switchState = WdfMemoryGetBuffer(Buffer, NULL); currentSwitchState = *switchState; @@ -812,8 +812,8 @@ Return Value: // USBD_ValidateConfigurationDescriptor validates that all descriptors are completely contained within the configuration descriptor buffer. // It also checks for interface numbers, number of endpoints in an interface etc. // Please refer to msdn documentation for this function for more information. - // - + // + status = USBD_ValidateConfigurationDescriptor( ConfigDesc, BufferLength , ValidationLevel , Offset , POOL_TAG ); if (!(NT_SUCCESS (status)) ){ return status; @@ -821,10 +821,10 @@ Return Value: // // TODO: You should validate the correctness of other descriptors which are not taken care by USBD_ValidateConfigurationDescriptor - // Check that all such descriptors have size >= sizeof(the descriptor they point to) - // Check for any association between them if required - // - + // Check that all such descriptors have size >= sizeof(the descriptor they point to) + // Check for any association between them if required + // + return status; } diff --git a/network/radio/HidSwitchDriverSample/driver.c b/network/radio/HidSwitchDriverSample/driver.c index 54e80dae..61cc97fc 100644 --- a/network/radio/HidSwitchDriverSample/driver.c +++ b/network/radio/HidSwitchDriverSample/driver.c @@ -1,4 +1,4 @@ -#include +#include "RadioSwitchHidUsbFx2.h" #pragma warning(disable:28252) #pragma warning(disable:28253) #include "driver.tmh" @@ -39,7 +39,7 @@ NTSTATUS DriverEntry (_In_ PDRIVER_OBJECT pDriverObject, _In_ PUNICODE_STRING ps &config, // Driver Config Info WDF_NO_HANDLE ); - if (!NT_SUCCESS(status)) + if (!NT_SUCCESS(status)) { TraceErr(DBG_INIT, "(%!FUNC!)WdfDriverCreate failed with status %!STATUS!\n", status); WPP_CLEANUP(pDriverObject); @@ -64,7 +64,7 @@ void HidFx2EvtDriverContextCleanup(_In_ WDFOBJECT hDriver) -//HidFx2EvtDeviceAdd is called by the framework in response to AddDevicecall from the PnP manager. +//HidFx2EvtDeviceAdd is called by the framework in response to AddDevicecall from the PnP manager. //We create and initialize a WDF device object to represent a new instance of device. // NTSTATUS HidFx2EvtDeviceAdd(_In_ WDFDRIVER hDriver, _Inout_ PWDFDEVICE_INIT pDeviceInit) @@ -111,7 +111,7 @@ NTSTATUS HidFx2EvtDeviceAdd(_In_ WDFDRIVER hDriver, _Inout_ PWDFDEVICE_INIT pDev } pDevContext = GetDeviceContext(hDevice); - + WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel); queueConfig.EvtIoInternalDeviceControl = HidFx2EvtInternalDeviceControl; @@ -136,7 +136,7 @@ NTSTATUS HidFx2EvtDeviceAdd(_In_ WDFDRIVER hDriver, _Inout_ PWDFDEVICE_INIT pDev return status; } - // Create a timer to handle debouncing of switchpack + // Create a timer to handle debouncing of switchpack WDF_TIMER_CONFIG_INIT(&timerConfig, HidFx2EvtTimerFunction); timerConfig.AutomaticSerialization = FALSE; diff --git a/network/radio/HidSwitchDriverSample/hid.c b/network/radio/HidSwitchDriverSample/hid.c index 27fcefea..2421b88f 100644 --- a/network/radio/HidSwitchDriverSample/hid.c +++ b/network/radio/HidSwitchDriverSample/hid.c @@ -1,4 +1,4 @@ -#include +#include "RadioSwitchHidUsbFx2.h" #include "hid.tmh" // Radio Management Collection - Scenario 1 control collection (Button only) @@ -223,7 +223,7 @@ NTSTATUS HidFx2GetInput(_In_ WDFREQUEST hRequest) TraceVerbose(DBG_IOCTL, "(%!FUNC!) Enter\n"); hDevice = WdfIoQueueGetDevice(WdfRequestGetIoQueue(hRequest)); - + WDF_REQUEST_PARAMETERS_INIT(¶ms); WdfRequestGetParameters(hRequest, ¶ms); @@ -296,7 +296,7 @@ NTSTATUS HidFx2SetOutput(_In_ WDFREQUEST hRequest) TraceVerbose(DBG_IOCTL, "(%!FUNC!) Enter\n"); hDevice = WdfIoQueueGetDevice(WdfRequestGetIoQueue(hRequest)); - + WDF_REQUEST_PARAMETERS_INIT(¶ms); WdfRequestGetParameters(hRequest, ¶ms); @@ -335,7 +335,7 @@ NTSTATUS HidFx2SetOutput(_In_ WDFREQUEST hRequest) TraceErr(DBG_IOCTL, "(%!FUNC!) Incorrect report ID, %!STATUS!\n", status); return status; } - + pOutputReport = (PHIDFX2_IO_REPORT)pTransferPacket->reportBuffer; if (pOutputReport->bData == 0) @@ -471,7 +471,7 @@ NTSTATUS HidFx2GetHidDescriptor(_In_ WDFDEVICE hDevice, _In_ WDFREQUEST hRequest TraceErr(DBG_IOCTL, "(%!FUNC!) c_DefaultHidDescriptor is zero, %!STATUS!\n", status); return status; } - + } else // WdfRequestRetrieveOutputMemory failed { diff --git a/network/radio/HidSwitchDriverSample/usb.c b/network/radio/HidSwitchDriverSample/usb.c index bacd1bce..84cf7faa 100644 --- a/network/radio/HidSwitchDriverSample/usb.c +++ b/network/radio/HidSwitchDriverSample/usb.c @@ -1,4 +1,4 @@ -#include +#include "RadioSwitchHidUsbFx2.h" #include "usb.tmh" @@ -39,7 +39,7 @@ HidFx2EvtDevicePrepareHardware( // The parent of each USB device object is the driver's framework driver object. The driver cannot change this parent, and the ParentObject // member or the WDF_OBJECT_ATTRIBUTES structure must be NULL. // - // We only create device the first time PrepareHardware is called. If the device is restarted by pnp manager for resource rebalance, we + // We only create device the first time PrepareHardware is called. If the device is restarted by pnp manager for resource rebalance, we // will use the same device handle but then select the interfaces again because the USB stack could reconfigure the device on restart. if (pDevContext->hUsbDevice == NULL) { @@ -162,7 +162,7 @@ void HidFx2EvtUsbInterruptPipeReadComplete( } - // Make sure that there is data in the read packet. + // Make sure that there is data in the read packet. // Depending on the device specification, it is possible for it to return a 0 length read in certain conditions. if (cNumBytesTransferred == 0) { @@ -269,7 +269,7 @@ void HidFx2EvtTimerFunction(_In_ WDFTIMER hTimer) WdfRequestCompleteWithInformation(hRequest, status, cBytesReturned); - } + } else if (status != STATUS_NO_MORE_ENTRIES) { TraceErr(DBG_IOCTL, "(%!FUNC!) WdfIoQueueRetrieveNextRequest status %!STATUS!\n", status); @@ -340,7 +340,7 @@ NTSTATUS HidFx2GetSwitchState(_In_ WDFDEVICE hDevice, _Out_ unsigned char *pbSwi // EvtDeviceD0Entry event callback must perform any operations that are necessary before the specified device is used. // Called every time the hardware needs to be initialized/reinitialized. -// This function is not marked pageable because this function is in the device power up path. +// This function is not marked pageable because this function is in the device power up path. // This function runs at PASSIVE_LEVEL, even though it is not paged. // NTSTATUS HidFx2EvtDeviceD0Entry(_In_ WDFDEVICE hDevice, _In_ WDF_POWER_DEVICE_STATE previousState) @@ -412,7 +412,7 @@ stopped, when it is removed, and when it is powered off. The device is still in D0 when this callback is invoked, which means that the driver can still touch hardware in this routine. -EvtDeviceD0Exit event callback must perform any operations that are necessary before the specified device is moved out of the D0 state. +EvtDeviceD0Exit event callback must perform any operations that are necessary before the specified device is moved out of the D0 state. If the driver needs to save hardware state before the device is powered down, then that should be done here. This function runs at PASSIVE_LEVEL, though it is generally not paged. A driver can optionally make this function pageable if DO_POWER_PAGABLE is set. diff --git a/network/wlan/WDI/PLATFORM/NDIS6/SDIO/sdio.vcxproj b/network/wlan/WDI/PLATFORM/NDIS6/SDIO/sdio.vcxproj index c6089236..af48c0a4 100644 --- a/network/wlan/WDI/PLATFORM/NDIS6/SDIO/sdio.vcxproj +++ b/network/wlan/WDI/PLATFORM/NDIS6/SDIO/sdio.vcxproj @@ -577,6 +577,8 @@ $(OutDir)$(TargetName)$(TargetExt) $(SolutionDir)COMMON\$(Configuration)\$(Platform)\common.lib;$(SolutionDir)PLATFORM\NdisComm\$(Configuration)\$(Platform)\NdisComm.lib;$(SolutionDir)\LIB\x64\hal.lib;$(SolutionDir)\LIB\x64\rtklibcom.lib;$(WindowsSDK_LibraryPath_x64)km\x64\ndis.lib;$(WindowsSDK_LibraryPath_x64)km\x64\ntoskrnl.lib;$(WindowsSDK_LibraryPath_x64)km\x64\sdbus.lib;$(WindowsSDK_LibraryPath_x64)km\x64\wlan\1.0\TlvGeneratorParser.lib; + + $(AdditionalOptions) /IGNORE:4099 true @@ -636,7 +638,7 @@ - @@ -748,4 +750,4 @@ - \ No newline at end of file + diff --git a/network/wlan/WDI/PLATFORM/NDIS6/WDI_Cmds.c b/network/wlan/WDI/PLATFORM/NDIS6/WDI_Cmds.c index d1005a4b..ec5cddd6 100644 --- a/network/wlan/WDI/PLATFORM/NDIS6/WDI_Cmds.c +++ b/network/wlan/WDI/PLATFORM/NDIS6/WDI_Cmds.c @@ -28,7 +28,7 @@ wdi_task_WriteResult( { NdisMoveMemory((u1Byte *)hdr + sizeof(*hdr), tlv, tlvlen); } - + hTask->OutputBufferLength = tlvlen; } @@ -40,7 +40,7 @@ wdi_ScanCb( ) { ADAPTER *pAdapter = (ADAPTER *)pCtx; - + RT_TRACE_F(COMP_MLME, DBG_LOUD, ("%s\n", CustomScan_ScanStateTxt(state))); if(CUSTOM_SCAN_STATE_PRE_DESTROY == state) @@ -59,13 +59,13 @@ wdi_P2PDiscoveryCb( ADAPTER *pAdapter = (ADAPTER *)pCtx; RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; P2P_INFO *info = GET_P2P_INFO(pAdapter); - + RT_TRACE_F(COMP_P2P, DBG_LOUD, ("%s\n", CustomScan_ScanStateTxt(state))); if(CUSTOM_SCAN_STATE_COMPLETED == state) { WDI_TASK_P2P_DISCOVER_PARAMETERS *param = hTask->tlvParser.parsedTlv.paramP2pDiscover; - + MGNT_INFO *mgnt = &pAdapter->MgntInfo; u4Byte it = 0; @@ -118,18 +118,18 @@ wdi_ConstructScanReq( u2Byte duration = (u2Byte)(SCAN_ACTIVE == scanType ? param->DwellTime.ActiveChannelDwellTime : param->DwellTime.PassiveChannelDwellTime); FunctionIn(COMP_SCAN); - + if(param->Optional.BandChannelList_IsPresent) { u4Byte itBand = 0; u4Byte itChnl = 0; - + for(itBand = 0; itBand < param->BandChannelList.ElementCount; itBand++) { for(itChnl = 0; itChnl < param->BandChannelList.pElements[itBand].ChannelList.ElementCount; itChnl++) { u1Byte chnl = (u1Byte)param->BandChannelList.pElements[itBand].ChannelList.pElements[itChnl]; - + CustomScan_AddScanChnl(req, chnl, 1, scanType, duration, 0, NULL); } } @@ -138,7 +138,7 @@ wdi_ConstructScanReq( { RT_CHANNEL_DOMAIN domain = GetDefaultAdapter(pAdapter)->MgntInfo.ChannelPlan; RT_CHANNEL_PLAN *plan = NULL; - + RtActChannelList(pAdapter, RT_CHNL_LIST_ACTION_GET_CHANNEL_PLAN, &domain, &plan); CustomScan_AddChnlPlanChnls(req, plan, scanType, duration, 0, NULL); @@ -163,7 +163,7 @@ wdi_ConstructP2PSpecificChnlReq( { RT_SCAN_TYPE scanType = WDI_P2P_SCAN_TYPE_PASSIVE == param->DiscoverMode.ScanType ? SCAN_PASSIVE : SCAN_ACTIVE; u2Byte duration = (u2Byte)(SCAN_ACTIVE == scanType ? param->DwellTime.ActiveChannelDwellTime : param->DwellTime.PassiveChannelDwellTime); - + if(param->Optional.DiscoveryChannelSettings_IsPresent) { u4Byte itSettings = 0; @@ -171,15 +171,15 @@ wdi_ConstructP2PSpecificChnlReq( u4Byte itChnl = 0; RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("channel setting present\n")); - + for(itSettings = 0; itSettings < param->DiscoveryChannelSettings.ElementCount; itSettings++) { WDI_P2P_DISCOVERY_CHANNEL_SETTINGS_CONTAINER *setting = param->DiscoveryChannelSettings.pElements + itSettings; - + for(itBand = 0; itBand < setting->BandChannelList.ElementCount; itBand++) { WDI_BAND_CHANNEL_LIST_CONTAINER *band = setting->BandChannelList.pElements + itBand; - + for(itChnl = 0; itChnl < band->ChannelList.ElementCount; itChnl++) { WDI_CHANNEL_NUMBER *chnl = band->ChannelList.pElements + itChnl; @@ -206,7 +206,7 @@ wdi_ConstructP2PScanPhaseReq( u2Byte duration = (u2Byte)(SCAN_ACTIVE == scanType ? param->DwellTime.ActiveChannelDwellTime : param->DwellTime.PassiveChannelDwellTime); RT_CHANNEL_DOMAIN domain = GetDefaultAdapter(pAdapter)->MgntInfo.ChannelPlan; RT_CHANNEL_PLAN *plan = NULL; - + RtActChannelList(pAdapter, RT_CHNL_LIST_ACTION_GET_CHANNEL_PLAN, &domain, &plan); CustomScan_AddChnlPlanChnls(req, plan, scanType, duration, MGN_6M, NULL); @@ -254,7 +254,7 @@ wdi_Construct_FakeInvitationRsp( OCTET_STRING osWFDIE, osProbeRspPkt; FunctionIn(COMP_OID_SET); - + // MAC Header p2p_add_ActionFrameMacHdr(fbuf, info->DeviceAddress, dev->mac, info->DeviceAddress); @@ -267,11 +267,11 @@ wdi_Construct_FakeInvitationRsp( // WFD IE, from probe rsp if(dev->rxFrames[P2P_FID_PROBE_RSP] && dev->rxFrames[P2P_FID_PROBE_RSP]->frameLen) { - FillOctetString(osProbeRspPkt, - dev->rxFrames[P2P_FID_PROBE_RSP]->frame, + FillOctetString(osProbeRspPkt, + dev->rxFrames[P2P_FID_PROBE_RSP]->frame, dev->rxFrames[P2P_FID_PROBE_RSP]->frameLen ); - + osWFDIE = PacketGetElement(osProbeRspPkt, EID_Vendor, OUI_SUB_WIFI_DISPLAY, OUI_SUB_DONT_CARE); if(osWFDIE.Length > 0) @@ -284,7 +284,7 @@ wdi_Construct_FakeInvitationRsp( FrameBuf_Dump(fbuf, 0, DBG_LOUD, __FUNCTION__); FunctionOut(COMP_OID_SET); - + return TRUE; } @@ -299,13 +299,13 @@ wdi_Construct_FakePdRsp( { P2P_INFO *info = GET_P2P_INFO(pAdapter); OCTET_STRING osPdReq, osTmpIe; - + FunctionIn(COMP_OID_SET); if(dev->txFrames[P2P_FID_PD_REQ] && dev->txFrames[P2P_FID_PD_REQ]->frameLen) { - FillOctetString(osPdReq, - dev->txFrames[P2P_FID_PD_REQ]->frame, + FillOctetString(osPdReq, + dev->txFrames[P2P_FID_PD_REQ]->frame, dev->txFrames[P2P_FID_PD_REQ]->frameLen ); } @@ -314,7 +314,7 @@ wdi_Construct_FakePdRsp( RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("no corresp. pd req\n")); FillOctetString(osPdReq, NULL, 0); } - + // MAC Header p2p_add_ActionFrameMacHdr(fbuf, info->DeviceAddress, dev->mac, dev->mac); @@ -323,14 +323,14 @@ wdi_Construct_FakePdRsp( // WPS IE, getting from the original PD request if(osPdReq.Length) - { + { osTmpIe = PacketGetElement(osPdReq, EID_Vendor, OUI_SUB_SimpleConfig, OUI_SUB_DONT_CARE); if(osTmpIe.Length) { PacketMakeElement(&fbuf->os, EID_Vendor, osTmpIe); } } - + // WFD IE if(osPdReq.Length) { @@ -338,9 +338,9 @@ wdi_Construct_FakePdRsp( if(osTmpIe.Length) { PacketMakeElement(&fbuf->os, EID_Vendor, osTmpIe); - } + } } - + RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("a fake pd rsp constructed\n")); FrameBuf_Dump(fbuf, 0, DBG_LOUD, __FUNCTION__); @@ -365,7 +365,7 @@ wdi_IndicateRxP2pRspActionFrame( u1Byte *buf = NULL; ULONG buflen = 0; - + NDIS_STATUS_INDICATION *indic = NULL; WDI_MESSAGE_HEADER *wdiHdr = NULL; @@ -384,7 +384,7 @@ wdi_IndicateRxP2pRspActionFrame( } FrameBuf_Init(GEN_TEMP_BUFFER_SIZE, 0, (u1Byte *)pGenBuf->Buffer.Ptr, &fbuf); - + if(WDI_P2P_ACTION_FRAME_PROVISION_DISCOVERY_RESPONSE == ctx->rspType) ft = P2P_FID_PD_RSP; else if(WDI_P2P_ACTION_FRAME_GO_NEGOTIATION_RESPONSE == ctx->rspType) @@ -407,10 +407,10 @@ wdi_IndicateRxP2pRspActionFrame( { dev = p2p_DevList_Get(&info->devList, ctx->da, P2P_DEV_TYPE_DEV); } - + if(NULL == dev) { - RT_TRACE_F(COMP_OID_SET, DBG_WARNING, + RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("dev not found: bGo: %u, mac: %02X:%02X:%02X:%02X:%02X:%02X\n", ctx->bGo, ctx->da[0], ctx->da[1], ctx->da[2], ctx->da[3], ctx->da[4], ctx->da[5] )); @@ -459,9 +459,9 @@ wdi_IndicateRxP2pRspActionFrame( // gen TLV if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationP2pActionFrameReceived( - ¶m, - sizeof(*indic) + sizeof(*wdiHdr), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(*indic) + sizeof(*wdiHdr), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) { RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("gen tlv failed\n")); @@ -471,7 +471,7 @@ wdi_IndicateRxP2pRspActionFrame( // fill ptrs indic = (NDIS_STATUS_INDICATION *)buf; wdiHdr = (WDI_MESSAGE_HEADER *)(buf + sizeof(*indic)); - + // indication data PlatformZeroMemory(indic, sizeof(*indic)); indic->Header.Type = NDIS_OBJECT_TYPE_STATUS_INDICATION; @@ -492,7 +492,7 @@ wdi_IndicateRxP2pRspActionFrame( // indicate NdisMIndicateStatusEx(pAdapter->pNdisCommon->hNdisAdapter, indic); - + // cleanup FreeGenerated((UINT8 *)buf); @@ -504,7 +504,7 @@ wdi_IndicateRxP2pRspActionFrame( } p2p_DevList_Unlock(&info->devList); - + FunctionOut(COMP_OID_SET); return; @@ -534,12 +534,12 @@ wdi_SendP2pActionFrameStateCb( } if(OFF_CHNL_TX_STATE_COMPLETE == state) - { + { RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("complete\n")); bHandled = TRUE; break; } - + if(OFF_CHNL_TX_STATE_FRAME_SENT == state) { RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("frame sent\n")); @@ -563,11 +563,11 @@ wdi_SendP2pReqActionFrameStateCb( ADAPTER *pAdapter = ctx->pAdapter; wdi_SendP2pActionFrameStateCb(req, state, pCtx); - + if(OFF_CHNL_TX_STATE_COMPLETE == state) { P2P_INFO *info = GET_P2P_INFO(pAdapter); - + WDI_CMD_P2pSendRequestActionFrameComplete(pAdapter, ctx); RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("restore StateBeforeScan to initialized\n")); @@ -581,7 +581,7 @@ wdi_SendP2pReqActionFrameStateCb( ) { wdi_IndicateRxP2pRspActionFrame(pAdapter, ctx); - } + } } else if(OFF_CHNL_TX_STATE_RETRY == state) { @@ -592,17 +592,17 @@ wdi_SendP2pReqActionFrameStateCb( if(pAdapter->bInHctTest) { - // Not to skip probing under HCT test, because it wastes time + // Not to skip probing under HCT test, because it wastes time // sending action frame to peer on its Listen Channel when peer // is not doing extended listen bSkip = FALSE; } - + if(bSkip) { WDI_SendAction_SkipProbeTemporarilly(req); } - + RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("retry with token: %u, reqType: %u, skip probe: %u\n", newToken, ctx->reqType, bSkip)); bSkip = !bSkip; @@ -626,13 +626,13 @@ wdi_SendP2pRspActionFrameStateCb( RT_TRACE_F(COMP_P2P, DBG_LOUD, ("state = %d\n", state)); wdi_SendP2pActionFrameStateCb(req, state, pCtx); - + if(OFF_CHNL_TX_STATE_COMPLETE == state) { WDI_CMD_P2pSendResponseActionFrameComplete(pAdapter, ctx); - // restore Dialog Token in P2PInfo since we are sending - // response action frame, self dialog token shall not be + // restore Dialog Token in P2PInfo since we are sending + // response action frame, self dialog token shall not be // modified RT_TRACE_F(COMP_P2P, DBG_LOUD, ("restore token from %u to %u\n", info->DialogToken, ctx->oldToken)); info->DialogToken = ctx->oldToken; @@ -643,7 +643,7 @@ wdi_SendP2pRspActionFrameStateCb( if(WDI_P2P_ACTION_FRAME_GO_NEGOTIATION_CONFIRM == ctx->rspType) { wdi_IndicateRxP2pRspActionFrame(pAdapter, ctx); - } + } } else if(OFF_CHNL_TX_STATE_RETRY == state) { @@ -664,7 +664,7 @@ wdi_SendActionFrameStateCb( BOOLEAN bHandled = FALSE; N63C_SEND_ACTION_CTX *ctx = (N63C_SEND_ACTION_CTX *)pCtx; ADAPTER *pAdapter = ctx->pAdapter; - + RT_TRACE(COMP_OID_SET, DBG_TRACE, ("wdi_SendActionFrameStateCb (0x%x)\n", state)); do @@ -677,12 +677,12 @@ wdi_SendActionFrameStateCb( } if(OFF_CHNL_TX_STATE_COMPLETE == state) - { + { RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("complete\n")); bHandled = TRUE; break; } - + if(OFF_CHNL_TX_STATE_FRAME_SENT == state) { RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("frame sent\n")); @@ -700,7 +700,7 @@ wdi_SendActionFrameStateCb( { WDI_SendAction_SkipProbeTemporarilly(req); } - + RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("retry with token: %u, reqType: %u, skip probe: %u\n", newToken, ctx->reqType, bSkip)); bSkip = !bSkip; @@ -728,7 +728,7 @@ wdi_SendReqActionFrameStateCb( RT_TRACE(COMP_OID_SET, DBG_TRACE, ("wdi_SendReqActionFrameStateCb (0x%x)\n", state)); wdi_SendActionFrameStateCb(req, state, pCtx); - + if(OFF_CHNL_TX_STATE_COMPLETE == state) { WDI_CMD_SendReqActionFrameComplete(pAdapter, ctx); @@ -750,11 +750,11 @@ wdi_SendRspActionFrameStateCb( { WDI_SEND_ACTION_CTX *ctx = (WDI_SEND_ACTION_CTX *)pCtx; ADAPTER *pAdapter = ctx->pAdapter; - + RT_TRACE(COMP_OID_SET, DBG_TRACE, ("wdi_SendRspActionFrameStateCb (0x%x)\n", state)); wdi_SendActionFrameStateCb(req, state, pCtx); - + if(OFF_CHNL_TX_STATE_COMPLETE == state) { WDI_CMD_SendRspActionFrameComplete(pAdapter, ctx); @@ -780,8 +780,8 @@ Wdi_Task_Scan( BOOLEAN bScanByRoam = FALSE; PMGNT_INFO pMgntInfo =&(pAdapter->MgntInfo); - RT_TRACE(COMP_OID_SET, DBG_LOUD, - ("==> Wdi_Task_Scan(): Input InformationBuffer (%d)\n", + RT_TRACE(COMP_OID_SET, DBG_LOUD, + ("==> Wdi_Task_Scan(): Input InformationBuffer (%d)\n", pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength)); ScanRequest.dot11BSSType = dot11_BSS_type_infrastructure; @@ -793,21 +793,21 @@ Wdi_Task_Scan( CopyMem(ScanRequest.dot11BSSID, param->BSSID.Address, ETHERNET_ADDRESS_LENGTH); RT_PRINT_ADDR(COMP_SCAN, DBG_LOUD, ("ScanRequest \n"), ScanRequest.dot11BSSID); - RT_TRACE(COMP_OID_SET, DBG_LOUD, ("WIFI_TLV_SSID\n")); + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("WIFI_TLV_SSID\n")); MgntClearSsidsToScan(pAdapter); - + for(itSsidl = 0; itSsidl < param->SSIDList.ElementCount; itSsidl++) { WdiSsid = param->SSIDList.pElements[itSsidl]; - + RT_PRINT_STR(COMP_MLME, DBG_LOUD, "===> Wdi_Task_Scan(): ", WdiSsid.pElements, WdiSsid.ElementCount); - + Ssid.Octet = WdiSsid.pElements; - Ssid.Length = (u2Byte)WdiSsid.ElementCount; - + Ssid.Length = (u2Byte)WdiSsid.ElementCount; + RT_PRINT_STR(COMP_MLME, DBG_LOUD, "===> Wdi_Task_Scan(): SSid ", Ssid.Octet, Ssid.Length); - + MgntAddSsidsToScan(pAdapter, Ssid); } RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Scan Type\n")); @@ -827,11 +827,11 @@ Wdi_Task_Scan( if(param->Optional.VendorIEs_IsPresent) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("WIFI_TLV_VENDORIE\n")); - - MgntActSet_AdditionalProbeReqIE(pAdapter, + + MgntActSet_AdditionalProbeReqIE(pAdapter, (u1Byte *)param->VendorIEs.pElements, (u4Byte)param->VendorIEs.ElementCount); - } + } // Sinda, 20150512 // Skip all scan triggered by Roam. @@ -857,7 +857,7 @@ Wdi_Task_Scan( { if(param->Optional.VendorIEs_IsPresent) { - MgntActSet_AdditionalProbeReqIE(pAdapter, + MgntActSet_AdditionalProbeReqIE(pAdapter, (u1Byte *)param->VendorIEs.pElements, (u4Byte)param->VendorIEs.ElementCount); } @@ -865,11 +865,11 @@ Wdi_Task_Scan( if(NULL != (req = CustomScan_AllocReq(GET_CUSTOM_SCAN_INFO(pAdapter), NULL, NULL))) { wdi_ConstructScanReq(pAdapter, param, req); - + CustomScan_SetTimeBound(req, param->DwellTime.MaximumScanTime); CustomScan_SetupCbCtx(req, wdi_ScanCb, pAdapter); CustomScan_SetRepeatCount(req, param->ScanModeParameters.ScanRepeatCount); - + CustomScan_IssueReq(GET_CUSTOM_SCAN_INFO(pAdapter), req, CUSTOM_SCAN_SRC_TYPE_SYS, "sys"); } } @@ -878,7 +878,7 @@ Wdi_Task_Scan( WDI_IndicateScanComplete(pAdapter, RT_STATUS_FAILURE); } } - + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("<== Wdi_Task_Scan()\n")); return status; } @@ -897,15 +897,15 @@ Wdi_Task_Connect( WDI_TASK_CONNECT_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramConnect; PWDI_CONNECT_BSS_ENTRY_CONTAINER connectBssEntry = NULL; PMGNT_INFO pMgntInfo=&pAdapter->MgntInfo; - - PWDI_MESSAGE_HEADER pWdiHeader + + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pOidHandle->pInputBuffer; - //Save PMKID + //Save PMKID u4Byte ulIndex, i, j; BOOLEAN blInserted; u1Byte bssidcount=0; - int NumPreferredBSSID = Params->PreferredBSSEntryList.ElementCount; + int NumPreferredBSSID = Params->PreferredBSSEntryList.ElementCount; RT_TRACE(COMP_MLME, DBG_LOUD, ("==> Wdi_Task_Connect()\n")); @@ -918,26 +918,26 @@ Wdi_Task_Connect( N6_ASSIGN_OBJECT_HEADER( SsidList.Header, - NDIS_OBJECT_TYPE_DEFAULT, - DOT11_SSID_LIST_REVISION_1, + NDIS_OBJECT_TYPE_DEFAULT, + DOT11_SSID_LIST_REVISION_1, sizeof(DOT11_SSID_LIST) ); - // Clear all entries + // Clear all entries for( ulIndex=0; ulIndexPMKIDList[ulIndex].bUsed = FALSE; } pSecInfo->PMKIDCount = 0; - - FtResetEntryList(pAdapter); + + FtResetEntryList(pAdapter); // TODO: Choose corresponding adapter before assigning parameters for(bssidcount=0;bssidcountPreferredBSSEntryList.pElements[bssidcount]; if( connectBssEntry->Optional.PMKID_IsPresent == TRUE ) - { + { // 2. Insert or cover with new PMKID. blInserted = FALSE; for(j=0 ; jOptional.FTInitialAssocParameters_IsPresent) { FtUpdateEntryInfo(pAdapter, FT_ENTRY_ACTION_UPDATE_MDE, connectBssEntry->BSSID.Address, @@ -986,12 +986,12 @@ Wdi_Task_Connect( connectBssEntry->FTReAssocParameters.MDE.pElements, connectBssEntry->FTReAssocParameters.MDE.ElementCount); RT_PRINT_DATA(COMP_MLME, DBG_LOUD, "FTReAssocParameters MDE:\n", connectBssEntry->FTReAssocParameters.MDE.pElements, connectBssEntry->FTReAssocParameters.MDE.ElementCount); - + FtUpdateEntryInfo(pAdapter, FT_ENTRY_ACTION_UPDATE_FTE, connectBssEntry->BSSID.Address, connectBssEntry->FTReAssocParameters.FTE.pElements, connectBssEntry->FTReAssocParameters.FTE.ElementCount); RT_PRINT_DATA(COMP_MLME, DBG_LOUD, "FTReAssocParameters FTE:\n", connectBssEntry->FTReAssocParameters.FTE.pElements, connectBssEntry->FTReAssocParameters.FTE.ElementCount); - + FtUpdateEntryInfo(pAdapter, FT_ENTRY_ACTION_UPDATE_PMKR0_NAME, connectBssEntry->BSSID.Address, connectBssEntry->FTReAssocParameters.PMKR0Name.pmkname.Name, sizeof(WDI_TYPE_PMK_NAME)); RT_PRINT_DATA(COMP_MLME, DBG_LOUD, "FTReAssocParameters PMKR0:\n", @@ -1019,14 +1019,14 @@ Wdi_Task_Connect( // TODO: HiddenNetwork / MFPEnabled / HostFIPSModeEnabled pMgntInfo->bRoamRequest = Params->ConnectParameters.ConnectionSettings.RoamRequest; RT_TRACE( COMP_MLME, DBG_LOUD, ("bRoamRequest %d\n", pMgntInfo->bRoamRequest) ); - + pMgntInfo->SafeModeEnabled = Params->ConnectParameters.ConnectionSettings.HostFIPSModeEnabled; - + if(pMgntInfo->SafeModeEnabled && !pMgntInfo->pHTInfo->bEnableHT) - pMgntInfo->pStaQos->QosCapability = QOS_DISABLE; + pMgntInfo->pStaQos->QosCapability = QOS_DISABLE; else - pMgntInfo->pStaQos->QosCapability = pMgntInfo->pStaQos->QosCapabilityBackup; - + pMgntInfo->pStaQos->QosCapability = pMgntInfo->pStaQos->QosCapabilityBackup; + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Wdi_task_connect(): bExcludeUnencrypted %d HostFIPSModeEnabled %d QosCapability 0x%x QosCapabilityBackup 0x%x enableHT %d\n", pMgntInfo->bExcludeUnencrypted, pMgntInfo->SafeModeEnabled, pMgntInfo->pStaQos->QosCapability, pMgntInfo->pStaQos->QosCapabilityBackup, pMgntInfo->pHTInfo->bEnableHT)); //3 DesiredSSIDList @@ -1040,9 +1040,9 @@ Wdi_Task_Connect( RT_PRINT_STR(COMP_MLME, DBG_LOUD, ("Desired SSID \n"), SsidList.SSIDs[i].ucSSID, SsidList.SSIDs[i].uSSIDLength); } pNdisCommon->dot11DesiredSSIDList = SsidList; - + //3 Authentication Algorithm - N6CSet_DOT11_AUTHENTICATION_ALOGORITHM(pAdapter, Params->ConnectParameters.AuthenticationAlgorithms.pElements[0]); + N6CSet_DOT11_AUTHENTICATION_ALOGORITHM(pAdapter, Params->ConnectParameters.AuthenticationAlgorithms.pElements[0]); RT_TRACE_F(COMP_SEC, DBG_LOUD, ("AuthenticationAlgorithms count = %d\n", Params->ConnectParameters.AuthenticationAlgorithms.ElementCount)); //3 Unicast Cipher Algorithm @@ -1052,20 +1052,20 @@ Wdi_Task_Connect( //3 Multicast Cipher Algorithm N6CSet_DOT11_MULTICAST_CIPHER_ALGORITHM(pAdapter, Params->ConnectParameters.MulticastCipherAlgorithms.pElements[0]); RT_TRACE_F(COMP_SEC, DBG_LOUD, ("MulticastCipherAlgorithms count = %d\n", Params->ConnectParameters.MulticastCipherAlgorithms.ElementCount)); - - + + //3 Additional Association Request IEs if(Params->ConnectParameters.Optional.AssociationRequestVendorIE_IsPresent) { if(Params->ConnectParameters.AssociationRequestVendorIE.ElementCount > 0) { RT_TRACE(COMP_MLME, DBG_LOUD, ("Wdi_Task_Connect(): set association request additional IE\n")); - MgntActSet_AdditionalAssocReqIE(pAdapter, - Params->ConnectParameters.AssociationRequestVendorIE.pElements, + MgntActSet_AdditionalAssocReqIE(pAdapter, + Params->ConnectParameters.AssociationRequestVendorIE.pElements, Params->ConnectParameters.AssociationRequestVendorIE.ElementCount ); - - RT_PRINT_DATA(COMP_MLME, DBG_TRACE, ("Wdi_Task_Connect(): AssociationRequestVendorIE\n"), + + RT_PRINT_DATA(COMP_MLME, DBG_TRACE, ("Wdi_Task_Connect(): AssociationRequestVendorIE\n"), Params->ConnectParameters.AssociationRequestVendorIE.pElements, Params->ConnectParameters.AssociationRequestVendorIE.ElementCount); } @@ -1084,11 +1084,11 @@ Wdi_Task_Connect( { RT_TRACE(COMP_MLME, DBG_LOUD, ("Wdi_Task_Connect(): set disallowed BSSIDs\n")); MgntActSet_ExcludedMacAddressList( - pAdapter, - (pu1Byte)Params->ConnectParameters.DisallowedBSSIDs.pElements, + pAdapter, + (pu1Byte)Params->ConnectParameters.DisallowedBSSIDs.pElements, Params->ConnectParameters.DisallowedBSSIDs.ElementCount ); - + for(; i < Params->ConnectParameters.DisallowedBSSIDs.ElementCount; i++) { RT_PRINT_ADDR(COMP_MLME, DBG_TRACE, ("Wdi_Task_Connect(): disallowed BSSID:"), @@ -1120,7 +1120,7 @@ Wdi_Task_Connect( PTLV_WDI_STRUCT pTlvData = NULL; ULONG BytesProcessed = 0; ULONG Prefix = sizeof(WDI_MESSAGE_HEADER); - + pTlvData = (PTLV_WDI_STRUCT)((pu1Byte)pOidHandle->pInputBuffer + sizeof(WDI_MESSAGE_HEADER)); // WDI_CONNECT_BSS_ENTRY @@ -1130,20 +1130,20 @@ Wdi_Task_Connect( DOT11_SSID_LIST SsidList; u1Byte NumSsid = 0; PRT_SECURITY_T pSecInfo = &(pAdapter->MgntInfo.SecurityInfo); - + InputBufferLength = pTlvData->Length; N6_ASSIGN_OBJECT_HEADER( SsidList.Header, - NDIS_OBJECT_TYPE_DEFAULT, - DOT11_SSID_LIST_REVISION_1, + NDIS_OBJECT_TYPE_DEFAULT, + DOT11_SSID_LIST_REVISION_1, sizeof(DOT11_SSID_LIST) ); SsidList.uNumOfEntries = NumSsid; pTlvData = (PTLV_WDI_STRUCT)((pu1Byte)pTlvData->Value); - + while(BytesProcessed < InputBufferLength) { // Parse Type @@ -1154,7 +1154,7 @@ Wdi_Task_Connect( RT_TRACE(COMP_MLME, DBG_LOUD, ("unknown TLV 0x%x\n", pTlvData->Type)); } break; - + case WDI_TLV_CONNECTION_SETTINGS: { u1Byte RoamRequest = 0; @@ -1168,7 +1168,7 @@ Wdi_Task_Connect( ExcludeUnencrypted = *(pu1Byte)(pTlvData->Value + 2); MFPEnabled = *(pu1Byte)(pTlvData->Value + 3); HostFIPSModeEnabled = *(pu1Byte)(pTlvData->Value + 4); - + RT_TRACE(COMP_MLME, DBG_LOUD, ("WDI_TLV_CONNECTION_SETTINGS\n")); RT_TRACE(COMP_MLME, DBG_LOUD, ("RoamRequest = %d, HiddenNetwork = %d, ExcludeUnencrypted = %d, MFPEnabled = %d, HostFIPSModeEnabled = %d\n", RoamRequest, HiddenNetwork, ExcludeUnencrypted, MFPEnabled, HostFIPSModeEnabled)); @@ -1208,7 +1208,7 @@ Wdi_Task_Connect( case WDI_TLV_MULTICAST_CIPHER_ALGO_LIST: { u4Byte AlgorithmId = (*((pu4Byte)(pTlvData->Value))); - + RT_TRACE(COMP_MLME, DBG_LOUD, ("WDI_TLV_MULTICAST_CIPHER_ALGO_LIST\n")); switch( AlgorithmId ) @@ -1222,7 +1222,7 @@ Wdi_Task_Connect( pSecInfo->GroupEncAlgorithm = RT_ENC_ALG_WEP40; RT_TRACE( COMP_SEC, DBG_LOUD, ("Wdi_Task_Connect(): DOT11_CIPHER_ALGO_WEP\n") ); break; - + case WDI_CIPHER_ALGO_WEP40: pSecInfo->GroupEncAlgorithm = RT_ENC_ALG_WEP40; RT_TRACE( COMP_SEC, DBG_LOUD, ("Wdi_Task_Connect(): DOT11_CIPHER_ALGO_WEP40\n") ); @@ -1239,8 +1239,8 @@ Wdi_Task_Connect( break; case DOT11_CIPHER_ALGO_WAPI_SMS4: //For WAPI IHV service support add by ylb 20111114 - pSecInfo->GroupEncAlgorithm = RT_ENC_ALG_SMS4; - RT_TRACE( COMP_SEC, DBG_LOUD, ("Wdi_Task_Connect(): DOT11_CIPHER_ALGO_WAPI_SMS4\n") ); + pSecInfo->GroupEncAlgorithm = RT_ENC_ALG_SMS4; + RT_TRACE( COMP_SEC, DBG_LOUD, ("Wdi_Task_Connect(): DOT11_CIPHER_ALGO_WAPI_SMS4\n") ); break; case WDI_CIPHER_ALGO_WEP104: pSecInfo->GroupEncAlgorithm = RT_ENC_ALG_WEP104; @@ -1263,7 +1263,7 @@ Wdi_Task_Connect( case WDI_TLV_UNICAST_CIPHER_ALGO_LIST: { u4Byte AlgorithmId = (*((pu4Byte)(pTlvData->Value))); - + RT_TRACE(COMP_MLME, DBG_LOUD, ("WDI_TLV_UNICAST_CIPHER_ALGO_LIST\n")); N6CSet_DOT11_UNICAST_CIPHER_ALGORITHM(pAdapter, (DOT11_CIPHER_ALGORITHM)AlgorithmId); @@ -1293,7 +1293,7 @@ Wdi_Task_Connect( RT_TRACE(COMP_MLME, DBG_LOUD, ("WDI_TLV_ALLOWED_BSSIDS_LIST\n")); } break; - + } // Parse Length @@ -1302,7 +1302,7 @@ Wdi_Task_Connect( // Parse Content BytesProcessed += (4 + pTlvData->Length); - + pTlvData = (PTLV_WDI_STRUCT)((pu1Byte)pOidHandle->pInputBuffer + Prefix + 4 + BytesProcessed); } @@ -1322,12 +1322,12 @@ Wdi_Task_Connect( { pMgntInfo->Ssid.Octet = pNdisCommon->dot11DesiredSSIDList.SSIDs[0].ucSSID; pMgntInfo->Ssid.Length = (u2Byte)pNdisCommon->dot11DesiredSSIDList.SSIDs[0].uSSIDLength; - + pMgntInfo->bDisconnectRequest = FALSE; RT_TRACE(COMP_MLME, DBG_LOUD, ("This is roam request, go to roam flow\n")); MgntLinkStatusSetRoamingState(pAdapter, 0, RT_ROAMING_BY_DEAUTH, ROAMINGSTATE_SCANNING); DrvIFIndicateRoamingStart(pAdapter); - + if( MgntRoamRetry(pAdapter, FALSE) == FALSE ) ndisStatus = NDIS_STATUS_FAILURE; else @@ -1349,7 +1349,7 @@ Wdi_Task_Disconnect( WDI_TASK_DISCONNECT_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramDisconnect; NDIS_OID_REQUEST *req = NULL; - + FunctionIn(COMP_OID_SET); do @@ -1358,7 +1358,7 @@ Wdi_Task_Disconnect( { RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("N6CSet_DOT11_DISCONNECT_REQUEST returns: 0x%08X\n", status)); break; - } + } }while(FALSE); // M4 indication is not required since bWaitComplete in RT_SUPPORT_TASKs is FALSE @@ -1389,12 +1389,12 @@ Wdi_Task_CreatePort( NDIS_OID_REQUEST *req = NULL; WDI_TASK_CREATE_PORT_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramCreatePort; - + FunctionIn(COMP_OID_SET); do { - RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("NdisPortNumber:%d OpModeMask: 0x%08X\n", + RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("NdisPortNumber:%d OpModeMask: 0x%08X\n", param->CreatePortParameters.NdisPortNumber, param->CreatePortParameters.OpModeMask)); @@ -1412,19 +1412,19 @@ Wdi_Task_CreatePort( ) // TODO: OpModeMask is a bitmap with combination of possible op modes { status = N62C_OID_DOT11_CREATE_MAC(pAdapter, req); - + if(NDIS_STATUS_SUCCESS != status && NDIS_STATUS_PENDING != status) { RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("N62C_OID_DOT11_CREATE_MAC returns error: 0x%08X\n", status)); Wdi_Xlat_FreeOid(req); } - + break; } else {// cases which we don't need to create mac DOT11_MAC_INFO *macInfo = req->DATA.METHOD_INFORMATION.InformationBuffer; - + status = NDIS_STATUS_SUCCESS; macInfo->uNdisPortNumber = 0; @@ -1436,7 +1436,7 @@ Wdi_Task_CreatePort( } }while(FALSE); - + FunctionOut(COMP_OID_SET); return status; } @@ -1452,9 +1452,9 @@ Wdi_Task_DeletePort( NDIS_OID_REQUEST *req = NULL; PADAPTER pTargetAdapter = NULL; WDI_TASK_DELETE_PORT_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramDeletePort; - + FunctionIn(COMP_OID_SET); - + do { if(NULL == (req = Wdi_Xlat_AllocDeleteMacOid(pOidHandle, param))) @@ -1462,36 +1462,36 @@ Wdi_Task_DeletePort( status = NDIS_STATUS_RESOURCES; break; } - + // delete mac if(0 != param->DeletePortParameters.PortNumber) { //Delete group peer. WDI_DeleteGroupPeer(pAdapter, param->DeletePortParameters.PortNumber); - + status = N62C_OID_DOT11_DELETE_MAC(pAdapter, req); - + if(NDIS_STATUS_SUCCESS != status && NDIS_STATUS_PENDING != status) { RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("N62C_OID_DOT11_DELETE_MAC returns error: 0x%08X\n", status)); Wdi_Xlat_FreeOid(req); } - + break; } else {// cases which we don't need to delete mac status = NDIS_STATUS_SUCCESS; - + //Delete group peer. WDI_DeleteGroupPeer(pAdapter, param->DeletePortParameters.PortNumber); - + WDI_CMD_DeletePortComplete(pAdapter, req, status); break; } - + }while(FALSE); - + FunctionOut(COMP_OID_SET); return status; } @@ -1513,16 +1513,16 @@ Wdi_Task_SetApCipherKeyMappingKey( if(!pEntry) return NDIS_STATUS_INVALID_DATA; - + CopyMem(pEntry->perSTAKeyInfo.PTK, pKeyMaterial, keyLen); // Added by Annie, 2005-07-12. - + if(WDI_CIPHER_ALGO_TKIP == cipherAlgo) { pEntry->perSTAKeyInfo.TempEncKey = pEntry->perSTAKeyInfo.PTK+TKIP_ENC_KEY_POS; - pEntry->perSTAKeyInfo.TxMICKey = pEntry->perSTAKeyInfo.PTK+(TKIP_MIC_KEY_POS); + pEntry->perSTAKeyInfo.TxMICKey = pEntry->perSTAKeyInfo.PTK+(TKIP_MIC_KEY_POS); pEntry->perSTAKeyInfo.RxMICKey = pEntry->perSTAKeyInfo.PTK+(TKIP_MIC_KEY_POS+TKIP_MIC_KEY_LEN); - //Add for AP mode HW enc,by CCW + //Add for AP mode HW enc,by CCW ucIndex = AP_FindFreeEntry(pAdapter , pEntry->MacAddr); if(ucIndex == TOTAL_CAM_ENTRY) { @@ -1531,12 +1531,12 @@ Wdi_Task_SetApCipherKeyMappingKey( } //set key - AP_Setkey(pAdapter , + AP_Setkey(pAdapter , pEntry->perSTAKeyInfo.pWLanSTA->MacAddr, - ucIndex, // Entey index + ucIndex, // Entey index CAM_TKIP, - 0, // Parise key - pEntry->perSTAKeyInfo.TempEncKey); + 0, // Parise key + pEntry->perSTAKeyInfo.TempEncKey); pEntry->keyindex = ucIndex; } @@ -1544,28 +1544,28 @@ Wdi_Task_SetApCipherKeyMappingKey( { // AES mode AP-WPA AES,CCW AESCCMP_BLOCK blockKey; AUTH_PKEY_MGNT_TAG *pKeyMgnt = &pEntry->perSTAKeyInfo; - + RT_TRACE(COMP_SEC, DBG_LOUD, ("===>CCMP Set Station Key.\n")); RT_PRINT_ADDR(COMP_SEC, DBG_LOUD, "===> Peer Address : ", addr); - - //Add for AP mode HW enc,by CCW + + //Add for AP mode HW enc,by CCW ucIndex = AP_FindFreeEntry(pAdapter, pEntry->MacAddr); if(ucIndex == TOTAL_CAM_ENTRY) { RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("[Warning]: Cam Entry is FULL!!!\n")); return NDIS_STATUS_INVALID_DATA; } - - //Set Key + + //Set Key PlatformMoveMemory(blockKey.x , pEntry->perSTAKeyInfo.PTK, 16); AES_SetKey(blockKey.x, AESCCMP_BLK_SIZE * 8, (u4Byte *)pEntry->perSTAKeyInfo.AESKeyBuf); //set hw key - AP_Setkey(pAdapter , + AP_Setkey(pAdapter , pEntry->perSTAKeyInfo.pWLanSTA->MacAddr, - ucIndex, // Entey index + ucIndex, // Entey index CAM_AES, - 0, // Parise key - pEntry->perSTAKeyInfo.PTK); + 0, // Parise key + pEntry->perSTAKeyInfo.PTK); pEntry->keyindex = ucIndex; } @@ -1599,7 +1599,7 @@ Wdi_Task_SetApCipherDefaultKey( else if(WDI_CIPHER_ALGO_CCMP == cipherAlgo) { AESCCMP_BLOCK blockKey; - + PlatformMoveMemory(blockKey.x, pGlInfo->GTK, 16); pMgntInfo->SecurityInfo.GroupTransmitKeyIdx = (u1Byte)keyId; AES_SetKey(blockKey.x, AESCCMP_BLK_SIZE * 8, (u4Byte *)pGlInfo->AESGTK); @@ -1618,7 +1618,7 @@ Wdi_Task_Set_Radio_State( PRT_NDIS6_COMMON pNdisCommon = pAdapter->pNdisCommon; ULONG InputBufferLength = pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength; WDI_SET_RADIO_STATE_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramSetRadioState; - + RT_TRACE(COMP_MLME, DBG_LOUD, ("==> Wdi_Task_Set_Radio_State()\n")); if( Params->SoftwareRadioState == TRUE ) @@ -1657,8 +1657,8 @@ Wdi_Task_Roam( u4Byte ulIndex, i, j; BOOLEAN blInserted; u1Byte bssidcount=0; - int NumPreferredBSSID = Params->PreferredBSSEntryList.ElementCount; - + int NumPreferredBSSID = Params->PreferredBSSEntryList.ElementCount; + RT_TRACE(COMP_MLME, DBG_LOUD, ("==> Wdi_Task_Roam()\n")); @@ -1671,28 +1671,28 @@ Wdi_Task_Roam( N6_ASSIGN_OBJECT_HEADER( SsidList.Header, - NDIS_OBJECT_TYPE_DEFAULT, - DOT11_SSID_LIST_REVISION_1, + NDIS_OBJECT_TYPE_DEFAULT, + DOT11_SSID_LIST_REVISION_1, sizeof(DOT11_SSID_LIST) ); // TODO: Choose corresponding adapter before assigning parameters - - // Clear all entries + + // Clear all entries for( ulIndex=0; ulIndexPMKIDList[ulIndex].bUsed = FALSE; } pSecInfo->PMKIDCount = 0; - - FtResetEntryList(pAdapter); + + FtResetEntryList(pAdapter); // TODO: Choose corresponding adapter before assigning parameters for(bssidcount=0;bssidcountPreferredBSSEntryList.pElements[bssidcount]; if( connectBssEntry->Optional.PMKID_IsPresent == TRUE ) - { + { // 2. Insert or cover with new PMKID. blInserted = FALSE; for(j=0 ; jOptional.FTInitialAssocParameters_IsPresent) { FtUpdateEntryInfo(pAdapter, FT_ENTRY_ACTION_UPDATE_MDE, connectBssEntry->BSSID.Address, @@ -1741,12 +1741,12 @@ Wdi_Task_Roam( connectBssEntry->FTReAssocParameters.MDE.pElements, connectBssEntry->FTReAssocParameters.MDE.ElementCount); RT_PRINT_DATA(COMP_MLME, DBG_LOUD, "FTReAssocParameters MDE:\n", connectBssEntry->FTReAssocParameters.MDE.pElements, connectBssEntry->FTReAssocParameters.MDE.ElementCount); - + FtUpdateEntryInfo(pAdapter, FT_ENTRY_ACTION_UPDATE_FTE, connectBssEntry->BSSID.Address, connectBssEntry->FTReAssocParameters.FTE.pElements, connectBssEntry->FTReAssocParameters.FTE.ElementCount); RT_PRINT_DATA(COMP_MLME, DBG_LOUD, "FTReAssocParameters FTE:\n", connectBssEntry->FTReAssocParameters.FTE.pElements, connectBssEntry->FTReAssocParameters.FTE.ElementCount); - + FtUpdateEntryInfo(pAdapter, FT_ENTRY_ACTION_UPDATE_PMKR0_NAME, connectBssEntry->BSSID.Address, connectBssEntry->FTReAssocParameters.PMKR0Name.pmkname.Name, sizeof(WDI_TYPE_PMK_NAME)); RT_PRINT_DATA(COMP_MLME, DBG_LOUD, "FTReAssocParameters PMKR0:\n", @@ -1768,26 +1768,26 @@ Wdi_Task_Roam( RT_PRINT_DATA( COMP_MLME, DBG_LOUD, "PMKID: ", pSecInfo->PMKIDList[ulIndex].PMKID, connectBssEntry->PMKID.ElementCount); } } - + pAdapter->MgntInfo.bExcludeUnencrypted = Params->ConnectParameters.ConnectionSettings.ExcludeUnencrypted; // TODO: HiddenNetwork / MFPEnabled / HostFIPSModeEnabled pMgntInfo->SafeModeEnabled = Params->ConnectParameters.ConnectionSettings.HostFIPSModeEnabled; - + if(pMgntInfo->SafeModeEnabled && !pMgntInfo->pHTInfo->bEnableHT) - pMgntInfo->pStaQos->QosCapability = QOS_DISABLE; + pMgntInfo->pStaQos->QosCapability = QOS_DISABLE; else - pMgntInfo->pStaQos->QosCapability = pMgntInfo->pStaQos->QosCapabilityBackup; - + pMgntInfo->pStaQos->QosCapability = pMgntInfo->pStaQos->QosCapabilityBackup; + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Wdi_task_roam(): bExcludeUnencrypted %d HostFIPSModeEnabled %d QosCapability 0x%x\n", pMgntInfo->bExcludeUnencrypted, pMgntInfo->SafeModeEnabled, pMgntInfo->pStaQos->QosCapability)); - + //3 RoamNeededReason if( Params->ConnectParameters.ConnectionSettings.RoamRequest == TRUE ) { AssocStatus = Params->ConnectParameters.ConnectionSettings.RoamNeededReason; RT_TRACE_F(COMP_MLME, DBG_LOUD, ("RoamNeededReason %d\n", AssocStatus)); } - + //3 DesiredSSIDList SsidList.uNumOfEntries = Params->ConnectParameters.SSIDList.ElementCount; @@ -1809,19 +1809,19 @@ Wdi_Task_Roam( //3 Multicast Cipher Algorithm N6CSet_DOT11_MULTICAST_CIPHER_ALGORITHM(pAdapter, Params->ConnectParameters.MulticastCipherAlgorithms.pElements[0]); - + //3 Additional Association Request IEs if(Params->ConnectParameters.Optional.AssociationRequestVendorIE_IsPresent) { if(Params->ConnectParameters.AssociationRequestVendorIE.ElementCount > 0) { RT_TRACE(COMP_MLME, DBG_LOUD, ("Wdi_Task_Roam(): set association request additional IE\n")); - MgntActSet_AdditionalAssocReqIE(pAdapter, - Params->ConnectParameters.AssociationRequestVendorIE.pElements, + MgntActSet_AdditionalAssocReqIE(pAdapter, + Params->ConnectParameters.AssociationRequestVendorIE.pElements, Params->ConnectParameters.AssociationRequestVendorIE.ElementCount ); - - RT_PRINT_DATA(COMP_MLME, DBG_TRACE, ("Wdi_Task_Roam(): AssociationRequestVendorIE\n"), + + RT_PRINT_DATA(COMP_MLME, DBG_TRACE, ("Wdi_Task_Roam(): AssociationRequestVendorIE\n"), Params->ConnectParameters.AssociationRequestVendorIE.pElements, Params->ConnectParameters.AssociationRequestVendorIE.ElementCount); } @@ -1840,11 +1840,11 @@ Wdi_Task_Roam( { RT_TRACE(COMP_MLME, DBG_LOUD, ("Wdi_Task_Roam(): set disallowed BSSIDs\n")); MgntActSet_ExcludedMacAddressList( - pAdapter, - (pu1Byte)Params->ConnectParameters.DisallowedBSSIDs.pElements, + pAdapter, + (pu1Byte)Params->ConnectParameters.DisallowedBSSIDs.pElements, Params->ConnectParameters.DisallowedBSSIDs.ElementCount ); - + for(; i < Params->ConnectParameters.DisallowedBSSIDs.ElementCount; i++) { RT_PRINT_ADDR(COMP_MLME, DBG_TRACE, ("Wdi_Task_Roam(): disallowed BSSID:"), @@ -1871,7 +1871,7 @@ Wdi_Task_Roam( } } } - + if( pMgntInfo->bMediaConnect || pMgntInfo->bIbssStarter) { if( pMgntInfo->mIbss ){ @@ -1885,7 +1885,7 @@ Wdi_Task_Roam( MgntDisconnectAP(pAdapter, disas_lv_ss); } } - + RT_TRACE(COMP_MLME, DBG_LOUD, ("pMgntInfo->PrepareRoamState %d\n", pMgntInfo->PrepareRoamState)); switch(pMgntInfo->PrepareRoamState) { @@ -1909,13 +1909,13 @@ Wdi_Task_Roam( RT_TRACE(COMP_MLME, DBG_WARNING, ("No matched roaming state\n")); break; } - + pMgntInfo->bPrepareRoaming = FALSE; pMgntInfo->PrepareRoamState = RT_PREPARE_ROAM_NONE; pMgntInfo->PrepareRoamingCount = 0; - + DrvIFIndicateRoamingStart(pAdapter); - + if( MgntRoamRetry(pAdapter, FALSE) == FALSE ) ndisStatus = NDIS_STATUS_FAILURE; else @@ -1937,7 +1937,7 @@ WdiSimpleSetProperty( PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); PRT_NDIS6_COMMON pNdisCommon = pAdapter->pNdisCommon; - PWDI_MESSAGE_HEADER pWdiHeader + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; // We complete the OID. Need to populate some fields @@ -1955,11 +1955,11 @@ WdiSimpleSetProperty( return ndisStatus; } -// +// // Translate from RT_PS_MODE to WDI_POWER_SAVE_LEVEL // 2005.02.15, by rcnjko. // -int +int TranslatePsToWdiPs( IN POWER_LEVEL_CONFIG PowerMode ) @@ -1969,20 +1969,20 @@ TranslatePsToWdiPs( switch(PowerMode) { case POWER_SAVING_NO_POWER_SAVING: - WdiPsMode = WDI_POWER_SAVE_LEVEL_NO_POWER_SAVE; - break; + WdiPsMode = WDI_POWER_SAVE_LEVEL_NO_POWER_SAVE; + break; case POWER_SAVING_FAST_PSP: - WdiPsMode = WDI_POWER_SAVE_LEVEL_FAST_PSP; - break; + WdiPsMode = WDI_POWER_SAVE_LEVEL_FAST_PSP; + break; case POWER_SAVING_MAX_PSP: - WdiPsMode = WDI_POWER_SAVE_LEVEL_MAX_PSP; - break; + WdiPsMode = WDI_POWER_SAVE_LEVEL_MAX_PSP; + break; case POWER_SAVING_MAXIMUM_LEVEL: - WdiPsMode = WDI_POWER_SAVE_LEVEL_MAXIMUM_LEVEL; - break; + WdiPsMode = WDI_POWER_SAVE_LEVEL_MAXIMUM_LEVEL; + break; default: RT_TRACE(COMP_DBG, DBG_SERIOUS, ("TranslatePsToWdiPs(): Unknown PowerMode: 0x%X !!!\n", PowerMode)); - WdiPsMode = WDI_POWER_SAVE_LEVEL_NO_POWER_SAVE; + WdiPsMode = WDI_POWER_SAVE_LEVEL_NO_POWER_SAVE; break; } @@ -2041,15 +2041,15 @@ Wdi_Set_Add_Cipher_Keys( cpMacAddr(MacAddress, CipherKey.PeerMacAddress.Address); bDefaultKey = FALSE; - RT_PRINT_ADDR(COMP_SCAN, DBG_LOUD, "WDI_TLV_PEER_MAC_ADDRESS(): ", MacAddress); + RT_PRINT_ADDR(COMP_SCAN, DBG_LOUD, "WDI_TLV_PEER_MAC_ADDRESS(): ", MacAddress); } if(CipherKey.Optional.CipherKeyID_IsPresent) { KeyIndex = CipherKey.CipherKeyID.CipherKeyID; - RT_TRACE(COMP_SEC, DBG_LOUD, ("WDI_TLV_CIPHER_KEY_ID 0x%x\n", KeyIndex)); + RT_TRACE(COMP_SEC, DBG_LOUD, ("WDI_TLV_CIPHER_KEY_ID 0x%x\n", KeyIndex)); } - + { cipherAlgo = CipherKey.CipherKeyTypeInfo.CipherAlgorithm; direction = CipherKey.CipherKeyTypeInfo.Direction; @@ -2061,7 +2061,7 @@ Wdi_Set_Add_Cipher_Keys( switch(cipherAlgo) { case WDI_CIPHER_ALGO_WEP: - rtEncAlgo = RT_ENC_ALG_WEP; + rtEncAlgo = RT_ENC_ALG_WEP; break; case WDI_CIPHER_ALGO_WEP40: @@ -2070,59 +2070,59 @@ Wdi_Set_Add_Cipher_Keys( case WDI_CIPHER_ALGO_WEP104: rtEncAlgo = RT_ENC_ALG_WEP104; - break; - - case WDI_CIPHER_ALGO_TKIP: + break; + + case WDI_CIPHER_ALGO_TKIP: rtEncAlgo = RT_ENC_ALG_TKIP; break; - case WDI_CIPHER_ALGO_CCMP: - rtEncAlgo = RT_ENC_ALG_AESCCMP; + case WDI_CIPHER_ALGO_CCMP: + rtEncAlgo = RT_ENC_ALG_AESCCMP; break; - case WDI_CIPHER_ALGO_BIP: + case WDI_CIPHER_ALGO_BIP: break; default: break; - } - } + } + } - if(CipherKey.Optional.ReceiveSequenceCount_IsPresent) + if(CipherKey.Optional.ReceiveSequenceCount_IsPresent) { PlatformMoveMemory(&KeyRSC, CipherKey.ReceiveSequenceCount.ReceiveSequenceCount, 6); -// RT_TRACE(COMP_SEC, DBG_LOUD, ("WIFI_TLV_CIPHER_KEY_RECEIVE_SEQUENCE_COUNT 0x%"i64fmt"x\n", KeyRSC)); +// RT_TRACE(COMP_SEC, DBG_LOUD, ("WIFI_TLV_CIPHER_KEY_RECEIVE_SEQUENCE_COUNT 0x%"i64fmt"x\n", KeyRSC)); } if(CipherKey.Optional.CCMPKey_IsPresent) - { + { KeyLen = CipherKey.CCMPKey.ElementCount; pKeyMaterial = CipherKey.CCMPKey.pElements; - bValidKeyRSC = TRUE; + bValidKeyRSC = TRUE; RT_PRINT_DATA(COMP_SEC, DBG_LOUD,("WDI_TLV_CIPHER_KEY_CCMP_KEY\n"),pKeyMaterial,KeyLen); } if(CipherKey.Optional.TKIPInfo_IsPresent) - { + { // Tkip Enc Key(16) + STA Rx MIC Key(8) + STA Tx MIC Key(8). RT_PRINT_DATA(COMP_SEC, DBG_LOUD, ("TKIPKey \n"), CipherKey.TKIPInfo.TKIPKey.pElements, CipherKey.TKIPInfo.TKIPKey.ElementCount); RT_PRINT_DATA(COMP_SEC, DBG_LOUD, ("TKIPMIC \n"), CipherKey.TKIPInfo.TKIPMIC.pElements, CipherKey.TKIPInfo.TKIPMIC.ElementCount); - + PlatformMoveMemory(pTkipKeyMaterial, CipherKey.TKIPInfo.TKIPKey.pElements, CipherKey.TKIPInfo.TKIPKey.ElementCount); - PlatformMoveMemory(pTkipKeyMaterial+CipherKey.TKIPInfo.TKIPKey.ElementCount, CipherKey.TKIPInfo.TKIPMIC.pElements, CipherKey.TKIPInfo.TKIPMIC.ElementCount); - - RT_PRINT_DATA(COMP_SEC, DBG_LOUD, ("pTkipKeyMaterial \n"), pTkipKeyMaterial, TKIP_KEY_LEN); - - pKeyMaterial = pTkipKeyMaterial; - KeyLen = CipherKey.TKIPInfo.TKIPKey.ElementCount + CipherKey.TKIPInfo.TKIPMIC.ElementCount; - - bValidKeyRSC = TRUE; - RT_PRINT_DATA(COMP_SEC, DBG_LOUD,("WDI_TLV_CIPHER_KEY_TKIP_KEY_INFO\n"),pKeyMaterial,KeyLen); + PlatformMoveMemory(pTkipKeyMaterial+CipherKey.TKIPInfo.TKIPKey.ElementCount, CipherKey.TKIPInfo.TKIPMIC.pElements, CipherKey.TKIPInfo.TKIPMIC.ElementCount); + + RT_PRINT_DATA(COMP_SEC, DBG_LOUD, ("pTkipKeyMaterial \n"), pTkipKeyMaterial, TKIP_KEY_LEN); + + pKeyMaterial = pTkipKeyMaterial; + KeyLen = CipherKey.TKIPInfo.TKIPKey.ElementCount + CipherKey.TKIPInfo.TKIPMIC.ElementCount; + + bValidKeyRSC = TRUE; + RT_PRINT_DATA(COMP_SEC, DBG_LOUD,("WDI_TLV_CIPHER_KEY_TKIP_KEY_INFO\n"),pKeyMaterial,KeyLen); } if(CipherKey.Optional.BIPKey_IsPresent) - { + { if( CipherKey.BIPKey.ElementCount == BIP_KEY_LEN) { PlatformMoveMemory( pSecInfo->BIPKeyBuffer ,CipherKey.BIPKey.pElements, CipherKey.BIPKey.ElementCount); @@ -2135,13 +2135,13 @@ Wdi_Set_Add_Cipher_Keys( { ndisStatus = NDIS_STATUS_INVALID_DATA; } - - return ndisStatus; - } - + + return ndisStatus; + } + if(CipherKey.Optional.WEPKey_IsPresent) - { - if(rtEncAlgo == RT_ENC_ALG_WEP) + { + if(rtEncAlgo == RT_ENC_ALG_WEP) { if (CipherKey.WEPKey.ElementCount == NATIVE_802_11_WEP40_KEY_LENGTH) { @@ -2154,13 +2154,13 @@ Wdi_Set_Add_Cipher_Keys( RT_TRACE( COMP_SEC, DBG_LOUD, ("Wdi_Set_Add_Cipher_Keys(): DOT11_CIPHER_ALGO_WEP104\n") ); } } - + KeyLen = CipherKey.WEPKey.ElementCount; pKeyMaterial = CipherKey.WEPKey.pElements; - RT_PRINT_DATA(COMP_SEC, DBG_LOUD,("WDI_TLV_CIPHER_KEY_WEP_KEY\n"),pKeyMaterial,KeyLen); - } - + RT_PRINT_DATA(COMP_SEC, DBG_LOUD,("WDI_TLV_CIPHER_KEY_WEP_KEY\n"),pKeyMaterial,KeyLen); + } + RT_TRACE(COMP_SEC, DBG_LOUD,("==>CipherType %s\n", (WDI_CIPHER_KEY_TYPE_PAIRWISE_KEY == cipherType)?"WDI_CIPHER_KEY_TYPE_PAIRWISE_KEY":( (WDI_CIPHER_KEY_TYPE_GROUP_KEY == cipherType)?"WDI_CIPHER_KEY_TYPE_GROUP_KEY":"WDI_CIPHER_KEY_TYPE_IGTK"))); if(0 == i && !ACTING_AS_AP(pAdapter)) { @@ -2169,12 +2169,12 @@ Wdi_Set_Add_Cipher_Keys( pSecInfo->PairwiseEncAlgorithm = rtEncAlgo; } else if(WDI_CIPHER_KEY_TYPE_GROUP_KEY == cipherType) - { - pSecInfo->GroupEncAlgorithm = rtEncAlgo; + { + pSecInfo->GroupEncAlgorithm = rtEncAlgo; } RT_TRACE(COMP_SEC, DBG_LOUD,("==> pSecInfo->PairwiseEncAlgorithm=0x%x\n",pSecInfo->PairwiseEncAlgorithm)); - - } + + } { if( ACTING_AS_AP(pAdapter)) { @@ -2201,7 +2201,7 @@ Wdi_Set_Add_Cipher_Keys( KeyRSC); } else - { + { for(i=0;i<4;i++){ // Save for Reconnent for Ad-hoc ,by CCW // PlatformMoveMemory( pNdisCommon->RegDefaultKeyBuf[i], pKeyMaterial, KeyLen); @@ -2222,13 +2222,13 @@ Wdi_Set_Add_Cipher_Keys( PlatformMoveMemory( pNdisCommon->RegDefaultKeyBuf[i], pKeyMaterial, KeyLen); pNdisCommon->RegDefaultKey[i].Length = (u2Byte)KeyLen; } - else if(rtEncAlgo == RT_ENC_ALG_WEP104) + else if(rtEncAlgo == RT_ENC_ALG_WEP104) { PlatformMoveMemory( pNdisCommon->RegDefaultKeyWBuf[i], pKeyMaterial, KeyLen); pNdisCommon->RegDefaultKeyW[i].Length =(u2Byte)KeyLen; } - } + } } } else @@ -2253,21 +2253,21 @@ Wdi_Set_Add_Cipher_Keys( PlatformMoveMemory( pNdisCommon->RegDefaultKeyBuf[i], pKeyMaterial, KeyLen); pNdisCommon->RegDefaultKey[i].Length = (u2Byte)KeyLen; } - else if(rtEncAlgo == RT_ENC_ALG_WEP104) + else if(rtEncAlgo == RT_ENC_ALG_WEP104) { PlatformMoveMemory( pNdisCommon->RegDefaultKeyWBuf[i], pKeyMaterial, KeyLen); pNdisCommon->RegDefaultKeyW[i].Length =(u2Byte)KeyLen; } } PlatformRequestPreAuthentication( pAdapter, PRE_AUTH_INDICATION_REASON_ASSOCIATION ); - + } else { // TODO: [WDI] security for Ad-hoc mode - + } - } + } } } @@ -2295,7 +2295,7 @@ Wdi_Set_Delete_Cipher_Keys( WDI_SET_DELETE_CIPHER_KEYS_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramSetDeleteDefaultCipherKeys; WDI_SET_DELETE_CIPHER_KEYS_CONTAINER CipherKeyInfo = {0}; - PWDI_MESSAGE_HEADER pWdiHeader + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; BOOLEAN bDefaultKey = TRUE; @@ -2305,7 +2305,7 @@ Wdi_Set_Delete_Cipher_Keys( ULONG cipherAlgo = 0; ULONG direction = WDI_CIPHER_KEY_DIRECTION_BOTH; u1Byte static_key = TRUE; - ULONG cipherType = WDI_CIPHER_KEY_TYPE_PAIRWISE_KEY; + ULONG cipherType = WDI_CIPHER_KEY_TYPE_PAIRWISE_KEY; u4Byte i = 0; @@ -2323,17 +2323,17 @@ Wdi_Set_Delete_Cipher_Keys( CipherKeyInfo = Params->CipherKeyInfo.pElements[i]; if(CipherKeyInfo.Optional.PeerMacAddress_IsPresent) { - RT_TRACE(COMP_SEC, DBG_LOUD, ("WDI_TLV_PEER_MAC_ADDRESS\n")); + RT_TRACE(COMP_SEC, DBG_LOUD, ("WDI_TLV_PEER_MAC_ADDRESS\n")); cpMacAddr(MacAddress, CipherKeyInfo.PeerMacAddress.Address); bDefaultKey = FALSE; } if(CipherKeyInfo.Optional.CipherKeyID_IsPresent) { - RT_TRACE(COMP_SEC, DBG_LOUD, ("WDI_TLV_CIPHER_KEY_ID\n")); + RT_TRACE(COMP_SEC, DBG_LOUD, ("WDI_TLV_CIPHER_KEY_ID\n")); KeyIndex = CipherKeyInfo.CipherKeyID.CipherKeyID; } - + { cipherAlgo = CipherKeyInfo.CipherKeyTypeInfo.CipherAlgorithm; direction = CipherKeyInfo.CipherKeyTypeInfo.Direction; @@ -2345,7 +2345,7 @@ Wdi_Set_Delete_Cipher_Keys( switch(cipherAlgo) { case WDI_CIPHER_ALGO_WEP: - rtEncAlgo = RT_ENC_ALG_WEP; + rtEncAlgo = RT_ENC_ALG_WEP; break; case WDI_CIPHER_ALGO_WEP40: @@ -2354,40 +2354,40 @@ Wdi_Set_Delete_Cipher_Keys( case WDI_CIPHER_ALGO_WEP104: rtEncAlgo = RT_ENC_ALG_WEP104; - break; - - case WDI_CIPHER_ALGO_TKIP: + break; + + case WDI_CIPHER_ALGO_TKIP: rtEncAlgo = RT_ENC_ALG_TKIP; break; - case WDI_CIPHER_ALGO_CCMP: - rtEncAlgo = RT_ENC_ALG_AESCCMP; + case WDI_CIPHER_ALGO_CCMP: + rtEncAlgo = RT_ENC_ALG_AESCCMP; break; - case WDI_CIPHER_ALGO_BIP: + case WDI_CIPHER_ALGO_BIP: break; default: break; - } - } + } + } RT_TRACE(COMP_SEC, DBG_LOUD, ("[WDI] [Property] WDI_SET_DELETE_CIPHER_KEYS: delete Key\n")); { // - // 061028, rcnjko: WDK said we shall ignore AlgorithmId if bDelete is set, - // so we use GroupEncAlgorithm instead. + // 061028, rcnjko: WDK said we shall ignore AlgorithmId if bDelete is set, + // so we use GroupEncAlgorithm instead. // if( KeyIndex > 3 && KeyIndex < 6 ) { // 802.11w BIP key Key index 5 or 6 - + PlatformZeroMemory(pSecInfo->BIPKeyBuffer, MAX_KEY_LEN); } else if( !pAdapter->MgntInfo.bRSNAPSKMode) { MgntActSet_802_11_REMOVE_KEY( - pAdapter, + pAdapter, rtEncAlgo, KeyIndex, MacAddress, @@ -2403,18 +2403,18 @@ Wdi_Set_Delete_Cipher_Keys( RT_TRACE( COMP_OID_SET, DBG_WARNING, (" <- [WDI] Property WIFI_SET_DELETE_CIPHER_KEYS, MgntActSet_RSNA_REMOVE_DEAULT_KEY return FALSE !!!\n")); return NDIS_STATUS_INVALID_DATA; } - } + } } - } + } } else if(WDI_TLV_DELETE_CIPHER_KEY_INFO== pTlvData->Type) - { + { InputBufferLength = pTlvData->Length; pTlvData = (PTLV_WDI_STRUCT)((pu1Byte)pTlvData->Value); Prefix += 4; - + while(BytesProcessed < InputBufferLength) { // Parse Type @@ -2425,7 +2425,7 @@ Wdi_Set_Delete_Cipher_Keys( RT_TRACE(COMP_SEC, DBG_LOUD, ("unknown TLV 0x%x\n", pTlvData->Type)); } break; - + case WDI_TLV_PEER_MAC_ADDRESS: { RT_TRACE(COMP_SEC, DBG_LOUD, ("WDI_TLV_PEER_MAC_ADDRESS\n")); @@ -2462,26 +2462,26 @@ Wdi_Set_Delete_Cipher_Keys( // Parse Content BytesProcessed += (4 + pTlvData->Length); - + pTlvData = (PTLV_WDI_STRUCT)((pu1Byte)pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer + Prefix + BytesProcessed); } RT_TRACE(COMP_SEC, DBG_LOUD, ("[WDI] [Property] WDI_SET_DELETE_CIPHER_KEYS: delete Key\n")); // - // 061028, rcnjko: WDK said we shall ignore AlgorithmId if bDelete is set, - // so we use GroupEncAlgorithm instead. + // 061028, rcnjko: WDK said we shall ignore AlgorithmId if bDelete is set, + // so we use GroupEncAlgorithm instead. // rtEncAlgo = pSecInfo->GroupEncAlgorithm; if( KeyIndex > 3 && KeyIndex < 6 ) { // 802.11w BIP key Key index 5 or 6 - + PlatformZeroMemory(pSecInfo->BIPKeyBuffer, MAX_KEY_LEN); } else if( !pAdapter->MgntInfo.bRSNAPSKMode) { MgntActSet_802_11_REMOVE_KEY( - pAdapter, + pAdapter, rtEncAlgo, KeyIndex, MacAddress, @@ -2523,7 +2523,7 @@ Wdi_Set_Default_Key_ID( // Set default key id: 0 ~ 3. KeyId &= 0x3; - // The following code will cause 8187 failed to link to AP. + // The following code will cause 8187 failed to link to AP. pSecInfo->DefaultTransmitKeyIdx = (u1Byte)KeyId; pNdisCommon->RegDefaultKeyId = (u1Byte)KeyId; @@ -2542,9 +2542,9 @@ Wdi_Set_Receive_Packet_Filter( NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; ULONG BytesRead = 0, BytesNeeded = 0; - PWDI_MESSAGE_HEADER pWdiHeader + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; - ULONG InputBufferLength + ULONG InputBufferLength = pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength;; WDI_SET_RECEIVE_PACKET_FILTER_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramSetReceivePacketFilter; @@ -2562,7 +2562,7 @@ Wdi_Set_Receive_Packet_Filter( pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength, &BytesRead, &BytesNeeded); - + return ndisStatus; } @@ -2581,7 +2581,7 @@ Wdi_Set_Network_List_Offload( NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; PADAPTER pDefaultAdapter = GetDefaultAdapter(pAdapter); PRT_NDIS6_COMMON pNdisCommon = pDefaultAdapter->pNdisCommon; - PRT_NLO_INFO pNLOInfo = &(pDefaultAdapter->MgntInfo.NLOInfo); + PRT_NLO_INFO pNLOInfo = &(pDefaultAdapter->MgntInfo.NLOInfo); u4Byte ChannelIndex = 0; u4Byte Index = 0; u4Byte ItemCnt = 0; @@ -2601,7 +2601,7 @@ Wdi_Set_Network_List_Offload( pNLOInfo->FastScanPeriod = 0; pNLOInfo->SlowScanPeriod = 0; pNdisCommon->ScanPeriod = 0; - + RT_TRACE( COMP_POWER, DBG_LOUD , (" ===>SsidOffload_IsPresent == 0 \n") ); return NDIS_STATUS_SUCCESS; } @@ -2633,12 +2633,12 @@ Wdi_Set_Network_List_Offload( for( i=0 ; iUnicastAlgorithms.ElementCount ; ++i, ++Index) { - // Copy SSID - CopySsid( pNLOInfo->dDot11OffloadNetworkList[Index].ssidbuf, + // Copy SSID + CopySsid( pNLOInfo->dDot11OffloadNetworkList[Index].ssidbuf, pNLOInfo->dDot11OffloadNetworkList[Index].ssidlen, pOffloadItem->SsidToScan.pElements, pOffloadItem->SsidToScan.ElementCount); - + RT_TRACE(COMP_POWER, DBG_LOUD, ("The %u OFFLOAD NETWORK SSID: %s\n", Index+1, pNLOInfo->dDot11OffloadNetworkList[Index].ssidbuf)); pAlgorithmItem = &(pOffloadItem->UnicastAlgorithms.pElements[i]); @@ -2658,15 +2658,15 @@ Wdi_Set_Network_List_Offload( pNLOInfo->dDot11OffloadNetworkList[Index].bPrivacy = TRUE; pNLOInfo->dDot11OffloadNetworkList[Index].chiper = 0x0; break; - case WDI_CIPHER_ALGO_TKIP : - if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_WPA || + case WDI_CIPHER_ALGO_TKIP : + if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_WPA || pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_WPA_PSK ) { pNLOInfo->dDot11OffloadNetworkList[Index].SecLvl = RT_SEC_LVL_WPA; pNLOInfo->dDot11OffloadNetworkList[Index].bPrivacy = TRUE; pNLOInfo->dDot11OffloadNetworkList[Index].chiper = WPA_TKIP; } - else if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_RSNA || + else if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_RSNA || pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_RSNA_PSK ) { pNLOInfo->dDot11OffloadNetworkList[Index].SecLvl = RT_SEC_LVL_WPA2; @@ -2682,14 +2682,14 @@ Wdi_Set_Network_List_Offload( } break; case WDI_CIPHER_ALGO_CCMP : - if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_WPA || + if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_WPA || pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_WPA_PSK ) { pNLOInfo->dDot11OffloadNetworkList[Index].SecLvl = RT_SEC_LVL_WPA; pNLOInfo->dDot11OffloadNetworkList[Index].bPrivacy = TRUE; pNLOInfo->dDot11OffloadNetworkList[Index].chiper = WPA_AES; } - else if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_RSNA || + else if( pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_RSNA || pAlgorithmItem->AuthAlgorithm == WDI_AUTH_ALGO_RSNA_PSK ) { pNLOInfo->dDot11OffloadNetworkList[Index].SecLvl = RT_SEC_LVL_WPA2; @@ -2711,29 +2711,29 @@ Wdi_Set_Network_List_Offload( RT_TRACE( COMP_POWER, DBG_LOUD , (" ===> Unknow UnicastCipher : %x\n", pAlgorithmItem->CipherAlgorithm) ); break; } - + RT_TRACE(COMP_POWER , DBG_LOUD , (" Seclvl : %d\n", pNLOInfo->dDot11OffloadNetworkList[Index].SecLvl) ); RT_TRACE(COMP_POWER , DBG_LOUD , (" bPrivacy : %d\n", pNLOInfo->dDot11OffloadNetworkList[Index].bPrivacy) ); RT_TRACE(COMP_POWER , DBG_LOUD , (" chiper : %d\n", pNLOInfo->dDot11OffloadNetworkList[Index].chiper) ); RT_TRACE( COMP_POWER, DBG_LOUD, (" Channel Hint:\n")); - - // Save channel info + + // Save channel info // DOT11_MAX_CHANNEL_HINTS 4 for( ChannelIndex = 0 ; ChannelIndex < pOffloadItem->ChannellHintList.ElementCount ; ChannelIndex++ ) { pNLOInfo->dDot11OffloadNetworkList[Index].channelNumberHit[ChannelIndex] = pChannelItem[ChannelIndex].ChannelNumber; RT_TRACE( COMP_POWER, DBG_LOUD, (" %u", pNLOInfo->dDot11OffloadNetworkList[Index].channelNumberHit[ChannelIndex])); } - + RT_TRACE( COMP_POWER, DBG_LOUD, ("\n")); - - // Show Entry information !! + + // Show Entry information !! RT_TRACE( COMP_POWER, DBG_LOUD , (" ===> Show NLO info Index (%x):\n", Index) ); RT_PRINT_STR(COMP_POWER, DBG_LOUD, (" SSID"), pNLOInfo->dDot11OffloadNetworkList[Index].ssidbuf, pNLOInfo->dDot11OffloadNetworkList[Index].ssidlen); RT_TRACE( COMP_POWER , DBG_LOUD , (" chiper : %x \n", pNLOInfo->dDot11OffloadNetworkList[Index].chiper) ); } - } + } } else { @@ -2757,9 +2757,9 @@ Wdi_Set_Privacy_Exemption_List( ULONG BytesRead = 0, BytesNeeded = 0; PRT_NDIS6_COMMON pNdisCommon = pAdapter->pNdisCommon; PNDIS_OID_REQUEST pNdisRequest = pOidHandle->pNdisRequest; - PWDI_MESSAGE_HEADER pWdiHeader + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; - ULONG InputBufferLength + ULONG InputBufferLength = pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength; WDI_SET_PRIVACY_EXEMPTION_LIST_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramSetPrivacyExemptionList; WDI_PRIVACY_EXEMPTION_LIST_CONTAINER PrivacyList = {0}; @@ -2780,34 +2780,34 @@ Wdi_Set_Privacy_Exemption_List( for(i = 0; i < Params->PrivacyExemptionEntry.ElementCount; i++) { PrivacyList = Params->PrivacyExemptionEntry.pElements[i]; - pNdisCommon->PrivacyExemptionEntries[i].usEtherType = + pNdisCommon->PrivacyExemptionEntries[i].usEtherType = PrivacyList.EtherType; - pNdisCommon->PrivacyExemptionEntries[i].usExemptionActionType = - PrivacyList.ExemptionActionType; - pNdisCommon->PrivacyExemptionEntries[i].usExemptionPacketType = - PrivacyList.ExemptionPacketType; + pNdisCommon->PrivacyExemptionEntries[i].usExemptionActionType = + PrivacyList.ExemptionActionType; + pNdisCommon->PrivacyExemptionEntries[i].usExemptionPacketType = + PrivacyList.ExemptionPacketType; } - RT_PRINT_DATA(COMP_OID_SET, DBG_LOUD, - "Privacy exempt list:", - pNdisCommon->PrivacyExemptionEntries, - (int)(pNdisCommon->PrivacyExemptionEntrieNum * sizeof(DOT11_PRIVACY_EXEMPTION))); + RT_PRINT_DATA(COMP_OID_SET, DBG_LOUD, + "Privacy exempt list:", + pNdisCommon->PrivacyExemptionEntries, + (int)(pNdisCommon->PrivacyExemptionEntrieNum * sizeof(DOT11_PRIVACY_EXEMPTION))); } - + return ndisStatus; } NDIS_STATUS -Wdi_Set_Power_State( +Wdi_Set_Power_State( IN PADAPTER pAdapter, IN PRT_OID_HANDLER pOidHandle ) { NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; - + ndisStatus = N6SdioWdi_Mgnt_SetPower(pAdapter, pOidHandle); return ndisStatus; @@ -2815,15 +2815,15 @@ Wdi_Set_Power_State( NDIS_STATUS -Wdi_Abort_Task( +Wdi_Abort_Task( IN PADAPTER pAdapter, IN PRT_OID_HANDLER pOidHandle ) { NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; - PWDI_MESSAGE_HEADER pWdiHeader + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER) pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; - ULONG InputBufferLength + ULONG InputBufferLength = pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength; WDI_TASK_ABORT_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramAbort; @@ -2875,7 +2875,7 @@ Wdi_Set_Add_Wol_Pattern( u1Byte Index, ptnIndex; RT_TRACE(COMP_OID_SET, DBG_LOUD, ("==> Wdi_Set_Add_Wol_Pattern()\n")); - + pWdiHeader->Status = NDIS_STATUS_SUCCESS; pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.BytesWritten = sizeof(WDI_MESSAGE_HEADER); @@ -2895,20 +2895,20 @@ Wdi_Set_Add_Wol_Pattern( for(Index = 0; Index < Params->WakePacketPattern.ElementCount; Index++, pPatternElements++) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("SET OID_PM_ADD_WOL_PATTERN[%d]:\n", Index)); - + if(pPatternElements->PacketPattern.ElementCount <= MAX_WOL_PATTERN_SIZE) { PlatformMoveMemory(WoLBitMapPatternContent, pPatternElements->PacketPattern.pElements, pPatternElements->PacketPattern.ElementCount); - RT_PRINT_DATA( COMP_OID_SET | COMP_POWER, DBG_LOUD, ("WoLBitMapPatternContent...\n"), + RT_PRINT_DATA( COMP_OID_SET | COMP_POWER, DBG_LOUD, ("WoLBitMapPatternContent...\n"), WoLBitMapPatternContent, sizeof(WoLBitMapPatternContent)); } if(pPatternElements->PacketPatternMask.ElementCount <= MAX_WOL_BIT_MASK_SIZE) { - PlatformMoveMemory(WoLBitMapPatternMask, pPatternElements->PacketPatternMask.pElements, pPatternElements->PacketPatternMask.ElementCount); - RT_PRINT_DATA( COMP_OID_SET | COMP_POWER, DBG_LOUD, ("WoLBitMapPatternMask...\n"), + PlatformMoveMemory(WoLBitMapPatternMask, pPatternElements->PacketPatternMask.pElements, pPatternElements->PacketPatternMask.ElementCount); + RT_PRINT_DATA( COMP_OID_SET | COMP_POWER, DBG_LOUD, ("WoLBitMapPatternMask...\n"), WoLBitMapPatternMask, sizeof(WoLBitMapPatternMask)); } - + //Find the index of the first empty entry. for(Index = 0; Index < MAX_SUPPORT_WOL_PATTERN_NUM(pAdapter); Index++) { @@ -2921,12 +2921,12 @@ Wdi_Set_Add_Wol_Pattern( if(pPmWoLPatternInfo[Index].PatternId == 0) break; } - + if(Index >= MAX_SUPPORT_WOL_PATTERN_NUM(pAdapter)) { ndisStatus = NDIS_STATUS_RESOURCES; RT_TRACE(COMP_POWER, DBG_LOUD, - ("SET OID_PNP_ADD_WOL_PATTERN: Return status(%#X). The number of wake up pattern is more than %d or the pattern Id is exist.\n", + ("SET OID_PNP_ADD_WOL_PATTERN: Return status(%#X). The number of wake up pattern is more than %d or the pattern Id is exist.\n", ndisStatus, MAX_SUPPORT_WOL_PATTERN_NUM(pAdapter))); return ndisStatus; } @@ -2946,9 +2946,9 @@ Wdi_Set_Add_Wol_Pattern( //Skip IPv4/IPv6 TCP SYN pattern because it will hit HW bug for the CRC. // We offload this pattern to FW. pPmWoLPatternInfo[Index].PatternType = eUnicastPattern; - RT_TRACE(COMP_OID_SET, DBG_LOUD, + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("OID_PM_ADD_WOL_PATTERN: IPv4/IPv6 TCP SYN pattern.\n")); - + } else if(PlatformCompareMemory(WoLBitMapPatternContent, MULTICAST_ADDR, sizeof(MULTICAST_ADDR)) == 0) { //Multicast @@ -2962,12 +2962,12 @@ Wdi_Set_Add_Wol_Pattern( { pPmWoLPatternInfo[Index].PatternType = eDontCareDA; } - + { - GetWOLWakeUpPattern(pAdapter, - (pu1Byte)&WoLBitMapPatternMask, - pPatternElements->PacketPatternMask.ElementCount, - (pu1Byte)&WoLBitMapPatternContent, + GetWOLWakeUpPattern(pAdapter, + (pu1Byte)&WoLBitMapPatternMask, + pPatternElements->PacketPatternMask.ElementCount, + (pu1Byte)&WoLBitMapPatternContent, pPatternElements->PacketPattern.ElementCount, Index, FALSE @@ -2976,7 +2976,7 @@ Wdi_Set_Add_Wol_Pattern( pPSC->WoLPatternNum++; } } - + } //2 Wake Packet Magic Packet @@ -3019,7 +3019,7 @@ Wdi_Set_Add_Wol_Pattern( if(Params->WakePacketEapolRequestIdPatternId) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("SET OID_PM_ADD_WOL_PATTERN: Support EapolRequestIdMessage.\n")); - + if(!pPSC->EapolRequestIdMessagePatternId) { pPSC->EapolRequestIdMessagePatternId = Params->WakePacketEapolRequestIdPatternId; @@ -3047,7 +3047,7 @@ Wdi_Set_Remove_Wol_Pattern( PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); PRT_POWER_SAVE_CONTROL pPSC = GET_POWER_SAVE_CONTROL(pMgntInfo); PRT_PM_WOL_PATTERN_INFO pPmWoLPatternInfo = &(pPSC->PmWoLPatternInfo[0]); - + u4Byte RemovePatternId = Params->PatternId; RT_TRACE(COMP_OID_SET, DBG_LOUD, ("==> Wdi_Set_Remove_Wol_Pattern()\n")); @@ -3059,41 +3059,41 @@ Wdi_Set_Remove_Wol_Pattern( if(RemovePatternId == pPSC->MagicPacketPatternId) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("SET_OID_PM_REMOVE_WOL_PATTERN: Remove MagicPacket.\n")); - + pPSC->MagicPacketPatternId = 0; pPSC->WoLPktNoPtnNum--; } else if(RemovePatternId == pPSC->EapolRequestIdMessagePatternId) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("SET_OID_PM_REMOVE_WOL_PATTERN: Remove EapolRequestIdMessage.\n")); - + pPSC->EapolRequestIdMessagePatternId = 0; pPSC->WoLPktNoPtnNum--; } else if(RemovePatternId == pPSC->IPv4TcpSynPatternId) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("SET_OID_PM_REMOVE_WOL_PATTERN: Remove IPv4TcpSyn.\n")); - + pPSC->IPv4TcpSynPatternId = 0; pPSC->WoLPktNoPtnNum--; } else if(RemovePatternId == pPSC->IPv6TcpSynPatternId) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("SET_OID_PM_REMOVE_WOL_PATTERN: Remove IPv6TcpSyn.\n")); - + pPSC->IPv6TcpSynPatternId = 0; pPSC->WoLPktNoPtnNum--; } else { u1Byte Index; - + for(Index = 0; Index < MAX_SUPPORT_WOL_PATTERN_NUM(pAdapter); Index++) { if(pPmWoLPatternInfo[Index].PatternId == RemovePatternId) break; } - + if(Index >= MAX_SUPPORT_WOL_PATTERN_NUM(pAdapter)) { RT_TRACE(COMP_OID_SET, DBG_LOUD,("SET OID_PM_REMOVE_WOL_PATTERN: Cannot find the wake up pattern Id(%08X).\n", RemovePatternId)); @@ -3106,9 +3106,9 @@ Wdi_Set_Remove_Wol_Pattern( pPmWoLPatternInfo[Index].CrcRemainder = 0xffff; pPmWoLPatternInfo[Index].IsPatternMatch = 0; pPmWoLPatternInfo[Index].IsSupportedByFW = 0; - - pAdapter->HalFunc.SetHwRegHandler(pAdapter, HW_VAR_WF_MASK, (pu1Byte)(&Index)); - pAdapter->HalFunc.SetHwRegHandler(pAdapter, HW_VAR_WF_CRC, (pu1Byte)(&Index)); + + pAdapter->HalFunc.SetHwRegHandler(pAdapter, HW_VAR_WF_MASK, (pu1Byte)(&Index)); + pAdapter->HalFunc.SetHwRegHandler(pAdapter, HW_VAR_WF_CRC, (pu1Byte)(&Index)); pPmWoLPatternInfo[Index].HwWFMIndex = 0xff; // reset the value after clear HW/CAM entry. pPSC->WoLPatternNum--; @@ -3139,7 +3139,7 @@ Wdi_Set_Multicast_List( NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; ULONG BytesRead = 0, BytesNeeded = 0; PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; - ULONG InputBufferLength = pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength; + ULONG InputBufferLength = pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength; WDI_SET_MULTICAST_LIST_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSetMulticastList; WDI_MAC_ADDRESS Address = {0}; DOT11_MAC_ADDRESS MulticastList[MAX_MCAST_LIST_NUM]; @@ -3155,7 +3155,7 @@ Wdi_Set_Multicast_List( Address = param->MulticastList.pElements[i]; CopyMem(MulticastList[i], Address.Address, sizeof(DOT11_MAC_ADDRESS)); RT_PRINT_ADDR(COMP_OID_SET, DBG_TRACE, ("Wdi_Set_Multicast_List MulticastList\n"), MulticastList[i]); - RT_PRINT_ADDR(COMP_OID_SET, DBG_TRACE, ("Wdi_Set_Multicast_List Address.Address\n"), Address.Address); + RT_PRINT_ADDR(COMP_OID_SET, DBG_TRACE, ("Wdi_Set_Multicast_List Address.Address\n"), Address.Address); } ndisStatus = N6CSet_DOT11_MULTICAST_LIST(pAdapter, @@ -3168,7 +3168,7 @@ Wdi_Set_Multicast_List( { // Shall we need to clear multicast list since parameter was empty? } - + return ndisStatus; } @@ -3183,9 +3183,9 @@ Wdi_Set_Add_Pm_Protocol_Offload( PRT_POWER_SAVE_CONTROL pPSC = GET_POWER_SAVE_CONTROL(pMgntInfo); PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER) pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; WDI_SET_ADD_PM_PROTOCOL_OFFLOAD_PARAMETERS_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramSetAddProtocolOffload; - + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("==> Wdi_Set_Add_Pm_Protocol_Offload()\n")); - + pWdiHeader->Status = NDIS_STATUS_SUCCESS; pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.BytesWritten = sizeof(WDI_MESSAGE_HEADER); @@ -3193,21 +3193,21 @@ Wdi_Set_Add_Pm_Protocol_Offload( //2 DOT11 RSN REKey Offload if(Params->DOT11RSNREKeyOffload.ProtocolOffloadId) { - RT_TRACE(COMP_OID_SET, DBG_LOUD, ("ProtocolOffloadId = %d\n", + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("ProtocolOffloadId = %d\n", Params->DOT11RSNREKeyOffload.ProtocolOffloadId)); - - pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eGTKOffloadIdx] + + pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eGTKOffloadIdx] = Params->DOT11RSNREKeyOffload.ProtocolOffloadId; - + //Copy kck, kek - PlatformMoveMemory(&(pMgntInfo->PMDot11RSNRekeyPara.KCK), - Params->DOT11RSNREKeyOffload.KCK_CONTENT, 32); + PlatformMoveMemory(&(pMgntInfo->PMDot11RSNRekeyPara.KCK), + Params->DOT11RSNREKeyOffload.KCK_CONTENT, 32); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("KCK_CONTENT:\n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("KCK_CONTENT:\n"), pMgntInfo->PMDot11RSNRekeyPara.KCK, 16); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("KEK_CONTENT:\n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("KEK_CONTENT:\n"), pMgntInfo->PMDot11RSNRekeyPara.KEK, 16); - + pMgntInfo->PMDot11RSNRekeyPara.KeyReplayCounter = Params->DOT11RSNREKeyOffload.ReplayCounter; if(pPSC->RegGTKOffloadEnable) @@ -3218,18 +3218,18 @@ Wdi_Set_Add_Pm_Protocol_Offload( //2 ipv4 ARP Offload if(Params->ipv4ARPOffload.ProtocolOffloadId) { - pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eARPOffloadIdx] + pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eARPOffloadIdx] = Params->ipv4ARPOffload.ProtocolOffloadId; //Copy RemoteIPv4Address, HostIPv4Address & MacAddress - PlatformMoveMemory(&(pMgntInfo->PMIPV4ARPPara.RemoteIPv4Address), - Params->ipv4ARPOffload.RemoteIPV4Address, 14); - - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("RemoteIPv4Address:\n"), + PlatformMoveMemory(&(pMgntInfo->PMIPV4ARPPara.RemoteIPv4Address), + Params->ipv4ARPOffload.RemoteIPV4Address, 14); + + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("RemoteIPv4Address:\n"), pMgntInfo->PMIPV4ARPPara.RemoteIPv4Address, 4); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("HostIPv4Address:\n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("HostIPv4Address:\n"), pMgntInfo->PMIPV4ARPPara.HostIPv4Address, 4); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("MacAddress:\n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("MacAddress:\n"), pMgntInfo->PMIPV4ARPPara.MacAddress, 6); if(pPSC->RegARPOffloadEnable) @@ -3241,7 +3241,7 @@ Wdi_Set_Add_Pm_Protocol_Offload( if(Params->ipv6ARPOffload.ProtocolOffloadId) { RT_TRACE(COMP_OID_SET, DBG_LOUD, ("SET OID_PM_ADD_PROTOCOL_OFFLOAD. (NS IPv6)\n")); - + if((pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx1] != 0) && (pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx2] != 0)) { @@ -3252,43 +3252,43 @@ Wdi_Set_Add_Pm_Protocol_Offload( { u1Byte IPv6NSIndex = 0; RT_PM_IPV6_NS_PARAMETERS *NsParams; - + if( pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx1] == 0) { - pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx1] + pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx1] = Params->ipv6ARPOffload.ProtocolOffloadId; IPv6NSIndex = 0; RT_TRACE( COMP_OID_SET, DBG_LOUD, ("==> eNSOffloadIdx1: \n")); } else { - pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx2] + pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx2] = Params->ipv6ARPOffload.ProtocolOffloadId; IPv6NSIndex = 1; RT_TRACE( COMP_OID_SET, DBG_LOUD, ("==> eNSOffloadIdx2: \n")); } NsParams = &(pMgntInfo->PMIPV6NSPara[IPv6NSIndex]); - - PlatformMoveMemory(NsParams->RemoteIPv6Address, + + PlatformMoveMemory(NsParams->RemoteIPv6Address, Params->ipv6ARPOffload.RemoteIPV6Address, 16); - PlatformMoveMemory(NsParams->SolicitedNodeIPv6Address, + PlatformMoveMemory(NsParams->SolicitedNodeIPv6Address, Params->ipv6ARPOffload.SolicitdNodeIPv6Address, 16); - PlatformMoveMemory(NsParams->MacAddress, + PlatformMoveMemory(NsParams->MacAddress, Params->ipv6ARPOffload.MacAddress.Address, 6); - PlatformMoveMemory(NsParams->TargetIPv6Addresses[0], + PlatformMoveMemory(NsParams->TargetIPv6Addresses[0], Params->ipv6ARPOffload.TargetIPV6Address1, 16); - PlatformMoveMemory(NsParams->TargetIPv6Addresses[1], + PlatformMoveMemory(NsParams->TargetIPv6Addresses[1], Params->ipv6ARPOffload.TargetIPV6Address2, 16); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM RemoteIPv6Address: \n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM RemoteIPv6Address: \n"), NsParams->RemoteIPv6Address, 16); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM SolicitedNodeIPv6Address: \n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM SolicitedNodeIPv6Address: \n"), NsParams->SolicitedNodeIPv6Address, 16); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM MacAddress: \n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM MacAddress: \n"), NsParams->MacAddress, 6); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM TargetIPv6Addresses[0]: \n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM TargetIPv6Addresses[0]: \n"), NsParams->TargetIPv6Addresses[0], 16); - RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM TargetIPv6Addresses[1]: \n"), + RT_PRINT_DATA( COMP_OID_SET, DBG_LOUD, ("SET PM TargetIPv6Addresses[1]: \n"), NsParams->TargetIPv6Addresses[1], 16); if(pPSC->RegNSOffloadEnable) @@ -3297,7 +3297,7 @@ Wdi_Set_Add_Pm_Protocol_Offload( } RT_TRACE(COMP_OID_SET, DBG_LOUD, ("<== Wdi_Set_Add_Pm_Protocol_Offload()\n")); - + return ndisStatus; } @@ -3313,9 +3313,9 @@ Wdi_Set_Remove_Pm_Protocol_Offload( WDI_SET_REMOVE_PM_PROTOCOL_OFFLOAD_PARAMETERS *Params = pOidHandle->tlvParser.parsedTlv.paramSetRemoveProtocolOffload; u4Byte MatchId, ProtocolOffloadId = Params->RemovePMOffload; - + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("==> Wdi_Set_Remove_Pm_Protocol_Offload()\n")); - + pWdiHeader->Status = NDIS_STATUS_SUCCESS; pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.BytesWritten = sizeof(WDI_MESSAGE_HEADER); @@ -3324,19 +3324,19 @@ Wdi_Set_Remove_Pm_Protocol_Offload( if(ProtocolOffloadId == pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[MatchId]) { RT_TRACE(COMP_POWER, DBG_LOUD, ("Find match protocol offload ID idx (%d)\n", MatchId)); - + if(MatchId == eGTKOffloadIdx) { - PlatformZeroMemory(&(pMgntInfo->PMDot11RSNRekeyPara), sizeof(RT_PM_DOT11_RSN_REKEY_PARAMETERS)); + PlatformZeroMemory(&(pMgntInfo->PMDot11RSNRekeyPara), sizeof(RT_PM_DOT11_RSN_REKEY_PARAMETERS)); RT_TRACE( COMP_OID_SET, DBG_LOUD, ("==>REMOVE eGTKOffloadIdx\n")); } else if(MatchId == eARPOffloadIdx) { - PlatformZeroMemory(&(pMgntInfo->PMIPV4ARPPara), sizeof(RT_PM_IPV4_ARP_PARAMETERS)); + PlatformZeroMemory(&(pMgntInfo->PMIPV4ARPPara), sizeof(RT_PM_IPV4_ARP_PARAMETERS)); RT_TRACE( COMP_OID_SET, DBG_LOUD, ("==>REMOVE eARPOffloadIdx\n")); } else if(MatchId == eNSOffloadIdx1 ) - { + { // Disable eNSOffloadIdx1 , set ID = 0 !! pMgntInfo->PowerSaveControl.PMProtocolOffloadIDs[eNSOffloadIdx1] = 0; RT_TRACE( COMP_OID_SET, DBG_LOUD, ("==>REMOVE eNSOffloadIdx1\n")); @@ -3351,7 +3351,7 @@ Wdi_Set_Remove_Pm_Protocol_Offload( } RT_TRACE(COMP_OID_SET, DBG_LOUD, ("<== Wdi_Set_Remove_Pm_Protocol_Offload()\n")); - + return ndisStatus; } @@ -3365,10 +3365,10 @@ Wdi_Set_Connection_Quality( ULONG BytesRead = 0, BytesNeeded = 0; PMGNT_INFO pMgntInfo=&(pAdapter->MgntInfo); PRT_POWER_SAVE_CONTROL pPSC = GET_POWER_SAVE_CONTROL(pMgntInfo); - PWDI_MESSAGE_HEADER pWdiHeader + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; - ULONG InputBufferLength - = pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength; + ULONG InputBufferLength + = pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InputBufferLength; WDI_SET_CONNECTION_QUALITY_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSetConnectionQuality; pWdiHeader->Status = NDIS_STATUS_SUCCESS; @@ -3385,18 +3385,18 @@ Wdi_Set_Connection_Quality( pPSC->ConnectionQuality = param->Quality; RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Wdi_Set_Connection_Quality ConnectionQuality 0x%x\n", pPSC->ConnectionQuality)); - + if(param->Optional.LowLatencyParameters_IsPresent) { pPSC->MaximumOffChannelOperationTime = param->LowLatencyParameters.MaximumOffChannelOperationTime; - pPSC->RoamingNeededLinkQualityThreshold = param->LowLatencyParameters.RoamingNeededLinkQualityThreshold; + pPSC->RoamingNeededLinkQualityThreshold = param->LowLatencyParameters.RoamingNeededLinkQualityThreshold; RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Wdi_Set_Connection_Quality MaximumOffChannelOperationTime 0x%x\n", pPSC->MaximumOffChannelOperationTime)); - RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Wdi_Set_Connection_Quality RoamingNeededLinkQualityThreshold 0x%x\n", pPSC->RoamingNeededLinkQualityThreshold)); + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Wdi_Set_Connection_Quality RoamingNeededLinkQualityThreshold 0x%x\n", pPSC->RoamingNeededLinkQualityThreshold)); } } - - + + return ndisStatus; } @@ -3413,23 +3413,23 @@ Wdi_Get_Auto_Power_Save( WDI_GET_AUTO_POWER_SAVE_RESULTS adapterPowerSave = {0}; PUCHAR pOutput = NULL; ULONG length = 0; - - PWDI_MESSAGE_HEADER pOidHeader + + PWDI_MESSAGE_HEADER pOidHeader = (PWDI_MESSAGE_HEADER)pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; - adapterPowerSave.AutoPowerSaveParameters.EnableAutoPSM = + adapterPowerSave.AutoPowerSaveParameters.EnableAutoPSM = pMgntInfo->bInAutoPowerSavemode; - adapterPowerSave.AutoPowerSaveParameters.BeaconInterval = + adapterPowerSave.AutoPowerSaveParameters.BeaconInterval = pMgntInfo->dot11BeaconPeriod; - adapterPowerSave.AutoPowerSaveParameters.ListenInterval = + adapterPowerSave.AutoPowerSaveParameters.ListenInterval = (UINT8)pMgntInfo->ListenInterval; if(pMgntInfo->ListenIntervalInDX) { - adapterPowerSave.AutoPowerSaveParameters.ListenIntervalInDx = - (UINT8)pMgntInfo->ListenIntervalInDX; + adapterPowerSave.AutoPowerSaveParameters.ListenIntervalInDx = + (UINT8)pMgntInfo->ListenIntervalInDX; } else { @@ -3446,13 +3446,13 @@ Wdi_Get_Auto_Power_Save( else { adapterPowerSave.AutoPowerSaveParameters.PowerMode = WDI_POWER_SAVE_LEVEL_NO_POWER_SAVE; - adapterPowerSave.AutoPowerSaveParameters.PowerModeinDx = WDI_POWER_SAVE_LEVEL_NO_POWER_SAVE; + adapterPowerSave.AutoPowerSaveParameters.PowerModeinDx = WDI_POWER_SAVE_LEVEL_NO_POWER_SAVE; } //2 Todo adapterPowerSave.AutoPowerSaveParameters.Reason = 0; - - adapterPowerSave.AutoPowerSaveParameters.MillisecondsSinceStart = + + adapterPowerSave.AutoPowerSaveParameters.MillisecondsSinceStart = (PlatformGetCurrentTime() - pDefAdapter->DriverUpTime) / 1000; if (pPSC->bLeisurePs && pMgntInfo->dot11PowerSaveMode != eActive) @@ -3461,21 +3461,21 @@ Wdi_Get_Auto_Power_Save( (PlatformGetCurrentTime() - pPSC->LastLPSEnterTime) / 1000; } else if (pPSC->LastLPSEnterTime) - { + { adapterPowerSave.AutoPowerSaveParameters.MillisecondsInPowerSave = (pPSC->LastLPSLeaveTime - pPSC->LastLPSEnterTime) / 1000; - } + } else { adapterPowerSave.AutoPowerSaveParameters.MillisecondsInPowerSave = 0; } //2 Todo - adapterPowerSave.AutoPowerSaveParameters.ReceivedMulticastPackets = - adapterPowerSave.AutoPowerSaveParameters.SentMulticastPackets = - adapterPowerSave.AutoPowerSaveParameters.ReceivedUnicastPackets = + adapterPowerSave.AutoPowerSaveParameters.ReceivedMulticastPackets = + adapterPowerSave.AutoPowerSaveParameters.SentMulticastPackets = + adapterPowerSave.AutoPowerSaveParameters.ReceivedUnicastPackets = adapterPowerSave.AutoPowerSaveParameters.SentUnicastPacket = 0; - + ndisStatus = GenerateWdiGetAutoPowerSave( //pAdapterCapabilities, &adapterPowerSave, @@ -3495,7 +3495,7 @@ Wdi_Get_Auto_Power_Save( return ndisStatus; } - if (pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.OutputBufferLength >= + if (pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.OutputBufferLength >= (length + sizeof(WDI_MESSAGE_HEADER))) { PlatformMoveMemory( @@ -3508,9 +3508,9 @@ Wdi_Get_Auto_Power_Save( { ndisStatus = NDIS_STATUS_BUFFER_TOO_SHORT; pOidHandle->pNdisRequest->DATA.METHOD_INFORMATION.BytesNeeded += (length + sizeof(WDI_MESSAGE_HEADER)); - RT_TRACE(COMP_INIT, DBG_WARNING, ("[Error] GenerateWdiGetAdapterCapabilities() failed with status(%x)\n", ndisStatus)); + RT_TRACE(COMP_INIT, DBG_WARNING, ("[Error] GenerateWdiGetAdapterCapabilities() failed with status(%x)\n", ndisStatus)); } - + if(pOutput) { FreeGenerated(pOutput); @@ -3518,7 +3518,7 @@ Wdi_Get_Auto_Power_Save( } pOidHeader->Status = ndisStatus; - + return ndisStatus; } @@ -3532,10 +3532,10 @@ Wdi_IHV_Request( PTLV_WDI_STRUCT pTlvData = NULL; ULONG BytesWritten = 0, BytesRead = 0, BytesNeeded = 0; PNDIS_OID_REQUEST pNdisRequest = pOidHandle->pNdisRequest; - PWDI_MESSAGE_HEADER pWdiHeader + PWDI_MESSAGE_HEADER pWdiHeader = (PWDI_MESSAGE_HEADER)pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; //20150915-KenSun -//Temp Workaround for setting a private OID +//Temp Workaround for setting a private OID #if 1 PCCX_NIC_SPECIFIC_EXTENSION ccxData; PIHV_CCX_TLV pTlv = NULL; @@ -3589,9 +3589,9 @@ Wdi_IHV_Request( //Because WDI would always pass 2046 in pNdisRequest->DATA.METHOD_INFORMATION.OutputBufferLength //which is not the same value that passed in RTK Appilcations. (All RTK appilcation pass 0 outputbufferlength when issuing a SET OID request) //Therefore, we cannot use it as refence. -//For interfacing with WDI, we have to make sure BytesWriiten is sizeof(WDI_MESSAGE_HEADER) when dealing with a SET method request. +//For interfacing with WDI, we have to make sure BytesWriiten is sizeof(WDI_MESSAGE_HEADER) when dealing with a SET method request. // -#if 1 +#if 1 ccxData = (PCCX_NIC_SPECIFIC_EXTENSION)pTlvData->Value; if(ccxData->event == CCX_EVENT_OID) { @@ -3631,7 +3631,7 @@ Wdi_Get_Statistics( WDI_MAC_STATISTICS_CONTAINER MacStatistics[2]; WDI_PHY_STATISTICS_CONTAINER PhyStatistics[WDI_802_11_MAX_NUM_PHY_TYPES]; PNDIS_OID_REQUEST pNdisRequest = pOidHandle->pNdisRequest; - PWDI_MESSAGE_HEADER pOidHeader + PWDI_MESSAGE_HEADER pOidHeader = (PWDI_MESSAGE_HEADER)pNdisRequest->DATA.METHOD_INFORMATION.InformationBuffer; FunctionIn(COMP_OID_QUERY); @@ -3652,7 +3652,7 @@ Wdi_Get_Statistics( MacStatistics[0].CCMPFormatErrors = pAdapter->RxStats.NumRxCCMPDecryptErrorsUnicast; MacStatistics[0].CCMPReplays = pAdapter->RxStats.NumRxCCMPReplayUnicast; MacStatistics[0].CCMPDecryptErrors = pAdapter->RxStats.NumRxCCMPDecryptErrorsUnicast; - MacStatistics[0].WEPUndecryptableCount = pAdapter->RxStats.NumRxWEPUndecryptableUnicast; + MacStatistics[0].WEPUndecryptableCount = pAdapter->RxStats.NumRxWEPUndecryptableUnicast; MacStatistics[0].WEPICVErrorCount = pAdapter->RxStats.NumRxWEPICVErrorUnicast; MacStatistics[0].DecryptSuccessCount = pAdapter->RxStats.NumRxDecryptSuccessUnicast; MacStatistics[0].DecryptFailureCount = pAdapter->RxStats.NumRxDecryptFailureUnicast; @@ -3668,11 +3668,11 @@ Wdi_Get_Statistics( MacStatistics[1].CCMPFormatErrors = pAdapter->RxStats.NumRxCCMPDecryptErrorsMulticast + pAdapter->RxStats.NumRxCCMPDecryptErrorsBroadcast; MacStatistics[1].CCMPReplays = pAdapter->RxStats.NumRxCCMPReplayMulticast; MacStatistics[1].CCMPDecryptErrors = pAdapter->RxStats.NumRxCCMPDecryptErrorsMulticast + pAdapter->RxStats.NumRxCCMPDecryptErrorsBroadcast; - MacStatistics[1].WEPUndecryptableCount = pAdapter->RxStats.NumRxWEPUndecryptableMulticast + pAdapter->RxStats.NumRxWEPUndecryptableBroadcast; + MacStatistics[1].WEPUndecryptableCount = pAdapter->RxStats.NumRxWEPUndecryptableMulticast + pAdapter->RxStats.NumRxWEPUndecryptableBroadcast; MacStatistics[1].WEPICVErrorCount = pAdapter->RxStats.NumRxWEPICVErrorMulticast + pAdapter->RxStats.NumRxWEPICVErrorBroadcast; MacStatistics[1].DecryptSuccessCount = pAdapter->RxStats.NumRxDecryptSuccessMulticast + pAdapter->RxStats.NumRxDecryptSuccessBroadcast; MacStatistics[1].DecryptFailureCount = pAdapter->RxStats.NumRxDecryptFailureMulticast + pAdapter->RxStats.NumRxDecryptFailureBroadcast; - + Params.PeerMACStatistics.ElementCount = 2; Params.PeerMACStatistics.pElements = MacStatistics; @@ -3704,24 +3704,24 @@ Wdi_Get_Statistics( PhyStatistics[0].PhyType = WDI_PHY_TYPE_VHT; break; - + } PhyStatistics[0].TransmittedFrameCount = pAdapter->TxStats.NumTxOkTotal; PhyStatistics[0].GroupTransmittedFrameCount = pAdapter->TxStats.NumTxMulticast + pAdapter->TxStats.NumTxBroadcast; - PhyStatistics[0].FailedCount = pAdapter->TxStats.NumTxErrTotal; - PhyStatistics[0].RetryCount = pAdapter->TxStats.NumTxRetryCount; + PhyStatistics[0].FailedCount = pAdapter->TxStats.NumTxErrTotal; + PhyStatistics[0].RetryCount = pAdapter->TxStats.NumTxRetryCount; PhyStatistics[0].MultipleRetryCount = 0; // TODO PhyStatistics[0].MaxTXLifetimeExceededCount = 0; // TODO - PhyStatistics[0].TransmittedFragmentCount = pAdapter->TxStats.NumTxOkTotal; + PhyStatistics[0].TransmittedFragmentCount = pAdapter->TxStats.NumTxOkTotal; PhyStatistics[0].RTSSuccessCount = 0; // TODO PhyStatistics[0].RTSFailureCount = 0; // TODO PhyStatistics[0].ACKFailureCount = 0; // TODO PhyStatistics[0].ReceivedFrameCount = pAdapter->RxStats.NumRxFramgment; - PhyStatistics[0].GroupReceivedFrameCount = pAdapter->RxStats.NumRxFramgment; + PhyStatistics[0].GroupReceivedFrameCount = pAdapter->RxStats.NumRxFramgment; PhyStatistics[0].PromiscuousReceivedFrameCount = 0; // TODO PhyStatistics[0].MaxRXLifetimeExceededCount = 0; // TODO PhyStatistics[0].FrameDuplicateCount = 0; // TODO - PhyStatistics[0].ReceivedFragmentCount = pAdapter->RxStats.NumRxFramgment; + PhyStatistics[0].ReceivedFragmentCount = pAdapter->RxStats.NumRxFramgment; PhyStatistics[0].PromiscuousReceivedFragmentCount = 0; // TODO PhyStatistics[0].FCSErrorCount = pAdapter->RxStats.NumRxErrTotalUnicast + pAdapter->RxStats.NumRxErrTotalMulticast; Params.PhyStatistics.ElementCount = 1; @@ -3730,7 +3730,7 @@ Wdi_Get_Statistics( else { u1Byte count = 0; - + PlatformZeroMemory(&MacStatistics[0], sizeof(WDI_MAC_STATISTICS_CONTAINER)*2); cpMacAddr(MacStatistics[0].MACAddress.Address, BroadcastAddress); Params.PeerMACStatistics.ElementCount = 1; @@ -3761,7 +3761,7 @@ Wdi_Get_Statistics( return ndisStatus; } - if (pNdisRequest->DATA.METHOD_INFORMATION.OutputBufferLength >= + if (pNdisRequest->DATA.METHOD_INFORMATION.OutputBufferLength >= (length + sizeof(WDI_MESSAGE_HEADER))) { PlatformMoveMemory( @@ -3774,9 +3774,9 @@ Wdi_Get_Statistics( { ndisStatus = NDIS_STATUS_BUFFER_TOO_SHORT; pNdisRequest->DATA.METHOD_INFORMATION.BytesNeeded += (length + sizeof(WDI_MESSAGE_HEADER)); - RT_TRACE(COMP_INIT, DBG_WARNING, ("[Error] GenerateWdiGetStatistics() failed with status(%x)\n", ndisStatus)); + RT_TRACE(COMP_INIT, DBG_WARNING, ("[Error] GenerateWdiGetStatistics() failed with status(%x)\n", ndisStatus)); } - + if(pOutput) { FreeGenerated(pOutput); @@ -3784,9 +3784,9 @@ Wdi_Get_Statistics( } pOidHeader->Status = ndisStatus; - + FunctionOut(COMP_OID_QUERY); - + return ndisStatus; } @@ -3798,7 +3798,7 @@ WDI_OID_TASK_OPEN( ) { NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; - + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Not Support WDI_OID_TASK_OPEN\n")); return ndisStatus; @@ -3813,7 +3813,7 @@ WDI_OID_TASK_CLOSE( { NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; - + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("Not Support WDI_OID_TASK_CLOSE\n")); return ndisStatus; @@ -3837,7 +3837,7 @@ WDI_OID_TASK_P2P_DISCOVER( { NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_TASK_P2P_DISCOVER_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramP2pDiscover; - + FunctionIn(COMP_OID_SET); do @@ -3846,7 +3846,7 @@ WDI_OID_TASK_P2P_DISCOVER( P2P_INFO *info = GET_P2P_INFO(pAdapter); FRAME_BUF *buf = NULL; - + // additional ie if(param->Optional.VendorIEs_IsPresent) { @@ -3856,20 +3856,20 @@ WDI_OID_TASK_P2P_DISCOVER( ); } - RT_TRACE_F(COMP_P2P, DBG_LOUD, ("DiscoveryType = %d, ScanType = %d\n", + RT_TRACE_F(COMP_P2P, DBG_LOUD, ("DiscoveryType = %d, ScanType = %d\n", param->DiscoverMode.DiscoveryType, param->DiscoverMode.ScanType)); // construct req if(NULL != (req = CustomScan_AllocReq(GET_CUSTOM_SCAN_INFO(pAdapter), NULL, NULL))) { static u1Byte bcst[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; - + buf = CustomScan_GetProbeReqBuf(req); if(param->SSIDList.ElementCount) { WDI_SSID *ssid = ¶m->SSIDList.pElements[0]; - + RT_PRINT_STR(COMP_OID_SET, DBG_LOUD, "to probe with ssid", ssid->pElements, ssid->ElementCount); P2P_Construct_ProbeReqEx(buf, info, bcst, (u1Byte)ssid->ElementCount, (u1Byte *)ssid->pElements); } @@ -3892,10 +3892,10 @@ WDI_OID_TASK_P2P_DISCOVER( if(WDI_P2P_SCAN_TYPE_PASSIVE == param->DiscoverMode.ScanType) CustomScan_ForcePassiveScan(req); - + CustomScan_SetTimeBound(req, param->DwellTime.MaximumScanTime); CustomScan_SetupCbCtx(req, wdi_P2PDiscoveryCb, pAdapter); - + CustomScan_IssueReq(GET_CUSTOM_SCAN_INFO(pAdapter), req, CUSTOM_SCAN_SRC_TYPE_P2P, "wdi-p2p-discovery"); } }while(FALSE); @@ -3936,7 +3936,7 @@ WDI_OID_TASK_DOT11_RESET( WDI_TASK_DOT11_RESET_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramDot11Reset; NDIS_OID_REQUEST *req = NULL; - + FunctionIn(COMP_OID_SET); do @@ -3959,7 +3959,7 @@ WDI_OID_TASK_DOT11_RESET( N63CResetNetworkListOffload(pAdapter); - // MAC Address Randomization + // MAC Address Randomization if(param->Optional.ResetMACAddress_IsPresent && pAdapter->MgntInfo.RegSupportMACRandom) { cpMacAddr( pAdapter->CurrentAddress, param->ResetMACAddress.Address); @@ -3968,7 +3968,7 @@ WDI_OID_TASK_DOT11_RESET( } // cleanup - if(req && NDIS_STATUS_SUCCESS != status) + if(req && NDIS_STATUS_SUCCESS != status) Wdi_Xlat_FreeOid(req); FunctionOut(COMP_OID_SET); @@ -3996,7 +3996,7 @@ WDI_OID_TASK_P2P_SEND_REQUEST_ACTION_FRAME( NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_TASK_P2P_SEND_REQUEST_ACTION_FRAME_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramP2pSendRequestActionFrame; VOID *req = NULL; - + FunctionIn(COMP_OID_SET); do @@ -4026,7 +4026,7 @@ WDI_OID_TASK_P2P_SEND_REQUEST_ACTION_FRAME( break; } }while(FALSE); - + FunctionOut(COMP_OID_SET); return status; @@ -4042,12 +4042,12 @@ WDI_OID_TASK_P2P_SEND_RESPONSE_ACTION_FRAME( NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_TASK_P2P_SEND_RESPONSE_ACTION_FRAME_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramP2pSendResponseActionFrame; VOID *req = NULL; - + FunctionIn(COMP_OID_SET); do { - // termincate any ongoing scan for sending rsp + // termincate any ongoing scan for sending rsp WDI_SendAction_TerminateReq(pAdapter); if(WDI_P2P_ACTION_FRAME_GO_NEGOTIATION_RESPONSE == param->ResponseParams.ResponseFrameType) @@ -4079,7 +4079,7 @@ WDI_OID_TASK_P2P_SEND_RESPONSE_ACTION_FRAME( break; } }while(FALSE); - + FunctionOut(COMP_OID_SET); return status; @@ -4103,7 +4103,7 @@ WDI_OID_TASK_CREATE_PORT( { NDIS_STATUS status = NDIS_STATUS_SUCCESS; PORT_HELPER *pPortHelper = pAdapter->pPortCommonInfo->pPortHelper; - + status = Wdi_Task_CreatePort(pAdapter, pOidHandle); if(NDIS_STATUS_PENDING == status) @@ -4113,7 +4113,7 @@ WDI_OID_TASK_CREATE_PORT( PlatformReleaseSpinLock(pAdapter, RT_PENDED_OID_SPINLOCK); status = NDIS_STATUS_SUCCESS; } - + return status; } @@ -4128,7 +4128,7 @@ WDI_OID_TASK_DELETE_PORT( PORT_HELPER *pPortHelper = pAdapter->pPortCommonInfo->pPortHelper; status = Wdi_Task_DeletePort(pAdapter, pOidHandle); - + if(NDIS_STATUS_PENDING == status) {// WDI always return success regardless of our status here, so we need to record pended req here PlatformAcquireSpinLock(pAdapter, RT_PENDED_OID_SPINLOCK); @@ -4151,7 +4151,7 @@ WDI_OID_TASK_START_AP( WDI_TASK_START_AP_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramStartAp; NDIS_OID_REQUEST *req = NULL; - + FunctionIn(COMP_OID_SET); do @@ -4171,7 +4171,7 @@ WDI_OID_TASK_START_AP( Wdi_Xlat_FreeOid(req); req = NULL; - + // Start AP if(NULL == (req = Wdi_Xlat_AllocStartApReqOid(pOidHandle, param))) { @@ -4187,13 +4187,13 @@ WDI_OID_TASK_START_AP( RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("N63C_OID_DOT11_WFD_START_GO_REQUEST returns: 0x%08X\n", status)); break; } - + }while(FALSE); // M4 indication is not required since bWaitComplete in RT_SUPPORT_TASKs is FALSE // cleanup - if(req) + if(req) Wdi_Xlat_FreeOid(req); FunctionOut(COMP_OID_SET); @@ -4209,17 +4209,17 @@ WDI_OID_TASK_STOP_AP( ) { NDIS_STATUS status = NDIS_STATUS_SUCCESS; - + FunctionIn(COMP_OID_SET); if(RT_AP_TYPE_VWIFI_AP == MgntActQuery_ApType(pAdapter)) { status = N6CSet_DOT11_DISCONNECT_REQUEST(pAdapter, NULL, 0, 0, 0); - + if(NDIS_STATUS_SUCCESS != status) { RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("N6CSet_DOT11_DISCONNECT_REQUEST returns: 0x%08X\n", status)); - } + } } else { @@ -4242,14 +4242,14 @@ WDI_OID_TASK_SEND_AP_ASSOCIATION_RESPONSE( WDI_TASK_SEND_AP_ASSOCIATION_RESPONSE_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSendApAssociationResponse; NDIS_OID_REQUEST *req = NULL; - + FunctionIn(COMP_OID_SET); do { MGNT_INFO *pMgntInfo = NULL; RT_WLAN_STA *pEntry = NULL; - + pMgntInfo = &pAdapter->MgntInfo; if(NULL == (req = Wdi_Xlat_AllocIncomingAssociationDecisionOid(pOidHandle, param))) @@ -4263,7 +4263,7 @@ WDI_OID_TASK_SEND_AP_ASSOCIATION_RESPONSE( status = NDIS_STATUS_INVALID_STATE; break; } - + if(NDIS_STATUS_SUCCESS != (status = N62C_OID_DOT11_INCOMING_ASSOCIATION_DECISION(pAdapter, req))) { RT_TRACE_F(COMP_MLME, DBG_WARNING, ("N62C_OID_DOT11_INCOMING_ASSOCIATION_DECISION returns: 0x%08X\n", status)); @@ -4273,21 +4273,21 @@ WDI_OID_TASK_SEND_AP_ASSOCIATION_RESPONSE( pOidHandle->pvCtx = req; AP_SendAsocRsp( - pAdapter, - pEntry, - TRUE == param->IncomingRequestInfo.AssocRequestParams.IsReassociationRequest, - FALSE, + pAdapter, + pEntry, + TRUE == param->IncomingRequestInfo.AssocRequestParams.IsReassociationRequest, + FALSE, param->AssocResponseParameters.ReasonCode ); // If succeeded, WDI_CMD_SendApAssociationResponseComplete is called from DrvIFIndicateIncommingAssociationComplete - + }while(FALSE); // cleanup if(NDIS_STATUS_SUCCESS != status) { - if(req) + if(req) Wdi_Xlat_FreeOid(req); } @@ -4299,7 +4299,7 @@ WDI_OID_TASK_SEND_AP_ASSOCIATION_RESPONSE( NDIS_STATUS -WDI_OID_TASK_CHANGE_OPERATION_MODE( +WDI_OID_TASK_CHANGE_OPERATION_MODE( IN PADAPTER pAdapter, IN PRT_OID_HANDLER pOidHandle ) @@ -4308,7 +4308,7 @@ WDI_OID_TASK_CHANGE_OPERATION_MODE( WDI_TASK_CHANGE_OPERATION_MODE_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramChangeOperationMode; NDIS_OID_REQUEST *req = NULL; - + FunctionIn(COMP_OID_SET); do @@ -4318,7 +4318,7 @@ WDI_OID_TASK_CHANGE_OPERATION_MODE( status = NDIS_STATUS_RESOURCES; break; } - + if(NDIS_STATUS_SUCCESS != (status = N6C_OID_DOT11_CURRENT_OPERATION_MODE(pAdapter, req))) { RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("N6C_OID_DOT11_CURRENT_OPERATION_MODE returns: 0x%08X\n", status)); @@ -4327,11 +4327,11 @@ WDI_OID_TASK_CHANGE_OPERATION_MODE( // Indicate completed successfully WDI_CMD_ChangeOpModeComplete(pAdapter, req, status); - + }while(FALSE); // cleanup - if(req && NDIS_STATUS_SUCCESS != status) + if(req && NDIS_STATUS_SUCCESS != status) Wdi_Xlat_FreeOid(req); FunctionOut(COMP_OID_SET); @@ -4348,9 +4348,9 @@ WDI_OID_TASK_SEND_REQUEST_ACTION_FRAME( NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_TASK_SEND_REQUEST_ACTION_FRAME_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSendRequestActionFrame; VOID *req = NULL; - + FunctionIn(COMP_OID_SET); - + do { req = WDI_SendAction_Req(pAdapter, param, wdi_SendReqActionFrameStateCb); @@ -4361,7 +4361,7 @@ WDI_OID_TASK_SEND_REQUEST_ACTION_FRAME( status = NDIS_STATUS_FAILURE; } }while(FALSE); - + FunctionOut(COMP_OID_SET); return status; @@ -4376,7 +4376,7 @@ WDI_OID_TASK_SEND_RESPONSE_ACTION_FRAME( NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_TASK_SEND_RESPONSE_ACTION_FRAME_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSendResponseActionFrame; VOID *req = NULL; - + FunctionIn(COMP_OID_SET); do @@ -4389,7 +4389,7 @@ WDI_OID_TASK_SEND_RESPONSE_ACTION_FRAME( status = NDIS_STATUS_FAILURE; } }while(FALSE); - + FunctionOut(COMP_OID_SET); return status; @@ -4404,7 +4404,7 @@ WDI_OID_SET_P2P_LISTEN_STATE( NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_SET_P2P_LISTEN_STATE_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSetP2pListenState; NDIS_OID_REQUEST *req = NULL; - + FunctionIn(COMP_OID_SET); if( param == NULL ) @@ -4453,7 +4453,7 @@ WDI_OID_SET_P2P_LISTEN_STATE( // TODO: }while(FALSE); - if(req) + if(req) Wdi_Xlat_FreeOid(req); FunctionOut(COMP_OID_SET); @@ -4518,7 +4518,7 @@ WDI_OID_GET_AUTO_POWER_SAVE( ) { NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; - + return Wdi_Get_Auto_Power_Save(pAdapter, pOidHandle); } @@ -4539,7 +4539,7 @@ WDI_OID_GET_ADAPTER_CAPABILITIES( ) { NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; - + ndisStatus = N6SdioWdi_AdapterCapabilities( pAdapter, pOidHandle @@ -4688,7 +4688,7 @@ WDI_OID_SET_ADVERTISEMENT_INFORMATION( NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_SET_ADVERTISEMENT_INFORMATION_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSetAdvertisementInformation; NDIS_OID_REQUEST *req = NULL; - + if( param == NULL ) return NDIS_STATUS_FAILURE; @@ -4706,8 +4706,8 @@ WDI_OID_SET_ADVERTISEMENT_INFORMATION( if(param->AdditionalIEs.AdditionalBeaconIEs.ElementCount) { P2P_AddIe_Set( - &info->AdditionalIEs, P2P_ADD_IE_BEACON, - param->AdditionalIEs.AdditionalBeaconIEs.ElementCount, + &info->AdditionalIEs, P2P_ADD_IE_BEACON, + param->AdditionalIEs.AdditionalBeaconIEs.ElementCount, param->AdditionalIEs.AdditionalBeaconIEs.pElements); RT_PRINT_DATA(COMP_P2P, DBG_LOUD, "WDI_OID_SET_ADVERTISEMENT_INFORMATION(): AdditionalBeaconIEs\n", param->AdditionalIEs.AdditionalBeaconIEs.pElements, param->AdditionalIEs.AdditionalBeaconIEs.ElementCount); @@ -4716,8 +4716,8 @@ WDI_OID_SET_ADVERTISEMENT_INFORMATION( if(param->AdditionalIEs.AdditionalProbeResponseIEs.ElementCount) { P2P_AddIe_Set( - &info->AdditionalIEs, P2P_ADD_IE_PROBE_RESPONSE, - param->AdditionalIEs.AdditionalProbeResponseIEs.ElementCount, + &info->AdditionalIEs, P2P_ADD_IE_PROBE_RESPONSE, + param->AdditionalIEs.AdditionalProbeResponseIEs.ElementCount, param->AdditionalIEs.AdditionalProbeResponseIEs.pElements); RT_PRINT_DATA(COMP_P2P, DBG_LOUD, "WDI_OID_SET_ADVERTISEMENT_INFORMATION(): AdditionalProbeResponseIEs\n", param->AdditionalIEs.AdditionalProbeResponseIEs.pElements, param->AdditionalIEs.AdditionalProbeResponseIEs.ElementCount); @@ -4728,14 +4728,14 @@ WDI_OID_SET_ADVERTISEMENT_INFORMATION( if(param->AdditionalIEs.AdditionalProbeRequestDefaultIEs.ElementCount) { P2P_AddIe_Set( - &info->AdditionalIEs, P2P_ADD_IE_DEFAULT_REQUEST, - param->AdditionalIEs.AdditionalProbeRequestDefaultIEs.ElementCount, + &info->AdditionalIEs, P2P_ADD_IE_DEFAULT_REQUEST, + param->AdditionalIEs.AdditionalProbeRequestDefaultIEs.ElementCount, param->AdditionalIEs.AdditionalProbeRequestDefaultIEs.pElements); RT_PRINT_DATA(COMP_P2P, DBG_LOUD, "WDI_OID_SET_ADVERTISEMENT_INFORMATION(): AdditionalProbeRequestDefaultIEs\n", param->AdditionalIEs.AdditionalProbeRequestDefaultIEs.pElements, param->AdditionalIEs.AdditionalProbeRequestDefaultIEs.ElementCount); } } - + // device info if(param->Optional.DeviceInformation_IsPresent) { @@ -4753,7 +4753,7 @@ WDI_OID_SET_ADVERTISEMENT_INFORMATION( Wdi_Xlat_FreeOid(req); req = NULL; } - + // dev cap if(param->Optional.DeviceCapability_IsPresent) { @@ -4807,12 +4807,12 @@ WDI_OID_SET_ADVERTISEMENT_INFORMATION( Wdi_Xlat_FreeOid(req); req = NULL; } - + // TODO: adv svc }while(FALSE); - if(req) + if(req) Wdi_Xlat_FreeOid(req); FunctionOut(COMP_OID_SET); @@ -4845,7 +4845,7 @@ WDI_OID_GET_NEXT_ACTION_FRAME_DIALOG_TOKEN( ULONG tlvlen = 0; UINT8 *tlv = NULL; - + FunctionIn(COMP_OID_SET); do @@ -4887,7 +4887,7 @@ WDI_OID_GET_NEXT_ACTION_FRAME_DIALOG_TOKEN( } GenerateWdiGetNextActionFrameDialogToken( - ¶m, 0, + ¶m, 0, &pAdapter->pPortCommonInfo->WdiData.TlvContext, &tlvlen, &tlv); @@ -4903,11 +4903,11 @@ WDI_OID_GET_NEXT_ACTION_FRAME_DIALOG_TOKEN( tlv, tlvlen); pNdisRequest->DATA.METHOD_INFORMATION.BytesWritten += tlvlen; - + }while(FALSE); // cleanup; - if(req) + if(req) Wdi_Xlat_FreeOid(req); if(tlv) @@ -4929,7 +4929,7 @@ WDI_OID_SET_P2P_WPS_ENABLED( NDIS_STATUS status = NDIS_STATUS_SUCCESS; WDI_SET_P2P_WPS_ENABLED_PARAMETERS *param = pOidHandle->tlvParser.parsedTlv.paramSetP2pWpsEnabled; NDIS_OID_REQUEST *req = NULL; - + if( param == NULL ) return NDIS_STATUS_FAILURE; @@ -4945,10 +4945,10 @@ WDI_OID_SET_P2P_WPS_ENABLED( RT_TRACE_F(COMP_OID_SET, DBG_WARNING, ("N62C_OID_DOT11_WPS_ENABLED returns: 0x%08X\n", status)); break; } - + }while(FALSE); - if(req) + if(req) Wdi_Xlat_FreeOid(req); FunctionOut(COMP_OID_SET); @@ -4985,7 +4985,7 @@ WDI_OID_SET_FAST_BSS_TRANSITION_PARAMETERS( NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; WDI_SET_FAST_BSS_TRANSITION_PARAMETERS_COMMAND *param = pOidHandle->tlvParser.parsedTlv.paramSetFastBssTransitionParametersCommand; u1Byte targetAddr[6] = {0}; - + if( param == NULL ) return NDIS_STATUS_FAILURE; @@ -5008,7 +5008,7 @@ WDI_OID_SET_FAST_BSS_TRANSITION_PARAMETERS( RT_PRINT_DATA(COMP_MLME, DBG_LOUD, "RSNIE:\n", param->RSNIE.pElements, param->RSNIE.ElementCount); } - + if(param->Optional.MDE_IsPresent) { FtUpdateEntryInfo(pAdapter, FT_ENTRY_ACTION_UPDATE_MDE, targetAddr, @@ -5048,8 +5048,8 @@ WDI_OID_SET_FAST_BSS_TRANSITION_PARAMETERS( // // Description: // Prepare indication data for WDI create port. -// Also add data path (via AddDataPathPeer()) as -// it was copied from the original code in +// Also add data path (via AddDataPathPeer()) as +// it was copied from the original code in // WdiSimpleTask(). // // Note: @@ -5066,12 +5066,12 @@ WDI_CMD_CreatePortComplete( { RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; DOT11_MAC_INFO *macInfo = NULL; - + UINT8 *tlv = NULL; ULONG len = 0; WDI_INDICATION_CREATE_PORT_COMPLETE_PARAMETERS param = {0}; - + macInfo = (DOT11_MAC_INFO *)req->DATA.METHOD_INFORMATION.InformationBuffer; FunctionIn(COMP_OID_SET); @@ -5108,7 +5108,7 @@ WDI_CMD_CreatePortComplete( PlatformAcquireSpinLock(pAdapter, RT_PENDED_OID_SPINLOCK); pAdapter->pNdisCommon->PendedRequest = NULL; PlatformReleaseSpinLock(pAdapter, RT_PENDED_OID_SPINLOCK); - + FunctionOut(COMP_OID_SET); return TRUE; @@ -5122,7 +5122,7 @@ WDI_CMD_DeletePortComplete( ) { RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5149,7 +5149,7 @@ WDI_CMD_DeletePortComplete( // Free pended oid PlatformAcquireSpinLock(pAdapter, RT_PENDED_OID_SPINLOCK); pAdapter->pNdisCommon->PendedRequest = NULL; - PlatformReleaseSpinLock(pAdapter, RT_PENDED_OID_SPINLOCK); + PlatformReleaseSpinLock(pAdapter, RT_PENDED_OID_SPINLOCK); FunctionOut(COMP_OID_SET); @@ -5164,7 +5164,7 @@ WDI_CMD_ResetComplete( ) { RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5177,7 +5177,7 @@ WDI_CMD_ResetComplete( // generate TLV //GenerateWdiIndicationDot11ResetComplete(¶m, 0, &pAdapter->pPortCommonInfo->WdiData.TlvContext, &len, &tlv); - + // copy tlv wdi_task_WriteResult(hTask, tlv, len, status); @@ -5201,7 +5201,7 @@ WDI_CMD_ChangeOpModeComplete( ) { RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5237,7 +5237,7 @@ WDI_CMD_P2PDiscoverComplete( ) { RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5255,7 +5255,7 @@ WDI_CMD_P2PDiscoverComplete( // generate TLV //GenerateWdiIndicationDot11ResetComplete(¶m, 0, &pAdapter->pPortCommonInfo->WdiData.TlvContext, &len, &tlv); - + // copy tlv wdi_task_WriteResult(hTask, tlv, len, status); @@ -5278,10 +5278,10 @@ WDI_CMD_P2pSendRequestActionFrameComplete( { RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; OFF_CHNL_TX_STATUS_FLAG txStatusFlag; - + u4Byte ieOffset = FRAME_OFFSET_P2P_PUB_ACT_ELEMENTS; NDIS_STATUS status = NDIS_STATUS_SUCCESS; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5300,7 +5300,7 @@ WDI_CMD_P2pSendRequestActionFrameComplete( FRAME_BUF *buf = OffChnlTx_GetTxFrameBuf(ctx->req); RT_ASSERT(buf, ("%s(): buf is NULL!!!n", __FUNCTION__)); - + cpMacAddr(param.SendActionFrameResult.FrameParameters.PeerDeviceAddress.Address, (FrameBuf_Head(buf) + FRAME_OFFSET_ADDRESS1)); param.SendActionFrameResult.FrameParameters.DialogToken = ctx->token; param.SendActionFrameResult.FrameIEs.ElementCount = FrameBuf_Length(buf) - ieOffset; @@ -5308,13 +5308,13 @@ WDI_CMD_P2pSendRequestActionFrameComplete( RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("token: %u\n", param.SendActionFrameResult.FrameParameters.DialogToken)); } - + // generate TLV GenerateWdiIndicationP2pSendRequestActionFrameComplete( - ¶m, 0, - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, 0, + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &len, &tlv); - + // copy tlv wdi_task_WriteResult(hTask, tlv, len, status); @@ -5337,10 +5337,10 @@ WDI_CMD_P2pSendResponseActionFrameComplete( { RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; OFF_CHNL_TX_STATUS_FLAG txStatusFlag; - + u4Byte ieOffset = FRAME_OFFSET_P2P_PUB_ACT_ELEMENTS; NDIS_STATUS status = NDIS_STATUS_SUCCESS; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5351,13 +5351,13 @@ WDI_CMD_P2pSendResponseActionFrameComplete( status = (TEST_FLAG(txStatusFlag.perTxAttemptFlag, OFF_CHNL_TX_PER_TX_ATTEMPT_FLAG_FRAME_SENT) ? NDIS_STATUS_SUCCESS : NDIS_STATUS_FAILURE); FunctionIn(COMP_OID_SET); - + if(NDIS_STATUS_SUCCESS == status) { FRAME_BUF *buf = OffChnlTx_GetTxFrameBuf(ctx->req); RT_ASSERT(buf, ("%s(): buf is NULL!!!n", __FUNCTION__)); - + cpMacAddr(param.SendActionFrameResult.FrameParameters.PeerDeviceAddress.Address, (FrameBuf_Head(buf) + FRAME_OFFSET_ADDRESS1)); param.SendActionFrameResult.FrameParameters.DialogToken = ctx->token; param.SendActionFrameResult.FrameIEs.ElementCount = FrameBuf_Length(buf) - ieOffset; @@ -5365,13 +5365,13 @@ WDI_CMD_P2pSendResponseActionFrameComplete( RT_TRACE_F(COMP_OID_SET, DBG_LOUD, ("token: %u\n", param.SendActionFrameResult.FrameParameters.DialogToken)); } - + // generate TLV GenerateWdiIndicationP2pSendResponseActionFrameComplete( - ¶m, 0, - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, 0, + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &len, &tlv); - + // copy tlv wdi_task_WriteResult(hTask, tlv, len, status); @@ -5391,11 +5391,11 @@ WDI_CMD_SendReqActionFrameComplete( IN PADAPTER pAdapter, IN const WDI_SEND_ACTION_CTX *ctx ) -{ +{ NDIS_STATUS status = NDIS_STATUS_SUCCESS; RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; OFF_CHNL_TX_STATUS_FLAG txStatusFlag = {0}; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5413,13 +5413,13 @@ WDI_CMD_SendReqActionFrameComplete( { RT_TRACE(COMP_MLME, DBG_WARNING, ("Action Req frame send failure.\n")); } - + #if 0 //GenerateWdiIndicationSendRequestActionFrameComplete( - // ¶m, 0, - // &pAdapter->pPortCommonInfo->WdiData.TlvContext, + // ¶m, 0, + // &pAdapter->pPortCommonInfo->WdiData.TlvContext, // &len, &tlv); - + wdi_task_WriteResult(hTask, tlv, len, status); FreeGenerated(tlv); @@ -5434,11 +5434,11 @@ WDI_CMD_SendRspActionFrameComplete( IN PADAPTER pAdapter, IN const WDI_SEND_ACTION_CTX *ctx ) -{ +{ NDIS_STATUS status = NDIS_STATUS_SUCCESS; RT_OID_HANDLER *hTask = &pAdapter->pPortCommonInfo->WdiData.TaskHandle; OFF_CHNL_TX_STATUS_FLAG txStatusFlag = {0}; - + UINT8 *tlv = NULL; ULONG len = 0; @@ -5453,13 +5453,13 @@ WDI_CMD_SendRspActionFrameComplete( { RT_TRACE(COMP_MLME, DBG_WARNING, ("Action Rsp frame send failure.\n")); } - + #if 0 GenerateWdiIndicationSendRequestActionFrameComplete( - ¶m, 0, - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, 0, + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &len, &tlv); - + wdi_task_WriteResult(hTask, tlv, len, status); FreeGenerated(tlv); @@ -5487,11 +5487,13 @@ WDI_CMD_SendApAssociationResponseComplete( FunctionIn(COMP_MLME); // prepare structure, ref N62CAPIndicateIncomAssocComplete +#if !defined(NTDDI_WIN10_RS3) param.Optional.ActivePhyList_IsPresent = FALSE; +#endif cpMacAddr(param.AssocResponseResult.PeerMACAddress.Address, sta->MacAddr); - param.AssocResponseResult.IsReassociationRequest = + param.AssocResponseResult.IsReassociationRequest = Type_Reasoc_Rsp == GET_80211_HDR_TYPE(sta->AP_SendAsocResp) ? TRUE : FALSE; - param.AssocResponseResult.IsReAssociationResponse = + param.AssocResponseResult.IsReAssociationResponse = param.AssocResponseResult.IsReassociationRequest; if(RT_802_11AuthModeOpen == sta->AuthMode) param.AssocResponseResult.AuthAlgorithm = WDI_AUTH_ALGO_80211_OPEN; @@ -5509,7 +5511,7 @@ WDI_CMD_SendApAssociationResponseComplete( param.AssocResponseResult.AuthAlgorithm = WDI_AUTH_ALGO_WPA_NONE; else if(RT_802_11AuthModeWPA2PSK == sta->AuthMode) param.AssocResponseResult.AuthAlgorithm = WDI_AUTH_ALGO_WPA_PSK; - else + else param.AssocResponseResult.AuthAlgorithm = WDI_AUTH_ALGO_80211_OPEN; if(RT_ENC_ALG_NO_CIPHER == sta->perSTAKeyInfo.PairwiseCipherSuite[0]) @@ -5543,7 +5545,7 @@ WDI_CMD_SendApAssociationResponseComplete( param.AssocResponseResult.UnicastCipherAlgorithm = WDI_CIPHER_ALGO_NONE; param.AssocResponseFrame.ElementCount = MMPDU_BODY_LEN(sta->AP_SendAsocRespLength); - param.AssocResponseFrame.pElements = MMPDU_BODY(sta->AP_SendAsocResp); + param.AssocResponseFrame.pElements = MMPDU_BODY(sta->AP_SendAsocResp); if(pAdapter->MgntInfo.beaconframe.Length) { @@ -5555,13 +5557,13 @@ WDI_CMD_SendApAssociationResponseComplete( param.BeaconIEs.ElementCount = 0; param.BeaconIEs.pElements = NULL; } - + // generate TLV GenerateWdiIndicationSendApAssociationResponseComplete( - ¶m, 0, - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, 0, + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &len, &tlv); - + // copy tlv wdi_task_WriteResult(hTask, tlv, len, status); @@ -5569,7 +5571,7 @@ WDI_CMD_SendApAssociationResponseComplete( FreeGenerated(tlv); ndisStatus = WDI_AddDatapathPeer(pAdapter, sta->MacAddr); - + // Free the OID Wdi_Xlat_FreeOid(req); @@ -5577,7 +5579,7 @@ WDI_CMD_SendApAssociationResponseComplete( OidHandle_Complete(pAdapter, OIDHANDLE_TYPE_TASK); if( ndisStatus != NDIS_STATUS_SUCCESS ) - { + { RT_TRACE(COMP_MLME, DBG_WARNING, ("WDI_CMD_SendApAssociationResponseComplete: fail to create peer, so disconnect with this AP[%2x:%2x:%2x:%2x:%2x:%2x]\n", sta->MacAddr[0], sta->MacAddr[1], sta->MacAddr[2], sta->MacAddr[3], sta->MacAddr[4], sta->MacAddr[5])); // 1. Send disassoc frame to the STA. @@ -5612,7 +5614,7 @@ WDI_CMD_PreIndicateRxP2pActionFrameCb( ADAPTER *pAdapter = pP2PInfo->pAdapter; FunctionIn(COMP_OID_SET); - + if(P2P_EVENT_RECEIVED_PROVISION_DISCOVERY_RESPONSE == EventID || P2P_EVENT_RECEIVED_INVITATION_RESPONSE == EventID || P2P_EVENT_RECEIVED_GO_NEGOTIATION_RESPONSE == EventID @@ -5621,7 +5623,7 @@ WDI_CMD_PreIndicateRxP2pActionFrameCb( { WDI_SendAction_TerminateReq(pAdapter); } - + FunctionOut(COMP_OID_SET); return; @@ -5732,7 +5734,7 @@ WDI_CANCEL_OID_TASK_SEND_RESPONSE_ACTION_FRAME( return NDIS_STATUS_SUCCESS; } -NDIS_STATUS +NDIS_STATUS WDI_PRE_M4_OID_TASK_SCAN( IN PADAPTER pAdapter, IN PRT_OID_HANDLER pOidHandle diff --git a/network/wlan/WDI/PLATFORM/NDIS6/WDI_Common.c b/network/wlan/WDI/PLATFORM/NDIS6/WDI_Common.c index 1b478b21..bfb1cce8 100644 --- a/network/wlan/WDI/PLATFORM/NDIS6/WDI_Common.c +++ b/network/wlan/WDI/PLATFORM/NDIS6/WDI_Common.c @@ -24,7 +24,7 @@ wdi_UnsolicitedIndication( NDIS_OID_REQUEST *req = NULL; RT_TRACE(COMP_MLME, DBG_LOUD, ("==>wdi_UnsolicitedIndication(): status indication code = %x, length=%d\n", Indication, Length)); - + indic = (NDIS_STATUS_INDICATION *)pInput; wdiHdr = (WDI_MESSAGE_HEADER *)(pInput + sizeof(*indic)); @@ -59,12 +59,12 @@ wdi_UnsolicitedIndication( pAdapter->pNdisCommon->hNdisAdapter, indic ); - + RT_TRACE(COMP_MLME, DBG_LOUD, ("<== wdi_UnsolicitedIndication()\n")); } // -// The following helper functions are used to determined if a +// The following helper functions are used to determined if a // BSS has the capability of specific wireless mode. // 2005.01.13, by rcnjko. // @@ -106,7 +106,7 @@ WDIWithWirelessG( { return FALSE; } - + // Check supported rates. for(i = 0; i < pRtBss->bdSupportRateEXLen; i++) { @@ -119,12 +119,12 @@ WDIWithWirelessG( } // Check if it contains ERP information element. - // Some AP, WAG-302, will not always claim OFDM rates in their ProbeRsp or Beacon + // Some AP, WAG-302, will not always claim OFDM rates in their ProbeRsp or Beacon // but it is in G mode. 2005.08.23, by rcnjko. if(pRtBss->bERPInfoValid) { return TRUE; - } + } return FALSE; } @@ -158,7 +158,7 @@ WDIWithWirelessA( //// // This routine determine if we should report the BSS scanned -// to upper layer. +// to upper layer. // 2005.01.13, by rcnjko. // BOOLEAN @@ -169,19 +169,19 @@ WDIFilterRtBss( { PRT_NDIS6_COMMON pNdisCommon = Adapter->pNdisCommon; BOOLEAN bAcceptable = TRUE; - BOOLEAN bHasB, bHasG, bHasA; + BOOLEAN bHasB, bHasG, bHasA; // Determine the capability of wireless mode of the BSS. bHasB = WDIWithWirelessB(pRtBss); bHasG = WDIWithWirelessG(pRtBss); bHasA = WDIWithWirelessA(pRtBss); - - // - // 1. Maybe we may need to use a table in the future. + + // + // 1. Maybe we may need to use a table in the future. // 2. Currently, we only consider B/G case. if( bHasB && !bHasG && !bHasA ) { // The BSS is pure B. - if( pNdisCommon->RegWirelessMode4ScanList == WIRELESS_MODE_G || + if( pNdisCommon->RegWirelessMode4ScanList == WIRELESS_MODE_G || pNdisCommon->RegWirelessMode4ScanList == WIRELESS_MODE_A ) { // We are pure A or pure G. bAcceptable = FALSE; @@ -219,7 +219,7 @@ wdiext_IndicateP2PDeviceFound( // get info of last rx frame if(RTIsListEmpty(&dev->rxFrameQ)) return; - + if(!pAdapter->pPortCommonInfo->WdiData.TaskHandle.pNdisRequest) return; @@ -280,13 +280,13 @@ wdiext_IndicateP2PDeviceFound( // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationBssEntryList( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) return; - wdi_UnsolicitedIndication(pAdapter, + wdi_UnsolicitedIndication(pAdapter, FALSE, (PVOID)req->RequestId, NDIS_STATUS_WDI_INDICATION_BSS_ENTRY_LIST, @@ -302,7 +302,7 @@ wdiext_IndicateP2PDeviceFound( VOID wdiext_IndicateP2PActionFrameReceived( - IN VOID *pvP2PInfo, + IN VOID *pvP2PInfo, IN u4Byte eid, IN MEMORY_BUFFER *info ) @@ -346,22 +346,22 @@ wdiext_IndicateP2PActionFrameReceived( param.FrameInfo.FrameParams.ActionFrameType = WDI_P2P_ACTION_FRAME_INVITATION_RESPONSE; else return; - + cpMacAddr(param.FrameInfo.FrameParams.PeerDeviceAddress.Address, evtData->Packet.Buffer + FRAME_OFFSET_ADDRESS2); param.FrameInfo.FrameParams.DialogToken = *(evtData->Packet.Buffer + FRAME_OFFSET_P2P_PUB_ACT_DIALOG_TOKEN); param.FrameInfo.FrameIEs.ElementCount = evtData->Packet.Length - ieOffset; param.FrameInfo.FrameIEs.pElements = evtData->Packet.Buffer + ieOffset; } - + // gen TLV if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationP2pActionFrameReceived( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) return; - wdi_UnsolicitedIndication(pAdapter, + wdi_UnsolicitedIndication(pAdapter, FALSE, NULL, NDIS_STATUS_WDI_INDICATION_P2P_ACTION_FRAME_RECEIVED, @@ -371,7 +371,7 @@ wdiext_IndicateP2PActionFrameReceived( // cleanup FreeGenerated((UINT8 *)buf); - + FunctionOut(COMP_OID_SET); return; @@ -394,7 +394,7 @@ wdiext_IndicateBSSEntry( WDI_MESSAGE_HEADER *reqWdiHdr = NULL; u4Byte devSpecCtx = 0x07060504; LARGE_INTEGER CurrentTime; - + if(!pAdapter->pPortCommonInfo->WdiData.TaskHandle.pNdisRequest) return; @@ -417,7 +417,7 @@ wdiext_IndicateBSSEntry( RT_TRACE(COMP_MLME, DBG_LOUD, ("Indicate actual scan result of BSS list\n")); MgntActQuery_802_11_BSSID_LIST(pAdapter, &RtBssList, TRUE); #endif - } + } req = pAdapter->pPortCommonInfo->WdiData.TaskHandle.pNdisRequest; reqWdiHdr = (WDI_MESSAGE_HEADER *)req->DATA.METHOD_INFORMATION.InformationBuffer; @@ -468,7 +468,7 @@ wdiext_IndicateBSSEntry( else { FunctionOut(COMP_MLME); - return; + return; } // WDI_SIGNAL_INFO_CONTAINER SignalInfo @@ -487,23 +487,23 @@ wdiext_IndicateBSSEntry( entry.DeviceSpecificContext.pElements = (UINT8 *)&devSpecCtx; NdisGetCurrentSystemTime(&CurrentTime); - + // WDI_AGE_INFO_CONTAINER EntryAgeInfo entry.EntryAgeInfo.HostTimeStamp = CurrentTime.QuadPart;// [SDIO-482] in JIRA entry.EntryAgeInfo.CachedInformation = 0; // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationBssEntryList( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) { FunctionOut(COMP_MLME); return; } - - wdi_UnsolicitedIndication(pAdapter, + + wdi_UnsolicitedIndication(pAdapter, FALSE, (PVOID)req->RequestId, NDIS_STATUS_WDI_INDICATION_BSS_ENTRY_LIST, @@ -516,7 +516,7 @@ wdiext_IndicateBSSEntry( } FunctionOut(COMP_MLME); - + return; } @@ -539,7 +539,7 @@ wdiext_IndicateBSSEntryBySSID( u4Byte devSpecCtx = 0x07060504; BOOL bWildCardSSID = TRUE; LARGE_INTEGER CurrentTime; - + if(!pAdapter->pPortCommonInfo->WdiData.TaskHandle.pNdisRequest) return; @@ -565,7 +565,7 @@ wdiext_IndicateBSSEntryBySSID( RT_TRACE(COMP_MLME, DBG_LOUD, ("Indicate actual scan result of BSS list\n")); MgntActQuery_802_11_BSSID_LIST(pAdapter, &RtBssList, TRUE); #endif - } + } req = pAdapter->pPortCommonInfo->WdiData.TaskHandle.pNdisRequest; reqWdiHdr = (WDI_MESSAGE_HEADER *)req->DATA.METHOD_INFORMATION.InformationBuffer; @@ -626,7 +626,7 @@ wdiext_IndicateBSSEntryBySSID( else { FunctionOut(COMP_MLME); - return; + return; } // WDI_SIGNAL_INFO_CONTAINER SignalInfo @@ -645,23 +645,23 @@ wdiext_IndicateBSSEntryBySSID( entry.DeviceSpecificContext.pElements = (UINT8 *)&devSpecCtx; NdisGetCurrentSystemTime(&CurrentTime); - + // WDI_AGE_INFO_CONTAINER EntryAgeInfo entry.EntryAgeInfo.HostTimeStamp = CurrentTime.QuadPart;// [SDIO-482] in JIRA entry.EntryAgeInfo.CachedInformation = 0; // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationBssEntryList( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) { FunctionOut(COMP_MLME); return; } - - wdi_UnsolicitedIndication(pAdapter, + + wdi_UnsolicitedIndication(pAdapter, FALSE, (PVOID)req->RequestId, NDIS_STATUS_WDI_INDICATION_BSS_ENTRY_LIST, @@ -674,7 +674,7 @@ wdiext_IndicateBSSEntryBySSID( } FunctionOut(COMP_MLME); - + return; } @@ -720,7 +720,7 @@ wdiext_IndicateAssociationResult( else AssocComeBackTime = 0; } - else + else AssocComeBackTime = 0; if(pMgntInfo->dot11CurrentChannelNumber < 36) BandID = WDI_BAND_ID_2400; @@ -736,7 +736,7 @@ wdiext_IndicateAssociationResult( case WIRELESS_MODE_A: PhyType = WDI_PHY_TYPE_OFDM; break; - + case WIRELESS_MODE_G: PhyType = WDI_PHY_TYPE_ERP; break; @@ -757,7 +757,7 @@ wdiext_IndicateAssociationResult( PhyType = WDI_PHY_TYPE_VHT; break; - + } PlatformZeroMemory(&AsocResult, sizeof(WDI_ASSOCIATION_RESULT_CONTAINER)); @@ -787,12 +787,14 @@ wdiext_IndicateAssociationResult( AsocResult.Optional.BeaconProbeResponse_IsPresent = TRUE; AsocResult.BeaconProbeResponse.ElementCount = MMPDU_BODY_LEN(pMgntInfo->AsocInfo.BeaconLength); AsocResult.BeaconProbeResponse.pElements = MMPDU_BODY(pMgntInfo->AsocInfo.Beacon); +#if 0 AsocResult.Optional.ActivePhyTypeList_IsPresent = TRUE; +#endif AsocResult.ActivePhyTypeList.ElementCount = 1; AsocResult.ActivePhyTypeList.pElements = &PhyType; ndisStatus = GenerateWdiIndicationAssociationResult( - &AsocResultList, + &AsocResultList, sizeof(NDIS_STATUS_INDICATION)+sizeof(WDI_MESSAGE_HEADER), &pAdapter->pPortCommonInfo->WdiData.TlvContext, &length, @@ -802,10 +804,10 @@ wdiext_IndicateAssociationResult( RT_TRACE(COMP_MLME, DBG_LOUD, ("GenerateWdiIndicationAssociationResult(): return length %d\n", length)); RT_PRINT_DATA(COMP_MLME, DBG_TRACE, ("buffer\n"), pOutput, length); RT_TRACE(COMP_MLME, DBG_LOUD, ("SendUnsolictedIndication(): EthertypeEncapTable_IsPresent %d\n", AsocResult.Optional.EthertypeEncapTable_IsPresent)); - + ndisStatus = WDI_AddDatapathPeer(pAdapter, AsocResult.BSSID.Address); - - wdi_UnsolicitedIndication(pAdapter, + + wdi_UnsolicitedIndication(pAdapter, FALSE, (PVOID)pAdapter->pPortCommonInfo->WdiData.TaskHandle.pNdisRequest->RequestId, NDIS_STATUS_WDI_INDICATION_ASSOCIATION_RESULT, @@ -833,7 +835,7 @@ wdiext_IndicateAssociationResult( // RT_STATUS wdiext_IndicateFtAssocNeeded( - IN PADAPTER pAdapter + IN PADAPTER pAdapter ) { RT_STATUS rtStatus = RT_STATUS_SUCCESS; @@ -851,18 +853,18 @@ wdiext_IndicateFtAssocNeeded( { RT_TRACE_F(COMP_INDIC, DBG_WARNING, ("Too short of AuthSeq2Length = %d\n", pMgntInfo->AsocInfo.AuthSeq1Length)); rtStatus = RT_STATUS_INVALID_DATA; - break; + break; } if(pMgntInfo->AsocInfo.AuthSeq2Length < sMacHdrLng) { RT_TRACE_F(COMP_INDIC, DBG_WARNING, ("Too short of AuthSeq2Length = %d\n", pMgntInfo->AsocInfo.AuthSeq2Length)); rtStatus = RT_STATUS_INVALID_DATA; - break; + break; } cpMacAddr(param.BssId.Address, pMgntInfo->Bssid); - + param.AuthRequest.ElementCount = MMPDU_BODY_LEN(pMgntInfo->AsocInfo.AuthSeq1Length); param.AuthRequest.pElements = MMPDU_BODY(pMgntInfo->AsocInfo.AuthSeq1); @@ -870,21 +872,21 @@ wdiext_IndicateFtAssocNeeded( param.AuthResponse.pElements = MMPDU_BODY(pMgntInfo->AsocInfo.AuthSeq2); // Gen tlv - if(NDIS_STATUS_SUCCESS != (ndisStatus = + if(NDIS_STATUS_SUCCESS != (ndisStatus = GenerateWdiIndicationFtAssocParamsNeeded( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &indicBufLen, &((UINT8 *)pIndicBuf)))) { RT_TRACE_F(COMP_INDIC, DBG_SERIOUS, ("Fail (ndisStatus = 0x%08X) from GenerateWdiIndicationFtAssocParamsNeeded()\n", ndisStatus)); rtStatus = RT_STATUS_OS_API_FAILED; - break; + break; } RT_PRINT_DATA(COMP_INDIC, DBG_LOUD, "NDIS_STATUS_WDI_INDICATION_FT_ASSOC_PARAMS_NEEDED:\n", pIndicBuf, indicBufLen); - wdi_UnsolicitedIndication(pAdapter, + wdi_UnsolicitedIndication(pAdapter, FALSE, NULL, NDIS_STATUS_WDI_INDICATION_FT_ASSOC_PARAMS_NEEDED, @@ -930,8 +932,8 @@ wdiext_IndicateDisassociation( param.Optional.NeedPeerStateCleanup_IsPresent = FALSE; cpMacAddr(param.DisconnectIndicationParameters.MacAddress.Address, addr); - param.DisconnectIndicationParameters.DisassociationWABIReason = bDisassoc - ? WDI_ASSOC_STATUS_PEER_DISASSOCIATED + param.DisconnectIndicationParameters.DisassociationWABIReason = bDisassoc + ? WDI_ASSOC_STATUS_PEER_DISASSOCIATED : WDI_ASSOC_STATUS_PEER_DEAUTHENTICATED; if(frameLen) @@ -947,23 +949,23 @@ wdiext_IndicateDisassociation( param.DeauthFrame.pElements = frame + sMacHdrLng; } } - + // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationDisassociation( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) return; - wdi_UnsolicitedIndication(pAdapter, + wdi_UnsolicitedIndication(pAdapter, FALSE, NULL, NDIS_STATUS_WDI_INDICATION_DISASSOCIATION, NDIS_STATUS_SUCCESS, buf, buflen); - + // cleanup FreeGenerated((UINT8 *)buf); @@ -987,24 +989,24 @@ wdiext_IndicateRadioStatus( Params.RadioState.HardwareState = (pMgntInfo->RfOffReason&RF_CHANGE_BY_HW)?0:1; RT_TRACE(COMP_RF, DBG_LOUD, ("wdiext_IndicateRadioStatus(): Params.RadioState.SoftwareState is %d, Params.RadioState.HardwareState is %d\n", Params.RadioState.SoftwareState, Params.RadioState.HardwareState)); - + ndisStatus = GenerateWdiIndicationRadioStatus( &Params, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), &pAdapter->pPortCommonInfo->WdiData.TlvContext, &length, &pOutput); if(NDIS_STATUS_SUCCESS == ndisStatus) { - wdi_UnsolicitedIndication(pAdapter, + wdi_UnsolicitedIndication(pAdapter, TRUE, NULL, NDIS_STATUS_WDI_INDICATION_RADIO_STATUS, NDIS_STATUS_SUCCESS, pOutput, length); - + FreeGenerated(pOutput); pOutput = NULL; } @@ -1023,7 +1025,7 @@ wdiext_IndicateLinkStateChanged( PUCHAR pOutput = NULL; ULONG length = 0; NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; - + if (pMgntInfo->mAssoc || pMgntInfo->mIbss) { Params.LinkStateChangeParameters.LinkQuality = GetSignalQuality(pAdapter); @@ -1044,7 +1046,7 @@ wdiext_IndicateLinkStateChanged( RT_TRACE(COMP_MLME, DBG_LOUD, ("wdiext_IndicateLinkStateChanged(): Params.LinkStateChangeParameters.TxLinkSpeed is %d\n", Params.LinkStateChangeParameters.TxLinkSpeed)); RT_TRACE(COMP_MLME, DBG_LOUD, ("wdiext_IndicateLinkStateChanged(): Params.LinkStateChangeParameters.RxLinkSpeed is %d\n", Params.LinkStateChangeParameters.RxLinkSpeed)); - + ndisStatus = GenerateWdiIndicationLinkStateChange( &Params, sizeof(NDIS_STATUS_INDICATION)+sizeof(WDI_MESSAGE_HEADER), @@ -1080,7 +1082,7 @@ wdiext_IndicateRoamingNeeded( NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; pMgntInfo->bPrepareRoaming = TRUE; - + Params.RoamingReason = IndicationReason; RT_TRACE_F(COMP_MLME, DBG_LOUD, ("Params.RoamingReason %d\n", Params.RoamingReason)); @@ -1143,20 +1145,20 @@ wdiext_IndicateP2POpChnl( // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationP2pGroupOperatingChannel( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) return; - wdi_UnsolicitedIndication(pAdapter, + wdi_UnsolicitedIndication(pAdapter, FALSE, (PVOID)req->RequestId, NDIS_STATUS_WDI_INDICATION_P2P_GROUP_OPERATING_CHANNEL, NDIS_STATUS_SUCCESS, buf, buflen); - + // cleanup FreeGenerated((UINT8 *)buf); @@ -1173,7 +1175,7 @@ wdi_FindGroupPeerByPort( PADAPTER pDefaultAdapter = GetDefaultAdapter(pAdapter); PRT_PEER_ENTRY pPeerEntry = NULL; u1Byte i; - + for(i = 0; i < MP_DEFAULT_NUMBER_OF_PORT; i++) { pPeerEntry = &pDefaultAdapter->RxPeerTable[i]; @@ -1185,7 +1187,7 @@ wdi_FindGroupPeerByPort( } } } - + return NULL; } @@ -1198,24 +1200,24 @@ wdi_FindPeerByAddr( PADAPTER pDefaultAdapter = GetDefaultAdapter(pAdapter); PRT_PEER_ENTRY pPeerEntry = NULL; u1Byte i = 0, count = 0; - + count = pDefaultAdapter->RxPeerUsedCount; for(i = MP_DEFAULT_NUMBER_OF_PORT; i < MAX_PEER_NUM; i++) { if( count == 0 ) break; - + pPeerEntry = &pDefaultAdapter->RxPeerTable[i]; if( pPeerEntry->bUsed == TRUE ) { - count--; + count--; if( PlatformCompareMemory(pPeerEntry->PeerAddr, pAddr, 6) == 0 ) { return (PVOID)pPeerEntry; } } } - + return NULL; } @@ -1230,18 +1232,18 @@ wdi_GetAvailablePeer( PRT_PEER_ENTRY pCurPeerEntry = NULL, pPeerEntry = NULL; u1Byte i = 0, UnusedIndex = 0, count = 0; BOOLEAN bFound = FALSE; - + FunctionIn(COMP_MLME); - + count = pDefaultAdapter->RxPeerUsedCount; - + for(i = MP_DEFAULT_NUMBER_OF_PORT; i < MAX_PEER_NUM; i++) { if( (count == 0) && (bFound == TRUE) ) break; - + pPeerEntry = &pDefaultAdapter->RxPeerTable[i]; - + if( (pPeerEntry->bUsed == FALSE) && (bFound == FALSE) ) { bFound = TRUE; @@ -1252,32 +1254,32 @@ wdi_GetAvailablePeer( count--; if( PlatformCompareMemory(pPeerEntry->PeerAddr, pAddr, 6) == 0 ) { - RT_TRACE(COMP_MLME, DBG_WARNING, ("wdi_GetAvailablePeer: The addres [%2x:%2x:%2x:%2x:%2x:%2x] had associated with specified Peer %d\n", pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], pPeerEntry->uPeerId)); + RT_TRACE(COMP_MLME, DBG_WARNING, ("wdi_GetAvailablePeer: The addres [%2x:%2x:%2x:%2x:%2x:%2x] had associated with specified Peer %d\n", pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], pPeerEntry->uPeerId)); FunctionOut(COMP_MLME); return (PVOID)pPeerEntry; } } } - + if( (i == MAX_PEER_NUM) && (bFound == FALSE) ) { - RT_TRACE(COMP_MLME, DBG_WARNING, ("wdi_GetAvailablePeer: Peer is already full, so cannot find an unused peer to associate [%2x:%2x:%2x:%2x:%2x:%2x]\n", pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5])); + RT_TRACE(COMP_MLME, DBG_WARNING, ("wdi_GetAvailablePeer: Peer is already full, so cannot find an unused peer to associate [%2x:%2x:%2x:%2x:%2x:%2x]\n", pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5])); FunctionOut(COMP_MLME); return NULL; } - + pDefaultAdapter->RxPeerUsedCount++; - + pCurPeerEntry = &pDefaultAdapter->RxPeerTable[UnusedIndex]; pCurPeerEntry->bUsed = TRUE; pCurPeerEntry->uPeerId = UnusedIndex; pCurPeerEntry->uPortId = (u2Byte)PortId; PlatformMoveMemory(pCurPeerEntry->PeerAddr, pAddr, 6); - RT_TRACE(COMP_MLME, DBG_LOUD, ("wdi_GetAvailablePeer: Port %d associate the addres [%2x:%2x:%2x:%2x:%2x:%2x] at Peer %d\n", (u2Byte)PortId, pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], UnusedIndex)); - + RT_TRACE(COMP_MLME, DBG_LOUD, ("wdi_GetAvailablePeer: Port %d associate the addres [%2x:%2x:%2x:%2x:%2x:%2x] at Peer %d\n", (u2Byte)PortId, pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], UnusedIndex)); + FunctionOut(COMP_MLME); - + return (PVOID)pCurPeerEntry; } @@ -1299,17 +1301,17 @@ wdi_NotifyPeerData( WDI_EXTENDED_TID ExtendTid = (WDI_EXTENDED_TID)ExTid; KIRQL Irql = 0; BOOLEAN bLackResource = FALSE; - + PlatformAcquireSpinLock(pAdapter, RT_RX_CONTROL_SPINLOCK); if( (pNdisCommon->bRxControlState != RT_RX_STOP) && (pDefaultNdisCommon->bRxDataPathState != RT_RX_PAUSE) ) - { + { pNdisCommon->bRxControlState = RT_RX_NOTIFYING; PlatformReleaseSpinLock(pAdapter, RT_RX_CONTROL_SPINLOCK); - + PlatformAcquireSpinLock(pAdapter, RT_RX_SPINLOCK); bLackResource = RxCheckResource(pAdapter)?FALSE:TRUE; PlatformReleaseSpinLock(pAdapter, RT_RX_SPINLOCK); - + if( bLackResource ) RT_TRACE(COMP_RECV, DBG_WARNING, ("wdi_NotifyPeerData(): RFD is less than lower bound (%d)\n", RFD_LOWER_BOUND)); @@ -1349,7 +1351,7 @@ wdi_NotifyPeerData( } pTempAdapter = GetNextExtAdapter(pTempAdapter); }while(pTempAdapter != NULL ); - + PlatformReleaseSpinLock(pAdapter, RT_RX_CONTROL_SPINLOCK); RT_TRACE(COMP_INIT, DBG_WARNING, ("Driver call RxStopConfirm for Rx manager\n")); pWdi->WdiDataApi.RxStopConfirm(pWdi->DataPathHandle); @@ -1395,23 +1397,23 @@ WDI_Initialize( // WorkAround for 0x9F BSOD pMChars->ResetHandlerEx = N6SdioReset; - + RtlZeroMemory(&WdiChar, sizeof(WdiChar)); WdiChar.WdiVersion = WDI_VERSION_LATEST; WdiChar.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_WDI_CHARACTERISTICS, WdiChar.Header.Size = NDIS_SIZEOF_MINIPORT_WDI_CHARACTERISTICS_REVISION_1; - WdiChar.Header.Revision = NDIS_MINIPORT_DRIVER_WDI_CHARACTERISTICS_REVISION_1; + WdiChar.Header.Revision = NDIS_MINIPORT_DRIVER_WDI_CHARACTERISTICS_REVISION_1; WdiChar.AllocateAdapterHandler = N6SdioWdi_AllocateAdapter; WdiChar.FreeAdapterHandler = N6SdioWdi_FreeAdapter; - WdiChar.OpenAdapterHandler = N6SdioWdi_OpenAdapter; - WdiChar.CloseAdapterHandler = N6SdioWdi_CloseAdapter; + WdiChar.OpenAdapterHandler = N6SdioWdi_OpenAdapter; + WdiChar.CloseAdapterHandler = N6SdioWdi_CloseAdapter; WdiChar.TalTxRxInitializeHandler = N6SdioWdi_TalTxRxInitialize; WdiChar.TalTxRxDeinitializeHandler = N6SdioWdi_TalTxRxDeinitialize; - WdiChar.HangDiagnoseHandler = N6SdioWdi_HangDiagnose; + WdiChar.HangDiagnoseHandler = N6SdioWdi_HangDiagnose; // Optional handler WdiChar.StartOperationHandler = N6SdioWdi_StartOperation; @@ -1432,7 +1434,7 @@ WDI_Initialize( VOID -WDI_DeInitialize( +WDI_DeInitialize( IN NDIS_HANDLE DriverHandle ) { @@ -1440,7 +1442,7 @@ WDI_DeInitialize( } VOID -WDI_InitRxQueue( +WDI_InitRxQueue( IN PADAPTER pAdapter ) { @@ -1463,14 +1465,14 @@ WDI_InitRxQueue( } VOID -WDI_DeInitRxQueue( +WDI_DeInitRxQueue( IN PADAPTER pAdapter ) { PADAPTER pDefaultAdapter = GetDefaultAdapter(pAdapter); u2Byte index = 0; PNET_BUFFER_LIST pNetBufferList=NULL; - + RT_TRACE(COMP_INIT, DBG_LOUD, ("[WDI], WDI_DeInitRxQueue() ==> \n")); PlatformAcquireSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); for(index=0; indexpPortCommonInfo->WdiData); - + if( pWdi->TaskHandle.Status & RT_OID_HANDLER_STATUS_SET ) { OidHandle_Complete(pAdapter, OIDHANDLE_TYPE_TASK); @@ -1541,11 +1543,11 @@ WdiExt_IndicateApAssocReqReceived( PlatformZeroMemory(¶m, sizeof(param)); - cpMacAddr(param.IncomingRequestInfo.AssocRequestParams.PeerMacAddress.Address, + cpMacAddr(param.IncomingRequestInfo.AssocRequestParams.PeerMacAddress.Address, assocReq + FRAME_OFFSET_ADDRESS2 ); - param.IncomingRequestInfo.AssocRequestParams.IsReassociationRequest = + param.IncomingRequestInfo.AssocRequestParams.IsReassociationRequest = (Type_Reasoc_Req == GET_80211_HDR_TYPE(assocReq)) ? TRUE : FALSE; FillOctetString(osAssocReq, assocReq, (u2Byte)assocReqLen); @@ -1561,20 +1563,20 @@ WdiExt_IndicateApAssocReqReceived( // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationApAssociationRequestReceived( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) return; - wdi_UnsolicitedIndication(pAdapter, + wdi_UnsolicitedIndication(pAdapter, FALSE, NULL, NDIS_STATUS_WDI_INDICATION_AP_ASSOCIATION_REQUEST_RECEIVED, NDIS_STATUS_SUCCESS, buf, buflen); - + // cleanup FreeGenerated((UINT8 *)buf); @@ -1593,16 +1595,16 @@ WdiExt_IndicateApAssocRspSent( if(FALSE == OidHandle_VerifyTask(pAdapter, OID_WDI_TASK_SEND_AP_ASSOCIATION_RESPONSE)) { - RT_TRACE(COMP_OID_SET, DBG_WARNING, + RT_TRACE(COMP_OID_SET, DBG_WARNING, ("WdiExt_IndicateApAssocRspSent(): skip indication because OidHandle_VerifyTask() returns FALSE\n")); return; } - + if(task->pvCtx) { if(WDI_CMD_SendApAssociationResponseComplete( - pAdapter, - (NDIS_OID_REQUEST *)task->pvCtx, + pAdapter, + (NDIS_OID_REQUEST *)task->pvCtx, StatusCode_success == status ? RT_STATUS_SUCCESS : RT_STATUS_FAILURE)) {// set pvCtx to NULL only when it is freed in WDI_CMD_SendApAssociationResponseComplete task->pvCtx = NULL; @@ -1621,18 +1623,18 @@ WDIAllocateMetaData( { PWDI_DATA_STRUCT pWdi = &(pAdapter->pPortCommonInfo->WdiData); PWDI_FRAME_METADATA pWdiFrameMeta = NULL; - + pWdiFrameMeta = pWdi->WdiDataApi.AllocateWiFiFrameMetaData(pWdi->DataPathHandle); if( pWdiFrameMeta == NULL ) return RT_STATUS_FAILURE; pWdiFrameMeta->u.rxMetaData.PayloadType = WDI_FRAME_MSDU; pWdiFrameMeta->pNBL = pNBL; - + RT_TRACE(COMP_RECV, DBG_TRACE, ("PayloadType %d\n", pWdiFrameMeta->u.rxMetaData.PayloadType)); MP_SET_PACKET_RFD_RESERVED_0(pNBL, pWdiFrameMeta); - + return RT_STATUS_SUCCESS; } @@ -1673,7 +1675,7 @@ WDI_InsertDataInQueue( FillOctetString(osMpdu, pRfd->Buffer.VirtualAddress + pRfd->FragOffset, pRfd->FragLength); PlatformAcquireSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + /**************************************************************************************************** * 20150707 Sinda * We insert frames in queue as below rules @@ -1694,12 +1696,12 @@ WDI_InsertDataInQueue( else PeerId = pPeerEntry->uPeerId; } - + if(pPeerEntry->bUsed == TRUE) { RT_TRACE(COMP_RECV, DBG_TRACE, ("WDI_InsertDataInQueue: Port %d, PeerId %d\n", PortNumber, PeerId)); for (pCurrNetBufferList = pNBL; pCurrNetBufferList != NULL; pCurrNetBufferList = pNextNetBufferList) - { + { pNextNetBufferList = NET_BUFFER_LIST_NEXT_NBL(pCurrNetBufferList); NET_BUFFER_LIST_NEXT_NBL(pCurrNetBufferList) = NULL; N6CAddNblWaitQueue(&pDefaultAdapter->RxPeerQueue[PeerId], pCurrNetBufferList, FALSE); @@ -1808,7 +1810,7 @@ WDI_IndicateBssListBySSID( } VOID -WDI_IndicateConnectionComplete( +WDI_IndicateConnectionComplete( PADAPTER pAdapter, RT_STATUS status ) @@ -1817,7 +1819,7 @@ WDI_IndicateConnectionComplete( if(FALSE == OidHandle_VerifyTask(pAdapter, OID_WDI_TASK_CONNECT)) return; - + OidHandle_Complete(pAdapter, OIDHANDLE_TYPE_TASK); } @@ -1827,7 +1829,7 @@ WDI_IndicateAssociationComplete( PADAPTER pAdapter, RT_STATUS status ) -{ +{ if( status == RT_STATUS_SUCCESS ) { wdiext_IndicateAssociationResult(pAdapter); @@ -1837,17 +1839,17 @@ WDI_IndicateAssociationComplete( VOID -WDI_IndicateDisassociation( +WDI_IndicateDisassociation( PADAPTER pAdapter, u2Byte reason, pu1Byte pAddr ) { PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); - + if(ACTING_AS_AP(pAdapter)) {// AP mode - RT_WLAN_STA *sta = pMgntInfo->pCurrentSta; + RT_WLAN_STA *sta = pMgntInfo->pCurrentSta; RT_ASSERT(sta, ("%s(): sta is NULL!!!\n", __FUNCTION__)); @@ -1856,7 +1858,7 @@ WDI_IndicateDisassociation( RT_TRACE_F(COMP_AP, DBG_SERIOUS, ("pMgntInfo->pCurrentSta is NULL!\n")); return; } - + wdiext_IndicateDisassociation(pAdapter, sta->MacAddr, 0, NULL, TRUE, reason); } else @@ -1876,17 +1878,17 @@ WDI_IndicateNLODiscovery( ) { WDI_INDICATION_NLO_DISCOVERY_PARAMETERS param; - PWDI_BSS_ENTRY_CONTAINER pEntry; + PWDI_BSS_ENTRY_CONTAINER pEntry; PRT_NLO_INFO pNLOInfo = &(pAdapter->MgntInfo.NLOInfo); PRT_WLAN_BSS pRtBss = NULL; - RT_802_11_BSSID_LIST RtBssList = {0}; + RT_802_11_BSSID_LIST RtBssList = {0}; u4Byte i = 0; u4Byte j = 0; - u4Byte nBss = 0; + u4Byte nBss = 0; ULONG buflen = 0; - pu1Byte buf = NULL; - pu1Byte pBssList = NULL; + pu1Byte buf = NULL; + pu1Byte pBssList = NULL; u4Byte devSpecCtx = 0x07060504; BOOLEAN Hit = FALSE; LARGE_INTEGER CurrentTime; @@ -1898,15 +1900,15 @@ WDI_IndicateNLODiscovery( // zero PlatformZeroMemory(¶m, sizeof(param)); - + //Get scan list RtBssList.NumberOfItems = 0; RtBssList.pbssidentry = pAdapter->bssDescList; - + MgntActQuery_802_11_BSSID_LIST(pAdapter, &RtBssList, FALSE); - PlatformAllocateMemoryWithZero(pAdapter, (PVOID *)&pEntry, sizeof(WDI_BSS_ENTRY_CONTAINER)*RtBssList.NumberOfItems); - + PlatformAllocateMemoryWithZero(pAdapter, (PVOID *)&pEntry, sizeof(WDI_BSS_ENTRY_CONTAINER)*RtBssList.NumberOfItems); + param.DeviceDescriptor.pElements = pEntry; nBss = 0; @@ -1922,14 +1924,14 @@ WDI_IndicateNLODiscovery( } pRtBss = &(RtBssList.pbssidentry[i]); - + // Determine if we shall report the BSS found by RegWirelessMode4ScanList. if(!WDIFilterRtBss(pAdapter, pRtBss)) { // Skip this BSS. continue; } - + for( j=0 ; jNumDot11OffloadNetwork ; ++j ) { // Compare to check whether it is what we desired or not @@ -1942,7 +1944,7 @@ WDI_IndicateNLODiscovery( if( !Hit ) // This BSS is not we desired. continue; - + // WIFI_MAC_ADDRESS_CONTAINER BSSID cpMacAddr(pEntry->BSSID.Address, pRtBss->bdBssIdBuf); @@ -1963,7 +1965,7 @@ WDI_IndicateNLODiscovery( { RT_TRACE(COMP_POWER, DBG_LOUD, ("Unknown BssPacketType: %u\n", pRtBss->BssPacketType)); FunctionOut(COMP_POWER); - return; + return; } // WDI_SIGNAL_INFO_CONTAINER SignalInfo @@ -1975,9 +1977,9 @@ WDI_IndicateNLODiscovery( pEntry->ChannelInfo.ChannelNumber = (UINT32)pRtBss->ChannelNumber; pEntry->ChannelInfo.BandId = (pRtBss->ChannelNumber < 36) ? WDI_BAND_ID_2400 : WDI_BAND_ID_5000; RT_TRACE(COMP_POWER, DBG_LOUD, ("pRtBss->ChannelNumber=%d, ", pRtBss->ChannelNumber)); - RT_TRACE(COMP_POWER, DBG_LOUD, ("%x:%x:%x:%x:%x:%x, ", - pEntry->BSSID.Address[0], pEntry->BSSID.Address[1], - pEntry->BSSID.Address[2], pEntry->BSSID.Address[3], + RT_TRACE(COMP_POWER, DBG_LOUD, ("%x:%x:%x:%x:%x:%x, ", + pEntry->BSSID.Address[0], pEntry->BSSID.Address[1], + pEntry->BSSID.Address[2], pEntry->BSSID.Address[3], pEntry->BSSID.Address[4], pEntry->BSSID.Address[5])); RT_TRACE(COMP_POWER, DBG_LOUD, ("SSID: %s\n", pRtBss->bdSsIdBuf)); @@ -1988,7 +1990,7 @@ WDI_IndicateNLODiscovery( // Get current timestamp NdisGetCurrentSystemTime(&CurrentTime); - + // WDI_AGE_INFO_CONTAINER EntryAgeInfo pEntry->EntryAgeInfo.HostTimeStamp = CurrentTime.QuadPart; // [SDIO-482] in JIRA pEntry->EntryAgeInfo.CachedInformation = 0; @@ -2007,17 +2009,17 @@ WDI_IndicateNLODiscovery( // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationNloDiscovery( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) { RT_TRACE(COMP_POWER, DBG_LOUD, ("WDI_IndicateNLODiscovery(): GenerateWdiIndicationNloDiscovery Failed\n")); FunctionOut(COMP_POWER); return; } - - wdi_UnsolicitedIndication( pAdapter, + + wdi_UnsolicitedIndication( pAdapter, FALSE, NULL, NDIS_STATUS_WDI_INDICATION_NLO_DISCOVERY, @@ -2026,8 +2028,8 @@ WDI_IndicateNLODiscovery( buflen); // cleanup - FreeGenerated((UINT8 *)buf); - + FreeGenerated((UINT8 *)buf); + FunctionOut(COMP_POWER); } @@ -2042,7 +2044,7 @@ WDI_IndicateCurrentPhyStatus( VOID -WDI_IndicateP2PEvent( +WDI_IndicateP2PEvent( VOID *pvP2PInfo, u4Byte EventID, MEMORY_BUFFER *pInformation @@ -2051,7 +2053,7 @@ WDI_IndicateP2PEvent( { P2P_INFO *pP2PInfo = (P2P_INFO *)pvP2PInfo; RT_OID_HANDLER *task = &pP2PInfo->pAdapter->pPortCommonInfo->WdiData.TaskHandle; - + if(P2P_EVENT_DEV_FOUND == EventID) { wdiext_IndicateP2PDeviceFound(pP2PInfo->pAdapter, pInformation->Buffer); @@ -2060,8 +2062,8 @@ WDI_IndicateP2PEvent( || P2P_EVENT_RECEIVED_GO_NEGOTIATION_REQUEST == EventID || P2P_EVENT_RECEIVED_INVITATION_REQUEST == EventID ) - {// rx req action - WDI_CMD_PreIndicateRxP2pActionFrameCb(pvP2PInfo, EventID, pInformation); + {// rx req action + WDI_CMD_PreIndicateRxP2pActionFrameCb(pvP2PInfo, EventID, pInformation); wdiext_IndicateP2PActionFrameReceived(pvP2PInfo, EventID, pInformation); WDI_CMD_PostIndicateRxP2pActionFrameCb(pvP2PInfo, EventID, pInformation); } @@ -2072,10 +2074,10 @@ WDI_IndicateP2PEvent( ) {// rx rsp action WDI_CMD_PreIndicateRxP2pActionFrameCb(pvP2PInfo, EventID, pInformation); - + // indicate in the corresp. OffChnlTx complete cb //wdiext_IndicateP2PActionFrameReceived(pvP2PInfo, EventID, pInformation); - + WDI_CMD_PostIndicateRxP2pActionFrameCb(pvP2PInfo, EventID, pInformation); } else if(P2P_EVENT_GO_OPERATING_CHANNEL == EventID) @@ -2083,7 +2085,7 @@ WDI_IndicateP2PEvent( wdiext_IndicateP2POpChnl(pP2PInfo->pAdapter, pP2PInfo); } - return; + return; } @@ -2105,7 +2107,7 @@ WDI_CompleteCreateDeleteMac( } VOID -WDI_IndicateLinkStateChanged( +WDI_IndicateLinkStateChanged( PADAPTER pAdapter, BOOLEAN bForceLinkQuality, u1Byte ucLinkQuality @@ -2122,14 +2124,14 @@ WDI_IndicateActionFrame( { NDIS_STATUS_INDICATION *indic = NULL; WDI_MESSAGE_HEADER *wdiHdr = NULL; - + u1Byte *buf = NULL; ULONG buflen = 0; WDI_INDICATION_ACTION_FRAME_RECEIVED_PARAMETERS param = {0}; RT_TRACE(COMP_OID_SET, DBG_WARNING, ("WDI_IndicateActionFrame +\n")); - + // TODO: fill the valid info into param PlatformMoveMemory(param.SourceAddress.Address,Frame_pSaddr(*posMpdu),6); @@ -2137,13 +2139,13 @@ WDI_IndicateActionFrame( param.ActionFrameBody.ElementCount = posMpdu->Length; // TODO: double check here to make sure channel correct - param.ChannelInfo.ChannelNumber = RT_GetChannelNumber(pAdapter); + param.ChannelInfo.ChannelNumber = RT_GetChannelNumber(pAdapter); param.ChannelInfo.BandId = WDI_BAND_ID_2400; if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationActionFrameReceived( - ¶m, - sizeof(*indic) + sizeof(*wdiHdr), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(*indic) + sizeof(*wdiHdr), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) { RT_TRACE(COMP_OID_SET, DBG_WARNING, ("ActionFrame generate tlv failed\n")); @@ -2173,7 +2175,7 @@ WDI_IndicateActionFrame( NdisMIndicateStatusEx(pAdapter->pNdisCommon->hNdisAdapter, indic); FreeGenerated((UINT8 *)buf); - + return RT_STATUS_SUCCESS; } @@ -2184,12 +2186,12 @@ WDI_IndicateWakeReason( IN pu1Byte pBuffer, IN u2Byte BufferLen ) -{ +{ WDI_INDICATION_WAKE_REASON_PARAMETERS param; PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); PRT_POWER_SAVE_CONTROL pPSC = GET_POWER_SAVE_CONTROL(pMgntInfo); - pu1Byte pWakePktbuf = NULL; + pu1Byte pWakePktbuf = NULL; BOOLEAN bIndicate = TRUE; u1Byte *buf = NULL; ULONG buflen = 0; @@ -2207,7 +2209,7 @@ WDI_IndicateWakeReason( RT_TRACE(COMP_POWER, DBG_SERIOUS, ("WDI_IndicateWakeReason(): Unknown pPSC->WakeUpReason(%#x)\n", pPSC->WakeUpReason)); } - param.WakeEventCode = WDI_WAKE_REASON_CODE_PACKET; + param.WakeEventCode = WDI_WAKE_REASON_CODE_PACKET; param.WakePacketPatternId = pPSC->MagicPacketPatternId; PlatformAllocateMemoryWithZero(pAdapter, (PVOID *)&pWakePktbuf, BufferLen); @@ -2241,47 +2243,47 @@ WDI_IndicateWakeReason( bIndicate = FALSE; } } - + if(bIndicate) { RT_TRACE(COMP_POWER, DBG_LOUD, ("WDI_IndicateWakeReason(): WakeEventCode(%#X)\n", param.WakeEventCode)); // Gen tlv if(NDIS_STATUS_SUCCESS != GenerateWdiIndicationWakeReasonFromIhv( - ¶m, - sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), - &pAdapter->pPortCommonInfo->WdiData.TlvContext, + ¶m, + sizeof(NDIS_STATUS_INDICATION) + sizeof(WDI_MESSAGE_HEADER), + &pAdapter->pPortCommonInfo->WdiData.TlvContext, &buflen, &((UINT8 *)buf))) { RT_TRACE(COMP_POWER, DBG_LOUD, ("WDI_IndicateWakeReason(): GenerateWdiIndicationWakeReasonFromIhv Failed\n")); return; } - - wdi_UnsolicitedIndication(pAdapter, + + wdi_UnsolicitedIndication(pAdapter, FALSE, NULL, NDIS_STATUS_WDI_INDICATION_WAKE_REASON, NDIS_STATUS_SUCCESS, buf, buflen); - + // cleanup FreeGenerated((UINT8 *)buf); - } - + } + } VOID -WDI_IndicateRoamingNeeded( +WDI_IndicateRoamingNeeded( PADAPTER pAdapter, RT_PREPARE_ROAM_TYPE IndicationReason ) { PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); - + pMgntInfo->PrepareRoamState = IndicationReason; - + switch(IndicationReason) { case RT_PREPARE_ROAM_DEAUTH_DISASSOC: @@ -2299,7 +2301,7 @@ WDI_IndicateRoamingNeeded( } VOID -WDI_IndicateRoamingComplete( +WDI_IndicateRoamingComplete( PADAPTER pAdapter ) { @@ -2307,11 +2309,11 @@ WDI_IndicateRoamingComplete( if(FALSE == OidHandle_VerifyTask(pAdapter, OID_WDI_TASK_ROAM)) return; - + OidHandle_Complete(pAdapter, OIDHANDLE_TYPE_TASK); } -VOID +VOID WDI_AddGroupPeer( IN PADAPTER pAdapter, IN u2Byte PortNumber @@ -2319,44 +2321,44 @@ WDI_AddGroupPeer( { PADAPTER pDefaultAdapter = GetDefaultAdapter(pAdapter); PWDI_DATA_STRUCT pWdi = &(pAdapter->pPortCommonInfo->WdiData); - WDI_MAC_ADDRESS PeerAddr = {0}; + WDI_MAC_ADDRESS PeerAddr = {0}; PRT_PEER_ENTRY pPeerEntry = NULL; u1Byte i = 0; - + FunctionIn(COMP_INIT); - + PlatformAcquireSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); for(i = 0; i < MP_DEFAULT_NUMBER_OF_PORT; i++) { pPeerEntry = &pDefaultAdapter->RxPeerTable[i]; if( pPeerEntry->bUsed == FALSE ) { - RT_TRACE(COMP_INIT, DBG_LOUD, ("WDI_AddGroupPeer: create group peer %d for port %d\n", i, PortNumber)); + RT_TRACE(COMP_INIT, DBG_LOUD, ("WDI_AddGroupPeer: create group peer %d for port %d\n", i, PortNumber)); break; } } - + if( i == MP_DEFAULT_NUMBER_OF_PORT ) { - RT_TRACE(COMP_INIT, DBG_WARNING, ("WDI_AddGroupPeer: there is no available group peer for port %d\n", PortNumber)); + RT_TRACE(COMP_INIT, DBG_WARNING, ("WDI_AddGroupPeer: there is no available group peer for port %d\n", PortNumber)); FunctionOut(COMP_INIT); PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); return ; } - + pPeerEntry->bUsed = TRUE; pPeerEntry->uPeerId = i; pPeerEntry->uPortId = PortNumber; PlatformMoveMemory(pPeerEntry->PeerAddr, MAC_BROADCAST_ADDR, 6); PlatformMoveMemory(PeerAddr.Address, pPeerEntry->PeerAddr, 6); pWdi->WdiDataApi.PeerCreateIndication(pWdi->DataPathHandle, (WDI_PORT_ID)pPeerEntry->uPortId, (WDI_PEER_ID)pPeerEntry->uPeerId, PeerAddr); - + PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + FunctionOut(COMP_INIT); } -VOID +VOID WDI_DeleteGroupPeer( IN PADAPTER pAdapter, IN u2Byte PortNumber @@ -2368,15 +2370,15 @@ WDI_DeleteGroupPeer( WDI_PEER_ID PeerId = 0; PRT_PEER_ENTRY pPeerEntry = NULL; u1Byte i; - + FunctionIn(COMP_INIT); PlatformAcquireSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + pPeerEntry = (PRT_PEER_ENTRY)wdi_FindGroupPeerByPort(pAdapter, PortNumber); if( pPeerEntry == NULL ) { - RT_TRACE(COMP_INIT, DBG_WARNING, ("wdi_FindPeerByAddr: Cannot find group peer of port %d\n", PortNumber)); + RT_TRACE(COMP_INIT, DBG_WARNING, ("wdi_FindPeerByAddr: Cannot find group peer of port %d\n", PortNumber)); FunctionOut(COMP_INIT); PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); return ; @@ -2385,23 +2387,23 @@ WDI_DeleteGroupPeer( { PeerId = (WDI_PEER_ID)pPeerEntry->uPeerId; pPeerEntry->bUsed = FALSE; - - PlatformZeroMemory(pPeerEntry->PeerAddr, 6); - + + PlatformZeroMemory(pPeerEntry->PeerAddr, 6); + pWdi->WdiDataApi.PeerDeleteIndication(pWdi->DataPathHandle, (WDI_PORT_ID)PortNumber, PeerId, &ndisStatus); - + WDI_FreeRxFrame(pAdapter, (PNET_BUFFER_LIST)N6CGetHeadNblWaitQueue(pDefaultAdapter->RxPeerQueue[PeerId])); RTInitializeSListHead(&pDefaultAdapter->RxPeerQueue[PeerId]); - + RT_TRACE(COMP_INIT, DBG_LOUD, ("WDI_DeleteGroupPeer: delete group peer %d of port %d, Status: %d\n", PeerId, PortNumber, ndisStatus)); } - + PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + FunctionOut(COMP_INIT); } -NDIS_STATUS +NDIS_STATUS WDI_AddDatapathPeer( IN PADAPTER pAdapter, IN pu1Byte pAddr) @@ -2412,28 +2414,28 @@ WDI_AddDatapathPeer( WDI_PORT_ID PortId = (WDI_PORT_ID)pAdapter->pNdis62Common->PortNumber; WDI_MAC_ADDRESS PeerAddr = {0}; PRT_PEER_ENTRY pPeerEntry = NULL; - + FunctionIn(COMP_MLME); - + PlatformAcquireSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + pPeerEntry = (PRT_PEER_ENTRY)wdi_GetAvailablePeer(pAdapter, pAddr); if( pPeerEntry != NULL ) - { + { PlatformMoveMemory(PeerAddr.Address, pPeerEntry->PeerAddr, 6); pWdi->WdiDataApi.PeerCreateIndication(pWdi->DataPathHandle, (WDI_PORT_ID)pPeerEntry->uPortId, (WDI_PEER_ID)pPeerEntry->uPeerId, PeerAddr); - + PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + FunctionOut(COMP_MLME); - + return NDIS_STATUS_SUCCESS; } - + PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + FunctionOut(COMP_MLME); - + return NDIS_STATUS_FAILURE; } @@ -2448,11 +2450,11 @@ void WDI_DeleteDatapathPeer( NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS; WDI_PEER_ID PeerId = 0; PRT_PEER_ENTRY pPeerEntry = NULL; - + FunctionIn(COMP_MLME); - + PlatformAcquireSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + pPeerEntry = (PRT_PEER_ENTRY)wdi_FindPeerByAddr(pAdapter, pAddr); if( pPeerEntry == NULL ) { @@ -2461,23 +2463,23 @@ void WDI_DeleteDatapathPeer( PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); return ; } - RT_TRACE(COMP_INIT, DBG_LOUD, ("WDI_DeleteDatapathPeer: Find the addres [%2x:%2x:%2x:%2x:%2x:%2x] associated at Peer %d\n", pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], pPeerEntry->uPeerId)); - + RT_TRACE(COMP_INIT, DBG_LOUD, ("WDI_DeleteDatapathPeer: Find the addres [%2x:%2x:%2x:%2x:%2x:%2x] associated at Peer %d\n", pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], pPeerEntry->uPeerId)); + pDefaultAdapter->RxPeerUsedCount--; PeerId = (WDI_PEER_ID)pPeerEntry->uPeerId; PortId = (WDI_PORT_ID)pPeerEntry->uPortId; pPeerEntry->bUsed = FALSE; - PlatformZeroMemory(pPeerEntry->PeerAddr, 6); - + PlatformZeroMemory(pPeerEntry->PeerAddr, 6); + pWdi->WdiDataApi.PeerDeleteIndication(pWdi->DataPathHandle, PortId, PeerId, &ndisStatus); - + WDI_FreeRxFrame(pAdapter, (PNET_BUFFER_LIST)N6CGetHeadNblWaitQueue(pDefaultAdapter->RxPeerQueue[PeerId])); RTInitializeSListHead(&pDefaultAdapter->RxPeerQueue[PeerId]); - + PlatformReleaseSpinLock(pAdapter, RT_RX_QUEUE_SPINLOCK); - + RT_TRACE(COMP_MLME, DBG_LOUD, ("WDI_DeleteDatapathPeer: delete peer %d, Status: %d\n", PeerId, ndisStatus)); - + FunctionOut(COMP_MLME); } @@ -2491,7 +2493,7 @@ WDI_FetchNBLByPort( PADAPTER pDefaultAdapter = GetDefaultAdapter(pAdapter); u2Byte index = 0; PRT_SINGLE_LIST_ENTRY pFirst = NULL, pTemp = NULL; - + *ppNetBufferList = NULL; RT_TRACE(COMP_RECV, DBG_LOUD, ("WDI_FetchNBLByPort: fetch frames of all peers at port %d\n", Port_ID)); @@ -2505,7 +2507,7 @@ WDI_FetchNBLByPort( { if(N6CIsNblWaitQueueEmpty(pDefaultAdapter->RxPeerQueue[index])) continue; - + pTemp = RTGetHeadSList(&pDefaultAdapter->RxPeerQueue[index]); if( pFirst == NULL ) { @@ -2518,7 +2520,7 @@ WDI_FetchNBLByPort( RTInitializeSListHead(&pDefaultAdapter->RxPeerQueue[index]); } } - + if( pFirst != NULL ) { *ppNetBufferList = RT_GET_NBL_FROM_QUEUE_LINK(pFirst); @@ -2534,7 +2536,7 @@ WDI_FetchNBLByPort( { if(N6CIsNblWaitQueueEmpty(pDefaultAdapter->RxPeerQueue[index])) continue; - + pTemp = RTGetHeadSList(&pDefaultAdapter->RxPeerQueue[index]); if( pFirst == NULL ) { @@ -2547,7 +2549,7 @@ WDI_FetchNBLByPort( RTInitializeSListHead(&pDefaultAdapter->RxPeerQueue[index]); } } - + if( pFirst != NULL ) { *ppNetBufferList = RT_GET_NBL_FROM_QUEUE_LINK(pFirst); @@ -2577,11 +2579,11 @@ WDI_FreeRxFrame( FunctionOut(COMP_RECV); return; } - + do - { + { //Get next NBL - pNextNBL = NET_BUFFER_LIST_NEXT_NBL(pNetBufferList); + pNextNBL = NET_BUFFER_LIST_NEXT_NBL(pNetBufferList); //Get RFD from NBL pRfd = MP_GET_PACKET_RFD(pNetBufferList); @@ -2617,22 +2619,22 @@ WDI_FreeRxFrame( //Assign NextNBL pointer pNetBufferList = pNextNBL; }while(pNetBufferList!=NULL); - + if (Count == 0) { NdisSetEvent(&pNdisCommon->AllPacketReturnedEvent); - if(pAdapter->MgntInfo.NdisVersion >= RT_NDIS_VERSION_6_20) - { + if(pAdapter->MgntInfo.NdisVersion >= RT_NDIS_VERSION_6_20) + { PADAPTER pTempAdapter = GetFirstExtAdapter(pAdapter); while(pTempAdapter != NULL) { NdisSetEvent(&pTempAdapter->pNdisCommon->AllPacketReturnedEvent); - pTempAdapter = GetNextExtAdapter(pTempAdapter); - } + pTempAdapter = GetNextExtAdapter(pTempAdapter); + } } } - + FunctionOut(COMP_RECV); } @@ -2641,7 +2643,7 @@ WDI_IndicateTKIPMICFailure( PADAPTER pAdapter ) { - PMGNT_INFO pMgntInfo; + PMGNT_INFO pMgntInfo; pMgntInfo = &(pAdapter->MgntInfo); PUCHAR pOutput = NULL; ULONG length = 0; @@ -2650,13 +2652,13 @@ WDI_IndicateTKIPMICFailure( FunctionIn(COMP_SEC); - + Params.FailureInfo.DefaultKeyFailure = FALSE; Params.FailureInfo.KeyIndex=0; //WDI_TKIPFailureParam.PeerMacAddress=pMgntInfo->Bssid; cpMacAddr(Params.FailureInfo.PeerMacAddress.Address, pMgntInfo->Bssid); - - + + ndisStatus = GenerateWdiIndicationTkipMicFailure( &Params, @@ -2696,7 +2698,7 @@ WDI_TxCreditCheck( GLWdiTxRxStatistics.monitorTxPauseReason = pWdi->txPauseReason; // First check if we have pause indication before. - // not to acquire tx lock frequently, so we do not acquire tx lock when read, but remember + // not to acquire tx lock frequently, so we do not acquire tx lock when read, but remember // we should acquire tx lock when need to change the pause reason. if(pWdi->txPauseReason) { @@ -2704,26 +2706,26 @@ WDI_TxCreditCheck( txCredit = *Get_NUM_IDLE_TCB(pAdapter); preTxPauseReason = pWdi->txPauseReason; - + RT_TRACE(COMP_INIT, DBG_LOUD, ("[WDI], WDI_TxCreditCheck(): txCredit=%d\n", txCredit)); - + if(txCredit > (pAdapter->RT_TCB_NUM/4)) { GLWdiTxRxStatistics.numTxResourceAvailable++; - + if( (preTxPauseReason&WDI_TX_PAUSE_REASON_CREDIT) == WDI_TX_PAUSE_REASON_CREDIT) { - RT_TRACE(COMP_INIT, DBG_LOUD, ("[WDI], WDI_TxCreditCheck(): TxPauseReason = 0x%x!!!\n", preTxPauseReason)); + RT_TRACE(COMP_INIT, DBG_LOUD, ("[WDI], WDI_TxCreditCheck(): TxPauseReason = 0x%x!!!\n", preTxPauseReason)); GLWdiTxRxStatistics.numWdiTxRestartIndicate++; RT_TRACE(COMP_INIT, DBG_LOUD, ("[WDI], WDI_TxCreditCheck(): TxSendRestart: %d times!!!\n", GLWdiTxRxStatistics.numWdiTxRestartIndicate)); - + pWdi->txPauseReason &= ~WDI_TX_PAUSE_REASON_CREDIT; PlatformReleaseSpinLock(pAdapter, RT_TX_SPINLOCK); // Before indicate to WDI, release the tx lock. - pWdi->WdiDataApi.TxSendRestartIndication(pWdi->DataPathHandle, - WDI_PORT_ANY, + pWdi->WdiDataApi.TxSendRestartIndication(pWdi->DataPathHandle, + WDI_PORT_ANY, WDI_PEER_ANY, WDI_EXT_TID_UNKNOWN, WDI_TX_PAUSE_REASON_CREDIT); @@ -2749,10 +2751,10 @@ WDI_IndicateFWStalled( PWDI_DATA_STRUCT pWdi = &(pAdapter->pPortCommonInfo->WdiData); NDIS_STATUS_INDICATION statusIndication = {0}; WDI_MESSAGE_HEADER WdiHeader = {0}; - + if(!pWdi->bWdiLEPLDR) return; - + RT_TRACE(COMP_OID_SET, DBG_LOUD, ("==> WDI_IndicateFWStalled\n")); N6_ASSIGN_OBJECT_HEADER( @@ -2818,7 +2820,7 @@ WDI_IndicateGeneralEvent( ) { RT_STATUS rtStatus = RT_STATUS_SUCCESS; - + switch(Event) { default: diff --git a/print/XPSDrvSmpl/src/common/pshndlr.cpp b/print/XPSDrvSmpl/src/common/pshndlr.cpp index 989837be..90acda70 100644 --- a/print/XPSDrvSmpl/src/common/pshndlr.cpp +++ b/print/XPSDrvSmpl/src/common/pshndlr.cpp @@ -133,7 +133,7 @@ CPSHandler::CPSHandler( cstrNSPrefix.Delete(iIndex, 1) > 0) { CStringXDW cstrOrgNamespaces; - cstrOrgNamespaces.Format(szNSSelection, cstrNSPrefix, FRAMEWORK_URI); + cstrOrgNamespaces.Format(szNSSelection, static_cast(cstrNSPrefix), FRAMEWORK_URI); hr = m_pPrintDocument->setProperty(CComBSTR(szSelectNS), CComVariant(cstrOrgNamespaces)); } @@ -1259,7 +1259,7 @@ Note: The annotation for pbstrValue is intended to express that the BSTR may be NULL when S_FALSE is returned, but not when S_OK is returned. - + In any case, when a failure HRESULT is returned, all out parameter annotations are ignored. @@ -1593,7 +1593,7 @@ CPSHandler::GetPrefixFromURI( // Construct the Root Query string // CStringXDW cstrRootQuery; - cstrRootQuery.Format(szPTRootQuery, szTmpNS, m_bstrDocumentType); + cstrRootQuery.Format(szPTRootQuery, szTmpNS, static_cast(m_bstrDocumentType)); // // Find the PrintSchema element so we can retrieve the private namespace prefix diff --git a/print/XPSDrvSmpl/src/common/ptquerybld.cpp b/print/XPSDrvSmpl/src/common/ptquerybld.cpp index 885af0b2..2b3bd749 100644 --- a/print/XPSDrvSmpl/src/common/ptquerybld.cpp +++ b/print/XPSDrvSmpl/src/common/ptquerybld.cpp @@ -236,7 +236,7 @@ CPTQueryBuilder::AddFeature( if (SUCCEEDED(hr)) { CStringXDW cstrFeatureQuery; - cstrFeatureQuery.Format(szPTQFeature, m_bstrFrameworkNS, bstrKeyword); + cstrFeatureQuery.Format(szPTQFeature, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrFeatureQuery); } @@ -305,7 +305,7 @@ CPTQueryBuilder::AddProperty( if (SUCCEEDED(hr)) { CStringXDW cstrPropertyQuery; - cstrPropertyQuery.Format(szPTQProperty, m_bstrFrameworkNS, bstrKeyword); + cstrPropertyQuery.Format(szPTQProperty, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrPropertyQuery); } @@ -369,7 +369,7 @@ CPTQueryBuilder::AddScoredProperty( if (SUCCEEDED(hr)) { CStringXDW cstrScoredPropertyQuery; - cstrScoredPropertyQuery.Format(szPTQScoredProperty, m_bstrFrameworkNS, bstrKeyword); + cstrScoredPropertyQuery.Format(szPTQScoredProperty, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrScoredPropertyQuery); } @@ -437,7 +437,7 @@ CPTQueryBuilder::AddParamRef( if (SUCCEEDED(hr)) { CStringXDW cstrParamRefQuery; - cstrParamRefQuery.Format(szPTQParamRef, m_bstrFrameworkNS, bstrKeyword); + cstrParamRefQuery.Format(szPTQParamRef, static_cast(m_bstrFrameworkNS), static_cast(bstrKeyword)); hr = m_bstrQuery.Append(cstrParamRefQuery); } @@ -490,13 +490,14 @@ CPTQueryBuilder::AddOption( { CStringXDW cstrQueryRoot(m_bstrQuery); CStringXDW cstrOptionQuery; - cstrOptionQuery.Format(szPTQOptionSH, m_bstrFrameworkNS); + cstrOptionQuery.Format(szPTQOptionSH, static_cast(m_bstrFrameworkNS)); if (SUCCEEDED(hr = m_bstrQuery.Append(cstrOptionQuery)) && SUCCEEDED(hr = m_bstrQuery.Append(szPTQOrNodes)) && SUCCEEDED(hr = m_bstrQuery.Append(cstrQueryRoot))) { - cstrOptionQuery.Format(szPTQOptionLH, m_bstrFrameworkNS, bstrKeywordNS, m_bstrFrameworkNS); + cstrOptionQuery.Format(szPTQOptionLH, static_cast(m_bstrFrameworkNS), + static_cast(bstrKeywordNS), static_cast(m_bstrFrameworkNS)); hr = m_bstrQuery.Append(cstrOptionQuery); } } diff --git a/print/XPSDrvSmpl/src/common/wmpthndlr.cpp b/print/XPSDrvSmpl/src/common/wmpthndlr.cpp index dcb1eff7..49792d6a 100644 --- a/print/XPSDrvSmpl/src/common/wmpthndlr.cpp +++ b/print/XPSDrvSmpl/src/common/wmpthndlr.cpp @@ -1123,7 +1123,7 @@ CWMPTHandler::GetTxtPropTypeAndValue( case FontColor: { cstrType = SCHEMA_STRING; - cstrValue.Format(L"%s", pWmData->txtData.bstrFontColor); + cstrValue.Format(L"%s", static_cast(pWmData->txtData.bstrFontColor)); } break; @@ -1137,7 +1137,7 @@ CWMPTHandler::GetTxtPropTypeAndValue( case Text: { cstrType = SCHEMA_STRING; - cstrValue.Format(L"%s", pWmData->txtData.bstrText); + cstrValue.Format(L"%s", static_cast(pWmData->txtData.bstrText)); } break; diff --git a/print/XPSDrvSmpl/src/filters/color/cmimg.cpp b/print/XPSDrvSmpl/src/filters/color/cmimg.cpp index f44fa028..6c312629 100644 --- a/print/XPSDrvSmpl/src/filters/color/cmimg.cpp +++ b/print/XPSDrvSmpl/src/filters/color/cmimg.cpp @@ -537,7 +537,7 @@ CColorManagedImage::GetResURI( // Create a unique name for the bitmap for this print session // CStringXDW cstrURI; - cstrURI.Format(L"%s_%u.wdp", cstrFileName, GetUniqueNumber()); + cstrURI.Format(L"%s_%u.wdp", static_cast(cstrFileName), GetUniqueNumber()); SysFreeString(*pbstrResURI); *pbstrResURI = cstrURI.AllocSysString(); diff --git a/print/XPSDrvSmpl/src/filters/color/dictionary.cpp b/print/XPSDrvSmpl/src/filters/color/dictionary.cpp index 5106aad7..efd15760 100644 --- a/print/XPSDrvSmpl/src/filters/color/dictionary.cpp +++ b/print/XPSDrvSmpl/src/filters/color/dictionary.cpp @@ -273,7 +273,7 @@ CRemoteDictionary::GetResURI( // Create a unique name for the dictionary for this print session // CStringXDW cstrURI; - cstrURI.Format(L"%s_%u.dict", m_bstrDictionaryURI, GetUniqueNumber()); + cstrURI.Format(L"%s_%u.dict", static_cast(m_bstrDictionaryURI), GetUniqueNumber()); *pbstrResURI = cstrURI.AllocSysString(); } diff --git a/print/XPSDrvSmpl/src/filters/color/profman.cpp b/print/XPSDrvSmpl/src/filters/color/profman.cpp index 8bd06284..16ee9dc2 100644 --- a/print/XPSDrvSmpl/src/filters/color/profman.cpp +++ b/print/XPSDrvSmpl/src/filters/color/profman.cpp @@ -692,7 +692,7 @@ CProfileManager::GetResURI( // Create a unique name for the profile for this print session // CStringXDW cstrURI; - cstrURI.Format(L"/%s_%u%s", cstrFileName, GetUniqueNumber(), cstrFileExt); + cstrURI.Format(L"/%s_%u%s", static_cast(cstrFileName), GetUniqueNumber(), static_cast(cstrFileExt)); *pbstrResURI = cstrURI.AllocSysString(); } diff --git a/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp b/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp index 209c344a..fa50170f 100644 --- a/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp +++ b/print/XPSDrvSmpl/src/filters/common/ptmanage.cpp @@ -178,9 +178,9 @@ CPTManager::Initialise( // // We couldn't revert the security context. The filter pipeline // manager will clean up the thread when operation is complete, - // when it is determined that the security context was not - // reverted. Since there are no security implications with - // running this filter in an elevated context, we can + // when it is determined that the security context was not + // reverted. Since there are no security implications with + // running this filter in an elevated context, we can // continue to run. // } @@ -589,7 +589,7 @@ CPTManager::GetCapabilities( { } } - + // // Always revert back to the default security context // @@ -598,9 +598,9 @@ CPTManager::GetCapabilities( // // We couldn't revert the security context. The filter pipeline // manager will clean up the thread when operation is complete, - // when it is determined that the security context was not - // reverted. Since there are no security implications with - // running this filter in an elevated context, we can + // when it is determined that the security context was not + // reverted. Since there are no security implications with + // running this filter in an elevated context, we can // continue to run. // } @@ -1034,7 +1034,7 @@ CPTManager::GetMergedTicket( { CStringXDA cstrMessage; CStringXDA cstrError(bstrErrorMessage); - cstrMessage.Format("PTMergeAndValidatePrintTicket failed with message: %s\n", cstrError); + cstrMessage.Format("PTMergeAndValidatePrintTicket failed with message: %s\n", static_cast(cstrError)); ERR(cstrMessage.GetBuffer()); } @@ -1047,9 +1047,9 @@ CPTManager::GetMergedTicket( // // We couldn't revert the security context. The filter pipeline // manager will clean up the thread when operation is complete, - // when it is determined that the security context was not - // reverted. Since there are no security implications with - // running this filter in an elevated context, we can + // when it is determined that the security context was not + // reverted. Since there are no security implications with + // running this filter in an elevated context, we can // continue to run. // } diff --git a/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp b/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp index 830f6928..6c92730c 100644 --- a/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp +++ b/print/XPSDrvSmpl/src/filters/nup/nupsax.cpp @@ -266,7 +266,7 @@ CNUpSaxHandler::startElement( if (sizePage.Width < 1.f) { // - // According to the Xps Specification, + // According to the Xps Specification, // FixedPage Width must be >= 1.0 // hr = E_FAIL; @@ -363,8 +363,8 @@ CNUpSaxHandler::startElement( sizePage.Height); cstrOut.Format(L"(bstrMatrix), + static_cast(strClip)); // // Add additional namespaces from the FixedPage diff --git a/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp b/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp index 44e0d5d3..7a7bc160 100644 --- a/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp +++ b/print/XPSDrvSmpl/src/filters/scaling/pagescale.cpp @@ -699,7 +699,7 @@ CPageScaling::GetOpenTagXML( if (SUCCEEDED(hr = CreateTransform(&bstrMatrixXForm))) { CStringXDW cstrCanvas; - cstrCanvas.Format(L"(bstrMatrixXForm)); *pbstrXML = cstrCanvas.AllocSysString(); } } diff --git a/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp b/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp index 578995bf..5f139830 100644 --- a/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp +++ b/print/XPSDrvSmpl/src/filters/watermark/wmvect.cpp @@ -159,7 +159,8 @@ CVectorWatermark::CreateXMLElement( try { CStringXDW strOpenCanvas; - strOpenCanvas.Format(L"", bstrWMOpacity, bstrMatrixXForm); + strOpenCanvas.Format(L"", + static_cast(bstrWMOpacity), static_cast(bstrMatrixXForm)); IStream* pStream; CComBSTR bstrContent; diff --git a/sd/sdiomars/mars.vcxproj b/sd/sdiomars/mars.vcxproj index fc11a774..21ca54ce 100644 --- a/sd/sdiomars/mars.vcxproj +++ b/sd/sdiomars/mars.vcxproj @@ -101,15 +101,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. @@ -117,15 +117,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. @@ -133,15 +133,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. @@ -149,15 +149,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\sdbus.lib;$(DDK_LIB_PATH)\ntstrsafe.lib - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. - %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories);. @@ -176,4 +176,4 @@ - \ No newline at end of file + diff --git a/security/elam/elamsample.c b/security/elam/elamsample.c index 13654d6e..0877ee71 100644 --- a/security/elam/elamsample.c +++ b/security/elam/elamsample.c @@ -20,7 +20,7 @@ // Kernel mode only. // -#include +#include "elamsample.h" #ifdef ALLOC_PRAGMA #pragma alloc_text(INIT, DriverEntry) diff --git a/sensors/Activity/Device.h b/sensors/Activity/Device.h index 64b2a5e4..afd205db 100644 --- a/sensors/Activity/Device.h +++ b/sensors/Activity/Device.h @@ -12,7 +12,7 @@ #include #include -#include +#include "SensorsTrace.h" #include #include @@ -197,4 +197,4 @@ private: // // Set up accessor function to retrieve device context // -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ActivityDevice, GetActivityContextFromSensorInstance); \ No newline at end of file +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(ActivityDevice, GetActivityContextFromSensorInstance); diff --git a/sensors/CustomSensors/Device.h b/sensors/CustomSensors/Device.h index 0679b137..692bf675 100644 --- a/sensors/CustomSensors/Device.h +++ b/sensors/CustomSensors/Device.h @@ -15,7 +15,7 @@ #include #include -#include +#include "SensorsTrace.h" #include #include @@ -135,4 +135,4 @@ WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(CustomSensorDevice, GetCustomSensorContextFro #define CustomSensorDevice_Resolution (0.1f) // CO2 concentration resolution in parts per million (ppmv). #define CustomSensorDevice_Minimum_CO2Level (0.0f) // Minimum CO2 concentration in parts per million (ppmv). -#define CustomSensorDevice_Maximum_CO2Level (10000.0f) // Maximum CO2 concentration in parts per million (ppmv). \ No newline at end of file +#define CustomSensorDevice_Maximum_CO2Level (10000.0f) // Maximum CO2 concentration in parts per million (ppmv). diff --git a/sensors/CustomSensors/HardwareSimulator.h b/sensors/CustomSensors/HardwareSimulator.h index e170918b..3bb6e04c 100644 --- a/sensors/CustomSensors/HardwareSimulator.h +++ b/sensors/CustomSensors/HardwareSimulator.h @@ -14,7 +14,7 @@ #include #include -#include +#include "SensorsTrace.h" #include #define SIMULATOR_HARDWARE_INTERVAL_MS (100) // 100ms diff --git a/sensors/Fusion/Device.h b/sensors/Fusion/Device.h index 1bd39606..89d45ed9 100644 --- a/sensors/Fusion/Device.h +++ b/sensors/Fusion/Device.h @@ -19,11 +19,7 @@ #include #include #include -#include #include -#include -#include -#include #define SENSOR_POOL_TAG_FUSIONSENSOR 'esuF' diff --git a/sensors/Pedometer/Device.h b/sensors/Pedometer/Device.h index 008c3ef6..593e0b95 100644 --- a/sensors/Pedometer/Device.h +++ b/sensors/Pedometer/Device.h @@ -15,7 +15,7 @@ #include #include -#include +#include "SensorsTrace.h" #include #include diff --git a/sensors/Pedometer/HardwareSimulator.h b/sensors/Pedometer/HardwareSimulator.h index 3d9646b9..c0f72cac 100644 --- a/sensors/Pedometer/HardwareSimulator.h +++ b/sensors/Pedometer/HardwareSimulator.h @@ -14,7 +14,7 @@ #include #include -#include +#include "SensorsTrace.h" #include #include "Device.h" diff --git a/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj b/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj index 15e5d0a5..381f5a03 100644 --- a/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj +++ b/sensors/SensorsComboDriver/SensorsComboDriver.vcxproj @@ -118,7 +118,6 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def @@ -139,7 +138,6 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def @@ -160,7 +158,6 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def @@ -181,7 +178,6 @@ %(AdditionalDependencies);$(SDK_LIB_PATH)\mincore.lib;$(SDK_LIB_PATH)\propsys.lib;$(SDK_LIB_PATH)\sensors\1.1\sensorscxstub.lib;$(SDK_LIB_PATH)\sensorsutils.lib - SensorsComboDriver.def @@ -197,4 +193,4 @@ - \ No newline at end of file + diff --git a/sensors/SimpleDeviceOrientationSensor/Device.h b/sensors/SimpleDeviceOrientationSensor/Device.h index b75b5ceb..3d1e677c 100644 --- a/sensors/SimpleDeviceOrientationSensor/Device.h +++ b/sensors/SimpleDeviceOrientationSensor/Device.h @@ -15,7 +15,7 @@ #include #include -#include +#include "SensorsTrace.h" #include #include diff --git a/sensors/SimpleDeviceOrientationSensor/HardwareSimulator.h b/sensors/SimpleDeviceOrientationSensor/HardwareSimulator.h index 8f96b902..7da0be14 100644 --- a/sensors/SimpleDeviceOrientationSensor/HardwareSimulator.h +++ b/sensors/SimpleDeviceOrientationSensor/HardwareSimulator.h @@ -14,7 +14,7 @@ #include #include -#include +#include "SensorsTrace.h" #include #include diff --git a/smartcrd/pscr/Pscr.vcxproj b/smartcrd/pscr/Pscr.vcxproj index 519d508f..2bcdd80d 100644 --- a/smartcrd/pscr/Pscr.vcxproj +++ b/smartcrd/pscr/Pscr.vcxproj @@ -99,15 +99,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\smclib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. @@ -115,15 +115,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\smclib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. @@ -131,15 +131,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\smclib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. @@ -147,15 +147,15 @@ %(AdditionalDependencies);$(DDK_LIB_PATH)\smclib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. @@ -179,4 +179,4 @@ - \ No newline at end of file + diff --git a/storage/class/classpnp/src/srblib.c b/storage/class/classpnp/src/srblib.c index a888d390..64a7ca88 100644 --- a/storage/class/classpnp/src/srblib.c +++ b/storage/class/classpnp/src/srblib.c @@ -22,7 +22,7 @@ Revision History: --*/ -#include +#include "classp.h" PVOID DefaultStorageRequestBlockAllocateRoutine( diff --git a/storage/miniports/lsi_u3/src/lsi_u3.inf b/storage/miniports/lsi_u3/src/lsi_u3.inf index 1225dad4..8d631d41 100644 Binary files a/storage/miniports/lsi_u3/src/lsi_u3.inf and b/storage/miniports/lsi_u3/src/lsi_u3.inf differ diff --git a/storage/msdsm/src/intrface.c b/storage/msdsm/src/intrface.c index e7c1eb29..925252be 100644 --- a/storage/msdsm/src/intrface.c +++ b/storage/msdsm/src/intrface.c @@ -2159,13 +2159,13 @@ Return Value: group->LBPolicySelection = DSM_DEFAULT_LB_POLICY_LUN_EXPLICIT; } - + if (!explicitlySet && !vidpidPolicySet && !overallPolicySet) { group->LBPolicySelection = DSM_DEFAULT_LB_POLICY_ALUA_CAPABILITY; - } - + } + // // If ALUA is enabled and the load balance policy is set to Round Robin, // we need to set it to Round Robin with Subset instead. @@ -2466,7 +2466,7 @@ Return Value: KIRQL irql; BOOLEAN retVal; ULONG SpecialHandlingFlag = 0; - + // // 1. If PR and reserved by this node, register the PR keys. // 2. Find the FOG for the passed in PathId @@ -2714,7 +2714,7 @@ Return Value: PDSM_FOG_DEVICELIST_ENTRY fogDeviceListEntry = NULL; PDSM_GROUP_ENTRY group = deviceInfo->Group; ULONG SpecialHandlingFlag = 0; - + TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_PNP, "DsmPathVerify (DevInfo %p): Entering function.\n", @@ -2722,22 +2722,6 @@ Return Value: if (DsmpIsDeviceInitialized(deviceInfo)) { - if (deviceInfo->Unresponsive) { - // - // Since the device is marked unresponsive, there - // is no point in sending RTPG or TUR down - // as that will fail by port driver. - // but that doesn't necessarily mean that the path doesn't exist. - // Return SUCCESS here so that MPIO doesn't remove - // disk in case of failover etc. - // If really this path is gone, this should get deleted - // as part of pnp removal and then if no other paths are left - // disk will be removed - // - status = STATUS_SUCCESS; - return status; - } - irql = ExAcquireSpinLockExclusive(&(dsmCtxt->DsmContextLock)); // @@ -2974,11 +2958,11 @@ Return Value: // Initialize all the entries to indicate that they haven't been processed. // for (entry = failGroup->ZombieGroupList.Flink; entry != &(failGroup->ZombieGroupList); entry = entry->Flink) { - + group = CONTAINING_RECORD(entry, DSM_ZOMBIEGROUP_ENTRY, ListEntry); group->Processed = FALSE; } - + // // Since we need to drop the spin lock while processing an entry, it is possible // that a removal in parallel frees up this entry during that time, thus making it @@ -2988,7 +2972,7 @@ Return Value: // of the list, skipping over the already processed ones. // entry = failGroup->ZombieGroupList.Flink; - + while (entry != &(failGroup->ZombieGroupList)) { group = CONTAINING_RECORD(entry, DSM_ZOMBIEGROUP_ENTRY, ListEntry); @@ -3165,7 +3149,7 @@ Return Value: BOOLEAN adminRequest = FALSE; PDSM_GROUP_ENTRY group = NULL; ULONG SpecialHandlingFlag = 0; - + TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_WMI, "DsmMoveDevice (DsmIds %p): Entering function - DsmContext %p MPIOPath (%p) SuggestedPath %p.\n", @@ -3613,7 +3597,7 @@ Return Value: cdb = SrbGetCdb(Srb); if (cdb) { opCode = cdb->AsByte[0]; - + } } @@ -3739,7 +3723,7 @@ Return Value: // 2. If the old path was supposed to be removed, check if there are // no more requests are outstanding, and if yes, remove the path // - + irpStack = IoGetCurrentIrpStackLocation(irp); oldPath = irpStack->Parameters.Others.Argument3; @@ -3788,7 +3772,7 @@ Return Value: } } else { - + *Status = STATUS_NO_SUCH_DEVICE; @@ -3796,7 +3780,7 @@ Return Value: TRACE_FLAG_RW, "DsmLBGetPath (DsmIds %p): Failed to get FO group in LBGetPath.\n", DsmList)); - + } @@ -4101,16 +4085,16 @@ Return Value: __Exit_DsmSrbDeviceControl: if (status != STATUS_PENDING) { - + // // Set-up the Irp status for mpio's completion of the request. // If it was IRP_MJ_SCSI, one of the helper routines set Srb->SrbStatus // already. // if ((irpStack->MajorFunction == IRP_MJ_SCSI) && - (Srb != NULL) && + (Srb != NULL) && (Srb->SrbStatus == SRB_STATUS_PENDING)) { - + Srb->SrbStatus = SRB_STATUS_ERROR; } @@ -4694,7 +4678,7 @@ Return Value: handled = TRUE; break; - } + } } } } @@ -4884,7 +4868,7 @@ Return Value: break; } - + default: { if ((scsiStatus == SCSISTAT_CHECK_CONDITION) && @@ -4998,7 +4982,7 @@ Return Value: if (failover) { ULONG SpecialHandlingFlag = 0; - + // // If ALUA is supported, then it is possible that we may need to send // down an STPG so build an IRP and fill in the SRB for STPG and send it down. @@ -5072,7 +5056,7 @@ Return Value: deviceInfo->Group->PathToBeUsed)); } } - } + } *Retry = retry; diff --git a/usb/UcmCxUcsi/UcmCxUcsi.vcxproj b/usb/UcmCxUcsi/UcmCxUcsi.vcxproj index 6a028bd4..6b1efbb1 100644 --- a/usb/UcmCxUcsi/UcmCxUcsi.vcxproj +++ b/usb/UcmCxUcsi/UcmCxUcsi.vcxproj @@ -90,6 +90,7 @@ pch.h + %(AdditionalIncludeDirectories);. true true trace.h @@ -128,4 +129,4 @@ - \ No newline at end of file + diff --git a/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj b/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj index e771d816..39422319 100644 --- a/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj +++ b/usb/kmdf_enumswitches/sys/kmdf_enumswitches.vcxproj @@ -99,18 +99,18 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING %(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -118,18 +118,18 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING %(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -137,18 +137,18 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING %(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -156,18 +156,18 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING %(AdditionalDependencies);$(DDK_LIB_PATH)\ntstrsafe.lib;$(DDK_LIB_PATH)\wdmsec.lib - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -220,4 +220,4 @@ - \ No newline at end of file + diff --git a/usb/kmdf_fx2/driver/osrusbfx2.vcxproj b/usb/kmdf_fx2/driver/osrusbfx2.vcxproj index 08cde31a..2bcf6616 100644 --- a/usb/kmdf_fx2/driver/osrusbfx2.vcxproj +++ b/usb/kmdf_fx2/driver/osrusbfx2.vcxproj @@ -115,17 +115,17 @@
- %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -134,17 +134,17 @@ - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -153,17 +153,17 @@ - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -172,17 +172,17 @@ - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -241,4 +241,4 @@ - \ No newline at end of file + diff --git a/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj b/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj index 72e39bc1..a4209763 100644 --- a/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj +++ b/usb/umdf2_fx2/driver/osrusbfx2um.vcxproj @@ -114,17 +114,17 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE @@ -135,17 +135,17 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE @@ -156,17 +156,17 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE @@ -177,17 +177,17 @@ true Level4 - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING;UNICODE;_UNICODE @@ -207,4 +207,4 @@ - \ No newline at end of file + diff --git a/usb/umdf_filter_kmdf/kmdf_driver/osrusbfx2.vcxproj b/usb/umdf_filter_kmdf/kmdf_driver/osrusbfx2.vcxproj index 2db1f7c1..3974f664 100644 --- a/usb/umdf_filter_kmdf/kmdf_driver/osrusbfx2.vcxproj +++ b/usb/umdf_filter_kmdf/kmdf_driver/osrusbfx2.vcxproj @@ -115,17 +115,17 @@
- %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -134,17 +134,17 @@ - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -153,17 +153,17 @@ - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -172,17 +172,17 @@ - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. true Level4 %(PreprocessorDefinitions);EVENT_TRACING - %(AdditionalIncludeDirectories);..\inc + %(AdditionalIncludeDirectories);..\inc;. %(PreprocessorDefinitions);EVENT_TRACING @@ -241,4 +241,4 @@ - \ No newline at end of file + diff --git a/wpd/WpdHelloWorldDriver/WpdHelloWorldDriver.inx b/wpd/WpdHelloWorldDriver/WpdHelloWorldDriver.inx index 40d31f8c..f79d7810 100644 --- a/wpd/WpdHelloWorldDriver/WpdHelloWorldDriver.inx +++ b/wpd/WpdHelloWorldDriver/WpdHelloWorldDriver.inx @@ -68,6 +68,7 @@ ServiceBinary=%12%\WUDFRd.sys [DestinationDirs] System32Copy=12,UMDF ; copy to system32\drivers\umdf +CoInstallers_CopyFiles= 11 [System32Copy] WpdHelloWorldDriver.dll diff --git a/wpd/WpdMultiTransportDriver/WpdMultiTransportDriver.inx b/wpd/WpdMultiTransportDriver/WpdMultiTransportDriver.inx index d293c9f7..5e20c4c3 100644 --- a/wpd/WpdMultiTransportDriver/WpdMultiTransportDriver.inx +++ b/wpd/WpdMultiTransportDriver/WpdMultiTransportDriver.inx @@ -69,6 +69,7 @@ ServiceBinary=%12%\WUDFRd.sys [DestinationDirs] System32Copy=12,UMDF ; copy to system32\drivers\umdf +CoInstallers_CopyFiles= 11 [System32Copy] WpdMultiTransportDriver.dll diff --git a/wpd/WpdServiceSampleDriver/WpdServiceSampleDriver.inx b/wpd/WpdServiceSampleDriver/WpdServiceSampleDriver.inx index 935a61cd..0f4365cc 100644 --- a/wpd/WpdServiceSampleDriver/WpdServiceSampleDriver.inx +++ b/wpd/WpdServiceSampleDriver/WpdServiceSampleDriver.inx @@ -65,6 +65,7 @@ ServiceBinary=%12%\WUDFRd.sys [DestinationDirs] System32Copy=12,UMDF ; copy to system32\drivers\umdf +CoInstallers_CopyFiles= 11 [System32Copy] WpdServiceSampleDriver.dll diff --git a/wpd/WpdWudfSampleDriver/WpdWudfSampleDriver.inx b/wpd/WpdWudfSampleDriver/WpdWudfSampleDriver.inx index c66eb485..a2e11b1b 100644 Binary files a/wpd/WpdWudfSampleDriver/WpdWudfSampleDriver.inx and b/wpd/WpdWudfSampleDriver/WpdWudfSampleDriver.inx differ -- cgit v1.3.1 From fb27e1ecfc10630a3cb41f48c1816be30ec91f4c Mon Sep 17 00:00:00 2001 From: Barry Golden Date: Mon, 18 Sep 2017 13:36:25 -0700 Subject: Update README.md platform metadata. --- general/toaster/toastDrv/README.md | 2 +- general/umdfSkeleton/README.md | 2 +- serial/VirtualSerial/README.md | 2 +- usb/wdf_osrfx2_lab/README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/general/toaster/toastDrv/README.md b/general/toaster/toastDrv/README.md index 4a29ff7d..9e9a469a 100644 --- a/general/toaster/toastDrv/README.md +++ b/general/toaster/toastDrv/README.md @@ -1,6 +1,6 @@ + # OEM Printer Customization Plug-in Samples The OEMDLL samples are an illustration of OEM customization plug-ins. The BITMAP, OEMPS, OEMUI, OEMUNI, OEMPREAN, CUSTHLP, SyncSet, ThemeUI, PSUIRep, and Watermark samples do not affect the printer output. They are only examples of how to build OEM Customization DLLs of various types. -- cgit v1.3.1 From 68ce6c64e66182c142f430d1e04393478e8cf089 Mon Sep 17 00:00:00 2001 From: Adonais Romero Gonzalez Date: Thu, 2 Nov 2017 15:57:59 -0700 Subject: Delete empty line on general/pcidrv; solves #113 --- general/pcidrv/kmdf/PCIDRV.C | 1 - 1 file changed, 1 deletion(-) diff --git a/general/pcidrv/kmdf/PCIDRV.C b/general/pcidrv/kmdf/PCIDRV.C index e3f65678..17ae76bf 100644 --- a/general/pcidrv/kmdf/PCIDRV.C +++ b/general/pcidrv/kmdf/PCIDRV.C @@ -1,4 +1,3 @@ - /*++ Copyright (c) Microsoft Corporation. All rights reserved. -- cgit v1.3.1 From 17dc03314bff5be5f8c0670e9be496b36ed27c1c Mon Sep 17 00:00:00 2001 From: Adonais Romero Gonzalez Date: Tue, 14 Nov 2017 14:46:22 -0800 Subject: Move DV-FailDriver-WDM sample --- tools/dv/samples/DV-FailDriver-WDM/README.md | 32 + .../dv/samples/DV-FailDriver-WDM/defect_toastmon.c | 1532 ++++++++++++++++++++ .../dv/samples/DV-FailDriver-WDM/defect_toastmon.h | 175 +++ .../samples/DV-FailDriver-WDM/defect_toastmon.inf | 89 ++ .../samples/DV-FailDriver-WDM/defect_toastmon.rc | 12 + tools/dv/samples/DV-FailDriver-WDM/driver.h | 118 ++ .../DV-FailDriver-WDM/driver/DV-FailDriver-WDM.sln | 32 + .../driver/defect_toastmon.vcxproj | 145 ++ .../driver/defect_toastmon.vcxproj.Filters | 39 + tools/dv/samples/DV-FailDriver-WDM/public.h | 174 +++ tools/dv/samples/DV-FailDriver-WDM/wmi.c | 314 ++++ tools/sdv/samples/DV-FailDriver-WDM/README.md | 32 - .../samples/DV-FailDriver-WDM/defect_toastmon.c | 1532 -------------------- .../samples/DV-FailDriver-WDM/defect_toastmon.h | 175 --- .../samples/DV-FailDriver-WDM/defect_toastmon.inf | 88 -- .../samples/DV-FailDriver-WDM/defect_toastmon.rc | 12 - tools/sdv/samples/DV-FailDriver-WDM/driver.h | 118 -- tools/sdv/samples/DV-FailDriver-WDM/public.h | 174 --- tools/sdv/samples/DV-FailDriver-WDM/wmi.c | 314 ---- 19 files changed, 2662 insertions(+), 2445 deletions(-) create mode 100644 tools/dv/samples/DV-FailDriver-WDM/README.md create mode 100644 tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.c create mode 100644 tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.h create mode 100644 tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.inf create mode 100644 tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.rc create mode 100644 tools/dv/samples/DV-FailDriver-WDM/driver.h create mode 100644 tools/dv/samples/DV-FailDriver-WDM/driver/DV-FailDriver-WDM.sln create mode 100644 tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj create mode 100644 tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj.Filters create mode 100644 tools/dv/samples/DV-FailDriver-WDM/public.h create mode 100644 tools/dv/samples/DV-FailDriver-WDM/wmi.c delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/README.md delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.c delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.h delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.inf delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.rc delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/driver.h delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/public.h delete mode 100644 tools/sdv/samples/DV-FailDriver-WDM/wmi.c diff --git a/tools/dv/samples/DV-FailDriver-WDM/README.md b/tools/dv/samples/DV-FailDriver-WDM/README.md new file mode 100644 index 00000000..9851ff31 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/README.md @@ -0,0 +1,32 @@ + + + +DV-FailDriver-WDM +================= + +The DV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Driver Verifier](https://msdn.microsoft.com/en-us/library/windows/hardware/ff545448) (DV) and the [Device Fundamentals tests](https://msdn.microsoft.com/en-us/library/windows/hardware/jj673011). Driver Verifier is a component of the Windows kernel designed to detect drivers that are behaving poorly and stop their execution via a bugcheck; the Device Fundamentals tests are a series of tests provided in the Windows Driver Kit (WDK) designed to provide a good basic set of tests against a driver. + +**Caution** This sample driver contains intentional code errors that are designed to show the capabilities and features of DV and SDV. This sample driver is not intended as an example for real driver development projects. + +Build the sample for desktop +-------------- +1. In the **Solutions Explorer** window, select the driver solution (DV-FailDriver-WDM). + +2. From the **Build** menu, select **Build Solution**. + +Deploy the sample +-------------- +See [Deploying a Driver to a Test Computer](https://msdn.microsoft.com/en-us/library/windows/hardware/hh454834) for details on how to deploy the sample. + +Test the sample +-------------- +See [How to test a driver at runtime](https://msdn.microsoft.com/en-us/library/windows/hardware/ff554820) for details on how to run tests on the Toastmon driver. + +To observe the injected defect being caught by DV, you should enable DV on the Toastmon driver, and then run the "DF - PNP Surprise Remove (Development and Integration)" test on the Toastmon sample driver and device. \ No newline at end of file diff --git a/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.c b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.c new file mode 100644 index 00000000..f8c545d2 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.c @@ -0,0 +1,1532 @@ +/*++ + +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: + + defect_toastmon.c + +Abstract: This sample is designed to demonstrate the Driver Verifier + functionality present in Windows. A bug violating the + IrqlPsPassive rule is injected in the ToasterDrvCancelQueuedReadIrps + callback. Running the Device Fundamentals PNP Surprise Remove test + with Driver Verifier enabled on this Defect_Toastmon driver will create + a bugcheck (0xC4) describing the error. + + This driver should not be used as a sample to build a new driver from. + +Environment: + + Kernel mode + +Revision History: + + Injected defect to demonstrate DV capabilities and cleaned sample + (7/14/2015) + + Added module to demonstrate how to register and receive WMI + notification in Kernel-mode (3/3/2004) + +--*/ +#include "defect_toastmon.h" +#include +#include +#include "public.h" + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (INIT, DriverEntry) +#pragma alloc_text (PAGE, Defect_ToastMon_AddDevice) +#pragma alloc_text (PAGE, Defect_ToastMon_DispatchPnp) +#pragma alloc_text (PAGE, Defect_ToastMon_DispatchPower) +#pragma alloc_text (PAGE, Defect_ToastMon_Dispatch) +#pragma alloc_text (PAGE, Defect_ToastMon_DispatchRead) +#pragma alloc_text (PAGE, Defect_ToastMon_DispatchSystemControl) +#pragma alloc_text (PAGE, Defect_ToastMon_Unload) +#pragma alloc_text (PAGE, Defect_ToastMon_PnpNotifyDeviceChange) +#pragma alloc_text (PAGE, Defect_ToastMon_PnpNotifyInterfaceChange) +#pragma alloc_text (PAGE, Defect_ToastMon_GetTargetDevicePdo) +#pragma alloc_text (PAGE, Defect_ToastMon_OpenTargetDevice) +#pragma alloc_text (PAGE, Defect_ToastMon_CloseTargetDevice) +#endif + +NTSTATUS +DriverEntry( + __in PDRIVER_OBJECT DriverObject, + __in PUNICODE_STRING RegistryPath + ) + //++ +/* + +Routine Description: + + Installable driver initialization entry point. + This entry point is called directly by the I/O system. + +Arguments: + + DriverObject - pointer to the driver object + + RegistryPath - pointer to a unicode string representing the path, + to driver-specific key in the registry. + +Return Value: + + STATUS_SUCCESS + +--*/ +{ + + UNREFERENCED_PARAMETER (RegistryPath); + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Driver Entry\n")); + + // + // Create dispatch points for the IRPs. + // + + DriverObject->MajorFunction[IRP_MJ_CREATE] = Defect_ToastMon_Dispatch; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = Defect_ToastMon_Dispatch; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = Defect_ToastMon_Dispatch; + DriverObject->MajorFunction[IRP_MJ_READ] = Defect_ToastMon_DispatchRead; + DriverObject->MajorFunction[IRP_MJ_PNP] = Defect_ToastMon_DispatchPnp; + DriverObject->MajorFunction[IRP_MJ_POWER] = Defect_ToastMon_DispatchPower; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = + Defect_ToastMon_DispatchSystemControl; + DriverObject->DriverExtension->AddDevice = Defect_ToastMon_AddDevice; + DriverObject->DriverUnload = Defect_ToastMon_Unload; + + return STATUS_SUCCESS; +} + + +NTSTATUS +Defect_ToastMon_AddDevice( + __in PDRIVER_OBJECT DriverObject, + __in PDEVICE_OBJECT PhysicalDeviceObject + ) +/*++ + +Routine Description: + + The Plug & Play subsystem is handing us a brand new PDO, for which we + (by means of INF registration) have been asked to provide a driver. + + We need to determine if we need to be in the driver stack for the device. + Create a functional device object to attach to the stack + Initialize that device object + Return status success. + + Remember: we can NOT actually send ANY non pnp IRPS to the given driver + stack, UNTIL we have received an IRP_MN_START_DEVICE. + +Arguments: + + DeviceObject - pointer to a device object. + + PhysicalDeviceObject - pointer to a device object created by the + underlying bus driver. + +Return Value: + + NT status code. + +--*/ +{ + NTSTATUS status = STATUS_SUCCESS; + PDEVICE_OBJECT deviceObject = NULL; + PDEVICE_EXTENSION deviceExtension; + + PAGED_CODE(); + + // + // Create a device object. + // + + status = IoCreateDevice (DriverObject, + sizeof (DEVICE_EXTENSION), + NULL, + FILE_DEVICE_UNKNOWN, + FILE_DEVICE_SECURE_OPEN, + FALSE, + &deviceObject); + + + if (!NT_SUCCESS (status)) { + // + // Either not enough memory to create a deviceobject or another + // deviceobject with the same name exits. This could happen + // if you install another instance of this device. + // + return status; + } + + deviceExtension = (PDEVICE_EXTENSION) deviceObject->DeviceExtension; + + // initialize the device wide spinlock + KeInitializeSpinLock(&deviceExtension->deviceSpinlock); + + deviceExtension->TopOfStack = IoAttachDeviceToDeviceStack ( + deviceObject, + PhysicalDeviceObject); + if (NULL == deviceExtension->TopOfStack) { + IoDeleteDevice(deviceObject); + return STATUS_DEVICE_REMOVED; + } + + IoInitializeRemoveLock (&deviceExtension->RemoveLock , + DRIVER_TAG, + 1, // MaxLockedMinutes + 5); // HighWatermark, this parameter is + // used only on checked build. + // + // Set the flag if the device is not holding a pagefile + // crashdump file or hibernate file. + // + + deviceObject->Flags |= DO_POWER_PAGABLE; + deviceObject->Flags |= DO_BUFFERED_IO; + + deviceExtension->DeviceObject = deviceObject; + INITIALIZE_PNP_STATE(deviceExtension); + + // + // We will keep list of all the toaster devices we + // interact with and protect the access to the list + // with a mutex. + // + InitializeListHead(&deviceExtension->DeviceListHead); + InitializeListHead(&deviceExtension->RecvQueueHead); + ExInitializeFastMutex (&deviceExtension->ListMutex); + + deviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: AddDevice: %p to %p->%p \n", deviceObject, + deviceExtension->TopOfStack, + PhysicalDeviceObject); + + // + // Register for TOASTER device interface changes. + // + // We will get an ARRIVAL callback for every TOASTER device that is + // started and a REMOVAL callback for every TOASTER that is removed + // + + status = IoRegisterPlugPlayNotification ( + EventCategoryDeviceInterfaceChange, + PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, + (PVOID)&GUID_DEVINTERFACE_TOASTER, + DriverObject, + (PDRIVER_NOTIFICATION_CALLBACK_ROUTINE) + Defect_ToastMon_PnpNotifyInterfaceChange, + (PVOID)deviceExtension, +#pragma warning(suppress: 6014) // handle is released with unregister call during remove IRP processing + &deviceExtension->NotificationHandle); + + if (!NT_SUCCESS(status)) { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Defect_Toastmon: RegisterPnPNotifiction failed: %x\n", status); + } + + RegisterForWMINotification(deviceExtension); + + return STATUS_SUCCESS; + +} + +NTSTATUS +Defect_ToastMon_CompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context + ) +/*++ + +Routine Description: + + The completion routine for plug & play irps that needs to be + processed first by the lower drivers. + +Arguments: + + DeviceObject - pointer to a device object. + + Irp - pointer to an I/O Request Packet. + + Context - pointer to an event object. + +Return Value: + + NT status code + +--*/ +{ + PKEVENT event; + + event = (PKEVENT) Context; + + UNREFERENCED_PARAMETER(DeviceObject); + + // + // If the lower driver didn't return STATUS_PENDING, we don't need to + // set the event because we won't be waiting on it. + // This optimization avoids grabbing the dispatcher lock and improves perf. + // + if (Irp->PendingReturned == TRUE) { +#pragma warning(suppress: 28183) + KeSetEvent(event, 0, FALSE); + } + // + // Allows the caller to reuse the IRP + // + return STATUS_MORE_PROCESSING_REQUIRED; +} + + +NTSTATUS +Defect_ToastMon_DispatchPnp ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +/*++ + +Routine Description: + + The plug and play dispatch routines. + + Most of these the driver will completely ignore. + In all cases it must pass the IRP to the next lower driver. + +Arguments: + + DeviceObject - pointer to a device object. + + Irp - pointer to an I/O Request Packet. + +Return Value: + + NT status code + +--*/ +{ + PIO_STACK_LOCATION irpStack; + NTSTATUS status = STATUS_SUCCESS; + KEVENT event; + PDEVICE_EXTENSION deviceExtension; + PLIST_ENTRY thisEntry; + PDEVICE_INFO list; + + + + + + deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; + + + + irpStack = IoGetCurrentIrpStackLocation(Irp); + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: %s IRP:0x%p \n", + PnPMinorFunctionString(irpStack->MinorFunction), Irp); + + + status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); + if (!NT_SUCCESS (status)) + { + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + } + + + + + + + + switch (irpStack->MinorFunction) { + case IRP_MN_START_DEVICE: + + // + // The device is starting. + // + // We cannot touch the device (send it any non pnp irps) until a + // start device has been passed down to the lower drivers. + // + IoCopyCurrentIrpStackLocationToNext(Irp); + KeInitializeEvent(&event, + NotificationEvent, + FALSE + ); + + IoSetCompletionRoutine(Irp, + (PIO_COMPLETION_ROUTINE)Defect_ToastMon_CompletionRoutine, + &event, + TRUE, + TRUE, + TRUE); // No need for Cancel + + status = IoCallDriver(deviceExtension->TopOfStack, Irp); + + if (STATUS_PENDING == status) { + KeWaitForSingleObject( + &event, + Executive, // Waiting for reason of a driver + KernelMode, // Waiting in kernel mode + FALSE, // No alert + NULL); // No timeout + status = Irp->IoStatus.Status; + } + + if (NT_SUCCESS(status)) { + + SET_NEW_PNP_STATE(deviceExtension, Started); + } + + // + // We must now complete the IRP, since we stopped it in the + // completion routine with STATUS_MORE_PROCESSING_REQUIRED. + // + IoCompleteRequest(Irp, IO_NO_INCREMENT); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; + + case IRP_MN_REMOVE_DEVICE: + + + // + // Wait for all outstanding requests to complete + // + IoReleaseRemoveLockAndWait(&deviceExtension->RemoveLock, Irp); + SET_NEW_PNP_STATE(deviceExtension, Deleted); + Irp->IoStatus.Status = STATUS_SUCCESS; + IoSkipCurrentIrpStackLocation(Irp); + status = IoCallDriver(deviceExtension->TopOfStack, Irp); + + // + // Unregister the interface notification + // + IoUnregisterPlugPlayNotification(deviceExtension->NotificationHandle); + // + // Close all the handles to the target device + // + ExAcquireFastMutex (&deviceExtension->ListMutex); + while(!IsListEmpty(&deviceExtension->DeviceListHead)) + { + thisEntry = RemoveHeadList(&deviceExtension->DeviceListHead); + list = CONTAINING_RECORD(thisEntry, DEVICE_INFO, ListEntry); + Defect_ToastMon_CloseTargetDevice(list); + } + ExReleaseFastMutex (&deviceExtension->ListMutex); + + UnregisterForWMINotification(deviceExtension); + + IoDetachDevice(deviceExtension->TopOfStack); + IoDeleteDevice(DeviceObject); + + return status; + + + case IRP_MN_QUERY_STOP_DEVICE: + SET_NEW_PNP_STATE(deviceExtension, StopPending); + status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + + // + // Check to see whether you have received cancel-stop + // without first receiving a query-stop. This could happen if someone + // above us fails a query-stop and passes down the subsequent + // cancel-stop. + // + + if (StopPending == deviceExtension->DevicePnPState) + { + // + // We did receive a query-stop, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(deviceExtension); + } + status = STATUS_SUCCESS; // We must not fail this IRP. + break; + + case IRP_MN_STOP_DEVICE: + SET_NEW_PNP_STATE(deviceExtension, Stopped); + status = STATUS_SUCCESS; + break; + + case IRP_MN_QUERY_REMOVE_DEVICE: + + SET_NEW_PNP_STATE(deviceExtension, RemovePending); + status = STATUS_SUCCESS; + break; + + case IRP_MN_SURPRISE_REMOVAL: + + + SET_NEW_PNP_STATE(deviceExtension, SurpriseRemovePending); + ToasterDrvCancelQueuedReadIrps(deviceExtension); + status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_REMOVE_DEVICE: + + // + // Check to see whether you have received cancel-remove + // without first receiving a query-remove. This could happen if + // someone above us fails a query-remove and passes down the + // subsequent cancel-remove. + // + + if (RemovePending == deviceExtension->DevicePnPState) + { + // + // We did receive a query-remove, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(deviceExtension); + } + status = STATUS_SUCCESS; // We must not fail this IRP. + break; + + + default: + // + // If you don't handle any IRP you must leave the + // status as is. + // + status = Irp->IoStatus.Status; + + break; + } + + // + // Pass the IRP down and forget it. + // + Irp->IoStatus.Status = status; + IoSkipCurrentIrpStackLocation (Irp); + status = IoCallDriver (deviceExtension->TopOfStack, Irp); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; +} + +NTSTATUS +Defect_ToastMon_DispatchPower( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +/*++ + +Routine Description: + + This routine is the dispatch routine for power irps. + Does nothing except forwarding the IRP to the next device + in the stack. + +Arguments: + + DeviceObject - Pointer to the device object. + + Irp - Pointer to the request packet. + +Return Value: + + NT Status code +--*/ +{ + PDEVICE_EXTENSION deviceExtension; + PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp); + POWER_STATE_TYPE powerType = stack->Parameters.Power.Type; + UCHAR minorFunction = stack->MinorFunction; + NTSTATUS status= STATUS_SUCCESS; + + deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; + + status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); + if (!NT_SUCCESS (status)) { + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + } + + switch( minorFunction ) + { + case IRP_MN_QUERY_POWER: + PoStartNextPowerIrp(Irp); + IoSkipCurrentIrpStackLocation(Irp); + status=PoCallDriver(deviceExtension->TopOfStack, Irp); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; + break; + case IRP_MN_SET_POWER: + switch( powerType ) + { + case DevicePowerState: + PoStartNextPowerIrp(Irp); + IoSkipCurrentIrpStackLocation(Irp); + status=PoCallDriver(deviceExtension->TopOfStack, Irp); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; + break; + case SystemPowerState: + PoStartNextPowerIrp(Irp); + IoSkipCurrentIrpStackLocation(Irp); + status=PoCallDriver(deviceExtension->TopOfStack, Irp); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; + break; + default: + status = Irp->IoStatus.Status; + PoStartNextPowerIrp(Irp); + IoSkipCurrentIrpStackLocation(Irp); + status=PoCallDriver(deviceExtension->TopOfStack, Irp); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; + } + + break; + default: + + status = Irp->IoStatus.Status; + PoStartNextPowerIrp(Irp); + IoSkipCurrentIrpStackLocation(Irp); + status=PoCallDriver(deviceExtension->TopOfStack, Irp); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; + } +} + +NTSTATUS +Defect_ToastMon_DispatchSystemControl( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +/*++ + +Routine Description: + + This routine is the dispatch routine for WMI irps. + Does nothing except forwarding the IRP to the next device + in the stack. + +Arguments: + + DeviceObject - Pointer to the device object. + + Irp - Pointer to the request packet. + +Return Value: + + NT Status code +--*/ +{ + PDEVICE_EXTENSION deviceExtension; + NTSTATUS status= STATUS_SUCCESS; + + deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; + status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); + if (!NT_SUCCESS (status)) + { + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + } + IoSkipCurrentIrpStackLocation(Irp); + status=IoCallDriver(deviceExtension->TopOfStack, Irp); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; +} + + +VOID +Defect_ToastMon_Unload( + __in PDRIVER_OBJECT DriverObject + ) +/*++ + +Routine Description: + + Free all the allocated resources, etc. + +Arguments: + + DriverObject - pointer to a driver object. + +Return Value: + + VOID. + +--*/ +{ + UNREFERENCED_PARAMETER(DriverObject); + + PAGED_CODE (); + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Defect_ToastMon_Unload\n")); + + return; +} + +NTSTATUS +Defect_ToastMon_Dispatch( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) + +/*++ + +Routine Description: + This routine is the dispatch handler for the driver. It is responsible + for processing the IRPs. + +Arguments: + + pDO - Pointer to device object. + + Irp - Pointer to the current IRP. + +Return Value: + + STATUS_SUCCESS if the IRP was processed successfully, otherwise an error + indicating the reason for failure. + +--*/ + +{ + PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; + PIO_STACK_LOCATION irpStack; + NTSTATUS status; + + Irp->IoStatus.Information = 0; + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Defect_ToastMon_Dispatch\n")); + + status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); + if (!NT_SUCCESS (status)) { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + } + + if (NotStarted == deviceExtension->DevicePnPState) + { + // + // We fail all the IRPs that arrive before the device is started. + // + Irp->IoStatus.Status = status = STATUS_DEVICE_NOT_READY; + IoCompleteRequest(Irp, IO_NO_INCREMENT ); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; + } + + irpStack = IoGetCurrentIrpStackLocation(Irp); + + // Dispatch based on major fcn code. + + switch (irpStack->MajorFunction) + { + case IRP_MJ_CREATE: + case IRP_MJ_CLOSE: + // We don't need any special processing on open/close so we'll + // just return success. + status = STATUS_SUCCESS; + break; + + case IRP_MJ_DEVICE_CONTROL: + default: + status = STATUS_NOT_IMPLEMENTED; + break; + } + + // + // We're done with I/O request. Record the status of the I/O action. + // + Irp->IoStatus.Status = status; + IoCompleteRequest(Irp, IO_NO_INCREMENT ); + IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); + return status; +} + + +NTSTATUS +#pragma warning(suppress: 28208) +Defect_ToastMon_PnpNotifyInterfaceChange( + PDEVICE_INTERFACE_CHANGE_NOTIFICATION NotificationStruct, + PVOID Context + ) +/*++ + +Routine Description: + + This routine is the PnP "interface change notification" callback routine. + + This gets called on a Toaster triggered device interface arrival or + removal. + - Interface arrival corresponds to a Toaster device being STARTED + - Interface removal corresponds to a Toaster device being REMOVED + + On arrival: + - Get the target deviceobject pointer by using the symboliclink. + - Get the PDO of the target device, in case you need to set the + device parameters of the target device. + - Regiter for EventCategoryTargetDeviceChange notification on the fileobject + so that you can cleanup whenever associated device is removed. + + On removal: + - This callback is a NO-OP for interface removal because we + for PnP EventCategoryTargetDeviceChange callbacks and + use that callback to clean up when their associated toaster device goes + away. + +Arguments: + + NotificationStruct - Structure defining the change. + + Context - pointer to the device extension. + (supplied as the "context" when we + registered for this callback) +Return Value: + + STATUS_SUCCESS - always, even if something goes wrong + +--*/ +{ + NTSTATUS status = STATUS_SUCCESS; + PDEVICE_INFO list = NULL; + PDEVICE_EXTENSION deviceExtension = Context; + PUNICODE_STRING symbolicLinkName; + + PAGED_CODE(); + + symbolicLinkName = NotificationStruct->SymbolicLinkName; + + // + // Verify that interface class is a toaster device interface. + // + // Any other InterfaceClassGuid is an error, but let it go since + // it is not fatal to the machine. + // + + if ( !IsEqualGUID( (LPGUID)&(NotificationStruct->InterfaceClassGuid), + (LPGUID)&GUID_DEVINTERFACE_TOASTER) ) { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, ("Defect_Toastmon: Bad interfaceClassGuid in Defect_ToastMon_PnpNotifyInterfaceChange\n")); + return STATUS_SUCCESS; + } + + // + // Check the callback event. + // + if (IsEqualGUID( (LPGUID)&(NotificationStruct->Event), + (LPGUID)&GUID_DEVICE_INTERFACE_ARRIVAL )) { + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Arrival Notification in Defect_ToastMon_PnpNotifyInterfaceChange\n")); + + // + // Allocate memory for the deviceinfo + // + + list = ExAllocatePoolWithTag(PagedPool,sizeof(DEVICE_INFO),DRIVER_TAG); + if (list == NULL) + { + goto Error; + } + RtlZeroMemory(list, sizeof(DEVICE_INFO)); + + // + // Copy the symbolic link + // + list->SymbolicLink.MaximumLength = symbolicLinkName->Length + + sizeof(UNICODE_NULL); + list->SymbolicLink.Length = symbolicLinkName->Length; + list->SymbolicLink.Buffer = ExAllocatePoolWithTag ( + PagedPool, + list->SymbolicLink.MaximumLength, + DRIVER_TAG); + if (list->SymbolicLink.Buffer == NULL) + { + goto Error; + } + RtlCopyUnicodeString(&list->SymbolicLink,symbolicLinkName); + + list->DeviceExtension = deviceExtension; + InitializeListHead(&list->ListEntry); + + // + // Warning: It's not recommended to open the targetdevice + // from a pnp notification callback routine, because if + // the target device initiates any kind of PnP action as + // a result of this open, the PnP manager could deadlock. + // You should queue a workitem to do that. + // For example, SWENUM devices in conjunction with KS + // initiate an enumeration of a device when you do the + // open on the device interface. + // For simplicity, I'm opening the device here, because + // I know the toaster function driver doesn't trigger + // any pnp action. + // For an example on how to queue a workitem, take a look + // at ToasterQueuePassiveLevelCallback in func\featured2\ + // wake.c file. + // + + status = Defect_ToastMon_OpenTargetDevice(list); + if (!NT_SUCCESS( status)) { + goto Error; + } + + // + // Finally queue the Deviceinfo. + // + ExAcquireFastMutex (&deviceExtension->ListMutex); + InsertTailList(&deviceExtension->DeviceListHead, &list->ListEntry); + ExReleaseFastMutex (&deviceExtension->ListMutex); + } + else + { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Removal Interface Notification\n")); + } + return STATUS_SUCCESS; + + Error: + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Defect_Toastmon: PnPNotifyInterfaceChange failed: %x\n", status); + Defect_ToastMon_CloseTargetDevice(list); + return STATUS_SUCCESS; +} + +NTSTATUS +#pragma warning(suppress: 28208) +Defect_ToastMon_PnpNotifyDeviceChange( + PTARGET_DEVICE_REMOVAL_NOTIFICATION NotificationStruct, + PVOID Context + ) +/*++ + +Routine Description: + + This routine is the PnP "Device Change Notification" callback routine. + + This gets called on a when the target is query or surprise removed. + + - Interface arrival corresponds to a toaster device being STARTed + - Interface removal corresponds to a toaster device being REMOVEd + + On Query_Remove or Remove_Complete: + - Find the targetdevice from the list by matching the fileobject pointers. + - Dereference the FileObject (this generates a close to the target device) + - Free the resources. + +Arguments: + + NotificationStruct - Structure defining the change. + + Context - pointer to the device extension. + (supplied as the "context" when we + registered for this callback) +Return Value: + + STATUS_SUCCESS - always, even if something goes wrong + +--*/ +{ + NTSTATUS status; + PDEVICE_INFO list = Context; + PDEVICE_EXTENSION deviceExtension = list->DeviceExtension; + + PAGED_CODE(); + + // + // if the event is query_remove + // + if ( (IsEqualGUID( (LPGUID)&(NotificationStruct->Event), + (LPGUID)&GUID_TARGET_DEVICE_QUERY_REMOVE))){ + PTARGET_DEVICE_REMOVAL_NOTIFICATION removalNotification; + +#pragma warning(suppress: 28930) // used in assert + removalNotification = + (PTARGET_DEVICE_REMOVAL_NOTIFICATION)NotificationStruct; + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Device Removal (query remove) Notification\n")); + + ASSERT(list->FileObject == removalNotification->FileObject); + // + // Deref the fileobject so that we don't prevent + // the target device from being removed. + // + ObDereferenceObject(list->FileObject); + list->FileObject = NULL; + // + // Deref the PDO to compensate for the reference taken + // by the bus driver when it returned the PDO in response + // to the query-device-relations (target-relations). + // + ObDereferenceObject(list->Pdo); + list->Pdo = NULL; + // + // We will defer freeing other resources to remove-complete + // notification because if query-remove is vetoed, we would reopen + // the device in remove-cancelled notification. + // + + } else if (IsEqualGUID( (LPGUID)&(NotificationStruct->Event), + (LPGUID)&GUID_TARGET_DEVICE_REMOVE_COMPLETE) ) { + // + // Device is gone. Let us cleanup our resources. + // + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Device Removal (remove complete) Notification\n")); + + ExAcquireFastMutex (&deviceExtension->ListMutex); + RemoveEntryList(&list->ListEntry); + ExReleaseFastMutex (&deviceExtension->ListMutex); + + Defect_ToastMon_CloseTargetDevice(list); + + } else if ( IsEqualGUID( (LPGUID)&(NotificationStruct->Event), + (LPGUID)&GUID_TARGET_DEVICE_REMOVE_CANCELLED) ) { + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Device Removal (remove cancelled) Notification\n")); + + // Should be null because we cleared it in query-remove + + ASSERT(!list->FileObject); + ASSERT(!list->Pdo); + + // + // Unregister the previous notification because when we reopen + // the device we will register again on the new fileobject. + // + IoUnregisterPlugPlayNotification(list->NotificationHandle); + + // + // Reopen the device + // +#pragma warning(suppress: 28183) + status = Defect_ToastMon_OpenTargetDevice(list); + if (!NT_SUCCESS (status)) { + // + // Couldn't reopen the device. Cleanup. + // + ExAcquireFastMutex (&deviceExtension->ListMutex); + RemoveEntryList(&list->ListEntry); + ExReleaseFastMutex (&deviceExtension->ListMutex); + + Defect_ToastMon_CloseTargetDevice(list); + } + + } else { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Unknown Device Notification\n")); + } + + return STATUS_SUCCESS; +} + +NTSTATUS +Defect_ToastMon_GetTargetDevicePdo( + __in PDEVICE_OBJECT DeviceObject, + __out PDEVICE_OBJECT *PhysicalDeviceObject + ) +/*++ + +Routine Description: + + This builds and send a pnp irp to get the PDO a device. + +Arguments: + + DeviceObject - This is the top of the device in the device stack + the irp is to be sent to. + + PhysicalDeviceObject - Address where the PDO pointer is returned + +Return Value: + + NT status code +--*/ +{ + + KEVENT event; + NTSTATUS status; + PIRP irp; + IO_STATUS_BLOCK ioStatusBlock; + PIO_STACK_LOCATION irpStack; + PDEVICE_RELATIONS deviceRelations; + + PAGED_CODE(); + + KeInitializeEvent( &event, NotificationEvent, FALSE ); + + irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, + DeviceObject, + NULL, + 0, + NULL, + &event, + &ioStatusBlock ); + + if (irp == NULL) { + status = STATUS_INSUFFICIENT_RESOURCES; + goto End; + } + + irpStack = IoGetNextIrpStackLocation( irp ); + irpStack->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS; + irpStack->Parameters.QueryDeviceRelations.Type = TargetDeviceRelation; + + // + // Initialize the status to error in case the bus driver decides not to + // set it correctly. + // + + irp->IoStatus.Status = STATUS_NOT_SUPPORTED ; + + + status = IoCallDriver( DeviceObject, irp ); + + if (status == STATUS_PENDING) { + + KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); + status = ioStatusBlock.Status; + } + + if (NT_SUCCESS( status)) { + deviceRelations = (PDEVICE_RELATIONS)ioStatusBlock.Information; + ASSERT(deviceRelations); + // + // You must dereference the PDO when it's no longer + // required. + // + *PhysicalDeviceObject = deviceRelations->Objects[0]; + ExFreePool(deviceRelations); + } + +End: + return status; + +} + +NTSTATUS +Defect_ToastMon_OpenTargetDevice( + __in PDEVICE_INFO List + ) +/*++ + +Routine Description: + + Open the target device, get the PDO and register + for TargetDeviceChange notification on the fileobject. + +Arguments: + + +Return Value: + + NT status code +--*/ +{ + NTSTATUS status; + + PAGED_CODE(); + + // + // Get a pointer to and open a handle to the toaster device + // + + status = IoGetDeviceObjectPointer(&List->SymbolicLink, + STANDARD_RIGHTS_ALL, + &List->FileObject, + &List->TargetDeviceObject); + if ( !NT_SUCCESS(status) ) { + goto Error; + } + + // + // Register for TargerDeviceChange notification on the fileobject. + // + status = IoRegisterPlugPlayNotification ( + EventCategoryTargetDeviceChange, + 0, + (PVOID)List->FileObject, + List->DeviceExtension->DeviceObject->DriverObject, + (PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)Defect_ToastMon_PnpNotifyDeviceChange, + (PVOID)List, + &List->NotificationHandle); + if (!NT_SUCCESS (status)) { + goto Error; + } + + // + // Get the PDO. This is required in case you need to set + // the target device's parameters using IoOpenDeviceRegistryKey + // + status = Defect_ToastMon_GetTargetDevicePdo(List->TargetDeviceObject, + &List->Pdo); + if (!NT_SUCCESS (status)) { + goto Error; + } + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: Target device Toplevel DO:0x%p and PDO: 0x%p\n", + List->TargetDeviceObject, List->Pdo); +Error: + + return status; +} + + +__drv_arg(List->SymbolicLink.Buffer, __drv_freesMem(SymLink)) +VOID +#pragma warning(suppress: 6014) +Defect_ToastMon_CloseTargetDevice( + __in __drv_freesMem(List) PDEVICE_INFO List + ) +/*++ + +Routine Description: + + Close all the handles and free the list. + +Arguments: + + +Return Value: + VOID +--*/ +{ + PAGED_CODE(); + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: Closing handle to 0x%p\n", List->TargetDeviceObject); + if (List->FileObject){ + ObDereferenceObject(List->FileObject); + } + if (List->NotificationHandle) { + IoUnregisterPlugPlayNotification(List->NotificationHandle); + } + if (List->Pdo) { + ObDereferenceObject(List->Pdo); + } + RtlFreeUnicodeString(&List->SymbolicLink); + ExFreePool(List); +} + +PCHAR +PnPMinorFunctionString ( + __in UCHAR MinorFunction +) +{ + switch (MinorFunction) + { + case IRP_MN_START_DEVICE: + return "IRP_MN_START_DEVICE"; + case IRP_MN_QUERY_REMOVE_DEVICE: + return "IRP_MN_QUERY_REMOVE_DEVICE"; + case IRP_MN_REMOVE_DEVICE: + return "IRP_MN_REMOVE_DEVICE"; + case IRP_MN_CANCEL_REMOVE_DEVICE: + return "IRP_MN_CANCEL_REMOVE_DEVICE"; + case IRP_MN_STOP_DEVICE: + return "IRP_MN_STOP_DEVICE"; + case IRP_MN_QUERY_STOP_DEVICE: + return "IRP_MN_QUERY_STOP_DEVICE"; + case IRP_MN_CANCEL_STOP_DEVICE: + return "IRP_MN_CANCEL_STOP_DEVICE"; + case IRP_MN_QUERY_DEVICE_RELATIONS: + return "IRP_MN_QUERY_DEVICE_RELATIONS"; + case IRP_MN_QUERY_INTERFACE: + return "IRP_MN_QUERY_INTERFACE"; + case IRP_MN_QUERY_CAPABILITIES: + return "IRP_MN_QUERY_CAPABILITIES"; + case IRP_MN_QUERY_RESOURCES: + return "IRP_MN_QUERY_RESOURCES"; + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + return "IRP_MN_QUERY_RESOURCE_REQUIREMENTS"; + case IRP_MN_QUERY_DEVICE_TEXT: + return "IRP_MN_QUERY_DEVICE_TEXT"; + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: + return "IRP_MN_FILTER_RESOURCE_REQUIREMENTS"; + case IRP_MN_READ_CONFIG: + return "IRP_MN_READ_CONFIG"; + case IRP_MN_WRITE_CONFIG: + return "IRP_MN_WRITE_CONFIG"; + case IRP_MN_EJECT: + return "IRP_MN_EJECT"; + case IRP_MN_SET_LOCK: + return "IRP_MN_SET_LOCK"; + case IRP_MN_QUERY_ID: + return "IRP_MN_QUERY_ID"; + case IRP_MN_QUERY_PNP_DEVICE_STATE: + return "IRP_MN_QUERY_PNP_DEVICE_STATE"; + case IRP_MN_QUERY_BUS_INFORMATION: + return "IRP_MN_QUERY_BUS_INFORMATION"; + case IRP_MN_DEVICE_USAGE_NOTIFICATION: + return "IRP_MN_DEVICE_USAGE_NOTIFICATION"; + case IRP_MN_SURPRISE_REMOVAL: + return "IRP_MN_SURPRISE_REMOVAL"; + case IRP_MN_QUERY_LEGACY_BUS_INFORMATION: + return "IRP_MN_QUERY_LEGACY_BUS_INFORMATION"; + default: + return "unknown_pnp_irp"; + } +} + + +NTSTATUS +Defect_ToastMon_DispatchRead ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +/*++ + +Routine Description: + + Performs read from the NIC. + +Arguments: + + FdoData - pointer to a FDO_DATA structure + + Irp - pointer to an I/O Request Packet. + +Return Value: + + NT status code + + +--*/ + +{ + NTSTATUS status; + KIRQL oldIrql; + BOOLEAN CancelIrp; + PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Defect_ToastMon_DispatchRead \n")); + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Attempting to acquire remove lock\n")); + status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); + if (!NT_SUCCESS (status)) + { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, ("Defect_Toastmon: Acquire remove lock failed; the device is already removed\n")); + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + } + + + KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); + CancelIrp = FALSE; + // + // Since we are queueing the IRP, we should set the cancel routine. + // + IoSetCancelRoutine(Irp, Defect_ToastmonCancelRoutineForReadIrp); + + // + // Let us check to see if the IRP is cancelled at this point. + // + if(Irp->Cancel!=FALSE) + { + // + // This irp has been marked cancelled. This may have occured + // before or after we set the cancel routine. If it occured + // before, our cancel routine will not be called and we must + // cancel the irp here. If it was cancelled after we set the + // cancel routine, the thread that is cancelling the irp will + // call our cancel routine. We determine this by setting the + // cancel routine to NULL and seeing if the original cancel + // routine is still there. + // + + + status = STATUS_CANCELLED; + if (IoSetCancelRoutine(Irp, NULL) != NULL) + { + CancelIrp = TRUE; + } + } + else + { + // + // Queue the IRP and return status pending. + // + IoMarkIrpPending(Irp); + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Defect_ToastMon_DispatchRead - insert the Read Irp into the Recieve Queue and mark IRP as pending \n ")); + InsertTailList(&deviceExtension->RecvQueueHead, + &Irp->Tail.Overlay.ListEntry); + status = STATUS_PENDING; + // + // The IRP shouldn't be accessed after the lock is released + // It could be grabbed by another thread or the cancel routine + // is running. + // + } + + KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); + + if (CancelIrp != FALSE) + { + Irp->IoStatus.Status = STATUS_CANCELLED; + Irp->IoStatus.Information = 0; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Release the removelock \n")); + IoReleaseRemoveLock (&deviceExtension->RemoveLock, Irp); + } + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Exiting Defect_ToastMon_DispatchRead \n")); + return status; +} + +VOID +Defect_ToastmonCancelRoutineForReadIrp ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) + +/*++ + +Routine Description: + + The cancel routine for IRPs waiting in the RecvQueue. + The cancel spin lock is already acquired when this routine is called. + +Arguments: + + DeviceObject - pointer to the device object. + + Irp - pointer to the IRP to be cancelled. + + +Return Value: + + VOID. + +--*/ +{ + PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; + KIRQL oldIrql; + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Canceling Read Request inside Defect_ToastmonCancelRoutineForReadIrp\n")); + + // + // Release the cancel spin lock and pass Irp->CancelIrql to + // restore the original Irql prior to the call to IoAcquireCancelSpinLock + // + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Releasing the cancel spinlock\n")); + IoReleaseCancelSpinLock(Irp->CancelIrql); + + // + // Acquire the local spinlock and raise the Irql to DISPATCH_LEVEL + // + + KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); + + // + // Remove the cancelled IRP from queue and release the queue lock. + // + RemoveEntryList(&Irp->Tail.Overlay.ListEntry); + + // + // Release the spinlock and restore the old Irql + // + KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); + + // + // Complete the request with STATUS_CANCELLED. + // + + Irp->IoStatus.Status = STATUS_CANCELLED; + Irp->IoStatus.Information = 0; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Releasing the removelock\n")); + IoReleaseRemoveLock (&deviceExtension->RemoveLock, Irp); + return; + +} + + +VOID +#pragma warning(suppress: 28167) +ToasterDrvCancelQueuedReadIrps( + PDEVICE_EXTENSION deviceExtension + ) +/*++ + +Routine Description: + + Cancel all the read IRPs waiting in the RecvQueue. + +Arguments: + + FdoData - Pointer to the device extension. + +Return Value: + + None + +--*/ +{ + KIRQL oldIrql; + PIRP irp; + PLIST_ENTRY listEntry; + ULONG MajorVersion; + ULONG MinorVersion; + ULONG BuildNumber; + BOOLEAN ListEmpty = FALSE; + + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Canceling queued IRPs inside ToasterDrvCancelQueuedReadIrps")); + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Acquire the RecvQueueLock before checking the RecvQueue as cancellation may also run at the same time")); + KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); + ListEmpty=IsListEmpty(&deviceExtension->RecvQueueHead); + if(ListEmpty) + { + // injected defect for IrqlPsPassive SDV and DV rule +#pragma warning(suppress: 28159) // this is the injected defect +#pragma warning(suppress: 28121) + PsGetVersion(&MajorVersion, &MinorVersion, &BuildNumber, NULL); + KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); + } + else + { + while(!ListEmpty) + { + // + // Remove a request from the queue. + // + listEntry = RemoveHeadList(&deviceExtension->RecvQueueHead); + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Extracting IRPs from the list.")); + irp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry); + // + // Set the cancel routine to NULL. This is an atomic operation. + // + if (IoSetCancelRoutine(irp, NULL)) + { + // injected defect for IrqlPsPassive SDV and DV rule +#pragma warning(suppress: 28159) // this is the injected defect +#pragma warning(suppress: 28121) + PsGetVersion(&MajorVersion, &MinorVersion, &BuildNumber, NULL); + irp->IoStatus.Status = STATUS_CANCELLED; + irp->IoStatus.Information = 0; + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Cancelling the queued IRPs from the list.")); + KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); + // do not complete the IRP while holding the lock + IoCompleteRequest(irp, IO_NO_INCREMENT); + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Releasing the removelock.")); + IoReleaseRemoveLock (&deviceExtension->RemoveLock, irp); + KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); + } + else + { + // + // Cancel rotuine is running. Leave the irp alone. + // + irp = NULL; + } + ListEmpty=IsListEmpty(&deviceExtension->RecvQueueHead); + if(ListEmpty) + { + KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); + } + } + } +} \ No newline at end of file diff --git a/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.h b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.h new file mode 100644 index 00000000..c70d53d8 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.h @@ -0,0 +1,175 @@ +/*++ + +Copyright (c) 1990-2000 Microsoft Corporation, All Rights Reserved + +Module Name: + + defect_toastmon.h + +Abstract: + + +Environment: + + Kernel mode + +Revision History: + +--*/ +#include +#include + +#if !defined(__TOASTMON_H__) +#define __TOASTMON_H__ + +#define DRIVER_TAG 'NOMT' + +#define INITIALIZE_PNP_STATE(_Data_) \ + (_Data_)->DevicePnPState = NotStarted;\ + (_Data_)->PreviousPnPState = NotStarted; + +#define SET_NEW_PNP_STATE(_Data_, _state_) \ + (_Data_)->PreviousPnPState = (_Data_)->DevicePnPState;\ + (_Data_)->DevicePnPState = (_state_); + +#define RESTORE_PREVIOUS_PNP_STATE(_Data_) \ + (_Data_)->DevicePnPState = (_Data_)->PreviousPnPState;\ +// +// These are the states a PDO or FDO transition upon +// receiving a specific PnP Irp. Refer to the PnP Device States +// diagram in DDK documentation for better understanding. +// + +typedef enum _DEVICE_PNP_STATE { + + NotStarted = 0, // Not started yet + Started, // Device has received the START_DEVICE IRP + StopPending, // Device has received the QUERY_STOP IRP + Stopped, // Device has received the STOP_DEVICE IRP + RemovePending, // Device has received the QUERY_REMOVE IRP + SurpriseRemovePending, // Device has received the SURPRISE_REMOVE IRP + Deleted, // Device has received the REMOVE_DEVICE IRP + UnKnown // Unknown state + +} DEVICE_PNP_STATE; + + +typedef struct _DEVICE_EXTENSION { + PDEVICE_OBJECT DeviceObject; // The Defect_ToastMon device object. + PDEVICE_OBJECT TopOfStack; // The top of the stack + DEVICE_PNP_STATE DevicePnPState; // Track PnP state + DEVICE_PNP_STATE PreviousPnPState; + IO_REMOVE_LOCK RemoveLock; // + KSPIN_LOCK deviceSpinlock; // device wide spinlock + PVOID NotificationHandle; // Interface notification handle + LIST_ENTRY DeviceListHead; // List to queue the target device info + FAST_MUTEX ListMutex; // Synchronize access to DeviceList + PVOID WMIDeviceArrivalNotificationObject; + LIST_ENTRY RecvQueueHead; + KSPIN_LOCK RecvQueueLock; + KSPIN_LOCK RcvLock; + KSPIN_LOCK ToasterpCancelSpinLock; +} DEVICE_EXTENSION, *PDEVICE_EXTENSION; + + +typedef struct _DEVICE_INFO { + PDEVICE_EXTENSION DeviceExtension; // Our FDO device extension + PDEVICE_OBJECT TargetDeviceObject; // Toplevel deviceobject of the target device + PDEVICE_OBJECT Pdo; // It's PDO + PFILE_OBJECT FileObject; + PVOID NotificationHandle; //Device change notification handle + LIST_ENTRY ListEntry; // Entry to chain to the listhead + UNICODE_STRING SymbolicLink; +} DEVICE_INFO, *PDEVICE_INFO; + + +#if DBG +#define DebugPrint(_x_) \ + DbgPrint ("Defect_ToastMon:"); \ + DbgPrint _x_; + +#define TRAP() DbgBreakPoint() + +#else +#define DebugPrint(_x_) +#define TRAP() +#endif + + +/********************* function prototypes ***********************************/ +// + +DRIVER_INITIALIZE DriverEntry; + +DRIVER_ADD_DEVICE Defect_ToastMon_AddDevice; + +__drv_dispatchType(IRP_MJ_CREATE) +__drv_dispatchType(IRP_MJ_CLOSE) +__drv_dispatchType(IRP_MJ_DEVICE_CONTROL) +DRIVER_DISPATCH Defect_ToastMon_Dispatch; + +__drv_dispatchType(IRP_MJ_PNP) +DRIVER_DISPATCH Defect_ToastMon_DispatchPnp; + +__drv_dispatchType(IRP_MJ_POWER) +DRIVER_DISPATCH Defect_ToastMon_DispatchPower; + +DRIVER_DISPATCH Defect_ToastMon_StartDevice; + +__drv_dispatchType(IRP_MJ_SYSTEM_CONTROL) +DRIVER_DISPATCH Defect_ToastMon_DispatchSystemControl; + +DRIVER_UNLOAD Defect_ToastMon_Unload; + +IO_COMPLETION_ROUTINE Defect_ToastMon_CompletionRoutine; + +DRIVER_NOTIFICATION_CALLBACK_ROUTINE Defect_ToastMon_PnpNotifyDeviceChange; + +DRIVER_NOTIFICATION_CALLBACK_ROUTINE Defect_ToastMon_PnpNotifyInterfaceChange; + +NTSTATUS +Defect_ToastMon_GetTargetDevicePdo( + __in PDEVICE_OBJECT DeviceObject, + __out PDEVICE_OBJECT* PhysicalDeviceObject + ); + +NTSTATUS +Defect_ToastMon_OpenTargetDevice( + __in PDEVICE_INFO List + ); + +__drv_arg(List->SymbolicLink.Buffer, __drv_freesMem(SymLink)) +VOID +Defect_ToastMon_CloseTargetDevice( + __in __drv_freesMem(List) PDEVICE_INFO List + ); + +PCHAR +PnPMinorFunctionString ( + __in UCHAR MinorFunction +); + +NTSTATUS +RegisterForWMINotification( + __in PDEVICE_EXTENSION DeviceExt + ); + +VOID +UnregisterForWMINotification( + __in PDEVICE_EXTENSION DeviceExt +); + +FWMI_NOTIFICATION_CALLBACK WmiNotificationCallback; + + +DRIVER_CANCEL Defect_ToastmonCancelRoutineForReadIrp; + +__drv_dispatchType(IRP_MJ_READ) +DRIVER_DISPATCH Defect_ToastMon_DispatchRead; + +VOID +ToasterDrvCancelQueuedReadIrps( + PDEVICE_EXTENSION deviceExtension + ); +#endif + diff --git a/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.inf b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.inf new file mode 100644 index 00000000..ae8f3e5a --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.inf @@ -0,0 +1,89 @@ +;/*++ +; +;Copyright (c) 1990-2015 Microsoft Corporation All rights Reserved +; +;Module Name: +; +; Defect_ToastMon.INF +; +;Abstract: +; INF file for installing sample buggy toastmon driver +; +;--*/ + +[Version] +Signature="$WINDOWS NT$" +Class=System +ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} +Provider="Sample Provider" +DriverVer=07/29/2015,10.0.0.0 +CatalogFile=Defect_Toastmon.cat + +[DestinationDirs] +DefaultDestDir = 12 + + +; ================= Device Install section ===================== + +[Manufacturer] +%ManufacturerString%=MSFT,NTx86, NTamd64, NTARM, NTARM64 + +; For XP and later +[MSFT.NTx86] +%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon + +[MSFT.NTARM] +%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon + +[MSFT.NTARM64] +%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon + +[MSFT.NTamd64] +%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon + +[Defect_ToastMon_Inst.NT] +CopyFiles=Defect_ToastMon.CopyFiles + +[Defect_ToastMon.CopyFiles] +defect_toastmon.sys + +[Defect_ToastMon_Inst.NT.Services] +AddService=Defect_ToastMon,0x00000002,Defect_ToastMon_Service + +[Defect_ToastMon_Service] +DisplayName = %Defect_ToastMon.SVCDESC% +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 1 ; SERVICE_SYSTEM_START +ErrorControl = 1 ; SERVICE_ERROR_NORMAL +ServiceBinary = %12%\defect_toastmon.sys + +[DeviceInstall32] +AddDevice=ROOT\Samples\0001,,ToastMonbuggy + +[ToastMonBuggy] +HardwareIds=root\defect_toastmon + +; ================= Source Media Section ===================== + +[SourceDisksFiles] +defect_toastmon.sys=1 + +[SourceDisksNames.x86] +1 = %DISK_NAME%,,, + +[SourceDisksNames.amd64] +1 = %DISK_NAME%,,, + +[SourceDisksNames.ARM] +1 = %DISK_NAME%,,, + +[SourceDisksNames.ARM64] +1 = %DISK_NAME%,,, + +[Strings] +ManufacturerString = "Sample Manufacturer" +ClassName = "Sample Drivers" +Defect_ToastMon.SVCDESC = "Sample ToastMon Buggy Service" +Defect_ToastMon.DRVDESC = "Sample ToastMon Buggy Driver" +DISK_NAME = "Toastmon Install Disk" + diff --git a/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.rc b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.rc new file mode 100644 index 00000000..6ae8a2d6 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/defect_toastmon.rc @@ -0,0 +1,12 @@ +#include + +#include + +#define VER_FILETYPE VFT_DRV +#define VER_FILESUBTYPE VFT2_DRV_SYSTEM +#define VER_FILEDESCRIPTION_STR "DV Defect-Injected Toastmon Sample" +#define VER_INTERNALNAME_STR "defect_toastmon.sys" + +#include "common.ver" + + diff --git a/tools/dv/samples/DV-FailDriver-WDM/driver.h b/tools/dv/samples/DV-FailDriver-WDM/driver.h new file mode 100644 index 00000000..0fb84d92 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/driver.h @@ -0,0 +1,118 @@ +/*++ +Copyright (c) 1990-2015 Microsoft Corporation All Rights Reserved + +Module Name: + + driver.h + +Abstract: + + This module contains the common declarations for the + bus, function and filter drivers. + +Author: +Environment: + + kernel mode only + +Notes: + + +Revision History: + + +--*/ + +// +// Define an Interface Guid to access the proprietary toaster interface. +// This guid is used to identify a specific interface in IRP_MN_QUERY_INTERFACE +// handler. +// + +DEFINE_GUID(GUID_TOASTER_INTERFACE_STANDARD, + 0xe0b27630, 0x5434, 0x11d3, 0xb8, 0x90, 0x0, 0xc0, 0x4f, 0xad, 0x51, 0x71); +// {E0B27630-5434-11d3-B890-00C04FAD5171} + +// +// This guid is used in IoCreateDeviceSecure call to create PDOs. The idea is to +// allow the administrators to control access to the child device, in case the +// device gets enumerated as a raw device - no function driver, by modifying the +// registry. If a function driver is loaded for the device, the system will override +// the security descriptor specified in the call to IoCreateDeviceSecure with the +// one specifyied for the setup class of the child device. +// + +DEFINE_GUID(GUID_SD_BUSENUM_PDO, + 0x9d3039dd, 0xcca5, 0x4b4d, 0xb3, 0x3d, 0xe2, 0xdd, 0xc8, 0xa8, 0xc5, 0x2e); +// {9D3039DD-CCA5-4b4d-B33D-E2DDC8A8C52E} + +// +// GUID definition are required to be outside of header inclusion pragma to avoid +// error during precompiled headers. +// + +#ifndef __DRIVER_H +#define __DRIVER_H + +// +// Define Interface reference/dereference routines for +// Interfaces exported by IRP_MN_QUERY_INTERFACE +// + +typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context); +typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context); + +typedef +BOOLEAN +(*PTOASTER_GET_CRISPINESS_LEVEL)( + __in PVOID Context, + __out PUCHAR Level + ); + +typedef +BOOLEAN +(*PTOASTER_SET_CRISPINESS_LEVEL)( + __in PVOID Context, + __out UCHAR Level + ); + +typedef +BOOLEAN +(*PTOASTER_IS_CHILD_PROTECTED)( + __in PVOID Context + ); + +// +// Interface for getting and setting power level etc., +// +typedef struct _TOASTER_INTERFACE_STANDARD { + // + // generic interface header + // + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + // + // standard bus interfaces + // + PTOASTER_GET_CRISPINESS_LEVEL GetCrispinessLevel; + PTOASTER_SET_CRISPINESS_LEVEL SetCrispinessLevel; + PTOASTER_IS_CHILD_PROTECTED IsSafetyLockEnabled; //): +} TOASTER_INTERFACE_STANDARD, *PTOASTER_INTERFACE_STANDARD; + +#ifndef STATUS_CONTINUE_COMPLETION //required to build driver in Win2K and XP build environment +// +// This value should be returned from completion routines to continue +// completing the IRP upwards. Otherwise, STATUS_MORE_PROCESSING_REQUIRED +// should be returned. +// +#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS + +#endif + +#endif + + + diff --git a/tools/dv/samples/DV-FailDriver-WDM/driver/DV-FailDriver-WDM.sln b/tools/dv/samples/DV-FailDriver-WDM/driver/DV-FailDriver-WDM.sln new file mode 100644 index 00000000..6c642b94 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/driver/DV-FailDriver-WDM.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "defect_toastmon", ".\defect_toastmon.vcxproj", "{50D75FD5-F47F-4289-98ED-B4AF87F5074D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Debug|x64.ActiveCfg = Debug|x64 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Debug|x64.Build.0 = Debug|x64 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Debug|x64.Deploy.0 = Debug|x64 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Debug|x86.ActiveCfg = Debug|Win32 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Debug|x86.Build.0 = Debug|Win32 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Debug|x86.Deploy.0 = Debug|Win32 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Release|x64.ActiveCfg = Release|x64 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Release|x64.Build.0 = Release|x64 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Release|x64.Deploy.0 = Release|x64 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Release|x86.ActiveCfg = Release|Win32 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Release|x86.Build.0 = Release|Win32 + {50D75FD5-F47F-4289-98ED-B4AF87F5074D}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj b/tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj new file mode 100644 index 00000000..3bbfc913 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj @@ -0,0 +1,145 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {50D75FD5-F47F-4289-98ED-B4AF87F5074D} + $(MSBuildProjectName) + false + true + Debug + Win32 + {2DC3C871-C129-48AF-8AEF-21660E90E355} + + + + Windows10 + False + Desktop + WDM + WindowsKernelModeDriver10.0 + Driver + + + Windows10 + True + Desktop + WDM + WindowsKernelModeDriver10.0 + Driver + + + Windows10 + False + Desktop + WDM + WindowsKernelModeDriver10.0 + Driver + + + Windows10 + True + Desktop + WDM + WindowsKernelModeDriver10.0 + Driver + + + + $(IntDir) + + + + + + + + + + + + + + + + defect_toastmon + + + defect_toastmon + + + defect_toastmon + + + defect_toastmon + + + + + + + true + Level4 + + + + + + + true + Level4 + + + + + + + true + Level4 + + + + + + + true + Level4 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj.Filters b/tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj.Filters new file mode 100644 index 00000000..54b3292a --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/driver/defect_toastmon.vcxproj.Filters @@ -0,0 +1,39 @@ + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {33678E2A-4D37-4513-B6BC-82247B32F21A} + + + h;hpp;hxx;hm;inl;inc;xsd + {FC4F9442-7A7D-4089-951C-730E92D24CB7} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {8848867A-B6EA-4C72-93B6-430DC2FE89D1} + + + inf;inv;inx;mof;mc; + {A8255629-05E3-46EC-8820-1F65B22797CF} + + + + + Driver Files + + + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/tools/dv/samples/DV-FailDriver-WDM/public.h b/tools/dv/samples/DV-FailDriver-WDM/public.h new file mode 100644 index 00000000..462f28e2 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/public.h @@ -0,0 +1,174 @@ +/*++ +Copyright (c) 1990-2015 Microsoft Corporation All Rights Reserved + +Module Name: + + public.h + +Abstract: + + This module contains the common declarations shared by driver + and user applications. + +Author: +Environment: + + user and kernel +Notes: + + +Revision History: + + +--*/ + +// +// Define an Interface Guid for bus enumerator class. +// This GUID is used to register (IoRegisterDeviceInterface) +// an instance of an interface so that enumerator application +// can send an ioctl to the bus driver. +// + +DEFINE_GUID (GUID_DEVINTERFACE_BUSENUM_TOASTER, + 0xD35F7840, 0x6A0C, 0x11d2, 0xB8, 0x41, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +// {D35F7840-6A0C-11d2-B841-00C04FAD5171} + +// +// Define an Interface Guid for toaster device class. +// This GUID is used to register (IoRegisterDeviceInterface) +// an instance of an interface so that user application +// can control the toaster device. +// + +DEFINE_GUID (GUID_DEVINTERFACE_TOASTER, + 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +//{781EF630-72B2-11d2-B852-00C04FAD5171} + +// +// Define a Setup Class GUID for Toaster Class. This is same +// as the TOASTSER CLASS guid in the INF files. +// + +DEFINE_GUID (GUID_DEVCLASS_TOASTER, + 0xB85B7C50, 0x6A01, 0x11d2, 0xB8, 0x41, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +//{B85B7C50-6A01-11d2-B841-00C04FAD5171} + +// +// Define a WMI GUID to get busenum info. +// + +DEFINE_GUID (TOASTER_BUS_WMI_STD_DATA_GUID, + 0x0006A660, 0x8F12, 0x11d2, 0xB8, 0x54, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +//{0006A660-8F12-11d2-B854-00C04FAD5171} + +// +// Define a WMI GUID to get toaster device info. +// + +DEFINE_GUID (TOASTER_WMI_STD_DATA_GUID, + 0xBBA21300L, 0x6DD3, 0x11d2, 0xB8, 0x44, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); + +// +// Define a WMI GUID to represent device arrival notification WMIEvent class. +// + +DEFINE_GUID (TOASTER_NOTIFY_DEVICE_ARRIVAL_EVENT, + 0x1cdaff1, 0xc901, 0x45b4, 0xb3, 0x59, 0xb5, 0x54, 0x27, 0x25, 0xe2, 0x9c); +// {01CDAFF1-C901-45b4-B359-B5542725E29C} + + +// +// GUID definition are required to be outside of header inclusion pragma to avoid +// error during precompiled headers. +// + +#ifndef __PUBLIC_H +#define __PUBLIC_H + +#define BUS_HARDWARE_IDS L"{B85B7C50-6A01-11d2-B841-00C04FAD5171}\\MsToaster\0" +#define BUS_HARDWARE_IDS_LENGTH sizeof (BUS_HARDWARE_IDS) + +#define BUSENUM_COMPATIBLE_IDS L"{B85B7C50-6A01-11d2-B841-00C04FAD5171}\\MsCompatibleToaster\0" +#define BUSENUM_COMPATIBLE_IDS_LENGTH sizeof(BUSENUM_COMPATIBLE_IDS) + + +#define FILE_DEVICE_BUSENUM FILE_DEVICE_BUS_EXTENDER + +#define BUSENUM_IOCTL(_index_) \ + CTL_CODE (FILE_DEVICE_BUSENUM, _index_, METHOD_BUFFERED, FILE_READ_DATA) + +#define IOCTL_BUSENUM_PLUGIN_HARDWARE BUSENUM_IOCTL (0x0) +#define IOCTL_BUSENUM_UNPLUG_HARDWARE BUSENUM_IOCTL (0x1) +#define IOCTL_BUSENUM_EJECT_HARDWARE BUSENUM_IOCTL (0x2) +#define IOCTL_TOASTER_DONT_DISPLAY_IN_UI_DEVICE BUSENUM_IOCTL (0x3) + +// +// Data structure used in PlugIn and UnPlug ioctls +// +#pragma warning(disable:4200) +typedef struct _BUSENUM_PLUGIN_HARDWARE +{ + // + // sizeof (struct _BUSENUM_HARDWARE) + // + __in ULONG Size; + + // + // Unique serial number of the device to be enumerated. + // Enumeration will be failed if another device on the + // bus has the same serail number. + // + + __in ULONG SerialNo; + + + // + // An array of (zero terminated wide character strings). The array itself + // also null terminated (ie, MULTI_SZ) + // + + __in WCHAR HardwareIDs[]; + +} BUSENUM_PLUGIN_HARDWARE, *PBUSENUM_PLUGIN_HARDWARE; +#pragma warning(default:4200) +typedef struct _BUSENUM_UNPLUG_HARDWARE +{ + // + // sizeof (struct _REMOVE_HARDWARE) + // + + __in ULONG Size; + + // + // Serial number of the device to be plugged out + // + + ULONG SerialNo; + + ULONG Reserved[2]; + +} BUSENUM_UNPLUG_HARDWARE, *PBUSENUM_UNPLUG_HARDWARE; + +typedef struct _BUSENUM_EJECT_HARDWARE +{ + // + // sizeof (struct _EJECT_HARDWARE) + // + + __in ULONG Size; + + // + // Serial number of the device to be ejected + // + + ULONG SerialNo; + + ULONG Reserved[2]; + +} BUSENUM_EJECT_HARDWARE, *PBUSENUM_EJECT_HARDWARE; + + +#endif + + + diff --git a/tools/dv/samples/DV-FailDriver-WDM/wmi.c b/tools/dv/samples/DV-FailDriver-WDM/wmi.c new file mode 100644 index 00000000..ee856d59 --- /dev/null +++ b/tools/dv/samples/DV-FailDriver-WDM/wmi.c @@ -0,0 +1,314 @@ +/*++ + +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: + + wmi.c + +Abstract: This module demonstrates how to receive WMI notification fired by + another driver. The code here basically registers for toaster + device arrival WMI notification fired by the toaster function driver. + You can use similar technique to receive media sense notification + (GUID_NDIS_STATUS_MEDIA_CONNECT/GUID_NDIS_STATUS_MEDIA_DISCONNECT) + fired by NDIS whenever the network cable is plugged or unplugged. + + +Environment: + + Kernel mode + +Revision History: + +--*/ +#include "defect_toastmon.h" +#include "public.h" +#include + +#pragma alloc_text (PAGE, RegisterForWMINotification) + +// +// These typedefs required to avoid compilation errors in Win2K build environment. +// +typedef +VOID +(*WMI_NOTIFICATION_CALLBACK)( // Copied from WDM.H + PVOID Wnode, + PVOID Context + ); + +typedef +NTSTATUS +(*PFN_IO_WMI_OPEN_BLOCK)( + __in GUID *DataBlockGuid, + __in ULONG DesiredAccess, + __out PVOID *DataBlockObject + ); + +typedef +NTSTATUS +(*PFN_IO_WMI_SET_NOTIFICATION_CALLBACK)( + __in PVOID Object, + __in WMI_NOTIFICATION_CALLBACK Callback, + __in PVOID Context + ); + + +NTSTATUS +RegisterForWMINotification( + __in PDEVICE_EXTENSION DeviceExt + ) +{ + NTSTATUS status = STATUS_SUCCESS; + GUID wmiGuid; + UNICODE_STRING funcName; + PFN_IO_WMI_OPEN_BLOCK WmiOpenBlock = NULL; + PFN_IO_WMI_SET_NOTIFICATION_CALLBACK WmiSetNotificationCallback = NULL; + + PAGED_CODE(); + +// allow pointer casts to functions +#pragma warning(disable : 4055) + + // + // APIs to open WMI interfaces are available on XP and beyond, so let us + // first check to see whether there are exported in the kernel we are running + // before using them. + // + RtlInitUnicodeString(&funcName, L"IoWMIOpenBlock"); + WmiOpenBlock = (PFN_IO_WMI_OPEN_BLOCK) MmGetSystemRoutineAddress(&funcName); + + RtlInitUnicodeString(&funcName, L"IoWMISetNotificationCallback"); + WmiSetNotificationCallback = (PFN_IO_WMI_SET_NOTIFICATION_CALLBACK) MmGetSystemRoutineAddress(&funcName); + +#pragma warning(default : 4055) + + if (WmiOpenBlock == NULL || WmiSetNotificationCallback==NULL) { + // + // Not available. + // + return STATUS_NOT_SUPPORTED; + } + + // + // Check to make sure we are not called multiple times. + // + if (DeviceExt->WMIDeviceArrivalNotificationObject != NULL) { + return STATUS_UNSUCCESSFUL; + } + + // + // Register WMI callbacks for toaster device arrival events + // + wmiGuid = TOASTER_NOTIFY_DEVICE_ARRIVAL_EVENT; + + status = WmiOpenBlock( + &wmiGuid, + WMIGUID_NOTIFICATION, + &DeviceExt->WMIDeviceArrivalNotificationObject + ); + if (!NT_SUCCESS(status)) { + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Unable to open wmi data block status 0x%x\n", status); + DeviceExt->WMIDeviceArrivalNotificationObject = NULL; + + } else { + + status = WmiSetNotificationCallback( + DeviceExt->WMIDeviceArrivalNotificationObject, + WmiNotificationCallback, + DeviceExt + ); + if (!NT_SUCCESS(status)) { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Unable to register for wmi notification 0x%x\n", status); + ObDereferenceObject(DeviceExt->WMIDeviceArrivalNotificationObject); + DeviceExt->WMIDeviceArrivalNotificationObject = NULL; + } + } + + return status; +} + + +VOID +UnregisterForWMINotification( + __in PDEVICE_EXTENSION DeviceExt +) +{ + if (DeviceExt->WMIDeviceArrivalNotificationObject != NULL) { + ObDereferenceObject(DeviceExt->WMIDeviceArrivalNotificationObject); + DeviceExt->WMIDeviceArrivalNotificationObject = NULL; + } +} + +NTSTATUS +GetDeviceFriendlyName( + __in PDEVICE_OBJECT Pdo, + __out PUNICODE_STRING DeviceName + ) +/*++ + +Routine Description: + + Return the friendly name associated with the given device object. + +Arguments: + +Return Value: + + NT status + +--*/ +{ + NTSTATUS status; + ULONG resultLength = 0; + DEVICE_REGISTRY_PROPERTY property; + PWCHAR valueInfo = NULL; + ULONG i; + + valueInfo = NULL; + + // + // First get the length of the string. If the FriendlyName + // is not there then get the lenght of device description. + // + property = DevicePropertyFriendlyName; + + for (i = 0; i < 2; i++) { + status = IoGetDeviceProperty(Pdo, + property, + 0, + NULL, + &resultLength); + + if (status != STATUS_BUFFER_TOO_SMALL) { + property = DevicePropertyDeviceDescription; + } + } + + valueInfo = ExAllocatePoolWithTag (NonPagedPool, resultLength, + DRIVER_TAG); + if (NULL == valueInfo) { + status = STATUS_INSUFFICIENT_RESOURCES; + goto Error; + } + + // + // Now we have the right size buffer, we can get the name + // + status = IoGetDeviceProperty(Pdo, + property, + resultLength, + valueInfo, + &resultLength); + if (!NT_SUCCESS(status)) { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "IoGetDeviceProperty returned %x\n", status); + goto Error; + } + +#pragma warning(suppress: 26035) + RtlInitUnicodeString(DeviceName, valueInfo); + +#pragma warning(suppress: 26030) + return STATUS_SUCCESS; + +Error: + if (valueInfo) { + ExFreePool(valueInfo); + } + return (status); +} + +VOID +WmiNotificationCallback( + PVOID Wnode, + PVOID Context + ) +/*++ + +Routine Description: + + WMI calls this function to notify the caller that the specified event has occurred. + +Arguments: + + Wnode - points to the WNODE_EVENT_ITEM structure returned by the driver triggering the event. + + Context - points to the value specified in the Context parameter of the + IoWMISetNotificationCallback routine. + +Return Value: + + NT status + +--*/ +{ + PWNODE_SINGLE_INSTANCE wnode = (PWNODE_SINGLE_INSTANCE) Wnode; + PDEVICE_EXTENSION deviceExtension = Context; + UNICODE_STRING deviceName; + PLIST_ENTRY thisEntry, listHead; + PDEVICE_INFO list = NULL; + PDEVICE_OBJECT devobj; + NTSTATUS status; + BOOLEAN found = FALSE; + + ExAcquireFastMutex (&deviceExtension->ListMutex); + + listHead = &deviceExtension->DeviceListHead; + + for(thisEntry = listHead->Flink; + thisEntry != listHead; + thisEntry = thisEntry->Flink) + { + list = CONTAINING_RECORD(thisEntry, DEVICE_INFO, ListEntry); + devobj = list->TargetDeviceObject; + + if (devobj && IoWMIDeviceObjectToProviderId(devobj) + == wnode->WnodeHeader.ProviderId) { + + if ( IsEqualGUID( (LPGUID)&(wnode->WnodeHeader.Guid), + (LPGUID)&TOASTER_NOTIFY_DEVICE_ARRIVAL_EVENT) ) { + // + // Currently IRQL level is APC_LEVEL since we have acquired the mutex. + // So make sure to release the mutext before doing anything + // that can be done only at PASSIVE_LEVEL such as sending PNP + // IRPs. + // + found = TRUE; + break; + + } else { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Unknown event.\n"); + } + } + + } + + ExReleaseFastMutex (&deviceExtension->ListMutex); + + // + // Get the friendlyname of the device. + // + if (found) { + + status = GetDeviceFriendlyName(list->Pdo, &deviceName); + if (!NT_SUCCESS(status)) { + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "GetDeviceFriendlyName returned %x\n", status); + return; + } + + DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "%ws fired a device arrival event\n", deviceName.Buffer); + // + // Free the memory allocated by GetDeviceFriendlyName. + // + ExFreePool(deviceName.Buffer); + } + + return; +} + diff --git a/tools/sdv/samples/DV-FailDriver-WDM/README.md b/tools/sdv/samples/DV-FailDriver-WDM/README.md deleted file mode 100644 index 9851ff31..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/README.md +++ /dev/null @@ -1,32 +0,0 @@ - - - -DV-FailDriver-WDM -================= - -The DV-FailDriver-WDM sample driver contains intentional code errors that are designed to show the capabilities and features of [Driver Verifier](https://msdn.microsoft.com/en-us/library/windows/hardware/ff545448) (DV) and the [Device Fundamentals tests](https://msdn.microsoft.com/en-us/library/windows/hardware/jj673011). Driver Verifier is a component of the Windows kernel designed to detect drivers that are behaving poorly and stop their execution via a bugcheck; the Device Fundamentals tests are a series of tests provided in the Windows Driver Kit (WDK) designed to provide a good basic set of tests against a driver. - -**Caution** This sample driver contains intentional code errors that are designed to show the capabilities and features of DV and SDV. This sample driver is not intended as an example for real driver development projects. - -Build the sample for desktop --------------- -1. In the **Solutions Explorer** window, select the driver solution (DV-FailDriver-WDM). - -2. From the **Build** menu, select **Build Solution**. - -Deploy the sample --------------- -See [Deploying a Driver to a Test Computer](https://msdn.microsoft.com/en-us/library/windows/hardware/hh454834) for details on how to deploy the sample. - -Test the sample --------------- -See [How to test a driver at runtime](https://msdn.microsoft.com/en-us/library/windows/hardware/ff554820) for details on how to run tests on the Toastmon driver. - -To observe the injected defect being caught by DV, you should enable DV on the Toastmon driver, and then run the "DF - PNP Surprise Remove (Development and Integration)" test on the Toastmon sample driver and device. \ No newline at end of file diff --git a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.c b/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.c deleted file mode 100644 index f8c545d2..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.c +++ /dev/null @@ -1,1532 +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: - - defect_toastmon.c - -Abstract: This sample is designed to demonstrate the Driver Verifier - functionality present in Windows. A bug violating the - IrqlPsPassive rule is injected in the ToasterDrvCancelQueuedReadIrps - callback. Running the Device Fundamentals PNP Surprise Remove test - with Driver Verifier enabled on this Defect_Toastmon driver will create - a bugcheck (0xC4) describing the error. - - This driver should not be used as a sample to build a new driver from. - -Environment: - - Kernel mode - -Revision History: - - Injected defect to demonstrate DV capabilities and cleaned sample - (7/14/2015) - - Added module to demonstrate how to register and receive WMI - notification in Kernel-mode (3/3/2004) - ---*/ -#include "defect_toastmon.h" -#include -#include -#include "public.h" - -#ifdef ALLOC_PRAGMA -#pragma alloc_text (INIT, DriverEntry) -#pragma alloc_text (PAGE, Defect_ToastMon_AddDevice) -#pragma alloc_text (PAGE, Defect_ToastMon_DispatchPnp) -#pragma alloc_text (PAGE, Defect_ToastMon_DispatchPower) -#pragma alloc_text (PAGE, Defect_ToastMon_Dispatch) -#pragma alloc_text (PAGE, Defect_ToastMon_DispatchRead) -#pragma alloc_text (PAGE, Defect_ToastMon_DispatchSystemControl) -#pragma alloc_text (PAGE, Defect_ToastMon_Unload) -#pragma alloc_text (PAGE, Defect_ToastMon_PnpNotifyDeviceChange) -#pragma alloc_text (PAGE, Defect_ToastMon_PnpNotifyInterfaceChange) -#pragma alloc_text (PAGE, Defect_ToastMon_GetTargetDevicePdo) -#pragma alloc_text (PAGE, Defect_ToastMon_OpenTargetDevice) -#pragma alloc_text (PAGE, Defect_ToastMon_CloseTargetDevice) -#endif - -NTSTATUS -DriverEntry( - __in PDRIVER_OBJECT DriverObject, - __in PUNICODE_STRING RegistryPath - ) - //++ -/* - -Routine Description: - - Installable driver initialization entry point. - This entry point is called directly by the I/O system. - -Arguments: - - DriverObject - pointer to the driver object - - RegistryPath - pointer to a unicode string representing the path, - to driver-specific key in the registry. - -Return Value: - - STATUS_SUCCESS - ---*/ -{ - - UNREFERENCED_PARAMETER (RegistryPath); - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Driver Entry\n")); - - // - // Create dispatch points for the IRPs. - // - - DriverObject->MajorFunction[IRP_MJ_CREATE] = Defect_ToastMon_Dispatch; - DriverObject->MajorFunction[IRP_MJ_CLOSE] = Defect_ToastMon_Dispatch; - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = Defect_ToastMon_Dispatch; - DriverObject->MajorFunction[IRP_MJ_READ] = Defect_ToastMon_DispatchRead; - DriverObject->MajorFunction[IRP_MJ_PNP] = Defect_ToastMon_DispatchPnp; - DriverObject->MajorFunction[IRP_MJ_POWER] = Defect_ToastMon_DispatchPower; - DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = - Defect_ToastMon_DispatchSystemControl; - DriverObject->DriverExtension->AddDevice = Defect_ToastMon_AddDevice; - DriverObject->DriverUnload = Defect_ToastMon_Unload; - - return STATUS_SUCCESS; -} - - -NTSTATUS -Defect_ToastMon_AddDevice( - __in PDRIVER_OBJECT DriverObject, - __in PDEVICE_OBJECT PhysicalDeviceObject - ) -/*++ - -Routine Description: - - The Plug & Play subsystem is handing us a brand new PDO, for which we - (by means of INF registration) have been asked to provide a driver. - - We need to determine if we need to be in the driver stack for the device. - Create a functional device object to attach to the stack - Initialize that device object - Return status success. - - Remember: we can NOT actually send ANY non pnp IRPS to the given driver - stack, UNTIL we have received an IRP_MN_START_DEVICE. - -Arguments: - - DeviceObject - pointer to a device object. - - PhysicalDeviceObject - pointer to a device object created by the - underlying bus driver. - -Return Value: - - NT status code. - ---*/ -{ - NTSTATUS status = STATUS_SUCCESS; - PDEVICE_OBJECT deviceObject = NULL; - PDEVICE_EXTENSION deviceExtension; - - PAGED_CODE(); - - // - // Create a device object. - // - - status = IoCreateDevice (DriverObject, - sizeof (DEVICE_EXTENSION), - NULL, - FILE_DEVICE_UNKNOWN, - FILE_DEVICE_SECURE_OPEN, - FALSE, - &deviceObject); - - - if (!NT_SUCCESS (status)) { - // - // Either not enough memory to create a deviceobject or another - // deviceobject with the same name exits. This could happen - // if you install another instance of this device. - // - return status; - } - - deviceExtension = (PDEVICE_EXTENSION) deviceObject->DeviceExtension; - - // initialize the device wide spinlock - KeInitializeSpinLock(&deviceExtension->deviceSpinlock); - - deviceExtension->TopOfStack = IoAttachDeviceToDeviceStack ( - deviceObject, - PhysicalDeviceObject); - if (NULL == deviceExtension->TopOfStack) { - IoDeleteDevice(deviceObject); - return STATUS_DEVICE_REMOVED; - } - - IoInitializeRemoveLock (&deviceExtension->RemoveLock , - DRIVER_TAG, - 1, // MaxLockedMinutes - 5); // HighWatermark, this parameter is - // used only on checked build. - // - // Set the flag if the device is not holding a pagefile - // crashdump file or hibernate file. - // - - deviceObject->Flags |= DO_POWER_PAGABLE; - deviceObject->Flags |= DO_BUFFERED_IO; - - deviceExtension->DeviceObject = deviceObject; - INITIALIZE_PNP_STATE(deviceExtension); - - // - // We will keep list of all the toaster devices we - // interact with and protect the access to the list - // with a mutex. - // - InitializeListHead(&deviceExtension->DeviceListHead); - InitializeListHead(&deviceExtension->RecvQueueHead); - ExInitializeFastMutex (&deviceExtension->ListMutex); - - deviceObject->Flags &= ~DO_DEVICE_INITIALIZING; - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: AddDevice: %p to %p->%p \n", deviceObject, - deviceExtension->TopOfStack, - PhysicalDeviceObject); - - // - // Register for TOASTER device interface changes. - // - // We will get an ARRIVAL callback for every TOASTER device that is - // started and a REMOVAL callback for every TOASTER that is removed - // - - status = IoRegisterPlugPlayNotification ( - EventCategoryDeviceInterfaceChange, - PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, - (PVOID)&GUID_DEVINTERFACE_TOASTER, - DriverObject, - (PDRIVER_NOTIFICATION_CALLBACK_ROUTINE) - Defect_ToastMon_PnpNotifyInterfaceChange, - (PVOID)deviceExtension, -#pragma warning(suppress: 6014) // handle is released with unregister call during remove IRP processing - &deviceExtension->NotificationHandle); - - if (!NT_SUCCESS(status)) { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Defect_Toastmon: RegisterPnPNotifiction failed: %x\n", status); - } - - RegisterForWMINotification(deviceExtension); - - return STATUS_SUCCESS; - -} - -NTSTATUS -Defect_ToastMon_CompletionRoutine( - PDEVICE_OBJECT DeviceObject, - PIRP Irp, - PVOID Context - ) -/*++ - -Routine Description: - - The completion routine for plug & play irps that needs to be - processed first by the lower drivers. - -Arguments: - - DeviceObject - pointer to a device object. - - Irp - pointer to an I/O Request Packet. - - Context - pointer to an event object. - -Return Value: - - NT status code - ---*/ -{ - PKEVENT event; - - event = (PKEVENT) Context; - - UNREFERENCED_PARAMETER(DeviceObject); - - // - // If the lower driver didn't return STATUS_PENDING, we don't need to - // set the event because we won't be waiting on it. - // This optimization avoids grabbing the dispatcher lock and improves perf. - // - if (Irp->PendingReturned == TRUE) { -#pragma warning(suppress: 28183) - KeSetEvent(event, 0, FALSE); - } - // - // Allows the caller to reuse the IRP - // - return STATUS_MORE_PROCESSING_REQUIRED; -} - - -NTSTATUS -Defect_ToastMon_DispatchPnp ( - PDEVICE_OBJECT DeviceObject, - PIRP Irp - ) -/*++ - -Routine Description: - - The plug and play dispatch routines. - - Most of these the driver will completely ignore. - In all cases it must pass the IRP to the next lower driver. - -Arguments: - - DeviceObject - pointer to a device object. - - Irp - pointer to an I/O Request Packet. - -Return Value: - - NT status code - ---*/ -{ - PIO_STACK_LOCATION irpStack; - NTSTATUS status = STATUS_SUCCESS; - KEVENT event; - PDEVICE_EXTENSION deviceExtension; - PLIST_ENTRY thisEntry; - PDEVICE_INFO list; - - - - - - deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; - - - - irpStack = IoGetCurrentIrpStackLocation(Irp); - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: %s IRP:0x%p \n", - PnPMinorFunctionString(irpStack->MinorFunction), Irp); - - - status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); - if (!NT_SUCCESS (status)) - { - Irp->IoStatus.Status = status; - IoCompleteRequest (Irp, IO_NO_INCREMENT); - return status; - } - - - - - - - - switch (irpStack->MinorFunction) { - case IRP_MN_START_DEVICE: - - // - // The device is starting. - // - // We cannot touch the device (send it any non pnp irps) until a - // start device has been passed down to the lower drivers. - // - IoCopyCurrentIrpStackLocationToNext(Irp); - KeInitializeEvent(&event, - NotificationEvent, - FALSE - ); - - IoSetCompletionRoutine(Irp, - (PIO_COMPLETION_ROUTINE)Defect_ToastMon_CompletionRoutine, - &event, - TRUE, - TRUE, - TRUE); // No need for Cancel - - status = IoCallDriver(deviceExtension->TopOfStack, Irp); - - if (STATUS_PENDING == status) { - KeWaitForSingleObject( - &event, - Executive, // Waiting for reason of a driver - KernelMode, // Waiting in kernel mode - FALSE, // No alert - NULL); // No timeout - status = Irp->IoStatus.Status; - } - - if (NT_SUCCESS(status)) { - - SET_NEW_PNP_STATE(deviceExtension, Started); - } - - // - // We must now complete the IRP, since we stopped it in the - // completion routine with STATUS_MORE_PROCESSING_REQUIRED. - // - IoCompleteRequest(Irp, IO_NO_INCREMENT); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; - - case IRP_MN_REMOVE_DEVICE: - - - // - // Wait for all outstanding requests to complete - // - IoReleaseRemoveLockAndWait(&deviceExtension->RemoveLock, Irp); - SET_NEW_PNP_STATE(deviceExtension, Deleted); - Irp->IoStatus.Status = STATUS_SUCCESS; - IoSkipCurrentIrpStackLocation(Irp); - status = IoCallDriver(deviceExtension->TopOfStack, Irp); - - // - // Unregister the interface notification - // - IoUnregisterPlugPlayNotification(deviceExtension->NotificationHandle); - // - // Close all the handles to the target device - // - ExAcquireFastMutex (&deviceExtension->ListMutex); - while(!IsListEmpty(&deviceExtension->DeviceListHead)) - { - thisEntry = RemoveHeadList(&deviceExtension->DeviceListHead); - list = CONTAINING_RECORD(thisEntry, DEVICE_INFO, ListEntry); - Defect_ToastMon_CloseTargetDevice(list); - } - ExReleaseFastMutex (&deviceExtension->ListMutex); - - UnregisterForWMINotification(deviceExtension); - - IoDetachDevice(deviceExtension->TopOfStack); - IoDeleteDevice(DeviceObject); - - return status; - - - case IRP_MN_QUERY_STOP_DEVICE: - SET_NEW_PNP_STATE(deviceExtension, StopPending); - status = STATUS_SUCCESS; - break; - - case IRP_MN_CANCEL_STOP_DEVICE: - - // - // Check to see whether you have received cancel-stop - // without first receiving a query-stop. This could happen if someone - // above us fails a query-stop and passes down the subsequent - // cancel-stop. - // - - if (StopPending == deviceExtension->DevicePnPState) - { - // - // We did receive a query-stop, so restore. - // - RESTORE_PREVIOUS_PNP_STATE(deviceExtension); - } - status = STATUS_SUCCESS; // We must not fail this IRP. - break; - - case IRP_MN_STOP_DEVICE: - SET_NEW_PNP_STATE(deviceExtension, Stopped); - status = STATUS_SUCCESS; - break; - - case IRP_MN_QUERY_REMOVE_DEVICE: - - SET_NEW_PNP_STATE(deviceExtension, RemovePending); - status = STATUS_SUCCESS; - break; - - case IRP_MN_SURPRISE_REMOVAL: - - - SET_NEW_PNP_STATE(deviceExtension, SurpriseRemovePending); - ToasterDrvCancelQueuedReadIrps(deviceExtension); - status = STATUS_SUCCESS; - break; - - case IRP_MN_CANCEL_REMOVE_DEVICE: - - // - // Check to see whether you have received cancel-remove - // without first receiving a query-remove. This could happen if - // someone above us fails a query-remove and passes down the - // subsequent cancel-remove. - // - - if (RemovePending == deviceExtension->DevicePnPState) - { - // - // We did receive a query-remove, so restore. - // - RESTORE_PREVIOUS_PNP_STATE(deviceExtension); - } - status = STATUS_SUCCESS; // We must not fail this IRP. - break; - - - default: - // - // If you don't handle any IRP you must leave the - // status as is. - // - status = Irp->IoStatus.Status; - - break; - } - - // - // Pass the IRP down and forget it. - // - Irp->IoStatus.Status = status; - IoSkipCurrentIrpStackLocation (Irp); - status = IoCallDriver (deviceExtension->TopOfStack, Irp); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; -} - -NTSTATUS -Defect_ToastMon_DispatchPower( - PDEVICE_OBJECT DeviceObject, - PIRP Irp - ) -/*++ - -Routine Description: - - This routine is the dispatch routine for power irps. - Does nothing except forwarding the IRP to the next device - in the stack. - -Arguments: - - DeviceObject - Pointer to the device object. - - Irp - Pointer to the request packet. - -Return Value: - - NT Status code ---*/ -{ - PDEVICE_EXTENSION deviceExtension; - PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(Irp); - POWER_STATE_TYPE powerType = stack->Parameters.Power.Type; - UCHAR minorFunction = stack->MinorFunction; - NTSTATUS status= STATUS_SUCCESS; - - deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; - - status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); - if (!NT_SUCCESS (status)) { - Irp->IoStatus.Status = status; - IoCompleteRequest (Irp, IO_NO_INCREMENT); - return status; - } - - switch( minorFunction ) - { - case IRP_MN_QUERY_POWER: - PoStartNextPowerIrp(Irp); - IoSkipCurrentIrpStackLocation(Irp); - status=PoCallDriver(deviceExtension->TopOfStack, Irp); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; - break; - case IRP_MN_SET_POWER: - switch( powerType ) - { - case DevicePowerState: - PoStartNextPowerIrp(Irp); - IoSkipCurrentIrpStackLocation(Irp); - status=PoCallDriver(deviceExtension->TopOfStack, Irp); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; - break; - case SystemPowerState: - PoStartNextPowerIrp(Irp); - IoSkipCurrentIrpStackLocation(Irp); - status=PoCallDriver(deviceExtension->TopOfStack, Irp); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; - break; - default: - status = Irp->IoStatus.Status; - PoStartNextPowerIrp(Irp); - IoSkipCurrentIrpStackLocation(Irp); - status=PoCallDriver(deviceExtension->TopOfStack, Irp); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; - } - - break; - default: - - status = Irp->IoStatus.Status; - PoStartNextPowerIrp(Irp); - IoSkipCurrentIrpStackLocation(Irp); - status=PoCallDriver(deviceExtension->TopOfStack, Irp); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; - } -} - -NTSTATUS -Defect_ToastMon_DispatchSystemControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp - ) -/*++ - -Routine Description: - - This routine is the dispatch routine for WMI irps. - Does nothing except forwarding the IRP to the next device - in the stack. - -Arguments: - - DeviceObject - Pointer to the device object. - - Irp - Pointer to the request packet. - -Return Value: - - NT Status code ---*/ -{ - PDEVICE_EXTENSION deviceExtension; - NTSTATUS status= STATUS_SUCCESS; - - deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; - status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); - if (!NT_SUCCESS (status)) - { - Irp->IoStatus.Status = status; - IoCompleteRequest (Irp, IO_NO_INCREMENT); - return status; - } - IoSkipCurrentIrpStackLocation(Irp); - status=IoCallDriver(deviceExtension->TopOfStack, Irp); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; -} - - -VOID -Defect_ToastMon_Unload( - __in PDRIVER_OBJECT DriverObject - ) -/*++ - -Routine Description: - - Free all the allocated resources, etc. - -Arguments: - - DriverObject - pointer to a driver object. - -Return Value: - - VOID. - ---*/ -{ - UNREFERENCED_PARAMETER(DriverObject); - - PAGED_CODE (); - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Defect_ToastMon_Unload\n")); - - return; -} - -NTSTATUS -Defect_ToastMon_Dispatch( - PDEVICE_OBJECT DeviceObject, - PIRP Irp - ) - -/*++ - -Routine Description: - This routine is the dispatch handler for the driver. It is responsible - for processing the IRPs. - -Arguments: - - pDO - Pointer to device object. - - Irp - Pointer to the current IRP. - -Return Value: - - STATUS_SUCCESS if the IRP was processed successfully, otherwise an error - indicating the reason for failure. - ---*/ - -{ - PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; - PIO_STACK_LOCATION irpStack; - NTSTATUS status; - - Irp->IoStatus.Information = 0; - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Defect_ToastMon_Dispatch\n")); - - status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); - if (!NT_SUCCESS (status)) { - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = status; - IoCompleteRequest (Irp, IO_NO_INCREMENT); - return status; - } - - if (NotStarted == deviceExtension->DevicePnPState) - { - // - // We fail all the IRPs that arrive before the device is started. - // - Irp->IoStatus.Status = status = STATUS_DEVICE_NOT_READY; - IoCompleteRequest(Irp, IO_NO_INCREMENT ); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; - } - - irpStack = IoGetCurrentIrpStackLocation(Irp); - - // Dispatch based on major fcn code. - - switch (irpStack->MajorFunction) - { - case IRP_MJ_CREATE: - case IRP_MJ_CLOSE: - // We don't need any special processing on open/close so we'll - // just return success. - status = STATUS_SUCCESS; - break; - - case IRP_MJ_DEVICE_CONTROL: - default: - status = STATUS_NOT_IMPLEMENTED; - break; - } - - // - // We're done with I/O request. Record the status of the I/O action. - // - Irp->IoStatus.Status = status; - IoCompleteRequest(Irp, IO_NO_INCREMENT ); - IoReleaseRemoveLock(&deviceExtension->RemoveLock, Irp); - return status; -} - - -NTSTATUS -#pragma warning(suppress: 28208) -Defect_ToastMon_PnpNotifyInterfaceChange( - PDEVICE_INTERFACE_CHANGE_NOTIFICATION NotificationStruct, - PVOID Context - ) -/*++ - -Routine Description: - - This routine is the PnP "interface change notification" callback routine. - - This gets called on a Toaster triggered device interface arrival or - removal. - - Interface arrival corresponds to a Toaster device being STARTED - - Interface removal corresponds to a Toaster device being REMOVED - - On arrival: - - Get the target deviceobject pointer by using the symboliclink. - - Get the PDO of the target device, in case you need to set the - device parameters of the target device. - - Regiter for EventCategoryTargetDeviceChange notification on the fileobject - so that you can cleanup whenever associated device is removed. - - On removal: - - This callback is a NO-OP for interface removal because we - for PnP EventCategoryTargetDeviceChange callbacks and - use that callback to clean up when their associated toaster device goes - away. - -Arguments: - - NotificationStruct - Structure defining the change. - - Context - pointer to the device extension. - (supplied as the "context" when we - registered for this callback) -Return Value: - - STATUS_SUCCESS - always, even if something goes wrong - ---*/ -{ - NTSTATUS status = STATUS_SUCCESS; - PDEVICE_INFO list = NULL; - PDEVICE_EXTENSION deviceExtension = Context; - PUNICODE_STRING symbolicLinkName; - - PAGED_CODE(); - - symbolicLinkName = NotificationStruct->SymbolicLinkName; - - // - // Verify that interface class is a toaster device interface. - // - // Any other InterfaceClassGuid is an error, but let it go since - // it is not fatal to the machine. - // - - if ( !IsEqualGUID( (LPGUID)&(NotificationStruct->InterfaceClassGuid), - (LPGUID)&GUID_DEVINTERFACE_TOASTER) ) { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, ("Defect_Toastmon: Bad interfaceClassGuid in Defect_ToastMon_PnpNotifyInterfaceChange\n")); - return STATUS_SUCCESS; - } - - // - // Check the callback event. - // - if (IsEqualGUID( (LPGUID)&(NotificationStruct->Event), - (LPGUID)&GUID_DEVICE_INTERFACE_ARRIVAL )) { - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Arrival Notification in Defect_ToastMon_PnpNotifyInterfaceChange\n")); - - // - // Allocate memory for the deviceinfo - // - - list = ExAllocatePoolWithTag(PagedPool,sizeof(DEVICE_INFO),DRIVER_TAG); - if (list == NULL) - { - goto Error; - } - RtlZeroMemory(list, sizeof(DEVICE_INFO)); - - // - // Copy the symbolic link - // - list->SymbolicLink.MaximumLength = symbolicLinkName->Length + - sizeof(UNICODE_NULL); - list->SymbolicLink.Length = symbolicLinkName->Length; - list->SymbolicLink.Buffer = ExAllocatePoolWithTag ( - PagedPool, - list->SymbolicLink.MaximumLength, - DRIVER_TAG); - if (list->SymbolicLink.Buffer == NULL) - { - goto Error; - } - RtlCopyUnicodeString(&list->SymbolicLink,symbolicLinkName); - - list->DeviceExtension = deviceExtension; - InitializeListHead(&list->ListEntry); - - // - // Warning: It's not recommended to open the targetdevice - // from a pnp notification callback routine, because if - // the target device initiates any kind of PnP action as - // a result of this open, the PnP manager could deadlock. - // You should queue a workitem to do that. - // For example, SWENUM devices in conjunction with KS - // initiate an enumeration of a device when you do the - // open on the device interface. - // For simplicity, I'm opening the device here, because - // I know the toaster function driver doesn't trigger - // any pnp action. - // For an example on how to queue a workitem, take a look - // at ToasterQueuePassiveLevelCallback in func\featured2\ - // wake.c file. - // - - status = Defect_ToastMon_OpenTargetDevice(list); - if (!NT_SUCCESS( status)) { - goto Error; - } - - // - // Finally queue the Deviceinfo. - // - ExAcquireFastMutex (&deviceExtension->ListMutex); - InsertTailList(&deviceExtension->DeviceListHead, &list->ListEntry); - ExReleaseFastMutex (&deviceExtension->ListMutex); - } - else - { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Removal Interface Notification\n")); - } - return STATUS_SUCCESS; - - Error: - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Defect_Toastmon: PnPNotifyInterfaceChange failed: %x\n", status); - Defect_ToastMon_CloseTargetDevice(list); - return STATUS_SUCCESS; -} - -NTSTATUS -#pragma warning(suppress: 28208) -Defect_ToastMon_PnpNotifyDeviceChange( - PTARGET_DEVICE_REMOVAL_NOTIFICATION NotificationStruct, - PVOID Context - ) -/*++ - -Routine Description: - - This routine is the PnP "Device Change Notification" callback routine. - - This gets called on a when the target is query or surprise removed. - - - Interface arrival corresponds to a toaster device being STARTed - - Interface removal corresponds to a toaster device being REMOVEd - - On Query_Remove or Remove_Complete: - - Find the targetdevice from the list by matching the fileobject pointers. - - Dereference the FileObject (this generates a close to the target device) - - Free the resources. - -Arguments: - - NotificationStruct - Structure defining the change. - - Context - pointer to the device extension. - (supplied as the "context" when we - registered for this callback) -Return Value: - - STATUS_SUCCESS - always, even if something goes wrong - ---*/ -{ - NTSTATUS status; - PDEVICE_INFO list = Context; - PDEVICE_EXTENSION deviceExtension = list->DeviceExtension; - - PAGED_CODE(); - - // - // if the event is query_remove - // - if ( (IsEqualGUID( (LPGUID)&(NotificationStruct->Event), - (LPGUID)&GUID_TARGET_DEVICE_QUERY_REMOVE))){ - PTARGET_DEVICE_REMOVAL_NOTIFICATION removalNotification; - -#pragma warning(suppress: 28930) // used in assert - removalNotification = - (PTARGET_DEVICE_REMOVAL_NOTIFICATION)NotificationStruct; - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Device Removal (query remove) Notification\n")); - - ASSERT(list->FileObject == removalNotification->FileObject); - // - // Deref the fileobject so that we don't prevent - // the target device from being removed. - // - ObDereferenceObject(list->FileObject); - list->FileObject = NULL; - // - // Deref the PDO to compensate for the reference taken - // by the bus driver when it returned the PDO in response - // to the query-device-relations (target-relations). - // - ObDereferenceObject(list->Pdo); - list->Pdo = NULL; - // - // We will defer freeing other resources to remove-complete - // notification because if query-remove is vetoed, we would reopen - // the device in remove-cancelled notification. - // - - } else if (IsEqualGUID( (LPGUID)&(NotificationStruct->Event), - (LPGUID)&GUID_TARGET_DEVICE_REMOVE_COMPLETE) ) { - // - // Device is gone. Let us cleanup our resources. - // - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Device Removal (remove complete) Notification\n")); - - ExAcquireFastMutex (&deviceExtension->ListMutex); - RemoveEntryList(&list->ListEntry); - ExReleaseFastMutex (&deviceExtension->ListMutex); - - Defect_ToastMon_CloseTargetDevice(list); - - } else if ( IsEqualGUID( (LPGUID)&(NotificationStruct->Event), - (LPGUID)&GUID_TARGET_DEVICE_REMOVE_CANCELLED) ) { - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Device Removal (remove cancelled) Notification\n")); - - // Should be null because we cleared it in query-remove - - ASSERT(!list->FileObject); - ASSERT(!list->Pdo); - - // - // Unregister the previous notification because when we reopen - // the device we will register again on the new fileobject. - // - IoUnregisterPlugPlayNotification(list->NotificationHandle); - - // - // Reopen the device - // -#pragma warning(suppress: 28183) - status = Defect_ToastMon_OpenTargetDevice(list); - if (!NT_SUCCESS (status)) { - // - // Couldn't reopen the device. Cleanup. - // - ExAcquireFastMutex (&deviceExtension->ListMutex); - RemoveEntryList(&list->ListEntry); - ExReleaseFastMutex (&deviceExtension->ListMutex); - - Defect_ToastMon_CloseTargetDevice(list); - } - - } else { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Unknown Device Notification\n")); - } - - return STATUS_SUCCESS; -} - -NTSTATUS -Defect_ToastMon_GetTargetDevicePdo( - __in PDEVICE_OBJECT DeviceObject, - __out PDEVICE_OBJECT *PhysicalDeviceObject - ) -/*++ - -Routine Description: - - This builds and send a pnp irp to get the PDO a device. - -Arguments: - - DeviceObject - This is the top of the device in the device stack - the irp is to be sent to. - - PhysicalDeviceObject - Address where the PDO pointer is returned - -Return Value: - - NT status code ---*/ -{ - - KEVENT event; - NTSTATUS status; - PIRP irp; - IO_STATUS_BLOCK ioStatusBlock; - PIO_STACK_LOCATION irpStack; - PDEVICE_RELATIONS deviceRelations; - - PAGED_CODE(); - - KeInitializeEvent( &event, NotificationEvent, FALSE ); - - irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP, - DeviceObject, - NULL, - 0, - NULL, - &event, - &ioStatusBlock ); - - if (irp == NULL) { - status = STATUS_INSUFFICIENT_RESOURCES; - goto End; - } - - irpStack = IoGetNextIrpStackLocation( irp ); - irpStack->MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS; - irpStack->Parameters.QueryDeviceRelations.Type = TargetDeviceRelation; - - // - // Initialize the status to error in case the bus driver decides not to - // set it correctly. - // - - irp->IoStatus.Status = STATUS_NOT_SUPPORTED ; - - - status = IoCallDriver( DeviceObject, irp ); - - if (status == STATUS_PENDING) { - - KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL ); - status = ioStatusBlock.Status; - } - - if (NT_SUCCESS( status)) { - deviceRelations = (PDEVICE_RELATIONS)ioStatusBlock.Information; - ASSERT(deviceRelations); - // - // You must dereference the PDO when it's no longer - // required. - // - *PhysicalDeviceObject = deviceRelations->Objects[0]; - ExFreePool(deviceRelations); - } - -End: - return status; - -} - -NTSTATUS -Defect_ToastMon_OpenTargetDevice( - __in PDEVICE_INFO List - ) -/*++ - -Routine Description: - - Open the target device, get the PDO and register - for TargetDeviceChange notification on the fileobject. - -Arguments: - - -Return Value: - - NT status code ---*/ -{ - NTSTATUS status; - - PAGED_CODE(); - - // - // Get a pointer to and open a handle to the toaster device - // - - status = IoGetDeviceObjectPointer(&List->SymbolicLink, - STANDARD_RIGHTS_ALL, - &List->FileObject, - &List->TargetDeviceObject); - if ( !NT_SUCCESS(status) ) { - goto Error; - } - - // - // Register for TargerDeviceChange notification on the fileobject. - // - status = IoRegisterPlugPlayNotification ( - EventCategoryTargetDeviceChange, - 0, - (PVOID)List->FileObject, - List->DeviceExtension->DeviceObject->DriverObject, - (PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)Defect_ToastMon_PnpNotifyDeviceChange, - (PVOID)List, - &List->NotificationHandle); - if (!NT_SUCCESS (status)) { - goto Error; - } - - // - // Get the PDO. This is required in case you need to set - // the target device's parameters using IoOpenDeviceRegistryKey - // - status = Defect_ToastMon_GetTargetDevicePdo(List->TargetDeviceObject, - &List->Pdo); - if (!NT_SUCCESS (status)) { - goto Error; - } - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: Target device Toplevel DO:0x%p and PDO: 0x%p\n", - List->TargetDeviceObject, List->Pdo); -Error: - - return status; -} - - -__drv_arg(List->SymbolicLink.Buffer, __drv_freesMem(SymLink)) -VOID -#pragma warning(suppress: 6014) -Defect_ToastMon_CloseTargetDevice( - __in __drv_freesMem(List) PDEVICE_INFO List - ) -/*++ - -Routine Description: - - Close all the handles and free the list. - -Arguments: - - -Return Value: - VOID ---*/ -{ - PAGED_CODE(); - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "Defect_Toastmon: Closing handle to 0x%p\n", List->TargetDeviceObject); - if (List->FileObject){ - ObDereferenceObject(List->FileObject); - } - if (List->NotificationHandle) { - IoUnregisterPlugPlayNotification(List->NotificationHandle); - } - if (List->Pdo) { - ObDereferenceObject(List->Pdo); - } - RtlFreeUnicodeString(&List->SymbolicLink); - ExFreePool(List); -} - -PCHAR -PnPMinorFunctionString ( - __in UCHAR MinorFunction -) -{ - switch (MinorFunction) - { - case IRP_MN_START_DEVICE: - return "IRP_MN_START_DEVICE"; - case IRP_MN_QUERY_REMOVE_DEVICE: - return "IRP_MN_QUERY_REMOVE_DEVICE"; - case IRP_MN_REMOVE_DEVICE: - return "IRP_MN_REMOVE_DEVICE"; - case IRP_MN_CANCEL_REMOVE_DEVICE: - return "IRP_MN_CANCEL_REMOVE_DEVICE"; - case IRP_MN_STOP_DEVICE: - return "IRP_MN_STOP_DEVICE"; - case IRP_MN_QUERY_STOP_DEVICE: - return "IRP_MN_QUERY_STOP_DEVICE"; - case IRP_MN_CANCEL_STOP_DEVICE: - return "IRP_MN_CANCEL_STOP_DEVICE"; - case IRP_MN_QUERY_DEVICE_RELATIONS: - return "IRP_MN_QUERY_DEVICE_RELATIONS"; - case IRP_MN_QUERY_INTERFACE: - return "IRP_MN_QUERY_INTERFACE"; - case IRP_MN_QUERY_CAPABILITIES: - return "IRP_MN_QUERY_CAPABILITIES"; - case IRP_MN_QUERY_RESOURCES: - return "IRP_MN_QUERY_RESOURCES"; - case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: - return "IRP_MN_QUERY_RESOURCE_REQUIREMENTS"; - case IRP_MN_QUERY_DEVICE_TEXT: - return "IRP_MN_QUERY_DEVICE_TEXT"; - case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: - return "IRP_MN_FILTER_RESOURCE_REQUIREMENTS"; - case IRP_MN_READ_CONFIG: - return "IRP_MN_READ_CONFIG"; - case IRP_MN_WRITE_CONFIG: - return "IRP_MN_WRITE_CONFIG"; - case IRP_MN_EJECT: - return "IRP_MN_EJECT"; - case IRP_MN_SET_LOCK: - return "IRP_MN_SET_LOCK"; - case IRP_MN_QUERY_ID: - return "IRP_MN_QUERY_ID"; - case IRP_MN_QUERY_PNP_DEVICE_STATE: - return "IRP_MN_QUERY_PNP_DEVICE_STATE"; - case IRP_MN_QUERY_BUS_INFORMATION: - return "IRP_MN_QUERY_BUS_INFORMATION"; - case IRP_MN_DEVICE_USAGE_NOTIFICATION: - return "IRP_MN_DEVICE_USAGE_NOTIFICATION"; - case IRP_MN_SURPRISE_REMOVAL: - return "IRP_MN_SURPRISE_REMOVAL"; - case IRP_MN_QUERY_LEGACY_BUS_INFORMATION: - return "IRP_MN_QUERY_LEGACY_BUS_INFORMATION"; - default: - return "unknown_pnp_irp"; - } -} - - -NTSTATUS -Defect_ToastMon_DispatchRead ( - PDEVICE_OBJECT DeviceObject, - PIRP Irp - ) -/*++ - -Routine Description: - - Performs read from the NIC. - -Arguments: - - FdoData - pointer to a FDO_DATA structure - - Irp - pointer to an I/O Request Packet. - -Return Value: - - NT status code - - ---*/ - -{ - NTSTATUS status; - KIRQL oldIrql; - BOOLEAN CancelIrp; - PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Entered Defect_ToastMon_DispatchRead \n")); - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Attempting to acquire remove lock\n")); - status = IoAcquireRemoveLock (&deviceExtension->RemoveLock, Irp); - if (!NT_SUCCESS (status)) - { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, ("Defect_Toastmon: Acquire remove lock failed; the device is already removed\n")); - Irp->IoStatus.Information = 0; - Irp->IoStatus.Status = status; - IoCompleteRequest (Irp, IO_NO_INCREMENT); - return status; - } - - - KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); - CancelIrp = FALSE; - // - // Since we are queueing the IRP, we should set the cancel routine. - // - IoSetCancelRoutine(Irp, Defect_ToastmonCancelRoutineForReadIrp); - - // - // Let us check to see if the IRP is cancelled at this point. - // - if(Irp->Cancel!=FALSE) - { - // - // This irp has been marked cancelled. This may have occured - // before or after we set the cancel routine. If it occured - // before, our cancel routine will not be called and we must - // cancel the irp here. If it was cancelled after we set the - // cancel routine, the thread that is cancelling the irp will - // call our cancel routine. We determine this by setting the - // cancel routine to NULL and seeing if the original cancel - // routine is still there. - // - - - status = STATUS_CANCELLED; - if (IoSetCancelRoutine(Irp, NULL) != NULL) - { - CancelIrp = TRUE; - } - } - else - { - // - // Queue the IRP and return status pending. - // - IoMarkIrpPending(Irp); - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Defect_ToastMon_DispatchRead - insert the Read Irp into the Recieve Queue and mark IRP as pending \n ")); - InsertTailList(&deviceExtension->RecvQueueHead, - &Irp->Tail.Overlay.ListEntry); - status = STATUS_PENDING; - // - // The IRP shouldn't be accessed after the lock is released - // It could be grabbed by another thread or the cancel routine - // is running. - // - } - - KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); - - if (CancelIrp != FALSE) - { - Irp->IoStatus.Status = STATUS_CANCELLED; - Irp->IoStatus.Information = 0; - IoCompleteRequest(Irp, IO_NO_INCREMENT); - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Release the removelock \n")); - IoReleaseRemoveLock (&deviceExtension->RemoveLock, Irp); - } - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Exiting Defect_ToastMon_DispatchRead \n")); - return status; -} - -VOID -Defect_ToastmonCancelRoutineForReadIrp ( - PDEVICE_OBJECT DeviceObject, - PIRP Irp - ) - -/*++ - -Routine Description: - - The cancel routine for IRPs waiting in the RecvQueue. - The cancel spin lock is already acquired when this routine is called. - -Arguments: - - DeviceObject - pointer to the device object. - - Irp - pointer to the IRP to be cancelled. - - -Return Value: - - VOID. - ---*/ -{ - PDEVICE_EXTENSION deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; - KIRQL oldIrql; - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Canceling Read Request inside Defect_ToastmonCancelRoutineForReadIrp\n")); - - // - // Release the cancel spin lock and pass Irp->CancelIrql to - // restore the original Irql prior to the call to IoAcquireCancelSpinLock - // - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Releasing the cancel spinlock\n")); - IoReleaseCancelSpinLock(Irp->CancelIrql); - - // - // Acquire the local spinlock and raise the Irql to DISPATCH_LEVEL - // - - KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); - - // - // Remove the cancelled IRP from queue and release the queue lock. - // - RemoveEntryList(&Irp->Tail.Overlay.ListEntry); - - // - // Release the spinlock and restore the old Irql - // - KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); - - // - // Complete the request with STATUS_CANCELLED. - // - - Irp->IoStatus.Status = STATUS_CANCELLED; - Irp->IoStatus.Information = 0; - IoCompleteRequest (Irp, IO_NO_INCREMENT); - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Releasing the removelock\n")); - IoReleaseRemoveLock (&deviceExtension->RemoveLock, Irp); - return; - -} - - -VOID -#pragma warning(suppress: 28167) -ToasterDrvCancelQueuedReadIrps( - PDEVICE_EXTENSION deviceExtension - ) -/*++ - -Routine Description: - - Cancel all the read IRPs waiting in the RecvQueue. - -Arguments: - - FdoData - Pointer to the device extension. - -Return Value: - - None - ---*/ -{ - KIRQL oldIrql; - PIRP irp; - PLIST_ENTRY listEntry; - ULONG MajorVersion; - ULONG MinorVersion; - ULONG BuildNumber; - BOOLEAN ListEmpty = FALSE; - - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Canceling queued IRPs inside ToasterDrvCancelQueuedReadIrps")); - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Acquire the RecvQueueLock before checking the RecvQueue as cancellation may also run at the same time")); - KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); - ListEmpty=IsListEmpty(&deviceExtension->RecvQueueHead); - if(ListEmpty) - { - // injected defect for IrqlPsPassive SDV and DV rule -#pragma warning(suppress: 28159) // this is the injected defect -#pragma warning(suppress: 28121) - PsGetVersion(&MajorVersion, &MinorVersion, &BuildNumber, NULL); - KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); - } - else - { - while(!ListEmpty) - { - // - // Remove a request from the queue. - // - listEntry = RemoveHeadList(&deviceExtension->RecvQueueHead); - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Extracting IRPs from the list.")); - irp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry); - // - // Set the cancel routine to NULL. This is an atomic operation. - // - if (IoSetCancelRoutine(irp, NULL)) - { - // injected defect for IrqlPsPassive SDV and DV rule -#pragma warning(suppress: 28159) // this is the injected defect -#pragma warning(suppress: 28121) - PsGetVersion(&MajorVersion, &MinorVersion, &BuildNumber, NULL); - irp->IoStatus.Status = STATUS_CANCELLED; - irp->IoStatus.Information = 0; - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Cancelling the queued IRPs from the list.")); - KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); - // do not complete the IRP while holding the lock - IoCompleteRequest(irp, IO_NO_INCREMENT); - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, ("Defect_Toastmon: Releasing the removelock.")); - IoReleaseRemoveLock (&deviceExtension->RemoveLock, irp); - KeAcquireSpinLock(&deviceExtension->RecvQueueLock, &oldIrql); - } - else - { - // - // Cancel rotuine is running. Leave the irp alone. - // - irp = NULL; - } - ListEmpty=IsListEmpty(&deviceExtension->RecvQueueHead); - if(ListEmpty) - { - KeReleaseSpinLock(&deviceExtension->RecvQueueLock, oldIrql); - } - } - } -} \ No newline at end of file diff --git a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.h b/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.h deleted file mode 100644 index c70d53d8..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.h +++ /dev/null @@ -1,175 +0,0 @@ -/*++ - -Copyright (c) 1990-2000 Microsoft Corporation, All Rights Reserved - -Module Name: - - defect_toastmon.h - -Abstract: - - -Environment: - - Kernel mode - -Revision History: - ---*/ -#include -#include - -#if !defined(__TOASTMON_H__) -#define __TOASTMON_H__ - -#define DRIVER_TAG 'NOMT' - -#define INITIALIZE_PNP_STATE(_Data_) \ - (_Data_)->DevicePnPState = NotStarted;\ - (_Data_)->PreviousPnPState = NotStarted; - -#define SET_NEW_PNP_STATE(_Data_, _state_) \ - (_Data_)->PreviousPnPState = (_Data_)->DevicePnPState;\ - (_Data_)->DevicePnPState = (_state_); - -#define RESTORE_PREVIOUS_PNP_STATE(_Data_) \ - (_Data_)->DevicePnPState = (_Data_)->PreviousPnPState;\ -// -// These are the states a PDO or FDO transition upon -// receiving a specific PnP Irp. Refer to the PnP Device States -// diagram in DDK documentation for better understanding. -// - -typedef enum _DEVICE_PNP_STATE { - - NotStarted = 0, // Not started yet - Started, // Device has received the START_DEVICE IRP - StopPending, // Device has received the QUERY_STOP IRP - Stopped, // Device has received the STOP_DEVICE IRP - RemovePending, // Device has received the QUERY_REMOVE IRP - SurpriseRemovePending, // Device has received the SURPRISE_REMOVE IRP - Deleted, // Device has received the REMOVE_DEVICE IRP - UnKnown // Unknown state - -} DEVICE_PNP_STATE; - - -typedef struct _DEVICE_EXTENSION { - PDEVICE_OBJECT DeviceObject; // The Defect_ToastMon device object. - PDEVICE_OBJECT TopOfStack; // The top of the stack - DEVICE_PNP_STATE DevicePnPState; // Track PnP state - DEVICE_PNP_STATE PreviousPnPState; - IO_REMOVE_LOCK RemoveLock; // - KSPIN_LOCK deviceSpinlock; // device wide spinlock - PVOID NotificationHandle; // Interface notification handle - LIST_ENTRY DeviceListHead; // List to queue the target device info - FAST_MUTEX ListMutex; // Synchronize access to DeviceList - PVOID WMIDeviceArrivalNotificationObject; - LIST_ENTRY RecvQueueHead; - KSPIN_LOCK RecvQueueLock; - KSPIN_LOCK RcvLock; - KSPIN_LOCK ToasterpCancelSpinLock; -} DEVICE_EXTENSION, *PDEVICE_EXTENSION; - - -typedef struct _DEVICE_INFO { - PDEVICE_EXTENSION DeviceExtension; // Our FDO device extension - PDEVICE_OBJECT TargetDeviceObject; // Toplevel deviceobject of the target device - PDEVICE_OBJECT Pdo; // It's PDO - PFILE_OBJECT FileObject; - PVOID NotificationHandle; //Device change notification handle - LIST_ENTRY ListEntry; // Entry to chain to the listhead - UNICODE_STRING SymbolicLink; -} DEVICE_INFO, *PDEVICE_INFO; - - -#if DBG -#define DebugPrint(_x_) \ - DbgPrint ("Defect_ToastMon:"); \ - DbgPrint _x_; - -#define TRAP() DbgBreakPoint() - -#else -#define DebugPrint(_x_) -#define TRAP() -#endif - - -/********************* function prototypes ***********************************/ -// - -DRIVER_INITIALIZE DriverEntry; - -DRIVER_ADD_DEVICE Defect_ToastMon_AddDevice; - -__drv_dispatchType(IRP_MJ_CREATE) -__drv_dispatchType(IRP_MJ_CLOSE) -__drv_dispatchType(IRP_MJ_DEVICE_CONTROL) -DRIVER_DISPATCH Defect_ToastMon_Dispatch; - -__drv_dispatchType(IRP_MJ_PNP) -DRIVER_DISPATCH Defect_ToastMon_DispatchPnp; - -__drv_dispatchType(IRP_MJ_POWER) -DRIVER_DISPATCH Defect_ToastMon_DispatchPower; - -DRIVER_DISPATCH Defect_ToastMon_StartDevice; - -__drv_dispatchType(IRP_MJ_SYSTEM_CONTROL) -DRIVER_DISPATCH Defect_ToastMon_DispatchSystemControl; - -DRIVER_UNLOAD Defect_ToastMon_Unload; - -IO_COMPLETION_ROUTINE Defect_ToastMon_CompletionRoutine; - -DRIVER_NOTIFICATION_CALLBACK_ROUTINE Defect_ToastMon_PnpNotifyDeviceChange; - -DRIVER_NOTIFICATION_CALLBACK_ROUTINE Defect_ToastMon_PnpNotifyInterfaceChange; - -NTSTATUS -Defect_ToastMon_GetTargetDevicePdo( - __in PDEVICE_OBJECT DeviceObject, - __out PDEVICE_OBJECT* PhysicalDeviceObject - ); - -NTSTATUS -Defect_ToastMon_OpenTargetDevice( - __in PDEVICE_INFO List - ); - -__drv_arg(List->SymbolicLink.Buffer, __drv_freesMem(SymLink)) -VOID -Defect_ToastMon_CloseTargetDevice( - __in __drv_freesMem(List) PDEVICE_INFO List - ); - -PCHAR -PnPMinorFunctionString ( - __in UCHAR MinorFunction -); - -NTSTATUS -RegisterForWMINotification( - __in PDEVICE_EXTENSION DeviceExt - ); - -VOID -UnregisterForWMINotification( - __in PDEVICE_EXTENSION DeviceExt -); - -FWMI_NOTIFICATION_CALLBACK WmiNotificationCallback; - - -DRIVER_CANCEL Defect_ToastmonCancelRoutineForReadIrp; - -__drv_dispatchType(IRP_MJ_READ) -DRIVER_DISPATCH Defect_ToastMon_DispatchRead; - -VOID -ToasterDrvCancelQueuedReadIrps( - PDEVICE_EXTENSION deviceExtension - ); -#endif - diff --git a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.inf b/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.inf deleted file mode 100644 index 2cbcf3ed..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.inf +++ /dev/null @@ -1,88 +0,0 @@ -;/*++ -; -;Copyright (c) 1990-2015 Microsoft Corporation All rights Reserved -; -;Module Name: -; -; Defect_ToastMon.INF -; -;Abstract: -; INF file for installing sample buggy toastmon driver -; -;--*/ - -[Version] -Signature="$WINDOWS NT$" -Class=System -ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} -Provider="Sample Provider" -DriverVer=07/29/2015,10.0.0.0 -CatalogFile=Defect_Toastmon.cat - -[DestinationDirs] -DefaultDestDir = 12 - - -; ================= Device Install section ===================== - -[Manufacturer] -%MSFT%=MSFT,NTx86, NTamd64, NTARM, NTARM64 - -; For XP and later -[MSFT.NTx86] -%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon - -[MSFT.NTARM] -%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon - -[MSFT.NTARM64] -%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon - -[MSFT.NTamd64] -%Defect_ToastMon.DRVDESC%=Defect_ToastMon_Inst,root\defect_toastmon - -[Defect_ToastMon_Inst.NT] -CopyFiles=Defect_ToastMon.CopyFiles - -[Defect_ToastMon.CopyFiles] -defect_toastmon.sys - -[Defect_ToastMon_Inst.NT.Services] -AddService=Defect_ToastMon,0x00000002,Defect_ToastMon_Service - -[Defect_ToastMon_Service] -DisplayName = %Defect_ToastMon.SVCDESC% -ServiceType = 1 ; SERVICE_KERNEL_DRIVER -StartType = 1 ; SERVICE_SYSTEM_START -ErrorControl = 1 ; SERVICE_ERROR_NORMAL -ServiceBinary = %12%\defect_toastmon.sys - -[DeviceInstall32] -AddDevice=ROOT\Samples\0001,,ToastMonbuggy - -[ToastMonBuggy] -HardwareIds=root\defect_toastmon - -; ================= Source Media Section ===================== - -[SourceDisksFiles] -defect_toastmon.sys=1 - -[SourceDisksNames.x86] -1 = %DISK_NAME%,,, - -[SourceDisksNames.amd64] -1 = %DISK_NAME%,,, - -[SourceDisksNames.ARM] -1 = %DISK_NAME%,,, - -[SourceDisksNames.ARM64] -1 = %DISK_NAME%,,, - -[Strings] -ClassName = "Sample Drivers" -Defect_ToastMon.SVCDESC = "Sample ToastMon Buggy Service" -Defect_ToastMon.DRVDESC = "Sample ToastMon Buggy Driver" -DISK_NAME = "Toastmon Install Disk" - diff --git a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.rc b/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.rc deleted file mode 100644 index 6ae8a2d6..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/defect_toastmon.rc +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#include - -#define VER_FILETYPE VFT_DRV -#define VER_FILESUBTYPE VFT2_DRV_SYSTEM -#define VER_FILEDESCRIPTION_STR "DV Defect-Injected Toastmon Sample" -#define VER_INTERNALNAME_STR "defect_toastmon.sys" - -#include "common.ver" - - diff --git a/tools/sdv/samples/DV-FailDriver-WDM/driver.h b/tools/sdv/samples/DV-FailDriver-WDM/driver.h deleted file mode 100644 index 0fb84d92..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/driver.h +++ /dev/null @@ -1,118 +0,0 @@ -/*++ -Copyright (c) 1990-2015 Microsoft Corporation All Rights Reserved - -Module Name: - - driver.h - -Abstract: - - This module contains the common declarations for the - bus, function and filter drivers. - -Author: -Environment: - - kernel mode only - -Notes: - - -Revision History: - - ---*/ - -// -// Define an Interface Guid to access the proprietary toaster interface. -// This guid is used to identify a specific interface in IRP_MN_QUERY_INTERFACE -// handler. -// - -DEFINE_GUID(GUID_TOASTER_INTERFACE_STANDARD, - 0xe0b27630, 0x5434, 0x11d3, 0xb8, 0x90, 0x0, 0xc0, 0x4f, 0xad, 0x51, 0x71); -// {E0B27630-5434-11d3-B890-00C04FAD5171} - -// -// This guid is used in IoCreateDeviceSecure call to create PDOs. The idea is to -// allow the administrators to control access to the child device, in case the -// device gets enumerated as a raw device - no function driver, by modifying the -// registry. If a function driver is loaded for the device, the system will override -// the security descriptor specified in the call to IoCreateDeviceSecure with the -// one specifyied for the setup class of the child device. -// - -DEFINE_GUID(GUID_SD_BUSENUM_PDO, - 0x9d3039dd, 0xcca5, 0x4b4d, 0xb3, 0x3d, 0xe2, 0xdd, 0xc8, 0xa8, 0xc5, 0x2e); -// {9D3039DD-CCA5-4b4d-B33D-E2DDC8A8C52E} - -// -// GUID definition are required to be outside of header inclusion pragma to avoid -// error during precompiled headers. -// - -#ifndef __DRIVER_H -#define __DRIVER_H - -// -// Define Interface reference/dereference routines for -// Interfaces exported by IRP_MN_QUERY_INTERFACE -// - -typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context); -typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context); - -typedef -BOOLEAN -(*PTOASTER_GET_CRISPINESS_LEVEL)( - __in PVOID Context, - __out PUCHAR Level - ); - -typedef -BOOLEAN -(*PTOASTER_SET_CRISPINESS_LEVEL)( - __in PVOID Context, - __out UCHAR Level - ); - -typedef -BOOLEAN -(*PTOASTER_IS_CHILD_PROTECTED)( - __in PVOID Context - ); - -// -// Interface for getting and setting power level etc., -// -typedef struct _TOASTER_INTERFACE_STANDARD { - // - // generic interface header - // - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - // - // standard bus interfaces - // - PTOASTER_GET_CRISPINESS_LEVEL GetCrispinessLevel; - PTOASTER_SET_CRISPINESS_LEVEL SetCrispinessLevel; - PTOASTER_IS_CHILD_PROTECTED IsSafetyLockEnabled; //): -} TOASTER_INTERFACE_STANDARD, *PTOASTER_INTERFACE_STANDARD; - -#ifndef STATUS_CONTINUE_COMPLETION //required to build driver in Win2K and XP build environment -// -// This value should be returned from completion routines to continue -// completing the IRP upwards. Otherwise, STATUS_MORE_PROCESSING_REQUIRED -// should be returned. -// -#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS - -#endif - -#endif - - - diff --git a/tools/sdv/samples/DV-FailDriver-WDM/public.h b/tools/sdv/samples/DV-FailDriver-WDM/public.h deleted file mode 100644 index 462f28e2..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/public.h +++ /dev/null @@ -1,174 +0,0 @@ -/*++ -Copyright (c) 1990-2015 Microsoft Corporation All Rights Reserved - -Module Name: - - public.h - -Abstract: - - This module contains the common declarations shared by driver - and user applications. - -Author: -Environment: - - user and kernel -Notes: - - -Revision History: - - ---*/ - -// -// Define an Interface Guid for bus enumerator class. -// This GUID is used to register (IoRegisterDeviceInterface) -// an instance of an interface so that enumerator application -// can send an ioctl to the bus driver. -// - -DEFINE_GUID (GUID_DEVINTERFACE_BUSENUM_TOASTER, - 0xD35F7840, 0x6A0C, 0x11d2, 0xB8, 0x41, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); -// {D35F7840-6A0C-11d2-B841-00C04FAD5171} - -// -// Define an Interface Guid for toaster device class. -// This GUID is used to register (IoRegisterDeviceInterface) -// an instance of an interface so that user application -// can control the toaster device. -// - -DEFINE_GUID (GUID_DEVINTERFACE_TOASTER, - 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); -//{781EF630-72B2-11d2-B852-00C04FAD5171} - -// -// Define a Setup Class GUID for Toaster Class. This is same -// as the TOASTSER CLASS guid in the INF files. -// - -DEFINE_GUID (GUID_DEVCLASS_TOASTER, - 0xB85B7C50, 0x6A01, 0x11d2, 0xB8, 0x41, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); -//{B85B7C50-6A01-11d2-B841-00C04FAD5171} - -// -// Define a WMI GUID to get busenum info. -// - -DEFINE_GUID (TOASTER_BUS_WMI_STD_DATA_GUID, - 0x0006A660, 0x8F12, 0x11d2, 0xB8, 0x54, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); -//{0006A660-8F12-11d2-B854-00C04FAD5171} - -// -// Define a WMI GUID to get toaster device info. -// - -DEFINE_GUID (TOASTER_WMI_STD_DATA_GUID, - 0xBBA21300L, 0x6DD3, 0x11d2, 0xB8, 0x44, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); - -// -// Define a WMI GUID to represent device arrival notification WMIEvent class. -// - -DEFINE_GUID (TOASTER_NOTIFY_DEVICE_ARRIVAL_EVENT, - 0x1cdaff1, 0xc901, 0x45b4, 0xb3, 0x59, 0xb5, 0x54, 0x27, 0x25, 0xe2, 0x9c); -// {01CDAFF1-C901-45b4-B359-B5542725E29C} - - -// -// GUID definition are required to be outside of header inclusion pragma to avoid -// error during precompiled headers. -// - -#ifndef __PUBLIC_H -#define __PUBLIC_H - -#define BUS_HARDWARE_IDS L"{B85B7C50-6A01-11d2-B841-00C04FAD5171}\\MsToaster\0" -#define BUS_HARDWARE_IDS_LENGTH sizeof (BUS_HARDWARE_IDS) - -#define BUSENUM_COMPATIBLE_IDS L"{B85B7C50-6A01-11d2-B841-00C04FAD5171}\\MsCompatibleToaster\0" -#define BUSENUM_COMPATIBLE_IDS_LENGTH sizeof(BUSENUM_COMPATIBLE_IDS) - - -#define FILE_DEVICE_BUSENUM FILE_DEVICE_BUS_EXTENDER - -#define BUSENUM_IOCTL(_index_) \ - CTL_CODE (FILE_DEVICE_BUSENUM, _index_, METHOD_BUFFERED, FILE_READ_DATA) - -#define IOCTL_BUSENUM_PLUGIN_HARDWARE BUSENUM_IOCTL (0x0) -#define IOCTL_BUSENUM_UNPLUG_HARDWARE BUSENUM_IOCTL (0x1) -#define IOCTL_BUSENUM_EJECT_HARDWARE BUSENUM_IOCTL (0x2) -#define IOCTL_TOASTER_DONT_DISPLAY_IN_UI_DEVICE BUSENUM_IOCTL (0x3) - -// -// Data structure used in PlugIn and UnPlug ioctls -// -#pragma warning(disable:4200) -typedef struct _BUSENUM_PLUGIN_HARDWARE -{ - // - // sizeof (struct _BUSENUM_HARDWARE) - // - __in ULONG Size; - - // - // Unique serial number of the device to be enumerated. - // Enumeration will be failed if another device on the - // bus has the same serail number. - // - - __in ULONG SerialNo; - - - // - // An array of (zero terminated wide character strings). The array itself - // also null terminated (ie, MULTI_SZ) - // - - __in WCHAR HardwareIDs[]; - -} BUSENUM_PLUGIN_HARDWARE, *PBUSENUM_PLUGIN_HARDWARE; -#pragma warning(default:4200) -typedef struct _BUSENUM_UNPLUG_HARDWARE -{ - // - // sizeof (struct _REMOVE_HARDWARE) - // - - __in ULONG Size; - - // - // Serial number of the device to be plugged out - // - - ULONG SerialNo; - - ULONG Reserved[2]; - -} BUSENUM_UNPLUG_HARDWARE, *PBUSENUM_UNPLUG_HARDWARE; - -typedef struct _BUSENUM_EJECT_HARDWARE -{ - // - // sizeof (struct _EJECT_HARDWARE) - // - - __in ULONG Size; - - // - // Serial number of the device to be ejected - // - - ULONG SerialNo; - - ULONG Reserved[2]; - -} BUSENUM_EJECT_HARDWARE, *PBUSENUM_EJECT_HARDWARE; - - -#endif - - - diff --git a/tools/sdv/samples/DV-FailDriver-WDM/wmi.c b/tools/sdv/samples/DV-FailDriver-WDM/wmi.c deleted file mode 100644 index ee856d59..00000000 --- a/tools/sdv/samples/DV-FailDriver-WDM/wmi.c +++ /dev/null @@ -1,314 +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: - - wmi.c - -Abstract: This module demonstrates how to receive WMI notification fired by - another driver. The code here basically registers for toaster - device arrival WMI notification fired by the toaster function driver. - You can use similar technique to receive media sense notification - (GUID_NDIS_STATUS_MEDIA_CONNECT/GUID_NDIS_STATUS_MEDIA_DISCONNECT) - fired by NDIS whenever the network cable is plugged or unplugged. - - -Environment: - - Kernel mode - -Revision History: - ---*/ -#include "defect_toastmon.h" -#include "public.h" -#include - -#pragma alloc_text (PAGE, RegisterForWMINotification) - -// -// These typedefs required to avoid compilation errors in Win2K build environment. -// -typedef -VOID -(*WMI_NOTIFICATION_CALLBACK)( // Copied from WDM.H - PVOID Wnode, - PVOID Context - ); - -typedef -NTSTATUS -(*PFN_IO_WMI_OPEN_BLOCK)( - __in GUID *DataBlockGuid, - __in ULONG DesiredAccess, - __out PVOID *DataBlockObject - ); - -typedef -NTSTATUS -(*PFN_IO_WMI_SET_NOTIFICATION_CALLBACK)( - __in PVOID Object, - __in WMI_NOTIFICATION_CALLBACK Callback, - __in PVOID Context - ); - - -NTSTATUS -RegisterForWMINotification( - __in PDEVICE_EXTENSION DeviceExt - ) -{ - NTSTATUS status = STATUS_SUCCESS; - GUID wmiGuid; - UNICODE_STRING funcName; - PFN_IO_WMI_OPEN_BLOCK WmiOpenBlock = NULL; - PFN_IO_WMI_SET_NOTIFICATION_CALLBACK WmiSetNotificationCallback = NULL; - - PAGED_CODE(); - -// allow pointer casts to functions -#pragma warning(disable : 4055) - - // - // APIs to open WMI interfaces are available on XP and beyond, so let us - // first check to see whether there are exported in the kernel we are running - // before using them. - // - RtlInitUnicodeString(&funcName, L"IoWMIOpenBlock"); - WmiOpenBlock = (PFN_IO_WMI_OPEN_BLOCK) MmGetSystemRoutineAddress(&funcName); - - RtlInitUnicodeString(&funcName, L"IoWMISetNotificationCallback"); - WmiSetNotificationCallback = (PFN_IO_WMI_SET_NOTIFICATION_CALLBACK) MmGetSystemRoutineAddress(&funcName); - -#pragma warning(default : 4055) - - if (WmiOpenBlock == NULL || WmiSetNotificationCallback==NULL) { - // - // Not available. - // - return STATUS_NOT_SUPPORTED; - } - - // - // Check to make sure we are not called multiple times. - // - if (DeviceExt->WMIDeviceArrivalNotificationObject != NULL) { - return STATUS_UNSUCCESSFUL; - } - - // - // Register WMI callbacks for toaster device arrival events - // - wmiGuid = TOASTER_NOTIFY_DEVICE_ARRIVAL_EVENT; - - status = WmiOpenBlock( - &wmiGuid, - WMIGUID_NOTIFICATION, - &DeviceExt->WMIDeviceArrivalNotificationObject - ); - if (!NT_SUCCESS(status)) { - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Unable to open wmi data block status 0x%x\n", status); - DeviceExt->WMIDeviceArrivalNotificationObject = NULL; - - } else { - - status = WmiSetNotificationCallback( - DeviceExt->WMIDeviceArrivalNotificationObject, - WmiNotificationCallback, - DeviceExt - ); - if (!NT_SUCCESS(status)) { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Unable to register for wmi notification 0x%x\n", status); - ObDereferenceObject(DeviceExt->WMIDeviceArrivalNotificationObject); - DeviceExt->WMIDeviceArrivalNotificationObject = NULL; - } - } - - return status; -} - - -VOID -UnregisterForWMINotification( - __in PDEVICE_EXTENSION DeviceExt -) -{ - if (DeviceExt->WMIDeviceArrivalNotificationObject != NULL) { - ObDereferenceObject(DeviceExt->WMIDeviceArrivalNotificationObject); - DeviceExt->WMIDeviceArrivalNotificationObject = NULL; - } -} - -NTSTATUS -GetDeviceFriendlyName( - __in PDEVICE_OBJECT Pdo, - __out PUNICODE_STRING DeviceName - ) -/*++ - -Routine Description: - - Return the friendly name associated with the given device object. - -Arguments: - -Return Value: - - NT status - ---*/ -{ - NTSTATUS status; - ULONG resultLength = 0; - DEVICE_REGISTRY_PROPERTY property; - PWCHAR valueInfo = NULL; - ULONG i; - - valueInfo = NULL; - - // - // First get the length of the string. If the FriendlyName - // is not there then get the lenght of device description. - // - property = DevicePropertyFriendlyName; - - for (i = 0; i < 2; i++) { - status = IoGetDeviceProperty(Pdo, - property, - 0, - NULL, - &resultLength); - - if (status != STATUS_BUFFER_TOO_SMALL) { - property = DevicePropertyDeviceDescription; - } - } - - valueInfo = ExAllocatePoolWithTag (NonPagedPool, resultLength, - DRIVER_TAG); - if (NULL == valueInfo) { - status = STATUS_INSUFFICIENT_RESOURCES; - goto Error; - } - - // - // Now we have the right size buffer, we can get the name - // - status = IoGetDeviceProperty(Pdo, - property, - resultLength, - valueInfo, - &resultLength); - if (!NT_SUCCESS(status)) { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "IoGetDeviceProperty returned %x\n", status); - goto Error; - } - -#pragma warning(suppress: 26035) - RtlInitUnicodeString(DeviceName, valueInfo); - -#pragma warning(suppress: 26030) - return STATUS_SUCCESS; - -Error: - if (valueInfo) { - ExFreePool(valueInfo); - } - return (status); -} - -VOID -WmiNotificationCallback( - PVOID Wnode, - PVOID Context - ) -/*++ - -Routine Description: - - WMI calls this function to notify the caller that the specified event has occurred. - -Arguments: - - Wnode - points to the WNODE_EVENT_ITEM structure returned by the driver triggering the event. - - Context - points to the value specified in the Context parameter of the - IoWMISetNotificationCallback routine. - -Return Value: - - NT status - ---*/ -{ - PWNODE_SINGLE_INSTANCE wnode = (PWNODE_SINGLE_INSTANCE) Wnode; - PDEVICE_EXTENSION deviceExtension = Context; - UNICODE_STRING deviceName; - PLIST_ENTRY thisEntry, listHead; - PDEVICE_INFO list = NULL; - PDEVICE_OBJECT devobj; - NTSTATUS status; - BOOLEAN found = FALSE; - - ExAcquireFastMutex (&deviceExtension->ListMutex); - - listHead = &deviceExtension->DeviceListHead; - - for(thisEntry = listHead->Flink; - thisEntry != listHead; - thisEntry = thisEntry->Flink) - { - list = CONTAINING_RECORD(thisEntry, DEVICE_INFO, ListEntry); - devobj = list->TargetDeviceObject; - - if (devobj && IoWMIDeviceObjectToProviderId(devobj) - == wnode->WnodeHeader.ProviderId) { - - if ( IsEqualGUID( (LPGUID)&(wnode->WnodeHeader.Guid), - (LPGUID)&TOASTER_NOTIFY_DEVICE_ARRIVAL_EVENT) ) { - // - // Currently IRQL level is APC_LEVEL since we have acquired the mutex. - // So make sure to release the mutext before doing anything - // that can be done only at PASSIVE_LEVEL such as sending PNP - // IRPs. - // - found = TRUE; - break; - - } else { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "Unknown event.\n"); - } - } - - } - - ExReleaseFastMutex (&deviceExtension->ListMutex); - - // - // Get the friendlyname of the device. - // - if (found) { - - status = GetDeviceFriendlyName(list->Pdo, &deviceName); - if (!NT_SUCCESS(status)) { - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_WARNING_LEVEL, "GetDeviceFriendlyName returned %x\n", status); - return; - } - - DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "%ws fired a device arrival event\n", deviceName.Buffer); - // - // Free the memory allocated by GetDeviceFriendlyName. - // - ExFreePool(deviceName.Buffer); - } - - return; -} - -- cgit v1.3.1 From a74c2429e2e7162985d138237de5d68c966ef3f1 Mon Sep 17 00:00:00 2001 From: 4con <4con@users.noreply.github.com> Date: Wed, 15 Nov 2017 15:46:23 +0800 Subject: Fix general/ioctl/kmdf/exe load wrong version of wdf controller dll. At installer.c `LoadWdfCoInstaller` function always get wrong coinstallerVersion 01011, even used `-v version` command line args. --- general/ioctl/kmdf/exe/testapp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/general/ioctl/kmdf/exe/testapp.c b/general/ioctl/kmdf/exe/testapp.c index a645203e..4e230124 100644 --- a/general/ioctl/kmdf/exe/testapp.c +++ b/general/ioctl/kmdf/exe/testapp.c @@ -198,7 +198,8 @@ GetCoinstallerVersion( VOID ) { - if (FAILED( StringCchPrintf(G_coInstallerVersion, + if (!G_versionSpecified && + FAILED( StringCchPrintf(G_coInstallerVersion, MAX_VERSION_SIZE, "%02d%03d", // for example, "01009" KMDF_VERSION_MAJOR, -- cgit v1.3.1 From 1a3e88d788fb533d8cbea006e6fb46ff3b16dcec Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 21 Nov 2017 17:50:07 -0800 Subject: Adding WinHEC Lab Content --- general/WinHEC 2017 Lab/PlugInToaster/devcon.exe | Bin 0 -> 81920 bytes general/WinHEC 2017 Lab/PlugInToaster/plug.exe | Bin 0 -> 12848 bytes general/WinHEC 2017 Lab/PlugInToaster/unplug.bat | 2 + .../Toaster Driver/Service/HsaService.cpp | 116 +++++ .../Toaster Driver/Service/Metering.cpp | 148 ++++++ .../Toaster Driver/Service/Metering.h | 29 ++ .../Toaster Driver/Service/RpcInterface.Idl | 51 ++ .../Toaster Driver/Service/RpcInterface.acf | 17 + .../Toaster Driver/Service/RpcInterface_c.c | 476 +++++++++++++++++ .../Toaster Driver/Service/RpcInterface_h.h | 103 ++++ .../Toaster Driver/Service/RpcInterface_s.c | 430 ++++++++++++++++ .../Toaster Driver/Service/RpcServer.cpp | 320 ++++++++++++ .../Toaster Driver/Service/RpcServer.h | 16 + .../Toaster Driver/Service/RpcServer.vcxproj | 284 +++++++++++ .../Service/RpcServer.vcxproj.filters | 76 +++ .../Toaster Driver/Service/SampleService.cpp | 155 ++++++ .../Toaster Driver/Service/SampleService.h | 46 ++ .../Toaster Driver/Service/ServiceBase.cpp | 566 +++++++++++++++++++++ .../Toaster Driver/Service/ServiceBase.h | 121 +++++ .../Toaster Driver/Service/ServiceInstaller.cpp | 191 +++++++ .../Toaster Driver/Service/ServiceInstaller.h | 57 +++ .../Toaster Driver/Service/stdafx.cpp | 8 + .../Toaster Driver/Service/stdafx.h | 15 + .../Toaster Driver/Service/targetver.h | 8 + general/WinHEC 2017 Lab/Toaster Driver/toaster.sln | 40 ++ .../Toaster Driver/toaster/driver.h | 80 +++ .../Toaster Driver/toaster/public.h | 167 ++++++ .../Toaster Driver/toaster/toaster.c | 418 +++++++++++++++ .../Toaster Driver/toaster/toaster.h | 134 +++++ .../Toaster Driver/toaster/toaster.inx | 25 + .../Toaster Driver/toaster/toaster.vcxproj | 229 +++++++++ .../Toaster Driver/toaster/toaster.vcxproj.filters | 45 ++ .../WinHEC 2017 Lab/Toaster Driver/toaster/trace.h | 62 +++ .../WinHEC 2017 Lab/Toaster Support App/App.sln | 40 ++ .../App/CustomCapability/cpp/CustomCapability.SCCD | 11 + .../CustomCapability/cpp/CustomCapability.vcxproj | 287 +++++++++++ .../cpp/CustomCapability.vcxproj.filters | 89 ++++ .../App/CustomCapability/cpp/DeviceList.cpp | 244 +++++++++ .../App/CustomCapability/cpp/Package.appxmanifest | 41 ++ .../App/CustomCapability/cpp/RpcClient.cpp | 177 +++++++ .../App/CustomCapability/cpp/RpcClient.h | 30 ++ .../App/CustomCapability/cpp/RpcInterface.c | 6 + .../App/CustomCapability/cpp/RpcInterface_c.c | 476 +++++++++++++++++ .../App/CustomCapability/cpp/RpcInterface_h.h | 112 ++++ .../App/CustomCapability/cpp/RpcInterface_s.c | 430 ++++++++++++++++ .../CustomCapability/cpp/SampleConfiguration.cpp | 21 + .../App/CustomCapability/cpp/SampleConfiguration.h | 47 ++ .../cpp/Scenario1_MeteringData.xaml | 68 +++ .../cpp/Scenario1_MeteringData.xaml.cpp | 47 ++ .../cpp/Scenario1_MeteringData.xaml.h | 31 ++ .../App/CustomCapability/cpp/ServiceViewModel.cpp | 282 ++++++++++ .../App/CustomCapability/cpp/ServiceViewModel.h | 77 +++ .../App/CustomCapability/cpp/pch.cpp | 60 +++ .../App/CustomCapability/cpp/pch.h | 27 + .../SharedContent/cpp/App.xaml.cpp | 134 +++++ .../SharedContent/cpp/App.xaml.h | 33 ++ .../SharedContent/cpp/DeviceHelpers.h | 67 +++ .../SharedContent/cpp/MainPage.xaml | 80 +++ .../SharedContent/cpp/MainPage.xaml.cpp | 154 ++++++ .../SharedContent/cpp/MainPage.xaml.h | 46 ++ .../SharedContent/media/Square310x310Logo.png | Bin 0 -> 6124 bytes .../SharedContent/media/microsoft-sdk.png | Bin 0 -> 3405 bytes .../SharedContent/media/placeholder-sdk.png | Bin 0 -> 8991 bytes .../SharedContent/media/placeholder.png | Bin 0 -> 4568 bytes .../SharedContent/media/smalltile-sdk.png | Bin 0 -> 670 bytes .../SharedContent/media/splash-sdk.png | Bin 0 -> 9274 bytes .../SharedContent/media/squaretile-sdk.png | Bin 0 -> 1137 bytes .../SharedContent/media/storelogo-sdk.png | Bin 0 -> 442 bytes .../SharedContent/media/tile-sdk.png | Bin 0 -> 4852 bytes .../SharedContent/media/windows-sdk.png | Bin 0 -> 2997 bytes .../SharedContent/xaml/App.xaml | 34 ++ .../SharedContent/xaml/Styles.xaml | 536 +++++++++++++++++++ general/WinHEC 2017 Lab/WinHEC 2017 Lab.docx | Bin 0 -> 1118785 bytes general/WinHEC 2017 Lab/WinHEC 2017 Lab.zip | Bin 0 -> 1125330 bytes 74 files changed, 8122 insertions(+) create mode 100644 general/WinHEC 2017 Lab/PlugInToaster/devcon.exe create mode 100644 general/WinHEC 2017 Lab/PlugInToaster/plug.exe create mode 100644 general/WinHEC 2017 Lab/PlugInToaster/unplug.bat create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/HsaService.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.Idl create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.acf create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_c.c create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_h.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_s.c create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj.filters create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/Service/targetver.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster.sln create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/driver.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/public.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.c create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.h create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.inx create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj.filters create mode 100644 general/WinHEC 2017 Lab/Toaster Driver/toaster/trace.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App.sln create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.SCCD create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj.filters create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/DeviceList.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Package.appxmanifest create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface.c create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_c.c create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_h.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_s.c create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Scenario1_MeteringData.xaml create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Scenario1_MeteringData.xaml.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Scenario1_MeteringData.xaml.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/ServiceViewModel.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/ServiceViewModel.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/App.xaml.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/App.xaml.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/DeviceHelpers.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.cpp create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/cpp/MainPage.xaml.h create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/Square310x310Logo.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/microsoft-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/placeholder-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/placeholder.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/smalltile-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/splash-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/squaretile-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/storelogo-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/tile-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/media/windows-sdk.png create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/xaml/App.xaml create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/SharedContent/xaml/Styles.xaml create mode 100644 general/WinHEC 2017 Lab/WinHEC 2017 Lab.docx create mode 100644 general/WinHEC 2017 Lab/WinHEC 2017 Lab.zip diff --git a/general/WinHEC 2017 Lab/PlugInToaster/devcon.exe b/general/WinHEC 2017 Lab/PlugInToaster/devcon.exe new file mode 100644 index 00000000..92f91505 Binary files /dev/null and b/general/WinHEC 2017 Lab/PlugInToaster/devcon.exe differ diff --git a/general/WinHEC 2017 Lab/PlugInToaster/plug.exe b/general/WinHEC 2017 Lab/PlugInToaster/plug.exe new file mode 100644 index 00000000..d84aa38b Binary files /dev/null and b/general/WinHEC 2017 Lab/PlugInToaster/plug.exe differ diff --git a/general/WinHEC 2017 Lab/PlugInToaster/unplug.bat b/general/WinHEC 2017 Lab/PlugInToaster/unplug.bat new file mode 100644 index 00000000..324ae1cf --- /dev/null +++ b/general/WinHEC 2017 Lab/PlugInToaster/unplug.bat @@ -0,0 +1,2 @@ +@sc delete hsa_usersrv +@devcon remove TOASTER\BASIC_TOASTER \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/HsaService.cpp b/general/WinHEC 2017 Lab/Toaster Driver/Service/HsaService.cpp new file mode 100644 index 00000000..d3f70fdf --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/HsaService.cpp @@ -0,0 +1,116 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "stdafx.h" + +#pragma region Includes +#include +#include +#include "ServiceInstaller.h" +#include "ServiceBase.h" +#include "SampleService.h" +#pragma endregion + +// +// Settings of the service +// + +// Internal name of the service +#define SERVICE_NAME L"HsaService" + +// Displayed name of the service +#define SERVICE_DISPLAY_NAME L"Hsa Sample Service" + +// Service start options. +#define SERVICE_START_TYPE SERVICE_DEMAND_START + +// List of service dependencies - "dep1\0dep2\0\0" +#define SERVICE_DEPENDENCIES L"" + +// The name of the account under which the service should run - NULL uses LocalSystem account. +#define SERVICE_ACCOUNT NULL + +// The password to the service account name +#define SERVICE_PASSWORD NULL + + +// +// FUNCTION: wmain(int, wchar_t *[]) +// +// PURPOSE: entrypoint for the application. +// +// PARAMETERS: +// argc - number of command line arguments +// argv - array of command line arguments +// +// RETURN VALUE: +// none +// +// COMMENTS: +// wmain() either performs the command line task, or run the service. +// +int wmain(_In_ int argc, _In_ wchar_t *argv[]) +{ + bool invalidArgs = false; + + if ((argc > 1) && ((*argv[1] == L'-' || (*argv[1] == L'/')))) + { + if (_wcsicmp(L"install", argv[1] + 1) == 0) + { + // Install the service when the command is + // "-install" or "/install". + InstallService( + SERVICE_NAME, // Name of service + SERVICE_DISPLAY_NAME, // Name to display + SERVICE_START_TYPE, // Service start type + SERVICE_DEPENDENCIES, // Dependencies + SERVICE_ACCOUNT, // Service running account + SERVICE_PASSWORD // Password of the account + ); + } + else if (_wcsicmp(L"remove", argv[1] + 1) == 0) + { + // Uninstall the service when the command is + // "-remove" or "/remove". + UninstallService(SERVICE_NAME); + } + else if (_wcsicmp(L"console", argv[1] + 1) == 0) + { + // Uninstall the service when the command is + // "-remove" or "/remove". + CSampleService service(SERVICE_NAME); + service.ConsoleRun(); + } + else + { + invalidArgs = true; + } + } + else + { + invalidArgs = true; + CSampleService service(SERVICE_NAME); + if (!CServiceBase::Run(service)) + { + wprintf(L"Service failed to run w/err 0x%08lx\n", GetLastError()); + } + } + + if (invalidArgs) + { + wprintf(L"Parameters:\n"); + wprintf(L" -install to install the service.\n"); + wprintf(L" -remove to remove the service.\n"); + wprintf(L" -console to run in console mode.\n"); + } + + return 0; +} \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.cpp b/general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.cpp new file mode 100644 index 00000000..1766b37c --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.cpp @@ -0,0 +1,148 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "stdafx.h" +#include "Metering.h" +#include +#include "RpcInterface_h.h" + +using namespace RpcServer; + +// +// Thread pool callback method for metering worker +// +void CALLBACK MeteringWorkerTpCallback( + _In_ PTP_CALLBACK_INSTANCE /*iTimerInstance*/, + _In_ PVOID pContext, + _In_ PTP_TIMER /*pTimer*/) +{ + Metering *metering = static_cast(pContext); + + if (metering != nullptr) + { + // Run the metering worker for this instance of metering + metering->MeteringWorker(); + } +} + +// +// ctor for Metering +// +Metering::Metering( + _In_ __int64 period) +{ + tpTimer = CreateThreadpoolTimer(::MeteringWorkerTpCallback, this, nullptr); + // TODO: Handle if CreateThreadpoolTimer fails i.e tpTimer == nullptr + + samplePeriod = period; + event = CreateEvent( + nullptr, // default security attributes + FALSE, // auto-reset event object + FALSE, // initial state is nonsignaled + nullptr); // unnamed object +} + +// +// dtor for Metering +// +Metering::~Metering() +{ + if (tpTimer != nullptr) + { + // How to close threadpool timer when there are outstanding callbacks: + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms682040(v=vs.85).aspx + SetThreadpoolTimer(tpTimer, nullptr, 0, 0); + WaitForThreadpoolTimerCallbacks(tpTimer, true); + CloseThreadpoolTimer(tpTimer); + tpTimer = nullptr; + } + CloseHandle(event); +} + +// +// Set the lowest sample period +// +void Metering::SetSamplePeriod(_In_ __int64 period) +{ + if (period < 1) + { + // Don't allow 0 (too fast) or negative numbers. + period = 1; + } + if (period > 1000) + { + // Don't let the period be too long, or we will be + // slow to shut down. + period = 1000; + } + samplePeriod = period; +} + +// +// Get last known metering data +// +__int64 Metering::GetMeteringData() const +{ + return _data; +} + +// +// Metering worker that updates metering data +// +void Metering::MeteringWorker() +{ + // Get the value from the imaginary driver and update the data + _data = GetTickCount(); + SetEvent(event); +} + +// +// Set the thread poot timer and wait for metering data. +// +void Metering::WaitForMeteringData() const +{ + ULARGE_INTEGER ulDueTime; + FILETIME FileDueTime; + ulDueTime.QuadPart = static_cast(-(1 * 10 * 1000 * samplePeriod)); + FileDueTime.dwHighDateTime = ulDueTime.HighPart; + FileDueTime.dwLowDateTime = ulDueTime.LowPart; + + SetThreadpoolTimer(tpTimer, + &FileDueTime, + 0, + 0); + + WaitForSingleObject(event, INFINITE); +} + +void Metering::StartMetering( + _In_ __int64 samplePeriod, + _In_ __int64 context) +{ + stopMeteringRequested = false; + SetSamplePeriod(samplePeriod); + + while (true) + { + WaitForMeteringData(); + if (stopMeteringRequested || ShutdownRequested) + { + break; + } + MeteringDataEvent(GetMeteringData(), context); + } +} + +void Metering::StopMetering() +{ + stopMeteringRequested = true; +} + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.h new file mode 100644 index 00000000..bfb48216 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/Metering.h @@ -0,0 +1,29 @@ +#include "stdafx.h" +#include + +#include // std::cout +#include // std::thread +#include + +namespace RpcServer +{ + class Metering + { + public: + Metering(__int64 period); + void SetSamplePeriod(__int64 period); + __int64 GetMeteringData() const; + void MeteringWorker(); + void WaitForMeteringData() const; + void StartMetering(__int64 samplePeriod, __int64 context); + void StopMetering(); + ~Metering(); + + private: + volatile __int64 _data; + volatile __int64 samplePeriod; + PTP_TIMER tpTimer = nullptr; + HANDLE event; + volatile bool stopMeteringRequested = false; + }; +} diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.Idl b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.Idl new file mode 100644 index 00000000..1b4b74cc --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.Idl @@ -0,0 +1,51 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +import "oaidl.idl"; +import "unknwn.idl"; + +[uuid (906B0CE0-C70B-1067-B317-00DD010662DA), +version(1.0), +pointer_default(unique), +] +interface RpcInterface +{ + + // context_handle_noserialize in acf for RPC to call rundown when the client goes away + typedef [context_handle] void* PCONTEXT_HANDLE_TYPE; + typedef [ref] PCONTEXT_HANDLE_TYPE * PPCONTEXT_HANDLE_TYPE; + + // + // RPC methods to retrieve/clean client context + // + void RemoteOpen([in] handle_t hBinding, + [out] PPCONTEXT_HANDLE_TYPE pphContext); + + void RemoteClose([in, out] PPCONTEXT_HANDLE_TYPE pphContext); + + // + // Metering Interface + // + void StartMetering( + [in] PCONTEXT_HANDLE_TYPE phContext, + [in] __int64 samplePeriod, + [in, optional] __int64 context); + + void SetSamplePeriod( + [in] PCONTEXT_HANDLE_TYPE phContext, + [in] __int64 samplePeriod); + + void StopMetering([in] PCONTEXT_HANDLE_TYPE phContext); + + [callback] void MeteringDataEvent( + [in] __int64 data, + [in, optional] __int64 context); +} diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.acf b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.acf new file mode 100644 index 00000000..d00ed5af --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface.acf @@ -0,0 +1,17 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the Microsoft Public License. +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + + +interface RpcInterface +{ + // We need the RPC to call rundown when the client goes away + typedef [context_handle_noserialize] PCONTEXT_HANDLE_TYPE; +} diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_c.c b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_c.c new file mode 100644 index 00000000..fbe0a799 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_c.c @@ -0,0 +1,476 @@ + + +/* this ALWAYS GENERATED file contains the RPC client stubs */ + + + /* File created by MIDL compiler version 8.01.0622 */ +/* at Mon Jan 18 19:14:07 2038 + */ +/* Compiler settings for RpcInterface.Idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#if defined(_M_AMD64) + + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif + +#pragma warning( disable: 4211 ) /* redefine extern to static */ +#pragma warning( disable: 4232 ) /* dllimport identity*/ +#pragma warning( disable: 4024 ) /* array to pointer mapping*/ + +#include + +#include "RpcInterface_h.h" + +#define TYPE_FORMAT_STRING_SIZE 23 +#define PROC_FORMAT_STRING_SIZE 245 +#define EXPR_FORMAT_STRING_SIZE 1 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _RpcInterface_MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_TYPE_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_PROC_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_EXPR_FORMAT_STRING + { + long Pad; + unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_EXPR_FORMAT_STRING; + + +static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = +{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; + + +extern const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString; +extern const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString; +extern const RpcInterface_MIDL_EXPR_FORMAT_STRING RpcInterface__MIDL_ExprFormatString; + +#define GENERIC_BINDING_TABLE_SIZE 0 + + +/* Standard interface: RpcInterface, ver. 1.0, + GUID={0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}} */ + + +extern const MIDL_SERVER_INFO RpcInterface_ServerInfo; + + +extern const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable; + +static const RPC_CLIENT_INTERFACE RpcInterface___RpcClientInterface = + { + sizeof(RPC_CLIENT_INTERFACE), + {{0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + (RPC_DISPATCH_TABLE*)&RpcInterface_v1_0_DispatchTable, + 0, + 0, + 0, + &RpcInterface_ServerInfo, + 0x04000000 + }; +RPC_IF_HANDLE RpcInterface_v1_0_c_ifspec = (RPC_IF_HANDLE)& RpcInterface___RpcClientInterface; + +extern const MIDL_STUB_DESC RpcInterface_StubDesc; + +static RPC_BINDING_HANDLE RpcInterface__MIDL_AutoBindHandle; + + +void RemoteOpen( + /* [in] */ handle_t hBinding, + /* [out] */ PPCONTEXT_HANDLE_TYPE pphContext) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[0], + hBinding, + pphContext); + +} + + +void RemoteClose( + /* [out][in] */ PPCONTEXT_HANDLE_TYPE pphContext) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[36], + pphContext); + +} + + +void StartMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod, + /* [optional][in] */ __int64 context) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[74], + phContext, + samplePeriod, + context); + +} + + +void SetSamplePeriod( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[124], + phContext, + samplePeriod); + +} + + +void StopMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[168], + phContext); + +} + + +#if !defined(__RPC_WIN64__) +#error Invalid build platform for this stub. +#endif + +static const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString = + { + 0, + { + + /* Procedure RemoteOpen */ + + 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x0 ), /* 0 */ +/* 8 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 12 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 14 */ NdrFcShort( 0x0 ), /* 0 */ +/* 16 */ NdrFcShort( 0x38 ), /* 56 */ +/* 18 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 20 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 22 */ NdrFcShort( 0x0 ), /* 0 */ +/* 24 */ NdrFcShort( 0x0 ), /* 0 */ +/* 26 */ NdrFcShort( 0x0 ), /* 0 */ +/* 28 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 30 */ NdrFcShort( 0x110 ), /* Flags: out, simple ref, */ +/* 32 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 34 */ NdrFcShort( 0x6 ), /* Type Offset=6 */ + + /* Procedure RemoteClose */ + +/* 36 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 38 */ NdrFcLong( 0x0 ), /* 0 */ +/* 42 */ NdrFcShort( 0x1 ), /* 1 */ +/* 44 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 46 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe4, /* Ctxt flags: via ptr, in, out, no serialize, */ +/* 48 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 50 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 52 */ NdrFcShort( 0x38 ), /* 56 */ +/* 54 */ NdrFcShort( 0x38 ), /* 56 */ +/* 56 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 58 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 60 */ NdrFcShort( 0x0 ), /* 0 */ +/* 62 */ NdrFcShort( 0x0 ), /* 0 */ +/* 64 */ NdrFcShort( 0x0 ), /* 0 */ +/* 66 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 68 */ NdrFcShort( 0x118 ), /* Flags: in, out, simple ref, */ +/* 70 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 72 */ NdrFcShort( 0xe ), /* Type Offset=14 */ + + /* Procedure StartMetering */ + +/* 74 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 76 */ NdrFcLong( 0x0 ), /* 0 */ +/* 80 */ NdrFcShort( 0x2 ), /* 2 */ +/* 82 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 84 */ 0x30, /* FC_BIND_CONTEXT */ + 0x44, /* Ctxt flags: in, no serialize, */ +/* 86 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 88 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 90 */ NdrFcShort( 0x44 ), /* 68 */ +/* 92 */ NdrFcShort( 0x0 ), /* 0 */ +/* 94 */ 0x40, /* Oi2 Flags: has ext, */ + 0x3, /* 3 */ +/* 96 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 98 */ NdrFcShort( 0x0 ), /* 0 */ +/* 100 */ NdrFcShort( 0x0 ), /* 0 */ +/* 102 */ NdrFcShort( 0x0 ), /* 0 */ +/* 104 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 106 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 108 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 110 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 112 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 114 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 116 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 118 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 120 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 122 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure SetSamplePeriod */ + +/* 124 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 126 */ NdrFcLong( 0x0 ), /* 0 */ +/* 130 */ NdrFcShort( 0x3 ), /* 3 */ +/* 132 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 134 */ 0x30, /* FC_BIND_CONTEXT */ + 0x44, /* Ctxt flags: in, no serialize, */ +/* 136 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 138 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 140 */ NdrFcShort( 0x34 ), /* 52 */ +/* 142 */ NdrFcShort( 0x0 ), /* 0 */ +/* 144 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 146 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 148 */ NdrFcShort( 0x0 ), /* 0 */ +/* 150 */ NdrFcShort( 0x0 ), /* 0 */ +/* 152 */ NdrFcShort( 0x0 ), /* 0 */ +/* 154 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 156 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 158 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 160 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 162 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 164 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 166 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure StopMetering */ + +/* 168 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 170 */ NdrFcLong( 0x0 ), /* 0 */ +/* 174 */ NdrFcShort( 0x4 ), /* 4 */ +/* 176 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 178 */ 0x30, /* FC_BIND_CONTEXT */ + 0x44, /* Ctxt flags: in, no serialize, */ +/* 180 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 182 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 184 */ NdrFcShort( 0x24 ), /* 36 */ +/* 186 */ NdrFcShort( 0x0 ), /* 0 */ +/* 188 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 190 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 192 */ NdrFcShort( 0x0 ), /* 0 */ +/* 194 */ NdrFcShort( 0x0 ), /* 0 */ +/* 196 */ NdrFcShort( 0x0 ), /* 0 */ +/* 198 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 200 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 202 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 204 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Procedure MeteringDataEvent */ + +/* 206 */ 0x34, /* FC_CALLBACK_HANDLE */ + 0x48, /* Old Flags: */ +/* 208 */ NdrFcLong( 0x0 ), /* 0 */ +/* 212 */ NdrFcShort( 0x0 ), /* 0 */ +/* 214 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 216 */ NdrFcShort( 0x20 ), /* 32 */ +/* 218 */ NdrFcShort( 0x0 ), /* 0 */ +/* 220 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 222 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 224 */ NdrFcShort( 0x0 ), /* 0 */ +/* 226 */ NdrFcShort( 0x0 ), /* 0 */ +/* 228 */ NdrFcShort( 0x0 ), /* 0 */ +/* 230 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter data */ + +/* 232 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 234 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 236 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 238 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 240 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 242 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */ +/* 6 */ 0x30, /* FC_BIND_CONTEXT */ + 0xa4, /* Ctxt flags: via ptr, out, no serialize, */ +/* 8 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 10 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 12 */ NdrFcShort( 0x2 ), /* Offset= 2 (14) */ +/* 14 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe5, /* Ctxt flags: via ptr, in, out, no serialize, can't be null */ +/* 16 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 18 */ 0x30, /* FC_BIND_CONTEXT */ + 0x45, /* Ctxt flags: in, no serialize, can't be null */ +/* 20 */ 0x0, /* 0 */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const unsigned short RpcInterface_FormatStringOffsetTable[] = + { + 0, + 36, + 74, + 124, + 168, + }; + + +static const unsigned short _callbackRpcInterface_FormatStringOffsetTable[] = + { + 206 + }; + + +static const MIDL_STUB_DESC RpcInterface_StubDesc = + { + (void *)& RpcInterface___RpcClientInterface, + MIDL_user_allocate, + MIDL_user_free, + &RpcInterface__MIDL_AutoBindHandle, + 0, + 0, + 0, + 0, + RpcInterface__MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x50002, /* Ndr library version */ + 0, + 0x801026e, /* MIDL Version 8.1.622 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* cs routines */ + 0, /* proxy/server info */ + 0 + }; + +static const RPC_DISPATCH_FUNCTION RpcInterface_table[] = + { + NdrServerCall2, + 0 + }; +static const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable = + { + 1, + (RPC_DISPATCH_FUNCTION*)RpcInterface_table + }; + +static const SERVER_ROUTINE RpcInterface_ServerRoutineTable[] = + { + (SERVER_ROUTINE)MeteringDataEvent + }; + +static const MIDL_SERVER_INFO RpcInterface_ServerInfo = + { + &RpcInterface_StubDesc, + RpcInterface_ServerRoutineTable, + RpcInterface__MIDL_ProcFormatString.Format, + _callbackRpcInterface_FormatStringOffsetTable, + 0, + 0, + 0, + 0}; +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + + +#endif /* defined(_M_AMD64)*/ + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_h.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_h.h new file mode 100644 index 00000000..98544da7 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_h.h @@ -0,0 +1,103 @@ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 8.01.0622 */ +/* at Mon Jan 18 19:14:07 2038 + */ +/* Compiler settings for RpcInterface.Idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif /* __RPCNDR_H_VERSION__ */ + + +#ifndef __RpcInterface_h_h__ +#define __RpcInterface_h_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +/* header files for imported files */ +#include "oaidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __RpcInterface_INTERFACE_DEFINED__ +#define __RpcInterface_INTERFACE_DEFINED__ + +/* interface RpcInterface */ +/* [unique][version][uuid] */ + +typedef /* [context_handle_noserialize][context_handle] */ void *PCONTEXT_HANDLE_TYPE; + +typedef /* [ref] */ PCONTEXT_HANDLE_TYPE *PPCONTEXT_HANDLE_TYPE; + +void RemoteOpen( + /* [in] */ handle_t hBinding, + /* [out] */ PPCONTEXT_HANDLE_TYPE pphContext); + +void RemoteClose( + /* [out][in] */ PPCONTEXT_HANDLE_TYPE pphContext); + +void StartMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod, + /* [optional][in] */ __int64 context); + +void SetSamplePeriod( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod); + +void StopMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext); + +/* [callback] */ void MeteringDataEvent( + /* [in] */ __int64 data, + /* [optional][in] */ __int64 context); + + + +extern RPC_IF_HANDLE RpcInterface_v1_0_c_ifspec; +extern RPC_IF_HANDLE RpcInterface_v1_0_s_ifspec; +#endif /* __RpcInterface_INTERFACE_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +void __RPC_USER PCONTEXT_HANDLE_TYPE_rundown( PCONTEXT_HANDLE_TYPE ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_s.c b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_s.c new file mode 100644 index 00000000..89aa59bf --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcInterface_s.c @@ -0,0 +1,430 @@ + + +/* this ALWAYS GENERATED file contains the RPC server stubs */ + + + /* File created by MIDL compiler version 8.01.0622 */ +/* at Mon Jan 18 19:14:07 2038 + */ +/* Compiler settings for RpcInterface.Idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#if defined(_M_AMD64) + + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif + +#pragma warning( disable: 4211 ) /* redefine extern to static */ +#pragma warning( disable: 4232 ) /* dllimport identity*/ +#pragma warning( disable: 4024 ) /* array to pointer mapping*/ + +#include +#include "RpcInterface_h.h" + +#define TYPE_FORMAT_STRING_SIZE 23 +#define PROC_FORMAT_STRING_SIZE 245 +#define EXPR_FORMAT_STRING_SIZE 1 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _RpcInterface_MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_TYPE_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_PROC_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_EXPR_FORMAT_STRING + { + long Pad; + unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_EXPR_FORMAT_STRING; + + +static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = +{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; + +extern const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString; +extern const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString; +extern const RpcInterface_MIDL_EXPR_FORMAT_STRING RpcInterface__MIDL_ExprFormatString; + +/* Standard interface: RpcInterface, ver. 1.0, + GUID={0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}} */ + + +extern const MIDL_SERVER_INFO RpcInterface_ServerInfo; + +extern const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable; + +static const RPC_SERVER_INTERFACE RpcInterface___RpcServerInterface = + { + sizeof(RPC_SERVER_INTERFACE), + {{0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + (RPC_DISPATCH_TABLE*)&RpcInterface_v1_0_DispatchTable, + 0, + 0, + 0, + &RpcInterface_ServerInfo, + 0x04000000 + }; +RPC_IF_HANDLE RpcInterface_v1_0_s_ifspec = (RPC_IF_HANDLE)& RpcInterface___RpcServerInterface; + +extern const MIDL_STUB_DESC RpcInterface_StubDesc; + + extern const MIDL_STUBLESS_PROXY_INFO RpcInterface_ProxyInfo; + +/* [callback] */ void MeteringDataEvent( + /* [in] */ __int64 data, + /* [optional][in] */ __int64 context) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[206], + data, + context); + +} + +extern const NDR_RUNDOWN RundownRoutines[]; + +#if !defined(__RPC_WIN64__) +#error Invalid build platform for this stub. +#endif + +static const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString = + { + 0, + { + + /* Procedure RemoteOpen */ + + 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x0 ), /* 0 */ +/* 8 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 12 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 14 */ NdrFcShort( 0x0 ), /* 0 */ +/* 16 */ NdrFcShort( 0x38 ), /* 56 */ +/* 18 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 20 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 22 */ NdrFcShort( 0x0 ), /* 0 */ +/* 24 */ NdrFcShort( 0x0 ), /* 0 */ +/* 26 */ NdrFcShort( 0x0 ), /* 0 */ +/* 28 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 30 */ NdrFcShort( 0x110 ), /* Flags: out, simple ref, */ +/* 32 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 34 */ NdrFcShort( 0x6 ), /* Type Offset=6 */ + + /* Procedure RemoteClose */ + +/* 36 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 38 */ NdrFcLong( 0x0 ), /* 0 */ +/* 42 */ NdrFcShort( 0x1 ), /* 1 */ +/* 44 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 46 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe4, /* Ctxt flags: via ptr, in, out, no serialize, */ +/* 48 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 50 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 52 */ NdrFcShort( 0x38 ), /* 56 */ +/* 54 */ NdrFcShort( 0x38 ), /* 56 */ +/* 56 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 58 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 60 */ NdrFcShort( 0x0 ), /* 0 */ +/* 62 */ NdrFcShort( 0x0 ), /* 0 */ +/* 64 */ NdrFcShort( 0x0 ), /* 0 */ +/* 66 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 68 */ NdrFcShort( 0x118 ), /* Flags: in, out, simple ref, */ +/* 70 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 72 */ NdrFcShort( 0xe ), /* Type Offset=14 */ + + /* Procedure StartMetering */ + +/* 74 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 76 */ NdrFcLong( 0x0 ), /* 0 */ +/* 80 */ NdrFcShort( 0x2 ), /* 2 */ +/* 82 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 84 */ 0x30, /* FC_BIND_CONTEXT */ + 0x44, /* Ctxt flags: in, no serialize, */ +/* 86 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 88 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 90 */ NdrFcShort( 0x44 ), /* 68 */ +/* 92 */ NdrFcShort( 0x0 ), /* 0 */ +/* 94 */ 0x40, /* Oi2 Flags: has ext, */ + 0x3, /* 3 */ +/* 96 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 98 */ NdrFcShort( 0x0 ), /* 0 */ +/* 100 */ NdrFcShort( 0x0 ), /* 0 */ +/* 102 */ NdrFcShort( 0x0 ), /* 0 */ +/* 104 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 106 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 108 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 110 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 112 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 114 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 116 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 118 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 120 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 122 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure SetSamplePeriod */ + +/* 124 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 126 */ NdrFcLong( 0x0 ), /* 0 */ +/* 130 */ NdrFcShort( 0x3 ), /* 3 */ +/* 132 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 134 */ 0x30, /* FC_BIND_CONTEXT */ + 0x44, /* Ctxt flags: in, no serialize, */ +/* 136 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 138 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 140 */ NdrFcShort( 0x34 ), /* 52 */ +/* 142 */ NdrFcShort( 0x0 ), /* 0 */ +/* 144 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 146 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 148 */ NdrFcShort( 0x0 ), /* 0 */ +/* 150 */ NdrFcShort( 0x0 ), /* 0 */ +/* 152 */ NdrFcShort( 0x0 ), /* 0 */ +/* 154 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 156 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 158 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 160 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 162 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 164 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 166 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure StopMetering */ + +/* 168 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 170 */ NdrFcLong( 0x0 ), /* 0 */ +/* 174 */ NdrFcShort( 0x4 ), /* 4 */ +/* 176 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 178 */ 0x30, /* FC_BIND_CONTEXT */ + 0x44, /* Ctxt flags: in, no serialize, */ +/* 180 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 182 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 184 */ NdrFcShort( 0x24 ), /* 36 */ +/* 186 */ NdrFcShort( 0x0 ), /* 0 */ +/* 188 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 190 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 192 */ NdrFcShort( 0x0 ), /* 0 */ +/* 194 */ NdrFcShort( 0x0 ), /* 0 */ +/* 196 */ NdrFcShort( 0x0 ), /* 0 */ +/* 198 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 200 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 202 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 204 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Procedure MeteringDataEvent */ + +/* 206 */ 0x34, /* FC_CALLBACK_HANDLE */ + 0x48, /* Old Flags: */ +/* 208 */ NdrFcLong( 0x0 ), /* 0 */ +/* 212 */ NdrFcShort( 0x0 ), /* 0 */ +/* 214 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 216 */ NdrFcShort( 0x20 ), /* 32 */ +/* 218 */ NdrFcShort( 0x0 ), /* 0 */ +/* 220 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 222 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 224 */ NdrFcShort( 0x0 ), /* 0 */ +/* 226 */ NdrFcShort( 0x0 ), /* 0 */ +/* 228 */ NdrFcShort( 0x0 ), /* 0 */ +/* 230 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter data */ + +/* 232 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 234 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 236 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 238 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 240 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 242 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */ +/* 6 */ 0x30, /* FC_BIND_CONTEXT */ + 0xa4, /* Ctxt flags: via ptr, out, no serialize, */ +/* 8 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 10 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 12 */ NdrFcShort( 0x2 ), /* Offset= 2 (14) */ +/* 14 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe5, /* Ctxt flags: via ptr, in, out, no serialize, can't be null */ +/* 16 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 18 */ 0x30, /* FC_BIND_CONTEXT */ + 0x45, /* Ctxt flags: in, no serialize, can't be null */ +/* 20 */ 0x0, /* 0 */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const NDR_RUNDOWN RundownRoutines[] = + { + PCONTEXT_HANDLE_TYPE_rundown + }; + + +static const unsigned short RpcInterface_FormatStringOffsetTable[] = + { + 0, + 36, + 74, + 124, + 168, + }; + + +static const unsigned short _callbackRpcInterface_FormatStringOffsetTable[] = + { + 206 + }; + + +static const MIDL_STUB_DESC RpcInterface_StubDesc = + { + (void *)& RpcInterface___RpcServerInterface, + MIDL_user_allocate, + MIDL_user_free, + 0, + RundownRoutines, + 0, + 0, + 0, + RpcInterface__MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x50002, /* Ndr library version */ + 0, + 0x801026e, /* MIDL Version 8.1.622 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* cs routines */ + 0, /* proxy/server info */ + 0 + }; + +static const RPC_DISPATCH_FUNCTION RpcInterface_table[] = + { + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + 0 + }; +static const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable = + { + 5, + (RPC_DISPATCH_FUNCTION*)RpcInterface_table + }; + +static const SERVER_ROUTINE RpcInterface_ServerRoutineTable[] = + { + (SERVER_ROUTINE)RemoteOpen, + (SERVER_ROUTINE)RemoteClose, + (SERVER_ROUTINE)StartMetering, + (SERVER_ROUTINE)SetSamplePeriod, + (SERVER_ROUTINE)StopMetering, + }; + +static const MIDL_SERVER_INFO RpcInterface_ServerInfo = + { + &RpcInterface_StubDesc, + RpcInterface_ServerRoutineTable, + RpcInterface__MIDL_ProcFormatString.Format, + RpcInterface_FormatStringOffsetTable, + 0, + 0, + 0, + 0}; +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + + +#endif /* defined(_M_AMD64)*/ + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.cpp b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.cpp new file mode 100644 index 00000000..0cad3578 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.cpp @@ -0,0 +1,320 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "stdafx.h" +#include +#include +#include +#include "RpcInterface_h.h" +#include + +#include +#include +#include +#include "RpcServer.h" + +using namespace RpcServer; + +#define DEFAULT_METERING_PERIOD 100 + +bool ShutdownRequested; +static RPC_BINDING_VECTOR* BindingVector = nullptr; + +void FreeSidArray(__inout_ecount(cSIDs) PSID* pSIDs, ULONG cSIDs) +{ + if (pSIDs != nullptr) + { + for (ULONG i = 0; i < cSIDs; i++) + { + LocalFree(pSIDs[i]); + + pSIDs[i] = nullptr; + } + + LocalFree(pSIDs); + + pSIDs = nullptr; + cSIDs = 0; + } +} + +// +// Routine to create RPC server and listen to incoming RPC calls +// +DWORD RpcServerStart() +{ + DWORD hResult = S_OK; + WCHAR* protocolSequence = L"ncalrpc"; + unsigned int minCalls = 1; + unsigned int dontWait = false; + ShutdownRequested = false; + + SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; + PSID everyoneSid = nullptr; + PSID* capabilitySids = nullptr; + DWORD capabilitySidCount = 0; + PSID* capabilityGroupSids = nullptr; + DWORD capabilityGroupSidCount = 0; + EXPLICIT_ACCESS ea[2] = {}; + PACL acl = nullptr; + SECURITY_DESCRIPTOR rpcSecurityDescriptor = {}; + + // When creating the RPC endpoint we want it to allow connections from any UWA that contains + // the custom capability SID in its process token. When a UWA declares the custom capability + // in its app manifest, it will later contain the SID form of that custom capability in its + // process token at runtime. By default, RPC endpoints don't allow UWAs (AppContainer processes) + // to connect to them, so we need to set the security on the endpoint to allow access to UWAs with the + // custom capability. + // + // To do this we'll perform the following steps: + // 1) Convert the custom capability name to a SID + // 2) Create a security descriptor using that SID, as well as other needed SIDs. This sample shows how to allow + // all 'non UWAs' access as well as UWAs containing the custom capability SID. + // 3) Create the RPC endpoint using that security descriptor + // + // To create the security descriptor we're roughly following this MSDN sample: + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa446595(v=vs.85).aspx + + // Get the SID form of the custom capability. In this case we only expect one SID and + // we don't care about the capability group. + //INSERT DERIVE CAPABILTY SIDS FROM NAME HERE + + // Get the SID that represents 'everyone' (this doesn't include AppContainers) + if (!AllocateAndInitializeSid( + &SIDAuthWorld, 1, + SECURITY_WORLD_RID, + 0, 0, 0, 0, 0, 0, 0, + &everyoneSid)) + { + hResult = GetLastError(); + goto end; + } + + // Now create the Access Control List (ACL) for the Security descriptor + + // Everyone GENERIC_ALL access + ea[0].grfAccessMode = SET_ACCESS; + ea[0].grfAccessPermissions = GENERIC_ALL; + ea[0].grfInheritance = NO_INHERITANCE; + ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID; + ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; + ea[0].Trustee.ptstrName = static_cast(everyoneSid); + + // Custom capability GENERIC_ALL access + ea[1].grfAccessMode = SET_ACCESS; + ea[1].grfAccessPermissions = GENERIC_ALL; + ea[1].grfInheritance = NO_INHERITANCE; + ea[1].Trustee.TrusteeForm = TRUSTEE_IS_SID; + ea[1].Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN; + ea[1].Trustee.ptstrName = static_cast(everyoneSid); + + hResult = SetEntriesInAcl(ARRAYSIZE(ea), ea, nullptr, &acl); + + if (hResult != ERROR_SUCCESS) + { + goto end; + } + + // Initialize an empty security descriptor + if (!InitializeSecurityDescriptor(&rpcSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION)) + { + hResult = GetLastError(); + goto end; + } + + // Assign the ACL to the security descriptor + if (!SetSecurityDescriptorDacl(&rpcSecurityDescriptor, TRUE, acl, FALSE)) + { + hResult = GetLastError(); + goto end; + } + + // + // Bind to LRPC using dynamic endpoints + // + hResult = RpcServerUseProtseqEp( + reinterpret_cast(protocolSequence), + RPC_C_PROTSEQ_MAX_REQS_DEFAULT, + reinterpret_cast(RPC_STATIC_ENDPOINT), + &rpcSecurityDescriptor); + + if (hResult != S_OK) + { + goto end; + } + + hResult = RpcServerRegisterIf3( + RpcInterface_v1_0_s_ifspec, + nullptr, + nullptr, + RPC_IF_AUTOLISTEN | RPC_IF_ALLOW_LOCAL_ONLY, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, + 0, + nullptr, + &rpcSecurityDescriptor); + + if (hResult != S_OK) + { + goto end; + } + + hResult = RpcServerInqBindings(&BindingVector); + + if (hResult != S_OK) + { + goto end; + } + + hResult = RpcEpRegister( + RpcInterface_v1_0_s_ifspec, + BindingVector, + nullptr, + nullptr); + + if (hResult != S_OK) + { + goto end; + } + + hResult = RpcServerListen( + minCalls, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, + dontWait); + + if (hResult == RPC_S_ALREADY_LISTENING) + { + hResult = RPC_S_OK; + } + +end: + + // Cleanup sids + FreeSidArray(capabilityGroupSids, capabilityGroupSidCount); + FreeSidArray(capabilitySids, capabilitySidCount); + + if (everyoneSid != nullptr) + { + FreeSid(everyoneSid); + } + + // cleanup acl + if (acl != nullptr) + { + LocalFree(acl); + } + + return hResult; +} + +// +// Notify rpc server to stop listening to incoming rpc calls +// +void RpcServerDisconnect() +{ + DWORD hResult = S_OK; + ShutdownRequested = true; + hResult = RpcServerUnregisterIf(RpcInterface_v1_0_s_ifspec, nullptr, 0); + + RpcEpUnregister(RpcInterface_v1_0_s_ifspec, BindingVector, nullptr); + + if (BindingVector != nullptr) + { + RpcBindingVectorFree(&BindingVector); + BindingVector = nullptr; + } +} + +// +// Rpc method to retrieve client context handle +// +void RemoteOpen( + _In_ handle_t hBinding, + _Out_ PPCONTEXT_HANDLE_TYPE pphContext) +{ + *pphContext = static_cast(midl_user_allocate(sizeof(METERING_CONTEXT))); + METERING_CONTEXT* meteringContext = static_cast(*pphContext); + meteringContext->metering = new Metering(DEFAULT_METERING_PERIOD); +} + +// +// Rpc method to close the client context handle +// +void RemoteClose(_Inout_ PPCONTEXT_HANDLE_TYPE pphContext) +{ + if (*pphContext == nullptr) + { + //Log error, client tried to close a NULL handle. + return; + } + + METERING_CONTEXT* meteringContext = static_cast(*pphContext); + delete meteringContext->metering; + MIDL_user_free(meteringContext); + + // This tells the run-time, when it is marshalling the out + // parameters, that the context handle has been closed normally. + *pphContext = nullptr; +} + +// +// Routine to cleanup client context when client has died with active +// connection with server +// +void __RPC_USER PCONTEXT_HANDLE_TYPE_rundown( + _In_ PCONTEXT_HANDLE_TYPE phContext) +{ + StopMetering(phContext); + RemoteClose(&phContext); +} + +#pragma region METERING_RPCROUTINES + +void StartMetering( + _In_ PCONTEXT_HANDLE_TYPE phContext, + _In_ __int64 period, + _In_ __int64 context) +{ + std::cout << "start metering" << std::endl; + METERING_CONTEXT* meteringContext = static_cast(phContext); + meteringContext->metering->StartMetering(period, context); + std::cout << "done metering" << std::endl; +} + +void SetSamplePeriod( + _In_ PCONTEXT_HANDLE_TYPE phContext, + _In_ __int64 period) +{ + METERING_CONTEXT* meteringContext = static_cast(phContext); + meteringContext->metering->SetSamplePeriod(period); +} + + +void StopMetering(_In_ PCONTEXT_HANDLE_TYPE phContext) +{ + METERING_CONTEXT* meteringContext = static_cast(phContext); + meteringContext->metering->StopMetering(); +} + +#pragma endregion METERING_RPCROUTINES + +/******************************************************/ +/* MIDL allocate and free */ +/******************************************************/ + +void __RPC_FAR * __RPC_USER midl_user_allocate(_In_ size_t len) +{ + return(malloc(len)); +} + +void __RPC_USER midl_user_free(_In_ void __RPC_FAR* ptr) +{ + free(ptr); +} diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.h new file mode 100644 index 00000000..bc7294db --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.h @@ -0,0 +1,16 @@ +#include "metering.h" + +#define RPC_STATIC_ENDPOINT L"HsaSampleRpcEndpoint" + +// Client context used for making rpc calls using context handle +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa378674(v=vs.85).aspx +typedef struct +{ + RpcServer::Metering* metering; +} METERING_CONTEXT; + +// Create a rpc server endpoint and listen to incoming rpc calls +DWORD RpcServerStart(); + +// Signal the rpc server to stop listening to incoming rpc calls +void RpcServerDisconnect(); diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj new file mode 100644 index 00000000..b5c043dc --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj @@ -0,0 +1,284 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {ADFC4322-5F0E-5BFD-83DA-19B35EFD513B} + Win32Proj + RpcServer + 10.0.16299.0 + + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + true + + + true + $(SolutionDir)$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + %(AdditionalIncludeDirectories);$(OutDir) + + + Console + true + onecoreuap.lib;%(AdditionalDependencies);rpcrt4.lib + false + %(IgnoreSpecificDefaultLibraries);kernel32.lib;user32.lib;shell32.lib;gdi32.lib + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + %(AdditionalIncludeDirectories);$(OutDir) + + + Console + true + onecoreuap.lib;%(AdditionalDependencies);rpcrt4.lib + false + %(IgnoreSpecificDefaultLibraries);kernel32.lib;user32.lib;shell32.lib;gdi32.lib + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + %(AdditionalIncludeDirectories);$(OutDir) + + + Console + true + onecoreuap.lib;%(AdditionalDependencies);rpcrt4.lib + false + %(IgnoreSpecificDefaultLibraries);kernel32.lib;user32.lib;shell32.lib;gdi32.lib + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + %(AdditionalIncludeDirectories);$(OutDir) + MultiThreaded + + + Console + true + true + true + onecoreuap.lib;%(AdditionalDependencies);ucrt.lib;rpcrt4.lib;libcmt.lib;libvcruntime.lib + true + %(IgnoreSpecificDefaultLibraries);kernel32.lib;user32.lib;shell32.lib;gdi32.lib + /VERBOSE %(AdditionalOptions) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions); + true + %(AdditionalIncludeDirectories);$(OutDir) + MultiThreaded + + + Console + true + true + true + onecoreuap.lib;%(AdditionalDependencies);ucrt.lib;rpcrt4.lib;libcmt.lib;libvcruntime.lib + true + %(IgnoreSpecificDefaultLibraries);kernel32.lib;user32.lib;shell32.lib;gdi32.lib + /VERBOSE %(AdditionalOptions) + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + %(AdditionalIncludeDirectories);$(OutDir) + MultiThreaded + + + Console + true + true + true + onecoreuap.lib;%(AdditionalDependencies);ucrt.lib;rpcrt4.lib;libcmt.lib;libvcruntime.lib + true + %(IgnoreSpecificDefaultLibraries);kernel32.lib;user32.lib;shell32.lib;gdi32.lib + /VERBOSE %(AdditionalOptions) + + + + + + + + + + + + + + NotUsing + NotUsing + NotUsing + NotUsing + NotUsing + NotUsing + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj.filters b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj.filters new file mode 100644 index 00000000..9644ad4e --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/RpcServer.vcxproj.filters @@ -0,0 +1,76 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.cpp b/general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.cpp new file mode 100644 index 00000000..793a7009 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.cpp @@ -0,0 +1,155 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "stdafx.h" + +#pragma region Includes +#include "SampleService.h" +#include "RpcServer.h" +#include +#pragma endregion + +CSampleService::CSampleService( + PWSTR pszServiceName, + BOOL fCanStop, + BOOL fCanShutdown, + BOOL fCanPauseContinue) + : CServiceBase(pszServiceName, fCanStop, fCanShutdown, fCanPauseContinue) +{ +} + +void CSampleService::WriteEventLogEntry(PWSTR pszMessage, BYTE bLevel) +{ + if (IsConsoleRun()) + { + wprintf(L"%d: %ls\n", bLevel, pszMessage); + } + __super::WriteEventLogEntry(pszMessage, bLevel); +} + +CSampleService::~CSampleService(void) +{ +} + +// +// This is the thread pool work callback function. +// +VOID CALLBACK ServiceWorkerThread( + _In_ PTP_CALLBACK_INSTANCE /*Instance*/, + _In_ PVOID Parameter, + _In_ PTP_WORK /*Work*/) +{ + // + // Do something when the work callback is invoked. + // + { + _int64 status = RpcServerStart(); + if (status) + { + CSampleService* sampleService = static_cast(Parameter); + sampleService->Stop(); + } + } + + return; +} + +// +// FUNCTION: CSampleService::OnStart(DWORD, LPWSTR *) +// +// PURPOSE: The 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. +// +// PARAMETERS: +// * dwArgc - number of command line arguments +// * lpszArgv - array of command line arguments +// +// 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. +// +void CSampleService::OnStart( + _In_ DWORD dwArgc, + _In_ LPWSTR *lpszArgv) +{ + // Log a service start message to the Application log. + WriteEventLogEntry(L"CppWindowsService in OnStart", TRACE_LEVEL_INFORMATION); + + // Queue the main service function for execution in a worker thread. + PTP_WORK_CALLBACK workcallback = ServiceWorkerThread; + m_work = CreateThreadpoolWork(workcallback, this, nullptr); + + if (NULL == m_work) + { + // TODO: Capture get last error + WriteEventLogEntry(L"CreateThreadpoolWork failed", TRACE_LEVEL_ERROR); + } + + // + // Submit the work to the pool. Because this was a pre-allocated + // work item (using CreateThreadpoolWork), it is guaranteed to execute. + // + SubmitThreadpoolWork(m_work); +} + +// +// FUNCTION: CSampleService::ConsoleRun() +// +// PURPOSE: The function is executed to simulate OnStart in +// console mode. +// +void CSampleService::ConsoleRun() +{ + m_runningInConsole = true; + + WriteEventLogEntry(L"Starting Rpc Server..", TRACE_LEVEL_INFORMATION); + long status = RpcServerStart(); + + if (status) + { + printf_s("RpcServerConnect returned: 0x%x\n", status); + WriteEventLogEntry(L"Starting Rpc Server..", TRACE_LEVEL_INFORMATION); + exit(static_cast(status)); + } +} + +// +// FUNCTION: CSampleService::OnStop() +// +// PURPOSE: The 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. +// +// COMMENTS: +// Be sure to periodically call ReportServiceStatus() with +// SERVICE_STOP_PENDING if the procedure is going to take long time. +// +void CSampleService::OnStop() +{ + // Log a service stop message to the Application log. + WriteEventLogEntry(L"CppWindowsService in OnStop", TRACE_LEVEL_INFORMATION); + + // Instruct server to stop listening to remote procedure calls and + // unregister rpc interface + RpcServerDisconnect(); +} \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.h new file mode 100644 index 00000000..04621b3e --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/SampleService.h @@ -0,0 +1,46 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +// 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. + +#pragma once + +#include "ServiceBase.h" + +class CSampleService : public CServiceBase +{ +public: + + CSampleService(PWSTR pszServiceName, + BOOL fCanStop = TRUE, + BOOL fCanShutdown = TRUE, + BOOL fCanPauseContinue = FALSE); + void ConsoleRun(); + bool IsConsoleRun() + { + return m_runningInConsole; + } + void WriteEventLogEntry(PWSTR pszMessage, BYTE bLevel) override; + virtual ~CSampleService(void); + +protected: + + virtual void OnStart(DWORD dwArgc, PWSTR *pszArgv) override; + virtual void OnStop() override; + + +private: + PTP_WORK m_work = nullptr; + bool m_runningInConsole = false; +}; \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.cpp b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.cpp new file mode 100644 index 00000000..117d740c --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.cpp @@ -0,0 +1,566 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "stdafx.h" +#pragma region Includes + +#include "ServiceBase.h" +#include +#include +#include +#include +#pragma endregion + +// +// HSA Service trace event provider +// {BE2E880E-F79F-4C30-9C95-09F003A0A7EA} +// +EXTERN_C __declspec(selectany) const GUID HSA_SERVICE_PROVIDER_GUID = { 0xbe2e880e, 0xf79f, 0x4c30,{ 0x9c, 0x95, 0x9, 0xf0, 0x3, 0xa0, 0xa7, 0xea } }; + +#pragma region Static Members + +// Initialize the singleton service instance. +CServiceBase *CServiceBase::s_service = nullptr; + + +// +// FUNCTION: CServiceBase::Run(CServiceBase &) +// +// PURPOSE: 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. +// +// PARAMETERS: +// * 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 }, + { nullptr, nullptr } + }; + + // 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); +} + + +// +// FUNCTION: CServiceBase::ServiceMain(DWORD, PWSTR *) +// +// PURPOSE: Entry point for the service. It registers the handler function +// for the service and starts the service. +// +// PARAMETERS: +// * dwArgc - number of command line arguments +// * lpszArgv - array of command line arguments +// +void WINAPI CServiceBase::ServiceMain(DWORD dwArgc, PWSTR *pszArgv) +{ + 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(dwArgc, pszArgv); +} + + +// +// FUNCTION: CServiceBase::ServiceCtrlHandler(DWORD) +// +// PURPOSE: The function is called by the SCM whenever a control code is +// sent to the service. +// +// PARAMETERS: +// * dwCtrlCode - 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 ranges from 128 +// to 255. +// +void WINAPI CServiceBase::ServiceCtrlHandler(DWORD dwCtrl) +{ + switch (dwCtrl) + { + 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 + +// +// FUNCTION: CServiceBase::CServiceBase(PWSTR, BOOL, BOOL, BOOL) +// +// PURPOSE: The constructor of CServiceBase. It initializes a new instance +// of the CServiceBase class. The optional parameters (fCanStop, +/// fCanShutdown and fCanPauseContinue) allow you to specify whether the +// service can be stopped, paused and continued, or be notified when system +// shutdown occurs. +// +// PARAMETERS: +// * pszServiceName - the name of the service +// * fCanStop - the service can be stopped +// * fCanShutdown - the service is notified when system shutdown occurs +// * fCanPauseContinue - the service can be paused and continued +// +CServiceBase::CServiceBase( + PWSTR pszServiceName, + BOOL fCanStop, + BOOL fCanShutdown, + BOOL fCanPauseContinue) +{ + // Service name must be a valid string and cannot be NULL. + m_name = (pszServiceName == nullptr) ? L"" : pszServiceName; + + m_statusHandle = nullptr; + + // 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 (fCanStop) + dwControlsAccepted |= SERVICE_ACCEPT_STOP; + if (fCanShutdown) + dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN; + if (fCanPauseContinue) + 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; + + NTSTATUS status = EventRegister(&HSA_SERVICE_PROVIDER_GUID, + nullptr, + nullptr, + &m_etwRegHandle); + if (ERROR_SUCCESS != status) + { + wprintf(L"Provider not registered. EventRegister failed with %d\n", status); + } +} + + +// +// FUNCTION: CServiceBase::~CServiceBase() +// +// PURPOSE: The virtual destructor of CServiceBase. +// +CServiceBase::~CServiceBase(void) +{ + if (m_etwRegHandle != NULL) + { + EventUnregister(m_etwRegHandle); + } +} + +#pragma endregion + + +#pragma region Service Start, Stop, Pause, Continue, and Shutdown + +// +// FUNCTION: CServiceBase::Start(DWORD, PWSTR *) +// +// PURPOSE: The 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. +// +// PARAMETERS: +// * dwArgc - number of command line arguments +// * lpszArgv - array of command line arguments +// +void CServiceBase::Start(DWORD dwArgc, PWSTR *pszArgv) +{ + WriteEventLogEntry(L"Service trying to start.", TRACE_LEVEL_ERROR); + try + { + // Tell SCM that the service is starting. + SetServiceStatus(SERVICE_START_PENDING); + + // Perform service-specific initialization. + OnStart(dwArgc, pszArgv); + + // Tell SCM that the service is started. + SetServiceStatus(SERVICE_RUNNING); + } + catch (DWORD dwError) + { + // Log the error. + WriteErrorLogEntry(L"Service Start", dwError); + + // Set the service status to be stopped. + SetServiceStatus(SERVICE_STOPPED, dwError); + } + catch (...) + { + // Log the error. + WriteEventLogEntry(L"Service failed to start.", TRACE_LEVEL_ERROR); + + // Set the service status to be stopped. + SetServiceStatus(SERVICE_STOPPED); + } +} + + +// +// FUNCTION: CServiceBase::OnStart(DWORD, PWSTR *) +// +// PURPOSE: 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. +// +// PARAMETERS: +// * dwArgc - number of command line arguments +// * lpszArgv - array of command line arguments +// +void CServiceBase::OnStart(DWORD dwArgc, PWSTR *pszArgv) +{ +} + + +// +// FUNCTION: CServiceBase::Stop() +// +// PURPOSE: The 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. +// +void CServiceBase::Stop() +{ + DWORD dwOriginalState = 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 dwError) + { + // Log the error. + WriteErrorLogEntry(L"Service Stop", dwError); + + // Set the orginal service status. + SetServiceStatus(dwOriginalState); + } + catch (...) + { + // Log the error. + WriteEventLogEntry(L"Service failed to stop.", TRACE_LEVEL_ERROR); + + // Set the orginal service status. + SetServiceStatus(dwOriginalState); + } +} + + +// +// FUNCTION: CServiceBase::OnStop() +// +// PURPOSE: 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. +// +void CServiceBase::OnStop() +{ +} + + +// +// FUNCTION: CServiceBase::Pause() +// +// PURPOSE: 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. +// +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 dwError) + { + // Log the error. + WriteErrorLogEntry(L"Service Pause", dwError); + + // Tell SCM that the service is still running. + SetServiceStatus(SERVICE_RUNNING); + } + catch (...) + { + // Log the error. + WriteEventLogEntry(L"Service failed to pause.", TRACE_LEVEL_ERROR); + + // Tell SCM that the service is still running. + SetServiceStatus(SERVICE_RUNNING); + } +} + + +// +// FUNCTION: CServiceBase::OnPause() +// +// PURPOSE: 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. +// +void CServiceBase::OnPause() +{ +} + + +// +// FUNCTION: CServiceBase::Continue() +// +// PURPOSE: 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. +// +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 dwError) + { + // Log the error. + WriteErrorLogEntry(L"Service Continue", dwError); + + // Tell SCM that the service is still paused. + SetServiceStatus(SERVICE_PAUSED); + } + catch (...) + { + // Log the error. + WriteEventLogEntry(L"Service failed to resume.", TRACE_LEVEL_ERROR); + + // Tell SCM that the service is still paused. + SetServiceStatus(SERVICE_PAUSED); + } +} + + +// +// FUNCTION: CServiceBase::OnContinue() +// +// PURPOSE: 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. +// +void CServiceBase::OnContinue() +{ +} + + +// +// FUNCTION: CServiceBase::Shutdown() +// +// PURPOSE: 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. +// +void CServiceBase::Shutdown() +{ + try + { + // Perform service-specific shutdown operations. + OnShutdown(); + + // Tell SCM that the service is stopped. + SetServiceStatus(SERVICE_STOPPED); + } + catch (DWORD dwError) + { + // Log the error. + WriteErrorLogEntry(L"Service Shutdown", dwError); + } + catch (...) + { + // Log the error. + WriteEventLogEntry(L"Service failed to shut down.", TRACE_LEVEL_ERROR); + } +} + + +// +// FUNCTION: CServiceBase::OnShutdown() +// +// PURPOSE: When implemented in a derived class, executes when the system +// is shutting down. Specifies what should occur immediately prior to the +// system shutting down. +// +void CServiceBase::OnShutdown() +{ +} + +#pragma endregion + + +#pragma region Helper Functions + +// +// FUNCTION: CServiceBase::SetServiceStatus(DWORD, DWORD, DWORD) +// +// PURPOSE: The function sets the service status and reports the status to +// the SCM. +// +// PARAMETERS: +// * dwCurrentState - the state of the service +// * dwWin32ExitCode - error code to report +// * dwWaitHint - estimated time for pending operation, in milliseconds +// +void CServiceBase::SetServiceStatus( + _In_ DWORD dwCurrentState, + _In_ DWORD dwWin32ExitCode, + _In_ DWORD dwWaitHint) +{ + static DWORD dwCheckPoint = 1; + + // Fill in the SERVICE_STATUS structure of the service. + + m_status.dwCurrentState = dwCurrentState; + m_status.dwWin32ExitCode = dwWin32ExitCode; + m_status.dwWaitHint = dwWaitHint; + + m_status.dwCheckPoint = + ((dwCurrentState == SERVICE_RUNNING) || + (dwCurrentState == SERVICE_STOPPED)) ? + 0 : dwCheckPoint++; + + // Report the status of the service to the SCM. + ::SetServiceStatus(m_statusHandle, &m_status); +} + + +// +// FUNCTION: CServiceBase::WriteEventLogEntry(PWSTR, WORD) +// +// PURPOSE: Log an event. +// +// PARAMETERS: +// * pszMessage - string message to be logged. +// * wType - the type of event to be logged. The parameter can be one of +// the following values. +// +// EVENTLOG_SUCCESS +// EVENTLOG_AUDIT_FAILURE +// EVENTLOG_AUDIT_SUCCESS +// EVENTLOG_ERROR_TYPE +// EVENTLOG_INFORMATION_TYPE +// EVENTLOG_WARNING_TYPE +// +void CServiceBase::WriteEventLogEntry( + _In_ PWSTR pszMessage, + _In_ BYTE bLevel) +{ + if (m_etwRegHandle != NULL) + { + EventWriteString(m_etwRegHandle, bLevel, 0, pszMessage); + } +} + +// +// FUNCTION: CServiceBase::WriteErrorLogEntry(PWSTR, DWORD) +// +// PURPOSE: Log an event. +// +// PARAMETERS: +// * pszFunction - the function that gives the error +// * dwError - the error code +// +void CServiceBase::WriteErrorLogEntry( + _In_ PWSTR pszFunction, + _In_ DWORD dwError) +{ + wchar_t szMessage[260]; + StringCchPrintf(szMessage, ARRAYSIZE(szMessage), + L"%s failed w/err 0x%08lx", pszFunction, dwError); + WriteEventLogEntry(szMessage, TRACE_LEVEL_ERROR); +} + +#pragma endregion \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.h new file mode 100644 index 00000000..ebae808e --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceBase.h @@ -0,0 +1,121 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +// 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. + +#pragma once + +#include +#include + +class CServiceBase +{ +public: + + // 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. + static BOOL Run(CServiceBase& service); + + // Service object constructor. The optional parameters (fCanStop, + // fCanShutdown and fCanPauseContinue) allow you to specify whether the + // service can be stopped, paused and continued, or be notified when + // system shutdown occurs. + CServiceBase(PWSTR pszServiceName, + BOOL fCanStop = TRUE, + BOOL fCanShutdown = TRUE, + BOOL fCanPauseContinue = FALSE); + + // Service object destructor. + virtual ~CServiceBase(void); + + // Stop the service. + void Stop(); + +protected: + + // 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. + virtual void OnStart(DWORD dwArgc, PWSTR *pszArgv); + + // 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. + virtual void OnStop(); + + // 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. + virtual void OnPause(); + + // 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. + virtual void OnContinue(); + + // When implemented in a derived class, executes when the system is + // shutting down. Specifies what should occur immediately prior to the + // system shutting down. + virtual void OnShutdown(); + + // Set the service status and report the status to the SCM. + void SetServiceStatus(DWORD dwCurrentState, + DWORD dwWin32ExitCode = NO_ERROR, + DWORD dwWaitHint = 0); + + // Log an event. + virtual void WriteEventLogEntry(PWSTR pszMessage, BYTE bLevel); + + // Log an event. + void WriteErrorLogEntry(PWSTR pszFunction, + DWORD dwError = GetLastError()); + +private: + + // Entry point for the service. It registers the handler function for the + // service and starts the service. + static void WINAPI ServiceMain(DWORD dwArgc, LPWSTR *lpszArgv); + + // The function is called by the SCM whenever a control code is sent to + // the service. + static void WINAPI ServiceCtrlHandler(DWORD dwCtrl); + + // Start the service. + void Start(DWORD dwArgc, PWSTR *pszArgv); + + // Pause the service. + void Pause(); + + // Resume the service after being paused. + void Continue(); + + // Execute when the system is shutting down. + 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; + + REGHANDLE m_etwRegHandle; +}; \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.cpp b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.cpp new file mode 100644 index 00000000..27b107a9 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.cpp @@ -0,0 +1,191 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "stdafx.h" +#pragma region "Includes" + +#include +#include +#include "ServiceInstaller.h" +#pragma endregion + + +// +// FUNCTION: InstallService +// +// PURPOSE: Install the current application as a service to the local +// service control manager database. +// +// PARAMETERS: +// * pszServiceName - the name of the service to be installed +// * pszDisplayName - the display name of the service +// * dwStartType - the service start option. This parameter can be one of +// the following values: SERVICE_AUTO_START, SERVICE_BOOT_START, +// SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START. +// * pszDependencies - a pointer to a double null-terminated array of null- +// separated names of services or load ordering groups that the system +// must start before this service. +// * pszAccount - the name of the account under which the service runs. +// * pszPassword - the password to the account name. +// +// NOTE: If the function fails to install the service, it prints the error +// in the standard output stream for users to diagnose the problem. +// +void InstallService( + _In_ PWSTR pszServiceName, + _In_ PWSTR pszDisplayName, + _In_ DWORD dwStartType, + _In_ PWSTR pszDependencies, + _In_ PWSTR pszAccount, + _In_ PWSTR pszPassword) +{ + wchar_t szPath[MAX_PATH]; + SC_HANDLE schSCManager = nullptr; + SC_HANDLE schService = nullptr; + + if (GetModuleFileName(nullptr, szPath, ARRAYSIZE(szPath)) == 0) + { + wprintf(L"GetModuleFileName failed w/err 0x%08lx\n", GetLastError()); + goto Cleanup; + } + + // Open the local default service control manager database + schSCManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT | + SC_MANAGER_CREATE_SERVICE); + if (schSCManager == nullptr) + { + wprintf(L"OpenSCManager failed w/err 0x%08lx\n", GetLastError()); + goto Cleanup; + } + + // Install the service into SCM by calling CreateService + schService = CreateService( + schSCManager, // SCManager database + pszServiceName, // Name of service + pszDisplayName, // Name to display + SERVICE_QUERY_STATUS, // Desired access + SERVICE_WIN32_OWN_PROCESS, // Service type + dwStartType, // Service start type + SERVICE_ERROR_NORMAL, // Error control type + szPath, // Service's binary + nullptr, // No load ordering group + nullptr, // No tag identifier + pszDependencies, // Dependencies + pszAccount, // Service running account + pszPassword // Password of the account + ); + + if (schService == nullptr) + { + wprintf(L"CreateService failed w/err 0x%08lx\n", GetLastError()); + goto Cleanup; + } + + wprintf(L"%s is installed.\n", pszServiceName); + +Cleanup: + // Centralized cleanup for all allocated resources. + if (schSCManager) + { + CloseServiceHandle(schSCManager); + schSCManager = nullptr; + } + if (schService) + { + CloseServiceHandle(schService); + schService = nullptr; + } +} + + +// +// FUNCTION: UninstallService +// +// PURPOSE: Stop and remove the service from the local service control +// manager database. +// +// PARAMETERS: +// * pszServiceName - the name of the service to be removed. +// +// NOTE: If the function fails to uninstall the service, it prints the +// error in the standard output stream for users to diagnose the problem. +// +void UninstallService(_In_ PWSTR pszServiceName) +{ + SC_HANDLE schSCManager = nullptr; + SC_HANDLE schService = nullptr; + SERVICE_STATUS ssSvcStatus = {}; + + // Open the local default service control manager database + schSCManager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT); + if (schSCManager == nullptr) + { + wprintf(L"OpenSCManager failed w/err 0x%08lx\n", GetLastError()); + goto Cleanup; + } + + // Open the service with delete, stop, and query status permissions + schService = OpenService(schSCManager, pszServiceName, SERVICE_STOP | + SERVICE_QUERY_STATUS | DELETE); + if (schService == nullptr) + { + wprintf(L"OpenService failed w/err 0x%08lx\n", GetLastError()); + goto Cleanup; + } + + // Try to stop the service + if (ControlService(schService, SERVICE_CONTROL_STOP, &ssSvcStatus)) + { + wprintf(L"Stopping %s.", pszServiceName); + Sleep(1000); + + while (QueryServiceStatus(schService, &ssSvcStatus)) + { + if (ssSvcStatus.dwCurrentState == SERVICE_STOP_PENDING) + { + wprintf(L"."); + Sleep(1000); + } + else break; + } + + if (ssSvcStatus.dwCurrentState == SERVICE_STOPPED) + { + wprintf(L"\n%s is stopped.\n", pszServiceName); + } + else + { + wprintf(L"\n%s failed to stop.\n", pszServiceName); + } + } + + // Now remove the service by calling DeleteService. + if (!DeleteService(schService)) + { + wprintf(L"DeleteService failed w/err 0x%08lx\n", GetLastError()); + goto Cleanup; + } + + wprintf(L"%s is removed.\n", pszServiceName); + +Cleanup: + // Centralized cleanup for all allocated resources. + if (schSCManager) + { + CloseServiceHandle(schSCManager); + schSCManager = nullptr; + } + if (schService) + { + CloseServiceHandle(schService); + schService = nullptr; + } +} \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.h new file mode 100644 index 00000000..af6507e6 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/ServiceInstaller.h @@ -0,0 +1,57 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +// The file declares functions that install and uninstall the service. + +#pragma once + +// +// FUNCTION: InstallService +// +// PURPOSE: Install the current application as a service to the local +// service control manager database. +// +// PARAMETERS: +// * pszServiceName - the name of the service to be installed +// * pszDisplayName - the display name of the service +// * dwStartType - the service start option. This parameter can be one of +// the following values: SERVICE_AUTO_START, SERVICE_BOOT_START, +// SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START. +// * pszDependencies - a pointer to a double null-terminated array of null- +// separated names of services or load ordering groups that the system +// must start before this service. +// * pszAccount - the name of the account under which the service runs. +// * pszPassword - the password to the account name. +// +// NOTE: If the function fails to install the service, it prints the error +// in the standard output stream for users to diagnose the problem. +// +void InstallService(PWSTR pszServiceName, + PWSTR pszDisplayName, + DWORD dwStartType, + PWSTR pszDependencies, + PWSTR pszAccount, + PWSTR pszPassword); + + +// +// FUNCTION: UninstallService +// +// PURPOSE: Stop and remove the service from the local service control +// manager database. +// +// PARAMETERS: +// * pszServiceName - the name of the service to be removed. +// +// NOTE: If the function fails to uninstall the service, it prints the +// error in the standard output stream for users to diagnose the problem. +// +void UninstallService(PWSTR pszServiceName); diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.cpp b/general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.cpp new file mode 100644 index 00000000..ce19a949 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// RpcServer.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.h new file mode 100644 index 00000000..306c4330 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#include +#include + +#define NOMINMAX // disable min and max macros in windows.h + +extern bool ShutdownRequested; diff --git a/general/WinHEC 2017 Lab/Toaster Driver/Service/targetver.h b/general/WinHEC 2017 Lab/Toaster Driver/Service/targetver.h new file mode 100644 index 00000000..87c0086d --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/Service/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster.sln b/general/WinHEC 2017 Lab/Toaster Driver/toaster.sln new file mode 100644 index 00000000..35e5dcbc --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toaster", "toaster\toaster.vcxproj", "{2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|ARM.ActiveCfg = Debug|ARM + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|ARM.Build.0 = Debug|ARM + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|ARM64.Build.0 = Debug|ARM64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|x64.ActiveCfg = Debug|x64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|x64.Build.0 = Debug|x64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|x86.ActiveCfg = Debug|Win32 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Debug|x86.Build.0 = Debug|Win32 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|ARM.ActiveCfg = Release|ARM + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|ARM.Build.0 = Release|ARM + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|ARM64.ActiveCfg = Release|ARM64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|ARM64.Build.0 = Release|ARM64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|x64.ActiveCfg = Release|x64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|x64.Build.0 = Release|x64 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|x86.ActiveCfg = Release|Win32 + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/driver.h b/general/WinHEC 2017 Lab/Toaster Driver/toaster/driver.h new file mode 100644 index 00000000..8e7ade01 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/driver.h @@ -0,0 +1,80 @@ +/*++ +Copyright (c) 1990-2000 Microsoft Corporation All Rights Reserved + +Module Name: + + driver.h + +Abstract: + + This module contains the common declarations for the + bus, function and filter drivers. + +Environment: + + kernel mode only + +--*/ + +//#include "public.h" + +// +// Define an Interface Guid to access the proprietary toaster interface. +// This guid is used to identify a specific interface in IRP_MN_QUERY_INTERFACE +// handler. +// + +DEFINE_GUID(GUID_TOASTER_INTERFACE_STANDARD, + 0xe0b27630, 0x5434, 0x11d3, 0xb8, 0x90, 0x0, 0xc0, 0x4f, 0xad, 0x51, 0x71); +// {E0B27630-5434-11d3-B890-00C04FAD5171} + + +// +// GUID definition are required to be outside of header inclusion pragma to avoid +// error during precompiled headers. +// + +#ifndef __DRIVER_H +#define __DRIVER_H + +// +// Define Interface reference/dereference routines for +// Interfaces exported by IRP_MN_QUERY_INTERFACE +// + +typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context); +typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context); + +typedef +BOOLEAN +(*PTOASTER_GET_CRISPINESS_LEVEL)( + IN PVOID Context, + OUT PUCHAR Level + ); + +typedef +BOOLEAN +(*PTOASTER_SET_CRISPINESS_LEVEL)( + IN PVOID Context, + OUT UCHAR Level + ); + +typedef +BOOLEAN +(*PTOASTER_IS_CHILD_PROTECTED)( + IN PVOID Context + ); + +// +// Interface for getting and setting power level etc., +// +typedef struct _TOASTER_INTERFACE_STANDARD { + INTERFACE InterfaceHeader; + PTOASTER_GET_CRISPINESS_LEVEL GetCrispinessLevel; + PTOASTER_SET_CRISPINESS_LEVEL SetCrispinessLevel; + PTOASTER_IS_CHILD_PROTECTED IsSafetyLockEnabled; //): +} TOASTER_INTERFACE_STANDARD, *PTOASTER_INTERFACE_STANDARD; + + +#endif + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/public.h b/general/WinHEC 2017 Lab/Toaster Driver/toaster/public.h new file mode 100644 index 00000000..0628f95f --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/public.h @@ -0,0 +1,167 @@ +/*++ +Copyright (c) 1990-2000 Microsoft Corporation All Rights Reserved + +Module Name: + + public.h + +Abstract: + + This module contains the common declarations shared by driver + and user applications. + +Environment: + + user and kernel + +--*/ + +// +// Define an Interface Guid for bus enumerator class. +// This GUID is used to register (IoRegisterDeviceInterface) +// an instance of an interface so that enumerator application +// can send an ioctl to the bus driver. +// + +DEFINE_GUID (GUID_DEVINTERFACE_BUSENUM_TOASTER, + 0xD35F7840, 0x6A0C, 0x11d2, 0xB8, 0x41, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +// {D35F7840-6A0C-11d2-B841-00C04FAD5171} + +// +// Define an Interface Guid for toaster device class. +// This GUID is used to register (IoRegisterDeviceInterface) +// an instance of an interface so that user application +// can control the toaster device. +// + +DEFINE_GUID (GUID_DEVINTERFACE_TOASTER, + 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +//{781EF630-72B2-11d2-B852-00C04FAD5171} + +// +// Define a Setup Class GUID for Toaster Class. This is same +// as the TOASTSER CLASS guid in the INF files. +// + +DEFINE_GUID (GUID_DEVCLASS_TOASTER, + 0xB85B7C50, 0x6A01, 0x11d2, 0xB8, 0x41, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +//{B85B7C50-6A01-11d2-B841-00C04FAD5171} + +// +// Define a WMI GUID to get busenum info. +// + +DEFINE_GUID (TOASTER_BUS_WMI_STD_DATA_GUID, + 0x0006A660, 0x8F12, 0x11d2, 0xB8, 0x54, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); +//{0006A660-8F12-11d2-B854-00C04FAD5171} + +// +// Define a WMI GUID to get toaster device info. +// + +DEFINE_GUID (TOASTER_WMI_STD_DATA_GUID, + 0xBBA21300L, 0x6DD3, 0x11d2, 0xB8, 0x44, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); + +// +// Define a WMI GUID to represent device arrival notification WMIEvent class. +// + +DEFINE_GUID (TOASTER_NOTIFY_DEVICE_ARRIVAL_EVENT, + 0x1cdaff1, 0xc901, 0x45b4, 0xb3, 0x59, 0xb5, 0x54, 0x27, 0x25, 0xe2, 0x9c); +// {01CDAFF1-C901-45b4-B359-B5542725E29C} + + +// +// GUID definition are required to be outside of header inclusion pragma to avoid +// error during precompiled headers. +// + +#ifndef __PUBLIC_H +#define __PUBLIC_H + +#define BUS_HARDWARE_IDS L"{B85B7C50-6A01-11d2-B841-00C04FAD5171}\\MsToaster\0" +#define BUS_HARDWARE_IDS_LENGTH sizeof (BUS_HARDWARE_IDS) + +#define BUSENUM_COMPATIBLE_IDS L"{B85B7C50-6A01-11d2-B841-00C04FAD5171}\\MsCompatibleToaster\0" +#define BUSENUM_COMPATIBLE_IDS_LENGTH sizeof(BUSENUM_COMPATIBLE_IDS) + + +#define FILE_DEVICE_BUSENUM FILE_DEVICE_BUS_EXTENDER + +#define BUSENUM_IOCTL(_index_) \ + CTL_CODE (FILE_DEVICE_BUSENUM, _index_, METHOD_BUFFERED, FILE_READ_DATA) + +#define IOCTL_BUSENUM_PLUGIN_HARDWARE BUSENUM_IOCTL (0x0) +#define IOCTL_BUSENUM_UNPLUG_HARDWARE BUSENUM_IOCTL (0x1) +#define IOCTL_BUSENUM_EJECT_HARDWARE BUSENUM_IOCTL (0x2) +#define IOCTL_TOASTER_DONT_DISPLAY_IN_UI_DEVICE BUSENUM_IOCTL (0x3) + +// +// Data structure used in PlugIn and UnPlug ioctls +// + +typedef struct _BUSENUM_PLUGIN_HARDWARE +{ + // + // sizeof (struct _BUSENUM_HARDWARE) + // + IN ULONG Size; + + // + // Unique serial number of the device to be enumerated. + // Enumeration will be failed if another device on the + // bus has the same serail number. + // + + IN ULONG SerialNo; + + // + // An array of (zero terminated wide character strings). The array itself + // also null terminated (ie, MULTI_SZ) + // + #pragma warning(disable:4200) // nonstandard extension used + + IN WCHAR HardwareIDs[]; + + #pragma warning(default:4200) + +} BUSENUM_PLUGIN_HARDWARE, *PBUSENUM_PLUGIN_HARDWARE; + +typedef struct _BUSENUM_UNPLUG_HARDWARE +{ + // + // sizeof (struct _REMOVE_HARDWARE) + // + + IN ULONG Size; + + // + // Serial number of the device to be plugged out + // + + ULONG SerialNo; + + ULONG Reserved[2]; + +} BUSENUM_UNPLUG_HARDWARE, *PBUSENUM_UNPLUG_HARDWARE; + +typedef struct _BUSENUM_EJECT_HARDWARE +{ + // + // sizeof (struct _EJECT_HARDWARE) + // + + IN ULONG Size; + + // + // Serial number of the device to be ejected + // + + ULONG SerialNo; + + ULONG Reserved[2]; + +} BUSENUM_EJECT_HARDWARE, *PBUSENUM_EJECT_HARDWARE; + +#endif + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.c b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.c new file mode 100644 index 00000000..6ed215db --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.c @@ -0,0 +1,418 @@ +/*++ + +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: + + Toaster.c + +Abstract: + + This is a simple form of function driver for toaster device. The driver + doesn't handle any PnP and Power events because the framework provides + default behavior for those events. This driver has enough support to + allow an user application (toast/notify.exe) to open the device + interface registered by the driver and send read, write or ioctl requests. + +Environment: + + Kernel mode + +--*/ + +#include "toaster.h" + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (INIT, DriverEntry) +#pragma alloc_text (PAGE, ToasterEvtDeviceAdd) +#pragma alloc_text (PAGE, ToasterEvtIoRead) +#pragma alloc_text (PAGE, ToasterEvtIoWrite) +#pragma alloc_text (PAGE, ToasterEvtIoDeviceControl) +#endif + + +NTSTATUS +DriverEntry( + IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegistryPath + ) +/*++ + +Routine Description: + DriverEntry initializes the driver and is the first routine called by the + system after the driver is loaded. DriverEntry configures and creates a WDF driver + object. + . +Parameters Description: + + DriverObject - represents the instance of the function driver that is loaded + into memory. DriverObject is allocated by the system before the + driver is loaded, and it is released by the system after the system unloads + the function driver from memory. + + RegistryPath - represents the driver specific path in the Registry. + The function driver can use the path to store driver related data between + reboots. The path does not store hardware instance specific data. + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL otherwise. + +--*/ +{ + NTSTATUS status = STATUS_SUCCESS; + WDF_DRIVER_CONFIG config; + + KdPrint(("Toaster Function Driver Sample - Driver Framework Edition.\n")); + + // + // Initiialize driver config to control the attributes that + // are global to the driver. Note that framework by default + // provides a driver unload routine. If DriverEntry creates any resources + // that require clean-up in driver unload, + // you can manually override the default by supplying a pointer to the EvtDriverUnload + // callback in the config structure. In general xxx_CONFIG_INIT macros are provided to + // initialize most commonly used members. + // + + WDF_DRIVER_CONFIG_INIT( + &config, + ToasterEvtDeviceAdd + ); + + + // + // Create a framework driver object to represent our driver. + // + status = WdfDriverCreate( + DriverObject, + RegistryPath, + WDF_NO_OBJECT_ATTRIBUTES, // Driver Attributes + &config, // Driver Config Info + WDF_NO_HANDLE + ); + + if (!NT_SUCCESS(status)) { + KdPrint( ("WdfDriverCreate failed with status 0x%x\n", status)); + } + + return status; +} + + +NTSTATUS +ToasterEvtDeviceAdd( + IN WDFDRIVER Driver, + IN PWDFDEVICE_INIT DeviceInit + ) +/*++ +Routine Description: + + ToasterEvtDeviceAdd is called by the framework in response to AddDevice + call from the PnP manager. We create and initialize a WDF device object to + represent a new instance of toaster device. + +Arguments: + + Driver - Handle to a framework driver object created in DriverEntry + + DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure. + +Return Value: + + NTSTATUS + +--*/ +{ + NTSTATUS status = STATUS_SUCCESS; + PFDO_DATA fdoData; + WDF_IO_QUEUE_CONFIG queueConfig; + WDF_OBJECT_ATTRIBUTES fdoAttributes; + WDFDEVICE hDevice; + WDFQUEUE queue; + + UNREFERENCED_PARAMETER(Driver); + + PAGED_CODE(); + + KdPrint(("ToasterEvtDeviceAdd called\n")); + + // + // Initialize attributes and a context area for the device object. + // + // + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fdoAttributes, FDO_DATA); + + // + // Create a framework device object.This call will in turn create + // a WDM device object, attach to the lower stack, and set the + // appropriate flags and attributes. + // + status = WdfDeviceCreate(&DeviceInit, &fdoAttributes, &hDevice); + if (!NT_SUCCESS(status)) { + KdPrint( ("WdfDeviceCreate failed with status code 0x%x\n", status)); + return status; + } + + // + // Get the device context by using the accessor function specified in + // the WDF_DECLARE_CONTEXT_TYPE_WITH_NAME macro for FDO_DATA. + // + fdoData = ToasterFdoGetData(hDevice); + + // + // Tell the Framework that this device will need an interface + // + status = WdfDeviceCreateDeviceInterface( + hDevice, + (LPGUID) &GUID_DEVINTERFACE_TOASTER, + NULL // ReferenceString + ); + + if (!NT_SUCCESS (status)) { + KdPrint( ("WdfDeviceCreateDeviceInterface failed 0x%x\n", status)); + return status; + } + + // + // Register I/O callbacks to tell the framework that you are interested + // in handling IRP_MJ_READ, IRP_MJ_WRITE, and IRP_MJ_DEVICE_CONTROL requests. + // If a specific callback function is not specified for one ofthese, + // the request will be dispatched to the EvtIoDefault handler, if any. + // If there is no EvtIoDefault handler, the request will be failed with + // STATUS_INVALID_DEVICE_REQUEST. + // WdfIoQueueDispatchParallel means that we are capable of handling + // all the I/O requests simultaneously and we are responsible for protecting + // data that could be accessed by these callbacks simultaneously. + // A default queue gets all the requests that are not + // configured for forwarding using WdfDeviceConfigureRequestDispatching. + // + WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel); + + queueConfig.EvtIoRead = ToasterEvtIoRead; + queueConfig.EvtIoWrite = ToasterEvtIoWrite; + queueConfig.EvtIoDeviceControl = ToasterEvtIoDeviceControl; + + // + // By default, Static Driver Verifier (SDV) displays a warning if it + // doesn't find the EvtIoStop callback on a power-managed queue. + // The 'assume' below causes SDV to suppress this warning. If the driver + // has not explicitly set PowerManaged to WdfFalse, the framework creates + // power-managed queues when the device is not a filter driver. Normally + // the EvtIoStop is required for power-managed queues, but for this driver + // it is not needed b/c the driver doesn't hold on to the requests or + // forward them to other drivers. This driver completes the requests + // directly in the queue's handlers. If the EvtIoStop callback is not + // implemented, the framework waits for all driver-owned requests to be + // done before moving in the Dx/sleep states or before removing the + // device, which is the correct behavior for this type of driver. + // If the requests were taking an indeterminate amount of time to complete, + // or if the driver forwarded the requests to a lower driver/another stack, + // the queue should have an EvtIoStop/EvtIoResume. + // + __analysis_assume(queueConfig.EvtIoStop != 0); + status = WdfIoQueueCreate( + hDevice, + &queueConfig, + WDF_NO_OBJECT_ATTRIBUTES, + &queue + ); + __analysis_assume(queueConfig.EvtIoStop == 0); + + if (!NT_SUCCESS (status)) { + + KdPrint( ("WdfIoQueueCreate failed 0x%x\n", status)); + return status; + } + + return status; +} + +VOID +ToasterEvtIoRead ( + WDFQUEUE Queue, + WDFREQUEST Request, + size_t Length + ) +/*++ + +Routine Description: + + Performs read from the toaster device. This event is called when the + framework receives IRP_MJ_READ requests. + +Arguments: + + Queue - Handle to the framework queue object that is associated with the + I/O request. + Request - Handle to a framework request object. + + Lenght - Length of the data buffer associated with the request. + By default, the queue does not dispatch + zero length read & write requests to the driver and instead to + complete such requests with status success. So we will never get + a zero length request. + +Return Value: + + None. + +--*/ +{ + NTSTATUS status; + ULONG_PTR bytesCopied =0; + WDFMEMORY memory; + + UNREFERENCED_PARAMETER(Queue); + UNREFERENCED_PARAMETER(Length); + + PAGED_CODE(); + + KdPrint(( "ToasterEvtIoRead: Request: 0x%p, Queue: 0x%p\n", + Request, Queue)); + + // + // Get the request memory and perform read operation here + // + status = WdfRequestRetrieveOutputMemory(Request, &memory); + if(NT_SUCCESS(status) ) { + // + // Copy data into the memory buffer using WdfMemoryCopyFromBuffer + // + } + + WdfRequestCompleteWithInformation(Request, status, bytesCopied); +} + +VOID +ToasterEvtIoWrite ( + WDFQUEUE Queue, + WDFREQUEST Request, + size_t Length + ) +/*++ + +Routine Description: + + Performs write to the toaster device. This event is called when the + framework receives IRP_MJ_WRITE requests. + +Arguments: + + Queue - Handle to the framework queue object that is associated with the + I/O request. + Request - Handle to a framework request object. + + Lenght - Length of the data buffer associated with the request. + The default property of the queue is to not dispatch + zero lenght read & write requests to the driver and + complete is with status success. So we will never get + a zero length request. + +Return Value: + + None +--*/ + +{ + NTSTATUS status; + ULONG_PTR bytesWritten =0; + WDFMEMORY memory; + + UNREFERENCED_PARAMETER(Queue); + UNREFERENCED_PARAMETER(Length); + + KdPrint(("ToasterEvtIoWrite. Request: 0x%p, Queue: 0x%p\n", + Request, Queue)); + + PAGED_CODE(); + + // + // Get the request buffer and perform write operation here + // + status = WdfRequestRetrieveInputMemory(Request, &memory); + if(NT_SUCCESS(status) ) { + // + // 1) Use WdfMemoryCopyToBuffer to copy data from the request + // to driver buffer. + // 2) Or get the buffer pointer from the request by calling + // WdfRequestRetrieveInputBuffer + // 3) Or you can get the buffer pointer from the memory handle + // by calling WdfMemoryGetBuffer. + // + bytesWritten = Length; + } + + WdfRequestCompleteWithInformation(Request, status, bytesWritten); + +} + + +VOID +ToasterEvtIoDeviceControl( + IN WDFQUEUE Queue, + IN WDFREQUEST Request, + IN size_t OutputBufferLength, + IN size_t InputBufferLength, + IN ULONG IoControlCode + ) +/*++ +Routine Description: + + This event is called when the framework receives IRP_MJ_DEVICE_CONTROL + requests from the system. + +Arguments: + + Queue - Handle to the framework queue object that is associated + with the I/O request. + Request - Handle to a framework request object. + + OutputBufferLength - length of the request's output buffer, + if an output buffer is available. + InputBufferLength - length of the request's input buffer, + if an input buffer is available. + + IoControlCode - the driver-defined or system-defined I/O control code + (IOCTL) that is associated with the request. + +Return Value: + + VOID + +--*/ +{ + NTSTATUS status= STATUS_SUCCESS; + + UNREFERENCED_PARAMETER(Queue); + UNREFERENCED_PARAMETER(OutputBufferLength); + UNREFERENCED_PARAMETER(InputBufferLength); + + KdPrint(("ToasterEvtIoDeviceControl called\n")); + + PAGED_CODE(); + + // + // Use WdfRequestRetrieveInputBuffer and WdfRequestRetrieveOutputBuffer + // to get the request buffers. + // + + switch (IoControlCode) { + + default: + status = STATUS_INVALID_DEVICE_REQUEST; + } + + // + // Complete the Request. + // + WdfRequestCompleteWithInformation(Request, status, (ULONG_PTR) 0); +} + + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.h b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.h new file mode 100644 index 00000000..fc847d2d --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.h @@ -0,0 +1,134 @@ +/*++ + +Copyright (c) 1990-2000 Microsoft Corporation All Rights Reserved + +Module Name: + + Toaster.h + +Abstract: + + Header file for the toaster driver modules. + +Environment: + + Kernel mode + +--*/ + + +#if !defined(_TOASTER_H_) +#define _TOASTER_H_ + +#include +#include + +#define NTSTRSAFE_LIB +#include + +#include "wmilib.h" +#include +#include "driver.h" +#include "public.h" + +// For Featured driver only +#ifdef TOASTER_FUNC_FEATURED +#include +#endif // TOASTER_FUNC_FEATURED + +#define TOASTER_POOL_TAG (ULONG) 'saoT' + +#define MOFRESOURCENAME L"ToasterWMI" + +#define TOASTER_FUNC_DEVICE_LOG_ID "ToasterDevice" +// +// The device extension for the device object +// +typedef struct _FDO_DATA +{ + + WDFWMIINSTANCE WmiDeviceArrivalEvent; + + BOOLEAN WmiPowerDeviceEnableRegistered; + + TOASTER_INTERFACE_STANDARD BusInterface; + +// For Featured driver only +#ifdef TOASTER_FUNC_FEATURED + RECORDER_LOG WppRecorderLog; +#endif // TOASTER_FUNC_FEATURED + +} FDO_DATA, *PFDO_DATA; + +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FDO_DATA, ToasterFdoGetData) + + +// +// Connector Types +// + +#define TOASTER_WMI_STD_I8042 0 +#define TOASTER_WMI_STD_SERIAL 1 +#define TOASTER_WMI_STD_PARALEL 2 +#define TOASTER_WMI_STD_USB 3 + +DRIVER_INITIALIZE DriverEntry; +EVT_WDF_DRIVER_UNLOAD ToasterEvtDriverUnload; + +EVT_WDF_DRIVER_DEVICE_ADD ToasterEvtDeviceAdd; + +EVT_WDF_DEVICE_CONTEXT_CLEANUP ToasterEvtDeviceContextCleanup; +EVT_WDF_DEVICE_D0_ENTRY ToasterEvtDeviceD0Entry; +EVT_WDF_DEVICE_D0_EXIT ToasterEvtDeviceD0Exit; +EVT_WDF_DEVICE_PREPARE_HARDWARE ToasterEvtDevicePrepareHardware; +EVT_WDF_DEVICE_RELEASE_HARDWARE ToasterEvtDeviceReleaseHardware; + +EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT ToasterEvtDeviceSelfManagedIoInit; + +// +// Io events callbacks. +// +EVT_WDF_IO_QUEUE_IO_READ ToasterEvtIoRead; +EVT_WDF_IO_QUEUE_IO_WRITE ToasterEvtIoWrite; +EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL ToasterEvtIoDeviceControl; +EVT_WDF_DEVICE_FILE_CREATE ToasterEvtDeviceFileCreate; +EVT_WDF_FILE_CLOSE ToasterEvtFileClose; + +NTSTATUS +ToasterWmiRegistration( + _In_ WDFDEVICE Device + ); + +// +// Power events callbacks +// +EVT_WDF_DEVICE_ARM_WAKE_FROM_S0 ToasterEvtDeviceArmWakeFromS0; +EVT_WDF_DEVICE_ARM_WAKE_FROM_SX ToasterEvtDeviceArmWakeFromSx; +EVT_WDF_DEVICE_DISARM_WAKE_FROM_S0 ToasterEvtDeviceDisarmWakeFromS0; +EVT_WDF_DEVICE_DISARM_WAKE_FROM_SX ToasterEvtDeviceDisarmWakeFromSx; +EVT_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED ToasterEvtDeviceWakeFromS0Triggered; +EVT_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED ToasterEvtDeviceWakeFromSxTriggered; + +PCHAR +DbgDevicePowerString( + IN WDF_POWER_DEVICE_STATE Type + ); + +// +// WMI event callbacks +// +EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE EvtWmiInstanceStdDeviceDataQueryInstance; +EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE EvtWmiInstanceToasterControlQueryInstance; +EVT_WDF_WMI_INSTANCE_SET_INSTANCE EvtWmiInstanceStdDeviceDataSetInstance; +EVT_WDF_WMI_INSTANCE_SET_INSTANCE EvtWmiInstanceToasterControlSetInstance; +EVT_WDF_WMI_INSTANCE_SET_ITEM EvtWmiInstanceToasterControlSetItem; +EVT_WDF_WMI_INSTANCE_SET_ITEM EvtWmiInstanceStdDeviceDataSetItem; +EVT_WDF_WMI_INSTANCE_EXECUTE_METHOD EvtWmiInstanceToasterControlExecuteMethod; + +NTSTATUS +ToasterFireArrivalEvent( + _In_ WDFDEVICE Device + ); + +#endif // _TOASTER_H_ + diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.inx b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.inx new file mode 100644 index 00000000..2217039d --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.inx @@ -0,0 +1,25 @@ +;Copyright (c) Microsoft Corporation. All rights reserved. + +[Version] +Signature = "$WINDOWS NT$" +Class = System +ClassGuid = {4D36E97D-E325-11CE-BFC1-08002BE10318} +Provider = Contoso +DriverVer = 06/16/1999, 5.00.2064 +CatalogFile = toaster.cat + +[Manufacturer] +Contoso = Contoso, NT$ARCH$ + +[Contoso.NT$ARCH$] +"Basic Toaster" = Toaster_Device, TOASTER\BASIC_TOASTER + +[Toaster_Device.NT] +CopyFiles = Toaster_Device.NT.Copy + +[Toaster_Device.NT.Copy] + +[SourceDisksNames] +1 = "Toaster Device Installation Disk #1",,,"" + +[SourceDisksFiles] \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj new file mode 100644 index 00000000..cfdfd574 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj @@ -0,0 +1,229 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + {2D4FC000-01E2-4FDD-B01A-4FD3C59D245D} + {497e31cb-056b-4f31-abb8-447fd55ee5a5} + v4.5 + 12.0 + Debug + Win32 + toaster + $(LatestTargetPlatformVersion) + + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + true + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + + + Windows10 + true + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + + + Windows10 + false + WindowsKernelModeDriver10.0 + Driver + KMDF + Universal + + + + + + + + + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + true + $(SolutionDir)$(Platform)\$(ConfigurationName)\ + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + DbgengKernelDebugger + + + + true + true + trace.h + true + + + + + true + true + trace.h + true + + + + + true + true + trace.h + true + + + + + true + true + trace.h + true + + + + + true + true + trace.h + true + + + + + true + true + trace.h + true + + + + + true + true + trace.h + true + + + + + true + true + trace.h + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj.filters b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj.filters new file mode 100644 index 00000000..2edeb4fc --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/toaster.vcxproj.filters @@ -0,0 +1,45 @@ + + + + + {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;mfcribbon-ms + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + Driver Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Driver/toaster/trace.h b/general/WinHEC 2017 Lab/Toaster Driver/toaster/trace.h new file mode 100644 index 00000000..820df2ea --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Driver/toaster/trace.h @@ -0,0 +1,62 @@ +/*++ + +Module Name: + + Trace.h + +Abstract: + + Header file for the debug tracing related function defintions and macros. + +Environment: + + Kernel mode + +--*/ + +// +// Define the tracing flags. +// +// Tracing GUID - f1f5e659-1217-48bd-9c69-6d9cb3a147d5 +// + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID( \ + KMDFDriver1TraceGuid, (f1f5e659,1217,48bd,9c69,6d9cb3a147d5), \ + \ + WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \ + WPP_DEFINE_BIT(TRACE_DRIVER) \ + WPP_DEFINE_BIT(TRACE_DEVICE) \ + WPP_DEFINE_BIT(TRACE_QUEUE) \ + ) + +#define WPP_FLAG_LEVEL_LOGGER(flag, level) \ + WPP_LEVEL_LOGGER(flag) + +#define WPP_FLAG_LEVEL_ENABLED(flag, level) \ + (WPP_LEVEL_ENABLED(flag) && \ + WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) + +#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ + WPP_LEVEL_LOGGER(flags) + +#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ + (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) + +// +// WPP orders static parameters before dynamic parameters. To support the Trace function +// defined below which sets FLAGS=MYDRIVER_ALL_INFO, a custom macro must be defined to +// reorder the arguments to what the .tpl configuration file expects. +// +#define WPP_RECORDER_FLAGS_LEVEL_ARGS(flags, lvl) WPP_RECORDER_LEVEL_FLAGS_ARGS(lvl, flags) +#define WPP_RECORDER_FLAGS_LEVEL_FILTER(flags, lvl) WPP_RECORDER_LEVEL_FLAGS_FILTER(lvl, flags) + +// +// This comment block is scanned by the trace preprocessor to define our +// Trace function. +// +// begin_wpp config +// FUNC Trace{FLAGS=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); +// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); +// end_wpp +// diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App.sln b/general/WinHEC 2017 Lab/Toaster Support App/App.sln new file mode 100644 index 00000000..8d28827e --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomCapability", "App\CustomCapability\cpp\CustomCapability.vcxproj", "{0213712B-62E6-5546-8D25-79B90244FFA9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|ARM.ActiveCfg = Debug|ARM + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|ARM.Build.0 = Debug|ARM + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|ARM.Deploy.0 = Debug|ARM + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|x64.ActiveCfg = Debug|x64 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|x64.Build.0 = Debug|x64 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|x64.Deploy.0 = Debug|x64 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|x86.ActiveCfg = Debug|Win32 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|x86.Build.0 = Debug|Win32 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Debug|x86.Deploy.0 = Debug|Win32 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|ARM.ActiveCfg = Release|ARM + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|ARM.Build.0 = Release|ARM + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|ARM.Deploy.0 = Release|ARM + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|x64.ActiveCfg = Release|x64 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|x64.Build.0 = Release|x64 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|x64.Deploy.0 = Release|x64 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|x86.ActiveCfg = Release|Win32 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|x86.Build.0 = Release|Win32 + {0213712B-62E6-5546-8D25-79B90244FFA9}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.SCCD b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.SCCD new file mode 100644 index 00000000..cad58db2 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.SCCD @@ -0,0 +1,11 @@ + + + + + + + + + + xxxx + diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj new file mode 100644 index 00000000..8efaa78d --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj @@ -0,0 +1,287 @@ + + + + {0213712b-62e6-5546-8d25-79b90244ffa9} + SDKTemplate + en-US + 14.0 + true + Windows Store + 10.0.15063.0 + 10.0.15063.0 + 10.0 + CustomCapability + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + Application + true + v141 + + + Application + true + v141 + + + Application + true + v141 + + + Application + false + true + v141 + true + + + Application + false + true + v141 + true + + + Application + false + true + v141 + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(IncludePath);..\..\..\SharedContent\cpp + + + $(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + $(Platform)\$(Configuration)\ + + + + /bigobj %(AdditionalOptions) + 4453;28204 + $(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories);$(OutDir).. + false + + + vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib + false + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + $(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories);$(OutDir).. + false + + + vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib + false + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + $(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories);$(OutDir).. + false + + + vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib + true + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + $(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories);$(OutDir).. + false + + + vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib + true + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + $(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories);$(OutDir).. + false + + + vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib + false + + + + + /bigobj %(AdditionalOptions) + 4453;28204 + $(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories);$(OutDir).. + false + + + vccorlib.lib;WindowsApp.lib;%(AdditionalDependencies);rpcrt4.lib + true + + + + + + + ..\..\..\SharedContent\xaml\App.xaml + + + ..\..\..\SharedContent\cpp\MainPage.xaml + + + Scenario1_MeteringData.xaml + + + + + + + Designer + + + Styles\Styles.xaml + + + Designer + + + Designer + + + + + Designer + + + + + Assets\microsoft-sdk.png + + + Assets\smalltile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squaretile-sdk.png + + + Assets\storelogo-sdk.png + + + Assets\tile-sdk.png + + + Assets\windows-sdk.png + + + + + false + NotUsing + + + ..\..\..\SharedContent\xaml\App.xaml + + + ..\..\..\SharedContent\cpp\MainPage.xaml + + + + Scenario1_MeteringData.xaml + + + + Create + Create + Create + Create + Create + Create + + + NotUsing + NotUsing + NotUsing + NotUsing + NotUsing + NotUsing + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj.filters b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj.filters new file mode 100644 index 00000000..af84bc38 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/CustomCapability.vcxproj.filters @@ -0,0 +1,89 @@ + + + + + 81d95eea-286c-4a5e-98f1-eef612020bf0 + + + 85b464d3-9e56-4242-b58b-1f226dd034b4 + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + {1c0f2943-52c2-4a54-93a2-971c14e7c8ec} + + + {33085be2-4c37-4eab-8f6e-6add0cffe2d4} + + + + + + + + + Model + + + Common + + + + + + ViewModel + + + + + + + Model + + + Common + + + + + + ViewModel + + + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/DeviceList.cpp b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/DeviceList.cpp new file mode 100644 index 00000000..cb3a7a8e --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/DeviceList.cpp @@ -0,0 +1,244 @@ +#include "pch.h" +#include "DeviceList.h" +#include "MainPage.xaml.h" +#include "App.xaml.h" + +using namespace SDKTemplate; + +using namespace Platform; +using namespace Platform::Collections; +using namespace Windows::ApplicationModel; +using namespace Windows::Devices::Enumeration; +using namespace Windows::Devices::Custom; +using namespace Windows::Foundation; +using namespace Windows::UI::Core; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Documents; + +DeviceList^ DeviceList::_Current = nullptr; + +DeviceList^ DeviceList::Current::get() +{ + if (DeviceList::_Current == nullptr) + { + DeviceList::_Current = ref new DeviceList(); + } + return DeviceList::_Current; +} + +DeviceList::DeviceList() : m_WatcherStarted(false), m_WatcherSuspended(false) +{ + m_Fx2Watcher = nullptr; + m_List = ref new Vector(); + InitDeviceWatcher(); + + // Register for app suspend/resume handlers + App::Current->Suspending += ref new SuspendingEventHandler(this, &DeviceList::SuspendDeviceWatcher); + App::Current->Resuming += ref new EventHandler(this, &DeviceList::ResumeDeviceWatcher); +} + +void DeviceList::InitDeviceWatcher() +{ + // Define the selector to enumerate all of the fx2 device interface class instances. + // Use the DeviceInterfaceGuid provided by the driver (Fx2Driver, in this case). + auto selector = CustomDevice::GetDeviceSelector(Fx2Driver::DeviceInterfaceGuid); + + // Set of properties to retrieve + auto properties = ref new Vector({ "System.Devices.DeviceInstanceId" }); + + // Create a device watcher to look for instances of the fx2 device interface. + m_Fx2Watcher = DeviceInformation::CreateWatcher(selector, properties); + + m_Fx2Watcher->Added += ref new TypedEventHandler(this, &DeviceList::OnFx2Added); + m_Fx2Watcher->Removed += ref new TypedEventHandler(this, &DeviceList::OnFx2Removed); + m_Fx2Watcher->EnumerationCompleted += ref new TypedEventHandler(this, &DeviceList::OnFx2EnumerationComplete); +} + +void DeviceList::StartFx2Watcher() +{ + MainPage::Current->NotifyUser("starting device watcher", NotifyType::StatusMessage); + + std::for_each( + begin(m_List), + end(m_List), + [](DeviceListEntry^ Entry) { + Entry->Matched = false; + }); + + WatcherStarted = true; + m_Fx2Watcher->Start(); +} + +void DeviceList::StopFx2Watcher() +{ + MainPage::Current->NotifyUser("stopping fx2 watcher", NotifyType::StatusMessage); + m_Fx2Watcher->Stop(); + WatcherStarted = false; +} + +void DeviceList::CreateBooleanTable( + InlineCollection^ Table, + const Platform::Array^ NewValues, + const Platform::Array^ OldValues, + String^ /* IndexTitle */, + String^ /* ValueTitle */, + String^ TrueValue, + String^ FalseValue) +{ + Table->Clear(); + + for (int i = 0; i < (int)NewValues->Length; i += 1) + { + auto line = ref new Span(); + auto block = ref new Run(); + block->Text = (i + 1).ToString(); + line->Inlines->Append(block); + + block = ref new Run(); + block->Text = " "; + line->Inlines->Append(block); + + block = ref new Run(); + block->Text = NewValues[i] ? TrueValue : FalseValue; + + if ((OldValues != nullptr) && (OldValues[i] != NewValues[i])) + { + auto bold = ref new Bold(); + bold->Inlines->Append(block); + line->Inlines->Append(bold); + } + else + { + line->Inlines->Append(block); + } + + line->Inlines->Append(ref new LineBreak()); + + Table->Append(line); + } +} + +DeviceListEntry^ DeviceList::FindDevice(String^ Id) +{ + auto i = std::find_if( + begin(m_List), + end(m_List), + [Id](DeviceListEntry^ e) {return e->Id == Id; }); + + if (i == end(m_List)) + { + return nullptr; + } + else + { + return *i; + } +} + +void DeviceList::OnFx2Added(DeviceWatcher ^ /* Sender */, DeviceInformation^ DevInterface) +{ + MainPage::Current->Dispatcher->RunAsync( + CoreDispatcherPriority::Normal, + ref new DispatchedHandler( + [this, DevInterface]()->void + { + MainPage::Current->NotifyUser("OnFx2Added: " + DevInterface->Id, NotifyType::StatusMessage); + + // search the device list for a device with a matching interface ID + auto match = FindDevice(DevInterface->Id); + + // If we found a match then mark it as verified and return + if (match != nullptr) + { + match->Matched = true; + return; + } + + // Create a new elemetn for this device interface, and queue up the query of its + // device information + match = ref new DeviceListEntry(DevInterface); + + // Add the new element to the end of the list of devices + m_List->Append(match); + })); +} + +void DeviceList::OnFx2Removed(DeviceWatcher ^ /* Sender */, DeviceInformationUpdate^ DevInterface) +{ + auto deviceId = DevInterface->Id; + + MainPage::Current->Dispatcher->RunAsync( + CoreDispatcherPriority::Normal, + ref new DispatchedHandler( + [this, deviceId]() + { + MainPage::Current->NotifyUser("OnFx2Removed: " + deviceId, NotifyType::StatusMessage); + + // Search the list of devices for one with a matching ID. Move the matched + // item to the end of the list. + auto i = std::remove_if( + begin(m_List), + end(m_List), + [deviceId](DeviceListEntry^ e) {return e->Id == deviceId; }); + + // if there's no match return. + if (i == end(m_List)) + { + return; + } + + // Remove the last item from the list. + MainPage::Current->NotifyUser("OnFx2Removed: " + deviceId + " removed", NotifyType::StatusMessage); + m_List->RemoveAtEnd(); + })); +} + +void DeviceList::OnFx2EnumerationComplete(DeviceWatcher ^ /* Sender */, Object ^ /* o */) +{ + MainPage::Current->Dispatcher->RunAsync( + CoreDispatcherPriority::Normal, + ref new DispatchedHandler( + [this]() + { + MainPage::Current->NotifyUser("OnFx2EnumerationComplete", NotifyType::StatusMessage); + + DeviceList^ me = this; + + // Move all the unmatched elements to the end of the list + auto i = std::remove_if( + begin(m_List), + end(m_List), + [](DeviceListEntry^ e) { return e->Matched == false; }); + + // Determine the number of unmatched entries + auto unmatchedCount = end(m_List) - i; + + while (unmatchedCount > 0) + { + m_List->RemoveAtEnd(); + unmatchedCount -= 1; + } + })); +} + +void DeviceList::SuspendDeviceWatcher(Object^, SuspendingEventArgs^) +{ + if (WatcherStarted) + { + m_WatcherSuspended = true; + StopFx2Watcher(); + } + else + { + m_WatcherSuspended = false; + } +} + +void DeviceList::ResumeDeviceWatcher(Object^, Object^) +{ + if (m_WatcherSuspended) + { + m_WatcherSuspended = false; + StartFx2Watcher(); + } +} diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Package.appxmanifest b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Package.appxmanifest new file mode 100644 index 00000000..0ec45a07 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Package.appxmanifest @@ -0,0 +1,41 @@ + + + + + + Custom Capability C++ Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp new file mode 100644 index 00000000..870d6306 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.cpp @@ -0,0 +1,177 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +// There is an error in the system header files that incorrectly +// places RpcStringBindingCompose in the app partition. +// Work around it by changing the WINAPI_FAMILY to desktop temporarily. +#pragma push_macro("WINAPI_FAMILY") +#undef WINAPI_FAMILY +#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP +#include "RpcClient.h" +#pragma pop_macro("WINAPI_FAMILY") + +using namespace SDKTemplate; + +__int64 RpcClient::Initialize() +{ + RPC_STATUS status; + RPC_WSTR pszStringBinding = nullptr; + + status = RpcStringBindingCompose( + NULL, + reinterpret_cast(L"ncalrpc"), + NULL, + reinterpret_cast(RPC_STATIC_ENDPOINT), + NULL, + &pszStringBinding); + + if (status) + { + goto error_status; + } + + status = RpcBindingFromStringBinding( + pszStringBinding, + &hRpcBinding); + + if (status) + { + goto error_status; + } + + status = RpcStringFree(&pszStringBinding); + + if (status) + { + goto error_status; + } + + RpcTryExcept + { + ::RemoteOpen(hRpcBinding, &phContext); + } + RpcExcept(1) + { + status = RpcExceptionCode(); + } + RpcEndExcept + +error_status: + + return status; +} + +// +// Make RPC call to start metering. This is a blocking call and +// will return only after StopMetering is called. +// +__int64 RpcClient::StartMeteringAndWaitForStop(__int64 samplePeriod) +{ + __int64 ulCode = 0; + CallbackCount = 0; + MeteringData = 0; + + RpcTryExcept + { + ::StartMetering(phContext, samplePeriod, (__int64)this); + } + RpcExcept(1) + { + ulCode = RpcExceptionCode(); + } + RpcEndExcept + + return ulCode; +} + + +// +// Make rpc call SetSampleRate +// +__int64 RpcClient::SetSampleRate(int rate) +{ + __int64 ulCode = 0; + RpcTryExcept + { + ::SetSamplePeriod(phContext, rate); + } + RpcExcept(1) + { + ulCode = RpcExceptionCode(); + } + RpcEndExcept + return ulCode; +} + +// +// Make rpc call StopMetering +// +__int64 RpcClient::StopMetering() +{ + __int64 ulCode = 0; + RpcTryExcept + { + ::StopMetering(phContext); + } + RpcExcept(1) + { + ulCode = RpcExceptionCode(); + } + RpcEndExcept + return ulCode; +} + +RpcClient::~RpcClient() +{ + RPC_STATUS status; + + if (hRpcBinding != NULL) + { + RpcTryExcept + { + ::RemoteClose(&phContext); + } + RpcExcept(1) + { + // Ignoring the result of RemoteClose as nothing can be + // done on the client side with this return code + status = RpcExceptionCode(); + } + RpcEndExcept + + status = RpcBindingFree(&hRpcBinding); + hRpcBinding = NULL; + } +} + +// +// Metering rpc callback +// +void MeteringDataEvent(__int64 data, __int64 context) +{ + RpcClient* client = static_cast((PVOID)context); + client->MeteringData = data; + ++client->CallbackCount; +} + +///******************************************************/ +///* MIDL allocate and free */ +///******************************************************/ + +void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) +{ + return(malloc(len)); +} + +void __RPC_USER midl_user_free(void __RPC_FAR * ptr) +{ + free(ptr); +} \ No newline at end of file diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.h b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.h new file mode 100644 index 00000000..0ee5ff78 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcClient.h @@ -0,0 +1,30 @@ +// +// RpcClient.h +// + +#pragma once + +#define RPC_STATIC_ENDPOINT L"HsaSampleRpcEndpoint" + +#include "RpcInterface_h.h" + +namespace SDKTemplate +{ + /// + /// Client side RPC implementation + /// + private class RpcClient sealed + { + public: + ~RpcClient(); + __int64 Initialize(); + __int64 StartMeteringAndWaitForStop(__int64 samplePeriod); + __int64 StopMetering(); + __int64 SetSampleRate(int rate); + int CallbackCount; + __int64 MeteringData; + private: + handle_t hRpcBinding; + PCONTEXT_HANDLE_TYPE phContext; + }; +} diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface.c b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface.c new file mode 100644 index 00000000..0f988533 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface.c @@ -0,0 +1,6 @@ +// RpcInterface_c.c expects _ARM_ to be set when building for ARM. +#ifdef _M_ARM +#define _ARM_ 1 +#endif + +#include "RpcInterface_c.c" diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_c.c b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_c.c new file mode 100644 index 00000000..8b05c1ea --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_c.c @@ -0,0 +1,476 @@ + + +/* this ALWAYS GENERATED file contains the RPC client stubs */ + + + /* File created by MIDL compiler version 8.01.0622 */ +/* at Mon Jan 18 19:14:07 2038 + */ +/* Compiler settings for C:\WinHEC 2017 Lab\Toaster Driver\Service\RpcInterface.Idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#if defined(_M_AMD64) + + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif + +#pragma warning( disable: 4211 ) /* redefine extern to static */ +#pragma warning( disable: 4232 ) /* dllimport identity*/ +#pragma warning( disable: 4024 ) /* array to pointer mapping*/ + +#include + +#include "RpcInterface_h.h" + +#define TYPE_FORMAT_STRING_SIZE 23 +#define PROC_FORMAT_STRING_SIZE 245 +#define EXPR_FORMAT_STRING_SIZE 1 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _RpcInterface_MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_TYPE_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_PROC_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_EXPR_FORMAT_STRING + { + long Pad; + unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_EXPR_FORMAT_STRING; + + +static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = +{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; + + +extern const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString; +extern const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString; +extern const RpcInterface_MIDL_EXPR_FORMAT_STRING RpcInterface__MIDL_ExprFormatString; + +#define GENERIC_BINDING_TABLE_SIZE 0 + + +/* Standard interface: RpcInterface, ver. 1.0, + GUID={0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}} */ + + +extern const MIDL_SERVER_INFO RpcInterface_ServerInfo; + + +extern const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable; + +static const RPC_CLIENT_INTERFACE RpcInterface___RpcClientInterface = + { + sizeof(RPC_CLIENT_INTERFACE), + {{0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + (RPC_DISPATCH_TABLE*)&RpcInterface_v1_0_DispatchTable, + 0, + 0, + 0, + &RpcInterface_ServerInfo, + 0x04000000 + }; +RPC_IF_HANDLE RpcInterface_v1_0_c_ifspec = (RPC_IF_HANDLE)& RpcInterface___RpcClientInterface; + +extern const MIDL_STUB_DESC RpcInterface_StubDesc; + +static RPC_BINDING_HANDLE RpcInterface__MIDL_AutoBindHandle; + + +void RemoteOpen( + /* [in] */ handle_t hBinding, + /* [out] */ PPCONTEXT_HANDLE_TYPE pphContext) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[0], + hBinding, + pphContext); + +} + + +void RemoteClose( + /* [out][in] */ PPCONTEXT_HANDLE_TYPE pphContext) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[36], + pphContext); + +} + + +void StartMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod, + /* [optional][in] */ __int64 context) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[74], + phContext, + samplePeriod, + context); + +} + + +void SetSamplePeriod( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[124], + phContext, + samplePeriod); + +} + + +void StopMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[168], + phContext); + +} + + +#if !defined(__RPC_WIN64__) +#error Invalid build platform for this stub. +#endif + +static const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString = + { + 0, + { + + /* Procedure RemoteOpen */ + + 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x0 ), /* 0 */ +/* 8 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 12 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 14 */ NdrFcShort( 0x0 ), /* 0 */ +/* 16 */ NdrFcShort( 0x38 ), /* 56 */ +/* 18 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 20 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 22 */ NdrFcShort( 0x0 ), /* 0 */ +/* 24 */ NdrFcShort( 0x0 ), /* 0 */ +/* 26 */ NdrFcShort( 0x0 ), /* 0 */ +/* 28 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 30 */ NdrFcShort( 0x110 ), /* Flags: out, simple ref, */ +/* 32 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 34 */ NdrFcShort( 0x6 ), /* Type Offset=6 */ + + /* Procedure RemoteClose */ + +/* 36 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 38 */ NdrFcLong( 0x0 ), /* 0 */ +/* 42 */ NdrFcShort( 0x1 ), /* 1 */ +/* 44 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 46 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe0, /* Ctxt flags: via ptr, in, out, */ +/* 48 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 50 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 52 */ NdrFcShort( 0x38 ), /* 56 */ +/* 54 */ NdrFcShort( 0x38 ), /* 56 */ +/* 56 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 58 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 60 */ NdrFcShort( 0x0 ), /* 0 */ +/* 62 */ NdrFcShort( 0x0 ), /* 0 */ +/* 64 */ NdrFcShort( 0x0 ), /* 0 */ +/* 66 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 68 */ NdrFcShort( 0x118 ), /* Flags: in, out, simple ref, */ +/* 70 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 72 */ NdrFcShort( 0xe ), /* Type Offset=14 */ + + /* Procedure StartMetering */ + +/* 74 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 76 */ NdrFcLong( 0x0 ), /* 0 */ +/* 80 */ NdrFcShort( 0x2 ), /* 2 */ +/* 82 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 84 */ 0x30, /* FC_BIND_CONTEXT */ + 0x40, /* Ctxt flags: in, */ +/* 86 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 88 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 90 */ NdrFcShort( 0x44 ), /* 68 */ +/* 92 */ NdrFcShort( 0x0 ), /* 0 */ +/* 94 */ 0x40, /* Oi2 Flags: has ext, */ + 0x3, /* 3 */ +/* 96 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 98 */ NdrFcShort( 0x0 ), /* 0 */ +/* 100 */ NdrFcShort( 0x0 ), /* 0 */ +/* 102 */ NdrFcShort( 0x0 ), /* 0 */ +/* 104 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 106 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 108 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 110 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 112 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 114 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 116 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 118 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 120 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 122 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure SetSamplePeriod */ + +/* 124 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 126 */ NdrFcLong( 0x0 ), /* 0 */ +/* 130 */ NdrFcShort( 0x3 ), /* 3 */ +/* 132 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 134 */ 0x30, /* FC_BIND_CONTEXT */ + 0x40, /* Ctxt flags: in, */ +/* 136 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 138 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 140 */ NdrFcShort( 0x34 ), /* 52 */ +/* 142 */ NdrFcShort( 0x0 ), /* 0 */ +/* 144 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 146 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 148 */ NdrFcShort( 0x0 ), /* 0 */ +/* 150 */ NdrFcShort( 0x0 ), /* 0 */ +/* 152 */ NdrFcShort( 0x0 ), /* 0 */ +/* 154 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 156 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 158 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 160 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 162 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 164 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 166 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure StopMetering */ + +/* 168 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 170 */ NdrFcLong( 0x0 ), /* 0 */ +/* 174 */ NdrFcShort( 0x4 ), /* 4 */ +/* 176 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 178 */ 0x30, /* FC_BIND_CONTEXT */ + 0x40, /* Ctxt flags: in, */ +/* 180 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 182 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 184 */ NdrFcShort( 0x24 ), /* 36 */ +/* 186 */ NdrFcShort( 0x0 ), /* 0 */ +/* 188 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 190 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 192 */ NdrFcShort( 0x0 ), /* 0 */ +/* 194 */ NdrFcShort( 0x0 ), /* 0 */ +/* 196 */ NdrFcShort( 0x0 ), /* 0 */ +/* 198 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 200 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 202 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 204 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Procedure MeteringDataEvent */ + +/* 206 */ 0x34, /* FC_CALLBACK_HANDLE */ + 0x48, /* Old Flags: */ +/* 208 */ NdrFcLong( 0x0 ), /* 0 */ +/* 212 */ NdrFcShort( 0x0 ), /* 0 */ +/* 214 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 216 */ NdrFcShort( 0x20 ), /* 32 */ +/* 218 */ NdrFcShort( 0x0 ), /* 0 */ +/* 220 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 222 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 224 */ NdrFcShort( 0x0 ), /* 0 */ +/* 226 */ NdrFcShort( 0x0 ), /* 0 */ +/* 228 */ NdrFcShort( 0x0 ), /* 0 */ +/* 230 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter data */ + +/* 232 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 234 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 236 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 238 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 240 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 242 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */ +/* 6 */ 0x30, /* FC_BIND_CONTEXT */ + 0xa0, /* Ctxt flags: via ptr, out, */ +/* 8 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 10 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 12 */ NdrFcShort( 0x2 ), /* Offset= 2 (14) */ +/* 14 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe1, /* Ctxt flags: via ptr, in, out, can't be null */ +/* 16 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 18 */ 0x30, /* FC_BIND_CONTEXT */ + 0x41, /* Ctxt flags: in, can't be null */ +/* 20 */ 0x0, /* 0 */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const unsigned short RpcInterface_FormatStringOffsetTable[] = + { + 0, + 36, + 74, + 124, + 168, + }; + + +static const unsigned short _callbackRpcInterface_FormatStringOffsetTable[] = + { + 206 + }; + + +static const MIDL_STUB_DESC RpcInterface_StubDesc = + { + (void *)& RpcInterface___RpcClientInterface, + MIDL_user_allocate, + MIDL_user_free, + &RpcInterface__MIDL_AutoBindHandle, + 0, + 0, + 0, + 0, + RpcInterface__MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x50002, /* Ndr library version */ + 0, + 0x801026e, /* MIDL Version 8.1.622 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* cs routines */ + 0, /* proxy/server info */ + 0 + }; + +static const RPC_DISPATCH_FUNCTION RpcInterface_table[] = + { + NdrServerCall2, + 0 + }; +static const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable = + { + 1, + (RPC_DISPATCH_FUNCTION*)RpcInterface_table + }; + +static const SERVER_ROUTINE RpcInterface_ServerRoutineTable[] = + { + (SERVER_ROUTINE)MeteringDataEvent + }; + +static const MIDL_SERVER_INFO RpcInterface_ServerInfo = + { + &RpcInterface_StubDesc, + RpcInterface_ServerRoutineTable, + RpcInterface__MIDL_ProcFormatString.Format, + _callbackRpcInterface_FormatStringOffsetTable, + 0, + 0, + 0, + 0}; +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + + +#endif /* defined(_M_AMD64)*/ + diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_h.h b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_h.h new file mode 100644 index 00000000..a0e2dcac --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_h.h @@ -0,0 +1,112 @@ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 8.01.0622 */ +/* at Mon Jan 18 19:14:07 2038 + */ +/* Compiler settings for C:\WinHEC 2017 Lab\Toaster Driver\Service\RpcInterface.Idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif /* __RPCNDR_H_VERSION__ */ + + +#ifndef __RpcInterface_h_h__ +#define __RpcInterface_h_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +#if defined(__cplusplus) +#if defined(__MIDL_USE_C_ENUM) +#define MIDL_ENUM enum +#else +#define MIDL_ENUM enum class +#endif +#endif + + +/* Forward Declarations */ + +/* header files for imported files */ +#include "oaidl.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __RpcInterface_INTERFACE_DEFINED__ +#define __RpcInterface_INTERFACE_DEFINED__ + +/* interface RpcInterface */ +/* [unique][version][uuid] */ + +typedef /* [context_handle] */ void *PCONTEXT_HANDLE_TYPE; + +typedef /* [ref] */ PCONTEXT_HANDLE_TYPE *PPCONTEXT_HANDLE_TYPE; + +void RemoteOpen( + /* [in] */ handle_t hBinding, + /* [out] */ PPCONTEXT_HANDLE_TYPE pphContext); + +void RemoteClose( + /* [out][in] */ PPCONTEXT_HANDLE_TYPE pphContext); + +void StartMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod, + /* [optional][in] */ __int64 context); + +void SetSamplePeriod( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext, + /* [in] */ __int64 samplePeriod); + +void StopMetering( + /* [in] */ PCONTEXT_HANDLE_TYPE phContext); + +/* [callback] */ void MeteringDataEvent( + /* [in] */ __int64 data, + /* [optional][in] */ __int64 context); + + + +extern RPC_IF_HANDLE RpcInterface_v1_0_c_ifspec; +extern RPC_IF_HANDLE RpcInterface_v1_0_s_ifspec; +#endif /* __RpcInterface_INTERFACE_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +void __RPC_USER PCONTEXT_HANDLE_TYPE_rundown( PCONTEXT_HANDLE_TYPE ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_s.c b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_s.c new file mode 100644 index 00000000..ec58170d --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/RpcInterface_s.c @@ -0,0 +1,430 @@ + + +/* this ALWAYS GENERATED file contains the RPC server stubs */ + + + /* File created by MIDL compiler version 8.01.0622 */ +/* at Mon Jan 18 19:14:07 2038 + */ +/* Compiler settings for C:\WinHEC 2017 Lab\Toaster Driver\Service\RpcInterface.Idl: + Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622 + protocol : dce , ms_ext, c_ext, robust + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +/* @@MIDL_FILE_HEADING( ) */ + +#if defined(_M_AMD64) + + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif + +#pragma warning( disable: 4211 ) /* redefine extern to static */ +#pragma warning( disable: 4232 ) /* dllimport identity*/ +#pragma warning( disable: 4024 ) /* array to pointer mapping*/ + +#include +#include "RpcInterface_h.h" + +#define TYPE_FORMAT_STRING_SIZE 23 +#define PROC_FORMAT_STRING_SIZE 245 +#define EXPR_FORMAT_STRING_SIZE 1 +#define TRANSMIT_AS_TABLE_SIZE 0 +#define WIRE_MARSHAL_TABLE_SIZE 0 + +typedef struct _RpcInterface_MIDL_TYPE_FORMAT_STRING + { + short Pad; + unsigned char Format[ TYPE_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_TYPE_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_PROC_FORMAT_STRING + { + short Pad; + unsigned char Format[ PROC_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_PROC_FORMAT_STRING; + +typedef struct _RpcInterface_MIDL_EXPR_FORMAT_STRING + { + long Pad; + unsigned char Format[ EXPR_FORMAT_STRING_SIZE ]; + } RpcInterface_MIDL_EXPR_FORMAT_STRING; + + +static const RPC_SYNTAX_IDENTIFIER _RpcTransferSyntax = +{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}; + +extern const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString; +extern const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString; +extern const RpcInterface_MIDL_EXPR_FORMAT_STRING RpcInterface__MIDL_ExprFormatString; + +/* Standard interface: RpcInterface, ver. 1.0, + GUID={0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}} */ + + +extern const MIDL_SERVER_INFO RpcInterface_ServerInfo; + +extern const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable; + +static const RPC_SERVER_INTERFACE RpcInterface___RpcServerInterface = + { + sizeof(RPC_SERVER_INTERFACE), + {{0x906B0CE0,0xC70B,0x1067,{0xB3,0x17,0x00,0xDD,0x01,0x06,0x62,0xDA}},{1,0}}, + {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}}, + (RPC_DISPATCH_TABLE*)&RpcInterface_v1_0_DispatchTable, + 0, + 0, + 0, + &RpcInterface_ServerInfo, + 0x04000000 + }; +RPC_IF_HANDLE RpcInterface_v1_0_s_ifspec = (RPC_IF_HANDLE)& RpcInterface___RpcServerInterface; + +extern const MIDL_STUB_DESC RpcInterface_StubDesc; + + extern const MIDL_STUBLESS_PROXY_INFO RpcInterface_ProxyInfo; + +/* [callback] */ void MeteringDataEvent( + /* [in] */ __int64 data, + /* [optional][in] */ __int64 context) +{ + + NdrClientCall2( + ( PMIDL_STUB_DESC )&RpcInterface_StubDesc, + (PFORMAT_STRING) &RpcInterface__MIDL_ProcFormatString.Format[206], + data, + context); + +} + +extern const NDR_RUNDOWN RundownRoutines[]; + +#if !defined(__RPC_WIN64__) +#error Invalid build platform for this stub. +#endif + +static const RpcInterface_MIDL_PROC_FORMAT_STRING RpcInterface__MIDL_ProcFormatString = + { + 0, + { + + /* Procedure RemoteOpen */ + + 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x0 ), /* 0 */ +/* 8 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 10 */ 0x32, /* FC_BIND_PRIMITIVE */ + 0x0, /* 0 */ +/* 12 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 14 */ NdrFcShort( 0x0 ), /* 0 */ +/* 16 */ NdrFcShort( 0x38 ), /* 56 */ +/* 18 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 20 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 22 */ NdrFcShort( 0x0 ), /* 0 */ +/* 24 */ NdrFcShort( 0x0 ), /* 0 */ +/* 26 */ NdrFcShort( 0x0 ), /* 0 */ +/* 28 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 30 */ NdrFcShort( 0x110 ), /* Flags: out, simple ref, */ +/* 32 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 34 */ NdrFcShort( 0x6 ), /* Type Offset=6 */ + + /* Procedure RemoteClose */ + +/* 36 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 38 */ NdrFcLong( 0x0 ), /* 0 */ +/* 42 */ NdrFcShort( 0x1 ), /* 1 */ +/* 44 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 46 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe0, /* Ctxt flags: via ptr, in, out, */ +/* 48 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 50 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 52 */ NdrFcShort( 0x38 ), /* 56 */ +/* 54 */ NdrFcShort( 0x38 ), /* 56 */ +/* 56 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 58 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 60 */ NdrFcShort( 0x0 ), /* 0 */ +/* 62 */ NdrFcShort( 0x0 ), /* 0 */ +/* 64 */ NdrFcShort( 0x0 ), /* 0 */ +/* 66 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter pphContext */ + +/* 68 */ NdrFcShort( 0x118 ), /* Flags: in, out, simple ref, */ +/* 70 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 72 */ NdrFcShort( 0xe ), /* Type Offset=14 */ + + /* Procedure StartMetering */ + +/* 74 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 76 */ NdrFcLong( 0x0 ), /* 0 */ +/* 80 */ NdrFcShort( 0x2 ), /* 2 */ +/* 82 */ NdrFcShort( 0x18 ), /* X64 Stack size/offset = 24 */ +/* 84 */ 0x30, /* FC_BIND_CONTEXT */ + 0x40, /* Ctxt flags: in, */ +/* 86 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 88 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 90 */ NdrFcShort( 0x44 ), /* 68 */ +/* 92 */ NdrFcShort( 0x0 ), /* 0 */ +/* 94 */ 0x40, /* Oi2 Flags: has ext, */ + 0x3, /* 3 */ +/* 96 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 98 */ NdrFcShort( 0x0 ), /* 0 */ +/* 100 */ NdrFcShort( 0x0 ), /* 0 */ +/* 102 */ NdrFcShort( 0x0 ), /* 0 */ +/* 104 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 106 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 108 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 110 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 112 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 114 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 116 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 118 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 120 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 122 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure SetSamplePeriod */ + +/* 124 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 126 */ NdrFcLong( 0x0 ), /* 0 */ +/* 130 */ NdrFcShort( 0x3 ), /* 3 */ +/* 132 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 134 */ 0x30, /* FC_BIND_CONTEXT */ + 0x40, /* Ctxt flags: in, */ +/* 136 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 138 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 140 */ NdrFcShort( 0x34 ), /* 52 */ +/* 142 */ NdrFcShort( 0x0 ), /* 0 */ +/* 144 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 146 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 148 */ NdrFcShort( 0x0 ), /* 0 */ +/* 150 */ NdrFcShort( 0x0 ), /* 0 */ +/* 152 */ NdrFcShort( 0x0 ), /* 0 */ +/* 154 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 156 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 158 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 160 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Parameter samplePeriod */ + +/* 162 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 164 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 166 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Procedure StopMetering */ + +/* 168 */ 0x0, /* 0 */ + 0x48, /* Old Flags: */ +/* 170 */ NdrFcLong( 0x0 ), /* 0 */ +/* 174 */ NdrFcShort( 0x4 ), /* 4 */ +/* 176 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 178 */ 0x30, /* FC_BIND_CONTEXT */ + 0x40, /* Ctxt flags: in, */ +/* 180 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 182 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 184 */ NdrFcShort( 0x24 ), /* 36 */ +/* 186 */ NdrFcShort( 0x0 ), /* 0 */ +/* 188 */ 0x40, /* Oi2 Flags: has ext, */ + 0x1, /* 1 */ +/* 190 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 192 */ NdrFcShort( 0x0 ), /* 0 */ +/* 194 */ NdrFcShort( 0x0 ), /* 0 */ +/* 196 */ NdrFcShort( 0x0 ), /* 0 */ +/* 198 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter phContext */ + +/* 200 */ NdrFcShort( 0x8 ), /* Flags: in, */ +/* 202 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 204 */ NdrFcShort( 0x12 ), /* Type Offset=18 */ + + /* Procedure MeteringDataEvent */ + +/* 206 */ 0x34, /* FC_CALLBACK_HANDLE */ + 0x48, /* Old Flags: */ +/* 208 */ NdrFcLong( 0x0 ), /* 0 */ +/* 212 */ NdrFcShort( 0x0 ), /* 0 */ +/* 214 */ NdrFcShort( 0x10 ), /* X64 Stack size/offset = 16 */ +/* 216 */ NdrFcShort( 0x20 ), /* 32 */ +/* 218 */ NdrFcShort( 0x0 ), /* 0 */ +/* 220 */ 0x40, /* Oi2 Flags: has ext, */ + 0x2, /* 2 */ +/* 222 */ 0xa, /* 10 */ + 0x1, /* Ext Flags: new corr desc, */ +/* 224 */ NdrFcShort( 0x0 ), /* 0 */ +/* 226 */ NdrFcShort( 0x0 ), /* 0 */ +/* 228 */ NdrFcShort( 0x0 ), /* 0 */ +/* 230 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter data */ + +/* 232 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 234 */ NdrFcShort( 0x0 ), /* X64 Stack size/offset = 0 */ +/* 236 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + /* Parameter context */ + +/* 238 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */ +/* 240 */ NdrFcShort( 0x8 ), /* X64 Stack size/offset = 8 */ +/* 242 */ 0xb, /* FC_HYPER */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const RpcInterface_MIDL_TYPE_FORMAT_STRING RpcInterface__MIDL_TypeFormatString = + { + 0, + { + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 4 */ NdrFcShort( 0x2 ), /* Offset= 2 (6) */ +/* 6 */ 0x30, /* FC_BIND_CONTEXT */ + 0xa0, /* Ctxt flags: via ptr, out, */ +/* 8 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 10 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 12 */ NdrFcShort( 0x2 ), /* Offset= 2 (14) */ +/* 14 */ 0x30, /* FC_BIND_CONTEXT */ + 0xe1, /* Ctxt flags: via ptr, in, out, can't be null */ +/* 16 */ 0x0, /* 0 */ + 0x0, /* 0 */ +/* 18 */ 0x30, /* FC_BIND_CONTEXT */ + 0x41, /* Ctxt flags: in, can't be null */ +/* 20 */ 0x0, /* 0 */ + 0x0, /* 0 */ + + 0x0 + } + }; + +static const NDR_RUNDOWN RundownRoutines[] = + { + PCONTEXT_HANDLE_TYPE_rundown + }; + + +static const unsigned short RpcInterface_FormatStringOffsetTable[] = + { + 0, + 36, + 74, + 124, + 168, + }; + + +static const unsigned short _callbackRpcInterface_FormatStringOffsetTable[] = + { + 206 + }; + + +static const MIDL_STUB_DESC RpcInterface_StubDesc = + { + (void *)& RpcInterface___RpcServerInterface, + MIDL_user_allocate, + MIDL_user_free, + 0, + RundownRoutines, + 0, + 0, + 0, + RpcInterface__MIDL_TypeFormatString.Format, + 1, /* -error bounds_check flag */ + 0x50002, /* Ndr library version */ + 0, + 0x801026e, /* MIDL Version 8.1.622 */ + 0, + 0, + 0, /* notify & notify_flag routine table */ + 0x1, /* MIDL flag */ + 0, /* cs routines */ + 0, /* proxy/server info */ + 0 + }; + +static const RPC_DISPATCH_FUNCTION RpcInterface_table[] = + { + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + NdrServerCall2, + 0 + }; +static const RPC_DISPATCH_TABLE RpcInterface_v1_0_DispatchTable = + { + 5, + (RPC_DISPATCH_FUNCTION*)RpcInterface_table + }; + +static const SERVER_ROUTINE RpcInterface_ServerRoutineTable[] = + { + (SERVER_ROUTINE)RemoteOpen, + (SERVER_ROUTINE)RemoteClose, + (SERVER_ROUTINE)StartMetering, + (SERVER_ROUTINE)SetSamplePeriod, + (SERVER_ROUTINE)StopMetering, + }; + +static const MIDL_SERVER_INFO RpcInterface_ServerInfo = + { + &RpcInterface_StubDesc, + RpcInterface_ServerRoutineTable, + RpcInterface__MIDL_ProcFormatString.Format, + RpcInterface_FormatStringOffsetTable, + 0, + 0, + 0, + 0}; +#if _MSC_VER >= 1200 +#pragma warning(pop) +#endif + + +#endif /* defined(_M_AMD64)*/ + diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.cpp b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.cpp new file mode 100644 index 00000000..a808cf83 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.cpp @@ -0,0 +1,21 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "pch.h" +#include "MainPage.xaml.h" +#include "SampleConfiguration.h" + +using namespace SDKTemplate; + +Platform::Array^ MainPage::scenariosInner = ref new Platform::Array +{ + { "Connect to an NT Service", "SDKTemplate.MeteringData" }, +}; diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.h b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.h new file mode 100644 index 00000000..22581275 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/SampleConfiguration.h @@ -0,0 +1,47 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#pragma once +#include "pch.h" + +namespace SDKTemplate +{ + value struct Scenario; + + partial ref class MainPage + { + internal: + static property Platform::String^ FEATURE_NAME + { + Platform::String^ get() + { + return "Custom Capability C++ sample"; + } + } + + static property Platform::Array^ scenarios + { + Platform::Array^ get() + { + return scenariosInner; + } + } + + private: + static Platform::Array^ scenariosInner; + }; + + public value struct Scenario + { + Platform::String^ Title; + Platform::String^ ClassName; + }; +} diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Scenario1_MeteringData.xaml b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Scenario1_MeteringData.xaml new file mode 100644 index 00000000..0636f74d --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/Scenario1_MeteringData.xaml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + This scenario demonstrates RPC communication between an app and an NT service. For demonstration purposes, the service reads data from an imaginary device. + + + + + + + Sample Period (ms): + + + + + + + + +