mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:23:03 +00:00
[NTOS:MM] Use image prefix in MmLoadSystemImage
MmLoadSystemImage has a PUNICODE_STRING NamePrefix parameter which is currently unused in ReactOS. When the kernel loads the crash dump storage stack drivers, the drivers will be loaded with MmLoadSystemImage with a "dump_" or "hiber_" (for hibernation, which uses crash dump stack too) prefix. This change adds in the prefix support, and is supposed to push crash dump support forward. CORE-376
This commit is contained in:
parent
543d390259
commit
346477fb3c
1 changed files with 49 additions and 4 deletions
|
@ -2900,7 +2900,7 @@ MmLoadSystemImage(IN PUNICODE_STRING FileName,
|
||||||
ULONG EntrySize, DriverSize;
|
ULONG EntrySize, DriverSize;
|
||||||
PLOAD_IMPORTS LoadedImports = MM_SYSLDR_NO_IMPORTS;
|
PLOAD_IMPORTS LoadedImports = MM_SYSLDR_NO_IMPORTS;
|
||||||
PCHAR MissingApiName, Buffer;
|
PCHAR MissingApiName, Buffer;
|
||||||
PWCHAR MissingDriverName;
|
PWCHAR MissingDriverName, PrefixedBuffer = NULL;
|
||||||
HANDLE SectionHandle;
|
HANDLE SectionHandle;
|
||||||
ACCESS_MASK DesiredAccess;
|
ACCESS_MASK DesiredAccess;
|
||||||
PSECTION Section = NULL;
|
PSECTION Section = NULL;
|
||||||
|
@ -2964,7 +2964,52 @@ MmLoadSystemImage(IN PUNICODE_STRING FileName,
|
||||||
PrefixName = *FileName;
|
PrefixName = *FileName;
|
||||||
|
|
||||||
/* Check if we have a prefix */
|
/* Check if we have a prefix */
|
||||||
if (NamePrefix) DPRINT1("Prefixed images are not yet supported!\n");
|
if (NamePrefix)
|
||||||
|
{
|
||||||
|
/* Check if "directory + prefix" is too long for the string */
|
||||||
|
Status = RtlUShortAdd(BaseDirectory.Length,
|
||||||
|
NamePrefix->Length,
|
||||||
|
&PrefixName.MaximumLength);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
|
goto Quickie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if "directory + prefix + basename" is too long for the string */
|
||||||
|
Status = RtlUShortAdd(PrefixName.MaximumLength,
|
||||||
|
BaseName.Length,
|
||||||
|
&PrefixName.MaximumLength);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
|
goto Quickie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate the buffer exclusively used for prefixed name */
|
||||||
|
PrefixedBuffer = ExAllocatePoolWithTag(PagedPool,
|
||||||
|
PrefixName.MaximumLength,
|
||||||
|
TAG_LDR_WSTR);
|
||||||
|
if (!PrefixedBuffer)
|
||||||
|
{
|
||||||
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
goto Quickie;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear out the prefixed name string */
|
||||||
|
PrefixName.Buffer = PrefixedBuffer;
|
||||||
|
PrefixName.Length = 0;
|
||||||
|
|
||||||
|
/* Concatenate the strings */
|
||||||
|
RtlAppendUnicodeStringToString(&PrefixName, &BaseDirectory);
|
||||||
|
RtlAppendUnicodeStringToString(&PrefixName, NamePrefix);
|
||||||
|
RtlAppendUnicodeStringToString(&PrefixName, &BaseName);
|
||||||
|
|
||||||
|
/* Now the base name of the image becomes the prefixed version */
|
||||||
|
BaseName.Buffer = &(PrefixName.Buffer[BaseDirectory.Length / sizeof(WCHAR)]);
|
||||||
|
BaseName.Length += NamePrefix->Length;
|
||||||
|
BaseName.MaximumLength = (PrefixName.MaximumLength - BaseDirectory.Length);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we already have a name, use it instead */
|
/* Check if we already have a name, use it instead */
|
||||||
if (LoadedName) BaseName = *LoadedName;
|
if (LoadedName) BaseName = *LoadedName;
|
||||||
|
@ -3406,8 +3451,8 @@ Quickie:
|
||||||
/* If we have a file handle, close it */
|
/* If we have a file handle, close it */
|
||||||
if (FileHandle) ZwClose(FileHandle);
|
if (FileHandle) ZwClose(FileHandle);
|
||||||
|
|
||||||
/* Check if we had a prefix (not supported yet - PrefixName == *FileName now) */
|
/* If we have allocated a prefixed name buffer, free it */
|
||||||
/* if (NamePrefix) ExFreePool(PrefixName.Buffer); */
|
if (PrefixedBuffer) ExFreePoolWithTag(PrefixedBuffer, TAG_LDR_WSTR);
|
||||||
|
|
||||||
/* Free the name buffer and return status */
|
/* Free the name buffer and return status */
|
||||||
ExFreePoolWithTag(Buffer, TAG_LDR_WSTR);
|
ExFreePoolWithTag(Buffer, TAG_LDR_WSTR);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue