微型过滤器将文件拖放到磁盘? [英] Mini-Filter intercept drag & drop file(s) to disk?

查看:252
本文介绍了微型过滤器将文件拖放到磁盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个小型过滤器来拦截文件并获取文件名称删除到特定磁盘并获取文件名。



如果我拖动&删除一个文件,我可以得到这个文件名并拦截它成功(这意味着这个文件不是在磁盘上创建的)。



如果我拖动&删除多个文件,我只能获得第一个文件名,而其他不是。但是当我打开磁盘,我没有看到任何文件在这里(这意味着Mini-Filter拦截他们成功)。 所以我无法获取文件名(除了第一个文件)



我截取拖动&


$ b
  • 通过FltGetFileNameInformation(),FltParseFileNameInformation()获取文件名

  • 它两部分

    • 第一个是:\Device\HarddiskVolume1\folder\

    • 第二个是file.ext


  • 为第一部分附加文件名:\Device\HarddiskVolume1\folder\\\
    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;


  • 上述代码只能拦截所有文件并获取第一个文件名。



    我如何做,当我拖动&删除多个文件?

    解决方案

    我发现:


    1. 从Data-> Iopb-> TargetFileObject-> FileName获取文件名


      • 文件路径和文件名

      • 将文件名更改为重定向文件名


    2. 删除重定向文件名。此步骤可以在步骤#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:

    1. Get file name by FltGetFileNameInformation() then FltParseFileNameInformation()
    2. Split it two part
      • First is: \Device\HarddiskVolume1\folder\
      • Second is: file.ext
    3. Append a file name for first part: \Device\HarddiskVolume1\folder\new_file.ext
    4. 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:

    1. 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
    2. 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆