Another way (rather than wait on an overlapped call) is to pass in an event
from the user code.
(This is thanks to Walter Oney, see "Programming the MS Windows Driver
Model, 2nd ed)
The kernel needs to get a safe reference to the event the user passes in…
PKEVENT pkNotifyAppEvent;
ntStatus = ObReferenceObjectByHandle(userEvent, EVENT_MODIFY_STATE,
*ExEventObjectType, Irp->RequestorMode, (PVOID*) &pkNotifyAppEvent, NULL);
//if okay
pDeviceExtension->pNotifyApp = pkNotifyAppEvent;
//…don’t forget to deref once finished with…
The kernel can set this event when the user must take same action:
KeSetEvent(pDeviceExtension->pNotifyAppEvent, EVENT_INCREMENT, FALSE);
A user mode thread can wait on the event and when it is triggered, call into
the driver to find out what the result was.
while(true)
{
//can wait forever but you may want to check every 100mS if you should
give up
result = WaitForSingleObject(userEvent, 100); //wait up to 100mS
// if it happened, inquire here
}
This way the user inquires rather than being “called back” by the kernel,
which I doubt is possible.
- Mike
----- Original Message -----
From: nayan kumar
To: Windows System Software Devs Interest List
Sent: Wednesday, January 10, 2007 12:08 PM
Subject: [ntdev] How to communicate from kernel mode to user mod app
Hi All,
i want to know is there any way so that i can send a message from
kernel mode to user mode app for notification. i have requirment of notifing
the user mode app with interrupt register value when i am getting any
interrupt that has been generated from my device.as far as handling
interrupt is concern i am doing that successfully in kernel side .
i also want to know how to use callback function feature for communicating
with the user mode application.
any pointer tutorial that can help me to solve this problem.
Best Regards
Nayan
Catch all the cricketing action right here. Live score, match reports,
photos et al. http://content.msn.co.in/Sports/Cricket/Default.aspx
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer