Author: cgutman Date: Fri Apr 30 00:35:49 2010 New Revision: 47064
URL: http://svn.reactos.org/svn/reactos?rev=47064&view=rev Log: [NTOSKRNL] - Fix a horrible casting bug - EventCategoryData1 is a pointer to a GUID not a pointer to a UNICODE_STRING - Convert the GUID into a UNICODE_STRING properly by using RtlStringFromGUID and pass that string to RtlCompareUnicodeString - Fix another bug which results in us sending EventCategoryHardwareProfileChange and EventCategoryTargetDeviceChange events to everyone registered for PnP notifications - Fixes sending EventCategoryDeviceInterfaceChange notifications that happen after calling IoRegisterPlugPlayNotification
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotif... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c [iso-8859-1] Fri Apr 30 00:35:49 2010 @@ -42,6 +42,8 @@ PLIST_ENTRY ListEntry; PVOID NotificationStructure; BOOLEAN CallCurrentEntry; + UNICODE_STRING GuidString; + NTSTATUS Status;
ASSERT(DeviceObject);
@@ -71,6 +73,13 @@ 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 @@ 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 @@ } KeReleaseGuardedMutex(&PnpNotifyListLock); ExFreePoolWithTag(NotificationStructure, TAG_PNP_NOTIFY); + if (EventCategory == EventCategoryDeviceInterfaceChange) + RtlFreeUnicodeString(&GuidString); }
/* PUBLIC FUNCTIONS **********************************************************/