wdm.h carries this comment:
// Notice that while in the context of the subject thread, the base virtual
// address of a buffer mapped by an MDL may be referenced using the
// following:
//
// Mdl->StartVa | Mdl->ByteOffset
//
Hence it is important that a mapped MDL has a valid StartVa field as well
as a valid MappedSystemVa field. Unfortunately, for reasons best known to
Microsoft, MmMapLockedPagesSpecifyCache() does not ensure this is the
case, so it needs to be fixed up by __AllocatePages() itself.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
if (MdlMappedSystemVa == NULL)
goto fail3;
- ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa);
+ Mdl->StartVa = PAGE_ALIGN(MdlMappedSystemVa);
+
+ ASSERT3U(Mdl->ByteOffset, ==, 0);
+ ASSERT3P(Mdl->StartVa, ==, MdlMappedSystemVa);
+ ASSERT3P(Mdl->MappedSystemVa, ==, MdlMappedSystemVa);
RtlZeroMemory(MdlMappedSystemVa, Mdl->ByteCount);