ReactOS  0.4.14-dev-49-gfb4591c
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 {
221 
223  if (!NT_SUCCESS(Status))
224  {
225  return Status;
226  }
227 
228  DPRINT("IopPnpEnumerateDevice(%wZ)\n", &DeviceInstance);
229 
230  /* Get the device object */
232  if (DeviceInstance.Buffer != NULL)
233  {
235  }
236  if (DeviceObject == NULL)
237  {
238  return STATUS_NO_SUCH_DEVICE;
239  }
240 
242 
244 
245  return Status;
246 }
247 
248 static NTSTATUS
250 {
255  GUID FilterGuid;
256  PZZWSTR SymbolicLinkList = NULL, LinkList;
258 
259  _SEH2_TRY
260  {
262 
263  ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
264  RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
265 
266  if (StackList.Buffer != NULL && StackList.BufferSize != 0)
267  {
268  ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
269  }
270  }
272  {
274  }
275  _SEH2_END;
276 
278  if (NT_SUCCESS(Status))
279  {
280  /* Get the device object */
282  if (DeviceInstance.Buffer != NULL)
283  {
285  }
286  }
287 
288  Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
290 
291  if (!NT_SUCCESS(Status))
292  {
293  /* failed */
294  return Status;
295  }
296 
297  LinkList = SymbolicLinkList;
298  while (*SymbolicLinkList != UNICODE_NULL)
299  {
300  SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
301  }
302  TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
303 
304  _SEH2_TRY
305  {
306  if (StackList.Buffer != NULL &&
307  StackList.BufferSize >= TotalLength)
308  {
309  // We've already probed the buffer for writing above.
310  RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
311  }
312 
313  DeviceList->BufferSize = TotalLength;
314  }
316  {
317  ExFreePool(LinkList);
319  }
320  _SEH2_END;
321 
322  ExFreePool(LinkList);
323  return STATUS_SUCCESS;
324 }
325 
326 static NTSTATUS
328 {
333  ULONG Property;
335  PVOID Buffer;
337 
338  DPRINT("IopGetDeviceProperty() called\n");
339  DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
340 
342  if (!NT_SUCCESS(Status))
343  {
344  return Status;
345  }
346 
347  _SEH2_TRY
348  {
349  Property = PropertyData->Property;
350  BufferSize = PropertyData->BufferSize;
351  ProbeForWrite(PropertyData->Buffer,
352  BufferSize,
353  sizeof(UCHAR));
354  }
356  {
357  if (DeviceInstance.Buffer != NULL)
358  {
360  }
362  }
363  _SEH2_END;
364 
365  /* Get the device object */
367  if (DeviceInstance.Buffer != NULL)
368  {
370  }
371  if (DeviceObject == NULL)
372  {
373  return STATUS_NO_SUCH_DEVICE;
374  }
375 
377  if (Buffer == NULL)
378  {
381  }
382 
383 
384  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
385 
387  {
388  if (BufferSize < sizeof(CM_POWER_DATA))
389  {
390  BufferSize = 0;
392  }
393  else
394  {
396  PCM_POWER_DATA PowerData;
397  IO_STACK_LOCATION Stack;
399 
400  PowerData = (PCM_POWER_DATA)Buffer;
401  RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
402  PowerData->PD_Size = sizeof(CM_POWER_DATA);
403 
406  DeviceCapabilities.Version = 1;
407  DeviceCapabilities.Address = -1;
408  DeviceCapabilities.UINumber = -1;
409 
410  Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
411 
413  &IoStatusBlock,
415  &Stack);
416  if (NT_SUCCESS(Status))
417  {
418  DPRINT("Got device capabiliities\n");
419 
420  PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
421  if (DeviceCapabilities.DeviceD1)
422  PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED;
423  if (DeviceCapabilities.DeviceD2)
424  PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED;
425  if (DeviceCapabilities.WakeFromD0)
427  if (DeviceCapabilities.WakeFromD1)
429  if (DeviceCapabilities.WakeFromD2)
431  if (DeviceCapabilities.WakeFromD3)
433  if (DeviceCapabilities.WarmEjectSupported)
435  PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
436  PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
437  PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
439  &DeviceCapabilities.DeviceState,
440  sizeof(DeviceCapabilities.DeviceState));
441  PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
442  }
443  else
444  {
445  DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
446 
449  }
450  }
451  }
453  {
454  }
456  {
457  if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
458  {
459  BufferSize = 0;
461  }
462  else
463  {
464  BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
466  &DeviceNode->HardwareRemovalPolicy,
467  BufferSize);
468  }
469  }
470  else
471  {
472  switch (Property)
473  {
476  break;
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 
510 #if (WINVER >= _WIN32_WINNT_WS03)
512  break;
513 #endif
514 
515 #if (WINVER >= _WIN32_WINNT_WIN7)
518  break;
519 #endif
520 
521  default:
522  BufferSize = 0;
524  break;
525  }
526 
527  if (Status == STATUS_SUCCESS)
528  {
531  BufferSize,
532  Buffer,
533  &BufferSize);
534  }
535  }
536 
538 
539  if (NT_SUCCESS(Status))
540  {
541  _SEH2_TRY
542  {
543  RtlCopyMemory(PropertyData->Buffer, Buffer, BufferSize);
544  PropertyData->BufferSize = BufferSize;
545  }
547  {
549  }
550  _SEH2_END;
551  }
552 
554  return Status;
555 }
556 
557 
558 static NTSTATUS
560 {
561  UNICODE_STRING RootDeviceName;
564  PDEVICE_NODE RelatedDeviceNode;
565  UNICODE_STRING TargetDeviceInstance;
567  ULONG Relation = 0;
568  ULONG MaximumLength = 0;
569 
570  DPRINT("IopGetRelatedDevice() called\n");
571  DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
572 
573  Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
574  if (!NT_SUCCESS(Status))
575  {
576  return Status;
577  }
578 
579  _SEH2_TRY
580  {
581  Relation = RelatedDeviceData->Relation;
582  MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
583  ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
585  sizeof(WCHAR));
586  }
588  {
589  if (TargetDeviceInstance.Buffer != NULL)
590  {
591  ExFreePool(TargetDeviceInstance.Buffer);
592  }
594  }
595  _SEH2_END;
596 
597  RtlInitUnicodeString(&RootDeviceName,
598  L"HTREE\\ROOT\\0");
599  if (RtlEqualUnicodeString(&TargetDeviceInstance,
600  &RootDeviceName,
601  TRUE))
602  {
604  if (TargetDeviceInstance.Buffer != NULL)
605  {
606  ExFreePool(TargetDeviceInstance.Buffer);
607  }
608  }
609  else
610  {
611  /* Get the device object */
612  DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
613  if (TargetDeviceInstance.Buffer != NULL)
614  {
615  ExFreePool(TargetDeviceInstance.Buffer);
616  }
617  if (DeviceObject == NULL)
618  return STATUS_NO_SUCH_DEVICE;
619 
620  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
621  }
622 
623  switch (Relation)
624  {
626  RelatedDeviceNode = DeviceNode->Parent;
627  break;
628 
630  RelatedDeviceNode = DeviceNode->Child;
631  break;
632 
634  RelatedDeviceNode = DeviceNode->Sibling;
635  break;
636 
637  default:
638  if (DeviceObject != NULL)
639  {
641  }
642 
644  }
645 
646  if (RelatedDeviceNode == NULL)
647  {
648  if (DeviceObject)
649  {
651  }
652 
653  return STATUS_NO_SUCH_DEVICE;
654  }
655 
656  if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
657  {
658  if (DeviceObject)
659  {
661  }
662 
664  }
665 
666  /* Copy related device instance name */
667  _SEH2_TRY
668  {
669  RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
670  RelatedDeviceNode->InstancePath.Buffer,
671  RelatedDeviceNode->InstancePath.Length);
672  RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
673  }
675  {
677  }
678  _SEH2_END;
679 
680  if (DeviceObject != NULL)
681  {
683  }
684 
685  DPRINT("IopGetRelatedDevice() done\n");
686 
687  return Status;
688 }
689 
690 static ULONG
692 {
693  ULONG Output = 0;
694 
695  if (DeviceNode->Parent == IopRootDeviceNode)
697 
698  if (DeviceNode->Flags & DNF_ADDED)
700 
701  /* FIXME: DN_ENUM_LOADED */
702 
703  if (DeviceNode->Flags & DNF_STARTED)
704  Output |= DN_STARTED;
705 
706  /* FIXME: Manual */
707 
708  if (!(DeviceNode->Flags & DNF_PROCESSED))
710 
711  /* DN_NOT_FIRST_TIME is 9x only */
712 
713  /* FIXME: DN_HARDWARE_ENUM */
714 
715  /* DN_LIAR and DN_HAS_MARK are 9x only */
716 
717  if (DeviceNode->Problem != 0)
719 
720  /* FIXME: DN_FILTERED */
721 
722  if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
724 
725  if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
727 
728  if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
730 
731  /* FIXME: Implement the rest */
732 
734 
735  return Output;
736 }
737 
738 static NTSTATUS
740 {
743  ULONG Operation = 0;
744  ULONG DeviceStatus = 0;
745  ULONG DeviceProblem = 0;
748 
749  DPRINT("IopDeviceStatus() called\n");
750 
752  if (!NT_SUCCESS(Status))
753  {
754  return Status;
755  }
756 
757  DPRINT("Device name: '%wZ'\n", &DeviceInstance);
758 
759  _SEH2_TRY
760  {
761  Operation = StatusData->Operation;
763  {
764  DeviceStatus = StatusData->DeviceStatus;
765  DeviceProblem = StatusData->DeviceProblem;
766  }
767  }
769  {
770  if (DeviceInstance.Buffer != NULL)
771  {
773  }
775  }
776  _SEH2_END;
777 
778  /* Get the device object */
780  if (DeviceInstance.Buffer != NULL)
781  {
783  }
784  if (DeviceObject == NULL)
785  {
786  return STATUS_NO_SUCH_DEVICE;
787  }
788 
790 
791  switch (Operation)
792  {
794  DPRINT("Get status data\n");
795  DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
796  DeviceProblem = DeviceNode->Problem;
797  break;
798 
800  DPRINT1("Set status data is NOT SUPPORTED\n");
801  break;
802 
804  DPRINT1("FIXME: Clear status data!\n");
805  break;
806  }
807 
809 
811  {
812  _SEH2_TRY
813  {
814  StatusData->DeviceStatus = DeviceStatus;
815  StatusData->DeviceProblem = DeviceProblem;
816  }
818  {
820  }
821  _SEH2_END;
822  }
823 
824  return Status;
825 }
826 
827 static
828 NTSTATUS
830 {
833  IO_STACK_LOCATION Stack;
835  PDEVICE_RELATIONS DeviceRelations = NULL;
836  PDEVICE_OBJECT ChildDeviceObject;
837  PDEVICE_NODE ChildDeviceNode;
838  ULONG i;
839  ULONG Relations;
841  ULONG BufferLeft;
842  PWCHAR Buffer, Ptr;
844 
845  DPRINT("IopGetDeviceRelations() called\n");
846  DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
847  DPRINT("Relations: %lu\n", RelationsData->Relations);
848  DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
849  DPRINT("Buffer: %p\n", RelationsData->Buffer);
850 
851  _SEH2_TRY
852  {
853  Relations = RelationsData->Relations;
854  BufferSize = RelationsData->BufferSize;
855  Buffer = RelationsData->Buffer;
856 
857  ProbeForWrite(Buffer, BufferSize, sizeof(CHAR));
858  }
860  {
862  }
863  _SEH2_END;
864 
866  if (!NT_SUCCESS(Status))
867  {
868  DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
869  return Status;
870  }
871 
872  /* Get the device object */
874  if (DeviceObject == NULL)
875  {
876  DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
878  goto done;
879  }
880 
881  switch (Relations)
882  {
883  case PNP_EJECT_RELATIONS:
884  Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
885  break;
886 
888  Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
889  break;
890 
891  case PNP_POWER_RELATIONS:
892  Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
893  break;
894 
895  case PNP_BUS_RELATIONS:
896  Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
897  break;
898 
899  default:
901  goto done;
902  }
903 
905  &IoStatusBlock,
907  &Stack);
908  if (!NT_SUCCESS(Status))
909  {
910  DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
911  goto done;
912  }
913 
914  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
915 
916  DPRINT("Found %d device relations\n", DeviceRelations->Count);
917 
918  _SEH2_TRY
919  {
920  RequiredSize = 0;
921  BufferLeft = BufferSize;
922  Ptr = Buffer;
923 
924  for (i = 0; i < DeviceRelations->Count; i++)
925  {
926  ChildDeviceObject = DeviceRelations->Objects[i];
927 
928  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
929  if (ChildDeviceNode)
930  {
931  DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
932  DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
933 
934  if (Ptr != NULL)
935  {
936  if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
937  {
939  break;
940  }
941 
943  ChildDeviceNode->InstancePath.Buffer,
944  ChildDeviceNode->InstancePath.Length);
945  Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
946  *Ptr = UNICODE_NULL;
947  Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
948 
949  BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
950  }
951 
952  RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
953  }
954  }
955 
956  if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
957  *Ptr = UNICODE_NULL;
958 
959  if (RequiredSize > 0)
960  RequiredSize += sizeof(WCHAR);
961 
962  DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
963 
964  RelationsData->BufferSize = RequiredSize;
965  }
967  {
969  }
970  _SEH2_END;
971 
972 done:
973  if (DeviceRelations != NULL)
974  ExFreePool(DeviceRelations);
975 
976  if (DeviceObject != NULL)
978 
979  if (DeviceInstance.Buffer != NULL)
981 
982  return Status;
983 }
984 
985 static NTSTATUS
987 {
992 
993  DPRINT("IopGetDeviceDepth() called\n");
994  DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
995 
997  if (!NT_SUCCESS(Status))
998  {
999  return Status;
1000  }
1001 
1002  /* Get the device object */
1004  if (DeviceInstance.Buffer != NULL)
1005  {
1007  }
1008  if (DeviceObject == NULL)
1009  {
1010  return STATUS_NO_SUCH_DEVICE;
1011  }
1012 
1014 
1015  _SEH2_TRY
1016  {
1017  DepthData->Depth = DeviceNode->Level;
1018  }
1020  {
1022  }
1023  _SEH2_END;
1024 
1026 
1027  return Status;
1028 }
1029 
1030 
1031 static NTSTATUS
1033 {
1038 
1040  if (!NT_SUCCESS(Status))
1041  {
1042  return Status;
1043  }
1044 
1045  DPRINT("IopResetDevice(%wZ)\n", &DeviceInstance);
1046 
1047  /* Get the device object */
1049  if (DeviceInstance.Buffer != NULL)
1050  {
1052  }
1053  if (DeviceObject == NULL)
1054  {
1055  return STATUS_NO_SUCH_DEVICE;
1056  }
1057 
1058  /* Get the device node */
1060 
1061  ASSERT(DeviceNode->Flags & DNF_ENUMERATED);
1062  ASSERT(DeviceNode->Flags & DNF_PROCESSED);
1063 
1064  /* Check if there's already a driver loaded for this device */
1065  if (DeviceNode->Flags & DNF_ADDED)
1066  {
1067 #if 0
1068  /* Remove the device node */
1070  if (NT_SUCCESS(Status))
1071  {
1072  /* Invalidate device relations for the parent to reenumerate the device */
1073  DPRINT1("A new driver will be loaded for '%wZ' (FDO above removed)\n", &DeviceNode->InstancePath);
1074  Status = IoSynchronousInvalidateDeviceRelations(DeviceNode->Parent->PhysicalDeviceObject, BusRelations);
1075  }
1076  else
1077 #endif
1078  {
1079  /* A driver has already been loaded for this device */
1080  DPRINT("A reboot is required for the current driver for '%wZ' to be replaced\n", &DeviceNode->InstancePath);
1081  DeviceNode->Problem = CM_PROB_NEED_RESTART;
1082  }
1083  }
1084  else
1085  {
1086  /* FIXME: What if the device really is disabled? */
1087  DeviceNode->Flags &= ~DNF_DISABLED;
1088  DeviceNode->Problem = 0;
1089 
1090  /* Load service data from the registry */
1092 
1093  if (NT_SUCCESS(Status))
1094  {
1095  /* Start the service and begin PnP initialization of the device again */
1096  DPRINT("A new driver will be loaded for '%wZ' (no FDO above)\n", &DeviceNode->InstancePath);
1098  }
1099  }
1100 
1102 
1103  return Status;
1104 }
1105 
1106 /* PUBLIC FUNCTIONS **********************************************************/
1107 
1108 /*
1109  * Plug and Play event structure used by NtGetPlugPlayEvent.
1110  *
1111  * EventGuid
1112  * Can be one of the following values:
1113  * GUID_HWPROFILE_QUERY_CHANGE
1114  * GUID_HWPROFILE_CHANGE_CANCELLED
1115  * GUID_HWPROFILE_CHANGE_COMPLETE
1116  * GUID_TARGET_DEVICE_QUERY_REMOVE
1117  * GUID_TARGET_DEVICE_REMOVE_CANCELLED
1118  * GUID_TARGET_DEVICE_REMOVE_COMPLETE
1119  * GUID_PNP_CUSTOM_NOTIFICATION
1120  * GUID_PNP_POWER_NOTIFICATION
1121  * GUID_DEVICE_* (see above)
1122  *
1123  * EventCategory
1124  * Type of the event that happened.
1125  *
1126  * Result
1127  * ?
1128  *
1129  * Flags
1130  * ?
1131  *
1132  * TotalSize
1133  * Size of the event block including the device IDs and other
1134  * per category specific fields.
1135  */
1136 
1137 /*
1138  * NtGetPlugPlayEvent
1139  *
1140  * Returns one Plug & Play event from a global queue.
1141  *
1142  * Parameters
1143  * Reserved1
1144  * Reserved2
1145  * Always set to zero.
1146  *
1147  * Buffer
1148  * The buffer that will be filled with the event information on
1149  * successful return from the function.
1150  *
1151  * BufferSize
1152  * Size of the buffer pointed by the Buffer parameter. If the
1153  * buffer size is not large enough to hold the whole event
1154  * information, error STATUS_BUFFER_TOO_SMALL is returned and
1155  * the buffer remains untouched.
1156  *
1157  * Return Values
1158  * STATUS_PRIVILEGE_NOT_HELD
1159  * STATUS_BUFFER_TOO_SMALL
1160  * STATUS_SUCCESS
1161  *
1162  * Remarks
1163  * This function isn't multi-thread safe!
1164  *
1165  * @implemented
1166  */
1167 NTSTATUS
1168 NTAPI
1170  IN ULONG Reserved2,
1173 {
1175  NTSTATUS Status;
1176 
1177  DPRINT("NtGetPlugPlayEvent() called\n");
1178 
1179  /* Function can only be called from user-mode */
1180  if (KeGetPreviousMode() == KernelMode)
1181  {
1182  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1183  return STATUS_ACCESS_DENIED;
1184  }
1185 
1186  /* Check for Tcb privilege */
1188  UserMode))
1189  {
1190  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1192  }
1193 
1194  /* Wait for a PnP event */
1195  DPRINT("Waiting for pnp notification event\n");
1197  UserRequest,
1198  UserMode,
1199  FALSE,
1200  NULL);
1202  {
1203  DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1205  return Status;
1206  }
1207 
1208  /* Get entry from the tail of the queue */
1211  ListEntry);
1212 
1213  /* Check the buffer size */
1214  if (BufferSize < Entry->Event.TotalSize)
1215  {
1216  DPRINT1("Buffer is too small for the pnp-event\n");
1217  return STATUS_BUFFER_TOO_SMALL;
1218  }
1219 
1220  /* Copy event data to the user buffer */
1221  _SEH2_TRY
1222  {
1224  Entry->Event.TotalSize,
1225  sizeof(UCHAR));
1227  &Entry->Event,
1228  Entry->Event.TotalSize);
1229  }
1231  {
1233  }
1234  _SEH2_END;
1235 
1236  DPRINT("NtGetPlugPlayEvent() done\n");
1237 
1238  return STATUS_SUCCESS;
1239 }
1240 
1241 /*
1242  * NtPlugPlayControl
1243  *
1244  * A function for doing various Plug & Play operations from user mode.
1245  *
1246  * Parameters
1247  * PlugPlayControlClass
1248  * 0x00 Reenumerate device tree
1249  *
1250  * Buffer points to UNICODE_STRING decribing the instance
1251  * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
1252  * more information about instance paths see !devnode command
1253  * in kernel debugger or look at "Inside Windows 2000" book,
1254  * chapter "Driver Loading, Initialization, and Installation".
1255  *
1256  * 0x01 Register new device
1257  * 0x02 Deregister device
1258  * 0x03 Initialize device
1259  * 0x04 Start device
1260  * 0x06 Query and remove device
1261  * 0x07 User response
1262  *
1263  * Called after processing the message from NtGetPlugPlayEvent.
1264  *
1265  * 0x08 Generate legacy device
1266  * 0x09 Get interface device list
1267  * 0x0A Get property data
1268  * 0x0B Device class association (Registration)
1269  * 0x0C Get related device
1270  * 0x0D Get device interface alias
1271  * 0x0E Get/set/clear device status
1272  * 0x0F Get device depth
1273  * 0x10 Query device relations
1274  * 0x11 Query target device relation
1275  * 0x12 Query conflict list
1276  * 0x13 Retrieve dock data
1277  * 0x14 Reset device
1278  * 0x15 Halt device
1279  * 0x16 Get blocked driver data
1280  *
1281  * Buffer
1282  * The buffer contains information that is specific to each control
1283  * code. The buffer is read-only.
1284  *
1285  * BufferSize
1286  * Size of the buffer pointed by the Buffer parameter. If the
1287  * buffer size specifies incorrect value for specified control
1288  * code, error ??? is returned.
1289  *
1290  * Return Values
1291  * STATUS_PRIVILEGE_NOT_HELD
1292  * STATUS_SUCCESS
1293  * ...
1294  *
1295  * @unimplemented
1296  */
1297 NTSTATUS
1298 NTAPI
1300  IN OUT PVOID Buffer,
1302 {
1303  DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1304  PlugPlayControlClass, Buffer, BufferLength);
1305 
1306  /* Function can only be called from user-mode */
1307  if (KeGetPreviousMode() == KernelMode)
1308  {
1309  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1310  return STATUS_ACCESS_DENIED;
1311  }
1312 
1313  /* Check for Tcb privilege */
1315  UserMode))
1316  {
1317  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1319  }
1320 
1321  /* Probe the buffer */
1322  _SEH2_TRY
1323  {
1325  BufferLength,
1326  sizeof(ULONG));
1327  }
1329  {
1331  }
1332  _SEH2_END;
1333 
1334  switch (PlugPlayControlClass)
1335  {
1338  return STATUS_INVALID_PARAMETER;
1340 
1341 // case PlugPlayControlRegisterNewDevice:
1342 // case PlugPlayControlDeregisterDevice:
1343 // case PlugPlayControlInitializeDevice:
1344 // case PlugPlayControlStartDevice:
1345 // case PlugPlayControlUnlockDevice:
1346 // case PlugPlayControlQueryAndRemoveDevice:
1347 
1350  return STATUS_INVALID_PARAMETER;
1351  return IopRemovePlugPlayEvent();
1352 
1353 // case PlugPlayControlGenerateLegacyDevice:
1354 
1357  return STATUS_INVALID_PARAMETER;
1359 
1362  return STATUS_INVALID_PARAMETER;
1364 
1365 // case PlugPlayControlDeviceClassAssociation:
1366 
1369  return STATUS_INVALID_PARAMETER;
1371 
1372 // case PlugPlayControlGetInterfaceDeviceAlias:
1373 
1376  return STATUS_INVALID_PARAMETER;
1378 
1381  return STATUS_INVALID_PARAMETER;
1383 
1386  return STATUS_INVALID_PARAMETER;
1388 
1389 // case PlugPlayControlTargetDeviceRelation:
1390 // case PlugPlayControlQueryConflictList:
1391 // case PlugPlayControlRetrieveDock:
1392 
1395  return STATUS_INVALID_PARAMETER;
1397 
1398 // case PlugPlayControlHaltDevice:
1399 // case PlugPlayControlGetBlockedDriverList:
1400 
1401  default:
1402  return STATUS_NOT_IMPLEMENTED;
1403  }
1404 
1405  return STATUS_NOT_IMPLEMENTED;
1406 }
NTSTATUS NTAPI IoSynchronousInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:5147
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1154
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:691
#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:559
static NTSTATUS IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
Definition: plugplay.c:1032
#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: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:54
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:829
_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:327
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:1169
#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:216
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:4444
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4228
#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
struct _PLUGPLAY_EVENT_BLOCK::@2278::@2281 TargetDevice
_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:2670
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:739
#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:5202
#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:986
#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:1299
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:2772
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966
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:249
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