How to get file size?

Hi All,

How to get the file size using the file object?

With Regards,
A.Ilamparithi.

> How to get the file size using the file object?

You must roll your own IRP_MJ_QUERY_INFORMATION
(FileEndOfFileInformation) to the lower FSD.
This will work when the file is open.

Or, optionally, look into the FCB (FileObject->FsContext)
which is actually FSRTL_COMMON_FCB_HEADER.
This structure contains the AllocationSize, FileSize
and the ValidDataLength values.
But I don’t know if this method is good enough.
The file must be open at least; then the FCB
must be valid (it means not set to some pseudo-value
by e.g. redirector).

L.