lhzh114
驱动牛犊
驱动牛犊
  • 注册日期2004-02-20
  • 最后登录2008-12-27
  • 粉丝0
  • 关注0
  • 积分9分
  • 威望37点
  • 贡献值0点
  • 好评度11点
  • 原创分0分
  • 专家分0分
阅读:1149回复:3

奇怪,sfilter 中内容 和 ddk doc内容?

楼主#
更多 发布于:2005-01-26 22:00
sfilter.c 中 SfCreateCompletion 完成历程:
    if (NULL != event)  {

        KeSetEvent(event, IO_NO_INCREMENT, FALSE);
    }

     if (Irp->PendingReturned) {

        IoMarkIrpPending( Irp );
    }

而在ifs kit 2003文档中:
Using IRP Completion Routines
→→Constraints on Completion Routines下:
Unless the completion routine signals an event, it must check the Irp->PendingReturned flag. If this flag is set, the completion routine must call IoMarkIrpPending to mark the IRP as pending.

If a completion routine signals an event, it should not call IoMarkIrpPending

请高人解惑!
tooflat
论坛版主
论坛版主
  • 注册日期2002-07-08
  • 最后登录2014-03-11
  • 粉丝2
  • 关注0
  • 积分1007分
  • 威望551点
  • 贡献值3点
  • 好评度476点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2005-01-27 09:31
说的很清楚啊,除非你要signal event,否则的话你就要检查PendingReturned,并且根据PendingReturned调用IoMarkIrpPending,


因为通常signal event是用来通知某个线程该irp已经被下层驱动完成了,然后该线程继续对该irp处理。所以在完成例程中,取消irp的回溯过程,将irp的处理交给等待事件的线程处理。
所以完成例程中的代码如下:

CompletionRoutine()
{
// 通知等待线程,你可以继续处理该irp了
// 然后该irp需要等待线程来完成。调用iocompleterequest or iofreeirp
KeSetEvent(...)

// 取消irp的回溯过程,因为等待线程需要继续处理该irp
return STATUS_MORE_PROCESSING_REQUIRED;
}
lhzh114
驱动牛犊
驱动牛犊
  • 注册日期2004-02-20
  • 最后登录2008-12-27
  • 粉丝0
  • 关注0
  • 积分9分
  • 威望37点
  • 贡献值0点
  • 好评度11点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2005-01-27 15:59
是这样,多谢tooflat!

But:

If a completion routine signals an event, it should not call

如果完成历程 signal event,就不应该call IoMarkIrpPending

怎磨在 CompletionRoutine() 先signal event 后又 IoMarkIrpPending( Irp );

我的理解有问题吗? :D
tooflat
论坛版主
论坛版主
  • 注册日期2002-07-08
  • 最后登录2014-03-11
  • 粉丝2
  • 关注0
  • 积分1007分
  • 威望551点
  • 贡献值3点
  • 好评度476点
  • 原创分0分
  • 专家分0分
地板#
发布于:2005-01-28 09:28
你的理解没问题,不知道你的sfilter是哪个版本,我的和你不一样
游客

返回顶部