}
static FORCEINLINE PMDL
-__AllocatePage(
- VOID
+__AllocatePages(
+ IN ULONG Count
)
{
PHYSICAL_ADDRESS LowAddress;
LowAddress.QuadPart = 0ull;
HighAddress.QuadPart = ~0ull;
SkipBytes.QuadPart = 0ull;
- TotalBytes = (SIZE_T)PAGE_SIZE;
+ TotalBytes = (SIZE_T)PAGE_SIZE * Count;
Mdl = MmAllocatePagesForMdlEx(LowAddress,
HighAddress,
if (Mdl == NULL)
goto fail1;
- if (Mdl->ByteCount < PAGE_SIZE)
+ if (Mdl->ByteCount < TotalBytes)
goto fail2;
ASSERT((Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA |
if (MdlMappedSystemVa == NULL)
goto fail3;
- ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa);
+ Mdl->StartVa = PAGE_ALIGN(MdlMappedSystemVa);
- RtlZeroMemory(MdlMappedSystemVa, PAGE_SIZE);
+ ASSERT3U(Mdl->ByteOffset, ==, 0);
+ ASSERT3P(Mdl->StartVa, ==, MdlMappedSystemVa);
+ ASSERT3P(Mdl->MappedSystemVa, ==, MdlMappedSystemVa);
+
+ RtlZeroMemory(MdlMappedSystemVa, Mdl->ByteCount);
return Mdl;
return NULL;
}
+#define __AllocatePage() __AllocatePages(1)
+
static FORCEINLINE VOID
-__FreePage(
+__FreePages(
IN PMDL Mdl
)
{
ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
MdlMappedSystemVa = Mdl->MappedSystemVa;
- RtlFillMemory(MdlMappedSystemVa, PAGE_SIZE, 0xAA);
-
MmUnmapLockedPages(MdlMappedSystemVa, Mdl);
MmFreePagesFromMdl(Mdl);
+ ExFreePool(Mdl);
}
+#define __FreePage(_Mdl) __FreePages(_Mdl)
+
static FORCEINLINE PCHAR
__strtok_r(
IN PCHAR Buffer,