diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c b/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c index c328c80965f..f19f986e4e3 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c @@ -42,6 +42,8 @@ IopNotifyPlugPlayNotification( PLIST_ENTRY ListEntry; PVOID NotificationStructure; BOOLEAN CallCurrentEntry; + UNICODE_STRING GuidString; + NTSTATUS Status; ASSERT(DeviceObject); @@ -71,6 +73,13 @@ IopNotifyPlugPlayNotification( RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID)); RtlCopyMemory(&NotificationInfos->InterfaceClassGuid, EventCategoryData1, sizeof(GUID)); NotificationInfos->SymbolicLinkName = (PUNICODE_STRING)EventCategoryData2; + Status = RtlStringFromGUID(&NotificationInfos->InterfaceClassGuid, &GuidString); + if (!NT_SUCCESS(Status)) + { + KeReleaseGuardedMutex(&PnpNotifyListLock); + ExFreePool(NotificationStructure); + return; + } break; } case EventCategoryHardwareProfileChange: @@ -125,12 +134,17 @@ IopNotifyPlugPlayNotification( ChangeEntry = CONTAINING_RECORD(ListEntry, PNP_NOTIFY_ENTRY, PnpNotifyList); CallCurrentEntry = FALSE; + if (ChangeEntry->EventCategory != EventCategory) + { + ListEntry = ListEntry->Flink; + continue; + } + switch (EventCategory) { case EventCategoryDeviceInterfaceChange: { - if (ChangeEntry->EventCategory == EventCategory - && RtlCompareUnicodeString(&ChangeEntry->Guid, (PUNICODE_STRING)EventCategoryData1, FALSE) == 0) + if (RtlCompareUnicodeString(&ChangeEntry->Guid, &GuidString, FALSE) == 0) { CallCurrentEntry = TRUE; } @@ -174,6 +188,8 @@ IopNotifyPlugPlayNotification( } KeReleaseGuardedMutex(&PnpNotifyListLock); ExFreePoolWithTag(NotificationStructure, TAG_PNP_NOTIFY); + if (EventCategory == EventCategoryDeviceInterfaceChange) + RtlFreeUnicodeString(&GuidString); } /* PUBLIC FUNCTIONS **********************************************************/