ReactOS  0.4.15-dev-2359-g0dedb9b
plugplay.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * COPYRIGHT: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/io/pnpmgr/plugplay.c
5  * PURPOSE: Plug-and-play interface routines
6  * PROGRAMMERS: Eric Kohl <eric.kohl@t-online.de>
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 typedef struct _PNP_EVENT_ENTRY
16 {
20 
21 
22 /* GLOBALS *******************************************************************/
23 
26 
27 /* FUNCTIONS *****************************************************************/
28 
29 CODE_SEG("INIT")
32 {
34 
37  FALSE);
38 
39  return STATUS_SUCCESS;
40 }
41 
44  PUNICODE_STRING DeviceIds)
45 {
46  PPNP_EVENT_ENTRY EventEntry;
48  ULONG TotalSize;
50 
51  ASSERT(DeviceIds);
52 
53  /* Allocate a big enough buffer */
54  Copy.Length = 0;
55  Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
56  TotalSize =
58  Copy.MaximumLength;
59 
60  EventEntry = ExAllocatePool(NonPagedPool,
61  TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
62  if (!EventEntry)
64  RtlZeroMemory(EventEntry, TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
65 
66  /* Fill the buffer with the event GUID */
67  RtlCopyMemory(&EventEntry->Event.EventGuid,
68  Guid,
69  sizeof(GUID));
71  EventEntry->Event.TotalSize = TotalSize;
72 
73  /* Fill the device id */
74  Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
76  if (!NT_SUCCESS(Status))
77  {
78  ExFreePool(EventEntry);
79  return Status;
80  }
81 
83  &EventEntry->ListEntry);
85  0,
86  FALSE);
87 
88  return STATUS_SUCCESS;
89 }
90 
91 
92 static PDEVICE_OBJECT
94 {
96  PDEVICE_NODE ChildNode;
97 
98  if (RtlEqualUnicodeString(&Node->InstancePath,
100  {
101  ObReferenceObject(Node->PhysicalDeviceObject);
102  return Node->PhysicalDeviceObject;
103  }
104 
105  /* Traversal of all children nodes */
106  for (ChildNode = Node->Child;
107  ChildNode != NULL;
108  ChildNode = ChildNode->Sibling)
109  {
111  if (DeviceObject != NULL)
112  {
113  return DeviceObject;
114  }
115  }
116 
117  return NULL;
118 }
119 
120 
123 {
124  if (IopRootDeviceNode == NULL)
125  return NULL;
126 
127  if (DeviceInstance == NULL ||
128  DeviceInstance->Length == 0)
129  {
131  {
134  }
135  else
136  return NULL;
137  }
138 
140 }
141 
142 static NTSTATUS
144 {
146  volatile UNICODE_STRING Name;
147 
148  Name.Buffer = NULL;
149  _SEH2_TRY
150  {
151  Name.Length = SrcName->Length;
152  Name.MaximumLength = SrcName->MaximumLength;
153  if (Name.Length > Name.MaximumLength)
154  {
156  _SEH2_LEAVE;
157  }
158 
159  if (Name.MaximumLength)
160  {
161  ProbeForRead(SrcName->Buffer,
162  Name.MaximumLength,
163  sizeof(WCHAR));
164  Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
165  if (Name.Buffer == NULL)
166  {
168  _SEH2_LEAVE;
169  }
170 
171  memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
172  }
173 
174  *DstName = Name;
175  }
177  {
178  if (Name.Buffer)
179  {
180  ExFreePool(Name.Buffer);
181  }
183  }
184  _SEH2_END;
185 
186  return Status;
187 }
188 
189 /*
190  * Remove the current PnP event from the tail of the event queue
191  * and signal IopPnpNotifyEvent if there is yet another event in the queue.
192  */
193 static
194 NTSTATUS
197 {
198  /* Remove a pnp event entry from the tail of the queue */
200  {
202  }
203 
204  /* Signal the next pnp event in the queue */
206  {
208  0,
209  FALSE);
210  }
211 
212  return STATUS_SUCCESS;
213 }
214 
215 
216 static NTSTATUS
218 {
223  GUID FilterGuid;
224  PZZWSTR SymbolicLinkList = NULL, LinkList;
226 
227  _SEH2_TRY
228  {
230 
231  ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
232  RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
233 
234  if (StackList.Buffer != NULL && StackList.BufferSize != 0)
235  {
236  ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
237  }
238  }
240  {
242  }
243  _SEH2_END;
244 
246  if (NT_SUCCESS(Status))
247  {
248  /* Get the device object */
250  if (DeviceInstance.Buffer != NULL)
251  {
253  }
254  }
255 
256  Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
258 
259  if (!NT_SUCCESS(Status))
260  {
261  /* failed */
262  return Status;
263  }
264 
265  LinkList = SymbolicLinkList;
266  while (*SymbolicLinkList != UNICODE_NULL)
267  {
268  SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
269  }
270  TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
271 
272  _SEH2_TRY
273  {
274  if (StackList.Buffer != NULL &&
275  StackList.BufferSize >= TotalLength)
276  {
277  // We've already probed the buffer for writing above.
278  RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
279  }
280 
281  DeviceList->BufferSize = TotalLength;
282  }
284  {
285  ExFreePool(LinkList);
287  }
288  _SEH2_END;
289 
290  ExFreePool(LinkList);
291  return STATUS_SUCCESS;
292 }
293 
294 static NTSTATUS
296 {
301  ULONG Property;
303  PVOID Buffer;
305 
306  DPRINT("IopGetDeviceProperty() called\n");
307  DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
308 
310  if (!NT_SUCCESS(Status))
311  {
312  return Status;
313  }
314 
315  _SEH2_TRY
316  {
317  Property = PropertyData->Property;
318  BufferSize = PropertyData->BufferSize;
319  ProbeForWrite(PropertyData->Buffer,
320  BufferSize,
321  sizeof(UCHAR));
322  }
324  {
325  if (DeviceInstance.Buffer != NULL)
326  {
328  }
330  }
331  _SEH2_END;
332 
333  /* Get the device object */
335  if (DeviceInstance.Buffer != NULL)
336  {
338  }
339  if (DeviceObject == NULL)
340  {
341  return STATUS_NO_SUCH_DEVICE;
342  }
343 
345  if (Buffer == NULL)
346  {
349  }
350 
351 
352  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
353 
355  {
356  if (BufferSize < sizeof(CM_POWER_DATA))
357  {
358  BufferSize = 0;
360  }
361  else
362  {
364  PCM_POWER_DATA PowerData;
367 
368  PowerData = (PCM_POWER_DATA)Buffer;
369  RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
370  PowerData->PD_Size = sizeof(CM_POWER_DATA);
371 
374  DeviceCapabilities.Version = 1;
375  DeviceCapabilities.Address = -1;
376  DeviceCapabilities.UINumber = -1;
377 
378  Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
379 
381  &IoStatusBlock,
383  &Stack);
384  if (NT_SUCCESS(Status))
385  {
386  DPRINT("Got device capabiliities\n");
387 
388  PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
389  if (DeviceCapabilities.DeviceD1)
390  PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED;
391  if (DeviceCapabilities.DeviceD2)
392  PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED;
393  if (DeviceCapabilities.WakeFromD0)
395  if (DeviceCapabilities.WakeFromD1)
397  if (DeviceCapabilities.WakeFromD2)
399  if (DeviceCapabilities.WakeFromD3)
401  if (DeviceCapabilities.WarmEjectSupported)
403  PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
404  PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
405  PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
407  &DeviceCapabilities.DeviceState,
408  sizeof(DeviceCapabilities.DeviceState));
409  PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
410  }
411  else
412  {
413  DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
414 
417  }
418  }
419  }
421  {
422  }
424  {
425  if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
426  {
427  BufferSize = 0;
429  }
430  else
431  {
432  BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
434  &DeviceNode->HardwareRemovalPolicy,
435  BufferSize);
436  }
437  }
438  else
439  {
440  switch (Property)
441  {
444  break;
445 
448  break;
449 
452  break;
453 
456  break;
457 
460  break;
461 
464  break;
465 
468  break;
469 
472  break;
473 
476  break;
477 
478 #if (WINVER >= _WIN32_WINNT_WS03)
480  break;
481 #endif
482 
483 #if (WINVER >= _WIN32_WINNT_WIN7)
486  break;
487 #endif
488 
489  default:
490  BufferSize = 0;
492  break;
493  }
494 
495  if (Status == STATUS_SUCCESS)
496  {
499  BufferSize,
500  Buffer,
501  &BufferSize);
502  }
503  }
504 
506 
507  if (NT_SUCCESS(Status))
508  {
509  _SEH2_TRY
510  {
512  PropertyData->BufferSize = BufferSize;
513  }
515  {
517  }
518  _SEH2_END;
519  }
520 
522  return Status;
523 }
524 
525 
526 static NTSTATUS
528 {
529  UNICODE_STRING RootDeviceName;
532  PDEVICE_NODE RelatedDeviceNode;
533  UNICODE_STRING TargetDeviceInstance;
535  ULONG Relation = 0;
536  ULONG MaximumLength = 0;
537 
538  DPRINT("IopGetRelatedDevice() called\n");
539  DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
540 
541  Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
542  if (!NT_SUCCESS(Status))
543  {
544  return Status;
545  }
546 
547  _SEH2_TRY
548  {
549  Relation = RelatedDeviceData->Relation;
550  MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
551  ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
553  sizeof(WCHAR));
554  }
556  {
557  if (TargetDeviceInstance.Buffer != NULL)
558  {
559  ExFreePool(TargetDeviceInstance.Buffer);
560  }
562  }
563  _SEH2_END;
564 
565  RtlInitUnicodeString(&RootDeviceName,
566  L"HTREE\\ROOT\\0");
567  if (RtlEqualUnicodeString(&TargetDeviceInstance,
568  &RootDeviceName,
569  TRUE))
570  {
572  if (TargetDeviceInstance.Buffer != NULL)
573  {
574  ExFreePool(TargetDeviceInstance.Buffer);
575  }
576  }
577  else
578  {
579  /* Get the device object */
580  DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
581  if (TargetDeviceInstance.Buffer != NULL)
582  {
583  ExFreePool(TargetDeviceInstance.Buffer);
584  }
585  if (DeviceObject == NULL)
586  return STATUS_NO_SUCH_DEVICE;
587 
588  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
589  }
590 
591  switch (Relation)
592  {
594  RelatedDeviceNode = DeviceNode->Parent;
595  break;
596 
598  RelatedDeviceNode = DeviceNode->Child;
599  break;
600 
602  RelatedDeviceNode = DeviceNode->Sibling;
603  break;
604 
605  default:
606  if (DeviceObject != NULL)
607  {
609  }
610 
612  }
613 
614  if (RelatedDeviceNode == NULL)
615  {
616  if (DeviceObject)
617  {
619  }
620 
621  return STATUS_NO_SUCH_DEVICE;
622  }
623 
624  if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
625  {
626  if (DeviceObject)
627  {
629  }
630 
632  }
633 
634  /* Copy related device instance name */
635  _SEH2_TRY
636  {
637  RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
638  RelatedDeviceNode->InstancePath.Buffer,
639  RelatedDeviceNode->InstancePath.Length);
640  RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
641  }
643  {
645  }
646  _SEH2_END;
647 
648  if (DeviceObject != NULL)
649  {
651  }
652 
653  DPRINT("IopGetRelatedDevice() done\n");
654 
655  return Status;
656 }
657 
658 static
659 BOOLEAN
662 {
663  return (DeviceNode->State == DeviceNodeStartPending ||
666  DeviceNode->State == DeviceNodeStarted ||
670  DeviceNode->State == DeviceNodeStopped ||
672 }
673 
674 static ULONG
676 {
678 
679  if (DeviceNode->Parent == IopRootDeviceNode)
681 
682  // FIXME: review for deleted and removed states
683  if (DeviceNode->State >= DeviceNodeDriversAdded)
685 
687  Output |= DN_STARTED;
688 
689  if (DeviceNode->UserFlags & DNUF_WILL_BE_REMOVED)
691 
692  if (DeviceNode->Flags & DNF_HAS_PROBLEM)
694 
695  if (DeviceNode->Flags & DNF_HAS_PRIVATE_PROBLEM)
697 
698  if (DeviceNode->Flags & DNF_DRIVER_BLOCKED)
700 
703 
704  if (DeviceNode->Flags & DNF_HAS_PRIVATE_PROBLEM)
706 
707  if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
709 
710  if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
712 
713  if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
715 
716  return Output;
717 }
718 
719 static NTSTATUS
721 {
724  ULONG Operation = 0;
725  ULONG DeviceStatus = 0;
726  ULONG DeviceProblem = 0;
729 
730  DPRINT("IopDeviceStatus() called\n");
731 
733  if (!NT_SUCCESS(Status))
734  {
735  return Status;
736  }
737 
738  DPRINT("Device name: '%wZ'\n", &DeviceInstance);
739 
740  _SEH2_TRY
741  {
742  Operation = StatusData->Operation;
744  {
745  DeviceStatus = StatusData->DeviceStatus;
746  DeviceProblem = StatusData->DeviceProblem;
747  }
748  }
750  {
751  if (DeviceInstance.Buffer != NULL)
752  {
754  }
756  }
757  _SEH2_END;
758 
759  /* Get the device object */
761  if (DeviceInstance.Buffer != NULL)
762  {
764  }
765  if (DeviceObject == NULL)
766  {
767  return STATUS_NO_SUCH_DEVICE;
768  }
769 
771 
772  switch (Operation)
773  {
775  DPRINT("Get status data\n");
776  DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
777  DeviceProblem = DeviceNode->Problem;
778  break;
779 
781  DPRINT1("Set status data is NOT SUPPORTED\n");
782  break;
783 
785  DPRINT1("FIXME: Clear status data!\n");
786  break;
787  }
788 
790 
792  {
793  _SEH2_TRY
794  {
795  StatusData->DeviceStatus = DeviceStatus;
796  StatusData->DeviceProblem = DeviceProblem;
797  }
799  {
801  }
802  _SEH2_END;
803  }
804 
805  return Status;
806 }
807 
808 static
809 NTSTATUS
811 {
816  PDEVICE_RELATIONS DeviceRelations = NULL;
817  PDEVICE_OBJECT ChildDeviceObject;
818  PDEVICE_NODE ChildDeviceNode;
819  ULONG i;
820  ULONG Relations;
822  ULONG BufferLeft;
823  PWCHAR Buffer, Ptr;
825 
826  DPRINT("IopGetDeviceRelations() called\n");
827  DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
828  DPRINT("Relations: %lu\n", RelationsData->Relations);
829  DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
830  DPRINT("Buffer: %p\n", RelationsData->Buffer);
831 
832  _SEH2_TRY
833  {
834  Relations = RelationsData->Relations;
835  BufferSize = RelationsData->BufferSize;
836  Buffer = RelationsData->Buffer;
837 
838  ProbeForWrite(Buffer, BufferSize, sizeof(CHAR));
839  }
841  {
843  }
844  _SEH2_END;
845 
847  if (!NT_SUCCESS(Status))
848  {
849  DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
850  return Status;
851  }
852 
853  /* Get the device object */
855  if (DeviceObject == NULL)
856  {
857  DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
859  goto done;
860  }
861 
862  switch (Relations)
863  {
864  case PNP_EJECT_RELATIONS:
865  Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
866  break;
867 
869  Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
870  break;
871 
872  case PNP_POWER_RELATIONS:
873  Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
874  break;
875 
876  case PNP_BUS_RELATIONS:
877  Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
878  break;
879 
880  default:
882  goto done;
883  }
884 
886  &IoStatusBlock,
888  &Stack);
889  if (!NT_SUCCESS(Status))
890  {
891  DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
892  goto done;
893  }
894 
895  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
896 
897  DPRINT("Found %d device relations\n", DeviceRelations->Count);
898 
899  _SEH2_TRY
900  {
901  RequiredSize = 0;
902  BufferLeft = BufferSize;
903  Ptr = Buffer;
904 
905  for (i = 0; i < DeviceRelations->Count; i++)
906  {
907  ChildDeviceObject = DeviceRelations->Objects[i];
908 
909  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
910  if (ChildDeviceNode)
911  {
912  DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
913  DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
914 
915  if (Ptr != NULL)
916  {
917  if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
918  {
920  break;
921  }
922 
924  ChildDeviceNode->InstancePath.Buffer,
925  ChildDeviceNode->InstancePath.Length);
926  Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
927  *Ptr = UNICODE_NULL;
928  Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
929 
930  BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
931  }
932 
933  RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
934  }
935  }
936 
937  if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
938  *Ptr = UNICODE_NULL;
939 
940  if (RequiredSize > 0)
941  RequiredSize += sizeof(WCHAR);
942 
943  DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
944 
945  RelationsData->BufferSize = RequiredSize;
946  }
948  {
950  }
951  _SEH2_END;
952 
953 done:
954  if (DeviceRelations != NULL)
955  ExFreePool(DeviceRelations);
956 
957  if (DeviceObject != NULL)
959 
960  if (DeviceInstance.Buffer != NULL)
962 
963  return Status;
964 }
965 
966 static NTSTATUS
968 {
973 
974  DPRINT("IopGetDeviceDepth() called\n");
975  DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
976 
978  if (!NT_SUCCESS(Status))
979  {
980  return Status;
981  }
982 
983  /* Get the device object */
985  if (DeviceInstance.Buffer != NULL)
986  {
988  }
989  if (DeviceObject == NULL)
990  {
991  return STATUS_NO_SUCH_DEVICE;
992  }
993 
995 
996  _SEH2_TRY
997  {
998  DepthData->Depth = DeviceNode->Level;
999  }
1001  {
1003  }
1004  _SEH2_END;
1005 
1007 
1008  return Status;
1009 }
1010 
1011 static
1012 NTSTATUS
1016 {
1018  NTSTATUS Status;
1020 
1024 
1026  if (!NT_SUCCESS(Status))
1027  {
1028  return Status;
1029  }
1030 
1032  if (DeviceInstance.Buffer != NULL)
1033  {
1035  }
1036  if (DeviceObject == NULL)
1037  {
1038  return STATUS_NO_SUCH_DEVICE;
1039  }
1040 
1042 
1043  switch (ControlClass)
1044  {
1047  break;
1050  break;
1053  break;
1054  default:
1055  UNREACHABLE;
1056  break;
1057  }
1058 
1060 
1062 
1063  return Status;
1064 }
1065 
1066 /* PUBLIC FUNCTIONS **********************************************************/
1067 
1068 /*
1069  * Plug and Play event structure used by NtGetPlugPlayEvent.
1070  *
1071  * EventGuid
1072  * Can be one of the following values:
1073  * GUID_HWPROFILE_QUERY_CHANGE
1074  * GUID_HWPROFILE_CHANGE_CANCELLED
1075  * GUID_HWPROFILE_CHANGE_COMPLETE
1076  * GUID_TARGET_DEVICE_QUERY_REMOVE
1077  * GUID_TARGET_DEVICE_REMOVE_CANCELLED
1078  * GUID_TARGET_DEVICE_REMOVE_COMPLETE
1079  * GUID_PNP_CUSTOM_NOTIFICATION
1080  * GUID_PNP_POWER_NOTIFICATION
1081  * GUID_DEVICE_* (see above)
1082  *
1083  * EventCategory
1084  * Type of the event that happened.
1085  *
1086  * Result
1087  * ?
1088  *
1089  * Flags
1090  * ?
1091  *
1092  * TotalSize
1093  * Size of the event block including the device IDs and other
1094  * per category specific fields.
1095  */
1096 
1097 /*
1098  * NtGetPlugPlayEvent
1099  *
1100  * Returns one Plug & Play event from a global queue.
1101  *
1102  * Parameters
1103  * Reserved1
1104  * Reserved2
1105  * Always set to zero.
1106  *
1107  * Buffer
1108  * The buffer that will be filled with the event information on
1109  * successful return from the function.
1110  *
1111  * BufferSize
1112  * Size of the buffer pointed by the Buffer parameter. If the
1113  * buffer size is not large enough to hold the whole event
1114  * information, error STATUS_BUFFER_TOO_SMALL is returned and
1115  * the buffer remains untouched.
1116  *
1117  * Return Values
1118  * STATUS_PRIVILEGE_NOT_HELD
1119  * STATUS_BUFFER_TOO_SMALL
1120  * STATUS_SUCCESS
1121  *
1122  * Remarks
1123  * This function isn't multi-thread safe!
1124  *
1125  * @implemented
1126  */
1127 NTSTATUS
1128 NTAPI
1130  IN ULONG Reserved2,
1133 {
1135  NTSTATUS Status;
1136 
1137  DPRINT("NtGetPlugPlayEvent() called\n");
1138 
1139  /* Function can only be called from user-mode */
1140  if (KeGetPreviousMode() == KernelMode)
1141  {
1142  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1143  return STATUS_ACCESS_DENIED;
1144  }
1145 
1146  /* Check for Tcb privilege */
1148  UserMode))
1149  {
1150  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1152  }
1153 
1154  /* Wait for a PnP event */
1155  DPRINT("Waiting for pnp notification event\n");
1157  UserRequest,
1158  UserMode,
1159  FALSE,
1160  NULL);
1162  {
1163  DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1165  return Status;
1166  }
1167 
1168  /* Get entry from the tail of the queue */
1171  ListEntry);
1172 
1173  /* Check the buffer size */
1174  if (BufferSize < Entry->Event.TotalSize)
1175  {
1176  DPRINT1("Buffer is too small for the pnp-event\n");
1177  return STATUS_BUFFER_TOO_SMALL;
1178  }
1179 
1180  /* Copy event data to the user buffer */
1181  _SEH2_TRY
1182  {
1184  Entry->Event.TotalSize,
1185  sizeof(UCHAR));
1187  &Entry->Event,
1188  Entry->Event.TotalSize);
1189  }
1191  {
1193  }
1194  _SEH2_END;
1195 
1196  DPRINT("NtGetPlugPlayEvent() done\n");
1197 
1198  return STATUS_SUCCESS;
1199 }
1200 
1201 /*
1202  * NtPlugPlayControl
1203  *
1204  * A function for doing various Plug & Play operations from user mode.
1205  *
1206  * Parameters
1207  * PlugPlayControlClass
1208  * 0x00 Reenumerate device tree
1209  *
1210  * Buffer points to UNICODE_STRING decribing the instance
1211  * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
1212  * more information about instance paths see !devnode command
1213  * in kernel debugger or look at "Inside Windows 2000" book,
1214  * chapter "Driver Loading, Initialization, and Installation".
1215  *
1216  * 0x01 Register new device
1217  * 0x02 Deregister device
1218  * 0x03 Initialize device
1219  * 0x04 Start device
1220  * 0x06 Query and remove device
1221  * 0x07 User response
1222  *
1223  * Called after processing the message from NtGetPlugPlayEvent.
1224  *
1225  * 0x08 Generate legacy device
1226  * 0x09 Get interface device list
1227  * 0x0A Get property data
1228  * 0x0B Device class association (Registration)
1229  * 0x0C Get related device
1230  * 0x0D Get device interface alias
1231  * 0x0E Get/set/clear device status
1232  * 0x0F Get device depth
1233  * 0x10 Query device relations
1234  * 0x11 Query target device relation
1235  * 0x12 Query conflict list
1236  * 0x13 Retrieve dock data
1237  * 0x14 Reset device
1238  * 0x15 Halt device
1239  * 0x16 Get blocked driver data
1240  *
1241  * Buffer
1242  * The buffer contains information that is specific to each control
1243  * code. The buffer is read-only.
1244  *
1245  * BufferSize
1246  * Size of the buffer pointed by the Buffer parameter. If the
1247  * buffer size specifies incorrect value for specified control
1248  * code, error ??? is returned.
1249  *
1250  * Return Values
1251  * STATUS_PRIVILEGE_NOT_HELD
1252  * STATUS_SUCCESS
1253  * ...
1254  *
1255  * @unimplemented
1256  */
1257 NTSTATUS
1258 NTAPI
1260  IN OUT PVOID Buffer,
1262 {
1263  DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1264  PlugPlayControlClass, Buffer, BufferLength);
1265 
1266  /* Function can only be called from user-mode */
1267  if (KeGetPreviousMode() == KernelMode)
1268  {
1269  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1270  return STATUS_ACCESS_DENIED;
1271  }
1272 
1273  /* Check for Tcb privilege */
1275  UserMode))
1276  {
1277  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1279  }
1280 
1281  /* Probe the buffer */
1282  _SEH2_TRY
1283  {
1285  BufferLength,
1286  sizeof(ULONG));
1287  }
1289  {
1291  }
1292  _SEH2_END;
1293 
1294  switch (PlugPlayControlClass)
1295  {
1298  return STATUS_INVALID_PARAMETER;
1299  // the Flags field is not used anyway
1301  PlugPlayControlClass);
1302 
1303 // case PlugPlayControlRegisterNewDevice:
1304 // case PlugPlayControlDeregisterDevice:
1305 // case PlugPlayControlInitializeDevice:
1306 
1310  return STATUS_INVALID_PARAMETER;
1312  PlugPlayControlClass);
1313 
1314 // case PlugPlayControlUnlockDevice:
1315 // case PlugPlayControlQueryAndRemoveDevice:
1316 
1319  return STATUS_INVALID_PARAMETER;
1321 
1322 // case PlugPlayControlGenerateLegacyDevice:
1323 
1326  return STATUS_INVALID_PARAMETER;
1328 
1331  return STATUS_INVALID_PARAMETER;
1333 
1334 // case PlugPlayControlDeviceClassAssociation:
1335 
1338  return STATUS_INVALID_PARAMETER;
1340 
1341 // case PlugPlayControlGetInterfaceDeviceAlias:
1342 
1345  return STATUS_INVALID_PARAMETER;
1347 
1350  return STATUS_INVALID_PARAMETER;
1352 
1355  return STATUS_INVALID_PARAMETER;
1357 
1358 // case PlugPlayControlTargetDeviceRelation:
1359 // case PlugPlayControlQueryConflictList:
1360 // case PlugPlayControlRetrieveDock:
1361 // case PlugPlayControlHaltDevice:
1362 // case PlugPlayControlGetBlockedDriverList:
1363 
1364  default:
1365  return STATUS_NOT_IMPLEMENTED;
1366  }
1367 
1368  return STATUS_NOT_IMPLEMENTED;
1369 }
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:675
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define IN
Definition: typedefs.h:39
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
#define PNP_REMOVAL_RELATIONS
Definition: cmtypes.h:67
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define PDCAP_WARM_EJECT_SUPPORTED
Definition: advprop.cpp:44
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:850
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
#define DNF_HAS_PROBLEM
Definition: iotypes.h:183
struct _Entry Entry
Definition: kefuncs.h:627
static const WCHAR ControlClass[]
Definition: cfgmgr.c:42
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:688
static NTSTATUS IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
Definition: plugplay.c:527
#define DNUF_NOT_DISABLEABLE
Definition: iotypes.h:211
#define PDCAP_D1_SUPPORTED
Definition: advprop.cpp:37
#define PNP_POWER_RELATIONS
Definition: cmtypes.h:68
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define DN_ROOT_ENUMERATED
Definition: cfg.h:118
#define TRUE
Definition: types.h:120
Definition: plugplay.c:15
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define DN_DRIVER_BLOCKED
Definition: cfg.h:154
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3767
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
#define PNP_GET_SIBLING_DEVICE
Definition: cmtypes.h:54
char CHAR
Definition: xmlstorage.h:175
FORCEINLINE PLIST_ENTRY RemoveTailList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:154
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define KeGetPreviousMode()
Definition: ketypes.h:1107
LONG NTSTATUS
Definition: precomp.h:26
#define DN_DRIVER_LOADED
Definition: cfg.h:119
#define DN_DISABLEABLE
Definition: cfg.h:131
PLUGPLAY_EVENT_BLOCK Event
Definition: plugplay.c:18
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:454
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:520
#define PNP_SET_DEVICE_STATUS
Definition: cmtypes.h:60
#define PNP_GET_PARENT_DEVICE
Definition: cmtypes.h:52
DEVICE_CAPABILITIES
Definition: iotypes.h:965
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
#define PNP_BUS_RELATIONS
Definition: cmtypes.h:69
PDEVICE_LIST DeviceList
Definition: utils.c:27
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:24
uint16_t * PWCHAR
Definition: typedefs.h:56
struct _PNP_EVENT_ENTRY PNP_EVENT_ENTRY
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:525
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:810
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:420
_In_ ULONG TotalLength
Definition: usbdlib.h:158
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
static PDEVICE_OBJECT IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:93
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
static NTSTATUS IopRemovePlugPlayEvent(_In_ PPLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData)
Definition: plugplay.c:195
enum _PLUGPLAY_CONTROL_CLASS PLUGPLAY_CONTROL_CLASS
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
NTSTATUS IopQueueTargetDeviceEvent(const GUID *Guid, PUNICODE_STRING DeviceIds)
Definition: plugplay.c:43
_SEH2_TRY
Definition: create.c:4226
uint32_t ULONG_PTR
Definition: typedefs.h:65
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:295
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:406
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define DNUF_DONT_SHOW_IN_UI
Definition: iotypes.h:209
NTSTATUS NTAPI NtGetPlugPlayEvent(IN ULONG Reserved1, IN ULONG Reserved2, OUT PPLUGPLAY_EVENT_BLOCK Buffer, IN ULONG BufferSize)
Definition: plugplay.c:1129
#define PDCAP_D2_SUPPORTED
Definition: advprop.cpp:38
ULONG PD_D2Latency
Definition: advprop.cpp:52
struct NameRec_ * Name
Definition: cdprocs.h:459
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
unsigned char BOOLEAN
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:122
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define DeviceCapabilities
Definition: wingdi.h:4448
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1953
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
Definition: bufpool.h:45
#define DN_NO_SHOW_IN_DM
Definition: cfg.h:148
#define PDCAP_D3_SUPPORTED
Definition: advprop.cpp:39
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:25
Definition: bcd.h:202
NTSTATUS IopInitPlugPlayEvents(VOID)
Definition: plugplay.c:31
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define PNP_PROPERTY_ADDRESS
Definition: cmtypes.h:42
enum _DEVICE_ACTION DEVICE_ACTION
ULONG PD_D3Latency
Definition: advprop.cpp:53
Status
Definition: gdiplustypes.h:24
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
#define DN_PRIVATE_PROBLEM
Definition: cfg.h:133
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define ASSERT(a)
Definition: mode.c:45
static BOOLEAN PiIsDevNodeStarted(_In_ PDEVICE_NODE DeviceNode)
Definition: plugplay.c:660
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PNP_GET_DEVICE_STATUS
Definition: cmtypes.h:59
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:760
#define PNP_PROPERTY_REMOVAL_POLICY
Definition: cmtypes.h:40
struct _PNP_EVENT_ENTRY * PPNP_EVENT_ENTRY
static NTSTATUS IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
Definition: plugplay.c:720
#define ObDereferenceObject
Definition: obfuncs.h:203
#define DN_HAS_PROBLEM
Definition: cfg.h:128
#define DN_NT_DRIVER
Definition: cfg.h:142
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
CODE_SEG("INIT")
Definition: fsrtlpc.c:19
#define DN_NT_ENUMERATOR
Definition: cfg.h:141
Definition: Node.h:9
#define DNF_CHILD_WITH_INVALID_ID
Definition: iotypes.h:191
#define PNP_PROPERTY_UI_NUMBER
Definition: cmtypes.h:34
#define PNP_PROPERTY_REMOVAL_POLICY_OVERRIDE
Definition: cmtypes.h:41
unsigned char UCHAR
Definition: xmlstorage.h:181
#define PNP_CLEAR_DEVICE_STATUS
Definition: cmtypes.h:61
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
static const WCHAR L[]
Definition: oid.c:1250
Definition: arc.h:85
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cmtypes.h:35
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:143
#define DNF_LEGACY_DRIVER
Definition: iotypes.h:182
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: typedefs.h:119
#define PNP_GET_CHILD_DEVICE
Definition: cmtypes.h:53
static NTSTATUS IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
Definition: plugplay.c:967
UNICODE_STRING InstancePath
Definition: iotypes.h:853
NTSTATUS PiPerformSyncDeviceAction(_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action)
Perfom a device operation synchronously via PiQueueDeviceAction.
Definition: devaction.c:2675
const LUID SeTcbPrivilege
Definition: priv.c:24
#define PDCAP_WAKE_FROM_D1_SUPPORTED
Definition: advprop.cpp:41
#define STATUS_USER_APC
Definition: ntstatus.h:78
#define _In_
Definition: no_sal2.h:158
_In_ DWORD Property
Definition: setupapi.h:1545
static NTSTATUS PiControlSyncDeviceAction(_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceData, _In_ PLUGPLAY_CONTROL_CLASS ControlClass)
Definition: plugplay.c:1013
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:126
SYSTEM_POWER_STATE PD_DeepestSystemWake
Definition: advprop.cpp:55
_SEH2_END
Definition: create.c:4400
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1259
LIST_ENTRY ListEntry
Definition: plugplay.c:17
ULONG PD_D1Latency
Definition: advprop.cpp:51
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:506
struct CM_Power_Data_s CM_POWER_DATA
struct CM_Power_Data_s * PCM_POWER_DATA
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define DNF_HAS_PRIVATE_PROBLEM
Definition: iotypes.h:184
#define NULL
Definition: types.h:112
#define IRP_MN_QUERY_DEVICE_RELATIONS
struct _DEVICE_NODE * Sibling
Definition: iotypes.h:834
Definition: bcd.h:201
DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]
Definition: advprop.cpp:54
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
#define PNP_EJECT_RELATIONS
Definition: cmtypes.h:66
#define DN_LEGACY_DRIVER
Definition: cfg.h:155
#define DN_CHILD_WITH_INVALID_ID
Definition: cfg.h:156
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
#define DN_STARTED
Definition: cfg.h:121
#define OUT
Definition: typedefs.h:40
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNREACHABLE
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define PDCAP_WAKE_FROM_D0_SUPPORTED
Definition: advprop.cpp:40
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
DEVICE_POWER_STATE PD_MostRecentPowerState
Definition: advprop.cpp:49
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4431
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define _SEH2_LEAVE
Definition: filesup.c:20
#define DPRINT
Definition: sndvol32.h:71
#define PDCAP_WAKE_FROM_D2_SUPPORTED
Definition: advprop.cpp:42
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
#define DN_WILL_BE_REMOVED
Definition: cfg.h:136
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
static NTSTATUS IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
Definition: plugplay.c:217
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:534
#define PDCAP_WAKE_FROM_D3_SUPPORTED
Definition: advprop.cpp:43
base of all file and directory entries
Definition: entries.h:82
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
struct _PLUGPLAY_EVENT_BLOCK::@2346::@2349 TargetDevice
ULONG PD_Capabilities
Definition: advprop.cpp:50
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define PDCAP_D0_SUPPORTED
Definition: advprop.cpp:36
#define DNF_DRIVER_BLOCKED
Definition: iotypes.h:190
#define IRP_MN_QUERY_CAPABILITIES
Definition: dlist.c:348
#define DNUF_WILL_BE_REMOVED
Definition: iotypes.h:208