mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 06:58:10 +00:00
[NTOS:PNP][UMPNPMGR] GUID_DEVICE_ENUMERATED should be a DeviceInstallEvent
- Move the GUID_DEVICE_ENUMERATED event from the TargetDeviceChangeEvent category to the DeviceInstallEvent category - Create a new function that handles DeviceInstallEvent category events
This commit is contained in:
parent
30b9be047f
commit
d8ba5920a2
4 changed files with 97 additions and 36 deletions
|
@ -42,34 +42,9 @@ ProcessTargetDeviceEvent(
|
||||||
{
|
{
|
||||||
RPC_STATUS RpcStatus;
|
RPC_STATUS RpcStatus;
|
||||||
|
|
||||||
if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ENUMERATED, &RpcStatus))
|
DPRINT("ProcessTargetDeviceEvent(%p)\n", PnpEvent);
|
||||||
{
|
|
||||||
DeviceInstallParams* Params;
|
|
||||||
DWORD len;
|
|
||||||
DWORD DeviceIdLength;
|
|
||||||
|
|
||||||
DPRINT("Device enumerated: %S\n", PnpEvent->TargetDevice.DeviceIds);
|
if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus))
|
||||||
|
|
||||||
DeviceIdLength = lstrlenW(PnpEvent->TargetDevice.DeviceIds);
|
|
||||||
if (DeviceIdLength)
|
|
||||||
{
|
|
||||||
/* Allocate a new device-install event */
|
|
||||||
len = FIELD_OFFSET(DeviceInstallParams, DeviceIds) + (DeviceIdLength + 1) * sizeof(WCHAR);
|
|
||||||
Params = HeapAlloc(GetProcessHeap(), 0, len);
|
|
||||||
if (Params)
|
|
||||||
{
|
|
||||||
wcscpy(Params->DeviceIds, PnpEvent->TargetDevice.DeviceIds);
|
|
||||||
|
|
||||||
/* Queue the event (will be dequeued by DeviceInstallThread) */
|
|
||||||
WaitForSingleObject(hDeviceInstallListMutex, INFINITE);
|
|
||||||
InsertTailList(&DeviceInstallListHead, &Params->ListEntry);
|
|
||||||
ReleaseMutex(hDeviceInstallListMutex);
|
|
||||||
|
|
||||||
SetEvent(hDeviceInstallListNotEmpty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ARRIVAL, &RpcStatus))
|
|
||||||
{
|
{
|
||||||
// DWORD dwRecipient;
|
// DWORD dwRecipient;
|
||||||
|
|
||||||
|
@ -143,8 +118,8 @@ VOID
|
||||||
ProcessDeviceClassChangeEvent(
|
ProcessDeviceClassChangeEvent(
|
||||||
_In_ PPLUGPLAY_EVENT_BLOCK PnpEvent)
|
_In_ PPLUGPLAY_EVENT_BLOCK PnpEvent)
|
||||||
{
|
{
|
||||||
DPRINT("DeviceClassChangeEvent: %S\n", PnpEvent->DeviceClass.SymbolicLinkName);
|
DPRINT("ProcessDeviceClassChangeEvent(%p)\n", PnpEvent);
|
||||||
|
DPRINT("SymbolicLink: %S\n", PnpEvent->DeviceClass.SymbolicLinkName);
|
||||||
DPRINT("ClassGuid: {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n",
|
DPRINT("ClassGuid: {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n",
|
||||||
PnpEvent->DeviceClass.ClassGuid.Data1, PnpEvent->DeviceClass.ClassGuid.Data2, PnpEvent->DeviceClass.ClassGuid.Data3,
|
PnpEvent->DeviceClass.ClassGuid.Data1, PnpEvent->DeviceClass.ClassGuid.Data2, PnpEvent->DeviceClass.ClassGuid.Data3,
|
||||||
PnpEvent->DeviceClass.ClassGuid.Data4[0], PnpEvent->DeviceClass.ClassGuid.Data4[1], PnpEvent->DeviceClass.ClassGuid.Data4[2],
|
PnpEvent->DeviceClass.ClassGuid.Data4[0], PnpEvent->DeviceClass.ClassGuid.Data4[1], PnpEvent->DeviceClass.ClassGuid.Data4[2],
|
||||||
|
@ -153,6 +128,39 @@ ProcessDeviceClassChangeEvent(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
ProcessDeviceInstallEvent(
|
||||||
|
_In_ PPLUGPLAY_EVENT_BLOCK PnpEvent)
|
||||||
|
{
|
||||||
|
DeviceInstallParams* Params;
|
||||||
|
DWORD len;
|
||||||
|
DWORD DeviceIdLength;
|
||||||
|
|
||||||
|
DPRINT("ProcessDeviceInstallEvent(%p)\n", PnpEvent);
|
||||||
|
DPRINT("Device enumerated: %S\n", PnpEvent->InstallDevice.DeviceId);
|
||||||
|
|
||||||
|
DeviceIdLength = lstrlenW(PnpEvent->InstallDevice.DeviceId);
|
||||||
|
if (DeviceIdLength)
|
||||||
|
{
|
||||||
|
/* Allocate a new device-install event */
|
||||||
|
len = FIELD_OFFSET(DeviceInstallParams, DeviceIds) + (DeviceIdLength + 1) * sizeof(WCHAR);
|
||||||
|
Params = HeapAlloc(GetProcessHeap(), 0, len);
|
||||||
|
if (Params)
|
||||||
|
{
|
||||||
|
wcscpy(Params->DeviceIds, PnpEvent->InstallDevice.DeviceId);
|
||||||
|
|
||||||
|
/* Queue the event (will be dequeued by DeviceInstallThread) */
|
||||||
|
WaitForSingleObject(hDeviceInstallListMutex, INFINITE);
|
||||||
|
InsertTailList(&DeviceInstallListHead, &Params->ListEntry);
|
||||||
|
ReleaseMutex(hDeviceInstallListMutex);
|
||||||
|
|
||||||
|
SetEvent(hDeviceInstallListNotEmpty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
WINAPI
|
WINAPI
|
||||||
PnpEventThread(
|
PnpEventThread(
|
||||||
|
@ -213,7 +221,11 @@ PnpEventThread(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case CustomDeviceEvent:
|
// case CustomDeviceEvent:
|
||||||
// case DeviceInstallEvent:
|
|
||||||
|
case DeviceInstallEvent:
|
||||||
|
ProcessDeviceInstallEvent(PnpEvent);
|
||||||
|
break;
|
||||||
|
|
||||||
// case DeviceArrivalEvent:
|
// case DeviceArrivalEvent:
|
||||||
// case PowerEvent:
|
// case PowerEvent:
|
||||||
// case VetoEvent:
|
// case VetoEvent:
|
||||||
|
|
|
@ -676,9 +676,13 @@ IopQueueDeviceChangeEvent(
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
IopQueueTargetDeviceEvent(
|
IopQueueTargetDeviceEvent(
|
||||||
const GUID *Guid,
|
_In_ const GUID *Guid,
|
||||||
PUNICODE_STRING DeviceIds
|
_In_ PUNICODE_STRING DeviceIds);
|
||||||
);
|
|
||||||
|
NTSTATUS
|
||||||
|
IopQueueDeviceInstallEvent(
|
||||||
|
_In_ const GUID *Guid,
|
||||||
|
_In_ PUNICODE_STRING DeviceId);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
|
|
|
@ -1331,7 +1331,7 @@ PiInitializeDevNode(
|
||||||
if (!IopDeviceNodeHasFlag(DeviceNode, DNF_LEGACY_DRIVER))
|
if (!IopDeviceNodeHasFlag(DeviceNode, DNF_LEGACY_DRIVER))
|
||||||
{
|
{
|
||||||
/* Report the device to the user-mode pnp manager */
|
/* Report the device to the user-mode pnp manager */
|
||||||
IopQueueTargetDeviceEvent(&GUID_DEVICE_ENUMERATED,
|
IopQueueDeviceInstallEvent(&GUID_DEVICE_ENUMERATED,
|
||||||
&DeviceNode->InstancePath);
|
&DeviceNode->InstancePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2580,6 +2580,10 @@ PipDeviceActionWorker(
|
||||||
case PiActionResetDevice:
|
case PiActionResetDevice:
|
||||||
// TODO: the operation is a no-op for everything except removed nodes
|
// TODO: the operation is a no-op for everything except removed nodes
|
||||||
// for removed nodes, it returns them back to DeviceNodeUninitialized
|
// for removed nodes, it returns them back to DeviceNodeUninitialized
|
||||||
|
if (deviceNode->State == DeviceNodeRemoved)
|
||||||
|
{
|
||||||
|
deviceNode->State = DeviceNodeUninitialized;
|
||||||
|
}
|
||||||
status = STATUS_SUCCESS;
|
status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,46 @@ IopQueueDeviceChangeEvent(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
IopQueueDeviceInstallEvent(
|
||||||
|
_In_ const GUID *EventGuid,
|
||||||
|
_In_ PUNICODE_STRING DeviceId)
|
||||||
|
{
|
||||||
|
PPNP_EVENT_ENTRY EventEntry;
|
||||||
|
UNICODE_STRING Copy;
|
||||||
|
ULONG TotalSize;
|
||||||
|
|
||||||
|
/* Allocate a big enough buffer */
|
||||||
|
Copy.Length = 0;
|
||||||
|
Copy.MaximumLength = DeviceId->Length + sizeof(UNICODE_NULL);
|
||||||
|
TotalSize =
|
||||||
|
FIELD_OFFSET(PLUGPLAY_EVENT_BLOCK, InstallDevice.DeviceId) +
|
||||||
|
Copy.MaximumLength;
|
||||||
|
|
||||||
|
EventEntry = ExAllocatePool(NonPagedPool,
|
||||||
|
TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
|
||||||
|
if (!EventEntry)
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
RtlZeroMemory(EventEntry, TotalSize + FIELD_OFFSET(PNP_EVENT_ENTRY, Event));
|
||||||
|
|
||||||
|
/* Fill the buffer with the event GUID */
|
||||||
|
RtlCopyMemory(&EventEntry->Event.EventGuid, EventGuid, sizeof(GUID));
|
||||||
|
EventEntry->Event.EventCategory = DeviceInstallEvent;
|
||||||
|
EventEntry->Event.TotalSize = TotalSize;
|
||||||
|
|
||||||
|
/* Fill the symbolic link name */
|
||||||
|
RtlCopyMemory(&EventEntry->Event.InstallDevice.DeviceId,
|
||||||
|
DeviceId->Buffer, DeviceId->Length);
|
||||||
|
EventEntry->Event.InstallDevice.DeviceId[DeviceId->Length / sizeof(WCHAR)] = UNICODE_NULL;
|
||||||
|
|
||||||
|
InsertHeadList(&IopPnpEventQueueHead, &EventEntry->ListEntry);
|
||||||
|
|
||||||
|
KeSetEvent(&IopPnpNotifyEvent, 0, FALSE);
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
IopQueueTargetDeviceEvent(const GUID *Guid,
|
IopQueueTargetDeviceEvent(const GUID *Guid,
|
||||||
PUNICODE_STRING DeviceIds)
|
PUNICODE_STRING DeviceIds)
|
||||||
|
@ -331,7 +371,8 @@ PiControlInitializeDevice(
|
||||||
/* Insert as a root enumerated device node */
|
/* Insert as a root enumerated device node */
|
||||||
PiInsertDevNode(DeviceNode, IopRootDeviceNode);
|
PiInsertDevNode(DeviceNode, IopRootDeviceNode);
|
||||||
|
|
||||||
IopQueueTargetDeviceEvent(&GUID_DEVICE_ENUMERATED, &DeviceInstance);
|
/* Report the device to the user-mode pnp manager */
|
||||||
|
IopQueueDeviceInstallEvent(&GUID_DEVICE_ENUMERATED, &DeviceNode->InstancePath);
|
||||||
|
|
||||||
ZwClose(InstanceKey);
|
ZwClose(InstanceKey);
|
||||||
done:
|
done:
|
||||||
|
|
Loading…
Reference in a new issue