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

Re: Problems sending named events to Driver by Maxim

Maxim
Mon Jun 30 06:25:16 CDT 2003

> 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");

A much better way is to not use the named event. Create the unnamed
event in user mode, and pass the handle to the driver via IOCTL call.

Max



Re: Problems sending named events to Driver by Eliyas

Eliyas
Mon Jun 30 12:54:28 CDT 2003

http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q228785

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx

"Maxim S. Shatskih" <maxim@storagecraft.com> wrote in message
news:uNCVsqvPDHA.2460@TK2MSFTNGP10.phx.gbl...
> > 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");
>
> A much better way is to not use the named event. Create the unnamed
> event in user mode, and pass the handle to the driver via IOCTL call.
>
> Max
>
>