Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results


More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

2 (or more) identical PCIe cards in PC

zviveredzvivered Member Posts: 89


I installed 2 **identical **PCIe cards in my PC.
Both cards are detected properly in the device manager.
When I "open" a card using a win32 application, I have to identify it according to its position in the PC.

Can I do it using : Bus, Device, Function assigned to it ?
Can I be sure that after each reset or power up, those numbers will remain the same for a specified card in a specified slot ?

If not, what is the right way doing this ?

Thank you,


  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,486

    Well... you would usually use the “Reference String” in the device interface for this purpose.

    Are these devices connected to different things externally, and so you a priori need to know which is which?

    Can you run a Config program, and have that program store info that’s retrievable by the driver (and maybe the app) so it knows which instance it is?


    Peter Viscarola

  • zviveredzvivered Member Posts: 89

    Hi Peter,

    Thank you very much for your reply.
    Exactly. Each device is connected to different external input. So I need to know a priori which is which.

    I can run a config program.
    What does this program should do ?

    Best regards,

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,486

    Have the program store the configuration in the Registry, where the driver can read it and do something appropriate with it. Change the Interface reference string, create a distinct device name, or implement an IOCTL that returns which device is which.

    This isn’t a Windows challenge so much as a logical challenge for you to figure out how to distinguish one device from the other. Consider running the config program, disconnecting both external interface, then connecting the first interface... that allows the config program and driver to identity which device is connected to that interface. Or something similar.

    It’s device dependent, right?


    Peter Viscarola

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,963

    Two interesting factoids here. First, manufacturers almost never number their PCIe slots in a human-readable way. Second, the slots will always enumerate in the same order. No web site will promise that, but it's true. When we've had this problem with USB cameras, we have the application present two images and say "which of these is camera 1"? Or, sometimes, "by what name should we call THIS camera?"

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Don_BurnDon_Burn Member - All Emails Posts: 1,730

    Actually, there a qualifiers to Tim Roberts comments on slot enumerating and numbering. First, the slots will have the same number every time on a given system that is not reconfigured. If it is reconfigured you cannot assure the slots have the same numbers, but normally do. I had a client who added a bus extender card and box that confused things on some systems. Second, caveat is even two systems from the same manufacturer may not have the same bus numbering. I worked for a firm that got 10 desktop PC's in one order from a manufacturer, they were all the same model, but they had 3 different slot numbering schemes.

    Your mileage may vary, but to be safe assume a system slot numbering is only good for that system and only until it's peripherals change.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,486

    the slots will always enumerate in the same order. No web site will promise that, but it's true

    So, what Mr. Roberts is saying here is that if CardX is enumerated before CardY today, then CardX will always be enumerated before CardY.

    That's a reasonable bet, but not one that I'd (quite frankly) be willing to make or on which I'd be willing to base a product.

    But, then again... I don't think the OP asked this question in any case.

    I had a client who added a bus extender card and box that confused things on some systems

    So, the OP asked specifically about whether the b:d:f can change.

    The reason I didn't comment on this specific question is (a) it's not really relevant (I mean, who cares if your first card is 1:2:0 and your second is 2:3:0??), and (b) I'm just not sure that given things like Thunderbolt and "bus extenders" as Mr. Burn noted, the B:D:F of a given device can't change.

    I would definitely expect it to NOT change, but again... this isn't something I'd personally be willing to base a product.

    Mr. Roberts gave you an example of the heuristic that's best to use: Your user runs a config program. You ask them something about one of the devices (Mr. Roberts' camera case... or think of how you identify which monitor is connected to a given port on a graphics card) , and you use this user action to identify that particular device.

    Like I said... this isn't a Windows OS architecture challenge -- It's a "how clever are you" challenge to figure out a way to allow your users to identify each device instance and then store that id info somewhere that your driver can retrieve it.


    Peter Viscarola

  • zviveredzvivered Member Posts: 89

    Hi Peter, All,

    Do you mean that by calling WdfDeviceRetrieveDeviceInterfaceString, I can read B:D:F ?

    Thank you,

  • Pavel_APavel_A Member Posts: 2,781
    edited April 27

    WdfDeviceQueryProperty with DevicePropertyAddress or DevicePropertyBusNumber or DevicePropertyLocationInformation or maybe DevicePropertyUINumber.

    My approach to this is to assign labels to all instances when the cards are installed. As Mr. Viscarola wrote, should have a configuration program
    and it puts these labels in the instances's registry. The driver returns these labels to user app.
    If configuration changes unexpectedly - there's an instance without a label, or some exected label is missing - the app declares hardware failure.
    This works even for devices on multiple buses (PCI and USB).
    Of course the app can read and write these strings without help of the driver(s), it's a matter of taste.


  • zviveredzvivered Member Posts: 89

    Hi Pavel, Don, Peter and Tim,

    Thank you very much for your help !
    Best regards,

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Developing Minifilters 24 May 2021 Live, Online
Writing WDF Drivers 14 June 2021 Live, Online
Internals & Software Drivers 27 September 2021 Live, Online
Kernel Debugging 15 November 2021 Live, Online