https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ea354c4bc70cb7ee9302c…
commit ea354c4bc70cb7ee9302cfdd6a2c780b29639af8
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Wed Jan 27 17:02:43 2021 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:23 2021 +0100
[NTOS:MM] Unconditionally purge cache on image section creation.
---
ntoskrnl/mm/section.c | 60 ++++++---------------------------------------------
1 file changed, 6 insertions(+), 54 deletions(-)
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index 8515820e116..ff7d9438baa 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -2470,20 +2470,6 @@ ExeFmtpAllocateSegments(IN ULONG NrSegments)
return Segments;
}
-
-static NTSTATUS
-MmMapViewOfSegment(PMMSUPPORT AddressSpace,
- BOOLEAN AsImage,
- PMM_SECTION_SEGMENT Segment,
- PVOID* BaseAddress,
- SIZE_T ViewSize,
- ULONG Protect,
- LONGLONG ViewOffset,
- ULONG AllocationType);
-static NTSTATUS
-MmUnmapViewOfSegment(PMMSUPPORT AddressSpace,
- PVOID BaseAddress);
-
static
NTSTATUS
NTAPI
@@ -2538,45 +2524,14 @@ ExeFmtpReadFile(IN PVOID File,
return STATUS_INSUFFICIENT_RESOURCES;
}
- if (FileObject->SectionObjectPointer->DataSectionObject)
- {
- PVOID SegmentMap = NULL;
-
- /* Get the data from the file mapping instead */
- MmLockAddressSpace(MmGetKernelAddressSpace());
- Status = MmMapViewOfSegment(MmGetKernelAddressSpace(),
- FALSE,
-
FileObject->SectionObjectPointer->DataSectionObject,
- &SegmentMap,
- BufferSize,
- PAGE_READONLY,
- FileOffset.QuadPart,
- 0);
- MmUnlockAddressSpace(MmGetKernelAddressSpace());
-
- if (!NT_SUCCESS(Status))
- return Status;
-
- RtlCopyMemory(Buffer, SegmentMap, BufferSize);
- UsedSize = BufferSize;
-
- MmLockAddressSpace(MmGetKernelAddressSpace());
+ Status = MiSimpleRead(FileObject, &FileOffset, Buffer, BufferSize, TRUE,
&Iosb);
- MmUnmapViewOfSegment(MmGetKernelAddressSpace(), SegmentMap);
+ UsedSize = (ULONG)Iosb.Information;
- MmUnlockAddressSpace(MmGetKernelAddressSpace());
- }
- else
+ if(NT_SUCCESS(Status) && UsedSize < OffsetAdjustment)
{
- Status = MiSimpleRead(FileObject, &FileOffset, Buffer, BufferSize, TRUE,
&Iosb);
-
- UsedSize = (ULONG)Iosb.Information;
-
- if(NT_SUCCESS(Status) && UsedSize < OffsetAdjustment)
- {
- Status = STATUS_IN_PAGE_ERROR;
- ASSERT(!NT_SUCCESS(Status));
- }
+ Status = STATUS_IN_PAGE_ERROR;
+ ASSERT(!NT_SUCCESS(Status));
}
if(NT_SUCCESS(Status))
@@ -3175,10 +3130,7 @@ MmCreateImageSection(PSECTION *SectionObject,
MiReleasePfnLock(OldIrql);
/* Purge the cache */
- if (CcIsFileCached(FileObject))
- {
- CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, NULL);
- }
+ CcFlushCache(FileObject->SectionObjectPointer, NULL, 0, NULL);
StatusExeFmt = ExeFmtpCreateImageSection(FileObject, ImageSectionObject);