ReactOS 0.4.15-dev-7076-gc00d41d
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
37
38CODE_SEG("INIT")
41{
43
46 FALSE);
47
48 return STATUS_SUCCESS;
49}
50
53 PUNICODE_STRING DeviceIds)
54{
55 PPNP_EVENT_ENTRY EventEntry;
57 ULONG TotalSize;
59
60 ASSERT(DeviceIds);
61
62 /* Allocate a big enough buffer */
63 Copy.Length = 0;
64 Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
65 TotalSize =
67 Copy.MaximumLength;
68
69 EventEntry = ExAllocatePool(NonPagedPool,
70 TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
71 if (!EventEntry)
73 RtlZeroMemory(EventEntry, TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
74
75 /* Fill the buffer with the event GUID */
76 RtlCopyMemory(&EventEntry->Event.EventGuid,
77 Guid,
78 sizeof(GUID));
80 EventEntry->Event.TotalSize = TotalSize;
81
82 /* Fill the device id */
83 Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
85 if (!NT_SUCCESS(Status))
86 {
87 ExFreePool(EventEntry);
88 return Status;
89 }
90
92 &EventEntry->ListEntry);
94 0,
95 FALSE);
96
97 return STATUS_SUCCESS;
98}
99
104{
106
107 if (RtlEqualUnicodeString(&DeviceNode->InstancePath,
108 DeviceInstanceContext->InstancePath, TRUE))
109 {
110 ObReferenceObject(DeviceNode->PhysicalDeviceObject);
111 DeviceInstanceContext->DeviceObject = DeviceNode->PhysicalDeviceObject;
112
113 /* Stop enumeration */
114 return STATUS_UNSUCCESSFUL;
115 }
116
117 return STATUS_SUCCESS;
118}
119
122{
124 IOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT DeviceInstanceContext;
125
126 if (IopRootDeviceNode == NULL)
127 return NULL;
128
129 if (DeviceInstance == NULL ||
130 DeviceInstance->Length == 0)
131 {
133 {
136 }
137 else
138 return NULL;
139 }
140
141 /* Traverse the device tree to find the matching device node */
142 DeviceInstanceContext.InstancePath = DeviceInstance;
143 DeviceInstanceContext.DeviceObject = NULL;
147 &DeviceInstanceContext);
149
150 /* In case of error or instance not found, this will still be NULL from above. */
151 return DeviceInstanceContext.DeviceObject;
152}
153
154static NTSTATUS
156{
158 volatile UNICODE_STRING Name;
159
160 Name.Buffer = NULL;
162 {
163 Name.Length = SrcName->Length;
164 Name.MaximumLength = SrcName->MaximumLength;
165 if (Name.Length > Name.MaximumLength)
166 {
169 }
170
171 if (Name.MaximumLength)
172 {
173 ProbeForRead(SrcName->Buffer,
174 Name.MaximumLength,
175 sizeof(WCHAR));
176 Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
177 if (Name.Buffer == NULL)
178 {
181 }
182
183 memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
184 }
185
186 *DstName = Name;
187 }
189 {
190 if (Name.Buffer)
191 {
192 ExFreePool(Name.Buffer);
193 }
195 }
196 _SEH2_END;
197
198 return Status;
199}
200
201
202static
206{
211 HANDLE InstanceKey;
212
213 DPRINT("PiControlInitializeDevice(%p)\n", ControlData);
214
215 Status = IopCaptureUnicodeString(&DeviceInstance, &ControlData->DeviceInstance);
216 if (!NT_SUCCESS(Status))
217 {
218 return Status;
219 }
220
221 DPRINT("Device: %wZ\n", &DeviceInstance);
222
223 /* Leave, if the device already exists */
225 if (DeviceObject != NULL)
226 {
227 DPRINT1("Device %wZ already exists!\n", &DeviceInstance);
230 goto done;
231 }
232
233 DPRINT("Device %wZ does not exist!\n", &DeviceInstance);
234
235 /* Create a device node for the device instance */
237 if (!NT_SUCCESS(Status))
238 {
239 DPRINT1("IoCreateDevice() failed (Status 0x%08lx)\n", Status);
240 goto done;
241 }
242
243 /* Allocate a new device node */
245 if (DeviceNode == NULL)
246 {
247 DPRINT1("Failed to allocate a device node!\n");
250 goto done;
251 }
252
253 // Set the device instance of the device node
254 // NOTE: a NULL-terminated string is required for PnpRootRegisterDevice
258 &DeviceNode->InstancePath);
259 if (!NT_SUCCESS(Status))
260 {
261 DPRINT1("RtlDuplicateUnicodeString() failed (Status 0x%08lx)\n", Status);
264 goto done;
265 }
266
270
272 if (!NT_SUCCESS(Status))
273 {
274 DPRINT1("Failed to create the instance key! (Status %lx)\n", Status);
277 goto done;
278 }
279
280 /* Write the resource information to the registry */
282
283 // Finish the root device registration
285
286 /* Insert as a root enumerated device node */
288
289 IopQueueTargetDeviceEvent(&GUID_DEVICE_ENUMERATED, &DeviceInstance);
290
291 ZwClose(InstanceKey);
292done:
294
295 return Status;
296}
297
298
299/*
300 * Remove the current PnP event from the tail of the event queue
301 * and signal IopPnpNotifyEvent if there is yet another event in the queue.
302 */
303static
307{
308 /* Remove a pnp event entry from the tail of the queue */
310 {
312 }
313
314 /* Signal the next pnp event in the queue */
316 {
318 0,
319 FALSE);
320 }
321
322 return STATUS_SUCCESS;
323}
324
325
326static NTSTATUS
328{
333 GUID FilterGuid;
334 PZZWSTR SymbolicLinkList = NULL, LinkList;
336
338 {
340
341 ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
342 RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
343
344 if (StackList.Buffer != NULL && StackList.BufferSize != 0)
345 {
346 ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
347 }
348 }
350 {
352 }
353 _SEH2_END;
354
356 if (NT_SUCCESS(Status))
357 {
358 /* Get the device object */
360 if (DeviceInstance.Buffer != NULL)
361 {
363 }
364 }
365
368
369 if (!NT_SUCCESS(Status))
370 {
371 /* failed */
372 return Status;
373 }
374
375 LinkList = SymbolicLinkList;
377 {
379 }
380 TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
381
383 {
384 if (StackList.Buffer != NULL &&
385 StackList.BufferSize >= TotalLength)
386 {
387 // We've already probed the buffer for writing above.
388 RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
389 }
390
391 DeviceList->BufferSize = TotalLength;
392 }
394 {
395 ExFreePool(LinkList);
397 }
398 _SEH2_END;
399
400 ExFreePool(LinkList);
401 return STATUS_SUCCESS;
402}
403
404static NTSTATUS
406{
415
416 DPRINT("IopGetDeviceProperty() called\n");
417 DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
418
420 if (!NT_SUCCESS(Status))
421 {
422 return Status;
423 }
424
426 {
427 Property = PropertyData->Property;
428 BufferSize = PropertyData->BufferSize;
431 sizeof(UCHAR));
432 }
434 {
435 if (DeviceInstance.Buffer != NULL)
436 {
438 }
440 }
441 _SEH2_END;
442
443 /* Get the device object */
445 if (DeviceInstance.Buffer != NULL)
446 {
448 }
449 if (DeviceObject == NULL)
450 {
452 }
453
455 if (Buffer == NULL)
456 {
459 }
460
461
462 DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
463
465 {
466 if (BufferSize < sizeof(CM_POWER_DATA))
467 {
468 BufferSize = 0;
470 }
471 else
472 {
474 PCM_POWER_DATA PowerData;
477
478 PowerData = (PCM_POWER_DATA)Buffer;
479 RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA));
480 PowerData->PD_Size = sizeof(CM_POWER_DATA);
481
484 DeviceCapabilities.Version = 1;
485 DeviceCapabilities.Address = -1;
486 DeviceCapabilities.UINumber = -1;
487
488 Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities;
489
493 &Stack);
494 if (NT_SUCCESS(Status))
495 {
496 DPRINT("Got device capabiliities\n");
497
498 PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME
499 if (DeviceCapabilities.DeviceD1)
501 if (DeviceCapabilities.DeviceD2)
503 if (DeviceCapabilities.WakeFromD0)
505 if (DeviceCapabilities.WakeFromD1)
507 if (DeviceCapabilities.WakeFromD2)
509 if (DeviceCapabilities.WakeFromD3)
511 if (DeviceCapabilities.WarmEjectSupported)
513 PowerData->PD_D1Latency = DeviceCapabilities.D1Latency;
514 PowerData->PD_D2Latency = DeviceCapabilities.D2Latency;
515 PowerData->PD_D3Latency = DeviceCapabilities.D3Latency;
517 &DeviceCapabilities.DeviceState,
518 sizeof(DeviceCapabilities.DeviceState));
519 PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake;
520 }
521 else
522 {
523 DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status);
524
527 }
528 }
529 }
531 {
533 BufferSize = 0;
535 }
537 {
538 if (BufferSize < sizeof(DeviceNode->HardwareRemovalPolicy))
539 {
540 BufferSize = 0;
542 }
543 else
544 {
545 BufferSize = sizeof(DeviceNode->HardwareRemovalPolicy);
547 &DeviceNode->HardwareRemovalPolicy,
548 BufferSize);
549 }
550 }
551 else
552 {
553 switch (Property)
554 {
557 break;
558
561 break;
562
565 break;
566
569 break;
570
573 break;
574
577 break;
578
581 break;
582
585 break;
586
589 break;
590
591#if (WINVER >= _WIN32_WINNT_WS03)
594 BufferSize = 0;
596 break;
597#endif
598
599#if (WINVER >= _WIN32_WINNT_WIN7)
602 break;
603#endif
604
605 default:
606 BufferSize = 0;
608 break;
609 }
610
611 if (Status == STATUS_SUCCESS)
612 {
616 Buffer,
617 &BufferSize);
618 }
619 }
620
622
623 if (NT_SUCCESS(Status))
624 {
626 {
628 PropertyData->BufferSize = BufferSize;
629 }
631 {
633 }
634 _SEH2_END;
635 }
636
638 return Status;
639}
640
641
642static NTSTATUS
644{
645 UNICODE_STRING RootDeviceName;
648 PDEVICE_NODE RelatedDeviceNode;
649 UNICODE_STRING TargetDeviceInstance;
651 ULONG Relation = 0;
653
654 DPRINT("IopGetRelatedDevice() called\n");
655 DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
656
657 Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
658 if (!NT_SUCCESS(Status))
659 {
660 return Status;
661 }
662
664 {
665 Relation = RelatedDeviceData->Relation;
666 MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
667 ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
669 sizeof(WCHAR));
670 }
672 {
673 if (TargetDeviceInstance.Buffer != NULL)
674 {
675 ExFreePool(TargetDeviceInstance.Buffer);
676 }
678 }
679 _SEH2_END;
680
681 RtlInitUnicodeString(&RootDeviceName,
682 L"HTREE\\ROOT\\0");
683 if (RtlEqualUnicodeString(&TargetDeviceInstance,
684 &RootDeviceName,
685 TRUE))
686 {
688 if (TargetDeviceInstance.Buffer != NULL)
689 {
690 ExFreePool(TargetDeviceInstance.Buffer);
691 }
692 }
693 else
694 {
695 /* Get the device object */
696 DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
697 if (TargetDeviceInstance.Buffer != NULL)
698 {
699 ExFreePool(TargetDeviceInstance.Buffer);
700 }
701 if (DeviceObject == NULL)
703
704 DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
705 }
706
707 switch (Relation)
708 {
710 RelatedDeviceNode = DeviceNode->Parent;
711 break;
712
714 RelatedDeviceNode = DeviceNode->Child;
715 break;
716
718 RelatedDeviceNode = DeviceNode->Sibling;
719 break;
720
721 default:
722 if (DeviceObject != NULL)
723 {
725 }
726
728 }
729
730 if (RelatedDeviceNode == NULL)
731 {
732 if (DeviceObject)
733 {
735 }
736
738 }
739
740 if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
741 {
742 if (DeviceObject)
743 {
745 }
746
748 }
749
750 /* Copy related device instance name */
752 {
753 RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
754 RelatedDeviceNode->InstancePath.Buffer,
755 RelatedDeviceNode->InstancePath.Length);
756 RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
757 }
759 {
761 }
762 _SEH2_END;
763
764 if (DeviceObject != NULL)
765 {
767 }
768
769 DPRINT("IopGetRelatedDevice() done\n");
770
771 return Status;
772}
773
774static
778{
779 return (DeviceNode->State == DeviceNodeStartPending ||
782 DeviceNode->State == DeviceNodeStarted ||
786 DeviceNode->State == DeviceNodeStopped ||
788}
789
790static ULONG
792{
794
795 if (DeviceNode->Parent == IopRootDeviceNode)
797
798 // FIXME: review for deleted and removed states
801
804
805 if (DeviceNode->UserFlags & DNUF_WILL_BE_REMOVED)
807
808 if (DeviceNode->Flags & DNF_HAS_PROBLEM)
810
813
814 if (DeviceNode->Flags & DNF_DRIVER_BLOCKED)
816
819
822
823 if (DeviceNode->Flags & DNF_LEGACY_DRIVER)
825
826 if (DeviceNode->UserFlags & DNUF_DONT_SHOW_IN_UI)
828
829 if (!(DeviceNode->UserFlags & DNUF_NOT_DISABLEABLE))
831
832 return Output;
833}
834
835static NTSTATUS
837{
840 ULONG Operation = 0;
841 ULONG DeviceStatus = 0;
842 ULONG DeviceProblem = 0;
845
846 DPRINT("IopDeviceStatus() called\n");
847
849 if (!NT_SUCCESS(Status))
850 {
851 return Status;
852 }
853
854 DPRINT("Device name: '%wZ'\n", &DeviceInstance);
855
857 {
858 Operation = StatusData->Operation;
860 {
861 DeviceStatus = StatusData->DeviceStatus;
862 DeviceProblem = StatusData->DeviceProblem;
863 }
864 }
866 {
867 if (DeviceInstance.Buffer != NULL)
868 {
870 }
872 }
873 _SEH2_END;
874
875 /* Get the device object */
877 if (DeviceInstance.Buffer != NULL)
878 {
880 }
881 if (DeviceObject == NULL)
882 {
884 }
885
887
888 switch (Operation)
889 {
891 DPRINT("Get status data\n");
892 DeviceStatus = IopGetDeviceNodeStatus(DeviceNode);
893 DeviceProblem = DeviceNode->Problem;
894 break;
895
897 DPRINT1("Set status data is NOT SUPPORTED\n");
898 break;
899
901 DPRINT1("FIXME: Clear status data!\n");
902 break;
903 }
904
906
908 {
910 {
911 StatusData->DeviceStatus = DeviceStatus;
912 StatusData->DeviceProblem = DeviceProblem;
913 }
915 {
917 }
918 _SEH2_END;
919 }
920
921 return Status;
922}
923
924static
927{
932 PDEVICE_RELATIONS DeviceRelations = NULL;
933 PDEVICE_OBJECT ChildDeviceObject;
934 PDEVICE_NODE ChildDeviceNode;
935 ULONG i;
936 ULONG Relations;
938 ULONG BufferLeft;
941
942 DPRINT("IopGetDeviceRelations() called\n");
943 DPRINT("Device name: %wZ\n", &RelationsData->DeviceInstance);
944 DPRINT("Relations: %lu\n", RelationsData->Relations);
945 DPRINT("BufferSize: %lu\n", RelationsData->BufferSize);
946 DPRINT("Buffer: %p\n", RelationsData->Buffer);
947
949 {
950 Relations = RelationsData->Relations;
951 BufferSize = RelationsData->BufferSize;
952 Buffer = RelationsData->Buffer;
953
955 }
957 {
959 }
960 _SEH2_END;
961
963 if (!NT_SUCCESS(Status))
964 {
965 DPRINT1("IopCaptureUnicodeString() failed (Status 0x%08lx)\n", Status);
966 return Status;
967 }
968
969 /* Get the device object */
971 if (DeviceObject == NULL)
972 {
973 DPRINT1("IopGetDeviceObjectFromDeviceInstance() returned NULL\n");
975 goto done;
976 }
977
978 switch (Relations)
979 {
981 Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations;
982 break;
983
985 Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations;
986 break;
987
989 Stack.Parameters.QueryDeviceRelations.Type = PowerRelations;
990 break;
991
993 Stack.Parameters.QueryDeviceRelations.Type = BusRelations;
994 break;
995
996 default:
998 goto done;
999 }
1000
1004 &Stack);
1005 if (!NT_SUCCESS(Status))
1006 {
1007 DPRINT1("IopInitiatePnpIrp() failed (Status 0x%08lx)\n", Status);
1008 goto done;
1009 }
1010
1011 DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
1012
1013 DPRINT("Found %d device relations\n", DeviceRelations->Count);
1014
1015 _SEH2_TRY
1016 {
1017 RequiredSize = 0;
1018 BufferLeft = BufferSize;
1019 Ptr = Buffer;
1020
1021 for (i = 0; i < DeviceRelations->Count; i++)
1022 {
1023 ChildDeviceObject = DeviceRelations->Objects[i];
1024
1025 ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
1026 if (ChildDeviceNode)
1027 {
1028 DPRINT("Device instance: %wZ\n", &ChildDeviceNode->InstancePath);
1029 DPRINT("RequiredSize: %hu\n", ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1030
1031 if (Ptr != NULL)
1032 {
1033 if (BufferLeft < ChildDeviceNode->InstancePath.Length + 2 * sizeof(WCHAR))
1034 {
1036 break;
1037 }
1038
1040 ChildDeviceNode->InstancePath.Buffer,
1041 ChildDeviceNode->InstancePath.Length);
1042 Ptr = (PWCHAR)((ULONG_PTR)Ptr + ChildDeviceNode->InstancePath.Length);
1043 *Ptr = UNICODE_NULL;
1044 Ptr = (PWCHAR)((ULONG_PTR)Ptr + sizeof(WCHAR));
1045
1046 BufferLeft -= (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1047 }
1048
1049 RequiredSize += (ChildDeviceNode->InstancePath.Length + sizeof(WCHAR));
1050 }
1051 }
1052
1053 if (Ptr != NULL && BufferLeft >= sizeof(WCHAR))
1054 *Ptr = UNICODE_NULL;
1055
1056 if (RequiredSize > 0)
1057 RequiredSize += sizeof(WCHAR);
1058
1059 DPRINT("BufferSize: %lu RequiredSize: %lu\n", RelationsData->BufferSize, RequiredSize);
1060
1061 RelationsData->BufferSize = RequiredSize;
1062 }
1064 {
1066 }
1067 _SEH2_END;
1068
1069done:
1070 if (DeviceRelations != NULL)
1071 ExFreePool(DeviceRelations);
1072
1073 if (DeviceObject != NULL)
1075
1076 if (DeviceInstance.Buffer != NULL)
1077 ExFreePool(DeviceInstance.Buffer);
1078
1079 return Status;
1080}
1081
1082static NTSTATUS
1084{
1089
1090 DPRINT("IopGetDeviceDepth() called\n");
1091 DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
1092
1094 if (!NT_SUCCESS(Status))
1095 {
1096 return Status;
1097 }
1098
1099 /* Get the device object */
1101 if (DeviceInstance.Buffer != NULL)
1102 {
1103 ExFreePool(DeviceInstance.Buffer);
1104 }
1105 if (DeviceObject == NULL)
1106 {
1107 return STATUS_NO_SUCH_DEVICE;
1108 }
1109
1111
1112 _SEH2_TRY
1113 {
1114 DepthData->Depth = DeviceNode->Level;
1115 }
1117 {
1119 }
1120 _SEH2_END;
1121
1123
1124 return Status;
1125}
1126
1127static
1132{
1136
1140
1142 if (!NT_SUCCESS(Status))
1143 {
1144 return Status;
1145 }
1146
1148 if (DeviceInstance.Buffer != NULL)
1149 {
1150 ExFreePool(DeviceInstance.Buffer);
1151 }
1152 if (DeviceObject == NULL)
1153 {
1154 return STATUS_NO_SUCH_DEVICE;
1155 }
1156
1158
1159 switch (ControlClass)
1160 {
1163 break;
1166 break;
1169 break;
1170 default:
1172 break;
1173 }
1174
1176
1178
1179 return Status;
1180}
1181
1182static
1186{
1190
1191 Status = IopCaptureUnicodeString(&DeviceInstance, &ControlData->DeviceInstance);
1192 if (!NT_SUCCESS(Status))
1193 {
1194 return Status;
1195 }
1196
1198 if (DeviceInstance.Buffer != NULL)
1199 {
1200 ExFreePool(DeviceInstance.Buffer);
1201 }
1202 if (DeviceObject == NULL)
1203 {
1204 return STATUS_NO_SUCH_DEVICE;
1205 }
1206
1209
1211
1212 return Status;
1213}
1214
1215/* PUBLIC FUNCTIONS **********************************************************/
1216
1217/*
1218 * Plug and Play event structure used by NtGetPlugPlayEvent.
1219 *
1220 * EventGuid
1221 * Can be one of the following values:
1222 * GUID_HWPROFILE_QUERY_CHANGE
1223 * GUID_HWPROFILE_CHANGE_CANCELLED
1224 * GUID_HWPROFILE_CHANGE_COMPLETE
1225 * GUID_TARGET_DEVICE_QUERY_REMOVE
1226 * GUID_TARGET_DEVICE_REMOVE_CANCELLED
1227 * GUID_TARGET_DEVICE_REMOVE_COMPLETE
1228 * GUID_PNP_CUSTOM_NOTIFICATION
1229 * GUID_PNP_POWER_NOTIFICATION
1230 * GUID_DEVICE_* (see above)
1231 *
1232 * EventCategory
1233 * Type of the event that happened.
1234 *
1235 * Result
1236 * ?
1237 *
1238 * Flags
1239 * ?
1240 *
1241 * TotalSize
1242 * Size of the event block including the device IDs and other
1243 * per category specific fields.
1244 */
1245
1246/*
1247 * NtGetPlugPlayEvent
1248 *
1249 * Returns one Plug & Play event from a global queue.
1250 *
1251 * Parameters
1252 * Reserved1
1253 * Reserved2
1254 * Always set to zero.
1255 *
1256 * Buffer
1257 * The buffer that will be filled with the event information on
1258 * successful return from the function.
1259 *
1260 * BufferSize
1261 * Size of the buffer pointed by the Buffer parameter. If the
1262 * buffer size is not large enough to hold the whole event
1263 * information, error STATUS_BUFFER_TOO_SMALL is returned and
1264 * the buffer remains untouched.
1265 *
1266 * Return Values
1267 * STATUS_PRIVILEGE_NOT_HELD
1268 * STATUS_BUFFER_TOO_SMALL
1269 * STATUS_SUCCESS
1270 *
1271 * Remarks
1272 * This function isn't multi-thread safe!
1273 *
1274 * @implemented
1275 */
1277NTAPI
1282{
1285
1286 DPRINT("NtGetPlugPlayEvent() called\n");
1287
1288 /* Function can only be called from user-mode */
1290 {
1291 DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1292 return STATUS_ACCESS_DENIED;
1293 }
1294
1295 /* Check for Tcb privilege */
1297 UserMode))
1298 {
1299 DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1301 }
1302
1303 /* Wait for a PnP event */
1304 DPRINT("Waiting for pnp notification event\n");
1307 UserMode,
1308 FALSE,
1309 NULL);
1311 {
1312 DPRINT("KeWaitForSingleObject() failed (Status %lx)\n", Status);
1314 return Status;
1315 }
1316
1317 /* Get entry from the tail of the queue */
1320 ListEntry);
1321
1322 /* Check the buffer size */
1323 if (BufferSize < Entry->Event.TotalSize)
1324 {
1325 DPRINT1("Buffer is too small for the pnp-event\n");
1327 }
1328
1329 /* Copy event data to the user buffer */
1330 _SEH2_TRY
1331 {
1333 Entry->Event.TotalSize,
1334 sizeof(UCHAR));
1336 &Entry->Event,
1337 Entry->Event.TotalSize);
1338 }
1340 {
1342 }
1343 _SEH2_END;
1344
1345 DPRINT("NtGetPlugPlayEvent() done\n");
1346
1347 return STATUS_SUCCESS;
1348}
1349
1350/*
1351 * NtPlugPlayControl
1352 *
1353 * A function for doing various Plug & Play operations from user mode.
1354 *
1355 * Parameters
1356 * PlugPlayControlClass
1357 * 0x00 Reenumerate device tree
1358 *
1359 * Buffer points to UNICODE_STRING decribing the instance
1360 * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
1361 * more information about instance paths see !devnode command
1362 * in kernel debugger or look at "Inside Windows 2000" book,
1363 * chapter "Driver Loading, Initialization, and Installation".
1364 *
1365 * 0x01 Register new device
1366 * 0x02 Deregister device
1367 * 0x03 Initialize device
1368 * 0x04 Start device
1369 * 0x06 Query and remove device
1370 * 0x07 User response
1371 *
1372 * Called after processing the message from NtGetPlugPlayEvent.
1373 *
1374 * 0x08 Generate legacy device
1375 * 0x09 Get interface device list
1376 * 0x0A Get property data
1377 * 0x0B Device class association (Registration)
1378 * 0x0C Get related device
1379 * 0x0D Get device interface alias
1380 * 0x0E Get/set/clear device status
1381 * 0x0F Get device depth
1382 * 0x10 Query device relations
1383 * 0x11 Query target device relation
1384 * 0x12 Query conflict list
1385 * 0x13 Retrieve dock data
1386 * 0x14 Reset device
1387 * 0x15 Halt device
1388 * 0x16 Get blocked driver data
1389 *
1390 * Buffer
1391 * The buffer contains information that is specific to each control
1392 * code. The buffer is read-only.
1393 *
1394 * BufferSize
1395 * Size of the buffer pointed by the Buffer parameter. If the
1396 * buffer size specifies incorrect value for specified control
1397 * code, error ??? is returned.
1398 *
1399 * Return Values
1400 * STATUS_PRIVILEGE_NOT_HELD
1401 * STATUS_SUCCESS
1402 * ...
1403 *
1404 * @unimplemented
1405 */
1407NTAPI
1411{
1412 DPRINT("NtPlugPlayControl(%d %p %lu) called\n",
1413 PlugPlayControlClass, Buffer, BufferLength);
1414
1415 /* Function can only be called from user-mode */
1417 {
1418 DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
1419 return STATUS_ACCESS_DENIED;
1420 }
1421
1422 /* Check for Tcb privilege */
1424 UserMode))
1425 {
1426 DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
1428 }
1429
1430 /* Probe the buffer */
1431 _SEH2_TRY
1432 {
1435 sizeof(ULONG));
1436 }
1438 {
1440 }
1441 _SEH2_END;
1442
1443 switch (PlugPlayControlClass)
1444 {
1448 // the Flags field is not used anyway
1450 PlugPlayControlClass);
1451
1452// case PlugPlayControlRegisterNewDevice:
1453// case PlugPlayControlDeregisterDevice:
1454
1459
1465 PlugPlayControlClass);
1466
1467// case PlugPlayControlUnlockDevice:
1472
1477
1478// case PlugPlayControlGenerateLegacyDevice:
1479
1484
1489
1490// case PlugPlayControlDeviceClassAssociation:
1491
1496
1497// case PlugPlayControlGetInterfaceDeviceAlias:
1498
1503
1508
1513
1514// case PlugPlayControlTargetDeviceRelation:
1515// case PlugPlayControlQueryConflictList:
1516// case PlugPlayControlRetrieveDock:
1517// case PlugPlayControlHaltDevice:
1518// case PlugPlayControlGetBlockedDriverList:
1519
1520 default:
1522 }
1523
1525}
#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 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
#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:1115
#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
#define DNF_ENUMERATED
Definition: iotypes.h:174
@ DeviceNodeDriversAdded
Definition: iotypes.h:424
@ DeviceNodeStopped
Definition: iotypes.h:431
@ DeviceNodeRestartCompletion
Definition: iotypes.h:432
@ DeviceNodeInitialized
Definition: iotypes.h:423
@ DeviceNodeStartPostWork
Definition: iotypes.h:428
@ DeviceNodeStarted
Definition: iotypes.h:429
@ DeviceNodeStartCompletion
Definition: iotypes.h:427
@ DeviceNodeEnumerateCompletion
Definition: iotypes.h:434
@ DeviceNodeEnumeratePending
Definition: iotypes.h:433
@ DeviceNodeQueryStopped
Definition: iotypes.h:430
@ DeviceNodeStartPending
Definition: iotypes.h:426
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 DNF_IDS_QUERIED
Definition: iotypes.h:175
#define DNF_MADEUP
Definition: iotypes.h:170
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
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 REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#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)
NTSTATUS NTAPI IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath, IN ULONG CreateOptions, OUT PHANDLE Handle)
Definition: pnpmgr.c:522
#define IopInitDeviceTreeTraverseContext( _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context)
Definition: io.h:229
NTSTATUS PnpRootRegisterDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pnproot.c:107
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)
PNP_DEVNODE_STATE PiSetDevNodeState(_In_ PDEVICE_NODE DeviceNode, _In_ PNP_DEVNODE_STATE NewState)
Definition: devnode.c:108
enum _DEVICE_ACTION DEVICE_ACTION
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
NTSTATUS PnpRootCreateDeviceObject(OUT PDEVICE_OBJECT *DeviceObject)
Definition: pnproot.c:167
const LUID SeTcbPrivilege
Definition: priv.c:26
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:776
static NTSTATUS IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
Definition: plugplay.c:643
NTSTATUS IopQueueTargetDeviceEvent(const GUID *Guid, PUNICODE_STRING DeviceIds)
Definition: plugplay.c:52
NTSTATUS IopInitPlugPlayEvents(VOID)
Definition: plugplay.c:40
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
Definition: plugplay.c:121
static NTSTATUS PiControlQueryRemoveDevice(_In_ PPLUGPLAY_CONTROL_QUERY_REMOVE_DATA ControlData)
Definition: plugplay.c:1184
static NTSTATUS IopRemovePlugPlayEvent(_In_ PPLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData)
Definition: plugplay.c:305
NTSTATUS IopSetDeviceInstanceData(HANDLE InstanceKey, PDEVICE_NODE DeviceNode)
Definition: pnpmgr.c:606
static NTSTATUS IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
Definition: plugplay.c:155
static NTSTATUS IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
Definition: plugplay.c:836
struct _PNP_EVENT_ENTRY * PPNP_EVENT_ENTRY
static ULONG IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode)
Definition: plugplay.c:791
NTSTATUS IopFindDeviceInstanceTraverse(_In_ PDEVICE_NODE DeviceNode, _Inout_ PVOID Context)
Definition: plugplay.c:101
static NTSTATUS IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
Definition: plugplay.c:327
static NTSTATUS IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
Definition: plugplay.c:1083
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:1278
static NTSTATUS PiControlSyncDeviceAction(_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceData, _In_ PLUGPLAY_CONTROL_CLASS ControlClass)
Definition: plugplay.c:1129
struct _IOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT * PIOP_FIND_DEVICE_INSTANCE_TRAVERSE_CONTEXT
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1408
static NTSTATUS IopGetDeviceRelations(PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData)
Definition: plugplay.c:926
static NTSTATUS IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
Definition: plugplay.c:405
static NTSTATUS PiControlInitializeDevice(_In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ControlData)
Definition: plugplay.c:204
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:1382
#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:892
UNICODE_STRING InstancePath
Definition: iotypes.h:895
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
struct _PLUGPLAY_EVENT_BLOCK::@2380::@2383 TargetDevice
PLUGPLAY_EVENT_CATEGORY EventCategory
Definition: cmtypes.h:406
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
#define DO_BUS_ENUMERATED_DEVICE
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:421
#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