-
-
[旧帖] 异步IRP的完成例程没有目前的堆堆单元是什么意思?...... 0.00雪花
-
发表于: 2013-6-15 18:37 2756
-
我是菜鸟,walter Oney的驱动书,第5章.完成例程这一节.
A variation on this idea occurs when you create an asynchronous IRP of some kind. You’re supposed to provide a completion routine to free the IRP, and you’ll necessarily return STATUS_MORE_PROCESSING_REQUIRED from that completion routine to prevent IoCompleteRequest from attempting to do any more work on an IRP that has disappeared:
SOMETYPE SomeFunction()
{
PIRP Irp = IoBuildAsynchronousFsdRequest(...);
IoSetCompletionRoutine(Irp, MyCompletionRoutine, ...);
IoCallDriver(...);
}
NTSTATUS MyCompletionRoutine(PDEVICE_OBJECT junk, PIRP Irp,
PVOID context)
{
if (Irp->PendingReturned)
IoMarkIrpPending(Irp); // <== oops!
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
The problem here is that there is no current stack location inside this completion routine! Consequently,
"问题在于完成例程没有目前的堆栈单元,因此,IoMarkIRPPending会修改一段任意的内存空间".这句该怎么理解
A variation on this idea occurs when you create an asynchronous IRP of some kind. You’re supposed to provide a completion routine to free the IRP, and you’ll necessarily return STATUS_MORE_PROCESSING_REQUIRED from that completion routine to prevent IoCompleteRequest from attempting to do any more work on an IRP that has disappeared:
SOMETYPE SomeFunction()
{
PIRP Irp = IoBuildAsynchronousFsdRequest(...);
IoSetCompletionRoutine(Irp, MyCompletionRoutine, ...);
IoCallDriver(...);
}
NTSTATUS MyCompletionRoutine(PDEVICE_OBJECT junk, PIRP Irp,
PVOID context)
{
if (Irp->PendingReturned)
IoMarkIrpPending(Irp); // <== oops!
IoFreeIrp(Irp);
return STATUS_MORE_PROCESSING_REQUIRED;
}
The problem here is that there is no current stack location inside this completion routine! Consequently,
"问题在于完成例程没有目前的堆栈单元,因此,IoMarkIRPPending会修改一段任意的内存空间".这句该怎么理解
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
他的文章
看原图
赞赏
雪币:
留言: