Device notification in KMDF driver

Hi,
I am trying to make my KMDF driver send a notification to a user-mode
application. I could not find a KMDF-specific function so I am using
IoReportTargetDeviceChangeAsynchronous. The code used for this is
pretty close to the sample in this link:
http://www.microsoft.com/whdc/Driver/tips/PnPUmNotif.mspx

To get the PDO I am using WdfDeviceWdmGetPhysicalDevice(). The code
appears to be running but the user application is never recieving the
DBT_CUSTOMEVENT notification. Is there some reason this wouldn’t work
in a KMDF driver? Is there better functionality I should be using?

Thanks!
Jeremy

it should work just fine. post the code in the driver and the registration code in the app.

d

Yep, that’s what I have done. Not sure why the app never receives the
notifications. I’ve stepped through the code and verified that the
event should be triggered. IoReportTargetDeviceChangeAsynchronous()
returns STATUS_PENDING. I assume there is something wrong with my app
code but it receives the insert and removal notifications fine and
Message Spy tools show no message arriving when the event occurs.
My driver exports 5 interfaces. I use the GUID from one of those
interfaces for the registration for notifications. I’ve tried using
the GUID from each interface, but no difference.

On Fri, Jul 17, 2009 at 10:14 AM, wrote:
> it should work just fine. ?post the code in the driver and the registration code in the app.
>
> d
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

i asked for you to post the code, but somehow you want to ignore that. are you registering for file handle notifications once you have opened a handle to the driver? that is how custom notifications get to your app. custom notifications are not sent to everyone who have registered for interface arrival/departure notiications.

d

Sorry about that. I misread your instruction to post as “put the code
from that link into your driver and app”. I should have known you
asking for clarity.
I am not registering for file handle notifications. That’s probably
the problem. I see that the linked page says in the instructions that
you should register with the the handle to the device and
DEV_BROADCAST_HANDLE, though the sample code doesn’t show this. I’ll
investigate more with the file notification.

On Mon, Jul 20, 2009 at 10:26 AM, wrote:
> i asked for you to post the code, but somehow you want to ignore that. ?are you registering for file handle notifications once you have opened a handle to the driver? ?that is how custom notifications get to your app. ?custom notifications are not sent to everyone who have registered for interface arrival/departure notiications.
>
> d
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>

Calling RegisterDeviceNotification() with DEV_BROADCAST_HANDLE instead
of DEV_BROADCAST_DEVICEINTERFACE worked. I guess the device interface
method can only be used for notification of insertion and removal
notification, not custom events. Thanks for your help Doron!

On Mon, Jul 20, 2009 at 10:49 AM, Jeremy Ramer wrote:
> Sorry about that. I misread your instruction to post as “put the code
> from that link into your driver and app”. I should have known you
> asking for clarity.
> I am not registering for file handle notifications. That’s probably
> the problem. ?I see that the linked page says in the instructions that
> you should register with the the handle to the device and
> DEV_BROADCAST_HANDLE, though the sample code doesn’t show this. I’ll
> investigate more with the file notification.
>
> On Mon, Jul 20, 2009 at 10:26 AM, wrote:
>> i asked for you to post the code, but somehow you want to ignore that. ?are you registering for file handle notifications once you have opened a handle to the driver? ?that is how custom notifications get to your app. ?custom notifications are not sent to everyone who have registered for interface arrival/departure notiications.
>>
>> d
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>>
>