ReactOS  0.4.15-dev-3303-g1ade494
utils.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 IMM32 helper functions
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 
18 
20 Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
21 {
22 #if 1
26  Status = RtlUnicodeStringToInteger(&UnicodeString, nBase, pdwValue);
27  if (!NT_SUCCESS(Status))
28  return E_FAIL;
29  return S_OK;
30 #else
31  LPWSTR endptr;
32  *pdwValue = wcstoul(pszText, &endptr, nBase);
33  return (*endptr ? E_FAIL : S_OK);
34 #endif
35 }
36 
38 Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
39 {
40 #if 1
43  UnicodeString.Buffer = pszBuff;
44  UnicodeString.MaximumLength = cchBuff * sizeof(WCHAR);
46  if (!NT_SUCCESS(Status))
47  return E_FAIL;
48  return S_OK;
49 #else
50  LPCWSTR pszFormat;
51  if (nBase == 16)
52  pszFormat = L"%lX";
53  else if (nBase == 10)
54  pszFormat = L"%lu";
55  else
56  return E_INVALIDARG;
57  return StringCchPrintfW(pszBuff, cchBuff, pszFormat, dwValue);
58 #endif
59 }
60 
62 {
63  BOOL ret;
64  PCLIENTIMC pClientImc = ImmLockClientImc(hIMC);
65  if (!pClientImc)
66  return -1;
67  ret = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
68  ImmUnlockClientImc(pClientImc);
69  return ret;
70 }
71 
73 {
74  INT cch = lstrlenA(pszA);
75  LPWSTR pszW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
76  if (pszW == NULL)
77  return NULL;
78  cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszA, cch, pszW, cch + 1);
79  pszW[cch] = 0;
80  return pszW;
81 }
82 
84 {
85  INT cchW = lstrlenW(pszW);
86  INT cchA = (cchW + 1) * sizeof(WCHAR);
87  LPSTR pszA = Imm32HeapAlloc(0, cchA);
88  if (!pszA)
89  return NULL;
90  cchA = WideCharToMultiByte(CP_ACP, 0, pszW, cchW, pszA, cchA, NULL, NULL);
91  pszA[cchA] = 0;
92  return pszA;
93 }
94 
95 /* Converts the character index */
96 LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
97 {
98  LONG cchWide;
99  for (cchWide = 0; cchAnsi > 0; ++cchWide)
100  {
101  if (IsDBCSLeadByteEx(uCodePage, *pchAnsi) && pchAnsi[1])
102  {
103  cchAnsi -= 2;
104  pchAnsi += 2;
105  }
106  else
107  {
108  --cchAnsi;
109  ++pchAnsi;
110  }
111  }
112  return cchWide;
113 }
114 
115 /* Converts the character index */
116 LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
117 {
118  LONG cb, cchAnsi;
119  for (cchAnsi = 0; cchWide > 0; ++cchAnsi, ++pchWide, --cchWide)
120  {
121  cb = WideCharToMultiByte(uCodePage, 0, pchWide, 1, NULL, 0, NULL, NULL);
122  if (cb > 1)
123  ++cchAnsi;
124  }
125  return cchAnsi;
126 }
127 
129 {
130  if (!pszFileName[0] || !GetSystemDirectoryW(pszPath, cchPath))
131  return FALSE;
132  StringCchCatW(pszPath, cchPath, L"\\");
133  StringCchCatW(pszPath, cchPath, pszFileName);
134  return TRUE;
135 }
136 
138 {
139  size_t cch;
140  RtlCopyMemory(plfW, plfA, offsetof(LOGFONTA, lfFaceName));
143  plfW->lfFaceName, _countof(plfW->lfFaceName));
144  if (cch > _countof(plfW->lfFaceName) - 1)
145  cch = _countof(plfW->lfFaceName) - 1;
146  plfW->lfFaceName[cch] = 0;
147 }
148 
150 {
151  size_t cch;
152  RtlCopyMemory(plfA, plfW, offsetof(LOGFONTW, lfFaceName));
155  plfA->lfFaceName, _countof(plfA->lfFaceName), NULL, NULL);
156  if (cch > _countof(plfA->lfFaceName) - 1)
157  cch = _countof(plfA->lfFaceName) - 1;
158  plfA->lfFaceName[cch] = 0;
159 }
160 
162 {
163  INT index;
167 
168  if (!NtUserValidateHandleSecure(hObject))
169  return NULL;
170 
171  ht = g_SharedInfo.aheList; /* handle table */
172  ASSERT(ht);
173  /* ReactOS-Specific! */
176 
177  index = (LOWORD(hObject) - FIRST_USER_HANDLE) >> 1;
178  if (index < 0 || ht->nb_handles <= index || he[index].type != uType)
179  return NULL;
180 
181  generation = HIWORD(hObject);
182  if (generation != he[index].generation && generation && generation != 0xFFFF)
183  return NULL;
184 
185  return &he[index];
186 }
187 
189 {
190  /* See if the window is cached */
192  if (hwnd == ClientInfo->CallbackWnd.hWnd)
193  return ClientInfo->CallbackWnd.pWnd;
194 
196 }
197 
199 {
200  HIMC hIMC;
201  DWORD dwProcessID;
202  if (pIMC->head.pti == NtCurrentTeb()->Win32ThreadInfo)
203  return TRUE;
204 
205  hIMC = pIMC->head.h;
206  dwProcessID = NtUserQueryInputContext(hIMC, 0);
207  return dwProcessID == (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
208 }
209 
211 {
212  if (!g_hImm32Heap)
213  {
214  g_hImm32Heap = RtlGetProcessHeap();
215  if (g_hImm32Heap == NULL)
216  return NULL;
217  }
218  return HeapAlloc(g_hImm32Heap, dwFlags, dwBytes);
219 }
220 
222 Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue,
223  DWORD_PTR dwCommand, DWORD_PTR dwData)
224 {
226  HKL hKL;
227  PIMEDPI pImeDpi;
228 
229  if (dwAction)
230  {
232  if (dwThreadId)
233  {
234  /* find keyboard layout and lock it */
236  pImeDpi = ImmLockImeDpi(hKL);
237  if (pImeDpi)
238  {
239  /* do notify */
240  pImeDpi->NotifyIME(hIMC, dwAction, dwIndex, dwValue);
241 
242  ImmUnlockImeDpi(pImeDpi); /* unlock */
243  }
244  }
245  }
246 
247  if (hwnd && dwCommand)
248  SendMessageW(hwnd, WM_IME_NOTIFY, dwCommand, dwData);
249 
250  return TRUE;
251 }
252 
254 {
255 #define INITIAL_COUNT 0x40
256 #define MAX_RETRY 10
258  DWORD dwCount = INITIAL_COUNT, cRetry = 0;
259  HIMC *phNewList;
260 
261  phNewList = Imm32HeapAlloc(0, dwCount * sizeof(HIMC));
262  if (phNewList == NULL)
263  return 0;
264 
265  Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
267  {
268  Imm32HeapFree(phNewList);
269  if (cRetry++ >= MAX_RETRY)
270  return 0;
271 
272  phNewList = Imm32HeapAlloc(0, dwCount * sizeof(HIMC));
273  if (phNewList == NULL)
274  return 0;
275 
276  Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
277  }
278 
279  if (NT_ERROR(Status) || !dwCount)
280  {
281  Imm32HeapFree(phNewList);
282  return 0;
283  }
284 
285  *pphList = phNewList;
286  return dwCount;
287 #undef INITIAL_COUNT
288 #undef MAX_RETRY
289 }
290 
293  UINT uCodePage, BOOL bBitmap)
294 {
295  INT ret;
296  pItemW->cbSize = pItemA->cbSize;
297  pItemW->fType = pItemA->fType;
298  pItemW->fState = pItemA->fState;
299  pItemW->wID = pItemA->wID;
300  if (bBitmap)
301  {
302  pItemW->hbmpChecked = pItemA->hbmpChecked;
303  pItemW->hbmpUnchecked = pItemA->hbmpUnchecked;
304  pItemW->hbmpItem = pItemA->hbmpItem;
305  }
306  pItemW->dwItemData = pItemA->dwItemData;
307  ret = MultiByteToWideChar(uCodePage, 0, pItemA->szString, -1,
308  pItemW->szString, _countof(pItemW->szString));
309  if (ret >= _countof(pItemW->szString))
310  {
311  ret = 0;
312  pItemW->szString[0] = 0;
313  }
314  return ret;
315 }
316 
319  UINT uCodePage)
320 {
321  INT ret;
322  pItemA->cbSize = pItemW->cbSize;
323  pItemA->fType = pItemW->fType;
324  pItemA->fState = pItemW->fState;
325  pItemA->wID = pItemW->wID;
326  pItemA->hbmpChecked = pItemW->hbmpChecked;
327  pItemA->hbmpUnchecked = pItemW->hbmpUnchecked;
328  pItemA->dwItemData = pItemW->dwItemData;
329  pItemA->hbmpItem = pItemW->hbmpItem;
330  ret = WideCharToMultiByte(uCodePage, 0, pItemW->szString, -1,
331  pItemA->szString, _countof(pItemA->szString), NULL, NULL);
332  if (ret >= _countof(pItemA->szString))
333  {
334  ret = 0;
335  pItemA->szString[0] = 0;
336  }
337  return ret;
338 }
339 
342 {
343  PIME_STATE pState;
344  WORD Lang = PRIMARYLANGID(LOWORD(hKL));
345  for (pState = pIC->pState; pState; pState = pState->pNext)
346  {
347  if (pState->wLang == Lang)
348  break;
349  }
350  if (!pState)
351  {
352  pState = Imm32HeapAlloc(HEAP_ZERO_MEMORY, sizeof(IME_STATE));
353  if (pState)
354  {
355  pState->wLang = Lang;
356  pState->pNext = pIC->pState;
357  pIC->pState = pState;
358  }
359  }
360  return pState;
361 }
362 
365 {
366  PIME_SUBSTATE pSubState;
367  for (pSubState = pState->pSubState; pSubState; pSubState = pSubState->pNext)
368  {
369  if (pSubState->hKL == hKL)
370  return pSubState;
371  }
372  pSubState = Imm32HeapAlloc(0, sizeof(IME_SUBSTATE));
373  if (!pSubState)
374  return NULL;
375  pSubState->dwValue = 0;
376  pSubState->hKL = hKL;
377  pSubState->pNext = pState->pSubState;
378  pState->pSubState = pSubState;
379  return pSubState;
380 }
381 
384 {
385  PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
386  if (pSubState)
387  {
388  pIC->fdwSentence |= pSubState->dwValue;
389  return TRUE;
390  }
391  return FALSE;
392 }
393 
396 {
397  PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
398  if (pSubState)
399  {
400  pSubState->dwValue = (pIC->fdwSentence & 0xffff0000);
401  return TRUE;
402  }
403  return FALSE;
404 }
405 
406 /*
407  * See RECONVERTSTRING structure:
408  * https://katahiromz.web.fc2.com/colony3rd/imehackerz/en/RECONVERTSTRING.html
409  *
410  * The dwCompStrOffset and dwTargetOffset members are the relative position of dwStrOffset.
411  * dwStrLen, dwCompStrLen, and dwTargetStrLen are the TCHAR count. dwStrOffset,
412  * dwCompStrOffset, and dwTargetStrOffset are the byte offset.
413  */
414 
417 {
418  DWORD cch0, cchDest, cbDest;
419  LPCSTR pchSrc = (LPCSTR)pSrc + pSrc->dwStrOffset;
420  LPWSTR pchDest;
421 
422  if (pSrc->dwVersion != 0)
423  return 0;
424 
425  cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
426  NULL, 0);
427  cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(WCHAR);
428  if (!pDest)
429  return cbDest;
430 
431  if (pDest->dwSize < cbDest)
432  return 0;
433 
434  /* dwSize */
435  pDest->dwSize = cbDest;
436 
437  /* dwVersion */
438  pDest->dwVersion = 0;
439 
440  /* dwStrOffset */
441  pDest->dwStrOffset = sizeof(RECONVERTSTRING);
442 
443  /* dwCompStrOffset */
444  cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset, pchSrc, uCodePage);
445  pDest->dwCompStrOffset = cch0 * sizeof(WCHAR);
446 
447  /* dwCompStrLen */
448  cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset + pSrc->dwCompStrLen, pchSrc, uCodePage);
449  pDest->dwCompStrLen = (cch0 * sizeof(WCHAR) - pDest->dwCompStrOffset) / sizeof(WCHAR);
450 
451  /* dwTargetStrOffset */
452  cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset, pchSrc, uCodePage);
453  pDest->dwTargetStrOffset = cch0 * sizeof(WCHAR);
454 
455  /* dwTargetStrLen */
456  cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset + pSrc->dwTargetStrLen, pchSrc, uCodePage);
457  pDest->dwTargetStrLen = (cch0 * sizeof(WCHAR) - pSrc->dwTargetStrOffset) / sizeof(WCHAR);
458 
459  /* dwStrLen */
460  pDest->dwStrLen = cchDest;
461 
462  /* the string */
463  pchDest = (LPWSTR)((LPBYTE)pDest + pDest->dwStrOffset);
464  cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
465  pchDest, cchDest);
466  pchDest[cchDest] = 0;
467 
468  return cbDest;
469 }
470 
473 {
474  DWORD cch0, cch1, cchDest, cbDest;
475  LPCWSTR pchSrc = (LPCWSTR)((LPCSTR)pSrc + pSrc->dwStrOffset);
476  LPSTR pchDest;
477 
478  if (pSrc->dwVersion != 0)
479  return 0;
480 
481  cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
482  NULL, 0, NULL, NULL);
483  cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(CHAR);
484  if (!pDest)
485  return cbDest;
486 
487  if (pDest->dwSize < cbDest)
488  return 0;
489 
490  /* dwSize */
491  pDest->dwSize = cbDest;
492 
493  /* dwVersion */
494  pDest->dwVersion = 0;
495 
496  /* dwStrOffset */
497  pDest->dwStrOffset = sizeof(RECONVERTSTRING);
498 
499  /* dwCompStrOffset */
500  cch1 = pSrc->dwCompStrOffset / sizeof(WCHAR);
501  cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
502  pDest->dwCompStrOffset = cch0 * sizeof(CHAR);
503 
504  /* dwCompStrLen */
505  cch0 = IchAnsiFromWide(cch1 + pSrc->dwCompStrLen, pchSrc, uCodePage);
506  pDest->dwCompStrLen = cch0 * sizeof(CHAR) - pDest->dwCompStrOffset;
507 
508  /* dwTargetStrOffset */
509  cch1 = pSrc->dwTargetStrOffset / sizeof(WCHAR);
510  cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
511  pDest->dwTargetStrOffset = cch0 * sizeof(CHAR);
512 
513  /* dwTargetStrLen */
514  cch0 = IchAnsiFromWide(cch1 + pSrc->dwTargetStrLen, pchSrc, uCodePage);
515  pDest->dwTargetStrLen = cch0 * sizeof(CHAR) - pDest->dwTargetStrOffset;
516 
517  /* dwStrLen */
518  pDest->dwStrLen = cchDest;
519 
520  /* the string */
521  pchDest = (LPSTR)pDest + pDest->dwStrOffset;
522  cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
523  pchDest, cchDest, NULL, NULL);
524  pchDest[cchDest] = 0;
525 
526  return cbDest;
527 }
528 
532 
536 
538 {
539  UINT cbFixed = 0;
540  VS_FIXEDFILEINFO *pFixed;
541  if (!s_fnVerQueryValueW(pVerInfo, L"\\", (LPVOID*)&pFixed, &cbFixed) || !cbFixed)
542  return FALSE;
543 
544  /* NOTE: The IME module must contain a version info of input method driver. */
545  if (pFixed->dwFileType != VFT_DRV || pFixed->dwFileSubtype != VFT2_DRV_INPUTMETHOD)
546  return FALSE;
547 
548  pInfoEx->dwProdVersion = pFixed->dwProductVersionMS;
549  pInfoEx->dwImeWinVersion = 0x40000;
550  return TRUE;
551 }
552 
553 static LPWSTR APIENTRY
554 Imm32GetVerInfoValue(LPCVOID pVerInfo, LPWSTR pszKey, DWORD cchKey, LPCWSTR pszName)
555 {
556  size_t cchExtra;
557  LPWSTR pszValue;
558  UINT cbValue = 0;
559 
560  StringCchLengthW(pszKey, cchKey, &cchExtra);
561 
562  StringCchCatW(pszKey, cchKey, pszName);
563  s_fnVerQueryValueW(pVerInfo, pszKey, (LPVOID*)&pszValue, &cbValue);
564  pszKey[cchExtra] = 0;
565 
566  return (cbValue ? pszValue : NULL);
567 }
568 
570 {
571  BOOL ret;
572  WCHAR szKey[80];
573  LPWSTR pszDesc;
574  LPWORD pw;
575  UINT cbData;
576  LANGID LangID;
577 
578  /* Getting the version info. See VerQueryValue */
579  ret = s_fnVerQueryValueW(pVerInfo, L"\\VarFileInfo\\Translation", (LPVOID*)&pw, &cbData);
580  if (!ret || !cbData)
581  return FALSE;
582 
583  if (pInfoEx->hkl == NULL)
584  pInfoEx->hkl = (HKL)(DWORD_PTR)*pw; /* This is an invalid HKL */
585 
586  /* Try the current language and the Unicode codepage (0x04B0) */
588  StringCchPrintfW(szKey, _countof(szKey), L"\\StringFileInfo\\%04X04B0\\", LangID);
589  pszDesc = Imm32GetVerInfoValue(pVerInfo, szKey, _countof(szKey), L"FileDescription");
590  if (!pszDesc)
591  {
592  /* Retry the language and codepage of the IME module */
593  StringCchPrintfW(szKey, _countof(szKey), L"\\StringFileInfo\\%04X%04X\\", pw[0], pw[1]);
594  pszDesc = Imm32GetVerInfoValue(pVerInfo, szKey, _countof(szKey), L"FileDescription");
595  }
596 
597  /* The description */
598  if (pszDesc)
599  StringCchCopyW(pInfoEx->wszImeDescription, _countof(pInfoEx->wszImeDescription), pszDesc);
600  else
601  pInfoEx->wszImeDescription[0] = 0;
602 
603  return TRUE;
604 }
605 
607 {
608  HINSTANCE hinstVersion;
609  BOOL ret = FALSE, bLoaded = FALSE;
611  LPVOID pVerInfo;
612  DWORD cbVerInfo, dwHandle;
613 
614  /* Load version.dll to use the version info API */
616  hinstVersion = GetModuleHandleW(szPath);
617  if (!hinstVersion)
618  {
619  hinstVersion = LoadLibraryW(szPath);
620  if (!hinstVersion)
621  return FALSE;
622  bLoaded = TRUE;
623  }
624 
625 #define GET_FN(name) do { \
626  s_fn##name = (FN_##name)GetProcAddress(hinstVersion, #name); \
627  if (!s_fn##name) goto Quit; \
628 } while (0)
632 #undef GET_FN
633 
634  /* The path of the IME module */
636 
637  cbVerInfo = s_fnGetFileVersionInfoSizeW(szPath, &dwHandle);
638  if (!cbVerInfo)
639  goto Quit;
640 
641  pVerInfo = Imm32HeapAlloc(0, cbVerInfo);
642  if (!pVerInfo)
643  goto Quit;
644 
645  /* Load the version info of the IME module */
646  if (s_fnGetFileVersionInfoW(szPath, dwHandle, cbVerInfo, pVerInfo) &&
647  Imm32LoadImeFixedInfo(pImeInfoEx, pVerInfo))
648  {
649  ret = Imm32LoadImeLangAndDesc(pImeInfoEx, pVerInfo);
650  }
651 
652  Imm32HeapFree(pVerInfo);
653 
654 Quit:
655  if (bLoaded)
656  FreeLibrary(hinstVersion);
657  return ret;
658 }
659 
660 HKL APIENTRY Imm32GetNextHKL(UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
661 {
662  UINT iKL, wID, wLow = 0xE0FF, wHigh = 0xE01F, wNextID = 0;
663 
664  for (iKL = 0; iKL < cKLs; ++iKL)
665  {
666  wHigh = max(wHigh, HIWORD(pLayouts[iKL].hKL));
667  wLow = min(wLow, HIWORD(pLayouts[iKL].hKL));
668  }
669 
670  if (wHigh < 0xE0FF)
671  {
672  wNextID = wHigh + 1;
673  }
674  else if (wLow > 0xE001)
675  {
676  wNextID = wLow - 1;
677  }
678  else
679  {
680  for (wID = 0xE020; wID <= 0xE0FF; ++wID)
681  {
682  for (iKL = 0; iKL < cKLs; ++iKL)
683  {
684  if (LOWORD(pLayouts[iKL].hKL) == wLangID &&
685  HIWORD(pLayouts[iKL].hKL) == wID)
686  {
687  break;
688  }
689  }
690 
691  if (iKL >= cKLs)
692  break;
693  }
694 
695  if (wID <= 0xE0FF)
696  wNextID = wID;
697  }
698 
699  if (!wNextID)
700  return NULL;
701 
702  return (HKL)(DWORD_PTR)MAKELONG(wLangID, wNextID);
703 }
704 
706 {
707  HKEY hkeyLayouts, hkeyIME;
708  WCHAR szImeFileName[80], szImeKey[20];
709  UINT iKey, nCount;
710  DWORD cbData;
711  LONG lError;
712  ULONG Value;
713  HKL hKL;
714 
715  /* Open the registry keyboard layouts */
716  lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
717  if (lError != ERROR_SUCCESS)
718  return 0;
719 
720  for (iKey = nCount = 0; ; ++iKey)
721  {
722  /* Get the key name */
723  lError = RegEnumKeyW(hkeyLayouts, iKey, szImeKey, _countof(szImeKey));
724  if (lError != ERROR_SUCCESS)
725  break;
726 
727  if (szImeKey[0] != L'E' && szImeKey[0] != L'e')
728  continue; /* Not an IME layout */
729 
730  if (pLayouts == NULL) /* for counting only */
731  {
732  ++nCount;
733  continue;
734  }
735 
736  if (cLayouts <= nCount)
737  break;
738 
739  lError = RegOpenKeyW(hkeyLayouts, szImeKey, &hkeyIME); /* Open the IME key */
740  if (lError != ERROR_SUCCESS)
741  break;
742 
743  /* Load the "Ime File" value */
744  szImeFileName[0] = 0;
745  cbData = sizeof(szImeFileName);
746  RegQueryValueExW(hkeyIME, L"Ime File", NULL, NULL, (LPBYTE)szImeFileName, &cbData);
747  szImeFileName[_countof(szImeFileName) - 1] = 0;
748 
749  RegCloseKey(hkeyIME);
750 
751  if (!szImeFileName[0])
752  break;
753 
754  Imm32StrToUInt(szImeKey, &Value, 16);
755  hKL = (HKL)(DWORD_PTR)Value;
756  if (!IS_IME_HKL(hKL))
757  break;
758 
759  /* Store the IME key and the IME filename */
760  pLayouts[nCount].hKL = hKL;
761  StringCchCopyW(pLayouts[nCount].szImeKey, _countof(pLayouts[nCount].szImeKey), szImeKey);
762  CharUpperW(szImeFileName);
763  StringCchCopyW(pLayouts[nCount].szFileName, _countof(pLayouts[nCount].szFileName),
764  szImeFileName);
765  ++nCount;
766  }
767 
768  RegCloseKey(hkeyLayouts);
769  return nCount;
770 }
771 
772 BOOL APIENTRY Imm32WriteRegIme(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout)
773 {
774  UINT iPreload;
775  HKEY hkeyLayouts, hkeyIME, hkeyPreload;
776  WCHAR szImeKey[20], szPreloadNumber[20], szPreloadKey[20], szImeFileName[80];
777  DWORD cbData;
778  LANGID LangID;
779  LONG lError;
780  LPCWSTR pszLayoutFile;
781 
782  /* Open the registry keyboard layouts */
783  lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
784  if (lError != ERROR_SUCCESS)
785  return FALSE;
786 
787  /* Get the IME key from hKL */
788  Imm32UIntToStr((DWORD)(DWORD_PTR)hKL, 16, szImeKey, _countof(szImeKey));
789 
790  /* Create a registry IME key */
791  lError = RegCreateKeyW(hkeyLayouts, szImeKey, &hkeyIME);
792  if (lError != ERROR_SUCCESS)
793  goto Failure;
794 
795  /* Write "Ime File" */
796  cbData = (wcslen(pchFilePart) + 1) * sizeof(WCHAR);
797  lError = RegSetValueExW(hkeyIME, L"Ime File", 0, REG_SZ, (LPBYTE)pchFilePart, cbData);
798  if (lError != ERROR_SUCCESS)
799  goto Failure;
800 
801  /* Write "Layout Text" */
802  cbData = (wcslen(pszLayout) + 1) * sizeof(WCHAR);
803  lError = RegSetValueExW(hkeyIME, L"Layout Text", 0, REG_SZ, (LPBYTE)pszLayout, cbData);
804  if (lError != ERROR_SUCCESS)
805  goto Failure;
806 
807  /* Choose "Layout File" from hKL */
808  LangID = LOWORD(hKL);
809  switch (LOBYTE(LangID))
810  {
811  case LANG_JAPANESE: pszLayoutFile = L"kbdjpn.dll"; break;
812  case LANG_KOREAN: pszLayoutFile = L"kbdkor.dll"; break;
813  default: pszLayoutFile = L"kbdus.dll"; break;
814  }
815  StringCchCopyW(szImeFileName, _countof(szImeFileName), pszLayoutFile);
816 
817  /* Write "Layout File" */
818  cbData = (wcslen(szImeFileName) + 1) * sizeof(WCHAR);
819  lError = RegSetValueExW(hkeyIME, L"Layout File", 0, REG_SZ, (LPBYTE)szImeFileName, cbData);
820  if (lError != ERROR_SUCCESS)
821  goto Failure;
822 
823  RegCloseKey(hkeyIME);
824  RegCloseKey(hkeyLayouts);
825 
826  /* Create "Preload" key */
827  RegCreateKeyW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", &hkeyPreload);
828 
829 #define MAX_PRELOAD 0x400
830  for (iPreload = 1; iPreload < MAX_PRELOAD; ++iPreload)
831  {
832  Imm32UIntToStr(iPreload, 10, szPreloadNumber, _countof(szPreloadNumber));
833 
834  /* Load the key of the preload number */
835  cbData = sizeof(szPreloadKey);
836  lError = RegQueryValueExW(hkeyPreload, szPreloadNumber, NULL, NULL,
837  (LPBYTE)szPreloadKey, &cbData);
838  szPreloadKey[_countof(szPreloadKey) - 1] = 0;
839 
840  if (lError != ERROR_SUCCESS || lstrcmpiW(szImeKey, szPreloadKey) == 0)
841  break; /* Found an empty room or the same key */
842  }
843 
844  if (iPreload >= MAX_PRELOAD) /* Not found */
845  {
846  RegCloseKey(hkeyPreload);
847  return FALSE;
848  }
849 #undef MAX_PRELOAD
850 
851  /* Write the IME key to the preload number */
852  cbData = (wcslen(szImeKey) + 1) * sizeof(WCHAR);
853  lError = RegSetValueExW(hkeyPreload, szPreloadNumber, 0, REG_SZ, (LPBYTE)szImeKey, cbData);
854  RegCloseKey(hkeyPreload);
855  return lError == ERROR_SUCCESS;
856 
857 Failure:
858  RegCloseKey(hkeyIME);
859  RegDeleteKeyW(hkeyLayouts, szImeKey);
860  RegCloseKey(hkeyLayouts);
861  return FALSE;
862 }
863 
865 typedef LONG (WINAPI *FN_LZCopy)(INT, INT);
866 typedef VOID (WINAPI *FN_LZClose)(INT);
867 
868 BOOL APIENTRY Imm32CopyFile(LPWSTR pszOldFile, LPCWSTR pszNewFile)
869 {
870  BOOL ret = FALSE, bLoaded = FALSE;
871  HMODULE hinstLZ32;
872  WCHAR szLZ32Path[MAX_PATH];
873  CHAR szDestA[MAX_PATH];
874  OFSTRUCT OFStruct;
875  FN_LZOpenFileW fnLZOpenFileW;
876  FN_LZCopy fnLZCopy;
877  FN_LZClose fnLZClose;
878  HFILE hfDest, hfSrc;
879 
880  /* Load LZ32.dll for copying/decompressing file */
881  Imm32GetSystemLibraryPath(szLZ32Path, _countof(szLZ32Path), L"LZ32");
882  hinstLZ32 = GetModuleHandleW(szLZ32Path);
883  if (!hinstLZ32)
884  {
885  hinstLZ32 = LoadLibraryW(szLZ32Path);
886  if (!hinstLZ32)
887  return FALSE;
888  bLoaded = TRUE;
889  }
890 
891 #define GET_FN(name) do { \
892  fn##name = (FN_##name)GetProcAddress(hinstLZ32, #name); \
893  if (!fn##name) goto Quit; \
894 } while (0)
896  GET_FN(LZCopy);
897  GET_FN(LZClose);
898 #undef GET_FN
899 
900  if (!WideCharToMultiByte(CP_ACP, 0, pszNewFile, -1, szDestA, _countof(szDestA), NULL, NULL))
901  goto Quit;
902  szDestA[_countof(szDestA) - 1] = 0;
903 
904  hfSrc = fnLZOpenFileW(pszOldFile, &OFStruct, OF_READ);
905  if (hfSrc < 0)
906  goto Quit;
907 
908  hfDest = OpenFile(szDestA, &OFStruct, OF_CREATE);
909  if (hfDest != HFILE_ERROR)
910  {
911  ret = (fnLZCopy(hfSrc, hfDest) >= 0);
912  _lclose(hfDest);
913  }
914 
915  fnLZClose(hfSrc);
916 
917 Quit:
918  if (bLoaded)
919  FreeLibrary(hinstLZ32);
920  return ret;
921 }
922 
923 /***********************************************************************
924  * CtfImmIsTextFrameServiceDisabled(IMM32.@)
925  */
927 {
928  return !!(GetWin32ClientInfo()->CI_flags & CI_TFSDISABLED);
929 }
930 
931 /***********************************************************************
932  * ImmCreateIMCC(IMM32.@)
933  */
935 {
936  if (size < sizeof(DWORD))
937  size = sizeof(DWORD);
938  return LocalAlloc(LHND, size);
939 }
940 
941 /***********************************************************************
942  * ImmDestroyIMCC(IMM32.@)
943  */
945 {
946  if (block)
947  return LocalFree(block);
948  return NULL;
949 }
950 
951 /***********************************************************************
952  * ImmLockIMCC(IMM32.@)
953  */
955 {
956  if (imcc)
957  return LocalLock(imcc);
958  return NULL;
959 }
960 
961 /***********************************************************************
962  * ImmUnlockIMCC(IMM32.@)
963  */
965 {
966  if (imcc)
967  return LocalUnlock(imcc);
968  return FALSE;
969 }
970 
971 /***********************************************************************
972  * ImmGetIMCCLockCount(IMM32.@)
973  */
975 {
976  return LocalFlags(imcc) & LMEM_LOCKCOUNT;
977 }
978 
979 /***********************************************************************
980  * ImmReSizeIMCC(IMM32.@)
981  */
983 {
984  if (!imcc)
985  return NULL;
986  return LocalReAlloc(imcc, size, LHND);
987 }
988 
989 /***********************************************************************
990  * ImmGetIMCCSize(IMM32.@)
991  */
993 {
994  if (imcc)
995  return LocalSize(imcc);
996  return 0;
997 }
998 
999 /***********************************************************************
1000  * ImmGetIMCLockCount(IMM32.@)
1001  */
1003 {
1004  DWORD ret;
1005  HANDLE hInputContext;
1006  PCLIENTIMC pClientImc;
1007 
1008  pClientImc = ImmLockClientImc(hIMC);
1009  if (pClientImc == NULL)
1010  return 0;
1011 
1012  ret = 0;
1013  hInputContext = pClientImc->hInputContext;
1014  if (hInputContext)
1015  ret = (LocalFlags(hInputContext) & LMEM_LOCKCOUNT);
1016 
1017  ImmUnlockClientImc(pClientImc);
1018  return ret;
1019 }
1020 
1021 /***********************************************************************
1022  * ImmIMPGetIMEA(IMM32.@)
1023  */
1025 {
1026  FIXME("(%p, %p)\n", hWnd, pImePro);
1027  return FALSE;
1028 }
1029 
1030 /***********************************************************************
1031  * ImmIMPGetIMEW(IMM32.@)
1032  */
1034 {
1035  FIXME("(%p, %p)\n", hWnd, pImePro);
1036  return FALSE;
1037 }
1038 
1039 /***********************************************************************
1040  * ImmIMPQueryIMEA(IMM32.@)
1041  */
1043 {
1044  FIXME("(%p)\n", pImePro);
1045  return FALSE;
1046 }
1047 
1048 /***********************************************************************
1049  * ImmIMPQueryIMEW(IMM32.@)
1050  */
1052 {
1053  FIXME("(%p)\n", pImePro);
1054  return FALSE;
1055 }
1056 
1057 /***********************************************************************
1058  * ImmIMPSetIMEA(IMM32.@)
1059  */
1061 {
1062  FIXME("(%p, %p)\n", hWnd, pImePro);
1063  return FALSE;
1064 }
1065 
1066 /***********************************************************************
1067  * ImmIMPSetIMEW(IMM32.@)
1068  */
1070 {
1071  FIXME("(%p, %p)\n", hWnd, pImePro);
1072  return FALSE;
1073 }
DWORD WINAPI ImmGetIMCCSize(HIMCC imcc)
Definition: utils.c:992
static unsigned int block
Definition: xmlmemory.c:118
DWORD HIMCC
Definition: dimm.idl:76
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:755
DWORD dwTargetStrOffset
Definition: imm.h:104
DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC)
Definition: utils.c:1002
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_IME_NOTIFY
Definition: winuser.h:1813
HANDLE g_hImm32Heap
Definition: utils.c:17
#define max(a, b)
Definition: svc.c:63
PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
Definition: utils.c:188
DWORD dwProdVersion
Definition: ntuser.h:1175
DWORD APIENTRY Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:416
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:364
#define OF_READ
Definition: winbase.h:116
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD_PTR
Definition: treelist.c:76
#define WideCharToMultiByte
Definition: compat.h:111
LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA)
Definition: utils.c:72
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
DWORD dwSize
Definition: imm.h:97
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
Definition: utils.c:944
#define LOBYTE(W)
Definition: jmemdos.c:487
BOOL APIENTRY Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:395
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
#define TRUE
Definition: types.h:120
BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC)
Definition: utils.c:61
DWORD dwCompStrOffset
Definition: imm.h:102
#define LMEM_LOCKCOUNT
Definition: winbase.h:376
#define CP_ACP
Definition: compat.h:109
HBITMAP hbmpChecked
Definition: imm.h:129
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
Definition: utils.c:20
NTSTATUS NTAPI NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCount)
Definition: ntstubs.c:56
Definition: ntuser.h:190
#define MAX_RETRY
LONG NTSTATUS
Definition: precomp.h:26
#define MB_PRECOMPOSED
Definition: winnls.h:281
#define INT
Definition: polytest.cpp:20
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
HWND hWnd
Definition: settings.c:17
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:954
static HANDLE ULONG_PTR dwData
Definition: file.c:35
DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList)
Definition: utils.c:253
#define VFT_DRV
Definition: verrsrc.h:77
WORD LANGID
Definition: typedefs.h:81
#define GetWin32ClientInfo()
Definition: ntuser.h:326
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
#define FIRST_USER_HANDLE
Definition: ntuser.h:10
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
BOOL(WINAPI * FN_VerQueryValueW)(LPCVOID, LPCWSTR, LPVOID *, PUINT)
Definition: utils.c:531
DWORD dwItemData
Definition: imm.h:131
HFILE WINAPI LZOpenFileW(LPWSTR fn, LPOFSTRUCT ofs, WORD mode)
Definition: lzexpand.c:585
HBITMAP hbmpChecked
Definition: dimm.idl:134
if(dx==0 &&dy==0)
Definition: linetemp.h:174
char * LPSTR
Definition: xmlstorage.h:182
HBITMAP hbmpUnchecked
Definition: imm.h:117
INT APIENTRY Imm32ImeMenuWideToAnsi(const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA, UINT uCodePage)
Definition: utils.c:318
DWORD dwVersion
Definition: imm.h:98
#define lstrlenW
Definition: compat.h:609
#define E_FAIL
Definition: ddrawi.h:102
#define BOOL
Definition: nt_native.h:43
#define FASTCALL
Definition: nt_native.h:50
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:161
DWORD APIENTRY Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:472
#define DWORD
Definition: nt_native.h:44
HKL hKL
Definition: precomp.h:67
int32_t INT
Definition: typedefs.h:58
int WINAPI _lclose(HFILE hFile)
Definition: lfile.c:138
LPWSTR WINAPI CharUpperW(_Inout_ LPWSTR)
CHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1894
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:132
uint32_t ULONG_PTR
Definition: typedefs.h:65
void WINAPI LZClose(HFILE fd)
Definition: lzexpand.c:600
DWORD dwCompStrLen
Definition: imm.h:101
BOOL APIENTRY Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:383
CLIENT_DATA ClientInfo
HBITMAP hbmpUnchecked
Definition: dimm.idl:123
#define CLIENTIMC_WIDE
Definition: ntuser.h:1314
BOOL WINAPI IsDBCSLeadByteEx(UINT CodePage, BYTE TestByte)
Definition: nls.c:2210
HBITMAP hbmpUnchecked
Definition: dimm.idl:135
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define HFILE_ERROR
Definition: winbase.h:111
unsigned char * LPBYTE
Definition: typedefs.h:53
#define LANG_JAPANESE
Definition: nls.h:76
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Definition: utils.c:606
BOOL WINAPI ImmIMPQueryIMEW(LPIMEPROW pImePro)
Definition: utils.c:1051
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
Definition: imm.h:178
WORD wLang
Definition: imm.h:181
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
BOOL WINAPI ImmIMPSetIMEA(HWND hWnd, LPIMEPROA pImePro)
Definition: utils.c:1060
struct _OFSTRUCT * LPOFSTRUCT
#define FIXME(fmt,...)
Definition: debug.h:111
PIME_STATE APIENTRY Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL)
Definition: utils.c:341
INT(WINAPI * FN_LZOpenFileW)(LPWSTR, LPOFSTRUCT, WORD)
Definition: utils.c:864
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
LONG(WINAPI * FN_LZCopy)(INT, INT)
Definition: utils.c:865
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:96
#define E_INVALIDARG
Definition: ddrawi.h:101
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define LoadLibraryW(x)
Definition: compat.h:606
#define offsetof(TYPE, MEMBER)
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
GLuint index
Definition: glext.h:6031
struct tagRECONVERTSTRING RECONVERTSTRING
const char * LPCSTR
Definition: xmlstorage.h:183
DWORD HIMC
Definition: dimm.idl:75
BOOL NTAPI NtUserValidateHandleSecure(HANDLE hHdl)
Definition: object.c:758
static FN_GetFileVersionInfoSizeW s_fnGetFileVersionInfoSizeW
Definition: utils.c:534
DWORD dwItemData
Definition: dimm.idl:136
BOOL APIENTRY Imm32WriteRegIme(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout)
Definition: utils.c:772
VOID(WINAPI * FN_LZClose)(INT)
Definition: utils.c:866
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
DWORD dwItemData
Definition: imm.h:118
Status
Definition: gdiplustypes.h:24
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle)
Definition: create.c:368
Definition: ntuser.h:16
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
#define CI_TFSDISABLED
Definition: ntuser.h:289
struct _USER_HANDLE_ENTRY * PUSER_HANDLE_ENTRY
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
HIMCC WINAPI ImmCreateIMCC(DWORD size)
Definition: utils.c:934
#define FreeLibrary(x)
Definition: compat.h:607
HBITMAP hbmpItem
Definition: dimm.idl:138
GLsizeiptr size
Definition: glext.h:5919
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
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
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:137
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
#define MAX_PATH
Definition: compat.h:34
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:38
DWORD dwStrLen
Definition: imm.h:99
HANDLE hInputContext
Definition: ntuser.h:1293
#define WINAPI
Definition: msvc.h:6
DWORD(WINAPI * FN_GetFileVersionInfoSizeW)(LPCWSTR, LPDWORD)
Definition: utils.c:530
BOOL WINAPI ImmIMPGetIMEW(HWND hWnd, LPIMEPROW pImePro)
Definition: utils.c:1033
static BOOL APIENTRY Imm32LoadImeFixedInfo(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:537
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GET_FN(name)
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler)
#define NT_ERROR(Status)
Definition: umtypes.h:106
UINT APIENTRY Imm32GetRegImes(PREG_IME pLayouts, UINT cLayouts)
Definition: utils.c:705
#define LPVOID
Definition: nt_native.h:45
HBITMAP hbmpChecked
Definition: imm.h:116
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:964
int ret
DWORD dwThreadId
Definition: fdebug.c:31
LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW)
Definition: utils.c:83
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:210
#define LPDWORD
Definition: nt_native.h:46
#define index(s, c)
Definition: various.h:29
static const WCHAR L[]
Definition: oid.c:1250
#define MAX_PRELOAD
BOOL WINAPI ImmIMPSetIMEW(HWND hWnd, LPIMEPROW pImePro)
Definition: utils.c:1069
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
DWORD dwItemData
Definition: dimm.idl:124
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:128
#define VOID
Definition: acefi.h:82
static FN_GetFileVersionInfoW s_fnGetFileVersionInfoW
Definition: utils.c:533
#define LANGIDFROMLCID(l)
Definition: nls.h:18
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
HBITMAP hbmpItem
Definition: imm.h:120
SHAREDINFO g_SharedInfo
Definition: imm.c:19
UINT_PTR HKL
Definition: msctf.idl:101
ULONG_PTR ulSharedDelta
Definition: ntuser.h:1091
uint32_t DWORD_PTR
Definition: typedefs.h:65
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:119
DWORD dwTargetStrLen
Definition: imm.h:103
INT APIENTRY Imm32ImeMenuAnsiToWide(const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW, UINT uCodePage, BOOL bBitmap)
Definition: utils.c:292
static LPWSTR APIENTRY Imm32GetVerInfoValue(LPCVOID pVerInfo, LPWSTR pszKey, DWORD cchKey, LPCWSTR pszName)
Definition: utils.c:554
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
LONG WINAPI LZCopy(HFILE src, HFILE dest)
Definition: lzexpand.c:472
uint16_t * LPWORD
Definition: typedefs.h:56
Definition: ntuser.h:663
HKL APIENTRY Imm32GetNextHKL(UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
Definition: utils.c:660
WCHAR wszImeFile[80]
Definition: ntuser.h:1178
PIME_SUBSTATE pSubState
Definition: imm.h:186
#define S_OK
Definition: intsafe.h:52
DWORD dwStrOffset
Definition: imm.h:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
DWORD dwValue
Definition: imm.h:171
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1608
#define LHND
Definition: winbase.h:379
unsigned short USHORT
Definition: pedump.c:61
STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:832
BOOL APIENTRY Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue, DWORD_PTR dwCommand, DWORD_PTR dwData)
Definition: utils.c:222
LPCWSTR szPath
Definition: env.c:37
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2929
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size)
Definition: utils.c:982
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:137
WCHAR wszImeDescription[50]
Definition: ntuser.h:1177
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
static const struct newhuff ht[]
Definition: huffman.h:296
THRDESKHEAD head
Definition: ntuser.h:192
#define min(a, b)
Definition: monoChain.cc:55
HBITMAP hbmpItem
Definition: dimm.idl:126
static FN_VerQueryValueW s_fnVerQueryValueW
Definition: utils.c:535
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
Definition: utils.c:926
struct IME_STATE * pState
Definition: imm.h:100
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define INITIAL_COUNT
STRSAFEAPI StringCchLengthW(STRSAFE_LPCWSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:842
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define MultiByteToWideChar
Definition: compat.h:110
UINT NTAPI LocalFlags(HLOCAL hMem)
Definition: heapmem.c:1503
BOOL APIENTRY Imm32CopyFile(LPWSTR pszOldFile, LPCWSTR pszNewFile)
Definition: utils.c:868
BOOL APIENTRY Imm32LoadImeLangAndDesc(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:569
HKL hKL
Definition: imm.h:170
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
struct IME_STATE * pNext
Definition: imm.h:180
BOOL WINAPI ImmIMPQueryIMEA(LPIMEPROA pImePro)
Definition: utils.c:1042
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
DWORD dwFlags
Definition: ntuser.h:1295
#define VFT2_DRV_INPUTMETHOD
Definition: verrsrc.h:95
CONST void * LPCVOID
Definition: windef.h:191
HBITMAP hbmpChecked
Definition: dimm.idl:122
DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc)
Definition: utils.c:974
BOOL WINAPI ImmIMPGetIMEA(HWND hWnd, LPIMEPROA pImePro)
Definition: utils.c:1024
#define OF_CREATE
Definition: winbase.h:125
uint32_t * LPDWORD
Definition: typedefs.h:59
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
HBITMAP hbmpItem
Definition: imm.h:133
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:116
#define HIWORD(l)
Definition: typedefs.h:247
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define LANG_KOREAN
Definition: nls.h:84
DWORD dwImeWinVersion
Definition: ntuser.h:1176
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
WCHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1910
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:149
IN PCTCH IN DWORD cch
Definition: pager.h:36
_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
HBITMAP hbmpUnchecked
Definition: imm.h:130
#define CHAR(Char)
int HFILE
Definition: windef.h:298
#define LOWORD(l)
Definition: pedump.c:82
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:125
struct IME_SUBSTATE * pNext
Definition: imm.h:169
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:660
unsigned int * PUINT
Definition: ndis.h:50
LCID WINAPI GetThreadLocale(void)
Definition: lang.c:1449
#define APIENTRY
Definition: api.h:79
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
Definition: utils.c:198
BOOL(WINAPI * FN_GetFileVersionInfoW)(LPCWSTR, DWORD, DWORD, LPVOID)
Definition: utils.c:529
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
PVOID aheList
Definition: ntuser.h:1089
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952
#define REG_SZ
Definition: layer.c:22