Using CreateEventEx causes problems with CAN_SetClientParam

CAN Development Packages for Windows®
Post Reply
hpetschko
Posts: 5
Joined: Fri 21. Aug 2015, 10:44

Using CreateEventEx causes problems with CAN_SetClientParam

Post by hpetschko » Thu 9. Jun 2022, 17:17

I have changed my event creation method from CreateEvent to CreateEventEx (see https://docs.microsoft.com/en-us/window ... teeventexw).
After doing so, CAN_SetClientParam (with CAN_PARAM_ONRCV_EVENT_HANDLE) returned CAN_ERR_ILLPARAMVAL.
I experimented a bit and found the following:

1) when using the following access rights in the last parameter: SYNCHRONIZE | DELETE | EVENT_MODIFY_STATE, the event handle was not accepted by the PEAK software.
2) when using STANDARD_RIGHTS_ALL, the event handle was not accepted by the PEAK software either
3) only when using EVENT_ALL_ACCESS, the event handle was accepted

::CreateEventExW(nullptr, nullptr, 0, EVENT_ALL_ACCESS);

The MS documentation does advise not use EVENT_ALL_ACCESS unless absolutely necessary and I never needed it so far.

My question now: why is it necessary for this handle to have these access rights?

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Using CreateEventEx causes problems with CAN_SetClientParam

Post by K.Wagner » Fri 10. Jun 2022, 09:29

Hello,

when you create an event for reading, this is not handled by the application/API but forwarded to the device driver which works in kernel mode. This has to do some opertations on the event to having it triggered from the kernel mode to the client mode, so this was implemented using ALL_ACCESS. If the event passed to the funciton doesn't have this flag, then it cannot be registered by the driver.

The documentation of this flag states :
Using this access right increases the possibility that your application must be run by an Administrator.
Since the event is managed by the device driver, this case wouldn't happen.

At the time the driver was written only the function CreateEvent was available. This function does use EVENT_ALL_ACCESS. We will nevertheless investigate, if there is a possibility to change this behaviour in the device driver.

Thanks for bringing this to our attention.
Best regards,
Keneth

hpetschko
Posts: 5
Joined: Fri 21. Aug 2015, 10:44

Re: Using CreateEventEx causes problems with CAN_SetClientParam

Post by hpetschko » Fri 10. Jun 2022, 13:47

Many thanks for the reply!

Post Reply