Modifying the Parameters for an I/O Operation
A minifilter driver can modify the parameters for an I/O operation. For example, a minifilter driver's preoperation callback routine can redirect an I/O operation to a different volume by changing the target instance for the operation. The new target instance must be an instance of the same minifilter driver at the same altitude on another volume.
The parameters for an I/O operation are found in the callback data (FLT_CALLBACK_DATA) structure and I/O parameter block (FLT_IO_PARAMETER_BLOCK) structure for the operation. The minifilter driver's preoperation callback routine and postoperation callback routine receive a pointer to the callback data structure for the operation in the Data input parameter. The Iopb member of the callback data structure is a pointer to an I/O parameter block structure that contains the parameters for the operation.
If a minifilter driver's preoperation callback routine modifies the parameters for an I/O operation, all minifilter drivers below that minifilter driver in the minifilter driver instance stack will receive the modified parameters in their preoperation and postoperation callback routines.
The modified parameters are not received by the current minifilter driver's postoperation callback routine or by any minifilter drivers above that minifilter driver in the minifilter driver instance stack. In all situations, a minifilter driver's preoperation and postoperation callback routines receive the same input parameter values for a given I/O operation.
After modifying the parameters for an I/O operation, the preoperation or postoperation callback routine must indicate that it has done so by calling FltSetCallbackDataDirty, unless it has changed the contents of the callback data structure's IoStatus field. Otherwise, the filter manager will ignore any changes to parameter values. FltSetCallbackDataDirty sets the FLTFL_CALLBACK_DATA_DIRTY flag in the callback data structure for the I/O operation. Minifilter drivers can test this flag by calling FltIsCallbackDataDirty or clear it by calling FltClearCallbackDataDirty.
If a minifilter driver's preoperation callback routine modifies the parameters for an I/O operation, all minifilter drivers below that minifilter driver in the minifilter driver instance stack will receive the modified parameters in the Data and FltObjects input parameters to their preoperation and postoperation callback routines. (Minifilter drivers cannot directly modify the contents of the FLT_RELATED_OBJECTS structure that is pointed to by the FltObjects parameter. However, if a minifilter driver modifies the target instance or target file object for an I/O operation, the filter manager modifies the value of the corresponding Instance or FileObject member of the FLT_RELATED_OBJECTS structure that is passed to lower minifilter drivers.)
Although any parameter changes that a minifilter driver's preoperation callback routine makes are not received by the minifilter driver's own postoperation callback routine, a preoperation callback routine is able to pass information about changed parameters to the minifilter driver's own postoperation callback routine. If the preoperation callback routine passes the I/O operation down the stack by returning FLT_PREOP_SUCCESS_WITH_CALLBACK or FLT_PREOP_SYNCHRONIZE, it can store information about changed parameter values into a minifilter driver-defined structure that is pointed to by the CompletionContext output parameter. The filter manager passes this structure pointer in the CompletionContext input parameter to the postoperation callback routine.
For more information about the parameters for an I/O operation, see FLT_CALLBACK_DATA and FLT_IO_PARAMETER_BLOCK.