过滤驱动 文件访问重定向方法
来源:互联网 发布:淘宝货源免费代理代销 编辑:程序博客网 时间:2024/05/21 12:48
在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 the original FileName.Buffer by using ExFreePool, and then replace FileName.Buffer with your buffer.
Sets the status field of the IoStatus block to STATUS_REPARSE, and then sets the Information field to IO_REPARSE.
Completes the request.
Returns STATUS_REPARSE.
The IO Manager then triggers another file-open operation and sends an IRP_MJ_CREATE, taking into account the particular file name.
The destination file can be local or on a remote computer. To redirect the file-open operation to a remote file, use the following syntax for the file name:
"\??\UNC\HostName\Share\File"
-or-
"\Device\Mup\HostName\Share\File"
-or-
"\Device\LanmanagerRedirector\HostName\Share\File" (assuming you are targeting a file on CIFS/SMB/LanManager)
The fact that the first create-file operation is performed relative to another file object does not matter. Do not modify the RelatedFileObject field of the FILE_OBJECT. To perform the reparse operation, the IO Manager considers only the FileName field and not the RelatedFileObject. Additionally, the IO Manager frees the RelatedFileObject, as appropriate, when it handles the STATUS_REPARSE status returned by the filter. Therefore, it is not the responsibility of the filter to free that file object.
There is a fixed limit concerning the number of nested reparse operations that the IO Manager can perform. This limit has been introduced to avoid infinite loops. The maximum number of nested reparse operations the system can perform is 32.
This reparsing method performed by the IO Manager has to be disassociated from reparse points. Reparse points have been introduced in NTFS, starting with Microsoft Windows 2000. Reparse points permit you to store information together with a file.
0 0
- 过滤驱动 文件访问重定向方法
- 基于文件过滤驱动的文件重定向
- 文件重定向(采用文件过滤驱动实现)
- 基于文件过滤驱动的文件重定向
- 文件过滤驱动实现目录重定向(一)
- 文件过滤驱动实现目录重定向(二)
- 文件过滤驱动实现目录重定向(三)
- 重定向方式访问文件
- 文件过滤驱动中的重入处理
- 文件过滤驱动中的重入处理
- 文件过滤驱动中的重入处理
- 【原创】内核驱动文件重定向 加图加代码
- 过滤驱动实现目录重定向之(完整版本程序下载以及使用)
- linux平台用VFS驱动实现目录重定向(文件驱动实现目录重定向 四)
- 重定向文件
- 重定向hosts文件
- shell 文件重定向
- 文件重定向总结
- java实现堆排序的小心得
- Android 百度地图marker中图片不显示的解决方案
- Android使用RxJava+Retrofit请求网络的小Demo
- 三种常见字符编码简介:ASCII、Unicode和UTF-8
- okHttp3.0获取网络数据
- 过滤驱动 文件访问重定向方法
- oop
- BZOJ 1036 [ZJOI2008]树的统计Count
- CorelDRAW中六种复制对象的方法分享
- Mimetype 对照表
- 每日一题 No.23 字符串学习
- 41
- 自动安装RED HAT ENTERPRISE LINUX
- 进程 、进程组、会话、控制终端之间的关系