https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bfa3e554d46975a193ff5a3ca22f67bfe15e8d54
commit bfa3e554d46975a193ff5a3ca22f67bfe15e8d54 Author: Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com> AuthorDate: Tue Dec 26 12:07:01 2023 +0900 Commit: GitHub <nore...@github.com> CommitDate: Tue Dec 26 12:07:01 2023 +0900 [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 --- base/applications/ctfmon/CLoaderWnd.cpp | 14 +++---- base/applications/ctfmon/CMakeLists.txt | 2 +- base/applications/ctfmon/CRegWatcher.cpp | 57 +++++++++++++------------- base/applications/ctfmon/CRegWatcher.h | 2 +- base/applications/ctfmon/ctfmon.cpp | 70 +++++++++++++++++++------------- base/applications/ctfmon/precomp.h | 1 + dll/ime/msctfime/msctfime.cpp | 21 +++++----- dll/ime/msctfime/msctfime.h | 1 + dll/win32/msctf/utils.cpp | 38 ++++++++++++----- dll/win32/msutb/CMakeLists.txt | 2 +- sdk/include/reactos/cicero/cicbase.h | 38 ++++++++--------- sdk/include/reactos/cicero/cicevent.h | 10 ++--- sdk/include/reactos/cicero/cicfmap.h | 24 +++++------ sdk/include/reactos/cicero/cicmutex.h | 4 +- sdk/include/reactos/cicero/cicreg.h | 69 ++++++++++++++++--------------- 15 files changed, 197 insertions(+), 156 deletions(-) diff --git a/base/applications/ctfmon/CLoaderWnd.cpp b/base/applications/ctfmon/CLoaderWnd.cpp index 45072bafe1b..b52de13d1b3 100644 --- a/base/applications/ctfmon/CLoaderWnd.cpp +++ b/base/applications/ctfmon/CLoaderWnd.cpp @@ -18,15 +18,15 @@ BOOL CLoaderWnd::Init() return TRUE; // Already registered // Register a window class - WNDCLASSEXW wc; + WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW; wc.hInstance = g_hInst; - wc.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpfnWndProc = WindowProc; - wc.lpszClassName = L"CiCTipBarClass"; - if (!::RegisterClassExW(&wc)) + wc.lpszClassName = TEXT("CiCTipBarClass"); + if (!::RegisterClassEx(&wc)) return FALSE; s_bWndClassRegistered = TRUE; // Remember @@ -35,8 +35,8 @@ BOOL CLoaderWnd::Init() HWND CLoaderWnd::CreateWnd() { - m_hWnd = ::CreateWindowExW(0, L"CiCTipBarClass", NULL, WS_DISABLED, - 0, 0, 0, 0, NULL, NULL, g_hInst, NULL); + m_hWnd = ::CreateWindowEx(0, TEXT("CiCTipBarClass"), NULL, WS_DISABLED, + 0, 0, 0, 0, NULL, NULL, g_hInst, NULL); return m_hWnd; } @@ -93,7 +93,7 @@ CLoaderWnd::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; default: - return DefWindowProcW(hwnd, uMsg, wParam, lParam); + return DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; diff --git a/base/applications/ctfmon/CMakeLists.txt b/base/applications/ctfmon/CMakeLists.txt index 2bc6d6a50f2..8ca1d7b5311 100644 --- a/base/applications/ctfmon/CMakeLists.txt +++ b/base/applications/ctfmon/CMakeLists.txt @@ -6,7 +6,7 @@ list(APPEND SOURCE add_rc_deps(ctfmon.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/ctfmon.ico) add_executable(ctfmon ${SOURCE} ctfmon.rc) -set_module_type(ctfmon win32gui UNICODE) +set_module_type(ctfmon win32gui) add_dependencies(ctfmon msctf msutb) target_link_libraries(ctfmon uuid) add_importlibs(ctfmon msctf msutb advapi32 shell32 user32 msvcrt kernel32) diff --git a/base/applications/ctfmon/CRegWatcher.cpp b/base/applications/ctfmon/CRegWatcher.cpp index d7271820f68..1905956cb91 100644 --- a/base/applications/ctfmon/CRegWatcher.cpp +++ b/base/applications/ctfmon/CRegWatcher.cpp @@ -14,18 +14,18 @@ HANDLE CRegWatcher::s_ahWatchEvents[WATCHENTRY_MAX] = { NULL }; // The registry entries to watch WATCHENTRY CRegWatcher::s_WatchEntries[WATCHENTRY_MAX] = { - { HKEY_CURRENT_USER, L"Keyboard Layout\\Toggle" }, // WI_TOGGLE - { HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\CTF\\TIP" }, // WI_MACHINE_TIF - { HKEY_CURRENT_USER, L"Keyboard Layout\\Preload" }, // WI_PRELOAD - { HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" }, // WI_RUN - { HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\TIP" }, // WI_USER_TIF - { HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Speech" }, // WI_USER_SPEECH - { HKEY_CURRENT_USER, L"Control Panel\\Appearance" }, // WI_APPEARANCE - { HKEY_CURRENT_USER, L"Control Panel\\Colors" }, // WI_COLORS - { HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics" }, // WI_WINDOW_METRICS - { HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Speech" }, // WI_MACHINE_SPEECH - { HKEY_CURRENT_USER, L"Keyboard Layout" }, // WI_KEYBOARD_LAYOUT - { HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\Assemblies" }, // WI_ASSEMBLIES + { HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Toggle") }, // WI_TOGGLE + { HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\CTF\\TIP") }, // WI_MACHINE_TIF + { HKEY_CURRENT_USER, TEXT("Keyboard Layout\\Preload") }, // WI_PRELOAD + { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") }, // WI_RUN + { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\CTF\\TIP") }, // WI_USER_TIF + { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Speech") }, // WI_USER_SPEECH + { HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance") }, // WI_APPEARANCE + { HKEY_CURRENT_USER, TEXT("Control Panel\\Colors") }, // WI_COLORS + { HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop\\WindowMetrics") }, // WI_WINDOW_METRICS + { HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Speech") }, // WI_MACHINE_SPEECH + { HKEY_CURRENT_USER, TEXT("Keyboard Layout") }, // WI_KEYBOARD_LAYOUT + { HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\CTF\\Assemblies") }, // WI_ASSEMBLIES }; // The timer IDs: For delaying ignitions @@ -48,7 +48,7 @@ CRegWatcher::Init() // Create some nameless events and initialize them for (SIZE_T iEvent = 0; iEvent < _countof(s_ahWatchEvents); ++iEvent) { - s_ahWatchEvents[iEvent] = ::CreateEventW(NULL, TRUE, FALSE, NULL); + s_ahWatchEvents[iEvent] = ::CreateEvent(NULL, TRUE, FALSE, NULL); InitEvent(iEvent, FALSE); } @@ -102,11 +102,11 @@ CRegWatcher::InitEvent( // Open or create a registry key to watch registry key LSTATUS error; - error = ::RegOpenKeyExW(entry.hRootKey, entry.pszSubKey, 0, KEY_READ, &entry.hKey); + error = ::RegOpenKeyEx(entry.hRootKey, entry.pszSubKey, 0, KEY_READ, &entry.hKey); if (error != ERROR_SUCCESS) { - error = ::RegCreateKeyExW(entry.hRootKey, entry.pszSubKey, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &entry.hKey, NULL); + error = ::RegCreateKeyEx(entry.hRootKey, entry.pszSubKey, 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &entry.hKey, NULL); if (error != ERROR_SUCCESS) return FALSE; } @@ -128,17 +128,18 @@ CRegWatcher::UpdateSpTip() // Clear "ProfileInitialized" value HKEY hKey; - LSTATUS error = ::RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\CTF\\Sapilayr", - 0, KEY_WRITE, &hKey); + LSTATUS error = ::RegOpenKeyEx(HKEY_CURRENT_USER, + TEXT("SOFTWARE\\Microsoft\\CTF\\Sapilayr"), + 0, KEY_WRITE, &hKey); if (error == ERROR_SUCCESS) { DWORD dwValue = 0, cbValue = sizeof(dwValue); - ::RegSetValueExW(hKey, L"ProfileInitialized", NULL, REG_DWORD, (LPBYTE)&dwValue, cbValue); + ::RegSetValueEx(hKey, TEXT("ProfileInitialized"), NULL, REG_DWORD, (LPBYTE)&dwValue, cbValue); ::RegCloseKey(hKey); } // Get %WINDIR%/IME/sptip.dll!TF_CreateLangProfileUtil function - HINSTANCE hSPTIP = cicLoadSystemLibrary(L"IME\\sptip.dll", TRUE); + HINSTANCE hSPTIP = cicLoadSystemLibrary(TEXT("IME\\sptip.dll"), TRUE); FN_TF_CreateLangProfileUtil fnTF_CreateLangProfileUtil = (FN_TF_CreateLangProfileUtil)::GetProcAddress(hSPTIP, "TF_CreateLangProfileUtil"); if (fnTF_CreateLangProfileUtil) @@ -168,17 +169,17 @@ CRegWatcher::KillInternat() WATCHENTRY& entry = s_WatchEntries[WI_RUN]; // Delete internat.exe from registry "Run" key - LSTATUS error = ::RegOpenKeyExW(entry.hRootKey, entry.pszSubKey, 0, KEY_ALL_ACCESS, &hKey); + LSTATUS error = ::RegOpenKeyEx(entry.hRootKey, entry.pszSubKey, 0, KEY_ALL_ACCESS, &hKey); if (error == ERROR_SUCCESS) { - ::RegDeleteValueW(hKey, L"internat.exe"); + ::RegDeleteValue(hKey, TEXT("internat.exe")); ::RegCloseKey(hKey); } // Kill the "Indicator" window (that internat.exe creates) - HWND hwndInternat = ::FindWindowW(L"Indicator", NULL); + HWND hwndInternat = ::FindWindow(TEXT("Indicator"), NULL); if (hwndInternat) - ::PostMessageW(hwndInternat, WM_CLOSE, 0, 0); + ::PostMessage(hwndInternat, WM_CLOSE, 0, 0); } // Post message 0x8002 to every "SapiTipWorkerClass" window. @@ -188,14 +189,14 @@ CRegWatcher::EnumWndProc( _In_ HWND hWnd, _In_ LPARAM lParam) { - WCHAR ClassName[MAX_PATH]; + TCHAR ClassName[MAX_PATH]; UNREFERENCED_PARAMETER(lParam); - if (::GetClassNameW(hWnd, ClassName, _countof(ClassName)) && - _wcsicmp(ClassName, L"SapiTipWorkerClass") == 0) + if (::GetClassName(hWnd, ClassName, _countof(ClassName)) && + _tcsicmp(ClassName, TEXT("SapiTipWorkerClass")) == 0) { - PostMessageW(hWnd, 0x8002, 0, 0); // FIXME: Magic number + PostMessage(hWnd, 0x8002, 0, 0); // FIXME: Magic number } return TRUE; diff --git a/base/applications/ctfmon/CRegWatcher.h b/base/applications/ctfmon/CRegWatcher.h index 1f75cb7fb4b..a74222cae8a 100644 --- a/base/applications/ctfmon/CRegWatcher.h +++ b/base/applications/ctfmon/CRegWatcher.h @@ -10,7 +10,7 @@ struct WATCHENTRY { HKEY hRootKey; - LPCWSTR pszSubKey; + LPCTSTR pszSubKey; HKEY hKey; }; diff --git a/base/applications/ctfmon/ctfmon.cpp b/base/applications/ctfmon/ctfmon.cpp index 7756ee75097..5ea37a4eb20 100644 --- a/base/applications/ctfmon/ctfmon.cpp +++ b/base/applications/ctfmon/ctfmon.cpp @@ -13,6 +13,9 @@ typedef BOOL (WINAPI *FN_SetProcessShutdownParameters)(DWORD, DWORD); FN_SetProcessShutdownParameters g_fnSetProcessShutdownParameters = NULL; +// kernel32!GetSystemWow64DirectoryA +typedef UINT (WINAPI *FN_GetSystemWow64DirectoryA)(LPSTR, UINT); +FN_GetSystemWow64DirectoryA g_fnGetSystemWow64DirectoryA = NULL; // kernel32!GetSystemWow64DirectoryW typedef UINT (WINAPI *FN_GetSystemWow64DirectoryW)(LPWSTR, UINT); FN_GetSystemWow64DirectoryW g_fnGetSystemWow64DirectoryW = NULL; @@ -30,29 +33,29 @@ CLoaderWnd* g_pLoaderWnd = NULL; // Tipbar loader window static VOID ParseCommandLine( - _In_ LPCWSTR pszCmdLine) + _In_ LPCTSTR pszCmdLine) { g_fNoRunKey = g_fJustRunKey = FALSE; - for (LPCWSTR pch = pszCmdLine; *pch; ++pch) + for (LPCTSTR pch = pszCmdLine; *pch; ++pch) { // Skip space - while (*pch == L' ') + while (*pch == TEXT(' ')) ++pch; - if (*pch == UNICODE_NULL) + if (*pch == TEXT('\0')) return; - if ((*pch == L'-') || (*pch == L'/')) + if ((*pch == TEXT('-')) || (*pch == TEXT('/'))) { ++pch; switch (*pch) { - case L'N': case L'n': // Found "/N" option + case TEXT('N'): case TEXT('n'): // Found "/N" option g_fNoRunKey = TRUE; break; - case L'R': case L'r': // Found "/R" option + case TEXT('R'): case TEXT('r'): // Found "/R" option g_fJustRunKey = TRUE; break; @@ -74,18 +77,18 @@ WriteRegRun(VOID) // Open "Run" key HKEY hKey; - LSTATUS error = ::RegCreateKeyW(HKEY_CURRENT_USER, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", - &hKey); + LSTATUS error = ::RegCreateKey(HKEY_CURRENT_USER, + TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), + &hKey); if (error != ERROR_SUCCESS) return; // Write the module path CicSystemModulePath ModPath; - if (ModPath.Init(L"ctfmon.exe", FALSE)) + if (ModPath.Init(TEXT("ctfmon.exe"), FALSE)) { - DWORD cbData = (ModPath.m_cchPath + 1) * sizeof(WCHAR); - ::RegSetValueExW(hKey, L"ctfmon.exe", 0, REG_SZ, (BYTE*)ModPath.m_szPath, cbData); + DWORD cbData = (ModPath.m_cchPath + 1) * sizeof(TCHAR); + ::RegSetValueEx(hKey, TEXT("ctfmon.exe"), 0, REG_SZ, (BYTE*)ModPath.m_szPath, cbData); } ::RegCloseKey(hKey); @@ -134,7 +137,7 @@ SetGlobalCompartmentDWORD( static BOOL CheckX64System( - _In_ LPWSTR lpCmdLine) + _In_ LPTSTR lpCmdLine) { // Is the system x64? SYSTEM_INFO SystemInfo; @@ -146,23 +149,34 @@ CheckX64System( } // Get GetSystemWow64DirectoryW function - g_hKernel32 = cicGetSystemModuleHandle(L"kernel32.dll", FALSE); + g_hKernel32 = cicGetSystemModuleHandle(TEXT("kernel32.dll"), FALSE); +#ifdef UNICODE g_fnGetSystemWow64DirectoryW = (FN_GetSystemWow64DirectoryW)::GetProcAddress(g_hKernel32, "GetSystemWow64DirectoryW"); if (!g_fnGetSystemWow64DirectoryW) return FALSE; +#else + g_fnGetSystemWow64DirectoryA = + (FN_GetSystemWow64DirectoryA)::GetProcAddress(g_hKernel32, "GetSystemWow64DirectoryA"); + if (!g_fnGetSystemWow64DirectoryA) + return FALSE; +#endif // Build WoW64 ctfmon.exe pathname - WCHAR szPath[MAX_PATH]; + TCHAR szPath[MAX_PATH]; +#ifdef UNICODE UINT cchPath = g_fnGetSystemWow64DirectoryW(szPath, _countof(szPath)); - if (!cchPath && FAILED(StringCchCatW(szPath, _countof(szPath), L"\\ctfmon.exe"))) +#else + UINT cchPath = g_fnGetSystemWow64DirectoryA(szPath, _countof(szPath)); +#endif + if (!cchPath && FAILED(StringCchCat(szPath, _countof(szPath), TEXT("\\ctfmon.exe")))) return FALSE; // Create a WoW64 ctfmon.exe process PROCESS_INFORMATION pi; - STARTUPINFOW si = { sizeof(si) }; + STARTUPINFO si = { sizeof(si) }; si.wShowWindow = SW_SHOWMINNOACTIVE; - if (!::CreateProcessW(szPath, lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) + if (!::CreateProcess(szPath, lpCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) return FALSE; ::CloseHandle(pi.hThread); @@ -173,7 +187,7 @@ CheckX64System( static BOOL InitApp( _In_ HINSTANCE hInstance, - _In_ LPWSTR lpCmdLine) + _In_ LPTSTR lpCmdLine) { g_hInst = hInstance; // Save the instance handle @@ -194,7 +208,7 @@ InitApp( // Call SetProcessShutdownParameters if possible if (g_dwOsInfo & CIC_OSINFO_NT) { - g_hKernel32 = cicGetSystemModuleHandle(L"kernel32.dll", FALSE); + g_hKernel32 = cicGetSystemModuleHandle(TEXT("kernel32.dll"), FALSE); g_fnSetProcessShutdownParameters = (FN_SetProcessShutdownParameters) ::GetProcAddress(g_hKernel32, "SetProcessShutdownParameters"); @@ -257,16 +271,16 @@ DoMainLoop(VOID) if (g_bOnWow64) // Is the current process on WoW64? { // Just a simple message loop - while (::GetMessageW(&msg, NULL, 0, 0)) + while (::GetMessage(&msg, NULL, 0, 0)) { ::TranslateMessage(&msg); - ::DispatchMessageW(&msg); + ::DispatchMessage(&msg); } return (INT)msg.wParam; } // Open the existing event by the name - HANDLE hSwitchEvent = ::OpenEventW(SYNCHRONIZE, FALSE, L"WinSta0_DesktopSwitch"); + HANDLE hSwitchEvent = ::OpenEvent(SYNCHRONIZE, FALSE, TEXT("WinSta0_DesktopSwitch")); // The target events to watch HANDLE ahEvents[WATCHENTRY_MAX + 1]; @@ -285,13 +299,13 @@ DoMainLoop(VOID) if (dwWait == (WAIT_OBJECT_0 + _countof(ahEvents))) // Is input available? { // Do the events - while (::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) + while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) goto Quit; ::TranslateMessage(&msg); - ::DispatchMessageW(&msg); + ::DispatchMessage(&msg); } } else if (dwWait == (WAIT_OBJECT_0 + WI_DESKTOP_SWITCH)) // Desktop switch? @@ -313,10 +327,10 @@ Quit: // The main function for Unicode Win32 EXTERN_C INT WINAPI -wWinMain( +_tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, - LPWSTR lpCmdLine, + LPTSTR lpCmdLine, INT nCmdShow) { UNREFERENCED_PARAMETER(hPrevInst); diff --git a/base/applications/ctfmon/precomp.h b/base/applications/ctfmon/precomp.h index 6e1282e2bfa..b6ca0bdcb4d 100644 --- a/base/applications/ctfmon/precomp.h +++ b/base/applications/ctfmon/precomp.h @@ -12,6 +12,7 @@ #include <shellapi.h> #include <shlwapi.h> #include <stdlib.h> +#include <tchar.h> #include <strsafe.h> #include <msctf.h> #include <ctfutb.h> diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp index 6aa33c76490..376416110a5 100644 --- a/dll/ime/msctfime/msctfime.cpp +++ b/dll/ime/msctfime/msctfime.cpp @@ -56,16 +56,17 @@ BOOL IsMsImeMessage(UINT uMsg) */ BOOL RegisterMSIMEMessage(VOID) { - WM_MSIME_SERVICE = RegisterWindowMessageW(L"MSIMEService"); - WM_MSIME_UIREADY = RegisterWindowMessageW(L"MSIMEUIReady"); - WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageW(L"MSIMEReconvertRequest"); - WM_MSIME_RECONVERT = RegisterWindowMessageW(L"MSIMEReconvert"); - WM_MSIME_DOCUMENTFEED = RegisterWindowMessageW(L"MSIMEDocumentFeed"); - WM_MSIME_QUERYPOSITION = RegisterWindowMessageW(L"MSIMEQueryPosition"); - WM_MSIME_MODEBIAS = RegisterWindowMessageW(L"MSIMEModeBias"); - WM_MSIME_SHOWIMEPAD = RegisterWindowMessageW(L"MSIMEShowImePad"); - WM_MSIME_MOUSE = RegisterWindowMessageW(L"MSIMEMouseOperation"); - WM_MSIME_KEYMAP = RegisterWindowMessageW(L"MSIMEKeyMap"); + // Using ANSI (A) version here can reduce binary size. + WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService"); + WM_MSIME_UIREADY = RegisterWindowMessageA("MSIMEUIReady"); + WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest"); + WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert"); + WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed"); + WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition"); + WM_MSIME_MODEBIAS = RegisterWindowMessageA("MSIMEModeBias"); + WM_MSIME_SHOWIMEPAD = RegisterWindowMessageA("MSIMEShowImePad"); + WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation"); + WM_MSIME_KEYMAP = RegisterWindowMessageA("MSIMEKeyMap"); return (WM_MSIME_SERVICE && WM_MSIME_UIREADY && WM_MSIME_RECONVERTREQUEST && diff --git a/dll/ime/msctfime/msctfime.h b/dll/ime/msctfime/msctfime.h index 5fce8fb5c42..a5273e11d2d 100644 --- a/dll/ime/msctfime/msctfime.h +++ b/dll/ime/msctfime/msctfime.h @@ -17,6 +17,7 @@ #include <imm.h> #include <ddk/immdev.h> #include <cguid.h> +#include <tchar.h> #include <msctf.h> #include <ctffunc.h> #include <shlwapi.h> diff --git a/dll/win32/msctf/utils.cpp b/dll/win32/msctf/utils.cpp index 9d0d455f8ad..944d3d1c063 100644 --- a/dll/win32/msctf/utils.cpp +++ b/dll/win32/msctf/utils.cpp @@ -17,6 +17,7 @@ #include <imm.h> #include <ddk/immdev.h> #include <cguid.h> +#include <tchar.h> #include <msctf.h> #include <ctffunc.h> #include <shlwapi.h> @@ -28,6 +29,23 @@ WINE_DEFAULT_DEBUG_CHANNEL(msctf); +BOOL StringFromGUID2A(REFGUID rguid, LPSTR pszGUID, INT cchGUID) +{ + pszGUID[0] = ANSI_NULL; + + WCHAR szWide[40]; + szWide[0] = UNICODE_NULL; + BOOL ret = StringFromGUID2(rguid, szWide, _countof(szWide)); + ::WideCharToMultiByte(CP_ACP, 0, szWide, -1, pszGUID, cchGUID, NULL, NULL); + return ret; +} + +#ifdef UNICODE + #define StringFromGUID2T StringFromGUID2 +#else + #define StringFromGUID2T StringFromGUID2A +#endif + /*********************************************************************** * TF_RegisterLangBarAddIn (MSCTF.@) * @@ -47,19 +65,19 @@ TF_RegisterLangBarAddIn( return E_INVALIDARG; } - WCHAR szBuff[MAX_PATH], szGUID[40]; - StringCchCopyW(szBuff, _countof(szBuff), L"SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"); - StringFromGUID2(rguid, szGUID, _countof(szGUID)); - StringCchCatW(szBuff, _countof(szBuff), szGUID); + TCHAR szBuff[MAX_PATH], szGUID[40]; + StringCchCopy(szBuff, _countof(szBuff), TEXT("SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\")); + StringFromGUID2T(rguid, szGUID, _countof(szGUID)); + StringCchCat(szBuff, _countof(szBuff), szGUID); CicRegKey regKey; HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); LSTATUS error = regKey.Create(hBaseKey, szBuff); if (error == ERROR_SUCCESS) { - error = regKey.SetSz(L"FilePath", pszFilePath); + error = regKey.SetSzW(L"FilePath", pszFilePath); if (error == ERROR_SUCCESS) - error = regKey.SetDword(L"Enable", !!(dwFlags & 4)); + error = regKey.SetDword(TEXT("Enable"), !!(dwFlags & 4)); } return ((error == ERROR_SUCCESS) ? S_OK : E_FAIL); @@ -83,8 +101,8 @@ TF_UnregisterLangBarAddIn( return E_INVALIDARG; } - WCHAR szSubKey[MAX_PATH]; - StringCchCopyW(szSubKey, _countof(szSubKey), L"SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\"); + TCHAR szSubKey[MAX_PATH]; + StringCchCopy(szSubKey, _countof(szSubKey), TEXT("SOFTWARE\\Microsoft\\CTF\\LangBarAddIn\\")); CicRegKey regKey; HKEY hBaseKey = ((dwFlags & 1) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER); @@ -92,8 +110,8 @@ TF_UnregisterLangBarAddIn( HRESULT hr = E_FAIL; if (error == ERROR_SUCCESS) { - WCHAR szGUID[40]; - StringFromGUID2(rguid, szGUID, _countof(szGUID)); + TCHAR szGUID[40]; + StringFromGUID2T(rguid, szGUID, _countof(szGUID)); regKey.RecurseDeleteKey(szGUID); hr = S_OK; } diff --git a/dll/win32/msutb/CMakeLists.txt b/dll/win32/msutb/CMakeLists.txt index 84760f101e8..3e48eb33311 100644 --- a/dll/win32/msutb/CMakeLists.txt +++ b/dll/win32/msutb/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(msutb MODULE ${SOURCE} msutb.rc ${CMAKE_CURRENT_BINARY_DIR}/msutb.def) -set_module_type(msutb win32dll UNICODE) +set_module_type(msutb win32dll) add_dependencies(msutb msctf psdk) target_link_libraries(msutb wine uuid atl_classes) add_importlibs(msutb user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll) diff --git a/sdk/include/reactos/cicero/cicbase.h b/sdk/include/reactos/cicero/cicbase.h index 28f5f96543f..14958780ba3 100644 --- a/sdk/include/reactos/cicero/cicbase.h +++ b/sdk/include/reactos/cicero/cicbase.h @@ -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; diff --git a/sdk/include/reactos/cicero/cicevent.h b/sdk/include/reactos/cicero/cicevent.h index a783872b2c2..0e679e2238e 100644 --- a/sdk/include/reactos/cicero/cicevent.h +++ b/sdk/include/reactos/cicero/cicevent.h @@ -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() diff --git a/sdk/include/reactos/cicero/cicfmap.h b/sdk/include/reactos/cicero/cicfmap.h index 201f3227db8..8e06fc77017 100644 --- a/sdk/include/reactos/cicero/cicfmap.h +++ b/sdk/include/reactos/cicero/cicfmap.h @@ -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; diff --git a/sdk/include/reactos/cicero/cicmutex.h b/sdk/include/reactos/cicero/cicmutex.h index 9c98146e8c0..73527edd092 100644 --- a/sdk/include/reactos/cicero/cicmutex.h +++ b/sdk/include/reactos/cicero/cicmutex.h @@ -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() diff --git a/sdk/include/reactos/cicero/cicreg.h b/sdk/include/reactos/cicero/cicreg.h index da18e0bd49e..f6c090bef4e 100644 --- a/sdk/include/reactos/cicero/cicreg.h +++ b/sdk/include/reactos/cicero/cicreg.h @@ -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;