CcCoherencyFlushAndPurgeCache function

The CcCoherencyFlushAndPurgeCache routine flushes and/or purges the cache to ensure cache coherency. Use CcCoherencyFlushAndPurgeCache when possible instead of an explicit flush and purge call sequence as it will invalidate user mapped views to prevent data corruption.

Syntax

void CcCoherencyFlushAndPurgeCache(
  PSECTION_OBJECT_POINTERS SectionObjectPointer,
  PLARGE_INTEGER           FileOffset,
  ULONG                    Length,
  PIO_STATUS_BLOCK         IoStatus,
  ULONG                    Flags
);

Parameters

SectionObjectPointer

A pointer to a structure that contains the section object pointers of the file object.

FileOffset

A pointer to a variable that specifies the starting byte offset to flush, purge, or both.

Length

The length, in bytes of the data to flush and/or purge starting at FileOffset. This parameter is ignored if a NULL pointer is passed to FileOffset.

IoStatus

A pointer to a caller-allocated structure that receives the final completion status and information about the operation.

Flags

A bitmask of flags that specify how the operation is to be performed. The one flag is defined in the following table.

Value Meaning
CC_FLUSH_AND_PURGE_NO_PURGE Flush, but do not purge the cache. This is useful for read coherency flushes.

Return Value

None

Remarks

The file must be acquired exclusively before you call CcCoherencyFlushAndPurgeCache.

You can flush and/or purge any byte range within a file by using the FileOffset and Length parameters. Or you can flush, purge, or both an entire file if you pass a NULL pointer to the FileOffset parameter.

A call to CcCoherencyFlushAndPurgeCache is a synchronous (blocking) operation, not an asynchronous (non-blocking) operation.

An IoStatus->Status value of STATUS_CACHE_PAGE_LOCKED indicates that page invalidation failed. Be aware that page invalidation can fail even if you pass CC_FLUSH_AND_PURGE_NO_PURGE in the Flags parameter.

Requirements

   
Minimum supported client Available in Windows 7 and later
Target Platform Universal
Header ntifs.h (include Ntifs.h, FltKernel.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL PASSIVE_LEVEL

See Also

CcFlushCache

CcPurgeCacheSection