[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

svn path=/trunk/; revision=47064
This commit is contained in:
Cameron Gutman 2010-04-29 22:35:49 +00:00
parent 04c6b45023
commit 174a4670ea

View file

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