FsRtlGetFileSize function (ntifs.h)

The FsRtlGetFileSize routine is used to get the size of a file.


NTSTATUS FsRtlGetFileSize(
  [in]  PFILE_OBJECT   FileObject,
  [out] PLARGE_INTEGER FileSize


[in] FileObject

A pointer to the file object to query.

[out] FileSize

A pointer to a large integer that receives the file size on output.

Return value

FsRtlGetFileSize returns STATUS_SUCCESS or an appropriate error status representing the final completion status of the operation. Possible error status codes include the following:

Return code Description
The memory required for use by this function could not be allocated.
The specified FileObject refers to a directory.


The FsRtlGetFileSize routine is used to retrieve the file size for a file. Unlike ZwQueryInformationFile, FsRtlGetFileSize does not acquire the file object lock on synchronous file objects. If you already own file system resources, you should call FsRtlGetFileSize instead of ZwQueryInformationFile, because attempting to acquire the file object lock would violate locking order and lead to deadlocks. The ZwQueryInformationFile function should be only if you do not already own file system resources.

FsRtlGetFileSize will use fast I/O if it is supported or regular IRP-based query to extract the file size.


Requirement Value
Target Platform Universal
Header ntifs.h (include Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
DDI compliance rules HwStorPortProhibitedDDIs(storport), PowerIrpDDis(wdm)

See also