mirror of
https://github.com/reactos/reactos.git
synced 2024-06-28 08:51:29 +00:00
[NTOS:IO]
- Avoid excessive stack usage in IopInitializeDriverModule. svn path=/trunk/; revision=71157
This commit is contained in:
parent
d55cb36612
commit
519abb5b4a
|
@ -463,8 +463,7 @@ IopInitializeDriverModule(
|
|||
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 @@ IopInitializeDriverModule(
|
|||
{
|
||||
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 @@ IopInitializeDriverModule(
|
|||
}
|
||||
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 @@ IopInitializeDriverModule(
|
|||
ModuleObject,
|
||||
&Driver);
|
||||
RtlFreeUnicodeString(&RegistryKey);
|
||||
RtlFreeUnicodeString(&DriverName);
|
||||
|
||||
*DriverObject = Driver;
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
|
Loading…
Reference in a new issue