ReactOS  0.4.13-dev-92-gf251225
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 #if defined (ALLOC_PRAGMA)
16 #pragma alloc_text(INIT, IopInitPlugPlayEvents)
17 #endif
18 
19 typedef struct _PNP_EVENT_ENTRY
20 {
24 
25 
26 /* GLOBALS *******************************************************************/
27 
30 
31 /* FUNCTIONS *****************************************************************/
32 
33 NTSTATUS INIT_FUNCTION
35 {
37 
40  FALSE);
41 
42  return STATUS_SUCCESS;
43 }
44 
47  PUNICODE_STRING DeviceIds)
48 {
49  PPNP_EVENT_ENTRY EventEntry;
51  ULONG TotalSize;
53 
54  ASSERT(DeviceIds);
55 
56  /* Allocate a big enough buffer */
57  Copy.Length = 0;
58  Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
59  TotalSize =
61  Copy.MaximumLength;
62 
63  EventEntry = ExAllocatePool(NonPagedPool,
64  TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
65  if (!EventEntry)
67 
68  /* Fill the buffer with the event GUID */
69  RtlCopyMemory(&EventEntry->Event.EventGuid,
70  Guid,
71  sizeof(GUID));
73  EventEntry->Event.TotalSize = TotalSize;
74 
75  /* Fill the device id */
76  Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
78  if (!NT_SUCCESS(Status))
79  {
80  ExFreePool(EventEntry);
81  return Status;
82  }
83 
85  &EventEntry->ListEntry);
87  0,
88  FALSE);
89 
90  return STATUS_SUCCESS;
91 }
92 
93 
94 /*
95  * Remove the current PnP event from the tail of the event queue
96  * and signal IopPnpNotifyEvent if there is yet another event in the queue.
97  */
98 static NTSTATUS
100 {
101  /* Remove a pnp event entry from the tail of the queue */
103  {
105  }
106 
107  /* Signal the next pnp event in the queue */
109  {
111  0,
112  FALSE);
113  }
114 
115  return STATUS_SUCCESS;
116 }
117 
118 static PDEVICE_OBJECT
120 {
122  PDEVICE_NODE ChildNode;
123 
124  if (RtlEqualUnicodeString(&Node->InstancePath,
126  {
127  ObReferenceObject(Node->PhysicalDeviceObject);
128  return Node->PhysicalDeviceObject;
129  }
130 
131  /* Traversal of all children nodes */
132  for (ChildNode = Node->Child;
133  ChildNode != NULL;
134  ChildNode = ChildNode->Sibling)
135  {
137  if (DeviceObject != NULL)
138  {
139  return DeviceObject;
140  }
141  }
142 
143  return NULL;
144 }
145 
146 
149 {
150  if (IopRootDeviceNode == NULL)
151  return NULL;
152 
153  if (DeviceInstance == NULL ||
154  DeviceInstance->Length == 0)
155  {
157  {
160  }
161  else
162  return NULL;
163  }
164 
166 }
167 
168 static NTSTATUS
170 {
172  volatile UNICODE_STRING Name;
173 
174  Name.Buffer = NULL;
175  _SEH2_TRY
176  {
177  Name.Length = SrcName->Length;
178  Name.MaximumLength = SrcName->MaximumLength;
179  if (Name.Length > Name.MaximumLength)
180  {
182  _SEH2_LEAVE;
183  }
184 
185  if (Name.MaximumLength)
186  {
187  ProbeForRead(SrcName->Buffer,
188  Name.MaximumLength,
189  sizeof(WCHAR));
190  Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
191  if (Name.Buffer == NULL)
192  {
194  _SEH2_LEAVE;
195  }
196 
197  memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
198  }
199 
200  *DstName = Name;
201  }
203  {
204  if (Name.Buffer)
205  {
206  ExFreePool(Name.Buffer);
207  }
209  }
210  _SEH2_END;
211 
212  return Status;
213 }
214 
215 static NTSTATUS
217 {
222  GUID FilterGuid;
223  PZZWSTR SymbolicLinkList = NULL, LinkList;
225 
226  _SEH2_TRY
227  {
229 
230  ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
231  RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
232 
233  if (StackList.Buffer != NULL && StackList.BufferSize != 0)
234  {
235  ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
236  }
237  }
239  {
241  }
242  _SEH2_END;
243 
245  if (NT_SUCCESS(Status))
246  {
247  /* Get the device object */
249  if (DeviceInstance.Buffer != NULL)
250  {
252  }
253  }
254 
255  Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
257 
258  if (!NT_SUCCESS(Status))
259  {
260  /* failed */
261  return Status;
262  }
263 
264  LinkList = SymbolicLinkList;
265  while (*SymbolicLinkList != UNICODE_NULL)
266  {
267  SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
268  }
269  TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
270 
271  _SEH2_TRY
272  {
273  if (StackList.Buffer != NULL &&
274  StackList.BufferSize >= TotalLength)
275  {
276  // We've already probed the buffer for writing above.
277  RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
278  }
279 
280  DeviceList->BufferSize = TotalLength;
281  }
283  {
284  ExFreePool(LinkList);
286  }
287  _SEH2_END;
288 
289  ExFreePool(LinkList);
290  return STATUS_SUCCESS;
291 }
292 
293 static NTSTATUS
295 {
300  ULONG Property;
302  PVOID Buffer;
304 
305  DPRINT("IopGetDeviceProperty() called\n");
306  DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
307 
309  if (!NT_SUCCESS(Status))
310  {
311  return Status;
312  }
313 
314  _SEH2_TRY
315  {
316  Property = PropertyData->Property;
317  BufferSize = PropertyData->BufferSize;
318  ProbeForWrite(PropertyData->Buffer,
319  BufferSize,
320  sizeof(UCHAR));
321  }
323  {
324  if (DeviceInstance.Buffer != NULL)
325  {
327  }
329  }
330  _SEH2_END;
331 
332  /* Get the device object */
334  if (DeviceInstance.Buffer != NULL)
335  {
337  }
338  if (DeviceObject == NULL)
339  {
340  return STATUS_NO_SUCH_DEVICE;
341  }
342 
344  if (Buffer == NULL)
345  {
348  }
349 
350 
351  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
352 
354  {
355  if (BufferSize < sizeof(CM_POWER_DATA))
356  {
357  BufferSize = 0;
359  }
360  else
361  {
363  PCM_POWER_DATA PowerData;
364  IO_STACK_LOCATION Stack;
366 
367  PowerData = (PCM_POWER_DATA)Buffer;
368  RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
369  PowerData->PD_Size = sizeof(CM_POWER_DATA);
370 
373  DeviceCapabilities.Version = 1;
374  DeviceCapabilities.Address = -1;
375  DeviceCapabilities.UINumber = -1;
376 
377  Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
378 
380  &IoStatusBlock,
382  &Stack);
383  if (NT_SUCCESS(Status))
384  {
385  DPRINT("Got device capabiliities\n");
386 
387  PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
388  if (DeviceCapabilities.DeviceD1)
389  PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED;
390  if (DeviceCapabilities.DeviceD2)
391  PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED;
392  if (DeviceCapabilities.WakeFromD0)
394  if (DeviceCapabilities.WakeFromD1)
396  if (DeviceCapabilities.WakeFromD2)
398  if (DeviceCapabilities.WakeFromD3)
400  if (DeviceCapabilities.WarmEjectSupported)
402  PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
403  PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
404  PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
406  &DeviceCapabilities.DeviceState,
407  sizeof(DeviceCapabilities.DeviceState));
408  PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
409  }
410  else
411  {
412  DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
413 
416  }
417  }
418  }
420  {
421  }
423  {
424  if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
425  {
426  BufferSize = 0;
428  }
429  else
430  {
431  BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
433  &DeviceNode->HardwareRemovalPolicy,
434  BufferSize);
435  }
436  }
437  else
438  {
439  switch (Property)
440  {
443  break;
444 
447  break;
448 
451  break;
452 
455  break;
456 
459  break;
460 
463  break;
464 
467  break;
468 
471  break;
472 
475  break;
476 
477 #if (WINVER >= _WIN32_WINNT_WS03)
479  break;
480 #endif
481 
482 #if (WINVER >= _WIN32_WINNT_WIN7)
485  break;
486 #endif
487 
488  default:
489  BufferSize = 0;
491  break;
492  }
493 
494  if (Status == STATUS_SUCCESS)
495  {
498  BufferSize,
499  Buffer,
500  &BufferSize);
501  }
502  }
503 
505 
506  if (NT_SUCCESS(Status))
507  {
508  _SEH2_TRY
509  {
510  RtlCopyMemory(PropertyData->Buffer, Buffer, BufferSize);
511  PropertyData->BufferSize = BufferSize;
512  }
514  {
516  }
517  _SEH2_END;
518  }
519 
521  return Status;
522 }
523 
524 
525 static NTSTATUS
527 {
528  UNICODE_STRING RootDeviceName;
531  PDEVICE_NODE RelatedDeviceNode;
532  UNICODE_STRING TargetDeviceInstance;
534  ULONG Relation = 0;
535  ULONG MaximumLength = 0;
536 
537  DPRINT("IopGetRelatedDevice() called\n");
538  DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
539 
540  Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
541  if (!NT_SUCCESS(Status))
542  {
543  return Status;
544  }
545 
546  _SEH2_TRY
547  {
548  Relation = RelatedDeviceData->Relation;
549  MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
550  ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
552  sizeof(WCHAR));
553  }
555  {
556  if (TargetDeviceInstance.Buffer != NULL)
557  {
558  ExFreePool(TargetDeviceInstance.Buffer);
559  }
561  }
562  _SEH2_END;
563 
564  RtlInitUnicodeString(&RootDeviceName,
565  L"HTREE\\ROOT\\0");
566  if (RtlEqualUnicodeString(&TargetDeviceInstance,
567  &RootDeviceName,
568  TRUE))
569  {
571  if (TargetDeviceInstance.Buffer != NULL)
572  {
573  ExFreePool(TargetDeviceInstance.Buffer);
574  }
575  }
576  else
577  {
578  /* Get the device object */
579  DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
580  if (TargetDeviceInstance.Buffer != NULL)
581  {
582  ExFreePool(TargetDeviceInstance.Buffer);
583  }
584  if (DeviceObject == NULL)
585  return STATUS_NO_SUCH_DEVICE;
586 
587  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
588  }
589 
590  switch (Relation)
591  {
593  RelatedDeviceNode = DeviceNode->Parent;
594  break;
595 
597  RelatedDeviceNode = DeviceNode->Child;
598  break;
599 
601  RelatedDeviceNode = DeviceNode->Sibling;
602  break;
603 
604  default:
605  if (DeviceObject != NULL)
606  {
608  }
609 
611  }
612 
613  if (RelatedDeviceNode == NULL)
614  {
615  if (DeviceObject)
616  {
618  }
619 
620  return STATUS_NO_SUCH_DEVICE;
621  }
622 
623  if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
624  {
625  if (DeviceObject)
626  {
628  }
629 
631  }
632 
633  /* Copy related device instance name */
634  _SEH2_TRY
635  {
636  RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
637  RelatedDeviceNode->InstancePath.Buffer,
638  RelatedDeviceNode->InstancePath.Length);
639  RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
640  }
642  {
644  }
645  _SEH2_END;
646 
647  if (DeviceObject != NULL)
648  {
650  }
651 
652  DPRINT("IopGetRelatedDevice() done\n");
653 
654  return Status;
655 }
656 
657 static ULONG
659 {
660  ULONG Output = 0;
661 
662  if (DeviceNode->Parent == IopRootDeviceNode)
664 
665  if (DeviceNode->Flags & DNF_ADDED)
667 
668  /* FIXME: DN_ENUM_LOADED */
669 
670  if (DeviceNode->Flags & DNF_STARTED)
671  Output |= DN_STARTED;
672 
673  /* FIXME: Manual */
674 
675  if (!(DeviceNode->Flags & DNF_PROCESSED))
677 
678  /* DN_NOT_FIRST_TIME is 9x only */
679 
680  /* FIXME: DN_HARDWARE_ENUM */
681 
682  /* DN_LIAR and DN_HAS_MARK are 9x only */
683 
684  if (DeviceNode->Problem != 0)
686 
687  /* FIXME: DN_FILTERED */
688 
689  if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
691 
692  if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
694 
695  if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
697 
698  /* FIXME: Implement the rest */
699 
701 
702  return Output;
703 }
704 
705 static NTSTATUS
707 {
710  ULONG Operation = 0;
711  ULONG DeviceStatus = 0;
712  ULONG DeviceProblem = 0;
715 
716  DPRINT("IopDeviceStatus() called\n");
717 
719  if (!NT_SUCCESS(Status))
720  {
721  return Status;
722  }
723 
724  DPRINT("Device name: '%wZ'\n", &DeviceInstance);
725 
726  _SEH2_TRY
727  {
728  Operation = StatusData->Operation;
730  {
731  DeviceStatus = StatusData->DeviceStatus;
732  DeviceProblem = StatusData->DeviceProblem;
733  }
734  }
736  {
737  if (DeviceInstance.Buffer != NULL)
738  {
740  }
742  }
743  _SEH2_END;
744 
745  /* Get the device object */
747  if (DeviceInstance.Buffer != NULL)
748  {
750  }
751  if (DeviceObject == NULL)
752  {
753  return STATUS_NO_SUCH_DEVICE;
754  }
755 
757 
758  switch (Operation)
759  {
761  DPRINT("Get status data\n");
762  DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
763  DeviceProblem = DeviceNode->Problem;
764  break;
765 
767  DPRINT1("Set status data is NOT SUPPORTED\n");
768  break;
769 
771  DPRINT1("FIXME: Clear status data!\n");
772  break;
773  }
774 
776 
778  {
779  _SEH2_TRY
780  {
781  StatusData->DeviceStatus = DeviceStatus;
782  StatusData->DeviceProblem = DeviceProblem;
783  }
785  {
787  }
788  _SEH2_END;
789  }
790 
791  return Status;
792 }
793 
794 static
795 NTSTATUS
797 {
800  IO_STACK_LOCATION Stack;
802  PDEVICE_RELATIONS DeviceRelations = NULL;
803  PDEVICE_OBJECT ChildDeviceObject;
804  PDEVICE_NODE ChildDeviceNode;
805  ULONG i;
806  ULONG Relations;
808  ULONG BufferLeft;
809  PWCHAR Buffer, Ptr;
811 
812  DPRINT("IopGetDeviceRelations() called\n");
813  DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
814  DPRINT("Relations: %lu\n", RelationsData->Relations);
815  DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
816  DPRINT("Buffer: %p\n", RelationsData->Buffer);
817 
818  _SEH2_TRY
819  {
820  Relations = RelationsData->Relations;
821  BufferSize = RelationsData->BufferSize;
822  Buffer = RelationsData->Buffer;
823 
824  ProbeForWrite(Buffer, BufferSize, sizeof(CHAR));
825  }
827  {
829  }
830  _SEH2_END;
831 
833  if (!NT_SUCCESS(Status))
834  {
835  DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
836  return Status;
837  }
838 
839  /* Get the device object */
841  if (DeviceObject == NULL)
842  {
843  DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
845  goto done;
846  }
847 
848  switch (Relations)
849  {
850  case PNP_EJECT_RELATIONS:
851  Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
852  break;
853 
855  Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
856  break;
857 
858  case PNP_POWER_RELATIONS:
859  Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
860  break;
861 
862  case PNP_BUS_RELATIONS:
863  Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
864  break;
865 
866  default:
868  goto done;
869  }
870 
872  &IoStatusBlock,
874  &Stack);
875  if (!NT_SUCCESS(Status))
876  {
877  DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
878  goto done;
879  }
880 
881  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
882 
883  DPRINT("Found %d device relations\n", DeviceRelations->Count);
884 
885  _SEH2_TRY
886  {
887  RequiredSize = 0;
888  BufferLeft = BufferSize;
889  Ptr = Buffer;
890 
891  for (i = 0; i < DeviceRelations->Count; i++)
892  {
893  ChildDeviceObject = DeviceRelations->Objects[i];
894 
895  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
896  if (ChildDeviceNode)
897  {
898  DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
899  DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
900 
901  if (Ptr != NULL)
902  {
903  if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
904  {
906  break;
907  }
908 
910  ChildDeviceNode->InstancePath.Buffer,
911  ChildDeviceNode->InstancePath.Length);
912  Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
913  *Ptr = UNICODE_NULL;
914  Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
915 
916  BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
917  }
918 
919  RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
920  }
921  }
922 
923  if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
924  *Ptr = UNICODE_NULL;
925 
926  if (RequiredSize > 0)
927  RequiredSize += sizeof(WCHAR);
928 
929  DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
930 
931  RelationsData->BufferSize = RequiredSize;
932  }
934  {
936  }
937  _SEH2_END;
938 
939 done:
940  if (DeviceRelations != NULL)
941  ExFreePool(DeviceRelations);
942 
943  if (DeviceObject != NULL)
945 
946  if (DeviceInstance.Buffer != NULL)
948 
949  return Status;
950 }
951 
952 static NTSTATUS
954 {
959 
960  DPRINT("IopGetDeviceDepth() called\n");
961  DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
962 
964  if (!NT_SUCCESS(Status))
965  {
966  return Status;
967  }
968 
969  /* Get the device object */
971  if (DeviceInstance.Buffer != NULL)
972  {
974  }
975  if (DeviceObject == NULL)
976  {
977  return STATUS_NO_SUCH_DEVICE;
978  }
979 
981 
982  _SEH2_TRY
983  {
984  DepthData->Depth = DeviceNode->Level;
985  }
987  {
989  }
990  _SEH2_END;
991 
993 
994  return Status;
995 }
996 
997 
998 static NTSTATUS
1000 {
1005 
1007  if (!NT_SUCCESS(Status))
1008  {
1009  return Status;
1010  }
1011 
1012  DPRINT("IopResetDevice(%wZ)\n", &DeviceInstance);
1013 
1014  /* Get the device object */
1016  if (DeviceInstance.Buffer != NULL)
1017  {
1019  }
1020  if (DeviceObject == NULL)
1021  {
1022  return STATUS_NO_SUCH_DEVICE;
1023  }
1024 
1025  /* Get the device node */
1027 
1028  ASSERT(DeviceNode->Flags & DNF_ENUMERATED);
1029  ASSERT(DeviceNode->Flags & DNF_PROCESSED);
1030 
1031  /* Check if there's already a driver loaded for this device */
1032  if (DeviceNode->Flags & DNF_ADDED)
1033  {
1034 #if 0
1035  /* Remove the device node */
1037  if (NT_SUCCESS(Status))
1038  {
1039  /* Invalidate device relations for the parent to reenumerate the device */
1040  DPRINT1("A new driver will be loaded for '%wZ' (FDO above removed)\n", &DeviceNode->InstancePath);
1041  Status = IoSynchronousInvalidateDeviceRelations(DeviceNode->Parent->PhysicalDeviceObject, BusRelations);
1042  }
1043  else
1044 #endif
1045  {
1046  /* A driver has already been loaded for this device */
1047  DPRINT1("A reboot is required for the current driver for '%wZ' to be replaced\n", &DeviceNode->InstancePath);
1048  DeviceNode->Problem = CM_PROB_NEED_RESTART;
1049  }
1050  }
1051  else
1052  {
1053  /* FIXME: What if the device really is disabled? */
1054  DeviceNode->Flags &= ~DNF_DISABLED;
1055  DeviceNode->Problem = 0;
1056 
1057  /* Load service data from the registry */
1059 
1060  if (NT_SUCCESS(Status))
1061  {
1062  /* Start the service and begin PnP initialization of the device again */
1063  DPRINT1("A new driver will be loaded for '%wZ' (no FDO above)\n", &DeviceNode->InstancePath);
1065  }
1066  }
1067 
1069 
1070  return Status;
1071 }
1072 
1073 /* PUBLIC FUNCTIONS **********************************************************/
1074 
1075 /*
1076  * Plug and Play event structure used by NtGetPlugPlayEvent.
1077  *
1078  * EventGuid
1079  * Can be one of the following values:
1080  * GUID_HWPROFILE_QUERY_CHANGE
1081  * GUID_HWPROFILE_CHANGE_CANCELLED
1082  * GUID_HWPROFILE_CHANGE_COMPLETE
1083  * GUID_TARGET_DEVICE_QUERY_REMOVE
1084  * GUID_TARGET_DEVICE_REMOVE_CANCELLED
1085  * GUID_TARGET_DEVICE_REMOVE_COMPLETE
1086  * GUID_PNP_CUSTOM_NOTIFICATION
1087  * GUID_PNP_POWER_NOTIFICATION
1088  * GUID_DEVICE_* (see above)
1089  *
1090  * EventCategory
1091  * Type of the event that happened.
1092  *
1093  * Result
1094  * ?
1095  *
1096  * Flags
1097  * ?
1098  *
1099  * TotalSize
1100  * Size of the event block including the device IDs and other
1101  * per category specific fields.
1102  */
1103 
1104 /*
1105  * NtGetPlugPlayEvent
1106  *
1107  * Returns one Plug & Play event from a global queue.
1108  *
1109  * Parameters
1110  * Reserved1
1111  * Reserved2
1112  * Always set to zero.
1113  *
1114  * Buffer
1115  * The buffer that will be filled with the event information on
1116  * successful return from the function.
1117  *
1118  * BufferSize
1119  * Size of the buffer pointed by the Buffer parameter. If the
1120  * buffer size is not large enough to hold the whole event
1121  * information, error STATUS_BUFFER_TOO_SMALL is returned and
1122  * the buffer remains untouched.
1123  *
1124  * Return Values
1125  * STATUS_PRIVILEGE_NOT_HELD
1126  * STATUS_BUFFER_TOO_SMALL
1127  * STATUS_SUCCESS
1128  *
1129  * Remarks
1130  * This function isn't multi-thread safe!
1131  *
1132  * @implemented
1133  */
1134 NTSTATUS
1135 NTAPI
1137  IN ULONG Reserved2,
1140 {
1142  NTSTATUS Status;
1143 
1144  DPRINT("NtGetPlugPlayEvent() called\n");
1145 
1146  /* Function can only be called from user-mode */
1147  if (KeGetPreviousMode() == KernelMode)
1148  {
1149  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1150  return STATUS_ACCESS_DENIED;
1151  }
1152 
1153  /* Check for Tcb privilege */
1155  UserMode))
1156  {
1157  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1159  }
1160 
1161  /* Wait for a PnP event */
1162  DPRINT("Waiting for pnp notification event\n");
1164  UserRequest,
1165  UserMode,
1166  FALSE,
1167  NULL);
1169  {
1170  DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1172  return Status;
1173  }
1174 
1175  /* Get entry from the tail of the queue */
1178  ListEntry);
1179 
1180  /* Check the buffer size */
1181  if (BufferSize < Entry->Event.TotalSize)
1182  {
1183  DPRINT1("Buffer is too small for the pnp-event\n");
1184  return STATUS_BUFFER_TOO_SMALL;
1185  }
1186 
1187  /* Copy event data to the user buffer */
1188  _SEH2_TRY
1189  {
1191  Entry->Event.TotalSize,
1192  sizeof(UCHAR));
1194  &Entry->Event,
1195  Entry->Event.TotalSize);
1196  }
1198  {
1200  }
1201  _SEH2_END;
1202 
1203  DPRINT("NtGetPlugPlayEvent() done\n");
1204 
1205  return STATUS_SUCCESS;
1206 }
1207 
1208 /*
1209  * NtPlugPlayControl
1210  *
1211  * A function for doing various Plug & Play operations from user mode.
1212  *
1213  * Parameters
1214  * PlugPlayControlClass
1215  * 0x00 Reenumerate device tree
1216  *
1217  * Buffer points to UNICODE_STRING decribing the instance
1218  * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
1219  * more information about instance paths see !devnode command
1220  * in kernel debugger or look at "Inside Windows 2000" book,
1221  * chapter "Driver Loading, Initialization, and Installation".
1222  *
1223  * 0x01 Register new device
1224  * 0x02 Deregister device
1225  * 0x03 Initialize device
1226  * 0x04 Start device
1227  * 0x06 Query and remove device
1228  * 0x07 User response
1229  *
1230  * Called after processing the message from NtGetPlugPlayEvent.
1231  *
1232  * 0x08 Generate legacy device
1233  * 0x09 Get interface device list
1234  * 0x0A Get property data
1235  * 0x0B Device class association (Registration)
1236  * 0x0C Get related device
1237  * 0x0D Get device interface alias
1238  * 0x0E Get/set/clear device status
1239  * 0x0F Get device depth
1240  * 0x10 Query device relations
1241  * 0x11 Query target device relation
1242  * 0x12 Query conflict list
1243  * 0x13 Retrieve dock data
1244  * 0x14 Reset device
1245  * 0x15 Halt device
1246  * 0x16 Get blocked driver data
1247  *
1248  * Buffer
1249  * The buffer contains information that is specific to each control
1250  * code. The buffer is read-only.
1251  *
1252  * BufferSize
1253  * Size of the buffer pointed by the Buffer parameter. If the
1254  * buffer size specifies incorrect value for specified control
1255  * code, error ??? is returned.
1256  *
1257  * Return Values
1258  * STATUS_PRIVILEGE_NOT_HELD
1259  * STATUS_SUCCESS
1260  * ...
1261  *
1262  * @unimplemented
1263  */
1264 NTSTATUS
1265 NTAPI
1267  IN OUT PVOID Buffer,
1269 {
1270  DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1271  PlugPlayControlClass, Buffer, BufferLength);
1272 
1273  /* Function can only be called from user-mode */
1274  if (KeGetPreviousMode() == KernelMode)
1275  {
1276  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1277  return STATUS_ACCESS_DENIED;
1278  }
1279 
1280  /* Check for Tcb privilege */
1282  UserMode))
1283  {
1284  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1286  }
1287 
1288  /* Probe the buffer */
1289  _SEH2_TRY
1290  {
1292  BufferLength,
1293  sizeof(ULONG));
1294  }
1296  {
1298  }
1299  _SEH2_END;
1300 
1301  switch (PlugPlayControlClass)
1302  {
1303 // case PlugPlayControlEnumerateDevice:
1304 // case PlugPlayControlRegisterNewDevice:
1305 // case PlugPlayControlDeregisterDevice:
1306 // case PlugPlayControlInitializeDevice:
1307 // case PlugPlayControlStartDevice:
1308 // case PlugPlayControlUnlockDevice:
1309 // case PlugPlayControlQueryAndRemoveDevice:
1310 
1312  if (Buffer || BufferLength != 0)
1313  return STATUS_INVALID_PARAMETER;
1314  return IopRemovePlugPlayEvent();
1315 
1316 // case PlugPlayControlGenerateLegacyDevice:
1317 
1320  return STATUS_INVALID_PARAMETER;
1322 
1325  return STATUS_INVALID_PARAMETER;
1327 
1328 // case PlugPlayControlDeviceClassAssociation:
1329 
1332  return STATUS_INVALID_PARAMETER;
1334 
1335 // case PlugPlayControlGetInterfaceDeviceAlias:
1336 
1339  return STATUS_INVALID_PARAMETER;
1341 
1344  return STATUS_INVALID_PARAMETER;
1346 
1349  return STATUS_INVALID_PARAMETER;
1351 
1352 // case PlugPlayControlTargetDeviceRelation:
1353 // case PlugPlayControlQueryConflictList:
1354 // case PlugPlayControlRetrieveDock:
1355 
1358  return STATUS_INVALID_PARAMETER;
1360 
1361 // case PlugPlayControlHaltDevice:
1362 // case PlugPlayControlGetBlockedDriverList:
1363 
1364  default:
1365  return STATUS_NOT_IMPLEMENTED;
1366  }
1367 
1368  return STATUS_NOT_IMPLEMENTED;
1369 }
NTSTATUS NTAPI IoSynchronousInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:5121
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1153
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:658
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define IN
Definition: typedefs.h:38
#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
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:839
PDEVICE_NODE IopRootDeviceNode
Definition: pnpmgr.c:18
#define DNF_PROCESSED
Definition: iotypes.h:167
#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
struct _Entry Entry
Definition: kefuncs.h:640
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
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:526
static NTSTATUS IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
Definition: plugplay.c:999
#define DNUF_NOT_DISABLEABLE
Definition: iotypes.h:204
#define PDCAP_D1_SUPPORTED
Definition: advprop.cpp:37
#define PNP_POWER_RELATIONS
Definition: cmtypes.h:68
#define DN_ROOT_ENUMERATED
Definition: cfg.h:118
Definition: plugplay.c:19
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2054
#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:1081
LONG NTSTATUS
Definition: precomp.h:26
#define DN_NEED_TO_ENUM
Definition: cfg.h:123
#define DN_DRIVER_LOADED
Definition: cfg.h:119
#define DN_DISABLEABLE
Definition: cfg.h:131
PLUGPLAY_EVENT_BLOCK Event
Definition: plugplay.c:22
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:524
#define PNP_SET_DEVICE_STATUS
Definition: cmtypes.h:60
#define PNP_GET_PARENT_DEVICE
Definition: cmtypes.h:52
DEVICE_CAPABILITIES
Definition: iotypes.h:927
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
#define PNP_BUS_RELATIONS
Definition: cmtypes.h:69
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:28
uint16_t * PWCHAR
Definition: typedefs.h:54
struct _PNP_EVENT_ENTRY PNP_EVENT_ENTRY
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:486
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:796
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:427
_In_ ULONG TotalLength
Definition: usbdlib.h:145
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:119
_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
enum _PLUGPLAY_CONTROL_CLASS PLUGPLAY_CONTROL_CLASS
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
NTSTATUS IopQueueTargetDeviceEvent(const GUID *Guid, PUNICODE_STRING DeviceIds)
Definition: plugplay.c:46
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
static NTSTATUS IopRemovePlugPlayEvent(VOID)
Definition: plugplay.c:99
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:294
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:398
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
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define UNICODE_NULL
#define DNUF_DONT_SHOW_IN_UI
Definition: iotypes.h:203
_In_ ULONG BufferLength
Definition: usbdlib.h:225
NTSTATUS IopRemoveDevice(IN PDEVICE_NODE DeviceNode)
NTSTATUS NTAPI NtGetPlugPlayEvent(IN ULONG Reserved1, IN ULONG Reserved2, OUT PPLUGPLAY_EVENT_BLOCK Buffer, IN ULONG BufferSize)
Definition: plugplay.c:1136
#define PDCAP_D2_SUPPORTED
Definition: advprop.cpp:38
ULONG PD_D2Latency
Definition: advprop.cpp:52
struct NameRec_ * Name
Definition: cdprocs.h:464
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
static GUID * Guid
Definition: apphelp.c:93
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:148
smooth NULL
Definition: ftsmooth.c:416
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define DeviceCapabilities
Definition: wingdi.h:4427
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4202
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
void DPRINT(...)
Definition: polytest.cpp:61
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:29
Definition: bcd.h:202
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
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
#define DNF_STARTED
Definition: iotypes.h:168
ULONG PD_D3Latency
Definition: advprop.cpp:53
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:468
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
__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
#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:706
#define DN_HAS_PROBLEM
Definition: cfg.h:128
#define BufferSize
Definition: classpnp.h:419
#define DN_NT_DRIVER
Definition: cfg.h:142
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define DN_NT_ENUMERATOR
Definition: cfg.h:141
Definition: Node.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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:169
#define DNF_LEGACY_DRIVER
Definition: iotypes.h:181
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5184
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DNF_DISABLED
Definition: iotypes.h:188
Definition: typedefs.h:117
#define PNP_GET_CHILD_DEVICE
Definition: cmtypes.h:53
static NTSTATUS IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
Definition: plugplay.c:953
#define CM_PROB_NEED_RESTART
Definition: cfg.h:44
UNICODE_STRING InstancePath
Definition: iotypes.h:842
Status
Definition: gdiplustypes.h:24
const LUID SeTcbPrivilege
Definition: priv.c:28
#define PDCAP_WAKE_FROM_D1_SUPPORTED
Definition: advprop.cpp:41
#define STATUS_USER_APC
Definition: ntstatus.h:78
_In_ DWORD Property
Definition: setupapi.h:1545
UnicodeString MaximumLength
Definition: rtlfuncs.h:2982
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR SIZE_T
Definition: typedefs.h:78
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:131
SYSTEM_POWER_STATE PD_DeepestSystemWake
Definition: advprop.cpp:55
_SEH2_END
Definition: create.c:4424
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
LIST_ENTRY ListEntry
Definition: plugplay.c:21
ULONG PD_D1Latency
Definition: advprop.cpp:51
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PDEVICE_LIST DeviceList
Definition: utils.c:27
_In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: iofuncs.h:1003
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:254
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define IRP_MN_QUERY_DEVICE_RELATIONS
struct _DEVICE_NODE * Sibling
Definition: iotypes.h:823
Definition: bcd.h:201
DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]
Definition: advprop.cpp:54
#define DPRINT1
Definition: precomp.h:8
#define PNP_EJECT_RELATIONS
Definition: cmtypes.h:66
#define DN_LEGACY_DRIVER
Definition: cfg.h:155
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
#define DN_STARTED
Definition: cfg.h:121
#define OUT
Definition: typedefs.h:39
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define PDCAP_WAKE_FROM_D0_SUPPORTED
Definition: advprop.cpp:40
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
#define DNF_ENUMERATED
Definition: iotypes.h:170
#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
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define _SEH2_LEAVE
Definition: filesup.c:20
#define PDCAP_WAKE_FROM_D2_SUPPORTED
Definition: advprop.cpp:42
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2725
NTSTATUS INIT_FUNCTION IopInitPlugPlayEvents(VOID)
Definition: plugplay.c:34
#define DNF_ADDED
Definition: iotypes.h:179
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
NTSTATUS IopActionInitChildServices(IN PDEVICE_NODE DeviceNode, IN PVOID Context)
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:216
NTSTATUS IopActionConfigureChildServices(IN PDEVICE_NODE DeviceNode, IN PVOID Context)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:495
#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
ULONG PD_Capabilities
Definition: advprop.cpp:50
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
#define PDCAP_D0_SUPPORTED
Definition: advprop.cpp:36
struct _PLUGPLAY_EVENT_BLOCK::@2269::@2272 TargetDevice
#define IRP_MN_QUERY_CAPABILITIES
Definition: dlist.c:348