zxm1983123
驱动牛犊
驱动牛犊
  • 注册日期2005-10-20
  • 最后登录2008-01-22
  • 粉丝1
  • 关注0
  • 积分475分
  • 威望49点
  • 贡献值0点
  • 好评度47点
  • 原创分0分
  • 专家分0分
阅读:1465回复:4

异步IRP的问题

楼主#
更多 发布于:2007-09-26 14:11
请问一下,在文件系统过滤驱动中过滤IRP_MJ_READ,然后检查读到的数据,驱动中这样写:
 IoCopyCurrentIrpStackLocationToNext( Irp );
  IoSetCompletionRoutine(
            Irp,
            SfCreateCompletion,
            &waitEvent,
            TRUE,
            TRUE,
            TRUE );
        status = IoCallDriver( devExt->NLExtHeader.AttachedToDeviceObject, Irp );
        if (STATUS_PENDING == status) {
            NTSTATUS localStatus = KeWaitForSingleObject( &waitEvent,
                                                          Executive,
                                                          KernelMode,
                                                          FALSE,
                                                          NULL );
            ASSERT(STATUS_SUCCESS == localStatus);
        }
如果应用层中是一OVERLAPPED的方式打开的,按照异步操作的理解,ReadFile应该马上就返回的。但是过滤驱动中对READ操作,直到读出数据后才返回,那么是不是由于这个过滤驱动的存在,会造成异步操作失效?
michaelgz
论坛版主
论坛版主
  • 注册日期2005-01-26
  • 最后登录2012-10-22
  • 粉丝1
  • 关注1
  • 积分150分
  • 威望1524点
  • 贡献值1点
  • 好评度213点
  • 原创分0分
  • 专家分2分
沙发#
发布于:2007-09-26 22:59
You are right, READ IRP can be either synchronous or asynchronous. In kernel, the IRP synchronous flag should be checked to decide whether the IRP should be blocked or pended and queued.

But since there's read ahead logic and lazy writer implemented in IO sub-system. Most of the times, user mode applications won't see differences even FSFD blocks asynchronous IRPs though it's not a correct way which may lead to dead lock potentially.
zxm1983123
驱动牛犊
驱动牛犊
  • 注册日期2005-10-20
  • 最后登录2008-01-22
  • 粉丝1
  • 关注0
  • 积分475分
  • 威望49点
  • 贡献值0点
  • 好评度47点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2007-09-27 19:54
敢问大哥这段话是出自何处,呵呵,我想把这本书找来读读
michaelgz
论坛版主
论坛版主
  • 注册日期2005-01-26
  • 最后登录2012-10-22
  • 粉丝1
  • 关注1
  • 积分150分
  • 威望1524点
  • 贡献值1点
  • 好评度213点
  • 原创分0分
  • 专家分2分
地板#
发布于:2007-09-27 22:56
How about from my non-published working journal. :)

If you want to read books, I recommend "NT File System Internals" and "Windows Internals" 4th Edition.
yaolixing
驱动小牛
驱动小牛
  • 注册日期2006-06-27
  • 最后登录2010-07-15
  • 粉丝1
  • 关注0
  • 积分991分
  • 威望135点
  • 贡献值0点
  • 好评度124点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2007-10-03 19:43
使用系统线程可以实现异步操作。
可以参看filedisk源码
游客

返回顶部