ReactOS  0.4.15-dev-448-gd6c4411
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  RtlZeroMemory(EventEntry, TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
68 
69  /* Fill the buffer with the event GUID */
70  RtlCopyMemory(&EventEntry->Event.EventGuid,
71  Guid,
72  sizeof(GUID));
74  EventEntry->Event.TotalSize = TotalSize;
75 
76  /* Fill the device id */
77  Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
79  if (!NT_SUCCESS(Status))
80  {
81  ExFreePool(EventEntry);
82  return Status;
83  }
84 
86  &EventEntry->ListEntry);
88  0,
89  FALSE);
90 
91  return STATUS_SUCCESS;
92 }
93 
94 
95 static PDEVICE_OBJECT
97 {
99  PDEVICE_NODE ChildNode;
100 
101  if (RtlEqualUnicodeString(&Node->InstancePath,
103  {
104  ObReferenceObject(Node->PhysicalDeviceObject);
105  return Node->PhysicalDeviceObject;
106  }
107 
108  /* Traversal of all children nodes */
109  for (ChildNode = Node->Child;
110  ChildNode != NULL;
111  ChildNode = ChildNode->Sibling)
112  {
114  if (DeviceObject != NULL)
115  {
116  return DeviceObject;
117  }
118  }
119 
120  return NULL;
121 }
122 
123 
126 {
127  if (IopRootDeviceNode == NULL)
128  return NULL;
129 
130  if (DeviceInstance == NULL ||
131  DeviceInstance->Length == 0)
132  {
134  {
137  }
138  else
139  return NULL;
140  }
141 
143 }
144 
145 static NTSTATUS
147 {
149  volatile UNICODE_STRING Name;
150 
151  Name.Buffer = NULL;
152  _SEH2_TRY
153  {
154  Name.Length = SrcName->Length;
155  Name.MaximumLength = SrcName->MaximumLength;
156  if (Name.Length > Name.MaximumLength)
157  {
159  _SEH2_LEAVE;
160  }
161 
162  if (Name.MaximumLength)
163  {
164  ProbeForRead(SrcName->Buffer,
165  Name.MaximumLength,
166  sizeof(WCHAR));
167  Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
168  if (Name.Buffer == NULL)
169  {
171  _SEH2_LEAVE;
172  }
173 
174  memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
175  }
176 
177  *DstName = Name;
178  }
180  {
181  if (Name.Buffer)
182  {
183  ExFreePool(Name.Buffer);
184  }
186  }
187  _SEH2_END;
188 
189  return Status;
190 }
191 
192 static NTSTATUS
194 {
198 
200  if (!NT_SUCCESS(Status))
201  {
202  return Status;
203  }
204 
205  DPRINT("IopPnpEnumerateDevice(%wZ)\n", &DeviceInstance);
206 
207  /* Get the device object */
209  if (DeviceInstance.Buffer != NULL)
210  {
212  }
213  if (DeviceObject == NULL)
214  {
215  return STATUS_NO_SUCH_DEVICE;
216  }
217 
219 
221 
222  return Status;
223 }
224 
225 
226 /*
227  * Remove the current PnP event from the tail of the event queue
228  * and signal IopPnpNotifyEvent if there is yet another event in the queue.
229  */
230 static
231 NTSTATUS
234 {
235  /* Remove a pnp event entry from the tail of the queue */
237  {
239  }
240 
241  /* Signal the next pnp event in the queue */
243  {
245  0,
246  FALSE);
247  }
248 
249  return STATUS_SUCCESS;
250 }
251 
252 
253 static NTSTATUS
255 {
260  GUID FilterGuid;
261  PZZWSTR SymbolicLinkList = NULL, LinkList;
263 
264  _SEH2_TRY
265  {
267 
268  ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
269  RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
270 
271  if (StackList.Buffer != NULL && StackList.BufferSize != 0)
272  {
273  ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
274  }
275  }
277  {
279  }
280  _SEH2_END;
281 
283  if (NT_SUCCESS(Status))
284  {
285  /* Get the device object */
287  if (DeviceInstance.Buffer != NULL)
288  {
290  }
291  }
292 
293  Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
295 
296  if (!NT_SUCCESS(Status))
297  {
298  /* failed */
299  return Status;
300  }
301 
302  LinkList = SymbolicLinkList;
303  while (*SymbolicLinkList != UNICODE_NULL)
304  {
305  SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
306  }
307  TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
308 
309  _SEH2_TRY
310  {
311  if (StackList.Buffer != NULL &&
312  StackList.BufferSize >= TotalLength)
313  {
314  // We've already probed the buffer for writing above.
315  RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
316  }
317 
318  DeviceList->BufferSize = TotalLength;
319  }
321  {
322  ExFreePool(LinkList);
324  }
325  _SEH2_END;
326 
327  ExFreePool(LinkList);
328  return STATUS_SUCCESS;
329 }
330 
331 static NTSTATUS
333 {
338  ULONG Property;
340  PVOID Buffer;
342 
343  DPRINT("IopGetDeviceProperty() called\n");
344  DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
345 
347  if (!NT_SUCCESS(Status))
348  {
349  return Status;
350  }
351 
352  _SEH2_TRY
353  {
354  Property = PropertyData->Property;
355  BufferSize = PropertyData->BufferSize;
356  ProbeForWrite(PropertyData->Buffer,
357  BufferSize,
358  sizeof(UCHAR));
359  }
361  {
362  if (DeviceInstance.Buffer != NULL)
363  {
365  }
367  }
368  _SEH2_END;
369 
370  /* Get the device object */
372  if (DeviceInstance.Buffer != NULL)
373  {
375  }
376  if (DeviceObject == NULL)
377  {
378  return STATUS_NO_SUCH_DEVICE;
379  }
380 
382  if (Buffer == NULL)
383  {
386  }
387 
388 
389  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
390 
392  {
393  if (BufferSize < sizeof(CM_POWER_DATA))
394  {
395  BufferSize = 0;
397  }
398  else
399  {
401  PCM_POWER_DATA PowerData;
402  IO_STACK_LOCATION Stack;
404 
405  PowerData = (PCM_POWER_DATA)Buffer;
406  RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
407  PowerData->PD_Size = sizeof(CM_POWER_DATA);
408 
411  DeviceCapabilities.Version = 1;
412  DeviceCapabilities.Address = -1;
413  DeviceCapabilities.UINumber = -1;
414 
415  Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
416 
418  &IoStatusBlock,
420  &Stack);
421  if (NT_SUCCESS(Status))
422  {
423  DPRINT("Got device capabiliities\n");
424 
425  PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
426  if (DeviceCapabilities.DeviceD1)
427  PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED;
428  if (DeviceCapabilities.DeviceD2)
429  PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED;
430  if (DeviceCapabilities.WakeFromD0)
432  if (DeviceCapabilities.WakeFromD1)
434  if (DeviceCapabilities.WakeFromD2)
436  if (DeviceCapabilities.WakeFromD3)
438  if (DeviceCapabilities.WarmEjectSupported)
440  PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
441  PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
442  PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
444  &DeviceCapabilities.DeviceState,
445  sizeof(DeviceCapabilities.DeviceState));
446  PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
447  }
448  else
449  {
450  DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
451 
454  }
455  }
456  }
458  {
459  }
461  {
462  if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
463  {
464  BufferSize = 0;
466  }
467  else
468  {
469  BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
471  &DeviceNode->HardwareRemovalPolicy,
472  BufferSize);
473  }
474  }
475  else
476  {
477  switch (Property)
478  {
481  break;
482 
485  break;
486 
489  break;
490 
493  break;
494 
497  break;
498 
501  break;
502 
505  break;
506 
509  break;
510 
513  break;
514 
515 #if (WINVER >= _WIN32_WINNT_WS03)
517  break;
518 #endif
519 
520 #if (WINVER >= _WIN32_WINNT_WIN7)
523  break;
524 #endif
525 
526  default:
527  BufferSize = 0;
529  break;
530  }
531 
532  if (Status == STATUS_SUCCESS)
533  {
536  BufferSize,
537  Buffer,
538  &BufferSize);
539  }
540  }
541 
543 
544  if (NT_SUCCESS(Status))
545  {
546  _SEH2_TRY
547  {
548  RtlCopyMemory(PropertyData->Buffer, Buffer, BufferSize);
549  PropertyData->BufferSize = BufferSize;
550  }
552  {
554  }
555  _SEH2_END;
556  }
557 
559  return Status;
560 }
561 
562 
563 static NTSTATUS
565 {
566  UNICODE_STRING RootDeviceName;
569  PDEVICE_NODE RelatedDeviceNode;
570  UNICODE_STRING TargetDeviceInstance;
572  ULONG Relation = 0;
573  ULONG MaximumLength = 0;
574 
575  DPRINT("IopGetRelatedDevice() called\n");
576  DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
577 
578  Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
579  if (!NT_SUCCESS(Status))
580  {
581  return Status;
582  }
583 
584  _SEH2_TRY
585  {
586  Relation = RelatedDeviceData->Relation;
587  MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
588  ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
590  sizeof(WCHAR));
591  }
593  {
594  if (TargetDeviceInstance.Buffer != NULL)
595  {
596  ExFreePool(TargetDeviceInstance.Buffer);
597  }
599  }
600  _SEH2_END;
601 
602  RtlInitUnicodeString(&RootDeviceName,
603  L"HTREE\\ROOT\\0");
604  if (RtlEqualUnicodeString(&TargetDeviceInstance,
605  &RootDeviceName,
606  TRUE))
607  {
609  if (TargetDeviceInstance.Buffer != NULL)
610  {
611  ExFreePool(TargetDeviceInstance.Buffer);
612  }
613  }
614  else
615  {
616  /* Get the device object */
617  DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
618  if (TargetDeviceInstance.Buffer != NULL)
619  {
620  ExFreePool(TargetDeviceInstance.Buffer);
621  }
622  if (DeviceObject == NULL)
623  return STATUS_NO_SUCH_DEVICE;
624 
625  DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
626  }
627 
628  switch (Relation)
629  {
631  RelatedDeviceNode = DeviceNode->Parent;
632  break;
633 
635  RelatedDeviceNode = DeviceNode->Child;
636  break;
637 
639  RelatedDeviceNode = DeviceNode->Sibling;
640  break;
641 
642  default:
643  if (DeviceObject != NULL)
644  {
646  }
647 
649  }
650 
651  if (RelatedDeviceNode == NULL)
652  {
653  if (DeviceObject)
654  {
656  }
657 
658  return STATUS_NO_SUCH_DEVICE;
659  }
660 
661  if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
662  {
663  if (DeviceObject)
664  {
666  }
667 
669  }
670 
671  /* Copy related device instance name */
672  _SEH2_TRY
673  {
674  RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
675  RelatedDeviceNode->InstancePath.Buffer,
676  RelatedDeviceNode->InstancePath.Length);
677  RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
678  }
680  {
682  }
683  _SEH2_END;
684 
685  if (DeviceObject != NULL)
686  {
688  }
689 
690  DPRINT("IopGetRelatedDevice() done\n");
691 
692  return Status;
693 }
694 
695 static ULONG
697 {
698  ULONG Output = 0;
699 
700  if (DeviceNode->Parent == IopRootDeviceNode)
702 
703  if (DeviceNode->Flags & DNF_ADDED)
705 
706  /* FIXME: DN_ENUM_LOADED */
707 
708  if (DeviceNode->Flags & DNF_STARTED)
709  Output |= DN_STARTED;
710 
711  /* FIXME: Manual */
712 
713  if (!(DeviceNode->Flags & DNF_PROCESSED))
715 
716  /* DN_NOT_FIRST_TIME is 9x only */
717 
718  /* FIXME: DN_HARDWARE_ENUM */
719 
720  /* DN_LIAR and DN_HAS_MARK are 9x only */
721 
722  if (DeviceNode->Problem != 0)
724 
725  /* FIXME: DN_FILTERED */
726 
727  if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
729 
730  if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
732 
733  if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
735 
736  /* FIXME: Implement the rest */
737 
739 
740  return Output;
741 }
742 
743 static NTSTATUS
745 {
748  ULONG Operation = 0;
749  ULONG DeviceStatus = 0;
750  ULONG DeviceProblem = 0;
753 
754  DPRINT("IopDeviceStatus() called\n");
755 
757  if (!NT_SUCCESS(Status))
758  {
759  return Status;
760  }
761 
762  DPRINT("Device name: '%wZ'\n", &DeviceInstance);
763 
764  _SEH2_TRY
765  {
766  Operation = StatusData->Operation;
768  {
769  DeviceStatus = StatusData->DeviceStatus;
770  DeviceProblem = StatusData->DeviceProblem;
771  }
772  }
774  {
775  if (DeviceInstance.Buffer != NULL)
776  {
778  }
780  }
781  _SEH2_END;
782 
783  /* Get the device object */
785  if (DeviceInstance.Buffer != NULL)
786  {
788  }
789  if (DeviceObject == NULL)
790  {
791  return STATUS_NO_SUCH_DEVICE;
792  }
793 
795 
796  switch (Operation)
797  {
799  DPRINT("Get status data\n");
800  DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
801  DeviceProblem = DeviceNode->Problem;
802  break;
803 
805  DPRINT1("Set status data is NOT SUPPORTED\n");
806  break;
807 
809  DPRINT1("FIXME: Clear status data!\n");
810  break;
811  }
812 
814 
816  {
817  _SEH2_TRY
818  {
819  StatusData->DeviceStatus = DeviceStatus;
820  StatusData->DeviceProblem = DeviceProblem;
821  }
823  {
825  }
826  _SEH2_END;
827  }
828 
829  return Status;
830 }
831 
832 static
833 NTSTATUS
835 {
838  IO_STACK_LOCATION Stack;
840  PDEVICE_RELATIONS DeviceRelations = NULL;
841  PDEVICE_OBJECT ChildDeviceObject;
842  PDEVICE_NODE ChildDeviceNode;
843  ULONG i;
844  ULONG Relations;
846  ULONG BufferLeft;
847  PWCHAR Buffer, Ptr;
849 
850  DPRINT("IopGetDeviceRelations() called\n");
851  DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
852  DPRINT("Relations: %lu\n", RelationsData->Relations);
853  DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
854  DPRINT("Buffer: %p\n", RelationsData->Buffer);
855 
856  _SEH2_TRY
857  {
858  Relations = RelationsData->Relations;
859  BufferSize = RelationsData->BufferSize;
860  Buffer = RelationsData->Buffer;
861 
862  ProbeForWrite(Buffer, BufferSize, sizeof(CHAR));
863  }
865  {
867  }
868  _SEH2_END;
869 
871  if (!NT_SUCCESS(Status))
872  {
873  DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
874  return Status;
875  }
876 
877  /* Get the device object */
879  if (DeviceObject == NULL)
880  {
881  DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
883  goto done;
884  }
885 
886  switch (Relations)
887  {
888  case PNP_EJECT_RELATIONS:
889  Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
890  break;
891 
893  Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
894  break;
895 
896  case PNP_POWER_RELATIONS:
897  Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
898  break;
899 
900  case PNP_BUS_RELATIONS:
901  Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
902  break;
903 
904  default:
906  goto done;
907  }
908 
910  &IoStatusBlock,
912  &Stack);
913  if (!NT_SUCCESS(Status))
914  {
915  DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
916  goto done;
917  }
918 
919  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
920 
921  DPRINT("Found %d device relations\n", DeviceRelations->Count);
922 
923  _SEH2_TRY
924  {
925  RequiredSize = 0;
926  BufferLeft = BufferSize;
927  Ptr = Buffer;
928 
929  for (i = 0; i < DeviceRelations->Count; i++)
930  {
931  ChildDeviceObject = DeviceRelations->Objects[i];
932 
933  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
934  if (ChildDeviceNode)
935  {
936  DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
937  DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
938 
939  if (Ptr != NULL)
940  {
941  if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
942  {
944  break;
945  }
946 
948  ChildDeviceNode->InstancePath.Buffer,
949  ChildDeviceNode->InstancePath.Length);
950  Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
951  *Ptr = UNICODE_NULL;
952  Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
953 
954  BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
955  }
956 
957  RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
958  }
959  }
960 
961  if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
962  *Ptr = UNICODE_NULL;
963 
964  if (RequiredSize > 0)
965  RequiredSize += sizeof(WCHAR);
966 
967  DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
968 
969  RelationsData->BufferSize = RequiredSize;
970  }
972  {
974  }
975  _SEH2_END;
976 
977 done:
978  if (DeviceRelations != NULL)
979  ExFreePool(DeviceRelations);
980 
981  if (DeviceObject != NULL)
983 
984  if (DeviceInstance.Buffer != NULL)
986 
987  return Status;
988 }
989 
990 static NTSTATUS
992 {
997 
998  DPRINT("IopGetDeviceDepth() called\n");
999  DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
1000 
1002  if (!NT_SUCCESS(Status))
1003  {
1004  return Status;
1005  }
1006 
1007  /* Get the device object */
1009  if (DeviceInstance.Buffer != NULL)
1010  {
1012  }
1013  if (DeviceObject == NULL)
1014  {
1015  return STATUS_NO_SUCH_DEVICE;
1016  }
1017 
1019 
1020  _SEH2_TRY
1021  {
1022  DepthData->Depth = DeviceNode->Level;
1023  }
1025  {
1027  }
1028  _SEH2_END;
1029 
1031 
1032  return Status;
1033 }
1034 
1035 
1036 static NTSTATUS
1038 {
1043 
1045  if (!NT_SUCCESS(Status))
1046  {
1047  return Status;
1048  }
1049 
1050  DPRINT("IopResetDevice(%wZ)\n", &DeviceInstance);
1051 
1052  /* Get the device object */
1054  if (DeviceInstance.Buffer != NULL)
1055  {
1057  }
1058  if (DeviceObject == NULL)
1059  {
1060  return STATUS_NO_SUCH_DEVICE;
1061  }
1062 
1063  /* Get the device node */
1065 
1066  ASSERT(DeviceNode->Flags & DNF_ENUMERATED);
1067  ASSERT(DeviceNode->Flags & DNF_PROCESSED);
1068 
1069  /* Check if there's already a driver loaded for this device */
1070  if (DeviceNode->Flags & DNF_ADDED)
1071  {
1072 #if 0
1073  /* Remove the device node */
1075  if (NT_SUCCESS(Status))
1076  {
1077  /* Invalidate device relations for the parent to reenumerate the device */
1078  DPRINT1("A new driver will be loaded for '%wZ' (FDO above removed)\n", &DeviceNode->InstancePath);
1079  Status = IoSynchronousInvalidateDeviceRelations(DeviceNode->Parent->PhysicalDeviceObject, BusRelations);
1080  }
1081  else
1082 #endif
1083  {
1084  /* A driver has already been loaded for this device */
1085  DPRINT("A reboot is required for the current driver for '%wZ' to be replaced\n", &DeviceNode->InstancePath);
1086  DeviceNode->Problem = CM_PROB_NEED_RESTART;
1087  }
1088  }
1089  else
1090  {
1091  /* FIXME: What if the device really is disabled? */
1092  DeviceNode->Flags &= ~DNF_DISABLED;
1093  DeviceNode->Problem = 0;
1094 
1095  /* Load service data from the registry */
1097 
1098  if (NT_SUCCESS(Status))
1099  {
1100  /* Start the service and begin PnP initialization of the device again */
1101  DPRINT("A new driver will be loaded for '%wZ' (no FDO above)\n", &DeviceNode->InstancePath);
1103  }
1104  }
1105 
1107 
1108  return Status;
1109 }
1110 
1111 /* PUBLIC FUNCTIONS **********************************************************/
1112 
1113 /*
1114  * Plug and Play event structure used by NtGetPlugPlayEvent.
1115  *
1116  * EventGuid
1117  * Can be one of the following values:
1118  * GUID_HWPROFILE_QUERY_CHANGE
1119  * GUID_HWPROFILE_CHANGE_CANCELLED
1120  * GUID_HWPROFILE_CHANGE_COMPLETE
1121  * GUID_TARGET_DEVICE_QUERY_REMOVE
1122  * GUID_TARGET_DEVICE_REMOVE_CANCELLED
1123  * GUID_TARGET_DEVICE_REMOVE_COMPLETE
1124  * GUID_PNP_CUSTOM_NOTIFICATION
1125  * GUID_PNP_POWER_NOTIFICATION
1126  * GUID_DEVICE_* (see above)
1127  *
1128  * EventCategory
1129  * Type of the event that happened.
1130  *
1131  * Result
1132  * ?
1133  *
1134  * Flags
1135  * ?
1136  *
1137  * TotalSize
1138  * Size of the event block including the device IDs and other
1139  * per category specific fields.
1140  */
1141 
1142 /*
1143  * NtGetPlugPlayEvent
1144  *
1145  * Returns one Plug & Play event from a global queue.
1146  *
1147  * Parameters
1148  * Reserved1
1149  * Reserved2
1150  * Always set to zero.
1151  *
1152  * Buffer
1153  * The buffer that will be filled with the event information on
1154  * successful return from the function.
1155  *
1156  * BufferSize
1157  * Size of the buffer pointed by the Buffer parameter. If the
1158  * buffer size is not large enough to hold the whole event
1159  * information, error STATUS_BUFFER_TOO_SMALL is returned and
1160  * the buffer remains untouched.
1161  *
1162  * Return Values
1163  * STATUS_PRIVILEGE_NOT_HELD
1164  * STATUS_BUFFER_TOO_SMALL
1165  * STATUS_SUCCESS
1166  *
1167  * Remarks
1168  * This function isn't multi-thread safe!
1169  *
1170  * @implemented
1171  */
1172 NTSTATUS
1173 NTAPI
1175  IN ULONG Reserved2,
1178 {
1180  NTSTATUS Status;
1181 
1182  DPRINT("NtGetPlugPlayEvent() called\n");
1183 
1184  /* Function can only be called from user-mode */
1185  if (KeGetPreviousMode() == KernelMode)
1186  {
1187  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1188  return STATUS_ACCESS_DENIED;
1189  }
1190 
1191  /* Check for Tcb privilege */
1193  UserMode))
1194  {
1195  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1197  }
1198 
1199  /* Wait for a PnP event */
1200  DPRINT("Waiting for pnp notification event\n");
1202  UserRequest,
1203  UserMode,
1204  FALSE,
1205  NULL);
1207  {
1208  DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1210  return Status;
1211  }
1212 
1213  /* Get entry from the tail of the queue */
1216  ListEntry);
1217 
1218  /* Check the buffer size */
1219  if (BufferSize < Entry->Event.TotalSize)
1220  {
1221  DPRINT1("Buffer is too small for the pnp-event\n");
1222  return STATUS_BUFFER_TOO_SMALL;
1223  }
1224 
1225  /* Copy event data to the user buffer */
1226  _SEH2_TRY
1227  {
1229  Entry->Event.TotalSize,
1230  sizeof(UCHAR));
1232  &Entry->Event,
1233  Entry->Event.TotalSize);
1234  }
1236  {
1238  }
1239  _SEH2_END;
1240 
1241  DPRINT("NtGetPlugPlayEvent() done\n");
1242 
1243  return STATUS_SUCCESS;
1244 }
1245 
1246 /*
1247  * NtPlugPlayControl
1248  *
1249  * A function for doing various Plug & Play operations from user mode.
1250  *
1251  * Parameters
1252  * PlugPlayControlClass
1253  * 0x00 Reenumerate device tree
1254  *
1255  * Buffer points to UNICODE_STRING decribing the instance
1256  * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
1257  * more information about instance paths see !devnode command
1258  * in kernel debugger or look at "Inside Windows 2000" book,
1259  * chapter "Driver Loading, Initialization, and Installation".
1260  *
1261  * 0x01 Register new device
1262  * 0x02 Deregister device
1263  * 0x03 Initialize device
1264  * 0x04 Start device
1265  * 0x06 Query and remove device
1266  * 0x07 User response
1267  *
1268  * Called after processing the message from NtGetPlugPlayEvent.
1269  *
1270  * 0x08 Generate legacy device
1271  * 0x09 Get interface device list
1272  * 0x0A Get property data
1273  * 0x0B Device class association (Registration)
1274  * 0x0C Get related device
1275  * 0x0D Get device interface alias
1276  * 0x0E Get/set/clear device status
1277  * 0x0F Get device depth
1278  * 0x10 Query device relations
1279  * 0x11 Query target device relation
1280  * 0x12 Query conflict list
1281  * 0x13 Retrieve dock data
1282  * 0x14 Reset device
1283  * 0x15 Halt device
1284  * 0x16 Get blocked driver data
1285  *
1286  * Buffer
1287  * The buffer contains information that is specific to each control
1288  * code. The buffer is read-only.
1289  *
1290  * BufferSize
1291  * Size of the buffer pointed by the Buffer parameter. If the
1292  * buffer size specifies incorrect value for specified control
1293  * code, error ??? is returned.
1294  *
1295  * Return Values
1296  * STATUS_PRIVILEGE_NOT_HELD
1297  * STATUS_SUCCESS
1298  * ...
1299  *
1300  * @unimplemented
1301  */
1302 NTSTATUS
1303 NTAPI
1305  IN OUT PVOID Buffer,
1307 {
1308  DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1309  PlugPlayControlClass, Buffer, BufferLength);
1310 
1311  /* Function can only be called from user-mode */
1312  if (KeGetPreviousMode() == KernelMode)
1313  {
1314  DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1315  return STATUS_ACCESS_DENIED;
1316  }
1317 
1318  /* Check for Tcb privilege */
1320  UserMode))
1321  {
1322  DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1324  }
1325 
1326  /* Probe the buffer */
1327  _SEH2_TRY
1328  {
1330  BufferLength,
1331  sizeof(ULONG));
1332  }
1334  {
1336  }
1337  _SEH2_END;
1338 
1339  switch (PlugPlayControlClass)
1340  {
1343  return STATUS_INVALID_PARAMETER;
1345 
1346 // case PlugPlayControlRegisterNewDevice:
1347 // case PlugPlayControlDeregisterDevice:
1348 // case PlugPlayControlInitializeDevice:
1349 // case PlugPlayControlStartDevice:
1350 // case PlugPlayControlUnlockDevice:
1351 // case PlugPlayControlQueryAndRemoveDevice:
1352 
1355  return STATUS_INVALID_PARAMETER;
1357 
1358 // case PlugPlayControlGenerateLegacyDevice:
1359 
1362  return STATUS_INVALID_PARAMETER;
1364 
1367  return STATUS_INVALID_PARAMETER;
1369 
1370 // case PlugPlayControlDeviceClassAssociation:
1371 
1374  return STATUS_INVALID_PARAMETER;
1376 
1377 // case PlugPlayControlGetInterfaceDeviceAlias:
1378 
1381  return STATUS_INVALID_PARAMETER;
1383 
1386  return STATUS_INVALID_PARAMETER;
1388 
1391  return STATUS_INVALID_PARAMETER;
1393 
1394 // case PlugPlayControlTargetDeviceRelation:
1395 // case PlugPlayControlQueryConflictList:
1396 // case PlugPlayControlRetrieveDock:
1397 
1400  return STATUS_INVALID_PARAMETER;
1402 
1403 // case PlugPlayControlHaltDevice:
1404 // case PlugPlayControlGetBlockedDriverList:
1405 
1406  default:
1407  return STATUS_NOT_IMPLEMENTED;
1408  }
1409 
1410  return STATUS_NOT_IMPLEMENTED;
1411 }
NTSTATUS NTAPI IoSynchronousInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:2491
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1154
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:696
#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: devnode.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:564
static NTSTATUS IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
Definition: plugplay.c:1037
#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:513
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:834
_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:96
_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:232
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:4226
uint32_t ULONG_PTR
Definition: typedefs.h:64
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:332
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:406
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:1174
#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:193
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:125
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:2083
#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: devaction.c:2054
ULONG PD_D3Latency
Definition: advprop.cpp:53
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:495
#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:744
#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:146
#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:991
#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
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
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:4400
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1304
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:3014
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:254
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:522
#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
struct _PLUGPLAY_EVENT_BLOCK::@2322::@2325 TargetDevice
Definition: dlist.c:348