[NTOSKRNL] Properly align VACB writes

Also simplify VACB reads alignment code.
Also add some sanity ASSERTs.
This commit is contained in:
Pierre Schweitzer 2018-09-23 10:31:01 +02:00
parent f7b9db0f66
commit 2a80ae2bb6
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -81,7 +81,7 @@ NTAPI
CcReadVirtualAddress (
PROS_VACB Vacb)
{
ULONG Size, Pages;
ULONG Size;
PMDL Mdl;
NTSTATUS Status;
IO_STATUS_BLOCK IoStatus;
@ -95,10 +95,11 @@ CcReadVirtualAddress (
}
Size = LargeSize.LowPart;
Pages = BYTES_TO_PAGES(Size);
ASSERT(Pages * PAGE_SIZE <= VACB_MAPPING_GRANULARITY);
Size = ROUND_TO_PAGES(Size);
ASSERT(Size <= VACB_MAPPING_GRANULARITY);
ASSERT(Size > 0);
Mdl = IoAllocateMdl(Vacb->BaseAddress, Pages * PAGE_SIZE, FALSE, FALSE, NULL);
Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
if (!Mdl)
{
return STATUS_INSUFFICIENT_RESOURCES;
@ -177,6 +178,10 @@ CcWriteVirtualAddress (
} while (++i < (Size >> PAGE_SHIFT));
}
Size = ROUND_TO_PAGES(Size);
ASSERT(Size <= VACB_MAPPING_GRANULARITY);
ASSERT(Size > 0);
Mdl = IoAllocateMdl(Vacb->BaseAddress, Size, FALSE, FALSE, NULL);
if (!Mdl)
{