How to get a device's location information?

Hi, all
I want to get a PCI device’s location information, just like PCI bus 0, device 31, function 6

SetupDiGetDeviceRegistryProperty
(
m_hDevInfo,
&DeviceInfoData,
SPDRP_LOCATION_INFORMATION,
NULL,
(PBYTE)DeviceLocation,
buffersize,
&buffersize
)
This function can get the Location data as the italic string metioned above. But on deferent operating system language region settings,
it can return in diferent language, like Japanese or Korean.
Is there any way to get the three positional parameters directly? Or, I have to make a match for each language.

xxxxx@sina.com

xxxxx@sina.com wrote:

    I want to get a PCI device’s location information, just
like /PCI bus 0, device 31, function 6/

Why?  What will you do with this information?

If you go hack the registry, you’ll see that the LocationInformation
registry value in the hardware key inside System\CurrentControlSet\Enum
contains both the localized printf string used to format the
information, plus the raw numbers themselves.  SetupDiOpenDevRegKey
should be helpful.


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

PNP_LOCATION_INTERFACE:: GetLocationString will return the string without resorting to direct registry access.

https://msdn.microsoft.com/en-us/library/windows/hardware/ff559634(v=vs.85).aspx?f=255&MSPPError=-2147217396

you can also query for the location property instead of manually QI’ing for it.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@probo.com
Sent: Tuesday, January 2, 2018 10:35 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How to get a device’s location information?

xxxxx@sina.com wrote:
>
> ? ? I want to get a PCI device’s location information, just like?/PCI?
> bus?0,?device?31,?function?6/


Why?? What will you do with this information?

If you go hack the registry, you’ll see that the LocationInformation registry value in the hardware key inside System\CurrentControlSet\Enum contains both the localized printf string used to format the information, plus the raw numbers themselves.? SetupDiOpenDevRegKey should be helpful.


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


NTDEV is sponsored by OSR

Visit the list online at: https:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:

To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>

Have you tried SPDRP_BUSNUMBER and SPDRP_ADDRESS? These should given you the
values*, though I have not personally used them.

-scott
OSR
@OSRDrivers

*The end of this MSDN page shows how to intepret DevicePropertyBusNumber and
DeviceProperyAddress for PCI devices, which should be the same values you
get back in user mode:

https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/obtaining-device-configuration-information-at-irql---dispatch-level