AfterWriteFile Event

Fires after data is written to a file.

Syntax

virtual int FireAfterWriteFile(CBFilterAfterWriteFileEventParams *e);
typedef struct {
const char *FileName;
int64 Position;
const void *Buffer;
int BufferLength;
int BytesToWrite;
int Direction;
int BytesWritten;
int Status;
void *FileContext;
void *HandleContext;
int ResultCode; int reserved; } CBFilterAfterWriteFileEventParams;
virtual INT FireAfterWriteFile(CBFilterAfterWriteFileEventParams *e);
typedef struct {
LPCWSTR FileName;
LONG64 Position;
LPCVOID Buffer;
INT BufferLength;
INT BytesToWrite;
INT Direction;
INT BytesWritten;
INT Status;
LPVOID FileContext;
LPVOID HandleContext;
INT ResultCode; INT reserved; } CBFilterAfterWriteFileEventParams;

Remarks

This event fires after data is written to the file specified by FileName.

Applications may use this event to inspect the data that was written to the file, but must not attempt to alter said data. If, during BeforeWriteFile, an application causes less data than was requested to be written to the file, it should use this event to set BytesWritten back to the expected value (i.e., BytesToWrite) in order to prevent the requestor from behaving unexpectedly.

Applications only need to handle this event if they've added a standard filter rule that includes the FS_CE_AFTER_WRITE flag.

The Position parameter reflects the byte offset in the file at which writing started. A value of -1 means "append to the end of the file".

The Buffer parameter points to a memory buffer that contains the data that, if the request was successful, was written to the file. The BufferLength parameter reflects the capacity of Buffer, in bytes. Please refer to the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The BytesToWrite parameter reflects how many bytes were to be written to the file (i.e., how many bytes the requestor expects will be written).

The Direction parameter indicates the request direction; please refer to the Cached and Non-Cached Requests topic for more information. Possible values are:

FS_REQUEST_DIR_USER_NONCACHED0Operations performed in the 'user mode application <--> filesystem' direction.
FS_REQUEST_DIR_USER_CACHED1Operations performed in the 'user mode application <--> system cache' direction.
FS_REQUEST_DIR_SYSTEM_NONCACHED2Operations performed in the 'system cache <--> filesystem' direction.
FS_REQUEST_DIR_SYSTEM_CACHED3Operations performed in the 'system component <--> system cache' direction.

The BytesWritten parameter specifies how many bytes were actually written to the file. This parameter's value must not exceed BufferLength (and should not exceed BytesToWrite; please refer to BeforeWriteFile for more information).

The Status parameter contains an NT status code that indicates the outcome of the operation; 0 indicates success. To convert this value to a Win32 error code, call the NtStatusToWin32Error method. Please note that this event won't fire for failed requests unless the ProcessFailedRequests property is enabled. Applications may change this parameter's value if they want a different NT status code to be returned.

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (If the system's cache manager or memory manager initiated the operation, HandleContext may be absent, in which case it will be NULL.)

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a non-zero value to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.

This event is fired synchronously; please refer to the Event Types topic for more information.

 
 
Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Filter 2020 C++ Edition - Version 20.0 [Build 7836]