-
-
[旧帖] 异步IRP的完成例程没有目前的堆堆单元是什么意思?...... 0.00雪花
-
发表于: 2013-6-15 18:37 2867
-
我是菜鸟,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会修改一段任意的内存空间".这句该怎么理解
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
他的文章
赞赏
雪币:
留言: