https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dcf0788f595ba4eb73fa3…
commit dcf0788f595ba4eb73fa368a7be91999588d58b4
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Jul 30 11:45:23 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Jul 30 11:45:23 2024 +0900
[IMM32][SDK][USER32] Fix ImmFreeLayout parameter (#7195)
JIRA issue: CORE-19268
- Define ImmFreeLayout parameter special
values (HKL_SWITCH_TO_NON_IME and
HKL_RELEASE_IME) at <imm32_undoc.h>.
- Make ImmFreeLayout parameter an HKL.
---
dll/win32/imm32/imm.c | 17 +++++++++--------
dll/win32/imm32/imm32.spec | 2 +-
sdk/include/reactos/imm32_undoc.h | 4 ++++
win32ss/user/user32/include/immtable.h | 2 +-
win32ss/user/user32/misc/imm.c | 2 +-
5 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index edbc4bcdb4e..117cb52eaa9 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -111,20 +111,22 @@ BOOL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
/***********************************************************************
* ImmFreeLayout (IMM32.@)
+ *
+ * NOTE: HKL_SWITCH_TO_NON_IME and HKL_RELEASE_IME are special values for hKL.
*/
-BOOL WINAPI ImmFreeLayout(DWORD dwUnknown)
+BOOL WINAPI ImmFreeLayout(HKL hKL)
{
WCHAR szKBD[KL_NAMELENGTH];
UINT iKL, cKLs;
- HKL hOldKL, hNewKL, *pList;
+ HKL hOldKL, *pList;
PIMEDPI pImeDpi;
LANGID LangID;
- TRACE("(0x%lX)\n", dwUnknown);
+ TRACE("(%p)\n", hKL);
hOldKL = GetKeyboardLayout(0);
- if (dwUnknown == 1)
+ if (hKL == HKL_SWITCH_TO_NON_IME)
{
if (!IS_IME_HKL(hOldKL))
return TRUE;
@@ -158,7 +160,7 @@ BOOL WINAPI ImmFreeLayout(DWORD dwUnknown)
LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200);
}
}
- else if (dwUnknown == 2)
+ else if (hKL == HKL_RELEASE_IME)
{
RtlEnterCriticalSection(&gcsImeDpi);
Retry:
@@ -171,9 +173,8 @@ Retry:
}
else
{
- hNewKL = UlongToHandle(dwUnknown);
- if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL)
- Imm32ReleaseIME(hNewKL);
+ if (IS_IME_HKL(hKL) && hKL != hOldKL)
+ Imm32ReleaseIME(hKL);
}
return TRUE;
diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec
index 03ba666c074..83c435a7a5e 100644
--- a/dll/win32/imm32/imm32.spec
+++ b/dll/win32/imm32/imm32.spec
@@ -38,7 +38,7 @@
@ stdcall ImmEnumRegisterWordW(long ptr wstr long wstr ptr)
@ stdcall ImmEscapeA(long ptr long ptr)
@ stdcall ImmEscapeW(long ptr long ptr)
-@ stdcall ImmFreeLayout(long)
+@ stdcall ImmFreeLayout(ptr)
@ stdcall ImmGenerateMessage(ptr)
@ stdcall ImmGetAppCompatFlags(ptr)
@ stdcall ImmGetCandidateListA(long long ptr long)
diff --git a/sdk/include/reactos/imm32_undoc.h b/sdk/include/reactos/imm32_undoc.h
index 184f6e13eac..eea17b6841c 100644
--- a/sdk/include/reactos/imm32_undoc.h
+++ b/sdk/include/reactos/imm32_undoc.h
@@ -24,6 +24,10 @@ extern "C" {
#define IS_IME_KLID(dwKLID) ((((ULONG)(dwKLID)) & 0xF0000000) == IME_MASK)
#define IS_SUBST_KLID(dwKLID) ((((ULONG)(dwKLID)) & 0xF0000000) == SUBST_MASK)
+/* The special values for ImmFreeLayout hKL */
+#define HKL_SWITCH_TO_NON_IME ((HKL)UlongToHandle(1))
+#define HKL_RELEASE_IME ((HKL)UlongToHandle(2))
+
typedef struct tagIMEINFOEX
{
HKL hkl;
diff --git a/win32ss/user/user32/include/immtable.h
b/win32ss/user/user32/include/immtable.h
index ad178c8282d..8657d6c4706 100644
--- a/win32ss/user/user32/include/immtable.h
+++ b/win32ss/user/user32/include/immtable.h
@@ -30,7 +30,7 @@ DEFINE_IMM_ENTRY(/*PINPUTCONTEXT*/ LPVOID, ImmLockIMC, (HIMC hIMC), 0,
NONVOID)
DEFINE_IMM_ENTRY(BOOL, ImmUnlockIMC, (HIMC hIMC), 0, NONVOID)
DEFINE_IMM_ENTRY(BOOL, ImmLoadIME, (HKL hKL), 0, NONVOID)
DEFINE_IMM_ENTRY(BOOL, ImmSetOpenStatus, (HIMC hIMC, BOOL bOpen), 0, NONVOID)
-DEFINE_IMM_ENTRY(BOOL, ImmFreeLayout, (DWORD dwFlags), 0, NONVOID)
+DEFINE_IMM_ENTRY(BOOL, ImmFreeLayout, (HKL hKL), 0, NONVOID)
DEFINE_IMM_ENTRY(BOOL, ImmActivateLayout, (HKL hKL), 0, NONVOID)
DEFINE_IMM_ENTRY(BOOL, ImmGetCandidateWindow, (HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM
lpCandForm), 0, NONVOID)
DEFINE_IMM_ENTRY(BOOL, ImmSetCandidateWindow, (HIMC hIMC, LPCANDIDATEFORM lpCandForm), 0,
NONVOID)
diff --git a/win32ss/user/user32/misc/imm.c b/win32ss/user/user32/misc/imm.c
index 640902bbabf..89d473632ec 100644
--- a/win32ss/user/user32/misc/imm.c
+++ b/win32ss/user/user32/misc/imm.c
@@ -717,7 +717,7 @@ static LRESULT ImeWnd_OnImeSystem(PIMEUI pimeui, WPARAM wParam, LPARAM
lParam)
break;
case IMS_FREELAYOUT:
- ret = IMM_FN(ImmFreeLayout)((DWORD)lParam);
+ ret = IMM_FN(ImmFreeLayout)((HKL)lParam);
break;
case 0x13: