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