CBFS Filter 2020 C++ Builder Edition

Questions / Feedback?

AfterReadFile Event

Fires after data is read from a file.

Syntax

typedef struct {
  String FileName;
  __int64 Position;
  void* Buffer;
  int BufferLength;
  int BytesToRead;
  int Direction;
  int BytesRead;
  int Status;
  void* FileContext;
  void* HandleContext;
  int ResultCode;
} TcbfCBFilterAfterReadFileEventParams;

typedef void __fastcall (__closure *TcbfCBFilterAfterReadFileEvent)(System::TObject* Sender, TcbfCBFilterAfterReadFileEventParams *e);

__property TcbfCBFilterAfterReadFileEvent OnAfterReadFile = { read=FOnAfterReadFile, write=FOnAfterReadFile };

Remarks

This event fires after data is read from the file specified by FileName.

Applications may use this event to modify the data that was read from the file before it is returned to the requestor. Applications that choose to do this must:

  1. Enable the ModifiableReadWriteBuffers configuration setting (before this event fires, that is).
  2. Copy no more than BytesToRead bytes into Buffer.
  3. Update the BytesRead parameter's value afterwards so that it correctly reflects the amount of data in Buffer.

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

The Position parameter reflects the byte offset in the file at which reading started.

The Buffer parameter points to a memory buffer that, if the request was successful, contains the data that was read from 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 BytesToRead parameter reflects how many bytes were to be read from the file (i.e., how many bytes the requestor expects will be read).

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 BytesRead parameter specifies how many bytes were actually read from the file, and thus the length of the data in Buffer. This parameter's value must not exceed BufferLength (and should not exceed BytesToRead; please refer to BeforeReadFile 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) 2020 Callback Technologies, Inc. - All rights reserved.
CBFS Filter 2020 C++ Builder Edition - Version 20.0 [Build 7543]