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:
- Is there any fool-proof methods for extracting this?
- I've realized that the key names for the data containing the hardware ID can be found in the
[Manufacturer]
key -- is this always the case? - Is the device ID always the second value? (separated by a comma)
- Does Microsoft document/define/recommend this behavior for vendors?
If clarification needed, please suggest an edit or leave a comment.
Thank you!