在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