Chapter 1 IRP Function Codes and IOCTLs

Each driver-specific I/O stack location in every IRP has a major function code (IRP_MJ_XXX) that tells the driver what operation it or the underlying device driver should carry out to satisfy the I/O request. Each Microsoft® Windows NT® kernel-mode driver must set up one or more Dispatch entry points for a required subset of system-defined major function codes that are set in the I/O stack location(s) of IRPs.

The subset of major function codes that a device driver must handle depends on the nature of its device. That is, the IRP_MJ_XXX requests sent to a keyboard driver are necessarily somewhat different from those sent to a disk driver.

Every higher-level driver must set up the appropriate I/O stack location in IRPs for the next-lower-level driver and call IoCallDriver either with each input IRP or with a driver-created IRP if the higher-level driver holds on to the input IRP. Consequently, every intermediate driver must supply a Dispatch entry point for each major function code that the underlying device driver handles. Otherwise, a new intermediate driver will "break the chain" whenever an application or still higher-level driver attempts to send an I/O request, which is valid but unsupported by the new intermediate driver, down to the underlying device driver.

File system drivers also handle a required subset of system-defined IRP_MJ_XXX, some with subordinate IRP_MN_XXX.

This chapter summarizes the basic I/O requests sent to the system device and intermediate drivers so that driver designers can determine which major function codes their new drivers must handle. For the most common IRP_MJ_XXX handled by device and intermediate drivers, this chapter summarizes general information about each request. It also discusses the definition of I/O control codes for device-type-specific, device-specific, and driver-specific device I/O control requests.