5
votes

Given the address of a PCI device (i.e. bus, device, function), how can one programatically read, using Win32 API calls in userspace, the config space (e.g. vendor ID, device ID) for that device?

On Linux, one openes the /sys/bus/pci/devices//config file and reads from the right offset.

1
In Windows I would try with WMI for something like this, maybe the Win32_PnPEntity class can help.yms
BIOS data is mapped (readonly) to the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Mssmbios\Data, also you can check this document "SMBIOS Support in Windows": download.microsoft.com/download/5/d/6/…Simon Mourier

1 Answers

3
votes

You can use the SetupDiGetClassDevs API to traverse a list of devices. If you pass PCI in the Enumerator parameter, you can enumerate only PCI devices.