device id in user mode

Is there a way to find out “device id” in user mode? I serached the archives/msdn but no luck. Thank you for your help.

Have you looked at the ‘setup’ API? I mercifully never have to deal with
it, but I think it would be a likely candidate.

Good luck,

Mm

On Oct 22, 2010 8:14 PM, wrote:
> Is there a way to find out “device id” in user mode? I serached the
archives/msdn but no luck. Thank you for your help.
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

no I couldn’t fine one. though there are apis to get the device instance id. I need device id. Thanks.

>

Is there a way to find out “device id” in user mode? I serached the
archives/msdn but no luck. Thank you for your help.

What is the device id? Is it the hardware id?

SetupDiGetDeviceRegistryProperty is the usermode equivalent of
IoGetDeviceProperty which might return one of the properties you want.

James

Device Id is supposed to be the first Hardware ID: while a device must have at least one, it can (and most do) have multiple hardware IDs of different levels of specificity, and 0 or more compatible IDs as well.

SetupDiGetDeviceRegistryProperty is the proper call for both. SPDRP_HARDWAREID for the hardware IDs (in REG_MULTI_SZ format, and SPDRP_COMPATIBLEIDS for compatible IDs (in the same format).

The most specific hardware ID (which is how device ID is defined) should be the first one in the list when you get hardware IDs.

The instance ID in the event that is what you want is SetupDiGetDeviceIsntanceId, but I gather you already viewed that and judged it not worthy.

>> Device Id is supposed to be the first Hardware ID

This is what my understanding was from MSDN. But I have a Silicon image card whose device id is not same as the first hardware id. So I wanted to query the device id separately.

>> I have a Silicon image card whose device id is not same as the first hardware id.

How do you know that the device ID is not the first hardware ID? Where does that information [as to what the device ID is] come from? I’m not trying to be querulous with those questions, but I can’t understand why you are making that statement without more background.

These IDs are reported by the bus driver reporting the device’s PDO, and they are then stored in the registry. If you are seeing something there you don’t expect, it is probably an issue of the interaction between the bus and the device, and what form that is supposed to take depends entirely upon the bus and any specifications applying to that bus and its protocols.

e.g., in USB, the IDs are formed from descriptors queried from the device through the control pipe (I hope I remembered that correctly, anyway). In PCI, they are read from Read only registers (at least they’re supposed to be read-only) at specified locations in config space. Both bus drivers generate multiple hardware IDs, but the most specific one should be first.

When you look at the device’s property page in the device manager, does the “real” device ID show up anywhere in the list of hardware IDs? If it doesn’t, then either the bus driver didn’t report it, or someone has modified the information it reported by editing the hardware key. At least, those are the only possibilities I see at the moment.

I looked at the IRP_MN_QUERY_ID request and with the Parameters.QueryId.IdType field to BusQueryDeviceID/BusQueryHardwareIDs response from the port driver in winDbg on the way up.

BusQueryDeviceID:
0: kd> db 0xfffff8a0002d97c0 l200 fffff8a0002d97c0 53 00 43 00 53 00 49 00-5c 00 44 00 69 00 73 00 S.C.S.I..D.i.s.
fffff8a0002d97d0 6b 00 26 00 56 00 65 00-6e 00 5f 00 53 00 69 00 k.&.V.e.n._.S.i. fffff8a0002d97e0 49 00 6d 00 61 00 67 00-65 00 26 00 50 00 72 00 I.m.a.g.e.&.P.r.
fffff8a0002d97f0 6f 00 64 00 5f 00 26 00-52 00 65 00 76 00 5f 00 o.d._.&.R.e.v._. fffff8a0002d9800 30 00 30 00 30 00 30 00-00 00 64 6f 5f 44 65 76 0.0.0.0…do_Dev
fffff8a0`002d9810 06 01 0a 05 53 65 53 64-00 10 18 00 01 00 0f 00 …SeSd…

BusQueryHardwareIDs:
0: kd> db 0xfffff8a00014a640 l200 fffff8a00014a640 53 00 43 00 53 00 49 00-5c 00 44 00 69 00 73 00 S.C.S.I..D.i.s.
fffff8a00014a650 6b 00 53 00 69 00 49 00-6d 00 61 00 67 00 65 00 k.S.i.I.m.a.g.e. fffff8a00014a660 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 ........
fffff8a00014a670 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a680 5f 00 30 00 30 00 30 00-30 00 00 00 53 00 43 00 .0.0.0.0…S.C.
fffff8a00014a690 53 00 49 00 5c 00 44 00-69 00 73 00 6b 00 53 00 S.I.\.D.i.s.k.S. fffff8a00014a6a0 69 00 49 00 6d 00 61 00-67 00 65 00 5f 00 5f 00 i.I.m.a.g.e.
..
fffff8a00014a6b0 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a6c0 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 00 00 ..
....
fffff8a00014a6d0 53 00 43 00 53 00 49 00-5c 00 44 00 69 00 73 00 S.C.S.I.\.D.i.s. fffff8a00014a6e0 6b 00 53 00 69 00 49 00-6d 00 61 00 67 00 65 00 k.S.i.I.m.a.g.e.
fffff8a00014a6f0 5f 00 00 00 53 00 43 00-53 00 49 00 5c 00 53 00 _...S.C.S.I.\.S. fffff8a00014a700 69 00 49 00 6d 00 61 00-67 00 65 00 5f 00 5f 00 i.I.m.a.g.e...
fffff8a00014a710 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a720 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 30 00 .......0.
fffff8a00014a730 00 00 53 00 69 00 49 00-6d 00 61 00 67 00 65 00 ..S.i.I.m.a.g.e. fffff8a00014a740 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 ..
....._.
fffff8a00014a750 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a760 5f 00 30 00 00 00 47 00-65 00 6e 00 44 00 69 00 _.0…G.e.n.D.i.
fffff8a0`0014a770 73 00 6b 00 00 00 00 00-01 02 00 00 00 00 00 05 s.k…

Thank you.

Now that’s worthy of a roflmfao.

So the bus driver (and I’ve got a pretty good idea whose it is) doesn’t follow the standard, and effectively hides the device ID. Always possible I’ve missed something, but it seems to me that leaves one falling back to parsing it out of the instance ID, if one leans to the pragmatic, or running around in a panic because it cannot be done if one leans to the dogmatic side of engineering.

Or writing a bus filter if one is a bit of both, and enjoys devious solutions (said filter to stuff the ID back into the hardware ID list).

Can you tell it’s late Friday, I’m burned out, and I’m overdue for a beer?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Friday, October 22, 2010 7:27 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] device id in user mode

I looked at the IRP_MN_QUERY_ID request and with the Parameters.QueryId.IdType field to BusQueryDeviceID/BusQueryHardwareIDs response from the port driver in winDbg on the way up.

BusQueryDeviceID:
0: kd> db 0xfffff8a0002d97c0 l200 fffff8a0002d97c0 53 00 43 00 53 00 49 00-5c 00 44 00 69 00 73 00 S.C.S.I..D.i.s.
fffff8a0002d97d0 6b 00 26 00 56 00 65 00-6e 00 5f 00 53 00 69 00 k.&.V.e.n._.S.i. fffff8a0002d97e0 49 00 6d 00 61 00 67 00-65 00 26 00 50 00 72 00 I.m.a.g.e.&.P.r.
fffff8a0002d97f0 6f 00 64 00 5f 00 26 00-52 00 65 00 76 00 5f 00 o.d._.&.R.e.v._. fffff8a0002d9800 30 00 30 00 30 00 30 00-00 00 64 6f 5f 44 65 76 0.0.0.0…do_Dev
fffff8a0`002d9810 06 01 0a 05 53 65 53 64-00 10 18 00 01 00 0f 00 …SeSd…

BusQueryHardwareIDs:
0: kd> db 0xfffff8a00014a640 l200 fffff8a00014a640 53 00 43 00 53 00 49 00-5c 00 44 00 69 00 73 00 S.C.S.I..D.i.s.
fffff8a00014a650 6b 00 53 00 69 00 49 00-6d 00 61 00 67 00 65 00 k.S.i.I.m.a.g.e. fffff8a00014a660 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 ........
fffff8a00014a670 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a680 5f 00 30 00 30 00 30 00-30 00 00 00 53 00 43 00 .0.0.0.0…S.C.
fffff8a00014a690 53 00 49 00 5c 00 44 00-69 00 73 00 6b 00 53 00 S.I.\.D.i.s.k.S. fffff8a00014a6a0 69 00 49 00 6d 00 61 00-67 00 65 00 5f 00 5f 00 i.I.m.a.g.e.
..
fffff8a00014a6b0 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a6c0 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 00 00 ..
....
fffff8a00014a6d0 53 00 43 00 53 00 49 00-5c 00 44 00 69 00 73 00 S.C.S.I.\.D.i.s. fffff8a00014a6e0 6b 00 53 00 69 00 49 00-6d 00 61 00 67 00 65 00 k.S.i.I.m.a.g.e.
fffff8a00014a6f0 5f 00 00 00 53 00 43 00-53 00 49 00 5c 00 53 00 _...S.C.S.I.\.S. fffff8a00014a700 69 00 49 00 6d 00 61 00-67 00 65 00 5f 00 5f 00 i.I.m.a.g.e...
fffff8a00014a710 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a720 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 30 00 .......0.
fffff8a00014a730 00 00 53 00 69 00 49 00-6d 00 61 00 67 00 65 00 ..S.i.I.m.a.g.e. fffff8a00014a740 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 ..
....._.
fffff8a00014a750 5f 00 5f 00 5f 00 5f 00-5f 00 5f 00 5f 00 5f 00 _._._._._._._._. fffff8a00014a760 5f 00 30 00 00 00 47 00-65 00 6e 00 44 00 69 00 _.0…G.e.n.D.i.
fffff8a0`0014a770 73 00 6b 00 00 00 00 00-01 02 00 00 00 00 00 05 s.k…

Thank you.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

>> but it seems to me that leaves one falling back to parsing it out of the instance ID, if one leans to the pragmatic

Thank you for the suggestion.

> Can you tell it’s late Friday, I’m burned out, and I’m overdue for a beer?

I could have bought you a beer for the above suggestion if I was in Redmond (assuming you are in Redmond) :-). Have a good weekend.

by any chance do you know (I was just curious), why they don’t follow the standard? Thank you.

>>by any chance do you know (I was just curious), why they don’t follow the standard? Thank you.

No. If I’d been aware of this, I would have said something about it sooner. My expectations of getting it changed or even explained / justified are low enough I’m not going to try.

I don’t think you can even PRACTICALLY parse it out of the Instance ID (unless you JUST want to solve the problem for THIS driver). IIRC, the Instance ID can simply be anything that allows the device instance to be uniquely identified among all others. It need NOT include the Hardware ID.

Peter
OSR

I used device instance id which is = <instance-specific-id> as per msdn.