IRP-Based IOCTL and FSCTL Operations

The following IRP-based I/O operations use the buffering method that matches the transfer type that is specified in the definition of the I/O control code (IOCTL) or file system control code (FSCTL):

  • IRP_MJ_DEVICE_CONTROL

  • IRP_MJ_FILE_SYSTEM_CONTROL

  • IRP_MJ_INTERNAL_DEVICE_CONTROL

The transfer type is specified in the TransferType parameter of the CTL_CODE macro. To obtain the transfer type for a given IOCTL or FSCTL, use the following macro:

#define METHOD_FROM_CTL_CODE(ctrlCode)         ((ULONG)(ctrlCode & 3))

This macro returns one of the following values:

#define METHOD_BUFFERED                 0
#define METHOD_IN_DIRECT                1
#define METHOD_OUT_DIRECT               2
#define METHOD_NEITHER                  3

For more information about the CTL_CODE macro, see Defining I/O Control Codes.

Note that IRP_MJ_DEVICE_CONTROL can also be a fast I/O operation. When it is a fast I/O operation, it always uses neither buffered nor direct I/O, regardless of the IOCTL's transfer type. For more information about when IRP_MJ_DEVICE_CONTROL can be a fast I/O operation, see Operations That Can Be IRP-Based or Fast I/O.