An INF file (or Setup Information file) is a plain text file used by Microsoft Windows for installation of software and drivers. INF files are most commonly used for installing device drivers for hardware components. Windows includes IExpress.exe for the creation of INF-based installations. INF files are part of the Windows Setup API.
Structure of an INF file
The structure of an INF file is very similar to that of an INI file; it contains various sections that specify the files to be copied, changes to the registry etc. All INF files contain a [version] section with a Signature value specifying the version of Windows that the INF file is meant for. The signature is commonly $CHICAGO$ (for Windows 9x) or $WINDOWS NT$ (for Windows NT/2K/XP) Most of the remaining sections are user-defined and contain information specific to the component being installed.
Purpose of .INF Files
Ask just about any device driver writer, "What is the worst part of writing Windows device drivers?" and most will reply, "Writing .INF files!" The reason for this is that the documentation on .INF files in the DDK has not provided a procedural approach to describing .INF files, such as, "If you want to accomplish X, then do Y followed by Z".
This article will describe the basics of .INF files and how they are used in the installation of a device driver.
An .INF file can do many things; however, 97% of all .INF files really only perform three tasks:
1.)Identify the driver for a particular device. This is done using one or more Hardware IDs or Compatible IDs. The system device installer will take the Hardware IDs and Compatible IDs that were reported for a device (by its bus driver), and try and find an exact character for character match in an .INF file. When a match is found, then the system device installer knows that the .INF file describes the driver(s) for the device.
2.)Copy files from the installation medium to the system. In addition to the driver binary (the .SYS file), driver packages may also include DLLs, co-installers, applications, or any other type of file.
3.)Add entries to the registry. This describes the device and its relationship to other devices, provides for device or driver specific configuration information, and describes the driver "service" to the service control manager.
Thats it. Sounds simple, doesnt it? Actually, it is pretty simple (no, Im not kidding!).
"Youre right", replied the little bear, "even a Bear of Little Brain understands that"
The two most confusing aspects of .INF files are usually:
1.)The .INF file is not 'run from the beginning to the end; individual sections in the .INF file are 'run based upon the phase of the installation process.
2.)Most of the sections in the .INF file are actually part of a well-defined hierarchy. This fact is obscured by the squashing of the hierarchy into a flat text file.
Creating International INF Files
An INF that will be used in an international market should use %strkey% tokens for all user-viewable text. The string tokens are defined in a [Strings] section, which is typically at the end of the INF file.
To create a single international INF file, the INF can have a set of locale-specific Strings.LanguageID sections, as described in the reference page for the INF Strings Section in the Windows 2000 DDK documentation.
Alternatively, you can create a separate INF for each locale. To reduce duplication and ease maintenance, you can create a main INF file with all the necessary sections and entries, except for the Strings section. Then create a second set of files, where each file contains just the Strings section for a supported locale. Concatenate the main file with each strings file to generate the locale-specific INF files.
If an INF contains characters outside the ASCII range (outside the range 0-127), the INF should be in Unicode format. To create such a file, for example, save the INF as a Unicode file from an application like Notepad. If the INF is not in Unicode format, Setup uses the current locale to translate characters. If the INF is in Unicode format, Setup uses the full character set.
commonly used sections
General Syntax Rules for INF Files
An INF file is a text file organized into named sections. Some sections have system-defined names and some sections have names determined by the writer of the INF file.
Each section contains section-specific entries, which are interpreted by Setup software (class installers, co-installers, SetupAPI). Some entries begin with a predefined keyword. These entries are called directives.
Some INF file entries are essentially pointers from one section to another, for a specific purpose. For example, an INF AddReg directive identifies a section containing entries that instruct Setup to modify the registry. These entries sometimes include additional arguments (required or optional) for Setup to interpret during installation.
Other INF file entries do not point to other sections, but simply supply information that Setup uses during installation, such as file names, registry values, hardware configuration information, flags, and so on. For example, an INF DriverVer directive supplies driver version information.
When Setup begins an installation, it first looks for an INF Version section to verify the validity of the INF file and to determine where installation files are located. It then starts the installation by finding an INF Manufacturer section, which will contain directives to INF Models sections, which in turn provide directives leading to various INF DDInstall sections, based on the hardware ID of the device being installed.
The following syntax rules govern the required and optional contents of INF files, the format of section names by using string tokens, and line format, continuation, and comments.
Sample INF File
The following is a sample INF file that demonstrates the syntax understood by the Internet Component Download service.
_________________________
;Sample INF file for CIRC3.OCX [Add.Code] circ3.ocx=circ3.ocx random.dll=random.dll mfc40.dll=mfc40.dll example.ocx=example.ocx
[circ3.ocx] ; Lines below specify that the specified circ3.ocx (clsid, version) ; needs to be installed on the system. If it doesn't exist already, ; it can be downloaded from the given location (a .cab file). ; Note: if "thiscab" is specified instead of the file location, ; it is assumed that the desired file is present in the same .cab ; cabinet that the INF originated from. Otherwise, if the location ; pointed to is a different .cab, the new cabinet is also downloaded ; and unpacked in order to extract the desired file. file=http://www.code.com/circ3/circ3.cab clsid={9DBAFCCF-592F-101B-85CE-00608CEC297B} ; Note that the {}s are required when entering a in the INF file. ; This is slightly different from the HTML syntax for inserting CLSIDs ; in an