If you remember to format all your output data structures before you
make calls, SetupDI isn’t really that hard. Create a device data set,
get classes with the right device interface, walk through the device
set, get the interface details and use the device path.
Since the device interface strings are static (assuming your device
instance ID stays stable) , your customer could just hard code those
into their app or make a cute symlink to the ugly DI one and use that.
This lets you build your driver the “right” way and lets your customer
use CRT functions to access the device.
-p
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Thursday, May 18, 2006 11:24 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Device interfaces and symbolic links
OK so there are advantages to device interfaces for standard hardware,
multiple instances of the hardware in one system, and devices that come
and go while the system is running.
For identifying a device for normal operation like reading writing and
sending IOCTLs, the SP_DEVINFO is not needed. It is only needed for
device management which is typically done by a setup program rather than
an application used for normal operation. Two different things. It’s OK
to have a setup aplication use the SetupDI stuff. That’s what it was
written for. Forcing an application to use it when all they want to do
is access the device is overkill.
Thanks for the input.
Beverly
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Thursday, May 18, 2006 1:21 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Device interfaces and symbolic links
Symbolic Links only work when there’s one of a device and it’s in the
machine all the time. They break down once you go outside that
scenario.
Other things that don’t work well:
1 - Device Interfaces let you get notification when the interface comes
and goes
2 - Device Interfaces are the same from boot to boot (assuming your
device instances IDs remain constant) regardless of the order the device
initialization. For symlinks you never know that Link0 points to the
same device from one boot to the next.
3 - You can’t convert a symbolic link into a SP_DEVINFO item that you
can use with SetupDI to manage the device. Once you dip into SetupDI to
find the device everything else is trivial.
Every time I’ve seen someone make decisions based on the assumption that
only one of their device will be installed all the time, I’ve seen them
regret it shortly afterwards once someone starts actually using the
device. They disable it and re-enable it and suddenly everything else
falls apart.
The device interface link remains the same from boot to boot. Once your
customers discover what it is, they can use it again and again (or make
their own symlink to that) if they’re really flummoxed by SetupDI.
-p
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Thursday, May 18, 2006 7:03 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Device interfaces and symbolic links
OK. I can see the advantage for something common like a CDROM drive. For
a proprietary device, it makes much less sense.
I can avoid name conflicts by giving it the same name as my driver with
an enumeration appended to it to identify a particular instance (if it
was easier to get the device instance number - you know the 4 -digit
decimal number that is the key under the class GUID for the device - I
could use that). The possiblity of a name conflict is about as high as
the possiblity of someone having a driver with the same name so I don’t
see it as a problem.
For multiple instances, that is taken care of with the instance ID
appended to my device name as mentioned above.
I had RegisterDeviceNotification working with a symbolically linked
named device, so it doesn’t seem to require device interfaces. My device
does not fit any of the standard setup classes, so it has its own class,
so I guess that’s why it worked?.
So for my purposes there still don’t seem to be any real advantages to
device interfaces over symbolic links. So what about my concern that the
DDI IoCreateSymbolicLink could go away because of the push towards
device interfaces? Is that a valid concern? Can I continue to use it in
order to make life easier for the users of my device? (Bear in mind that
some of these users are accustomed to a linux-style interface and need
to make their code work with both Linux and Windows ( and they pretty
much vomit when they see the SetupDI stuff). Oh and they don’t want me
to supply an API, they want to use standard OS interfaces, so wrapping
the setupDI stuff in a library call or class is out of the question for
what I am currently working on.
Beverly
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Roddy, Mark
Sent: Thursday, May 18, 2006 9:15 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Device interfaces and symbolic links
-
Guids avoid name conflicts.
-
For device interfaces where there can be multiple instances,
the hideous setupdi api provides a consistent and reliable enumeration
mechanism.
-
For devices that can arrive and depart while the system is
running the scheme is essential. RegisterDeviceNotification is essential
and it is part of the whole guid based interface mechanism.
I just wrap the whole setupdi mess in a simple C++ class that takes a
guid as a constructor argument.
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Thursday, May 18, 2006 8:51 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Device interfaces and symbolic links
I have used both device interfaces and symbolic links and quite frankly
I do not see any advantages to using device interfaces. They are
cumbersome for the user because it forces them to use that awful SetupDI
API. It doesn’t save on documentation because I still have to document
the GUID to use for the device interface. It seems a whole lot more
user-friendly to use IoCreateSymboliLink instead and just document the
symbolic link name. It’s much more readable and easier for the user to
understand (and no SetupDI usage required). Opening a device with a
published symbolic lionk name is much more user-friendly.
I don’t want to make life more difficult for the users of my driver
because I chose to implement it “the right way”. My users don’t see it
as the right way at all. They see it as overly cumbersome. But I am
concerned that the IoCreateSymbolicLink DDI will go away because the
docs state that WDM drivers do not create named devices. (Huh? Why not?)
However I don’t see the downside of using it and don’t see the
advantages of device interfaces. Are there any that maybe I’m just not
aware of?
Beverly
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer