Author: tfaber
Date: Thu Oct 23 22:05:56 2014
New Revision: 64946
URL:
http://svn.reactos.org/svn/reactos?rev=64946&view=rev
Log:
[NTOS:IO]
- Normalize, er.. simplify IopNormalizeImagePath a bit and use pool tagging
Modified:
trunk/reactos/ntoskrnl/io/iomgr/driver.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Thu Oct 23 22:05:56 2014
@@ -239,39 +239,44 @@
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 @@
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
{