* MmProbeAndLockPages:
* @Mdl: Pointer to the #MDL specification structure to probe and lock.
* %NULL value is forbidden.
- * @AccessMode: Access at which to probe the pages. Ignored by libcaptive.
+ * @AccessMode: Access at which to lock the pages. %KernelMode required by libcaptive.
* @Operation: One of %IoReadAccess, %IoWriteAccess or %IoModifyAccess.
*
* Probles the specified @AccessMode and locks those pages specified by @Mdl to memory
VOID MmProbeAndLockPages(PMDL Mdl,KPROCESSOR_MODE AccessMode,LOCK_OPERATION Operation)
{
g_return_if_fail(Mdl!=NULL);
+ g_return_if_fail(AccessMode==KernelMode /* || AccessMode==UserMode */);
Mdl->MdlFlags|=MDL_PAGES_LOCKED;
}
* MmMapLockedPages:
* @Mdl: Pointer to the #MDL specification structure to map.
* %NULL value is forbidden.
- * @AccessMode: Access at which to lock the pages. Ignored by libcaptive.
+ * @AccessMode: Access at which to lock the pages. %KernelMode required by libcaptive.
*
* Leaves the pages at their original location as they are never moved anyway
* by libcaptive.
{
g_return_val_if_fail(Mdl!=NULL,NULL);
g_assert(Mdl->StartVa!=NULL);
+ g_return_val_if_fail(AccessMode==KernelMode /* || AccessMode==UserMode */ ,NULL);
if (Mdl->MdlFlags&MDL_MAPPED_TO_SYSTEM_VA) {
/* already mapped */
/**
- * @MmUnmapLockedPages:
- * BaseAddress: Address of the mapped pages base.
+ * MmUnmapLockedPages:
+ * @BaseAddress: Address of the mapped pages base.
* This offset does not neet to be %PAGE_SIZE aligned.
* @Mdl: Pointer to the #MDL specification structure to unmap.
*
{
g_return_if_fail(BaseAddress!=NULL);
g_return_if_fail(Mdl!=NULL);
- g_return_if_fail(Mdl->MdlFlags&MDL_MAPPED_TO_SYSTEM_VA);
- g_return_if_fail(BaseAddress!=Mdl->MappedSystemVa);
+ g_return_if_fail(BaseAddress==Mdl->MappedSystemVa);
+ /* No mapping is done for pages from MmBuildMdlForNonPagedPool(). */
+ if (Mdl->MdlFlags&MDL_SOURCE_IS_NONPAGED_POOL) {
+ g_return_if_fail(!(Mdl->MdlFlags&MDL_MAPPED_TO_SYSTEM_VA));
+ }
+ else {
+ g_return_if_fail(Mdl->MdlFlags&MDL_MAPPED_TO_SYSTEM_VA);
+ Mdl->MdlFlags&=~MDL_MAPPED_TO_SYSTEM_VA;
+ }
Mdl->MappedSystemVa=NULL;
- Mdl->MdlFlags&=~MDL_MAPPED_TO_SYSTEM_VA;
+}
+
+/**
+ * MmMapLockedPagesSpecifyCache:
+ * @Mdl: Pointer to the #MDL specification structure to map.
+ * %NULL value is forbidden.
+ * @AccessMode: Access at which to lock the pages. %KernelMode required by libcaptive.
+ * @CacheType: Suggested caching type. %MmNonCached, %MmCached or %MmWriteCombined required by libcaptive.
+ * @BaseAddress: Required block base address if @AccessMode is %UserMode. Ignored by libcaptive.
+ * @BugCheckOnFailure: Whether to call KeBugCheck() instead of returning %NULL. Ignored by libcaptive.
+ * @Priority: Suggested pages priority. %LowPagePriority, %NormalPagePriority or %HighPagePriority required by libcaptive.
+ *
+ * Leaves the pages at their original location as they are never moved anyway
+ * by libcaptive. This call is just a wrapper around MmMapLockedPages() in libcaptive.
+ *
+ * Returns: Address of the mapped pages base.
+ * This offset does not neet to be %PAGE_SIZE aligned.
+ */
+PVOID MmMapLockedPagesSpecifyCache(IN PMDL Mdl,
+ IN KPROCESSOR_MODE AccessMode,IN MEMORY_CACHING_TYPE CacheType,IN PVOID BaseAddress,
+ IN ULONG BugCheckOnFailure,IN MM_PAGE_PRIORITY Priority)
+{
+ g_return_val_if_fail(Mdl!=NULL,NULL);
+ g_return_val_if_fail(AccessMode==KernelMode /* || AccessMode==UserMode */ ,NULL);
+ g_return_val_if_fail(0
+ || CacheType==MmNonCached
+ || CacheType==MmCached
+ || CacheType==MmWriteCombined,
+ NULL);
+ g_return_val_if_fail(0
+ || Priority==LowPagePriority
+ || Priority==NormalPagePriority
+ || Priority==HighPagePriority,
+ NULL);
+
+ return MmMapLockedPages(Mdl,AccessMode);
}