From 93e60bc7315e44b30f0c5c20d03cc32e70525c39 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sun, 23 Mar 2014 17:33:01 +0000 Subject: [PATCH] [NTOS:PO] - Fix symbolic link name handling in PopAddRemoveSysCapsCallback. Fixes ACPI power button. CORE-8017 #resolve svn path=/trunk/; revision=62554 --- reactos/ntoskrnl/io/iomgr/deviface.c | 3 ++- reactos/ntoskrnl/po/events.c | 15 +-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/deviface.c b/reactos/ntoskrnl/io/iomgr/deviface.c index 4c4f6188e7b..f43d70f990d 100644 --- a/reactos/ntoskrnl/io/iomgr/deviface.c +++ b/reactos/ntoskrnl/io/iomgr/deviface.c @@ -739,7 +739,7 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, if (ReturnBuffer.Length + KeyName.Length + sizeof(WCHAR) > ReturnBuffer.MaximumLength) { PWSTR NewBuffer; - ReturnBuffer.MaximumLength = (USHORT)max(ReturnBuffer.MaximumLength * sizeof(WCHAR), + ReturnBuffer.MaximumLength = (USHORT)max(2 * ReturnBuffer.MaximumLength, (USHORT)(ReturnBuffer.Length + KeyName.Length + 2 * sizeof(WCHAR))); @@ -800,6 +800,7 @@ NextReferenceString: } /* Add final NULL to ReturnBuffer */ + NT_ASSERT(ReturnBuffer.Length <= ReturnBuffer.MaximumLength); if (ReturnBuffer.Length >= ReturnBuffer.MaximumLength) { PWSTR NewBuffer; diff --git a/reactos/ntoskrnl/po/events.c b/reactos/ntoskrnl/po/events.c index ed549be1e8f..4e01ca1cf32 100644 --- a/reactos/ntoskrnl/po/events.c +++ b/reactos/ntoskrnl/po/events.c @@ -162,8 +162,6 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure, BOOLEAN Arrival; ULONG Caps; NTSTATUS Status; - UNICODE_STRING DeviceName; - UNICODE_STRING DeviceNamePrefix = RTL_CONSTANT_STRING(L"\\??\\"); DPRINT("PopAddRemoveSysCapsCallback(%p %p)\n", NotificationStructure, Context); @@ -184,20 +182,10 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure, { DPRINT("Arrival of %wZ\n", Notification->SymbolicLinkName); - DeviceName.Length = 0; - DeviceName.MaximumLength = Notification->SymbolicLinkName->MaximumLength + DeviceNamePrefix.MaximumLength; - DeviceName.Buffer = ExAllocatePool(PagedPool, DeviceName.MaximumLength); - if (!DeviceName.Buffer) return STATUS_INSUFFICIENT_RESOURCES; - - RtlCopyUnicodeString(&DeviceName, &DeviceNamePrefix); - RtlAppendUnicodeStringToString(&DeviceName, Notification->SymbolicLinkName); - - DPRINT("Opening handle to %wZ\n", &DeviceName); - /* Open the device */ InitializeObjectAttributes( &ObjectAttributes, - &DeviceName, + Notification->SymbolicLinkName, OBJ_KERNEL_HANDLE, NULL, NULL); @@ -208,7 +196,6 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure, &IoStatusBlock, FILE_SHARE_READ | FILE_SHARE_WRITE, 0); - RtlFreeUnicodeString(&DeviceName); if (!NT_SUCCESS(Status)) { DPRINT1("ZwOpenFile() failed with status 0x%08lx\n", Status);