2010-03-04 22:58:41 +00:00
|
|
|
#pragma once
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-09-15 09:03:57 +00:00
|
|
|
#ifndef DECLSPEC_EXPORT
|
|
|
|
#define DECLSPEC_EXPORT __declspec(dllexport)
|
|
|
|
#endif
|
|
|
|
|
2010-03-04 22:58:41 +00:00
|
|
|
typedef struct _USBD_INTERFACE_LIST_ENTRY {
|
|
|
|
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
|
|
|
|
PUSBD_INTERFACE_INFORMATION Interface;
|
|
|
|
} USBD_INTERFACE_LIST_ENTRY, *PUSBD_INTERFACE_LIST_ENTRY;
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildInterruptOrBulkTransferRequest(urb,length, pipeHandle, transferBuffer, transferBufferMDL, transferBufferLength, transferFlags, link) { \
|
|
|
|
(urb)->UrbHeader.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; \
|
|
|
|
(urb)->UrbHeader.Length = (length); \
|
|
|
|
(urb)->UrbBulkOrInterruptTransfer.PipeHandle = (pipeHandle); \
|
|
|
|
(urb)->UrbBulkOrInterruptTransfer.TransferBufferLength = (transferBufferLength); \
|
|
|
|
(urb)->UrbBulkOrInterruptTransfer.TransferBufferMDL = (transferBufferMDL); \
|
|
|
|
(urb)->UrbBulkOrInterruptTransfer.TransferBuffer = (transferBuffer); \
|
|
|
|
(urb)->UrbBulkOrInterruptTransfer.TransferFlags = (transferFlags); \
|
|
|
|
(urb)->UrbBulkOrInterruptTransfer.UrbLink = (link); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
|
|
|
|
(urb)->UrbHeader.Function = URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE; \
|
|
|
|
(urb)->UrbHeader.Length = (length); \
|
|
|
|
(urb)->UrbControlDescriptorRequest.TransferBufferLength = (transferBufferLength); \
|
|
|
|
(urb)->UrbControlDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
|
|
|
|
(urb)->UrbControlDescriptorRequest.TransferBuffer = (transferBuffer); \
|
|
|
|
(urb)->UrbControlDescriptorRequest.DescriptorType = (descriptorType); \
|
|
|
|
(urb)->UrbControlDescriptorRequest.Index = (descriptorIndex); \
|
|
|
|
(urb)->UrbControlDescriptorRequest.LanguageId = (languageId); \
|
|
|
|
(urb)->UrbControlDescriptorRequest.UrbLink = (link); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildGetStatusRequest(urb, op, index, transferBuffer, transferBufferMDL, link) { \
|
|
|
|
(urb)->UrbHeader.Function = (op); \
|
|
|
|
(urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_GET_STATUS_REQUEST); \
|
|
|
|
(urb)->UrbControlGetStatusRequest.TransferBufferLength = sizeof(USHORT); \
|
|
|
|
(urb)->UrbControlGetStatusRequest.TransferBufferMDL = (transferBufferMDL); \
|
|
|
|
(urb)->UrbControlGetStatusRequest.TransferBuffer = (transferBuffer); \
|
|
|
|
(urb)->UrbControlGetStatusRequest.Index = (index); \
|
|
|
|
(urb)->UrbControlGetStatusRequest.UrbLink = (link); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildFeatureRequest(urb, op, featureSelector, index, link) { \
|
|
|
|
(urb)->UrbHeader.Function = (op); \
|
|
|
|
(urb)->UrbHeader.Length = sizeof(struct _URB_CONTROL_FEATURE_REQUEST); \
|
|
|
|
(urb)->UrbControlFeatureRequest.FeatureSelector = (featureSelector); \
|
|
|
|
(urb)->UrbControlFeatureRequest.Index = (index); \
|
|
|
|
(urb)->UrbControlFeatureRequest.UrbLink = (link); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildSelectConfigurationRequest(urb, length, configurationDescriptor) { \
|
|
|
|
(urb)->UrbHeader.Function = URB_FUNCTION_SELECT_CONFIGURATION; \
|
|
|
|
(urb)->UrbHeader.Length = (length); \
|
|
|
|
(urb)->UrbSelectConfiguration.ConfigurationDescriptor = (configurationDescriptor); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildSelectInterfaceRequest(urb, length, configurationHandle, interfaceNumber, alternateSetting) { \
|
|
|
|
(urb)->UrbHeader.Function = URB_FUNCTION_SELECT_INTERFACE; \
|
|
|
|
(urb)->UrbHeader.Length = (length); \
|
|
|
|
(urb)->UrbSelectInterface.Interface.AlternateSetting = (alternateSetting); \
|
|
|
|
(urb)->UrbSelectInterface.Interface.InterfaceNumber = (interfaceNumber); \
|
|
|
|
(urb)->UrbSelectInterface.Interface.Length = (length - sizeof(struct _URB_HEADER) - sizeof(USBD_CONFIGURATION_HANDLE)); \
|
|
|
|
(urb)->UrbSelectInterface.ConfigurationHandle = (configurationHandle); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildVendorRequest(urb, cmd, length, transferFlags, reservedbits, request, value, index, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
|
|
|
|
(urb)->UrbHeader.Function = cmd; \
|
|
|
|
(urb)->UrbHeader.Length = (length); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.TransferBufferLength = (transferBufferLength); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.TransferBufferMDL = (transferBufferMDL); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.TransferBuffer = (transferBuffer); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.RequestTypeReservedBits = (reservedbits); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.Request = (request); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.Value = (value); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.Index = (index); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.TransferFlags = (transferFlags); \
|
|
|
|
(urb)->UrbControlVendorClassRequest.UrbLink = (link); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_WINXP)
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define UsbBuildOsFeatureDescriptorRequest(urb, length, interface, index, transferBuffer, transferBufferMDL, transferBufferLength, link) { \
|
|
|
|
(urb)->UrbHeader.Function = URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR; \
|
|
|
|
(urb)->UrbHeader.Length = (length); \
|
|
|
|
(urb)->UrbOSFeatureDescriptorRequest.TransferBufferLength = (transferBufferLength); \
|
|
|
|
(urb)->UrbOSFeatureDescriptorRequest.TransferBufferMDL = (transferBufferMDL); \
|
|
|
|
(urb)->UrbOSFeatureDescriptorRequest.TransferBuffer = (transferBuffer); \
|
|
|
|
(urb)->UrbOSFeatureDescriptorRequest.InterfaceNumber = (interface); \
|
|
|
|
(urb)->UrbOSFeatureDescriptorRequest.MS_FeatureDescriptorIndex = (index); \
|
|
|
|
urb)->UrbOSFeatureDescriptorRequest.UrbLink = (link); \
|
2009-09-30 23:58:04 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#endif /* NTDDI_VERSION >= NTDDI_WINXP */
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define URB_STATUS(urb) ((urb)->UrbHeader.Status)
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes) \
|
|
|
|
(sizeof(struct _URB_SELECT_CONFIGURATION) + \
|
|
|
|
((totalInterfaces-1) * sizeof(USBD_INTERFACE_INFORMATION)) + \
|
|
|
|
((totalPipes-totalInterfaces)*sizeof(USBD_PIPE_INFORMATION)))
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define GET_SELECT_INTERFACE_REQUEST_SIZE(totalPipes) \
|
|
|
|
(sizeof(struct _URB_SELECT_INTERFACE) + \
|
|
|
|
((totalPipes-1)*sizeof(USBD_PIPE_INFORMATION)))
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define GET_USBD_INTERFACE_SIZE(numEndpoints) \
|
|
|
|
(sizeof(USBD_INTERFACE_INFORMATION) + \
|
|
|
|
(sizeof(USBD_PIPE_INFORMATION)*(numEndpoints)) - sizeof(USBD_PIPE_INFORMATION))
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#define GET_ISO_URB_SIZE(n) (sizeof(struct _URB_ISOCH_TRANSFER)+ \
|
|
|
|
sizeof(USBD_ISO_PACKET_DESCRIPTOR)*n)
|
2009-09-30 23:58:04 +00:00
|
|
|
|
|
|
|
#ifndef _USBD_
|
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
2009-09-30 23:58:04 +00:00
|
|
|
DECLSPEC_IMPORT
|
|
|
|
VOID
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_GetUSBDIVersion(
|
2012-01-23 16:07:08 +00:00
|
|
|
_Out_ PUSBD_VERSION_INFORMATION VersionInformation);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
|
|
|
DECLSPEC_IMPORT
|
|
|
|
PUSB_INTERFACE_DESCRIPTOR
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_ParseConfigurationDescriptor(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
|
|
|
|
_In_ UCHAR InterfaceNumber,
|
|
|
|
_In_ UCHAR AlternateSetting);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
|
|
|
DECLSPEC_IMPORT
|
|
|
|
PURB
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_CreateConfigurationRequest(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
|
|
|
|
_Out_ PUSHORT Siz);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
2009-09-30 23:58:04 +00:00
|
|
|
DECLSPEC_IMPORT
|
|
|
|
PUSB_COMMON_DESCRIPTOR
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_ParseDescriptors(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PVOID DescriptorBuffer,
|
|
|
|
_In_ ULONG TotalLength,
|
|
|
|
_In_ PVOID StartPosition,
|
|
|
|
_In_ LONG DescriptorType);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
2009-09-30 23:58:04 +00:00
|
|
|
DECLSPEC_IMPORT
|
|
|
|
PUSB_INTERFACE_DESCRIPTOR
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_ParseConfigurationDescriptorEx(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
|
|
|
|
_In_ PVOID StartPosition,
|
|
|
|
_In_ LONG InterfaceNumber,
|
|
|
|
_In_ LONG AlternateSetting,
|
|
|
|
_In_ LONG InterfaceClass,
|
|
|
|
_In_ LONG InterfaceSubClass,
|
|
|
|
_In_ LONG InterfaceProtocol);
|
|
|
|
|
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
2009-09-30 23:58:04 +00:00
|
|
|
DECLSPEC_IMPORT
|
|
|
|
PURB
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_CreateConfigurationRequestEx(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
|
|
|
|
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(PASSIVE_LEVEL)
|
2010-03-04 22:58:41 +00:00
|
|
|
DECLSPEC_EXPORT
|
2009-09-30 23:58:04 +00:00
|
|
|
ULONG
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_GetInterfaceLength(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor,
|
|
|
|
_In_ PUCHAR BufferEnd);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(PASSIVE_LEVEL)
|
2010-03-04 22:58:41 +00:00
|
|
|
DECLSPEC_EXPORT
|
2009-09-30 23:58:04 +00:00
|
|
|
VOID
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_RegisterHcFilter(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PDEVICE_OBJECT DeviceObject,
|
|
|
|
_In_ PDEVICE_OBJECT FilterDeviceObject);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(APC_LEVEL)
|
2010-03-04 22:58:41 +00:00
|
|
|
DECLSPEC_EXPORT
|
2009-09-30 23:58:04 +00:00
|
|
|
NTSTATUS
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_GetPdoRegistryParameter(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PDEVICE_OBJECT PhysicalDeviceObject,
|
|
|
|
_Inout_updates_bytes_(ParameterLength) PVOID Parameter,
|
|
|
|
_In_ ULONG ParameterLength,
|
|
|
|
_In_reads_bytes_(KeyNameLength) PWSTR KeyName,
|
|
|
|
_In_ ULONG KeyNameLength);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
2010-03-04 22:58:41 +00:00
|
|
|
DECLSPEC_EXPORT
|
2009-09-30 23:58:04 +00:00
|
|
|
NTSTATUS
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_QueryBusTime(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ PDEVICE_OBJECT RootHubPdo,
|
|
|
|
_Out_ PULONG CurrentFrame);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_WINXP)
|
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
2009-09-30 23:58:04 +00:00
|
|
|
DECLSPEC_IMPORT
|
|
|
|
ULONG
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_CalculateUsbBandwidth(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_ ULONG MaxPacketSize,
|
|
|
|
_In_ UCHAR EndpointType,
|
|
|
|
_In_ BOOLEAN LowSpeed);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (NTDDI_VERSION >= NTDDI_VISTA)
|
|
|
|
|
2012-01-23 16:07:08 +00:00
|
|
|
_IRQL_requires_max_(DISPATCH_LEVEL)
|
2009-09-30 23:58:04 +00:00
|
|
|
DECLSPEC_IMPORT
|
|
|
|
USBD_STATUS
|
2009-10-12 18:40:18 +00:00
|
|
|
NTAPI
|
2009-09-30 23:58:04 +00:00
|
|
|
USBD_ValidateConfigurationDescriptor(
|
2012-01-23 16:07:08 +00:00
|
|
|
_In_reads_bytes_(BufferLength) PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc,
|
|
|
|
_In_ ULONG BufferLength,
|
|
|
|
_In_ USHORT Level,
|
|
|
|
_Out_ PUCHAR *Offset,
|
|
|
|
_In_opt_ ULONG Tag);
|
2009-09-30 23:58:04 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-08-10 20:50:55 +00:00
|
|
|
#endif /* ! _USBD_ */
|
|
|
|
|