ReactOS  0.4.14-dev-1332-g6db3d88
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 static PDEVICE_OBJECT
96 {
98  PDEVICE_NODE ChildNode;
99 
100  if (RtlEqualUnicodeString(&Node->InstancePath,
102  {
103  ObReferenceObject(Node->PhysicalDeviceObject);
104  return Node->PhysicalDeviceObject;
105  }
106 
107  /* Traversal of all children nodes */
108  for (ChildNode = Node->Child;
109  ChildNode != NULL;
110  ChildNode = ChildNode->Sibling)
111  {
113  if (DeviceObject != NULL)
114  {
115  return DeviceObject;
116  }
117  }
118 
119  return NULL;
120 }
121 
122 
125 {
126  if (IopRootDeviceNode == NULL)
127  return NULL;
128 
129  if (DeviceInstance == NULL ||
130  DeviceInstance->Length == 0)
131  {
133  {
136  }
137  else
138  return NULL;
139  }
140 
142 }
143 
144 static NTSTATUS
146 {
148  volatile UNICODE_STRING Name;
149 
150  Name.Buffer = NULL;
151  _SEH2_TRY
152  {
153  Name.Length = SrcName->Length;
154  Name.MaximumLength = SrcName->MaximumLength;
155  if (Name.Length > Name.MaximumLength)
156  {
158  _SEH2_LEAVE;
159  }
160 
161  if (Name.MaximumLength)
162  {
163  ProbeForRead(SrcName->Buffer,
164  Name.MaximumLength,
165  sizeof(WCHAR));
166  Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
167  if (Name.Buffer == NULL)
168  {
170  _SEH2_LEAVE;
171  }
172 
173  memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
174  }
175 
176  *DstName = Name;
177  }
179  {
180  if (Name.Buffer)
181  {
182  ExFreePool(Name.Buffer);
183  }
185  }
186  _SEH2_END;
187 
188  return Status;
189 }
190 
191 static NTSTATUS
193 {
197 
199  if (!NT_SUCCESS(Status))
200  {
201  return Status;
202  }
203 
204  DPRINT("IopPnpEnumerateDevice(%wZ)\n", &DeviceInstance);
205 
206  /* Get the device object */
208  if (DeviceInstance.Buffer != NULL)
209  {
211  }
212  if (DeviceObject == NULL)
213  {
214  return STATUS_NO_SUCH_DEVICE;
215  }
216 
218 
220 
221  return Status;
222 }
223 
224 
225 /*
226  * Remove the current PnP event from the tail of the event queue
227  * and signal IopPnpNotifyEvent if there is yet another event in the queue.
228  */
229 static
230 NTSTATUS
233 {
234  /* Remove a pnp event entry from the tail of the queue */
236  {
238  }
239 
240  /* Signal the next pnp event in the queue */
242  {
244  0,
245  FALSE);
246  }
247 
248  return STATUS_SUCCESS;
249 }
250 
251 
252 static NTSTATUS
254 {
259  GUID FilterGuid;
260  PZZWSTR SymbolicLinkList = NULL, LinkList;
262 
263  _SEH2_TRY
264  {
266 
267  ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
268  RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
269 
270  if (StackList.Buffer != NULL && StackList.BufferSize != 0)
271  {
272  ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
273  }
274  }
276  {
278  }
279  _SEH2_END;
280 
282  if (NT_SUCCESS(Status))
283  {
284  /* Get the device object */
286  if (DeviceInstance.Buffer != NULL)
287  {
289  }
290  }
291 
292  Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
294 
295  if (!NT_SUCCESS(Status))
296  {
297  /* failed */
298  return Status;
299  }
300 
301  LinkList = SymbolicLinkList;
302  while (*SymbolicLinkList != UNICODE_NULL)
303  {
304  SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
305  }
306  TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
307 
308  _SEH2_TRY
309  {
310  if (StackList.Buffer != NULL &&
311  StackList.BufferSize >= TotalLength)
312  {
313  // We've already probed the buffer for writing above.
314  RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
315  }
316 
317  DeviceList->BufferSize = TotalLength;
318  }
320  {
321  ExFreePool(LinkList);
323  }
324  _SEH2_END;
325 
326  ExFreePool(LinkList);
327  return STATUS_SUCCESS;
328 }
329 
330 static NTSTATUS
332 {
337  ULONG Property;
339  PVOID Buffer;
341 
342  DPRINT("IopGetDeviceProperty() called\n");
343  DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
344 
346  if (!NT_SUCCESS(Status))
347  {
348  return Status;
349  }
350 
351  _SEH2_TRY
352  {
353  Property = PropertyData->Property;
354  BufferSize = PropertyData->BufferSize;
355  ProbeForWrite(PropertyData->Buffer,
356  BufferSize,
357  sizeof(UCHAR));
358  }
360  {
361  if (DeviceInstance.Buffer != NULL)
362  {
364  }
366  }
367  _SEH2_END;
368 
369  /* Get the device object */
371  if (DeviceInstance.Buffer != NULL)
372  {
374  }
375  if (DeviceObject == NULL)
376  {
377  return STATUS_NO_SUCH_DEVICE;
378  }
379 
381  if (Buffer == NULL)
382  {
385  }
386 
387 
388  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
389 
391  {
392  if (BufferSize < sizeof(CM_POWER_DATA))
393  {
394  BufferSize = 0;
396  }
397  else
398  {
400  PCM_POWER_DATA PowerData;
401  IO_STACK_LOCATION Stack;
403 
404  PowerData = (PCM_POWER_DATA)Buffer;
405  RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
406  PowerData->PD_Size = sizeof(CM_POWER_DATA);
407 
410  DeviceCapabilities.Version = 1;
411  DeviceCapabilities.Address = -1;
412  DeviceCapabilities.UINumber = -1;
413 
414  Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
415 
417  &IoStatusBlock,
419  &Stack);
420  if (NT_SUCCESS(Status))
421  {
422  DPRINT("Got device capabiliities\n");
423 
424  PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
425  if (DeviceCapabilities.DeviceD1)
426  PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED;
427  if (DeviceCapabilities.DeviceD2)
428  PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED;
429  if (DeviceCapabilities.WakeFromD0)
431  if (DeviceCapabilities.WakeFromD1)
433  if (DeviceCapabilities.WakeFromD2)
435  if (DeviceCapabilities.WakeFromD3)
437  if (DeviceCapabilities.WarmEjectSupported)
439  PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
440  PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
441  PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
443  &DeviceCapabilities.DeviceState,
444  sizeof(DeviceCapabilities.DeviceState));
445  PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
446  }
447  else
448  {
449  DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
450 
453  }
454  }
455  }
457  {
458  }
460  {
461  if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
462  {
463  BufferSize = 0;
465  }
466  else
467  {
468  BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
470  &DeviceNode->HardwareRemovalPolicy,
471  BufferSize);
472  }
473  }
474  else
475  {
476  switch (Property)
477  {
480  break;
481 
484  break;
485 
488  break;
489 
492  break;
493 
496  break;
497 
500  break;
501 
504  break;
505 
508  break;
509 
512  break;
513 
514 #if (WINVER >= _WIN32_WINNT_WS03)
516  break;
517 #endif
518 
519 #if (WINVER >= _WIN32_WINNT_WIN7)
522  break;
523 #endif
524 
525  default:
526  BufferSize = 0;
528  break;
529  }
530 
531  if (Status == STATUS_SUCCESS)
532  {
535  BufferSize,
536  Buffer,
537  &BufferSize);
538  }
539  }
540 
542 
543  if (NT_SUCCESS(Status))
544  {
545  _SEH2_TRY
546  {
547  RtlCopyMemory(PropertyData->Buffer, Buffer, BufferSize);
548  PropertyData->BufferSize = BufferSize;
549  }
551  {
553  }
554  _SEH2_END;
555  }
556 
558  return Status;
559 }
560 
561 
562 static NTSTATUS
564 {
565  UNICODE_STRING RootDeviceName;
568  PDEVICE_NODE RelatedDeviceNode;
569  UNICODE_STRING TargetDeviceInstance;
571  ULONG Relation = 0;
572  ULONG MaximumLength = 0;
573 
574  DPRINT("IopGetRelatedDevice() called\n");
575  DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
576 
577  Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
578  if (!NT_SUCCESS(Status))
579  {
580  return Status;
581  }
582 
583  _SEH2_TRY
584  {
585  Relation = RelatedDeviceData->Relation;
586  MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
587  ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
589  sizeof(WCHAR));
590  }
592  {
593  if (TargetDeviceInstance.Buffer != NULL)
594  {
595  ExFreePool(TargetDeviceInstance.Buffer);
596  }
598  }
599  _SEH2_END;
600 
601  RtlInitUnicodeString(&RootDeviceName,
602  L"HTREE\\ROOT\\0");
603  if (RtlEqualUnicodeString(&TargetDeviceInstance,
604  &RootDeviceName,
605  TRUE))
606  {
608  if (TargetDeviceInstance.Buffer != NULL)
609  {
610  ExFreePool(TargetDeviceInstance.Buffer);
611  }
612  }
613  else
614  {
615  /* Get the device object */
616  DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
617  if (TargetDeviceInstance.Buffer != NULL)
618  {
619  ExFreePool(TargetDeviceInstance.Buffer);
620  }
621  if (DeviceObject == NULL)
622  return STATUS_NO_SUCH_DEVICE;
623 
624  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
625  }
626 
627  switch (Relation)
628  {
630  RelatedDeviceNode = DeviceNode->Parent;
631  break;
632 
634  RelatedDeviceNode = DeviceNode->Child;
635  break;
636 
638  RelatedDeviceNode = DeviceNode->Sibling;
639  break;
640 
641  default:
642  if (DeviceObject != NULL)
643  {
645  }
646 
648  }
649 
650  if (RelatedDeviceNode == NULL)
651  {
652  if (DeviceObject)
653  {
655  }
656 
657  return STATUS_NO_SUCH_DEVICE;
658  }
659 
660  if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
661  {
662  if (DeviceObject)
663  {
665  }
666 
668  }
669 
670  /* Copy related device instance name */
671  _SEH2_TRY
672  {
673  RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
674  RelatedDeviceNode->InstancePath.Buffer,
675  RelatedDeviceNode->InstancePath.Length);
676  RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
677  }
679  {
681  }
682  _SEH2_END;
683 
684  if (DeviceObject != NULL)
685  {
687  }
688 
689  DPRINT("IopGetRelatedDevice() done\n");
690 
691  return Status;
692 }
693 
694 static ULONG
696 {
697  ULONG Output = 0;
698 
699  if (DeviceNode->Parent == IopRootDeviceNode)
701 
702  if (DeviceNode->Flags & DNF_ADDED)
704 
705  /* FIXME: DN_ENUM_LOADED */
706 
707  if (DeviceNode->Flags & DNF_STARTED)
708  Output |= DN_STARTED;
709 
710  /* FIXME: Manual */
711 
712  if (!(DeviceNode->Flags & DNF_PROCESSED))
714 
715  /* DN_NOT_FIRST_TIME is 9x only */
716 
717  /* FIXME: DN_HARDWARE_ENUM */
718 
719  /* DN_LIAR and DN_HAS_MARK are 9x only */
720 
721  if (DeviceNode->Problem != 0)
723 
724  /* FIXME: DN_FILTERED */
725 
726  if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
728 
729  if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
731 
732  if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
734 
735  /* FIXME: Implement the rest */
736 
738 
739  return Output;
740 }
741 
742 static NTSTATUS
744 {
747  ULONG Operation = 0;
748  ULONG DeviceStatus = 0;
749  ULONG DeviceProblem = 0;
752 
753  DPRINT("IopDeviceStatus() called\n");
754 
756  if (!NT_SUCCESS(Status))
757  {
758  return Status;
759  }
760 
761  DPRINT("Device name: '%wZ'\n", &DeviceInstance);
762 
763  _SEH2_TRY
764  {
765  Operation = StatusData->Operation;
767  {
768  DeviceStatus = StatusData->DeviceStatus;
769  DeviceProblem = StatusData->DeviceProblem;
770  }
771  }
773  {
774  if (DeviceInstance.Buffer != NULL)
775  {
777  }
779  }
780  _SEH2_END;
781 
782  /* Get the device object */
784  if (DeviceInstance.Buffer != NULL)
785  {
787  }
788  if (DeviceObject == NULL)
789  {
790  return STATUS_NO_SUCH_DEVICE;
791  }
792 
794 
795  switch (Operation)
796  {
798  DPRINT("Get status data\n");
799  DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
800  DeviceProblem = DeviceNode->Problem;
801  break;
802 
804  DPRINT1("Set status data is NOT SUPPORTED\n");
805  break;
806 
808  DPRINT1("FIXME: Clear status data!\n");
809  break;
810  }
811 
813 
815  {
816  _SEH2_TRY
817  {
818  StatusData->DeviceStatus = DeviceStatus;
819  StatusData->DeviceProblem = DeviceProblem;
820  }
822  {
824  }
825  _SEH2_END;
826  }
827 
828  return Status;
829 }
830 
831 static
832 NTSTATUS
834 {
837  IO_STACK_LOCATION Stack;
839  PDEVICE_RELATIONS DeviceRelations = NULL;
840  PDEVICE_OBJECT ChildDeviceObject;
841  PDEVICE_NODE ChildDeviceNode;
842  ULONG i;
843  ULONG Relations;
845  ULONG BufferLeft;
846  PWCHAR Buffer, Ptr;
848 
849  DPRINT("IopGetDeviceRelations() called\n");
850  DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
851  DPRINT("Relations: %lu\n", RelationsData->Relations);
852  DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
853  DPRINT("Buffer: %p\n", RelationsData->Buffer);
854 
855  _SEH2_TRY
856  {
857  Relations = RelationsData->Relations;
858  BufferSize = RelationsData->BufferSize;
859  Buffer = RelationsData->Buffer;
860 
861  ProbeForWrite(Buffer, BufferSize, sizeof(CHAR));
862  }
864  {
866  }
867  _SEH2_END;
868 
870  if (!NT_SUCCESS(Status))
871  {
872  DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
873  return Status;
874  }
875 
876  /* Get the device object */
878  if (DeviceObject == NULL)
879  {
880  DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
882  goto done;
883  }
884 
885  switch (Relations)
886  {
887  case PNP_EJECT_RELATIONS:
888  Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
889  break;
890 
892  Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
893  break;
894 
895  case PNP_POWER_RELATIONS:
896  Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
897  break;
898 
899  case PNP_BUS_RELATIONS:
900  Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
901  break;
902 
903  default:
905  goto done;
906  }
907 
909  &IoStatusBlock,
911  &Stack);
912  if (!NT_SUCCESS(Status))
913  {
914  DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
915  goto done;
916  }
917 
918  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
919 
920  DPRINT("Found %d device relations\n", DeviceRelations->Count);
921 
922  _SEH2_TRY
923  {
924  RequiredSize = 0;
925  BufferLeft = BufferSize;
926  Ptr = Buffer;
927 
928  for (i = 0; i < DeviceRelations->Count; i++)
929  {
930  ChildDeviceObject = DeviceRelations->Objects[i];
931 
932  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
933  if (ChildDeviceNode)
934  {
935  DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
936  DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
937 
938  if (Ptr != NULL)
939  {
940  if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
941  {
943  break;
944  }
945 
947  ChildDeviceNode->InstancePath.Buffer,
948  ChildDeviceNode->InstancePath.Length);
949  Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
950  *Ptr = UNICODE_NULL;
951  Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
952 
953  BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
954  }
955 
956  RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
957  }
958  }
959 
960  if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
961  *Ptr = UNICODE_NULL;
962 
963  if (RequiredSize > 0)
964  RequiredSize += sizeof(WCHAR);
965 
966  DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
967 
968  RelationsData->BufferSize = RequiredSize;
969  }
971  {
973  }
974  _SEH2_END;
975 
976 done:
977  if (DeviceRelations != NULL)
978  ExFreePool(DeviceRelations);
979 
980  if (DeviceObject != NULL)
982 
983  if (DeviceInstance.Buffer != NULL)
985 
986  return Status;
987 }
988 
989 static NTSTATUS
991 {
996 
997  DPRINT("IopGetDeviceDepth() called\n");
998  DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
999 
1001  if (!NT_SUCCESS(Status))
1002  {
1003  return Status;
1004  }
1005 
1006  /* Get the device object */
1008  if (DeviceInstance.Buffer != NULL)
1009  {
1011  }
1012  if (DeviceObject == NULL)
1013  {
1014  return STATUS_NO_SUCH_DEVICE;
1015  }
1016 
1018 
1019  _SEH2_TRY
1020  {
1021  DepthData->Depth = DeviceNode->Level;
1022  }
1024  {
1026  }
1027  _SEH2_END;
1028 
1030 
1031  return Status;
1032 }
1033 
1034 
1035 static NTSTATUS
1037 {
1042 
1044  if (!NT_SUCCESS(Status))
1045  {
1046  return Status;
1047  }
1048 
1049  DPRINT("IopResetDevice(%wZ)\n", &DeviceInstance);
1050 
1051  /* Get the device object */
1053  if (DeviceInstance.Buffer != NULL)
1054  {
1056  }
1057  if (DeviceObject == NULL)
1058  {
1059  return STATUS_NO_SUCH_DEVICE;
1060  }
1061 
1062  /* Get the device node */
1064 
1065  ASSERT(DeviceNode->Flags & DNF_ENUMERATED);
1066  ASSERT(DeviceNode->Flags & DNF_PROCESSED);
1067 
1068  /* Check if there's already a driver loaded for this device */
1069  if (DeviceNode->Flags & DNF_ADDED)
1070  {
1071 #if 0
1072  /* Remove the device node */
1074  if (NT_SUCCESS(Status))
1075  {
1076  /* Invalidate device relations for the parent to reenumerate the device */
1077  DPRINT1("A new driver will be loaded for '%wZ' (FDO above removed)\n", &DeviceNode->InstancePath);
1078  Status = IoSynchronousInvalidateDeviceRelations(DeviceNode->Parent->PhysicalDeviceObject, BusRelations);
1079  }
1080  else
1081 #endif
1082  {
1083  /* A driver has already been loaded for this device */
1084  DPRINT("A reboot is required for the current driver for '%wZ' to be replaced\n", &DeviceNode->InstancePath);
1085  DeviceNode->Problem = CM_PROB_NEED_RESTART;
1086  }
1087  }
1088  else
1089  {
1090  /* FIXME: What if the device really is disabled? */
1091  DeviceNode->Flags &= ~DNF_DISABLED;
1092  DeviceNode->Problem = 0;
1093 
1094  /* Load service data from the registry */
1096 
1097  if (NT_SUCCESS(Status))
1098  {
1099  /* Start the service and begin PnP initialization of the device again */
1100  DPRINT("A new driver will be loaded for '%wZ' (no FDO above)\n", &DeviceNode->InstancePath);
1102  }
1103  }
1104 
1106 
1107  return Status;
1108 }
1109 
1110 /* PUBLIC FUNCTIONS **********************************************************/
1111 
1112 /*
1113  * Plug and Play event structure used by NtGetPlugPlayEvent.
1114  *
1115  * EventGuid
1116  * Can be one of the following values:
1117  * GUID_HWPROFILE_QUERY_CHANGE
1118  * GUID_HWPROFILE_CHANGE_CANCELLED
1119  * GUID_HWPROFILE_CHANGE_COMPLETE
1120  * GUID_TARGET_DEVICE_QUERY_REMOVE
1121  * GUID_TARGET_DEVICE_REMOVE_CANCELLED
1122  * GUID_TARGET_DEVICE_REMOVE_COMPLETE
1123  * GUID_PNP_CUSTOM_NOTIFICATION
1124  * GUID_PNP_POWER_NOTIFICATION
1125  * GUID_DEVICE_* (see above)
1126  *
1127  * EventCategory
1128  * Type of the event that happened.
1129  *
1130  * Result
1131  * ?
1132  *
1133  * Flags
1134  * ?
1135  *
1136  * TotalSize
1137  * Size of the event block including the device IDs and other
1138  * per category specific fields.
1139  */
1140 
1141 /*
1142  * NtGetPlugPlayEvent
1143  *
1144  * Returns one Plug & Play event from a global queue.
1145  *
1146  * Parameters
1147  * Reserved1
1148  * Reserved2
1149  * Always set to zero.
1150  *
1151  * Buffer
1152  * The buffer that will be filled with the event information on
1153  * successful return from the function.
1154  *
1155  * BufferSize
1156  * Size of the buffer pointed by the Buffer parameter. If the
1157  * buffer size is not large enough to hold the whole event
1158  * information, error STATUS_BUFFER_TOO_SMALL is returned and
1159  * the buffer remains untouched.
1160  *
1161  * Return Values
1162  * STATUS_PRIVILEGE_NOT_HELD
1163  * STATUS_BUFFER_TOO_SMALL
1164  * STATUS_SUCCESS
1165  *
1166  * Remarks
1167  * This function isn't multi-thread safe!
1168  *
1169  * @implemented
1170  */
1171 NTSTATUS
1172 NTAPI
1174  IN ULONG Reserved2,
1177 {
1179  NTSTATUS Status;
1180 
1181  DPRINT("NtGetPlugPlayEvent() called\n");
1182 
1183  /* Function can only be called from user-mode */
1184  if (KeGetPreviousMode() == KernelMode)
1185  {
1186  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1187  return STATUS_ACCESS_DENIED;
1188  }
1189 
1190  /* Check for Tcb privilege */
1192  UserMode))
1193  {
1194  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1196  }
1197 
1198  /* Wait for a PnP event */
1199  DPRINT("Waiting for pnp notification event\n");
1201  UserRequest,
1202  UserMode,
1203  FALSE,
1204  NULL);
1206  {
1207  DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1209  return Status;
1210  }
1211 
1212  /* Get entry from the tail of the queue */
1215  ListEntry);
1216 
1217  /* Check the buffer size */
1218  if (BufferSize < Entry->Event.TotalSize)
1219  {
1220  DPRINT1("Buffer is too small for the pnp-event\n");
1221  return STATUS_BUFFER_TOO_SMALL;
1222  }
1223 
1224  /* Copy event data to the user buffer */
1225  _SEH2_TRY
1226  {
1228  Entry->Event.TotalSize,
1229  sizeof(UCHAR));
1231  &Entry->Event,
1232  Entry->Event.TotalSize);
1233  }
1235  {
1237  }
1238  _SEH2_END;
1239 
1240  DPRINT("NtGetPlugPlayEvent() done\n");
1241 
1242  return STATUS_SUCCESS;
1243 }
1244 
1245 /*
1246  * NtPlugPlayControl
1247  *
1248  * A function for doing various Plug & Play operations from user mode.
1249  *
1250  * Parameters
1251  * PlugPlayControlClass
1252  * 0x00 Reenumerate device tree
1253  *
1254  * Buffer points to UNICODE_STRING decribing the instance
1255  * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
1256  * more information about instance paths see !devnode command
1257  * in kernel debugger or look at "Inside Windows 2000" book,
1258  * chapter "Driver Loading, Initialization, and Installation".
1259  *
1260  * 0x01 Register new device
1261  * 0x02 Deregister device
1262  * 0x03 Initialize device
1263  * 0x04 Start device
1264  * 0x06 Query and remove device
1265  * 0x07 User response
1266  *
1267  * Called after processing the message from NtGetPlugPlayEvent.
1268  *
1269  * 0x08 Generate legacy device
1270  * 0x09 Get interface device list
1271  * 0x0A Get property data
1272  * 0x0B Device class association (Registration)
1273  * 0x0C Get related device
1274  * 0x0D Get device interface alias
1275  * 0x0E Get/set/clear device status
1276  * 0x0F Get device depth
1277  * 0x10 Query device relations
1278  * 0x11 Query target device relation
1279  * 0x12 Query conflict list
1280  * 0x13 Retrieve dock data
1281  * 0x14 Reset device
1282  * 0x15 Halt device
1283  * 0x16 Get blocked driver data
1284  *
1285  * Buffer
1286  * The buffer contains information that is specific to each control
1287  * code. The buffer is read-only.
1288  *
1289  * BufferSize
1290  * Size of the buffer pointed by the Buffer parameter. If the
1291  * buffer size specifies incorrect value for specified control
1292  * code, error ??? is returned.
1293  *
1294  * Return Values
1295  * STATUS_PRIVILEGE_NOT_HELD
1296  * STATUS_SUCCESS
1297  * ...
1298  *
1299  * @unimplemented
1300  */
1301 NTSTATUS
1302 NTAPI
1304  IN OUT PVOID Buffer,
1306 {
1307  DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1308  PlugPlayControlClass, Buffer, BufferLength);
1309 
1310  /* Function can only be called from user-mode */
1311  if (KeGetPreviousMode() == KernelMode)
1312  {
1313  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1314  return STATUS_ACCESS_DENIED;
1315  }
1316 
1317  /* Check for Tcb privilege */
1319  UserMode))
1320  {
1321  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1323  }
1324 
1325  /* Probe the buffer */
1326  _SEH2_TRY
1327  {
1329  BufferLength,
1330  sizeof(ULONG));
1331  }
1333  {
1335  }
1336  _SEH2_END;
1337 
1338  switch (PlugPlayControlClass)
1339  {
1342  return STATUS_INVALID_PARAMETER;
1344 
1345 // case PlugPlayControlRegisterNewDevice:
1346 // case PlugPlayControlDeregisterDevice:
1347 // case PlugPlayControlInitializeDevice:
1348 // case PlugPlayControlStartDevice:
1349 // case PlugPlayControlUnlockDevice:
1350 // case PlugPlayControlQueryAndRemoveDevice:
1351 
1354  return STATUS_INVALID_PARAMETER;
1356 
1357 // case PlugPlayControlGenerateLegacyDevice:
1358 
1361  return STATUS_INVALID_PARAMETER;
1363 
1366  return STATUS_INVALID_PARAMETER;
1368 
1369 // case PlugPlayControlDeviceClassAssociation:
1370 
1373  return STATUS_INVALID_PARAMETER;
1375 
1376 // case PlugPlayControlGetInterfaceDeviceAlias:
1377 
1380  return STATUS_INVALID_PARAMETER;
1382 
1385  return STATUS_INVALID_PARAMETER;
1387 
1390  return STATUS_INVALID_PARAMETER;
1392 
1393 // case PlugPlayControlTargetDeviceRelation:
1394 // case PlugPlayControlQueryConflictList:
1395 // case PlugPlayControlRetrieveDock:
1396 
1399  return STATUS_INVALID_PARAMETER;
1401 
1402 // case PlugPlayControlHaltDevice:
1403 // case PlugPlayControlGetBlockedDriverList:
1404 
1405  default:
1406  return STATUS_NOT_IMPLEMENTED;
1407  }
1408 
1409  return STATUS_NOT_IMPLEMENTED;
1410 }
NTSTATUS NTAPI IoSynchronousInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:5201
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1154
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:695
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define IN
Definition: typedefs.h:39
#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:627
#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:563
static NTSTATUS IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
Definition: plugplay.c:1036
#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:121
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
#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_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:928
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:55
struct _PNP_EVENT_ENTRY PNP_EVENT_ENTRY
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:506
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:833
_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:95
_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:231
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:46
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:64
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:331
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:399
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:1173
#define PDCAP_D2_SUPPORTED
Definition: advprop.cpp:38
ULONG PD_D2Latency
Definition: advprop.cpp:52
static NTSTATUS IopPnpEnumerateDevice(PPLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA DeviceData)
Definition: plugplay.c:192
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:124
smooth NULL
Definition: ftsmooth.c:416
#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:4300
#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
NTSTATUS IopEnumerateDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pnpmgr.c:2740
ULONG PD_D3Latency
Definition: advprop.cpp:53
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:488
#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:743
#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:145
#define DNF_LEGACY_DRIVER
Definition: iotypes.h:181
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DNF_DISABLED
Definition: iotypes.h:188
Definition: typedefs.h:118
#define PNP_GET_CHILD_DEVICE
Definition: cmtypes.h:53
static NTSTATUS IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
Definition: plugplay.c:990
#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
#define _In_
Definition: no_sal2.h:204
_In_ DWORD Property
Definition: setupapi.h:1545
UnicodeString MaximumLength
Definition: rtlfuncs.h:2982
struct _PLUGPLAY_EVENT_BLOCK::@2302::@2305 TargetDevice
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR SIZE_T
Definition: typedefs.h:79
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:1303
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:40
#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:2772
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
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:253
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:515
#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
#define IRP_MN_QUERY_CAPABILITIES
Definition: dlist.c:348