0

我正在开发一个微过滤器来检测拖放文件到硬盘。当用户将文件拖放到驱动器时​​:

  1. 将文件名更改为指定的文件名。例如:redirect_file_name.txt
  2. 然后我删除这个文件。

但是文件redirect_file_name.txt 的大小不会改变。

  1. 如果源文件大小为 1GB,redirect_file_name.txt 为 1GB
  2. 如果源文件大小为 100MB,redirect_file_name.txt 为 100MB

我通过这篇文章将源名称更改为 redirect_file_name.txt

如何更改文件 redirect_file_name.txt 的大小?

更新:将 FltSetInformationFile 与 FileAllocationInformation 一起使用

FILE_ALLOCATION_INFORMATION fileInformation;
fileInformation.AllocationSize.QuadPart = 1024;
status = FltSetInformationFile( FltObjects->Instance,
                          FltObjects->FileObject,
                          &fileInformation,
                          sizeof(FILE_ALLOCATION_INFORMATION),
                          FileAllocationInformation);

但状态是 0XC000000D (STATUS_INVALID_PARAMETER)

4

1 回答 1

0

在 IRP_MJ_SET_INFORMATION 使用这些代码(如备注中所述)

FILE_ALLOCATION_INFORMATION fileInformation;
fileInformation.AllocationSize.QuadPart = 1024; // Size of file
status = FltSetInformationFile( FltObjects->Instance,
                          FltObjects->FileObject,
                          &fileInformation,
                          sizeof(FILE_ALLOCATION_INFORMATION),
                          FileAllocationInformation);
于 2015-02-03T09:51:12.000 回答