Device Class

There two device classes used to put devices and drivers into groups whose members have similar characteristics:

  1. Device Setup Classes
  2. Device Interface Classes

Windows classes are defined in the system file Devguid.h. This file defines a series of GUIDs for setup classes. A device interface class is always defined in a header file that belongs exclusively to a particular class of devices. For example, Ntddmou.h contains the definition of GUID_CLASS_MOUSE, the GUID representing the mouse interface class. The GUIDs in header files that are specific to the device interface class should be used to register for notification of arrival of an instance of a device interface. If a driver registers for notification using a setup class GUID instead of an interface class GUID, then it will not be notified when an interface arrives.

Device Setup Class

Used to group devices together that are installed and configured in a similar manner. This classes provide a mechanism for grouping devices that are installed and configured in the same way. A setup class identifies the class installer and class co-installers that are involved in installing the devices that belong to the class. For example, all CD-ROM drives belong to the CDROM setup class and will use the same co-installer when installed.

Microsoft defines setup classes for most devices. There is a GUID associated with each device setup class. System-defined setup class GUIDs are defined in Devguid.h and typically have symbolic names of the form GUID_DEVCLASS_Xxx. The device setup class GUID defines the ..\CurrentControlSet\Control\Class\ClassGuid registry key under which to create a new subkey for any particular device of a standard setup class.

One should only create a new device setup class if absolutely necessary. It is usually possible to assign your device to one of the system-defined device setup classes. If device provides capabilities that are significantly different from the capabilities that are provided by devices that belong to existing classes.

Device Interface Class

Used to group devices together that provide similar capabilities. This classes provide a mechanism for grouping devices according to shared characteristics. A device interface class is a way of exporting device and driver functionality to other system components, including other drivers, as well as user-mode applications. A driver can register a device interface class, then enable an instance of the class for each device object to which user-mode I/O requests might be sent. Each device interface class is associated with a GUID. The system defines GUIDs for common device interface classes in device-specific header files. Vendors can create additional device interface classes.

Instead of tracking the presence in the system of an individual device, drivers and user applications can register to be notified of the arrival or removal of any device that belongs to a particular interface class. Typically, drivers register for only one interface class. When a driver registers an instance of a device interface class, the I/O manager associates the device and the device interface class GUID with a symbolic link name. The link name is stored in the registry and persists across system starts. An application that uses the interface can query for instances of the interface and receive a symbolic link name representing a device that supports the interface. The application can then use the symbolic link name as a target for I/O requests.

There are three ways to register a device interface class:

A WDM driver does not name its device objects. Instead, driver calls IoCreateDevice to create a device object,  After creating the device object and attaching it to the device stack, one driver calls IoRegisterDeviceInterface to register a device interface class and to create an instance of the interface. Typically, the function driver makes this call from its AddDevice routine. Other system components cannot use a device interface instance until the driver has enabled it. The driver uses the symbolic link name to access the registry key, in which it can store information that is specific to the device interface. (IoOpenDeviceInterfaceRegistryKey) Applications use the link name to open the device.

Reference

Device Classes