Discussion:
IOCTL_IEEE1394_API_REQUEST Adding and Opening Virtual Devices
(too old to reply)
Freddie Witherden
2010-09-23 22:12:09 UTC
Permalink
Hello,

I've been working on a WDF PnP driver which uses the
IOCTL_IEEE1394_API_REQUEST with IEEE1394_API_ADD_VIRTUAL_DEVICE to add
a virtual device. Assuming my driver is installed Windows will load
it and it will create a device interface. My program then uses
SetupDiEnumDeviceInterfaces and friends to find and open this handle.

My problem is as follows. The first time a virtual device is created
Windows takes a couple of seconds to delay-install the driver and
create the interface. All subsequent uses of the virtual device after
this are extremely quick. I want to know how my (library) code can
work around this. Always sleeping for two seconds or so is firstly
hacky, but also sub-optimal the second time my library is used (as the
interface is created quickly). Moreover, after waking up there is no
guarantee that a device interface will be created (such as if the
driver is not installed on the system).

How can my library do something along the lines of: "wait for an
interface if the driver is installed" otherwise to exit fast?
Repeatedly checking for new interfaces in a busy loop is also anything
but ideal (and again, may be in vain).

Finally, the virtual device created must be removed explicitly by user-
space with the IEEE1394_API_REMOVE_VIRTUAL_DEVICE IOCTL. However, if
a program using my library does not terminate correctly a virtual
device (and hence my driver and an interface) is left dangling. Is
there a means of cleaning up?
Maxim S. Shatskih
2010-09-24 07:42:00 UTC
Permalink
Post by Freddie Witherden
How can my library do something along the lines of: "wait for an
interface if the driver is installed" otherwise to exit fast?
You can subscribe to interface arrival notification with WM_DEVICECHANGE.
Post by Freddie Witherden
device (and hence my driver and an interface) is left dangling. Is
there a means of cleaning up?
SetupDi APIs on the next app start.
--
Maxim S. Shatskih
Windows DDK MVP
***@storagecraft.com
http://www.storagecraft.com
Pavel A.
2010-09-24 10:59:54 UTC
Permalink
.................
Finally, the virtual device created must be removed explicitly by user-
space with the IEEE1394_API_REMOVE_VIRTUAL_DEVICE IOCTL. However, if
a program using my library does not terminate correctly a virtual
device (and hence my driver and an interface) is left dangling. Is
there a means of cleaning up?
What bad could happen if the device is left behind after your app exited?
If nothing, you can just let it be; when the app runs again it will reuse
the device.
If you definitely must remove the device, make the driver detect that the
app
exited, for example, leave a pending ioctl. The driver will
receive cleanup when the app exits.

-- pa

Loading...