mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 05:55:42 +00:00
[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:
parent
a8a4703699
commit
bfa3e554d4
15 changed files with 197 additions and 156 deletions
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
struct WATCHENTRY
|
||||
{
|
||||
HKEY hRootKey;
|
||||
LPCWSTR pszSubKey;
|
||||
LPCTSTR pszSubKey;
|
||||
HKEY hKey;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue