kenli79
驱动小牛
驱动小牛
  • 注册日期2002-06-12
  • 最后登录2003-07-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:3074回复:9

求教,关于IRP_MJ_DIRECTORY_CONTROL

楼主#
更多 发布于:2002-06-19 16:50
我打算修改包的返回值,以对目录进行过滤,隐藏某些目录。普通情况下可以成功。
但是,我发现IRP_MJ_DIRECTORY_CONTROL基本上每次请求两次,第一次返回一条,第二次返回剩余的。当这个目录是某个硬盘的根目录时候,我真样删除这一条唯一的记录。
我试过的方法:
  1,直接给userbuffer=NULL, information=0,没任何效果
  2,将文件名修改成 \".\",出来一个奇怪的目录,打开显示根目录的东西
  3,将这条记录后的内存复制到userbuffer,然后userbuf=NULL,Explorer出错。

请大侠帮忙。
  
超级菜鸟!!!!!!!!!
Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-06-19 17:38
这是从OSR网站上拷来的,你看对你是否有帮助。
Q54 I am building a filter driver where I must change the directory information. How do I do that?
Filter drivers that manipulate the contents of directories must be careful to handle these operations properly because application behavior relies upon these very specific semantics. For example, it is an error to return STATUS_SUCCESS but to indicate that no data is being returned. Thus, if a filter determines that it does not wish to return the one entry within the buffer, it should re-issue the request to the underlying file system, rather than relying upon the application to handle this case correctly.

Normally, a filter driver would do this by intercepting the completion of a directory enumeration operation (IRP_MJ_DIRECTORY_CONTROL, IRP_MN_QUERY_DIRECTORY). In the completion routine it can signal the waiting thread in its dispatch entry point, post the IRP for additional processing, or process it directly in the completion routine.

Processing it directly in the completion routine might seem to be the most appealing solution, but it suffers from the standard problems of processing anything within a completion routine:

? The completion routine can be called at DISPATCH_LEVEL. Thus, the allowed operations are limited.
? The completion routine may be called in arbitrary context. Thus, the buffer may not be valid in the current context.

If a completion routine posts the IRP to a worker thread, it must ensure that either its dispatch routine returned STATUS_PENDING, or its dispatch routine blocks waiting for the worker thread to complete the I/O.
Tom_lyd
kenli79
驱动小牛
驱动小牛
  • 注册日期2002-06-12
  • 最后登录2003-07-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-06-19 21:38
非常感谢!
他说re-issue the request to the underlying file system。
我前面以及IoCallDriver了一次,我如何再调用一次下层驱动呢?
超级菜鸟!!!!!!!!!
Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-06-20 08:25
他的意思是在完成例程里再调和一次,你可能需要一个Worker Thread帮忙,因为完成例程不能做很多的事情,完成例程运行在arbitrary thread context,且很有可能是在DISPATCH_LEVEL.
Tom_lyd
kenli79
驱动小牛
驱动小牛
  • 注册日期2002-06-12
  • 最后登录2003-07-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2002-06-20 11:05
不好意思,完成例程里再调用一次,是指调用IoCallDriver么?
能不能详细解释一下。
超级菜鸟!!!!!!!!!
Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-06-20 11:23
我想意思是这样的:
你可以直接在IRP_MJ_DIRECTORY_CONTROL的IRP_MN_QUERY_DIRECTORY的完成例程里处理下层返回的内容,但是这会有很多潜在的问题存在:
1.完成例程运行非线程环境中,原始线程的内存在这里不再有效。
2.完成例程大多运行在DISPATCH_LEVEL级,不好处理,否则很可能引起诸如PAGE_FAULT的错误。
所以,OSR建议你重新处理这个IRP,当然是调用IoCallDriver一次,但是你要改变IRP中的请求参数。

希望对你有帮助。
Tom_lyd
kenli79
驱动小牛
驱动小牛
  • 注册日期2002-06-12
  • 最后登录2003-07-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2002-06-20 11:45
非常感谢,我再试试,可能还要再请教。
超级菜鸟!!!!!!!!!
kenli79
驱动小牛
驱动小牛
  • 注册日期2002-06-12
  • 最后登录2003-07-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2002-06-21 09:37
我终于尝到了自酿的苦果。我尝试修改了Parameters后,再次调用IoCallDriver,这些完全是在完成例程里完成的,并且我是直接返回,没有调用IoCompleteRequest。
使用SoftICE一步步调试是正确的,可是一运行,就蓝屏了。
超级菜鸟!!!!!!!!!
kenli79
驱动小牛
驱动小牛
  • 注册日期2002-06-12
  • 最后登录2003-07-06
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
8楼#
发布于:2002-06-21 10:11
我加上了IoCompleteRequest,还是蓝屏了。这次的蓝屏和前一次不太一样了,这次信息没有以前那么多。错误代码好像是MULTIPLE_IPR_XXX,后面的没有看清,我查DDK,IFS好像没有。是不是一定要用IoSetCompleteRoutine,请斑竹帮忙。谢谢!
超级菜鸟!!!!!!!!!
hellozhihua
驱动牛犊
驱动牛犊
  • 注册日期2010-03-20
  • 最后登录2010-09-27
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望81点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2010-05-13 22:30
楼主这个问题解决了吗?
游客

返回顶部