Modifying File Size on XP

Hi:

I’m coding a program for XP that modify the file’s size. I did it without
any problem in the IRP completion for IRP_MJ_DIRECTORY_CONTROL, but when
righ click the file in Windows Explorer and select “Properties”, the
information is still the original one. I tried to change it in the IRP
completion for IRP_MJ_QUERY_INFORMATION without success.

Below is an example for FileStandardInformation. I also tried
FileAllInformation:

//---------------------------------

case IRP_MJ_QUERY_INFORMATION:
if(pIrpStack->Parameters.QueryFile.FileInformationClass ==
FileStandardInformation) {

LARGE_INTEGER NewEof;
LARGE_INTEGER NewAllocSize;
PFILE_STANDARD_INFORMATION QueryBuffer = NULL;
ULONG offset = 0;
ULONG bufferLength = pIrpStack->Parameters.QueryFile.Length;
ULONG NewLength = 0;
ULONG NewSize = 9876; //any size here

QueryBuffer = (PFILE_STANDARD_INFORMATION)
Irp->AssociatedIrp.SystemBuffer;

NewEof.QuadPart = NewSize;
QueryBuffer->EndOfFile = NewEof;
NewAllocSize.QuadPart = NewSize;
QueryBuffer->AllocationSize = NewAllocSize;
}
break;

//---------------------------------

Can anybody give me a suggestion? What am I doing wrong?

Thanks in advance.

Pablo Frank

You need to update file size reported by FastIO routines as well.

Alexei.

“Pablo Frank” wrote in message news:xxxxx@ntfsd…
>
> Hi:
>
> I’m coding a program for XP that modify the file’s size. I did it without
> any problem in the IRP completion for IRP_MJ_DIRECTORY_CONTROL, but when
> righ click the file in Windows Explorer and select “Properties”, the
> information is still the original one. I tried to change it in the IRP
> completion for IRP_MJ_QUERY_INFORMATION without success.
>
> Below is an example for FileStandardInformation. I also tried
> FileAllInformation:
>
> //---------------------------------
>
> case IRP_MJ_QUERY_INFORMATION:
> if(pIrpStack->Parameters.QueryFile.FileInformationClass ==
> FileStandardInformation) {
>
> LARGE_INTEGER NewEof;
> LARGE_INTEGER NewAllocSize;
> PFILE_STANDARD_INFORMATION QueryBuffer = NULL;
> ULONG offset = 0;
> ULONG bufferLength = pIrpStack->Parameters.QueryFile.Length;
> ULONG NewLength = 0;
> ULONG NewSize = 9876; //any size here
>
> QueryBuffer = (PFILE_STANDARD_INFORMATION)
> Irp->AssociatedIrp.SystemBuffer;
>
> NewEof.QuadPart = NewSize;
> QueryBuffer->EndOfFile = NewEof;
> NewAllocSize.QuadPart = NewSize;
> QueryBuffer->AllocationSize = NewAllocSize;
> }
> break;
>
> //---------------------------------
>
> Can anybody give me a suggestion? What am I doing wrong?
>
> Thanks in advance.
>
> Pablo Frank
>
>