24#ifndef __GNU_EXTENSION
26#define __GNU_EXTENSION __extension__
28#define __GNU_EXTENSION
33#pragma message("WARNING: OSR21_COMPAT SWITCH NOT SUPPORTED")
43#define USBDI_VERSION 0x00000500
47#define USB_PORTATTR_NO_CONNECTOR 0x00000001
48#define USB_PORTATTR_SHARED_USB2 0x00000002
49#define USB_PORTATTR_MINI_CONNECTOR 0x00000004
50#define USB_PORTATTR_OEM_CONNECTOR 0x00000008
51#define USB_PORTATTR_OWNED_BY_CC 0x01000000
52#define USB_PORTATTR_NO_OVERCURRENT_UI 0x02000000
82#define USB_DEFAULT_DEVICE_ADDRESS 0
83#define USB_DEFAULT_ENDPOINT_ADDRESS 0
84#define USB_DEFAULT_MAX_PACKET 64
85#define URB_FROM_IRP(Irp) ((IoGetCurrentIrpStackLocation(Irp))->Parameters.Others.Argument1)
86#define URB_FUNCTION_SELECT_CONFIGURATION 0x0000
87#define URB_FUNCTION_SELECT_INTERFACE 0x0001
88#define URB_FUNCTION_ABORT_PIPE 0x0002
89#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL 0x0003
90#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL 0x0004
91#define URB_FUNCTION_GET_FRAME_LENGTH 0x0005
92#define URB_FUNCTION_SET_FRAME_LENGTH 0x0006
93#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER 0x0007
94#define URB_FUNCTION_CONTROL_TRANSFER 0x0008
95#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER 0x0009
96#define URB_FUNCTION_ISOCH_TRANSFER 0x000A
97#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE 0x000B
98#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE 0x000C
99#define URB_FUNCTION_SET_FEATURE_TO_DEVICE 0x000D
100#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE 0x000E
101#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT 0x000F
102#define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE 0x0010
103#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE 0x0011
104#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT 0x0012
105#define URB_FUNCTION_GET_STATUS_FROM_DEVICE 0x0013
106#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE 0x0014
107#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT 0x0015
108#define URB_FUNCTION_RESERVED_0X0016 0x0016
109#define URB_FUNCTION_VENDOR_DEVICE 0x0017
110#define URB_FUNCTION_VENDOR_INTERFACE 0x0018
111#define URB_FUNCTION_VENDOR_ENDPOINT 0x0019
112#define URB_FUNCTION_CLASS_DEVICE 0x001A
113#define URB_FUNCTION_CLASS_INTERFACE 0x001B
114#define URB_FUNCTION_CLASS_ENDPOINT 0x001C
115#define URB_FUNCTION_RESERVE_0X001D 0x001D
116#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E
117#define URB_FUNCTION_CLASS_OTHER 0x001F
118#define URB_FUNCTION_VENDOR_OTHER 0x0020
119#define URB_FUNCTION_GET_STATUS_FROM_OTHER 0x0021
120#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER 0x0022
121#define URB_FUNCTION_SET_FEATURE_TO_OTHER 0x0023
122#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT 0x0024
123#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT 0x0025
124#define URB_FUNCTION_GET_CONFIGURATION 0x0026
125#define URB_FUNCTION_GET_INTERFACE 0x0027
126#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE 0x0028
127#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE 0x0029
129#if (_WIN32_WINNT >= 0x0501)
131#define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR 0x002A
132#define URB_FUNCTION_SYNC_RESET_PIPE 0x0030
133#define URB_FUNCTION_SYNC_CLEAR_STALL 0x0031
137#if (_WIN32_WINNT >= 0x0600)
139#define URB_FUNCTION_CONTROL_TRANSFER_EX 0x0032
140#define URB_FUNCTION_RESERVE_0X0033 0x0033
141#define URB_FUNCTION_RESERVE_0X0034 0x0034
145#define URB_FUNCTION_RESERVE_0X002B 0x002B
146#define URB_FUNCTION_RESERVE_0X002C 0x002C
147#define URB_FUNCTION_RESERVE_0X002D 0x002D
148#define URB_FUNCTION_RESERVE_0X002E 0x002E
149#define URB_FUNCTION_RESERVE_0X002F 0x002F
151#define URB_FUNCTION_RESET_PIPE URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
153#define USBD_TRANSFER_DIRECTION 0x00000001
154#define USBD_SHORT_TRANSFER_OK 0x00000002
155#define USBD_START_ISO_TRANSFER_ASAP 0x00000004
156#define USBD_DEFAULT_PIPE_TRANSFER 0x00000008
157#define USBD_TRANSFER_DIRECTION_FLAG(flags) ((flags) & USBD_TRANSFER_DIRECTION)
159#define USBD_TRANSFER_DIRECTION_OUT 0
160#define USBD_TRANSFER_DIRECTION_IN 1
161#define VALID_TRANSFER_FLAGS_MASK (USBD_SHORT_TRANSFER_OK | USBD_TRANSFER_DIRECTION | \
162 USBD_START_ISO_TRANSFER_ASAP | USBD_DEFAULT_PIPE_TRANSFER)
163#define USBD_ISO_START_FRAME_RANGE 1024
167#define USBD_SUCCESS(Status) ((USBD_STATUS)(Status) >= 0)
168#define USBD_PENDING(Status) ((ULONG)(Status) >> 30 == 1)
169#define USBD_ERROR(Status) ((USBD_STATUS)(Status) < 0)
170#define USBD_STATUS_SUCCESS ((USBD_STATUS)0x00000000L)
171#define USBD_STATUS_PENDING ((USBD_STATUS)0x40000000L)
172#define USBD_STATUS_CRC ((USBD_STATUS)0xC0000001L)
173#define USBD_STATUS_BTSTUFF ((USBD_STATUS)0xC0000002L)
174#define USBD_STATUS_DATA_TOGGLE_MISMATCH ((USBD_STATUS)0xC0000003L)
175#define USBD_STATUS_STALL_PID ((USBD_STATUS)0xC0000004L)
176#define USBD_STATUS_DEV_NOT_RESPONDING ((USBD_STATUS)0xC0000005L)
177#define USBD_STATUS_PID_CHECK_FAILURE ((USBD_STATUS)0xC0000006L)
178#define USBD_STATUS_UNEXPECTED_PID ((USBD_STATUS)0xC0000007L)
179#define USBD_STATUS_DATA_OVERRUN ((USBD_STATUS)0xC0000008L)
180#define USBD_STATUS_DATA_UNDERRUN ((USBD_STATUS)0xC0000009L)
181#define USBD_STATUS_RESERVED1 ((USBD_STATUS)0xC000000AL)
182#define USBD_STATUS_RESERVED2 ((USBD_STATUS)0xC000000BL)
183#define USBD_STATUS_BUFFER_OVERRUN ((USBD_STATUS)0xC000000CL)
184#define USBD_STATUS_BUFFER_UNDERRUN ((USBD_STATUS)0xC000000DL)
185#define USBD_STATUS_NOT_ACCESSED ((USBD_STATUS)0xC000000FL)
186#define USBD_STATUS_FIFO ((USBD_STATUS)0xC0000010L)
187#define USBD_STATUS_XACT_ERROR ((USBD_STATUS)0xC0000011L)
188#define USBD_STATUS_BABBLE_DETECTED ((USBD_STATUS)0xC0000012L)
189#define USBD_STATUS_DATA_BUFFER_ERROR ((USBD_STATUS)0xC0000013L)
190#define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS)0xC0000030L)
191#define USBD_STATUS_INVALID_URB_FUNCTION ((USBD_STATUS)0x80000200L)
192#define USBD_STATUS_INVALID_PARAMETER ((USBD_STATUS)0x80000300L)
193#define USBD_STATUS_ERROR_BUSY ((USBD_STATUS)0x80000400L)
194#define USBD_STATUS_INVALID_PIPE_HANDLE ((USBD_STATUS)0x80000600L)
195#define USBD_STATUS_NO_BANDWIDTH ((USBD_STATUS)0x80000700L)
196#define USBD_STATUS_INTERNAL_HC_ERROR ((USBD_STATUS)0x80000800L)
197#define USBD_STATUS_ERROR_SHORT_TRANSFER ((USBD_STATUS)0x80000900L)
198#define USBD_STATUS_BAD_START_FRAME ((USBD_STATUS)0xC0000A00L)
199#define USBD_STATUS_ISOCH_REQUEST_FAILED ((USBD_STATUS)0xC0000B00L)
200#define USBD_STATUS_FRAME_CONTROL_OWNED ((USBD_STATUS)0xC0000C00L)
201#define USBD_STATUS_FRAME_CONTROL_NOT_OWNED ((USBD_STATUS)0xC0000D00L)
202#define USBD_STATUS_NOT_SUPPORTED ((USBD_STATUS)0xC0000E00L)
203#define USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR ((USBD_STATUS)0xC0000F00L)
204#define USBD_STATUS_INSUFFICIENT_RESOURCES ((USBD_STATUS)0xC0001000L)
205#define USBD_STATUS_SET_CONFIG_FAILED ((USBD_STATUS)0xC0002000L)
206#define USBD_STATUS_BUFFER_TOO_SMALL ((USBD_STATUS)0xC0003000L)
207#define USBD_STATUS_INTERFACE_NOT_FOUND ((USBD_STATUS)0xC0004000L)
208#define USBD_STATUS_INVALID_PIPE_FLAGS ((USBD_STATUS)0xC0005000L)
209#define USBD_STATUS_TIMEOUT ((USBD_STATUS)0xC0006000L)
210#define USBD_STATUS_DEVICE_GONE ((USBD_STATUS)0xC0007000L)
211#define USBD_STATUS_STATUS_NOT_MAPPED ((USBD_STATUS)0xC0008000L)
212#define USBD_STATUS_HUB_INTERNAL_ERROR ((USBD_STATUS)0xC0009000L)
213#define USBD_STATUS_CANCELED ((USBD_STATUS)0xC0010000L)
214#define USBD_STATUS_ISO_NOT_ACCESSED_BY_HW ((USBD_STATUS)0xC0020000L)
215#define USBD_STATUS_ISO_TD_ERROR ((USBD_STATUS)0xC0030000L)
216#define USBD_STATUS_ISO_NA_LATE_USBPORT ((USBD_STATUS)0xC0040000L)
217#define USBD_STATUS_ISO_NOT_ACCESSED_LATE ((USBD_STATUS)0xC0050000L)
218#define USBD_STATUS_BAD_DESCRIPTOR ((USBD_STATUS)0xC0100000L)
219#define USBD_STATUS_BAD_DESCRIPTOR_BLEN ((USBD_STATUS)0xC0100001L)
220#define USBD_STATUS_BAD_DESCRIPTOR_TYPE ((USBD_STATUS)0xC0100002L)
221#define USBD_STATUS_BAD_INTERFACE_DESCRIPTOR ((USBD_STATUS)0xC0100003L)
222#define USBD_STATUS_BAD_ENDPOINT_DESCRIPTOR ((USBD_STATUS)0xC0100004L)
223#define USBD_STATUS_BAD_INTERFACE_ASSOC_DESCRIPTOR ((USBD_STATUS)0xC0100005L)
224#define USBD_STATUS_BAD_CONFIG_DESC_LENGTH ((USBD_STATUS)0xC0100006L)
225#define USBD_STATUS_BAD_NUMBER_OF_INTERFACES ((USBD_STATUS)0xC0100007L)
226#define USBD_STATUS_BAD_NUMBER_OF_ENDPOINTS ((USBD_STATUS)0xC0100008L)
227#define USBD_STATUS_BAD_ENDPOINT_ADDRESS ((USBD_STATUS)0xC0100009L)
233#if (_WIN32_WINNT >= 0x0501)
234#define USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE 0xFFFFFFFF
236#define USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE PAGE_SIZE
251#define USBD_PIPE_DIRECTION_IN(pipeInformation) ((pipeInformation)->EndpointAddress & USB_ENDPOINT_DIRECTION_MASK)
269#define USBD_PF_CHANGE_MAX_PACKET 0x00000001
270#define USBD_PF_SHORT_PACKET_OPT 0x00000002
271#define USBD_PF_ENABLE_RT_THREAD_ACCESS 0x00000004
272#define USBD_PF_MAP_ADD_TRANSFERS 0x00000008
273#define USBD_PF_VALID_MASK (USBD_PF_CHANGE_MAX_PACKET | USBD_PF_SHORT_PACKET_OPT | \
274 USBD_PF_ENABLE_RT_THREAD_ACCESS | USBD_PF_MAP_ADD_TRANSFERS)
427#if (_WIN32_WINNT >= 0x0501)
429#define OS_STRING_DESCRIPTOR_INDEX 0xEE
430#define MS_GENRE_DESCRIPTOR_INDEX 0x0001
431#define MS_POWER_DESCRIPTOR_INDEX 0x0002
432#define MS_OS_STRING_SIGNATURE L"MSFT100"
433#define MS_OS_FLAGS_CONTAINERID 0x02
435typedef struct _OS_STRING {
437 UCHAR bDescriptorType;
438 WCHAR MicrosoftString[7];
444} OS_STRING, *POS_STRING;
446struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST {
450 ULONG TransferBufferLength;
451 PVOID TransferBuffer;
452 PMDL TransferBufferMDL;
453 struct _URB *UrbLink;
460 USHORT MS_FeatureDescriptorIndex;
478#if (_WIN32_WINNT >= 0x0600)
480struct _URB_CONTROL_TRANSFER_EX {
484 ULONG TransferBufferLength;
485 PVOID TransferBuffer;
486 PMDL TransferBufferMDL;
540#if (_WIN32_WINNT >= 0x0600)
541 struct _URB_CONTROL_TRANSFER_EX UrbControlTransferEx;
551#if (_WIN32_WINNT >= 0x0501)
552 struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST UrbOSFeatureDescriptorRequest;
char * Pad(char *Str, char PadChar, ULONG Length)
USBD_PIPE_HANDLE PipeHandle
ULONG TransferBufferLength
ULONG TransferBufferLength
ULONG TransferBufferLength
ULONG TransferBufferLength
ULONG TransferBufferLength
USBD_PIPE_HANDLE PipeHandle
ULONG TransferBufferLength
ULONG TransferBufferLength
UCHAR RequestTypeReservedBits
USBD_PIPE_HANDLE PipeHandle
USBD_ISO_PACKET_DESCRIPTOR IsoPacket[1]
ULONG TransferBufferLength
USBD_PIPE_HANDLE PipeHandle
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
USBD_INTERFACE_INFORMATION Interface
USBD_CONFIGURATION_HANDLE ConfigurationHandle
USBD_INTERFACE_INFORMATION Interface
USBD_CONFIGURATION_HANDLE ConfigurationHandle
struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST UrbControlVendorClassRequest
struct _URB_CONTROL_GET_INTERFACE_REQUEST UrbControlGetInterfaceRequest
struct _URB_FRAME_LENGTH_CONTROL UrbFrameLengthControl
struct _URB_CONTROL_FEATURE_REQUEST UrbControlFeatureRequest
struct _URB_SET_FRAME_LENGTH UrbSetFrameLength
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
struct _URB_ISOCH_TRANSFER UrbIsochronousTransfer
struct _URB_CONTROL_GET_CONFIGURATION_REQUEST UrbControlGetConfigurationRequest
struct _URB_CONTROL_DESCRIPTOR_REQUEST UrbControlDescriptorRequest
struct _URB_CONTROL_TRANSFER UrbControlTransfer
struct _URB_BULK_OR_INTERRUPT_TRANSFER UrbBulkOrInterruptTransfer
struct _URB_GET_FRAME_LENGTH UrbGetFrameLength
struct _URB_CONTROL_GET_STATUS_REQUEST UrbControlGetStatusRequest
struct _URB_PIPE_REQUEST UrbPipeRequest
struct _URB_GET_CURRENT_FRAME_NUMBER UrbGetCurrentFrameNumber
struct _URB_SELECT_INTERFACE UrbSelectInterface
struct _URB_HEADER UrbHeader
struct _USBD_INTERFACE_INFORMATION * PUSBD_INTERFACE_INFORMATION
struct _USBD_PIPE_INFORMATION USBD_PIPE_INFORMATION
struct _USBD_INTERFACE_INFORMATION USBD_INTERFACE_INFORMATION
struct _USBD_ISO_PACKET_DESCRIPTOR USBD_ISO_PACKET_DESCRIPTOR
struct _USBD_VERSION_INFORMATION * PUSBD_VERSION_INFORMATION
struct _USBD_ISO_PACKET_DESCRIPTOR * PUSBD_ISO_PACKET_DESCRIPTOR
enum _USBD_PIPE_TYPE USBD_PIPE_TYPE
PVOID USBD_INTERFACE_HANDLE
struct _USBD_VERSION_INFORMATION USBD_VERSION_INFORMATION
struct _USBD_DEVICE_INFORMATION USBD_DEVICE_INFORMATION
enum _USB_CONTROLLER_FLAVOR USB_CONTROLLER_FLAVOR
struct _USBD_PIPE_INFORMATION * PUSBD_PIPE_INFORMATION
@ UsbdPipeTypeIsochronous
PVOID USBD_CONFIGURATION_HANDLE
struct _USBD_DEVICE_INFORMATION * PUSBD_DEVICE_INFORMATION
_In_ PVOID _In_ LONG InterfaceNumber
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
_Reserved_ PVOID Reserved