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!
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
...