https://git.reactos.org/?p=reactos.git;a=commitdiff;h=372a445ad6de905ee5699…
commit 372a445ad6de905ee56992b7b5dedb804c2776b1
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Aug 23 21:57:45 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Aug 23 21:57:45 2022 +0900
[IMM32] Add CtfImmIsGuidMapEnable and CtfImmGetGuidAtom (#4621)
- Add CtfImmIsGuidMapEnable and CtfImmGetGuidAtom functions.
- Modify imetable.h and imm32.spec.
CORE-11700
---
dll/win32/imm32/ctf.c | 75 +++++++++++++++++++++++++++++++++++++++++++++-
dll/win32/imm32/imm32.spec | 2 ++
win32ss/include/imetable.h | 4 +--
3 files changed, 78 insertions(+), 3 deletions(-)
diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c
index 153d4c5e5fa..7c4c9dae4ac 100644
--- a/dll/win32/imm32/ctf.c
+++ b/dll/win32/imm32/ctf.c
@@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS IMM32
* LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later)
- * PURPOSE: Implementing IMM32 Cicero (modern input method)
+ * PURPOSE: Implementing the IMM32 Cicero-aware Text Framework (CTF)
* COPYRIGHT: Copyright 2022 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
*/
@@ -9,6 +9,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(imm);
+/*
+ * NOTE: Microsoft CTF protocol has vulnerability.
+ * If insecure, we don't follow the dangerous design.
+ *
+ *
https://www.zdnet.com/article/vulnerability-in-microsoft-ctf-protocol-goes-…
+ *
https://googleprojectzero.blogspot.com/2019/08/down-rabbit-hole.html
+ */
+
// Win: LoadCtfIme
HMODULE APIENTRY Imm32LoadCtfIme(VOID)
{
@@ -95,3 +103,68 @@ LRESULT WINAPI CtfImmDispatchDefImeMessage(HWND hWnd, UINT uMsg,
WPARAM wParam,
FIXME("(%p, %u, %p, %p)\n", hWnd, uMsg, wParam, lParam);
return 0;
}
+
+/***********************************************************************
+ * CtfImmIsGuidMapEnable(IMM32.@)
+ */
+BOOL WINAPI CtfImmIsGuidMapEnable(HIMC hIMC)
+{
+ DWORD dwThreadId;
+ HKL hKL;
+ PIMEDPI pImeDpi;
+ BOOL ret = FALSE;
+
+ TRACE("(%p)\n", hIMC);
+
+ if (!Imm32IsCiceroMode() || Imm32Is16BitMode())
+ return ret;
+
+ dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
+ hKL = GetKeyboardLayout(dwThreadId);
+
+ if (IS_IME_HKL(hKL))
+ return ret;
+
+ pImeDpi = Imm32FindOrLoadImeDpi(hKL);
+ if (!pImeDpi)
+ return ret;
+
+ if (pImeDpi->CtfImeIsGuidMapEnable)
+ ret = pImeDpi->CtfImeIsGuidMapEnable(hIMC);
+
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
+}
+
+/***********************************************************************
+ * CtfImmGetGuidAtom(IMM32.@)
+ */
+HRESULT WINAPI CtfImmGetGuidAtom(HIMC hIMC, DWORD dwUnknown, LPDWORD pdwGuidAtom)
+{
+ HRESULT hr = E_FAIL;
+ PIMEDPI pImeDpi;
+ DWORD dwThreadId;
+ HKL hKL;
+
+ TRACE("(%p, 0xlX, %p)\n", hIMC, dwUnknown, pdwGuidAtom);
+
+ *pdwGuidAtom = 0;
+
+ if (!Imm32IsCiceroMode() || Imm32Is16BitMode())
+ return hr;
+
+ dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
+ hKL = GetKeyboardLayout(dwThreadId);
+ if (IS_IME_HKL(hKL))
+ return S_OK;
+
+ pImeDpi = Imm32FindOrLoadImeDpi(hKL);
+ if (!pImeDpi)
+ return hr;
+
+ if (pImeDpi->CtfImeGetGuidAtom)
+ hr = pImeDpi->CtfImeGetGuidAtom(hIMC, dwUnknown, pdwGuidAtom);
+
+ ImmUnlockImeDpi(pImeDpi);
+ return hr;
+}
diff --git a/dll/win32/imm32/imm32.spec b/dll/win32/imm32/imm32.spec
index 78316f2a447..77442f45829 100644
--- a/dll/win32/imm32/imm32.spec
+++ b/dll/win32/imm32/imm32.spec
@@ -4,6 +4,8 @@
@ stdcall CtfImmRestoreToolbarWnd(long)
@ stdcall CtfImmHideToolbarWnd()
@ stdcall CtfImmDispatchDefImeMessage(ptr long ptr ptr)
+@ stdcall CtfImmIsGuidMapEnable(ptr)
+@ stdcall CtfImmGetGuidAtom(ptr long ptr)
@ stdcall ImmActivateLayout(ptr)
@ stdcall ImmAssociateContext(ptr ptr)
@ stdcall ImmAssociateContextEx(ptr ptr long)
diff --git a/win32ss/include/imetable.h b/win32ss/include/imetable.h
index 70bc982a6dc..d41c5af653d 100644
--- a/win32ss/include/imetable.h
+++ b/win32ss/include/imetable.h
@@ -18,5 +18,5 @@ DEFINE_IME_ENTRY(DWORD, ImeGetImeMenuItems, (HIMC hIMC, DWORD dwFlags,
DWORD dwT
DEFINE_IME_ENTRY(BOOL, CtfImeInquireExW, (LPIMEINFO lpIMEInfo, LPVOID lpszWndClass, DWORD
dwSystemInfoFlags, HKL hKL), TRUE)
DEFINE_IME_ENTRY(BOOL, CtfImeSelectEx, (HIMC hIMC, BOOL fSelect, HKL hKL), TRUE)
DEFINE_IME_ENTRY(LRESULT, CtfImeEscapeEx, (HIMC hIMC, UINT uSubFunc, LPVOID lpData, HKL
hKL), TRUE)
-DEFINE_IME_ENTRY(DWORD, CtfImeGetGuidAtom, (VOID /* FIXME: unknown */), TRUE)
-DEFINE_IME_ENTRY(DWORD, CtfImeIsGuidMapEnable, (VOID /* FIXME: unknown */), TRUE)
+DEFINE_IME_ENTRY(HRESULT, CtfImeGetGuidAtom, (HIMC hIMC, DWORD dwUnknown, LPDWORD
pdwGuidAtom), TRUE)
+DEFINE_IME_ENTRY(BOOL, CtfImeIsGuidMapEnable, (HIMC hIMC), TRUE)