https://git.reactos.org/?p=reactos.git;a=commitdiff;h=35c091adaf7ee70a57743…
commit 35c091adaf7ee70a57743f29ab288e3ca0881366
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Tue Feb 16 11:27:19 2021 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Fri Feb 26 08:46:53 2021 +0100
[NTOS:MM] Do not chunk-read files marked with FO_RANDOM_ACCESS
---
ntoskrnl/mm/section.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index 3f364b49f4d..ea56635b72f 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -1200,9 +1200,19 @@ MmMakeSegmentResident(
if (!NT_SUCCESS(Status))
return Status;
- RangeStart = Offset - (Offset % _64K);
- if (RangeEnd % _64K)
- RangeEnd += _64K - (RangeEnd % _64K);
+ /* If the file is not random access, read a 64K Chunk. */
+ if (!FlagOn(FileObject->Flags, FO_RANDOM_ACCESS))
+ {
+ RangeStart = Offset - (Offset % _64K);
+ if (RangeEnd % _64K)
+ RangeEnd += _64K - (RangeEnd % _64K);
+ }
+ else
+ {
+ RangeStart = Offset - (Offset % PAGE_SIZE);
+ if (RangeEnd % PAGE_SIZE)
+ RangeEnd += PAGE_SIZE - (RangeEnd % PAGE_SIZE);
+ }
/* Clamp if needed */
if (!FlagOn(*Segment->Flags, MM_DATAFILE_SEGMENT))