[NTOSKRNL] Fix indentation. No code changes!

This commit is contained in:
Eric Kohl 2019-08-24 10:02:55 +02:00
parent 6d2381631f
commit 0b129da05c

View file

@ -34,196 +34,195 @@ LIST_ENTRY PnpNotifyListHead;
VOID VOID
IopNotifyPlugPlayNotification( IopNotifyPlugPlayNotification(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
IN LPCGUID Event, IN LPCGUID Event,
IN PVOID EventCategoryData1, IN PVOID EventCategoryData1,
IN PVOID EventCategoryData2) IN PVOID EventCategoryData2)
{ {
PPNP_NOTIFY_ENTRY ChangeEntry; PPNP_NOTIFY_ENTRY ChangeEntry;
PLIST_ENTRY ListEntry; PLIST_ENTRY ListEntry;
PVOID NotificationStructure; PVOID NotificationStructure;
BOOLEAN CallCurrentEntry; BOOLEAN CallCurrentEntry;
UNICODE_STRING GuidString; UNICODE_STRING GuidString;
NTSTATUS Status; NTSTATUS Status;
PDEVICE_OBJECT EntryDeviceObject = NULL; PDEVICE_OBJECT EntryDeviceObject = NULL;
ASSERT(DeviceObject); ASSERT(DeviceObject);
KeAcquireGuardedMutex(&PnpNotifyListLock); KeAcquireGuardedMutex(&PnpNotifyListLock);
if (IsListEmpty(&PnpNotifyListHead)) if (IsListEmpty(&PnpNotifyListHead))
{ {
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
return; return;
} }
switch (EventCategory) switch (EventCategory)
{ {
case EventCategoryDeviceInterfaceChange: case EventCategoryDeviceInterfaceChange:
{ {
PDEVICE_INTERFACE_CHANGE_NOTIFICATION NotificationInfos; PDEVICE_INTERFACE_CHANGE_NOTIFICATION NotificationInfos;
NotificationStructure = NotificationInfos = ExAllocatePoolWithTag( NotificationStructure = NotificationInfos = ExAllocatePoolWithTag(
PagedPool, PagedPool,
sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION), sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION),
TAG_PNP_NOTIFY); TAG_PNP_NOTIFY);
if (!NotificationInfos) if (!NotificationInfos)
{ {
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
return; return;
} }
NotificationInfos->Version = 1; NotificationInfos->Version = 1;
NotificationInfos->Size = sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION); NotificationInfos->Size = sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION);
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); Status = RtlStringFromGUID(&NotificationInfos->InterfaceClassGuid, &GuidString);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
ExFreePoolWithTag(NotificationStructure, TAG_PNP_NOTIFY); ExFreePoolWithTag(NotificationStructure, TAG_PNP_NOTIFY);
return; return;
} }
break; break;
} }
case EventCategoryHardwareProfileChange: case EventCategoryHardwareProfileChange:
{ {
PHWPROFILE_CHANGE_NOTIFICATION NotificationInfos; PHWPROFILE_CHANGE_NOTIFICATION NotificationInfos;
NotificationStructure = NotificationInfos = ExAllocatePoolWithTag( NotificationStructure = NotificationInfos = ExAllocatePoolWithTag(
PagedPool, PagedPool,
sizeof(HWPROFILE_CHANGE_NOTIFICATION), sizeof(HWPROFILE_CHANGE_NOTIFICATION),
TAG_PNP_NOTIFY); TAG_PNP_NOTIFY);
if (!NotificationInfos) if (!NotificationInfos)
{ {
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
return; return;
} }
NotificationInfos->Version = 1; NotificationInfos->Version = 1;
NotificationInfos->Size = sizeof(HWPROFILE_CHANGE_NOTIFICATION); NotificationInfos->Size = sizeof(HWPROFILE_CHANGE_NOTIFICATION);
RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID)); RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID));
break; break;
} }
case EventCategoryTargetDeviceChange: case EventCategoryTargetDeviceChange:
{ {
if (Event != &GUID_PNP_CUSTOM_NOTIFICATION) if (Event != &GUID_PNP_CUSTOM_NOTIFICATION)
{ {
PTARGET_DEVICE_REMOVAL_NOTIFICATION NotificationInfos; PTARGET_DEVICE_REMOVAL_NOTIFICATION NotificationInfos;
NotificationStructure = NotificationInfos = ExAllocatePoolWithTag( NotificationStructure = NotificationInfos = ExAllocatePoolWithTag(
PagedPool, PagedPool,
sizeof(TARGET_DEVICE_REMOVAL_NOTIFICATION), sizeof(TARGET_DEVICE_REMOVAL_NOTIFICATION),
TAG_PNP_NOTIFY); TAG_PNP_NOTIFY);
if (!NotificationInfos) if (!NotificationInfos)
{ {
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
return; return;
} }
NotificationInfos->Version = 1; NotificationInfos->Version = 1;
NotificationInfos->Size = sizeof(TARGET_DEVICE_REMOVAL_NOTIFICATION); NotificationInfos->Size = sizeof(TARGET_DEVICE_REMOVAL_NOTIFICATION);
RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID)); RtlCopyMemory(&NotificationInfos->Event, Event, sizeof(GUID));
} }
else else
{ {
PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationInfos; PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationInfos;
NotificationStructure = NotificationInfos = ExAllocatePoolWithTag( NotificationStructure = NotificationInfos = ExAllocatePoolWithTag(
PagedPool, PagedPool,
sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION), sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION),
TAG_PNP_NOTIFY); TAG_PNP_NOTIFY);
if (!NotificationInfos) if (!NotificationInfos)
{ {
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
return; return;
} }
RtlCopyMemory(NotificationInfos, EventCategoryData1, sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION)); RtlCopyMemory(NotificationInfos, EventCategoryData1, sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION));
} }
break; break;
} }
default: default:
{ {
DPRINT1("IopNotifyPlugPlayNotification(): unknown EventCategory 0x%x UNIMPLEMENTED\n", EventCategory); DPRINT1("IopNotifyPlugPlayNotification(): unknown EventCategory 0x%x UNIMPLEMENTED\n", EventCategory);
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
return; return;
} }
} }
/* Loop through procedures registred in PnpNotifyListHead /* Loop through procedures registred in PnpNotifyListHead
* list to find those that meet some criteria. * list to find those that meet some criteria.
*/ */
ListEntry = PnpNotifyListHead.Flink; ListEntry = PnpNotifyListHead.Flink;
while (ListEntry != &PnpNotifyListHead) while (ListEntry != &PnpNotifyListHead)
{ {
ChangeEntry = CONTAINING_RECORD(ListEntry, PNP_NOTIFY_ENTRY, PnpNotifyList); ChangeEntry = CONTAINING_RECORD(ListEntry, PNP_NOTIFY_ENTRY, PnpNotifyList);
CallCurrentEntry = FALSE; CallCurrentEntry = FALSE;
if (ChangeEntry->EventCategory != EventCategory) if (ChangeEntry->EventCategory != EventCategory)
{ {
ListEntry = ListEntry->Flink; ListEntry = ListEntry->Flink;
continue; continue;
} }
switch (EventCategory) switch (EventCategory)
{ {
case EventCategoryDeviceInterfaceChange: case EventCategoryDeviceInterfaceChange:
{ {
if (RtlCompareUnicodeString(&ChangeEntry->Guid, &GuidString, FALSE) == 0) if (RtlCompareUnicodeString(&ChangeEntry->Guid, &GuidString, FALSE) == 0)
{ {
CallCurrentEntry = TRUE; CallCurrentEntry = TRUE;
} }
break; break;
} }
case EventCategoryHardwareProfileChange: case EventCategoryHardwareProfileChange:
{ {
CallCurrentEntry = TRUE; CallCurrentEntry = TRUE;
break; break;
} }
case EventCategoryTargetDeviceChange: case EventCategoryTargetDeviceChange:
{ {
Status = IoGetRelatedTargetDevice(ChangeEntry->FileObject, &EntryDeviceObject); Status = IoGetRelatedTargetDevice(ChangeEntry->FileObject, &EntryDeviceObject);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
if (DeviceObject == EntryDeviceObject) if (DeviceObject == EntryDeviceObject)
{ {
if (Event == &GUID_PNP_CUSTOM_NOTIFICATION) if (Event == &GUID_PNP_CUSTOM_NOTIFICATION)
{ {
((PTARGET_DEVICE_CUSTOM_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject; ((PTARGET_DEVICE_CUSTOM_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject;
} }
else else
{ {
((PTARGET_DEVICE_REMOVAL_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject; ((PTARGET_DEVICE_REMOVAL_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject;
} }
CallCurrentEntry = TRUE; CallCurrentEntry = TRUE;
} }
} }
break; break;
} }
default: default:
{ {
DPRINT1("IopNotifyPlugPlayNotification(): unknown EventCategory 0x%x UNIMPLEMENTED\n", EventCategory); DPRINT1("IopNotifyPlugPlayNotification(): unknown EventCategory 0x%x UNIMPLEMENTED\n", EventCategory);
break; break;
} }
} }
/* Move to the next element now, as callback may unregister itself */ /* Move to the next element now, as callback may unregister itself */
ListEntry = ListEntry->Flink; ListEntry = ListEntry->Flink;
/* FIXME: If ListEntry was the last element and that callback registers /* FIXME: If ListEntry was the last element and that callback registers
* new notifications, those won't be checked... */ * new notifications, those won't be checked... */
if (CallCurrentEntry) if (CallCurrentEntry)
{ {
/* Call entry into new allocated memory */ /* Call entry into new allocated memory */
DPRINT("IopNotifyPlugPlayNotification(): found suitable callback %p\n", DPRINT("IopNotifyPlugPlayNotification(): found suitable callback %p\n",
ChangeEntry); ChangeEntry);
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
(ChangeEntry->PnpNotificationProc)( (ChangeEntry->PnpNotificationProc)(NotificationStructure,
NotificationStructure, ChangeEntry->Context);
ChangeEntry->Context); KeAcquireGuardedMutex(&PnpNotifyListLock);
KeAcquireGuardedMutex(&PnpNotifyListLock); }
}
} }
KeReleaseGuardedMutex(&PnpNotifyListLock); KeReleaseGuardedMutex(&PnpNotifyListLock);
ExFreePoolWithTag(NotificationStructure, TAG_PNP_NOTIFY); ExFreePoolWithTag(NotificationStructure, TAG_PNP_NOTIFY);
if (EventCategory == EventCategoryDeviceInterfaceChange) if (EventCategory == EventCategoryDeviceInterfaceChange)
RtlFreeUnicodeString(&GuidString); RtlFreeUnicodeString(&GuidString);
} }
/* PUBLIC FUNCTIONS **********************************************************/ /* PUBLIC FUNCTIONS **********************************************************/
@ -280,7 +279,7 @@ IoRegisterPlugPlayNotification(IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
if (EventCategory == EventCategoryDeviceInterfaceChange && if (EventCategory == EventCategoryDeviceInterfaceChange &&
EventCategoryFlags & PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES) EventCategoryFlags & PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES)
{ {
DEVICE_INTERFACE_CHANGE_NOTIFICATION NotificationInfos; DEVICE_INTERFACE_CHANGE_NOTIFICATION NotificationInfos;