[CTFMON][MSCTFIME][MSCTF][MSUTB][SDK] Cicero is ANSI, not Unicode (#6230)

Cicero interface is not Unicode (W)
but ANSI (A).
- ctfmon.exe is ANSI, not Unicode.
- msutb.dll is ANSI, not Unicode.
- Apply generic text mapping to the
  cicero headers.
- Include <tchar.h> to use generic
  text mapping.
CORE-19361, CORE-19362, CORE-19363
This commit is contained in:
Katayama Hirofumi MZ 2023-12-26 12:07:01 +09:00 committed by GitHub
parent a8a4703699
commit bfa3e554d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 197 additions and 156 deletions

View file

@ -71,9 +71,9 @@ cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
*pdwOSInfo = 0;
/* Check OS version info */
OSVERSIONINFOW VerInfo;
OSVERSIONINFO VerInfo;
VerInfo.dwOSVersionInfoSize = sizeof(VerInfo);
GetVersionExW(&VerInfo);
GetVersionEx(&VerInfo);
if (VerInfo.dwPlatformId == DLLVER_PLATFORM_NT)
{
*pdwOSInfo |= CIC_OSINFO_NT;
@ -113,7 +113,7 @@ cicGetOSInfo(LPUINT puACP, LPDWORD pdwOSInfo)
struct CicSystemModulePath
{
WCHAR m_szPath[MAX_PATH + 2];
TCHAR m_szPath[MAX_PATH + 2];
SIZE_T m_cchPath;
CicSystemModulePath()
@ -122,31 +122,31 @@ struct CicSystemModulePath
m_cchPath = 0;
}
BOOL Init(_In_ LPCWSTR pszFileName, _In_ BOOL bSysWinDir);
BOOL Init(_In_ LPCTSTR pszFileName, _In_ BOOL bSysWinDir);
};
// Get an instance handle that is already loaded
static inline HINSTANCE
cicGetSystemModuleHandle(
_In_ LPCWSTR pszFileName,
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir)
{
CicSystemModulePath ModPath;
if (!ModPath.Init(pszFileName, bSysWinDir))
return NULL;
return GetModuleHandleW(ModPath.m_szPath);
return GetModuleHandle(ModPath.m_szPath);
}
// Load a system library
static inline HINSTANCE
cicLoadSystemLibrary(
_In_ LPCWSTR pszFileName,
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir)
{
CicSystemModulePath ModPath;
if (!ModPath.Init(pszFileName, bSysWinDir))
return NULL;
return ::LoadLibraryW(ModPath.m_szPath);
return ::LoadLibrary(ModPath.m_szPath);
}
#include <ndk/pstypes.h> /* for PROCESSINFOCLASS */
@ -163,7 +163,7 @@ static inline BOOL cicIsWow64(VOID)
if (!s_fnNtQueryInformationProcess)
{
HMODULE hNTDLL = cicGetSystemModuleHandle(L"ntdll.dll", FALSE);
HMODULE hNTDLL = cicGetSystemModuleHandle(TEXT("ntdll.dll"), FALSE);
if (!hNTDLL)
return FALSE;
@ -184,38 +184,38 @@ static inline BOOL cicIsWow64(VOID)
inline BOOL
CicSystemModulePath::Init(
_In_ LPCWSTR pszFileName,
_In_ LPCTSTR pszFileName,
_In_ BOOL bSysWinDir)
{
SIZE_T cchPath;
if (bSysWinDir)
{
// Usually C:\Windows or C:\ReactOS
cchPath = ::GetSystemWindowsDirectoryW(m_szPath, _countof(m_szPath));
cchPath = ::GetSystemWindowsDirectory(m_szPath, _countof(m_szPath));
}
else
{
// Usually C:\Windows\system32 or C:\ReactOS\system32
cchPath = ::GetSystemDirectoryW(m_szPath, _countof(m_szPath));
cchPath = ::GetSystemDirectory(m_szPath, _countof(m_szPath));
}
m_szPath[_countof(m_szPath) - 1] = UNICODE_NULL; // Avoid buffer overrun
m_szPath[_countof(m_szPath) - 1] = TEXT('\0'); // Avoid buffer overrun
if ((cchPath == 0) || (cchPath > _countof(m_szPath) - 2))
goto Failure;
// Add backslash if necessary
if ((cchPath > 0) && (m_szPath[cchPath - 1] != L'\\'))
if ((cchPath > 0) && (m_szPath[cchPath - 1] != TEXT('\\')))
{
m_szPath[cchPath + 0] = L'\\';
m_szPath[cchPath + 1] = UNICODE_NULL;
m_szPath[cchPath + 0] = TEXT('\\');
m_szPath[cchPath + 1] = TEXT('\0');
}
// Append pszFileName
if (FAILED(StringCchCatW(m_szPath, _countof(m_szPath), pszFileName)))
if (FAILED(StringCchCat(m_szPath, _countof(m_szPath), pszFileName)))
goto Failure;
m_cchPath = wcslen(m_szPath);
m_cchPath = _tcslen(m_szPath);
return TRUE;
Failure:
@ -254,7 +254,7 @@ cicRealCoCreateInstance(
if (!s_fnCoCreateInstance)
{
if (!s_hOle32)
s_hOle32 = cicLoadSystemLibrary(L"ole32.dll", FALSE);
s_hOle32 = cicLoadSystemLibrary(TEXT("ole32.dll"), FALSE);
s_fnCoCreateInstance = (FN_CoCreateInstance)GetProcAddress(s_hOle32, "CoCreateInstance");
if (!s_fnCoCreateInstance)
return E_NOTIMPL;

View file

@ -12,7 +12,7 @@
class CicEvent
{
HANDLE m_hEvent;
LPCWSTR m_pszName;
LPCTSTR m_pszName;
public:
CicEvent() : m_hEvent(NULL), m_pszName(NULL)
@ -23,20 +23,20 @@ public:
Close();
}
BOOL Create(LPSECURITY_ATTRIBUTES lpSA, LPCWSTR pszName)
BOOL Create(LPSECURITY_ATTRIBUTES lpSA, LPCTSTR pszName)
{
if (pszName)
m_pszName = pszName;
if (!m_pszName)
return FALSE;
m_hEvent = ::CreateEventW(lpSA, FALSE, FALSE, m_pszName);
m_hEvent = ::CreateEvent(lpSA, FALSE, FALSE, m_pszName);
return (m_hEvent != NULL);
}
BOOL Open(LPCWSTR pszName)
BOOL Open(LPCTSTR pszName)
{
if (pszName)
m_pszName = pszName;
m_hEvent = ::OpenEventW(EVENT_ALL_ACCESS, FALSE, m_pszName);
m_hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, m_pszName);
return (m_hEvent != NULL);
}
void Close()

View file

@ -15,7 +15,7 @@
class CicFileMappingStatic
{
protected:
LPCWSTR m_pszName;
LPCTSTR m_pszName;
LPVOID m_pView;
HANDLE m_hMapping;
BOOL m_bCreated;
@ -28,7 +28,7 @@ public:
CicFileMappingStatic() { }
~CicFileMappingStatic() { }
void Init(LPCWSTR pszName, CicMutex *pMutex);
void Init(LPCTSTR pszName, CicMutex *pMutex);
LPVOID Create(LPSECURITY_ATTRIBUTES pSA, DWORD dwMaximumSizeLow, LPBOOL pbAlreadyExists);
LPVOID Open();
@ -43,14 +43,14 @@ public:
class CicFileMapping : public CCicFileMappingStatic
{
public:
CicFileMapping(LPCWSTR pszName, CicMutex *pMutex);
CicFileMapping(LPCTSTR pszName, CicMutex *pMutex);
virtual ~CicFileMapping() { Finalize(); }
};
/******************************************************************************/
inline
CicFileMapping::CicFileMapping(LPCWSTR pszName, CicMutex *pMutex)
CicFileMapping::CicFileMapping(LPCTSTR pszName, CicMutex *pMutex)
: m_pszName(NULL)
, m_pView(NULL)
, m_hMapping(NULL)
@ -78,7 +78,7 @@ inline void CicFileMappingStatic::Close()
m_bCreated = FALSE;
}
inline void CicFileMappingStatic::Init(LPCWSTR pszName, CicMutex *pMutex)
inline void CicFileMappingStatic::Init(LPCTSTR pszName, CicMutex *pMutex)
{
if (pMutex)
m_pMutex = pMutex;
@ -97,12 +97,12 @@ CicFileMappingStatic::Create(
if (!m_pszName)
return NULL;
m_hMapping = ::CreateFileMappingW(INVALID_HANDLE_VALUE,
pSA,
PAGE_READWRITE,
0,
dwMaximumSizeLow,
m_pszName);
m_hMapping = ::CreateFileMapping(INVALID_HANDLE_VALUE,
pSA,
PAGE_READWRITE,
0,
dwMaximumSizeLow,
m_pszName);
if (pbAlreadyExists)
*pbAlreadyExists = (::GetLastError() == ERROR_ALREADY_EXISTS);
if (!m_hMapping)
@ -116,7 +116,7 @@ inline LPVOID CicFileMappingStatic::Open()
{
if (!m_pszName)
return NULL;
m_hMapping = ::OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, m_pszName);
m_hMapping = ::OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, m_pszName);
if (!m_hMapping)
return NULL;

View file

@ -23,9 +23,9 @@ public:
Uninit();
}
void Init(LPSECURITY_ATTRIBUTES lpSA, LPCWSTR pszMutexName)
void Init(LPSECURITY_ATTRIBUTES lpSA, LPCTSTR pszMutexName)
{
m_hMutex = ::CreateMutexW(lpSA, FALSE, pszMutexName);
m_hMutex = ::CreateMutex(lpSA, FALSE, pszMutexName);
m_bInit = TRUE;
}
void Uninit()

View file

@ -23,43 +23,48 @@ public:
LSTATUS Open(
HKEY hKey,
LPCWSTR lpSubKey,
LPCTSTR lpSubKey,
REGSAM samDesired = KEY_READ);
LSTATUS Create(
HKEY hKey,
LPCWSTR lpSubKey,
LPWSTR lpClass = NULL,
LPCTSTR lpSubKey,
LPTSTR lpClass = NULL,
DWORD dwOptions = REG_OPTION_NON_VOLATILE,
REGSAM samDesired = KEY_ALL_ACCESS,
LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL,
LPDWORD pdwDisposition = NULL);
LSTATUS QueryDword(LPCWSTR pszValueName, LPDWORD pdwValue)
LSTATUS QueryDword(LPCTSTR pszValueName, LPDWORD pdwValue)
{
DWORD cbData = sizeof(DWORD);
return ::RegQueryValueExW(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData);
return ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL, (LPBYTE)pdwValue, &cbData);
}
LSTATUS SetDword(LPCWSTR pszValueName, DWORD dwValue)
LSTATUS SetDword(LPCTSTR pszValueName, DWORD dwValue)
{
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(dwValue));
}
LSTATUS QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax);
LSTATUS QuerySz(LPCTSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax);
LSTATUS SetSz(LPCWSTR pszValueName, LPCWSTR pszValue)
LSTATUS SetSz(LPCTSTR pszValueName, LPCTSTR pszValue)
{
DWORD cbValue = (lstrlen(pszValue) + 1) * sizeof(TCHAR);
return ::RegSetValueEx(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
LSTATUS SetSzW(LPCWSTR pszValueName, LPCWSTR pszValue)
{
DWORD cbValue = (lstrlenW(pszValue) + 1) * sizeof(WCHAR);
return ::RegSetValueExW(m_hKey, pszValueName, 0, REG_SZ, (LPBYTE)pszValue, cbValue);
}
LSTATUS DeleteSubKey(LPCWSTR lpSubKey)
LSTATUS DeleteSubKey(LPCTSTR lpSubKey)
{
return ::RegDeleteKeyW(m_hKey, lpSubKey);
return ::RegDeleteKey(m_hKey, lpSubKey);
}
LSTATUS RecurseDeleteKey(LPCWSTR lpSubKey);
LSTATUS RecurseDeleteKey(LPCTSTR lpSubKey);
};
/******************************************************************************/
@ -77,11 +82,11 @@ CicRegKey::Close()
inline LSTATUS
CicRegKey::Open(
HKEY hKey,
LPCWSTR lpSubKey,
LPCTSTR lpSubKey,
REGSAM samDesired)
{
HKEY hNewKey = NULL;
LSTATUS error = ::RegOpenKeyExW(hKey, lpSubKey, 0, samDesired, &hNewKey);
LSTATUS error = ::RegOpenKeyEx(hKey, lpSubKey, 0, samDesired, &hNewKey);
if (error != ERROR_SUCCESS)
return error;
@ -93,23 +98,23 @@ CicRegKey::Open(
inline LSTATUS
CicRegKey::Create(
HKEY hKey,
LPCWSTR lpSubKey,
LPWSTR lpClass,
LPCTSTR lpSubKey,
LPTSTR lpClass,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
LPDWORD pdwDisposition)
{
HKEY hNewKey = NULL;
LSTATUS error = ::RegCreateKeyExW(hKey,
lpSubKey,
0,
lpClass,
dwOptions,
samDesired,
lpSecurityAttributes,
&hNewKey,
pdwDisposition);
LSTATUS error = ::RegCreateKeyEx(hKey,
lpSubKey,
0,
lpClass,
dwOptions,
samDesired,
lpSecurityAttributes,
&hNewKey,
pdwDisposition);
if (error != ERROR_SUCCESS)
return error;
@ -119,13 +124,13 @@ CicRegKey::Create(
}
inline LSTATUS
CicRegKey::QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax)
CicRegKey::QuerySz(LPCTSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax)
{
DWORD cchSaveMax = cchValueMax;
cchValueMax *= sizeof(WCHAR);
LSTATUS error = ::RegQueryValueExW(m_hKey, pszValueName, 0, NULL,
(LPBYTE)pszValue, &cchValueMax);
cchValueMax *= sizeof(TCHAR);
LSTATUS error = ::RegQueryValueEx(m_hKey, pszValueName, 0, NULL,
(LPBYTE)pszValue, &cchValueMax);
if (cchSaveMax > 0)
pszValue[(error == ERROR_SUCCESS) ? (cchSaveMax - 1) : 0] = UNICODE_NULL;
@ -133,19 +138,19 @@ CicRegKey::QuerySz(LPCWSTR pszValueName, LPWSTR pszValue, DWORD cchValueMax)
}
inline LSTATUS
CicRegKey::RecurseDeleteKey(LPCWSTR lpSubKey)
CicRegKey::RecurseDeleteKey(LPCTSTR lpSubKey)
{
CicRegKey regKey;
LSTATUS error = regKey.Open(m_hKey, lpSubKey, KEY_READ | KEY_WRITE);
if (error != ERROR_SUCCESS)
return error;
WCHAR szName[MAX_PATH];
TCHAR szName[MAX_PATH];
DWORD cchName;
do
{
cchName = _countof(szName);
error = ::RegEnumKeyExW(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL);
error = ::RegEnumKeyEx(regKey, 0, szName, &cchName, NULL, NULL, NULL, NULL);
if (error != ERROR_SUCCESS)
break;