Optional Virtual Address for IoAllocateMdl

According to MSDN (https://msdn.microsoft.com/en-us/library/windows/hardware/ff548263(v=vs.85).aspx ) the VirtualAddress parameter of IoAllocateMdl is optional :

PMDL IoAllocateMdl(
In_opt PVOID VirtualAddress,
In ULONG Length,
In BOOLEAN SecondaryBuffer,
In BOOLEAN ChargeQuota,
Inout_opt PIRP Irp
);

Why is it optional? If we pass NULL for VirtualAddress, how does the allocated MDL ever know what address to describe?

It allocates an uninitialized MDL, with no reference to any data, but with the correct number of PFN slots to span the range. You might use an empty MDL with for example IoBuildPartialMdl.

Jan

On 11/10/15, 10:32 PM, “xxxxx@lists.osr.com on behalf of xxxxx@hotmail.com” wrote:

>According to MSDN (https://msdn.microsoft.com/en-us/library/windows/hardware/ff548263(v=vs.85).aspx ) the VirtualAddress parameter of IoAllocateMdl is optional :
>
>PMDL IoAllocateMdl(
> In_opt PVOID VirtualAddress,
> In ULONG Length,
> In BOOLEAN SecondaryBuffer,
> In BOOLEAN ChargeQuota,
> Inout_opt PIRP Irp
>);
>
>Why is it optional? If we pass NULL for VirtualAddress, how does the allocated MDL ever know what address to describe?

Note that the alignment of the virtual address will define whether it needs one more PFN slot.