2005-06-06 20:31:56 +00:00
|
|
|
/*
|
2008-08-18 13:30:17 +00:00
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* COPYRIGHT: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: ntoskrnl/io/pnpmgr/plugplay.c
|
2005-02-01 16:24:10 +00:00
|
|
|
* PURPOSE: Plug-and-play interface routines
|
2005-02-05 08:43:52 +00:00
|
|
|
* PROGRAMMERS: Eric Kohl <eric.kohl@t-online.de>
|
2005-01-07 06:54:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
2005-02-01 16:24:10 +00:00
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
2005-01-07 06:54:27 +00:00
|
|
|
|
2005-11-28 23:25:31 +00:00
|
|
|
#if defined (ALLOC_PRAGMA)
|
|
|
|
#pragma alloc_text(INIT, IopInitPlugPlayEvents)
|
|
|
|
#endif
|
2005-02-05 00:04:52 +00:00
|
|
|
|
|
|
|
typedef struct _PNP_EVENT_ENTRY
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
PLUGPLAY_EVENT_BLOCK Event;
|
2005-02-05 00:04:52 +00:00
|
|
|
} PNP_EVENT_ENTRY, *PPNP_EVENT_ENTRY;
|
|
|
|
|
|
|
|
|
2005-02-01 16:24:10 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
2005-02-05 00:04:52 +00:00
|
|
|
static LIST_ENTRY IopPnpEventQueueHead;
|
2005-02-01 16:24:10 +00:00
|
|
|
static KEVENT IopPnpNotifyEvent;
|
|
|
|
|
2005-01-07 06:54:27 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2005-02-01 16:24:10 +00:00
|
|
|
NTSTATUS INIT_FUNCTION
|
|
|
|
IopInitPlugPlayEvents(VOID)
|
|
|
|
{
|
2005-06-06 20:31:56 +00:00
|
|
|
InitializeListHead(&IopPnpEventQueueHead);
|
2005-02-01 16:24:10 +00:00
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
KeInitializeEvent(&IopPnpNotifyEvent,
|
|
|
|
SynchronizationEvent,
|
|
|
|
FALSE);
|
2005-02-01 16:24:10 +00:00
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
return STATUS_SUCCESS;
|
2005-02-01 16:24:10 +00:00
|
|
|
}
|
|
|
|
|
2005-02-05 00:04:52 +00:00
|
|
|
NTSTATUS
|
|
|
|
IopQueueTargetDeviceEvent(const GUID *Guid,
|
|
|
|
PUNICODE_STRING DeviceIds)
|
2005-02-01 16:24:10 +00:00
|
|
|
{
|
2005-06-06 20:31:56 +00:00
|
|
|
PPNP_EVENT_ENTRY EventEntry;
|
2007-12-27 18:53:24 +00:00
|
|
|
UNICODE_STRING Copy;
|
2006-09-07 05:07:34 +00:00
|
|
|
ULONG TotalSize;
|
2007-12-27 18:53:24 +00:00
|
|
|
NTSTATUS Status;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
2007-12-27 18:53:24 +00:00
|
|
|
ASSERT(DeviceIds);
|
|
|
|
|
|
|
|
/* Allocate a big enough buffer */
|
|
|
|
Copy.Length = 0;
|
|
|
|
Copy.MaximumLength = DeviceIds->Length + sizeof(UNICODE_NULL);
|
2005-06-06 20:31:56 +00:00
|
|
|
TotalSize =
|
|
|
|
FIELD_OFFSET(PLUGPLAY_EVENT_BLOCK, TargetDevice.DeviceIds) +
|
2007-12-27 18:53:24 +00:00
|
|
|
Copy.MaximumLength;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
|
|
|
EventEntry = ExAllocatePool(NonPagedPool,
|
|
|
|
TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
|
2007-12-27 18:53:24 +00:00
|
|
|
if (!EventEntry)
|
2005-06-06 20:31:56 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
|
2007-12-27 18:53:24 +00:00
|
|
|
/* Fill the buffer with the event GUID */
|
|
|
|
RtlCopyMemory(&EventEntry->Event.EventGuid,
|
|
|
|
Guid,
|
|
|
|
sizeof(GUID));
|
2005-06-06 20:31:56 +00:00
|
|
|
EventEntry->Event.EventCategory = TargetDeviceChangeEvent;
|
|
|
|
EventEntry->Event.TotalSize = TotalSize;
|
|
|
|
|
2007-12-27 18:53:24 +00:00
|
|
|
/* Fill the device id */
|
|
|
|
Copy.Buffer = EventEntry->Event.TargetDevice.DeviceIds;
|
|
|
|
Status = RtlAppendUnicodeStringToString(&Copy, DeviceIds);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return Status;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
|
|
|
InsertHeadList(&IopPnpEventQueueHead,
|
|
|
|
&EventEntry->ListEntry);
|
|
|
|
KeSetEvent(&IopPnpNotifyEvent,
|
|
|
|
0,
|
|
|
|
FALSE);
|
2005-02-01 16:24:10 +00:00
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
return STATUS_SUCCESS;
|
2005-02-01 16:24:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove the current PnP event from the tail of the event queue
|
|
|
|
* and signal IopPnpNotifyEvent if there is yet another event in the queue.
|
|
|
|
*/
|
2005-06-06 20:31:56 +00:00
|
|
|
static NTSTATUS
|
2005-02-05 00:04:52 +00:00
|
|
|
IopRemovePlugPlayEvent(VOID)
|
2005-02-01 16:24:10 +00:00
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
/* Remove a pnp event entry from the tail of the queue */
|
|
|
|
if (!IsListEmpty(&IopPnpEventQueueHead))
|
|
|
|
{
|
|
|
|
ExFreePool(RemoveTailList(&IopPnpEventQueueHead));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Signal the next pnp event in the queue */
|
|
|
|
if (!IsListEmpty(&IopPnpEventQueueHead))
|
|
|
|
{
|
|
|
|
KeSetEvent(&IopPnpNotifyEvent,
|
|
|
|
0,
|
|
|
|
FALSE);
|
|
|
|
}
|
2005-06-06 20:31:56 +00:00
|
|
|
|
2010-01-03 15:20:09 +00:00
|
|
|
return STATUS_SUCCESS;
|
2005-02-01 16:24:10 +00:00
|
|
|
}
|
|
|
|
|
2005-07-21 20:30:55 +00:00
|
|
|
static PDEVICE_OBJECT
|
|
|
|
IopTraverseDeviceNode(PDEVICE_NODE Node, PUNICODE_STRING DeviceInstance)
|
|
|
|
{
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PDEVICE_NODE ChildNode;
|
|
|
|
|
|
|
|
if (RtlEqualUnicodeString(&Node->InstancePath,
|
|
|
|
DeviceInstance, TRUE))
|
2005-10-03 10:13:28 +00:00
|
|
|
{
|
|
|
|
ObReferenceObject(Node->PhysicalDeviceObject);
|
2005-07-21 20:30:55 +00:00
|
|
|
return Node->PhysicalDeviceObject;
|
2005-10-03 10:13:28 +00:00
|
|
|
}
|
2005-07-21 20:30:55 +00:00
|
|
|
|
|
|
|
/* Traversal of all children nodes */
|
|
|
|
for (ChildNode = Node->Child;
|
|
|
|
ChildNode != NULL;
|
2008-08-22 21:43:42 +00:00
|
|
|
ChildNode = ChildNode->Sibling)
|
2005-07-21 20:30:55 +00:00
|
|
|
{
|
|
|
|
DeviceObject = IopTraverseDeviceNode(ChildNode, DeviceInstance);
|
|
|
|
if (DeviceObject != NULL)
|
|
|
|
{
|
|
|
|
return DeviceObject;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
static PDEVICE_OBJECT
|
|
|
|
IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
|
|
|
|
{
|
2005-07-21 20:30:55 +00:00
|
|
|
if (IopRootDeviceNode == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (DeviceInstance == NULL ||
|
2010-01-03 15:20:09 +00:00
|
|
|
DeviceInstance->Length == 0)
|
2005-07-21 20:30:55 +00:00
|
|
|
{
|
|
|
|
if (IopRootDeviceNode->PhysicalDeviceObject)
|
|
|
|
{
|
|
|
|
ObReferenceObject(IopRootDeviceNode->PhysicalDeviceObject);
|
|
|
|
return IopRootDeviceNode->PhysicalDeviceObject;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IopTraverseDeviceNode(IopRootDeviceNode, DeviceInstance);
|
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
}
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
static NTSTATUS
|
|
|
|
IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
UNICODE_STRING Name;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
Name.Buffer = NULL;
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
Name.Length = SrcName->Length;
|
|
|
|
Name.MaximumLength = SrcName->MaximumLength;
|
|
|
|
if (Name.Length > Name.MaximumLength)
|
|
|
|
{
|
|
|
|
Status = STATUS_INVALID_PARAMETER;
|
|
|
|
_SEH2_LEAVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Name.MaximumLength)
|
|
|
|
{
|
|
|
|
ProbeForRead(SrcName->Buffer,
|
|
|
|
Name.MaximumLength,
|
|
|
|
sizeof(WCHAR));
|
|
|
|
Name.Buffer = ExAllocatePool(NonPagedPool, Name.MaximumLength);
|
|
|
|
if (Name.Buffer == NULL)
|
|
|
|
{
|
|
|
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
_SEH2_LEAVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(Name.Buffer, SrcName->Buffer, Name.MaximumLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
*DstName = Name;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
if (Name.Buffer)
|
|
|
|
ExFreePool(Name.Buffer);
|
2008-11-24 13:40:26 +00:00
|
|
|
Status = _SEH2_GetExceptionCode();
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2010-01-03 15:20:09 +00:00
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
return Status;
|
|
|
|
}
|
2005-07-21 20:30:55 +00:00
|
|
|
|
2005-07-03 21:25:00 +00:00
|
|
|
static NTSTATUS
|
|
|
|
IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData)
|
|
|
|
{
|
|
|
|
PDEVICE_OBJECT DeviceObject = NULL;
|
2009-08-26 17:31:02 +00:00
|
|
|
NTSTATUS Status;
|
2005-10-15 21:41:48 +00:00
|
|
|
UNICODE_STRING DeviceInstance;
|
|
|
|
ULONG BufferSize;
|
|
|
|
ULONG Property = 0;
|
2007-04-02 15:08:54 +00:00
|
|
|
PVOID Buffer;
|
2005-07-03 21:25:00 +00:00
|
|
|
|
|
|
|
DPRINT("IopGetDeviceProperty() called\n");
|
|
|
|
DPRINT("Device name: %wZ\n", &PropertyData->DeviceInstance);
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
Status = IopCaptureUnicodeString(&DeviceInstance, &PropertyData->DeviceInstance);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
return Status;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
Property = PropertyData->Property;
|
2005-10-15 21:41:48 +00:00
|
|
|
BufferSize = PropertyData->BufferSize;
|
|
|
|
ProbeForWrite(PropertyData->Buffer,
|
|
|
|
BufferSize,
|
|
|
|
sizeof(UCHAR));
|
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2009-08-26 17:31:02 +00:00
|
|
|
ExFreePool(DeviceInstance.Buffer);
|
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2010-01-03 15:20:09 +00:00
|
|
|
|
2005-07-03 21:25:00 +00:00
|
|
|
/* Get the device object */
|
2007-12-27 21:21:36 +00:00
|
|
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
|
2005-10-15 21:41:48 +00:00
|
|
|
ExFreePool(DeviceInstance.Buffer);
|
2005-07-03 21:25:00 +00:00
|
|
|
if (DeviceObject == NULL)
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2005-07-03 21:25:00 +00:00
|
|
|
return STATUS_NO_SUCH_DEVICE;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Buffer = ExAllocatePool(NonPagedPool, BufferSize);
|
|
|
|
if (Buffer == NULL)
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
|
|
|
|
2005-07-03 21:25:00 +00:00
|
|
|
Status = IoGetDeviceProperty(DeviceObject,
|
2005-10-15 21:41:48 +00:00
|
|
|
Property,
|
|
|
|
BufferSize,
|
|
|
|
Buffer,
|
|
|
|
&BufferSize);
|
2005-07-03 21:25:00 +00:00
|
|
|
|
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2010-01-03 15:24:16 +00:00
|
|
|
memcpy(PropertyData->Buffer, Buffer, BufferSize);
|
2010-01-03 15:20:09 +00:00
|
|
|
PropertyData->BufferSize = BufferSize;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2010-01-03 15:20:09 +00:00
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
ExFreePool(Buffer);
|
2005-07-03 21:25:00 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
static NTSTATUS
|
2005-07-03 12:18:23 +00:00
|
|
|
IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
|
|
|
UNICODE_STRING RootDeviceName;
|
|
|
|
PDEVICE_OBJECT DeviceObject = NULL;
|
|
|
|
PDEVICE_NODE DeviceNode = NULL;
|
|
|
|
PDEVICE_NODE RelatedDeviceNode;
|
2005-10-15 21:41:48 +00:00
|
|
|
UNICODE_STRING TargetDeviceInstance;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
ULONG Relation = 0;
|
|
|
|
ULONG MaximumLength = 0;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
|
|
|
DPRINT("IopGetRelatedDevice() called\n");
|
2005-07-03 12:18:23 +00:00
|
|
|
DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
|
2005-06-06 20:31:56 +00:00
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
Status = IopCaptureUnicodeString(&TargetDeviceInstance, &RelatedDeviceData->TargetDeviceInstance);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
return Status;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
Relation = RelatedDeviceData->Relation;
|
|
|
|
MaximumLength = RelatedDeviceData->RelatedDeviceInstanceLength;
|
|
|
|
ProbeForWrite(RelatedDeviceData->RelatedDeviceInstance,
|
|
|
|
MaximumLength,
|
|
|
|
sizeof(WCHAR));
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
|
|
|
ExFreePool(TargetDeviceInstance.Buffer);
|
2009-08-26 17:31:02 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2009-08-26 17:31:02 +00:00
|
|
|
_SEH2_END;
|
2005-10-15 21:41:48 +00:00
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
RtlInitUnicodeString(&RootDeviceName,
|
|
|
|
L"HTREE\\ROOT\\0");
|
2005-10-15 21:41:48 +00:00
|
|
|
if (RtlEqualUnicodeString(&TargetDeviceInstance,
|
2005-06-06 20:31:56 +00:00
|
|
|
&RootDeviceName,
|
|
|
|
TRUE))
|
|
|
|
{
|
|
|
|
DeviceNode = IopRootDeviceNode;
|
2010-01-03 15:20:09 +00:00
|
|
|
ExFreePool(TargetDeviceInstance.Buffer);
|
2005-06-06 20:31:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Get the device object */
|
2005-10-15 21:41:48 +00:00
|
|
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&TargetDeviceInstance);
|
2010-01-03 15:20:09 +00:00
|
|
|
ExFreePool(TargetDeviceInstance.Buffer);
|
2005-06-06 20:31:56 +00:00
|
|
|
if (DeviceObject == NULL)
|
|
|
|
return STATUS_NO_SUCH_DEVICE;
|
|
|
|
|
2005-09-04 23:48:19 +00:00
|
|
|
DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
|
2005-06-06 20:31:56 +00:00
|
|
|
}
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
switch (Relation)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
|
|
|
case PNP_GET_PARENT_DEVICE:
|
|
|
|
RelatedDeviceNode = DeviceNode->Parent;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PNP_GET_CHILD_DEVICE:
|
|
|
|
RelatedDeviceNode = DeviceNode->Child;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PNP_GET_SIBLING_DEVICE:
|
2008-08-22 21:43:42 +00:00
|
|
|
RelatedDeviceNode = DeviceNode->Sibling;
|
2005-06-06 20:31:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (DeviceObject != NULL)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RelatedDeviceNode == NULL)
|
|
|
|
{
|
|
|
|
if (DeviceObject)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_NO_SUCH_DEVICE;
|
|
|
|
}
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
if (RelatedDeviceNode->InstancePath.Length > MaximumLength)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
|
|
|
if (DeviceObject)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy related device instance name */
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2006-05-10 17:47:44 +00:00
|
|
|
RtlCopyMemory(RelatedDeviceData->RelatedDeviceInstance,
|
2005-10-15 21:41:48 +00:00
|
|
|
RelatedDeviceNode->InstancePath.Buffer,
|
|
|
|
RelatedDeviceNode->InstancePath.Length);
|
2006-05-10 17:47:44 +00:00
|
|
|
RelatedDeviceData->RelatedDeviceInstanceLength = RelatedDeviceNode->InstancePath.Length;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2008-11-24 13:40:26 +00:00
|
|
|
Status = _SEH2_GetExceptionCode();
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
|
|
|
if (DeviceObject != NULL)
|
|
|
|
{
|
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("IopGetRelatedDevice() done\n");
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
return Status;
|
2005-06-06 20:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS
|
2005-07-03 12:18:23 +00:00
|
|
|
IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PDEVICE_NODE DeviceNode;
|
2005-10-15 21:41:48 +00:00
|
|
|
ULONG Operation = 0;
|
|
|
|
ULONG DeviceStatus = 0;
|
|
|
|
ULONG DeviceProblem = 0;
|
|
|
|
UNICODE_STRING DeviceInstance;
|
2009-08-26 17:31:02 +00:00
|
|
|
NTSTATUS Status;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
|
|
|
DPRINT("IopDeviceStatus() called\n");
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
Status = IopCaptureUnicodeString(&DeviceInstance, &StatusData->DeviceInstance);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2007-12-27 21:21:36 +00:00
|
|
|
return Status;
|
|
|
|
DPRINT("Device name: '%wZ'\n", &DeviceInstance);
|
2005-10-15 21:41:48 +00:00
|
|
|
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
Operation = StatusData->Operation;
|
|
|
|
if (Operation == PNP_SET_DEVICE_STATUS)
|
|
|
|
{
|
|
|
|
DeviceStatus = StatusData->DeviceStatus;
|
|
|
|
DeviceProblem = StatusData->DeviceProblem;
|
|
|
|
}
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2009-08-26 17:31:02 +00:00
|
|
|
if (DeviceInstance.Buffer) ExFreePool(DeviceInstance.Buffer);
|
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2005-10-15 21:41:48 +00:00
|
|
|
|
2005-06-06 20:31:56 +00:00
|
|
|
/* Get the device object */
|
2007-12-27 21:21:36 +00:00
|
|
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
|
2005-10-15 21:41:48 +00:00
|
|
|
ExFreePool(DeviceInstance.Buffer);
|
2005-06-06 20:31:56 +00:00
|
|
|
if (DeviceObject == NULL)
|
|
|
|
return STATUS_NO_SUCH_DEVICE;
|
|
|
|
|
2007-06-12 08:38:32 +00:00
|
|
|
DeviceNode = IopGetDeviceNode(DeviceObject);
|
2005-06-06 20:31:56 +00:00
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
switch (Operation)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
|
|
|
case PNP_GET_DEVICE_STATUS:
|
|
|
|
DPRINT("Get status data\n");
|
2005-10-15 21:41:48 +00:00
|
|
|
DeviceStatus = DeviceNode->Flags;
|
|
|
|
DeviceProblem = DeviceNode->Problem;
|
2005-06-06 20:31:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PNP_SET_DEVICE_STATUS:
|
|
|
|
DPRINT("Set status data\n");
|
2005-10-15 21:41:48 +00:00
|
|
|
DeviceNode->Flags = DeviceStatus;
|
|
|
|
DeviceNode->Problem = DeviceProblem;
|
2005-06-06 20:31:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PNP_CLEAR_DEVICE_STATUS:
|
|
|
|
DPRINT1("FIXME: Clear status data!\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
if (Operation == PNP_GET_DEVICE_STATUS)
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
StatusData->DeviceStatus = DeviceStatus;
|
|
|
|
StatusData->DeviceProblem = DeviceProblem;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
2005-06-06 20:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-03 21:25:00 +00:00
|
|
|
static NTSTATUS
|
|
|
|
IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
|
|
|
|
{
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PDEVICE_NODE DeviceNode;
|
2005-10-15 21:41:48 +00:00
|
|
|
UNICODE_STRING DeviceInstance;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2005-07-03 21:25:00 +00:00
|
|
|
|
|
|
|
DPRINT("IopGetDeviceDepth() called\n");
|
|
|
|
DPRINT("Device name: %wZ\n", &DepthData->DeviceInstance);
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
Status = IopCaptureUnicodeString(&DeviceInstance, &DepthData->DeviceInstance);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
return Status;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
|
|
|
|
2005-07-03 21:25:00 +00:00
|
|
|
/* Get the device object */
|
2007-12-27 21:21:36 +00:00
|
|
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
|
2005-10-15 21:41:48 +00:00
|
|
|
ExFreePool(DeviceInstance.Buffer);
|
2005-07-03 21:25:00 +00:00
|
|
|
if (DeviceObject == NULL)
|
|
|
|
return STATUS_NO_SUCH_DEVICE;
|
|
|
|
|
2005-10-08 14:47:25 +00:00
|
|
|
DeviceNode = IopGetDeviceNode(DeviceObject);
|
2005-07-03 21:25:00 +00:00
|
|
|
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
DepthData->Depth = DeviceNode->Level;
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-10-15 21:41:48 +00:00
|
|
|
{
|
2008-11-24 13:40:26 +00:00
|
|
|
Status = _SEH2_GetExceptionCode();
|
2005-10-15 21:41:48 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2005-10-15 21:41:48 +00:00
|
|
|
|
2008-10-31 23:34:54 +00:00
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
return Status;
|
2005-07-03 21:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-08 14:47:25 +00:00
|
|
|
static NTSTATUS
|
|
|
|
IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
|
|
|
|
{
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PDEVICE_NODE DeviceNode;
|
2005-10-15 21:41:48 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
UNICODE_STRING DeviceInstance;
|
2005-10-08 14:47:25 +00:00
|
|
|
|
2005-10-15 21:41:48 +00:00
|
|
|
Status = IopCaptureUnicodeString(&DeviceInstance, &ResetDeviceData->DeviceInstance);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2007-06-04 19:32:28 +00:00
|
|
|
return Status;
|
|
|
|
|
|
|
|
DPRINT("IopResetDevice(%wZ)\n", &DeviceInstance);
|
2005-10-15 21:41:48 +00:00
|
|
|
|
2005-10-08 14:47:25 +00:00
|
|
|
/* Get the device object */
|
2005-10-15 21:41:48 +00:00
|
|
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
|
|
|
|
ExFreePool(DeviceInstance.Buffer);
|
2005-10-08 14:47:25 +00:00
|
|
|
if (DeviceObject == NULL)
|
|
|
|
return STATUS_NO_SUCH_DEVICE;
|
|
|
|
|
|
|
|
DeviceNode = IopGetDeviceNode(DeviceObject);
|
|
|
|
|
|
|
|
/* FIXME: we should stop the device, before starting it again */
|
|
|
|
|
|
|
|
/* Start the device */
|
|
|
|
IopDeviceNodeClearFlag(DeviceNode, DNF_DISABLED);
|
|
|
|
Status = IopActionConfigureChildServices(DeviceNode, DeviceNode->Parent);
|
|
|
|
|
|
|
|
if (NT_SUCCESS(Status))
|
2008-08-22 17:47:13 +00:00
|
|
|
Status = IopActionInitChildServices(DeviceNode, DeviceNode->Parent);
|
2005-10-08 14:47:25 +00:00
|
|
|
|
|
|
|
ObDereferenceObject(DeviceObject);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-08-18 13:30:17 +00:00
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Plug and Play event structure used by NtGetPlugPlayEvent.
|
|
|
|
*
|
|
|
|
* EventGuid
|
|
|
|
* Can be one of the following values:
|
|
|
|
* GUID_HWPROFILE_QUERY_CHANGE
|
|
|
|
* GUID_HWPROFILE_CHANGE_CANCELLED
|
|
|
|
* GUID_HWPROFILE_CHANGE_COMPLETE
|
|
|
|
* GUID_TARGET_DEVICE_QUERY_REMOVE
|
|
|
|
* GUID_TARGET_DEVICE_REMOVE_CANCELLED
|
|
|
|
* GUID_TARGET_DEVICE_REMOVE_COMPLETE
|
|
|
|
* GUID_PNP_CUSTOM_NOTIFICATION
|
|
|
|
* GUID_PNP_POWER_NOTIFICATION
|
|
|
|
* GUID_DEVICE_* (see above)
|
|
|
|
*
|
|
|
|
* EventCategory
|
|
|
|
* Type of the event that happened.
|
|
|
|
*
|
|
|
|
* Result
|
|
|
|
* ?
|
|
|
|
*
|
|
|
|
* Flags
|
|
|
|
* ?
|
|
|
|
*
|
|
|
|
* TotalSize
|
|
|
|
* Size of the event block including the device IDs and other
|
|
|
|
* per category specific fields.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NtGetPlugPlayEvent
|
|
|
|
*
|
|
|
|
* Returns one Plug & Play event from a global queue.
|
|
|
|
*
|
|
|
|
* Parameters
|
|
|
|
* Reserved1
|
|
|
|
* Reserved2
|
|
|
|
* Always set to zero.
|
|
|
|
*
|
|
|
|
* Buffer
|
|
|
|
* The buffer that will be filled with the event information on
|
|
|
|
* successful return from the function.
|
|
|
|
*
|
|
|
|
* BufferSize
|
|
|
|
* Size of the buffer pointed by the Buffer parameter. If the
|
|
|
|
* buffer size is not large enough to hold the whole event
|
|
|
|
* information, error STATUS_BUFFER_TOO_SMALL is returned and
|
|
|
|
* the buffer remains untouched.
|
|
|
|
*
|
|
|
|
* Return Values
|
|
|
|
* STATUS_PRIVILEGE_NOT_HELD
|
|
|
|
* STATUS_BUFFER_TOO_SMALL
|
|
|
|
* STATUS_SUCCESS
|
|
|
|
*
|
|
|
|
* Remarks
|
|
|
|
* This function isn't multi-thread safe!
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
NtGetPlugPlayEvent(IN ULONG Reserved1,
|
|
|
|
IN ULONG Reserved2,
|
|
|
|
OUT PPLUGPLAY_EVENT_BLOCK Buffer,
|
|
|
|
IN ULONG BufferSize)
|
|
|
|
{
|
2010-01-03 15:20:09 +00:00
|
|
|
PPNP_EVENT_ENTRY Entry;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DPRINT("NtGetPlugPlayEvent() called\n");
|
|
|
|
|
|
|
|
/* Function can only be called from user-mode */
|
|
|
|
if (KeGetPreviousMode() == KernelMode)
|
|
|
|
{
|
|
|
|
DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
|
|
|
|
return STATUS_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for Tcb privilege */
|
|
|
|
if (!SeSinglePrivilegeCheck(SeTcbPrivilege,
|
|
|
|
UserMode))
|
|
|
|
{
|
|
|
|
DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
|
|
|
|
return STATUS_PRIVILEGE_NOT_HELD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for a PnP event */
|
|
|
|
DPRINT("Waiting for pnp notification event\n");
|
|
|
|
Status = KeWaitForSingleObject(&IopPnpNotifyEvent,
|
|
|
|
UserRequest,
|
|
|
|
KernelMode,
|
|
|
|
FALSE,
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("KeWaitForSingleObject() failed (Status %lx)\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
2008-08-18 13:30:17 +00:00
|
|
|
|
2010-01-03 15:20:09 +00:00
|
|
|
/* Get entry from the tail of the queue */
|
|
|
|
Entry = CONTAINING_RECORD(IopPnpEventQueueHead.Blink,
|
|
|
|
PNP_EVENT_ENTRY,
|
|
|
|
ListEntry);
|
2008-08-18 13:30:17 +00:00
|
|
|
|
2010-01-03 15:20:09 +00:00
|
|
|
/* Check the buffer size */
|
|
|
|
if (BufferSize < Entry->Event.TotalSize)
|
|
|
|
{
|
|
|
|
DPRINT1("Buffer is too small for the pnp-event\n");
|
|
|
|
return STATUS_BUFFER_TOO_SMALL;
|
|
|
|
}
|
2008-08-18 13:30:17 +00:00
|
|
|
|
2010-01-03 15:20:09 +00:00
|
|
|
/* Copy event data to the user buffer */
|
|
|
|
memcpy(Buffer,
|
|
|
|
&Entry->Event,
|
|
|
|
Entry->Event.TotalSize);
|
2008-08-18 13:30:17 +00:00
|
|
|
|
2010-01-03 15:20:09 +00:00
|
|
|
DPRINT("NtGetPlugPlayEvent() done\n");
|
2008-08-18 13:30:17 +00:00
|
|
|
|
2010-01-03 15:20:09 +00:00
|
|
|
return STATUS_SUCCESS;
|
2008-08-18 13:30:17 +00:00
|
|
|
}
|
2005-10-08 14:47:25 +00:00
|
|
|
|
2005-02-01 16:24:10 +00:00
|
|
|
/*
|
2005-07-03 15:21:19 +00:00
|
|
|
* NtPlugPlayControl
|
|
|
|
*
|
|
|
|
* A function for doing various Plug & Play operations from user mode.
|
|
|
|
*
|
|
|
|
* Parameters
|
|
|
|
* PlugPlayControlClass
|
|
|
|
* 0x00 Reenumerate device tree
|
|
|
|
*
|
|
|
|
* Buffer points to UNICODE_STRING decribing the instance
|
|
|
|
* path (like "HTREE\ROOT\0" or "Root\ACPI_HAL\0000"). For
|
|
|
|
* more information about instance paths see !devnode command
|
|
|
|
* in kernel debugger or look at "Inside Windows 2000" book,
|
|
|
|
* chapter "Driver Loading, Initialization, and Installation".
|
|
|
|
*
|
|
|
|
* 0x01 Register new device
|
|
|
|
* 0x02 Deregister device
|
|
|
|
* 0x03 Initialize device
|
|
|
|
* 0x04 Start device
|
|
|
|
* 0x06 Query and remove device
|
|
|
|
* 0x07 User response
|
|
|
|
*
|
|
|
|
* Called after processing the message from NtGetPlugPlayEvent.
|
|
|
|
*
|
|
|
|
* 0x08 Generate legacy device
|
|
|
|
* 0x09 Get interface device list
|
|
|
|
* 0x0A Get property data
|
|
|
|
* 0x0B Device class association (Registration)
|
|
|
|
* 0x0C Get related device
|
|
|
|
* 0x0D Get device interface alias
|
|
|
|
* 0x0E Get/set/clear device status
|
|
|
|
* 0x0F Get device depth
|
|
|
|
* 0x10 Query device relations
|
|
|
|
* 0x11 Query target device relation
|
|
|
|
* 0x12 Query conflict list
|
|
|
|
* 0x13 Retrieve dock data
|
|
|
|
* 0x14 Reset device
|
|
|
|
* 0x15 Halt device
|
|
|
|
* 0x16 Get blocked driver data
|
|
|
|
*
|
|
|
|
* Buffer
|
|
|
|
* The buffer contains information that is specific to each control
|
|
|
|
* code. The buffer is read-only.
|
|
|
|
*
|
|
|
|
* BufferSize
|
|
|
|
* Size of the buffer pointed by the Buffer parameter. If the
|
|
|
|
* buffer size specifies incorrect value for specified control
|
|
|
|
* code, error ??? is returned.
|
|
|
|
*
|
|
|
|
* Return Values
|
|
|
|
* STATUS_PRIVILEGE_NOT_HELD
|
|
|
|
* STATUS_SUCCESS
|
|
|
|
* ...
|
|
|
|
*
|
2005-02-01 16:24:10 +00:00
|
|
|
* @unimplemented
|
|
|
|
*/
|
2008-08-18 13:30:17 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2005-07-03 12:18:23 +00:00
|
|
|
NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
|
2005-02-01 16:24:10 +00:00
|
|
|
IN OUT PVOID Buffer,
|
|
|
|
IN ULONG BufferLength)
|
2005-01-07 06:54:27 +00:00
|
|
|
{
|
2005-06-06 20:31:56 +00:00
|
|
|
DPRINT("NtPlugPlayControl(%lu %p %lu) called\n",
|
2005-07-03 12:18:23 +00:00
|
|
|
PlugPlayControlClass, Buffer, BufferLength);
|
2005-06-06 20:31:56 +00:00
|
|
|
|
|
|
|
/* Function can only be called from user-mode */
|
2005-08-21 19:04:23 +00:00
|
|
|
if (KeGetPreviousMode() == KernelMode)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
|
|
|
DPRINT1("NtGetPlugPlayEvent cannot be called from kernel mode!\n");
|
|
|
|
return STATUS_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for Tcb privilege */
|
|
|
|
if (!SeSinglePrivilegeCheck(SeTcbPrivilege,
|
|
|
|
UserMode))
|
|
|
|
{
|
|
|
|
DPRINT1("NtGetPlugPlayEvent: Caller does not hold the SeTcbPrivilege privilege!\n");
|
|
|
|
return STATUS_PRIVILEGE_NOT_HELD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Probe the buffer */
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_TRY
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
|
|
|
ProbeForWrite(Buffer,
|
|
|
|
BufferLength,
|
|
|
|
sizeof(ULONG));
|
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
2009-08-26 17:31:02 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2005-06-06 20:31:56 +00:00
|
|
|
}
|
2008-11-24 13:40:26 +00:00
|
|
|
_SEH2_END;
|
2005-06-06 20:31:56 +00:00
|
|
|
|
2005-07-03 12:18:23 +00:00
|
|
|
switch (PlugPlayControlClass)
|
2005-06-06 20:31:56 +00:00
|
|
|
{
|
2005-07-03 12:18:23 +00:00
|
|
|
case PlugPlayControlUserResponse:
|
2005-06-06 20:31:56 +00:00
|
|
|
if (Buffer || BufferLength != 0)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
return IopRemovePlugPlayEvent();
|
|
|
|
|
2005-07-03 21:25:00 +00:00
|
|
|
case PlugPlayControlProperty:
|
|
|
|
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
return IopGetDeviceProperty((PPLUGPLAY_CONTROL_PROPERTY_DATA)Buffer);
|
|
|
|
|
2005-07-03 12:18:23 +00:00
|
|
|
case PlugPlayControlGetRelatedDevice:
|
|
|
|
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA))
|
2005-06-06 20:31:56 +00:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
2005-07-03 12:18:23 +00:00
|
|
|
return IopGetRelatedDevice((PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA)Buffer);
|
2005-06-06 20:31:56 +00:00
|
|
|
|
2005-07-03 12:18:23 +00:00
|
|
|
case PlugPlayControlDeviceStatus:
|
|
|
|
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_STATUS_DATA))
|
2005-06-06 20:31:56 +00:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
2005-07-03 12:18:23 +00:00
|
|
|
return IopDeviceStatus((PPLUGPLAY_CONTROL_STATUS_DATA)Buffer);
|
|
|
|
|
2005-07-03 21:25:00 +00:00
|
|
|
case PlugPlayControlGetDeviceDepth:
|
|
|
|
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_DEPTH_DATA))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
return IopGetDeviceDepth((PPLUGPLAY_CONTROL_DEPTH_DATA)Buffer);
|
|
|
|
|
2005-10-08 14:47:25 +00:00
|
|
|
case PlugPlayControlResetDevice:
|
|
|
|
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA))
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
return IopResetDevice((PPLUGPLAY_CONTROL_RESET_DEVICE_DATA)Buffer);
|
|
|
|
|
2005-07-03 12:18:23 +00:00
|
|
|
default:
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2005-06-06 20:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2005-01-07 06:54:27 +00:00
|
|
|
}
|