ReactOS  0.4.13-dev-259-g5ca9c9c
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 }
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ USBD_AllocateDeviceName()

PVOID NTAPI USBD_AllocateDeviceName ( ULONG  Unknown)

Definition at line 102 of file usbd.c.

103 {
105  return NULL;
106 }
smooth NULL
Definition: ftsmooth.c:416
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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  };
124  ULONG Result;
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 }
_In_ UCHAR _In_ BOOLEAN LowSpeed
Definition: usbdlib.h:212
_In_ UCHAR EndpointType
Definition: usbdlib.h:212
_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:426
unsigned int ULONG
Definition: retypes.h:1

◆ USBD_CompleteRequest()

VOID NTAPI USBD_CompleteRequest ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 241 of file usbd.c.

242 {
244 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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 }
smooth NULL
Definition: ftsmooth.c:416

◆ 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
379  InterfaceInfo->Length = GET_USBD_INTERFACE_SIZE(InterfaceList[InterfaceNumber].InterfaceDescriptor->bNumEndpoints);
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 }
USBD_PIPE_INFORMATION Pipes[1]
Definition: usb.h:286
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:168
struct _USBD_INTERFACE_INFORMATION * PUSBD_INTERFACE_INFORMATION
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
#define GET_SELECT_CONFIGURATION_REQUEST_SIZE(totalInterfaces, totalPipes)
Definition: usbdlib.h:99
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:155
#define GET_USBD_INTERFACE_SIZE(numEndpoints)
Definition: usbdlib.h:108
ULONG MaximumTransferSize
Definition: usb.h:265
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define PAGE_SIZE
Definition: env_spec_w32.h:49
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
Definition: usb.h:533
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbdlib.h:8
Definition: usb.h:529
PUSBD_INTERFACE_INFORMATION Interface
Definition: usbdlib.h:9
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by FDO_CloseConfiguration(), Hid_SelectConfiguration(), SelectInterfaces(), USBAudioSelectConfiguration(), USBCCGP_SelectConfiguration(), USBH_OpenConfiguration(), USBHUB_FdoStartDevice(), USBHUB_ParentFDOStartDevice(), 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 {
224  return STATUS_NOT_SUPPORTED;
225 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:997
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

◆ 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 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_FreeDeviceMutex()

VOID NTAPI USBD_FreeDeviceMutex ( PVOID  Unknown)

Definition at line 150 of file usbd.c.

151 {
153 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_FreeDeviceName()

VOID NTAPI USBD_FreeDeviceName ( PVOID  Unknown)

Definition at line 159 of file usbd.c.

160 {
162 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_GetDeviceInformation()

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

Definition at line 210 of file usbd.c.

211 {
213  return STATUS_NOT_SUPPORTED;
214 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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;
420  PUSB_INTERFACE_DESCRIPTOR CurrentDescriptor = InterfaceDescriptor;
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 }
#define TRUE
Definition: types.h:120
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char BOOLEAN
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:176
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101

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  {
636  PKEY_VALUE_PARTIAL_INFORMATION PartialInfo;
638  ULONG Length;
639 
640  /* Initialize the unicode string based on caller data */
643 
645  PartialInfo = ExAllocatePool(PagedPool, Length);
646  if (PartialInfo)
647  {
648  Status = ZwQueryValueKey(DevInstRegKey, &ValueName,
649  KeyValuePartialInformation, PartialInfo, Length, &Length);
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,
658  KeyValuePartialInformation, PartialInfo, Length, &Length);
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 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2738
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
_In_ PVOID Parameter
Definition: ldrtypes.h:240
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
_In_ ULONG ParameterLength
Definition: usbdlib.h:193
_In_ ULONG _In_ ULONG KeyNameLength
Definition: usbdlib.h:195
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1123
Status
Definition: gdiplustypes.h:24
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4565
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

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 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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 }
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
#define USBDI_VERSION
Definition: usb.h:43
smooth NULL
Definition: ftsmooth.c:416

◆ 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 {
191  return STATUS_NOT_SUPPORTED;
192 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_MakePdoName()

NTSTATUS NTAPI USBD_MakePdoName ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 271 of file usbd.c.

272 {
274  return STATUS_NOT_SUPPORTED;
275 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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 }
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:155
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:155
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

Referenced by CUSBDevice::SelectConfiguration(), and CUSBDevice::SelectInterface().

◆ 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 {
506  BOOLEAN Found;
507  PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
508 
509  /* set to start position */
510  InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)StartPosition;
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 
516  while(InterfaceDescriptor)
517  {
518  /* get interface descriptor */
519  InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR) USBD_ParseDescriptors(ConfigurationDescriptor, ConfigurationDescriptor->wTotalLength, InterfaceDescriptor, USB_INTERFACE_DESCRIPTOR_TYPE);
520  if (!InterfaceDescriptor)
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 */
591  InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)((ULONG_PTR)InterfaceDescriptor + InterfaceDescriptor->bLength);
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 }
#define TRUE
Definition: types.h:120
_In_ PVOID _In_ LONG _In_ LONG AlternateSetting
Definition: usbdlib.h:155
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceSubClass
Definition: usbdlib.h:155
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned char BOOLEAN
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
return Found
Definition: dirsup.c:1270
_In_ PVOID _In_ LONG InterfaceNumber
Definition: usbdlib.h:155
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG _In_ LONG _In_ LONG InterfaceProtocol
Definition: usbdlib.h:155
PUSB_COMMON_DESCRIPTOR NTAPI USBD_ParseDescriptors(PVOID DescriptorBuffer, ULONG TotalLength, PVOID StartPosition, LONG DescriptorType)
Definition: usbd.c:445
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ ULONG _In_ PVOID StartPosition
Definition: usbdlib.h:145
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG InterfaceClass
Definition: usbdlib.h:155

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

◆ 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_ ULONG TotalLength
Definition: usbdlib.h:145
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
_In_ ULONG _In_ PVOID StartPosition
Definition: usbdlib.h:145
#define ULONG_PTR
Definition: config.h:101
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:145

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 {
287  return STATUS_NOT_SUPPORTED;
288 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_RegisterHcDeviceCapabilities()

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

Definition at line 319 of file usbd.c.

321 {
323 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_RegisterHcFilter()

VOID NTAPI USBD_RegisterHcFilter ( PDEVICE_OBJECT  DeviceObject,
PDEVICE_OBJECT  FilterDeviceObject 
)

Definition at line 250 of file usbd.c.

254 {
256 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ 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 {
203  return STATUS_NOT_SUPPORTED;
204 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_RemoveDevice()

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

Definition at line 231 of file usbd.c.

232 {
234  return STATUS_NOT_SUPPORTED;
235 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_RestoreDevice()

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

Definition at line 309 of file usbd.c.

310 {
312  return STATUS_NOT_SUPPORTED;
313 }
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_SetSuspendPowerState()

VOID NTAPI USBD_SetSuspendPowerState ( ULONG  Unknown1,
ULONG  Unknown2 
)

Definition at line 262 of file usbd.c.

263 {
265 }
#define UNIMPLEMENTED
Definition: debug.h:114

◆ USBD_WaitDeviceMutex()

VOID NTAPI USBD_WaitDeviceMutex ( PVOID  Unknown)

Definition at line 168 of file usbd.c.

169 {
171 }
#define UNIMPLEMENTED
Definition: debug.h:114