[NTOS:MM] Do not chunk-read files marked with FO_RANDOM_ACCESS

This commit is contained in:
Jérôme Gardou 2021-02-16 11:27:19 +01:00
parent f04890c2af
commit 35c091adaf

View file

@ -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))