mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-27092 Windows - services that have non-ASCII characters do not work with activeCodePage=UTF8
CreateServiceA, OpenServiceA, and couple of other functions do not work correctly with non-ASCII character, in the special case where application has defined activeCodePage=UTF8. Workaround by redefining affected ANSI functions to own wrapper, which works by converting narrow(ANSI) to wide, then calling wide function. Deprecate original ANSI service functions, via declspec, so that we can catch their use.
This commit is contained in:
committed by
Sergei Golubchik
parent
99e5ae3b1a
commit
ea0a5cb0a4
@@ -141,24 +141,24 @@ void CUpgradeDlg::PopulateServicesList()
|
||||
ErrorExit("OpenSCManager failed");
|
||||
}
|
||||
|
||||
static BYTE buf[64*1024];
|
||||
static BYTE buf[2*64*1024];
|
||||
static BYTE configBuffer[8*1024];
|
||||
|
||||
DWORD bufsize= sizeof(buf);
|
||||
DWORD bufneed;
|
||||
DWORD num_services;
|
||||
BOOL ok= EnumServicesStatusEx(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
|
||||
BOOL ok= EnumServicesStatusExW(scm, SC_ENUM_PROCESS_INFO, SERVICE_WIN32,
|
||||
SERVICE_STATE_ALL, buf, bufsize, &bufneed, &num_services, NULL, NULL);
|
||||
if(!ok)
|
||||
ErrorExit("EnumServicesStatusEx failed");
|
||||
|
||||
|
||||
LPENUM_SERVICE_STATUS_PROCESS info =
|
||||
(LPENUM_SERVICE_STATUS_PROCESS)buf;
|
||||
LPENUM_SERVICE_STATUS_PROCESSW info =
|
||||
(LPENUM_SERVICE_STATUS_PROCESSW)buf;
|
||||
int index=-1;
|
||||
for (ULONG i=0; i < num_services; i++)
|
||||
{
|
||||
SC_HANDLE service= OpenService(scm, info[i].lpServiceName,
|
||||
SC_HANDLE service= OpenServiceW(scm, info[i].lpServiceName,
|
||||
SERVICE_QUERY_CONFIG);
|
||||
if (!service)
|
||||
continue;
|
||||
@@ -187,7 +187,11 @@ void CUpgradeDlg::PopulateServicesList()
|
||||
ServiceProperties props;
|
||||
props.myini= service_props.inifile;
|
||||
props.datadir= service_props.datadir;
|
||||
props.servicename = info[i].lpServiceName;
|
||||
char service_name_buf[1024];
|
||||
WideCharToMultiByte(GetACP(), 0, info[i].lpServiceName, -1,
|
||||
service_name_buf, sizeof(service_name_buf),
|
||||
0, 0);
|
||||
props.servicename= service_name_buf;
|
||||
if (service_props.version_major)
|
||||
{
|
||||
char ver[64];
|
||||
@@ -198,7 +202,7 @@ void CUpgradeDlg::PopulateServicesList()
|
||||
else
|
||||
props.version= "<unknown>";
|
||||
|
||||
index = m_Services.AddString(info[i].lpServiceName);
|
||||
index = m_Services.AddString(service_name_buf);
|
||||
services.resize(index+1);
|
||||
services[index] = props;
|
||||
}
|
||||
|
Reference in New Issue
Block a user