RE: Device driver load/unload notifications



Thanks, Sascha. I really appreciate your help :)

"Saga" wrote:

HI,

you can use the DEVCLASS_STREAM_GUID, too. But then you' ll get a
notification for every StreamDevice driver which is in the system. With your
own unique guid, you'll get only the notification for your special device. It
depends on your project, if you use your own guid or the DEVCLASS_STREAM_GUID.
You don't misinterpret the header comment, for stream-interface drivers
without a guid the device managers send a notification with the
DEVCLASS_STREAM_GUID automatically.


br

sascha
Thanks, Sascha. This looks like exactly what I need :)

Do I need a unique GUID? Can't I use the DEVCLASS_STREAM_GUID since my
driver is providing a stream device interface and use the instance name to
distinguish between the various drivers that advertise support for this GUID?

So is the flow something like:

When stream driver A is being loaded and unloaded, arrange to have
AdvertiseInterface called (or use the IClass in registry). Please see note at
end.

In application C, create the message queue and call
RequestDeviceNotifications specifying DEVCLASS_STREAM_GUID

Have the app block on the message queue handle. The app will get a message
when any driver that advertises a stream device interface is loaded and
unloaded by Device manager. Use the instance name to know if this is the
driver I am interested in.

When app is done, it does StopDeviceNotifications.

NOTE: The comments in the header file which defines the DEVCLASS_STREAM_GUID
seems to suggest there is no need to call AdvertiseInterface. Am I
misinterpreting this?

// Indicates an ordinary "stream" interface: open/read/write/iocontrol/close.
// Devices that do not specify anything else and which expose a "ABCN:"
// type of name automatically generate a notification with this GUID and
// and a name equal to the device name (e.g., "FOO2:").

Thanks much for your help.

"Saga" wrote:

Hi,

the Notification mechanism is really simple.
First you have to create the IClass Registry Key in your StreamDriver
Registry Settings and set this ICLass Key to an unique GUID (use GUID Gen).
In your Code, see this short example:

HANDLE hDevNotificationQueue = CreateMsgQueue( NULL, &msgQueueOptions );
// the devicemgr writes add/remove requests in this queue,
hDevNotifications = RequestDeviceNotifications(
&myGuid
hDevNotificationQueue,
TRUE );

while(!done)
{
dwWaitResult =
WaitForSingleObject(hDevNotificationQueue,MAX_TIME_FOR_MOUNT);
WCHAR buf[MAX_PATH + sizeof(DEVDETAIL)];
DEVDETAIL *lpDevDetail = (DEVDETAIL *) buf;
DWORD dwBytesRead = sizeof(buf);
if( ReadMsgQueue(
hDevNotificationQueue,
lpDevDetail,
dwBytesRead,
&dwBytesRead,
0,
&dwFlags )
{
GUID* guid = &lpDevDetail->guidDevClass;
......
}
CloseMsgQueue(...);
}

Best Regards

Sascha
"Gammaraman" wrote:

Hi,

I have a stream device driver A that is loaded as part of a (NDIS) miniport
device B bringup and unloaded as part of the miniport device B bringdown.

An application C does a CreateFile to open the stream device A (the
application in question does not have the option of loading A itself). If B
has not successfully loaded A then the CreateFile fails with device not found
as expected.

I would however like the application to be able to get a notification of
when B is up OR A is loaded (both of which are coupled). This way the
application would not have to sit in a tight loop doing a CreateFile till it
succeeds which sounds very inefficient.

Is there some kind of always on service that can keep track of state of A
and/or B and allow applications to register for state change notification or
something along those lines?

Any advice on how this can be accomplished? Any help is highly appreciated.

Thanks.
.



Relevant Pages

  • RE: Device driver load/unload notifications
    ... notification for every StreamDevice driver which is in the system. ... you'll get only the notification for your special device. ... if you use your own guid or the DEVCLASS_STREAM_GUID. ... When stream driver A is being loaded and unloaded, ...
    (microsoft.public.windowsce.platbuilder)
  • Kernel Streaming problem
    ... Im back to work on my KS based driver. ... My goal is to convert USB vendor specyfic stream producet by my USB sound ... generated guid and put it to name property ...
    (microsoft.public.development.device.drivers)
  • Confused about Kernel Streaming / DShow clocks...
    ... queried to give me a very accurate clock source. ... master clock for the graph (which might be themselves, ... then my clock support is going via the stream class driver. ...
    (microsoft.public.development.device.drivers)
  • Confused about Kernel Streaming / DShow clocks...
    ... queried to give me a very accurate clock source. ... master clock for the graph (which might be themselves, ... then my clock support is going via the stream class driver. ...
    (microsoft.public.win32.programmer.directx.video)
  • RE: Device driver load/unload notifications
    ... the Notification mechanism is really simple. ... Registry Settings and set this ICLass Key to an unique GUID. ... I have a stream device driver A that is loaded as part of a miniport ... An application C does a CreateFile to open the stream device A (the ...
    (microsoft.public.windowsce.platbuilder)

Loading