mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 01:25:56 +00:00
[UMPNPMGR] Split the notification code by event category
- Move the TargetDeviceChangeEvent code into a separate function. - Add a new function for the DeviceClassChangeEvent category.
This commit is contained in:
parent
75cf6920bc
commit
30b9be047f
1 changed files with 139 additions and 90 deletions
|
@ -35,52 +35,13 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
DWORD WINAPI
|
||||
PnpEventThread(LPVOID lpParameter)
|
||||
static
|
||||
VOID
|
||||
ProcessTargetDeviceEvent(
|
||||
_In_ PPLUGPLAY_EVENT_BLOCK PnpEvent)
|
||||
{
|
||||
PLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData = {0, 0, 0, 0};
|
||||
DWORD dwRet = ERROR_SUCCESS;
|
||||
NTSTATUS Status;
|
||||
RPC_STATUS RpcStatus;
|
||||
PPLUGPLAY_EVENT_BLOCK PnpEvent, NewPnpEvent;
|
||||
ULONG PnpEventSize;
|
||||
|
||||
UNREFERENCED_PARAMETER(lpParameter);
|
||||
|
||||
PnpEventSize = 0x1000;
|
||||
PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize);
|
||||
if (PnpEvent == NULL)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
DPRINT("Calling NtGetPlugPlayEvent()\n");
|
||||
|
||||
/* Wait for the next PnP event */
|
||||
Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize);
|
||||
|
||||
/* Resize the buffer for the PnP event if it's too small */
|
||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
PnpEventSize += 0x400;
|
||||
NewPnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize);
|
||||
if (NewPnpEvent == NULL)
|
||||
{
|
||||
dwRet = ERROR_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
PnpEvent = NewPnpEvent;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtGetPlugPlayEvent() failed (Status 0x%08lx)\n", Status);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Process the PnP event */
|
||||
DPRINT("Received PnP Event\n");
|
||||
if (UuidEqual(&PnpEvent->EventGuid, (UUID*)&GUID_DEVICE_ENUMERATED, &RpcStatus))
|
||||
{
|
||||
DeviceInstallParams* Params;
|
||||
|
@ -174,6 +135,94 @@ PnpEventThread(LPVOID lpParameter)
|
|||
PnpEvent->EventGuid.Data4[3], PnpEvent->EventGuid.Data4[4], PnpEvent->EventGuid.Data4[5],
|
||||
PnpEvent->EventGuid.Data4[6], PnpEvent->EventGuid.Data4[7]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
ProcessDeviceClassChangeEvent(
|
||||
_In_ PPLUGPLAY_EVENT_BLOCK PnpEvent)
|
||||
{
|
||||
DPRINT("DeviceClassChangeEvent: %S\n", PnpEvent->DeviceClass.SymbolicLinkName);
|
||||
|
||||
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.Data4[0], PnpEvent->DeviceClass.ClassGuid.Data4[1], PnpEvent->DeviceClass.ClassGuid.Data4[2],
|
||||
PnpEvent->DeviceClass.ClassGuid.Data4[3], PnpEvent->DeviceClass.ClassGuid.Data4[4], PnpEvent->DeviceClass.ClassGuid.Data4[5],
|
||||
PnpEvent->DeviceClass.ClassGuid.Data4[6], PnpEvent->DeviceClass.ClassGuid.Data4[7]);
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
PnpEventThread(
|
||||
_In_ LPVOID lpParameter)
|
||||
{
|
||||
PLUGPLAY_CONTROL_USER_RESPONSE_DATA ResponseData = {0, 0, 0, 0};
|
||||
DWORD dwRet = ERROR_SUCCESS;
|
||||
NTSTATUS Status;
|
||||
PPLUGPLAY_EVENT_BLOCK PnpEvent, NewPnpEvent;
|
||||
ULONG PnpEventSize;
|
||||
|
||||
UNREFERENCED_PARAMETER(lpParameter);
|
||||
|
||||
PnpEventSize = 0x1000;
|
||||
PnpEvent = HeapAlloc(GetProcessHeap(), 0, PnpEventSize);
|
||||
if (PnpEvent == NULL)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
DPRINT("Calling NtGetPlugPlayEvent()\n");
|
||||
|
||||
/* Wait for the next PnP event */
|
||||
Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize);
|
||||
|
||||
/* Resize the buffer for the PnP event if it's too small */
|
||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
PnpEventSize += 0x400;
|
||||
NewPnpEvent = HeapReAlloc(GetProcessHeap(), 0, PnpEvent, PnpEventSize);
|
||||
if (NewPnpEvent == NULL)
|
||||
{
|
||||
dwRet = ERROR_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
PnpEvent = NewPnpEvent;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtGetPlugPlayEvent() failed (Status 0x%08lx)\n", Status);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Process the PnP event */
|
||||
DPRINT("Received PnP Event\n");
|
||||
switch (PnpEvent->EventCategory)
|
||||
{
|
||||
// case HardwareProfileChangeEvent:
|
||||
|
||||
case TargetDeviceChangeEvent:
|
||||
ProcessTargetDeviceEvent(PnpEvent);
|
||||
break;
|
||||
|
||||
case DeviceClassChangeEvent:
|
||||
ProcessDeviceClassChangeEvent(PnpEvent);
|
||||
break;
|
||||
|
||||
// case CustomDeviceEvent:
|
||||
// case DeviceInstallEvent:
|
||||
// case DeviceArrivalEvent:
|
||||
// case PowerEvent:
|
||||
// case VetoEvent:
|
||||
// case BlockedDriverEvent:
|
||||
|
||||
default:
|
||||
DPRINT1("Unsupported Event Category: %lu\n", PnpEvent->EventCategory);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Dequeue the current PnP event and signal the next one */
|
||||
Status = NtPlugPlayControl(PlugPlayControlUserResponse,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue