Discussion:
CreateEvent and SetEvent in WinCE6.0
(too old to reply)
vikranth_gaddam
2008-05-09 12:06:00 UTC
Permalink
Hi,

I am a newbie to Windows Embedded CE. Try to understand Embedded :)

I have a wince 5.0 based Application which creates a unnamed event and sends
an IOCTL to driver.
Upon completion of requested IO, driver uses setevent on event handle passed
by APP.
The whole thing works fine on WinCE 5.0

Now I have this driver in wince6.0 for a different platform, when i run the
APP (built using wince 5.0), i see exception "Abort data" in driver
(setevent, driver built using wince 6.0)

using unnamed events is not allowed in WinCE6.0?

If so, is there a work around for this instead of using named events?

Any information on this would be of great help

--Thanks in advance
Vikranth
Dean Ramsier
2008-05-09 12:20:22 UTC
Permalink
You need to duplicate the handle; you can't use the same event handle
directly in different processes. You got away with it in CE5 (even though
you shouldn't have done it) because there was a global handle table shared
by all processes, but that has now changed.

See DuplicateHandle() in the docs
--
Dean Ramsier - eMVP
BSQUARE Corporation
Post by vikranth_gaddam
Hi,
I am a newbie to Windows Embedded CE. Try to understand Embedded :)
I have a wince 5.0 based Application which creates a unnamed event and sends
an IOCTL to driver.
Upon completion of requested IO, driver uses setevent on event handle passed
by APP.
The whole thing works fine on WinCE 5.0
Now I have this driver in wince6.0 for a different platform, when i run the
APP (built using wince 5.0), i see exception "Abort data" in driver
(setevent, driver built using wince 6.0)
using unnamed events is not allowed in WinCE6.0?
If so, is there a work around for this instead of using named events?
Any information on this would be of great help
--Thanks in advance
Vikranth
vikranth_gaddam
2008-05-12 14:12:01 UTC
Permalink
Thanks Ramsier

When I modified driver code (in WinCE 5.0) to following

if (pUData->event != NULL)
{

if( !DuplicateHandle(hCallerProc, pUData->event, hCurrentProc,
&hLocalHandle, PROCESS_ALL_ACCESS, FALSE, DUPLICATE_SAME_ACCESS) )
{
DBG_WARNING(gDbgInfo, ("\n<---OwnerProcess: 0x%X CurrentProcess: 0x%X
Failed to duplicate handle: 0x%x\n", GetOwnerProcess(), GetCurrentProcess(),
GetLastError()));
}
else
{
//code to set event.
}

DuplicateHandle always returns zero with GetLastError as 0x57 (I think
INVALID_PARAMETER).

I couldn't figure out what went wrong with my code.
Any pointers will help me a lot.
Post by Dean Ramsier
You need to duplicate the handle; you can't use the same event handle
directly in different processes. You got away with it in CE5 (even though
you shouldn't have done it) because there was a global handle table shared
by all processes, but that has now changed.
See DuplicateHandle() in the docs
--
Dean Ramsier - eMVP
BSQUARE Corporation
Post by vikranth_gaddam
Hi,
I am a newbie to Windows Embedded CE. Try to understand Embedded :)
I have a wince 5.0 based Application which creates a unnamed event and sends
an IOCTL to driver.
Upon completion of requested IO, driver uses setevent on event handle passed
by APP.
The whole thing works fine on WinCE 5.0
Now I have this driver in wince6.0 for a different platform, when i run the
APP (built using wince 5.0), i see exception "Abort data" in driver
(setevent, driver built using wince 6.0)
using unnamed events is not allowed in WinCE6.0?
If so, is there a work around for this instead of using named events?
Any information on this would be of great help
--Thanks in advance
Vikranth
Dean Ramsier
2008-05-12 16:15:36 UTC
Permalink
I don't see any problems. Are you sure you have valid values in your
process handles?
--
Dean Ramsier - eMVP
BSQUARE Corporation
Post by vikranth_gaddam
Thanks Ramsier
When I modified driver code (in WinCE 5.0) to following
if (pUData->event != NULL)
{
if( !DuplicateHandle(hCallerProc, pUData->event, hCurrentProc,
&hLocalHandle, PROCESS_ALL_ACCESS, FALSE, DUPLICATE_SAME_ACCESS) )
{
DBG_WARNING(gDbgInfo, ("\n<---OwnerProcess: 0x%X CurrentProcess: 0x%X
Failed to duplicate handle: 0x%x\n", GetOwnerProcess(),
GetCurrentProcess(),
GetLastError()));
}
else
{
//code to set event.
}
DuplicateHandle always returns zero with GetLastError as 0x57 (I think
INVALID_PARAMETER).
I couldn't figure out what went wrong with my code.
Any pointers will help me a lot.
Post by Dean Ramsier
You need to duplicate the handle; you can't use the same event handle
directly in different processes. You got away with it in CE5 (even though
you shouldn't have done it) because there was a global handle table shared
by all processes, but that has now changed.
See DuplicateHandle() in the docs
--
Dean Ramsier - eMVP
BSQUARE Corporation
Post by vikranth_gaddam
Hi,
I am a newbie to Windows Embedded CE. Try to understand Embedded :)
I have a wince 5.0 based Application which creates a unnamed event and sends
an IOCTL to driver.
Upon completion of requested IO, driver uses setevent on event handle passed
by APP.
The whole thing works fine on WinCE 5.0
Now I have this driver in wince6.0 for a different platform, when i run the
APP (built using wince 5.0), i see exception "Abort data" in driver
(setevent, driver built using wince 6.0)
using unnamed events is not allowed in WinCE6.0?
If so, is there a work around for this instead of using named events?
Any information on this would be of great help
--Thanks in advance
Vikranth
vikranth_gaddam
2008-05-13 02:55:00 UTC
Permalink
I think so,

HANDLE hCallerProc = GetOwnerProcess();
HANDLE hCurrentProc = GetCurrentProcess();
HANDLE hLocalHandle = 0;

Also I tried by replacing GetOwnerProcess with GetCallerProcess.
Post by Dean Ramsier
I don't see any problems. Are you sure you have valid values in your
process handles?
--
Dean Ramsier - eMVP
BSQUARE Corporation
Post by vikranth_gaddam
Thanks Ramsier
When I modified driver code (in WinCE 5.0) to following
if (pUData->event != NULL)
{
if( !DuplicateHandle(hCallerProc, pUData->event, hCurrentProc,
&hLocalHandle, PROCESS_ALL_ACCESS, FALSE, DUPLICATE_SAME_ACCESS) )
{
DBG_WARNING(gDbgInfo, ("\n<---OwnerProcess: 0x%X CurrentProcess: 0x%X
Failed to duplicate handle: 0x%x\n", GetOwnerProcess(),
GetCurrentProcess(),
GetLastError()));
}
else
{
//code to set event.
}
DuplicateHandle always returns zero with GetLastError as 0x57 (I think
INVALID_PARAMETER).
I couldn't figure out what went wrong with my code.
Any pointers will help me a lot.
Post by Dean Ramsier
You need to duplicate the handle; you can't use the same event handle
directly in different processes. You got away with it in CE5 (even though
you shouldn't have done it) because there was a global handle table shared
by all processes, but that has now changed.
See DuplicateHandle() in the docs
--
Dean Ramsier - eMVP
BSQUARE Corporation
Post by vikranth_gaddam
Hi,
I am a newbie to Windows Embedded CE. Try to understand Embedded :)
I have a wince 5.0 based Application which creates a unnamed event and sends
an IOCTL to driver.
Upon completion of requested IO, driver uses setevent on event handle passed
by APP.
The whole thing works fine on WinCE 5.0
Now I have this driver in wince6.0 for a different platform, when i run the
APP (built using wince 5.0), i see exception "Abort data" in driver
(setevent, driver built using wince 6.0)
using unnamed events is not allowed in WinCE6.0?
If so, is there a work around for this instead of using named events?
Any information on this would be of great help
--Thanks in advance
Vikranth
Loading...