4#define DECLSPEC_EXPORT __declspec(dllexport)
12#define UsbBuildInterruptOrBulkTransferRequest(urb,length, pipeHandle, transferBuffer, transferBufferMDL, transferBufferLength, transferFlags, link) { \
13 (urb)->UrbHeader.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; \
14 (urb)->UrbHeader.Length = (length); \
15 (urb)->UrbBulkOrInterruptTransfer.PipeHandle = (pipeHandle); \
16 (urb)->UrbBulkOrInterruptTransfer.TransferBufferLength = (transferBufferLength); \
17 (urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL = (transferBufferMDL); \
18 (urb)->UrbBulkOrInterruptTransfer.TransferBuffer = (transferBuffer); \
19 (urb)->UrbBulkOrInterruptTransfer.TransferFlags = (transferFlags); \
20 (urb)->UrbBulkOrInterruptTransfer.UrbLink = (link); \
23#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
24 (urb)->UrbHeader.Function = URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE; \
25 (urb)->UrbHeader.Length = (length); \
26 (urb)->UrbControlDescriptorRequest.TransferBufferLength = (transferBufferLength); \
27 (urb)->UrbControlDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
28 (urb)->UrbControlDescriptorRequest.TransferBuffer = (transferBuffer); \
29 (urb)->UrbControlDescriptorRequest.DescriptorType = (descriptorType); \
30 (urb)->UrbControlDescriptorRequest.Index = (descriptorIndex); \
31 (urb)->UrbControlDescriptorRequest.LanguageId = (languageId); \
32 (urb)->UrbControlDescriptorRequest.UrbLink = (link); \
35#define UsbBuildGetStatusRequest(urb, op, index, transferBuffer, transferBufferMDL, link) { \
36 (urb)->UrbHeader.Function = (op); \
37 (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_GET_STATUS_REQUEST); \
38 (urb)->UrbControlGetStatusRequest.TransferBufferLength = sizeof(USHORT); \
39 (urb)->UrbControlGetStatusRequest.TransferBufferMDL = (transferBufferMDL); \
40 (urb)->UrbControlGetStatusRequest.TransferBuffer = (transferBuffer); \
41 (urb)->UrbControlGetStatusRequest.Index = (index); \
42 (urb)->UrbControlGetStatusRequest.UrbLink = (link); \
45#define UsbBuildFeatureRequest(urb, op, featureSelector, index, link) { \
46 (urb)->UrbHeader.Function = (op); \
47 (urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_FEATURE_REQUEST); \
48 (urb)->UrbControlFeatureRequest.FeatureSelector = (featureSelector); \
49 (urb)->UrbControlFeatureRequest.Index = (index); \
50 (urb)->UrbControlFeatureRequest.UrbLink = (link); \
53#define UsbBuildSelectConfigurationRequest(urb, length, configurationDescriptor) { \
54 (urb)->UrbHeader.Function = URB_FUNCTION_SELECT_CONFIGURATION; \
55 (urb)->UrbHeader.Length = (length); \
56 (urb)->UrbSelectConfiguration.ConfigurationDescriptor = (configurationDescriptor); \
59#define UsbBuildSelectInterfaceRequest(urb, length, configurationHandle, interfaceNumber, alternateSetting) { \
60 (urb)->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE; \
61 (urb)->UrbHeader.Length = (length); \
62 (urb)->UrbSelectInterface.Interface.AlternateSetting = (alternateSetting); \
63 (urb)->UrbSelectInterface.Interface.InterfaceNumber = (interfaceNumber); \
64 (urb)->UrbSelectInterface.Interface.Length = (length - sizeof(struct _URB_HEADER) - sizeof(USBD_CONFIGURATION_HANDLE)); \
65 (urb)->UrbSelectInterface.ConfigurationHandle = (configurationHandle); \
68#define UsbBuildVendorRequest(urb, cmd, length, transferFlags, reservedbits, request, value, index, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
69 (urb)->UrbHeader.Function = cmd; \
70 (urb)->UrbHeader.Length = (length); \
71 (urb)->UrbControlVendorClassRequest.TransferBufferLength = (transferBufferLength); \
72 (urb)->UrbControlVendorClassRequest.TransferBufferMDL = (transferBufferMDL); \
73 (urb)->UrbControlVendorClassRequest.TransferBuffer = (transferBuffer); \
74 (urb)->UrbControlVendorClassRequest.RequestTypeReservedBits = (reservedbits); \
75 (urb)->UrbControlVendorClassRequest.Request = (request); \
76 (urb)->UrbControlVendorClassRequest.Value = (value); \
77 (urb)->UrbControlVendorClassRequest.Index = (index); \
78 (urb)->UrbControlVendorClassRequest.TransferFlags = (transferFlags); \
79 (urb)->UrbControlVendorClassRequest.UrbLink = (link); \
82#if (NTDDI_VERSION >= NTDDI_WINXP)
84#define UsbBuildOsFeatureDescriptorRequest(urb, length, interface, index, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
85 (urb)->UrbHeader.Function = URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR; \
86 (urb)->UrbHeader.Length = (length); \
87 (urb)->UrbOSFeatureDescriptorRequest.TransferBufferLength = (transferBufferLength); \
88 (urb)->UrbOSFeatureDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
89 (urb)->UrbOSFeatureDescriptorRequest.TransferBuffer = (transferBuffer); \
90 (urb)->UrbOSFeatureDescriptorRequest.InterfaceNumber = (interface); \
91 (urb)->UrbOSFeatureDescriptorRequest.MS_FeatureDescriptorIndex = (index); \
92 (urb)->UrbOSFeatureDescriptorRequest.UrbLink = (link); \
97#if (NTDDI_VERSION >= NTDDI_VISTA)
99#define USBD_CLIENT_CONTRACT_VERSION_INVALID 0xFFFFFFFF
100#define USBD_CLIENT_CONTRACT_VERSION_602 0x602
102#define USBD_INTERFACE_VERSION_600 0x600
103#define USBD_INTERFACE_VERSION_602 0x602
104#define USBD_INTERFACE_VERSION_603 0x603
137#define URB_STATUS(urb) ((urb)->UrbHeader.Status)
139#define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes) \
140 (sizeof(struct _URB_SELECT_CONFIGURATION) + \
141 ((totalInterfaces-1) * sizeof(USBD_INTERFACE_INFORMATION)) + \
142 ((totalPipes-totalInterfaces)*sizeof(USBD_PIPE_INFORMATION)))
144#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes) \
145 (sizeof(struct _URB_SELECT_INTERFACE) + \
146 ((totalPipes-1)*sizeof(USBD_PIPE_INFORMATION)))
148#define GET_USBD_INTERFACE_SIZE(numEndpoints) \
149 (sizeof(USBD_INTERFACE_INFORMATION) + \
150 (sizeof(USBD_PIPE_INFORMATION)*(numEndpoints)) - sizeof(USBD_PIPE_INFORMATION))
152#define GET_ISO_URB_SIZE(n) (sizeof(struct _URB_ISOCH_TRANSFER)+ \
153 sizeof(USBD_ISO_PACKET_DESCRIPTOR)*n)
244#if (NTDDI_VERSION >= NTDDI_WINXP)
257#if (NTDDI_VERSION >= NTDDI_VISTA)
263USBD_ValidateConfigurationDescriptor(
343 0xf5ceeb23, 0xad90, 0x458c, 0x97, 0x9a, 0xd5, 0x9b, 0x3a, 0xd6, 0x88, 0x4f);
345 0x09051e1f, 0x0dc9, 0x4e6b, 0x8b, 0x12, 0x96, 0x0c, 0xbd, 0x81, 0xaa, 0x8f);
347 0x755c630d, 0xc8a0, 0x4765, 0x94, 0x6f, 0x90, 0xcc, 0x70, 0x38, 0x56, 0xa4);
349 0xf4563183, 0xd66e, 0x42bd, 0xbd, 0x53, 0x1a, 0xc7, 0xb0, 0x4c, 0xd5, 0x9d);
351 0x9c8a8a27, 0x15f9, 0x42e3, 0xa3, 0x56, 0xcd, 0xa6, 0xae, 0x97, 0xa8, 0xc8);
352DEFINE_GUID(GUID_USB_CAPABILITY_DEVICE_CONNECTION_HIGH_SPEED_COMPATIBLE,
353 0x81a885a6, 0xf239, 0x42a2, 0x83, 0x97, 0xa5, 0xd9, 0x5b, 0xea, 0x69, 0x53);
354DEFINE_GUID(GUID_USB_CAPABILITY_DEVICE_CONNECTION_SUPER_SPEED_COMPATIBLE,
355 0x8a2f776c, 0x9bd0, 0x4f29, 0x97, 0x71, 0xc7, 0xa3, 0x88, 0x46, 0xd4, 0xc7);
357 0xbb6e6472, 0x4be5, 0x44a3, 0x96, 0x41, 0x34, 0x5e, 0x56, 0xac, 0x34, 0x85);
359 0x59819125, 0x33a3, 0x421a, 0xa5, 0xdd, 0x37, 0x63, 0x9f, 0x30, 0xb9, 0x3e);
360DEFINE_GUID(GUID_USB_CAPABILITY_CONTROLLER_EUSB2_DOUBLE_ISOCH_COMPATIBLE,
361 0x5f0e4b3f, 0xde94, 0x473a, 0xa3, 0x73, 0x78, 0x1a, 0xcb, 0x92, 0xb5, 0xe8);
PDEVICE_OBJECT PhysicalDeviceObject
_In_ ULONG _In_ UCHAR Level
#define _IRQL_requires_max_(irql)
#define _IRQL_requires_(irql)
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG MaxPacketSize
#define DECLARE_HANDLE(name)
#define _In_reads_bytes_(s)
#define _Outptr_result_bytebuffer_(s)
#define _Deref_out_range_(l, h)
#define _Must_inspect_result_
#define _Out_writes_bytes_to_opt_(s, c)
#define _Inout_updates_bytes_(s)
#define _Out_writes_bytes_(s)
_In_ ULONG _In_ ULONG Offset
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
_In_ UCHAR _Outptr_result_bytebuffer_ DescriptorBufferLength PVOID * DescriptorBuffer
ULONG CapabilityFunctionSuspend
COMPOSITE_DEVICE_CAPABILITIES CapabilityFlags
USBD_FUNCTION_HANDLE UsbdFunctionHandle
PUSBD_INTERFACE_INFORMATION Interface
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
_In_ PGUID _In_ ULONG _Out_ PULONG ResultLength
_In_ PGUID CapabilityType
_In_ PGUID _In_ ULONG OutputBufferLength
_Must_inspect_result_ _In_ UCXENDPOINT _In_ PVOID Tag
PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors(PVOID DescriptorBuffer, ULONG TotalLength, PVOID StartPosition, LONG DescriptorType)
PURB NTAPI USBD_CreateConfigurationRequestEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSBD_INTERFACE_LIST_ENTRY InterfaceList)
PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptorEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PVOID StartPosition, LONG InterfaceNumber, LONG AlternateSetting, LONG InterfaceClass, LONG InterfaceSubClass, LONG InterfaceProtocol)
ULONG NTAPI USBD_CalculateUsbBandwidth(ULONG MaxPacketSize, UCHAR EndpointType, BOOLEAN LowSpeed)
ULONG NTAPI USBD_GetPdoRegistryParameter(PDEVICE_OBJECT PhysicalDeviceObject, PVOID Parameter, ULONG ParameterLength, PWCHAR KeyName, ULONG KeyNameLength)
VOID NTAPI USBD_RegisterHcFilter(PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT FilterDeviceObject)
VOID NTAPI USBD_GetUSBDIVersion(PUSBD_VERSION_INFORMATION Version)
ULONG NTAPI USBD_GetInterfaceLength(PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor, PUCHAR BufferEnd)
NTSTATUS USBD_QueryUsbCapability(_In_ USBD_HANDLE USBDHandle, _In_ const GUID *CapabilityType, _In_ ULONG OutputBufferLength, _When_(OutputBufferLength==0, _Pre_null_) _When_(OutputBufferLength !=0 &&ResultLength==NULL, _Out_writes_bytes_(OutputBufferLength)) _When_(OutputBufferLength !=0 &&ResultLength !=NULL, _Out_writes_bytes_to_opt_(OutputBufferLength, *ResultLength)) PUCHAR OutputBuffer, _Out_opt_ _When_(ResultLength !=NULL, _Deref_out_range_(<=, OutputBufferLength)) PULONG ResultLength)
NTSTATUS USBD_UrbAllocate(_In_ USBD_HANDLE USBDHandle, _Outptr_result_bytebuffer_(sizeof(URB)) PURB *Urb)
NTSTATUS USBD_IsochUrbAllocate(_In_ USBD_HANDLE USBDHandle, _In_ ULONG NumberOfIsochPacket, _Outptr_result_bytebuffer_(sizeof(struct _URB_ISOCH_TRANSFER)+(NumberOfIsochPackets *sizeof(USBD_ISO_PACKET_DESCRIPTOR)) - sizeof(USBD_ISO_PACKET_DESCRIPTOR)) PURB *Urb)
NTSTATUS USBD_CreateHandle(_In_ PDEVICE_OBJECT DeviceObject, _In_ PDEVICE_OBJECT TargetDeviceObject, _In_ ULONG USBDClientContractVersion, _In_ ULONG PoolTag, _Out_ USBD_HANDLE *USBDHandle)
VOID USBD_AssignUrbToIoStackLocation(_In_ USBD_HANDLE USBDHandle, _In_ PIO_STACK_LOCATION IoStackLocation, _In_ PURB Urb)
VOID USBD_UrbFree(_In_ USBD_HANDLE USBDHandle, _In_ PURB Urb)
_In_ ULONG _In_ PVOID StartPosition
_In_ UCHAR _In_ BOOLEAN LowSpeed
USBD_FUNCTION_HANDLE * PUSBD_FUNCTION_HANDLE
DECLSPEC_IMPORT PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptor(_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _In_ UCHAR InterfaceNumber, _In_ UCHAR AlternateSetting)
struct _REQUEST_REMOTE_WAKE_NOTIFICATION * PREQUEST_REMOTE_WAKE_NOTIFICATION
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceSubClass
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ ULONG _In_ ULONG _Out_ USBD_HANDLE * USBDHandle
struct _REGISTER_COMPOSITE_DEVICE REGISTER_COMPOSITE_DEVICE
_In_ ULONG NumberOfIsochPacket
struct _COMPOSITE_DEVICE_CAPABILITIES COMPOSITE_DEVICE_CAPABILITIES
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
_In_ PDEVICE_OBJECT FilterDeviceObject
VOID USBD_CloseHandle(_In_ USBD_HANDLE USBDHandle)
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
_Must_inspect_result_ _In_ PDEVICE_OBJECT _In_ ULONG USBDClientContractVersion
struct _USBD_INTERFACE_LIST_ENTRY * PUSBD_INTERFACE_LIST_ENTRY
struct _REQUEST_REMOTE_WAKE_NOTIFICATION REQUEST_REMOTE_WAKE_NOTIFICATION
_In_ ULONG ParameterLength
_In_ PIO_STACK_LOCATION _In_ PURB Urb
_In_ ULONG _In_ ULONG KeyNameLength
struct _USBD_INTERFACE_LIST_ENTRY USBD_INTERFACE_LIST_ENTRY
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceProtocol
DECLSPEC_EXPORT NTSTATUS NTAPI USBD_QueryBusTime(_In_ PDEVICE_OBJECT RootHubPdo, _Out_ PULONG CurrentFrame)
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG InterfaceClass
_In_ PVOID _In_ LONG InterfaceNumber
_Must_inspect_result_ _In_ PDEVICE_OBJECT TargetDeviceObject
struct _COMPOSITE_DEVICE_CAPABILITIES * PCOMPOSITE_DEVICE_CAPABILITIES
struct _REGISTER_COMPOSITE_DEVICE * PREGISTER_COMPOSITE_DEVICE
_In_ PIO_STACK_LOCATION IoStackLocation
DECLSPEC_IMPORT PURB NTAPI USBD_CreateConfigurationRequest(_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, _Out_ PUSHORT Siz)
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG PoolTag
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ ULONG NumberOfIsochPackets
_Inout_opt_ PVOID Parameter