Programming the Microsoft Windows Driver Model

Chapter 9

I/O Control Operations

If you look at the various types of requests that come to a device, most of them involve reading or writing data. On occasion, however, an application needs to communicate out of band with the driver. For most types of device, the application can use the standard MicrosoftWin32 API function DeviceIoControl. On the driver side, an application s call to DeviceIoControl turns into an I/O request packet (IRP) with the major function code IRP_MJ_DEVICE_CONTROL.

I ll discuss the user-mode and kernel-mode sides of DeviceIoControl in this chapter. With several specific types of device, however, an application isn t supposed to (or can t) use DeviceIoControl to talk to a driver. See Table 9-1.

Table 9-1. Alternatives to DeviceIoControl for Certain Types of Driver

Driver Type

Alternative to DeviceIoControl

Human Interface Device (HID) minidriver (see Chapter 13)

HidD_GetFeature, HidD_SetFeature

SCSI miniport driver

IOCTL_SCSI_PASS_THROUGH

Network Driver Interface Specification (NDIS) miniport driver

WMI request using custom GUID. You re on your own for Win98 Gold, where WMI doesn t work.

SmartCard reader driver (Interface Device [IFD] Handler in PC/SC terms)

ScardControl

There is also a special problem associated with using DeviceIoControl to communicate with a filter driver. I ll discuss that problem and its solution in Chapter 16.

Категории