Previous Next

DispatchReadWrite

The DispatchReadWrite routine services IRPs containing the IRP_MJ_READ or IRP_MJ_WRITE I/O function code.

NTSTATUS
  XxxDispatchReadWrite(
    IN PDEVICE_OBJECT  DeviceObject,
    IN PIRP  Irp
    );

Parameters

DeviceObject
Caller-supplied pointer to a DEVICE_OBJECT structure. This is the device object for the target device, previously created by the driver's AddDevice routine.
Irp
Caller-supplied pointer to an IRP structure that describes the requested I/O operation.

Return Value

If the routine succeeds, it must return STATUS_SUCCESS. Otherwise it must return one of the error status values defined in ntstatus.h.

Comments

A driver can provide a single DispatchReadWrite routine instead of separate DispatchRead and DispatchWrite routines.

A driver's DispatchReadWrite routine should be named XxxDispatchReadWrite, where Xxx is a driver-specific prefix. The driver's DriverEntry routine must store the DispatchReadWrite routine's address in DriverObject->MajorFunction[IRP_MJ_READ] and in DriverObject->MajorFunction[IRP_MJ_WRITE].

Input parameters for all Dispatch routines are supplied in the IRP structure pointed to by Irp. Additional parameters are supplied in the driver's associated I/O stack location, which is described by the IO_STACK_LOCATION structure and can be obtained by calling IoGetCurrentIrpStackLocation.

Generally, all Dispatch routines execute in an arbitrary thread context at IRQL = PASSIVE_LEVEL, but there are exceptions. For more information, see Dispatch Routines and IRQLs.

For more information about DispatchReadWrite routines, see Writing Dispatch Routines. For more information about IRPs, see Handling IRPs.