Reputation: 504
I am trying to parse a large number of INF files for Windows driver installations.
I have a large collection of drivers for various devices (Biometrics, Bluetooth, Video, etc) -- all with varying creation dates and contents. I am trying to parse these files such that I can input the file contents and return the Hardware ID which is formatted like this for USB devices, and this for PCI and PCI-E devices.
My issue is that there does not seem to be any specific order or standardization for the location of these values in the respective INF file.
For example, this Bluetooth driver from Intel begins as follows:
[Version]
Signature = "$WINDOWS NT$"
Class = Bluetooth
ClassGuid = {e0cbf06c-cd8b-4647-bb8a-263b43f0f974}
Provider = %PROVIDER_NAME%
CatalogFile = ibtusb.cat
DriverVer = 07/06/2018,20.70.1.1
[SourceDisksNames]
1=%SOURCEDISK1%,,,
[SourceDisksFiles]
ibtusb.sys = 1
ibtfw.dat = 1
[DestinationDirs]
ibtusb.Copy = 12 ; drivers
firmware.Copy = 12
;
; Driver Information
;
[Manufacturer]
%COMPANY_NAME% = Device,NTamd64.10.0...16299
[Device.NTamd64.10.0...16299]
;---Start VID_PIDS section---
%iBT_USB% = ibtusb, USB\VID_8087&PID_0025&REV_0001
%iBT_USB% = ibtusb, USB\VID_8087&PID_0025&REV_0002
;---End VID_PIDS section---
Notice how the devices ID (USB\VID_8087&PID_0025
) is stored under the [Device.NTamd64.10.0...16299]
key.
On this particular line: %COMPANY_NAME% = Device,NTamd64.10.0...16299
The device ID is set equal to %COMPANY_NAME%
and is separated by itbtusb,
However, if I compare this layout with a Nokia Bluetooth driver, for example, it is totally different:
[Version]
Signature="$Windows NT$"
Class=CustomUSBDevices
ClassGuid={a503e2d3-a031-49dc-b684-c99085dbfe92}
Provider=%Manufacturer%
CatalogFile=%DriverBaseName%.cat
DriverVer=05/15/2012,2.4.0.4
[ClassInstall32]
AddReg=ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%DeviceManagerCategory%
HKR,,Icon,,"-20"
[Manufacturer]
%Manufacturer%=DeviceList, NTamd64
[ControlFlags]
ExcludeFromSelect=*
[DeviceList]
%NokiaBH907%=DriverInstall, USB\VID_0421&PID_064B
%NokiaBH907%=DriverInstall, USB\VID_0421&PID_064C
[DeviceList.NTamd64]
%NokiaBH907%=DriverInstallX64, USB\VID_0421&PID_064B
%NokiaBH907%=DriverInstallX64, USB\VID_0421&PID_064C
This time, the device ID is stored under the [DeviceList]
and [DeviceList.NTamd64]
keys.
[DeviceList]
%NokiaBH907%=DriverInstall, USB\VID_0421&PID_064B
%NokiaBH907%=DriverInstall, USB\VID_0421&PID_064C
[DeviceList.NTamd64]
%NokiaBH907%=DriverInstallX64, USB\VID_0421&PID_064B
%NokiaBH907%=DriverInstallX64, USB\VID_0421&PID_064C
With this I had some general questions:
[Manufacturer]
key -- is this always the case?If clarification needed, please suggest an edit or leave a comment.
Thank you!
Upvotes: -1
Views: 2052
Reputation: 1362
Here are some MSDN links that you might find useful:
General Syntax Rules for INF Files
The sections you're looking for are called Models sections, which indeed are defined in the Manufacturer sections - this is mentioned in the Models section documentation from the link above:
Each models-section-name must be listed in the INF Manufacturer section of the INF file. There can be one or more entries in any per-manufacturer Models section, depending on how many devices (and drivers) the INF file installs for a particular manufacturer.
Here's the documented Models section syntax (from the same link):
[models-section-name] |
[models-section-name.TargetOSVersion] (Windows XP and later versions of Windows)
device-description=install-section-name[,hw-id][,compatible-id...]
[device-description=install-section-name[,hw-id][,compatible-id]...] ...
If you want to parse the INFs by hand, you might also find useful some of the Windows SetupAPI utilities, listed here:
Extracting File Information from the INF file
If you are interested in extracting info relevant only for a specific OS version, these APIs might also be of use:
SetupDiGetActualSectionToInstallEx
Finally, if you're just interested in the hardware IDs, using the InfVerif WDK tool /info
flag mentioned by @cody might indeed be the best way to solve your problem, since the tool will do all the necessary parsing for you.
Upvotes: 2
Reputation: 11157
It might be easier to consume the output of the InfVerif
utility that comes as part of the Windows Driver Kit. You don't need to have Visual Studio or anything else installed to use it.
It takes an /info
flag that prints device information in a consistent format. For example, running it on a random inf file on my current machine:
xusb22.inf Information
INF Hash: e41db3fe2103ee21
Family ID: Microsoft-xusb22.inf
Device: Xbox 360 Controller for Windows
Hardware ID: USB\Vid_045E&Pid_028E
Service: xusb22
Section Name: CC_Install
Architecture: amd64
Device: Xbox 360 Wireless Receiver for Windows
Hardware ID: USB\Vid_045E&Pid_0719
Service: xusb22
Section Name: CC_Install
Architecture: amd64
Device: Xbox 360 Controller for Windows
Hardware ID: USB\MS_COMP_XUSB10
Service: xusb22
Section Name: CC_Install
Architecture: amd64
...
Upvotes: 2