https://git.reactos.org/?p=reactos.git;a=commitdiff;h=543112008aafc40b34fd6…
commit 543112008aafc40b34fd68b43baa04645aeaaaf1
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Fri Dec 18 16:53:39 2020 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:22 2021 +0100
Fix physical memory section creation
---
ntoskrnl/mm/section.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index b709a50cd8d..b9242c6eade 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -2068,7 +2068,7 @@ MmCreatePhysicalMemorySection(VOID)
/*
* Create the section mapping physical memory
*/
- SectionSize.QuadPart = MmNumberOfPhysicalPages * PAGE_SIZE;
+ SectionSize.QuadPart = MmHighestPhysicalPage * PAGE_SIZE;
InitializeObjectAttributes(&Obj,
&Name,
OBJ_PERMANENT | OBJ_KERNEL_EXCLUSIVE,
@@ -2136,6 +2136,7 @@ MmCreatePhysicalMemorySection(VOID)
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(PhysSection);
+ return Status;
}
ObCloseHandle(Handle, KernelMode);
@@ -3654,16 +3655,17 @@ NtQuerySection(
Sbi.BaseAddress = (PVOID)Section->Address.StartingVpn;
Sbi.Attributes = 0;
- if (Section->u.Flags.Commit)
- Sbi.Attributes |= SEC_COMMIT;
- if (Section->u.Flags.Reserve)
- Sbi.Attributes |= SEC_RESERVE;
if (Section->u.Flags.File)
Sbi.Attributes |= SEC_FILE;
if (Section->u.Flags.Image)
Sbi.Attributes |= SEC_IMAGE;
- /* FIXME : Complete/test the list of flags passed back from NtCreateSection
*/
+ /* Those are not set *************
+ if (Section->u.Flags.Commit)
+ Sbi.Attributes |= SEC_COMMIT;
+ if (Section->u.Flags.Reserve)
+ Sbi.Attributes |= SEC_RESERVE;
+ **********************************/
if (Section->u.Flags.Image)
{
@@ -4005,8 +4007,9 @@ MmMapViewOfSection(IN PVOID SectionObject,
{
(*ViewSize) = Section->SizeOfSection.QuadPart - ViewOffset;
}
- else if (((*ViewSize)+ViewOffset) > Section->SizeOfSection.QuadPart)
+ else if ((ExGetPreviousMode() == UserMode) && (((*ViewSize)+ViewOffset)
> Section->SizeOfSection.QuadPart))
{
+ /* Dubious */
(*ViewSize) = MIN(Section->SizeOfSection.QuadPart - ViewOffset, SIZE_T_MAX
- PAGE_SIZE);
}
@@ -4329,8 +4332,16 @@ MmCreateSection (OUT PVOID * Section,
return STATUS_INVALID_PARAMETER_6;
}
- /* Did the caller pass a handle? */
- if (FileHandle)
+ /* Did the caller pass a file object ? */
+ if (FileObject)
+ {
+ /* Reference the object directly */
+ ObReferenceObject(FileObject);
+
+ /* We don't create image mappings with file objects */
+ AllocationAttributes &= ~SEC_IMAGE;
+ }
+ else
{
/* Reference the file handle to get the object */
Status = ObReferenceObjectByHandle(FileHandle,
@@ -4368,11 +4379,6 @@ MmCreateSection (OUT PVOID * Section,
DPRINT1("Creating image map with writers open on the
file!\n");
#endif
}
- else
- {
- /* Reference the object directly */
- ObReferenceObject(FileObject);
- }
}
else
{