Author: tfaber
Date: Thu Apr 14 15:18:53 2016
New Revision: 71157
URL:
http://svn.reactos.org/svn/reactos?rev=71157&view=rev
Log:
[NTOS:IO]
- Avoid excessive stack usage in IopInitializeDriverModule.
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 Apr 14 15:18:53 2016
@@ -463,8 +463,7 @@
IN BOOLEAN FileSystemDriver,
OUT PDRIVER_OBJECT *DriverObject)
{
- const WCHAR ServicesKeyName[] =
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\";
- WCHAR NameBuffer[MAX_PATH];
+ static const WCHAR ServicesKeyName[] =
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\";
UNICODE_STRING DriverName;
UNICODE_STRING RegistryKey;
PDRIVER_INITIALIZE DriverEntry;
@@ -477,7 +476,9 @@
{
RegistryKey.Length = 0;
RegistryKey.MaximumLength = sizeof(ServicesKeyName) + ServiceName->Length;
- RegistryKey.Buffer = ExAllocatePool(PagedPool, RegistryKey.MaximumLength);
+ RegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool,
+ RegistryKey.MaximumLength,
+ TAG_IO);
if (RegistryKey.Buffer == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -487,26 +488,35 @@
}
else
{
- RtlInitUnicodeString(&RegistryKey, NULL);
+ RtlInitEmptyUnicodeString(&RegistryKey, NULL, 0);
}
/* Create ModuleName string */
if (ServiceName && ServiceName->Length > 0)
{
+ DriverName.Length = 0;
+ DriverName.MaximumLength = sizeof(FILESYSTEM_ROOT_NAME) +
ServiceName->Length;
+ DriverName.Buffer = ExAllocatePoolWithTag(PagedPool,
+ DriverName.MaximumLength,
+ TAG_IO);
+ if (DriverName.Buffer == NULL)
+ {
+ RtlFreeUnicodeString(&RegistryKey);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
if (FileSystemDriver != FALSE)
- wcscpy(NameBuffer, FILESYSTEM_ROOT_NAME);
+ RtlAppendUnicodeToString(&DriverName, FILESYSTEM_ROOT_NAME);
else
- wcscpy(NameBuffer, DRIVER_ROOT_NAME);
-
- RtlInitUnicodeString(&DriverName, NameBuffer);
- DriverName.MaximumLength = sizeof(NameBuffer);
-
+ RtlAppendUnicodeToString(&DriverName, DRIVER_ROOT_NAME);
RtlAppendUnicodeStringToString(&DriverName, ServiceName);
DPRINT("Driver name: '%wZ'\n", &DriverName);
}
else
- DriverName.Length = 0;
+ {
+ RtlInitEmptyUnicodeString(&DriverName, NULL, 0);
+ }
Status = IopCreateDriver(DriverName.Length > 0 ? &DriverName : NULL,
DriverEntry,
@@ -515,6 +525,7 @@
ModuleObject,
&Driver);
RtlFreeUnicodeString(&RegistryKey);
+ RtlFreeUnicodeString(&DriverName);
*DriverObject = Driver;
if (!NT_SUCCESS(Status))