Hi, My understanding is that this is related to https://github.com/OpenVPN/openvpn-gui/issues/626#issuecomment-1546934297 since normally we use string representation of HANDLE value as an event name.
Looks good to me. Also compiled and tested. Acked-by: Lev Stipakov <lstipa...@gmail.com> ti 16. toukok. 2023 klo 5.57 selva.n...@gmail.com kirjoitti: > > From: Selva Nair <selva.n...@gmail.com> > > Currently we use the ANSI version of CreateEvent causing name of the > exit event to be interpreted differently depending on the code page > in effect. Internally all strings parsed from command line and config > file are stored as UTF8-encoded Uniode. When passed to Windows API calls, > these should be converted to UTF16 and wide character version of the API > should be used. > > CreateEvent calls for unnamed events are left unchanged as there is no > text-encoding dependence in those cases. > > Signed-off-by: Selva Nair <selva.n...@gmail.com> > --- > src/openvpn/win32.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c > index 1ae3723f..25da54ab 100644 > --- a/src/openvpn/win32.c > +++ b/src/openvpn/win32.c > @@ -509,19 +509,19 @@ win32_signal_open(struct win32_signal *ws, > && !HANDLE_DEFINED(ws->in.read) && exit_event_name) > { > struct security_attributes sa; > + struct gc_arena gc = gc_new(); > + const wchar_t *exit_event_nameW = wide_string(exit_event_name, &gc); > > if (!init_security_attributes_allow_all(&sa)) > { > msg(M_ERR, "Error: win32_signal_open: init SA failed"); > } > > - ws->in.read = CreateEvent(&sa.sa, > - TRUE, > - exit_event_initial_state ? TRUE : FALSE, > - exit_event_name); > + ws->in.read = CreateEventW(&sa.sa, TRUE, exit_event_initial_state ? > TRUE : FALSE, > + exit_event_nameW); > if (ws->in.read == NULL) > { > - msg(M_WARN|M_ERRNO, "NOTE: CreateEvent '%s' failed", > exit_event_name); > + msg(M_WARN|M_ERRNO, "NOTE: CreateEventW '%s' failed", > exit_event_name); > } > else > { > @@ -534,6 +534,7 @@ win32_signal_open(struct win32_signal *ws, > ws->mode = WSO_MODE_SERVICE; > } > } > + gc_free(&gc); > } > /* set the ctrl handler in both console and service modes */ > if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) win_ctrl_handler, true)) > -- > 2.34.1 > > > > _______________________________________________ > Openvpn-devel mailing list > Openvpn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openvpn-devel -- -Lev _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel