微型过滤器将文件拖放到磁盘? [英] Mini-Filter intercept drag & drop file(s) to disk?
问题描述
我正在开发一个小型过滤器来拦截文件并获取文件名称删除到特定磁盘并获取文件名。
如果我拖动&删除一个文件,我可以得到这个文件名并拦截它成功(这意味着这个文件不是在磁盘上创建的)。
如果我拖动&删除多个文件,我只能获得第一个文件名,而其他不是。但是当我打开磁盘,我没有看到任何文件在这里(这意味着Mini-Filter拦截他们成功)。 所以我无法获取文件名(除了第一个文件)
我截取拖动&
$ b
- 第一个是:\Device\HarddiskVolume1\folder\
- 第二个是file.ext
-
ew_file.ext
- 释放此缓冲区:Data-> Iopb-> TargetFileObject-> FileName.Buffer
- 第一部分到Data-> Iopb-> TargetFileObject-> FileName
- 设置为:Data-> Iopb-> TargetFileObject-> RelatedFileObject = NULL;
- Data-> IoStatus.Information = IO_REPARSE;
- Data-> IoStatus.Status = STATUS_REPARSE;
- 返回FLT_PREOP_SUCCESS_NO_CALLBACK;
上述代码只能拦截所有文件并获取第一个文件名。
我如何做,当我拖动&删除多个文件?
我发现:
-
从Data-> Iopb-> TargetFileObject-> FileName获取文件名
- 文件路径和文件名
- 将文件名更改为重定向文件名
-
删除重定向文件名。此步骤可以在步骤#1之前运行
- 如果重定向文件名不存在,则返回STATUS_OBJECT_NAME_NOT_FOUND(0xC0000034)。系统没有问题。
- 如果重定向文件名存在。可以。
I am developing a mini-filter to intercept files and get the name of files which are dragged & dropped to a specific disk and get the file names.
If I drag & drop a file, I can get this file name and intercept it successfully (That's mean this file is not created on disk).
If I drag & drop multiple files, I can only get the first file name and other is not. But when I open the disk, I don't see any file here (That's mean Mini-Filter intercept them successfully). So I can not get the file names (except the first file)
I intercept drag & drop by redirect them:
- Get file name by FltGetFileNameInformation() then FltParseFileNameInformation()
- Split it two part
- First is: \Device\HarddiskVolume1\folder\
- Second is: file.ext
- Append a file name for first part: \Device\HarddiskVolume1\folder\new_file.ext
- Intercept create on disk
- Release this buffer: Data->Iopb->TargetFileObject->FileName.Buffer
- Assign first part to Data->Iopb->TargetFileObject->FileName
- Set this: Data->Iopb->TargetFileObject->RelatedFileObject = NULL;
- Data->IoStatus.Information = IO_REPARSE;
- Data->IoStatus.Status = STATUS_REPARSE;
- return FLT_PREOP_SUCCESS_NO_CALLBACK;
Above code can only intercept all files and get the first file name.
How can I do to intercept each file when I drag & drop multiple file?
I found myself that:
Get file name from Data->Iopb->TargetFileObject->FileName
- Slipt it two part: file path and file name
- Change file name to a redirect file name
Delete redirect file name. This step can be run before step #1
- If redirect file name is not exist, It return STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034). It is not problem for system.
- If redirect file name is exist. It is OK.
这篇关于微型过滤器将文件拖放到磁盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!