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

Go to the source code of this file.

Macros

#define NDEBUG
 
#define HUB_WMI_MIN_ACQUIRE_SIZE   10
 
#define HUB_WMI_FIELD(Info, Field)    ((PUCHAR)(Info) + FIELD_OFFSET(USB_DEVICE_NODE_INFO, Field))
 

Functions

 C_ASSERT (sizeof(USB_CONNECTION_NOTIFICATION)==24)
 
 C_ASSERT (sizeof(USB_BUS_NOTIFICATION)==16)
 
 C_ASSERT (FIELD_OFFSET(USB_ACQUIRE_INFO, Buffer)==8)
 
 C_ASSERT (sizeof(USB_PIPE_INFO)==11)
 
 C_ASSERT (sizeof(USB_HUB_PORT_INFORMATION)==16)
 
 C_ASSERT (sizeof(USB_DEVICE_NODE_INFO)==1202)
 
 C_ASSERT (FIELD_OFFSET(USB_DEVICE_NODE_INFO, UsbDeviceInfo.PipeList)==1191)
 
 C_ASSERT (FIELD_OFFSET(USB_DEVICE_NODE_INFO, HubDeviceInfo.PortInfo)==211)
 
static PCWSTR NTAPI HubWmiHubName (_In_ HubFdo *Hub, _Out_ PULONG Length)
 
static VOID NTAPI HubWmiFirePortEvent (_In_ HubFdo *Hub, _In_ ULONG PortNumber, _In_ USB_NOTIFICATION_TYPE Type)
 
 _IRQL_requires_ (PASSIVE_LEVEL) static NTSTATUS NTAPI HubWmiCreateInstance(_In_ WDFDEVICE Device
 Sends a synchronous IOCTL to the specified device object.
 
return WdfWmiInstanceCreate (Device, &Config, Attributes, Instance)
 
VOID NTAPI HubMakeUsb2StyleDescriptor (_In_ HubFdo *Hub, _Out_ PUSB_HUB_DESCRIPTOR Descriptor)
 
 WdfFdoLockStaticChildListForIteration (Hub->m_Device)
 
 while ((Child=WdfFdoRetrieveNextStaticChild(Hub->m_Device, Child, WdfRetrievePresentChildren)) !=NULL)
 
 WdfFdoUnlockStaticChildListFromIteration (Hub->m_Device)
 
static NTSTATUS NTAPI HubWmiQueryHubNode (_In_ WDFWMIINSTANCE WmiInstance, _In_ ULONG OutBufferSize, _Out_writes_bytes_to_(OutBufferSize, *BufferUsed) PVOID OutBuffer, _Out_ PULONG BufferUsed)
 
_In_ DEVICE_REGISTRY_PROPERTY _Out_writes_bytes_ (Size) PUCHAR Destination
 
 if (!NT_SUCCESS(WdfDeviceAllocAndQueryProperty(Device, Property, NonPagedPool, &Attributes, &Memory))) return
 
 RtlCopyMemory (Destination, Data, min(Length,(size_t) Size))
 
 WdfObjectDelete (Memory)
 
static VOID NTAPI HubWmiCopyPipes (_In_ HubConfiguration *Config, _Out_ PUSB_PIPE_INFO Pipes)
 
static NTSTATUS NTAPI HubWmiQueryDeviceNode (_In_ WDFWMIINSTANCE WmiInstance, _In_ ULONG OutBufferSize, _Out_writes_bytes_to_(OutBufferSize, *BufferUsed) PVOID OutBuffer, _Out_ PULONG BufferUsed)
 
static NTSTATUS NTAPI HubWmiResetOverCurrent (_In_ HubFdo *Hub, _In_ PUSB_CONNECTION_NOTIFICATION Request)
 
 if (OutBufferSize< sizeof(*Notification))
 
 if (!NT_SUCCESS(Status))
 
static BOOLEAN NTAPI HubWmiAcquireSizeValid (_In_ PUSB_ACQUIRE_INFO Request, _In_ ULONG OutBufferSize)
 
static NTSTATUS NTAPI HubWmiHubNameRequest (_In_ HubFdo *Hub, _In_ ULONG OutBufferSize, _Inout_ PUSB_ACQUIRE_INFO Request, _Out_ PULONG BufferUsed)
 
 if (!HubWmiAcquireSizeValid(Request, OutBufferSize)) return STATUS_BUFFER_TOO_SMALL
 
static NTSTATUS NTAPI HubWmiExecuteMethod (_In_ WDFWMIINSTANCE WmiInstance, _In_ ULONG MethodId, _In_ ULONG InBufferSize, _In_ ULONG OutBufferSize, _Inout_ PVOID Buffer, _Out_ PULONG BufferUsed)
 
static VOID NTAPI HubWmiEvtSurpriseRemovalCleanup (_In_ WDFOBJECT Object)
 
VOID NTAPI HubWmiNotifyOverCurrent (_In_ HubFdo *Hub, _In_ ULONG PortNumber)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) VOID NTAPI HubWmiNotifyEnumerationFailure(_In_ HubFdo *Hub
 

Variables

static const GUID HubWmiSurpriseRemovalGuid
 
static KSPIN_LOCK HubWmiSurpriseLock
 
_In_ const GUID * Guid
 
_In_ const GUID _In_ ULONG ProviderFlags
 
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE Query
 
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE _In_opt_ PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD Method
 
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE _In_opt_ PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
 
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE _In_opt_ PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
 
WDF_WMI_INSTANCE_CONFIG Config
 
WDF_WMI_PROVIDER_CONFIG_INIT & Provider
 
Provider Flags = ProviderFlags
 
Config Register = TRUE
 
Config EvtWmiInstanceQueryInstance = Query
 
Config EvtWmiInstanceExecuteMethod = Method
 
_In_ HubPort * Port
 
_In_ HubPort _In_ USHORT PortNumber
 
_In_ HubPort _In_ USHORT _Out_ PUSHORT DeviceAddress
 
HubPdo * Pdo
 
return Port m_ConnectionStatus
 
_In_ DEVICE_REGISTRY_PROPERTY Property
 
_In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG Size
 
WDFMEMORY Memory
 
size_t Length
 
PVOID Data = WdfMemoryGetBuffer(Memory, &Length)
 
Attributes ParentObject = Device
 
_In_ ULONG OutBufferSize
 
_In_ ULONG _Inout_ PUSB_BUS_NOTIFICATION Notification
 
_In_ ULONG _Inout_ PUSB_BUS_NOTIFICATION _Out_ PULONG BufferUsed
 
NTSTATUS Status = HubQueryControllerName(Hub, &Name, sizeof(Name))
 
Name ActualLength = 0
 
Name HubName [0] = UNICODE_NULL
 
Notification TotalBandwidth = 0
 
Notification ConsumedBandwidth = 0
 
Notification ControllerNameLength = Name.ActualLength
 
return STATUS_SUCCESS
 
_In_ ULONG _Inout_ PUSB_ACQUIRE_INFO Request
 
ULONG Total = Request->TotalSize
 
Request TotalSize = Total - sizeof(ULONG)
 

Macro Definition Documentation

◆ HUB_WMI_FIELD

#define HUB_WMI_FIELD (   Info,
  Field 
)     ((PUCHAR)(Info) + FIELD_OFFSET(USB_DEVICE_NODE_INFO, Field))

Definition at line 31 of file hubwmi.cpp.

◆ HUB_WMI_MIN_ACQUIRE_SIZE

#define HUB_WMI_MIN_ACQUIRE_SIZE   10

Definition at line 28 of file hubwmi.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file hubwmi.cpp.

Function Documentation

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Sends a synchronous IOCTL to the specified device object.

Copies up to Size bytes of a device property; a failed query leaves the field zero.

Only the controller name length is real; both bandwidth fields read 0.

The answer overlays a USB_HUB_NAME on TotalSize, so TotalSize comes back as the name length + 4.

Definition at line 621 of file hubwmi.cpp.

626{
627 WDFWMIINSTANCE Instance;
629
630 /* Runs on every start; earlier instances stay registered */
631 Status = HubWmiCreateInstance(Hub->m_Device,
632 &GUID_USB_WMI_STD_DATA,
633 0,
634 NULL,
637 &Instance);
638 if (NT_SUCCESS(Status))
640 else
641 DPRINT1("Hub %p: WMI notification provider failed 0x%lx\n", Hub, Status);
642
643 Status = HubWmiCreateInstance(Hub->m_Device,
644 &GUID_USB_WMI_NODE_INFO,
645 0,
647 NULL,
649 NULL);
650 if (!NT_SUCCESS(Status))
651 DPRINT1("Hub %p: WMI node info provider failed 0x%lx\n", Hub, Status);
652}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
HubFdo * Hub
Definition: bootdev.cpp:261
WDFWMIINSTANCE m_WmiInstance
Definition: fdo.h:448
WDFDEVICE m_Device
Definition: fdo.h:349
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:24
static NTSTATUS NTAPI HubWmiQueryHubNode(_In_ WDFWMIINSTANCE WmiInstance, _In_ ULONG OutBufferSize, _Out_writes_bytes_to_(OutBufferSize, *BufferUsed) PVOID OutBuffer, _Out_ PULONG BufferUsed)
Definition: hubwmi.cpp:212
NTSTATUS Status
Definition: hubwmi.cpp:461
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE _In_opt_ PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: hubwmi.cpp:118
static NTSTATUS NTAPI HubWmiExecuteMethod(_In_ WDFWMIINSTANCE WmiInstance, _In_ ULONG MethodId, _In_ ULONG InBufferSize, _In_ ULONG OutBufferSize, _Inout_ PVOID Buffer, _Out_ PULONG BufferUsed)
Definition: hubwmi.cpp:573
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION; the idle machine owns the IRP afterwards.

Records hub over current in the hub hardware key, once per devnode.

First selective suspend of the device; the registry write runs in a work item.

"USB device not recognized" popup for a port.

A hub was attached beyond the allowed tier depth.

The selected configuration draws more power than the port can give.

The controller ran out of bandwidth for the device; fired by the out of bandwidth timer.

Definition at line 77 of file common.c.

3587{
3589 BOOLEAN requestSent = FALSE;
3590
3591 BOOLEAN shouldRetry = TRUE;
3592 PCDB cdb = (PCDB)DeviceExtension->PowerContext.Srb.Cdb;
3593 ULONG timeoutValue = DeviceExtension->TimeOutValue;
3594 ULONG retryCount = 1;
3595
3596 // reset some fields.
3597 DeviceExtension->PowerContext.RetryIntervalIn100ns = 0;
3598 status = PowerContextReuseRequest(DeviceExtension);
3599 RequestClearSendTime(DeviceExtension->PowerContext.PowerRequest);
3600
3601 if (!NT_SUCCESS(status))
3602 {
3603 return status;
3604 }
3605
3606 // set proper timeout value and max retry count.
3607 switch(DeviceExtension->PowerContext.PowerChangeState.PowerDown)
3608 {
3612 break;
3613
3615 // Case of issuing SYNC CACHE command. Do not use power irp timeout remaining time in this case
3616 // as we want to give best try on SYNC CACHE command.
3617 retryCount = MAXIMUM_RETRIES;
3618 timeoutValue = DeviceExtension->TimeOutValue;
3619 break;
3620
3622 {
3623 // Case of issuing STOP UNIT command
3624 // As "Imme" bit is set to '1', this command should be completed in short time.
3625 // This command is at low importance, failure of this command has very small impact.
3626 ULONG secondsRemaining = 0;
3627
3628#if (WINVER >= 0x0601)
3629 // this API is introduced in Windows7
3630 PoQueryWatchdogTime(DeviceExtension->LowerPdo, &secondsRemaining);
3631#endif
3632
3633 if (secondsRemaining == 0)
3634 {
3635 // not able to retrieve remaining time from PoQueryWatchdogTime API, use default values.
3636 retryCount = MAXIMUM_RETRIES;
3637 timeoutValue = SCSI_CDROM_TIMEOUT;
3638 }
3639 else
3640 {
3641 // plan to leave about 30 seconds to lower level drivers if possible.
3642 if (secondsRemaining >= 32)
3643 {
3644 retryCount = (secondsRemaining - 30)/SCSI_CDROM_TIMEOUT + 1;
3645 timeoutValue = SCSI_CDROM_TIMEOUT;
3646
3647 if (retryCount > MAXIMUM_RETRIES)
3648 {
3649 retryCount = MAXIMUM_RETRIES;
3650 }
3651
3652 if (retryCount == 1)
3653 {
3654 timeoutValue = secondsRemaining - 30;
3655 }
3656 }
3657 else
3658 {
3659 // issue the command with minimal timeout value and do not retry on it.
3660 retryCount = 1;
3661 timeoutValue = 2;
3662 }
3663 }
3664 }
3665 break;
3666 default:
3667 NT_ASSERT( FALSE );
3669 return status;
3670 }
3671
3672 DeviceExtension->PowerContext.RetryCount = retryCount;
3673
3674 // issue command.
3675 while (shouldRetry)
3676 {
3677
3678 // set SRB fields.
3679 DeviceExtension->PowerContext.Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
3684
3685 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
3686 DeviceExtension->PowerContext.Srb.TimeOutValue = timeoutValue;
3687
3688 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceInitial)
3689 {
3690 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_LOCK_QUEUE;
3691 }
3692 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceLocked)
3693 {
3694 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_QUIESCE_DEVICE;
3695 }
3696 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3697 {
3698 // Case of issuing SYNC CACHE command.
3699 DeviceExtension->PowerContext.Srb.CdbLength = 10;
3700 cdb->SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE;
3701 }
3702 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceFlushed)
3703 {
3704 // Case of issuing STOP UNIT command.
3705 DeviceExtension->PowerContext.Srb.CdbLength = 6;
3706 cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
3707 cdb->START_STOP.Start = 0;
3708 cdb->START_STOP.Immediate = 1;
3709 }
3710 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceStopped)
3711 {
3712 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
3713 }
3714
3715 // Set up completion routine and context if requested
3717 {
3718 WdfRequestSetCompletionRoutine(DeviceExtension->PowerContext.PowerRequest,
3720 Context);
3721 }
3722
3723 status = RequestSend(DeviceExtension,
3724 DeviceExtension->PowerContext.PowerRequest,
3725 DeviceExtension->IoTarget,
3727 &requestSent);
3728
3729 if (requestSent)
3730 {
3731 if ((CompletionRoutine == NULL) &&
3732 (SRB_STATUS(DeviceExtension->PowerContext.Srb.SrbStatus) != SRB_STATUS_SUCCESS))
3733 {
3734 TracePrint((TRACE_LEVEL_ERROR,
3735 TRACE_FLAG_POWER,
3736 "%p\tError occured when issuing %s command to device. Srb %p, Status %x\n",
3737 DeviceExtension->PowerContext.PowerRequest,
3738 (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced) ? "SYNC CACHE" : "STOP UNIT",
3739 &DeviceExtension->PowerContext.Srb,
3740 DeviceExtension->PowerContext.Srb.SrbStatus));
3741
3742 NT_ASSERT(!(TEST_FLAG(DeviceExtension->PowerContext.Srb.SrbStatus, SRB_STATUS_QUEUE_FROZEN)));
3743
3744 shouldRetry = RequestSenseInfoInterpret(DeviceExtension,
3745 DeviceExtension->PowerContext.PowerRequest,
3746 &(DeviceExtension->PowerContext.Srb),
3747 retryCount - DeviceExtension->PowerContext.RetryCount,
3748 &status,
3749 &(DeviceExtension->PowerContext.RetryIntervalIn100ns));
3750
3751 if (shouldRetry && (DeviceExtension->PowerContext.RetryCount-- == 0))
3752 {
3753 shouldRetry = FALSE;
3754 }
3755 }
3756 else
3757 {
3758 // succeeded, do not need to retry.
3759 shouldRetry = FALSE;
3760 }
3761
3762 }
3763 else
3764 {
3765 // request failed to be sent
3766 shouldRetry = FALSE;
3767 }
3768
3769 if (shouldRetry)
3770 {
3772 t.QuadPart = -DeviceExtension->PowerContext.RetryIntervalIn100ns;
3774
3775 status = PowerContextReuseRequest(DeviceExtension);
3776 if (!NT_SUCCESS(status))
3777 {
3778 shouldRetry = FALSE;
3779 }
3780 }
3781 }
3782
3783 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3784 {
3785 // record SYNC CACHE command completion time stamp.
3786 KeQueryTickCount(&DeviceExtension->PowerContext.Step1CompleteTime);
3787 }
3788
3789 return status;
3790}
unsigned char BOOLEAN
Definition: actypes.h:127
#define MAXIMUM_RETRIES
Definition: cdrom.h:124
#define SCSI_CDROM_TIMEOUT
Definition: cdrom.h:680
BOOLEAN RequestSenseInfoInterpret(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ PSCSI_REQUEST_BLOCK Srb, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2467
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
@ PowerDownDeviceStopped
Definition: cdrom.h:412
@ PowerDownDeviceQuiesced
Definition: cdrom.h:410
@ PowerDownDeviceInitial
Definition: cdrom.h:408
@ PowerDownDeviceLocked
Definition: cdrom.h:409
@ PowerDownDeviceFlushed
Definition: cdrom.h:411
union _CDB * PCDB
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
Definition: common.c:111
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_FLAGS_NO_DATA_TRANSFER
Definition: srb.h:402
#define SRB_FUNCTION_LOCK_QUEUE
Definition: srb.h:332
#define SRB_FUNCTION_UNLOCK_QUEUE
Definition: srb.h:333
#define SRB_FLAGS_BYPASS_LOCKED_QUEUE
Definition: srb.h:410
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:397
#define SRB_STATUS(Status)
Definition: srb.h:389
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:386
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:404
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
GLdouble GLdouble t
Definition: gl.h:2047
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE CompletionRoutine
Definition: kse.h:80
#define KernelMode
Definition: asm.h:38
#define SRB_FLAGS_D3_PROCESSING
Definition: srb.h:165
#define SRB_FUNCTION_QUIESCE_DEVICE
Definition: srb.h:99
#define KeQueryTickCount(CurrentCount)
Definition: ke.h:43
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
Definition: cdrw_hw.h:28
struct _CDB::_START_STOP START_STOP
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
@ WDF_REQUEST_SEND_OPTION_SYNCHRONOUS
Definition: wdfrequest.h:109
#define NT_ASSERT
Definition: rtlfuncs.h:3334

◆ _Out_writes_bytes_()

_In_ DEVICE_REGISTRY_PROPERTY _Out_writes_bytes_ ( Size  )

Definition at line 35 of file hubregistry.cpp.

109{
111
114
116}
_In_ const HubIdStrings _In_ PCWSTR ValueName
_In_ PCWSTR Name
return WdfRegistryQueryValue(Key, Name, sizeof(*Record), Record, NULL, NULL)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

◆ C_ASSERT() [1/8]

C_ASSERT ( FIELD_OFFSET(USB_ACQUIRE_INFO, Buffer)  = =8)

◆ C_ASSERT() [2/8]

C_ASSERT ( FIELD_OFFSET(USB_DEVICE_NODE_INFO, HubDeviceInfo.PortInfo)  = =211)

◆ C_ASSERT() [3/8]

C_ASSERT ( FIELD_OFFSET(USB_DEVICE_NODE_INFO, UsbDeviceInfo.PipeList)  = =1191)

◆ C_ASSERT() [4/8]

C_ASSERT ( sizeof(USB_BUS_NOTIFICATION)  = =16)

◆ C_ASSERT() [5/8]

C_ASSERT ( sizeof(USB_CONNECTION_NOTIFICATION)  = =24)

◆ C_ASSERT() [6/8]

C_ASSERT ( sizeof(USB_DEVICE_NODE_INFO)  = =1202)

◆ C_ASSERT() [7/8]

C_ASSERT ( sizeof(USB_HUB_PORT_INFORMATION)  = =16)

◆ C_ASSERT() [8/8]

C_ASSERT ( sizeof(USB_PIPE_INFO)  = =11)

◆ HubMakeUsb2StyleDescriptor()

VOID NTAPI HubMakeUsb2StyleDescriptor ( _In_ HubFdo *  Hub,
_Out_ PUSB_HUB_DESCRIPTOR  Descriptor 
)

The 71 byte USB 2.0 style hub descriptor legacy tools expect, for any hub speed.

Definition at line 135 of file hubwmi.cpp.

138{
139 ULONG MaskBytes;
140
142
143 if (Hub->IsRootHub())
144 {
145 Descriptor->bPowerOnToPowerGood = 2;
146 }
148 {
150 return;
151 }
152 else if (Hub->m_Parent.HubSpeed == UsbSuperSpeed)
153 {
154 Descriptor->wHubCharacteristics = Hub->m_HubDescriptor.Usb30.wHubCharacteristics & 0x1F;
157 }
158 else
159 {
160 /* A low speed hub cannot exist */
161 return;
162 }
163
164 /* Always 9, even when more than 7 ports need a longer mask */
165 Descriptor->bDescriptorLength = 9;
166 Descriptor->bDescriptorType = USB_20_HUB_DESCRIPTOR_TYPE;
167 Descriptor->bNumberOfPorts = (UCHAR)Hub->m_PortCount;
168
169 /* All ports removable, followed by an all ones power control mask */
170 MaskBytes = Descriptor->bNumberOfPorts / 8 + 1;
171 RtlFillMemory(&Descriptor->bRemoveAndPowerMask[MaskBytes], MaskBytes, 0xFF);
172}
USB_HUB_DESCRIPTOR Usb20
Definition: fdo.h:419
ULONG m_PortCount
Definition: fdo.h:379
USB_30_HUB_DESCRIPTOR Usb30
Definition: fdo.h:420
UCXHUB_PARENT_INTERFACE m_Parent
Definition: fdo.h:355
BOOLEAN IsRootHub() const
Definition: fdo.h:174
union HubFdo::@1628 m_HubDescriptor
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
USB_DEVICE_SPEED HubSpeed
Definition: hubucx.h:504
UCHAR bPowerOnToPowerGood
Definition: usb300.h:289
USHORT wHubCharacteristics
Definition: usb300.h:288
UCHAR bHubControlCurrent
Definition: usb300.h:290
unsigned char UCHAR
Definition: typedefs.h:53
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
@ UsbSuperSpeed
Definition: usb200.h:45
@ UsbHighSpeed
Definition: usb200.h:44
@ UsbFullSpeed
Definition: usb200.h:43
#define USB_20_HUB_DESCRIPTOR_TYPE
Definition: usb200.h:280
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by HubWmiQueryHubNode().

◆ HubWmiAcquireSizeValid()

static BOOLEAN NTAPI HubWmiAcquireSizeValid ( _In_ PUSB_ACQUIRE_INFO  Request,
_In_ ULONG  OutBufferSize 
)
static

Definition at line 489 of file hubwmi.cpp.

492{
494 Request->TotalSize >= HUB_WMI_MIN_ACQUIRE_SIZE &&
495 Request->TotalSize <= OutBufferSize)
496 {
497 return TRUE;
498 }
499
500 DPRINT1("WMI name request size %lu does not fit buffer of %lu bytes\n",
502 return FALSE;
503}
#define HUB_WMI_MIN_ACQUIRE_SIZE
Definition: hubwmi.cpp:28
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87

Referenced by HubWmiHubNameRequest().

◆ HubWmiCopyPipes()

static VOID NTAPI HubWmiCopyPipes ( _In_ HubConfiguration *  Config,
_Out_ PUSB_PIPE_INFO  Pipes 
)
static

Endpoints of the current configuration, listed only when the first interface owns all of them.

Definition at line 302 of file hubwmi.cpp.

305{
307 ULONG Index;
308
309 if (IsListEmpty(&Config->Interfaces))
310 return;
311
312 Interface = CONTAINING_RECORD(Config->Interfaces.Flink, HubInterface, Link);
313 if (Interface->PipeCount != Config->EndpointCount)
314 return;
315
316 for (Index = 0; Index < Interface->PipeCount; Index++)
317 Pipes[Index].EndpointDescriptor = *Interface->Pipes[Index].Descriptor;
318}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by HubWmiQueryDeviceNode().

◆ HubWmiEvtSurpriseRemovalCleanup()

static VOID NTAPI HubWmiEvtSurpriseRemovalCleanup ( _In_ WDFOBJECT  Object)
static

Clears the driver wide handle along with its instance.

Definition at line 677 of file hubwmi.cpp.

679{
681
682 if (HubDriver.SurpriseRemovalWmi == (WDFWMIINSTANCE)Object)
684}
HubDriverState HubDriver
Definition: entry.cpp:13
static KSPIN_LOCK HubWmiSurpriseLock
Definition: hubwmi.cpp:35
WDFWMIINSTANCE SurpriseRemovalWmi
Definition: hubdriver.h:105
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

◆ HubWmiExecuteMethod()

static NTSTATUS NTAPI HubWmiExecuteMethod ( _In_ WDFWMIINSTANCE  WmiInstance,
_In_ ULONG  MethodId,
_In_ ULONG  InBufferSize,
_In_ ULONG  OutBufferSize,
_Inout_ PVOID  Buffer,
_Out_ PULONG  BufferUsed 
)
static

Dispatches on the request's notification type; MethodId and InBufferSize are ignored.

Definition at line 573 of file hubwmi.cpp.

580{
581 HubFdo* Hub;
582
585
586 *BufferUsed = 0;
587 if (OutBufferSize < sizeof(USB_NOTIFICATION))
588 {
589 DPRINT1("WMI method buffer of %lu bytes too small\n", OutBufferSize);
591 }
592
593 Hub = HubFdo::FromDevice(WdfWmiInstanceGetDevice(WmiInstance));
594
596 {
597 case ResetOvercurrent:
599 {
600 DPRINT1("Hub %p over current reset buffer of %lu bytes too small\n", Hub, OutBufferSize);
602 }
604
605 case AcquireBusInfo:
606 return HubWmiBusInfo(Hub, OutBufferSize, (PUSB_BUS_NOTIFICATION)Buffer, BufferUsed);
607
608 case AcquireHubName:
610
612 return HubWmiControllerNameRequest(Hub, OutBufferSize, (PUSB_ACQUIRE_INFO)Buffer, BufferUsed);
613
614 default:
615 return STATUS_SUCCESS;
616 }
617}
Definition: bufpool.h:45
Definition: fdo.h:132
static HubFdo * FromDevice(_In_ WDFDEVICE Device)
Definition: fdo.cpp:37
static NTSTATUS NTAPI HubWmiHubNameRequest(_In_ HubFdo *Hub, _In_ ULONG OutBufferSize, _Inout_ PUSB_ACQUIRE_INFO Request, _Out_ PULONG BufferUsed)
Definition: hubwmi.cpp:509
return STATUS_SUCCESS
Definition: hubwmi.cpp:483
static NTSTATUS NTAPI HubWmiResetOverCurrent(_In_ HubFdo *Hub, _In_ PUSB_CONNECTION_NOTIFICATION Request)
Definition: hubwmi.cpp:426
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
@ ResetOvercurrent
Definition: usbioctl.h:512
@ AcquireBusInfo
Definition: usbioctl.h:513
@ AcquireHubName
Definition: usbioctl.h:514
@ AcquireControllerName
Definition: usbioctl.h:515
_In_ WDF_SPECIAL_FILE_TYPE NotificationType
Definition: wdfdevice.h:1024
_In_ ULONG _Out_ PULONG BufferUsed
Definition: wdfwmi.h:92
_Must_inspect_result_ _In_ WDFWMIINSTANCE WmiInstance
Definition: wdfwmi.h:514
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
_In_ ULONG MethodId
Definition: wdfwmi.h:142

Referenced by _IRQL_requires_().

◆ HubWmiFirePortEvent()

static VOID NTAPI HubWmiFirePortEvent ( _In_ HubFdo *  Hub,
_In_ ULONG  PortNumber,
_In_ USB_NOTIFICATION_TYPE  Type 
)
static

Definition at line 72 of file hubwmi.cpp.

76{
77 WDFWMIINSTANCE Instance = Hub->m_WmiInstance;
81
82 /* A failed registration leaves no instance */
83 if (Instance == NULL)
84 return;
85
86 if (!WdfWmiProviderIsEnabled(WdfWmiInstanceGetProvider(Instance), WdfWmiEventControl))
87 {
88 DPRINT("Hub %p: nobody listens for WMI event %d on port %lu\n", Hub, Type, PortNumber);
89 return;
90 }
91
92 RtlZeroMemory(&Event, sizeof(Event));
94
95 Event.NotificationType = Type;
96 Event.ConnectionNumber = PortNumber;
97
98 /* What a USB_HUB_NAME query reports: the length field, the name and a NUL */
99 Event.HubNameLength = NameLength + sizeof(ULONG) + sizeof(WCHAR);
100
101 Status = WdfWmiInstanceFireEvent(Instance, sizeof(Event), &Event);
102 if (!NT_SUCCESS(Status))
103 DPRINT1("Hub %p: WMI event %d on port %lu failed 0x%lx\n", Hub, Type, PortNumber, Status);
104}
Type
Definition: Type.h:7
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
_In_ ULONG PortNumber
Definition: hubucx.h:272
static PCWSTR NTAPI HubWmiHubName(_In_ HubFdo *Hub, _Out_ PULONG Length)
Definition: hubwmi.cpp:41
_In_ HubPort _In_ USHORT PortNumber
Definition: hubwmi.cpp:183
short WCHAR
Definition: pedump.c:58
Input NameLength
Definition: portacpi.cpp:298
#define DPRINT
Definition: sndvol32.h:73
@ WdfWmiEventControl
Definition: wdfwmi.h:52

Referenced by HubWmiNotifyOverCurrent().

◆ HubWmiHubName()

static PCWSTR NTAPI HubWmiHubName ( _In_ HubFdo *  Hub,
_Out_ PULONG  Length 
)
static

Hub symbolic link without its "\??\" prefix. Bounded by the string length, not a NUL.

Definition at line 41 of file hubwmi.cpp.

44{
47 ULONG Start = 0;
48
49 *Length = 0;
50 if (Text == NULL)
51 return NULL;
52
53 if (Count != 0 && Text[0] == L'\\')
54 {
55 for (Start = 1; Start < Count; Start++)
56 {
57 if (Text[Start] == L'\\' || Text[Start] == UNICODE_NULL)
58 break;
59 }
60
61 if (Start < Count && Text[Start] == L'\\')
62 Start++;
63 }
64
65 *Length = (Count - Start) * sizeof(WCHAR);
66 return Text + Start;
67}
static _Out_opt_ PULONGLONG Start
UNICODE_STRING m_SymbolicLinkName
Definition: fdo.h:441
#define L(x)
Definition: resources.c:13
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
const uint16_t * PCWSTR
Definition: typedefs.h:57
USHORT Count
Definition: userreq.cpp:200
UNICODE_STRING Text
Definition: userreq.cpp:261

Referenced by HubWmiFirePortEvent(), and HubWmiHubNameRequest().

◆ HubWmiHubNameRequest()

static NTSTATUS NTAPI HubWmiHubNameRequest ( _In_ HubFdo *  Hub,
_In_ ULONG  OutBufferSize,
_Inout_ PUSB_ACQUIRE_INFO  Request,
_Out_ PULONG  BufferUsed 
)
static

A short TotalSize truncates the name without saying so.

Definition at line 509 of file hubwmi.cpp.

514{
516 ULONG Room;
518 PCWSTR Name;
519 ULONG Copy;
520
523
524 Room = Request->TotalSize - FIELD_OFFSET(USB_ACQUIRE_INFO, Buffer);
526 Copy = min(Room, NameLength);
527
528 RtlZeroMemory(Text, Room);
529 if (Copy != 0)
531
533 return STATUS_SUCCESS;
534}
LPWSTR Name
Definition: desk.c:124
ULONG Copy
Definition: devhcd.cpp:1449
static BOOLEAN NTAPI HubWmiAcquireSizeValid(_In_ PUSB_ACQUIRE_INFO Request, _In_ ULONG OutBufferSize)
Definition: hubwmi.cpp:489
#define min(a, b)
Definition: monoChain.cc:55
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by HubWmiExecuteMethod().

◆ HubWmiNotifyOverCurrent()

VOID NTAPI HubWmiNotifyOverCurrent ( _In_ HubFdo *  Hub,
_In_ ULONG  PortNumber 
)

Definition at line 750 of file hubwmi.cpp.

753{
755}
static VOID NTAPI HubWmiFirePortEvent(_In_ HubFdo *Hub, _In_ ULONG PortNumber, _In_ USB_NOTIFICATION_TYPE Type)
Definition: hubwmi.cpp:72
@ OverCurrent
Definition: usbioctl.h:511

Referenced by PortMachine::NotifyUserOfOverCurrent().

◆ HubWmiQueryDeviceNode()

static NTSTATUS NTAPI HubWmiQueryDeviceNode ( _In_ WDFWMIINSTANCE  WmiInstance,
_In_ ULONG  OutBufferSize,
_Out_writes_bytes_to_(OutBufferSize, *BufferUsed) PVOID  OutBuffer,
_Out_ PULONG  BufferUsed 
)
static

Definition at line 323 of file hubwmi.cpp.

328{
329 WDFDEVICE Device = WdfWmiInstanceGetDevice(WmiInstance);
331 PUSB_DEVICE_NODE_INFO Info = (PUSB_DEVICE_NODE_INFO)OutBuffer;
333 HubFdo* Hub;
334 UCHAR Depth;
336
337 *BufferUsed = sizeof(USB_DEVICE_NODE_INFO);
338 if (OutBufferSize < sizeof(USB_DEVICE_NODE_INFO))
340
341 Child = Pdo->m_Child;
342 if (Child == NULL)
343 {
344 DPRINT1("PDO %p WMI node query without a device\n", Pdo);
345 *BufferUsed = 0;
347 }
348
349 Hub = Child->m_Hub;
351
352 {
353 HubSpinLockGuard Guard(&Child->m_ConfigLock);
354 HubConfiguration* Config = Child->m_CurrentConfig;
355
356 if (Child->HasState(ChildState::ConfigurationValid) && Config != NULL)
357 {
358 /* With no endpoints this is less than the unconfigured size */
359 Length = FIELD_OFFSET(USB_DEVICE_NODE_INFO, UsbDeviceInfo.PipeList) +
360 Config->EndpointCount * sizeof(USB_PIPE_INFO);
362 if (Length > OutBufferSize)
364
365 Info->UsbDeviceInfo.CurrentConfigurationValue = Config->Descriptor.bConfigurationValue;
366 Info->UsbDeviceInfo.NumberOfOpenPipes = Config->EndpointCount;
367 HubWmiCopyPipes(Config, (PUSB_PIPE_INFO)HUB_WMI_FIELD(Info, UsbDeviceInfo.PipeList));
368 }
369 }
370
371 Info->Sig = USB_NODE_INFO_SIG;
372 Info->LengthInBytes = *BufferUsed;
373 Info->NodeType = UsbDevice;
374
375 Info->UsbDeviceInfo.DeviceDescriptor = Child->m_DeviceDescriptor;
376 Info->UsbDeviceInfo.Speed = Child->Speed();
377 Info->UsbDeviceInfo.PortNumber = Pdo->m_PortNumber;
378 Info->UsbDeviceInfo.ConnectionIndex = Pdo->m_PortNumber;
379 Info->UsbDeviceInfo.ConnectionStatus = Child->m_Port->m_ConnectionStatus;
380
381 /* The device sits one tier below its hub */
382 Info->BusAddress = Hub->m_Parent.HubTopologyAddress;
384 if (Depth == 0)
385 Info->BusAddress.RootHubPortNumber = Pdo->m_PortNumber;
386 else if (Depth <= RTL_NUMBER_OF(Info->BusAddress.HubPortNumber))
387 Info->BusAddress.HubPortNumber[Depth - 1] = Pdo->m_PortNumber;
388
389 /* Truncated strings keep no NUL */
390 HubWmiCopyProperty(Device,
393 sizeof(Info->DeviceDescription));
394 HubWmiCopyProperty(Device,
396 HUB_WMI_FIELD(Info, UsbDeviceInfo.PnpHardwareId),
397 sizeof(Info->UsbDeviceInfo.PnpHardwareId));
398 HubWmiCopyProperty(Device,
400 HUB_WMI_FIELD(Info, UsbDeviceInfo.PnpCompatibleId),
401 sizeof(Info->UsbDeviceInfo.PnpCompatibleId));
402
403 if (Child->m_SerialNumber != NULL)
404 {
405 RtlCopyMemory(HUB_WMI_FIELD(Info, UsbDeviceInfo.SerialNumberId),
406 Child->m_SerialNumber,
407 min(Child->m_SerialNumberLength, sizeof(Info->UsbDeviceInfo.SerialNumberId)));
408 }
409
410 if (Child->m_FriendlyName != NULL)
411 {
412 RtlCopyMemory(HUB_WMI_FIELD(Info, UsbDeviceInfo.PnpDeviceDescription),
413 Child->m_FriendlyName,
414 min((ULONG)Child->m_FriendlyNameLength, sizeof(Info->UsbDeviceInfo.PnpDeviceDescription)));
415 }
416
417 return STATUS_SUCCESS;
418}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static HubPdo * FromDevice(_In_ WDFDEVICE Device)
Definition: childpdo.cpp:180
UINT Depth
Definition: d3d12.idl:4644
_In_ UCXUSBDEVICE UsbDevice
Definition: hostctl.h:31
@ ConfigurationValid
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
_In_ UCXUSBDEVICE _In_ PDEVICE_OBJECT Pdo
Definition: hubucx.h:280
#define HUB_WMI_FIELD(Info, Field)
Definition: hubwmi.cpp:31
_In_ ULONG _Inout_ PUSB_BUS_NOTIFICATION _Out_ PULONG BufferUsed
Definition: hubwmi.cpp:459
static VOID NTAPI HubWmiCopyPipes(_In_ HubConfiguration *Config, _Out_ PUSB_PIPE_INFO Pipes)
Definition: hubwmi.cpp:302
size_t Length
Definition: hubwmi.cpp:284
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4117
USB_TOPOLOGY_ADDRESS HubTopologyAddress
Definition: hubucx.h:514
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
struct _USB_PIPE_INFO USB_PIPE_INFO
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432
@ DevicePropertyCompatibleIDs
Definition: iotypes.h:1197
@ DevicePropertyHardwareID
Definition: iotypes.h:1196
@ DevicePropertyDeviceDescription
Definition: iotypes.h:1195

◆ HubWmiQueryHubNode()

static NTSTATUS NTAPI HubWmiQueryHubNode ( _In_ WDFWMIINSTANCE  WmiInstance,
_In_ ULONG  OutBufferSize,
_Out_writes_bytes_to_(OutBufferSize, *BufferUsed) PVOID  OutBuffer,
_Out_ PULONG  BufferUsed 
)
static

Definition at line 212 of file hubwmi.cpp.

217{
218 HubFdo* Hub = HubFdo::FromDevice(WdfWmiInstanceGetDevice(WmiInstance));
219 PUSB_DEVICE_NODE_INFO Info = (PUSB_DEVICE_NODE_INFO)OutBuffer;
220 PUSB_HUB_PORT_INFORMATION Entry;
222 USHORT PortCount = (USHORT)Hub->m_PortCount;
225 HubPort* Port;
226 ULONG Needed;
227
228 /* Sized as one full device block plus the extra ports, larger than the data */
229 Needed = sizeof(USB_DEVICE_NODE_INFO) + ((ULONG)PortCount - 1) * sizeof(USB_HUB_PORT_INFORMATION);
230 *BufferUsed = Needed;
231 if (OutBufferSize < Needed)
232 {
233 DPRINT("Hub %p WMI node query needs %lu bytes, got %lu\n", Hub, Needed, OutBufferSize);
235 }
236
238
239 Info->Sig = USB_NODE_INFO_SIG;
240 Info->LengthInBytes = Needed;
241 Info->NodeType = HubDevice;
242 Info->BusAddress = Hub->m_Parent.HubTopologyAddress;
243
245 Info->HubDeviceInfo.HubDescriptor = Descriptor;
246 Info->HubDeviceInfo.HubNumber = Hub->m_HubNumber;
247 Info->HubDeviceInfo.HubIsSelfPowered = (Hub->m_MaxPortPower != 100);
248 Info->HubDeviceInfo.HubIsRootHub = Hub->IsRootHub();
249 Info->HubDeviceInfo.NumberOfHubPorts = PortCount;
250
251 /* Entries are numbered from 0 while ports start at 1: entry 0 stays empty and the last port is left out */
252 Entry = (PUSB_HUB_PORT_INFORMATION)HUB_WMI_FIELD(Info, HubDeviceInfo.PortInfo);
253 for (Index = 0; Index < PortCount; Index++, Entry++)
254 {
255 Entry->PortNumber = Index;
256 Entry->ConnectionIndex = Index;
257
259 if (Port == NULL)
260 continue;
261
262 Entry->ConnectionStatus = HubWmiPortEntry(Hub, Port, Index, &Address);
263 Entry->DeviceAddress = Address;
264 }
265
266 return STATUS_SUCCESS;
267}
WDFDEVICE HubDevice
Definition: childpdo.cpp:989
ULONG m_HubNumber
Definition: fdo.h:351
ULONG m_MaxPortPower
Definition: fdo.h:384
HubPort * FindPort(_In_ ULONG PortNumber)
Definition: fanout.cpp:42
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
_In_ HubPort * Port
Definition: hubwmi.cpp:182
VOID NTAPI HubMakeUsb2StyleDescriptor(_In_ HubFdo *Hub, _Out_ PUSB_HUB_DESCRIPTOR Descriptor)
Definition: hubwmi.cpp:135
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68

Referenced by _IRQL_requires_().

◆ HubWmiResetOverCurrent()

static NTSTATUS NTAPI HubWmiResetOverCurrent ( _In_ HubFdo *  Hub,
_In_ PUSB_CONNECTION_NOTIFICATION  Request 
)
static

Accepts a reset only while the port machine waits for one after the over current popup.

Definition at line 426 of file hubwmi.cpp.

429{
430 HubPort* Port = Hub->FindPort(Request->ConnectionNumber);
432
433 if (Port == NULL)
434 {
435 DPRINT1("Hub %p over current reset for invalid port %lu\n", Hub, Request->ConnectionNumber);
437 }
438
441 {
442 DPRINT("Hub %p port %u over current reset requested by the user\n", Hub, Port->Number());
444 }
445
446 return STATUS_SUCCESS;
447}
volatile LONG m_Flags
Definition: hubport.h:233
USHORT Number() const
Definition: hubport.h:213
VOID Post(_In_ PortEvent Event)
Definition: hubport.h:157
@ OverCurrentResetArmed
Previous
#define InterlockedAnd
Definition: interlocked.h:77
long LONG
Definition: pedump.c:60
@ UserOverCurrentReset
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by HubWmiExecuteMethod().

◆ if() [1/4]

if ( !  HubWmiAcquireSizeValidRequest, OutBufferSize)

◆ if() [2/4]

if ( !  NT_SUCCESSStatus)

Definition at line 473 of file hubwmi.cpp.

474 {
475 DPRINT1("Hub %p: controller name for WMI bus info failed 0x%lx\n", Hub, Status);
476 return Status;
477 }

◆ if() [3/4]

if ( !  NT_SUCCESSWdfDeviceAllocAndQueryProperty(Device, Property, NonPagedPool, &Attributes, &Memory))

◆ if() [4/4]

if ( )

Definition at line 463 of file hubwmi.cpp.

464 {
465 DPRINT1("Hub %p WMI bus info buffer of %lu bytes too small\n", Hub, OutBufferSize);
467 }

◆ RtlCopyMemory()

RtlCopyMemory ( Destination  ,
Data  ,
min(Length,(size_t) Size)   
)

◆ WdfFdoLockStaticChildListForIteration()

WdfFdoLockStaticChildListForIteration ( Hub->  m_Device)

Referenced by HubIoLockChild().

◆ WdfFdoUnlockStaticChildListFromIteration()

WdfFdoUnlockStaticChildListFromIteration ( Hub->  m_Device)

Referenced by HubIoUnlockChildren().

◆ WdfObjectDelete()

WdfObjectDelete ( Memory  )

◆ WdfWmiInstanceCreate()

return WdfWmiInstanceCreate ( Device  ,
&  Config,
Attributes  ,
Instance   
)

◆ while()

while ( (Child=WdfFdoRetrieveNextStaticChild(Hub->m_Device, Child, WdfRetrievePresentChildren)) !  = NULL)

Definition at line 193 of file hubwmi.cpp.

194 {
196 if (Pdo->m_PortNumber != PortNumber)
197 continue;
198
199 if (Pdo->m_Child != NULL)
201 break;
202 }
UCHAR m_Address
Definition: hubchild.h:350
HubChild * m_Child
Definition: hubport.h:236
_In_ HubPort _In_ USHORT _Out_ PUSHORT DeviceAddress
Definition: hubwmi.cpp:185

Variable Documentation

◆ ActualLength

Name ActualLength = 0

Definition at line 469 of file hubwmi.cpp.

◆ Attributes

Definition at line 116 of file hubwmi.cpp.

◆ BufferUsed

Initial value:

Definition at line 458 of file hubwmi.cpp.

Referenced by HubWmiQueryDeviceNode().

◆ Config

◆ ConsumedBandwidth

Notification ConsumedBandwidth = 0

Definition at line 480 of file hubwmi.cpp.

◆ ControllerNameLength

Notification ControllerNameLength = Name.ActualLength

Definition at line 481 of file hubwmi.cpp.

◆ Data

Data = WdfMemoryGetBuffer(Memory, &Length)

Definition at line 285 of file hubwmi.cpp.

◆ DeviceAddress

◆ EvtWmiInstanceExecuteMethod

Config EvtWmiInstanceExecuteMethod = Method

Definition at line 128 of file hubwmi.cpp.

◆ EvtWmiInstanceQueryInstance

Config EvtWmiInstanceQueryInstance = Query

Definition at line 127 of file hubwmi.cpp.

◆ Flags

Definition at line 123 of file hubwmi.cpp.

◆ Guid

Definition at line 112 of file hubwmi.cpp.

◆ HubName

Name HubName[0] = UNICODE_NULL

Definition at line 470 of file hubwmi.cpp.

Referenced by HubPdoGetHubName(), and USBHI_GetRootHubSymbolicName().

◆ HubWmiSurpriseLock

KSPIN_LOCK HubWmiSurpriseLock
static

Definition at line 35 of file hubwmi.cpp.

Referenced by HubWmiEvtSurpriseRemovalCleanup().

◆ HubWmiSurpriseRemovalGuid

const GUID HubWmiSurpriseRemovalGuid
static
Initial value:
=
{ 0x9bbbf831, 0xa2f2, 0x43b4, { 0x96, 0xd1, 0x86, 0x94, 0x4b, 0x59, 0x14, 0xb3 } }

Definition at line 14 of file hubwmi.cpp.

◆ Instance

◆ Length

Definition at line 284 of file hubwmi.cpp.

Referenced by HubWmiQueryDeviceNode().

◆ m_ConnectionStatus

return Port m_ConnectionStatus

Definition at line 206 of file hubwmi.cpp.

◆ Memory

WDFMEMORY Memory

Definition at line 283 of file hubwmi.cpp.

◆ Method

◆ Notification

◆ OutBufferSize

Definition at line 456 of file hubwmi.cpp.

◆ ParentObject

Attributes ParentObject = Device

Definition at line 288 of file hubwmi.cpp.

◆ Pdo

Definition at line 187 of file hubwmi.cpp.

◆ Port

_In_ HubPort* Port

Definition at line 182 of file hubwmi.cpp.

Referenced by HubWmiQueryHubNode(), and HubWmiResetOverCurrent().

◆ PortNumber

Initial value:

Definition at line 183 of file hubwmi.cpp.

Referenced by HubWmiFirePortEvent().

◆ Property

Definition at line 278 of file hubwmi.cpp.

◆ Provider

Initial value:
=
{
1,
"Provider",
&Provider_child.IRawElementProviderFragment_iface, &Provider_child2.IRawElementProviderFragment_iface,
0, 0, 0,
}
static struct Provider Provider_child
static const IValueProviderVtbl ProviderValuePatternVtbl
static const IRawElementProviderFragmentRootVtbl ProviderFragmentRootVtbl
static const ILegacyIAccessibleProviderVtbl ProviderLegacyIAccessiblePatternVtbl
static const IRawElementProviderAdviseEventsVtbl ProviderAdviseEventsVtbl
static struct Provider Provider_child2
IRawElementProviderSimpleVtbl ProviderSimpleVtbl
static const IRawElementProviderFragmentVtbl ProviderFragmentVtbl
static const IRawElementProviderHwndOverrideVtbl ProviderHwndOverrideVtbl
static const IProxyProviderWinEventHandlerVtbl ProviderWinEventHandlerVtbl

Definition at line 122 of file hubwmi.cpp.

◆ ProviderFlags

_In_ const GUID _In_ ULONG ProviderFlags

Definition at line 113 of file hubwmi.cpp.

◆ Query

◆ Register

Config Register = TRUE

Definition at line 126 of file hubwmi.cpp.

Referenced by __writemsr(), _Requires_lock_held_(), AHCI_HBA_READ(), AHCI_HBA_WRITE(), AHCI_PORT_READ(), AHCI_PORT_WRITE(), ApicInitializeIOApic(), ApicRead(), ApicWrite(), ApicWriteIORedirectionEntry(), AtaAhciPmpRead(), AtaAhciPmpWrite(), AtaAhciPollRegister(), AtaPdoWmiRegistration(), CmdCheckInterruptPci(), CmdSetTransferMode(), co_IntRegisterLogonProcess(), DC_READ(), DcWriteGpio(), DECLARE_INTERFACE_(), HalpConfigureDebuggingDevice(), HalpReadNvram(), HptHasUdmaCable(), HubMailboxTransfer(), IOApicRead(), IOApicWrite(), LpcReadRegister(), LpcWriteRegister(), XhciRegisters::ModifyCapability32(), NV_READ(), NV_WRITE(), PciEcamTransfer(), PhyInitRealtek8211b(), CMMCModule::PreMessageLoop(), HubMachine::ReadDromRegister(), FxDevice::ReadRegister(), FxDevice::ReadRegisterBuffer(), reg_unreg_wine_test_class(), FxDeviceInterface::Register(), UcxUsbDevice::RegisterComposite(), RegisterVDD(), ScsiPortReadRegisterBufferUchar(), ScsiPortReadRegisterBufferUlong(), ScsiPortReadRegisterBufferUshort(), ScsiPortReadRegisterUchar(), ScsiPortReadRegisterUlong(), ScsiPortReadRegisterUshort(), ScsiPortWriteRegisterBufferUchar(), ScsiPortWriteRegisterBufferUlong(), ScsiPortWriteRegisterBufferUshort(), ScsiPortWriteRegisterUchar(), ScsiPortWriteRegisterUlong(), ScsiPortWriteRegisterUshort(), SMBusWriteByte(), StorPortReadRegisterBufferUchar(), StorPortReadRegisterBufferUlong(), StorPortReadRegisterBufferUshort(), StorPortReadRegisterUchar(), StorPortReadRegisterUlong(), StorPortReadRegisterUshort(), StorPortWriteRegisterBufferUchar(), StorPortWriteRegisterBufferUlong(), StorPortWriteRegisterBufferUshort(), StorPortWriteRegisterUchar(), StorPortWriteRegisterUlong(), StorPortWriteRegisterUshort(), SvwSataScrRead(), SvwSataScrWrite(), test_wm_notify(), UpdateRegistryFromResource(), ViaScrReadIoPort(), ViaScrReadPci(), ViaScrWriteIoPort(), ViaScrWritePci(), HubMachine::WriteDromRegister(), FxDevice::WriteRegister(), FxDevice::WriteRegisterBuffer(), X2ApicMsrFromRegister(), X2ApicRead(), and X2ApicWrite().

◆ Request

Definition at line 544 of file hubwmi.cpp.

◆ Size

Initial value:

Definition at line 280 of file hubwmi.cpp.

◆ Status

Status = HubQueryControllerName(Hub, &Name, sizeof(Name))

Definition at line 461 of file hubwmi.cpp.

Referenced by _IRQL_requires_(), HubWmiFirePortEvent(), and if().

◆ STATUS_SUCCESS

◆ Total

◆ TotalBandwidth

Notification TotalBandwidth = 0

Definition at line 479 of file hubwmi.cpp.

◆ TotalSize