Minifilter在预操作中重定向文件创建?

时间:2015-02-06 11:07:25

标签: c++ driver minifilter windows-kernel kernel-mode

我正在尝试将文件创建重定向到一卷硬盘上(即\ Device \ HarddiskVolume2)

我找到了redirecting file name in minifilter open pre。但是我得到了一个系统对话框,如下所示

enter image description here

这是我的代码:

// I tested with pFileName = &Data->Iopb->TargetFileObject->FileName;
// It has same result
pFileName = &FltObjects->FileObject->FileName;
if (pFileName->Buffer != NULL)
    ExFreePool(pFileName->Buffer);

// gRedirectFullFilePath is \\Device\\HarddiskVolume2\\File.ext
pFileName->Length = gRedirectFullFilePath.Length;
pFileName->MaximumLength = pFileName->Length;
pFileName->Buffer = (PWCH) ExAllocatePool(NonPagedPool, pFileName->MaximumLength);
if (pFileName->Buffer == NULL)
    goto PreOperationCleanup;

RtlCopyUnicodeString(pFileName, &gRedirectFullFilePath);

// Change I/O status
Data->IoStatus.Information = IO_REPARSE;
Data->IoStatus.Status = STATUS_REPARSE;
Data->Iopb->TargetFileObject->RelatedFileObject = NULL;

FltSetCallbackDataDirty(Data);

return FLT_PREOP_COMPLETE;

我希望此对话框不显示。我该怎么办?

非常感谢!

1 个答案:

答案 0 :(得分:1)

您应该从WDK8.1样本中查看SimRep File System Minifilter Driver示例。

例如,它会忽略卷打开( FO_VOLUME_OPEN )并打开目录( SL_OPEN_TARGET_DIRECTORY )。也许这会给你带来麻烦 它还使用IoReplaceFileObjectName替换文件对象的名称(应该比直接更改 FILE_OBJECT 更安全。)