过滤驱动 文件访问重定向方法

本文介绍了如何在文件过滤驱动中利用IoReplaceFileObjectName函数修改目标文件对象路径,实现文件访问重定向。通过设置IoStatus.Status为STATUS_REPARSE,促使IO管理器重新处理请求,这种方式常见于不同类型的文件过滤驱动操作。
摘要由CSDN通过智能技术生成

  在pre callback 中,使用IoReplaceFileObjectName 修改 Data->Iopb->TargetFileObject 文件路径, 然后:

                Data->IoStatus.Status = STATUS_REPARSE;
                Data->IoStatus.Information = IO_REPARSE;
                return FLT_PREOP_COMPLETE; // 返回 complete 因为 Status 是 reparse 因此IO管理器会重新进行一次文件访问。

这种 reparse 在其他类型的文件过滤驱动中也会用到。

To redirect a file-open or file-creation operation to another file, a file system filter driver does the following: 

In the handler of IRP_MJ_CREATE, obtains the file name (FileName field) from the FILE_OBJECT.
Replaces this name with the full name of the destination file.

This full name includes the name of the volume device object (for example, Device\HardDiskVolume0\Directory\MyFile.txt). You can substitute your own buffer to the existing FileName.Buffer present in the FILE_OBJECT. In this case, allocate your buffer from NonPaged pool memory, free t
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值