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)));
}
/* Add final NULL to ReturnBuffer */
+ NT_ASSERT(ReturnBuffer.Length <= ReturnBuffer.MaximumLength);
if (ReturnBuffer.Length >= ReturnBuffer.MaximumLength)
{
PWSTR NewBuffer;
BOOLEAN Arrival;
ULONG Caps;
NTSTATUS Status;
- UNICODE_STRING DeviceName;
- UNICODE_STRING DeviceNamePrefix = RTL_CONSTANT_STRING(L"\\??\\");
DPRINT("PopAddRemoveSysCapsCallback(%p %p)\n",
NotificationStructure, Context);
{
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);
&IoStatusBlock,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0);
- RtlFreeUnicodeString(&DeviceName);
if (!NT_SUCCESS(Status))
{
DPRINT1("ZwOpenFile() failed with status 0x%08lx\n", Status);