Registering Preoperation and Postoperation Callback Routines

To register preoperation callback routines and postoperation callback routines, a minifilter driver makes a single call to FltRegisterFilter in its DriverEntry routine. For the Registration parameter in FltRegisterFilter, the minifilter driver passes a pointer to an FLT_REGISTRATION structure. The OperationRegistration member of this structure contains a pointer to an array of FLT_OPERATION_REGISTRATION structures, one for each type of I/O operation that the minifilter driver must filter.

Each FLT_OPERATION_REGISTRATION structure in the array, except for the last one, contains the following information:

  • The major function code for the operation. See FLT_PARAMETERS for information on I/O operations, and their request-type-specific parameters.

  • For read and write operations (IRP_MJ_READ and IRP_MJ_WRITE), a set of flags that specify whether to ignore cached I/O or paging I/O or both for IRP-based I/O operations

  • Entry points for up to one preoperation callback routine and one postoperation callback routine

The last element in the array must be {IRP_MJ_OPERATION_END}.

The following code example, which is taken from the Scanner sample minifilter driver, shows an array of FLT_OPERATION_REGISTRATION structures. The Scanner sample minifilter driver registers preoperation and postoperation callback routines for IRP_MJ_CREATE and preoperation callback routines for IRP_MJ_CLEANUP and IRP_MJ_WRITE operations.

const FLT_OPERATION_REGISTRATION Callbacks[] = {
    {IRP_MJ_CREATE,
     0,
     ScannerPreCreate,
     ScannerPostCreate},
    {IRP_MJ_CLEANUP,
     0, 
     ScannerPreCleanup,
     NULL},
    {IRP_MJ_WRITE,
     0, 
     ScannerPreWrite,
     NULL},
    {IRP_MJ_OPERATION_END}
};