https://git.reactos.org/?p=reactos.git;a=commitdiff;h=77911014f3d55114d9a5c…
commit 77911014f3d55114d9a5c74893ded0b02154ac1a
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Aug 16 15:33:51 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Aug 16 15:33:51 2021 +0900
[IMM32] Rewrite ImmIsUIMessageA/W (#3907)
- Rewrite ImmIsUIMessageA and ImmIsUIMessageW functions.
- Modify HIMC and HIMCC handle types for strictness. Add typecasts.
- Add WM_IME_SYSTEM macro.
- Modify imm32.spec.
CORE-11700
---
dll/win32/imm32/imm.c | 73 +++++++++++++++--------------
dll/win32/imm32/imm32.spec | 4 +-
modules/rostests/apitests/imm32/clientimc.c | 6 +--
modules/rostests/winetests/imm32/imm32.c | 8 ++++
sdk/include/psdk/imm.h | 7 ++-
win32ss/include/ntuser.h | 5 +-
6 files changed, 57 insertions(+), 46 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index d1fa849150e..7b0b415f74f 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -784,7 +784,7 @@ static void ImmInternalSendIMEMessage(InputContextData *data, UINT
msg, WPARAM w
static InputContextData* get_imc_data(HIMC hIMC)
{
- InputContextData *data = hIMC;
+ InputContextData *data = (InputContextData *)hIMC;
if (hIMC == NULL)
return NULL;
@@ -861,7 +861,7 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
if (old)
{
- InputContextData *old_data = old;
+ InputContextData *old_data = (InputContextData *)old;
if (old_data->IMC.hWnd == hWnd)
old_data->IMC.hWnd = NULL;
}
@@ -2546,7 +2546,7 @@ HIMC WINAPI ImmGetContext(HWND hWnd)
if (rc)
{
- InputContextData *data = rc;
+ InputContextData *data = (InputContextData *)rc;
data->IMC.hWnd = hWnd;
}
@@ -3340,26 +3340,38 @@ BOOL WINAPI ImmIsIME(HKL hKL)
return !!ImmGetImeInfoEx(&info, ImeInfoExImeWindow, &hKL);
}
+static BOOL APIENTRY
+ImmIsUIMessageAW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAnsi)
+{
+ switch (msg)
+ {
+ case WM_IME_STARTCOMPOSITION: case WM_IME_ENDCOMPOSITION:
+ case WM_IME_COMPOSITION: case WM_IME_SETCONTEXT: case WM_IME_NOTIFY:
+ case WM_IME_COMPOSITIONFULL: case WM_IME_SELECT: case WM_IME_SYSTEM:
+ break;
+ default:
+ return FALSE;
+ }
+
+ if (!hWndIME)
+ return TRUE;
+
+ if (bAnsi)
+ SendMessageA(hWndIME, msg, wParam, lParam);
+ else
+ SendMessageW(hWndIME, msg, wParam, lParam);
+
+ return TRUE;
+}
+
/***********************************************************************
* ImmIsUIMessageA (IMM32.@)
*/
BOOL WINAPI ImmIsUIMessageA(
HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
{
- TRACE("(%p, %x, %ld, %ld)\n", hWndIME, msg, wParam, lParam);
- if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
- (msg == WM_IME_SETCONTEXT) ||
- (msg == WM_IME_NOTIFY) ||
- (msg == WM_IME_COMPOSITIONFULL) ||
- (msg == WM_IME_SELECT) ||
- (msg == 0x287 /* FIXME: WM_IME_SYSTEM */))
- {
- if (hWndIME)
- SendMessageA(hWndIME, msg, wParam, lParam);
-
- return TRUE;
- }
- return FALSE;
+ TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
+ return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, TRUE);
}
/***********************************************************************
@@ -3368,20 +3380,8 @@ BOOL WINAPI ImmIsUIMessageA(
BOOL WINAPI ImmIsUIMessageW(
HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
{
- TRACE("(%p, %x, %ld, %ld)\n", hWndIME, msg, wParam, lParam);
- if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
- (msg == WM_IME_SETCONTEXT) ||
- (msg == WM_IME_NOTIFY) ||
- (msg == WM_IME_COMPOSITIONFULL) ||
- (msg == WM_IME_SELECT) ||
- (msg == 0x287 /* FIXME: WM_IME_SYSTEM */))
- {
- if (hWndIME)
- SendMessageW(hWndIME, msg, wParam, lParam);
-
- return TRUE;
- }
- return FALSE;
+ TRACE("(%p, 0x%X, %p, %p)\n", hWndIME, msg, wParam, lParam);
+ return ImmIsUIMessageAW(hWndIME, msg, wParam, lParam, FALSE);
}
/***********************************************************************
@@ -4543,7 +4543,7 @@ BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lKeyD
TRACE("%p %x %x %x\n",hwnd, msg, (UINT)wParam, (UINT)lKeyData);
if (imc)
- data = imc;
+ data = (InputContextData *)imc;
else
return FALSE;
@@ -4602,7 +4602,7 @@ BOOL WINAPI ImmProcessKey(HWND hwnd, HKL hKL, UINT vKey, LPARAM
lKeyData, DWORD
TRACE("%p %p %x %x %x\n",hwnd, hKL, vKey, (UINT)lKeyData, unknown);
if (imc)
- data = imc;
+ data = (InputContextData *)imc;
else
return FALSE;
@@ -4800,7 +4800,7 @@ BOOL WINAPI User32InitializeImmEntryTable(DWORD);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
HKL hKL;
- HWND hWnd;
+ HIMC hIMC;
PTEB pTeb;
TRACE("(%p, 0x%X, %p)\n", hinstDLL, fdwReason, lpReserved);
@@ -4833,8 +4833,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID
lpReserved)
return TRUE;
hKL = GetKeyboardLayout(0);
- hWnd = (HWND)Imm32GetThreadState(THREADSTATE_CAPTUREWINDOW);
- Imm32CleanupContext(hWnd, hKL, TRUE);
+ // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
+ hIMC = (HIMC)Imm32GetThreadState(4);
+ Imm32CleanupContext(hIMC, hKL, TRUE);
break;
case DLL_PROCESS_DETACH:
diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec
index e196f08627a..bca6da02f8a 100644
--- a/dll/win32/imm32/imm32.spec
+++ b/dll/win32/imm32/imm32.spec
@@ -66,8 +66,8 @@
@ stdcall ImmInstallIMEA(str str)
@ stdcall ImmInstallIMEW(wstr wstr)
@ stdcall ImmIsIME(long)
-@ stdcall ImmIsUIMessageA(long long long long)
-@ stdcall ImmIsUIMessageW(long long long long)
+@ stdcall ImmIsUIMessageA(ptr long ptr ptr)
+@ stdcall ImmIsUIMessageW(ptr long ptr ptr)
@ stdcall ImmLoadIME(ptr)
@ stdcall ImmLoadLayout(ptr ptr)
@ stdcall ImmLockClientImc(ptr)
diff --git a/modules/rostests/apitests/imm32/clientimc.c
b/modules/rostests/apitests/imm32/clientimc.c
index 99ed8423537..0f43024efd0 100644
--- a/modules/rostests/apitests/imm32/clientimc.c
+++ b/modules/rostests/apitests/imm32/clientimc.c
@@ -28,11 +28,11 @@ START_TEST(clientimc)
pClientImc->cLockObj = 2;
pClientImc->dwFlags = 0x40;
RtlInitializeCriticalSection(&pClientImc->cs);
- ok_long(ImmGetIMCCSize(pClientImc->hImc), 4);
+ ok_long(ImmGetIMCCSize((HIMCC)pClientImc->hImc), 4);
ImmUnlockClientImc(pClientImc);
ok_long(pClientImc->cLockObj, 1);
- ok_long(ImmGetIMCCSize(pClientImc->hImc), 4);
+ ok_long(ImmGetIMCCSize((HIMCC)pClientImc->hImc), 4);
dwCode = 0;
_SEH2_TRY
@@ -47,7 +47,7 @@ START_TEST(clientimc)
ok_long(dwCode, STATUS_ACCESS_VIOLATION);
ok_long(pClientImc->cLockObj, 0);
- ok_long(ImmGetIMCCSize(pClientImc->hImc), 0);
+ ok_long(ImmGetIMCCSize((HIMCC)pClientImc->hImc), 0);
HeapFree(GetProcessHeap(), 0, pClientImc);
}
diff --git a/modules/rostests/winetests/imm32/imm32.c
b/modules/rostests/winetests/imm32/imm32.c
index 040a43fc058..fef5b0dbb0d 100644
--- a/modules/rostests/winetests/imm32/imm32.c
+++ b/modules/rostests/winetests/imm32/imm32.c
@@ -606,9 +606,17 @@ static void test_ImmIME(void)
if (imc)
{
BOOL rc;
+#ifdef __REACTOS__
+ rc = ImmConfigureIMEA((HKL)imc, NULL, IME_CONFIG_REGISTERWORD, NULL);
+#else
rc = ImmConfigureIMEA(imc, NULL, IME_CONFIG_REGISTERWORD, NULL);
+#endif
ok (rc == 0, "ImmConfigureIMEA did not fail\n");
+#ifdef __REACTOS__
+ rc = ImmConfigureIMEW((HKL)imc, NULL, IME_CONFIG_REGISTERWORD, NULL);
+#else
rc = ImmConfigureIMEW(imc, NULL, IME_CONFIG_REGISTERWORD, NULL);
+#endif
ok (rc == 0, "ImmConfigureIMEW did not fail\n");
}
ImmReleaseContext(hwnd,imc);
diff --git a/sdk/include/psdk/imm.h b/sdk/include/psdk/imm.h
index 7b0888b033e..7fc769ee1eb 100644
--- a/sdk/include/psdk/imm.h
+++ b/sdk/include/psdk/imm.h
@@ -25,10 +25,13 @@
extern "C" {
#endif
-typedef HANDLE HIMC;
-typedef HANDLE HIMCC;
#ifdef __REACTOS__
+DECLARE_HANDLE(HIMC);
+DECLARE_HANDLE(HIMCC);
typedef HKL *LPHKL;
+#else
+typedef HANDLE HIMC;
+typedef HANDLE HIMCC;
#endif
typedef struct tagREGISTERWORDA {
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h
index 26e89fb396a..3147acfac6f 100644
--- a/win32ss/include/ntuser.h
+++ b/win32ss/include/ntuser.h
@@ -6,9 +6,8 @@ struct _THREADINFO;
struct _DESKTOP;
struct _WND;
struct tagPOPUPMENU;
-#ifndef HIMC
-typedef HANDLE HIMC;
-#endif
+
+#define WM_IME_SYSTEM 0x287
#define FIRST_USER_HANDLE 0x0020 /* first possible value for low word of user handle */
#define LAST_USER_HANDLE 0xffef /* last possible value for low word of user handle */