Freddie Witherden
2010-09-23 22:12:09 UTC
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?
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?