ReactOS 0.4.17-dev-1281-g065abb3
hubid.cpp File Reference
#include "usbhub3.h"
#include "hubid.h"
#include <debug.h>
Include dependency graph for hubid.cpp:

Go to the source code of this file.

Classes

struct  HubFailureId
 
struct  HubIdSink
 
struct  HubIdText
 

Macros

#define NDEBUG
 
#define HUB_ID_MAX_CHARS   128
 
#define HUB_INSTANCE_ID_CHARS   28
 
#define HUB_LOCATION_TEXT_BYTES   42
 
#define HUB_DEFAULT_LANGUAGE   0x0409
 
#define HUB_FAILURE_ID(Reason, Pid, Text)   { (Reason), (Pid), Text, sizeof(Text) }
 

Enumerations

enum class  HubIdKind { Device , Hardware , Compatible , Container }
 

Functions

static const HubFailureId *NTAPI HubFailureIdFor (_In_ HubChild *Child)
 
static NTSTATUS NTAPI HubIdListAppend (_Inout_ PUSB_ID_STRING List, _In_ PCUNICODE_STRING Id)
 
VOID NTAPI HubIdListFree (_Inout_ PUSB_ID_STRING Ids)
 
NTSTATUS NTAPI HubIdListCopy (_Out_ PUSB_ID_STRING Destination, _In_ const USB_ID_STRING *Source)
 
static NTSTATUS NTAPI HubIdEmit (_In_ const HubIdSink *Sink, _In_ PCUNICODE_STRING Id)
 
static NTSTATUS NTAPI HubIdEmitText (_In_ const HubIdSink *Sink, _In_ const HubIdText *Text)
 
static NTSTATUS NTAPI HubIdEmitCounted (_In_ const HubIdSink *Sink, _In_reads_bytes_(IdBytes) PCWSTR Id, _In_ USHORT IdBytes)
 
static BOOLEAN NTAPI HubIdIsKnown (_In_ HubChild *Child)
 
static BOOLEAN NTAPI HubIdUsesFailureId (_In_ HubChild *Child)
 
static BOOLEAN NTAPI HubIdIsVmReserved (_In_ HubChild *Child)
 
static VOID NTAPI HubIdRevisionText (_In_ USHORT BcdUsb, _In_ USHORT BcdDevice, _Out_writes_(5) PWCHAR Text)
 
static VOID NTAPI HubIdWidenMsOsField (_In_reads_(8) const UCHAR *Field, _Out_writes_(9) PWCHAR Text)
 
static NTSTATUS NTAPI HubIdBuildDeviceId (_In_ HubChild *Child, _In_ PWDFDEVICE_INIT DeviceInit)
 
NTSTATUS NTAPI HubIdBuildHardwareIds (_In_ HubChild *Child, _In_opt_ PWDFDEVICE_INIT DeviceInit, _Out_opt_ PUSB_ID_STRING Ids)
 
static NTSTATUS NTAPI HubIdBuildCompositeIds (_In_ HubChild *Child, _In_ const HubIdSink *Sink)
 
static NTSTATUS NTAPI HubIdEmitMsComp (_In_ const HubIdSink *Sink, _In_reads_(8) const UCHAR *CompatibleId, _In_reads_opt_(8) const UCHAR *SubCompatibleId)
 
static NTSTATUS NTAPI HubIdBuildMsOsIds (_In_ HubChild *Child, _In_ const HubIdSink *Sink)
 
static NTSTATUS NTAPI HubIdBuildClassIds (_In_ HubChild *Child, _In_ const HubIdSink *Sink)
 
NTSTATUS NTAPI HubIdBuildCompatibleIds (_In_ HubChild *Child, _In_opt_ PWDFDEVICE_INIT DeviceInit, _Out_opt_ PUSB_ID_STRING Ids)
 
static VOID NTAPI HubIdGenerateContainerId (_In_ HubChild *Child)
 
static BOOLEAN NTAPI HubIdHasContainerId (_In_ HubChild *Child)
 
static VOID NTAPI HubIdBuildContainerId (_In_ HubChild *Child, _In_ PWDFDEVICE_INIT DeviceInit)
 
BOOLEAN NTAPI HubIdGetContainerId (_In_ HubChild *Child, _Out_ GUID *ContainerId)
 
 _IRQL_requires_ (PASSIVE_LEVEL) static NTSTATUS NTAPI HubIdLoadVmReservedId(_In_ HubChild *Child)
 Sends a synchronous IOCTL to the specified device object.
 
VOID NTAPI HubIdFreeDeviceIds (_In_ HubChild *Child)
 
 if (Child->m_SerialNumber !=NULL)
 
 if (Port->HasProperty(PortProperty::TypeCWithoutSwitch) &&Port->m_InstancePortNumber !=0 &&HubIdIsKnown(Child))
 
RtlInitEmptyUnicodeString & Id (Digits)
 
 if (NT_SUCCESS(Status)) Status
 
 if (!NT_SUCCESS(Status)) DPRINT1("Instance id from port %lu for device %p failed 0x%lx\n"
 
 PAGED_CODE ()
 
 HubSaveUxdState (Child->m_Hub, Child, NULL)
 
 if (Child->HasProperty(ChildProperty::UxdReserved))
 
 HubIdBuildContainerId (Child, DeviceInit)
 
return HubIdAssignInstanceId (Child, DeviceInit)
 
BOOLEAN NTAPI HubIdLanguageSupported (_In_ HubChild *Child, _In_ USHORT Language)
 
 if (Text==NULL)
 
 if (Child->m_DeviceDescriptor.iProduct==0||Child->HasHack(ChildHack::DisableSerialNumber)) return STATUS_NOT_SUPPORTED
 
 if (Language==0||!HubIdLanguageSupported(Child, Language)) Language
 
 if (Language !=Child->m_LanguageId)
 
 if (Child->m_ProductString==NULL)
 
 RtlCopyMemory (Text, Product->bString,(Characters - 1) *sizeof(WCHAR))
 
 switch (Stack->Parameters.QueryDeviceText.DeviceTextType)
 
 IoCompleteRequest (Irp, IO_NO_INCREMENT)
 
static ULONG NTAPI HubIdBytesReturned (_In_ HubChild *Child)
 
static PCWSTR NTAPI HubIdSerialPrefix (_In_ HubChild *Child)
 
BOOLEAN NTAPI HubIdGetSerialNumberText (_In_ HubChild *Child, _Outptr_result_bytebuffer_(*Length) PCWSTR *Text, _Out_ PULONG Length)
 

Variables

static const GUID HubContainerIdNamespace
 
static const HubFailureId HubFailureIds []
 
static const HubFailureId HubUnknownDeviceId
 
static const WCHAR HubBillboardId [] = L"USB\\Class_11&SubClass_00&Prot_00"
 
_In_ PWDFDEVICE_INIT DeviceInit
 
WCHAR Digits [HUB_INSTANCE_ID_CHARS]
 
UNICODE_STRING Id
 
ULONG Number = Port->Number()
 
NTSTATUS Status = RtlIntegerToUnicodeString(Number, 10, &Id)
 
 Child
 
_Inout_ PIRP Irp
 
 Text = (PWCHAR)ExAllocatePoolWithTag(NonPagedPool, HUB_LOCATION_TEXT_BYTES, HUB_TAG_DEVICE)
 
Irp IoStatus Information = (ULONG_PTR)Text
 
return STATUS_SUCCESS
 
_Inout_ PIRP _In_ LCID Locale
 
PUSB_STRING_DESCRIPTOR Product = Child->m_ProductString
 
ULONG Characters = (Product->bLength - 2) / sizeof(WCHAR) + 1
 

Macro Definition Documentation

◆ HUB_DEFAULT_LANGUAGE

#define HUB_DEFAULT_LANGUAGE   0x0409

Definition at line 23 of file hubid.cpp.

◆ HUB_FAILURE_ID

#define HUB_FAILURE_ID (   Reason,
  Pid,
  Text 
)    { (Reason), (Pid), Text, sizeof(Text) }

Definition at line 38 of file hubid.cpp.

◆ HUB_ID_MAX_CHARS

#define HUB_ID_MAX_CHARS   128

Definition at line 15 of file hubid.cpp.

◆ HUB_INSTANCE_ID_CHARS

#define HUB_INSTANCE_ID_CHARS   28

Definition at line 18 of file hubid.cpp.

◆ HUB_LOCATION_TEXT_BYTES

#define HUB_LOCATION_TEXT_BYTES   42

Definition at line 21 of file hubid.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file hubid.cpp.

Enumeration Type Documentation

◆ HubIdKind

Enumerator
Device 
Hardware 
Compatible 
Container 

Definition at line 78 of file hubid.cpp.

79{
80 Device,
84};

Function Documentation

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Sends a synchronous IOCTL to the specified device object.

Parameters
[in]IoControlCodeThe IOCTL to send to the device.
[in]DeviceObjectPointer to the device object that will handle the IOCTL.
[in]InputBufferOptional pointer to a buffer containing input data for the IOCTL. When specified, the buffer should be at least of InputBufferLength size.
[in]InputBufferLengthSize in bytes, of the buffer pointed by InputBuffer.
[out]OutputBufferOptional pointer to a buffer that will receive output data from the IOCTL. When specified, the buffer should be at least of OutputBufferLength size.
[in]OutputBufferLengthSize in bytes, of the buffer pointed by OutputBuffer.
[in]FileObjectOptional pointer to a file object that may be necessary for the IOCTL.
Returns
An NTSTATUS code indicating success or failure of this function.
Note
Must be called at PASSIVE_LEVEL with all APCs enabled.

Nothing is found unless the PCI bus driver publishes the properties.

The root hub name without its prefix; NULL when the PDO has no name.

Grows a private buffer to what the helper asks for.

Lets KMDF handle the IRP, then hands it back here still uncompleted.

Waits for the device machine to answer a PnP or power event; returns the PnP status.

Deletes the UCX endpoints of the disabled pipes, then the interface record.

One 4 byte value; the registry type is not checked.

Reread whenever user experience settings change; the open status is returned.

Sends a synchronous IOCTL to the specified device object.

Definition at line 765 of file hubid.cpp.

771{
773 WDFSTRING String;
776
777 PAGED_CODE();
778
779 if (Child->m_VmReservedId.Buffer != NULL)
780 ExFreePoolWithTag(Child->m_VmReservedId.Buffer, HUB_TAG_DEVICE);
781 RtlZeroMemory(&Child->m_VmReservedId, sizeof(Child->m_VmReservedId));
782
783 Status = WdfStringCreate(NULL, WDF_NO_OBJECT_ATTRIBUTES, &String);
784 if (!NT_SUCCESS(Status))
785 {
786 DPRINT1("VM reserved id string for device %p failed 0x%lx\n", Child, Status);
787 return Status;
788 }
789
790 HubQueryUxdDeviceValue(Child, String);
792
794 if (Buffer == NULL)
795 {
796 DPRINT1("VM reserved id for device %p could not be allocated\n", Child);
799 }
800
801 RtlCopyMemory(Buffer, Value.Buffer, Value.Length);
802
803 Child->m_VmReservedId.Buffer = Buffer;
804 Child->m_VmReservedId.Length = Value.Length + sizeof(WCHAR);
805 Child->m_VmReservedId.MaximumLength = Child->m_VmReservedId.Length;
806
808 return STATUS_SUCCESS;
809}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:24
PAGED_CODE()
return STATUS_SUCCESS
Definition: hubid.cpp:973
NTSTATUS Status
Definition: hubid.cpp:837
#define HUB_TAG_DEVICE
Definition: hubutil.h:13
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
short WCHAR
Definition: pedump.c:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
WdfObjectDelete(String)
WdfStringGetUnicodeString(Original, &Name)
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105

◆ HubFailureIdFor()

static const HubFailureId *NTAPI HubFailureIdFor ( _In_ HubChild *  Child)
static

Definition at line 61 of file hubid.cpp.

63{
65
67 {
68 if (HubFailureIds[Index].Reason == Child->m_EnumMessageId)
69 return &HubFailureIds[Index];
70 }
71
72 return &HubUnknownDeviceId;
73}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static const HubFailureId HubUnknownDeviceId
Definition: hubid.cpp:52
static const HubFailureId HubFailureIds[]
Definition: hubid.cpp:40
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by HubIdBuildCompatibleIds(), HubIdBuildDeviceId(), and HubIdBuildHardwareIds().

◆ HubIdAssignInstanceId()

return HubIdAssignInstanceId ( Child  ,
DeviceInit   
)

◆ HubIdBuildClassIds()

static NTSTATUS NTAPI HubIdBuildClassIds ( _In_ HubChild *  Child,
_In_ const HubIdSink *  Sink 
)
static

Definition at line 541 of file hubid.cpp.

544{
545 const USB_INTERFACE_DESCRIPTOR* Interface = Child->m_CompatIdInterface;
546 USHORT VendorId = Child->m_DeviceDescriptor.idVendor;
547 UCHAR Class = 0;
548 UCHAR SubClass = 0;
549 UCHAR Protocol = 0;
552
553 if (Interface != NULL)
554 {
555 Class = Interface->bInterfaceClass;
556 SubClass = Interface->bInterfaceSubClass;
557 Protocol = Interface->bInterfaceProtocol;
558 }
559
561 if (!NT_SUCCESS(Status))
562 return Status;
563
564 /* COMPAT_VID class ids, between the MS OS ids and the plain class ids */
565 Text.Format(L"USB\\COMPAT_VID_%04X&Class_%02X&SubClass_%02X&Prot_%02X", VendorId, Class, SubClass, Protocol);
567 if (!NT_SUCCESS(Status))
568 return Status;
569
570 Text.Format(L"USB\\COMPAT_VID_%04X&Class_%02X&SubClass_%02X", VendorId, Class, SubClass);
572 if (!NT_SUCCESS(Status))
573 return Status;
574
575 Text.Format(L"USB\\COMPAT_VID_%04X&Class_%02X", VendorId, Class);
577 if (!NT_SUCCESS(Status))
578 return Status;
579
580 Text.Format(L"USB\\Class_%02X&SubClass_%02X&Prot_%02X", Class, SubClass, Protocol);
582 if (!NT_SUCCESS(Status))
583 return Status;
584
585 Text.Format(L"USB\\Class_%02X&SubClass_%02X", Class, SubClass);
587 if (!NT_SUCCESS(Status))
588 return Status;
589
590 Text.Format(L"USB\\Class_%02X", Class);
591 return HubIdEmitText(Sink, &Text);
592}
#define L(x)
Definition: resources.c:13
static NTSTATUS NTAPI HubIdBuildMsOsIds(_In_ HubChild *Child, _In_ const HubIdSink *Sink)
Definition: hubid.cpp:494
Text
Definition: hubid.cpp:956
static NTSTATUS NTAPI HubIdEmitText(_In_ const HubIdSink *Sink, _In_ const HubIdText *Text)
Definition: hubid.cpp:241
unsigned short USHORT
Definition: pedump.c:61
Definition: precomp.h:83
unsigned char UCHAR
Definition: typedefs.h:53
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428

Referenced by HubIdBuildCompatibleIds().

◆ HubIdBuildCompatibleIds()

NTSTATUS NTAPI HubIdBuildCompatibleIds ( _In_ HubChild *  Child,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_Out_opt_ PUSB_ID_STRING  Ids 
)

Compatible ids into a PDO init and/or a multi-sz list, which is zeroed first.

Definition at line 597 of file hubid.cpp.

601{
604
605 if (Ids != NULL)
606 RtlZeroMemory(Ids, sizeof(*Ids));
607
609 {
610 const HubFailureId* Failure = HubFailureIdFor(Child);
611 return HubIdEmitCounted(&Sink, Failure->Id, Failure->IdBytes);
612 }
613
614 if (Child->HasProperty(ChildProperty::IsComposite))
616
617 if (Child->HasProperty(ChildProperty::IsHub))
618 {
619 switch (Child->Speed())
620 {
621 case UsbHighSpeed:
622 case UsbFullSpeed:
623 Text.Set(L"USB\\USB20_HUB");
624 return HubIdEmitText(&Sink, &Text);
625
626 case UsbSuperSpeed:
627 Text.Set(L"USB\\USB30_HUB");
628 return HubIdEmitText(&Sink, &Text);
629
630 default:
631 return STATUS_SUCCESS;
632 }
633 }
634
635 if (Child->HasProperty(ChildProperty::HasBillboard))
637
638 return HubIdBuildClassIds(Child, &Sink);
639}
static BOOLEAN NTAPI HubIdUsesFailureId(_In_ HubChild *Child)
Definition: hubid.cpp:289
static const WCHAR HubBillboardId[]
Definition: hubid.cpp:56
static NTSTATUS NTAPI HubIdBuildCompositeIds(_In_ HubChild *Child, _In_ const HubIdSink *Sink)
Definition: hubid.cpp:422
static const HubFailureId *NTAPI HubFailureIdFor(_In_ HubChild *Child)
Definition: hubid.cpp:61
static NTSTATUS NTAPI HubIdBuildClassIds(_In_ HubChild *Child, _In_ const HubIdSink *Sink)
Definition: hubid.cpp:541
static NTSTATUS NTAPI HubIdEmitCounted(_In_ const HubIdSink *Sink, _In_reads_bytes_(IdBytes) PCWSTR Id, _In_ USHORT IdBytes)
Definition: hubid.cpp:261
_In_ PWDFDEVICE_INIT DeviceInit
Definition: hubid.cpp:832
_In_ const HubIdStrings * Ids
PCWSTR Id
Definition: hubid.cpp:34
USHORT IdBytes
Definition: hubid.cpp:35
@ UsbSuperSpeed
Definition: usb200.h:45
@ UsbHighSpeed
Definition: usb200.h:44
@ UsbFullSpeed
Definition: usb200.h:43

◆ HubIdBuildCompositeIds()

static NTSTATUS NTAPI HubIdBuildCompositeIds ( _In_ HubChild *  Child,
_In_ const HubIdSink *  Sink 
)
static

Definition at line 422 of file hubid.cpp.

425{
426 static PCWSTR const Plain[] =
427 {
428 L"USB\\DevClass_00&SubClass_00&Prot_00",
429 L"USB\\DevClass_00&SubClass_00",
430 L"USB\\DevClass_00",
431 L"USB\\COMPOSITE"
432 };
433 USHORT VendorId = Child->m_DeviceDescriptor.idVendor;
436 ULONG Index;
437
438 /* "Prot00" without the underscore is intentional */
439 Text.Format(L"USB\\COMPAT_VID_%04X&DevClass_00&SubClass_00&Prot00", VendorId);
441 if (!NT_SUCCESS(Status))
442 return Status;
443
444 Text.Format(L"USB\\COMPAT_VID_%04X&DevClass_00&SubClass_00", VendorId);
446 if (!NT_SUCCESS(Status))
447 return Status;
448
449 Text.Format(L"USB\\COMPAT_VID_%04X&DevClass_00", VendorId);
451 if (!NT_SUCCESS(Status))
452 return Status;
453
454 for (Index = 0; Index < RTL_NUMBER_OF(Plain); Index++)
455 {
456 Text.Set(Plain[Index]);
458 if (!NT_SUCCESS(Status))
459 return Status;
460 }
461
462 return STATUS_SUCCESS;
463}
const uint16_t * PCWSTR
Definition: typedefs.h:57

Referenced by HubIdBuildCompatibleIds().

◆ HubIdBuildContainerId() [1/2]

static VOID NTAPI HubIdBuildContainerId ( _In_ HubChild *  Child,
_In_ PWDFDEVICE_INIT  DeviceInit 
)
static

Definition at line 719 of file hubid.cpp.

722{
724 const GUID* Id = &Child->m_ContainerId;
727
728 if (Child->HasProperty(ChildProperty::NotRemovable))
729 return;
730
731 if (!HubIdHasContainerId(Child) && Child->m_SerialNumber != NULL)
733
735 return;
736
737 Text.Format(L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
738 Id->Data1, Id->Data2, Id->Data3,
739 Id->Data4[0], Id->Data4[1], Id->Data4[2], Id->Data4[3],
740 Id->Data4[4], Id->Data4[5], Id->Data4[6], Id->Data4[7]);
741
743 if (!NT_SUCCESS(Status))
744 DPRINT1("Container id for device %p not assigned: 0x%lx\n", Child, Status);
745}
static BOOLEAN NTAPI HubIdHasContainerId(_In_ HubChild *Child)
Definition: hubid.cpp:708
UNICODE_STRING Id
Definition: hubid.cpp:835
static VOID NTAPI HubIdGenerateContainerId(_In_ HubChild *Child)
Definition: hubid.cpp:647

◆ HubIdBuildContainerId() [2/2]

HubIdBuildContainerId ( Child  ,
DeviceInit   
)

◆ HubIdBuildDeviceId()

static NTSTATUS NTAPI HubIdBuildDeviceId ( _In_ HubChild *  Child,
_In_ PWDFDEVICE_INIT  DeviceInit 
)
static

Definition at line 348 of file hubid.cpp.

351{
354 USHORT VendorId = Child->m_DeviceDescriptor.idVendor;
355 USHORT ProductId = Child->m_DeviceDescriptor.idProduct;
356
358 return HubIdEmit(&Sink, &Child->m_VmReservedId);
359
361 {
362 VendorId = 0;
363 ProductId = HubFailureIdFor(Child)->ProductId;
364 }
365
366 Text.Format(L"USB\\VID_%04X&PID_%04X", VendorId, ProductId);
367 if (Child->HasHack(ChildHack::NonFunctional))
368 Text.Append(L"_NON_FUNCTIONAL");
369
370 return HubIdEmitText(&Sink, &Text);
371}
static NTSTATUS NTAPI HubIdEmit(_In_ const HubIdSink *Sink, _In_ PCUNICODE_STRING Id)
Definition: hubid.cpp:198
static BOOLEAN NTAPI HubIdIsKnown(_In_ HubChild *Child)
Definition: hubid.cpp:279
static BOOLEAN NTAPI HubIdIsVmReserved(_In_ HubChild *Child)
Definition: hubid.cpp:298
USHORT ProductId
Definition: hubid.cpp:33

◆ HubIdBuildHardwareIds()

NTSTATUS NTAPI HubIdBuildHardwareIds ( _In_ HubChild *  Child,
_In_opt_ PWDFDEVICE_INIT  DeviceInit,
_Out_opt_ PUSB_ID_STRING  Ids 
)

Hardware ids into a PDO init and/or a multi-sz list, which is zeroed first.

Definition at line 381 of file hubid.cpp.

385{
387 const USB_DEVICE_DESCRIPTOR* Descriptor = &Child->m_DeviceDescriptor;
389 WCHAR Revision[5];
391
392 if (Ids != NULL)
393 RtlZeroMemory(Ids, sizeof(*Ids));
394
396 {
397 const HubFailureId* Failure = HubFailureIdFor(Child);
398 return HubIdEmitCounted(&Sink, Failure->Id, Failure->IdBytes);
399 }
400
402 return HubIdEmit(&Sink, &Child->m_VmReservedId);
403
404 HubIdRevisionText(Descriptor->bcdUSB, Descriptor->bcdDevice, Revision);
405
406 Text.Format(L"USB\\VID_%04X&PID_%04X&REV_", Descriptor->idVendor, Descriptor->idProduct);
407 Text.Append(Revision);
409 if (!NT_SUCCESS(Status))
410 return Status;
411
412 Text.Format(L"USB\\VID_%04X&PID_%04X", Descriptor->idVendor, Descriptor->idProduct);
413 return HubIdEmitText(&Sink, &Text);
414}
static VOID NTAPI HubIdRevisionText(_In_ USHORT BcdUsb, _In_ USHORT BcdDevice, _Out_writes_(5) PWCHAR Text)
Definition: hubid.cpp:309
_In_ const GUID _In_ ULONG Revision
Definition: slotdev.cpp:85
_In_ PWDFDEVICE_INIT DeviceInit
Definition: wdfcontrol.h:113
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

◆ HubIdBuildMsOsIds()

static NTSTATUS NTAPI HubIdBuildMsOsIds ( _In_ HubChild *  Child,
_In_ const HubIdSink *  Sink 
)
static

Definition at line 494 of file hubid.cpp.

497{
498 const UCHAR* CompatibleId;
499 const UCHAR* SubCompatibleId;
501
502 if ((Child->m_MsOs20.Flags & HUB_MSOS20_COMPATIBLE_ID) && Child->m_MsOs20.CompatibleId != NULL)
503 {
504 CompatibleId = Child->m_MsOs20.CompatibleId->CompatibleId;
505 SubCompatibleId = Child->m_MsOs20.CompatibleId->SubCompatibleId;
506
507 if (SubCompatibleId[0] != 0 && CompatibleId[0] != 0)
508 {
509 Status = HubIdEmitMsComp(Sink, CompatibleId, SubCompatibleId);
510 if (!NT_SUCCESS(Status))
511 return Status;
512 }
513 }
514 else if (Child->m_MsOsExtConfig != NULL)
515 {
516 CompatibleId = Child->m_MsOsExtConfig->Function[0].CompatibleId;
517 SubCompatibleId = Child->m_MsOsExtConfig->Function[0].SubCompatibleId;
518
519 /* Only the sub compatible id is checked, so the compatible id can come out empty */
520 if (SubCompatibleId[0] != 0)
521 {
522 Status = HubIdEmitMsComp(Sink, CompatibleId, SubCompatibleId);
523 if (!NT_SUCCESS(Status))
524 return Status;
525 }
526 }
527 else
528 {
529 return STATUS_SUCCESS;
530 }
531
532 if (CompatibleId[0] != 0)
533 return HubIdEmitMsComp(Sink, CompatibleId, NULL);
534
535 return STATUS_SUCCESS;
536}
#define HUB_MSOS20_COMPATIBLE_ID
Definition: desccheck.h:493
static NTSTATUS NTAPI HubIdEmitMsComp(_In_ const HubIdSink *Sink, _In_reads_(8) const UCHAR *CompatibleId, _In_reads_opt_(8) const UCHAR *SubCompatibleId)
Definition: hubid.cpp:468

Referenced by HubIdBuildClassIds().

◆ HubIdBytesReturned()

static ULONG NTAPI HubIdBytesReturned ( _In_ HubChild *  Child)
static

Definition at line 1087 of file hubid.cpp.

1089{
1090 return min(Child->m_Control.Urb.TransferBufferLength, (ULONG)sizeof(Child->m_ScratchBuffer));
1091}
#define min(a, b)
Definition: monoChain.cc:55

Referenced by DeviceMachine::SameSerialNumber(), and DeviceMachine::SerialNumberValid().

◆ HubIdEmit()

static NTSTATUS NTAPI HubIdEmit ( _In_ const HubIdSink *  Sink,
_In_ PCUNICODE_STRING  Id 
)
static

Definition at line 198 of file hubid.cpp.

201{
203
204 if (Sink->Init != NULL)
205 {
206 switch (Sink->Kind)
207 {
209 Status = WdfPdoInitAssignDeviceID(Sink->Init, Id);
210 break;
211
213 Status = WdfPdoInitAddHardwareID(Sink->Init, Id);
214 break;
215
217 Status = WdfPdoInitAddCompatibleID(Sink->Init, Id);
218 break;
219
221 Status = WdfPdoInitAssignContainerID(Sink->Init, Id);
222 break;
223 }
224
225 if (!NT_SUCCESS(Status))
226 {
227 DPRINT1("Assigning id %wZ (kind %d) failed 0x%lx\n", Id, (int)Sink->Kind, Status);
228 return Status;
229 }
230 }
231
232 if (Sink->List != NULL)
233 Status = HubIdListAppend(Sink->List, Id);
234
235 return Status;
236}
static NTSTATUS NTAPI HubIdListAppend(_Inout_ PUSB_ID_STRING List, _In_ PCUNICODE_STRING Id)
Definition: hubid.cpp:130

Referenced by HubIdBuildDeviceId(), HubIdBuildHardwareIds(), HubIdEmitCounted(), and HubIdEmitText().

◆ HubIdEmitCounted()

static NTSTATUS NTAPI HubIdEmitCounted ( _In_ const HubIdSink *  Sink,
_In_reads_bytes_(IdBytes) PCWSTR  Id,
_In_ USHORT  IdBytes 
)
static

Emits a fixed id whose byte count is given as is, counted NUL included.

Definition at line 261 of file hubid.cpp.

265{
267
268 String.Buffer = (PWCH)Id;
269 String.Length = IdBytes;
270 String.MaximumLength = IdBytes;
271 return HubIdEmit(Sink, &String);
272}
WCHAR * PWCH
Definition: ntbasedef.h:422

Referenced by HubIdBuildCompatibleIds(), and HubIdBuildHardwareIds().

◆ HubIdEmitMsComp()

static NTSTATUS NTAPI HubIdEmitMsComp ( _In_ const HubIdSink *  Sink,
_In_reads_(8) const UCHAR *  CompatibleId,
_In_reads_opt_(8) const UCHAR *  SubCompatibleId 
)
static

Definition at line 468 of file hubid.cpp.

472{
474 WCHAR Field[9];
475
476 HubIdWidenMsOsField(CompatibleId, Field);
477 Text.Set(L"USB\\MS_COMP_");
478 Text.Append(Field);
479
480 if (SubCompatibleId != NULL)
481 {
482 HubIdWidenMsOsField(SubCompatibleId, Field);
483 Text.Append(L"&MS_SUBCOMP_");
484 Text.Append(Field);
485 }
486
487 return HubIdEmitText(Sink, &Text);
488}
static VOID NTAPI HubIdWidenMsOsField(_In_reads_(8) const UCHAR *Field, _Out_writes_(9) PWCHAR Text)
Definition: hubid.cpp:331

Referenced by HubIdBuildMsOsIds().

◆ HubIdEmitText()

static NTSTATUS NTAPI HubIdEmitText ( _In_ const HubIdSink *  Sink,
_In_ const HubIdText *  Text 
)
static

Definition at line 241 of file hubid.cpp.

244{
246
247 if (!NT_SUCCESS(Text->Status))
248 {
249 DPRINT1("Formatting an id failed 0x%lx\n", Text->Status);
250 return Text->Status;
251 }
252
253 RtlInitUnicodeString(&Id, Text->Buffer);
254 return HubIdEmit(Sink, &Id);
255}
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by HubIdBuildClassIds(), HubIdBuildCompatibleIds(), HubIdBuildCompositeIds(), HubIdBuildContainerId(), HubIdBuildDeviceId(), HubIdBuildHardwareIds(), and HubIdEmitMsComp().

◆ HubIdFreeDeviceIds()

VOID NTAPI HubIdFreeDeviceIds ( _In_ HubChild *  Child)

Frees the identity buffers of a device; called when the device object is destroyed.

Definition at line 813 of file hubid.cpp.

815{
816 if (Child->m_VmReservedId.Buffer != NULL)
817 ExFreePoolWithTag(Child->m_VmReservedId.Buffer, HUB_TAG_DEVICE);
818
819 RtlZeroMemory(&Child->m_VmReservedId, sizeof(Child->m_VmReservedId));
820}

◆ HubIdGenerateContainerId()

static VOID NTAPI HubIdGenerateContainerId ( _In_ HubChild *  Child)
static

Definition at line 647 of file hubid.cpp.

649{
650 const USB_DEVICE_DESCRIPTOR* Descriptor = &Child->m_DeviceDescriptor;
651 ULONG NameBytes = Child->m_SerialNumberLength + 28;
653 WCHAR Revision[5];
654 HubSha1 Sha;
655 PWCHAR Name;
656 size_t NameLength;
658
660 if (Name == NULL)
661 {
662 DPRINT1("Container id name for device %p could not be allocated\n", Child);
663 return;
664 }
665
666 if (Descriptor->bcdUSB > 0x0200)
667 {
668 /* bcdUSB, not bcdDevice, and space padded */
669 Status = RtlStringCbPrintfW(Name, NameBytes, L"%04X%04X.%4X",
670 Descriptor->idVendor, Descriptor->idProduct, Descriptor->bcdUSB);
671 }
672 else
673 {
674 HubIdRevisionText(Descriptor->bcdUSB, Descriptor->bcdDevice, Revision);
675 Status = RtlStringCbPrintfW(Name, NameBytes, L"%04X%04X", Descriptor->idVendor, Descriptor->idProduct);
676 if (NT_SUCCESS(Status))
677 Status = RtlStringCbCatW(Name, NameBytes, Revision);
678 }
679
680 if (NT_SUCCESS(Status))
681 Status = RtlStringCbCatW(Name, NameBytes, Child->m_SerialNumber + Child->m_SerialPrefixLength / sizeof(WCHAR));
682
683 if (NT_SUCCESS(Status))
685
686 if (!NT_SUCCESS(Status))
687 {
688 DPRINT1("Container id name for device %p failed: 0x%lx\n", Child, Status);
690 return;
691 }
692
693 HubSha1Init(&Sha);
696 HubSha1Final(&Sha, Digest);
698
699 RtlCopyMemory(&Child->m_ContainerId, Digest, sizeof(Child->m_ContainerId));
700 Child->m_ContainerId.Data3 = (Child->m_ContainerId.Data3 & 0x0FFF) | 0x5000;
701 Child->m_ContainerId.Data4[0] = (Child->m_ContainerId.Data4[0] & 0x3F) | 0x80;
703}
LPWSTR Name
Definition: desk.c:124
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const GUID HubContainerIdNamespace
Definition: hubid.cpp:26
VOID NTAPI HubSha1Init(_Out_ HubSha1 *Context)
Definition: hubsha1.cpp:90
VOID NTAPI HubSha1Update(_Inout_ HubSha1 *Context, _In_reads_bytes_(Length) const VOID *Data, _In_ SIZE_T Length)
Definition: hubsha1.cpp:103
VOID NTAPI HubSha1Final(_Inout_ HubSha1 *Context, _Out_writes_bytes_all_(HUB_SHA1_DIGEST_BYTES) PUCHAR Digest)
Definition: hubsha1.cpp:132
#define HUB_SHA1_DIGEST_BYTES
Definition: hubid.h:53
NTSTRSAFEAPI RtlStringCbCatW(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:636
_Must_inspect_result_ NTSTRSAFEAPI RtlStringCbLengthW(_In_reads_or_z_(cbMax/sizeof(wchar_t)) STRSAFE_LPCWSTR psz, _In_ _In_range_(1, NTSTRSAFE_MAX_CCH *sizeof(wchar_t)) size_t cbMax, _Out_opt_ _Deref_out_range_(<, cbMax - 1) size_t *pcbLength)
Definition: ntstrsafe.h:1641
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
Input NameLength
Definition: portacpi.cpp:298
Definition: hubid.h:46

Referenced by HubIdBuildContainerId().

◆ HubIdGetContainerId()

BOOLEAN NTAPI HubIdGetContainerId ( _In_ HubChild *  Child,
_Out_ GUID *  ContainerId 
)

Container id the PDO got; FALSE when it got none.

Definition at line 749 of file hubid.cpp.

752{
754
756 return FALSE;
757
758 *ContainerId = Child->m_ContainerId;
759 return TRUE;
760}
_Check_return_ _In_ ULONG _Inout_ PDXGK_CHILD_CONTAINER_ID ContainerId
Definition: dispmprt.h:1484
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

◆ HubIdGetSerialNumberText()

BOOLEAN NTAPI HubIdGetSerialNumberText ( _In_ HubChild *  Child,
_Outptr_result_bytebuffer_ *Length PCWSTR *  Text,
_Out_ PULONG  Length 
)

Cached serial number text without its decoration, for the serial string IOCTL.

Definition at line 1111 of file hubid.cpp.

1115{
1116 *Text = NULL;
1117 *Length = 0;
1118
1119 if (Child->m_SerialNumber == NULL ||
1120 Child->m_SerialNumberLength < Child->m_SerialPrefixLength + sizeof(WCHAR))
1121 {
1122 return FALSE;
1123 }
1124
1125 *Text = Child->m_SerialNumber + Child->m_SerialPrefixLength / sizeof(WCHAR);
1126 *Length = Child->m_SerialNumberLength - Child->m_SerialPrefixLength - sizeof(WCHAR);
1127 return TRUE;
1128}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Referenced by HubIoGetDescriptor(), and DeviceMachine::SameSerialNumber().

◆ HubIdHasContainerId()

static BOOLEAN NTAPI HubIdHasContainerId ( _In_ HubChild *  Child)
static

Definition at line 708 of file hubid.cpp.

710{
711 return Child->HasProperty(ChildProperty::ContainerIdKnown) ||
713}

Referenced by HubIdBuildContainerId(), and HubIdGetContainerId().

◆ HubIdIsKnown()

static BOOLEAN NTAPI HubIdIsKnown ( _In_ HubChild *  Child)
static

Definition at line 279 of file hubid.cpp.

281{
282 return Child->HasState(ChildState::WorkingDevice);
283}

Referenced by HubIdBuildDeviceId(), and HubIdUsesFailureId().

◆ HubIdIsVmReserved()

static BOOLEAN NTAPI HubIdIsVmReserved ( _In_ HubChild *  Child)
static

Definition at line 298 of file hubid.cpp.

300{
301 return Child->HasProperty(ChildProperty::UxdReserved) &&
302 !Child->HasProperty(ChildProperty::IsHub);
303}

Referenced by HubIdBuildDeviceId(), and HubIdBuildHardwareIds().

◆ HubIdLanguageSupported()

BOOLEAN NTAPI HubIdLanguageSupported ( _In_ HubChild *  Child,
_In_ USHORT  Language 
)

TRUE when the device lists Language among its string languages.

Definition at line 911 of file hubid.cpp.

914{
915 const USB_STRING_DESCRIPTOR* List = Child->m_LanguageIds;
916 ULONG Count;
917 ULONG Index;
918
919 if (List == NULL || List->bLength <= 2)
920 return FALSE;
921
922 Count = (List->bLength - 2) / sizeof(WCHAR);
923 for (Index = 0; Index < Count && List->bString[Index] != 0; Index++)
924 {
925 if (List->bString[Index] == Language)
926 return TRUE;
927 }
928
929 return FALSE;
930}
USHORT Count
Definition: userreq.cpp:200
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by DeviceMachine::ProductNameWanted().

◆ HubIdListAppend()

static NTSTATUS NTAPI HubIdListAppend ( _Inout_ PUSB_ID_STRING  List,
_In_ PCUNICODE_STRING  Id 
)
static

Definition at line 130 of file hubid.cpp.

133{
134 ULONG Kept = (List->Buffer != NULL) ? List->LengthInBytes - sizeof(WCHAR) : 0;
135 ULONG Total = Kept + Id->Length + 2 * sizeof(WCHAR);
137
139 if (Buffer == NULL)
140 {
141 DPRINT1("Id list of %lu bytes could not be allocated\n", Total);
143 }
144
145 if (Kept != 0)
146 RtlCopyMemory(Buffer, List->Buffer, Kept);
148
149 if (List->Buffer != NULL)
151
152 List->Buffer = Buffer;
153 List->LengthInBytes = Total;
154 return STATUS_SUCCESS;
155}
ULONG Total
Definition: hubwmi.cpp:548
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by HubIdEmit().

◆ HubIdListCopy()

NTSTATUS NTAPI HubIdListCopy ( _Out_ PUSB_ID_STRING  Destination,
_In_ const USB_ID_STRING *  Source 
)

Duplicates a multi-sz id list into nonpaged pool.

Definition at line 173 of file hubid.cpp.

176{
178
179 if (Source->Buffer == NULL || Source->LengthInBytes == 0)
180 return STATUS_SUCCESS;
181
184 if (Destination->Buffer == NULL)
185 {
186 DPRINT1("Id list copy of %lu bytes could not be allocated\n", Source->LengthInBytes);
188 }
189
190 RtlCopyMemory(Destination->Buffer, Source->Buffer, Source->LengthInBytes);
191 return STATUS_SUCCESS;
192}
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3051

Referenced by if().

◆ HubIdListFree()

VOID NTAPI HubIdListFree ( _Inout_ PUSB_ID_STRING  Ids)

Frees a multi-sz id list; an empty list is fine.

Definition at line 159 of file hubid.cpp.

161{
162 if (Ids->Buffer == NULL)
163 return;
164
166 Ids->Buffer = NULL;
167 Ids->LengthInBytes = 0;
168}

◆ HubIdRevisionText()

static VOID NTAPI HubIdRevisionText ( _In_ USHORT  BcdUsb,
_In_ USHORT  BcdDevice,
_Out_writes_(5) PWCHAR  Text 
)
static

Definition at line 309 of file hubid.cpp.

313{
314 static const WCHAR HexDigits[] = L"0123456789ABCDEF";
315 ULONG Index;
316 ULONG Nibble;
317
318 for (Index = 0; Index < 4; Index++)
319 {
320 Nibble = (BcdDevice >> (12 - Index * 4)) & 0xF;
321 Text[Index] = (BcdUsb > 0x0200) ? HexDigits[Nibble] : (WCHAR)(L'0' + Nibble);
322 }
323
324 Text[4] = UNICODE_NULL;
325}
#define UNICODE_NULL

Referenced by HubIdBuildHardwareIds(), and HubIdGenerateContainerId().

◆ HubIdSerialPrefix()

static PCWSTR NTAPI HubIdSerialPrefix ( _In_ HubChild *  Child)
static

Definition at line 1097 of file hubid.cpp.

1099{
1100 if (Child->HasProperty(ChildProperty::IsHub))
1101 return (Child->m_DeviceDescriptor.bcdUSB >= 0x0300) ? L"MSFT30" : L"MSFT20";
1102
1103 if (Child->HasState(ChildState::PrefixedSerial))
1104 return L"MSFT30";
1105
1106 return NULL;
1107}

Referenced by DeviceMachine::SerialNumberValid().

◆ HubIdUsesFailureId()

static BOOLEAN NTAPI HubIdUsesFailureId ( _In_ HubChild *  Child)
static

Definition at line 289 of file hubid.cpp.

291{
293}
@ ConfigurationValid

Referenced by HubIdBuildCompatibleIds(), HubIdBuildDeviceId(), and HubIdBuildHardwareIds().

◆ HubIdWidenMsOsField()

static VOID NTAPI HubIdWidenMsOsField ( _In_reads_(8) const UCHAR *  Field,
_Out_writes_(9) PWCHAR  Text 
)
static

Definition at line 331 of file hubid.cpp.

334{
335 ULONG Index;
336
337 for (Index = 0; Index < 8 && Field[Index] != 0; Index++)
338 Text[Index] = Field[Index];
339
341}

Referenced by HubIdEmitMsComp().

◆ HubSaveUxdState()

HubSaveUxdState ( Child->  m_Hub,
Child  ,
NULL   
)

Referenced by HubIoCyclePort().

◆ Id()

◆ if() [1/10]

if ( !  NT_SUCCESSStatus)

Definition at line 965 of file hubid.cpp.

966 {
967 DPRINT1("Location text for device %p failed 0x%lx\n", Child, Status);
969 return Status;
970 }

◆ if() [2/10]

if ( Child->  HasPropertyChildProperty::UxdReserved)

Definition at line 882 of file hubid.cpp.

883 {
884 Status = HubIdLoadVmReservedId(Child);
885 if (!NT_SUCCESS(Status))
886 return Status;
887 }

◆ if() [3/10]

if ( Child->m_DeviceDescriptor.  iProduct = =0||Child->HasHack(ChildHack::DisableSerialNumber))

◆ if() [4/10]

if ( Child->  m_ProductString = = NULL)

Definition at line 1014 of file hubid.cpp.

1015 {
1016 if (Language == HUB_DEFAULT_LANGUAGE)
1017 {
1018 DPRINT("Device %p has no product string\n", Child);
1019 return STATUS_NOT_SUPPORTED;
1020 }
1021
1022 Child->m_LanguageId = HUB_DEFAULT_LANGUAGE;
1023 HubIdReadProductString(Child);
1024
1025 if (Child->m_ProductString == NULL)
1026 {
1027 DPRINT("Device %p has no product string\n", Child);
1028 return STATUS_NOT_SUPPORTED;
1029 }
1030 }
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define HUB_DEFAULT_LANGUAGE
Definition: hubid.cpp:23
#define DPRINT
Definition: sndvol32.h:73

◆ if() [5/10]

if ( Child->m_SerialNumber !  = NULL)

Definition at line 839 of file hubid.cpp.

840 {
841 RtlInitUnicodeString(&Id, Child->m_SerialNumber);
842 Status = WdfPdoInitAssignInstanceID(DeviceInit, &Id);
843 if (!NT_SUCCESS(Status))
844 DPRINT1("Instance id %wZ for device %p failed 0x%lx\n", &Id, Child, Status);
845
846 return Status;
847 }

◆ if() [6/10]

if ( Language !  = Child->m_LanguageId)

Definition at line 1002 of file hubid.cpp.

1003 {
1004 Child->m_LanguageId = Language;
1005 if (Child->m_ProductString != NULL)
1006 {
1007 ExFreePoolWithTag(Child->m_ProductString, HUB_TAG_DEVICE);
1008 Child->m_ProductString = NULL;
1009 }
1010
1011 HubIdReadProductString(Child);
1012 }

◆ if() [7/10]

if ( Language  = =0||!HubIdLanguageSupported(Child, Language))

◆ if() [8/10]

if ( NT_SUCCESS(Status)  )

Definition at line 169 of file userreq.cpp.

170 {
171 User.SetStatus(UsbUserSuccess);
172 Name->Length = ResultLength + sizeof(WCHAR);
173 }
_In_ PGUID _In_ ULONG _Out_ PULONG ResultLength
Definition: ucxcontroller.h:83
UNICODE_STRING Name
Definition: userreq.cpp:197

◆ if() [9/10]

if ( Port->HasProperty(PortProperty::TypeCWithoutSwitch) &&Port->m_InstancePortNumber !  = 0 && HubIdIsKnown(Child))

Definition at line 850 of file hubid.cpp.

853 {
854 Number = Port->m_InstancePortNumber;
855 }
CPPORT Port[4]
Definition: headless.c:38
_In_ ULONG Number
Definition: haltypes.h:1940

◆ if() [10/10]

if ( Text  = = NULL)

Definition at line 957 of file hubid.cpp.

958 {
959 DPRINT1("Location text for device %p could not be allocated\n", Child);
961 }

◆ IoCompleteRequest()

IoCompleteRequest ( Irp  ,
IO_NO_INCREMENT   
)

◆ PAGED_CODE()

PAGED_CODE ( )

Referenced by _IRQL_requires_().

◆ RtlCopyMemory()

RtlCopyMemory ( Text  ,
Product->  bString,
(Characters - 1) *sizeof(WCHAR)   
)

◆ switch()

switch ( Stack->Parameters.QueryDeviceText.  DeviceTextType)

Definition at line 1061 of file hubid.cpp.

1062 {
1064 Status = HubIdLocationText(Child, Irp);
1065 break;
1066
1068 Status = HubIdDescriptionText(Child, Irp, Stack->Parameters.QueryDeviceText.LocaleId);
1069 break;
1070
1071 default:
1073 break;
1074 }
_In_ PIRP Irp
Definition: kse.h:79
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
@ DeviceTextLocationInformation
Definition: iotypes.h:2961
@ DeviceTextDescription
Definition: iotypes.h:2960

Variable Documentation

◆ Characters

Characters = (Product->bLength - 2) / sizeof(WCHAR) + 1

Definition at line 991 of file hubid.cpp.

◆ Child

Definition at line 864 of file hubid.cpp.

◆ DeviceInit

◆ Digits

Definition at line 834 of file hubid.cpp.

Referenced by AcpiUtPutNumber(), and GetDigitCount().

◆ HubBillboardId

const WCHAR HubBillboardId[] = L"USB\\Class_11&SubClass_00&Prot_00"
static

Definition at line 56 of file hubid.cpp.

Referenced by HubIdBuildCompatibleIds().

◆ HubContainerIdNamespace

const GUID HubContainerIdNamespace
static
Initial value:
=
{ 0x4B06FD46, 0xC84E, 0x4664, { 0x9C, 0x65, 0x0C, 0x86, 0xD9, 0x04, 0x7A, 0x0C } }

Definition at line 26 of file hubid.cpp.

Referenced by HubIdGenerateContainerId().

◆ HubFailureIds

const HubFailureId HubFailureIds[]
static
Initial value:
=
{
HUB_FAILURE_ID(HUB_ENUM_DEVICE_DESCRIPTOR_FAILED, 0x0002, L"USB\\DEVICE_DESCRIPTOR_FAILURE"),
HUB_FAILURE_ID(HUB_ENUM_SET_ADDRESS_FAILED, 0x0004, L"USB\\SET_ADDRESS_FAILURE"),
HUB_FAILURE_ID(HUB_ENUM_PORT_RESET_FAILED, 0x0001, L"USB\\RESET_FAILURE"),
HUB_FAILURE_ID(HUB_ENUM_BAD_CONFIG_DESCRIPTOR, 0x0006, L"USB\\CONFIGURATION_DESCRIPTOR_VALIDATION_FAILURE"),
HUB_FAILURE_ID(HUB_ENUM_BAD_DEVICE_DESCRIPTOR, 0x0005, L"USB\\DEVICE_DESCRIPTOR_VALIDATION_FAILURE"),
HUB_FAILURE_ID(HUB_ENUM_CONFIG_DESCRIPTOR_FAILED, 0x0003, L"USB\\CONFIG_DESCRIPTOR_FAILURE"),
HUB_FAILURE_ID(HUB_ENUM_LINK_SS_INACTIVE, 0x0007, L"USB\\PORT_LINK_SSINACTIVE"),
HUB_FAILURE_ID(HUB_ENUM_LINK_COMPLIANCE, 0x0008, L"USB\\PORT_LINK_COMPLIANCE_MODE"),
}
#define HUB_FAILURE_ID(Reason, Pid, Text)
Definition: hubid.cpp:38
#define HUB_ENUM_DEVICE_DESCRIPTOR_FAILED
Definition: hubid.h:11
#define HUB_ENUM_BAD_DEVICE_DESCRIPTOR
Definition: hubid.h:15
#define HUB_ENUM_SET_ADDRESS_FAILED
Definition: hubid.h:12
#define HUB_ENUM_BAD_CONFIG_DESCRIPTOR
Definition: hubid.h:14
#define HUB_ENUM_PORT_RESET_FAILED
Definition: hubid.h:13
#define HUB_ENUM_LINK_COMPLIANCE
Definition: hubid.h:33
#define HUB_ENUM_CONFIG_DESCRIPTOR_FAILED
Definition: hubid.h:16
#define HUB_ENUM_LINK_SS_INACTIVE
Definition: hubid.h:32

Definition at line 40 of file hubid.cpp.

Referenced by HubFailureIdFor().

◆ HubUnknownDeviceId

const HubFailureId HubUnknownDeviceId
static
Initial value:
=
HUB_FAILURE_ID(0, 0x0000, L"USB\\UNKNOWN_DEVICE")

Definition at line 52 of file hubid.cpp.

Referenced by HubFailureIdFor().

◆ Id

◆ Information

Definition at line 972 of file hubid.cpp.

◆ Irp

Initial value:

Definition at line 951 of file hubid.cpp.

◆ Locale

◆ Number

Definition at line 836 of file hubid.cpp.

◆ Product

Product = Child->m_ProductString

◆ Status

◆ STATUS_SUCCESS

◆ Text