mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
don't leak the registry path string after initializing a driver
svn path=/trunk/; revision=15028
This commit is contained in:
parent
5267e6247e
commit
83a2899311
2 changed files with 44 additions and 17 deletions
|
@ -587,7 +587,26 @@ VideoPortInitialize(
|
||||||
}
|
}
|
||||||
DriverExtension->HwContext = HwContext;
|
DriverExtension->HwContext = HwContext;
|
||||||
|
|
||||||
RtlCopyMemory(&DriverExtension->RegistryPath, RegistryPath, sizeof(UNICODE_STRING));
|
/* we can't use RtlDuplicateUnicodeString because only ntdll exposes it... */
|
||||||
|
if (RegistryPath->Length != 0)
|
||||||
|
{
|
||||||
|
DriverExtension->RegistryPath.Length = 0;
|
||||||
|
DriverExtension->RegistryPath.MaximumLength = RegistryPath->Length + sizeof(UNICODE_NULL);
|
||||||
|
DriverExtension->RegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool,
|
||||||
|
DriverExtension->RegistryPath.MaximumLength,
|
||||||
|
TAG('U', 'S', 'T', 'R'));
|
||||||
|
if (DriverExtension->RegistryPath.Buffer == NULL)
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlCopyUnicodeString(&DriverExtension->RegistryPath, RegistryPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
switch (HwInitializationData->HwInitDataSize)
|
switch (HwInitializationData->HwInitDataSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -544,10 +544,29 @@ IopInitializeDriverModule(
|
||||||
IN BOOLEAN FileSystemDriver,
|
IN BOOLEAN FileSystemDriver,
|
||||||
OUT PDRIVER_OBJECT *DriverObject)
|
OUT PDRIVER_OBJECT *DriverObject)
|
||||||
{
|
{
|
||||||
|
const WCHAR ServicesKeyName[] = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\";
|
||||||
UNICODE_STRING RegistryKey;
|
UNICODE_STRING RegistryKey;
|
||||||
PDRIVER_INITIALIZE DriverEntry = ModuleObject->EntryPoint;
|
PDRIVER_INITIALIZE DriverEntry;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
WCHAR ServicesKeyName[] = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\";
|
|
||||||
|
DriverEntry = ModuleObject->EntryPoint;
|
||||||
|
|
||||||
|
if (ServiceName != NULL && ServiceName->Length != 0)
|
||||||
|
{
|
||||||
|
RegistryKey.Length = 0;
|
||||||
|
RegistryKey.MaximumLength = sizeof(ServicesKeyName) + ServiceName->Length;
|
||||||
|
RegistryKey.Buffer = ExAllocatePool(PagedPool, RegistryKey.MaximumLength);
|
||||||
|
if (RegistryKey.Buffer == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
RtlAppendUnicodeToString(&RegistryKey, ServicesKeyName);
|
||||||
|
RtlAppendUnicodeStringToString(&RegistryKey, ServiceName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&RegistryKey, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
Status = IopCreateDriverObject(
|
Status = IopCreateDriverObject(
|
||||||
DriverObject,
|
DriverObject,
|
||||||
|
@ -563,26 +582,15 @@ IopInitializeDriverModule(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServiceName->Buffer)
|
|
||||||
{
|
|
||||||
RegistryKey.Length = ServiceName->Length +
|
|
||||||
sizeof(ServicesKeyName) - sizeof(UNICODE_NULL);
|
|
||||||
RegistryKey.MaximumLength = RegistryKey.Length + sizeof(UNICODE_NULL);
|
|
||||||
RegistryKey.Buffer = ExAllocatePool(PagedPool, RegistryKey.MaximumLength);
|
|
||||||
wcscpy(RegistryKey.Buffer, ServicesKeyName);
|
|
||||||
wcscat(RegistryKey.Buffer, ServiceName->Buffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RtlInitUnicodeString(&RegistryKey, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("RegistryKey: %wZ\n", &RegistryKey);
|
DPRINT("RegistryKey: %wZ\n", &RegistryKey);
|
||||||
DPRINT("Calling driver entrypoint at %08lx\n", DriverEntry);
|
DPRINT("Calling driver entrypoint at %08lx\n", DriverEntry);
|
||||||
|
|
||||||
IopMarkLastReinitializeDriver();
|
IopMarkLastReinitializeDriver();
|
||||||
|
|
||||||
Status = DriverEntry(*DriverObject, &RegistryKey);
|
Status = DriverEntry(*DriverObject, &RegistryKey);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&RegistryKey);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ObMakeTemporaryObject(*DriverObject);
|
ObMakeTemporaryObject(*DriverObject);
|
||||||
|
|
Loading…
Reference in a new issue