diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index fbe571b44f9..0b0891aea7a 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -239,39 +239,44 @@ IopNormalizeImagePath( PUNICODE_STRING ImagePath, _In_ PUNICODE_STRING ServiceName) { + UNICODE_STRING SystemRootString = RTL_CONSTANT_STRING(L"\\SystemRoot\\"); + UNICODE_STRING DriversPathString = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\drivers\\"); + UNICODE_STRING DotSysString = RTL_CONSTANT_STRING(L".sys"); UNICODE_STRING InputImagePath; DPRINT("Normalizing image path '%wZ' for service '%wZ'\n", ImagePath, ServiceName); - RtlCopyMemory(&InputImagePath, - ImagePath, - sizeof(UNICODE_STRING)); - + InputImagePath = *ImagePath; if (InputImagePath.Length == 0) { ImagePath->Length = 0; - ImagePath->MaximumLength = - (33 * sizeof(WCHAR)) + ServiceName->Length + sizeof(UNICODE_NULL); - ImagePath->Buffer = ExAllocatePool(NonPagedPool, - ImagePath->MaximumLength); + ImagePath->MaximumLength = DriversPathString.Length + + ServiceName->Length + + DotSysString.Length + + sizeof(UNICODE_NULL); + ImagePath->Buffer = ExAllocatePoolWithTag(NonPagedPool, + ImagePath->MaximumLength, + TAG_IO); if (ImagePath->Buffer == NULL) return STATUS_NO_MEMORY; - RtlAppendUnicodeToString(ImagePath, L"\\SystemRoot\\system32\\drivers\\"); + RtlCopyUnicodeString(ImagePath, &DriversPathString); RtlAppendUnicodeStringToString(ImagePath, ServiceName); - RtlAppendUnicodeToString(ImagePath, L".sys"); + RtlAppendUnicodeStringToString(ImagePath, &DotSysString); } else if (InputImagePath.Buffer[0] != L'\\') { ImagePath->Length = 0; - ImagePath->MaximumLength = - 12 * sizeof(WCHAR) + InputImagePath.Length + sizeof(UNICODE_NULL); - ImagePath->Buffer = ExAllocatePool(NonPagedPool, - ImagePath->MaximumLength); + ImagePath->MaximumLength = SystemRootString.Length + + InputImagePath.Length + + sizeof(UNICODE_NULL); + ImagePath->Buffer = ExAllocatePoolWithTag(NonPagedPool, + ImagePath->MaximumLength, + TAG_IO); if (ImagePath->Buffer == NULL) return STATUS_NO_MEMORY; - RtlAppendUnicodeToString(ImagePath, L"\\SystemRoot\\"); + RtlCopyUnicodeString(ImagePath, &SystemRootString); RtlAppendUnicodeStringToString(ImagePath, &InputImagePath); /* Free caller's string */ @@ -319,8 +324,7 @@ IopLoadServiceModule( ServiceStart = 0; /* IopNormalizeImagePath will do all of the work for us if we give it an empty string */ - ServiceImagePath.Length = ServiceImagePath.MaximumLength = 0; - ServiceImagePath.Buffer = NULL; + RtlInitEmptyUnicodeString(&ServiceImagePath, NULL, 0); } else {