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