Reading BAR address from user mode application

Hi all,
how can application, using only windows API, know a BAR address of some specific PCI device?.. Can this be done?..

(device manager displays this information as “Memory Range”…)

thanks ahead

An Windows application could not read directly BAR registers. You need a PCI driver which could get such information. And the Windows application could call the driver to get such information.

Igor Sharovar

you can not do it from user mode unless you have a driver something like pci bus filter or specific pci device driver.

> (device manager displays this information as “Memory Range”…)

It uses some SetupDiXxx calls.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Thank you all for your answers :slight_smile:

Igor, I only want to know the address, not read the contents of BAR registers. (well it’s kind of a lie, I have another way to read phisical Memory…)

Maxim, do you have some code example?..

Thanks ahead,

Eylon

> Maxim, do you have some code example?..

Read the list of all CM_xxx and SetupDiXxx functions.

Also look at src\setup\devcon sample source in the WDK - it can contain similar code.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

xxxxx@nana.co.il wrote:

Igor, I only want to know the address, not read the contents of BAR registers. (well it’s kind of a lie, I have another way to read phisical Memory…)

In order to know the address of your memory region, you have to read the
contents of the BAR registers. Once you have the contents, THEN you
have a physical address you can use to access the device.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Maxim, Thanks!

Devcom Sample from the WDK Rocks! Exactly what I need!

thank you very much,

Eylon