CcSetFileSizesEx - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// ntifs.h

NTSTATUS CcSetFileSizesEx(
  PFILE_OBJECT   FileObject,
  PCC_FILE_SIZES FileSizes
);

View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-ntifs-ccsetfilesizesex)

Description

The CcSetFileSizesEx routine updates the cache maps and section object for a cached file whose size has changed.

Parameters

FileObject

[in] Pointer to a file object for the cached file.

FileSizes

[in] Pointer to a CC_FILE_SIZES structure containing the new file size information.

Return value

CcSetFileSizesEx returns STATUS_SUCCESS if the file size was successfully changed, and, if a purge was needed that the purge was successful. Otherwise it returns a non-success NSTATUS code such as STATUS_INSUFFICIENT_RESOURCES, and might raise a status exception.

Regarding raising a status exception on error:

Remarks

File systems must call CcSetFileSizesEx to update the cache manager data structures whenever one of the following changes is made to a cached file:

If the operation causes CcSetFileSizesEx to extend the section and a failure occurs, CcSetFileSizesEx raises a status exception for that particular failure. For example, if a pool allocation failure occurs, CcSetFileSizesEx raises a STATUS_INSUFFICIENT_RESOURCES exception. Therefore, to gain control if a failure occurs, the driver should wrap the call to CcSetFileSizesEx in a try-except or try-finally statement.

The file system must ensure that the cache map is valid and will remain so for the duration of this call.

To cache a file, use CcInitializeCacheMap.

To get the size of the cached file, pass FileObject to CcGetFileSizePointer.

See also

CcInitializeCacheMap

CcSetCacheFileSizes