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>
9 /* INCLUDES *****************************************************************/
15 #if defined (ALLOC_PRAGMA)
16 #pragma alloc_text(INIT, IopInitPlugPlayEvents)
19 typedef struct _PNP_EVENT_ENTRY
22 PLUGPLAY_EVENT_BLOCK Event
;
23 } PNP_EVENT_ENTRY
, *PPNP_EVENT_ENTRY
;
26 /* GLOBALS *******************************************************************/
28 static LIST_ENTRY IopPnpEventQueueHead
;
29 static KEVENT IopPnpNotifyEvent
;
31 /* FUNCTIONS *****************************************************************/
33 NTSTATUS INIT_FUNCTION
34 IopInitPlugPlayEvents(VOID
)
36 InitializeListHead(&IopPnpEventQueueHead
);
38 KeInitializeEvent(&IopPnpNotifyEvent
,
42 return STATUS_SUCCESS
;
46 IopQueueTargetDeviceEvent(const GUID
*Guid
,
47 PUNICODE_STRING DeviceIds
)
49 PPNP_EVENT_ENTRY EventEntry
;
56 /* Allocate a big enough buffer */
58 Copy
.MaximumLength
= DeviceIds
->Length
+ sizeof(UNICODE_NULL
);
60 FIELD_OFFSET(PLUGPLAY_EVENT_BLOCK
, TargetDevice
.DeviceIds
) +
63 EventEntry
= ExAllocatePool(NonPagedPool
,
64 TotalSize
+ FIELD_OFFSET(PNP_EVENT_ENTRY
, Event
));
66 return STATUS_INSUFFICIENT_RESOURCES
;
68 /* Fill the buffer with the event GUID */
69 RtlCopyMemory(&EventEntry
->Event
.EventGuid
,
72 EventEntry
->Event
.EventCategory
= TargetDeviceChangeEvent
;
73 EventEntry
->Event
.TotalSize
= TotalSize
;
75 /* Fill the device id */
76 Copy
.Buffer
= EventEntry
->Event
.TargetDevice
.DeviceIds
;
77 Status
= RtlAppendUnicodeStringToString(&Copy
, DeviceIds
);
78 if (!NT_SUCCESS(Status
))
81 InsertHeadList(&IopPnpEventQueueHead
,
82 &EventEntry
->ListEntry
);
83 KeSetEvent(&IopPnpNotifyEvent
,
87 return STATUS_SUCCESS
;
92 * Remove the current PnP event from the tail of the event queue
93 * and signal IopPnpNotifyEvent if there is yet another event in the queue.
96 IopRemovePlugPlayEvent(VOID
)
98 /* Remove a pnp event entry from the tail of the queue */
99 if (!IsListEmpty(&IopPnpEventQueueHead
))
101 ExFreePool(CONTAINING_RECORD(RemoveTailList(&IopPnpEventQueueHead
), PNP_EVENT_ENTRY
, ListEntry
));
104 /* Signal the next pnp event in the queue */
105 if (!IsListEmpty(&IopPnpEventQueueHead
))
107 KeSetEvent(&IopPnpNotifyEvent
,
112 return STATUS_SUCCESS
;
115 static PDEVICE_OBJECT
116 IopTraverseDeviceNode(PDEVICE_NODE Node
, PUNICODE_STRING DeviceInstance
)
118 PDEVICE_OBJECT DeviceObject
;
119 PDEVICE_NODE ChildNode
;
121 if (RtlEqualUnicodeString(&Node
->InstancePath
,
122 DeviceInstance
, TRUE
))
124 ObReferenceObject(Node
->PhysicalDeviceObject
);
125 return Node
->PhysicalDeviceObject
;
128 /* Traversal of all children nodes */
129 for (ChildNode
= Node
->Child
;
131 ChildNode
= ChildNode
->Sibling
)
133 DeviceObject
= IopTraverseDeviceNode(ChildNode
, DeviceInstance
);
134 if (DeviceObject
!= NULL
)
145 IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance
)
147 if (IopRootDeviceNode
== NULL
)
150 if (DeviceInstance
== NULL
||
151 DeviceInstance
->Length
== 0)
153 if (IopRootDeviceNode
->PhysicalDeviceObject
)
155 ObReferenceObject(IopRootDeviceNode
->PhysicalDeviceObject
);
156 return IopRootDeviceNode
->PhysicalDeviceObject
;
162 return IopTraverseDeviceNode(IopRootDeviceNode
, DeviceInstance
);
167 IopCaptureUnicodeString(PUNICODE_STRING DstName
, PUNICODE_STRING SrcName
)
169 NTSTATUS Status
= STATUS_SUCCESS
;
170 volatile UNICODE_STRING Name
;
175 Name
.Length
= SrcName
->Length
;
176 Name
.MaximumLength
= SrcName
->MaximumLength
;
177 if (Name
.Length
> Name
.MaximumLength
)
179 Status
= STATUS_INVALID_PARAMETER
;
183 if (Name
.MaximumLength
)
185 ProbeForRead(SrcName
->Buffer
,
188 Name
.Buffer
= ExAllocatePool(NonPagedPool
, Name
.MaximumLength
);
189 if (Name
.Buffer
== NULL
)
191 Status
= STATUS_INSUFFICIENT_RESOURCES
;
195 memcpy(Name
.Buffer
, SrcName
->Buffer
, Name
.MaximumLength
);
200 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
203 ExFreePool(Name
.Buffer
);
204 Status
= _SEH2_GetExceptionCode();
212 IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData
)
214 PDEVICE_OBJECT DeviceObject
= NULL
;
216 UNICODE_STRING DeviceInstance
;
221 DPRINT("IopGetDeviceProperty() called\n");
222 DPRINT("Device name: %wZ\n", &PropertyData
->DeviceInstance
);
224 Status
= IopCaptureUnicodeString(&DeviceInstance
, &PropertyData
->DeviceInstance
);
225 if (!NT_SUCCESS(Status
))
232 Property
= PropertyData
->Property
;
233 BufferSize
= PropertyData
->BufferSize
;
234 ProbeForWrite(PropertyData
->Buffer
,
238 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
240 ExFreePool(DeviceInstance
.Buffer
);
241 _SEH2_YIELD(return _SEH2_GetExceptionCode());
245 /* Get the device object */
246 DeviceObject
= IopGetDeviceObjectFromDeviceInstance(&DeviceInstance
);
247 ExFreePool(DeviceInstance
.Buffer
);
248 if (DeviceObject
== NULL
)
250 return STATUS_NO_SUCH_DEVICE
;
253 Buffer
= ExAllocatePool(NonPagedPool
, BufferSize
);
256 return STATUS_INSUFFICIENT_RESOURCES
;
259 Status
= IoGetDeviceProperty(DeviceObject
,
265 ObDereferenceObject(DeviceObject
);
267 if (NT_SUCCESS(Status
))
271 memcpy(PropertyData
->Buffer
, Buffer
, BufferSize
);
272 PropertyData
->BufferSize
= BufferSize
;
274 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
276 Status
= _SEH2_GetExceptionCode();
287 IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData
)
289 UNICODE_STRING RootDeviceName
;
290 PDEVICE_OBJECT DeviceObject
= NULL
;
291 PDEVICE_NODE DeviceNode
= NULL
;
292 PDEVICE_NODE RelatedDeviceNode
;
293 UNICODE_STRING TargetDeviceInstance
;
294 NTSTATUS Status
= STATUS_SUCCESS
;
296 ULONG MaximumLength
= 0;
298 DPRINT("IopGetRelatedDevice() called\n");
299 DPRINT("Device name: %wZ\n", &RelatedDeviceData
->TargetDeviceInstance
);
301 Status
= IopCaptureUnicodeString(&TargetDeviceInstance
, &RelatedDeviceData
->TargetDeviceInstance
);
302 if (!NT_SUCCESS(Status
))
309 Relation
= RelatedDeviceData
->Relation
;
310 MaximumLength
= RelatedDeviceData
->RelatedDeviceInstanceLength
;
311 ProbeForWrite(RelatedDeviceData
->RelatedDeviceInstance
,
315 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
317 ExFreePool(TargetDeviceInstance
.Buffer
);
318 _SEH2_YIELD(return _SEH2_GetExceptionCode());
322 RtlInitUnicodeString(&RootDeviceName
,
324 if (RtlEqualUnicodeString(&TargetDeviceInstance
,
328 DeviceNode
= IopRootDeviceNode
;
329 ExFreePool(TargetDeviceInstance
.Buffer
);
333 /* Get the device object */
334 DeviceObject
= IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance
);
335 ExFreePool(TargetDeviceInstance
.Buffer
);
336 if (DeviceObject
== NULL
)
337 return STATUS_NO_SUCH_DEVICE
;
339 DeviceNode
= ((PEXTENDED_DEVOBJ_EXTENSION
)DeviceObject
->DeviceObjectExtension
)->DeviceNode
;
344 case PNP_GET_PARENT_DEVICE
:
345 RelatedDeviceNode
= DeviceNode
->Parent
;
348 case PNP_GET_CHILD_DEVICE
:
349 RelatedDeviceNode
= DeviceNode
->Child
;
352 case PNP_GET_SIBLING_DEVICE
:
353 RelatedDeviceNode
= DeviceNode
->Sibling
;
357 if (DeviceObject
!= NULL
)
359 ObDereferenceObject(DeviceObject
);
362 return STATUS_INVALID_PARAMETER
;
365 if (RelatedDeviceNode
== NULL
)
369 ObDereferenceObject(DeviceObject
);
372 return STATUS_NO_SUCH_DEVICE
;
375 if (RelatedDeviceNode
->InstancePath
.Length
> MaximumLength
)
379 ObDereferenceObject(DeviceObject
);
382 return STATUS_BUFFER_TOO_SMALL
;
385 /* Copy related device instance name */
388 RtlCopyMemory(RelatedDeviceData
->RelatedDeviceInstance
,
389 RelatedDeviceNode
->InstancePath
.Buffer
,
390 RelatedDeviceNode
->InstancePath
.Length
);
391 RelatedDeviceData
->RelatedDeviceInstanceLength
= RelatedDeviceNode
->InstancePath
.Length
;
393 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
395 Status
= _SEH2_GetExceptionCode();
399 if (DeviceObject
!= NULL
)
401 ObDereferenceObject(DeviceObject
);
404 DPRINT("IopGetRelatedDevice() done\n");
410 IopGetDeviceNodeStatus(PDEVICE_NODE DeviceNode
)
414 if (DeviceNode
->Parent
== IopRootDeviceNode
)
415 Output
|= DN_ROOT_ENUMERATED
;
417 if (DeviceNode
->Flags
& DNF_ADDED
)
418 Output
|= DN_DRIVER_LOADED
;
420 /* FIXME: DN_ENUM_LOADED */
422 if (DeviceNode
->Flags
& DNF_STARTED
)
423 Output
|= DN_STARTED
;
427 if (!(DeviceNode
->Flags
& DNF_PROCESSED
))
428 Output
|= DN_NEED_TO_ENUM
;
430 /* DN_NOT_FIRST_TIME is 9x only */
432 /* FIXME: DN_HARDWARE_ENUM */
434 /* DN_LIAR and DN_HAS_MARK are 9x only */
436 if (DeviceNode
->Problem
!= 0)
437 Output
|= DN_HAS_PROBLEM
;
439 /* FIXME: DN_FILTERED */
441 if (DeviceNode
->Flags
& DNF_LEGACY_DRIVER
)
442 Output
|= DN_LEGACY_DRIVER
;
444 if (DeviceNode
->UserFlags
& DNUF_DONT_SHOW_IN_UI
)
445 Output
|= DN_NO_SHOW_IN_DM
;
447 if (!(DeviceNode
->UserFlags
& DNUF_NOT_DISABLEABLE
))
448 Output
|= DN_DISABLEABLE
;
450 /* FIXME: Implement the rest */
452 Output
|= DN_NT_ENUMERATOR
| DN_NT_DRIVER
;
458 IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData
)
460 PDEVICE_OBJECT DeviceObject
;
461 PDEVICE_NODE DeviceNode
;
463 ULONG DeviceStatus
= 0;
464 ULONG DeviceProblem
= 0;
465 UNICODE_STRING DeviceInstance
;
468 DPRINT("IopDeviceStatus() called\n");
470 Status
= IopCaptureUnicodeString(&DeviceInstance
, &StatusData
->DeviceInstance
);
471 if (!NT_SUCCESS(Status
))
473 DPRINT("Device name: '%wZ'\n", &DeviceInstance
);
477 Operation
= StatusData
->Operation
;
478 if (Operation
== PNP_SET_DEVICE_STATUS
)
480 DeviceStatus
= StatusData
->DeviceStatus
;
481 DeviceProblem
= StatusData
->DeviceProblem
;
484 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
486 if (DeviceInstance
.Buffer
) ExFreePool(DeviceInstance
.Buffer
);
487 _SEH2_YIELD(return _SEH2_GetExceptionCode());
491 /* Get the device object */
492 DeviceObject
= IopGetDeviceObjectFromDeviceInstance(&DeviceInstance
);
493 ExFreePool(DeviceInstance
.Buffer
);
494 if (DeviceObject
== NULL
)
495 return STATUS_NO_SUCH_DEVICE
;
497 DeviceNode
= IopGetDeviceNode(DeviceObject
);
501 case PNP_GET_DEVICE_STATUS
:
502 DPRINT("Get status data\n");
503 DeviceStatus
= IopGetDeviceNodeStatus(DeviceNode
);
504 DeviceProblem
= DeviceNode
->Problem
;
507 case PNP_SET_DEVICE_STATUS
:
508 DPRINT1("Set status data is NOT SUPPORTED\n");
511 case PNP_CLEAR_DEVICE_STATUS
:
512 DPRINT1("FIXME: Clear status data!\n");
516 ObDereferenceObject(DeviceObject
);
518 if (Operation
== PNP_GET_DEVICE_STATUS
)
522 StatusData
->DeviceStatus
= DeviceStatus
;
523 StatusData
->DeviceProblem
= DeviceProblem
;
525 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
527 Status
= _SEH2_GetExceptionCode();
537 IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData
)
539 PDEVICE_OBJECT DeviceObject
;
540 PDEVICE_NODE DeviceNode
;
541 UNICODE_STRING DeviceInstance
;
542 NTSTATUS Status
= STATUS_SUCCESS
;
544 DPRINT("IopGetDeviceDepth() called\n");
545 DPRINT("Device name: %wZ\n", &DepthData
->DeviceInstance
);
547 Status
= IopCaptureUnicodeString(&DeviceInstance
, &DepthData
->DeviceInstance
);
548 if (!NT_SUCCESS(Status
))
553 /* Get the device object */
554 DeviceObject
= IopGetDeviceObjectFromDeviceInstance(&DeviceInstance
);
555 ExFreePool(DeviceInstance
.Buffer
);
556 if (DeviceObject
== NULL
)
557 return STATUS_NO_SUCH_DEVICE
;
559 DeviceNode
= IopGetDeviceNode(DeviceObject
);
563 DepthData
->Depth
= DeviceNode
->Level
;
565 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
567 Status
= _SEH2_GetExceptionCode();
571 ObDereferenceObject(DeviceObject
);
578 IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData
)
580 PDEVICE_OBJECT DeviceObject
;
581 PDEVICE_NODE DeviceNode
;
582 NTSTATUS Status
= STATUS_SUCCESS
;
583 UNICODE_STRING DeviceInstance
;
585 Status
= IopCaptureUnicodeString(&DeviceInstance
, &ResetDeviceData
->DeviceInstance
);
586 if (!NT_SUCCESS(Status
))
589 DPRINT("IopResetDevice(%wZ)\n", &DeviceInstance
);
591 /* Get the device object */
592 DeviceObject
= IopGetDeviceObjectFromDeviceInstance(&DeviceInstance
);
593 ExFreePool(DeviceInstance
.Buffer
);
594 if (DeviceObject
== NULL
)
595 return STATUS_NO_SUCH_DEVICE
;
597 /* Get the device node */
598 DeviceNode
= IopGetDeviceNode(DeviceObject
);
600 ASSERT(DeviceNode
->Flags
& DNF_ENUMERATED
);
601 ASSERT(DeviceNode
->Flags
& DNF_PROCESSED
);
603 /* Check if there's already a driver loaded for this device */
604 if (DeviceNode
->Flags
& DNF_ADDED
)
607 /* Remove the device node */
608 Status
= IopRemoveDevice(DeviceNode
);
609 if (NT_SUCCESS(Status
))
611 /* Invalidate device relations for the parent to reenumerate the device */
612 DPRINT1("A new driver will be loaded for '%wZ' (FDO above removed)\n", &DeviceNode
->InstancePath
);
613 Status
= IoSynchronousInvalidateDeviceRelations(DeviceNode
->Parent
->PhysicalDeviceObject
, BusRelations
);
618 /* A driver has already been loaded for this device */
619 DPRINT1("A reboot is required for the current driver for '%wZ' to be replaced\n", &DeviceNode
->InstancePath
);
620 DeviceNode
->Problem
= CM_PROB_NEED_RESTART
;
625 /* FIXME: What if the device really is disabled? */
626 DeviceNode
->Flags
&= ~DNF_DISABLED
;
627 DeviceNode
->Problem
= 0;
629 /* Load service data from the registry */
630 Status
= IopActionConfigureChildServices(DeviceNode
, DeviceNode
->Parent
);
632 if (NT_SUCCESS(Status
))
634 /* Start the service and begin PnP initialization of the device again */
635 DPRINT1("A new driver will be loaded for '%wZ' (no FDO above)\n", &DeviceNode
->InstancePath
);
636 Status
= IopActionInitChildServices(DeviceNode
, DeviceNode
->Parent
);
640 ObDereferenceObject(DeviceObject
);
645 /* PUBLIC FUNCTIONS **********************************************************/
648 * Plug and Play event structure used by NtGetPlugPlayEvent.
651 * Can be one of the following values:
652 * GUID_HWPROFILE_QUERY_CHANGE
653 * GUID_HWPROFILE_CHANGE_CANCELLED
654 * GUID_HWPROFILE_CHANGE_COMPLETE
655 * GUID_TARGET_DEVICE_QUERY_REMOVE
656 * GUID_TARGET_DEVICE_REMOVE_CANCELLED
657 * GUID_TARGET_DEVICE_REMOVE_COMPLETE
658 * GUID_PNP_CUSTOM_NOTIFICATION
659 * GUID_PNP_POWER_NOTIFICATION
660 * GUID_DEVICE_* (see above)
663 * Type of the event that happened.
672 * Size of the event block including the device IDs and other
673 * per category specific fields.
679 * Returns one Plug & Play event from a global queue.
684 * Always set to zero.
687 * The buffer that will be filled with the event information on
688 * successful return from the function.
691 * Size of the buffer pointed by the Buffer parameter. If the
692 * buffer size is not large enough to hold the whole event
693 * information, error STATUS_BUFFER_TOO_SMALL is returned and
694 * the buffer remains untouched.
697 * STATUS_PRIVILEGE_NOT_HELD
698 * STATUS_BUFFER_TOO_SMALL
702 * This function isn't multi-thread safe!
708 NtGetPlugPlayEvent(IN ULONG Reserved1
,
710 OUT PPLUGPLAY_EVENT_BLOCK Buffer
,
713 PPNP_EVENT_ENTRY Entry
;
716 DPRINT("NtGetPlugPlayEvent() called\n");
718 /* Function can only be called from user-mode */
719 if (KeGetPreviousMode() == KernelMode
)
721 DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
722 return STATUS_ACCESS_DENIED
;
725 /* Check for Tcb privilege */
726 if (!SeSinglePrivilegeCheck(SeTcbPrivilege
,
729 DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
730 return STATUS_PRIVILEGE_NOT_HELD
;
733 /* Wait for a PnP event */
734 DPRINT("Waiting for pnp notification event\n");
735 Status
= KeWaitForSingleObject(&IopPnpNotifyEvent
,
740 if (!NT_SUCCESS(Status
))
742 DPRINT1("KeWaitForSingleObject() failed (Status %lx)\n", Status
);
746 /* Get entry from the tail of the queue */
747 Entry
= CONTAINING_RECORD(IopPnpEventQueueHead
.Blink
,
751 /* Check the buffer size */
752 if (BufferSize
< Entry
->Event
.TotalSize
)
754 DPRINT1("Buffer is too small for the pnp-event\n");
755 return STATUS_BUFFER_TOO_SMALL
;
758 /* Copy event data to the user buffer */
761 Entry
->Event
.TotalSize
);
763 DPRINT("NtGetPlugPlayEvent() done\n");
765 return STATUS_SUCCESS
;
771 * A function for doing various Plug & Play operations from user mode.
774 * PlugPlayControlClass
775 * 0x00 Reenumerate device tree
777 * Buffer points to UNICODE_STRING decribing the instance
778 * path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
779 * more information about instance paths see !devnode command
780 * in kernel debugger or look at "Inside Windows 2000" book,
781 * chapter "Driver Loading, Initialization, and Installation".
783 * 0x01 Register new device
784 * 0x02 Deregister device
785 * 0x03 Initialize device
787 * 0x06 Query and remove device
790 * Called after processing the message from NtGetPlugPlayEvent.
792 * 0x08 Generate legacy device
793 * 0x09 Get interface device list
794 * 0x0A Get property data
795 * 0x0B Device class association (Registration)
796 * 0x0C Get related device
797 * 0x0D Get device interface alias
798 * 0x0E Get/set/clear device status
799 * 0x0F Get device depth
800 * 0x10 Query device relations
801 * 0x11 Query target device relation
802 * 0x12 Query conflict list
803 * 0x13 Retrieve dock data
806 * 0x16 Get blocked driver data
809 * The buffer contains information that is specific to each control
810 * code. The buffer is read-only.
813 * Size of the buffer pointed by the Buffer parameter. If the
814 * buffer size specifies incorrect value for specified control
815 * code, error ??? is returned.
818 * STATUS_PRIVILEGE_NOT_HELD
826 NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass
,
828 IN ULONG BufferLength
)
830 DPRINT("NtPlugPlayControl(%lu %p %lu) called\n",
831 PlugPlayControlClass
, Buffer
, BufferLength
);
833 /* Function can only be called from user-mode */
834 if (KeGetPreviousMode() == KernelMode
)
836 DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
837 return STATUS_ACCESS_DENIED
;
840 /* Check for Tcb privilege */
841 if (!SeSinglePrivilegeCheck(SeTcbPrivilege
,
844 DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
845 return STATUS_PRIVILEGE_NOT_HELD
;
848 /* Probe the buffer */
851 ProbeForWrite(Buffer
,
855 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
857 _SEH2_YIELD(return _SEH2_GetExceptionCode());
861 switch (PlugPlayControlClass
)
863 case PlugPlayControlUserResponse
:
864 if (Buffer
|| BufferLength
!= 0)
865 return STATUS_INVALID_PARAMETER
;
866 return IopRemovePlugPlayEvent();
868 case PlugPlayControlProperty
:
869 if (!Buffer
|| BufferLength
< sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA
))
870 return STATUS_INVALID_PARAMETER
;
871 return IopGetDeviceProperty((PPLUGPLAY_CONTROL_PROPERTY_DATA
)Buffer
);
873 case PlugPlayControlGetRelatedDevice
:
874 if (!Buffer
|| BufferLength
< sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
))
875 return STATUS_INVALID_PARAMETER
;
876 return IopGetRelatedDevice((PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA
)Buffer
);
878 case PlugPlayControlDeviceStatus
:
879 if (!Buffer
|| BufferLength
< sizeof(PLUGPLAY_CONTROL_STATUS_DATA
))
880 return STATUS_INVALID_PARAMETER
;
881 return IopDeviceStatus((PPLUGPLAY_CONTROL_STATUS_DATA
)Buffer
);
883 case PlugPlayControlGetDeviceDepth
:
884 if (!Buffer
|| BufferLength
< sizeof(PLUGPLAY_CONTROL_DEPTH_DATA
))
885 return STATUS_INVALID_PARAMETER
;
886 return IopGetDeviceDepth((PPLUGPLAY_CONTROL_DEPTH_DATA
)Buffer
);
888 case PlugPlayControlResetDevice
:
889 if (!Buffer
|| BufferLength
< sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA
))
890 return STATUS_INVALID_PARAMETER
;
891 return IopResetDevice((PPLUGPLAY_CONTROL_RESET_DEVICE_DATA
)Buffer
);
894 return STATUS_NOT_IMPLEMENTED
;
897 return STATUS_NOT_IMPLEMENTED
;