内核API笔记之IoBuildPartialMdl

IoBuildPartialMdl

VOID
IoBuildPartialMdl(
    __in PMDL SourceMdl,
    __inout PMDL TargetMdl,
    __in PVOID VirtualAddress,
    __in ULONG Length
    );

驱动程序可以使用IoBuildPartialMdl来把一个IRP请求分解成多个IRP请求. The physical pages that the source MDL describes must be locked before the driver calls IoBuildPartialMdl. Typically, the source MDL describes a buffer in user address space, and the driver calls the MmProbeAndLockPages routine to lock the pages in this buffer. However, the driver can build the source MDL from nonpaged memory by calling the MmBuildMdlForNonPagedPool, MmAllocatePagesForMdlEx, or MmAllocatePagesForMdl routine.

意思就是说,如果分配的内存是不可置换的,则没什么事情,需要注意的是,如果源MDL是用户空间的,那么必须使用MmProbeAndLockPages 函数来锁定内存。

驱动程序可以使用MmGetSystemAddressForMdlSafe 宏来映射一部分用户空间MDL到系统空间中。如果这一部分用户空间的源MDL已经映射到系统空间,那么MmGetSystemAddressForMdlSafe宏使用已存在的源映射。否则, MmGetSystemAddressForMdlSafe宏就会创建一个新的映射, 为了防止新映射的内存存在泄漏,驱动在重新使用那一部分的MDL之前必须调用MmPrepareMdlForReuse。另外, IoFreeMdl函数会释放系统地址空间的映射, 当然了,前提是这个映射必须要存在啊,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值