ReactOS  0.4.15-dev-5112-g22d8c0f
ctf.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS IMM32
3  * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE: Implementing the IMM32 Cicero-aware Text Framework (CTF)
5  * COPYRIGHT: Copyright 2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  */
7 
8 #include "precomp.h"
9 
11 
12 /*
13  * NOTE: Microsoft CTF protocol has vulnerability.
14  * If insecure, we don't follow the dangerous design.
15  *
16  * https://www.zdnet.com/article/vulnerability-in-microsoft-ctf-protocol-goes-back-to-windows-xp/
17  * https://googleprojectzero.blogspot.com/2019/08/down-rabbit-hole.html
18  */
19 
20 // Win: LoadCtfIme
22 {
23  FIXME("()\n");
24  return NULL;
25 }
26 
27 // Win: Internal_CtfImeDestroyInputContext
29 {
30  if (!Imm32LoadCtfIme())
31  return E_FAIL;
32 #if 1
33  FIXME("(%p)\n", hIMC);
34  return E_NOTIMPL;
35 #else
36  return g_pfnCtfImeDestroyInputContext(hIMC);
37 #endif
38 }
39 
40 // Win: CtfImmTIMDestroyInputContext
42 {
43  if (!IS_CICERO_MODE() || (GetWin32ClientInfo()->dwCompatFlags2 & 2))
44  return E_NOINTERFACE;
45 
46  return Imm32CtfImeDestroyInputContext(hIMC);
47 }
48 
49 // Win: CtfImmTIMCreateInputContext
51 {
52  TRACE("(%p)\n", hIMC);
53  return E_NOTIMPL;
54 }
55 
56 /***********************************************************************
57  * CtfImmIsCiceroEnabled (IMM32.@)
58  */
60 {
61  return IS_CICERO_MODE();
62 }
63 
64 /***********************************************************************
65  * CtfImmIsTextFrameServiceDisabled(IMM32.@)
66  */
68 {
69  return !!(GetWin32ClientInfo()->CI_flags & CI_TFSDISABLED);
70 }
71 
72 /***********************************************************************
73  * CtfImmTIMActivate(IMM32.@)
74  */
76 {
77  FIXME("(%p)\n", hKL);
78  return E_NOTIMPL;
79 }
80 
81 /***********************************************************************
82  * CtfImmRestoreToolbarWnd(IMM32.@)
83  */
85 {
86  FIXME("(0x%lx)\n", dwStatus);
87 }
88 
89 /***********************************************************************
90  * CtfImmHideToolbarWnd(IMM32.@)
91  */
93 {
94  FIXME("()\n");
95  return 0;
96 }
97 
98 /***********************************************************************
99  * CtfImmDispatchDefImeMessage(IMM32.@)
100  */
102 {
103  FIXME("(%p, %u, %p, %p)\n", hWnd, uMsg, wParam, lParam);
104  return 0;
105 }
106 
107 /***********************************************************************
108  * CtfImmIsGuidMapEnable(IMM32.@)
109  */
111 {
113  HKL hKL;
114  PIMEDPI pImeDpi;
115  BOOL ret = FALSE;
116 
117  TRACE("(%p)\n", hIMC);
118 
119  if (!IS_CICERO_MODE() || IS_16BIT_MODE())
120  return ret;
121 
124 
125  if (IS_IME_HKL(hKL))
126  return ret;
127 
128  pImeDpi = Imm32FindOrLoadImeDpi(hKL);
129  if (!pImeDpi)
130  return ret;
131 
132  ret = pImeDpi->CtfImeIsGuidMapEnable(hIMC);
133 
134  ImmUnlockImeDpi(pImeDpi);
135  return ret;
136 }
137 
138 /***********************************************************************
139  * CtfImmGetGuidAtom(IMM32.@)
140  */
141 HRESULT WINAPI CtfImmGetGuidAtom(HIMC hIMC, DWORD dwUnknown, LPDWORD pdwGuidAtom)
142 {
143  HRESULT hr = E_FAIL;
144  PIMEDPI pImeDpi;
146  HKL hKL;
147 
148  TRACE("(%p, 0xlX, %p)\n", hIMC, dwUnknown, pdwGuidAtom);
149 
150  *pdwGuidAtom = 0;
151 
152  if (!IS_CICERO_MODE() || IS_16BIT_MODE())
153  return hr;
154 
157  if (IS_IME_HKL(hKL))
158  return S_OK;
159 
160  pImeDpi = Imm32FindOrLoadImeDpi(hKL);
161  if (!pImeDpi)
162  return hr;
163 
164  hr = pImeDpi->CtfImeGetGuidAtom(hIMC, dwUnknown, pdwGuidAtom);
165 
166  ImmUnlockImeDpi(pImeDpi);
167  return hr;
168 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:945
BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
Definition: ctf.c:67
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
HWND hWnd
Definition: settings.c:17
HRESULT APIENTRY CtfImmTIMCreateInputContext(HIMC hIMC)
Definition: ctf.c:50
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWin32ClientInfo()
Definition: ntuser.h:335
DWORD WINAPI CtfImmHideToolbarWnd(VOID)
Definition: ctf.c:92
#define E_FAIL
Definition: ddrawi.h:102
#define DWORD
Definition: nt_native.h:44
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI CtfImmDispatchDefImeMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ctf.c:101
HRESULT WINAPI CtfImmGetGuidAtom(HIMC hIMC, DWORD dwUnknown, LPDWORD pdwGuidAtom)
Definition: ctf.c:141
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
LONG_PTR LPARAM
Definition: windef.h:208
DWORD HIMC
Definition: dimm.idl:75
BOOL WINAPI CtfImmIsGuidMapEnable(HIMC hIMC)
Definition: ctf.c:110
#define CI_TFSDISABLED
Definition: ntuser.h:298
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1794
#define WINAPI
Definition: msvc.h:6
#define IS_CICERO_MODE()
Definition: ntuser.h:1205
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT APIENTRY Imm32CtfImeDestroyInputContext(HIMC hIMC)
Definition: ctf.c:28
WINE_DEFAULT_DEBUG_CHANNEL(imm)
int ret
DWORD dwThreadId
Definition: fdebug.c:31
UINT_PTR HKL
Definition: msctf.idl:101
HMODULE APIENTRY Imm32LoadCtfIme(VOID)
Definition: ctf.c:21
#define S_OK
Definition: intsafe.h:52
#define IS_IME_HKL(hKL)
Definition: input.h:88
DWORD dwStatus
Definition: mediaobj.idl:95
#define E_NOTIMPL
Definition: ddrawi.h:99
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL)
Definition: ime.c:295
uint32_t * LPDWORD
Definition: typedefs.h:59
BOOL WINAPI CtfImmIsCiceroEnabled(VOID)
Definition: ctf.c:59
HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC)
Definition: ctf.c:41
LONG_PTR LRESULT
Definition: windef.h:209
#define IS_16BIT_MODE()
Definition: precomp.h:117
VOID WINAPI CtfImmRestoreToolbarWnd(DWORD dwStatus)
Definition: ctf.c:84
LPARAM lParam
Definition: combotst.c:139
#define APIENTRY
Definition: api.h:79
HRESULT WINAPI CtfImmTIMActivate(HKL hKL)
Definition: ctf.c:75