ReactOS 0.4.16-dev-306-g647d351
usbd.c File Reference
#include <ntddk.h>
#include <usbdi.h>
#include <usbdlib.h>
#include <debug.h>
Include dependency graph for usbd.c:

Go to the source code of this file.

Macros

#define _USBD_
 
#define NDEBUG
 
#define PLUGPLAY_REGKEY_DRIVER   2
 

Functions

NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
ULONG NTAPI DllInitialize (ULONG Unknown)
 
ULONG NTAPI DllUnload (VOID)
 
PVOID NTAPI USBD_Debug_GetHeap (ULONG Unknown1, POOL_TYPE PoolType, ULONG NumberOfBytes, ULONG Tag)
 
VOID NTAPI USBD_Debug_RetHeap (PVOID Heap, ULONG Unknown2, ULONG Unknown3)
 
VOID NTAPI USBD_Debug_LogEntry (PCHAR Name, ULONG_PTR Info1, ULONG_PTR Info2, ULONG_PTR Info3)
 
PVOID NTAPI USBD_AllocateDeviceName (ULONG Unknown)
 
ULONG NTAPI USBD_CalculateUsbBandwidth (ULONG MaxPacketSize, UCHAR EndpointType, BOOLEAN LowSpeed)
 
ULONG NTAPI USBD_Dispatch (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3, ULONG Unknown4)
 
VOID NTAPI USBD_FreeDeviceMutex (PVOID Unknown)
 
VOID NTAPI USBD_FreeDeviceName (PVOID Unknown)
 
VOID NTAPI USBD_WaitDeviceMutex (PVOID Unknown)
 
ULONG NTAPI USBD_GetSuspendPowerState (ULONG Unknown1)
 
NTSTATUS NTAPI USBD_InitializeDevice (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3, ULONG Unknown4, ULONG Unknown5, ULONG Unknown6)
 
NTSTATUS NTAPI USBD_RegisterHostController (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3, ULONG Unknown4, ULONG Unknown5, ULONG Unknown6, ULONG Unknown7, ULONG Unknown8, ULONG Unknown9, ULONG Unknown10)
 
NTSTATUS NTAPI USBD_GetDeviceInformation (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3)
 
NTSTATUS NTAPI USBD_CreateDevice (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3, ULONG Unknown4, ULONG Unknown5)
 
NTSTATUS NTAPI USBD_RemoveDevice (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3)
 
VOID NTAPI USBD_CompleteRequest (ULONG Unknown1, ULONG Unknown2)
 
VOID NTAPI USBD_RegisterHcFilter (PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT FilterDeviceObject)
 
VOID NTAPI USBD_SetSuspendPowerState (ULONG Unknown1, ULONG Unknown2)
 
NTSTATUS NTAPI USBD_MakePdoName (ULONG Unknown1, ULONG Unknown2)
 
NTSTATUS NTAPI USBD_QueryBusTime (PDEVICE_OBJECT RootHubPdo, PULONG CurrentFrame)
 
VOID NTAPI USBD_GetUSBDIVersion (PUSBD_VERSION_INFORMATION Version)
 
NTSTATUS NTAPI USBD_RestoreDevice (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3)
 
VOID NTAPI USBD_RegisterHcDeviceCapabilities (ULONG Unknown1, ULONG Unknown2, ULONG Unknown3)
 
PURB NTAPI USBD_CreateConfigurationRequestEx (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSBD_INTERFACE_LIST_ENTRY InterfaceList)
 
PURB NTAPI USBD_CreateConfigurationRequest (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PUSHORT Size)
 
ULONG NTAPI USBD_GetInterfaceLength (PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor, PUCHAR BufferEnd)
 
PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors (PVOID DescriptorBuffer, ULONG TotalLength, PVOID StartPosition, LONG DescriptorType)
 
PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptorEx (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PVOID StartPosition, LONG InterfaceNumber, LONG AlternateSetting, LONG InterfaceClass, LONG InterfaceSubClass, LONG InterfaceProtocol)
 
PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptor (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, UCHAR InterfaceNumber, UCHAR AlternateSetting)
 
ULONG NTAPI USBD_GetPdoRegistryParameter (PDEVICE_OBJECT PhysicalDeviceObject, PVOID Parameter, ULONG ParameterLength, PWCHAR KeyName, ULONG KeyNameLength)
 

Macro Definition Documentation

◆ _USBD_

#define _USBD_

Definition at line 35 of file usbd.c.

◆ NDEBUG

#define NDEBUG

Definition at line 36 of file usbd.c.

◆ PLUGPLAY_REGKEY_DRIVER

#define PLUGPLAY_REGKEY_DRIVER   2

Definition at line 42 of file usbd.c.

Function Documentation

◆ DllInitialize()

ULONG NTAPI DllInitialize ( ULONG  Unknown)

Definition at line 56 of file usbd.c.

57{
58 return 0;
59}

◆ DllUnload()

ULONG NTAPI DllUnload ( VOID  )

Definition at line 65 of file usbd.c.

66{
67 return 0;
68}

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 46 of file usbd.c.

48{
49 return STATUS_SUCCESS;
50}
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ USBD_AllocateDeviceName()

PVOID NTAPI USBD_AllocateDeviceName ( ULONG  Unknown)

Definition at line 102 of file usbd.c.

103{
105 return NULL;
106}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define NULL
Definition: types.h:112

◆ USBD_CalculateUsbBandwidth()

ULONG NTAPI USBD_CalculateUsbBandwidth ( ULONG  MaxPacketSize,
UCHAR  EndpointType,
BOOLEAN  LowSpeed 
)

Definition at line 112 of file usbd.c.

117{
118 ULONG OverheadTable[] = {
119 0x00, /* UsbdPipeTypeControl */
120 0x09, /* UsbdPipeTypeIsochronous */
121 0x00, /* UsbdPipeTypeBulk */
122 0x0d /* UsbdPipeTypeInterrupt */
123 };
125
126 if (OverheadTable[EndpointType] != 0)
127 {
128 Result = ((MaxPacketSize + OverheadTable[EndpointType]) * 8 * 7) / 6;
129 if (LowSpeed)
130 return Result << 3;
131 return Result;
132 }
133 return 0;
134}
uint32_t ULONG
Definition: typedefs.h:59
_In_ UCHAR EndpointType
Definition: usbdlib.h:225
_In_ UCHAR _In_ BOOLEAN LowSpeed
Definition: usbdlib.h:226
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ USBD_CompleteRequest()

VOID NTAPI USBD_CompleteRequest ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 241 of file usbd.c.

242{
244}

◆ USBD_CreateConfigurationRequest()

PURB NTAPI USBD_CreateConfigurationRequest ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor,
PUSHORT  Size 
)

Definition at line 401 of file usbd.c.

405{
406 /* WindowsXP returns NULL */
407 return NULL;
408}

◆ USBD_CreateConfigurationRequestEx()

PURB NTAPI USBD_CreateConfigurationRequestEx ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor,
PUSBD_INTERFACE_LIST_ENTRY  InterfaceList 
)

Definition at line 329 of file usbd.c.

333{
334 PURB Urb;
335 ULONG UrbSize = 0;
336 ULONG InterfaceCount = 0, PipeCount = 0;
337 ULONG InterfaceNumber, EndPointNumber;
338 PUSBD_INTERFACE_INFORMATION InterfaceInfo;
339
340 while(InterfaceList[InterfaceCount].InterfaceDescriptor)
341 {
342 // pipe count
343 PipeCount += InterfaceList[InterfaceCount].InterfaceDescriptor->bNumEndpoints;
344
345 // interface count
346 InterfaceCount++;
347 }
348
349 // size of urb
350 UrbSize = GET_SELECT_CONFIGURATION_REQUEST_SIZE(InterfaceCount, PipeCount);
351
352 // allocate urb
353 Urb = ExAllocatePool(NonPagedPool, UrbSize);
354 if (!Urb)
355 {
356 // no memory
357 return NULL;
358 }
359
360 // zero urb
361 RtlZeroMemory(Urb, UrbSize);
362
363 // init urb header
365 Urb->UrbSelectConfiguration.Hdr.Length = UrbSize;
366 Urb->UrbSelectConfiguration.ConfigurationDescriptor = ConfigurationDescriptor;
367
368 // init interface information
369 InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
370 for (InterfaceNumber = 0; InterfaceNumber < InterfaceCount; InterfaceNumber++)
371 {
372 // init interface info
373 InterfaceList[InterfaceNumber].Interface = InterfaceInfo;
377
378 // store length
380
381 // sanity check
382 //C_ASSERT(FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes) == 16);
383
384 for (EndPointNumber = 0; EndPointNumber < InterfaceInfo->NumberOfPipes; EndPointNumber++)
385 {
386 // init max transfer size
387 InterfaceInfo->Pipes[EndPointNumber].MaximumTransferSize = PAGE_SIZE;
388 }
389
390 // next interface info
391 InterfaceInfo = (PUSBD_INTERFACE_INFORMATION) ((ULONG_PTR)InterfaceInfo + InterfaceInfo->Length);
392 }
393
394 return Urb;
395}
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Definition: usb.h:529
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
Definition: usb.h:533
USBD_PIPE_INFORMATION Pipes[1]
Definition: usb.h:286
PUSBD_INTERFACE_INFORMATION Interface
Definition: usbdlib.h:9
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbdlib.h:8
ULONG MaximumTransferSize
Definition: usb.h:265
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct _USBD_INTERFACE_INFORMATION * PUSBD_INTERFACE_INFORMATION
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
#define GET_USBD_INTERFACE_SIZE(numEndpoints)
Definition: usbdlib.h:121
#define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes)
Definition: usbdlib.h:112
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:181
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:169
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: wdfusb.h:2334

Referenced by FDO_CloseConfiguration(), Hid_SelectConfiguration(), SelectInterfaces(), USBAudioSelectConfiguration(), USBCCGP_SelectConfiguration(), USBH_OpenConfiguration(), and USBSTOR_SelectConfigurationAndInterface().

◆ USBD_CreateDevice()

NTSTATUS NTAPI USBD_CreateDevice ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3,
ULONG  Unknown4,
ULONG  Unknown5 
)

Definition at line 220 of file usbd.c.

222{
225}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48

◆ USBD_Debug_GetHeap()

PVOID NTAPI USBD_Debug_GetHeap ( ULONG  Unknown1,
POOL_TYPE  PoolType,
ULONG  NumberOfBytes,
ULONG  Tag 
)

Definition at line 74 of file usbd.c.

76{
78}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

◆ USBD_Debug_LogEntry()

VOID NTAPI USBD_Debug_LogEntry ( PCHAR  Name,
ULONG_PTR  Info1,
ULONG_PTR  Info2,
ULONG_PTR  Info3 
)

Definition at line 93 of file usbd.c.

95{
96}

◆ USBD_Debug_RetHeap()

VOID NTAPI USBD_Debug_RetHeap ( PVOID  Heap,
ULONG  Unknown2,
ULONG  Unknown3 
)

Definition at line 84 of file usbd.c.

85{
86 ExFreePool(Heap);
87}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ USBD_Dispatch()

ULONG NTAPI USBD_Dispatch ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3,
ULONG  Unknown4 
)

Definition at line 140 of file usbd.c.

141{
143 return 1;
144}

◆ USBD_FreeDeviceMutex()

VOID NTAPI USBD_FreeDeviceMutex ( PVOID  Unknown)

Definition at line 150 of file usbd.c.

151{
153}

◆ USBD_FreeDeviceName()

VOID NTAPI USBD_FreeDeviceName ( PVOID  Unknown)

Definition at line 159 of file usbd.c.

160{
162}

◆ USBD_GetDeviceInformation()

NTSTATUS NTAPI USBD_GetDeviceInformation ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3 
)

Definition at line 210 of file usbd.c.

211{
214}

◆ USBD_GetInterfaceLength()

ULONG NTAPI USBD_GetInterfaceLength ( PUSB_INTERFACE_DESCRIPTOR  InterfaceDescriptor,
PUCHAR  BufferEnd 
)

Definition at line 414 of file usbd.c.

418{
419 ULONG_PTR Current;
421 ULONG Length = 0;
422 BOOLEAN InterfaceFound = FALSE;
423
424 for (Current = (ULONG_PTR)CurrentDescriptor;
425 Current < (ULONG_PTR)BufferEnd;
426 Current += CurrentDescriptor->bLength)
427 {
428 CurrentDescriptor = (PUSB_INTERFACE_DESCRIPTOR)Current;
429
430 if ((CurrentDescriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE) && (InterfaceFound))
431 break;
432 else if (CurrentDescriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE)
433 InterfaceFound = TRUE;
434
435 Length += CurrentDescriptor->bLength;
436 }
437
438 return Length;
439}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:189

Referenced by main().

◆ USBD_GetPdoRegistryParameter()

ULONG NTAPI USBD_GetPdoRegistryParameter ( PDEVICE_OBJECT  PhysicalDeviceObject,
PVOID  Parameter,
ULONG  ParameterLength,
PWCHAR  KeyName,
ULONG  KeyNameLength 
)

Definition at line 620 of file usbd.c.

627{
630
631 /* Open the device key */
634 if (NT_SUCCESS(Status))
635 {
639
640 /* Initialize the unicode string based on caller data */
641 ValueName.Buffer = KeyName;
642 ValueName.Length = ValueName.MaximumLength = KeyNameLength;
643
645 PartialInfo = ExAllocatePool(PagedPool, Length);
646 if (PartialInfo)
647 {
648 Status = ZwQueryValueKey(DevInstRegKey, &ValueName,
651 {
652 /* The caller doesn't want all the data */
653 ExFreePool(PartialInfo);
654 PartialInfo = ExAllocatePool(PagedPool, Length);
655 if (PartialInfo)
656 {
657 Status = ZwQueryValueKey(DevInstRegKey, &ValueName,
659 }
660 else
661 {
663 }
664 }
665
666 if (NT_SUCCESS(Status))
667 {
668 /* Compute the length to copy back */
669 if (ParameterLength < PartialInfo->DataLength)
671 else
672 Length = PartialInfo->DataLength;
673
675 PartialInfo->Data,
676 Length);
677 }
678
679 if (PartialInfo)
680 {
681 ExFreePool(PartialInfo);
682 }
683 } else
686 }
687 return Status;
688}
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:1621
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ ULONG ParameterLength
Definition: usbdlib.h:206
_In_ ULONG _In_ ULONG KeyNameLength
Definition: usbdlib.h:208
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1127
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2786
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

Referenced by USBH_StartHubFdoDevice().

◆ USBD_GetSuspendPowerState()

ULONG NTAPI USBD_GetSuspendPowerState ( ULONG  Unknown1)

Definition at line 177 of file usbd.c.

178{
180 return 0;
181}

◆ USBD_GetUSBDIVersion()

VOID NTAPI USBD_GetUSBDIVersion ( PUSBD_VERSION_INFORMATION  Version)

Definition at line 294 of file usbd.c.

297{
298 if (Version != NULL)
299 {
300 Version->USBDI_Version = USBDI_VERSION;
301 Version->Supported_USB_Version = 0x200;
302 }
303}
#define USBDI_VERSION
Definition: usb.h:43
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

◆ USBD_InitializeDevice()

NTSTATUS NTAPI USBD_InitializeDevice ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3,
ULONG  Unknown4,
ULONG  Unknown5,
ULONG  Unknown6 
)

Definition at line 187 of file usbd.c.

189{
192}

◆ USBD_MakePdoName()

NTSTATUS NTAPI USBD_MakePdoName ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 271 of file usbd.c.

272{
275}

◆ USBD_ParseConfigurationDescriptor()

PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptor ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor,
UCHAR  InterfaceNumber,
UCHAR  AlternateSetting 
)

Definition at line 604 of file usbd.c.

609{
610 return USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor,
611 (PVOID)ConfigurationDescriptor, InterfaceNumber, AlternateSetting,
612 -1, -1, -1);
613}
PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptorEx(PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor, PVOID StartPosition, LONG InterfaceNumber, LONG AlternateSetting, LONG InterfaceClass, LONG InterfaceSubClass, LONG InterfaceProtocol)
Definition: usbd.c:496
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:170

◆ USBD_ParseConfigurationDescriptorEx()

PUSB_INTERFACE_DESCRIPTOR NTAPI USBD_ParseConfigurationDescriptorEx ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor,
PVOID  StartPosition,
LONG  InterfaceNumber,
LONG  AlternateSetting,
LONG  InterfaceClass,
LONG  InterfaceSubClass,
LONG  InterfaceProtocol 
)

Definition at line 496 of file usbd.c.

505{
508
509 /* set to start position */
511
512 DPRINT("USBD_ParseConfigurationDescriptorEx\n");
513 DPRINT("ConfigurationDescriptor %p Length %lu\n", ConfigurationDescriptor, ConfigurationDescriptor->wTotalLength);
514 DPRINT("CurrentOffset %p Offset %lu\n", StartPosition, ((ULONG_PTR)StartPosition - (ULONG_PTR)ConfigurationDescriptor));
515
517 {
518 /* get interface descriptor */
521 {
522 /* no more descriptors available */
523 break;
524 }
525
526 DPRINT("InterfaceDescriptor %p InterfaceNumber %x AlternateSetting %x Length %lu\n", InterfaceDescriptor, InterfaceDescriptor->bInterfaceNumber, InterfaceDescriptor->bAlternateSetting, InterfaceDescriptor->bLength);
527
528 /* set found */
529 Found = TRUE;
530
531 /* is there an interface number provided */
532 if(InterfaceNumber != -1)
533 {
534 if(InterfaceNumber != InterfaceDescriptor->bInterfaceNumber)
535 {
536 /* interface number does not match */
537 Found = FALSE;
538 }
539 }
540
541 /* is there an alternate setting provided */
542 if(AlternateSetting != -1)
543 {
544 if(AlternateSetting != InterfaceDescriptor->bAlternateSetting)
545 {
546 /* alternate setting does not match */
547 Found = FALSE;
548 }
549 }
550
551 /* match on interface class */
552 if(InterfaceClass != -1)
553 {
554 if(InterfaceClass != InterfaceDescriptor->bInterfaceClass)
555 {
556 /* no match with interface class criteria */
557 Found = FALSE;
558 }
559 }
560
561 /* match on interface sub class */
562 if(InterfaceSubClass != -1)
563 {
564 if(InterfaceSubClass != InterfaceDescriptor->bInterfaceSubClass)
565 {
566 /* no interface sub class match */
567 Found = FALSE;
568 }
569 }
570
571 /* interface protocol criteria */
572 if(InterfaceProtocol != -1)
573 {
574 if(InterfaceProtocol != InterfaceDescriptor->bInterfaceProtocol)
575 {
576 /* no interface protocol match */
577 Found = FALSE;
578 }
579 }
580
581 if (Found)
582 {
583 /* the chosen one */
584 return InterfaceDescriptor;
585 }
586
587 /* sanity check */
588 ASSERT(InterfaceDescriptor->bLength);
589
590 /* move to next descriptor */
592 }
593
594 DPRINT("No Descriptor With InterfaceNumber %ld AlternateSetting %ld InterfaceClass %ld InterfaceSubClass %ld InterfaceProtocol %ld found\n", InterfaceNumber,
596
597 return NULL;
598}
return Found
Definition: dirsup.c:1270
#define ASSERT(a)
Definition: mode.c:44
#define DPRINT
Definition: sndvol32.h:73
PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors(PVOID DescriptorBuffer, ULONG TotalLength, PVOID StartPosition, LONG DescriptorType)
Definition: usbd.c:445
_In_ ULONG _In_ PVOID StartPosition
Definition: usbdlib.h:159
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceSubClass
Definition: usbdlib.h:172
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceProtocol
Definition: usbdlib.h:173
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG InterfaceClass
Definition: usbdlib.h:171

Referenced by AllocateInterfaceDescriptorsArray(), BuildUSBAudioFilterTopology(), CountTerminalUnits(), CountTopologyComponents(), Hid_PnpStart(), Hid_SelectConfiguration(), SelectInterfaces(), UsbAudioGetDataRanges(), UsbAudioGetNonStreamingTerminalDescriptorByIndex(), UsbAudioGetStreamingTerminalDescriptorByIndex(), USBAudioSelectAudioStreamingInterface(), USBAudioSelectConfiguration(), USBCCGP_EnumWithAudioLegacy(), USBCCGP_LegacyEnum(), USBCCGP_ScanConfigurationDescriptor(), USBD_ParseConfigurationDescriptor(), USBH_OpenConfiguration(), and USBH_ProcessDeviceInformation().

◆ USBD_ParseDescriptors()

PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors ( PVOID  DescriptorBuffer,
ULONG  TotalLength,
PVOID  StartPosition,
LONG  DescriptorType 
)

Definition at line 445 of file usbd.c.

451{
452 PUSB_COMMON_DESCRIPTOR CommonDescriptor;
453
454 /* use start position */
455 CommonDescriptor = (PUSB_COMMON_DESCRIPTOR)StartPosition;
456
457
458 /* find next available descriptor */
459 while(CommonDescriptor)
460 {
461 if ((ULONG_PTR)CommonDescriptor >= ((ULONG_PTR)DescriptorBuffer + TotalLength))
462 {
463 /* end reached */
464 DPRINT("End reached %p\n", CommonDescriptor);
465 return NULL;
466 }
467
468 DPRINT("CommonDescriptor Type %x Length %x\n", CommonDescriptor->bDescriptorType, CommonDescriptor->bLength);
469
470 /* is the requested one */
471 if (CommonDescriptor->bDescriptorType == DescriptorType)
472 {
473 /* it is */
474 return CommonDescriptor;
475 }
476
477 if (CommonDescriptor->bLength == 0)
478 {
479 /* invalid usb descriptor */
480 return NULL;
481 }
482
483 /* move to next descriptor */
484 CommonDescriptor = (PUSB_COMMON_DESCRIPTOR)((ULONG_PTR)CommonDescriptor + CommonDescriptor->bLength);
485 }
486
487 /* no descriptor found */
488 return NULL;
489}
_In_ UCHAR _Outptr_result_bytebuffer_ DescriptorBufferLength PVOID * DescriptorBuffer
Definition: scsi.h:3884
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
_In_ ULONG TotalLength
Definition: usbdlib.h:158
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:160

Referenced by BuildUSBAudioFilterTopology(), CountTerminalUnits(), CountTopologyComponents(), UsbAudioGetDataRanges(), UsbAudioGetNonStreamingTerminalDescriptorByIndex(), UsbAudioGetStreamingTerminalDescriptorByIndex(), USBAudioSelectAudioStreamingInterface(), and USBD_ParseConfigurationDescriptorEx().

◆ USBD_QueryBusTime()

NTSTATUS NTAPI USBD_QueryBusTime ( PDEVICE_OBJECT  RootHubPdo,
PULONG  CurrentFrame 
)

Definition at line 281 of file usbd.c.

285{
288}

◆ USBD_RegisterHcDeviceCapabilities()

VOID NTAPI USBD_RegisterHcDeviceCapabilities ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3 
)

Definition at line 319 of file usbd.c.

321{
323}

◆ USBD_RegisterHcFilter()

VOID NTAPI USBD_RegisterHcFilter ( PDEVICE_OBJECT  DeviceObject,
PDEVICE_OBJECT  FilterDeviceObject 
)

Definition at line 250 of file usbd.c.

254{
256}

◆ USBD_RegisterHostController()

NTSTATUS NTAPI USBD_RegisterHostController ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3,
ULONG  Unknown4,
ULONG  Unknown5,
ULONG  Unknown6,
ULONG  Unknown7,
ULONG  Unknown8,
ULONG  Unknown9,
ULONG  Unknown10 
)

Definition at line 198 of file usbd.c.

201{
204}

◆ USBD_RemoveDevice()

NTSTATUS NTAPI USBD_RemoveDevice ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3 
)

Definition at line 231 of file usbd.c.

232{
235}

◆ USBD_RestoreDevice()

NTSTATUS NTAPI USBD_RestoreDevice ( ULONG  Unknown1,
ULONG  Unknown2,
ULONG  Unknown3 
)

Definition at line 309 of file usbd.c.

310{
313}

◆ USBD_SetSuspendPowerState()

VOID NTAPI USBD_SetSuspendPowerState ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 262 of file usbd.c.

263{
265}

◆ USBD_WaitDeviceMutex()

VOID NTAPI USBD_WaitDeviceMutex ( PVOID  Unknown)

Definition at line 168 of file usbd.c.

169{
171}