Hi all,
I'm trying to get a driver to notify an application of the occurrence
of a certain condition by doing SetEvent on a handle provided by the
application via a DeviceIoControl call. However, the SetEvent fails
with error code ERROR_INVALID_HANDLE.
I guess it has something to do with manipulating user space pointers
in kernel space but what is the correct way around this? Any ideas are
much appreciated.

Thanks,
Rickard

Re: SetEvent by driver in WinCE6 by Valter

Valter
Mon Apr 21 01:53:11 PDT 2008

rickard.fahlquist@gmail.com wrote in
news:c6856114-f36e-4271-b4d8-ecdc4f51847e@k13g2000hse.googlegroups.co
m:

> Hi all,
> I'm trying to get a driver to notify an application of the
> occurrence of a certain condition by doing SetEvent on a handle
> provided by the application via a DeviceIoControl call. However,
> the SetEvent fails with error code ERROR_INVALID_HANDLE.
> I guess it has something to do with manipulating user space
> pointers in kernel space but what is the correct way around this?
> Any ideas are much appreciated.

You can create a named event inside the application and pass the event
name instead of the handle, letting the driver create it's own handle
using CreateEvent and the same obect name.
All the syncronization object creation functions allow you to specify
a name to give you a chance to share it to other processes.
Use some kind of naming convention to name those events (I use my
internet domain in reverse, project name and then a meaningful name)
and don't use names like "myevent" or "rxevent" to avoid that two
completely unrelated things get to share the same syncronization
object.
Naming events and other synchronization object, at least in debug
builds, is also useful to detect deadlock and other syncronization
issues because Kernel tracker will use object names in it's
visualization and this could avoid you the need to write out the
different event handles to understand the tracking.

--
Valter Minute
www.fortechembeddedlabs.it
Training, support and development for Windows CE
(the reply address of this message is invalid)

Re: SetEvent by driver in WinCE6 by shai

shai
Mon Apr 21 02:34:18 PDT 2008

On Apr 21, 11:34=A0am, rickard.fahlqu...@gmail.com wrote:
> Hi all,
> I'm trying to get a driver to notify an application of the occurrence
> of a certain condition by doing SetEvent on a handle provided by the
> application via a DeviceIoControl call. However, the SetEvent fails
> with error code ERROR_INVALID_HANDLE.
> I guess it has something to do with manipulating user space pointers
> in kernel space but what is the correct way around this? Any ideas are
> much appreciated.
>
> Thanks,
> Rickard

take a look at CeDriverDuplicateCallerHandle() before using the
setevent on the handle.

Shai

Re: SetEvent by driver in WinCE6 by rickard

rickard
Tue Apr 29 00:15:49 PDT 2008

On Apr 21, 11:34 am, shai <sha...@gmail.com> wrote:
> On Apr 21, 11:34 am, rickard.fahlqu...@gmail.com wrote:
>
> > Hi all,
> > I'm trying to get a driver to notify an application of the occurrence
> > of a certain condition by doing SetEvent on a handle provided by the
> > application via a DeviceIoControl call. However, the SetEvent fails
> > with error code ERROR_INVALID_HANDLE.
> > I guess it has something to do with manipulating user space pointers
> > in kernel space but what is the correct way around this? Any ideas are
> > much appreciated.
>
> > Thanks,
> > Rickard
>
> take a look at CeDriverDuplicateCallerHandle() before using the
> setevent on the handle.
>
> Shai

Hi,
Tried the CeDriverDuplicateCallerHandle() and it works fine! Thanks.

/Rickard