// wdm.h
NTSTATUS MmAdvanceMdl(
[in, out] PMDL Mdl,
[in] ULONG NumberOfBytes
);
View the official Windows Driver Kit DDI referenceNo description available.
The MmAdvanceMdl routine advances the beginning of an MDL's virtual memory range by the specified number of bytes.
Mdl [in, out]Specifies the MDL to advance.
NumberOfBytes [in]Specifies the number of bytes to advance the beginning of the MDL.
MmAdvanceMdl returns an NTSTATUS code. The possible return values include:
| Return code | Description |
|---|---|
| STATUS_SUCCESS | The routine successfully advanced the beginning of the MDL. |
| STATUS_INVALID_PARAMETER_2 | The caller attempted to advance the beginning of the MDL past the end. |
MmAdvanceMdl advances only the beginning of the virtual memory address range. The ending address remains the same, and the length of the range is shrunk accordingly.
A higher-level driver can use MmAdvanceMdl under low-memory conditions when a lower-level driver can only partially complete a read/write request. The higher-level driver can use MmAdvanceMdl to advance past the part of the buffer that has already been read or written, and then reissue the IRP to complete the request. (The driver can, of course, repeat this process as many times as necessary.)
If MmAdvanceMdl advances past the initial page, any pages that MmAdvanceMdl passed are immediately unlocked, and the system virtual address that maps the MDL and the user address are also adjusted.
Use of MmAdvanceMdl can slow system performance. It must be used only when all of the following conditions hold:
Drivers that do not satisfy these conditions must instead use the IoBuildPartialMdl routine to complete any partially-successful I/O operations.