Windows Driver Kit: Kernel-Mode Driver Architecture
MmProbeAndLockPages

The MmProbeAndLockPages routine probes the specified virtual memory pages, makes them resident, and locks them in memory.

VOID 
  MmProbeAndLockPages(
    IN OUT PMDL  MemoryDescriptorList,
    IN KPROCESSOR_MODE  AccessMode,
    IN LOCK_OPERATION  Operation
    );

Parameters

MemoryDescriptorList
Pointer to an MDL that specifies a virtual memory buffer. If the routine successfully locks the pages in memory, the MDL is updated to describe the underlying physical pages.
AccessMode
Specifies the access mode in which to probe the arguments, either KernelMode or UserMode.
Operation
Specifies the type of operation for which the caller wants the access rights probed and the pages locked, one of IoReadAccess, IoWriteAccess, or IoModifyAccess.

Return Value

None

Comments

The highest-level driver in a chain of layered drivers that use direct I/O calls this routine. Drivers that use buffered I/O never call MmProbeAndLockPages.

MmProbeAndLockPages performs the following operations:

  1. If the specified memory range is paged to a backing store (disk, network, and so on), MmProbeAndLockPages makes it resident.
  2. The routine then confirms that the pages permit the operation specified by the Operation parameter.
  3. If the memory range permits the specified operation, the routine locks the pages in memory so that they cannot be paged out. Use MmUnlockPages to unlock the pages.

MmProbeAndLockPages can be called multiple times for the same page. Each successful call to MmProbeAndLockPages for an MDL must be matched by a call to MmUnlockPages for the same MDL.

Calls to MmProbeAndLockPages must be enclosed in a try/except block. If the pages do not support the specified operation, the routine raises the STATUS_ACCESS_VIOLATION or other exceptions. For more information, see Handling Exceptions.

Callers of MmProbeAndLockPages must be running at IRQL <= APC_LEVEL for pageable addresses, or at IRQL <= DISPATCH_LEVEL for nonpageable addresses.

This routine does not provide any guarantees about the virtual address that describe these pages (that is, the virtual address might be unmapped, reused, and so on). However, the physical pages are guaranteed to be locked on successful return.

Requirements

IRQL: See Comments section.

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

See Also

MmUnlockPages


Send feedback on this topic
Built on October 01, 2009
Page view tracker