ClasFilt Sample INF File

Description

The ClasFilt.inf file is a sample INF file that demonstrates the installation of a class filter driver that will be applied as an upper or lower filter to all devices of a specific device setup class.

Theory of Operation

Before you can use ClasFilt.inf to install a class filter driver, you must make the following changes:

  • Change the name of the INF file. We recommended that you use the same file name as the binary that the INF file installs.

  • Change the name of the driver file itself to the name of the actual driver. In ClasFilt.inf, this binary is called ClasFilt.sys and is listed in four different locations: the SourceDisksFiles section, the DefaultInstall section, the Service Installation section (clasfilt_Service_Inst), and the EventLog AddReg directive in the clasfilt_EventLog_AddReg section.

  • Change {setup-ClassGUID} in the ClassFilter_AddReg section to the string form of the device ClassGUID on which you are installing the filter driver. ClassGUID values are listed in the Microsoft Windows Driver Kit (WDK) documentation.

  • In the ClassFilter_AddReg section, change UpperFilters to LowerFilters if the filter driver is a lower-class filter.

  • Update the service description (the ClasFilt.SvcDesc string in the Strings section) to better describe your driver.

  • Update the media description (the ClasFilt.MediaDesc string in the Strings section) to better describe your media.

  • Replace "Microsoft" with your organization's name in the copyright notice in the first comment block.

Implementation and Design

As discussed earlier, you must modify several items in the INF file before you can use the INF file to install a class filter driver.

To have the Windows operating system load the class filter driver, you must either restart the computer, or restart all of the devices of the class in question.

If a class filter driver is updated, restarting the devices might not be enough for the devices of that class to use the updated driver.

Installation

A device installation program can install the class filter driver programmatically by running the following code example:


TCHAR szCommandLine[] = TEXT("DefaultInstall 132 .\\clasfilt.inf"); 
InstallHinfSection(NULL, NULL, szCommandLine, SW_SHOW); 

This code example uses the InstallHinfSection API, which reads the indicated INF file and installs the driver that is installed by the indicated DefaultInstall section.

In the preceding code example, the szCommandLine argument that is passed to the InstallHinfSection API contains the following:

  • "DefaultInstall" is the installation section in the INF file.

  • "132" is a flags field that indicates whether a restart is needed. The value "132" indicates that Windows will determine if a restart is required.

  • ".\\clasfilt.inf" is the INF file that installs the class filter driver. The full path to this INF file should also be included.

Note  Use the InstallHinfSection API to install class filter drivers only. This API and the methodology that this sample demonstrates cannot be used to install device drivers or device filter drivers.

For more information and a detailed function description of the InstallHinfSection API, see the Microsoft Windows SDK documentation.

For more information about the DefaultInstall section in INF files, see INF DefaultInstall Section.

For more information about how to write device installation programs, see Writing a Device Installation Application.

Alternate Installation

You can install an INF file based on ClasFilt.inf by using right-click installation as follows:

  1. Right-click the INF file in Windows Explorer.

  2. Click Install.

Code Tour

File Manifest

The following file is located in the src\setup\infs\clasfilt directory.

FileDescription

ClasFilt.inf

Sample class filter INF file.

 

 

 

Send comments about this topic to Microsoft

Build date: 6/29/2012

Show: