[I8042PRT][RAMDISK] Fix usage of the RegistryPath in DriverEntry

We can't rely on it being zero-terminated, so ensure that it's
duplicated first before usage in RtlQueryRegistryValues
This commit is contained in:
Victor Perevertkin 2021-01-04 17:19:12 +03:00
parent e12233daf6
commit 06bff99edb
No known key found for this signature in database
GPG key ID: C750B7222E9C7830
2 changed files with 10 additions and 8 deletions

View file

@ -511,7 +511,7 @@ DriverEntry(
return Status;
}
Status = ReadRegistryEntries(RegistryPath, &DriverExtension->Port.Settings);
Status = ReadRegistryEntries(&DriverExtension->RegistryPath, &DriverExtension->Port.Settings);
if (!NT_SUCCESS(Status))
{
WARN_(I8042PRT, "ReadRegistryEntries() failed with status 0x%08lx\n", Status);

View file

@ -2419,18 +2419,20 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
NTSTATUS Status;
DPRINT("RAM Disk Driver Initialized\n");
/* Query ramdisk parameters */
QueryParameters(RegistryPath);
/* Save the registry path */
DriverRegistryPath = *RegistryPath;
DriverRegistryPath.MaximumLength = RegistryPath->Length + sizeof(UNICODE_NULL);
DriverRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool,
RegistryPath->Length +
sizeof(UNICODE_NULL),
DriverRegistryPath.MaximumLength,
'dmaR');
if (!DriverRegistryPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES;
if (!DriverRegistryPath.Buffer)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlCopyUnicodeString(&DriverRegistryPath, RegistryPath);
/* Query ramdisk parameters */
QueryParameters(&DriverRegistryPath);
/* Set device routines */
DriverObject->MajorFunction[IRP_MJ_CREATE] = RamdiskOpenClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = RamdiskOpenClose;