Getting device identification information in AddDevice or earlier

Hello,

I have a filter driver that, based on the device identification
information, decides whether to attach to device stack of a newly
reported device or not. Since the decision policy may change
dynamically, I cannot configure it via registry (as a filter driver for
only some device IDs).

My question: is there a reliable way of getting device ID/instance ID
during the AddDevice routine (or possibly earlier; when I see the PDO
appearing in the IRP_MN_QUERY_DEVICE_RELATIONS:BusRelations request)?
Or, is it possible to base the device identification on something else
than these IDs? I was relying on the hardware and compatible IDs and
that worked quite well but I am also inserted in the device ID case. My
experiments show that it is not possible to query this ID via
IRP_MN_QUERY_ID, since some devices (namely, WPDs) may then behave
incorrectly.

I know that I may query device descriptors by a way specific to the bus
the device is connected to, however, I would like to know about a
generic way first.

Thank you in advance for any replies/suggestions.

Martin

IoGetDeviceProperty

My experience with this function is that it may return empty results for
devices seen for the first time (the system apparently needs to gather
necessary information itself). Also, it does not help in terms of the
device ID (it does with HW/compatible ID but I can get those without
using this function).

Dne 10. 9. 2017 v 22:16 "xxxxx@broadcom.com ntdev"@lists.osr.com
napsal(a):

IoGetDeviceProperty


NTDEV is sponsored by OSR

Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:
></http:></http:></http:>

What you can do in AddDevice depends on the bus. USB will let you send queries for descriptors, others like pci may not be fully powered on yet

Bent from my phone


From: xxxxx@lists.osr.com on behalf of Martin Dr?b
Sent: Sunday, September 10, 2017 3:57:52 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Getting device identification information in AddDevice or earlier

My experience with this function is that it may return empty results for
devices seen for the first time (the system apparently needs to gather
necessary information itself). Also, it does not help in terms of the
device ID (it does with HW/compatible ID but I can get those without
using this function).

Dne 10. 9. 2017 v 22:16 "xxxxx@broadcom.com ntdev"@lists.osr.com
napsal(a):
> IoGetDeviceProperty
>
> —
> 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:
>


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:></https:></https:></https:>

During AddDevice, HW ID and instance ID must be fully available.

If all the information you need is not present in add device the other
option is to switch between “active” and “passive” filtering later when the
information is available. Passive filter mode is just pass through and
should add negligible performance cost and almost no additional complexity.

Mark Roddy

On Sun, Sep 10, 2017 at 10:31 PM, xxxxx@broadcom.com
wrote:

> During AddDevice, HW ID and instance ID must be fully available.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

Hello Mark,

my current implementation does exactly that. I was asked whether it
would be possible to achieve the same thing even without passive
filtering. And since I did not come with any reasonable idea, I decided
to ask more skilled audience (means: these mailing lists).

Martin

Dne 11. 9. 2017 v 17:47 "Mark Roddyntdev"@lists.osr.com napsal(a):

If all the information you need is not present in add device the other
option is to switch between “active” and “passive” filtering later when the
information is available. Passive filter mode is just pass through and
should add negligible performance cost and almost no additional complexity.

Mark Roddy

On Sun, Sep 10, 2017 at 10:31 PM, xxxxx@broadcom.com
> wrote:
>
>> During AddDevice, HW ID and instance ID must be fully available.
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list online at: http:>> showlists.cfm?list=ntdev>
>>
>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>> software drivers!
>> Details at http:
>>
>> To unsubscribe, visit the List Server section of OSR Online at <
>> http://www.osronline.com/page.cfm?name=ListServer&gt;
>>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:
></http:></http:></http:></http:></http:>

You can send an IRP_MN_QUERY_ID PNP IRP with an IdType of BusQueryHardwareIDs to the lower drivers. On success, the bus driver sets the Information member of the IoStatusBlock to the address of a MULTI_SZ string containing the hardware IDs of the device.