Minifilter how to change file size?

0

I am develop a minifilter to detect drag & drop file to harddisk. When user drag & drop file to drive:

  1. Change file name to a specified file name. Ex: redirect_file_name.txt
  2. Then I delete this file.

But the size of file redirect_file_name.txt does not change.

  1. If source file's size is 1GB, redirect_file_name.txt is 1GB
  2. If source file's size is 100MB, redirect_file_name.txt is 100MB

I change source name to redirect_file_name.txt by this post

How can I do to change the size of file redirect_file_name.txt?

UPDATE: Use FltSetInformationFile with FileAllocationInformation

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

But status is 0XC000000D (STATUS_INVALID_PARAMETER)

c++
windows
driver
minifilter
windows-kernel
asked on Stack Overflow Feb 3, 2015 by GSP • edited May 23, 2017 by Community

1 Answer

0

Use these code at IRP_MJ_SET_INFORMATION (as said on Remarks)

FILE_ALLOCATION_INFORMATION fileInformation;
fileInformation.AllocationSize.QuadPart = 1024; // Size of file
status = FltSetInformationFile( FltObjects->Instance,
                          FltObjects->FileObject,
                          &fileInformation,
                          sizeof(FILE_ALLOCATION_INFORMATION),
                          FileAllocationInformation);
answered on Stack Overflow Feb 3, 2015 by GSP • edited Feb 6, 2015 by GSP

User contributions licensed under CC BY-SA 3.0