Determining if PCI device is physically present... - Programmer

This is a discussion on Determining if PCI device is physically present... - Programmer ; OS: Windows 2K/XP How does one programmatically determine if a PCI device (with a given device and vendor ID) physically exists in a Windows 2K or XP system without relying on a driver being installed? I realize the PCI bus ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Determining if PCI device is physically present...

  1. Determining if PCI device is physically present...

    OS: Windows 2K/XP

    How does one programmatically determine if a PCI device (with a given device
    and vendor ID) physically exists in a Windows 2K or XP system without
    relying on a driver being installed?

    I realize the PCI bus driver does the device enumeration and then drivers
    are eventually loaded accordingly. In my case, I have to assume that a
    driver may not yet be installed for a particular device. I obviously do not
    wish to interact with it (until the driver is installed), but is there a way
    to "ask" the bus driver if it has seen the PCI vendor/device ID on the last
    PCI scan?

    Most of what I have found in Windows programming documentation assumes that
    a driver already exists, a device interface has been registered, etc.

    I would be interested in either a user-mode or kernel-mode solution to this
    problem. Preferably a user-mode solution. But I do have a kernel driver
    (that is guaranteed to exist) that I can communicate with and modify if
    necessary.

    Thanks in advance.

    Matt



  2. Re: Determining if PCI device is physically present...

    In article <1064885393.94788@goodnews.cos.agilent.com>,
    Matt wrote:

    (I really wish people would use real email addresses...)

    >OS: Windows 2K/XP
    >
    >How does one programmatically determine if a PCI device (with a given device
    >and vendor ID) physically exists in a Windows 2K or XP system without
    >relying on a driver being installed?
    >
    >I realize the PCI bus driver does the device enumeration and then drivers
    >are eventually loaded accordingly. In my case, I have to assume that a
    >driver may not yet be installed for a particular device. I obviously do not
    >wish to interact with it (until the driver is installed), but is there a way
    >to "ask" the bus driver if it has seen the PCI vendor/device ID on the last
    >PCI scan?


    Have you considered scanning the registry? Specifically, it looks like
    the HKLM\SYSTEM\CurrentControlSet\Enum\PCI area would be a good place to
    start. I don't know if Windows is smart enough to clear out an entry if
    a card is removed, but it's a start?

    ========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
    Patrick Klos Email: patrick@klos.com
    Klos Technologies, Inc. Web: http://www.klos.com/
    ===== Why do I keep getting "one time mailings" over and over again?!? =====

  3. Re: Determining if PCI device is physically present...

    wrote:

    > Matt wrote:
    >
    > (I really wish people would use real email addresses...)


    I really wish spammers would go to so I COULD use my real e-mail! I
    did this once before and they tore my e-mail account to shreds (craploads of
    BS spam). In the mean time the group postings work fine and benefit
    everyone that way.


    > >OS: Windows 2K/XP
    > >
    > >How does one programmatically determine if a PCI device (with a given

    device
    > >and vendor ID) physically exists in a Windows 2K or XP system without
    > >relying on a driver being installed?
    > >
    > >I realize the PCI bus driver does the device enumeration and then drivers
    > >are eventually loaded accordingly. In my case, I have to assume that a
    > >driver may not yet be installed for a particular device. I obviously do

    not
    > >wish to interact with it (until the driver is installed), but is there a

    way
    > >to "ask" the bus driver if it has seen the PCI vendor/device ID on the

    last
    > >PCI scan?

    >
    > Have you considered scanning the registry? Specifically, it looks like
    > the HKLM\SYSTEM\CurrentControlSet\Enum\PCI area would be a good place to
    > start. I don't know if Windows is smart enough to clear out an entry if
    > a card is removed, but it's a start?
    >
    > ========= For LAN/WAN Protocol Analysis, check out PacketView Pro!

    =========
    > Patrick Klos Email: patrick@klos.com
    > Klos Technologies, Inc. Web: http://www.klos.com/
    > ===== Why do I keep getting "one time mailings" over and over again?!?

    =====


    Thanks for your input, but unfortunately the bus driver's enumeration key
    (in this case "PCI") only reliably indicates all past and present devices.
    Plus assumptions on registry structure must be made (non-portable).

    I wonder if the following would work:

    Call

    SetupDiGetClassDevs(NULL, "PCI", NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES);

    to get a list of all PCI devices that are present (device information set).
    I'm assuming "present" means detected on the bus (not necessarily having a
    driver installed).

    Use SetupDiEnumDeviceInterfaces(...) on each device information element in
    the set to extract its "DevInst" from the SP_DEVINFO_DATA structure. Use
    this "DevInst" (or devnode handle) in a follow up call to

    CM_Get_Device_ID();

    to get a "device instance ID" string.

    In the case of PCI, the device instance ID string would look like:

    \\
    PCI\VEN_1000&DEV_0001&SUBSYS_00000000&REV_02\1&08

    If I assume that the PCI enumerator's device IDs will ALWAYS take on the

    VEN_????&DEV_????...

    form, then I suppose this would work?

    Will it? Anyone?

    Is there a better way?

    Thanks again.

    Matt



  4. Re: Determining if PCI device is physically present...

    "Matt" wrote in message news:<1064893390.76378@goodnews.cos.agilent.com>...

    > SetupDiGetClassDevs(NULL, "PCI", NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES);
    >
    > to get a list of all PCI devices that are present (device information set).
    > I'm assuming "present" means detected on the bus (not necessarily having a
    > driver installed).
    >
    > Use SetupDiEnumDeviceInterfaces(...) on each device information element in
    > the set to extract its "DevInst" from the SP_DEVINFO_DATA structure. Use
    > this "DevInst" (or devnode handle) in a follow up call to

    [snip]

    A slightly more direct alternative: After you do the
    SetupDiGetClassDevs, next do SetupDiEnumDeviceInfo; then for each
    device returned, use SetupDiGetDeviceRegistryProperty with
    SPDRP_HARDWAREID. The return value is the
    "PCI\VEN_xxxx&DEV_xxxx&SUBSYS_xxxxxxxx&&REV=xx" string.

    - GH

+ Reply to Thread