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(
__inout PMDLX 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. Set this parameter to IoReadAccess, IoWriteAccess, or IoModifyAccess. IoReadAccess indicates that the driver can examine the contents of the buffer but cannot change the contents. IoWriteAccess and IoModifyAccess, which are equivalent, indicate that the driver has both read and write access to the buffer.
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:
- If the specified memory range is paged to a backing store (disk, network, and so on), MmProbeAndLockPages makes it resident.
- The routine then confirms that the pages permit the operation specified by the Operation parameter.
- 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 describes 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