AddDevice routine that does not attach or create a device object

Hello,

I am quite confused about several things related to PNP drivers and
AddDevice routine. I would be really grateful if someone would be so
kind and cleared the things for me a bit.

I know that when I install my driver as an upper (or lower) filter for a
device setup class, PnP Manager will invoke its AddDevice routine when a
new device of that class is connected to the system and initialized a
bit. It is expected that the AddDevice routine will create a device
object and attaches it to the newly creating device stack (PDO of which
is given in the second argument of the call). My question is, what bad
happens (pr does not happen) when I decide not to attach my device to
the device stack and just return STATUS_SUCCESS?

It seems that such a driver (that just returns STATUS_SUCCESS in its
AddDevice) may have problems in being loaded again when a new device of
the same class is connected to the system. At least, I seem to have this
experience with boot-start drivers. System reports that they failed to
start. The drivers do not create any device objects apart from their
AddDevice routines (and only in case they decide to attach to the given
device stack).

I know I can just attach to any device stack and work as a pass-through
filter for devices I am not interested in but I am not a fan of
attaching to device stacks I have nothing to do.

I would appreciate any information related to this stuff.

Best regards
Martin Dráb

It is valid for a filter to not attach and return success from AddDevice. It should bot affect reload or attaching to new stacks. Perhaps boot start imposes a restriction on that statement, but I haven’t heard of that before.

Sent from Outlook Mailhttp: for Windows 10 phone

From: Martin Dr?b
Sent: Saturday, November 21, 2015 4:13 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] AddDevice routine that does not attach or create a device object

Hello,

I am quite confused about several things related to PNP drivers and
AddDevice routine. I would be really grateful if someone would be so
kind and cleared the things for me a bit.

I know that when I install my driver as an upper (or lower) filter for a
device setup class, PnP Manager will invoke its AddDevice routine when a
new device of that class is connected to the system and initialized a
bit. It is expected that the AddDevice routine will create a device
object and attaches it to the newly creating device stack (PDO of which
is given in the second argument of the call). My question is, what bad
happens (pr does not happen) when I decide not to attach my device to
the device stack and just return STATUS_SUCCESS?

It seems that such a driver (that just returns STATUS_SUCCESS in its
AddDevice) may have problems in being loaded again when a new device of
the same class is connected to the system. At least, I seem to have this
experience with boot-start drivers. System reports that they failed to
start. The drivers do not create any device objects apart from their
AddDevice routines (and only in case they decide to attach to the given
device stack).

I know I can just attach to any device stack and work as a pass-through
filter for devices I am not interested in but I am not a fan of
attaching to device stacks I have nothing to do.

I would appreciate any information related to this stuff.

Best regards
Martin Dr?b


NTDEV is sponsored by OSR

Visit the list at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.com%2Fshowlists.cfm%3Flist%3Dntdev&data=01|01|Doron.Holan%40microsoft.com|49d8daf1e6d945b83dc508d2f26d3089|72f988bf86f141af91ab2d7cd011db47|1&sdata=8ebvTzzMXis%2F%2BHNxhhMd4PEcHrBANZO7pdoYvZSE3po%3D

OSR is HIRING!! See https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osr.com%2Fcareers&data=01|01|Doron.Holan%40microsoft.com|49d8daf1e6d945b83dc508d2f26d3089|72f988bf86f141af91ab2d7cd011db47|1&sdata=3ojDM3dfsM4U7uGRAwz5UAB6agq8Ik2xZChZbarXhr0%3D

For our schedule of WDF, WDM, debugging and other seminars visit:
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osr.com%2Fseminars&data=01|01|Doron.Holan%40microsoft.com|49d8daf1e6d945b83dc508d2f26d3089|72f988bf86f141af91ab2d7cd011db47|1&sdata=OcLG7WzaJ51u1uCeD%2BCDUJ403pgS5%2B1%2BbeeeBJH4idY%3D

To unsubscribe, visit the List Server section of OSR Online at https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.com%2Fpage.cfm%3Fname%3DListServer&amp;data=01|01|Doron.Holan%40microsoft.com|49d8daf1e6d945b83dc508d2f26d3089|72f988bf86f141af91ab2d7cd011db47|1&amp;sdata=860G%2FSI3tONz3ezVAiP%2FFBQUDhNTDiXRgBwgZgT5Oco%3D</http:>

> is given in the second argument of the call). My question is, what bad

happens (pr does not happen) when I decide not to attach my device to
the device stack and just return STATUS_SUCCESS?

Nothing bad, I think it is even documented to be legitimate way.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

@Doron Holan:

In my experience, boot start drivers, in case if there was no devnode created for them (the board was pulled out), caused creation of a persistent root-enumerated devnode, but I don’t think their AddDevice was ever called. That root-enumerated devnode was sometimes confusing WLK, though.