From e3b0a953196766445adbbe86520f206bc5f3222e Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Wed, 10 Aug 2016 11:52:30 +0000 Subject: [PATCH] [NTOSKRNL] While attempting to read data from disk in CcReadVirtualAddress(), always align our read size by pages. That means that even on boundaries, we will read a complete page. This fixes FSD relying on Cc to properly align reads and thus poorly failing in disk.sys because of unaligned reads. Notably, it helps MS FastFAT loading a bit farther in ReactOS (but it still fails :-(). This also fixes a few kmtests. CORE-11003 CORE-11819 svn path=/trunk/; revision=72186 --- reactos/ntoskrnl/cc/copy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/cc/copy.c b/reactos/ntoskrnl/cc/copy.c index c268304b2cb..7575991fe36 100644 --- a/reactos/ntoskrnl/cc/copy.c +++ b/reactos/ntoskrnl/cc/copy.c @@ -65,7 +65,7 @@ NTAPI CcReadVirtualAddress ( PROS_VACB Vacb) { - ULONG Size; + ULONG Size, Pages; PMDL Mdl; NTSTATUS Status; IO_STATUS_BLOCK IoStatus; @@ -77,7 +77,10 @@ CcReadVirtualAddress ( Size = VACB_MAPPING_GRANULARITY; } - Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL); + Pages = BYTES_TO_PAGES(Size); + ASSERT(Pages * PAGE_SIZE <= VACB_MAPPING_GRANULARITY); + + Mdl = IoAllocateMdl(Vacb->BaseAddress, Pages * PAGE_SIZE, FALSE, FALSE, NULL); if (!Mdl) { return STATUS_INSUFFICIENT_RESOURCES; -- 2.17.1