ReactOS 0.4.17-dev-1321-g5c122a9
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)
 
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

◆ 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 84 of file usbd.c.

85{
87 return NULL;
88}
#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 94 of file usbd.c.

99{
100 ULONG OverheadTable[] = {
101 0x00, /* UsbdPipeTypeControl */
102 0x09, /* UsbdPipeTypeIsochronous */
103 0x00, /* UsbdPipeTypeBulk */
104 0x0d /* UsbdPipeTypeInterrupt */
105 };
107
108 if (OverheadTable[EndpointType] != 0)
109 {
110 Result = ((MaxPacketSize + OverheadTable[EndpointType]) * 8 * 7) / 6;
111 if (LowSpeed)
112 return Result << 3;
113 return Result;
114 }
115 return 0;
116}
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG MaxPacketSize
Definition: hubucx.h:289
uint32_t ULONG
Definition: typedefs.h:59
_In_ UCHAR EndpointType
Definition: usbdlib.h:252
_In_ UCHAR _In_ BOOLEAN LowSpeed
Definition: usbdlib.h:253
_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 223 of file usbd.c.

224{
226}

◆ USBD_CreateConfigurationRequest()

PURB NTAPI USBD_CreateConfigurationRequest ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor,
PUSHORT  Size 
)

Definition at line 383 of file usbd.c.

387{
388 /* WindowsXP returns NULL */
389 return NULL;
390}

◆ USBD_CreateConfigurationRequestEx()

PURB NTAPI USBD_CreateConfigurationRequestEx ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor,
PUSBD_INTERFACE_LIST_ENTRY  InterfaceList 
)

Definition at line 311 of file usbd.c.

315{
316 PURB Urb;
317 ULONG UrbSize = 0;
318 ULONG InterfaceCount = 0, PipeCount = 0;
319 ULONG InterfaceNumber, EndPointNumber;
320 PUSBD_INTERFACE_INFORMATION InterfaceInfo;
321
322 while(InterfaceList[InterfaceCount].InterfaceDescriptor)
323 {
324 // pipe count
325 PipeCount += InterfaceList[InterfaceCount].InterfaceDescriptor->bNumEndpoints;
326
327 // interface count
328 InterfaceCount++;
329 }
330
331 // size of urb
332 UrbSize = GET_SELECT_CONFIGURATION_REQUEST_SIZE(InterfaceCount, PipeCount);
333
334 // allocate urb
335 Urb = ExAllocatePool(NonPagedPool, UrbSize);
336 if (!Urb)
337 {
338 // no memory
339 return NULL;
340 }
341
342 // zero urb
343 RtlZeroMemory(Urb, UrbSize);
344
345 // init urb header
346 Urb->UrbSelectConfiguration.Hdr.Function = URB_FUNCTION_SELECT_CONFIGURATION;
347 Urb->UrbSelectConfiguration.Hdr.Length = UrbSize;
348 Urb->UrbSelectConfiguration.ConfigurationDescriptor = ConfigurationDescriptor;
349
350 // init interface information
351 InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
352 for (InterfaceNumber = 0; InterfaceNumber < InterfaceCount; InterfaceNumber++)
353 {
354 // init interface info
355 InterfaceList[InterfaceNumber].Interface = InterfaceInfo;
359
360 // store length
362
363 // sanity check
364 //C_ASSERT(FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes) == 16);
365
366 for (EndPointNumber = 0; EndPointNumber < InterfaceInfo->NumberOfPipes; EndPointNumber++)
367 {
368 // init max transfer size
369 InterfaceInfo->Pipes[EndPointNumber].MaximumTransferSize = PAGE_SIZE;
370 }
371
372 // next interface info
373 InterfaceInfo = (PUSBD_INTERFACE_INFORMATION) ((ULONG_PTR)InterfaceInfo + InterfaceInfo->Length);
374 }
375
376 return Urb;
377}
#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:565
USBD_PIPE_INFORMATION Pipes[1]
Definition: usb.h:298
PUSBD_INTERFACE_INFORMATION Interface
Definition: usbdlib.h:9
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbdlib.h:8
ULONG MaximumTransferSize
Definition: usb.h:277
#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
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
Definition: usbdlib.h:331
#define GET_USBD_INTERFACE_SIZE(numEndpoints)
Definition: usbdlib.h:148
#define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes)
Definition: usbdlib.h:139
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:208
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:196
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333
_In_ WDFUSBINTERFACE _In_ UCHAR _Out_ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: wdfusb.h:2334

Referenced by FDO_CloseConfiguration(), Hid_SelectConfiguration(), HubMachine::SelectHubConfiguration(), 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 202 of file usbd.c.

204{
207}
#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 56 of file usbd.c.

58{
60}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ UCXENDPOINT _In_ PVOID Tag
Definition: ucxendpoint.h:325
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3821
_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 75 of file usbd.c.

77{
78}

◆ USBD_Debug_RetHeap()

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

Definition at line 66 of file usbd.c.

67{
68 ExFreePool(Heap);
69}
#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 122 of file usbd.c.

123{
125 return 1;
126}

◆ USBD_FreeDeviceMutex()

VOID NTAPI USBD_FreeDeviceMutex ( PVOID  Unknown)

Definition at line 132 of file usbd.c.

133{
135}

◆ USBD_FreeDeviceName()

VOID NTAPI USBD_FreeDeviceName ( PVOID  Unknown)

Definition at line 141 of file usbd.c.

142{
144}

◆ USBD_GetDeviceInformation()

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

Definition at line 192 of file usbd.c.

193{
196}

◆ USBD_GetInterfaceLength()

ULONG NTAPI USBD_GetInterfaceLength ( PUSB_INTERFACE_DESCRIPTOR  InterfaceDescriptor,
PUCHAR  BufferEnd 
)

Definition at line 396 of file usbd.c.

400{
403 ULONG Length = 0;
404 BOOLEAN InterfaceFound = FALSE;
405
406 for (Current = (ULONG_PTR)CurrentDescriptor;
408 Current += CurrentDescriptor->bLength)
409 {
410 CurrentDescriptor = (PUSB_INTERFACE_DESCRIPTOR)Current;
411
412 if ((CurrentDescriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE) && (InterfaceFound))
413 break;
414 else if (CurrentDescriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE)
415 InterfaceFound = TRUE;
416
417 Length += CurrentDescriptor->bLength;
418 }
419
420 return Length;
421}
unsigned char BOOLEAN
Definition: actypes.h:127
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
HubUxdSettings Current
_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:216

Referenced by main().

◆ USBD_GetPdoRegistryParameter()

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

Definition at line 602 of file usbd.c.

609{
612
613 /* Open the device key */
616 if (NT_SUCCESS(Status))
617 {
621
622 /* Initialize the unicode string based on caller data */
623 ValueName.Buffer = KeyName;
624 ValueName.Length = ValueName.MaximumLength = KeyNameLength;
625
627 PartialInfo = ExAllocatePool(PagedPool, Length);
628 if (PartialInfo)
629 {
630 Status = ZwQueryValueKey(DevInstRegKey, &ValueName,
633 {
634 /* The caller doesn't want all the data */
635 ExFreePool(PartialInfo);
636 PartialInfo = ExAllocatePool(PagedPool, Length);
637 if (PartialInfo)
638 {
639 Status = ZwQueryValueKey(DevInstRegKey, &ValueName,
641 }
642 else
643 {
645 }
646 }
647
648 if (NT_SUCCESS(Status))
649 {
650 /* Compute the length to copy back */
651 if (ParameterLength < PartialInfo->DataLength)
653 else
654 Length = PartialInfo->DataLength;
655
657 PartialInfo->Data,
658 Length);
659 }
660
661 if (PartialInfo)
662 {
663 ExFreePool(PartialInfo);
664 }
665 } else
668 }
669 return Status;
670}
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG DataLength
Definition: dispmprt.h:233
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:24
ZwClose(Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1185
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:1619
#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:233
_In_ ULONG _In_ ULONG KeyNameLength
Definition: usbdlib.h:235
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1146
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2812
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

Referenced by USBH_StartHubFdoDevice().

◆ USBD_GetSuspendPowerState()

ULONG NTAPI USBD_GetSuspendPowerState ( ULONG  Unknown1)

Definition at line 159 of file usbd.c.

160{
162 return 0;
163}

◆ USBD_GetUSBDIVersion()

VOID NTAPI USBD_GetUSBDIVersion ( PUSBD_VERSION_INFORMATION  Version)

Definition at line 276 of file usbd.c.

279{
280 if (Version != NULL)
281 {
282 Version->USBDI_Version = USBDI_VERSION;
283 Version->Supported_USB_Version = 0x200;
284 }
285}
#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 169 of file usbd.c.

171{
174}

◆ USBD_MakePdoName()

NTSTATUS NTAPI USBD_MakePdoName ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 253 of file usbd.c.

254{
257}

◆ USBD_ParseConfigurationDescriptor()

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

Definition at line 586 of file usbd.c.

591{
594 -1, -1, -1);
595}
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:478
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:197

◆ 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 478 of file usbd.c.

487{
490
491 /* set to start position */
493
494 DPRINT("USBD_ParseConfigurationDescriptorEx\n");
495 DPRINT("ConfigurationDescriptor %p Length %lu\n", ConfigurationDescriptor, ConfigurationDescriptor->wTotalLength);
496 DPRINT("CurrentOffset %p Offset %lu\n", StartPosition, ((ULONG_PTR)StartPosition - (ULONG_PTR)ConfigurationDescriptor));
497
499 {
500 /* get interface descriptor */
503 {
504 /* no more descriptors available */
505 break;
506 }
507
508 DPRINT("InterfaceDescriptor %p InterfaceNumber %x AlternateSetting %x Length %lu\n", InterfaceDescriptor, InterfaceDescriptor->bInterfaceNumber, InterfaceDescriptor->bAlternateSetting, InterfaceDescriptor->bLength);
509
510 /* set found */
511 Found = TRUE;
512
513 /* is there an interface number provided */
514 if(InterfaceNumber != -1)
515 {
516 if(InterfaceNumber != InterfaceDescriptor->bInterfaceNumber)
517 {
518 /* interface number does not match */
519 Found = FALSE;
520 }
521 }
522
523 /* is there an alternate setting provided */
524 if(AlternateSetting != -1)
525 {
526 if(AlternateSetting != InterfaceDescriptor->bAlternateSetting)
527 {
528 /* alternate setting does not match */
529 Found = FALSE;
530 }
531 }
532
533 /* match on interface class */
534 if(InterfaceClass != -1)
535 {
536 if(InterfaceClass != InterfaceDescriptor->bInterfaceClass)
537 {
538 /* no match with interface class criteria */
539 Found = FALSE;
540 }
541 }
542
543 /* match on interface sub class */
544 if(InterfaceSubClass != -1)
545 {
546 if(InterfaceSubClass != InterfaceDescriptor->bInterfaceSubClass)
547 {
548 /* no interface sub class match */
549 Found = FALSE;
550 }
551 }
552
553 /* interface protocol criteria */
554 if(InterfaceProtocol != -1)
555 {
556 if(InterfaceProtocol != InterfaceDescriptor->bInterfaceProtocol)
557 {
558 /* no interface protocol match */
559 Found = FALSE;
560 }
561 }
562
563 if (Found)
564 {
565 /* the chosen one */
566 return InterfaceDescriptor;
567 }
568
569 /* sanity check */
570 ASSERT(InterfaceDescriptor->bLength);
571
572 /* move to next descriptor */
574 }
575
576 DPRINT("No Descriptor With InterfaceNumber %ld AlternateSetting %ld InterfaceClass %ld InterfaceSubClass %ld InterfaceProtocol %ld found\n", InterfaceNumber,
578
579 return NULL;
580}
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:427
_In_ ULONG _In_ PVOID StartPosition
Definition: usbdlib.h:186
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceSubClass
Definition: usbdlib.h:199
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceProtocol
Definition: usbdlib.h:200
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG InterfaceClass
Definition: usbdlib.h:198

Referenced by AllocateInterfaceDescriptorsArray(), BuildUSBAudioFilterTopology(), CountTerminalUnits(), CountTopologyComponents(), Hid_PnpStart(), Hid_SelectConfiguration(), HubFindHubInterface(), 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 427 of file usbd.c.

433{
434 PUSB_COMMON_DESCRIPTOR CommonDescriptor;
435
436 /* use start position */
437 CommonDescriptor = (PUSB_COMMON_DESCRIPTOR)StartPosition;
438
439
440 /* find next available descriptor */
441 while(CommonDescriptor)
442 {
443 if ((ULONG_PTR)CommonDescriptor >= ((ULONG_PTR)DescriptorBuffer + TotalLength))
444 {
445 /* end reached */
446 DPRINT("End reached %p\n", CommonDescriptor);
447 return NULL;
448 }
449
450 DPRINT("CommonDescriptor Type %x Length %x\n", CommonDescriptor->bDescriptorType, CommonDescriptor->bLength);
451
452 /* is the requested one */
453 if (CommonDescriptor->bDescriptorType == DescriptorType)
454 {
455 /* it is */
456 return CommonDescriptor;
457 }
458
459 if (CommonDescriptor->bLength == 0)
460 {
461 /* invalid usb descriptor */
462 return NULL;
463 }
464
465 /* move to next descriptor */
466 CommonDescriptor = (PUSB_COMMON_DESCRIPTOR)((ULONG_PTR)CommonDescriptor + CommonDescriptor->bLength);
467 }
468
469 /* no descriptor found */
470 return NULL;
471}
_In_ UCHAR _Outptr_result_bytebuffer_ DescriptorBufferLength PVOID * DescriptorBuffer
Definition: scsi.h:3930
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
_In_ ULONG TotalLength
Definition: usbdlib.h:185
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:187

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 263 of file usbd.c.

267{
270}

◆ USBD_RegisterHcDeviceCapabilities()

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

Definition at line 301 of file usbd.c.

303{
305}

◆ USBD_RegisterHcFilter()

VOID NTAPI USBD_RegisterHcFilter ( PDEVICE_OBJECT  DeviceObject,
PDEVICE_OBJECT  FilterDeviceObject 
)

Definition at line 232 of file usbd.c.

236{
238}

◆ 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 180 of file usbd.c.

183{
186}

◆ USBD_RemoveDevice()

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

Definition at line 213 of file usbd.c.

214{
217}

◆ USBD_RestoreDevice()

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

Definition at line 291 of file usbd.c.

292{
295}

◆ USBD_SetSuspendPowerState()

VOID NTAPI USBD_SetSuspendPowerState ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 244 of file usbd.c.

245{
247}

◆ USBD_WaitDeviceMutex()

VOID NTAPI USBD_WaitDeviceMutex ( PVOID  Unknown)

Definition at line 150 of file usbd.c.

151{
153}