https://git.reactos.org/?p=reactos.git;a=commitdiff;h=36740ca98142cd96a7c3f…
commit 36740ca98142cd96a7c3facc3a901dc81f486ef9
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Jan 12 12:06:24 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jan 12 12:06:24 2022 +0900
[NTUSER][IMM32] Implement NtUserGetImeInfoEx (#4271)
- Add UserGetImeInfoEx helper function.
- Implement NtUserGetImeInfoEx function by using UserGetImeInfoEx.
- Fix imm32.ImmGetImeInfoEx.
- Modify enum IMEINFOEXCLASS.
CORE-11700
---
dll/win32/imm32/ime.c | 57 +++++++++++++++---------------
win32ss/include/ntuser.h | 5 ++-
win32ss/user/ntuser/ime.c | 88 +++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 116 insertions(+), 34 deletions(-)
diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c
index 7da1ea09fec..4866bd00f5f 100644
--- a/dll/win32/imm32/ime.c
+++ b/dll/win32/imm32/ime.c
@@ -574,8 +574,7 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
}
/* If the IME for the specified filename is valid, then unload it now */
- /* FIXME: ImmGetImeInfoEx is broken */
- if (ImmGetImeInfoEx(&InfoEx, 3, pchFilePart) &&
+ if (ImmGetImeInfoEx(&InfoEx, ImeInfoExImeFileName, pchFilePart) &&
!UnloadKeyboardLayout(InfoEx.hkl))
{
hNewKL = NULL;
@@ -623,8 +622,7 @@ BOOL WINAPI ImmIsIME(HKL hKL)
{
IMEINFOEX info;
TRACE("(%p)\n", hKL);
- /* FIXME: ImmGetImeInfoEx is broken */
- return !!ImmGetImeInfoEx(&info, 1, &hKL);
+ return !!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayoutTFS, &hKL);
}
/***********************************************************************
@@ -681,42 +679,41 @@ BOOL WINAPI ImmDisableLegacyIME(void)
BOOL WINAPI
ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType, PVOID pvSearchKey)
{
- BOOL bDisabled = FALSE;
HKL hKL;
-
- /* FIXME: broken */
- switch (SearchType)
+ if (SearchType == ImeInfoExKeyboardLayout || SearchType ==
ImeInfoExKeyboardLayoutTFS)
{
- case ImeInfoExKeyboardLayout:
- break;
-
- case ImeInfoExImeWindow:
- bDisabled = CtfImmIsTextFrameServiceDisabled();
- SearchType = ImeInfoExKeyboardLayout;
- break;
-
- case ImeInfoExImeFileName:
- StringCchCopyW(pImeInfoEx->wszImeFile,
_countof(pImeInfoEx->wszImeFile),
- pvSearchKey);
- goto Quit;
- }
+ hKL = *(HKL*)pvSearchKey;
+ pImeInfoEx->hkl = hKL;
- hKL = *(HKL*)pvSearchKey;
- pImeInfoEx->hkl = hKL;
+ if (SearchType == ImeInfoExKeyboardLayoutTFS)
+ {
+ if (!IS_IME_HKL(hKL))
+ {
+ if (!CtfImmIsTextFrameServiceDisabled() ||
+ !Imm32IsCiceroMode() || Imm32Is16BitMode())
+ {
+ return FALSE;
+ }
+ }
- if (!IS_IME_HKL(hKL))
- {
- if (Imm32IsCiceroMode())
+ SearchType = ImeInfoExKeyboardLayout;
+ }
+ else
{
- if (Imm32Is16BitMode())
+ if (!IS_IME_HKL(hKL))
return FALSE;
- if (!bDisabled)
- goto Quit;
}
+ }
+ else if (SearchType == ImeInfoExImeFileName)
+ {
+ StringCchCopyW(pImeInfoEx->wszImeFile, _countof(pImeInfoEx->wszImeFile),
+ pvSearchKey);
+ }
+ else
+ {
return FALSE;
}
-Quit:
return NtUserGetImeInfoEx(pImeInfoEx, SearchType);
}
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h
index 4618c99af76..4519b3a35aa 100644
--- a/win32ss/include/ntuser.h
+++ b/win32ss/include/ntuser.h
@@ -1183,9 +1183,12 @@ typedef struct tagIMEINFOEX
};
} IMEINFOEX, *PIMEINFOEX;
-typedef enum IMEINFOEXCLASS /* unconfirmed: buggy */
+typedef enum IMEINFOEXCLASS
{
ImeInfoExKeyboardLayout,
+#if 1
+ ImeInfoExKeyboardLayoutTFS,
+#endif
ImeInfoExImeWindow,
ImeInfoExImeFileName
} IMEINFOEXCLASS;
diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c
index 81c4e330243..ee79b14d60f 100644
--- a/win32ss/user/ntuser/ime.c
+++ b/win32ss/user/ntuser/ime.c
@@ -157,16 +157,98 @@ NtUserGetAppImeLevel(HWND hWnd)
return 0;
}
+BOOL FASTCALL UserGetImeInfoEx(LPVOID pUnknown, PIMEINFOEX pInfoEx, IMEINFOEXCLASS
SearchType)
+{
+ PKL pkl, pklHead;
+
+ if (!gspklBaseLayout)
+ return FALSE;
+
+ pkl = pklHead = gspklBaseLayout;
+
+ /* Find the matching entry from the list and get info */
+ if (SearchType == ImeInfoExKeyboardLayout)
+ {
+ do
+ {
+ if (pInfoEx->hkl == pkl->hkl) /* Matched */
+ {
+ if (!pkl->piiex)
+ break;
+
+ *pInfoEx = *pkl->piiex; /* Get */
+ return TRUE; /* Found */
+ }
+
+ pkl = pkl->pklNext;
+ } while (pkl != pklHead);
+ }
+ else if (SearchType == ImeInfoExImeFileName)
+ {
+ do
+ {
+ if (pkl->piiex &&
+ _wcsnicmp(pkl->piiex->wszImeFile, pInfoEx->wszImeFile,
+ RTL_NUMBER_OF(pkl->piiex->wszImeFile)) == 0) /* Matched
*/
+ {
+ *pInfoEx = *pkl->piiex; /* Get */
+ return TRUE; /* Found */
+ }
+
+ pkl = pkl->pklNext;
+ } while (pkl != pklHead);
+ }
+ else
+ {
+ /* Do nothing */
+ }
+
+ return FALSE; /* Not found */
+}
+
BOOL
APIENTRY
NtUserGetImeInfoEx(
PIMEINFOEX pImeInfoEx,
IMEINFOEXCLASS SearchType)
{
- STUB;
- return FALSE;
-}
+ IMEINFOEX ImeInfoEx;
+ BOOL ret = FALSE;
+
+ UserEnterShared();
+
+ if (!IS_IMM_MODE())
+ goto Quit;
+
+ _SEH2_TRY
+ {
+ ProbeForWrite(pImeInfoEx, sizeof(*pImeInfoEx), 1);
+ ImeInfoEx = *pImeInfoEx;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ goto Quit;
+ }
+ _SEH2_END;
+
+ ret = UserGetImeInfoEx(NULL, &ImeInfoEx, SearchType);
+ if (ret)
+ {
+ _SEH2_TRY
+ {
+ *pImeInfoEx = ImeInfoEx;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ ret = FALSE;
+ }
+ _SEH2_END;
+ }
+Quit:
+ UserLeave();
+ return ret;
+}
DWORD
APIENTRY