ReactOS  0.4.15-dev-3326-ga91f5e8
imm.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 Far-Eastern languages input
5  * COPYRIGHT: Copyright 1998 Patrik Stridvall
6  * Copyright 2002, 2003, 2007 CodeWeavers, Aric Stewart
7  * Copyright 2017 James Tabor <james.tabor@reactos.org>
8  * Copyright 2018 Amine Khaldi <amine.khaldi@reactos.org>
9  * Copyright 2020 Oleg Dubinskiy <oleg.dubinskij2013@yandex.ua>
10  * Copyright 2020-2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
11  */
12 
13 #include "precomp.h"
14 
16 
21 
23 {
25 
26  if (hMod)
27  g_hImm32Inst = hMod;
28 
29  if (g_bClientRegd)
30  return TRUE;
31 
33  if (NT_ERROR(status))
34  return FALSE;
35 
37  return TRUE;
38 }
39 
40 /***********************************************************************
41  * ImmRegisterClient(IMM32.@)
42  * ( Undocumented, called from user32.dll )
43  */
45 {
46  g_SharedInfo = *ptr;
48  return Imm32InitInstance(hMod);
49 }
50 
51 /***********************************************************************
52  * ImmLoadLayout (IMM32.@)
53  */
55 {
56  DWORD cbData;
57  HKEY hLayoutKey = NULL, hLayoutsKey = NULL;
58  LONG error;
59  WCHAR szLayout[MAX_PATH];
60 
61  TRACE("(%p, %p)\n", hKL, pImeInfoEx);
62 
63  if (IS_IME_HKL(hKL) || !Imm32IsCiceroMode() || Imm32Is16BitMode())
64  {
65  Imm32UIntToStr((DWORD)(DWORD_PTR)hKL, 16, szLayout, _countof(szLayout));
66 
68  if (error)
69  {
70  ERR("RegOpenKeyW: 0x%08lX\n", error);
71  return FALSE;
72  }
73 
74  error = RegOpenKeyW(hLayoutsKey, szLayout, &hLayoutKey);
75  if (error)
76  {
77  ERR("RegOpenKeyW: 0x%08lX\n", error);
78  RegCloseKey(hLayoutsKey);
79  return FALSE;
80  }
81  }
82  else
83  {
85  if (error)
86  {
87  ERR("RegOpenKeyW: 0x%08lX\n", error);
88  return FALSE;
89  }
90  }
91 
92  cbData = sizeof(pImeInfoEx->wszImeFile);
93  error = RegQueryValueExW(hLayoutKey, L"Ime File", 0, 0,
94  (LPBYTE)pImeInfoEx->wszImeFile, &cbData);
95  pImeInfoEx->wszImeFile[_countof(pImeInfoEx->wszImeFile) - 1] = 0;
96 
97  RegCloseKey(hLayoutKey);
98  if (hLayoutsKey)
99  RegCloseKey(hLayoutsKey);
100 
101  pImeInfoEx->fLoadFlag = 0;
102 
103  if (error)
104  {
105  ERR("RegQueryValueExW: 0x%08lX\n", error);
106  pImeInfoEx->hkl = NULL;
107  return FALSE;
108  }
109 
110  pImeInfoEx->hkl = hKL;
111  return Imm32LoadImeVerInfo(pImeInfoEx);
112 }
113 
114 /***********************************************************************
115  * ImmFreeLayout (IMM32.@)
116  */
118 {
119  WCHAR szKBD[9];
120  UINT iKL, cKLs;
121  HKL hOldKL, hNewKL, *pList;
122  PIMEDPI pImeDpi;
123  LANGID LangID;
124 
125  TRACE("(0x%lX)\n", dwUnknown);
126 
127  hOldKL = GetKeyboardLayout(0);
128 
129  if (dwUnknown == 1)
130  {
131  if (!IS_IME_HKL(hOldKL))
132  return TRUE;
133 
135 
136  cKLs = GetKeyboardLayoutList(0, NULL);
137  if (cKLs)
138  {
139  pList = Imm32HeapAlloc(0, cKLs * sizeof(HKL));
140  if (pList == NULL)
141  return FALSE;
142 
143  cKLs = GetKeyboardLayoutList(cKLs, pList);
144  for (iKL = 0; iKL < cKLs; ++iKL)
145  {
146  if (!IS_IME_HKL(pList[iKL]))
147  {
148  LangID = LOWORD(pList[iKL]);
149  break;
150  }
151  }
152 
154  }
155 
156  StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID);
157  if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE))
158  LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200);
159  }
160  else if (dwUnknown == 2)
161  {
163 Retry:
164  for (pImeDpi = g_pImeDpiList; pImeDpi; pImeDpi = pImeDpi->pNext)
165  {
166  if (Imm32ReleaseIME(pImeDpi->hKL))
167  goto Retry;
168  }
170  }
171  else
172  {
173  hNewKL = (HKL)(DWORD_PTR)dwUnknown;
174  if (IS_IME_HKL(hNewKL) && hNewKL != hOldKL)
175  Imm32ReleaseIME(hNewKL);
176  }
177 
178  return TRUE;
179 }
180 
181 VOID APIENTRY Imm32SelectLayout(HKL hNewKL, HKL hOldKL, HIMC hIMC)
182 {
183  PCLIENTIMC pClientImc;
184  LPINPUTCONTEXTDX pIC;
185  LPGUIDELINE pGL;
186  LPCANDIDATEINFO pCI;
188  LOGFONTA LogFontA;
189  LOGFONTW LogFontW;
190  BOOL fOpen, bIsNewHKLIme = TRUE, bIsOldHKLIme = TRUE, bClientWide, bNewDpiWide;
191  DWORD cbNewPrivate = 0, cbOldPrivate = 0, dwConversion, dwSentence, dwSize, dwNewSize;
192  PIMEDPI pNewImeDpi = NULL, pOldImeDpi = NULL;
193  HANDLE hPrivate;
194  PIME_STATE pNewState = NULL, pOldState = NULL;
195 
196  pClientImc = ImmLockClientImc(hIMC);
197  if (!pClientImc)
198  return;
199 
200  pNewImeDpi = ImmLockImeDpi(hNewKL);
201 
202  if (hNewKL != hOldKL)
203  pOldImeDpi = ImmLockImeDpi(hOldKL);
204 
205  if (pNewImeDpi)
206  {
207  cbNewPrivate = pNewImeDpi->ImeInfo.dwPrivateDataSize;
208  pClientImc->uCodePage = pNewImeDpi->uCodePage;
209  }
210  else
211  {
212  pClientImc->uCodePage = CP_ACP;
213  }
214 
215  if (cbNewPrivate < sizeof(DWORD))
216  cbNewPrivate = sizeof(DWORD);
217 
218  if (pOldImeDpi)
219  cbOldPrivate = pOldImeDpi->ImeInfo.dwPrivateDataSize;
220 
221  if (cbOldPrivate < sizeof(DWORD))
222  cbOldPrivate = sizeof(DWORD);
223 
224  if (pClientImc->hKL == hOldKL)
225  {
226  if (pOldImeDpi)
227  {
228  if (IS_IME_HKL(hOldKL))
229  pOldImeDpi->ImeSelect(hIMC, FALSE);
230  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pOldImeDpi->CtfImeSelectEx)
231  pOldImeDpi->CtfImeSelectEx(hIMC, FALSE, hOldKL);
232  }
233  pClientImc->hKL = NULL;
234  }
235 
237  {
238  if (Imm32IsImmMode() && !Imm32IsCiceroMode())
239  {
240  bIsNewHKLIme = IS_IME_HKL(hNewKL);
241  bIsOldHKLIme = IS_IME_HKL(hOldKL);
242  }
243  }
244 
245  pIC = (LPINPUTCONTEXTDX)Imm32LockIMCEx(hIMC, FALSE);
246  if (!pIC)
247  {
248  if (pNewImeDpi)
249  {
250  if (IS_IME_HKL(hNewKL))
251  pNewImeDpi->ImeSelect(hIMC, TRUE);
252  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pNewImeDpi->CtfImeSelectEx)
253  pNewImeDpi->CtfImeSelectEx(hIMC, TRUE, hNewKL);
254 
255  pClientImc->hKL = hNewKL;
256  }
257  }
258  else
259  {
260  dwConversion = pIC->fdwConversion;
261  dwSentence = pIC->fdwSentence;
262  fOpen = pIC->fOpen;
263 
264  if (pNewImeDpi)
265  {
266  bClientWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
267  bNewDpiWide = ImeDpi_IsUnicode(pNewImeDpi);
268  if (bClientWide && !bNewDpiWide)
269  {
270  if (pIC->fdwInit & INIT_LOGFONT)
271  {
272  LogFontWideToAnsi(&pIC->lfFont.W, &LogFontA);
273  pIC->lfFont.A = LogFontA;
274  }
275  pClientImc->dwFlags &= ~CLIENTIMC_WIDE;
276  }
277  else if (!bClientWide && bNewDpiWide)
278  {
279  if (pIC->fdwInit & INIT_LOGFONT)
280  {
281  LogFontAnsiToWide(&pIC->lfFont.A, &LogFontW);
282  pIC->lfFont.W = LogFontW;
283  }
284  pClientImc->dwFlags |= CLIENTIMC_WIDE;
285  }
286  }
287 
288  if (cbOldPrivate != cbNewPrivate)
289  {
290  hPrivate = ImmReSizeIMCC(pIC->hPrivate, cbNewPrivate);
291  if (!hPrivate)
292  {
293  ImmDestroyIMCC(pIC->hPrivate);
294  hPrivate = ImmCreateIMCC(cbNewPrivate);
295  }
296  pIC->hPrivate = hPrivate;
297  }
298 
299 #define MAX_IMCC_SIZE 0x1000
300  dwSize = ImmGetIMCCSize(pIC->hMsgBuf);
301  if (ImmGetIMCCLockCount(pIC->hMsgBuf) || dwSize > MAX_IMCC_SIZE)
302  {
303  ImmDestroyIMCC(pIC->hMsgBuf);
304  pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
305  pIC->dwNumMsgBuf = 0;
306  }
307 
308  dwSize = ImmGetIMCCSize(pIC->hGuideLine);
309  dwNewSize = sizeof(GUIDELINE);
310  if (ImmGetIMCCLockCount(pIC->hGuideLine) ||
311  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
312  {
313  ImmDestroyIMCC(pIC->hGuideLine);
314  pIC->hGuideLine = ImmCreateIMCC(dwNewSize);
315  pGL = ImmLockIMCC(pIC->hGuideLine);
316  if (pGL)
317  {
318  pGL->dwSize = dwNewSize;
319  ImmUnlockIMCC(pIC->hGuideLine);
320  }
321  }
322 
323  dwSize = ImmGetIMCCSize(pIC->hCandInfo);
324  dwNewSize = sizeof(CANDIDATEINFO);
325  if (ImmGetIMCCLockCount(pIC->hCandInfo) ||
326  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
327  {
328  ImmDestroyIMCC(pIC->hCandInfo);
329  pIC->hCandInfo = ImmCreateIMCC(dwNewSize);
330  pCI = ImmLockIMCC(pIC->hCandInfo);
331  if (pCI)
332  {
333  pCI->dwSize = dwNewSize;
334  ImmUnlockIMCC(pIC->hCandInfo);
335  }
336  }
337 
338  dwSize = ImmGetIMCCSize(pIC->hCompStr);
339  dwNewSize = sizeof(COMPOSITIONSTRING);
340  if (ImmGetIMCCLockCount(pIC->hCompStr) ||
341  dwSize < dwNewSize || dwSize > MAX_IMCC_SIZE)
342  {
343  ImmDestroyIMCC(pIC->hCompStr);
344  pIC->hCompStr = ImmCreateIMCC(dwNewSize);
345  pCS = ImmLockIMCC(pIC->hCompStr);
346  if (pCS)
347  {
348  pCS->dwSize = dwNewSize;
349  ImmUnlockIMCC(pIC->hCompStr);
350  }
351  }
352 #undef MAX_IMCC_SIZE
353 
354  if (pOldImeDpi && bIsOldHKLIme)
355  {
356  pOldState = Imm32FetchImeState(pIC, hOldKL);
357  if (pOldState)
358  Imm32SaveImeStateSentence(pIC, pOldState, hOldKL);
359  }
360 
361  if (pNewImeDpi && bIsNewHKLIme)
362  pNewState = Imm32FetchImeState(pIC, hNewKL);
363 
364  if (pOldState != pNewState)
365  {
366  if (pOldState)
367  {
368  pOldState->fOpen = !!pIC->fOpen;
369  pOldState->dwConversion = (pIC->fdwConversion & ~IME_CMODE_EUDC);
370  pOldState->dwSentence = pIC->fdwSentence;
371  pOldState->dwInit = pIC->fdwInit;
372  }
373 
374  if (pNewState)
375  {
377  {
379  pIC->fOpen = TRUE;
380  }
381  else
382  {
383  pIC->fOpen = pNewState->fOpen;
384  }
385 
386  pIC->fdwConversion = (pNewState->dwConversion & ~IME_CMODE_EUDC);
387  pIC->fdwSentence = pNewState->dwSentence;
388  pIC->fdwInit = pNewState->dwInit;
389  }
390  }
391 
392  if (pNewState)
393  Imm32LoadImeStateSentence(pIC, pNewState, hNewKL);
394 
395  if (pNewImeDpi)
396  {
397  if (IS_IME_HKL(hNewKL))
398  pNewImeDpi->ImeSelect(hIMC, TRUE);
399  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pNewImeDpi->CtfImeSelectEx)
400  pNewImeDpi->CtfImeSelectEx(hIMC, TRUE, hNewKL);
401 
402  pClientImc->hKL = hNewKL;
403  }
404 
405  pIC->dwChange = 0;
406  if (pIC->fOpen != fOpen)
408  if (pIC->fdwConversion != dwConversion)
410  if (pIC->fdwSentence != dwSentence)
412 
413  ImmUnlockIMC(hIMC);
414  }
415 
416  ImmUnlockImeDpi(pOldImeDpi);
417  ImmUnlockImeDpi(pNewImeDpi);
418  ImmUnlockClientImc(pClientImc);
419 }
420 
421 typedef struct SELECT_LAYOUT
422 {
426 
428 {
430  Imm32SelectLayout(pSelect->hNewKL, pSelect->hOldKL, hIMC);
431  return TRUE;
432 }
433 
435 {
437  return TRUE;
438 }
439 
440 /***********************************************************************
441  * ImmActivateLayout (IMM32.@)
442  */
444 {
445  PIMEDPI pImeDpi;
446  HKL hOldKL;
447  LPARAM lParam;
448  HWND hwndDefIME = NULL;
449  SELECT_LAYOUT SelectLayout;
450 
451  hOldKL = GetKeyboardLayout(0);
452 
453  if (hOldKL == hKL && !(GetWin32ClientInfo()->CI_flags & CI_IMMACTIVATE))
454  return TRUE;
455 
456  ImmLoadIME(hKL);
457 
458  if (hOldKL != hKL)
459  {
460  pImeDpi = ImmLockImeDpi(hOldKL);
461  if (pImeDpi)
462  {
465  else
466  lParam = CPS_CANCEL;
467  ImmUnlockImeDpi(pImeDpi);
468 
470  }
471 
472  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
473  if (IsWindow(hwndDefIME))
474  SendMessageW(hwndDefIME, WM_IME_SELECT, FALSE, (LPARAM)hOldKL);
475 
476  NtUserSetThreadLayoutHandles(hKL, hOldKL);
477  }
478 
479  SelectLayout.hNewKL = hKL;
480  SelectLayout.hOldKL = hOldKL;
482 
483  if (IsWindow(hwndDefIME))
484  SendMessageW(hwndDefIME, WM_IME_SELECT, TRUE, (LPARAM)hKL);
485 
486  return TRUE;
487 }
488 
490 {
491  FIXME("We have to do something\n");
492 }
493 
494 /***********************************************************************
495  * ImmAssociateContext (IMM32.@)
496  */
498 {
499  PWND pWnd;
500  HWND hwndFocus;
501  DWORD dwValue;
502  HIMC hOldIMC;
503 
504  TRACE("(%p, %p)\n", hWnd, hIMC);
505 
506  if (!Imm32IsImmMode())
507  return NULL;
508 
509  pWnd = ValidateHwndNoErr(hWnd);
510  if (!pWnd)
511  return NULL;
512 
513  if (hIMC && Imm32IsCrossThreadAccess(hIMC))
514  return NULL;
515 
516  hOldIMC = pWnd->hImc;
517  if (hOldIMC == hIMC)
518  return hIMC;
519 
520  dwValue = NtUserAssociateInputContext(hWnd, hIMC, 0);
521  if (dwValue == 0)
522  return hOldIMC;
523  if (dwValue != 1)
524  return NULL;
525 
527  if (hwndFocus == hWnd)
528  {
529  ImmSetActiveContext(hWnd, hOldIMC, FALSE);
530  ImmSetActiveContext(hWnd, hIMC, TRUE);
531  }
532 
533  return hOldIMC;
534 }
535 
536 /***********************************************************************
537  * ImmAssociateContextEx (IMM32.@)
538  */
540 {
541  HWND hwndFocus;
542  PWND pFocusWnd;
543  HIMC hOldIMC = NULL;
544  DWORD dwValue;
545 
546  TRACE("(%p, %p, 0x%lX)\n", hWnd, hIMC, dwFlags);
547 
548  if (!Imm32IsImmMode())
549  return FALSE;
550 
551  if (hIMC && !(dwFlags & IACE_DEFAULT) && Imm32IsCrossThreadAccess(hIMC))
552  return FALSE;
553 
555  pFocusWnd = ValidateHwndNoErr(hwndFocus);
556  if (pFocusWnd)
557  hOldIMC = pFocusWnd->hImc;
558 
559  dwValue = NtUserAssociateInputContext(hWnd, hIMC, dwFlags);
560  switch (dwValue)
561  {
562  case 0:
563  return TRUE;
564 
565  case 1:
566  pFocusWnd = ValidateHwndNoErr(hwndFocus);
567  if (pFocusWnd)
568  {
569  hIMC = pFocusWnd->hImc;
570  if (hIMC != hOldIMC)
571  {
572  ImmSetActiveContext(hwndFocus, hOldIMC, FALSE);
573  ImmSetActiveContext(hwndFocus, hIMC, TRUE);
574  }
575  }
576  return TRUE;
577 
578  default:
579  return FALSE;
580  }
581 }
582 
583 /***********************************************************************
584  * ImmCreateContext (IMM32.@)
585  */
587 {
588  PCLIENTIMC pClientImc;
589  HIMC hIMC;
590 
591  TRACE("()\n");
592 
593  if (!Imm32IsImmMode())
594  return NULL;
595 
596  pClientImc = Imm32HeapAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
597  if (pClientImc == NULL)
598  return NULL;
599 
600  hIMC = NtUserCreateInputContext(pClientImc);
601  if (hIMC == NULL)
602  {
603  Imm32HeapFree(pClientImc);
604  return NULL;
605  }
606 
607  RtlInitializeCriticalSection(&pClientImc->cs);
608 
609  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
610  pClientImc->unknown = NtUserGetThreadState(13);
611 
612  return hIMC;
613 }
614 
616 {
617  PIME_STATE pState, pStateNext;
618  PIME_SUBSTATE pSubState, pSubStateNext;
619 
620  pState = pIC->pState;
621  pIC->pState = NULL;
622  for (; pState; pState = pStateNext)
623  {
624  pStateNext = pState->pNext;
625  for (pSubState = pState->pSubState; pSubState; pSubState = pSubStateNext)
626  {
627  pSubStateNext = pSubState->pNext;
628  Imm32HeapFree(pSubState);
629  }
630  Imm32HeapFree(pState);
631  }
632 }
633 
635 {
636  PIMEDPI pImeDpi;
637  LPINPUTCONTEXTDX pIC;
638  PCLIENTIMC pClientImc;
639  PIMC pIMC;
640 
641  if (!Imm32IsImmMode() || hIMC == NULL)
642  return FALSE;
643 
645  if (!pIMC || pIMC->head.pti != NtCurrentTeb()->Win32ThreadInfo)
646  return FALSE;
647 
648  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
649  if (!pClientImc)
650  return FALSE;
651 
652  if (pClientImc->hInputContext == NULL)
653  {
654  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN1;
655  ImmUnlockClientImc(pClientImc);
656  if (!bKeep)
657  return NtUserDestroyInputContext(hIMC);
658  return TRUE;
659  }
660 
661  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
662  if (pIC == NULL)
663  {
664  ImmUnlockClientImc(pClientImc);
665  return FALSE;
666  }
667 
668  FIXME("We have do something to do here\n");
669 
670  if (pClientImc->hKL == hKL)
671  {
672  pImeDpi = ImmLockImeDpi(hKL);
673  if (pImeDpi != NULL)
674  {
675  if (IS_IME_HKL(hKL))
676  {
677  pImeDpi->ImeSelect(hIMC, FALSE);
678  }
679  else if (Imm32IsCiceroMode() && pImeDpi->CtfImeSelectEx)
680  {
681  pImeDpi->CtfImeSelectEx(hIMC, FALSE, hKL);
682  }
683  ImmUnlockImeDpi(pImeDpi);
684  }
685  pClientImc->hKL = NULL;
686  }
687 
688  pIC->hPrivate = ImmDestroyIMCC(pIC->hPrivate);
689  pIC->hMsgBuf = ImmDestroyIMCC(pIC->hMsgBuf);
690  pIC->hGuideLine = ImmDestroyIMCC(pIC->hGuideLine);
691  pIC->hCandInfo = ImmDestroyIMCC(pIC->hCandInfo);
692  pIC->hCompStr = ImmDestroyIMCC(pIC->hCompStr);
693 
694  Imm32FreeImeStates(pIC);
695 
696  ImmUnlockIMC(hIMC);
697 
698  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN1;
699  ImmUnlockClientImc(pClientImc);
700 
701  if (!bKeep)
702  return NtUserDestroyInputContext(hIMC);
703 
704  return TRUE;
705 }
706 
708 Imm32InitContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
709 {
710  DWORD dwIndex, cbPrivate;
711  PIMEDPI pImeDpi = NULL;
713  LPCANDIDATEINFO pCI;
714  LPGUIDELINE pGL;
715  /* NOTE: Windows does recursive call ImmLockIMC here but we don't do so. */
716 
717  /* Create IC components */
718  pIC->hCompStr = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
719  pIC->hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO));
720  pIC->hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE));
721  pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
722  if (!pIC->hCompStr || !pIC->hCandInfo || !pIC->hGuideLine || !pIC->hMsgBuf)
723  goto Fail;
724 
725  /* Initialize IC components */
726  pCS = ImmLockIMCC(pIC->hCompStr);
727  if (!pCS)
728  goto Fail;
729  pCS->dwSize = sizeof(COMPOSITIONSTRING);
730  ImmUnlockIMCC(pIC->hCompStr);
731 
732  pCI = ImmLockIMCC(pIC->hCandInfo);
733  if (!pCI)
734  goto Fail;
735  pCI->dwSize = sizeof(CANDIDATEINFO);
736  ImmUnlockIMCC(pIC->hCandInfo);
737 
738  pGL = ImmLockIMCC(pIC->hGuideLine);
739  if (!pGL)
740  goto Fail;
741  pGL->dwSize = sizeof(GUIDELINE);
743 
744  pIC->dwNumMsgBuf = 0;
745  pIC->fOpen = FALSE;
746  pIC->fdwConversion = pIC->fdwSentence = 0;
747 
748  for (dwIndex = 0; dwIndex < MAX_CANDIDATEFORM; ++dwIndex)
749  pIC->cfCandForm[dwIndex].dwIndex = IMM_INVALID_CANDFORM;
750 
751  /* Get private data size */
752  pImeDpi = ImmLockImeDpi(hKL);
753  if (!pImeDpi)
754  {
755  cbPrivate = sizeof(DWORD);
756  }
757  else
758  {
759  /* Update CLIENTIMC */
760  pClientImc->uCodePage = pImeDpi->uCodePage;
761  if (ImeDpi_IsUnicode(pImeDpi))
762  pClientImc->dwFlags |= CLIENTIMC_WIDE;
763 
764  cbPrivate = pImeDpi->ImeInfo.dwPrivateDataSize;
765  }
766 
767  /* Create private data */
768  pIC->hPrivate = ImmCreateIMCC(cbPrivate);
769  if (!pIC->hPrivate)
770  goto Fail;
771 
772  if (pImeDpi)
773  {
774  /* Select the IME */
775  if (fSelect)
776  {
777  if (IS_IME_HKL(hKL))
778  pImeDpi->ImeSelect(hIMC, TRUE);
779  else if (Imm32IsCiceroMode() && !Imm32Is16BitMode() && pImeDpi->CtfImeSelectEx)
780  pImeDpi->CtfImeSelectEx(hIMC, TRUE, hKL);
781  }
782 
783  /* Set HKL */
784  pClientImc->hKL = hKL;
785 
786  ImmUnlockImeDpi(pImeDpi);
787  }
788 
789  return TRUE;
790 
791 Fail:
792  if (pImeDpi)
793  ImmUnlockImeDpi(pImeDpi);
794 
795  pIC->hMsgBuf = ImmDestroyIMCC(pIC->hMsgBuf);
796  pIC->hGuideLine = ImmDestroyIMCC(pIC->hGuideLine);
797  pIC->hCandInfo = ImmDestroyIMCC(pIC->hCandInfo);
798  pIC->hCompStr = ImmDestroyIMCC(pIC->hCompStr);
799  return FALSE;
800 }
801 
803 {
804  HANDLE hIC;
805  LPINPUTCONTEXT pIC = NULL;
806  PCLIENTIMC pClientImc;
807  WORD Word;
809  HKL hKL, hNewKL;
810  PIMEDPI pImeDpi = NULL;
811  BOOL bInited;
812 
813  pClientImc = ImmLockClientImc(hIMC);
814  if (!pClientImc)
815  return NULL;
816 
817  RtlEnterCriticalSection(&pClientImc->cs);
818 
819  if (!pClientImc->hInputContext)
820  {
822 
824  {
825  hKL = GetKeyboardLayout(0);
826  Word = LOWORD(hKL);
827  hNewKL = (HKL)(DWORD_PTR)MAKELONG(Word, Word);
828 
829  pImeDpi = ImmLockOrLoadImeDpi(hNewKL);
830  if (pImeDpi)
831  {
832  FIXME("We have to do something here\n");
833  }
834  }
835 
836  if (!NtUserQueryInputContext(hIMC, 2))
837  {
838  RtlLeaveCriticalSection(&pClientImc->cs);
839  goto Quit;
840  }
841 
842  hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
843  if (!hIC)
844  {
845  RtlLeaveCriticalSection(&pClientImc->cs);
846  goto Quit;
847  }
848  pClientImc->hInputContext = hIC;
849 
850  pIC = LocalLock(pClientImc->hInputContext);
851  if (!pIC)
852  {
853  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
854  RtlLeaveCriticalSection(&pClientImc->cs);
855  goto Quit;
856  }
857 
859  // bInited = Imm32InitContext(hIMC, hKL, fSelect);
860  bInited = Imm32InitContext(hIMC, pIC, pClientImc, hKL, fSelect);
861  LocalUnlock(pClientImc->hInputContext);
862 
863  if (!bInited)
864  {
865  pIC = NULL;
866  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
867  RtlLeaveCriticalSection(&pClientImc->cs);
868  goto Quit;
869  }
870  }
871 
872  FIXME("We have to do something here\n");
873 
874  RtlLeaveCriticalSection(&pClientImc->cs);
875  pIC = LocalLock(pClientImc->hInputContext);
876  InterlockedIncrement(&pClientImc->cLockObj);
877 
878 Quit:
879  ImmUnlockClientImc(pClientImc);
880  return pIC;
881 }
882 
883 /***********************************************************************
884  * ImmDestroyContext (IMM32.@)
885  */
887 {
888  HKL hKL;
889 
890  TRACE("(%p)\n", hIMC);
891 
892  if (!Imm32IsImmMode())
893  return FALSE;
894 
895  if (Imm32IsCrossThreadAccess(hIMC))
896  return FALSE;
897 
898  hKL = GetKeyboardLayout(0);
899  return Imm32CleanupContext(hIMC, hKL, FALSE);
900 }
901 
902 /***********************************************************************
903  * ImmLockClientImc (IMM32.@)
904  */
906 {
907  PIMC pIMC;
908  PCLIENTIMC pClientImc;
909 
910  TRACE("(%p)\n", hImc);
911 
912  if (hImc == NULL)
913  return NULL;
914 
916  if (pIMC == NULL || !Imm32CheckImcProcess(pIMC))
917  return NULL;
918 
919  pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
920  if (!pClientImc)
921  {
922  pClientImc = Imm32HeapAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
923  if (!pClientImc)
924  return NULL;
925 
926  RtlInitializeCriticalSection(&pClientImc->cs);
927 
928  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
929  pClientImc->unknown = NtUserGetThreadState(13);
930 
931  if (!NtUserUpdateInputContext(hImc, 0, pClientImc))
932  {
933  Imm32HeapFree(pClientImc);
934  return NULL;
935  }
936 
937  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN2;
938  }
939  else
940  {
941  if (pClientImc->dwFlags & CLIENTIMC_UNKNOWN1)
942  return NULL;
943  }
944 
945  InterlockedIncrement(&pClientImc->cLockObj);
946  return pClientImc;
947 }
948 
949 /***********************************************************************
950  * ImmUnlockClientImc (IMM32.@)
951  */
953 {
954  LONG cLocks;
955  HANDLE hInputContext;
956 
957  TRACE("(%p)\n", pClientImc);
958 
959  cLocks = InterlockedDecrement(&pClientImc->cLockObj);
960  if (cLocks != 0 || !(pClientImc->dwFlags & CLIENTIMC_UNKNOWN1))
961  return;
962 
963  hInputContext = pClientImc->hInputContext;
964  if (hInputContext)
965  LocalFree(hInputContext);
966 
967  RtlDeleteCriticalSection(&pClientImc->cs);
968  Imm32HeapFree(pClientImc);
969 }
970 
971 static HIMC APIENTRY Imm32GetContextEx(HWND hWnd, DWORD dwContextFlags)
972 {
973  HIMC hIMC;
974  PCLIENTIMC pClientImc;
975  PWND pWnd;
976 
977  if (!Imm32IsImmMode())
978  return NULL;
979 
980  if (!hWnd)
981  {
982  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
983  hIMC = (HIMC)NtUserGetThreadState(4);
984  goto Quit;
985  }
986 
987  pWnd = ValidateHwndNoErr(hWnd);
988  if (!pWnd || Imm32IsCrossProcessAccess(hWnd))
989  return NULL;
990 
991  hIMC = pWnd->hImc;
992  if (!hIMC && (dwContextFlags & 1))
994 
995 Quit:
996  pClientImc = ImmLockClientImc(hIMC);
997  if (pClientImc == NULL)
998  return NULL;
999  if ((dwContextFlags & 2) && (pClientImc->dwFlags & CLIENTIMC_UNKNOWN3))
1000  hIMC = NULL;
1001  ImmUnlockClientImc(pClientImc);
1002  return hIMC;
1003 }
1004 
1005 /***********************************************************************
1006  * ImmGetContext (IMM32.@)
1007  */
1009 {
1010  TRACE("(%p)\n", hWnd);
1011  if (hWnd == NULL)
1012  return NULL;
1013  return Imm32GetContextEx(hWnd, 2);
1014 }
1015 
1016 /***********************************************************************
1017  * CtfImmIsCiceroEnabled (IMM32.@)
1018  */
1020 {
1021  return Imm32IsCiceroMode();
1022 }
1023 
1024 /***********************************************************************
1025  * ImmLockIMC(IMM32.@)
1026  *
1027  * NOTE: This is not ImmLockIMCC. Don't confuse.
1028  */
1030 {
1031  TRACE("(%p)\n", hIMC);
1032  return Imm32LockIMCEx(hIMC, TRUE);
1033 }
1034 
1035 /***********************************************************************
1036 * ImmUnlockIMC(IMM32.@)
1037 */
1039 {
1040  PCLIENTIMC pClientImc;
1041 
1042  pClientImc = ImmLockClientImc(hIMC);
1043  if (pClientImc == NULL)
1044  return FALSE;
1045 
1046  if (pClientImc->hInputContext)
1047  LocalUnlock(pClientImc->hInputContext);
1048 
1049  InterlockedDecrement(&pClientImc->cLockObj);
1050  ImmUnlockClientImc(pClientImc);
1051  return TRUE;
1052 }
1053 
1054 /***********************************************************************
1055  * ImmReleaseContext (IMM32.@)
1056  */
1058 {
1059  TRACE("(%p, %p)\n", hWnd, hIMC);
1061  UNREFERENCED_PARAMETER(hIMC);
1062  return TRUE; // Do nothing. This is correct.
1063 }
1064 
1065 /***********************************************************************
1066  * ImmCreateSoftKeyboard(IMM32.@)
1067  */
1068 HWND WINAPI ImmCreateSoftKeyboard(UINT uType, UINT hOwner, int x, int y)
1069 {
1070  FIXME("(%d, %d, %d, %d): stub\n", uType, hOwner, x, y);
1072  return 0;
1073 }
1074 
1075 /***********************************************************************
1076  * ImmDestroySoftKeyboard(IMM32.@)
1077  */
1079 {
1080  TRACE("(%p)\n", hSoftWnd);
1081  return DestroyWindow(hSoftWnd);
1082 }
1083 
1084 /***********************************************************************
1085  * ImmShowSoftKeyboard(IMM32.@)
1086  */
1087 BOOL WINAPI ImmShowSoftKeyboard(HWND hSoftWnd, int nCmdShow)
1088 {
1089  TRACE("(%p, %d)\n", hSoftWnd, nCmdShow);
1090  if (hSoftWnd)
1091  return ShowWindow(hSoftWnd, nCmdShow);
1092  return FALSE;
1093 }
1094 
1095 /***********************************************************************
1096 * ImmDisableTextFrameService(IMM32.@)
1097 */
1099 {
1100  FIXME("Stub\n");
1101  return FALSE;
1102 }
1103 
1104 /***********************************************************************
1105  * ImmEnumInputContext(IMM32.@)
1106  */
1108 {
1109  HIMC *phList;
1110  DWORD dwIndex, dwCount;
1111  BOOL ret = TRUE;
1112  HIMC hIMC;
1113 
1114  TRACE("(%lu, %p, %p)\n", dwThreadId, lpfn, lParam);
1115 
1116  dwCount = Imm32AllocAndBuildHimcList(dwThreadId, &phList);
1117  if (!dwCount)
1118  return FALSE;
1119 
1120  for (dwIndex = 0; dwIndex < dwCount; ++dwIndex)
1121  {
1122  hIMC = phList[dwIndex];
1123  ret = (*lpfn)(hIMC, lParam);
1124  if (!ret)
1125  break;
1126  }
1127 
1128  Imm32HeapFree(phList);
1129  return ret;
1130 }
1131 
1132 /***********************************************************************
1133  * ImmSetActiveContext(IMM32.@)
1134  */
1136 {
1137  PCLIENTIMC pClientImc;
1138  LPINPUTCONTEXTDX pIC;
1139  PIMEDPI pImeDpi;
1140  HKL hKL;
1141  BOOL fOpen = FALSE;
1142  DWORD dwConversion = 0, iShow = ISC_SHOWUIALL;
1143  HWND hwndDefIME;
1144 
1145  TRACE("(%p, %p, %d)\n", hWnd, hIMC, fActive);
1146 
1147  if (!Imm32IsImmMode())
1148  return FALSE;
1149 
1150  pClientImc = ImmLockClientImc(hIMC);
1151 
1152  if (!fActive)
1153  {
1154  if (pClientImc)
1155  pClientImc->dwFlags &= ~CLIENTIMC_UNKNOWN4;
1156  }
1157  else if (hIMC)
1158  {
1159  if (!pClientImc)
1160  return FALSE;
1161 
1162  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1163  if (!pIC)
1164  {
1165  ImmUnlockClientImc(pClientImc);
1166  return FALSE;
1167  }
1168 
1169  pIC->hWnd = hWnd;
1170  pClientImc->dwFlags |= CLIENTIMC_UNKNOWN5;
1171 
1172  if (pIC->dwUIFlags & 2)
1174 
1175  fOpen = pIC->fOpen;
1176  dwConversion = pIC->fdwConversion;
1177 
1178  ImmUnlockIMC(hIMC);
1179  }
1180  else
1181  {
1182  hIMC = Imm32GetContextEx(hWnd, TRUE);
1183  pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
1184  if (pIC)
1185  {
1186  pIC->hWnd = hWnd;
1187  ImmUnlockIMC(hIMC);
1188  }
1189  hIMC = NULL;
1190  }
1191 
1192  hKL = GetKeyboardLayout(0);
1193 
1194  if (Imm32IsCiceroMode() && !Imm32Is16BitMode())
1195  {
1196  Imm32CiceroSetActiveContext(hIMC, fActive, hWnd, hKL);
1197  hKL = GetKeyboardLayout(0);
1198  }
1199 
1200  pImeDpi = ImmLockImeDpi(hKL);
1201  if (pImeDpi)
1202  {
1203  if (IS_IME_HKL(hKL))
1204  pImeDpi->ImeSetActiveContext(hIMC, fActive);
1205  ImmUnlockImeDpi(pImeDpi);
1206  }
1207 
1208  if (IsWindow(hWnd))
1209  {
1210  SendMessageW(hWnd, WM_IME_SETCONTEXT, fActive, iShow);
1211  if (fActive)
1212  NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion);
1213  }
1214  else if (!fActive)
1215  {
1216  hwndDefIME = ImmGetDefaultIMEWnd(NULL);
1217  if (hwndDefIME)
1218  SendMessageW(hwndDefIME, WM_IME_SETCONTEXT, 0, iShow);
1219  }
1220 
1221  if (pClientImc)
1222  ImmUnlockClientImc(pClientImc);
1223 
1224  return TRUE;
1225 }
1226 
1227 /***********************************************************************
1228  * ImmSetActiveContextConsoleIME(IMM32.@)
1229  */
1231 {
1232  HIMC hIMC;
1233  TRACE("(%p, %d)\n", hwnd, fFlag);
1234 
1235  hIMC = ImmGetContext(hwnd);
1236  if (hIMC)
1237  return ImmSetActiveContext(hwnd, hIMC, fFlag);
1238  return FALSE;
1239 }
1240 
1242 
1243 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
1244 {
1245  HKL hKL;
1246  HIMC hIMC;
1247  PTEB pTeb;
1248 
1249  TRACE("(%p, 0x%X, %p)\n", hinstDLL, fdwReason, lpReserved);
1250 
1251  switch (fdwReason)
1252  {
1253  case DLL_PROCESS_ATTACH:
1254  if (!Imm32InitInstance(hinstDLL))
1255  {
1256  ERR("Imm32InitInstance failed\n");
1257  return FALSE;
1258  }
1260  {
1261  ERR("User32InitializeImmEntryTable failed\n");
1262  return FALSE;
1263  }
1264  break;
1265 
1266  case DLL_THREAD_ATTACH:
1267  break;
1268 
1269  case DLL_THREAD_DETACH:
1270  if (!Imm32IsImmMode())
1271  return TRUE;
1272 
1273  pTeb = NtCurrentTeb();
1274  if (pTeb->Win32ThreadInfo == NULL)
1275  return TRUE;
1276 
1277  hKL = GetKeyboardLayout(0);
1278  // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
1279  hIMC = (HIMC)NtUserGetThreadState(4);
1280  Imm32CleanupContext(hIMC, hKL, TRUE);
1281  break;
1282 
1283  case DLL_PROCESS_DETACH:
1285  TRACE("imm32.dll is unloaded\n");
1286  break;
1287  }
1288 
1289  return TRUE;
1290 }
DWORD NTAPI NtUserAssociateInputContext(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: ntstubs.c:14
DWORD NTAPI NtUserSetThreadLayoutHandles(HKL hNewKL, HKL hOldKL)
Definition: ntstubs.c:897
DWORD WINAPI ImmGetIMCCSize(HIMCC imcc)
Definition: utils.c:975
HIMC NTAPI NtUserCreateInputContext(PCLIENTIMC pClientImc)
Definition: ntstubs.c:421
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:755
#define IACE_DEFAULT
Definition: imm.h:586
UINT uCodePage
Definition: ntuser.h:1244
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1107
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:32
IMEINFO ImeInfo
Definition: ntuser.h:1243
BOOL WINAPI ImmDisableTextFrameService(DWORD dwThreadId)
Definition: imm.c:1098
DWORD dwUIFlags
Definition: imm.h:98
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Definition: utils.c:589
#define CPS_COMPLETE
Definition: imm.h:315
BOOL WINAPI CtfImmIsCiceroEnabled(VOID)
Definition: imm.c:1019
DWORD dwInit
Definition: imm.h:185
#define error(str)
Definition: mkdosfs.c:1605
BOOL WINAPI IsWindow(_In_opt_ HWND)
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:927
PSERVERINFO g_psi
Definition: imm.c:18
PVOID Win32ThreadInfo
Definition: compat.h:705
RTL_CRITICAL_SECTION g_csImeDpi
Definition: ime.c:17
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:120
#define KLF_ACTIVATE
Definition: winuser.h:111
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define DLL_THREAD_ATTACH
Definition: compat.h:132
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
LPFN_SELECT pSelect
Definition: handle.c:32
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1029
#define CP_ACP
Definition: compat.h:109
static VOID APIENTRY Imm32FreeImeStates(LPINPUTCONTEXTDX pIC)
Definition: imm.c:615
BOOL APIENTRY Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:366
CANDIDATEFORM cfCandForm[4]
Definition: imm.h:39
LONG cLockObj
Definition: ntuser.h:1294
Definition: ntuser.h:190
HMODULE g_hImm32Inst
Definition: imm.c:17
LONG NTSTATUS
Definition: precomp.h:26
#define CALLBACK
Definition: compat.h:35
HWND hWnd
Definition: settings.c:17
#define ISC_SHOWUIGUIDELINE
Definition: imm.h:309
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:937
DWORD NTAPI NtUserNotifyIMEStatus(HWND hwnd, BOOL fOpen, DWORD dwConversion)
Definition: ime.c:52
HANDLE HWND
Definition: compat.h:19
#define WM_IME_SELECT
Definition: winuser.h:1816
BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags)
Definition: imm.c:539
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOL WINAPI ImmLoadIME(HKL hKL)
Definition: ime.c:803
static VOID APIENTRY Imm32CiceroSetActiveContext(HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL)
Definition: imm.c:489
BOOL APIENTRY Imm32InitContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
Definition: imm.c:708
static LONG cLocks
Definition: compobj.c:119
#define CLIENTIMC_UNKNOWN5
Definition: ntuser.h:1315
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HKL hOldKL
Definition: imm.c:424
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
WORD LANGID
Definition: typedefs.h:81
#define GetWin32ClientInfo()
Definition: ntuser.h:326
DWORD fdwConversion
Definition: imm.h:32
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
DWORD dwChange
Definition: imm.h:101
HIMCC hPrivate
Definition: imm.h:43
HIMC hImc
Definition: ntuser.h:710
BOOL fOpen
Definition: imm.h:29
DWORD dwSize
Definition: imm.h:205
static BOOL CALLBACK Imm32SelectLayoutProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:427
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define REGKEY_IMM
Definition: precomp.h:61
int Fail
Definition: ehthrow.cxx:24
BOOL WINAPI DestroyWindow(_In_ HWND)
#define INPUTCONTEXTDX_CHANGE_OPEN
Definition: imm.h:123
#define DWORD
Definition: nt_native.h:44
BOOL WINAPI ImmRegisterClient(PSHAREDINFO ptr, HINSTANCE hMod)
Definition: imm.c:44
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define CLIENTIMC_UNKNOWN2
Definition: ntuser.h:1319
#define INPUTCONTEXTDX_CHANGE_FORCE_OPEN
Definition: imm.h:126
BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL fActive)
Definition: imm.c:1135
BOOL WINAPI ImmDestroyContext(HIMC hIMC)
Definition: imm.c:886
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3929
#define CLIENTIMC_WIDE
Definition: ntuser.h:1314
#define INPUTCONTEXTDX_CHANGE_CONVERSION
Definition: imm.h:124
PIME_STATE APIENTRY Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL)
Definition: utils.c:324
#define MAX_IMCC_SIZE
#define QUERY_WINDOW_FOCUS
Definition: ntuser.h:2903
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define INIT_LOGFONT
Definition: imm.h:118
DWORD unknown
Definition: ntuser.h:1296
#define FALSE
Definition: types.h:117
DWORD dwSentence
Definition: imm.h:184
HIMCC hCandInfo
Definition: imm.h:41
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
struct SELECT_LAYOUT SELECT_LAYOUT
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
static BOOL CALLBACK Imm32NotifyCompStrProc(HIMC hIMC, LPARAM lParam)
Definition: imm.c:434
FxChildList * pList
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
Definition: imm.h:178
BOOL WINAPI ImmFreeLayout(DWORD dwUnknown)
Definition: imm.c:117
#define FIXME(fmt,...)
Definition: debug.h:111
static BOOL APIENTRY Imm32InitInstance(HMODULE hMod)
Definition: imm.c:22
static PVOID ptr
Definition: dispmode.c:27
BOOL WINAPI ImmSetActiveContextConsoleIME(HWND hwnd, BOOL fFlag)
Definition: imm.c:1230
LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect)
Definition: imm.c:802
#define MAKELONG(a, b)
Definition: typedefs.h:249
BOOL WINAPI User32InitializeImmEntryTable(DWORD)
Definition: imm.c:108
LONG_PTR LPARAM
Definition: windef.h:208
BOOL APIENTRY Imm32CleanupContext(HIMC hIMC, HKL hKL, BOOL bKeep)
Definition: imm.c:634
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
#define INPUTCONTEXTDX_CHANGE_SENTENCE
Definition: imm.h:125
DWORD HIMC
Definition: dimm.idl:75
#define CLIENTIMC_UNKNOWN1
Definition: ntuser.h:1317
UINT uCodePage
Definition: ntuser.h:1298
HIMC WINAPI ImmCreateContext(void)
Definition: imm.c:586
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
#define DLL_PROCESS_DETACH
Definition: compat.h:130
PSERVERINFO psi
Definition: ntuser.h:1088
#define MAX_CANDIDATEFORM
Definition: precomp.h:53
DWORD NTAPI NtUserUpdateInputContext(HIMC hIMC, DWORD Unknown1, LPVOID pClientImc)
Definition: ntstubs.c:351
HIMCC WINAPI ImmCreateIMCC(DWORD size)
Definition: utils.c:917
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
Definition: ime.c:648
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:144
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
struct tagCLIENTIMC * PCLIENTIMC
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
VOID APIENTRY Imm32SelectLayout(HKL hNewKL, HKL hOldKL, HIMC hIMC)
Definition: imm.c:181
DWORD fdwProperty
Definition: imm.h:158
#define WM_IME_SETCONTEXT
Definition: winuser.h:1812
#define _countof(array)
Definition: sndvol32.h:68
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1008
WORD fOpen
Definition: imm.h:182
BOOL NTAPI NtUserDestroyInputContext(HIMC hIMC)
Definition: ntstubs.c:429
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
#define MAX_PATH
Definition: compat.h:34
HANDLE hInputContext
Definition: ntuser.h:1293
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:132
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList)
Definition: utils.c:236
static HIMC APIENTRY Imm32GetContextEx(HWND hWnd, DWORD dwContextFlags)
Definition: imm.c:971
#define SetLastError(x)
Definition: compat.h:611
DWORD dwSize
Definition: imm.h:195
#define NT_ERROR(Status)
Definition: umtypes.h:106
#define CLIENTIMC_UNKNOWN3
Definition: ntuser.h:1318
#define ImeDpi_IsUnicode(pImeDpi)
Definition: precomp.h:113
static BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: precomp.h:98
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:947
int ret
struct tagCANDIDATEINFO CANDIDATEINFO
DWORD dwThreadId
Definition: fdebug.c:31
struct IMEDPI * pNext
Definition: ntuser.h:1240
HIMCC hMsgBuf
Definition: imm.h:45
DWORD dwPrivateDataSize
Definition: imm.h:157
static const WCHAR L[]
Definition: oid.c:1250
struct tagGUIDELINE GUIDELINE
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:310
#define InterlockedDecrement
Definition: armddk.h:52
HIMCC hCompStr
Definition: imm.h:40
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1297
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
PIMEDPI g_pImeDpiList
Definition: ime.c:18
#define CPS_CANCEL
Definition: imm.h:318
#define LANGIDFROMLCID(l)
Definition: nls.h:18
PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
Definition: utils.c:171
SHAREDINFO g_SharedInfo
Definition: imm.c:19
WINE_DEFAULT_DEBUG_CHANNEL(imm)
UINT_PTR HKL
Definition: msctf.idl:101
HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:497
uint32_t DWORD_PTR
Definition: typedefs.h:65
BOOL WINAPI ImmDestroySoftKeyboard(HWND hSoftWnd)
Definition: imm.c:1078
unsigned char BYTE
Definition: xxhash.c:193
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1057
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:663
WCHAR wszImeFile[80]
Definition: ntuser.h:1178
PIME_SUBSTATE pSubState
Definition: imm.h:186
Definition: compat.h:694
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
Definition: ime.c:633
#define InterlockedIncrement
Definition: armddk.h:53
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
DWORD dwIndex
Definition: dimm.idl:79
BOOL APIENTRY Imm32ReleaseIME(HKL hKL)
Definition: ime.c:306
#define LHND
Definition: winbase.h:379
#define QUERY_WINDOW_DEFAULT_ICONTEXT
Definition: ntuser.h:2908
HWND WINAPI ImmCreateSoftKeyboard(UINT uType, UINT hOwner, int x, int y)
Definition: imm.c:1068
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
DWORD dwConversion
Definition: imm.h:183
#define CI_IMMACTIVATE
Definition: ntuser.h:288
#define IME_PROP_COMPLETE_ON_UNSELECT
Definition: imm.h:397
#define IMM_INVALID_CANDFORM
Definition: precomp.h:51
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
BOOL WINAPI ImmShowSoftKeyboard(HWND hSoftWnd, int nCmdShow)
Definition: imm.c:1087
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HIMCC hGuideLine
Definition: imm.h:42
HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size)
Definition: utils.c:965
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
HKL WINAPI LoadKeyboardLayoutW(_In_ LPCWSTR, _In_ UINT)
HWND pFocusWnd
Definition: magnifier.c:66
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
struct tagCOMPOSITIONSTRING COMPOSITIONSTRING
DWORD dwNumMsgBuf
Definition: imm.h:44
THRDESKHEAD head
Definition: ntuser.h:192
#define Imm32IsImmMode()
Definition: precomp.h:114
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
INT fLoadFlag
Definition: ntuser.h:1174
BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
Definition: utils.c:909
struct IME_STATE * pState
Definition: imm.h:100
DWORD fdwSentence
Definition: imm.h:33
struct SELECT_LAYOUT * LPSELECT_LAYOUT
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
Definition: utils.c:181
#define ISC_SHOWUIALL
Definition: imm.h:311
#define Imm32Is16BitMode()
Definition: precomp.h:116
struct IME_STATE * pNext
Definition: imm.h:180
DWORD dwFlags
Definition: ntuser.h:1295
DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc)
Definition: utils.c:957
HKL hNewKL
Definition: imm.c:423
BOOL(CALLBACK * IMCENUMPROC)(HIMC, LPARAM)
Definition: imm.h:147
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define IMM_INIT_MAGIC
Definition: imm.c:17
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL)
Definition: ime.c:281
BOOL APIENTRY Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:378
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define ISC_SHOWUIALLCANDIDATEWINDOW
Definition: imm.h:310
static BOOL Imm32IsCrossProcessAccess(HWND hWnd)
Definition: precomp.h:105
BOOL WINAPI ImmActivateLayout(HKL hKL)
Definition: imm.c:443
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define NI_COMPOSITIONSTR
Definition: imm.h:301
#define CLIENTIMC_UNKNOWN4
Definition: ntuser.h:1316
static SERVICE_STATUS status
Definition: service.c:31
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1038
LPARAM lParam
Definition: combotst.c:139
#define Imm32IsCiceroMode()
Definition: precomp.h:115
#define LOWORD(l)
Definition: pedump.c:82
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
Definition: imm.c:1243
struct IME_SUBSTATE * pNext
Definition: imm.h:169
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:660
#define IME_CMODE_EUDC
Definition: imm.h:502
#define APIENTRY
Definition: api.h:79
BOOL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
Definition: imm.c:54
BYTE g_bClientRegd
Definition: imm.c:20
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
Definition: ps.c:97
HKL hKL
Definition: ntuser.h:1242