mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:55:41 +00:00
[NTOS:IO]
- Avoid excessive stack usage in IopInitializeDriverModule. svn path=/trunk/; revision=71157
This commit is contained in:
parent
d55cb36612
commit
519abb5b4a
1 changed files with 22 additions and 11 deletions
|
@ -463,8 +463,7 @@ IopInitializeDriverModule(
|
||||||
IN BOOLEAN FileSystemDriver,
|
IN BOOLEAN FileSystemDriver,
|
||||||
OUT PDRIVER_OBJECT *DriverObject)
|
OUT PDRIVER_OBJECT *DriverObject)
|
||||||
{
|
{
|
||||||
const WCHAR ServicesKeyName[] = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\";
|
static const WCHAR ServicesKeyName[] = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\";
|
||||||
WCHAR NameBuffer[MAX_PATH];
|
|
||||||
UNICODE_STRING DriverName;
|
UNICODE_STRING DriverName;
|
||||||
UNICODE_STRING RegistryKey;
|
UNICODE_STRING RegistryKey;
|
||||||
PDRIVER_INITIALIZE DriverEntry;
|
PDRIVER_INITIALIZE DriverEntry;
|
||||||
|
@ -477,7 +476,9 @@ IopInitializeDriverModule(
|
||||||
{
|
{
|
||||||
RegistryKey.Length = 0;
|
RegistryKey.Length = 0;
|
||||||
RegistryKey.MaximumLength = sizeof(ServicesKeyName) + ServiceName->Length;
|
RegistryKey.MaximumLength = sizeof(ServicesKeyName) + ServiceName->Length;
|
||||||
RegistryKey.Buffer = ExAllocatePool(PagedPool, RegistryKey.MaximumLength);
|
RegistryKey.Buffer = ExAllocatePoolWithTag(PagedPool,
|
||||||
|
RegistryKey.MaximumLength,
|
||||||
|
TAG_IO);
|
||||||
if (RegistryKey.Buffer == NULL)
|
if (RegistryKey.Buffer == NULL)
|
||||||
{
|
{
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
@ -487,26 +488,35 @@ IopInitializeDriverModule(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&RegistryKey, NULL);
|
RtlInitEmptyUnicodeString(&RegistryKey, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create ModuleName string */
|
/* Create ModuleName string */
|
||||||
if (ServiceName && ServiceName->Length > 0)
|
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)
|
if (FileSystemDriver != FALSE)
|
||||||
wcscpy(NameBuffer, FILESYSTEM_ROOT_NAME);
|
RtlAppendUnicodeToString(&DriverName, FILESYSTEM_ROOT_NAME);
|
||||||
else
|
else
|
||||||
wcscpy(NameBuffer, DRIVER_ROOT_NAME);
|
RtlAppendUnicodeToString(&DriverName, DRIVER_ROOT_NAME);
|
||||||
|
|
||||||
RtlInitUnicodeString(&DriverName, NameBuffer);
|
|
||||||
DriverName.MaximumLength = sizeof(NameBuffer);
|
|
||||||
|
|
||||||
RtlAppendUnicodeStringToString(&DriverName, ServiceName);
|
RtlAppendUnicodeStringToString(&DriverName, ServiceName);
|
||||||
|
|
||||||
DPRINT("Driver name: '%wZ'\n", &DriverName);
|
DPRINT("Driver name: '%wZ'\n", &DriverName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DriverName.Length = 0;
|
{
|
||||||
|
RtlInitEmptyUnicodeString(&DriverName, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
Status = IopCreateDriver(DriverName.Length > 0 ? &DriverName : NULL,
|
Status = IopCreateDriver(DriverName.Length > 0 ? &DriverName : NULL,
|
||||||
DriverEntry,
|
DriverEntry,
|
||||||
|
@ -515,6 +525,7 @@ IopInitializeDriverModule(
|
||||||
ModuleObject,
|
ModuleObject,
|
||||||
&Driver);
|
&Driver);
|
||||||
RtlFreeUnicodeString(&RegistryKey);
|
RtlFreeUnicodeString(&RegistryKey);
|
||||||
|
RtlFreeUnicodeString(&DriverName);
|
||||||
|
|
||||||
*DriverObject = Driver;
|
*DriverObject = Driver;
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue