@@ -746,6 +746,43 @@ NTSTATUS PhUnlockFileStream(
746
746
);
747
747
}
748
748
749
+ NTSTATUS PhSetAllocationSizeFileStream (
750
+ _Inout_ PPH_FILE_STREAM FileStream ,
751
+ _In_ PLARGE_INTEGER AllocationSize
752
+ )
753
+ {
754
+ NTSTATUS status ;
755
+ IO_STATUS_BLOCK isb ;
756
+ FILE_END_OF_FILE_INFORMATION endOfFileInfo ;
757
+ FILE_ALLOCATION_INFORMATION allocationInfo ;
758
+
759
+ memset (& endOfFileInfo , 0 , sizeof (FILE_END_OF_FILE_INFORMATION ));
760
+ endOfFileInfo .EndOfFile .QuadPart = AllocationSize -> QuadPart ;
761
+
762
+ if (!NT_SUCCESS (status = NtSetInformationFile (
763
+ FileStream -> FileHandle ,
764
+ & isb ,
765
+ & endOfFileInfo ,
766
+ sizeof (FILE_END_OF_FILE_INFORMATION ),
767
+ FileEndOfFileInformation
768
+ )))
769
+ return status ;
770
+
771
+ memset (& allocationInfo , 0 , sizeof (FILE_ALLOCATION_INFORMATION ));
772
+ allocationInfo .AllocationSize .QuadPart = AllocationSize -> QuadPart ;
773
+
774
+ if (!NT_SUCCESS (status = NtSetInformationFile (
775
+ FileStream -> FileHandle ,
776
+ & isb ,
777
+ & allocationInfo ,
778
+ sizeof (FILE_ALLOCATION_INFORMATION ),
779
+ FileAllocationInformation
780
+ )))
781
+ return status ;
782
+
783
+ return status ;
784
+ }
785
+
749
786
NTSTATUS PhWriteStringAsUtf8FileStream (
750
787
_Inout_ PPH_FILE_STREAM FileStream ,
751
788
_In_ PPH_STRINGREF String
0 commit comments