Setting Up ControllerControl Routines

A driver's DispatchPnP routine must do the following when it receives an IRP_MN_START_DEVICE request, to set up a ControllerControl routine:

  1. Call IoCreateController to set up the controller object, specifying the driver-determined Size for the controller extension, which the system allocates from nonpaged pool and initializes with zeros.

  2. Save the ControllerObject pointer returned by IoCreateController, usually in the device extension of each device object representing a physical or logical device that is controlled by the hardware represented by the controller object.

  3. Set up and/or initialize the driver-determined contents of the ControllerObject->ControllerExtension.

The returned ControllerObject pointer, the entry point of the driver's ControllerControl routine, the DeviceObject pointer representing the target device for the current IRP, and a Context pointer to an area already set up for the ControllerControl routine must be passed in the driver's calls to IoAllocateController. Usually, a driver's StartIo routine sets up the area at Context before it calls IoAllocateController.