ReactOS 0.4.15-dev-5893-g1bb4167
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@reactos.org>
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include <ntoskrnl.h>
12#define NDEBUG
13#include <debug.h>
14
15typedef struct _PNP_EVENT_ENTRY
16{
20
22{
26
27
28/* GLOBALS *******************************************************************/
29
32
33/* FUNCTIONS *****************************************************************/
34
35CODE_SEG("INIT")
38{
40
43 FALSE);
44
45 return STATUS_SUCCESS;
46}
47
50 PUNICODE_STRING DeviceIds)
51{
52 PPNP_EVENT_ENTRY EventEntry;
54 ULONG TotalSize;
56
57 ASSERT(DeviceIds);
58
59 /* Allocate a big enough buffer */
60 Copy.Length = 0;
61 Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
62 TotalSize =
64 Copy.MaximumLength;
65
66 EventEntry = ExAllocatePool(NonPagedPool,
67 TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
68 if (!EventEntry)
70 RtlZeroMemory(EventEntry, TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
71
72 /* Fill the buffer with the event GUID */
73 RtlCopyMemory(&EventEntry->Event.EventGuid,
74 Guid,
75 sizeof(GUID));
77 EventEntry->Event.TotalSize = TotalSize;
78
79 /* Fill the device id */
80 Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
82 if (!NT_SUCCESS(Status))
83 {
84 ExFreePool(EventEntry);
85 return Status;
86 }
87
89 &EventEntry->ListEntry);
91 0,
92 FALSE);
93
94 return STATUS_SUCCESS;
95}
96
101{
103
104 if (RtlEqualUnicodeString(&DeviceNode->InstancePath,
105 DeviceInstanceContext->InstancePath, TRUE))
106 {
107 ObReferenceObject(DeviceNode->PhysicalDeviceObject);
108 DeviceInstanceContext->DeviceObject = DeviceNode->PhysicalDeviceObject;
109
110 /* Stop enumeration */
111 return STATUS_UNSUCCESSFUL;
112 }
113
114 return STATUS_SUCCESS;
115}
116
119{
121 IOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT DeviceInstanceContext;
122
123 if (IopRootDeviceNode == NULL)
124 return NULL;
125
126 if (DeviceInstance == NULL ||
127 DeviceInstance->Length == 0)
128 {
130 {
133 }
134 else
135 return NULL;
136 }
137
138 /* Traverse the device tree to find the matching device node */
139 DeviceInstanceContext.InstancePath = DeviceInstance;
140 DeviceInstanceContext.DeviceObject = NULL;
144 &DeviceInstanceContext);
146
147 /* In case of error or instance not found, this will still be NULL from above. */
148 return DeviceInstanceContext.DeviceObject;
149}
150
151static NTSTATUS
153{
155 volatile UNICODE_STRING Name;
156
157 Name.Buffer = NULL;
159 {
160 Name.Length = SrcName->Length;
161 Name.MaximumLength = SrcName->MaximumLength;
162 if (Name.Length > Name.MaximumLength)
163 {
166 }
167
168 if (Name.MaximumLength)
169 {
170 ProbeForRead(SrcName->Buffer,
171 Name.MaximumLength,
172 sizeof(WCHAR));
173 Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
174 if (Name.Buffer == NULL)
175 {
178 }
179
180 memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
181 }
182
183 *DstName = Name;
184 }
186 {
187 if (Name.Buffer)
188 {
189 ExFreePool(Name.Buffer);
190 }
192 }
193 _SEH2_END;
194
195 return Status;
196}
197
198
199static
203{
208
209 DPRINT("IopInitializeDevice(%p)\n", ControlData);
210
211 Status = IopCaptureUnicodeString(&DeviceInstance, &ControlData->DeviceInstance);
212 if (!NT_SUCCESS(Status))
213 {
214 return Status;
215 }
216
217 DPRINT("Device: %wZ\n", &DeviceInstance);
218
219 /* Leave, if the device already exists */
221 if (DeviceInstance.Buffer != NULL)
222 {
223 DPRINT1("Device %wZ already exists!\n", &DeviceInstance);
225 goto done;
226 }
227
229
230 DPRINT("Device %wZ does not exist!\n", &DeviceInstance);
231
232 /* Create a device node for the device instance */
234 0,
235 NULL,
238 FALSE,
239 &DeviceObject);
240 if (!NT_SUCCESS(Status))
241 {
242 DPRINT1("IoCreateDevice() failed (Status 0x%08lx)\n", Status);
243 goto done;
244 }
245
246 /* Allocate a new device node */
248 if (DeviceNode == NULL)
249 {
250 DPRINT1("Failed to allocate a device node!\n");
253 goto done;
254 }
255
256 /* Set the device instance of the device node */
258 if (!NT_SUCCESS(Status))
259 {
260 DPRINT1("RtlDuplicateUnicodeString() failed (Status 0x%08lx)\n", Status);
263 goto done;
264 }
265
266 /* Insert as a root enumerated device node */
268
269done:
271
272 return Status;
273}
274
275
276/*
277 * Remove the current PnP event from the tail of the event queue
278 * and signal IopPnpNotifyEvent if there is yet another event in the queue.
279 */
280static
284{
285 /* Remove a pnp event entry from the tail of the queue */
287 {
289 }
290
291 /* Signal the next pnp event in the queue */
293 {
295 0,
296 FALSE);
297 }
298
299 return STATUS_SUCCESS;
300}
301
302
303static NTSTATUS
305{
310 GUID FilterGuid;
311 PZZWSTR SymbolicLinkList = NULL, LinkList;
313
315 {
317
318 ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
319 RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
320
321 if (StackList.Buffer != NULL && StackList.BufferSize != 0)
322 {
323 ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
324 }
325 }
327 {
329 }
330 _SEH2_END;
331
333 if (NT_SUCCESS(Status))
334 {
335 /* Get the device object */
337 if (DeviceInstance.Buffer != NULL)
338 {
340 }
341 }
342
345
346 if (!NT_SUCCESS(Status))
347 {
348 /* failed */
349 return Status;
350 }
351
352 LinkList = SymbolicLinkList;
354 {
356 }
357 TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
358
360 {
361 if (StackList.Buffer != NULL &&
362 StackList.BufferSize >= TotalLength)
363 {
364 // We've already probed the buffer for writing above.
365 RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
366 }
367
368 DeviceList->BufferSize = TotalLength;
369 }
371 {
372 ExFreePool(LinkList);
374 }
375 _SEH2_END;
376
377 ExFreePool(LinkList);
378 return STATUS_SUCCESS;
379}
380
381static NTSTATUS
383{
392
393 DPRINT("IopGetDeviceProperty() called\n");
394 DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
395
397 if (!NT_SUCCESS(Status))
398 {
399 return Status;
400 }
401
403 {
404 Property = PropertyData->Property;
405 BufferSize = PropertyData->BufferSize;
408 sizeof(UCHAR));
409 }
411 {
412 if (DeviceInstance.Buffer != NULL)
413 {
415 }
417 }
418 _SEH2_END;
419
420 /* Get the device object */
422 if (DeviceInstance.Buffer != NULL)
423 {
425 }
426 if (DeviceObject == NULL)
427 {
429 }
430
432 if (Buffer == NULL)
433 {
436 }
437
438
439 DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
440
442 {
443 if (BufferSize < sizeof(CM_POWER_DATA))
444 {
445 BufferSize = 0;
447 }
448 else
449 {
451 PCM_POWER_DATA PowerData;
454
455 PowerData = (PCM_POWER_DATA)Buffer;
456 RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
457 PowerData->PD_Size = sizeof(CM_POWER_DATA);
458
461 DeviceCapabilities.Version = 1;
462 DeviceCapabilities.Address = -1;
463 DeviceCapabilities.UINumber = -1;
464
465 Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
466
470 &Stack);
471 if (NT_SUCCESS(Status))
472 {
473 DPRINT("Got device capabiliities\n");
474
475 PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
476 if (DeviceCapabilities.DeviceD1)
478 if (DeviceCapabilities.DeviceD2)
480 if (DeviceCapabilities.WakeFromD0)
482 if (DeviceCapabilities.WakeFromD1)
484 if (DeviceCapabilities.WakeFromD2)
486 if (DeviceCapabilities.WakeFromD3)
488 if (DeviceCapabilities.WarmEjectSupported)
490 PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
491 PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
492 PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
494 &DeviceCapabilities.DeviceState,
495 sizeof(DeviceCapabilities.DeviceState));
496 PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
497 }
498 else
499 {
500 DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
501
504 }
505 }
506 }
508 {
510 BufferSize = 0;
512 }
514 {
515 if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
516 {
517 BufferSize = 0;
519 }
520 else
521 {
522 BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
524 &DeviceNode->HardwareRemovalPolicy,
525 BufferSize);
526 }
527 }
528 else
529 {
530 switch (Property)
531 {
534 break;
535
538 break;
539
542 break;
543
546 break;
547
550 break;
551
554 break;
555
558 break;
559
562 break;
563
566 break;
567
568#if (WINVER >= _WIN32_WINNT_WS03)
571 BufferSize = 0;
573 break;
574#endif
575
576#if (WINVER >= _WIN32_WINNT_WIN7)
579 break;
580#endif
581
582 default:
583 BufferSize = 0;
585 break;
586 }
587
588 if (Status == STATUS_SUCCESS)
589 {
593 Buffer,
594 &BufferSize);
595 }
596 }
597
599
600 if (NT_SUCCESS(Status))
601 {
603 {
605 PropertyData->BufferSize = BufferSize;
606 }
608 {
610 }
611 _SEH2_END;
612 }
613
615 return Status;
616}
617
618
619static NTSTATUS
621{
622 UNICODE_STRING RootDeviceName;
625 PDEVICE_NODE RelatedDeviceNode;
626 UNICODE_STRING TargetDeviceInstance;
628 ULONG Relation = 0;
630
631 DPRINT("IopGetRelatedDevice() called\n");
632 DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
633
634 Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
635 if (!NT_SUCCESS(Status))
636 {
637 return Status;
638 }
639
641 {
642 Relation = RelatedDeviceData->Relation;
643 MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
644 ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
646 sizeof(WCHAR));
647 }
649 {
650 if (TargetDeviceInstance.Buffer != NULL)
651 {
652 ExFreePool(TargetDeviceInstance.Buffer);
653 }
655 }
656 _SEH2_END;
657
658 RtlInitUnicodeString(&RootDeviceName,
659 L"HTREE\\ROOT\\0");
660 if (RtlEqualUnicodeString(&TargetDeviceInstance,
661 &RootDeviceName,
662 TRUE))
663 {
665 if (TargetDeviceInstance.Buffer != NULL)
666 {
667 ExFreePool(TargetDeviceInstance.Buffer);
668 }
669 }
670 else
671 {
672 /* Get the device object */
673 DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
674 if (TargetDeviceInstance.Buffer != NULL)
675 {
676 ExFreePool(TargetDeviceInstance.Buffer);
677 }
678 if (DeviceObject == NULL)
680
681 DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
682 }
683
684 switch (Relation)
685 {
687 RelatedDeviceNode = DeviceNode->Parent;
688 break;
689
691 RelatedDeviceNode = DeviceNode->Child;
692 break;
693
695 RelatedDeviceNode = DeviceNode->Sibling;
696 break;
697
698 default:
699 if (DeviceObject != NULL)
700 {
702 }
703
705 }
706
707 if (RelatedDeviceNode == NULL)
708 {
709 if (DeviceObject)
710 {
712 }
713
715 }
716
717 if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
718 {
719 if (DeviceObject)
720 {
722 }
723
725 }
726
727 /* Copy related device instance name */
729 {
730 RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
731 RelatedDeviceNode->InstancePath.Buffer,
732 RelatedDeviceNode->InstancePath.Length);
733 RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
734 }
736 {
738 }
739 _SEH2_END;
740
741 if (DeviceObject != NULL)
742 {
744 }
745
746 DPRINT("IopGetRelatedDevice() done\n");
747
748 return Status;
749}
750
751static
755{
756 return (DeviceNode->State == DeviceNodeStartPending ||
759 DeviceNode->State == DeviceNodeStarted ||
763 DeviceNode->State == DeviceNodeStopped ||
765}
766
767static ULONG
769{
771
772 if (DeviceNode->Parent == IopRootDeviceNode)
774
775 // FIXME: review for deleted and removed states
778
781
782 if (DeviceNode->UserFlags & DNUF_WILL_BE_REMOVED)
784
785 if (DeviceNode->Flags & DNF_HAS_PROBLEM)
787
790
791 if (DeviceNode->Flags & DNF_DRIVER_BLOCKED)
793
796
799
800 if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
802
803 if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
805
806 if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
808
809 return Output;
810}
811
812static NTSTATUS
814{
817 ULONG Operation = 0;
818 ULONG DeviceStatus = 0;
819 ULONG DeviceProblem = 0;
822
823 DPRINT("IopDeviceStatus() called\n");
824
826 if (!NT_SUCCESS(Status))
827 {
828 return Status;
829 }
830
831 DPRINT("Device name: '%wZ'\n", &DeviceInstance);
832
834 {
835 Operation = StatusData->Operation;
837 {
838 DeviceStatus = StatusData->DeviceStatus;
839 DeviceProblem = StatusData->DeviceProblem;
840 }
841 }
843 {
844 if (DeviceInstance.Buffer != NULL)
845 {
847 }
849 }
850 _SEH2_END;
851
852 /* Get the device object */
854 if (DeviceInstance.Buffer != NULL)
855 {
857 }
858 if (DeviceObject == NULL)
859 {
861 }
862
864
865 switch (Operation)
866 {
868 DPRINT("Get status data\n");
869 DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
870 DeviceProblem = DeviceNode->Problem;
871 break;
872
874 DPRINT1("Set status data is NOT SUPPORTED\n");
875 break;
876
878 DPRINT1("FIXME: Clear status data!\n");
879 break;
880 }
881
883
885 {
887 {
888 StatusData->DeviceStatus = DeviceStatus;
889 StatusData->DeviceProblem = DeviceProblem;
890 }
892 {
894 }
895 _SEH2_END;
896 }
897
898 return Status;
899}
900
901static
904{
909 PDEVICE_RELATIONS DeviceRelations = NULL;
910 PDEVICE_OBJECT ChildDeviceObject;
911 PDEVICE_NODE ChildDeviceNode;
912 ULONG i;
913 ULONG Relations;
915 ULONG BufferLeft;
918
919 DPRINT("IopGetDeviceRelations() called\n");
920 DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
921 DPRINT("Relations: %lu\n", RelationsData->Relations);
922 DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
923 DPRINT("Buffer: %p\n", RelationsData->Buffer);
924
926 {
927 Relations = RelationsData->Relations;
928 BufferSize = RelationsData->BufferSize;
929 Buffer = RelationsData->Buffer;
930
932 }
934 {
936 }
937 _SEH2_END;
938
940 if (!NT_SUCCESS(Status))
941 {
942 DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
943 return Status;
944 }
945
946 /* Get the device object */
948 if (DeviceObject == NULL)
949 {
950 DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
952 goto done;
953 }
954
955 switch (Relations)
956 {
958 Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
959 break;
960
962 Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
963 break;
964
966 Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
967 break;
968
970 Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
971 break;
972
973 default:
975 goto done;
976 }
977
981 &Stack);
982 if (!NT_SUCCESS(Status))
983 {
984 DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
985 goto done;
986 }
987
989
990 DPRINT("Found %d device relations\n", DeviceRelations->Count);
991
993 {
994 RequiredSize = 0;
995 BufferLeft = BufferSize;
996 Ptr = Buffer;
997
998 for (i = 0; i < DeviceRelations->Count; i++)
999 {
1000 ChildDeviceObject = DeviceRelations->Objects[i];
1001
1002 ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
1003 if (ChildDeviceNode)
1004 {
1005 DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
1006 DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1007
1008 if (Ptr != NULL)
1009 {
1010 if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
1011 {
1013 break;
1014 }
1015
1017 ChildDeviceNode->InstancePath.Buffer,
1018 ChildDeviceNode->InstancePath.Length);
1019 Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
1020 *Ptr = UNICODE_NULL;
1021 Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
1022
1023 BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1024 }
1025
1026 RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1027 }
1028 }
1029
1030 if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
1031 *Ptr = UNICODE_NULL;
1032
1033 if (RequiredSize > 0)
1034 RequiredSize += sizeof(WCHAR);
1035
1036 DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
1037
1038 RelationsData->BufferSize = RequiredSize;
1039 }
1041 {
1043 }
1044 _SEH2_END;
1045
1046done:
1047 if (DeviceRelations != NULL)
1048 ExFreePool(DeviceRelations);
1049
1050 if (DeviceObject != NULL)
1052
1053 if (DeviceInstance.Buffer != NULL)
1054 ExFreePool(DeviceInstance.Buffer);
1055
1056 return Status;
1057}
1058
1059static NTSTATUS
1061{
1066
1067 DPRINT("IopGetDeviceDepth() called\n");
1068 DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
1069
1071 if (!NT_SUCCESS(Status))
1072 {
1073 return Status;
1074 }
1075
1076 /* Get the device object */
1078 if (DeviceInstance.Buffer != NULL)
1079 {
1080 ExFreePool(DeviceInstance.Buffer);
1081 }
1082 if (DeviceObject == NULL)
1083 {
1084 return STATUS_NO_SUCH_DEVICE;
1085 }
1086
1088
1089 _SEH2_TRY
1090 {
1091 DepthData->Depth = DeviceNode->Level;
1092 }
1094 {
1096 }
1097 _SEH2_END;
1098
1100
1101 return Status;
1102}
1103
1104static
1109{
1113
1117
1119 if (!NT_SUCCESS(Status))
1120 {
1121 return Status;
1122 }
1123
1125 if (DeviceInstance.Buffer != NULL)
1126 {
1127 ExFreePool(DeviceInstance.Buffer);
1128 }
1129 if (DeviceObject == NULL)
1130 {
1131 return STATUS_NO_SUCH_DEVICE;
1132 }
1133
1135
1136 switch (ControlClass)
1137 {
1140 break;
1143 break;
1146 break;
1147 default:
1149 break;
1150 }
1151
1153
1155
1156 return Status;
1157}
1158
1159static
1163{
1167
1168 Status = IopCaptureUnicodeString(&DeviceInstance, &ControlData->DeviceInstance);
1169 if (!NT_SUCCESS(Status))
1170 {
1171 return Status;
1172 }
1173
1175 if (DeviceInstance.Buffer != NULL)
1176 {
1177 ExFreePool(DeviceInstance.Buffer);
1178 }
1179 if (DeviceObject == NULL)
1180 {
1181 return STATUS_NO_SUCH_DEVICE;
1182 }
1183
1186
1188
1189 return Status;
1190}
1191
1192/* PUBLIC FUNCTIONS **********************************************************/
1193
1194/*
1195 * Plug and Play event structure used by NtGetPlugPlayEvent.
1196 *
1197 * EventGuid
1198 * Can be one of the following values:
1199 * GUID_HWPROFILE_QUERY_CHANGE
1200 * GUID_HWPROFILE_CHANGE_CANCELLED
1201 * GUID_HWPROFILE_CHANGE_COMPLETE
1202 * GUID_TARGET_DEVICE_QUERY_REMOVE
1203 * GUID_TARGET_DEVICE_REMOVE_CANCELLED
1204 * GUID_TARGET_DEVICE_REMOVE_COMPLETE
1205 * GUID_PNP_CUSTOM_NOTIFICATION
1206 * GUID_PNP_POWER_NOTIFICATION
1207 * GUID_DEVICE_* (see above)
1208 *
1209 * EventCategory
1210 * Type of the event that happened.
1211 *
1212 * Result
1213 * ?
1214 *
1215 * Flags
1216 * ?
1217 *
1218 * TotalSize
1219 * Size of the event block including the device IDs and other
1220 * per category specific fields.
1221 */
1222
1223/*
1224 * NtGetPlugPlayEvent
1225 *
1226 * Returns one Plug & Play event from a global queue.
1227 *
1228 * Parameters
1229 * Reserved1
1230 * Reserved2
1231 * Always set to zero.
1232 *
1233 * Buffer
1234 * The buffer that will be filled with the event information on
1235 * successful return from the function.
1236 *
1237 * BufferSize
1238 * Size of the buffer pointed by the Buffer parameter. If the
1239 * buffer size is not large enough to hold the whole event
1240 * information, error STATUS_BUFFER_TOO_SMALL is returned and
1241 * the buffer remains untouched.
1242 *
1243 * Return Values
1244 * STATUS_PRIVILEGE_NOT_HELD
1245 * STATUS_BUFFER_TOO_SMALL
1246 * STATUS_SUCCESS
1247 *
1248 * Remarks
1249 * This function isn't multi-thread safe!
1250 *
1251 * @implemented
1252 */
1254NTAPI
1259{
1262
1263 DPRINT("NtGetPlugPlayEvent() called\n");
1264
1265 /* Function can only be called from user-mode */
1267 {
1268 DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1269 return STATUS_ACCESS_DENIED;
1270 }
1271
1272 /* Check for Tcb privilege */
1274 UserMode))
1275 {
1276 DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1278 }
1279
1280 /* Wait for a PnP event */
1281 DPRINT("Waiting for pnp notification event\n");
1284 UserMode,
1285 FALSE,
1286 NULL);
1288 {
1289 DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1291 return Status;
1292 }
1293
1294 /* Get entry from the tail of the queue */
1297 ListEntry);
1298
1299 /* Check the buffer size */
1300 if (BufferSize < Entry->Event.TotalSize)
1301 {
1302 DPRINT1("Buffer is too small for the pnp-event\n");
1304 }
1305
1306 /* Copy event data to the user buffer */
1307 _SEH2_TRY
1308 {
1310 Entry->Event.TotalSize,
1311 sizeof(UCHAR));
1313 &Entry->Event,
1314 Entry->Event.TotalSize);
1315 }
1317 {
1319 }
1320 _SEH2_END;
1321
1322 DPRINT("NtGetPlugPlayEvent() done\n");
1323
1324 return STATUS_SUCCESS;
1325}
1326
1327/*
1328 * NtPlugPlayControl
1329 *
1330 * A function for doing various Plug & Play operations from user mode.
1331 *
1332 * Parameters
1333 * PlugPlayControlClass
1334 * 0x00 Reenumerate device tree
1335 *
1336 * Buffer points to UNICODE_STRING decribing the instance
1337 * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
1338 * more information about instance paths see !devnode command
1339 * in kernel debugger or look at "Inside Windows 2000" book,
1340 * chapter "Driver Loading, Initialization, and Installation".
1341 *
1342 * 0x01 Register new device
1343 * 0x02 Deregister device
1344 * 0x03 Initialize device
1345 * 0x04 Start device
1346 * 0x06 Query and remove device
1347 * 0x07 User response
1348 *
1349 * Called after processing the message from NtGetPlugPlayEvent.
1350 *
1351 * 0x08 Generate legacy device
1352 * 0x09 Get interface device list
1353 * 0x0A Get property data
1354 * 0x0B Device class association (Registration)
1355 * 0x0C Get related device
1356 * 0x0D Get device interface alias
1357 * 0x0E Get/set/clear device status
1358 * 0x0F Get device depth
1359 * 0x10 Query device relations
1360 * 0x11 Query target device relation
1361 * 0x12 Query conflict list
1362 * 0x13 Retrieve dock data
1363 * 0x14 Reset device
1364 * 0x15 Halt device
1365 * 0x16 Get blocked driver data
1366 *
1367 * Buffer
1368 * The buffer contains information that is specific to each control
1369 * code. The buffer is read-only.
1370 *
1371 * BufferSize
1372 * Size of the buffer pointed by the Buffer parameter. If the
1373 * buffer size specifies incorrect value for specified control
1374 * code, error ??? is returned.
1375 *
1376 * Return Values
1377 * STATUS_PRIVILEGE_NOT_HELD
1378 * STATUS_SUCCESS
1379 * ...
1380 *
1381 * @unimplemented
1382 */
1384NTAPI
1388{
1389 DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1390 PlugPlayControlClass, Buffer, BufferLength);
1391
1392 /* Function can only be called from user-mode */
1394 {
1395 DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1396 return STATUS_ACCESS_DENIED;
1397 }
1398
1399 /* Check for Tcb privilege */
1401 UserMode))
1402 {
1403 DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1405 }
1406
1407 /* Probe the buffer */
1408 _SEH2_TRY
1409 {
1412 sizeof(ULONG));
1413 }
1415 {
1417 }
1418 _SEH2_END;
1419
1420 switch (PlugPlayControlClass)
1421 {
1425 // the Flags field is not used anyway
1427 PlugPlayControlClass);
1428
1429// case PlugPlayControlRegisterNewDevice:
1430// case PlugPlayControlDeregisterDevice:
1431
1436
1442 PlugPlayControlClass);
1443
1444// case PlugPlayControlUnlockDevice:
1449
1454
1455// case PlugPlayControlGenerateLegacyDevice:
1456
1461
1466
1467// case PlugPlayControlDeviceClassAssociation:
1468
1473
1474// case PlugPlayControlGetInterfaceDeviceAlias:
1475
1480
1485
1490
1491// case PlugPlayControlTargetDeviceRelation:
1492// case PlugPlayControlQueryConflictList:
1493// case PlugPlayControlRetrieveDock:
1494// case PlugPlayControlHaltDevice:
1495// case PlugPlayControlGetBlockedDriverList:
1496
1497 default:
1499 }
1500
1502}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
@ DeviceNode
Definition: Node.h:9
unsigned char BOOLEAN
struct CM_Power_Data_s * PCM_POWER_DATA
#define PDCAP_WARM_EJECT_SUPPORTED
Definition: advprop.cpp:44
#define PDCAP_D2_SUPPORTED
Definition: advprop.cpp:38
struct CM_Power_Data_s CM_POWER_DATA
#define PDCAP_D0_SUPPORTED
Definition: advprop.cpp:36
#define PDCAP_D1_SUPPORTED
Definition: advprop.cpp:37
#define PDCAP_WAKE_FROM_D3_SUPPORTED
Definition: advprop.cpp:43
#define PDCAP_WAKE_FROM_D1_SUPPORTED
Definition: advprop.cpp:41
#define PDCAP_WAKE_FROM_D0_SUPPORTED
Definition: advprop.cpp:40
#define PDCAP_D3_SUPPORTED
Definition: advprop.cpp:39
#define PDCAP_WAKE_FROM_D2_SUPPORTED
Definition: advprop.cpp:42
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
@ Reserved2
Definition: bcd.h:202
@ Reserved1
Definition: bcd.h:201
#define UNIMPLEMENTED
Definition: debug.h:115
#define DN_NT_DRIVER
Definition: cfg.h:142
#define DN_NO_SHOW_IN_DM
Definition: cfg.h:148
#define DN_NT_ENUMERATOR
Definition: cfg.h:141
#define DN_DRIVER_LOADED
Definition: cfg.h:119
#define DN_DISABLEABLE
Definition: cfg.h:131
#define DN_DRIVER_BLOCKED
Definition: cfg.h:154
#define DN_CHILD_WITH_INVALID_ID
Definition: cfg.h:156
#define DN_HAS_PROBLEM
Definition: cfg.h:128
#define DN_STARTED
Definition: cfg.h:121
#define DN_WILL_BE_REMOVED
Definition: cfg.h:136
#define DN_ROOT_ENUMERATED
Definition: cfg.h:118
#define DN_LEGACY_DRIVER
Definition: cfg.h:155
#define DN_PRIVATE_PROBLEM
Definition: cfg.h:133
static const WCHAR ControlClass[]
Definition: cfgmgr.c:44
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PDEVICE_LIST DeviceList
Definition: utils.c:27
static const WCHAR DeviceInstance[]
Definition: interface.c:28
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
Definition: mmixer.c:126
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define RemoveTailList(ListHead)
Definition: env_spec_w32.h:975
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_LEAVE
Definition: filesup.c:20
FP_OP Operation
Definition: fpcontrol.c:150
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_In_ WDFDEVICE _In_ PWDF_DEVICE_INTERFACE_PROPERTY_DATA PropertyData
Status
Definition: gdiplustypes.h:25
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
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ASSERT(a)
Definition: mode.c:44
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define _Inout_
Definition: ms_sal.h:378
#define _In_
Definition: ms_sal.h:308
#define KernelMode
Definition: asm.h:34
#define UserMode
Definition: asm.h:35
#define KeGetPreviousMode()
Definition: ketypes.h:1108
#define PNP_PROPERTY_UI_NUMBER
Definition: cmtypes.h:34
#define PNP_SET_DEVICE_STATUS
Definition: cmtypes.h:60
#define PNP_PROPERTY_REMOVAL_POLICY
Definition: cmtypes.h:40
enum _PLUGPLAY_CONTROL_CLASS PLUGPLAY_CONTROL_CLASS
#define PNP_GET_SIBLING_DEVICE
Definition: cmtypes.h:54
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define PNP_GET_PARENT_DEVICE
Definition: cmtypes.h:52
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
#define PNP_GET_CHILD_DEVICE
Definition: cmtypes.h:53
@ TargetDeviceChangeEvent
Definition: cmtypes.h:257
#define PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cmtypes.h:35
@ PlugPlayControlEnumerateDevice
Definition: cmtypes.h:209
@ PlugPlayControlUserResponse
Definition: cmtypes.h:216
@ PlugPlayControlProperty
Definition: cmtypes.h:219
@ PlugPlayControlQueryDeviceRelations
Definition: cmtypes.h:225
@ PlugPlayControlGetRelatedDevice
Definition: cmtypes.h:221
@ PlugPlayControlDeviceStatus
Definition: cmtypes.h:223
@ PlugPlayControlQueryAndRemoveDevice
Definition: cmtypes.h:215
@ PlugPlayControlGetDeviceDepth
Definition: cmtypes.h:224
@ PlugPlayControlInitializeDevice
Definition: cmtypes.h:212
@ PlugPlayControlGetInterfaceDeviceList
Definition: cmtypes.h:218
@ PlugPlayControlStartDevice
Definition: cmtypes.h:213
@ PlugPlayControlResetDevice
Definition: cmtypes.h:229
#define PNP_POWER_RELATIONS
Definition: cmtypes.h:68
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
#define PNP_BUS_RELATIONS
Definition: cmtypes.h:69
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
#define PNP_PROPERTY_REMOVAL_POLICY_OVERRIDE
Definition: cmtypes.h:41
#define PNP_CLEAR_DEVICE_STATUS
Definition: cmtypes.h:61
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define PNP_GET_DEVICE_STATUS
Definition: cmtypes.h:59
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define PNP_REMOVAL_RELATIONS
Definition: cmtypes.h:67
#define PNP_PROPERTY_ADDRESS
Definition: cmtypes.h:42
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
#define PNP_EJECT_RELATIONS
Definition: cmtypes.h:66
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
#define DNUF_WILL_BE_REMOVED
Definition: iotypes.h:208
#define DNF_LEGACY_DRIVER
Definition: iotypes.h:182
@ DeviceNodeDriversAdded
Definition: iotypes.h:387
@ DeviceNodeStopped
Definition: iotypes.h:394
@ DeviceNodeRestartCompletion
Definition: iotypes.h:395
@ DeviceNodeStartPostWork
Definition: iotypes.h:391
@ DeviceNodeStarted
Definition: iotypes.h:392
@ DeviceNodeStartCompletion
Definition: iotypes.h:390
@ DeviceNodeEnumerateCompletion
Definition: iotypes.h:397
@ DeviceNodeEnumeratePending
Definition: iotypes.h:396
@ DeviceNodeQueryStopped
Definition: iotypes.h:393
@ DeviceNodeStartPending
Definition: iotypes.h:389
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
#define DNUF_NOT_DISABLEABLE
Definition: iotypes.h:211
#define DNF_HAS_PRIVATE_PROBLEM
Definition: iotypes.h:184
#define DNUF_DONT_SHOW_IN_UI
Definition: iotypes.h:209
#define DNF_CHILD_WITH_INVALID_ID
Definition: iotypes.h:191
#define DNF_DRIVER_BLOCKED
Definition: iotypes.h:190
#define DNF_HAS_PROBLEM
Definition: iotypes.h:183
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define UNREACHABLE
#define UNICODE_NULL
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:420
@ SynchronizationEvent
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
@ PiActionResetDevice
Definition: io.h:528
@ PiActionStartDevice
Definition: io.h:530
@ PiActionEnumDeviceTree
Definition: io.h:526
VOID PiInsertDevNode(_In_ PDEVICE_NODE DeviceNode, _In_ PDEVICE_NODE ParentNode)
Definition: devnode.c:80
PDEVICE_NODE PipAllocateDeviceNode(IN PDEVICE_OBJECT PhysicalDeviceObject)
#define IopInitDeviceTreeTraverseContext( _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context)
Definition: io.h:229
NTSTATUS IopTraverseDeviceTree(PDEVICETREE_TRAVERSE_CONTEXT Context)
NTSTATUS IopFreeDeviceNode(IN PDEVICE_NODE DeviceNode)
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
enum _DEVICE_ACTION DEVICE_ACTION
PDRIVER_OBJECT IopRootDriverObject
Definition: pnpmgr.c:26
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
NTSTATUS PiPerformSyncDeviceAction(_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action)
Perfom a device operation synchronously via PiQueueDeviceAction.
Definition: devaction.c:2714
const LUID SeTcbPrivilege
Definition: priv.c:26
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
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)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
@ PowerDeviceD0
Definition: ntpoapi.h:49
#define STATUS_USER_APC
Definition: ntstatus.h:78
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define L(x)
Definition: ntvdm.h:50
struct _IOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT IOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT
static BOOLEAN PiIsDevNodeStarted(_In_ PDEVICE_NODE DeviceNode)
Definition: plugplay.c:753
static NTSTATUS IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
Definition: plugplay.c:620
NTSTATUS IopQueueTargetDeviceEvent(const GUID *Guid, PUNICODE_STRING DeviceIds)
Definition: plugplay.c:49
NTSTATUS IopInitPlugPlayEvents(VOID)
Definition: plugplay.c:37
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:118
static NTSTATUS PiControlQueryRemoveDevice(_In_ PPLUGPLAY_CONTROL_QUERY_REMOVE_DATA ControlData)
Definition: plugplay.c:1161
static NTSTATUS IopRemovePlugPlayEvent(_In_ PPLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData)
Definition: plugplay.c:282
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:152
static NTSTATUS IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
Definition: plugplay.c:813
struct _PNP_EVENT_ENTRY * PPNP_EVENT_ENTRY
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:768
NTSTATUS IopFindDeviceInstanceTraverse(_In_ PDEVICE_NODE DeviceNode, _Inout_ PVOID Context)
Definition: plugplay.c:98
static NTSTATUS IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
Definition: plugplay.c:304
static NTSTATUS IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
Definition: plugplay.c:1060
static LIST_ENTRY IopPnpEventQueueHead
Definition: plugplay.c:30
NTSTATUS NTAPI NtGetPlugPlayEvent(IN ULONG Reserved1, IN ULONG Reserved2, OUT PPLUGPLAY_EVENT_BLOCK Buffer, IN ULONG BufferSize)
Definition: plugplay.c:1255
static NTSTATUS PiControlSyncDeviceAction(_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceData, _In_ PLUGPLAY_CONTROL_CLASS ControlClass)
Definition: plugplay.c:1106
struct _IOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT * PIOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT
static NTSTATUS IopInitializeDevice(_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ControlData)
Definition: plugplay.c:201
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1385
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:903
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:382
static KEVENT IopPnpNotifyEvent
Definition: plugplay.c:31
struct _PNP_EVENT_ENTRY PNP_EVENT_ENTRY
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1952
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:110
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
@ Output
Definition: arc.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:71
SYSTEM_POWER_STATE PD_DeepestSystemWake
Definition: advprop.cpp:55
DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]
Definition: advprop.cpp:54
ULONG PD_D2Latency
Definition: advprop.cpp:52
ULONG PD_Capabilities
Definition: advprop.cpp:50
ULONG PD_D1Latency
Definition: advprop.cpp:51
DEVICE_POWER_STATE PD_MostRecentPowerState
Definition: advprop.cpp:49
ULONG PD_D3Latency
Definition: advprop.cpp:53
base of all file and directory entries
Definition: entries.h:83
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:855
UNICODE_STRING InstancePath
Definition: iotypes.h:858
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:525
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:534
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:406
struct _PLUGPLAY_EVENT_BLOCK::@2370::@2373 TargetDevice
Definition: plugplay.c:16
LIST_ENTRY ListEntry
Definition: plugplay.c:17
PLUGPLAY_EVENT_BLOCK Event
Definition: plugplay.c:18
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG TotalLength
Definition: usbdlib.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3769
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
#define DeviceCapabilities
Definition: wingdi.h:4449
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:691
DEVICE_CAPABILITIES
Definition: iotypes.h:965
@ EjectionRelations
Definition: iotypes.h:2153
@ RemovalRelations
Definition: iotypes.h:2155
@ BusRelations
Definition: iotypes.h:2152
@ PowerRelations
Definition: iotypes.h:2154
DEVICE_REGISTRY_PROPERTY
Definition: iotypes.h:1194
@ DevicePropertyAddress
Definition: iotypes.h:1211
@ DevicePropertyEnumeratorName
Definition: iotypes.h:1210
@ DevicePropertyInstallState
Definition: iotypes.h:1213
@ DevicePropertyUINumber
Definition: iotypes.h:1212
@ DevicePropertyBusNumber
Definition: iotypes.h:1209
@ DevicePropertyRemovalPolicy
Definition: iotypes.h:1214
@ DevicePropertyPhysicalDeviceObjectName
Definition: iotypes.h:1206
@ DevicePropertyLegacyBusType
Definition: iotypes.h:1208
@ DevicePropertyContainerID
Definition: iotypes.h:1217
@ DevicePropertyBusTypeGuid
Definition: iotypes.h:1207
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_CAPABILITIES
@ UserRequest
Definition: ketypes.h:409
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175