Problem on RegisterDeviceNotification(...)

Hello Everyone!

I have recently been trouble-shooting a service that calls
RegisterDeviceNotification to get device change notifications from CDROM
(GUID_DEVCLASS_CDROM) and HID (GUID_DEVCLASS_HIDCLASS) devices. The problem
is, even if the service sent RegisterDeviceNotification (and the function
succeeded), it doesn’t receive any SERVICE_CONTROL_DEVICEEVENT message even
when plugging my CDROM and HID devices (please see the device notification
registration code below).

HDEVNOTIFY DeviceNotificationHandleCD_ROM = NULL;
HDEVNOTIFY DeviceNotificationHandleHID = NULL;

////////////////////////////////////////////////////////////////////
//A. Request Notification from CDROM devices
////////////////////////////////////////////////////////////////////
DEV_BROADCAST_DEVICEINTERFACE DevNtfInterfaceCD_ROM;
memset(&DevNtfInterfaceCD_ROM, 0, sizeof(DevNtfInterfaceCD_ROM));
DevNtfInterfaceCD_ROM.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
DevNtfInterfaceCD_ROM.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
DevNtfInterfaceCD_ROM.dbcc_classguid = GUID_DEVCLASS_CDROM;
DeviceNotificationHandleCD_ROM = RegisterDeviceNotification(

MyServiceStatusHandle,

&DevNtfInterfaceCD_ROM,

DEVICE_NOTIFY_SERVICE_HANDLE);

if(DeviceNotificationHandleCD_ROM == NULL){
g_pTempClass->WriteLogWithTime(“CD-ROM Notification request
failed\r\n”);
}

////////////////////////////////////////////////////////////////////
//B. Request notification from HID devices
////////////////////////////////////////////////////////////////////
/*same as above, except that I used GUID_DEVCLASS_HIDCLASS instead of
GUID_DEVCLASS_CDROM*/

However, when I registered with DEVICE_NOTIFY_ALL_INTERFACE_CLASSES, I could
now get SERVICE_CONTROL_DEVICEEVENT notifications from my CDROM and HID
Devices(see code below):
////////////////////////////////////////////////////////////////////
Request Notification from all devices (please forgive me for the ***CDROM***
identifiers here, I just based this from my code above to avoid errors)
////////////////////////////////////////////////////////////////////
DEV_BROADCAST_DEVICEINTERFACE DevNtfInterfaceCD_ROM;
memset(&DevNtfInterfaceCD_ROM, 0, sizeof(DevNtfInterfaceCD_ROM));
DevNtfInterfaceCD_ROM.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
DevNtfInterfaceCD_ROM.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
DevNtfInterfaceCD_ROM.dbcc_classguid = GUID_DEVCLASS_CDROM;
//this param will be ignored
DeviceNotificationHandleCD_ROM = RegisterDeviceNotification(

MyServiceStatusHandle,

&DevNtfInterfaceCD_ROM,

DEVICE_NOTIFY_SERVICE_HANDLE |

DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);

This should have been ok, but the problem is, since
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES is not supported for Win2K
(which is one of our supported OS’s), I can’t use the said flag. What could
have been the problem of my code above(i.e. the code without the
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)?

Thanks a lot:D

You are using the device class GUID, that is not the same as the device
*interface* GUID. GUID_DEVINTERFACE_HID and GUID_DEVINTERFACE_CDROM are
the GUIDs you want to use.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raneil Ensomo
Sent: Friday, February 03, 2006 1:40 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem on RegisterDeviceNotification(…)

Hello Everyone!

I have recently been trouble-shooting a service that calls
RegisterDeviceNotification to get device change notifications from CDROM
(GUID_DEVCLASS_CDROM) and HID (GUID_DEVCLASS_HIDCLASS) devices. The
problem
is, even if the service sent RegisterDeviceNotification (and the
function
succeeded), it doesn’t receive any SERVICE_CONTROL_DEVICEEVENT message
even
when plugging my CDROM and HID devices (please see the device
notification
registration code below).

HDEVNOTIFY DeviceNotificationHandleCD_ROM = NULL;
HDEVNOTIFY DeviceNotificationHandleHID = NULL;

////////////////////////////////////////////////////////////////////
//A. Request Notification from CDROM devices
////////////////////////////////////////////////////////////////////
DEV_BROADCAST_DEVICEINTERFACE DevNtfInterfaceCD_ROM;
memset(&DevNtfInterfaceCD_ROM, 0, sizeof(DevNtfInterfaceCD_ROM));
DevNtfInterfaceCD_ROM.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
DevNtfInterfaceCD_ROM.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
DevNtfInterfaceCD_ROM.dbcc_classguid = GUID_DEVCLASS_CDROM;
DeviceNotificationHandleCD_ROM = RegisterDeviceNotification(

MyServiceStatusHandle,

&DevNtfInterfaceCD_ROM,

DEVICE_NOTIFY_SERVICE_HANDLE);

if(DeviceNotificationHandleCD_ROM == NULL){
g_pTempClass->WriteLogWithTime(“CD-ROM Notification request
failed\r\n”);
}

////////////////////////////////////////////////////////////////////
//B. Request notification from HID devices
////////////////////////////////////////////////////////////////////
/*same as above, except that I used GUID_DEVCLASS_HIDCLASS instead of
GUID_DEVCLASS_CDROM*/

However, when I registered with DEVICE_NOTIFY_ALL_INTERFACE_CLASSES, I
could
now get SERVICE_CONTROL_DEVICEEVENT notifications from my CDROM and HID
Devices(see code below):
////////////////////////////////////////////////////////////////////
Request Notification from all devices (please forgive me for the
***CDROM***
identifiers here, I just based this from my code above to avoid errors)
////////////////////////////////////////////////////////////////////
DEV_BROADCAST_DEVICEINTERFACE DevNtfInterfaceCD_ROM;
memset(&DevNtfInterfaceCD_ROM, 0, sizeof(DevNtfInterfaceCD_ROM));
DevNtfInterfaceCD_ROM.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
DevNtfInterfaceCD_ROM.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
DevNtfInterfaceCD_ROM.dbcc_classguid = GUID_DEVCLASS_CDROM;
//this param will be ignored
DeviceNotificationHandleCD_ROM = RegisterDeviceNotification(

MyServiceStatusHandle,

&DevNtfInterfaceCD_ROM,

DEVICE_NOTIFY_SERVICE_HANDLE |

DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);

This should have been ok, but the problem is, since
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES is not supported for Win2K
(which is one of our supported OS’s), I can’t use the said flag. What
could
have been the problem of my code above(i.e. the code without the
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)?

Thanks a lot:D


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks a lot. Had I not asked, it would have taken me centuries to solve
this one:))

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Doron Holan
Sent: Saturday, February 04, 2006 3:39 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Problem on RegisterDeviceNotification(…)

You are using the device class GUID, that is not the same as the device
*interface* GUID. GUID_DEVINTERFACE_HID and GUID_DEVINTERFACE_CDROM are
the GUIDs you want to use.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raneil Ensomo
Sent: Friday, February 03, 2006 1:40 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem on RegisterDeviceNotification(…)

Hello Everyone!

I have recently been trouble-shooting a service that calls
RegisterDeviceNotification to get device change notifications from CDROM
(GUID_DEVCLASS_CDROM) and HID (GUID_DEVCLASS_HIDCLASS) devices. The
problem
is, even if the service sent RegisterDeviceNotification (and the
function
succeeded), it doesn’t receive any SERVICE_CONTROL_DEVICEEVENT message
even
when plugging my CDROM and HID devices (please see the device
notification
registration code below).

HDEVNOTIFY DeviceNotificationHandleCD_ROM = NULL;
HDEVNOTIFY DeviceNotificationHandleHID = NULL;

////////////////////////////////////////////////////////////////////
//A. Request Notification from CDROM devices
////////////////////////////////////////////////////////////////////
DEV_BROADCAST_DEVICEINTERFACE DevNtfInterfaceCD_ROM;
memset(&DevNtfInterfaceCD_ROM, 0, sizeof(DevNtfInterfaceCD_ROM));
DevNtfInterfaceCD_ROM.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
DevNtfInterfaceCD_ROM.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
DevNtfInterfaceCD_ROM.dbcc_classguid = GUID_DEVCLASS_CDROM;
DeviceNotificationHandleCD_ROM = RegisterDeviceNotification(

MyServiceStatusHandle,

&DevNtfInterfaceCD_ROM,

DEVICE_NOTIFY_SERVICE_HANDLE);

if(DeviceNotificationHandleCD_ROM == NULL){
g_pTempClass->WriteLogWithTime(“CD-ROM Notification request
failed\r\n”);
}

////////////////////////////////////////////////////////////////////
//B. Request notification from HID devices
////////////////////////////////////////////////////////////////////
/*same as above, except that I used GUID_DEVCLASS_HIDCLASS instead of
GUID_DEVCLASS_CDROM*/

However, when I registered with DEVICE_NOTIFY_ALL_INTERFACE_CLASSES, I
could
now get SERVICE_CONTROL_DEVICEEVENT notifications from my CDROM and HID
Devices(see code below):
////////////////////////////////////////////////////////////////////
Request Notification from all devices (please forgive me for the
***CDROM***
identifiers here, I just based this from my code above to avoid errors)
////////////////////////////////////////////////////////////////////
DEV_BROADCAST_DEVICEINTERFACE DevNtfInterfaceCD_ROM;
memset(&DevNtfInterfaceCD_ROM, 0, sizeof(DevNtfInterfaceCD_ROM));
DevNtfInterfaceCD_ROM.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
DevNtfInterfaceCD_ROM.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
DevNtfInterfaceCD_ROM.dbcc_classguid = GUID_DEVCLASS_CDROM;
//this param will be ignored
DeviceNotificationHandleCD_ROM = RegisterDeviceNotification(

MyServiceStatusHandle,

&DevNtfInterfaceCD_ROM,

DEVICE_NOTIFY_SERVICE_HANDLE |

DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);

This should have been ok, but the problem is, since
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES is not supported for Win2K
(which is one of our supported OS’s), I can’t use the said flag. What
could
have been the problem of my code above(i.e. the code without the
DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)?

Thanks a lot:D


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com