Hi NG
My driver has problems recieving a event from my user mode applikation. But
there is no problems recieving the same event in my appilication from the
device driver.
Thia is what I do:
In my DriverEntry i create the event with this:
// Create event for user-mode processes to monitor
RtlInitUnicodeString(&uszNotifyEventString,
L"\\BaseNamedObjects\\AppEvent");
// Trying to create the event
NotifyEvent = IoCreateNotificationEvent(&uszNotifyEventString,
&NotifyHandle);
if(NotifyEvent)
{
// Success
KdPrint(("NotifyEvent event created with success\r\n"));
// Clear it...
KeClearEvent(NotifyEvent);
}
I get the handle to the event in my application like this:
// Creating event. ITs created by the driver..
hEvent = OpenEvent(SYNCHRONIZE, FALSE, _T("AppEvent"));
if(NULL == hEvent )
{
return 0;
}
They both succed.
My application then waits for the event:
// The events used..
hEvents[0] = pService->HEndThread;
byNumOfEvents++;
hEvents[1] = hEvent ;
byNumOfEvents++;
dwWait = WaitForMultipleObjects(byNumOfEvents, hEvents, FALSE,
INFINITE);
if((WAIT_OBJECT_0 + 1) == dwWait)
{
// Set event again. Driver does not respond to this
SetEvent(hEvent ); <----- No responds in my driver on this
}
When my driver signals the event ( KeSetEvent(NotifyEvent, 0, TRUE) ) my
application is responding OK to the event
But when my application sets the event my driver does not respond to it.
// Setting event
KeSetEvent(NotifyEvent, 0, TRUE); <--- My application responds to this
KeResetEvent(NotifyEvent);
// Waiting for the service to answer
status = KeWaitForSingleObject(NotifyEvent, UserRequest, KernelMode,
FALSE, &WaitTimeOut);
// Never reached.
if(STATUS_SUCCESS == status)
{
KdPrint(("Got event.\r\n"));
// Service has answered. Clear the event. Shutdown in progress
KeResetEvent(NotifyEvent);
}
Any Idea ??
Schould I call the OpenEvent() with EVENT_ALL_ACCESS instead of SYNCHRONIZE
?? If I do I got an error that say "Access is denied". How can I create the
event with privilege to do this ??
Thomas