PnP Notification

Hi,

I’d like to get notified in my driver whenever a Cdrom device is enabled/
disabled or switched on/off - I did this with
IoRegisterPlugPlayNotification.

IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
(PVOID)&CdRomClassGuid,
pDriverObject,
MyPlugPlayNotification,
gDevObj,
&gNotificationEntry);

What I need now is to get a pointer to the file object in the notification

routine, which I tried to get with IoGetDeviceObjectPointer. This is
working
in case of event GUID_DEVICE_INTERFACE_ARRIVAL but not in case of
GUID_DEVICE_INTERFACE_REMOVAL. In case of GUID_DEVICE_INTERFACE_REMOVAL I
always get a STATUS_OBJECT_NAME_NOT_FOUND.

NTSTATUS MyPlugPlayNotification(IN PVOID NotificationStructure, IN PVOID
Context)
{
PDEVICE_INTERFACE_CHANGE_NOTIFICATION InterfaceNotification=
(PDEVICE_INTERFACE_CHANGE_NOTIFICATION)NotificationStructure;

NTSTATUS
status=IoGetDeviceObjectPointer(InterfaceNotification->SymbolicLinkName,
0, &pFileObj, &pDeviceObj);

}

Is there a way to get the pointer to the file object, it was still there
but
could not be accessed via the symbolic link name. I already tried not to
dereference the file object on arrival, but this also did not help.

Any clues?

Andreas Winter