From 948b220e8bd0819d5b340c06c969c497556da950 Mon Sep 17 00:00:00 2001 From: Wei Mao Date: Wed, 11 Jan 2023 18:38:29 -0800 Subject: [PATCH] [UMDF v1] Remove usb/wdf_osrfx2_lab/umdf --- usb/wdf_osrfx2_lab/README.md | 7 + .../umdf/exe/WudfOsrUsbFx2Test.vcxproj | 223 --- .../exe/WudfOsrUsbFx2Test.vcxproj.Filters | 30 - usb/wdf_osrfx2_lab/umdf/exe/dump.c | 444 ------ usb/wdf_osrfx2_lab/umdf/exe/testapp.c | 1367 ----------------- usb/wdf_osrfx2_lab/umdf/exe/testapp.rc | 13 - .../umdf/inc/WUDFOsrUsbPublic.h | 32 - usb/wdf_osrfx2_lab/umdf/inc/list.h | 77 - usb/wdf_osrfx2_lab/umdf/inc/public.h | 217 --- usb/wdf_osrfx2_lab/umdf/inc/usb_hw.h | 233 --- usb/wdf_osrfx2_lab/umdf/step1/Device.cpp | 235 --- usb/wdf_osrfx2_lab/umdf/step1/Device.h | 128 -- usb/wdf_osrfx2_lab/umdf/step1/Driver.cpp | 220 --- usb/wdf_osrfx2_lab/umdf/step1/Driver.h | 149 -- usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.ctl | 1 - usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.rc | 21 - .../umdf/step1/WUDFOsrUsbFx2_1.inx | Bin 5920 -> 0 bytes .../umdf/step1/WUDFOsrUsbFx2_1.vcxproj | 279 ---- .../step1/WUDFOsrUsbFx2_1.vcxproj.Filters | 43 - usb/wdf_osrfx2_lab/umdf/step1/comsup.cpp | 344 ----- usb/wdf_osrfx2_lab/umdf/step1/comsup.h | 215 --- usb/wdf_osrfx2_lab/umdf/step1/dllsup.cpp | 204 --- usb/wdf_osrfx2_lab/umdf/step1/exports.def | 4 - usb/wdf_osrfx2_lab/umdf/step1/internal.h | 150 -- usb/wdf_osrfx2_lab/umdf/step2/Device.cpp | 483 ------ usb/wdf_osrfx2_lab/umdf/step2/Device.h | 180 --- usb/wdf_osrfx2_lab/umdf/step2/Driver.cpp | 220 --- usb/wdf_osrfx2_lab/umdf/step2/Driver.h | 149 -- usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.ctl | 1 - usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.rc | 21 - .../umdf/step2/WUDFOsrUsbFx2_2.inx | Bin 5920 -> 0 bytes .../umdf/step2/WUDFOsrUsbFx2_2.vcxproj | 279 ---- .../step2/WUDFOsrUsbFx2_2.vcxproj.Filters | 43 - usb/wdf_osrfx2_lab/umdf/step2/comsup.cpp | 344 ----- usb/wdf_osrfx2_lab/umdf/step2/comsup.h | 215 --- usb/wdf_osrfx2_lab/umdf/step2/dllsup.cpp | 204 --- usb/wdf_osrfx2_lab/umdf/step2/exports.def | 4 - usb/wdf_osrfx2_lab/umdf/step2/internal.h | 150 -- .../umdf/step3/ControlQueue.cpp | 246 --- usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.h | 101 -- usb/wdf_osrfx2_lab/umdf/step3/Device.cpp | 644 -------- usb/wdf_osrfx2_lab/umdf/step3/Device.h | 203 --- usb/wdf_osrfx2_lab/umdf/step3/Driver.cpp | 220 --- usb/wdf_osrfx2_lab/umdf/step3/Driver.h | 149 -- usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.ctl | 1 - usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.rc | 21 - usb/wdf_osrfx2_lab/umdf/step3/Queue.cpp | 147 -- usb/wdf_osrfx2_lab/umdf/step3/Queue.h | 93 -- .../umdf/step3/WUDFOsrUsbFx2_3.inx | Bin 5920 -> 0 bytes .../umdf/step3/WUDFOsrUsbFx2_3.vcxproj | 279 ---- .../step3/WUDFOsrUsbFx2_3.vcxproj.Filters | 49 - usb/wdf_osrfx2_lab/umdf/step3/comsup.cpp | 344 ----- usb/wdf_osrfx2_lab/umdf/step3/comsup.h | 215 --- usb/wdf_osrfx2_lab/umdf/step3/dllsup.cpp | 204 --- usb/wdf_osrfx2_lab/umdf/step3/exports.def | 4 - usb/wdf_osrfx2_lab/umdf/step3/internal.h | 152 -- .../umdf/step4/ControlQueue.cpp | 246 --- usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.h | 101 -- usb/wdf_osrfx2_lab/umdf/step4/Device.cpp | 812 ---------- usb/wdf_osrfx2_lab/umdf/step4/Device.h | 256 --- usb/wdf_osrfx2_lab/umdf/step4/Driver.cpp | 220 --- usb/wdf_osrfx2_lab/umdf/step4/Driver.h | 149 -- usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.ctl | 1 - usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.rc | 21 - .../umdf/step4/ReadWriteQueue.cpp | 423 ----- .../umdf/step4/ReadWriteQueue.h | 163 -- .../umdf/step4/WUDFOsrUsbFx2_4.inx | Bin 5920 -> 0 bytes .../umdf/step4/WUDFOsrUsbFx2_4.vcxproj | 279 ---- .../step4/WUDFOsrUsbFx2_4.vcxproj.Filters | 52 - usb/wdf_osrfx2_lab/umdf/step4/comsup.cpp | 344 ----- usb/wdf_osrfx2_lab/umdf/step4/comsup.h | 215 --- usb/wdf_osrfx2_lab/umdf/step4/dllsup.cpp | 204 --- usb/wdf_osrfx2_lab/umdf/step4/exports.def | 4 - usb/wdf_osrfx2_lab/umdf/step4/internal.h | 154 -- usb/wdf_osrfx2_lab/umdf/step4/queue.cpp | 147 -- usb/wdf_osrfx2_lab/umdf/step4/queue.h | 93 -- usb/wdf_osrfx2_lab/wdf_osrfx2_lab.sln | 72 - 77 files changed, 7 insertions(+), 13950 deletions(-) delete mode 100644 usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj delete mode 100644 usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj.Filters delete mode 100644 usb/wdf_osrfx2_lab/umdf/exe/dump.c delete mode 100644 usb/wdf_osrfx2_lab/umdf/exe/testapp.c delete mode 100644 usb/wdf_osrfx2_lab/umdf/exe/testapp.rc delete mode 100644 usb/wdf_osrfx2_lab/umdf/inc/WUDFOsrUsbPublic.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/inc/list.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/inc/public.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/inc/usb_hw.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/Device.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/Device.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/Driver.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/Driver.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.ctl delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.rc delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj.Filters delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/comsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/comsup.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/dllsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/exports.def delete mode 100644 usb/wdf_osrfx2_lab/umdf/step1/internal.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/Device.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/Device.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/Driver.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/Driver.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.ctl delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.rc delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj.Filters delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/comsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/comsup.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/dllsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/exports.def delete mode 100644 usb/wdf_osrfx2_lab/umdf/step2/internal.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/Device.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/Device.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/Driver.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/Driver.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.ctl delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.rc delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/Queue.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/Queue.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj.Filters delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/comsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/comsup.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/dllsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/exports.def delete mode 100644 usb/wdf_osrfx2_lab/umdf/step3/internal.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/Device.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/Device.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/Driver.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/Driver.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.ctl delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.rc delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj.Filters delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/comsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/comsup.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/dllsup.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/exports.def delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/internal.h delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/queue.cpp delete mode 100644 usb/wdf_osrfx2_lab/umdf/step4/queue.h diff --git a/usb/wdf_osrfx2_lab/README.md b/usb/wdf_osrfx2_lab/README.md index aee7a8865..d24a43d06 100644 --- a/usb/wdf_osrfx2_lab/README.md +++ b/usb/wdf_osrfx2_lab/README.md @@ -10,6 +10,13 @@ products: # WDF Sample Driver Learning Lab for OSR USB-FX2 +> [!WARNING] +> UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2. +> +> For more info, see [Getting Started with UMDF](https://docs.microsoft.com/windows-hardware/drivers/wdf/getting-started-with-umdf-version-2). +> +> The UMDF v1 sample can be accessed using `git checkout win11-22h2`. A direct link is: https://github.com/microsoft/Windows-driver-samples/tree/win11-22h2 + The wdf\_osrfx2\_lab sample contains a console test application and a series of iterative drivers for both Kernel-Mode Driver Framework (KMDF) and User-Mode Driver Framework (UMDF) version 1. In the Windows Driver Kit (WDK) for Windows 7 and earlier versions of Windows, the osrusbfx2 sample demonstrated how to perform bulk and interrupt data transfers to an USB device. The sample was written for the OSR USB-FX2 Learning Kit. diff --git a/usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj b/usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj deleted file mode 100644 index 53ba424d3..000000000 --- a/usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj +++ /dev/null @@ -1,223 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {B4244D54-7EBF-43D4-BB6D-C994C182C572} - $(MSBuildProjectName) - Debug - Win32 - {6A99CFCE-4C34-4F5D-B7D4-D810AE496B95} - - - - Windows10 - False - Desktop - - WindowsApplicationForDrivers10.0 - Application - - - Windows10 - True - Desktop - - WindowsApplicationForDrivers10.0 - Application - - - Windows10 - False - Desktop - - WindowsApplicationForDrivers10.0 - Application - - - Windows10 - True - Desktop - - WindowsApplicationForDrivers10.0 - Application - - - - $(IntDir) - - - - - - - - - - - - - - - - WudfOsrUsbFx2Test - - - WudfOsrUsbFx2Test - - - WudfOsrUsbFx2Test - - - WudfOsrUsbFx2Test - - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - true - Level4 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);setupapi.lib - - - sha256 - - - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - true - Level4 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);setupapi.lib - - - sha256 - - - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - true - Level4 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);setupapi.lib - - - sha256 - - - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - true - Level4 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(PreprocessorDefinitions);BUILT_IN_DDK=1;UNICODE=1;_UNICODE=1 - %(AdditionalIncludeDirectories);..\inc;..\..\inc;$(DDK_INC_PATH) - - - %(AdditionalDependencies);setupapi.lib - - - sha256 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj.Filters b/usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj.Filters deleted file mode 100644 index a430f986c..000000000 --- a/usb/wdf_osrfx2_lab/umdf/exe/WudfOsrUsbFx2Test.vcxproj.Filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {047255FC-568B-4968-9167-306B7BC95B6D} - - - h;hpp;hxx;hm;inl;inc;xsd - {4B1DCCF4-7F0A-4571-BA4F-DF378E24BD68} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {AC1DECB1-7996-4C71-8D32-0543B4C57AD4} - - - - - Source Files - - - Source Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/exe/dump.c b/usb/wdf_osrfx2_lab/umdf/exe/dump.c deleted file mode 100644 index aef55116c..000000000 --- a/usb/wdf_osrfx2_lab/umdf/exe/dump.c +++ /dev/null @@ -1,444 +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: - - 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 %u\n", cd->bLength, cd->bLength - ); - - printf( - "bDescriptorType = 0x%x ( %s )\n", cd->bDescriptorType, - usbDescriptorTypeString( cd->bDescriptorType ) - ); - - printf( - "wTotalLength = 0x%x, decimal %u\n", cd->wTotalLength, cd->wTotalLength - ); - - printf( - "bNumInterfaces = 0x%x, decimal %u\n", cd->bNumInterfaces, cd->bNumInterfaces - ); - - printf( - "bConfigurationValue = 0x%x, decimal %u\n", - cd->bConfigurationValue, cd->bConfigurationValue - ); - - printf( - "iConfiguration = 0x%x, decimal %u\n", cd->iConfiguration, cd->iConfiguration - ); - - printf( - "bmAttributes = 0x%x ( %s )\n", cd->bmAttributes, - usbConfigAttributesString( cd->bmAttributes ) - ); - - printf( - "MaxPower = 0x%x, decimal %u\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 #%u\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 %u\n", ed->wMaxPacketSize, - ed->wMaxPacketSize - ); - - printf( - "bInterval = 0x%x, decimal %u\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, - NULL, - 0, - buf, - siz, - (PULONG) &nBytes, - NULL); - - if(success == FALSE) { - printf("Ioct - GetConfigDesc failed %u\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/usb/wdf_osrfx2_lab/umdf/exe/testapp.c b/usb/wdf_osrfx2_lab/umdf/exe/testapp.c deleted file mode 100644 index 48f494922..000000000 --- a/usb/wdf_osrfx2_lab/umdf/exe/testapp.c +++ /dev/null @@ -1,1367 +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: - - TESTAPP.C - -Abstract: - - Console test app for osrusbfx2 driver. - -Environment: - - user mode only - ---*/ - -#include -_Analysis_mode_(_Analysis_code_type_user_code_); - -#include -#include -#include -#include - -#include "devioctl.h" -#include "strsafe.h" - -#pragma warning(push) -#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(pop) - -#define WHILE(a) \ -while(__pragma(warning(disable:4127)) a __pragma(warning(disable:4127))) - -#define countof(x) (sizeof(x) / sizeof(x[0])) - -#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 -int G_WriteLen = 512; // #bytes to write -int G_ReadLen = 512; // #bytes to read -PCWSTR G_SendFileName = NULL; -ULONG G_SendFileInterval = 1; - -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 != FALSE) -BOOL -GetDevicePath( - IN LPGUID InterfaceGuid, - _Out_writes_(BufLen) PWSTR DevicePath, - _In_ size_t BufLen - ) -{ - HDEVINFO HardwareDeviceInfo; - SP_DEVICE_INTERFACE_DATA DeviceInterfaceData; - PSP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData = NULL; - ULONG Length, RequiredLength = 0; - BOOL bResult; - HRESULT hr; - - HardwareDeviceInfo = SetupDiGetClassDevs( - InterfaceGuid, - NULL, - NULL, - (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE)); - - if (HardwareDeviceInfo == INVALID_HANDLE_VALUE) { - wprintf(L"SetupDiGetClassDevs failed!\n"); - return FALSE; - } - - DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); - - bResult = SetupDiEnumDeviceInterfaces(HardwareDeviceInfo, - 0, - InterfaceGuid, - 0, - &DeviceInterfaceData); - - if (bResult == FALSE) { - - LPVOID lpMsgBuf; - - if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR) &lpMsgBuf, - 0, - NULL - )) { - - printf("SetupDiEnumDeviceInterfaces failed: %s", (LPSTR)lpMsgBuf); - LocalFree(lpMsgBuf); - } - - SetupDiDestroyDeviceInfoList(HardwareDeviceInfo); - return FALSE; - } - - SetupDiGetDeviceInterfaceDetail( - HardwareDeviceInfo, - &DeviceInterfaceData, - NULL, - 0, - &RequiredLength, - NULL - ); - - DeviceInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) - LocalAlloc(LMEM_FIXED, RequiredLength); - - if (DeviceInterfaceDetailData == NULL) { - SetupDiDestroyDeviceInfoList(HardwareDeviceInfo); - wprintf(L"Failed to allocate memory.\n"); - return FALSE; - } - - DeviceInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - - Length = RequiredLength; - - bResult = SetupDiGetDeviceInterfaceDetail( - HardwareDeviceInfo, - &DeviceInterfaceData, - DeviceInterfaceDetailData, - Length, - &RequiredLength, - NULL); - - if (bResult == FALSE) { - - LPVOID lpMsgBuf; - - if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR) &lpMsgBuf, - 0, - NULL)) { - - printf("Error in SetupDiGetDeviceInterfaceDetail: %s\n", (LPSTR)lpMsgBuf); - LocalFree(lpMsgBuf); - } - - SetupDiDestroyDeviceInfoList(HardwareDeviceInfo); - LocalFree(DeviceInterfaceDetailData); - return FALSE; - } - - hr = StringCchCopy(DevicePath, - BufLen, - DeviceInterfaceDetailData->DevicePath); - if (FAILED(hr)) { - SetupDiDestroyDeviceInfoList(HardwareDeviceInfo); - LocalFree(DeviceInterfaceDetailData); - return FALSE; - } - - SetupDiDestroyDeviceInfoList(HardwareDeviceInfo); - LocalFree(DeviceInterfaceDetailData); - - return TRUE; - -} - -_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, - countof(completeDeviceName)) ) - { - return INVALID_HANDLE_VALUE; - } - - wprintf(L"DeviceName = (%s)\n", completeDeviceName); - - hDev = CreateFile(completeDeviceName, - GENERIC_WRITE | GENERIC_READ, - FILE_SHARE_WRITE | FILE_SHARE_READ, - NULL, // default security - OPEN_EXISTING, - ((Synchronous ? FILE_ATTRIBUTE_NORMAL : FILE_FLAG_OVERLAPPED) | SECURITY_IMPERSONATION), - NULL); - - if (hDev == INVALID_HANDLE_VALUE) { - wprintf(L"Failed to open the device, error - %d", GetLastError()); - } else { - wprintf(L"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 - ---*/ - -{ - wprintf(L"Usage for osrusbfx2 testapp:\n"); - wprintf(L"-r where n is number of bytes to read\n"); - wprintf(L"-w where n is number of bytes to write\n"); - wprintf(L"-c where n is number of iterations (default = 1)\n"); - wprintf(L"-v -- dumps read data\n"); - wprintf(L"-p to control bar LEDs, seven segment, and dip switch\n"); - wprintf(L"-a to perform asynchronous I/O\n"); - wprintf(L"-u to dump USB configuration and pipe info \n"); - wprintf(L"-f [interval-seconds] to send a text file to the seven-segment display (UMDF only)\n"); - - return; -} - - -void -Parse( - _In_ int argc, - _In_reads_(argc) LPWSTR *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; - PWSTR endchar; - - if ( argc < 2 ) // give usage if invoked with no parms - Usage(); - - for (i=0; i= argc) { - Usage(); - exit(1); - } - else { - G_ReadLen = wcstoul(&argv[i+1][0], &endchar, 10); - G_fRead = TRUE; - } - i++; - break; - case L'w': - case L'W': - if (i+1 >= argc) { - Usage(); - exit(1); - } - else { - G_WriteLen = wcstoul(&argv[i+1][0], &endchar, 10); - G_fWrite = TRUE; - } - i++; - break; - case L'c': - case L'C': - if (i+1 >= argc) { - Usage(); - exit(1); - } - else { - G_IterationCount = wcstoul(&argv[i+1][0], &endchar, 10); - } - i++; - break; - case L'f': - case L'F': - if (i+1 >= argc) { - Usage(); - exit(1); - } - else { - G_SendFileName = argv[i+1]; - } - - i++; - - if (i+1 < argc) { - G_SendFileInterval = wcstoul(&argv[i+1][0], &endchar, 10); - } - i++; - - break; - case L'u': - case L'U': - G_fDumpUsbConfig = TRUE; - break; - case L'p': - case L'P': - G_fPlayWithDevice = TRUE; - break; - case L'a': - case L'A': - G_fPerformAsyncIo = TRUE; - break; - case L'v': - case L'V': - G_fDumpReadData = TRUE; - break; - default: - Usage(); - } - } - } -} - -BOOL -Compare_Buffs( - _In_reads_bytes_(length) PVOID *buff1, - _In_reads_bytes_(length) PVOID *buff2, - _In_ int length - ) -/*++ -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 (memcmp(buff1, buff2, length )) { - // 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 - wprintf(L"\n****** BEGIN DUMP LEN decimal %d, 0x%x\n", len,len); - for (i=0; i 8){ - wprintf(L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - break; - - case CLEAR_ONE_BAR: - - - wprintf(L"Which Bar (input number 1 thru 8)?\n"); - if (scanf_s ("%d", &bar) <= 0) { - - wprintf(L"Error reading input!\n"); - goto Error; - - } - - if(bar == 0 || bar > 8){ - wprintf(L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - if (barGraphState.BarsAsUChar & (1 << bar)) { - - wprintf(L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - - } - - } else { - - wprintf(L"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(); - - wprintf(L"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(); - - wprintf(L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - wprintf(L"Bar Graph: \n"); - wprintf(L" Bar8 is %s\n", barGraphState.Bar8 ? L"ON" : L"OFF"); - wprintf(L" Bar7 is %s\n", barGraphState.Bar7 ? L"ON" : L"OFF"); - wprintf(L" Bar6 is %s\n", barGraphState.Bar6 ? L"ON" : L"OFF"); - wprintf(L" Bar5 is %s\n", barGraphState.Bar5 ? L"ON" : L"OFF"); - wprintf(L" Bar4 is %s\n", barGraphState.Bar4 ? L"ON" : L"OFF"); - wprintf(L" Bar3 is %s\n", barGraphState.Bar3 ? L"ON" : L"OFF"); - wprintf(L" Bar2 is %s\n", barGraphState.Bar2 ? L"ON" : L"OFF"); - wprintf(L" Bar1 is %s\n", barGraphState.Bar1 ? L"ON" : L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - wprintf(L"Switches: \n"); - wprintf(L" Switch8 is %s\n", switchState.Switch8 ? L"ON" : L"OFF"); - wprintf(L" Switch7 is %s\n", switchState.Switch7 ? L"ON" : L"OFF"); - wprintf(L" Switch6 is %s\n", switchState.Switch6 ? L"ON" : L"OFF"); - wprintf(L" Switch5 is %s\n", switchState.Switch5 ? L"ON" : L"OFF"); - wprintf(L" Switch4 is %s\n", switchState.Switch4 ? L"ON" : L"OFF"); - wprintf(L" Switch3 is %s\n", switchState.Switch3 ? L"ON" : L"OFF"); - wprintf(L" Switch2 is %s\n", switchState.Switch2 ? L"ON" : L"OFF"); - wprintf(L" Switch1 is %s\n", switchState.Switch1 ? L"ON" : L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - wprintf(L"Switches: %d\n",index); - wprintf(L" Switch8 is %s\n", switchState.Switch8 ? L"ON" : L"OFF"); - wprintf(L" Switch7 is %s\n", switchState.Switch7 ? L"ON" : L"OFF"); - wprintf(L" Switch6 is %s\n", switchState.Switch6 ? L"ON" : L"OFF"); - wprintf(L" Switch5 is %s\n", switchState.Switch5 ? L"ON" : L"OFF"); - wprintf(L" Switch4 is %s\n", switchState.Switch4 ? L"ON" : L"OFF"); - wprintf(L" Switch3 is %s\n", switchState.Switch3 ? L"ON" : L"OFF"); - wprintf(L" Switch2 is %s\n", switchState.Switch2 ? L"ON" : L"OFF"); - wprintf(L" Switch1 is %s\n", switchState.Switch1 ? L"ON" : L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - wprintf(L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - wprintf(L"This is %d\n", i); - Sleep(500); - - } - - wprintf(L"7 Segment mask: 0x%x\n", sevenSegment); - break; - - case RESET_DEVICE: - - wprintf(L"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(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - break; - - case REENUMERATE_DEVICE: - - wprintf(L"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(); - - wprintf(L"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; - -} - -BOOL -SendFileToDevice( - _In_ PCWSTR FileName - ) -{ - HANDLE deviceHandle; - - struct - { - USHORT delay; - WCHAR buffer[MAX_PATH + 1]; - } playback; - - ULONG bufferCch; - - DWORD code; - BOOL result = FALSE; - - // - // Open a handle to the device. - // - - deviceHandle = OpenDevice(FALSE); - - if (deviceHandle == INVALID_HANDLE_VALUE) { - - wprintf(L"Unable to find any OSR FX2 devices!\n"); - - return FALSE; - - } - - // - // Convert the file name from relative to absolute. - // - - bufferCch = GetFullPathName(FileName, - countof(playback.buffer), - playback.buffer, - NULL); - - if (bufferCch == 0) - { - wprintf(L"Error getting full path name for %s - %d\n", - FileName, - GetLastError()); - goto Error; - } - - if ((G_SendFileInterval * 1000) >= ((USHORT) 0xffff)) - { - wprintf(L"Error - delay is too large. Remember that it's in terms of seconds.\n"); - goto Error; - } - - playback.delay = (USHORT) (G_SendFileInterval * 1000); - - if (!DeviceIoControl(deviceHandle, - IOCTL_OSRUSBFX2_PLAY_FILE, - &playback, - sizeof(playback), - NULL, - 0, - &bufferCch, - 0)) { - - code = GetLastError(); - - wprintf(L"DeviceIoControl failed with error 0x%x\n", code); - - goto Error; - } - - result = TRUE; - -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) { - wprintf(L"Cannot open device %d\n", GetLastError()); - goto Error; - } - - hCompletionPort = CreateIoCompletionPort(hDevice, NULL, 1, 0); - - if (hCompletionPort == NULL) { - wprintf(L"Cannot open completion port %d \n",GetLastError()); - goto Error; - } - - pOvList = (OVERLAPPED *)malloc(NUM_ASYNCH_IO * sizeof(OVERLAPPED)); - - if (pOvList == NULL) { - wprintf(L"Cannot allocate overlapped array \n"); - goto Error; - } - - buf = (PUCHAR)malloc(NUM_ASYNCH_IO * BUFFER_SIZE); - - if (buf == NULL) { - wprintf(L"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) { - wprintf(L" %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) { - wprintf(L" %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) { - wprintf(L"GetQueuedCompletionStatus failed %d\n", GetLastError()); - goto Error; - } - - // - // Read successfully completed. Issue another one. - // - - if (ioType == READER_TYPE) { - - i = completedOv - pOvList; - - wprintf(L"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) { - wprintf(L"%Iu th Read failed %d \n", i, GetLastError()); - goto Error; - } - } - } else { - - i = completedOv - pOvList; - - wprintf(L"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) { - wprintf(L"%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 -wmain( - _In_ int argc, - _In_reads_(argc) LPWSTR *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 - ---*/ - -{ - PWSTR * pinBuf = NULL; - PWSTR * poutBuf = NULL; - int nBytesRead; - int nBytesWrite; - 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_SendFileName != NULL) - { - SendFileToDevice(G_SendFileName); - 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) { - wprintf(L"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 (pinBuf == 0) { - retValue = 1; - goto exit; - } - } - - 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); - if (poutBuf == 0) { - retValue = 1; - goto exit; - } - } - - 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 for UMDF" -#define VER_INTERNALNAME_STR "WudfOsrUsbFx2Test.exe" -#define VER_ORIGINALFILENAME_STR "WudfOsrUsbFx2Test.exe" - -#include - - diff --git a/usb/wdf_osrfx2_lab/umdf/inc/WUDFOsrUsbPublic.h b/usb/wdf_osrfx2_lab/umdf/inc/WUDFOsrUsbPublic.h deleted file mode 100644 index 6681fa146..000000000 --- a/usb/wdf_osrfx2_lab/umdf/inc/WUDFOsrUsbPublic.h +++ /dev/null @@ -1,32 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - WUDFOsrUsbPublic.h - -Abstract: - - This module contains the common declarations shared by driver - and user applications for the UMDF OSR device sample. - - Note that this driver does NOT use the same device interface GUID - as the KMDF OSR USB sample. - -Environment: - - user and kernel - ---*/ - -#pragma once - -// -// Define an Interface Guid so that app can find the device and talk to it. -// - -// {573E8C73-0CB4-4471-A1BF-FAB26C31D384} -DEFINE_GUID(GUID_DEVINTERFACE_OSRUSBFX2, - 0x573e8c73, 0xcb4, 0x4471, 0xa1, 0xbf, 0xfa, 0xb2, 0x6c, 0x31, 0xd3, 0x84); - diff --git a/usb/wdf_osrfx2_lab/umdf/inc/list.h b/usb/wdf_osrfx2_lab/umdf/inc/list.h deleted file mode 100644 index 38d0b1e90..000000000 --- a/usb/wdf_osrfx2_lab/umdf/inc/list.h +++ /dev/null @@ -1,77 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - list.h - -Abstract: - - This module contains doubly linked list macros - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - - -FORCEINLINE -VOID -InitializeListHead( - IN PLIST_ENTRY ListHead - ) -{ - ListHead->Flink = ListHead->Blink = ListHead; -} - -FORCEINLINE -BOOLEAN -RemoveEntryList( - IN PLIST_ENTRY Entry - ) -{ - PLIST_ENTRY Blink; - PLIST_ENTRY Flink; - - Flink = Entry->Flink; - Blink = Entry->Blink; - Blink->Flink = Flink; - Flink->Blink = Blink; - return (BOOLEAN)(Flink == Blink); -} - -FORCEINLINE -VOID -InsertHeadList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY Entry - ) -{ - PLIST_ENTRY Flink; - - Flink = ListHead->Flink; - Entry->Flink = Flink; - Entry->Blink = ListHead; - Flink->Blink = Entry; - ListHead->Flink = Entry; -} - -FORCEINLINE -VOID -InsertTailList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY Entry - ) -{ - PLIST_ENTRY Blink; - - Blink = ListHead->Blink; - Entry->Flink = ListHead; - Entry->Blink = Blink; - Blink->Flink = Entry; - ListHead->Blink = Entry; -} diff --git a/usb/wdf_osrfx2_lab/umdf/inc/public.h b/usb/wdf_osrfx2_lab/umdf/inc/public.h deleted file mode 100644 index 2c3f6805c..000000000 --- a/usb/wdf_osrfx2_lab/umdf/inc/public.h +++ /dev/null @@ -1,217 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - -Module Name: - - public.h - -Abstract: - - Public definitions for the OSR_FX2 device operations. - -Environment: - - User & Kernel mode - ---*/ - -#ifndef _PUBLIC_H -#define _PUBLIC_H - -#include - -#include "WudfOsrUsbPublic.h" - - -// -// 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 - -#pragma warning( push ) -#pragma warning( disable : 4201 ) // nameless struct/union -#pragma warning( disable : 4214 ) // bit-field type other than int - -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; - -// -// Seven segment display bit values. -// - -// -// Undefine conflicting MFC constant -// -#undef SS_CENTER -#undef SS_LEFT -#undef SS_RIGHT - -#define SS_TOP 0x01 -#define SS_TOP_LEFT 0x40 -#define SS_TOP_RIGHT 0x02 -#define SS_CENTER 0x20 -#define SS_BOTTOM_LEFT 0x10 -#define SS_BOTTOM_RIGHT 0x04 -#define SS_BOTTOM 0x80 -#define SS_DOT 0x08 - -// -// FILE_PLAYBACK -// -// FILE_PLAYBACK structure contains the parameters for the PLAY_FILE I/O Control. -// - -typedef struct _FILE_PLAYBACK -{ - // - // The delay between changes in the display, in milliseconds. - // - - USHORT Delay; - - // - // The data file path. - // - - WCHAR Path[1]; -} FILE_PLAYBACK, *PFILE_PLAYBACK; - -#include - -#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) - -#define IOCTL_OSRUSBFX2_PLAY_FILE CTL_CODE(FILE_DEVICE_OSRUSBFX2, \ - IOCTL_INDEX + 10, \ - METHOD_BUFFERED, \ - FILE_WRITE_ACCESS) - -#pragma warning(pop) - -#endif - diff --git a/usb/wdf_osrfx2_lab/umdf/inc/usb_hw.h b/usb/wdf_osrfx2_lab/umdf/inc/usb_hw.h deleted file mode 100644 index d6e983f1a..000000000 --- a/usb/wdf_osrfx2_lab/umdf/inc/usb_hw.h +++ /dev/null @@ -1,233 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation. All rights reserved. - -Module Name: - - Usb.h - -Abstract: - - Contains prototypes for interfacing with a USB connected device. These - are copied from the KMDF WDFUSB.H header file (but with the WDF specific - portions removed) - -Environment: - - kernel mode only - ---*/ - -#pragma once - -typedef enum _WINUSB_BMREQUEST_DIRECTION { - BmRequestHostToDevice = BMREQUEST_HOST_TO_DEVICE, - BmRequestDeviceToHost = BMREQUEST_DEVICE_TO_HOST, -} WINUSB_BMREQUEST_DIRECTION; - -typedef enum _WINUSB_BMREQUEST_TYPE { - BmRequestStandard = BMREQUEST_STANDARD, - BmRequestClass = BMREQUEST_CLASS, - BmRequestVendor = BMREQUEST_VENDOR, -} WINUSB_BMREQUEST_TYPE; - -typedef enum _WINUSB_BMREQUEST_RECIPIENT { - BmRequestToDevice = BMREQUEST_TO_DEVICE, - BmRequestToInterface = BMREQUEST_TO_INTERFACE, - BmRequestToEndpoint = BMREQUEST_TO_ENDPOINT, - BmRequestToOther = BMREQUEST_TO_OTHER, -} WINUSB_BMREQUEST_RECIPIENT; - -typedef enum _WINUSB_DEVICE_TRAITS { - WINUSB_DEVICE_TRAIT_SELF_POWERED = 0x00000001, - WINUSB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE = 0x00000002, - WINUSB_DEVICE_TRAIT_AT_HIGH_SPEED = 0x00000004, -} WINUSB_DEVICE_TRAITS; - -typedef enum _WdfUsbTargetDeviceSelectInterfaceType { - WdfUsbTargetDeviceSelectInterfaceTypeInterface = 0x10, - WdfUsbTargetDeviceSelectInterfaceTypeUrb = 0x11, -} WdfUsbTargetDeviceSelectInterfaceType; - - - -typedef union _WINUSB_CONTROL_SETUP_PACKET { - struct { - union { - #pragma warning(disable:4214) // bit field types other than int - struct { - // - // Valid values are BMREQUEST_TO_DEVICE, BMREQUEST_TO_INTERFACE, - // BMREQUEST_TO_ENDPOINT, BMREQUEST_TO_OTHER - // - BYTE Recipient:2; - - BYTE Reserved:3; - - // - // Valid values are BMREQUEST_STANDARD, BMREQUEST_CLASS, - // BMREQUEST_VENDOR - // - BYTE Type:2; - - // - // Valid values are BMREQUEST_HOST_TO_DEVICE, - // BMREQUEST_DEVICE_TO_HOST - // - BYTE Dir:1; - } Request; - #pragma warning(default:4214) // bit field types other than int - BYTE Byte; - } bm; - - BYTE bRequest; - - union { - struct { - BYTE LowByte; - BYTE HiByte; - } Bytes; - USHORT Value; - } wValue; - - union { - struct { - BYTE LowByte; - BYTE HiByte; - } Bytes; - USHORT Value; - } wIndex; - - USHORT wLength; - } Packet; - - struct { - BYTE Bytes[8]; - } Generic; - - WINUSB_SETUP_PACKET WinUsb; - -} WINUSB_CONTROL_SETUP_PACKET, *PWINUSB_CONTROL_SETUP_PACKET; - -VOID -FORCEINLINE -WINUSB_CONTROL_SETUP_PACKET_INIT( - PWINUSB_CONTROL_SETUP_PACKET Packet, - WINUSB_BMREQUEST_DIRECTION Direction, - WINUSB_BMREQUEST_RECIPIENT Recipient, - BYTE Request, - USHORT Value, - USHORT Index - ) -{ - RtlZeroMemory(Packet, sizeof(WINUSB_CONTROL_SETUP_PACKET)); - - Packet->Packet.bm.Request.Dir = (BYTE) Direction; - Packet->Packet.bm.Request.Type = (BYTE) BmRequestStandard; - Packet->Packet.bm.Request.Recipient = (BYTE) Recipient; - - Packet->Packet.bRequest = Request; - Packet->Packet.wValue.Value = Value; - Packet->Packet.wIndex.Value = Index; - - // Packet->Packet.wLength will be set by the formatting function -} - -VOID -FORCEINLINE -WINUSB_CONTROL_SETUP_PACKET_INIT_CLASS( - PWINUSB_CONTROL_SETUP_PACKET Packet, - WINUSB_BMREQUEST_DIRECTION Direction, - WINUSB_BMREQUEST_RECIPIENT Recipient, - BYTE Request, - USHORT Value, - USHORT Index - ) -{ - RtlZeroMemory(Packet, sizeof(WINUSB_CONTROL_SETUP_PACKET)); - - Packet->Packet.bm.Request.Dir = (BYTE) Direction; - Packet->Packet.bm.Request.Type = (BYTE) BmRequestClass; - Packet->Packet.bm.Request.Recipient = (BYTE) Recipient; - - Packet->Packet.bRequest = Request; - Packet->Packet.wValue.Value = Value; - Packet->Packet.wIndex.Value = Index; - - // Packet->Packet.wLength will be set by the formatting function -} - -VOID -FORCEINLINE -WINUSB_CONTROL_SETUP_PACKET_INIT_VENDOR( - PWINUSB_CONTROL_SETUP_PACKET Packet, - WINUSB_BMREQUEST_DIRECTION Direction, - WINUSB_BMREQUEST_RECIPIENT Recipient, - BYTE Request, - USHORT Value, - USHORT Index - ) -{ - RtlZeroMemory(Packet, sizeof(WINUSB_CONTROL_SETUP_PACKET)); - - Packet->Packet.bm.Request.Dir = (BYTE) Direction; - Packet->Packet.bm.Request.Type = (BYTE) BmRequestVendor; - Packet->Packet.bm.Request.Recipient = (BYTE) Recipient; - - Packet->Packet.bRequest = Request; - Packet->Packet.wValue.Value = Value; - Packet->Packet.wIndex.Value = Index; - - // Packet->Packet.wLength will be set by the formatting function -} - -VOID -FORCEINLINE -WINUSB_CONTROL_SETUP_PACKET_INIT_FEATURE( - PWINUSB_CONTROL_SETUP_PACKET Packet, - WINUSB_BMREQUEST_RECIPIENT BmRequestRecipient, - USHORT FeatureSelector, - USHORT Index, - BOOLEAN SetFeature - ) -{ - RtlZeroMemory(Packet, sizeof(WINUSB_CONTROL_SETUP_PACKET)); - - Packet->Packet.bm.Request.Dir = (BYTE) BmRequestHostToDevice; - Packet->Packet.bm.Request.Type = (BYTE) BmRequestStandard; - Packet->Packet.bm.Request.Recipient = (BYTE) BmRequestRecipient; - - if (SetFeature) { - Packet->Packet.bRequest = USB_REQUEST_SET_FEATURE; - } - else { - Packet->Packet.bRequest = USB_REQUEST_CLEAR_FEATURE; - } - - Packet->Packet.wValue.Value = FeatureSelector; - Packet->Packet.wIndex.Value = Index; - - // Packet->Packet.wLength will be set by the formatting function -} - -VOID -FORCEINLINE -WINUSB_CONTROL_SETUP_PACKET_INIT_GET_STATUS( - PWINUSB_CONTROL_SETUP_PACKET Packet, - WINUSB_BMREQUEST_RECIPIENT BmRequestRecipient, - USHORT Index - ) -{ - RtlZeroMemory(Packet, sizeof(WINUSB_CONTROL_SETUP_PACKET)); - - Packet->Packet.bm.Request.Dir = (BYTE) BmRequestDeviceToHost; - Packet->Packet.bm.Request.Type = (BYTE) BmRequestStandard; - Packet->Packet.bm.Request.Recipient = (BYTE) BmRequestRecipient; - - Packet->Packet.bRequest = USB_REQUEST_GET_STATUS; - Packet->Packet.wIndex.Value = Index; - Packet->Packet.wValue.Value = 0; - - // Packet->Packet.wLength will be set by the formatting function -} - diff --git a/usb/wdf_osrfx2_lab/umdf/step1/Device.cpp b/usb/wdf_osrfx2_lab/umdf/step1/Device.cpp deleted file mode 100644 index 68c1245ce..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/Device.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Device.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton sample driver's - device callback object. - - The skeleton sample device does very little. It does not implement either - of the PNP interfaces so once the device is setup, it won't ever get any - callbacks until the device is removed. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "initguid.h" -#include "usb_hw.h" - -#include "device.tmh" - - -HRESULT -CMyDevice::CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit, - _Out_ PCMyDevice *Device - ) -/*++ - - Routine Description: - - This method creates and initializs an instance of the skeleton driver's - device callback object. - - Arguments: - - FxDeviceInit - the settings for the device. - - Device - a location to store the referenced pointer to the device object. - - Return Value: - - Status - ---*/ -{ - PCMyDevice device; - HRESULT hr; - - // - // Allocate a new instance of the device class. - // - - device = new CMyDevice(); - - if (NULL == device) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the instance. - // - - hr = device->Initialize(FxDriver, FxDeviceInit); - - if (SUCCEEDED(hr)) - { - *Device = device; - } - else - { - device->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Initialize( - _In_ IWDFDriver * FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit - ) -/*++ - - Routine Description: - - This method initializes the device callback object and creates the - partner device object. - - The method should perform any device-specific configuration that: - * could fail (these can't be done in the constructor) - * must be done before the partner object is created -or- - * can be done after the partner object is created and which aren't - influenced by any device-level parameters the parent (the driver - in this case) might set. - - Arguments: - - FxDeviceInit - the settings for this device. - - Return Value: - - status. - ---*/ -{ - IWDFDevice *fxDevice = NULL; - - HRESULT hr = S_OK; - - // - // TODO: If you're writing a filter driver then indicate that here. - // - // FxDeviceInit->SetFilter(); - // - - // - // Set no locking unless you need an automatic callbacks synchronization - // - - FxDeviceInit->SetLockingConstraint(None); - - // - // TODO: Any per-device initialization which must be done before - // creating the partner object. - // - - // - // Create a new FX device object and assign the new callback object to - // handle any device level events that occur. - // - - // - // QueryIUnknown references the IUnknown interface that it returns - // (which is the same as referencing the device). We pass that to - // CreateDevice, which takes its own reference if everything works. - // - - if (SUCCEEDED(hr)) - { - IUnknown *unknown = this->QueryIUnknown(); - - hr = FxDriver->CreateDevice(FxDeviceInit, unknown, &fxDevice); - - unknown->Release(); - } - - // - // If that succeeded then set our FxDevice member variable. - // - - if (SUCCEEDED(hr)) - { - m_FxDevice = fxDevice; - - // - // Drop the reference we got from CreateDevice. Since this object - // is partnered with the framework object they have the same - // lifespan - there is no need for an additional reference. - // - - fxDevice->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Configure( - VOID - ) -/*++ - - Routine Description: - - This method is called after the device callback object has been initialized - and returned to the driver. It would setup the device's queues and their - corresponding callback objects. - - Arguments: - - FxDevice - the framework device object for which we're handling events. - - Return Value: - - status - ---*/ -{ - return S_OK; -} - -HRESULT -CMyDevice::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method is called to get a pointer to one of the object's callback - interfaces. - - Since the skeleton driver doesn't support any of the device events, this - method simply calls the base class's BaseQueryInterface. - - If the skeleton is extended to include device event interfaces then this - method must be changed to check the IID and return pointers to them as - appropriate. - - Arguments: - - InterfaceId - the interface being requested - - Object - a location to store the interface pointer if successful - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - return CUnknown::QueryInterface(InterfaceId, Object); -} diff --git a/usb/wdf_osrfx2_lab/umdf/step1/Device.h b/usb/wdf_osrfx2_lab/umdf/step1/Device.h deleted file mode 100644 index 24954a6b1..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/Device.h +++ /dev/null @@ -1,128 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Device.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample - driver's device callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once -#include "internal.h" - -// -// Class for the iotrace driver. -// - -class CMyDevice : - public CUnknown -{ - -// -// Private data members. -// -private: - // - // Weak reference to framework device - // - - IWDFDevice *m_FxDevice; - -// -// Private methods. -// - -private: - - CMyDevice( - VOID - ) : - m_FxDevice(NULL) - { - } - - HRESULT - Initialize( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit, - _Out_ PCMyDevice *Device - ); - - IWDFDevice * - GetFxDevice( - VOID - ) - { - return m_FxDevice; - } - - HRESULT - Configure( - VOID - ); - -// -// COM methods -// -public: - - // - // IUnknown methods. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step1/Driver.cpp b/usb/wdf_osrfx2_lab/umdf/step1/Driver.cpp deleted file mode 100644 index bac5caca9..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/Driver.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Driver.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample's - core driver callback object. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "driver.tmh" - -HRESULT -CMyDriver::CreateInstance( - _Out_ PCMyDriver *Driver - ) -/*++ - - Routine Description: - - This static method is invoked in order to create and initialize a new - instance of the driver class. The caller should arrange for the object - to be released when it is no longer in use. - - Arguments: - - Driver - a location to store a referenced pointer to the new instance - - Return Value: - - S_OK if successful, or error otherwise. - ---*/ -{ - PCMyDriver driver; - HRESULT hr; - - // - // Allocate the callback object. - // - - driver = new CMyDriver(); - - if (NULL == driver) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the callback object. - // - - hr = driver->Initialize(); - - if (SUCCEEDED(hr)) - { - // - // Store a pointer to the new, initialized object in the output - // parameter. - // - - *Driver = driver; - } - else - { - - // - // Release the reference on the driver object to get it to delete - // itself. - // - - driver->Release(); - } - - return hr; -} - -HRESULT -CMyDriver::Initialize( - VOID - ) -/*++ - - Routine Description: - - This method is called to initialize a newly created driver callback object - before it is returned to the creator. Unlike the constructor, the - Initialize method contains operations which could potentially fail. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - return S_OK; -} - -HRESULT -CMyDriver::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Interface - ) -/*++ - - Routine Description: - - This method returns a pointer to the requested interface on the callback - object.. - - Arguments: - - InterfaceId - the IID of the interface to query/reference - - Interface - a location to store the interface pointer. - - Return Value: - - S_OK if the interface is supported. - E_NOINTERFACE if it is not supported. - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IDriverEntry))) - { - *Interface = QueryIDriverEntry(); - return S_OK; - } - else - { - return CUnknown::QueryInterface(InterfaceId, Interface); - } -} - -HRESULT -CMyDriver::OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ) -/*++ - - Routine Description: - - The FX invokes this method when it wants to install our driver on a device - stack. This method creates a device callback object, then calls the Fx - to create an Fx device object and associate the new callback object with - it. - - Arguments: - - FxWdfDriver - the Fx driver object. - - FxDeviceInit - the initialization information for the device. - - Return Value: - - status - ---*/ -{ - HRESULT hr; - - PCMyDevice device = NULL; - - // - // TODO: Do any per-device initialization (reading settings from the - // registry for example) that's necessary before creating your - // device callback object here. Otherwise you can leave such - // initialization to the initialization of the device event - // handler. - // - - // - // Create a new instance of our device callback object - // - - hr = CMyDevice::CreateInstance(FxWdfDriver, FxDeviceInit, &device); - - // - // TODO: Change any per-device settings that the object exposes before - // calling Configure to let it complete its initialization. - // - - // - // If that succeeded then call the device's construct method. This - // allows the device to create any queues or other structures that it - // needs now that the corresponding fx device object has been created. - // - - if (SUCCEEDED(hr)) - { - hr = device->Configure(); - } - - // - // Release the reference on the device callback object now that it's been - // associated with an fx device object. - // - - if (NULL != device) - { - device->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step1/Driver.h b/usb/wdf_osrfx2_lab/umdf/step1/Driver.h deleted file mode 100644 index 800ab1d9a..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/Driver.h +++ /dev/null @@ -1,149 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Driver.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample's - driver callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// This class handles driver events for the skeleton sample. In particular -// it supports the OnDeviceAdd event, which occurs when the driver is called -// to setup per-device handlers for a new device stack. -// - -class CMyDriver : public CUnknown, public IDriverEntry -{ -// -// Private data members. -// -private: - -// -// Private methods. -// -private: - - // - // Returns a refernced pointer to the IDriverEntry interface. - // - - IDriverEntry * - QueryIDriverEntry( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - HRESULT - Initialize( - VOID - ); - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _Out_ PCMyDriver *Driver - ); - -// -// COM methods -// -public: - - // - // IDriverEntry methods - // - - virtual - HRESULT - STDMETHODCALLTYPE - OnInitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return S_OK; - } - - virtual - HRESULT - STDMETHODCALLTYPE - OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - virtual - VOID - STDMETHODCALLTYPE - OnDeinitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return; - } - - // - // IUnknown methods. - // - // We have to implement basic ones here that redirect to the - // base class becuase of the multiple inheritance. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.ctl b/usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.ctl deleted file mode 100644 index 4dab56ae3..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.ctl +++ /dev/null @@ -1 +0,0 @@ -da5fbdfd-1eae-4ecf-b426-a3818f325ddb WudfOsrUsbFx2TraceGuid diff --git a/usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.rc b/usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.rc deleted file mode 100644 index 36f10ea90..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/OsrUsbFx2.rc +++ /dev/null @@ -1,21 +0,0 @@ -//--------------------------------------------------------------------------- -// OsrUsbDevice.rc -// -// Copyright (c) Microsoft Corporation, All Rights Reserved -//--------------------------------------------------------------------------- - - -#include -#include - -// -// TODO: Change the file description and file names to match your binary. -// - -#define VER_FILETYPE VFT_DLL -#define VER_FILESUBTYPE VFT_UNKNOWN -#define VER_FILEDESCRIPTION_STR "WDF:UMDF OSR USB Fx2 User-Mode Driver Sample" -#define VER_INTERNALNAME_STR "WUDFOsrUsbFx2" -#define VER_ORIGINALFILENAME_STR "WUDFOsrUsbFx2.dll" - -#include "common.ver" diff --git a/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx b/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.inx deleted file mode 100644 index 69f0c0c40cea63bc24387b9138bbf4d80acce6b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5920 zcmb`L+fG|Y6o%)zQr}?V1%6mYV+!Czkim; zGqde&j1+C{^UON@>p1h@zfauH?kD%e74Droac#Hnj@-!I@H}#7ynS;UuItua-CepX zcfq(C=K;?nH+DVuk)z=0PdDIx|Av{y##>jN zr|zx)I^zEj4uANs9o|0h)`QDu<_=ubt+)rsD~bAy{0f)C9lB$_uJ}1Er0Vf?#Mll` zpWHQH2Bm+`pmzy{ru*AHayxDpJzH+mZE>%0-RAi*PwO0go@?l|!_nrc!O`N}0;65N zY%}H&=XcNJHF6HoQPib>)2+Jlw?i-2fIrf`ouFbUG@-ufegXe&e-+1Vx5l+TJ=Z51 z2^-mB2vYlSm99;2`3(OH#-HeR^R0npBSO(*^Vr&Clwq@rE`6{aVB_4Y z-b)iQ}Hu^&LvXFhex2HoOg{(mf0-k zMO&G-xzwSoYMLm|#vEOE9wAParM8%-Bs0xZPUTp$C^jEyVbN>+E!wa-kvC@hFh-Q+ z<>y#W8A`e8owtqEjkfI>v7ATtz`NVWJby!WWqnFgwsrh&AR{HlFcqXSy^ zv00sZ{dI0$$?ctH;BF@2{kV0I|7M!YL%djS%Kr&>>qFjvfvVj%pDUFw8$`M))><+~ z`8B7I=TBKeR=Dsv>jO`sxWQfiG4`m+GRi>(v~>-Z(ugRvXc+q8zdSd@o$#pAC)#SB zK098YIA%G0qReF}O%u_J9h!W)pr4aJ_3%f{DbU&U@9})W+ehA|aXqOQxj*FCTKw0s zhPn*P122d#y>&dLfKDDws?n(jm-C9SJekn3>Tr$JV`NvCsctHrosOR6TGi8<3{`&@ zNtE+ALLT{nNmWJfe$k=~ks~eodDMhHpla-Fw9e+8CN*(Br>_5#=kusTihdcX+zVdf zRcFYq4)M0s-CM2H%Hnb2Zz1|qzYD97924Ud{A3ZQX3_%Fu}d+!!~fx3YdZ65c zo`TWU1fjrl6$%^l5$}lutNHJzId2{^LecsbTmML_)2vJAW?e$=9foA=-d4ast15Y& zRVm90Bjisrn02v2M_pd(6)Pa8th*1TXJlxtklIwjJ^yy>exnoL3wP*fF>)dh+9z*GRO2xWS zTk)t9$^UM8+4n$Jy~vG^vnxjFO)F{15hw`%kU?j?B>G5*8A)9yPuy~*2+6;!S6EzI z79$jTnt)VJ^$Y&3Zb7~7VvJHcK~t?HbF9KB-No@P+-&@E=mnZ7f~JjjEoKp{&XVbx ztQC&MNwlCMYd-DF{_v~8&t_NFV~wcAsT*+EYTy)Pt=(!?}ZLs@fNF`<-OUp zgI0UOFXTnbGv`E)s+D@TA=h+|X+)M$MiXbl6kb_O2TG^*sHEYqGB~S?t$hq?h^}Id)jV@t%Gg - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {94BDC8D1-B62F-4200-9873-D403B6D30301} - $(MSBuildProjectName) - 1 - 1 - Debug - Win32 - {A2C76CA1-1B47-420E-9768-93D69A3266B6} - - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - - $(IntDir) - - - - - - - - - - - - - - - - true - true - internal.h - - - true - true - internal.h - - - - WUDFOsrUsbFx2_1 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_1 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_1 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_1 - 0x0A00 - 0x0A000000 - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj.Filters b/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj.Filters deleted file mode 100644 index 6b21dc4a0..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/WUDFOsrUsbFx2_1.vcxproj.Filters +++ /dev/null @@ -1,43 +0,0 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {83D4660B-A09F-4A40-A1FD-237876304103} - - - h;hpp;hxx;hm;inl;inc;xsd - {3C16D1C8-B1DE-467D-9DF0-AE732A9B8915} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {E23C96E3-DE9A-457A-A1D4-DA476B16AD08} - - - inf;inv;inx;mof;mc; - {C71DC5A8-0692-4670-A5B8-B6706FA885E7} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/step1/comsup.cpp b/usb/wdf_osrfx2_lab/umdf/step1/comsup.cpp deleted file mode 100644 index 9c9aec3b5..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/comsup.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.cpp - -Abstract: - - This module contains implementations for the functions and methods - used for providing COM support. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" - -#include "comsup.tmh" - -// -// Implementation of CUnknown methods. -// - -CUnknown::CUnknown( - VOID - ) : m_ReferenceCount(1) -/*++ - - Routine Description: - - Constructor for an instance of the CUnknown class. This simply initializes - the reference count of the object to 1. The caller is expected to - call Release() if it wants to delete the object once it has been allocated. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - // do nothing. -} - -HRESULT -STDMETHODCALLTYPE -CUnknown::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method provides the basic support for query interface on CUnknown. - If the interface requested is IUnknown it references the object and - returns an interface pointer. Otherwise it returns an error. - - Arguments: - - InterfaceId - the IID being requested - - Object - a location to store the interface pointer to return. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IUnknown))) - { - *Object = QueryIUnknown(); - return S_OK; - } - else - { - *Object = NULL; - return E_NOINTERFACE; - } -} - -IUnknown * -CUnknown::QueryIUnknown( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IUnknown interface. - - This allows other methods to convert a CUnknown pointer into an IUnknown - pointer without a typecast and without calling QueryInterface and dealing - with the return value. - - Arguments: - - None - - Return Value: - - A pointer to the object's IUnknown interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::AddRef( - VOID - ) -/*++ - - Routine Description: - - This method adds one to the object's reference count. - - Arguments: - - None - - Return Value: - - The new reference count. The caller should only use this for debugging - as the object's actual reference count can change while the caller - examines the return value. - ---*/ -{ - return InterlockedIncrement(&m_ReferenceCount); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::Release( - VOID - ) -/*++ - - Routine Description: - - This method subtracts one to the object's reference count. If the count - goes to zero, this method deletes the object. - - Arguments: - - None - - Return Value: - - The new reference count. If the caller uses this value it should only be - to check for zero (i.e. this call caused or will cause deletion) or - non-zero (i.e. some other call may have caused deletion, but this one - didn't). - ---*/ -{ - ULONG count = InterlockedDecrement(&m_ReferenceCount); - - if (count == 0) - { - delete this; - } - return count; -} - -// -// Implementation of CClassFactory methods. -// - -// -// Define storage for the factory's static lock count variable. -// - -LONG CClassFactory::s_LockCount = 0; - -IClassFactory * -CClassFactory::QueryIClassFactory( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IClassFactory interface. - - This allows other methods to convert a CClassFactory pointer into an - IClassFactory pointer without a typecast and without dealing with the - return value QueryInterface. - - Arguments: - - None - - Return Value: - - A referenced pointer to the object's IClassFactory interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -HRESULT -CClassFactory::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method attempts to retrieve the requested interface from the object. - - If the interface is found then the reference count on that interface (and - thus the object itself) is incremented. - - Arguments: - - InterfaceId - the interface the caller is requesting. - - Object - a location to store the interface pointer. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - // - // This class only supports IClassFactory so check for that. - // - - if (IsEqualIID(InterfaceId, __uuidof(IClassFactory))) - { - *Object = QueryIClassFactory(); - return S_OK; - } - else - { - // - // See if the base class supports the interface. - // - - return CUnknown::QueryInterface(InterfaceId, Object); - } -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::CreateInstance( - _In_opt_ IUnknown * /* OuterObject */, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ) -/*++ - - Routine Description: - - This COM method is the factory routine - it creates instances of the driver - callback class and returns the specified interface on them. - - Arguments: - - OuterObject - only used for aggregation, which our driver callback class - does not support. - - InterfaceId - the interface ID the caller would like to get from our - new object. - - Object - a location to store the referenced interface pointer to the new - object. - - Return Value: - - Status. - ---*/ -{ - HRESULT hr; - - PCMyDriver driver; - - *Object = NULL; - - hr = CMyDriver::CreateInstance(&driver); - - if (SUCCEEDED(hr)) - { - hr = driver->QueryInterface(InterfaceId, Object); - driver->Release(); - } - - return hr; -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::LockServer( - _In_ BOOL Lock - ) -/*++ - - Routine Description: - - This COM method can be used to keep the DLL in memory. However since the - driver's DllCanUnloadNow function always returns false, this has little - effect. Still it tracks the number of lock and unlock operations. - - Arguments: - - Lock - Whether the caller wants to lock or unlock the "server" - - Return Value: - - S_OK - ---*/ -{ - if (Lock) - { - InterlockedIncrement(&s_LockCount); - } - else - { - InterlockedDecrement(&s_LockCount); - } - return S_OK; -} - diff --git a/usb/wdf_osrfx2_lab/umdf/step1/comsup.h b/usb/wdf_osrfx2_lab/umdf/step1/comsup.h deleted file mode 100644 index dedf78c84..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/comsup.h +++ /dev/null @@ -1,215 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.h - -Abstract: - - This module contains classes and functions use for providing COM support - code. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Forward type declarations. They are here rather than in internal.h as -// you only need them if you choose to use these support classes. -// - -typedef class CUnknown *PCUnknown; -typedef class CClassFactory *PCClassFactory; - -// -// Base class to implement IUnknown. You can choose to derive your COM -// classes from this class, or simply implement IUnknown in each of your -// classes. -// - -class CUnknown : public IUnknown -{ - -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The reference count for this object. Initialized to 1 in the - // constructor. - // - - LONG m_ReferenceCount; - -// -// Protected data members and methods. These are accessible by the subclasses -// but not by other classes. -// -protected: - - // - // The constructor and destructor are protected to ensure that only the - // subclasses of CUnknown can create and destroy instances. - // - - CUnknown( - VOID - ); - - // - // The destructor MUST be virtual. Since any instance of a CUnknown - // derived class should only be deleted from within CUnknown::Release, - // the destructor MUST be virtual or only CUnknown::~CUnknown will get - // invoked on deletion. - // - // If you see that your CMyDevice specific destructor is never being - // called, make sure you haven't deleted the virtual destructor here. - // - - virtual - ~CUnknown( - VOID - ) - { - // Do nothing - } - -// -// Public Methods. These are accessible by any class. -// -public: - - IUnknown * - QueryIUnknown( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ); - - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ); - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; - -// -// Class factory support class. Create an instance of this from your -// DllGetClassObject method and modify the implementation to create -// an instance of your driver event handler class. -// - -class CClassFactory : public CUnknown, public IClassFactory -{ -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The lock count. This is shared across all instances of IClassFactory - // and can be queried through the public IsLocked method. - // - - static LONG s_LockCount; - -// -// Public Methods. These are accessible by any class. -// -public: - - IClassFactory * - QueryIClassFactory( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - // - // IClassFactory methods. - // - - virtual - HRESULT - STDMETHODCALLTYPE - CreateInstance( - _In_opt_ IUnknown *OuterObject, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ); - - virtual - HRESULT - STDMETHODCALLTYPE - LockServer( - _In_ BOOL Lock - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step1/dllsup.cpp b/usb/wdf_osrfx2_lab/umdf/step1/dllsup.cpp deleted file mode 100644 index bd681ac22..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/dllsup.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - dllsup.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample - Driver's entry point and its exported functions for providing COM support. - - This module can be copied without modification to a new UMDF driver. It - depends on some of the code in comsup.cpp & comsup.h to handle DLL - registration and creating the first class factory. - - This module is dependent on the following defines: - - MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing - tracing. For example the skeleton uses - L"Microsoft\\UMDF\\Skeleton" - - MYDRIVER_CLASS_ID - A GUID encoded in struct format used to - initialize the driver's ClassID. - - These are defined in internal.h for the skeleton sample. If you choose - to use a different primary include file, you should ensure they are - defined there as well. - -Environment: - - WDF User-Mode Driver Framework (WDF:UMDF) - ---*/ - -#include "internal.h" -#include "dllsup.tmh" - -const GUID CLSID_MyDriverCoClass = MYDRIVER_CLASS_ID; - -BOOL -WINAPI -DllMain( - HINSTANCE ModuleHandle, - DWORD Reason, - PVOID /* Reserved */ - ) -/*++ - - Routine Description: - - This is the entry point and exit point for the I/O trace driver. This - does very little as the I/O trace driver has minimal global data. - - This method initializes tracing, and saves the module handle away in a - global variable so that it can be referenced should the COM registration - code (Dll[Un]RegisterServer) be called. - - Arguments: - - ModuleHandle - the DLL handle for this module. - - Reason - the reason this entry point was called. - - Reserved - unused - - Return Value: - - TRUE - ---*/ -{ - UNREFERENCED_PARAMETER(ModuleHandle); - - if (DLL_PROCESS_ATTACH == Reason) - { - // - // Initialize tracing. - // - - WPP_INIT_TRACING(MYDRIVER_TRACING_ID); - } - else if (DLL_PROCESS_DETACH == Reason) - { - // - // Cleanup tracing. - // - - WPP_CLEANUP(); - } - - return TRUE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllCanUnloadNow( - VOID - ) -/*++ - - Routine Description: - - Called by the COM runtime when determining whether or not this module - can be unloaded. Our answer is always "no". - - Arguments: - - None - - Return Value: - - S_FALSE - ---*/ -{ - return S_FALSE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllGetClassObject( - REFCLSID ClassId, - REFIID InterfaceId, - LPVOID *Interface - ) -/*++ - - Routine Description: - - This routine is called by COM in order to instantiate the - skeleton driver callback object and do an initial query interface on it. - - This method only creates an instance of the driver's class factory, as this - is the minimum required to support UMDF. - - Arguments: - - ClassId - the CLSID of the object being "gotten" - - InterfaceId - the interface the caller wants from that object. - - Interface - a location to store the referenced interface pointer - - Return Value: - - S_OK if the function succeeds or error indicating the cause of the - failure. - ---*/ -{ - PCClassFactory factory; - - HRESULT hr = S_OK; - - *Interface = NULL; - - // - // If the CLSID doesn't match that of our "coclass" (defined in the IDL - // file) then we can't create the object the caller wants. This may - // indicate that the COM registration is incorrect, and another CLSID - // is referencing this drvier. - // - - if (IsEqualCLSID(ClassId, CLSID_MyDriverCoClass) == false) - { - Trace( - TRACE_LEVEL_ERROR, - L"ERROR: Called to create instance of unrecognized class (%!GUID!)", - &ClassId - ); - - return CLASS_E_CLASSNOTAVAILABLE; - } - - // - // Create an instance of the class factory for the caller. - // - - factory = new CClassFactory(); - - if (NULL == factory) - { - hr = E_OUTOFMEMORY; - } - - // - // Query the object we created for the interface the caller wants. After - // that we release the object. This will drive the reference count to - // 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed). - // In the later case the object is automatically deleted. - // - - if (SUCCEEDED(hr)) - { - hr = factory->QueryInterface(InterfaceId, Interface); - factory->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step1/exports.def b/usb/wdf_osrfx2_lab/umdf/step1/exports.def deleted file mode 100644 index 15f923d3b..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/exports.def +++ /dev/null @@ -1,4 +0,0 @@ -; WudfOsrUsbDriver.def : Declares the module parameters. - -EXPORTS - DllGetClassObject PRIVATE diff --git a/usb/wdf_osrfx2_lab/umdf/step1/internal.h b/usb/wdf_osrfx2_lab/umdf/step1/internal.h deleted file mode 100644 index 374931e05..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step1/internal.h +++ /dev/null @@ -1,150 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Internal.h - -Abstract: - - This module contains the local type definitions for the UMDF Skeleton - driver sample. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -// -// Include the WUDF Headers -// - -#include "wudfddi.h" - -// -// Use specstrings for in/out annotation of function parameters. -// - -#include "specstrings.h" - -// -// Get limits on common data types (ULONG_MAX for example) -// - -#include "limits.h" - -// -// We need usb I/O targets to talk to the OSR device. -// - -#include "wudfusb.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "public.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "WUDFOsrUsbPublic.h" - -// -// Forward definitions of classes in the other header files. -// - -typedef class CMyDriver *PCMyDriver; -typedef class CMyDevice *PCMyDevice; -typedef class CMyQueue *PCMyQueue; - -typedef class CMyControlQueue *PCMyControlQueue; - -// -// Define the tracing flags. -// -// TODO: Choose a different trace control GUID -// - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - WudfOsrUsbFx2TraceGuid, (da5fbdfd,1eae,4ecf,b426,a3818f325ddb), \ - \ - WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \ - WPP_DEFINE_BIT(TEST_TRACE_DRIVER) \ - WPP_DEFINE_BIT(TEST_TRACE_DEVICE) \ - WPP_DEFINE_BIT(TEST_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) - -// -// This comment block is scanned by the trace preprocessor to define our -// Trace function. -// -// begin_wpp config -// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); -// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); -// end_wpp -// - -// -// Driver specific #defines -// -// TODO: Change these values to be appropriate for your driver. -// - -#define MYDRIVER_TRACING_ID L"Microsoft\\UMDF\\OsrUsb" -#define MYDRIVER_CLASS_ID {0x0865b2b0, 0x6b73, 0x428f, {0xa3, 0xea, 0x21, 0x72, 0x83, 0x2d, 0x6b, 0xfc}} - -// -// Include the type specific headers. -// - -#include "comsup.h" -#include "driver.h" -#include "device.h" -#include "list.h" - -__forceinline -#ifdef _PREFAST_ -__declspec(noreturn) -#endif -VOID -WdfTestNoReturn( - VOID - ) -{ - // do nothing. -} - -#define WUDF_TEST_DRIVER_ASSERT(p) \ -{ \ - if ( !(p) ) \ - { \ - DebugBreak(); \ - WdfTestNoReturn(); \ - } \ -} - -#define SAFE_RELEASE(p) {if ((p)) { (p)->Release(); (p) = NULL; }} diff --git a/usb/wdf_osrfx2_lab/umdf/step2/Device.cpp b/usb/wdf_osrfx2_lab/umdf/step2/Device.cpp deleted file mode 100644 index 433309ca6..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/Device.cpp +++ /dev/null @@ -1,483 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Device.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton sample driver's - device callback object. - - The skeleton sample device does very little. It does not implement either - of the PNP interfaces so once the device is setup, it won't ever get any - callbacks until the device is removed. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "initguid.h" -#include "usb_hw.h" - -#include "device.tmh" - -CMyDevice::~CMyDevice( - ) -{ -} - -HRESULT -CMyDevice::CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit, - _Out_ PCMyDevice *Device - ) -/*++ - - Routine Description: - - This method creates and initializs an instance of the skeleton driver's - device callback object. - - Arguments: - - FxDeviceInit - the settings for the device. - - Device - a location to store the referenced pointer to the device object. - - Return Value: - - Status - ---*/ -{ - PCMyDevice device; - HRESULT hr; - - // - // Allocate a new instance of the device class. - // - - device = new CMyDevice(); - - if (NULL == device) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the instance. - // - - hr = device->Initialize(FxDriver, FxDeviceInit); - - if (SUCCEEDED(hr)) - { - *Device = device; - } - else - { - device->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Initialize( - _In_ IWDFDriver * FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit - ) -/*++ - - Routine Description: - - This method initializes the device callback object and creates the - partner device object. - - The method should perform any device-specific configuration that: - * could fail (these can't be done in the constructor) - * must be done before the partner object is created -or- - * can be done after the partner object is created and which aren't - influenced by any device-level parameters the parent (the driver - in this case) might set. - - Arguments: - - FxDeviceInit - the settings for this device. - - Return Value: - - status. - ---*/ -{ - IWDFDevice *fxDevice = NULL; - - HRESULT hr = S_OK; - - // - // TODO: If you're writing a filter driver then indicate that here. - // - // FxDeviceInit->SetFilter(); - // - - // - // Set no locking unless you need an automatic callbacks synchronization - // - - FxDeviceInit->SetLockingConstraint(None); - - // - // TODO: Any per-device initialization which must be done before - // creating the partner object. - // - - - // - // Create a new FX device object and assign the new callback object to - // handle any device level events that occur. - // - - // - // QueryIUnknown references the IUnknown interface that it returns - // (which is the same as referencing the device). We pass that to - // CreateDevice, which takes its own reference if everything works. - // - - if (SUCCEEDED(hr)) - { - IUnknown *unknown = this->QueryIUnknown(); - - hr = FxDriver->CreateDevice(FxDeviceInit, unknown, &fxDevice); - - unknown->Release(); - } - - // - // If that succeeded then set our FxDevice member variable. - // - - if (SUCCEEDED(hr)) - { - m_FxDevice = fxDevice; - - // - // Drop the reference we got from CreateDevice. Since this object - // is partnered with the framework object they have the same - // lifespan - there is no need for an additional reference. - // - - fxDevice->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Configure( - VOID - ) -/*++ - - Routine Description: - - This method is called after the device callback object has been initialized - and returned to the driver. It would setup the device's queues and their - corresponding callback objects. - - Arguments: - - FxDevice - the framework device object for which we're handling events. - - Return Value: - - status - ---*/ -{ - HRESULT hr = S_OK; - - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_OSRUSBFX2, - NULL); - } - - return hr; -} - -HRESULT -CMyDevice::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method is called to get a pointer to one of the object's callback - interfaces. - - Since the skeleton driver doesn't support any of the device events, this - method simply calls the base class's BaseQueryInterface. - - If the skeleton is extended to include device event interfaces then this - method must be changed to check the IID and return pointers to them as - appropriate. - - Arguments: - - InterfaceId - the interface being requested - - Object - a location to store the interface pointer if successful - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - HRESULT hr; - - if (IsEqualIID(InterfaceId, __uuidof(IPnpCallbackHardware))) - { - *Object = QueryIPnpCallbackHardware(); - hr = S_OK; - } - else - { - hr = CUnknown::QueryInterface(InterfaceId, Object); - } - - return hr; -} - -HRESULT -CMyDevice::OnPrepareHardware( - _In_ IWDFDevice * /* FxDevice */ - ) -/*++ - -Routine Description: - - This routine is invoked to ready the driver - to talk to hardware. It opens the handle to the - device and talks to it using the WINUSB interface. - It invokes WINUSB to discver the interfaces and stores - the information related to bulk endpoints. - -Arguments: - - FxDevice : Pointer to the WDF device interface - -Return Value: - - HRESULT - ---*/ -{ - PWSTR deviceName = NULL; - DWORD deviceNameCch = 0; - - HRESULT hr; - - // - // Get the device name. - // Get the length to allocate first - // - - hr = m_FxDevice->RetrieveDeviceName(NULL, &deviceNameCch); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get device name %!hresult!", - hr - ); - } - - // - // Allocate the buffer - // - - if (SUCCEEDED(hr)) - { - deviceName = new WCHAR[deviceNameCch]; - - if (deviceName == NULL) - { - hr = E_OUTOFMEMORY; - } - } - - // - // Get the actual name - // - - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->RetrieveDeviceName(deviceName, &deviceNameCch); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get device name %!hresult!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_DEVICE, - "%!FUNC! Device name %S", - deviceName - ); - } - - // - // Create USB I/O Targets and configure them - // - - if (SUCCEEDED(hr)) - { - hr = CreateUsbIoTargets(); - } - - if (SUCCEEDED(hr)) - { - ULONG length = sizeof(m_Speed); - - hr = m_pIUsbTargetDevice->RetrieveDeviceInformation(DEVICE_SPEED, - &length, - &m_Speed); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get usb device speed information %!HRESULT!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_DEVICE, - "%!FUNC! Speed - %x\n", - m_Speed - ); - } - - delete[] deviceName; - - return hr; -} - -HRESULT -CMyDevice::OnReleaseHardware( - _In_ IWDFDevice * /* FxDevice */ - ) -/*++ - -Routine Description: - - This routine is invoked when the device is being removed or stopped - It releases all resources allocated for this device. - -Arguments: - - FxDevice - Pointer to the Device object. - -Return Value: - - HRESULT - Always succeeds. - ---*/ -{ - // - // Remove I/O target from object tree before any potential subsequent - // OnPrepareHardware creates a new one - // - - if (m_pIUsbTargetDevice) - { - m_pIUsbTargetDevice->DeleteWdfObject(); - } - - return S_OK; -} - -HRESULT -CMyDevice::CreateUsbIoTargets( - ) -/*++ - -Routine Description: - - This routine creates Usb device, interface and pipe objects - -Arguments: - - None - -Return Value: - - HRESULT ---*/ -{ - HRESULT hr; - IWDFUsbTargetFactory * pIUsbTargetFactory = NULL; - IWDFUsbTargetDevice * pIUsbTargetDevice = NULL; - - hr = m_FxDevice->QueryInterface(IID_PPV_ARGS(&pIUsbTargetFactory)); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get usb target factory %!HRESULT!", - hr - ); - } - - if (SUCCEEDED(hr)) - { - hr = pIUsbTargetFactory->CreateUsbTargetDevice( - &pIUsbTargetDevice); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Unable to create USB Device I/O Target %!HRESULT!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - m_pIUsbTargetDevice = pIUsbTargetDevice; - - // - // Release the creation reference as object tree will maintain a reference - // - - pIUsbTargetDevice->Release(); - } - - SAFE_RELEASE(pIUsbTargetFactory); - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step2/Device.h b/usb/wdf_osrfx2_lab/umdf/step2/Device.h deleted file mode 100644 index dadbfd5b5..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/Device.h +++ /dev/null @@ -1,180 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Device.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample - driver's device callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once -#include "internal.h" - -// -// Class for the iotrace driver. -// - -class CMyDevice : - public CUnknown, - public IPnpCallbackHardware -{ - -// -// Private data members. -// -private: - // - // Weak reference to framework device - // - IWDFDevice *m_FxDevice; - - // - // USB Device I/O Target - // - IWDFUsbTargetDevice * m_pIUsbTargetDevice; - - - // - // Device Speed (Low, Full, High) - // - UCHAR m_Speed; - -// -// Private methods. -// - -private: - - CMyDevice( - VOID - ) : - m_FxDevice(NULL), - m_pIUsbTargetDevice(NULL), - m_Speed(0) - { - } - - ~CMyDevice( - ); - - HRESULT - Initialize( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - // - // Helper methods - // - - HRESULT - CreateUsbIoTargets( - VOID - ); - - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit, - _Out_ PCMyDevice *Device - ); - - IWDFDevice * - GetFxDevice( - VOID - ) - { - return m_FxDevice; - } - - HRESULT - Configure( - VOID - ); - - IPnpCallbackHardware * - QueryIPnpCallbackHardware( - VOID - ) - { - AddRef(); - return static_cast(this); - } - -// -// COM methods -// -public: - - // - // IUnknown methods. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - // - // IPnpCallbackHardware - // - - virtual - HRESULT - STDMETHODCALLTYPE - OnPrepareHardware( - _In_ IWDFDevice *FxDevice - ); - - virtual - HRESULT - STDMETHODCALLTYPE - OnReleaseHardware( - _In_ IWDFDevice *FxDevice - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step2/Driver.cpp b/usb/wdf_osrfx2_lab/umdf/step2/Driver.cpp deleted file mode 100644 index bac5caca9..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/Driver.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Driver.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample's - core driver callback object. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "driver.tmh" - -HRESULT -CMyDriver::CreateInstance( - _Out_ PCMyDriver *Driver - ) -/*++ - - Routine Description: - - This static method is invoked in order to create and initialize a new - instance of the driver class. The caller should arrange for the object - to be released when it is no longer in use. - - Arguments: - - Driver - a location to store a referenced pointer to the new instance - - Return Value: - - S_OK if successful, or error otherwise. - ---*/ -{ - PCMyDriver driver; - HRESULT hr; - - // - // Allocate the callback object. - // - - driver = new CMyDriver(); - - if (NULL == driver) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the callback object. - // - - hr = driver->Initialize(); - - if (SUCCEEDED(hr)) - { - // - // Store a pointer to the new, initialized object in the output - // parameter. - // - - *Driver = driver; - } - else - { - - // - // Release the reference on the driver object to get it to delete - // itself. - // - - driver->Release(); - } - - return hr; -} - -HRESULT -CMyDriver::Initialize( - VOID - ) -/*++ - - Routine Description: - - This method is called to initialize a newly created driver callback object - before it is returned to the creator. Unlike the constructor, the - Initialize method contains operations which could potentially fail. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - return S_OK; -} - -HRESULT -CMyDriver::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Interface - ) -/*++ - - Routine Description: - - This method returns a pointer to the requested interface on the callback - object.. - - Arguments: - - InterfaceId - the IID of the interface to query/reference - - Interface - a location to store the interface pointer. - - Return Value: - - S_OK if the interface is supported. - E_NOINTERFACE if it is not supported. - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IDriverEntry))) - { - *Interface = QueryIDriverEntry(); - return S_OK; - } - else - { - return CUnknown::QueryInterface(InterfaceId, Interface); - } -} - -HRESULT -CMyDriver::OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ) -/*++ - - Routine Description: - - The FX invokes this method when it wants to install our driver on a device - stack. This method creates a device callback object, then calls the Fx - to create an Fx device object and associate the new callback object with - it. - - Arguments: - - FxWdfDriver - the Fx driver object. - - FxDeviceInit - the initialization information for the device. - - Return Value: - - status - ---*/ -{ - HRESULT hr; - - PCMyDevice device = NULL; - - // - // TODO: Do any per-device initialization (reading settings from the - // registry for example) that's necessary before creating your - // device callback object here. Otherwise you can leave such - // initialization to the initialization of the device event - // handler. - // - - // - // Create a new instance of our device callback object - // - - hr = CMyDevice::CreateInstance(FxWdfDriver, FxDeviceInit, &device); - - // - // TODO: Change any per-device settings that the object exposes before - // calling Configure to let it complete its initialization. - // - - // - // If that succeeded then call the device's construct method. This - // allows the device to create any queues or other structures that it - // needs now that the corresponding fx device object has been created. - // - - if (SUCCEEDED(hr)) - { - hr = device->Configure(); - } - - // - // Release the reference on the device callback object now that it's been - // associated with an fx device object. - // - - if (NULL != device) - { - device->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step2/Driver.h b/usb/wdf_osrfx2_lab/umdf/step2/Driver.h deleted file mode 100644 index 800ab1d9a..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/Driver.h +++ /dev/null @@ -1,149 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Driver.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample's - driver callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// This class handles driver events for the skeleton sample. In particular -// it supports the OnDeviceAdd event, which occurs when the driver is called -// to setup per-device handlers for a new device stack. -// - -class CMyDriver : public CUnknown, public IDriverEntry -{ -// -// Private data members. -// -private: - -// -// Private methods. -// -private: - - // - // Returns a refernced pointer to the IDriverEntry interface. - // - - IDriverEntry * - QueryIDriverEntry( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - HRESULT - Initialize( - VOID - ); - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _Out_ PCMyDriver *Driver - ); - -// -// COM methods -// -public: - - // - // IDriverEntry methods - // - - virtual - HRESULT - STDMETHODCALLTYPE - OnInitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return S_OK; - } - - virtual - HRESULT - STDMETHODCALLTYPE - OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - virtual - VOID - STDMETHODCALLTYPE - OnDeinitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return; - } - - // - // IUnknown methods. - // - // We have to implement basic ones here that redirect to the - // base class becuase of the multiple inheritance. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.ctl b/usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.ctl deleted file mode 100644 index 4dab56ae3..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.ctl +++ /dev/null @@ -1 +0,0 @@ -da5fbdfd-1eae-4ecf-b426-a3818f325ddb WudfOsrUsbFx2TraceGuid diff --git a/usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.rc b/usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.rc deleted file mode 100644 index 36f10ea90..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/OsrUsbFx2.rc +++ /dev/null @@ -1,21 +0,0 @@ -//--------------------------------------------------------------------------- -// OsrUsbDevice.rc -// -// Copyright (c) Microsoft Corporation, All Rights Reserved -//--------------------------------------------------------------------------- - - -#include -#include - -// -// TODO: Change the file description and file names to match your binary. -// - -#define VER_FILETYPE VFT_DLL -#define VER_FILESUBTYPE VFT_UNKNOWN -#define VER_FILEDESCRIPTION_STR "WDF:UMDF OSR USB Fx2 User-Mode Driver Sample" -#define VER_INTERNALNAME_STR "WUDFOsrUsbFx2" -#define VER_ORIGINALFILENAME_STR "WUDFOsrUsbFx2.dll" - -#include "common.ver" diff --git a/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx b/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.inx deleted file mode 100644 index 98d8c4539d30b81d3747fb338bb80e323ff5c3e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5920 zcmb`L+fG|Y6o%)zQr}?V1%6mYV+!Czkim; zGqde&j1+C{^UON@>p1h@zfauH?kD%e74Droac#Hnj@-!I@H}#7ynS;UuFF|>m+s14 zFs{aV!1KtBUC({wD0uqQ4Y(hY@J zd+WcB_&jqCO+P!liJB?wGGDeohOidVC!*w!_mW zcg>eU>EAQxT|%Mh{&tVtj@xzXuH`n}7WW$0ZJrAhi!y>DmOB&+xxs{5gNeeyrjAiuWu2UT{C3;(9YdeAQL`k1`8a@stI6$lgaX zv%oGM&~neQMYL;qY<*^|*?KkezBXD2!*lK_=hQ>HC0|^ddf$7zN%(g`OST-ihuFZr zJmyP};~}1L=|?oYv_G2v0d^JtZTLO%{O!v+-x^ppA{0F~kF8Bc88*A<(g)iCHqN~| z&h1YAU*h>=ta6KQYF6ZvM#J6njPrB%0=jFHV-@R$=!#YmhdAy4n<;`dXT?WQV-lGf zcZ%-}eJsneZ7eWye{lxS9ZfX8DX0XP-Aj%=w0i5W9sV5g?*XxrQ(Yu)&_2k!j_)-&6+Z*$Tq1>hcmx{CdDqBfnayHe zw3T_AOC8Fprit=w%+ZDC5#nT7YKwVFGSfWeRE{-^V)Ky}7QM#bq79o9d1JN@V?#h?q(9+k6Q=%Z>G6C#Ea#o{GV{QKI9D;sM>w=xl;MEL8PlZa1!>F8OmRXwfAQ1y3_ zL^+QmaSn>ula>QWNKM>iR!%Fu}d+!!~fx3YdZ65c zo`TWU1fjrl6$%^l5$}lutNHJzId2{^TAx|pV(TAib((bv-KPW=@J{X9T`KM-{PB_j=6tJqQ{kD5%+1b|6 zX-~UFJ<%bbRL0aQ^)>l1WKOM9y72D!e5nk2NH%@NJ>aQXi&t~uZ$b7QfVuLDc2$<0 z7v|5u2RXE=S00m9KTNxos$DPb;T@xEo3rM-#WDBtX!GB@cBAIgs+tvOE?%LFX1Z6R zRd%#}c?UFlae-|DW#crvTQZM!TuIoh5PQ{?NK~xm#y!wn#(iQzYfsw^v30QR->MqO z3(|er@?3Ros*PWva>M?NRnsy|L?NGBqb(N$sUKgPnR#@eIWa|J6 tdIfb@H|S(uR - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {808B6774-93FA-4ABF-A23F-35C55FA80B80} - $(MSBuildProjectName) - 1 - 1 - Debug - Win32 - {A944547C-61E9-47C5-82EC-797D95019735} - - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - - $(IntDir) - - - - - - - - - - - - - - - - true - true - internal.h - - - true - true - internal.h - - - - WUDFOsrUsbFx2_2 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_2 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_2 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_2 - 0x0A00 - 0x0A000000 - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj.Filters b/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj.Filters deleted file mode 100644 index 228729fe9..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/WUDFOsrUsbFx2_2.vcxproj.Filters +++ /dev/null @@ -1,43 +0,0 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {CAFDA06D-52D2-4C5B-B355-1D19E80B1C72} - - - h;hpp;hxx;hm;inl;inc;xsd - {2C5F0467-9539-41AD-95E0-0BD835F2F9EE} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {310FFCBB-E46B-43FA-B790-61A981127DBF} - - - inf;inv;inx;mof;mc; - {04E87A31-118A-4F72-8349-D26123A6EE71} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/step2/comsup.cpp b/usb/wdf_osrfx2_lab/umdf/step2/comsup.cpp deleted file mode 100644 index 9c9aec3b5..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/comsup.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.cpp - -Abstract: - - This module contains implementations for the functions and methods - used for providing COM support. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" - -#include "comsup.tmh" - -// -// Implementation of CUnknown methods. -// - -CUnknown::CUnknown( - VOID - ) : m_ReferenceCount(1) -/*++ - - Routine Description: - - Constructor for an instance of the CUnknown class. This simply initializes - the reference count of the object to 1. The caller is expected to - call Release() if it wants to delete the object once it has been allocated. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - // do nothing. -} - -HRESULT -STDMETHODCALLTYPE -CUnknown::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method provides the basic support for query interface on CUnknown. - If the interface requested is IUnknown it references the object and - returns an interface pointer. Otherwise it returns an error. - - Arguments: - - InterfaceId - the IID being requested - - Object - a location to store the interface pointer to return. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IUnknown))) - { - *Object = QueryIUnknown(); - return S_OK; - } - else - { - *Object = NULL; - return E_NOINTERFACE; - } -} - -IUnknown * -CUnknown::QueryIUnknown( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IUnknown interface. - - This allows other methods to convert a CUnknown pointer into an IUnknown - pointer without a typecast and without calling QueryInterface and dealing - with the return value. - - Arguments: - - None - - Return Value: - - A pointer to the object's IUnknown interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::AddRef( - VOID - ) -/*++ - - Routine Description: - - This method adds one to the object's reference count. - - Arguments: - - None - - Return Value: - - The new reference count. The caller should only use this for debugging - as the object's actual reference count can change while the caller - examines the return value. - ---*/ -{ - return InterlockedIncrement(&m_ReferenceCount); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::Release( - VOID - ) -/*++ - - Routine Description: - - This method subtracts one to the object's reference count. If the count - goes to zero, this method deletes the object. - - Arguments: - - None - - Return Value: - - The new reference count. If the caller uses this value it should only be - to check for zero (i.e. this call caused or will cause deletion) or - non-zero (i.e. some other call may have caused deletion, but this one - didn't). - ---*/ -{ - ULONG count = InterlockedDecrement(&m_ReferenceCount); - - if (count == 0) - { - delete this; - } - return count; -} - -// -// Implementation of CClassFactory methods. -// - -// -// Define storage for the factory's static lock count variable. -// - -LONG CClassFactory::s_LockCount = 0; - -IClassFactory * -CClassFactory::QueryIClassFactory( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IClassFactory interface. - - This allows other methods to convert a CClassFactory pointer into an - IClassFactory pointer without a typecast and without dealing with the - return value QueryInterface. - - Arguments: - - None - - Return Value: - - A referenced pointer to the object's IClassFactory interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -HRESULT -CClassFactory::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method attempts to retrieve the requested interface from the object. - - If the interface is found then the reference count on that interface (and - thus the object itself) is incremented. - - Arguments: - - InterfaceId - the interface the caller is requesting. - - Object - a location to store the interface pointer. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - // - // This class only supports IClassFactory so check for that. - // - - if (IsEqualIID(InterfaceId, __uuidof(IClassFactory))) - { - *Object = QueryIClassFactory(); - return S_OK; - } - else - { - // - // See if the base class supports the interface. - // - - return CUnknown::QueryInterface(InterfaceId, Object); - } -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::CreateInstance( - _In_opt_ IUnknown * /* OuterObject */, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ) -/*++ - - Routine Description: - - This COM method is the factory routine - it creates instances of the driver - callback class and returns the specified interface on them. - - Arguments: - - OuterObject - only used for aggregation, which our driver callback class - does not support. - - InterfaceId - the interface ID the caller would like to get from our - new object. - - Object - a location to store the referenced interface pointer to the new - object. - - Return Value: - - Status. - ---*/ -{ - HRESULT hr; - - PCMyDriver driver; - - *Object = NULL; - - hr = CMyDriver::CreateInstance(&driver); - - if (SUCCEEDED(hr)) - { - hr = driver->QueryInterface(InterfaceId, Object); - driver->Release(); - } - - return hr; -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::LockServer( - _In_ BOOL Lock - ) -/*++ - - Routine Description: - - This COM method can be used to keep the DLL in memory. However since the - driver's DllCanUnloadNow function always returns false, this has little - effect. Still it tracks the number of lock and unlock operations. - - Arguments: - - Lock - Whether the caller wants to lock or unlock the "server" - - Return Value: - - S_OK - ---*/ -{ - if (Lock) - { - InterlockedIncrement(&s_LockCount); - } - else - { - InterlockedDecrement(&s_LockCount); - } - return S_OK; -} - diff --git a/usb/wdf_osrfx2_lab/umdf/step2/comsup.h b/usb/wdf_osrfx2_lab/umdf/step2/comsup.h deleted file mode 100644 index dedf78c84..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/comsup.h +++ /dev/null @@ -1,215 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.h - -Abstract: - - This module contains classes and functions use for providing COM support - code. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Forward type declarations. They are here rather than in internal.h as -// you only need them if you choose to use these support classes. -// - -typedef class CUnknown *PCUnknown; -typedef class CClassFactory *PCClassFactory; - -// -// Base class to implement IUnknown. You can choose to derive your COM -// classes from this class, or simply implement IUnknown in each of your -// classes. -// - -class CUnknown : public IUnknown -{ - -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The reference count for this object. Initialized to 1 in the - // constructor. - // - - LONG m_ReferenceCount; - -// -// Protected data members and methods. These are accessible by the subclasses -// but not by other classes. -// -protected: - - // - // The constructor and destructor are protected to ensure that only the - // subclasses of CUnknown can create and destroy instances. - // - - CUnknown( - VOID - ); - - // - // The destructor MUST be virtual. Since any instance of a CUnknown - // derived class should only be deleted from within CUnknown::Release, - // the destructor MUST be virtual or only CUnknown::~CUnknown will get - // invoked on deletion. - // - // If you see that your CMyDevice specific destructor is never being - // called, make sure you haven't deleted the virtual destructor here. - // - - virtual - ~CUnknown( - VOID - ) - { - // Do nothing - } - -// -// Public Methods. These are accessible by any class. -// -public: - - IUnknown * - QueryIUnknown( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ); - - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ); - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; - -// -// Class factory support class. Create an instance of this from your -// DllGetClassObject method and modify the implementation to create -// an instance of your driver event handler class. -// - -class CClassFactory : public CUnknown, public IClassFactory -{ -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The lock count. This is shared across all instances of IClassFactory - // and can be queried through the public IsLocked method. - // - - static LONG s_LockCount; - -// -// Public Methods. These are accessible by any class. -// -public: - - IClassFactory * - QueryIClassFactory( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - // - // IClassFactory methods. - // - - virtual - HRESULT - STDMETHODCALLTYPE - CreateInstance( - _In_opt_ IUnknown *OuterObject, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ); - - virtual - HRESULT - STDMETHODCALLTYPE - LockServer( - _In_ BOOL Lock - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step2/dllsup.cpp b/usb/wdf_osrfx2_lab/umdf/step2/dllsup.cpp deleted file mode 100644 index bd681ac22..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/dllsup.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - dllsup.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample - Driver's entry point and its exported functions for providing COM support. - - This module can be copied without modification to a new UMDF driver. It - depends on some of the code in comsup.cpp & comsup.h to handle DLL - registration and creating the first class factory. - - This module is dependent on the following defines: - - MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing - tracing. For example the skeleton uses - L"Microsoft\\UMDF\\Skeleton" - - MYDRIVER_CLASS_ID - A GUID encoded in struct format used to - initialize the driver's ClassID. - - These are defined in internal.h for the skeleton sample. If you choose - to use a different primary include file, you should ensure they are - defined there as well. - -Environment: - - WDF User-Mode Driver Framework (WDF:UMDF) - ---*/ - -#include "internal.h" -#include "dllsup.tmh" - -const GUID CLSID_MyDriverCoClass = MYDRIVER_CLASS_ID; - -BOOL -WINAPI -DllMain( - HINSTANCE ModuleHandle, - DWORD Reason, - PVOID /* Reserved */ - ) -/*++ - - Routine Description: - - This is the entry point and exit point for the I/O trace driver. This - does very little as the I/O trace driver has minimal global data. - - This method initializes tracing, and saves the module handle away in a - global variable so that it can be referenced should the COM registration - code (Dll[Un]RegisterServer) be called. - - Arguments: - - ModuleHandle - the DLL handle for this module. - - Reason - the reason this entry point was called. - - Reserved - unused - - Return Value: - - TRUE - ---*/ -{ - UNREFERENCED_PARAMETER(ModuleHandle); - - if (DLL_PROCESS_ATTACH == Reason) - { - // - // Initialize tracing. - // - - WPP_INIT_TRACING(MYDRIVER_TRACING_ID); - } - else if (DLL_PROCESS_DETACH == Reason) - { - // - // Cleanup tracing. - // - - WPP_CLEANUP(); - } - - return TRUE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllCanUnloadNow( - VOID - ) -/*++ - - Routine Description: - - Called by the COM runtime when determining whether or not this module - can be unloaded. Our answer is always "no". - - Arguments: - - None - - Return Value: - - S_FALSE - ---*/ -{ - return S_FALSE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllGetClassObject( - REFCLSID ClassId, - REFIID InterfaceId, - LPVOID *Interface - ) -/*++ - - Routine Description: - - This routine is called by COM in order to instantiate the - skeleton driver callback object and do an initial query interface on it. - - This method only creates an instance of the driver's class factory, as this - is the minimum required to support UMDF. - - Arguments: - - ClassId - the CLSID of the object being "gotten" - - InterfaceId - the interface the caller wants from that object. - - Interface - a location to store the referenced interface pointer - - Return Value: - - S_OK if the function succeeds or error indicating the cause of the - failure. - ---*/ -{ - PCClassFactory factory; - - HRESULT hr = S_OK; - - *Interface = NULL; - - // - // If the CLSID doesn't match that of our "coclass" (defined in the IDL - // file) then we can't create the object the caller wants. This may - // indicate that the COM registration is incorrect, and another CLSID - // is referencing this drvier. - // - - if (IsEqualCLSID(ClassId, CLSID_MyDriverCoClass) == false) - { - Trace( - TRACE_LEVEL_ERROR, - L"ERROR: Called to create instance of unrecognized class (%!GUID!)", - &ClassId - ); - - return CLASS_E_CLASSNOTAVAILABLE; - } - - // - // Create an instance of the class factory for the caller. - // - - factory = new CClassFactory(); - - if (NULL == factory) - { - hr = E_OUTOFMEMORY; - } - - // - // Query the object we created for the interface the caller wants. After - // that we release the object. This will drive the reference count to - // 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed). - // In the later case the object is automatically deleted. - // - - if (SUCCEEDED(hr)) - { - hr = factory->QueryInterface(InterfaceId, Interface); - factory->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step2/exports.def b/usb/wdf_osrfx2_lab/umdf/step2/exports.def deleted file mode 100644 index 15f923d3b..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/exports.def +++ /dev/null @@ -1,4 +0,0 @@ -; WudfOsrUsbDriver.def : Declares the module parameters. - -EXPORTS - DllGetClassObject PRIVATE diff --git a/usb/wdf_osrfx2_lab/umdf/step2/internal.h b/usb/wdf_osrfx2_lab/umdf/step2/internal.h deleted file mode 100644 index 374931e05..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step2/internal.h +++ /dev/null @@ -1,150 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Internal.h - -Abstract: - - This module contains the local type definitions for the UMDF Skeleton - driver sample. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -// -// Include the WUDF Headers -// - -#include "wudfddi.h" - -// -// Use specstrings for in/out annotation of function parameters. -// - -#include "specstrings.h" - -// -// Get limits on common data types (ULONG_MAX for example) -// - -#include "limits.h" - -// -// We need usb I/O targets to talk to the OSR device. -// - -#include "wudfusb.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "public.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "WUDFOsrUsbPublic.h" - -// -// Forward definitions of classes in the other header files. -// - -typedef class CMyDriver *PCMyDriver; -typedef class CMyDevice *PCMyDevice; -typedef class CMyQueue *PCMyQueue; - -typedef class CMyControlQueue *PCMyControlQueue; - -// -// Define the tracing flags. -// -// TODO: Choose a different trace control GUID -// - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - WudfOsrUsbFx2TraceGuid, (da5fbdfd,1eae,4ecf,b426,a3818f325ddb), \ - \ - WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \ - WPP_DEFINE_BIT(TEST_TRACE_DRIVER) \ - WPP_DEFINE_BIT(TEST_TRACE_DEVICE) \ - WPP_DEFINE_BIT(TEST_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) - -// -// This comment block is scanned by the trace preprocessor to define our -// Trace function. -// -// begin_wpp config -// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); -// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); -// end_wpp -// - -// -// Driver specific #defines -// -// TODO: Change these values to be appropriate for your driver. -// - -#define MYDRIVER_TRACING_ID L"Microsoft\\UMDF\\OsrUsb" -#define MYDRIVER_CLASS_ID {0x0865b2b0, 0x6b73, 0x428f, {0xa3, 0xea, 0x21, 0x72, 0x83, 0x2d, 0x6b, 0xfc}} - -// -// Include the type specific headers. -// - -#include "comsup.h" -#include "driver.h" -#include "device.h" -#include "list.h" - -__forceinline -#ifdef _PREFAST_ -__declspec(noreturn) -#endif -VOID -WdfTestNoReturn( - VOID - ) -{ - // do nothing. -} - -#define WUDF_TEST_DRIVER_ASSERT(p) \ -{ \ - if ( !(p) ) \ - { \ - DebugBreak(); \ - WdfTestNoReturn(); \ - } \ -} - -#define SAFE_RELEASE(p) {if ((p)) { (p)->Release(); (p) = NULL; }} diff --git a/usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.cpp b/usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.cpp deleted file mode 100644 index 48de237d2..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - ControlQueue.cpp - -Abstract: - - This file implements the I/O queue interface and performs - the ioctl operations. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" - -#include "winioctl.h" - -#include "ControlQueue.tmh" - -CMyControlQueue::CMyControlQueue( - _In_ PCMyDevice Device - ) : CMyQueue(Device) -{ - -} - -HRESULT -STDMETHODCALLTYPE -CMyControlQueue::QueryInterface( - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ) -/*++ - -Routine Description: - - - Query Interface - -Aruments: - - Follows COM specifications - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - HRESULT hr; - - - if (IsEqualIID(InterfaceId, __uuidof(IQueueCallbackDeviceIoControl))) - { - hr = S_OK; - *Object = QueryIQueueCallbackDeviceIoControl(); - - } - else - { - hr = CMyQueue::QueryInterface(InterfaceId, Object); - } - - return hr; -} - -// -// Initialize -// - -HRESULT -CMyControlQueue::CreateInstance( - _In_ PCMyDevice Device, - _Out_ PCMyControlQueue *Queue - ) -/*++ - -Routine Description: - - - CreateInstance creates an instance of the queue object. - -Aruments: - - ppUkwn - OUT parameter is an IUnknown interface to the queue object - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - PCMyControlQueue queue = NULL; - HRESULT hr = S_OK; - - queue = new CMyControlQueue(Device); - - if (NULL == queue) - { - hr = E_OUTOFMEMORY; - } - - // - // Call the queue callback object to initialize itself. This will create - // its partner queue framework object. - // - - if (SUCCEEDED(hr)) - { - hr = queue->Initialize(); - } - - if (SUCCEEDED(hr)) - { - *Queue = queue; - } - else - { - SAFE_RELEASE(queue); - } - - return hr; -} - -HRESULT -CMyControlQueue::Initialize( - VOID - ) -{ - HRESULT hr; - - // - // First initialize the base class. This will create the partner FxIoQueue - // object and setup automatic forwarding of I/O controls. - // - - hr = __super::Initialize(WdfIoQueueDispatchSequential, - false, - true); - - // - // return the status. - // - - return hr; -} - -VOID -STDMETHODCALLTYPE -CMyControlQueue::OnDeviceIoControl( - _In_ IWDFIoQueue *FxQueue, - _In_ IWDFIoRequest *FxRequest, - _In_ ULONG ControlCode, - _In_ SIZE_T InputBufferSizeInBytes, - _In_ SIZE_T OutputBufferSizeInBytes - ) -/*++ - -Routine Description: - - - DeviceIoControl dispatch routine - -Aruments: - - FxQueue - Framework Queue instance - FxRequest - Framework Request instance - ControlCode - IO Control Code - InputBufferSizeInBytes - Lenth of input buffer - OutputBufferSizeInBytes - Lenth of output buffer - - Always succeeds DeviceIoIoctl -Return Value: - - VOID - ---*/ -{ - UNREFERENCED_PARAMETER(FxQueue); - UNREFERENCED_PARAMETER(OutputBufferSizeInBytes); - - IWDFMemory *memory = NULL; - PVOID buffer; - - SIZE_T bigBufferCb; - - ULONG information = 0; - - bool completeRequest = true; - - HRESULT hr = S_OK; - - switch (ControlCode) - { - case IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY: - { - // - // Make sure the buffer is big enough to hold the input for the - // control transfer. - // - - if (InputBufferSizeInBytes < sizeof(BAR_GRAPH_STATE)) - { - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - else - { - FxRequest->GetInputMemory(&memory); - } - - // - // Get the data buffer and use it to set the bar graph on the - // device. - // - - if (SUCCEEDED(hr)) - { - buffer = memory->GetDataBuffer(&bigBufferCb); - memory->Release(); - - hr = m_Device->SetBarGraphDisplay((PBAR_GRAPH_STATE) buffer); - } - - break; - } - - default: - { - hr = HRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION); - break; - } - } - - if (completeRequest) - { - FxRequest->CompleteWithInformation(hr, information); - } - - return; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.h b/usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.h deleted file mode 100644 index 251521e1b..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/ControlQueue.h +++ /dev/null @@ -1,101 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - ControlQueue.h - -Abstract: - - This file defines the queue callback object for handling device I/O - control requests. This is a serialized queue. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Queue Callback Object. -// - -class CMyControlQueue : public IQueueCallbackDeviceIoControl, - public CMyQueue -{ - HRESULT - Initialize( - VOID - ); - -public: - - CMyControlQueue( - _In_ PCMyDevice Device - ); - - virtual - ~CMyControlQueue( - VOID - ) - { - return; - } - - static - HRESULT - CreateInstance( - _In_ PCMyDevice Device, - _Out_ PCMyControlQueue *Queue - ); - - HRESULT - Configure( - VOID - ) - { - return S_OK; - } - - IQueueCallbackDeviceIoControl * - QueryIQueueCallbackDeviceIoControl( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - // - // IUnknown - // - - STDMETHOD_(ULONG,AddRef) (VOID) {return CUnknown::AddRef();} - - _At_(this, __drv_freesMem(object)) - STDMETHOD_(ULONG,Release) (VOID) {return CUnknown::Release();} - - STDMETHOD_(HRESULT, QueryInterface)( - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ); - - // - // Wdf Callbacks - // - - // - // IQueueCallbackDeviceIoControl - // - STDMETHOD_ (void, OnDeviceIoControl)( - _In_ IWDFIoQueue *pWdfQueue, - _In_ IWDFIoRequest *pWdfRequest, - _In_ ULONG ControlCode, - _In_ SIZE_T InputBufferSizeInBytes, - _In_ SIZE_T OutputBufferSizeInBytes - ); -}; - diff --git a/usb/wdf_osrfx2_lab/umdf/step3/Device.cpp b/usb/wdf_osrfx2_lab/umdf/step3/Device.cpp deleted file mode 100644 index 20c997c5d..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/Device.cpp +++ /dev/null @@ -1,644 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Device.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton sample driver's - device callback object. - - The skeleton sample device does very little. It does not implement either - of the PNP interfaces so once the device is setup, it won't ever get any - callbacks until the device is removed. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "initguid.h" -#include "usb_hw.h" - -#include "device.tmh" - -CMyDevice::~CMyDevice( - ) -{ -} - -HRESULT -CMyDevice::CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit, - _Out_ PCMyDevice *Device - ) -/*++ - - Routine Description: - - This method creates and initializs an instance of the skeleton driver's - device callback object. - - Arguments: - - FxDeviceInit - the settings for the device. - - Device - a location to store the referenced pointer to the device object. - - Return Value: - - Status - ---*/ -{ - PCMyDevice device; - HRESULT hr; - - // - // Allocate a new instance of the device class. - // - - device = new CMyDevice(); - - if (NULL == device) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the instance. - // - - hr = device->Initialize(FxDriver, FxDeviceInit); - - if (SUCCEEDED(hr)) - { - *Device = device; - } - else - { - device->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Initialize( - _In_ IWDFDriver * FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit - ) -/*++ - - Routine Description: - - This method initializes the device callback object and creates the - partner device object. - - The method should perform any device-specific configuration that: - * could fail (these can't be done in the constructor) - * must be done before the partner object is created -or- - * can be done after the partner object is created and which aren't - influenced by any device-level parameters the parent (the driver - in this case) might set. - - Arguments: - - FxDeviceInit - the settings for this device. - - Return Value: - - status. - ---*/ -{ - IWDFDevice *fxDevice = NULL; - - HRESULT hr = S_OK; - - // - // TODO: If you're writing a filter driver then indicate that here. - // - // FxDeviceInit->SetFilter(); - // - - // - // Set no locking unless you need an automatic callbacks synchronization - // - - FxDeviceInit->SetLockingConstraint(None); - - // - // TODO: Any per-device initialization which must be done before - // creating the partner object. - // - - // - // Create a new FX device object and assign the new callback object to - // handle any device level events that occur. - // - - // - // QueryIUnknown references the IUnknown interface that it returns - // (which is the same as referencing the device). We pass that to - // CreateDevice, which takes its own reference if everything works. - // - - if (SUCCEEDED(hr)) - { - IUnknown *unknown = this->QueryIUnknown(); - - hr = FxDriver->CreateDevice(FxDeviceInit, unknown, &fxDevice); - - unknown->Release(); - } - - // - // If that succeeded then set our FxDevice member variable. - // - - if (SUCCEEDED(hr)) - { - m_FxDevice = fxDevice; - - // - // Drop the reference we got from CreateDevice. Since this object - // is partnered with the framework object they have the same - // lifespan - there is no need for an additional reference. - // - - fxDevice->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Configure( - VOID - ) -/*++ - - Routine Description: - - This method is called after the device callback object has been initialized - and returned to the driver. It would setup the device's queues and their - corresponding callback objects. - - Arguments: - - FxDevice - the framework device object for which we're handling events. - - Return Value: - - status - ---*/ -{ - HRESULT hr = S_OK; - - - // - // Create the control queue and configure forwarding for IOCTL requests. - // - - if (SUCCEEDED(hr)) - { - hr = CMyControlQueue::CreateInstance(this, &m_ControlQueue); - - if (SUCCEEDED(hr)) - { - hr = m_ControlQueue->Configure(); - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->ConfigureRequestDispatching( - m_ControlQueue->GetFxQueue(), - WdfRequestDeviceIoControl, - true - ); - } - m_ControlQueue->Release(); - } - } - - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_OSRUSBFX2, - NULL); - } - - return hr; -} - -HRESULT -CMyDevice::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method is called to get a pointer to one of the object's callback - interfaces. - - Since the skeleton driver doesn't support any of the device events, this - method simply calls the base class's BaseQueryInterface. - - If the skeleton is extended to include device event interfaces then this - method must be changed to check the IID and return pointers to them as - appropriate. - - Arguments: - - InterfaceId - the interface being requested - - Object - a location to store the interface pointer if successful - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - HRESULT hr; - - if (IsEqualIID(InterfaceId, __uuidof(IPnpCallbackHardware))) - { - *Object = QueryIPnpCallbackHardware(); - hr = S_OK; - } - else - { - hr = CUnknown::QueryInterface(InterfaceId, Object); - } - - return hr; -} - -HRESULT -CMyDevice::OnPrepareHardware( - _In_ IWDFDevice * /* FxDevice */ - ) -/*++ - -Routine Description: - - This routine is invoked to ready the driver - to talk to hardware. It opens the handle to the - device and talks to it using the WINUSB interface. - It invokes WINUSB to discver the interfaces and stores - the information related to bulk endpoints. - -Arguments: - - FxDevice : Pointer to the WDF device interface - -Return Value: - - HRESULT - ---*/ -{ - PWSTR deviceName = NULL; - DWORD deviceNameCch = 0; - - HRESULT hr; - - // - // Get the device name. - // Get the length to allocate first - // - - hr = m_FxDevice->RetrieveDeviceName(NULL, &deviceNameCch); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get device name %!hresult!", - hr - ); - } - - // - // Allocate the buffer - // - - if (SUCCEEDED(hr)) - { - deviceName = new WCHAR[deviceNameCch]; - - if (deviceName == NULL) - { - hr = E_OUTOFMEMORY; - } - } - - // - // Get the actual name - // - - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->RetrieveDeviceName(deviceName, &deviceNameCch); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get device name %!hresult!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_DEVICE, - "%!FUNC! Device name %S", - deviceName - ); - } - - // - // Create USB I/O Targets and configure them - // - - if (SUCCEEDED(hr)) - { - hr = CreateUsbIoTargets(); - } - - if (SUCCEEDED(hr)) - { - ULONG length = sizeof(m_Speed); - - hr = m_pIUsbTargetDevice->RetrieveDeviceInformation(DEVICE_SPEED, - &length, - &m_Speed); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get usb device speed information %!HRESULT!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_DEVICE, - "%!FUNC! Speed - %x\n", - m_Speed - ); - } - - delete[] deviceName; - - return hr; -} - -HRESULT -CMyDevice::OnReleaseHardware( - _In_ IWDFDevice * /* FxDevice */ - ) -/*++ - -Routine Description: - - This routine is invoked when the device is being removed or stopped - It releases all resources allocated for this device. - -Arguments: - - FxDevice - Pointer to the Device object. - -Return Value: - - HRESULT - Always succeeds. - ---*/ -{ - // - // Remove I/O target from object tree before any potential subsequent - // OnPrepareHardware creates a new one - // - - if (m_pIUsbTargetDevice) - { - m_pIUsbTargetDevice->DeleteWdfObject(); - } - - return S_OK; -} - -HRESULT -CMyDevice::CreateUsbIoTargets( - ) -/*++ - -Routine Description: - - This routine creates Usb device, interface and pipe objects - -Arguments: - - None - -Return Value: - - HRESULT ---*/ -{ - HRESULT hr; - IWDFUsbTargetFactory * pIUsbTargetFactory = NULL; - IWDFUsbTargetDevice * pIUsbTargetDevice = NULL; - - hr = m_FxDevice->QueryInterface(IID_PPV_ARGS(&pIUsbTargetFactory)); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get usb target factory %!HRESULT!", - hr - ); - } - - if (SUCCEEDED(hr)) - { - hr = pIUsbTargetFactory->CreateUsbTargetDevice( - &pIUsbTargetDevice); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Unable to create USB Device I/O Target %!HRESULT!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - m_pIUsbTargetDevice = pIUsbTargetDevice; - - // - // Release the creation reference as object tree will maintain a reference - // - - pIUsbTargetDevice->Release(); - } - - SAFE_RELEASE(pIUsbTargetFactory); - - return hr; -} - -HRESULT -CMyDevice::SetBarGraphDisplay( - _In_ PBAR_GRAPH_STATE BarGraphState - ) -/*++ - - Routine Description: - - This method synchronously sets the bar graph display on the OSR USB-FX2 - device using the buffers in the FxRequest as input. - - Arguments: - - FxRequest - the request to set the bar-graph info. - - Return Value: - - Status - ---*/ -{ - WINUSB_CONTROL_SETUP_PACKET setupPacket; - - ULONG bytesTransferred; - - HRESULT hr = S_OK; - - // - // Setup the control packet. - // - - WINUSB_CONTROL_SETUP_PACKET_INIT( &setupPacket, - BmRequestHostToDevice, - BmRequestToDevice, - USBFX2LK_SET_BARGRAPH_DISPLAY, - 0, - 0 ); - - // - // Issue the request to WinUsb. - // - - hr = SendControlTransferSynchronously( - &(setupPacket.WinUsb), - (PUCHAR) BarGraphState, - sizeof(BAR_GRAPH_STATE), - &bytesTransferred - ); - - - return hr; -} - -HRESULT -CMyDevice::SendControlTransferSynchronously( - _In_ PWINUSB_SETUP_PACKET SetupPacket, - _Inout_updates_(BufferLength) PBYTE Buffer, - _In_ ULONG BufferLength, - _Out_ PULONG LengthTransferred - ) -{ - HRESULT hr = S_OK; - HRESULT hrRequest = S_OK; - IWDFIoRequest *pWdfRequest = NULL; - IWDFDriver * FxDriver = NULL; - IWDFMemory * FxMemory = NULL; - IWDFRequestCompletionParams * FxComplParams = NULL; - IWDFUsbRequestCompletionParams * FxUsbComplParams = NULL; - - *LengthTransferred = 0; - - hr = m_FxDevice->CreateRequest( NULL, //pCallbackInterface - NULL, //pParentObject - &pWdfRequest); - hrRequest = hr; - - if (SUCCEEDED(hr)) - { - m_FxDevice->GetDriver(&FxDriver); - - hr = FxDriver->CreatePreallocatedWdfMemory( Buffer, - BufferLength, - NULL, //pCallbackInterface - pWdfRequest, //pParetObject - &FxMemory ); - } - - if (SUCCEEDED(hr)) - { - hr = m_pIUsbTargetDevice->FormatRequestForControlTransfer( pWdfRequest, - SetupPacket, - FxMemory, - NULL); //TransferOffset - } - - if (SUCCEEDED(hr)) - { - hr = pWdfRequest->Send( m_pIUsbTargetDevice, - WDF_REQUEST_SEND_OPTION_SYNCHRONOUS, - 0); //Timeout - } - - if (SUCCEEDED(hr)) - { - pWdfRequest->GetCompletionParams(&FxComplParams); - - hr = FxComplParams->GetCompletionStatus(); - } - - if (SUCCEEDED(hr)) - { - HRESULT hrQI = FxComplParams->QueryInterface(IID_PPV_ARGS(&FxUsbComplParams)); - WUDF_TEST_DRIVER_ASSERT(SUCCEEDED(hrQI)); - - WUDF_TEST_DRIVER_ASSERT( WdfUsbRequestTypeDeviceControlTransfer == - FxUsbComplParams->GetCompletedUsbRequestType() ); - - FxUsbComplParams->GetDeviceControlTransferParameters( NULL, - LengthTransferred, - NULL, - NULL ); - } - - SAFE_RELEASE(FxUsbComplParams); - SAFE_RELEASE(FxComplParams); - SAFE_RELEASE(FxMemory); - - if (SUCCEEDED(hrRequest)) - { - pWdfRequest->DeleteWdfObject(); - } - SAFE_RELEASE(pWdfRequest); - - SAFE_RELEASE(FxDriver); - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step3/Device.h b/usb/wdf_osrfx2_lab/umdf/step3/Device.h deleted file mode 100644 index 6d3435827..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/Device.h +++ /dev/null @@ -1,203 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Device.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample - driver's device callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once -#include "internal.h" - -// -// Define the vendor commands supported by our device -// -#define USBFX2LK_SET_BARGRAPH_DISPLAY 0xD8 - -// -// Class for the iotrace driver. -// - -class CMyDevice : - public CUnknown, - public IPnpCallbackHardware -{ - -// -// Private data members. -// -private: - // - // Weak reference to framework device - // - IWDFDevice *m_FxDevice; - - // - // Weak reference to the control queue - // - PCMyControlQueue m_ControlQueue; - - // - // USB Device I/O Target - // - IWDFUsbTargetDevice * m_pIUsbTargetDevice; - - - // - // Device Speed (Low, Full, High) - // - UCHAR m_Speed; - -// -// Private methods. -// - -private: - - CMyDevice( - VOID - ) : - m_FxDevice(NULL), - m_ControlQueue(NULL), - m_pIUsbTargetDevice(NULL), - m_Speed(0) - { - } - - ~CMyDevice( - ); - - HRESULT - Initialize( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - // - // Helper methods - // - - HRESULT - CreateUsbIoTargets( - VOID - ); - - HRESULT - SendControlTransferSynchronously( - _In_ PWINUSB_SETUP_PACKET SetupPacket, - _Inout_updates_(BufferLength) PBYTE Buffer, - _In_ ULONG BufferLength, - _Out_ PULONG LengthTransferred - ); - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit, - _Out_ PCMyDevice *Device - ); - - IWDFDevice * - GetFxDevice( - VOID - ) - { - return m_FxDevice; - } - - HRESULT - Configure( - VOID - ); - - IPnpCallbackHardware * - QueryIPnpCallbackHardware( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - HRESULT - SetBarGraphDisplay( - _In_ PBAR_GRAPH_STATE BarGraphState - ); - -// -// COM methods -// -public: - - // - // IUnknown methods. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - // - // IPnpCallbackHardware - // - - virtual - HRESULT - STDMETHODCALLTYPE - OnPrepareHardware( - _In_ IWDFDevice *FxDevice - ); - - virtual - HRESULT - STDMETHODCALLTYPE - OnReleaseHardware( - _In_ IWDFDevice *FxDevice - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step3/Driver.cpp b/usb/wdf_osrfx2_lab/umdf/step3/Driver.cpp deleted file mode 100644 index bac5caca9..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/Driver.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Driver.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample's - core driver callback object. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "driver.tmh" - -HRESULT -CMyDriver::CreateInstance( - _Out_ PCMyDriver *Driver - ) -/*++ - - Routine Description: - - This static method is invoked in order to create and initialize a new - instance of the driver class. The caller should arrange for the object - to be released when it is no longer in use. - - Arguments: - - Driver - a location to store a referenced pointer to the new instance - - Return Value: - - S_OK if successful, or error otherwise. - ---*/ -{ - PCMyDriver driver; - HRESULT hr; - - // - // Allocate the callback object. - // - - driver = new CMyDriver(); - - if (NULL == driver) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the callback object. - // - - hr = driver->Initialize(); - - if (SUCCEEDED(hr)) - { - // - // Store a pointer to the new, initialized object in the output - // parameter. - // - - *Driver = driver; - } - else - { - - // - // Release the reference on the driver object to get it to delete - // itself. - // - - driver->Release(); - } - - return hr; -} - -HRESULT -CMyDriver::Initialize( - VOID - ) -/*++ - - Routine Description: - - This method is called to initialize a newly created driver callback object - before it is returned to the creator. Unlike the constructor, the - Initialize method contains operations which could potentially fail. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - return S_OK; -} - -HRESULT -CMyDriver::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Interface - ) -/*++ - - Routine Description: - - This method returns a pointer to the requested interface on the callback - object.. - - Arguments: - - InterfaceId - the IID of the interface to query/reference - - Interface - a location to store the interface pointer. - - Return Value: - - S_OK if the interface is supported. - E_NOINTERFACE if it is not supported. - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IDriverEntry))) - { - *Interface = QueryIDriverEntry(); - return S_OK; - } - else - { - return CUnknown::QueryInterface(InterfaceId, Interface); - } -} - -HRESULT -CMyDriver::OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ) -/*++ - - Routine Description: - - The FX invokes this method when it wants to install our driver on a device - stack. This method creates a device callback object, then calls the Fx - to create an Fx device object and associate the new callback object with - it. - - Arguments: - - FxWdfDriver - the Fx driver object. - - FxDeviceInit - the initialization information for the device. - - Return Value: - - status - ---*/ -{ - HRESULT hr; - - PCMyDevice device = NULL; - - // - // TODO: Do any per-device initialization (reading settings from the - // registry for example) that's necessary before creating your - // device callback object here. Otherwise you can leave such - // initialization to the initialization of the device event - // handler. - // - - // - // Create a new instance of our device callback object - // - - hr = CMyDevice::CreateInstance(FxWdfDriver, FxDeviceInit, &device); - - // - // TODO: Change any per-device settings that the object exposes before - // calling Configure to let it complete its initialization. - // - - // - // If that succeeded then call the device's construct method. This - // allows the device to create any queues or other structures that it - // needs now that the corresponding fx device object has been created. - // - - if (SUCCEEDED(hr)) - { - hr = device->Configure(); - } - - // - // Release the reference on the device callback object now that it's been - // associated with an fx device object. - // - - if (NULL != device) - { - device->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step3/Driver.h b/usb/wdf_osrfx2_lab/umdf/step3/Driver.h deleted file mode 100644 index 800ab1d9a..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/Driver.h +++ /dev/null @@ -1,149 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Driver.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample's - driver callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// This class handles driver events for the skeleton sample. In particular -// it supports the OnDeviceAdd event, which occurs when the driver is called -// to setup per-device handlers for a new device stack. -// - -class CMyDriver : public CUnknown, public IDriverEntry -{ -// -// Private data members. -// -private: - -// -// Private methods. -// -private: - - // - // Returns a refernced pointer to the IDriverEntry interface. - // - - IDriverEntry * - QueryIDriverEntry( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - HRESULT - Initialize( - VOID - ); - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _Out_ PCMyDriver *Driver - ); - -// -// COM methods -// -public: - - // - // IDriverEntry methods - // - - virtual - HRESULT - STDMETHODCALLTYPE - OnInitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return S_OK; - } - - virtual - HRESULT - STDMETHODCALLTYPE - OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - virtual - VOID - STDMETHODCALLTYPE - OnDeinitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return; - } - - // - // IUnknown methods. - // - // We have to implement basic ones here that redirect to the - // base class becuase of the multiple inheritance. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.ctl b/usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.ctl deleted file mode 100644 index 4dab56ae3..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.ctl +++ /dev/null @@ -1 +0,0 @@ -da5fbdfd-1eae-4ecf-b426-a3818f325ddb WudfOsrUsbFx2TraceGuid diff --git a/usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.rc b/usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.rc deleted file mode 100644 index 36f10ea90..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/OsrUsbFx2.rc +++ /dev/null @@ -1,21 +0,0 @@ -//--------------------------------------------------------------------------- -// OsrUsbDevice.rc -// -// Copyright (c) Microsoft Corporation, All Rights Reserved -//--------------------------------------------------------------------------- - - -#include -#include - -// -// TODO: Change the file description and file names to match your binary. -// - -#define VER_FILETYPE VFT_DLL -#define VER_FILESUBTYPE VFT_UNKNOWN -#define VER_FILEDESCRIPTION_STR "WDF:UMDF OSR USB Fx2 User-Mode Driver Sample" -#define VER_INTERNALNAME_STR "WUDFOsrUsbFx2" -#define VER_ORIGINALFILENAME_STR "WUDFOsrUsbFx2.dll" - -#include "common.ver" diff --git a/usb/wdf_osrfx2_lab/umdf/step3/Queue.cpp b/usb/wdf_osrfx2_lab/umdf/step3/Queue.cpp deleted file mode 100644 index c56b38bbc..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/Queue.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - queue.cpp - -Abstract: - - This file implements the I/O queue interface and performs - the read/write/ioctl operations. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "queue.tmh" - -CMyQueue::CMyQueue( - _In_ PCMyDevice Device - ) : - m_FxQueue(NULL), - m_Device(Device) -{ -} - -// -// Queue destructor. -// Free up the buffer, wait for thread to terminate and -// - -CMyQueue::~CMyQueue( - VOID - ) -/*++ - -Routine Description: - - - IUnknown implementation of Release - -Aruments: - - -Return Value: - - ULONG (reference count after Release) - ---*/ -{ - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_QUEUE, - "%!FUNC! Entry" - ); - -} - - -HRESULT -STDMETHODCALLTYPE -CMyQueue::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - -Routine Description: - - - Query Interface - -Aruments: - - Follows COM specifications - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - HRESULT hr; - - hr = CUnknown::QueryInterface(InterfaceId, Object); - - return hr; -} - -// -// Initialize -// - -HRESULT -CMyQueue::Initialize( - _In_ WDF_IO_QUEUE_DISPATCH_TYPE DispatchType, - _In_ bool Default, - _In_ bool PowerManaged - ) -{ - IWDFIoQueue *fxQueue; - HRESULT hr; - - // - // Create the I/O Queue object. - // - - { - IUnknown *callback = QueryIUnknown(); - - hr = m_Device->GetFxDevice()->CreateIoQueue( - callback, - Default, - DispatchType, - PowerManaged, - FALSE, - &fxQueue - ); - callback->Release(); - } - - if (SUCCEEDED(hr)) - { - m_FxQueue = fxQueue; - - // - // Release the creation reference on the queue. This object will be - // destroyed before the queue so we don't need to have a reference out - // on it. - // - - fxQueue->Release(); - } - - return hr; -} - -HRESULT -CMyQueue::Configure( - VOID - ) -{ - return S_OK; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step3/Queue.h b/usb/wdf_osrfx2_lab/umdf/step3/Queue.h deleted file mode 100644 index 5659224bb..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/Queue.h +++ /dev/null @@ -1,93 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - queue.h - -Abstract: - - This file defines the queue callback interface. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Queue Callback Object. -// - -class CMyQueue : - public CUnknown -{ -protected: - // - // Unreferenced pointer to the partner Fx device. - // - - IWDFIoQueue *m_FxQueue; - - // - // Unreferenced pointer to the parent device. - // - - PCMyDevice m_Device; - - HRESULT - Initialize( - _In_ WDF_IO_QUEUE_DISPATCH_TYPE DispatchType, - _In_ bool Default, - _In_ bool PowerManaged - ); - -protected: - - CMyQueue( - _In_ PCMyDevice Device - ); - - virtual ~CMyQueue(); - - HRESULT - Configure( - VOID - ); - -public: - - IWDFIoQueue * - GetFxQueue( - VOID - ) - { - return m_FxQueue; - } - - - PCMyDevice - GetDevice( - VOID - ) - { - return m_Device; - } - - // - // IUnknown - // - - STDMETHOD_(ULONG,AddRef) (VOID) {return CUnknown::AddRef();} - - _At_(this, __drv_freesMem(object)) - STDMETHOD_(ULONG,Release) (VOID) {return CUnknown::Release();} - - STDMETHOD_(HRESULT, QueryInterface)( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx b/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.inx deleted file mode 100644 index c4846f6ee0ddf8184c9f84ad01e6be4006bf71ad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5920 zcmb`L+fG|Y6o%)zQr}?V1%6mYV+!Czkim; zGqde&j1+C{^UON@>p1h@zfauH?kD%e74Droac#Hnj@-!I@H}#7ynS;UuIn~k-CepX zcfq(C=K;?nH+DVuk)z=0PdDIx|Av{y##>jN zr|zx)I^zEj4uANs9o|0h)`QDu<_=ubt+)rsD~bAy{0f)C9lB$_uJ}1Er0Vf?#Mll` zpWHQH2Bm+`pmzy{ru*AHayxF)2+Jlw?i-2fIrf`ouFbUG@-ufegXe&e-+1Vx5l+TJ=Z51 z2^-mB2vYlSm99;2`3(OH#-HeR^R0npBSO(*^Vr&Clwq@rE`6{aVB_4Y z-b)iQ}Hu^&LvXFhex2HoOg{(mf0-k zMO&G-xzwSoYMLm|#vEOE9wAParM8%-Bs0xZPUTp$C^jEyVbN>+E!wa-kvC@hFh-Q+ z<>y#W8A`e8owtqEjkfI>v7ATtz`NVWJby!WWqnFgwsrh&AR{HlFcqXSy^ zv00sZ{dI0$$?ctH;BF@2{kV0I|7M!YL%djS%Kr&>>qFjvfvVj%pDUFw8$`M))><+~ z`8B7I=TBKeR=Dsv>jO`sxWQfiG4`m+GRi>(v~>-Z(ugRvXc+q8zdSd@o$#pAC)#SB zK098YIA%G0qReF}O%u_J9h!W)pr4aJ_3%f{DbU&U@9})W+ehA|aXqOQxj*FCTKw0s zhPn*P122d#y>&dLfKDDws?n(jm-C9SJekn3>Tr$JV`NvCsctHrosOR6TGi8<3{`&@ zNtE+ALLT{nNmWJfe$k=~ks~eodDMhHpla-Fw9e+8CN*(Br>_5#=kusTihdcX+zVdf zRcFYq4)M0s-CM0($J-t!{uZJ?^}DbN$uTib!A}-(Y9?Jkx!y~wwD)e&7pNO(gRW-#kwg^s$s)GJm%PFZ&!O3%p9S|PQmgnRz&*!@N)zQ^}h==YM!df>D8 z@67n8a@H<$H0uybsV|0VaaScUEkiz02YU-Gtqqk6t#1oGq-xLnk=D887CeU1^^}Tr zqqgEvCzAi&^s?`Pta_0fA7@vL(wkP&k|R(M{vm_TdP($=5HpgxPM)~sOc9cQS+B6T zwk$>{^fUpfoaz_+Tit?s-NhKCbb_W@N#Qv^*L?OMztSe+%) zHCZ`|s%9xC%!{JNB#La!{$o}#X*Q^mXI`#1T|zYc7+Io6nxCjMSKbR9y5cQXIm>&q zYX`0NgkQ*umS@h19#t##ZbPo=9@B^{qmD%U?}LFjnSW~L>4f8~L;vr3>$l&zH)ehh)=N+ykDPwRklb{uX540hlYVXjf&~ zd13zidyqq`dgU=$^~1DVsoM3@9^Ns!wmECQTO4yQk2e3kYd2~>t*Tjp=HeB)Xr_B5 zT4hJumv=y;7Z=zjP&Q7pyCw5z$CZT53b9vRiA2R}ZrlUSW!xtgwDz>!5L*Y^{;jHk zydd3|EzecgrrP)wDmU!UXeB!!j - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {4BED411D-1B55-4A64-84C9-36EC25F083D2} - $(MSBuildProjectName) - 1 - 1 - Debug - Win32 - {9EBE799A-093D-4C8A-9CDC-63244A61D166} - - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - - $(IntDir) - - - - - - - - - - - - - - - - true - true - internal.h - - - true - true - internal.h - - - - WUDFOsrUsbFx2_3 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_3 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_3 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_3 - 0x0A00 - 0x0A000000 - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj.Filters b/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj.Filters deleted file mode 100644 index 1007a3534..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/WUDFOsrUsbFx2_3.vcxproj.Filters +++ /dev/null @@ -1,49 +0,0 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {275FF43B-A34B-4413-A946-DB6C89B85700} - - - h;hpp;hxx;hm;inl;inc;xsd - {3E57B132-7C76-4977-9406-304A1D0E3E93} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {9A62ABB9-1665-44C3-A018-B30C085A8EC5} - - - inf;inv;inx;mof;mc; - {6FE8DFE2-D3E3-4713-9FD8-A937B598C72C} - - - - - 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/usb/wdf_osrfx2_lab/umdf/step3/comsup.cpp b/usb/wdf_osrfx2_lab/umdf/step3/comsup.cpp deleted file mode 100644 index 9c9aec3b5..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/comsup.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.cpp - -Abstract: - - This module contains implementations for the functions and methods - used for providing COM support. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" - -#include "comsup.tmh" - -// -// Implementation of CUnknown methods. -// - -CUnknown::CUnknown( - VOID - ) : m_ReferenceCount(1) -/*++ - - Routine Description: - - Constructor for an instance of the CUnknown class. This simply initializes - the reference count of the object to 1. The caller is expected to - call Release() if it wants to delete the object once it has been allocated. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - // do nothing. -} - -HRESULT -STDMETHODCALLTYPE -CUnknown::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method provides the basic support for query interface on CUnknown. - If the interface requested is IUnknown it references the object and - returns an interface pointer. Otherwise it returns an error. - - Arguments: - - InterfaceId - the IID being requested - - Object - a location to store the interface pointer to return. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IUnknown))) - { - *Object = QueryIUnknown(); - return S_OK; - } - else - { - *Object = NULL; - return E_NOINTERFACE; - } -} - -IUnknown * -CUnknown::QueryIUnknown( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IUnknown interface. - - This allows other methods to convert a CUnknown pointer into an IUnknown - pointer without a typecast and without calling QueryInterface and dealing - with the return value. - - Arguments: - - None - - Return Value: - - A pointer to the object's IUnknown interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::AddRef( - VOID - ) -/*++ - - Routine Description: - - This method adds one to the object's reference count. - - Arguments: - - None - - Return Value: - - The new reference count. The caller should only use this for debugging - as the object's actual reference count can change while the caller - examines the return value. - ---*/ -{ - return InterlockedIncrement(&m_ReferenceCount); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::Release( - VOID - ) -/*++ - - Routine Description: - - This method subtracts one to the object's reference count. If the count - goes to zero, this method deletes the object. - - Arguments: - - None - - Return Value: - - The new reference count. If the caller uses this value it should only be - to check for zero (i.e. this call caused or will cause deletion) or - non-zero (i.e. some other call may have caused deletion, but this one - didn't). - ---*/ -{ - ULONG count = InterlockedDecrement(&m_ReferenceCount); - - if (count == 0) - { - delete this; - } - return count; -} - -// -// Implementation of CClassFactory methods. -// - -// -// Define storage for the factory's static lock count variable. -// - -LONG CClassFactory::s_LockCount = 0; - -IClassFactory * -CClassFactory::QueryIClassFactory( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IClassFactory interface. - - This allows other methods to convert a CClassFactory pointer into an - IClassFactory pointer without a typecast and without dealing with the - return value QueryInterface. - - Arguments: - - None - - Return Value: - - A referenced pointer to the object's IClassFactory interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -HRESULT -CClassFactory::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method attempts to retrieve the requested interface from the object. - - If the interface is found then the reference count on that interface (and - thus the object itself) is incremented. - - Arguments: - - InterfaceId - the interface the caller is requesting. - - Object - a location to store the interface pointer. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - // - // This class only supports IClassFactory so check for that. - // - - if (IsEqualIID(InterfaceId, __uuidof(IClassFactory))) - { - *Object = QueryIClassFactory(); - return S_OK; - } - else - { - // - // See if the base class supports the interface. - // - - return CUnknown::QueryInterface(InterfaceId, Object); - } -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::CreateInstance( - _In_opt_ IUnknown * /* OuterObject */, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ) -/*++ - - Routine Description: - - This COM method is the factory routine - it creates instances of the driver - callback class and returns the specified interface on them. - - Arguments: - - OuterObject - only used for aggregation, which our driver callback class - does not support. - - InterfaceId - the interface ID the caller would like to get from our - new object. - - Object - a location to store the referenced interface pointer to the new - object. - - Return Value: - - Status. - ---*/ -{ - HRESULT hr; - - PCMyDriver driver; - - *Object = NULL; - - hr = CMyDriver::CreateInstance(&driver); - - if (SUCCEEDED(hr)) - { - hr = driver->QueryInterface(InterfaceId, Object); - driver->Release(); - } - - return hr; -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::LockServer( - _In_ BOOL Lock - ) -/*++ - - Routine Description: - - This COM method can be used to keep the DLL in memory. However since the - driver's DllCanUnloadNow function always returns false, this has little - effect. Still it tracks the number of lock and unlock operations. - - Arguments: - - Lock - Whether the caller wants to lock or unlock the "server" - - Return Value: - - S_OK - ---*/ -{ - if (Lock) - { - InterlockedIncrement(&s_LockCount); - } - else - { - InterlockedDecrement(&s_LockCount); - } - return S_OK; -} - diff --git a/usb/wdf_osrfx2_lab/umdf/step3/comsup.h b/usb/wdf_osrfx2_lab/umdf/step3/comsup.h deleted file mode 100644 index dedf78c84..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/comsup.h +++ /dev/null @@ -1,215 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.h - -Abstract: - - This module contains classes and functions use for providing COM support - code. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Forward type declarations. They are here rather than in internal.h as -// you only need them if you choose to use these support classes. -// - -typedef class CUnknown *PCUnknown; -typedef class CClassFactory *PCClassFactory; - -// -// Base class to implement IUnknown. You can choose to derive your COM -// classes from this class, or simply implement IUnknown in each of your -// classes. -// - -class CUnknown : public IUnknown -{ - -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The reference count for this object. Initialized to 1 in the - // constructor. - // - - LONG m_ReferenceCount; - -// -// Protected data members and methods. These are accessible by the subclasses -// but not by other classes. -// -protected: - - // - // The constructor and destructor are protected to ensure that only the - // subclasses of CUnknown can create and destroy instances. - // - - CUnknown( - VOID - ); - - // - // The destructor MUST be virtual. Since any instance of a CUnknown - // derived class should only be deleted from within CUnknown::Release, - // the destructor MUST be virtual or only CUnknown::~CUnknown will get - // invoked on deletion. - // - // If you see that your CMyDevice specific destructor is never being - // called, make sure you haven't deleted the virtual destructor here. - // - - virtual - ~CUnknown( - VOID - ) - { - // Do nothing - } - -// -// Public Methods. These are accessible by any class. -// -public: - - IUnknown * - QueryIUnknown( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ); - - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ); - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; - -// -// Class factory support class. Create an instance of this from your -// DllGetClassObject method and modify the implementation to create -// an instance of your driver event handler class. -// - -class CClassFactory : public CUnknown, public IClassFactory -{ -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The lock count. This is shared across all instances of IClassFactory - // and can be queried through the public IsLocked method. - // - - static LONG s_LockCount; - -// -// Public Methods. These are accessible by any class. -// -public: - - IClassFactory * - QueryIClassFactory( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - // - // IClassFactory methods. - // - - virtual - HRESULT - STDMETHODCALLTYPE - CreateInstance( - _In_opt_ IUnknown *OuterObject, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ); - - virtual - HRESULT - STDMETHODCALLTYPE - LockServer( - _In_ BOOL Lock - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step3/dllsup.cpp b/usb/wdf_osrfx2_lab/umdf/step3/dllsup.cpp deleted file mode 100644 index bd681ac22..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/dllsup.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - dllsup.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample - Driver's entry point and its exported functions for providing COM support. - - This module can be copied without modification to a new UMDF driver. It - depends on some of the code in comsup.cpp & comsup.h to handle DLL - registration and creating the first class factory. - - This module is dependent on the following defines: - - MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing - tracing. For example the skeleton uses - L"Microsoft\\UMDF\\Skeleton" - - MYDRIVER_CLASS_ID - A GUID encoded in struct format used to - initialize the driver's ClassID. - - These are defined in internal.h for the skeleton sample. If you choose - to use a different primary include file, you should ensure they are - defined there as well. - -Environment: - - WDF User-Mode Driver Framework (WDF:UMDF) - ---*/ - -#include "internal.h" -#include "dllsup.tmh" - -const GUID CLSID_MyDriverCoClass = MYDRIVER_CLASS_ID; - -BOOL -WINAPI -DllMain( - HINSTANCE ModuleHandle, - DWORD Reason, - PVOID /* Reserved */ - ) -/*++ - - Routine Description: - - This is the entry point and exit point for the I/O trace driver. This - does very little as the I/O trace driver has minimal global data. - - This method initializes tracing, and saves the module handle away in a - global variable so that it can be referenced should the COM registration - code (Dll[Un]RegisterServer) be called. - - Arguments: - - ModuleHandle - the DLL handle for this module. - - Reason - the reason this entry point was called. - - Reserved - unused - - Return Value: - - TRUE - ---*/ -{ - UNREFERENCED_PARAMETER(ModuleHandle); - - if (DLL_PROCESS_ATTACH == Reason) - { - // - // Initialize tracing. - // - - WPP_INIT_TRACING(MYDRIVER_TRACING_ID); - } - else if (DLL_PROCESS_DETACH == Reason) - { - // - // Cleanup tracing. - // - - WPP_CLEANUP(); - } - - return TRUE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllCanUnloadNow( - VOID - ) -/*++ - - Routine Description: - - Called by the COM runtime when determining whether or not this module - can be unloaded. Our answer is always "no". - - Arguments: - - None - - Return Value: - - S_FALSE - ---*/ -{ - return S_FALSE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllGetClassObject( - REFCLSID ClassId, - REFIID InterfaceId, - LPVOID *Interface - ) -/*++ - - Routine Description: - - This routine is called by COM in order to instantiate the - skeleton driver callback object and do an initial query interface on it. - - This method only creates an instance of the driver's class factory, as this - is the minimum required to support UMDF. - - Arguments: - - ClassId - the CLSID of the object being "gotten" - - InterfaceId - the interface the caller wants from that object. - - Interface - a location to store the referenced interface pointer - - Return Value: - - S_OK if the function succeeds or error indicating the cause of the - failure. - ---*/ -{ - PCClassFactory factory; - - HRESULT hr = S_OK; - - *Interface = NULL; - - // - // If the CLSID doesn't match that of our "coclass" (defined in the IDL - // file) then we can't create the object the caller wants. This may - // indicate that the COM registration is incorrect, and another CLSID - // is referencing this drvier. - // - - if (IsEqualCLSID(ClassId, CLSID_MyDriverCoClass) == false) - { - Trace( - TRACE_LEVEL_ERROR, - L"ERROR: Called to create instance of unrecognized class (%!GUID!)", - &ClassId - ); - - return CLASS_E_CLASSNOTAVAILABLE; - } - - // - // Create an instance of the class factory for the caller. - // - - factory = new CClassFactory(); - - if (NULL == factory) - { - hr = E_OUTOFMEMORY; - } - - // - // Query the object we created for the interface the caller wants. After - // that we release the object. This will drive the reference count to - // 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed). - // In the later case the object is automatically deleted. - // - - if (SUCCEEDED(hr)) - { - hr = factory->QueryInterface(InterfaceId, Interface); - factory->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step3/exports.def b/usb/wdf_osrfx2_lab/umdf/step3/exports.def deleted file mode 100644 index 15f923d3b..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/exports.def +++ /dev/null @@ -1,4 +0,0 @@ -; WudfOsrUsbDriver.def : Declares the module parameters. - -EXPORTS - DllGetClassObject PRIVATE diff --git a/usb/wdf_osrfx2_lab/umdf/step3/internal.h b/usb/wdf_osrfx2_lab/umdf/step3/internal.h deleted file mode 100644 index 7db8f1c42..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step3/internal.h +++ /dev/null @@ -1,152 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Internal.h - -Abstract: - - This module contains the local type definitions for the UMDF Skeleton - driver sample. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -// -// Include the WUDF Headers -// - -#include "wudfddi.h" - -// -// Use specstrings for in/out annotation of function parameters. -// - -#include "specstrings.h" - -// -// Get limits on common data types (ULONG_MAX for example) -// - -#include "limits.h" - -// -// We need usb I/O targets to talk to the OSR device. -// - -#include "wudfusb.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "public.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "WUDFOsrUsbPublic.h" - -// -// Forward definitions of classes in the other header files. -// - -typedef class CMyDriver *PCMyDriver; -typedef class CMyDevice *PCMyDevice; -typedef class CMyQueue *PCMyQueue; - -typedef class CMyControlQueue *PCMyControlQueue; - -// -// Define the tracing flags. -// -// TODO: Choose a different trace control GUID -// - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - WudfOsrUsbFx2TraceGuid, (da5fbdfd,1eae,4ecf,b426,a3818f325ddb), \ - \ - WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \ - WPP_DEFINE_BIT(TEST_TRACE_DRIVER) \ - WPP_DEFINE_BIT(TEST_TRACE_DEVICE) \ - WPP_DEFINE_BIT(TEST_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) - -// -// This comment block is scanned by the trace preprocessor to define our -// Trace function. -// -// begin_wpp config -// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); -// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); -// end_wpp -// - -// -// Driver specific #defines -// -// TODO: Change these values to be appropriate for your driver. -// - -#define MYDRIVER_TRACING_ID L"Microsoft\\UMDF\\OsrUsb" -#define MYDRIVER_CLASS_ID {0x0865b2b0, 0x6b73, 0x428f, {0xa3, 0xea, 0x21, 0x72, 0x83, 0x2d, 0x6b, 0xfc}} - -// -// Include the type specific headers. -// - -#include "comsup.h" -#include "driver.h" -#include "device.h" -#include "queue.h" -#include "ControlQueue.h" -#include "list.h" - -__forceinline -#ifdef _PREFAST_ -__declspec(noreturn) -#endif -VOID -WdfTestNoReturn( - VOID - ) -{ - // do nothing. -} - -#define WUDF_TEST_DRIVER_ASSERT(p) \ -{ \ - if ( !(p) ) \ - { \ - DebugBreak(); \ - WdfTestNoReturn(); \ - } \ -} - -#define SAFE_RELEASE(p) {if ((p)) { (p)->Release(); (p) = NULL; }} diff --git a/usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.cpp b/usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.cpp deleted file mode 100644 index 48de237d2..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - ControlQueue.cpp - -Abstract: - - This file implements the I/O queue interface and performs - the ioctl operations. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" - -#include "winioctl.h" - -#include "ControlQueue.tmh" - -CMyControlQueue::CMyControlQueue( - _In_ PCMyDevice Device - ) : CMyQueue(Device) -{ - -} - -HRESULT -STDMETHODCALLTYPE -CMyControlQueue::QueryInterface( - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ) -/*++ - -Routine Description: - - - Query Interface - -Aruments: - - Follows COM specifications - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - HRESULT hr; - - - if (IsEqualIID(InterfaceId, __uuidof(IQueueCallbackDeviceIoControl))) - { - hr = S_OK; - *Object = QueryIQueueCallbackDeviceIoControl(); - - } - else - { - hr = CMyQueue::QueryInterface(InterfaceId, Object); - } - - return hr; -} - -// -// Initialize -// - -HRESULT -CMyControlQueue::CreateInstance( - _In_ PCMyDevice Device, - _Out_ PCMyControlQueue *Queue - ) -/*++ - -Routine Description: - - - CreateInstance creates an instance of the queue object. - -Aruments: - - ppUkwn - OUT parameter is an IUnknown interface to the queue object - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - PCMyControlQueue queue = NULL; - HRESULT hr = S_OK; - - queue = new CMyControlQueue(Device); - - if (NULL == queue) - { - hr = E_OUTOFMEMORY; - } - - // - // Call the queue callback object to initialize itself. This will create - // its partner queue framework object. - // - - if (SUCCEEDED(hr)) - { - hr = queue->Initialize(); - } - - if (SUCCEEDED(hr)) - { - *Queue = queue; - } - else - { - SAFE_RELEASE(queue); - } - - return hr; -} - -HRESULT -CMyControlQueue::Initialize( - VOID - ) -{ - HRESULT hr; - - // - // First initialize the base class. This will create the partner FxIoQueue - // object and setup automatic forwarding of I/O controls. - // - - hr = __super::Initialize(WdfIoQueueDispatchSequential, - false, - true); - - // - // return the status. - // - - return hr; -} - -VOID -STDMETHODCALLTYPE -CMyControlQueue::OnDeviceIoControl( - _In_ IWDFIoQueue *FxQueue, - _In_ IWDFIoRequest *FxRequest, - _In_ ULONG ControlCode, - _In_ SIZE_T InputBufferSizeInBytes, - _In_ SIZE_T OutputBufferSizeInBytes - ) -/*++ - -Routine Description: - - - DeviceIoControl dispatch routine - -Aruments: - - FxQueue - Framework Queue instance - FxRequest - Framework Request instance - ControlCode - IO Control Code - InputBufferSizeInBytes - Lenth of input buffer - OutputBufferSizeInBytes - Lenth of output buffer - - Always succeeds DeviceIoIoctl -Return Value: - - VOID - ---*/ -{ - UNREFERENCED_PARAMETER(FxQueue); - UNREFERENCED_PARAMETER(OutputBufferSizeInBytes); - - IWDFMemory *memory = NULL; - PVOID buffer; - - SIZE_T bigBufferCb; - - ULONG information = 0; - - bool completeRequest = true; - - HRESULT hr = S_OK; - - switch (ControlCode) - { - case IOCTL_OSRUSBFX2_SET_BAR_GRAPH_DISPLAY: - { - // - // Make sure the buffer is big enough to hold the input for the - // control transfer. - // - - if (InputBufferSizeInBytes < sizeof(BAR_GRAPH_STATE)) - { - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - else - { - FxRequest->GetInputMemory(&memory); - } - - // - // Get the data buffer and use it to set the bar graph on the - // device. - // - - if (SUCCEEDED(hr)) - { - buffer = memory->GetDataBuffer(&bigBufferCb); - memory->Release(); - - hr = m_Device->SetBarGraphDisplay((PBAR_GRAPH_STATE) buffer); - } - - break; - } - - default: - { - hr = HRESULT_FROM_WIN32(ERROR_INVALID_FUNCTION); - break; - } - } - - if (completeRequest) - { - FxRequest->CompleteWithInformation(hr, information); - } - - return; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.h b/usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.h deleted file mode 100644 index 251521e1b..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/ControlQueue.h +++ /dev/null @@ -1,101 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - ControlQueue.h - -Abstract: - - This file defines the queue callback object for handling device I/O - control requests. This is a serialized queue. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Queue Callback Object. -// - -class CMyControlQueue : public IQueueCallbackDeviceIoControl, - public CMyQueue -{ - HRESULT - Initialize( - VOID - ); - -public: - - CMyControlQueue( - _In_ PCMyDevice Device - ); - - virtual - ~CMyControlQueue( - VOID - ) - { - return; - } - - static - HRESULT - CreateInstance( - _In_ PCMyDevice Device, - _Out_ PCMyControlQueue *Queue - ); - - HRESULT - Configure( - VOID - ) - { - return S_OK; - } - - IQueueCallbackDeviceIoControl * - QueryIQueueCallbackDeviceIoControl( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - // - // IUnknown - // - - STDMETHOD_(ULONG,AddRef) (VOID) {return CUnknown::AddRef();} - - _At_(this, __drv_freesMem(object)) - STDMETHOD_(ULONG,Release) (VOID) {return CUnknown::Release();} - - STDMETHOD_(HRESULT, QueryInterface)( - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ); - - // - // Wdf Callbacks - // - - // - // IQueueCallbackDeviceIoControl - // - STDMETHOD_ (void, OnDeviceIoControl)( - _In_ IWDFIoQueue *pWdfQueue, - _In_ IWDFIoRequest *pWdfRequest, - _In_ ULONG ControlCode, - _In_ SIZE_T InputBufferSizeInBytes, - _In_ SIZE_T OutputBufferSizeInBytes - ); -}; - diff --git a/usb/wdf_osrfx2_lab/umdf/step4/Device.cpp b/usb/wdf_osrfx2_lab/umdf/step4/Device.cpp deleted file mode 100644 index bc6700c5c..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/Device.cpp +++ /dev/null @@ -1,812 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Device.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton sample driver's - device callback object. - - The skeleton sample device does very little. It does not implement either - of the PNP interfaces so once the device is setup, it won't ever get any - callbacks until the device is removed. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "initguid.h" -#include "usb_hw.h" - -#include "device.tmh" - -CMyDevice::~CMyDevice( - ) -{ -} - -HRESULT -CMyDevice::CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit, - _Out_ PCMyDevice *Device - ) -/*++ - - Routine Description: - - This method creates and initializs an instance of the skeleton driver's - device callback object. - - Arguments: - - FxDeviceInit - the settings for the device. - - Device - a location to store the referenced pointer to the device object. - - Return Value: - - Status - ---*/ -{ - PCMyDevice device; - HRESULT hr; - - // - // Allocate a new instance of the device class. - // - - device = new CMyDevice(); - - if (NULL == device) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the instance. - // - - hr = device->Initialize(FxDriver, FxDeviceInit); - - if (SUCCEEDED(hr)) - { - *Device = device; - } - else - { - device->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Initialize( - _In_ IWDFDriver * FxDriver, - _In_ IWDFDeviceInitialize * FxDeviceInit - ) -/*++ - - Routine Description: - - This method initializes the device callback object and creates the - partner device object. - - The method should perform any device-specific configuration that: - * could fail (these can't be done in the constructor) - * must be done before the partner object is created -or- - * can be done after the partner object is created and which aren't - influenced by any device-level parameters the parent (the driver - in this case) might set. - - Arguments: - - FxDeviceInit - the settings for this device. - - Return Value: - - status. - ---*/ -{ - IWDFDevice *fxDevice = NULL; - - HRESULT hr = S_OK; - - // - // TODO: If you're writing a filter driver then indicate that here. - // - // FxDeviceInit->SetFilter(); - // - - // - // Set no locking unless you need an automatic callbacks synchronization - // - - FxDeviceInit->SetLockingConstraint(None); - - // - // TODO: Any per-device initialization which must be done before - // creating the partner object. - // - - // - // Create a new FX device object and assign the new callback object to - // handle any device level events that occur. - // - - // - // QueryIUnknown references the IUnknown interface that it returns - // (which is the same as referencing the device). We pass that to - // CreateDevice, which takes its own reference if everything works. - // - - if (SUCCEEDED(hr)) - { - IUnknown *unknown = this->QueryIUnknown(); - - hr = FxDriver->CreateDevice(FxDeviceInit, unknown, &fxDevice); - - unknown->Release(); - } - - // - // If that succeeded then set our FxDevice member variable. - // - - if (SUCCEEDED(hr)) - { - m_FxDevice = fxDevice; - - // - // Drop the reference we got from CreateDevice. Since this object - // is partnered with the framework object they have the same - // lifespan - there is no need for an additional reference. - // - - fxDevice->Release(); - } - - return hr; -} - -HRESULT -CMyDevice::Configure( - VOID - ) -/*++ - - Routine Description: - - This method is called after the device callback object has been initialized - and returned to the driver. It would setup the device's queues and their - corresponding callback objects. - - Arguments: - - FxDevice - the framework device object for which we're handling events. - - Return Value: - - status - ---*/ -{ - HRESULT hr = S_OK; - - hr = CMyReadWriteQueue::CreateInstance(this, &m_ReadWriteQueue); - - if (FAILED(hr)) - { - return hr; - } - - // - // We use default queue for read/write - // - - hr = m_ReadWriteQueue->Configure(); - - m_ReadWriteQueue->Release(); - - // - // Create the control queue and configure forwarding for IOCTL requests. - // - - if (SUCCEEDED(hr)) - { - hr = CMyControlQueue::CreateInstance(this, &m_ControlQueue); - - if (SUCCEEDED(hr)) - { - hr = m_ControlQueue->Configure(); - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->ConfigureRequestDispatching( - m_ControlQueue->GetFxQueue(), - WdfRequestDeviceIoControl, - true - ); - } - m_ControlQueue->Release(); - } - } - - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->CreateDeviceInterface(&GUID_DEVINTERFACE_OSRUSBFX2, - NULL); - } - - return hr; -} - -HRESULT -CMyDevice::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method is called to get a pointer to one of the object's callback - interfaces. - - Since the skeleton driver doesn't support any of the device events, this - method simply calls the base class's BaseQueryInterface. - - If the skeleton is extended to include device event interfaces then this - method must be changed to check the IID and return pointers to them as - appropriate. - - Arguments: - - InterfaceId - the interface being requested - - Object - a location to store the interface pointer if successful - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - HRESULT hr; - - if (IsEqualIID(InterfaceId, __uuidof(IPnpCallbackHardware))) - { - *Object = QueryIPnpCallbackHardware(); - hr = S_OK; - } - else - { - hr = CUnknown::QueryInterface(InterfaceId, Object); - } - - return hr; -} - -HRESULT -CMyDevice::OnPrepareHardware( - _In_ IWDFDevice * /* FxDevice */ - ) -/*++ - -Routine Description: - - This routine is invoked to ready the driver - to talk to hardware. It opens the handle to the - device and talks to it using the WINUSB interface. - It invokes WINUSB to discver the interfaces and stores - the information related to bulk endpoints. - -Arguments: - - FxDevice : Pointer to the WDF device interface - -Return Value: - - HRESULT - ---*/ -{ - PWSTR deviceName = NULL; - DWORD deviceNameCch = 0; - - HRESULT hr; - - // - // Get the device name. - // Get the length to allocate first - // - - hr = m_FxDevice->RetrieveDeviceName(NULL, &deviceNameCch); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get device name %!hresult!", - hr - ); - } - - // - // Allocate the buffer - // - - if (SUCCEEDED(hr)) - { - deviceName = new WCHAR[deviceNameCch]; - - if (deviceName == NULL) - { - hr = E_OUTOFMEMORY; - } - } - - // - // Get the actual name - // - - if (SUCCEEDED(hr)) - { - hr = m_FxDevice->RetrieveDeviceName(deviceName, &deviceNameCch); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get device name %!hresult!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_DEVICE, - "%!FUNC! Device name %S", - deviceName - ); - } - - // - // Create USB I/O Targets and configure them - // - - if (SUCCEEDED(hr)) - { - hr = CreateUsbIoTargets(); - } - - if (SUCCEEDED(hr)) - { - ULONG length = sizeof(m_Speed); - - hr = m_pIUsbTargetDevice->RetrieveDeviceInformation(DEVICE_SPEED, - &length, - &m_Speed); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get usb device speed information %!HRESULT!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_DEVICE, - "%!FUNC! Speed - %x\n", - m_Speed - ); - } - - if (SUCCEEDED(hr)) - { - hr = ConfigureUsbPipes(); - } - - delete[] deviceName; - - return hr; -} - -HRESULT -CMyDevice::OnReleaseHardware( - _In_ IWDFDevice * /* FxDevice */ - ) -/*++ - -Routine Description: - - This routine is invoked when the device is being removed or stopped - It releases all resources allocated for this device. - -Arguments: - - FxDevice - Pointer to the Device object. - -Return Value: - - HRESULT - Always succeeds. - ---*/ -{ - // - // Remove I/O target from object tree before any potential subsequent - // OnPrepareHardware creates a new one - // - - if (m_pIUsbTargetDevice) - { - m_pIUsbTargetDevice->DeleteWdfObject(); - } - - return S_OK; -} - -HRESULT -CMyDevice::CreateUsbIoTargets( - ) -/*++ - -Routine Description: - - This routine creates Usb device, interface and pipe objects - -Arguments: - - None - -Return Value: - - HRESULT ---*/ -{ - HRESULT hr; - UCHAR NumEndPoints = 0; - IWDFUsbTargetFactory * pIUsbTargetFactory = NULL; - IWDFUsbTargetDevice * pIUsbTargetDevice = NULL; - IWDFUsbInterface * pIUsbInterface = NULL; - IWDFUsbTargetPipe * pIUsbPipe = NULL; - - hr = m_FxDevice->QueryInterface(IID_PPV_ARGS(&pIUsbTargetFactory)); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Cannot get usb target factory %!HRESULT!", - hr - ); - } - - if (SUCCEEDED(hr)) - { - hr = pIUsbTargetFactory->CreateUsbTargetDevice( - &pIUsbTargetDevice); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Unable to create USB Device I/O Target %!HRESULT!", - hr - ); - } - else - { - m_pIUsbTargetDevice = pIUsbTargetDevice; - - // - // Release the creation reference as object tree will maintain a reference - // - - pIUsbTargetDevice->Release(); - } - } - - if (SUCCEEDED(hr)) - { - UCHAR NumInterfaces = pIUsbTargetDevice->GetNumInterfaces(); - - WUDF_TEST_DRIVER_ASSERT(1 == NumInterfaces); - - hr = pIUsbTargetDevice->RetrieveUsbInterface(0, &pIUsbInterface); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Unable to retrieve USB interface from USB Device I/O Target %!HRESULT!", - hr - ); - } - else - { - m_pIUsbInterface = pIUsbInterface; - - pIUsbInterface->Release(); //release creation reference - } - } - - if (SUCCEEDED(hr)) - { - NumEndPoints = pIUsbInterface->GetNumEndPoints(); - - if (NumEndPoints != NUM_OSRUSB_ENDPOINTS) { - hr = E_UNEXPECTED; - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Has %d endpoints, expected %d, returning %!HRESULT! ", - NumEndPoints, - NUM_OSRUSB_ENDPOINTS, - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - for (UCHAR PipeIndex = 0; PipeIndex < NumEndPoints; PipeIndex++) - { - hr = pIUsbInterface->RetrieveUsbPipeObject(PipeIndex, - &pIUsbPipe); - - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Unable to retrieve USB Pipe for PipeIndex %d, %!HRESULT!", - PipeIndex, - hr - ); - } - else - { - if ( pIUsbPipe->IsInEndPoint() && (UsbdPipeTypeBulk == pIUsbPipe->GetType()) ) - { - m_pIUsbInputPipe = pIUsbPipe; - } - else if ( pIUsbPipe->IsOutEndPoint() && (UsbdPipeTypeBulk == pIUsbPipe->GetType()) ) - { - m_pIUsbOutputPipe = pIUsbPipe; - } - else - { - pIUsbPipe->DeleteWdfObject(); - } - - SAFE_RELEASE(pIUsbPipe); //release creation reference - } - } - - if (NULL == m_pIUsbInputPipe || NULL == m_pIUsbOutputPipe) - { - hr = E_UNEXPECTED; - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Input or output pipe not found, returning %!HRESULT!", - hr - ); - } - } - - SAFE_RELEASE(pIUsbTargetFactory); - - return hr; -} - -HRESULT -CMyDevice::ConfigureUsbPipes( - ) -/*++ - -Routine Description: - - This routine retrieves the IDs for the bulk end points of the USB device. - -Arguments: - - None - -Return Value: - - HRESULT ---*/ -{ - HRESULT hr = S_OK; - LONG timeout; - - // - // Set timeout policies for input/output pipes - // - - if (SUCCEEDED(hr)) - { - timeout = ENDPOINT_TIMEOUT; - - hr = m_pIUsbInputPipe->SetPipePolicy(PIPE_TRANSFER_TIMEOUT, - sizeof(timeout), - &timeout); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Unable to set timeout policy for input pipe %!HRESULT!", - hr - ); - } - } - - if (SUCCEEDED(hr)) - { - timeout = ENDPOINT_TIMEOUT; - - hr = m_pIUsbOutputPipe->SetPipePolicy(PIPE_TRANSFER_TIMEOUT, - sizeof(timeout), - &timeout); - if (FAILED(hr)) - { - TraceEvents(TRACE_LEVEL_ERROR, - TEST_TRACE_DEVICE, - "%!FUNC! Unable to set timeout policy for output pipe %!HRESULT!", - hr - ); - } - } - - return hr; -} - -HRESULT -CMyDevice::SetBarGraphDisplay( - _In_ PBAR_GRAPH_STATE BarGraphState - ) -/*++ - - Routine Description: - - This method synchronously sets the bar graph display on the OSR USB-FX2 - device using the buffers in the FxRequest as input. - - Arguments: - - FxRequest - the request to set the bar-graph info. - - Return Value: - - Status - ---*/ -{ - WINUSB_CONTROL_SETUP_PACKET setupPacket; - - ULONG bytesTransferred; - - HRESULT hr = S_OK; - - // - // Setup the control packet. - // - - WINUSB_CONTROL_SETUP_PACKET_INIT( &setupPacket, - BmRequestHostToDevice, - BmRequestToDevice, - USBFX2LK_SET_BARGRAPH_DISPLAY, - 0, - 0 ); - - // - // Issue the request to WinUsb. - // - - hr = SendControlTransferSynchronously( - &(setupPacket.WinUsb), - (PUCHAR) BarGraphState, - sizeof(BAR_GRAPH_STATE), - &bytesTransferred - ); - - - return hr; -} - -HRESULT -CMyDevice::SendControlTransferSynchronously( - _In_ PWINUSB_SETUP_PACKET SetupPacket, - _Inout_updates_(BufferLength) PBYTE Buffer, - _In_ ULONG BufferLength, - _Out_ PULONG LengthTransferred - ) -{ - HRESULT hr = S_OK; - HRESULT hrRequest = S_OK; - IWDFIoRequest *pWdfRequest = NULL; - IWDFDriver * FxDriver = NULL; - IWDFMemory * FxMemory = NULL; - IWDFRequestCompletionParams * FxComplParams = NULL; - IWDFUsbRequestCompletionParams * FxUsbComplParams = NULL; - - *LengthTransferred = 0; - - hr = m_FxDevice->CreateRequest( NULL, //pCallbackInterface - NULL, //pParentObject - &pWdfRequest); - hrRequest = hr; - - if (SUCCEEDED(hr)) - { - m_FxDevice->GetDriver(&FxDriver); - - hr = FxDriver->CreatePreallocatedWdfMemory( Buffer, - BufferLength, - NULL, //pCallbackInterface - pWdfRequest, //pParetObject - &FxMemory ); - } - - if (SUCCEEDED(hr)) - { - hr = m_pIUsbTargetDevice->FormatRequestForControlTransfer( pWdfRequest, - SetupPacket, - FxMemory, - NULL); //TransferOffset - } - - if (SUCCEEDED(hr)) - { - hr = pWdfRequest->Send( m_pIUsbTargetDevice, - WDF_REQUEST_SEND_OPTION_SYNCHRONOUS, - 0); //Timeout - } - - if (SUCCEEDED(hr)) - { - pWdfRequest->GetCompletionParams(&FxComplParams); - - hr = FxComplParams->GetCompletionStatus(); - } - - if (SUCCEEDED(hr)) - { - HRESULT hrQI = FxComplParams->QueryInterface(IID_PPV_ARGS(&FxUsbComplParams)); - WUDF_TEST_DRIVER_ASSERT(SUCCEEDED(hrQI)); - - WUDF_TEST_DRIVER_ASSERT( WdfUsbRequestTypeDeviceControlTransfer == - FxUsbComplParams->GetCompletedUsbRequestType() ); - - FxUsbComplParams->GetDeviceControlTransferParameters( NULL, - LengthTransferred, - NULL, - NULL ); - } - - SAFE_RELEASE(FxUsbComplParams); - SAFE_RELEASE(FxComplParams); - SAFE_RELEASE(FxMemory); - - if (SUCCEEDED(hrRequest)) - { - pWdfRequest->DeleteWdfObject(); - } - SAFE_RELEASE(pWdfRequest); - - SAFE_RELEASE(FxDriver); - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step4/Device.h b/usb/wdf_osrfx2_lab/umdf/step4/Device.h deleted file mode 100644 index fe5acfed4..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/Device.h +++ /dev/null @@ -1,256 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Device.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample - driver's device callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once -#include "internal.h" - -#define ENDPOINT_TIMEOUT 10000 -#define NUM_OSRUSB_ENDPOINTS 3 - -// -// Define the vendor commands supported by our device -// -#define USBFX2LK_SET_BARGRAPH_DISPLAY 0xD8 - -// -// Class for the iotrace driver. -// - -class CMyDevice : - public CUnknown, - public IPnpCallbackHardware -{ - -// -// Private data members. -// -private: - // - // Weak reference to framework device - // - IWDFDevice *m_FxDevice; - - // - // Weak reference to the control queue - // - PCMyReadWriteQueue m_ReadWriteQueue; - - // - // Weak reference to the control queue - // - PCMyControlQueue m_ControlQueue; - - // - // USB Device I/O Target - // - IWDFUsbTargetDevice * m_pIUsbTargetDevice; - - // - // USB Interface - // - IWDFUsbInterface * m_pIUsbInterface; - - // - // USB Input pipe for Reads - // - IWDFUsbTargetPipe * m_pIUsbInputPipe; - - // - // USB Output pipe for writes - // - IWDFUsbTargetPipe * m_pIUsbOutputPipe; - - // - // Device Speed (Low, Full, High) - // - UCHAR m_Speed; - -// -// Private methods. -// - -private: - - CMyDevice( - VOID - ) : - m_FxDevice(NULL), - m_ControlQueue(NULL), - m_ReadWriteQueue(NULL), - m_pIUsbTargetDevice(NULL), - m_pIUsbInterface(NULL), - m_pIUsbInputPipe(NULL), - m_pIUsbOutputPipe(NULL), - m_Speed(0) - { - } - - ~CMyDevice( - ); - - HRESULT - Initialize( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - // - // Helper methods - // - - HRESULT - CreateUsbIoTargets( - VOID - ); - - - HRESULT - ConfigureUsbPipes( - ); - - HRESULT - SendControlTransferSynchronously( - _In_ PWINUSB_SETUP_PACKET SetupPacket, - _Inout_updates_(BufferLength) PBYTE Buffer, - _In_ ULONG BufferLength, - _Out_ PULONG LengthTransferred - ); - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _In_ IWDFDriver *FxDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit, - _Out_ PCMyDevice *Device - ); - - IWDFDevice * - GetFxDevice( - VOID - ) - { - return m_FxDevice; - } - - HRESULT - Configure( - VOID - ); - - IPnpCallbackHardware * - QueryIPnpCallbackHardware( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - HRESULT - SetBarGraphDisplay( - _In_ PBAR_GRAPH_STATE BarGraphState - ); - - // - //returns a weak reference to input pipe - //DO NOT release it - // - IWDFUsbTargetPipe * - GetInputPipe( - ) - { - return m_pIUsbInputPipe; - } - - // - //returns a weak reference to output pipe - //DO NOT release it - // - IWDFUsbTargetPipe * - GetOutputPipe( - ) - { - return m_pIUsbOutputPipe; - } - -// -// COM methods -// -public: - - // - // IUnknown methods. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - // - // IPnpCallbackHardware - // - - virtual - HRESULT - STDMETHODCALLTYPE - OnPrepareHardware( - _In_ IWDFDevice *FxDevice - ); - - virtual - HRESULT - STDMETHODCALLTYPE - OnReleaseHardware( - _In_ IWDFDevice *FxDevice - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step4/Driver.cpp b/usb/wdf_osrfx2_lab/umdf/step4/Driver.cpp deleted file mode 100644 index bac5caca9..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/Driver.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - Driver.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample's - core driver callback object. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "driver.tmh" - -HRESULT -CMyDriver::CreateInstance( - _Out_ PCMyDriver *Driver - ) -/*++ - - Routine Description: - - This static method is invoked in order to create and initialize a new - instance of the driver class. The caller should arrange for the object - to be released when it is no longer in use. - - Arguments: - - Driver - a location to store a referenced pointer to the new instance - - Return Value: - - S_OK if successful, or error otherwise. - ---*/ -{ - PCMyDriver driver; - HRESULT hr; - - // - // Allocate the callback object. - // - - driver = new CMyDriver(); - - if (NULL == driver) - { - return E_OUTOFMEMORY; - } - - // - // Initialize the callback object. - // - - hr = driver->Initialize(); - - if (SUCCEEDED(hr)) - { - // - // Store a pointer to the new, initialized object in the output - // parameter. - // - - *Driver = driver; - } - else - { - - // - // Release the reference on the driver object to get it to delete - // itself. - // - - driver->Release(); - } - - return hr; -} - -HRESULT -CMyDriver::Initialize( - VOID - ) -/*++ - - Routine Description: - - This method is called to initialize a newly created driver callback object - before it is returned to the creator. Unlike the constructor, the - Initialize method contains operations which could potentially fail. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - return S_OK; -} - -HRESULT -CMyDriver::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Interface - ) -/*++ - - Routine Description: - - This method returns a pointer to the requested interface on the callback - object.. - - Arguments: - - InterfaceId - the IID of the interface to query/reference - - Interface - a location to store the interface pointer. - - Return Value: - - S_OK if the interface is supported. - E_NOINTERFACE if it is not supported. - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IDriverEntry))) - { - *Interface = QueryIDriverEntry(); - return S_OK; - } - else - { - return CUnknown::QueryInterface(InterfaceId, Interface); - } -} - -HRESULT -CMyDriver::OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ) -/*++ - - Routine Description: - - The FX invokes this method when it wants to install our driver on a device - stack. This method creates a device callback object, then calls the Fx - to create an Fx device object and associate the new callback object with - it. - - Arguments: - - FxWdfDriver - the Fx driver object. - - FxDeviceInit - the initialization information for the device. - - Return Value: - - status - ---*/ -{ - HRESULT hr; - - PCMyDevice device = NULL; - - // - // TODO: Do any per-device initialization (reading settings from the - // registry for example) that's necessary before creating your - // device callback object here. Otherwise you can leave such - // initialization to the initialization of the device event - // handler. - // - - // - // Create a new instance of our device callback object - // - - hr = CMyDevice::CreateInstance(FxWdfDriver, FxDeviceInit, &device); - - // - // TODO: Change any per-device settings that the object exposes before - // calling Configure to let it complete its initialization. - // - - // - // If that succeeded then call the device's construct method. This - // allows the device to create any queues or other structures that it - // needs now that the corresponding fx device object has been created. - // - - if (SUCCEEDED(hr)) - { - hr = device->Configure(); - } - - // - // Release the reference on the device callback object now that it's been - // associated with an fx device object. - // - - if (NULL != device) - { - device->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step4/Driver.h b/usb/wdf_osrfx2_lab/umdf/step4/Driver.h deleted file mode 100644 index 800ab1d9a..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/Driver.h +++ /dev/null @@ -1,149 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Driver.h - -Abstract: - - This module contains the type definitions for the UMDF Skeleton sample's - driver callback class. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// This class handles driver events for the skeleton sample. In particular -// it supports the OnDeviceAdd event, which occurs when the driver is called -// to setup per-device handlers for a new device stack. -// - -class CMyDriver : public CUnknown, public IDriverEntry -{ -// -// Private data members. -// -private: - -// -// Private methods. -// -private: - - // - // Returns a refernced pointer to the IDriverEntry interface. - // - - IDriverEntry * - QueryIDriverEntry( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - HRESULT - Initialize( - VOID - ); - -// -// Public methods -// -public: - - // - // The factory method used to create an instance of this driver. - // - - static - HRESULT - CreateInstance( - _Out_ PCMyDriver *Driver - ); - -// -// COM methods -// -public: - - // - // IDriverEntry methods - // - - virtual - HRESULT - STDMETHODCALLTYPE - OnInitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return S_OK; - } - - virtual - HRESULT - STDMETHODCALLTYPE - OnDeviceAdd( - _In_ IWDFDriver *FxWdfDriver, - _In_ IWDFDeviceInitialize *FxDeviceInit - ); - - virtual - VOID - STDMETHODCALLTYPE - OnDeinitialize( - _In_ IWDFDriver *FxWdfDriver - ) - { - UNREFERENCED_PARAMETER(FxWdfDriver); - - return; - } - - // - // IUnknown methods. - // - // We have to implement basic ones here that redirect to the - // base class becuase of the multiple inheritance. - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.ctl b/usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.ctl deleted file mode 100644 index 4dab56ae3..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.ctl +++ /dev/null @@ -1 +0,0 @@ -da5fbdfd-1eae-4ecf-b426-a3818f325ddb WudfOsrUsbFx2TraceGuid diff --git a/usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.rc b/usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.rc deleted file mode 100644 index 36f10ea90..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/OsrUsbFx2.rc +++ /dev/null @@ -1,21 +0,0 @@ -//--------------------------------------------------------------------------- -// OsrUsbDevice.rc -// -// Copyright (c) Microsoft Corporation, All Rights Reserved -//--------------------------------------------------------------------------- - - -#include -#include - -// -// TODO: Change the file description and file names to match your binary. -// - -#define VER_FILETYPE VFT_DLL -#define VER_FILESUBTYPE VFT_UNKNOWN -#define VER_FILEDESCRIPTION_STR "WDF:UMDF OSR USB Fx2 User-Mode Driver Sample" -#define VER_INTERNALNAME_STR "WUDFOsrUsbFx2" -#define VER_ORIGINALFILENAME_STR "WUDFOsrUsbFx2.dll" - -#include "common.ver" diff --git a/usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.cpp b/usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.cpp deleted file mode 100644 index 21f425488..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - queue.cpp - -Abstract: - - This file implements the I/O queue interface and performs - the read/write/ioctl operations. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "ReadWriteQueue.tmh" - -VOID -CMyReadWriteQueue::OnCompletion( - _In_ IWDFIoRequest* pWdfRequest, - _In_ IWDFIoTarget* pIoTarget, - _In_ IWDFRequestCompletionParams* pParams, - _In_ PVOID pContext - ) -{ - UNREFERENCED_PARAMETER(pIoTarget); - UNREFERENCED_PARAMETER(pContext); - - pWdfRequest->CompleteWithInformation( - pParams->GetCompletionStatus(), - pParams->GetInformation() - ); -} - -void -CMyReadWriteQueue::ForwardFormattedRequest( - _In_ IWDFIoRequest* pRequest, - _In_ IWDFIoTarget* pIoTarget - ) -{ - // - //First set the completion callback - // - - IRequestCallbackRequestCompletion * pCompletionCallback = NULL; - HRESULT hrQI = this->QueryInterface(IID_PPV_ARGS(&pCompletionCallback)); - WUDF_TEST_DRIVER_ASSERT(SUCCEEDED(hrQI) && (NULL != pCompletionCallback)); - - pRequest->SetCompletionCallback( - pCompletionCallback, - NULL - ); - - pCompletionCallback->Release(); - pCompletionCallback = NULL; - - // - //Send down the request - // - - HRESULT hrSend = S_OK; - hrSend = pRequest->Send(pIoTarget, - 0, //flags - 0); //timeout - - if (FAILED(hrSend)) - { - pRequest->CompleteWithInformation(hrSend, 0); - } - - return; -} - - -CMyReadWriteQueue::CMyReadWriteQueue( - _In_ PCMyDevice Device - ) : - CMyQueue(Device) -{ -} - -// -// Queue destructor. -// Free up the buffer, wait for thread to terminate and -// - -CMyReadWriteQueue::~CMyReadWriteQueue( - VOID - ) -/*++ - -Routine Description: - - - IUnknown implementation of Release - -Aruments: - - -Return Value: - - ULONG (reference count after Release) - ---*/ -{ - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_QUEUE, - "%!FUNC! Entry" - ); - -} - - -HRESULT -STDMETHODCALLTYPE -CMyReadWriteQueue::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - -Routine Description: - - - Query Interface - -Aruments: - - Follows COM specifications - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - HRESULT hr; - - - if (IsEqualIID(InterfaceId, __uuidof(IQueueCallbackWrite))) - { - hr = S_OK; - *Object = QueryIQueueCallbackWrite(); - } - else if (IsEqualIID(InterfaceId, __uuidof(IQueueCallbackRead))) - { - hr = S_OK; - *Object = QueryIQueueCallbackRead(); - } - else if (IsEqualIID(InterfaceId, __uuidof(IRequestCallbackRequestCompletion))) - { - hr = S_OK; - *Object = QueryIRequestCallbackRequestCompletion(); - } - else if (IsEqualIID(InterfaceId, __uuidof(IQueueCallbackIoStop))) - { - hr = S_OK; - *Object = QueryIQueueCallbackIoStop(); - } - else - { - hr = CMyQueue::QueryInterface(InterfaceId, Object); - } - - return hr; -} - -// -// Initialize -// - -HRESULT -CMyReadWriteQueue::CreateInstance( - _In_ PCMyDevice Device, - _Out_ PCMyReadWriteQueue *Queue - ) -/*++ - -Routine Description: - - - CreateInstance creates an instance of the queue object. - -Aruments: - - ppUkwn - OUT parameter is an IUnknown interface to the queue object - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - PCMyReadWriteQueue queue; - HRESULT hr = S_OK; - - queue = new CMyReadWriteQueue(Device); - - if (NULL == queue) - { - hr = E_OUTOFMEMORY; - } - - // - // Call the queue callback object to initialize itself. This will create - // its partner queue framework object. - // - - if (SUCCEEDED(hr)) - { - hr = queue->Initialize(); - } - - if (SUCCEEDED(hr)) - { - *Queue = queue; - } - else - { - SAFE_RELEASE(queue); - } - - return hr; -} - -HRESULT -CMyReadWriteQueue::Initialize( - ) -{ - HRESULT hr; - - // - // First initialize the base class. This will create the partner FxIoQueue - // object and setup automatic forwarding of I/O controls. - // - - hr = __super::Initialize(WdfIoQueueDispatchParallel, - true, - true); - - // - // return the status. - // - - return hr; -} - -STDMETHODIMP_ (void) -CMyReadWriteQueue::OnWrite( - _In_ IWDFIoQueue *pWdfQueue, - _In_ IWDFIoRequest *pWdfRequest, - _In_ SIZE_T BytesToWrite - ) -/*++ - -Routine Description: - - - Write dispatch routine - IQueueCallbackWrite - -Aruments: - - pWdfQueue - Framework Queue instance - pWdfRequest - Framework Request instance - BytesToWrite - Lenth of bytes in the write buffer - - Allocate and copy data to local buffer -Return Value: - - VOID - ---*/ -{ - UNREFERENCED_PARAMETER(pWdfQueue); - - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_QUEUE, - "%!FUNC!: Queue %p Request %p BytesToTransfer %d\n", - this, - pWdfRequest, - (ULONG)(ULONG_PTR)BytesToWrite - ); - - HRESULT hr = S_OK; - IWDFMemory * pInputMemory = NULL; - IWDFUsbTargetPipe * pOutputPipe = m_Device->GetOutputPipe(); - - pWdfRequest->GetInputMemory(&pInputMemory); - - hr = pOutputPipe->FormatRequestForWrite( - pWdfRequest, - NULL, //pFile - pInputMemory, - NULL, //Memory offset - NULL //DeviceOffset - ); - - if (FAILED(hr)) - { - pWdfRequest->Complete(hr); - } - else - { - ForwardFormattedRequest(pWdfRequest, pOutputPipe); - } - - SAFE_RELEASE(pInputMemory); - - return; -} - -STDMETHODIMP_ (void) -CMyReadWriteQueue::OnRead( - _In_ IWDFIoQueue *pWdfQueue, - _In_ IWDFIoRequest *pWdfRequest, - _In_ SIZE_T BytesToRead - ) -/*++ - -Routine Description: - - - Read dispatch routine - IQueueCallbackRead - -Aruments: - - pWdfQueue - Framework Queue instance - pWdfRequest - Framework Request instance - BytesToRead - Lenth of bytes in the read buffer - - Copy available data into the read buffer -Return Value: - - VOID - ---*/ -{ - UNREFERENCED_PARAMETER(pWdfQueue); - - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_QUEUE, - "%!FUNC!: Queue %p Request %p BytesToTransfer %d\n", - this, - pWdfRequest, - (ULONG)(ULONG_PTR)BytesToRead - ); - - HRESULT hr = S_OK; - IWDFMemory * pOutputMemory = NULL; - - pWdfRequest->GetOutputMemory(&pOutputMemory); - - hr = m_Device->GetInputPipe()->FormatRequestForRead( - pWdfRequest, - NULL, //pFile - pOutputMemory, - NULL, //Memory offset - NULL //DeviceOffset - ); - - if (FAILED(hr)) - { - pWdfRequest->Complete(hr); - } - else - { - ForwardFormattedRequest(pWdfRequest, m_Device->GetInputPipe()); - } - - SAFE_RELEASE(pOutputMemory); - - return; -} - -STDMETHODIMP_ (void) -CMyReadWriteQueue::OnIoStop( - _In_ IWDFIoQueue * pWdfQueue, - _In_ IWDFIoRequest * pWdfRequest, - _In_ ULONG ActionFlags - ) -{ - UNREFERENCED_PARAMETER(pWdfQueue); - - - // - // Because of device level locking we know that if our driver - // owns the request and we get here, our OnRead/OnWrite callback - // has returned and the request has been sent to I/O target - // - - if (ActionFlags == WdfRequestStopActionSuspend ) - { - // - // UMDF does not support an equivalent to WdfRequestStopAcknowledge. - // - // Cancel the request so that the power management operation can continue. - // - // NOTE: if cancelling the request would have an adverse affect and if the - // requests are expected to complete very quickly then leaving the - // request running may be a better option. - // - - pWdfRequest->CancelSentRequest(); - } - else if(ActionFlags == WdfRequestStopActionPurge) - { - // - // Cancel the sent request since we are asked to purge the request - // - - pWdfRequest->CancelSentRequest(); - } - - return; -} - diff --git a/usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.h b/usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.h deleted file mode 100644 index 4f1a98c13..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/ReadWriteQueue.h +++ /dev/null @@ -1,163 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - queue.h - -Abstract: - - This file defines the queue callback interface. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - - -#define MAX_TRANSFER_SIZE(x) 64*1024*1024 - -// -// Queue Callback Object. -// - -class CMyReadWriteQueue : - public IQueueCallbackRead, - public IQueueCallbackWrite, - public IRequestCallbackRequestCompletion, - public IQueueCallbackIoStop, - public CMyQueue -{ -protected: - HRESULT - Initialize( - ); - - void - ForwardFormattedRequest( - _In_ IWDFIoRequest* pRequest, - _In_ IWDFIoTarget* pIoTarget - ); - -public: - - CMyReadWriteQueue( - _In_ PCMyDevice Device - ); - - virtual ~CMyReadWriteQueue(); - - static - HRESULT - CreateInstance( - _In_ PCMyDevice Device, - _Out_ PCMyReadWriteQueue *Queue - ); - - HRESULT - Configure( - VOID - ) - { - return CMyQueue::Configure(); - } - - IQueueCallbackWrite * - QueryIQueueCallbackWrite( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - IQueueCallbackRead * - QueryIQueueCallbackRead( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - IRequestCallbackRequestCompletion * - QueryIRequestCallbackRequestCompletion( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - IQueueCallbackIoStop* - QueryIQueueCallbackIoStop( - VOID - ) - { - AddRef(); - return static_cast(this); - } - - // - // IUnknown - // - - STDMETHOD_(ULONG,AddRef) (VOID) {return CUnknown::AddRef();} - - _At_(this, __drv_freesMem(object)) - STDMETHOD_(ULONG,Release) (VOID) {return CUnknown::Release();} - - STDMETHOD_(HRESULT, QueryInterface)( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - - // - // Wdf Callbacks - // - - // - // IQueueCallbackWrite - // - STDMETHOD_ (void, OnWrite)( - _In_ IWDFIoQueue *pWdfQueue, - _In_ IWDFIoRequest *pWdfRequest, - _In_ SIZE_T NumOfBytesToWrite - ); - - // - // IQueueCallbackRead - // - STDMETHOD_ (void, OnRead)( - _In_ IWDFIoQueue *pWdfQueue, - _In_ IWDFIoRequest *pWdfRequest, - _In_ SIZE_T NumOfBytesToRead - ); - - // - //IRequestCallbackRequestCompletion - // - - STDMETHOD_ (void, OnCompletion)( - _In_ IWDFIoRequest* pWdfRequest, - _In_ IWDFIoTarget* pIoTarget, - _In_ IWDFRequestCompletionParams* pParams, - _In_ PVOID pContext - ); - - // - //IQueueCallbackIoStop - // - - STDMETHOD_ (void, OnIoStop)( - _In_ IWDFIoQueue * pWdfQueue, - _In_ IWDFIoRequest * pWdfRequest, - _In_ ULONG ActionFlags - ); - -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx b/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.inx deleted file mode 100644 index 215e5f989eb1ffce76143c69a2c8744323653872..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5920 zcmb`L+fG|Y6o%)zQr}?@UP>{fB!ylKf9mY6IZx*?$ov1fjf31cf<3@o%8n1ZMu%zb~ShD zuH1lm>--LR9=WmWx{q81Pk*{T_hZ*~Z@8awf6Dzcv-(h5cc0wQ_57S3@0ae2|8BhX zuiu$_>%Wc|AHv}e|FzBA2j04H`OMnBYq%Bn0C^=*kC|WLQn({`!q*kQrioNtzK)pN z=IN8W=1adc_6&NLP-wWn-6OZ__S}YRx-GQbK;mt;!}DXFHn@5`ucOm0SBs}QSCij1 z813<8hdGboJMwb%8IkU-1QkP}0rf5S3;6H&e{tM#Yy8)y zzm17T!bY|jg46+ArE3FRKEr>&{0m0Mey-vCiuWr<2iz~FxZX?m8oO)=dJ;XCE{fxSo_DAzS#IEAM1HVU}zkS)@TOG?rgrdjhv9-l4!)6a%dSKhf z#<^F=wVlcMC7wUVD!2HiRz*H(G~B(;I6rqUpu0A?RdKPA@XlVfOi@WNBPS$VCA zZyn-CZSusPd&#wrR&V`(n~`J29uO-z)kX3K?Ss4<_+Epb;-?RtOQetwk3d5??;4pb zvsuiGwlZ&HsY_YaG*O<7IlAyXLYyp1Z81+tW}2s*%CTlqY(CP&qSyFav|(c+Z_M^# zjws8^FR-36lycQOZyT!{HUE47GRt4W@zCe_Ay|)jQ{_=^GsIOP28;}uqgp3V$hk?X zBi6`rsvG$n<+kOe2{R?t8+5$l9%^JjAtF_f8H!1yT6`DYdsOR81651YK-x)u)jq4y z0j>MktVX^5IybN6_D(Z!CzJ4g+}g;0GtK28UMx4|W5V6~kT+nUYWL0OO6AKsk*PDxh$n=B6_hylTR1)bMmJy{-`wtI-CAoo(H^r%dkA~g80%~+fxeY{+f=J*~-5 zHM&TmoX0Wp$PY}aDth;e7G;PWY0=N4CiDSSb7!MV*dz|=Ni2l^?!Y(Ao#5e^%S;VQ4bOGghFRjwvyGdW5ZlHya zs+O;?H>lI||4I*cPTn}@ZJoDs`Z?_gw)wV;zpta?7Jks>Y18io^j+Os&(9vx|+x(85tMuyf7sYNB+_irceH#+fszQ01hmsHk6 zpT&P?#Xps+_E@7;M^H+AF;t7YDuHPk@`*awTWD!-s9b1$Tj(KGd*;uy&Mmj#36!p< zRID4d9gjMZe00mpz7MkMMQ(hYT`@~<+DS`}KtcG23_9y2(MLkeNa`AS;+9{Eko?Pf zg~hdHF+!oI2}tEszu@2M7S!u5#weu|G}TTr$12RyT^#Si&E_wMUZ9yGXxix1Viv*b zESc`f%28CcN;zR(6xAnDWPA1>vx`ZyL6to7a=qyiqT$EL57>JYkr&gX#IL=BGu&S#4c6w&n z+4j(BPrFS$(IuZ$#?&tLHTf}QPVG}V@NWBjsSJ8VHhslC;Hg!McXMI1Ap7>gTzN&O zD$A}5>*wEt9NN_@kIAYZrrk=_sh7_1PSCZ*Z{2r`WA5eI=D&BHM$M;HwJOkDyh9hw z^sGd?>}dP)325}<0^0=2#%cDnWFGCfldx4G_Npt9s94R7XP~)^2gHK*o^~2y`(Qi2 zRW*?MM{cp=O2ZDoJC!E7}HAr*C!8b!>{o1k@h62eQA}7_=VHz6amxhf4AkL00000 diff --git a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj b/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj deleted file mode 100644 index ea987abd1..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj +++ /dev/null @@ -1,279 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {48343119-5771-494E-977E-0D439A45BF65} - $(MSBuildProjectName) - 1 - 1 - Debug - Win32 - {F45B07B6-EA19-4312-9BB3-5CF1BAFF50A8} - - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - False - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - Windows10 - True - Desktop - UMDF - WindowsUserModeDriver10.0 - DynamicLibrary - - - - $(IntDir) - - - - - - - - - - - - - - - - true - true - internal.h - - - true - true - internal.h - - - - WUDFOsrUsbFx2_4 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_4 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_4 - 0x0A00 - 0x0A000000 - - - WUDFOsrUsbFx2_4 - 0x0A00 - 0x0A000000 - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - true - Level4 - %(DisableSpecificWarnings);4201 - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - %(PreprocessorDefinitions);_UNICODE;UNICODE - - - _DllMainCRTStartup@12 - _DllMainCRTStartup - - - sha256 - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - - - %(AdditionalIncludeDirectories);..\..\inc;..\inc - - - %(AdditionalDependencies);$(SDK_LIB_PATH)\strsafe.lib;$(SDK_LIB_PATH)\kernel32.lib;$(SDK_LIB_PATH)\advapi32.lib - exports.def - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj.Filters b/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj.Filters deleted file mode 100644 index 43c2d8813..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/WUDFOsrUsbFx2_4.vcxproj.Filters +++ /dev/null @@ -1,52 +0,0 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {FFDE5D69-37F8-4393-A23B-564E903D88CD} - - - h;hpp;hxx;hm;inl;inc;xsd - {0B249192-6B94-4C90-BD54-09BDA2702DF1} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {080D7F17-64DE-4D25-95ED-5FB56D2F35D7} - - - inf;inv;inx;mof;mc; - {71EC47E9-66DB-49A4-A668-16475FA16BB4} - - - - - 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/usb/wdf_osrfx2_lab/umdf/step4/comsup.cpp b/usb/wdf_osrfx2_lab/umdf/step4/comsup.cpp deleted file mode 100644 index 9c9aec3b5..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/comsup.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.cpp - -Abstract: - - This module contains implementations for the functions and methods - used for providing COM support. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" - -#include "comsup.tmh" - -// -// Implementation of CUnknown methods. -// - -CUnknown::CUnknown( - VOID - ) : m_ReferenceCount(1) -/*++ - - Routine Description: - - Constructor for an instance of the CUnknown class. This simply initializes - the reference count of the object to 1. The caller is expected to - call Release() if it wants to delete the object once it has been allocated. - - Arguments: - - None - - Return Value: - - None - ---*/ -{ - // do nothing. -} - -HRESULT -STDMETHODCALLTYPE -CUnknown::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method provides the basic support for query interface on CUnknown. - If the interface requested is IUnknown it references the object and - returns an interface pointer. Otherwise it returns an error. - - Arguments: - - InterfaceId - the IID being requested - - Object - a location to store the interface pointer to return. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - if (IsEqualIID(InterfaceId, __uuidof(IUnknown))) - { - *Object = QueryIUnknown(); - return S_OK; - } - else - { - *Object = NULL; - return E_NOINTERFACE; - } -} - -IUnknown * -CUnknown::QueryIUnknown( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IUnknown interface. - - This allows other methods to convert a CUnknown pointer into an IUnknown - pointer without a typecast and without calling QueryInterface and dealing - with the return value. - - Arguments: - - None - - Return Value: - - A pointer to the object's IUnknown interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::AddRef( - VOID - ) -/*++ - - Routine Description: - - This method adds one to the object's reference count. - - Arguments: - - None - - Return Value: - - The new reference count. The caller should only use this for debugging - as the object's actual reference count can change while the caller - examines the return value. - ---*/ -{ - return InterlockedIncrement(&m_ReferenceCount); -} - -ULONG -STDMETHODCALLTYPE -CUnknown::Release( - VOID - ) -/*++ - - Routine Description: - - This method subtracts one to the object's reference count. If the count - goes to zero, this method deletes the object. - - Arguments: - - None - - Return Value: - - The new reference count. If the caller uses this value it should only be - to check for zero (i.e. this call caused or will cause deletion) or - non-zero (i.e. some other call may have caused deletion, but this one - didn't). - ---*/ -{ - ULONG count = InterlockedDecrement(&m_ReferenceCount); - - if (count == 0) - { - delete this; - } - return count; -} - -// -// Implementation of CClassFactory methods. -// - -// -// Define storage for the factory's static lock count variable. -// - -LONG CClassFactory::s_LockCount = 0; - -IClassFactory * -CClassFactory::QueryIClassFactory( - VOID - ) -/*++ - - Routine Description: - - This helper method references the object and returns a pointer to the - object's IClassFactory interface. - - This allows other methods to convert a CClassFactory pointer into an - IClassFactory pointer without a typecast and without dealing with the - return value QueryInterface. - - Arguments: - - None - - Return Value: - - A referenced pointer to the object's IClassFactory interface. - ---*/ -{ - AddRef(); - return static_cast(this); -} - -HRESULT -CClassFactory::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - - Routine Description: - - This method attempts to retrieve the requested interface from the object. - - If the interface is found then the reference count on that interface (and - thus the object itself) is incremented. - - Arguments: - - InterfaceId - the interface the caller is requesting. - - Object - a location to store the interface pointer. - - Return Value: - - S_OK or E_NOINTERFACE - ---*/ -{ - // - // This class only supports IClassFactory so check for that. - // - - if (IsEqualIID(InterfaceId, __uuidof(IClassFactory))) - { - *Object = QueryIClassFactory(); - return S_OK; - } - else - { - // - // See if the base class supports the interface. - // - - return CUnknown::QueryInterface(InterfaceId, Object); - } -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::CreateInstance( - _In_opt_ IUnknown * /* OuterObject */, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ) -/*++ - - Routine Description: - - This COM method is the factory routine - it creates instances of the driver - callback class and returns the specified interface on them. - - Arguments: - - OuterObject - only used for aggregation, which our driver callback class - does not support. - - InterfaceId - the interface ID the caller would like to get from our - new object. - - Object - a location to store the referenced interface pointer to the new - object. - - Return Value: - - Status. - ---*/ -{ - HRESULT hr; - - PCMyDriver driver; - - *Object = NULL; - - hr = CMyDriver::CreateInstance(&driver); - - if (SUCCEEDED(hr)) - { - hr = driver->QueryInterface(InterfaceId, Object); - driver->Release(); - } - - return hr; -} - -HRESULT -STDMETHODCALLTYPE -CClassFactory::LockServer( - _In_ BOOL Lock - ) -/*++ - - Routine Description: - - This COM method can be used to keep the DLL in memory. However since the - driver's DllCanUnloadNow function always returns false, this has little - effect. Still it tracks the number of lock and unlock operations. - - Arguments: - - Lock - Whether the caller wants to lock or unlock the "server" - - Return Value: - - S_OK - ---*/ -{ - if (Lock) - { - InterlockedIncrement(&s_LockCount); - } - else - { - InterlockedDecrement(&s_LockCount); - } - return S_OK; -} - diff --git a/usb/wdf_osrfx2_lab/umdf/step4/comsup.h b/usb/wdf_osrfx2_lab/umdf/step4/comsup.h deleted file mode 100644 index dedf78c84..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/comsup.h +++ /dev/null @@ -1,215 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - ComSup.h - -Abstract: - - This module contains classes and functions use for providing COM support - code. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Forward type declarations. They are here rather than in internal.h as -// you only need them if you choose to use these support classes. -// - -typedef class CUnknown *PCUnknown; -typedef class CClassFactory *PCClassFactory; - -// -// Base class to implement IUnknown. You can choose to derive your COM -// classes from this class, or simply implement IUnknown in each of your -// classes. -// - -class CUnknown : public IUnknown -{ - -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The reference count for this object. Initialized to 1 in the - // constructor. - // - - LONG m_ReferenceCount; - -// -// Protected data members and methods. These are accessible by the subclasses -// but not by other classes. -// -protected: - - // - // The constructor and destructor are protected to ensure that only the - // subclasses of CUnknown can create and destroy instances. - // - - CUnknown( - VOID - ); - - // - // The destructor MUST be virtual. Since any instance of a CUnknown - // derived class should only be deleted from within CUnknown::Release, - // the destructor MUST be virtual or only CUnknown::~CUnknown will get - // invoked on deletion. - // - // If you see that your CMyDevice specific destructor is never being - // called, make sure you haven't deleted the virtual destructor here. - // - - virtual - ~CUnknown( - VOID - ) - { - // Do nothing - } - -// -// Public Methods. These are accessible by any class. -// -public: - - IUnknown * - QueryIUnknown( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ); - - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ); - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; - -// -// Class factory support class. Create an instance of this from your -// DllGetClassObject method and modify the implementation to create -// an instance of your driver event handler class. -// - -class CClassFactory : public CUnknown, public IClassFactory -{ -// -// Private data members and methods. These are only accessible by the methods -// of this class. -// -private: - - // - // The lock count. This is shared across all instances of IClassFactory - // and can be queried through the public IsLocked method. - // - - static LONG s_LockCount; - -// -// Public Methods. These are accessible by any class. -// -public: - - IClassFactory * - QueryIClassFactory( - VOID - ); - -// -// COM Methods. -// -public: - - // - // IUnknown methods - // - - virtual - ULONG - STDMETHODCALLTYPE - AddRef( - VOID - ) - { - return __super::AddRef(); - } - - _At_(this, __drv_freesMem(object)) - virtual - ULONG - STDMETHODCALLTYPE - Release( - VOID - ) - { - return __super::Release(); - } - - virtual - HRESULT - STDMETHODCALLTYPE - QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); - - // - // IClassFactory methods. - // - - virtual - HRESULT - STDMETHODCALLTYPE - CreateInstance( - _In_opt_ IUnknown *OuterObject, - _In_ REFIID InterfaceId, - _Out_ PVOID *Object - ); - - virtual - HRESULT - STDMETHODCALLTYPE - LockServer( - _In_ BOOL Lock - ); -}; diff --git a/usb/wdf_osrfx2_lab/umdf/step4/dllsup.cpp b/usb/wdf_osrfx2_lab/umdf/step4/dllsup.cpp deleted file mode 100644 index bd681ac22..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/dllsup.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved. - -Module Name: - - dllsup.cpp - -Abstract: - - This module contains the implementation of the UMDF Skeleton Sample - Driver's entry point and its exported functions for providing COM support. - - This module can be copied without modification to a new UMDF driver. It - depends on some of the code in comsup.cpp & comsup.h to handle DLL - registration and creating the first class factory. - - This module is dependent on the following defines: - - MYDRIVER_TRACING_ID - A wide string passed to WPP when initializing - tracing. For example the skeleton uses - L"Microsoft\\UMDF\\Skeleton" - - MYDRIVER_CLASS_ID - A GUID encoded in struct format used to - initialize the driver's ClassID. - - These are defined in internal.h for the skeleton sample. If you choose - to use a different primary include file, you should ensure they are - defined there as well. - -Environment: - - WDF User-Mode Driver Framework (WDF:UMDF) - ---*/ - -#include "internal.h" -#include "dllsup.tmh" - -const GUID CLSID_MyDriverCoClass = MYDRIVER_CLASS_ID; - -BOOL -WINAPI -DllMain( - HINSTANCE ModuleHandle, - DWORD Reason, - PVOID /* Reserved */ - ) -/*++ - - Routine Description: - - This is the entry point and exit point for the I/O trace driver. This - does very little as the I/O trace driver has minimal global data. - - This method initializes tracing, and saves the module handle away in a - global variable so that it can be referenced should the COM registration - code (Dll[Un]RegisterServer) be called. - - Arguments: - - ModuleHandle - the DLL handle for this module. - - Reason - the reason this entry point was called. - - Reserved - unused - - Return Value: - - TRUE - ---*/ -{ - UNREFERENCED_PARAMETER(ModuleHandle); - - if (DLL_PROCESS_ATTACH == Reason) - { - // - // Initialize tracing. - // - - WPP_INIT_TRACING(MYDRIVER_TRACING_ID); - } - else if (DLL_PROCESS_DETACH == Reason) - { - // - // Cleanup tracing. - // - - WPP_CLEANUP(); - } - - return TRUE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllCanUnloadNow( - VOID - ) -/*++ - - Routine Description: - - Called by the COM runtime when determining whether or not this module - can be unloaded. Our answer is always "no". - - Arguments: - - None - - Return Value: - - S_FALSE - ---*/ -{ - return S_FALSE; -} - -_Use_decl_annotations_ -HRESULT -STDAPICALLTYPE -DllGetClassObject( - REFCLSID ClassId, - REFIID InterfaceId, - LPVOID *Interface - ) -/*++ - - Routine Description: - - This routine is called by COM in order to instantiate the - skeleton driver callback object and do an initial query interface on it. - - This method only creates an instance of the driver's class factory, as this - is the minimum required to support UMDF. - - Arguments: - - ClassId - the CLSID of the object being "gotten" - - InterfaceId - the interface the caller wants from that object. - - Interface - a location to store the referenced interface pointer - - Return Value: - - S_OK if the function succeeds or error indicating the cause of the - failure. - ---*/ -{ - PCClassFactory factory; - - HRESULT hr = S_OK; - - *Interface = NULL; - - // - // If the CLSID doesn't match that of our "coclass" (defined in the IDL - // file) then we can't create the object the caller wants. This may - // indicate that the COM registration is incorrect, and another CLSID - // is referencing this drvier. - // - - if (IsEqualCLSID(ClassId, CLSID_MyDriverCoClass) == false) - { - Trace( - TRACE_LEVEL_ERROR, - L"ERROR: Called to create instance of unrecognized class (%!GUID!)", - &ClassId - ); - - return CLASS_E_CLASSNOTAVAILABLE; - } - - // - // Create an instance of the class factory for the caller. - // - - factory = new CClassFactory(); - - if (NULL == factory) - { - hr = E_OUTOFMEMORY; - } - - // - // Query the object we created for the interface the caller wants. After - // that we release the object. This will drive the reference count to - // 1 (if the QI succeeded an referenced the object) or 0 (if the QI failed). - // In the later case the object is automatically deleted. - // - - if (SUCCEEDED(hr)) - { - hr = factory->QueryInterface(InterfaceId, Interface); - factory->Release(); - } - - return hr; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step4/exports.def b/usb/wdf_osrfx2_lab/umdf/step4/exports.def deleted file mode 100644 index 15f923d3b..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/exports.def +++ /dev/null @@ -1,4 +0,0 @@ -; WudfOsrUsbDriver.def : Declares the module parameters. - -EXPORTS - DllGetClassObject PRIVATE diff --git a/usb/wdf_osrfx2_lab/umdf/step4/internal.h b/usb/wdf_osrfx2_lab/umdf/step4/internal.h deleted file mode 100644 index 86487dd90..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/internal.h +++ /dev/null @@ -1,154 +0,0 @@ -/*++ - -Copyright (C) Microsoft Corporation, All Rights Reserved - -Module Name: - - Internal.h - -Abstract: - - This module contains the local type definitions for the UMDF Skeleton - driver sample. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -// -// Include the WUDF Headers -// - -#include "wudfddi.h" - -// -// Use specstrings for in/out annotation of function parameters. -// - -#include "specstrings.h" - -// -// Get limits on common data types (ULONG_MAX for example) -// - -#include "limits.h" - -// -// We need usb I/O targets to talk to the OSR device. -// - -#include "wudfusb.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "public.h" - -// -// Include the header shared between the drivers and the test applications. -// - -#include "WUDFOsrUsbPublic.h" - -// -// Forward definitions of classes in the other header files. -// - -typedef class CMyDriver *PCMyDriver; -typedef class CMyDevice *PCMyDevice; -typedef class CMyQueue *PCMyQueue; - -typedef class CMyControlQueue *PCMyControlQueue; -typedef class CMyReadWriteQueue *PCMyReadWriteQueue; - -// -// Define the tracing flags. -// -// TODO: Choose a different trace control GUID -// - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - WudfOsrUsbFx2TraceGuid, (da5fbdfd,1eae,4ecf,b426,a3818f325ddb), \ - \ - WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \ - WPP_DEFINE_BIT(TEST_TRACE_DRIVER) \ - WPP_DEFINE_BIT(TEST_TRACE_DEVICE) \ - WPP_DEFINE_BIT(TEST_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) - -// -// This comment block is scanned by the trace preprocessor to define our -// Trace function. -// -// begin_wpp config -// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); -// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); -// end_wpp -// - -// -// Driver specific #defines -// -// TODO: Change these values to be appropriate for your driver. -// - -#define MYDRIVER_TRACING_ID L"Microsoft\\UMDF\\OsrUsb" -#define MYDRIVER_CLASS_ID {0x0865b2b0, 0x6b73, 0x428f, {0xa3, 0xea, 0x21, 0x72, 0x83, 0x2d, 0x6b, 0xfc}} - -// -// Include the type specific headers. -// - -#include "comsup.h" -#include "driver.h" -#include "device.h" -#include "queue.h" -#include "ControlQueue.h" -#include "ReadWriteQueue.h" -#include "list.h" - -__forceinline -#ifdef _PREFAST_ -__declspec(noreturn) -#endif -VOID -WdfTestNoReturn( - VOID - ) -{ - // do nothing. -} - -#define WUDF_TEST_DRIVER_ASSERT(p) \ -{ \ - if ( !(p) ) \ - { \ - DebugBreak(); \ - WdfTestNoReturn(); \ - } \ -} - -#define SAFE_RELEASE(p) {if ((p)) { (p)->Release(); (p) = NULL; }} diff --git a/usb/wdf_osrfx2_lab/umdf/step4/queue.cpp b/usb/wdf_osrfx2_lab/umdf/step4/queue.cpp deleted file mode 100644 index c56b38bbc..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/queue.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - queue.cpp - -Abstract: - - This file implements the I/O queue interface and performs - the read/write/ioctl operations. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#include "internal.h" -#include "queue.tmh" - -CMyQueue::CMyQueue( - _In_ PCMyDevice Device - ) : - m_FxQueue(NULL), - m_Device(Device) -{ -} - -// -// Queue destructor. -// Free up the buffer, wait for thread to terminate and -// - -CMyQueue::~CMyQueue( - VOID - ) -/*++ - -Routine Description: - - - IUnknown implementation of Release - -Aruments: - - -Return Value: - - ULONG (reference count after Release) - ---*/ -{ - TraceEvents(TRACE_LEVEL_INFORMATION, - TEST_TRACE_QUEUE, - "%!FUNC! Entry" - ); - -} - - -HRESULT -STDMETHODCALLTYPE -CMyQueue::QueryInterface( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ) -/*++ - -Routine Description: - - - Query Interface - -Aruments: - - Follows COM specifications - -Return Value: - - HRESULT indicatin success or failure - ---*/ -{ - HRESULT hr; - - hr = CUnknown::QueryInterface(InterfaceId, Object); - - return hr; -} - -// -// Initialize -// - -HRESULT -CMyQueue::Initialize( - _In_ WDF_IO_QUEUE_DISPATCH_TYPE DispatchType, - _In_ bool Default, - _In_ bool PowerManaged - ) -{ - IWDFIoQueue *fxQueue; - HRESULT hr; - - // - // Create the I/O Queue object. - // - - { - IUnknown *callback = QueryIUnknown(); - - hr = m_Device->GetFxDevice()->CreateIoQueue( - callback, - Default, - DispatchType, - PowerManaged, - FALSE, - &fxQueue - ); - callback->Release(); - } - - if (SUCCEEDED(hr)) - { - m_FxQueue = fxQueue; - - // - // Release the creation reference on the queue. This object will be - // destroyed before the queue so we don't need to have a reference out - // on it. - // - - fxQueue->Release(); - } - - return hr; -} - -HRESULT -CMyQueue::Configure( - VOID - ) -{ - return S_OK; -} diff --git a/usb/wdf_osrfx2_lab/umdf/step4/queue.h b/usb/wdf_osrfx2_lab/umdf/step4/queue.h deleted file mode 100644 index 5659224bb..000000000 --- a/usb/wdf_osrfx2_lab/umdf/step4/queue.h +++ /dev/null @@ -1,93 +0,0 @@ -/*++ - -Copyright (c) Microsoft Corporation, All Rights Reserved - -Module Name: - - queue.h - -Abstract: - - This file defines the queue callback interface. - -Environment: - - Windows User-Mode Driver Framework (WUDF) - ---*/ - -#pragma once - -// -// Queue Callback Object. -// - -class CMyQueue : - public CUnknown -{ -protected: - // - // Unreferenced pointer to the partner Fx device. - // - - IWDFIoQueue *m_FxQueue; - - // - // Unreferenced pointer to the parent device. - // - - PCMyDevice m_Device; - - HRESULT - Initialize( - _In_ WDF_IO_QUEUE_DISPATCH_TYPE DispatchType, - _In_ bool Default, - _In_ bool PowerManaged - ); - -protected: - - CMyQueue( - _In_ PCMyDevice Device - ); - - virtual ~CMyQueue(); - - HRESULT - Configure( - VOID - ); - -public: - - IWDFIoQueue * - GetFxQueue( - VOID - ) - { - return m_FxQueue; - } - - - PCMyDevice - GetDevice( - VOID - ) - { - return m_Device; - } - - // - // IUnknown - // - - STDMETHOD_(ULONG,AddRef) (VOID) {return CUnknown::AddRef();} - - _At_(this, __drv_freesMem(object)) - STDMETHOD_(ULONG,Release) (VOID) {return CUnknown::Release();} - - STDMETHOD_(HRESULT, QueryInterface)( - _In_ REFIID InterfaceId, - _Outptr_ PVOID *Object - ); -}; diff --git a/usb/wdf_osrfx2_lab/wdf_osrfx2_lab.sln b/usb/wdf_osrfx2_lab/wdf_osrfx2_lab.sln index 105c66432..13795799c 100644 --- a/usb/wdf_osrfx2_lab/wdf_osrfx2_lab.sln +++ b/usb/wdf_osrfx2_lab/wdf_osrfx2_lab.sln @@ -17,18 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Step5", "Step5", "{20339A89 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exe", "Exe", "{BC1A657D-F736-42B1-8B6F-65660268D1E4}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Step1", "Step1", "{5B8D9AE9-CD64-4BDE-924B-85E2CFF7AC6D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Umdf", "Umdf", "{891C089F-780C-4983-8C50-1A1C9BEB0593}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Step2", "Step2", "{9C88D019-1CD4-44BD-8355-75C0F1A0D348}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Step3", "Step3", "{F9F19F6E-0B8B-4ED0-BA15-75455AC110D4}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Step4", "Step4", "{852E07AA-FE41-404F-BE25-30B5BCE596B7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Exe", "Exe", "{CAFB7E8F-109E-4224-BD53-EE93946311DF}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrusbfx2", "kmdf\step1\osrusbfx2.vcxproj", "{E54BDD18-FDE9-42BF-BC23-343F8764B387}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrusbfx2", "kmdf\step2\osrusbfx2.vcxproj", "{CE2CAF81-E96B-4C32-9BE9-58238742D295}" @@ -41,16 +29,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrusbfx2", "kmdf\step5\osr EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osrusbfx2", "kmdf\exe\osrusbfx2.vcxproj", "{6EED5CDD-5526-40DC-97F9-582857E10187}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WUDFOsrUsbFx2_1", "umdf\step1\WUDFOsrUsbFx2_1.vcxproj", "{94BDC8D1-B62F-4200-9873-D403B6D30301}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WUDFOsrUsbFx2_2", "umdf\step2\WUDFOsrUsbFx2_2.vcxproj", "{808B6774-93FA-4ABF-A23F-35C55FA80B80}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WUDFOsrUsbFx2_3", "umdf\step3\WUDFOsrUsbFx2_3.vcxproj", "{4BED411D-1B55-4A64-84C9-36EC25F083D2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WUDFOsrUsbFx2_4", "umdf\step4\WUDFOsrUsbFx2_4.vcxproj", "{48343119-5771-494E-977E-0D439A45BF65}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WudfOsrUsbFx2Test", "umdf\exe\WudfOsrUsbFx2Test.vcxproj", "{B4244D54-7EBF-43D4-BB6D-C994C182C572}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -107,46 +85,6 @@ Global {6EED5CDD-5526-40DC-97F9-582857E10187}.Debug|x64.Build.0 = Debug|x64 {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|x64.ActiveCfg = Release|x64 {6EED5CDD-5526-40DC-97F9-582857E10187}.Release|x64.Build.0 = Release|x64 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Debug|Win32.ActiveCfg = Debug|Win32 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Debug|Win32.Build.0 = Debug|Win32 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Release|Win32.ActiveCfg = Release|Win32 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Release|Win32.Build.0 = Release|Win32 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Debug|x64.ActiveCfg = Debug|x64 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Debug|x64.Build.0 = Debug|x64 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Release|x64.ActiveCfg = Release|x64 - {94BDC8D1-B62F-4200-9873-D403B6D30301}.Release|x64.Build.0 = Release|x64 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Debug|Win32.ActiveCfg = Debug|Win32 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Debug|Win32.Build.0 = Debug|Win32 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Release|Win32.ActiveCfg = Release|Win32 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Release|Win32.Build.0 = Release|Win32 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Debug|x64.ActiveCfg = Debug|x64 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Debug|x64.Build.0 = Debug|x64 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Release|x64.ActiveCfg = Release|x64 - {808B6774-93FA-4ABF-A23F-35C55FA80B80}.Release|x64.Build.0 = Release|x64 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Debug|Win32.ActiveCfg = Debug|Win32 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Debug|Win32.Build.0 = Debug|Win32 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Release|Win32.ActiveCfg = Release|Win32 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Release|Win32.Build.0 = Release|Win32 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Debug|x64.ActiveCfg = Debug|x64 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Debug|x64.Build.0 = Debug|x64 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Release|x64.ActiveCfg = Release|x64 - {4BED411D-1B55-4A64-84C9-36EC25F083D2}.Release|x64.Build.0 = Release|x64 - {48343119-5771-494E-977E-0D439A45BF65}.Debug|Win32.ActiveCfg = Debug|Win32 - {48343119-5771-494E-977E-0D439A45BF65}.Debug|Win32.Build.0 = Debug|Win32 - {48343119-5771-494E-977E-0D439A45BF65}.Release|Win32.ActiveCfg = Release|Win32 - {48343119-5771-494E-977E-0D439A45BF65}.Release|Win32.Build.0 = Release|Win32 - {48343119-5771-494E-977E-0D439A45BF65}.Debug|x64.ActiveCfg = Debug|x64 - {48343119-5771-494E-977E-0D439A45BF65}.Debug|x64.Build.0 = Debug|x64 - {48343119-5771-494E-977E-0D439A45BF65}.Release|x64.ActiveCfg = Release|x64 - {48343119-5771-494E-977E-0D439A45BF65}.Release|x64.Build.0 = Release|x64 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Debug|Win32.ActiveCfg = Debug|Win32 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Debug|Win32.Build.0 = Debug|Win32 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Release|Win32.ActiveCfg = Release|Win32 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Release|Win32.Build.0 = Release|Win32 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Debug|x64.ActiveCfg = Debug|x64 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Debug|x64.Build.0 = Debug|x64 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Release|x64.ActiveCfg = Release|x64 - {B4244D54-7EBF-43D4-BB6D-C994C182C572}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -158,21 +96,11 @@ Global {AE6270A1-FAC6-45B2-A641-9BFAF534DD01} = {A9C9BC25-9393-405C-A366-B7F457CAD629} {EEB5FBCF-333A-4D54-B937-C24FB0CC10EB} = {20339A89-50EB-4567-9AD9-BF3B2484D1EA} {6EED5CDD-5526-40DC-97F9-582857E10187} = {BC1A657D-F736-42B1-8B6F-65660268D1E4} - {94BDC8D1-B62F-4200-9873-D403B6D30301} = {5B8D9AE9-CD64-4BDE-924B-85E2CFF7AC6D} - {808B6774-93FA-4ABF-A23F-35C55FA80B80} = {9C88D019-1CD4-44BD-8355-75C0F1A0D348} - {4BED411D-1B55-4A64-84C9-36EC25F083D2} = {F9F19F6E-0B8B-4ED0-BA15-75455AC110D4} - {48343119-5771-494E-977E-0D439A45BF65} = {852E07AA-FE41-404F-BE25-30B5BCE596B7} - {B4244D54-7EBF-43D4-BB6D-C994C182C572} = {CAFB7E8F-109E-4224-BD53-EE93946311DF} {D00328D3-8C3F-4702-B819-5A3830E7FA70} = {EA42BA41-FC92-4985-80CA-B8BAC85DA33D} {46FAA529-1596-416E-82DA-C7BE08A96774} = {EA42BA41-FC92-4985-80CA-B8BAC85DA33D} {DB521009-ED4B-48E6-85CE-9C5B8B6CA915} = {EA42BA41-FC92-4985-80CA-B8BAC85DA33D} {A9C9BC25-9393-405C-A366-B7F457CAD629} = {EA42BA41-FC92-4985-80CA-B8BAC85DA33D} {20339A89-50EB-4567-9AD9-BF3B2484D1EA} = {EA42BA41-FC92-4985-80CA-B8BAC85DA33D} {BC1A657D-F736-42B1-8B6F-65660268D1E4} = {EA42BA41-FC92-4985-80CA-B8BAC85DA33D} - {5B8D9AE9-CD64-4BDE-924B-85E2CFF7AC6D} = {891C089F-780C-4983-8C50-1A1C9BEB0593} - {9C88D019-1CD4-44BD-8355-75C0F1A0D348} = {891C089F-780C-4983-8C50-1A1C9BEB0593} - {F9F19F6E-0B8B-4ED0-BA15-75455AC110D4} = {891C089F-780C-4983-8C50-1A1C9BEB0593} - {852E07AA-FE41-404F-BE25-30B5BCE596B7} = {891C089F-780C-4983-8C50-1A1C9BEB0593} - {CAFB7E8F-109E-4224-BD53-EE93946311DF} = {891C089F-780C-4983-8C50-1A1C9BEB0593} EndGlobalSection EndGlobal