6.1.2 Conditionally Implemented Dispatch Routines
Other requests that NT device and intermediate drivers might handle include the following:
·IRP_MJ_QUERY_INFORMATION and IRP_MJ_SET_INFORMATION for certain highest-level NT drivers
Such a request indicates that a user-mode application, component, or driver has requested information about the length of the file object (representing the driver's device object) for which the user-mode requestor has a handle, or that the user-mode requestor is attempting to set an end-of-file on that file object.
NT parallel class and serial device drivers handle these requests by setting the FILE_STANDARD_INFORMATION or FILE_POSITION_INFORMATION length or position to zero. Other highest-level NT device drivers should support these requests, particularly if a user-mode application or user-mode driver might call C runtime functions to manipulate the file object. NT file system drivers must support these requests more fully than these highest-level NT device drivers.
·IRP_MJ_FLUSH_BUFFERS for any NT driver that caches data in a device or buffers data internally in driver-allocated memory
Receipt of this request indicates that the driver should write its buffered data or flush the cached data out to the device, or should discard buffered or cached data that was read from the device.
For example, the system keyboard and mouse class drivers, which have internal ring buffers for input data from their devices, support the flush request. Drivers of mass-storage devices and drivers layered above them also support this request.
·IRP_MJ_SHUTDOWN for any driver that should be called before the system itself is shut down
If the underlying device is not a mass-storage device, an NT driver can set a DispatchShutdown entry point in the driver object when it initializes at the discretion of the driver designer. For such a driver, its DriverEntry routine must call IoRegisterShutdownNotification with pointer(s) to the device object(s) for which its DispatchShutdown routine will do whatever driver-determined cleanup is necessary before the system is shut down.
NT drivers for mass-storage devices and intermediate drivers layered over them can rely on a highest-level NT file system driver to send them shutdown IRPs when the system is about to shut down. That is, the FSD is responsible for making sure that any cached file data is written out to peripheral devices, calling underlying drivers to flush data from their device caches or buffers (if any), and so forth before the system is shut down.
The driver of a mass-storage device that caches data internally must set the entry points in the driver object for its DispatchShutdown and DispatchFlush routines when it initializes. If such a driver buffers data in memory but its device has no internal cache, it also must set DispatchShutdown and DispatchFlush entry points in its driver object when it initializes.
Any intermediate driver layered above a driver that handles IRP_MJ_FLUSH and IRP_MJ_SHUTDOWN requests also must set its DispatchShutdown and DispatchFlush entry points in its driver object when it initializes.