IO Manager
Overview
The IO Manager is the kernel component responsible for managing all I/O operations in Windows. It provides the infrastructure for device drivers, handles I/O request packets (IRPs), and implements the Windows I/O model.
Key responsibilities
- Creation and management of device objects.
- Dispatching IRPs to appropriate driver routines.
- Synchronizing access to devices.
- Providing I/O completion mechanisms.
- Supporting plug‑and‑play, power management, and security checks.
Functions
Below are the most commonly used IO Manager functions. Click a function name to view its detailed documentation.
| Function | Header | Description |
|---|---|---|
| IoCreateDevice | wdm.h | Creates a device object for a driver. |
| IoDeleteDevice | wdm.h | Deletes a previously created device object. |
| IoBuildDeviceIoControlRequest | wdm.h | Builds an IRP for a device‑I/O control request. |
| IoCompleteRequest | wdm.h | Completes an IRP and notifies the originating thread. |
| IoGetCurrentIrpStackLocation | wdm.h | Retrieves the current stack location for the given IRP. |
Structures
- DEVICE_OBJECT – Represents a device created by a driver.
- IRP – I/O request packet that describes an I/O operation.
- IO_STACK_LOCATION – Stack frame that driver routines use to access parameters.
- FILE_OBJECT – Represents an open instance of a file or device.
Constants & Enumerations
typedef enum _IO_ALLOCATION_ACTION {
KeepObject,
DeallocateObject,
DeallocateObjectKeepRegisters
} IO_ALLOCATION_ACTION;
#define IO_NO_INCREMENT 0
#define IO_NO_PARAMETERS 0x00000000
Remarks
The IO Manager interacts heavily with the Plug and Play (PnP) and Power Manager subsystems. When developing a kernel‑mode driver, you must follow the IRP processing rules and correctly set the Status field before completing the request.
Best practices
- Validate all input buffers before accessing them.
- Use
IoMarkIrpPendingwhen an operation will be completed asynchronously. - Always set the appropriate
IRP_MJ_*major function codes during driver initialization. - Release any allocated resources in the driver’s
Unloadroutine.