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?
Using CreateEventEx causes problems with CAN_SetClientParam
Re: Using CreateEventEx causes problems with CAN_SetClientParam
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 :
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.
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 :
Since the event is managed by the device driver, this case wouldn't happen.Using this access right increases the possibility that your application must be run by an Administrator.
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
Keneth
Re: Using CreateEventEx causes problems with CAN_SetClientParam
Many thanks for the reply!