zylthinking
驱动牛犊
驱动牛犊
  • 注册日期2006-03-22
  • 最后登录2009-07-28
  • 粉丝0
  • 关注0
  • 积分62分
  • 威望9点
  • 贡献值0点
  • 好评度7点
  • 原创分0分
  • 专家分0分
阅读:1750回复:0

IoCompletion中有点搞不懂的逻辑

楼主#
更多 发布于:2008-06-30 11:51

本无(951285841) 11:47:35
        if ( (NT_SUCCESS( Irp->IoStatus.Status ) &&
             stackPointer->Control & SL_INVOKE_ON_SUCCESS) ||
             (!NT_SUCCESS( Irp->IoStatus.Status ) &&
             stackPointer->Control & SL_INVOKE_ON_ERROR) ||
             (Irp->Cancel &&
             stackPointer->Control & SL_INVOKE_ON_CANCEL)
           ) {

            //
            // This driver has specified a completion routine.  Invoke the
            // routine passing it a pointer to its device object and the
            // IRP that is being completed.
            //

            ZeroIrpStackLocation( stackPointer );

            if (Irp->CurrentLocation == (CCHAR) (Irp->StackCount + 1)) {
                deviceObject = NULL;
            }
            else {
                deviceObject = IoGetCurrentIrpStackLocation( Irp )->DeviceObject;
            }

            status = stackPointer->CompletionRoutine( deviceObject,
                                                      Irp,
                                                      stackPointer->Context );

            if (status == STATUS_MORE_PROCESSING_REQUIRED) {

                //
                // Note:  Notice that if the driver has returned the above
                //        status value, it may have already DEALLOCATED the
                //        packet!  Therefore, do NOT touch any part of the
                //        IRP in the following code.
                //

                return;
            }

        } else {
            if (Irp->PendingReturned && Irp->CurrentLocation <= Irp->StackCount) {
                IoMarkIrpPending( Irp );
            }
            ZeroIrpStackLocation( stackPointer );
        }
这段代码有点奇怪啊, 照这个逻辑, 如果一个过滤驱动这样编码: SetIoCompletion(...); return IoCallDriver(...);那么因为其设置了完成例程, 因此不会调用上面代码的else块, 而如果下一层驱动返回STATUS_PENDING, 则岂不是上层驱动很可能不会得到这个信息从而不进行DPC么
游客

返回顶部