ReactOS 0.4.17-dev-1281-g065abb3
hubwmi.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS SuperSpeed USB Hub Driver
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: WMI providers, user notifications and the over current reset method
5 * COPYRIGHT: Copyright 2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8#include "usbhub3.h"
9
10#define NDEBUG
11#include <debug.h>
12
13/* Missing from our usbiodef.h */
15 { 0x9bbbf831, 0xa2f2, 0x43b4, { 0x96, 0xd1, 0x86, 0x94, 0x4b, 0x59, 0x14, 0xb3 } };
16
17/* Layouts user mode tools parse */
21C_ASSERT(sizeof(USB_PIPE_INFO) == 11);
22C_ASSERT(sizeof(USB_HUB_PORT_INFORMATION) == 16);
23C_ASSERT(sizeof(USB_DEVICE_NODE_INFO) == 1202);
24C_ASSERT(FIELD_OFFSET(USB_DEVICE_NODE_INFO, UsbDeviceInfo.PipeList) == 1191);
25C_ASSERT(FIELD_OFFSET(USB_DEVICE_NODE_INFO, HubDeviceInfo.PortInfo) == 211);
26
27/* Smallest USB_ACQUIRE_INFO a name request may use */
28#define HUB_WMI_MIN_ACQUIRE_SIZE 10
29
30/* Byte field of a packed node info block */
31#define HUB_WMI_FIELD(Info, Field) \
32 ((PUCHAR)(Info) + FIELD_OFFSET(USB_DEVICE_NODE_INFO, Field))
33
34/* Guards HubDriver.SurpriseRemovalWmi against the cleanup of its instance */
36
38static
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}
68
69static
70VOID
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}
105
107static
109NTAPI
110HubWmiCreateInstance(
111 _In_ WDFDEVICE Device,
112 _In_ const GUID* Guid,
117 _Out_opt_ WDFWMIINSTANCE* Instance)
118{
121
124
126 Config.Register = TRUE;
127 Config.EvtWmiInstanceQueryInstance = Query;
128 Config.EvtWmiInstanceExecuteMethod = Method;
129
131}
132
133VOID
134NTAPI
136 _In_ HubFdo* Hub,
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}
173
174/* Node information of a hub FDO */
175
177static
179NTAPI
180HubWmiPortEntry(
181 _In_ HubFdo* Hub,
185{
186 WDFDEVICE Child = NULL;
188
189 *DeviceAddress = 0;
190
192
193 while ((Child = WdfFdoRetrieveNextStaticChild(Hub->m_Device, Child, WdfRetrievePresentChildren)) != NULL)
194 {
196 if (Pdo->m_PortNumber != PortNumber)
197 continue;
198
199 if (Pdo->m_Child != NULL)
201 break;
202 }
203
205
207}
208
209static
211NTAPI
213 _In_ WDFWMIINSTANCE WmiInstance,
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}
268
269/* Node information of a child PDO */
270
273static
274VOID
275NTAPI
276HubWmiCopyProperty(
277 _In_ WDFDEVICE Device,
281{
283 WDFMEMORY Memory;
284 size_t Length;
286
288 Attributes.ParentObject = Device;
289
290 if (!NT_SUCCESS(WdfDeviceAllocAndQueryProperty(Device, Property, NonPagedPool, &Attributes, &Memory)))
291 return;
292
293 Data = WdfMemoryGetBuffer(Memory, &Length);
296}
297
299static
300VOID
301NTAPI
304 _Out_ PUSB_PIPE_INFO Pipes)
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}
319
320static
322NTAPI
324 _In_ WDFWMIINSTANCE WmiInstance,
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}
419
420/* GUID_USB_WMI_STD_DATA methods */
421
423static
425NTAPI
427 _In_ HubFdo* Hub,
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}
448
451static
453NTAPI
454HubWmiBusInfo(
455 _In_ HubFdo* Hub,
459{
462
464 {
465 DPRINT1("Hub %p WMI bus info buffer of %lu bytes too small\n", Hub, OutBufferSize);
467 }
468
469 Name.ActualLength = 0;
470 Name.HubName[0] = UNICODE_NULL;
471
472 Status = HubQueryControllerName(Hub, &Name, sizeof(Name));
474 {
475 DPRINT1("Hub %p: controller name for WMI bus info failed 0x%lx\n", Hub, Status);
476 return Status;
477 }
478
479 Notification->TotalBandwidth = 0;
480 Notification->ConsumedBandwidth = 0;
481 Notification->ControllerNameLength = Name.ActualLength;
482 *BufferUsed = sizeof(*Notification);
484}
485
486static
488NTAPI
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}
504
506static
508NTAPI
510 _In_ HubFdo* Hub,
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}
535
538static
540NTAPI
541HubWmiControllerNameRequest(
542 _In_ HubFdo* Hub,
546{
550
553
554 Total = Request->TotalSize;
555 Request->TotalSize = Total - sizeof(ULONG);
556
557 Status = HubQueryControllerName(Hub, Name, Total - sizeof(ULONG));
558 if (!NT_SUCCESS(Status))
559 {
560 DPRINT1("Hub %p: controller name for WMI failed 0x%lx\n", Hub, Status);
561 return Status;
562 }
563
564 Name->ActualLength += sizeof(ULONG);
565 *BufferUsed = Total;
566 return STATUS_SUCCESS;
567}
568
570static
572NTAPI
574 _In_ WDFWMIINSTANCE WmiInstance,
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}
618
619/* Registration */
620
622VOID
623NTAPI
624HubWmiRegister(
625 _In_ HubFdo* Hub)
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}
653
655VOID
656NTAPI
657HubWmiRegisterDevice(
658 _In_ WDFDEVICE Pdo)
659{
661
662 Status = HubWmiCreateInstance(Pdo,
663 &GUID_USB_WMI_NODE_INFO,
664 0,
666 NULL,
668 NULL);
669 if (!NT_SUCCESS(Status))
670 DPRINT1("PDO %p: WMI node info provider failed 0x%lx\n", Pdo, Status);
671}
672
674static
675VOID
676NTAPI
679{
681
682 if (HubDriver.SurpriseRemovalWmi == (WDFWMIINSTANCE)Object)
684}
685
687VOID
688NTAPI
689HubWmiRegisterBootSurpriseRemoval(
690 _In_ WDFDEVICE Pdo)
691{
693 WDFWMIINSTANCE Instance;
695
697 Attributes.EvtCleanupCallback = HubWmiEvtSurpriseRemovalCleanup;
698
699 Status = HubWmiCreateInstance(Pdo,
702 NULL,
703 NULL,
704 &Attributes,
705 &Instance);
706 if (!NT_SUCCESS(Status))
707 {
708 DPRINT1("PDO %p: WMI surprise removal provider failed 0x%lx\n", Pdo, Status);
709 return;
710 }
711
712 /* One for the whole driver; the latest boot device wins */
715}
716
717/* Notifications */
718
720VOID
721NTAPI
722HubWmiNotifyBootSurpriseRemoval(VOID)
723{
724 WDFWMIINSTANCE Instance;
726
727 {
729
730 /* Nothing to send when no boot device registered one */
732 if (Instance == NULL)
733 return;
734
736 }
737
738 if (WdfWmiProviderIsEnabled(WdfWmiInstanceGetProvider(Instance), WdfWmiEventControl))
739 {
740 Status = WdfWmiInstanceFireEvent(Instance, 0, NULL);
741 if (!NT_SUCCESS(Status))
742 DPRINT1("WMI surprise removal event failed 0x%lx\n", Status);
743 }
744
746}
747
748VOID
749NTAPI
751 _In_ HubFdo* Hub,
753{
755}
756
758VOID
759NTAPI
760HubWmiNotifyEnumerationFailure(
761 _In_ HubFdo* Hub,
763{
765}
766
768VOID
769NTAPI
770HubWmiNotifyHubNestedTooDeeply(
771 _In_ HubFdo* Hub,
773{
774 HubWmiFirePortEvent(Hub, PortNumber, HubNestedTooDeeply);
775}
776
778VOID
779NTAPI
780HubWmiNotifyInsufficientPower(
781 _In_ HubFdo* Hub,
783{
785}
786
788VOID
789NTAPI
790HubWmiNotifyInsufficientBandwidth(
791 _In_ HubFdo* Hub,
793{
795}
static _Out_opt_ PULONGLONG Start
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
Type
Definition: Type.h:7
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
HubFdo * Hub
Definition: bootdev.cpp:261
WDFDEVICE HubDevice
Definition: childpdo.cpp:989
Definition: bufpool.h:45
UCHAR m_Address
Definition: hubchild.h:350
Definition: fdo.h:132
WDFWMIINSTANCE m_WmiInstance
Definition: fdo.h:448
WDFDEVICE m_Device
Definition: fdo.h:349
ULONG m_HubNumber
Definition: fdo.h:351
USB_HUB_DESCRIPTOR Usb20
Definition: fdo.h:419
UNICODE_STRING m_SymbolicLinkName
Definition: fdo.h:441
ULONG m_PortCount
Definition: fdo.h:379
static HubFdo * FromDevice(_In_ WDFDEVICE Device)
Definition: fdo.cpp:37
USB_30_HUB_DESCRIPTOR Usb30
Definition: fdo.h:420
ULONG m_MaxPortPower
Definition: fdo.h:384
UCXHUB_PARENT_INTERFACE m_Parent
Definition: fdo.h:355
BOOLEAN IsRootHub() const
Definition: fdo.h:174
union HubFdo::@1628 m_HubDescriptor
HubPort * FindPort(_In_ ULONG PortNumber)
Definition: fanout.cpp:42
static HubPdo * FromDevice(_In_ WDFDEVICE Device)
Definition: childpdo.cpp:180
volatile LONG m_Flags
Definition: hubport.h:233
HubChild * m_Child
Definition: hubport.h:236
USHORT Number() const
Definition: hubport.h:213
VOID Post(_In_ PortEvent Event)
Definition: hubport.h:157
USB_CONNECTION_STATUS m_ConnectionStatus
Definition: hubport.h:254
UINT Depth
Definition: d3d12.idl:4644
LPWSTR Name
Definition: desk.c:124
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
ULONG Copy
Definition: devhcd.cpp:1449
_In_ ULONG Attributes
Definition: dispmprt.h:1077
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define _IRQL_requires_(irql)
Definition: driverspecs.h:229
HubDriverState HubDriver
Definition: entry.cpp:13
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define NonPagedPool
Definition: env_spec_w32.h:307
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
Status
Definition: gdiplustypes.h:24
_In_ UCXUSBDEVICE UsbDevice
Definition: hostctl.h:31
@ ConfigurationValid
@ OverCurrentResetArmed
Previous
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
_In_ ULONG PortNumber
Definition: hubucx.h:272
_In_ UCXUSBDEVICE _In_ PDEVICE_OBJECT Pdo
Definition: hubucx.h:280
_In_ HubPort * Port
Definition: hubwmi.cpp:182
WdfFdoLockStaticChildListForIteration(Hub->m_Device)
static KSPIN_LOCK HubWmiSurpriseLock
Definition: hubwmi.cpp:35
_In_ HubPort _In_ USHORT _Out_ PUSHORT DeviceAddress
Definition: hubwmi.cpp:185
WDFMEMORY Memory
Definition: hubwmi.cpp:283
HubPdo * Pdo
Definition: hubwmi.cpp:187
#define HUB_WMI_FIELD(Info, Field)
Definition: hubwmi.cpp:31
WdfFdoUnlockStaticChildListFromIteration(Hub->m_Device)
VOID NTAPI HubMakeUsb2StyleDescriptor(_In_ HubFdo *Hub, _Out_ PUSB_HUB_DESCRIPTOR Descriptor)
Definition: hubwmi.cpp:135
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE _In_opt_ PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD Method
Definition: hubwmi.cpp:115
static PCWSTR NTAPI HubWmiHubName(_In_ HubFdo *Hub, _Out_ PULONG Length)
Definition: hubwmi.cpp:41
static VOID NTAPI HubWmiFirePortEvent(_In_ HubFdo *Hub, _In_ ULONG PortNumber, _In_ USB_NOTIFICATION_TYPE Type)
Definition: hubwmi.cpp:72
VOID NTAPI HubWmiNotifyOverCurrent(_In_ HubFdo *Hub, _In_ ULONG PortNumber)
Definition: hubwmi.cpp:750
_In_ const GUID _In_ ULONG ProviderFlags
Definition: hubwmi.cpp:113
return WdfWmiInstanceCreate(Device, &Config, Attributes, Instance)
WDF_WMI_INSTANCE_CONFIG Config
Definition: hubwmi.cpp:120
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_ ULONG _Inout_ PUSB_BUS_NOTIFICATION _Out_ PULONG BufferUsed
Definition: hubwmi.cpp:459
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
ULONG Total
Definition: hubwmi.cpp:548
_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
WDF_WMI_PROVIDER_CONFIG_INIT & Provider
Definition: hubwmi.cpp:122
static NTSTATUS NTAPI HubWmiResetOverCurrent(_In_ HubFdo *Hub, _In_ PUSB_CONNECTION_NOTIFICATION Request)
Definition: hubwmi.cpp:426
static const GUID HubWmiSurpriseRemovalGuid
Definition: hubwmi.cpp:14
#define HUB_WMI_MIN_ACQUIRE_SIZE
Definition: hubwmi.cpp:28
static BOOLEAN NTAPI HubWmiAcquireSizeValid(_In_ PUSB_ACQUIRE_INFO Request, _In_ ULONG OutBufferSize)
Definition: hubwmi.cpp:489
_In_ HubPort _In_ USHORT PortNumber
Definition: hubwmi.cpp:183
Request TotalSize
Definition: hubwmi.cpp:555
static NTSTATUS NTAPI HubWmiQueryDeviceNode(_In_ WDFWMIINSTANCE WmiInstance, _In_ ULONG OutBufferSize, _Out_writes_bytes_to_(OutBufferSize, *BufferUsed) PVOID OutBuffer, _Out_ PULONG BufferUsed)
Definition: hubwmi.cpp:323
static VOID NTAPI HubWmiEvtSurpriseRemovalCleanup(_In_ WDFOBJECT Object)
Definition: hubwmi.cpp:677
_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
Definition: hubwmi.cpp:116
static VOID NTAPI HubWmiCopyPipes(_In_ HubConfiguration *Config, _Out_ PUSB_PIPE_INFO Pipes)
Definition: hubwmi.cpp:302
WdfObjectDelete(Memory)
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE Query
Definition: hubwmi.cpp:114
size_t Length
Definition: hubwmi.cpp:284
PVOID Data
Definition: hubwmi.cpp:285
#define InterlockedAnd
Definition: interlocked.h:77
#define C_ASSERT(e)
Definition: intsafe.h:73
#define min(a, b)
Definition: monoChain.cc:55
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3051
#define _Out_opt_
Definition: no_sal2.h:214
#define _Inout_
Definition: no_sal2.h:162
#define _Out_writes_bytes_to_(s, c)
Definition: no_sal2.h:190
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
Input NameLength
Definition: portacpi.cpp:298
@ UserOverCurrentReset
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4117
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:73
WDFWMIINSTANCE SurpriseRemovalWmi
Definition: hubdriver.h:105
USB_DEVICE_SPEED HubSpeed
Definition: hubucx.h:504
USB_TOPOLOGY_ADDRESS HubTopologyAddress
Definition: hubucx.h:514
UCHAR bPowerOnToPowerGood
Definition: usb300.h:289
USHORT wHubCharacteristics
Definition: usb300.h:288
UCHAR bHubControlCurrent
Definition: usb300.h:290
uint32_t * PULONG
Definition: typedefs.h:59
const uint16_t * PCWSTR
Definition: typedefs.h:57
unsigned char UCHAR
Definition: typedefs.h:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
@ 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
@ ResetOvercurrent
Definition: usbioctl.h:512
@ AcquireBusInfo
Definition: usbioctl.h:513
@ OverCurrent
Definition: usbioctl.h:511
@ InsufficentPower
Definition: usbioctl.h:510
@ AcquireHubName
Definition: usbioctl.h:514
@ AcquireControllerName
Definition: usbioctl.h:515
@ InsufficentBandwidth
Definition: usbioctl.h:509
@ EnumerationFailure
Definition: usbioctl.h:508
enum _USB_NOTIFICATION_TYPE USB_NOTIFICATION_TYPE
struct _USB_PIPE_INFO USB_PIPE_INFO
enum _USB_CONNECTION_STATUS USB_CONNECTION_STATUS
struct _USB_HUB_NAME * PUSB_HUB_NAME
USHORT Count
Definition: userreq.cpp:200
UNICODE_STRING Text
Definition: userreq.cpp:261
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
@ WdfRetrievePresentChildren
Definition: wdfchildlist.h:61
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115
_In_ WDF_SPECIAL_FILE_TYPE NotificationType
Definition: wdfdevice.h:1024
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
#define WdfObjectReference(Handle)
Definition: wdfobject.h:803
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
#define WdfObjectDereference(Handle)
Definition: wdfobject.h:826
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
#define WDF_NO_OBJECT_ATTRIBUTES
Definition: wdftypes.h:105
FORCEINLINE VOID WDF_WMI_PROVIDER_CONFIG_INIT(_Out_ PWDF_WMI_PROVIDER_CONFIG Config, _In_ CONST GUID *Guid)
Definition: wdfwmi.h:205
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
EVT_WDF_WMI_INSTANCE_EXECUTE_METHOD * PFN_WDF_WMI_INSTANCE_EXECUTE_METHOD
Definition: wdfwmi.h:154
_In_ ULONG _Out_ PULONG BufferUsed
Definition: wdfwmi.h:92
EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE * PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE
Definition: wdfwmi.h:94
@ WdfWmiEventControl
Definition: wdfwmi.h:52
FORCEINLINE VOID WDF_WMI_INSTANCE_CONFIG_INIT_PROVIDER_CONFIG(_Out_ PWDF_WMI_INSTANCE_CONFIG Config, _In_ PWDF_WMI_PROVIDER_CONFIG ProviderConfig)
Definition: wdfwmi.h:286
@ WdfWmiProviderEventOnly
Definition: wdfwmi.h:69
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481
_Must_inspect_result_ _In_ WDFWMIINSTANCE WmiInstance
Definition: wdfwmi.h:514
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
_In_ ULONG MethodId
Definition: wdfwmi.h:142
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
@ DevicePropertyCompatibleIDs
Definition: iotypes.h:1197
@ DevicePropertyHardwareID
Definition: iotypes.h:1196
@ DevicePropertyDeviceDescription
Definition: iotypes.h:1195