ReactOS  0.4.15-dev-3442-gc05a45e
utils.c File Reference
#include "precomp.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Macros

#define INITIAL_COUNT   0x40
 
#define MAX_RETRY   10
 
#define GET_FN(name)
 
#define MAX_PRELOAD   0x400
 
#define GET_FN(name)
 

Typedefs

typedef BOOL(WINAPIFN_GetFileVersionInfoW) (LPCWSTR, DWORD, DWORD, LPVOID)
 
typedef DWORD(WINAPIFN_GetFileVersionInfoSizeW) (LPCWSTR, LPDWORD)
 
typedef BOOL(WINAPIFN_VerQueryValueW) (LPCVOID, LPCWSTR, LPVOID *, PUINT)
 
typedef INT(WINAPIFN_LZOpenFileW) (LPWSTR, LPOFSTRUCT, WORD)
 
typedef LONG(WINAPIFN_LZCopy) (INT, INT)
 
typedef VOID(WINAPIFN_LZClose) (INT)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (imm)
 
HRESULT APIENTRY Imm32StrToUInt (LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
 
HRESULT APIENTRY Imm32UIntToStr (DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
 
BOOL WINAPI Imm32IsImcAnsi (HIMC hIMC)
 
LPWSTR APIENTRY Imm32WideFromAnsi (LPCSTR pszA)
 
LPSTR APIENTRY Imm32AnsiFromWide (LPCWSTR pszW)
 
LONG APIENTRY IchWideFromAnsi (LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
 
LONG APIENTRY IchAnsiFromWide (LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
 
BOOL Imm32GetSystemLibraryPath (LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
 
VOID APIENTRY LogFontAnsiToWide (const LOGFONTA *plfA, LPLOGFONTW plfW)
 
VOID APIENTRY LogFontWideToAnsi (const LOGFONTW *plfW, LPLOGFONTA plfA)
 
LPVOID FASTCALL ValidateHandleNoErr (HANDLE hObject, UINT uType)
 
PWND FASTCALL ValidateHwndNoErr (HWND hwnd)
 
BOOL APIENTRY Imm32CheckImcProcess (PIMC pIMC)
 
LPVOID APIENTRY Imm32HeapAlloc (DWORD dwFlags, DWORD dwBytes)
 
BOOL APIENTRY Imm32NotifyAction (HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue, DWORD_PTR dwCommand, DWORD_PTR dwData)
 
DWORD APIENTRY Imm32AllocAndBuildHimcList (DWORD dwThreadId, HIMC **pphList)
 
INT APIENTRY Imm32ImeMenuAnsiToWide (const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW, UINT uCodePage, BOOL bBitmap)
 
INT APIENTRY Imm32ImeMenuWideToAnsi (const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA, UINT uCodePage)
 
PIME_STATE APIENTRY Imm32FetchImeState (LPINPUTCONTEXTDX pIC, HKL hKL)
 
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState (PIME_STATE pState, HKL hKL)
 
BOOL APIENTRY Imm32LoadImeStateSentence (LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
 
BOOL APIENTRY Imm32SaveImeStateSentence (LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
 
DWORD APIENTRY Imm32ReconvertWideFromAnsi (LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
 
DWORD APIENTRY Imm32ReconvertAnsiFromWide (LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
 
static BOOL APIENTRY Imm32LoadImeFixedInfo (PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
 
static LPWSTR APIENTRY Imm32GetVerInfoValue (LPCVOID pVerInfo, LPWSTR pszKey, DWORD cchKey, LPCWSTR pszName)
 
BOOL APIENTRY Imm32LoadImeLangAndDesc (PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
 
BOOL APIENTRY Imm32LoadImeVerInfo (PIMEINFOEX pImeInfoEx)
 
HKL APIENTRY Imm32GetNextHKL (UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
 
UINT APIENTRY Imm32GetRegImes (PREG_IME pLayouts, UINT cLayouts)
 
BOOL APIENTRY Imm32WriteRegIme (HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout)
 
BOOL APIENTRY Imm32CopyFile (LPWSTR pszOldFile, LPCWSTR pszNewFile)
 
BOOL WINAPI CtfImmIsTextFrameServiceDisabled (VOID)
 
HIMCC WINAPI ImmCreateIMCC (DWORD size)
 
HIMCC WINAPI ImmDestroyIMCC (HIMCC block)
 
LPVOID WINAPI ImmLockIMCC (HIMCC imcc)
 
BOOL WINAPI ImmUnlockIMCC (HIMCC imcc)
 
DWORD WINAPI ImmGetIMCCLockCount (HIMCC imcc)
 
HIMCC WINAPI ImmReSizeIMCC (HIMCC imcc, DWORD size)
 
DWORD WINAPI ImmGetIMCCSize (HIMCC imcc)
 
DWORD WINAPI ImmGetIMCLockCount (HIMC hIMC)
 
BOOL WINAPI ImmIMPGetIMEA (HWND hWnd, LPIMEPROA pImePro)
 
BOOL WINAPI ImmIMPGetIMEW (HWND hWnd, LPIMEPROW pImePro)
 
BOOL WINAPI ImmIMPQueryIMEA (LPIMEPROA pImePro)
 
BOOL WINAPI ImmIMPQueryIMEW (LPIMEPROW pImePro)
 
BOOL WINAPI ImmIMPSetIMEA (HWND hWnd, LPIMEPROA pImePro)
 
BOOL WINAPI ImmIMPSetIMEW (HWND hWnd, LPIMEPROW pImePro)
 

Variables

HANDLE g_hImm32Heap = NULL
 
static FN_GetFileVersionInfoW s_fnGetFileVersionInfoW = NULL
 
static FN_GetFileVersionInfoSizeW s_fnGetFileVersionInfoSizeW = NULL
 
static FN_VerQueryValueW s_fnVerQueryValueW = NULL
 

Macro Definition Documentation

◆ GET_FN [1/2]

#define GET_FN (   name)
Value:
do { \
s_fn##name = (FN_##name)GetProcAddress(hinstVersion, #name); \
if (!s_fn##name) goto Quit; \
} while (0)
Definition: name.c:38
#define GetProcAddress(x, y)
Definition: compat.h:612
GLuint const GLchar * name
Definition: glext.h:6031

◆ GET_FN [2/2]

#define GET_FN (   name)
Value:
do { \
fn##name = (FN_##name)GetProcAddress(hinstLZ32, #name); \
if (!fn##name) goto Quit; \
} while (0)
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
Definition: name.c:38
#define GetProcAddress(x, y)
Definition: compat.h:612
GLuint const GLchar * name
Definition: glext.h:6031

◆ INITIAL_COUNT

#define INITIAL_COUNT   0x40

◆ MAX_PRELOAD

#define MAX_PRELOAD   0x400

◆ MAX_RETRY

#define MAX_RETRY   10

Typedef Documentation

◆ FN_GetFileVersionInfoSizeW

typedef DWORD(WINAPI * FN_GetFileVersionInfoSizeW) (LPCWSTR, LPDWORD)

Definition at line 513 of file utils.c.

◆ FN_GetFileVersionInfoW

typedef BOOL(WINAPI * FN_GetFileVersionInfoW) (LPCWSTR, DWORD, DWORD, LPVOID)

Definition at line 512 of file utils.c.

◆ FN_LZClose

typedef VOID(WINAPI * FN_LZClose) (INT)

Definition at line 849 of file utils.c.

◆ FN_LZCopy

typedef LONG(WINAPI * FN_LZCopy) (INT, INT)

Definition at line 848 of file utils.c.

◆ FN_LZOpenFileW

typedef INT(WINAPI * FN_LZOpenFileW) (LPWSTR, LPOFSTRUCT, WORD)

Definition at line 847 of file utils.c.

◆ FN_VerQueryValueW

typedef BOOL(WINAPI * FN_VerQueryValueW) (LPCVOID, LPCWSTR, LPVOID *, PUINT)

Definition at line 514 of file utils.c.

Function Documentation

◆ CtfImmIsTextFrameServiceDisabled()

BOOL WINAPI CtfImmIsTextFrameServiceDisabled ( VOID  )

Definition at line 909 of file utils.c.

910 {
911  return !!(GetWin32ClientInfo()->CI_flags & CI_TFSDISABLED);
912 }
#define GetWin32ClientInfo()
Definition: ntuser.h:326
#define CI_TFSDISABLED
Definition: ntuser.h:289

Referenced by Imm32SelectLayout(), and ImmGetImeInfoEx().

◆ IchAnsiFromWide()

LONG APIENTRY IchAnsiFromWide ( LONG  cchWide,
LPCWSTR  pchWide,
UINT  uCodePage 
)

Definition at line 99 of file utils.c.

100 {
101  LONG cb, cchAnsi;
102  for (cchAnsi = 0; cchWide > 0; ++cchAnsi, ++pchWide, --cchWide)
103  {
104  cb = WideCharToMultiByte(uCodePage, 0, pchWide, 1, NULL, 0, NULL, NULL);
105  if (cb > 1)
106  ++cchAnsi;
107  }
108  return cchAnsi;
109 }
#define WideCharToMultiByte
Definition: compat.h:111
long LONG
Definition: pedump.c:60
#define NULL
Definition: types.h:112
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

Referenced by Imm32GetCompStrA(), Imm32ProcessRequest(), and Imm32ReconvertAnsiFromWide().

◆ IchWideFromAnsi()

LONG APIENTRY IchWideFromAnsi ( LONG  cchAnsi,
LPCSTR  pchAnsi,
UINT  uCodePage 
)

Definition at line 79 of file utils.c.

80 {
81  LONG cchWide;
82  for (cchWide = 0; cchAnsi > 0; ++cchWide)
83  {
84  if (IsDBCSLeadByteEx(uCodePage, *pchAnsi) && pchAnsi[1])
85  {
86  cchAnsi -= 2;
87  pchAnsi += 2;
88  }
89  else
90  {
91  --cchAnsi;
92  ++pchAnsi;
93  }
94  }
95  return cchWide;
96 }
BOOL WINAPI IsDBCSLeadByteEx(UINT CodePage, BYTE TestByte)
Definition: nls.c:2213
long LONG
Definition: pedump.c:60

Referenced by Imm32GetCompStrW(), Imm32ProcessRequest(), and Imm32ReconvertWideFromAnsi().

◆ Imm32AllocAndBuildHimcList()

DWORD APIENTRY Imm32AllocAndBuildHimcList ( DWORD  dwThreadId,
HIMC **  pphList 
)

Definition at line 236 of file utils.c.

237 {
238 #define INITIAL_COUNT 0x40
239 #define MAX_RETRY 10
241  DWORD dwCount = INITIAL_COUNT, cRetry = 0;
242  HIMC *phNewList;
243 
244  phNewList = Imm32HeapAlloc(0, dwCount * sizeof(HIMC));
245  if (phNewList == NULL)
246  return 0;
247 
248  Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
250  {
251  Imm32HeapFree(phNewList);
252  if (cRetry++ >= MAX_RETRY)
253  return 0;
254 
255  phNewList = Imm32HeapAlloc(0, dwCount * sizeof(HIMC));
256  if (phNewList == NULL)
257  return 0;
258 
259  Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
260  }
261 
262  if (NT_ERROR(Status) || !dwCount)
263  {
264  Imm32HeapFree(phNewList);
265  return 0;
266  }
267 
268  *pphList = phNewList;
269  return dwCount;
270 #undef INITIAL_COUNT
271 #undef MAX_RETRY
272 }
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
NTSTATUS NTAPI NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCount)
Definition: ntstubs.c:56
#define MAX_RETRY
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
DWORD HIMC
Definition: dimm.idl:75
Status
Definition: gdiplustypes.h:24
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NT_ERROR(Status)
Definition: umtypes.h:106
DWORD dwThreadId
Definition: fdebug.c:31
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
#define NULL
Definition: types.h:112
#define INITIAL_COUNT

Referenced by ImmEnumInputContext().

◆ Imm32AnsiFromWide()

LPSTR APIENTRY Imm32AnsiFromWide ( LPCWSTR  pszW)

Definition at line 66 of file utils.c.

67 {
68  INT cchW = lstrlenW(pszW);
69  INT cchA = (cchW + 1) * sizeof(WCHAR);
70  LPSTR pszA = Imm32HeapAlloc(0, cchA);
71  if (!pszA)
72  return NULL;
73  cchA = WideCharToMultiByte(CP_ACP, 0, pszW, cchW, pszA, cchA, NULL, NULL);
74  pszA[cchA] = 0;
75  return pszA;
76 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
char * LPSTR
Definition: xmlstorage.h:182
#define lstrlenW
Definition: compat.h:609
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
#define NULL
Definition: types.h:112

Referenced by Imm32EnumWordProcW2A(), ImmConfigureIMEW(), ImmEnumRegisterWordW(), ImmGetConversionListW(), ImmRegisterWordW(), and ImmUnregisterWordW().

◆ Imm32CheckImcProcess()

BOOL APIENTRY Imm32CheckImcProcess ( PIMC  pIMC)

Definition at line 181 of file utils.c.

182 {
183  HIMC hIMC;
184  DWORD dwProcessID;
185  if (pIMC->head.pti == NtCurrentTeb()->Win32ThreadInfo)
186  return TRUE;
187 
188  hIMC = pIMC->head.h;
189  dwProcessID = NtUserQueryInputContext(hIMC, 0);
190  return dwProcessID == (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
191 }
#define DWORD_PTR
Definition: treelist.c:76
#define TRUE
Definition: types.h:120
DWORD HIMC
Definition: dimm.idl:75
unsigned long DWORD
Definition: ntddk_ex.h:95
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
THRDESKHEAD head
Definition: ntuser.h:192
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:652

Referenced by ImmLockClientImc().

◆ Imm32CopyFile()

BOOL APIENTRY Imm32CopyFile ( LPWSTR  pszOldFile,
LPCWSTR  pszNewFile 
)

Definition at line 851 of file utils.c.

852 {
853  BOOL ret = FALSE, bLoaded = FALSE;
854  HMODULE hinstLZ32;
855  WCHAR szLZ32Path[MAX_PATH];
856  CHAR szDestA[MAX_PATH];
857  OFSTRUCT OFStruct;
858  FN_LZOpenFileW fnLZOpenFileW;
859  FN_LZCopy fnLZCopy;
860  FN_LZClose fnLZClose;
861  HFILE hfDest, hfSrc;
862 
863  /* Load LZ32.dll for copying/decompressing file */
864  Imm32GetSystemLibraryPath(szLZ32Path, _countof(szLZ32Path), L"LZ32");
865  hinstLZ32 = GetModuleHandleW(szLZ32Path);
866  if (!hinstLZ32)
867  {
868  hinstLZ32 = LoadLibraryW(szLZ32Path);
869  if (!hinstLZ32)
870  return FALSE;
871  bLoaded = TRUE;
872  }
873 
874 #define GET_FN(name) do { \
875  fn##name = (FN_##name)GetProcAddress(hinstLZ32, #name); \
876  if (!fn##name) goto Quit; \
877 } while (0)
879  GET_FN(LZCopy);
880  GET_FN(LZClose);
881 #undef GET_FN
882 
883  if (!WideCharToMultiByte(CP_ACP, 0, pszNewFile, -1, szDestA, _countof(szDestA), NULL, NULL))
884  goto Quit;
885  szDestA[_countof(szDestA) - 1] = 0;
886 
887  hfSrc = fnLZOpenFileW(pszOldFile, &OFStruct, OF_READ);
888  if (hfSrc < 0)
889  goto Quit;
890 
891  hfDest = OpenFile(szDestA, &OFStruct, OF_CREATE);
892  if (hfDest != HFILE_ERROR)
893  {
894  ret = (fnLZCopy(hfSrc, hfDest) >= 0);
895  _lclose(hfDest);
896  }
897 
898  fnLZClose(hfSrc);
899 
900 Quit:
901  if (bLoaded)
902  FreeLibrary(hinstLZ32);
903  return ret;
904 }
#define OF_READ
Definition: winbase.h:116
#define WideCharToMultiByte
Definition: compat.h:111
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
HFILE WINAPI LZOpenFileW(LPWSTR fn, LPOFSTRUCT ofs, WORD mode)
Definition: lzexpand.c:585
int WINAPI _lclose(HFILE hFile)
Definition: lfile.c:138
void WINAPI LZClose(HFILE fd)
Definition: lzexpand.c:600
#define L(x)
Definition: ntvdm.h:50
#define HFILE_ERROR
Definition: winbase.h:111
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
INT(WINAPI * FN_LZOpenFileW)(LPWSTR, LPOFSTRUCT, WORD)
Definition: utils.c:847
LONG(WINAPI * FN_LZCopy)(INT, INT)
Definition: utils.c:848
#define LoadLibraryW(x)
Definition: compat.h:606
VOID(WINAPI * FN_LZClose)(INT)
Definition: utils.c:849
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle)
Definition: create.c:368
#define FreeLibrary(x)
Definition: compat.h:607
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define GET_FN(name)
int ret
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:111
LONG WINAPI LZCopy(HFILE src, HFILE dest)
Definition: lzexpand.c:472
#define NULL
Definition: types.h:112
#define OF_CREATE
Definition: winbase.h:125
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
int HFILE
Definition: windef.h:298

Referenced by ImmInstallIMEW().

◆ Imm32FetchImeState()

PIME_STATE APIENTRY Imm32FetchImeState ( LPINPUTCONTEXTDX  pIC,
HKL  hKL 
)

Definition at line 324 of file utils.c.

325 {
326  PIME_STATE pState;
327  WORD Lang = PRIMARYLANGID(LOWORD(hKL));
328  for (pState = pIC->pState; pState; pState = pState->pNext)
329  {
330  if (pState->wLang == Lang)
331  break;
332  }
333  if (!pState)
334  {
335  pState = Imm32HeapAlloc(HEAP_ZERO_MEMORY, sizeof(IME_STATE));
336  if (pState)
337  {
338  pState->wLang = Lang;
339  pState->pNext = pIC->pState;
340  pIC->pState = pState;
341  }
342  }
343  return pState;
344 }
Definition: imm.h:178
WORD wLang
Definition: imm.h:181
unsigned short WORD
Definition: ntddk_ex.h:93
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
struct IME_STATE * pState
Definition: imm.h:100
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
struct IME_STATE * pNext
Definition: imm.h:180
#define LOWORD(l)
Definition: pedump.c:82
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by Imm32SelectLayout().

◆ Imm32FetchImeSubState()

PIME_SUBSTATE APIENTRY Imm32FetchImeSubState ( PIME_STATE  pState,
HKL  hKL 
)

Definition at line 347 of file utils.c.

348 {
349  PIME_SUBSTATE pSubState;
350  for (pSubState = pState->pSubState; pSubState; pSubState = pSubState->pNext)
351  {
352  if (pSubState->hKL == hKL)
353  return pSubState;
354  }
355  pSubState = Imm32HeapAlloc(0, sizeof(IME_SUBSTATE));
356  if (!pSubState)
357  return NULL;
358  pSubState->dwValue = 0;
359  pSubState->hKL = hKL;
360  pSubState->pNext = pState->pSubState;
361  pState->pSubState = pSubState;
362  return pSubState;
363 }
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
PIME_SUBSTATE pSubState
Definition: imm.h:186
DWORD dwValue
Definition: imm.h:171
#define NULL
Definition: types.h:112
HKL hKL
Definition: imm.h:170
struct IME_SUBSTATE * pNext
Definition: imm.h:169

Referenced by Imm32LoadImeStateSentence(), and Imm32SaveImeStateSentence().

◆ Imm32GetNextHKL()

HKL APIENTRY Imm32GetNextHKL ( UINT  cKLs,
const REG_IME pLayouts,
WORD  wLangID 
)

Definition at line 643 of file utils.c.

644 {
645  UINT iKL, wID, wLow = 0xE0FF, wHigh = 0xE01F, wNextID = 0;
646 
647  for (iKL = 0; iKL < cKLs; ++iKL)
648  {
649  wHigh = max(wHigh, HIWORD(pLayouts[iKL].hKL));
650  wLow = min(wLow, HIWORD(pLayouts[iKL].hKL));
651  }
652 
653  if (wHigh < 0xE0FF)
654  {
655  wNextID = wHigh + 1;
656  }
657  else if (wLow > 0xE001)
658  {
659  wNextID = wLow - 1;
660  }
661  else
662  {
663  for (wID = 0xE020; wID <= 0xE0FF; ++wID)
664  {
665  for (iKL = 0; iKL < cKLs; ++iKL)
666  {
667  if (LOWORD(pLayouts[iKL].hKL) == wLangID &&
668  HIWORD(pLayouts[iKL].hKL) == wID)
669  {
670  break;
671  }
672  }
673 
674  if (iKL >= cKLs)
675  break;
676  }
677 
678  if (wID <= 0xE0FF)
679  wNextID = wID;
680  }
681 
682  if (!wNextID)
683  return NULL;
684 
685  return (HKL)(DWORD_PTR)MAKELONG(wLangID, wNextID);
686 }
#define max(a, b)
Definition: svc.c:63
#define DWORD_PTR
Definition: treelist.c:76
#define MAKELONG(a, b)
Definition: typedefs.h:249
UINT_PTR HKL
Definition: msctf.idl:101
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HIWORD(l)
Definition: typedefs.h:247
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ImmInstallIMEW().

◆ Imm32GetRegImes()

UINT APIENTRY Imm32GetRegImes ( PREG_IME  pLayouts,
UINT  cLayouts 
)

Definition at line 688 of file utils.c.

689 {
690  HKEY hkeyLayouts, hkeyIME;
691  WCHAR szImeFileName[80], szImeKey[20];
692  UINT iKey, nCount;
693  DWORD cbData;
694  LONG lError;
695  ULONG Value;
696  HKL hKL;
697 
698  /* Open the registry keyboard layouts */
699  lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
700  if (lError != ERROR_SUCCESS)
701  return 0;
702 
703  for (iKey = nCount = 0; ; ++iKey)
704  {
705  /* Get the key name */
706  lError = RegEnumKeyW(hkeyLayouts, iKey, szImeKey, _countof(szImeKey));
707  if (lError != ERROR_SUCCESS)
708  break;
709 
710  if (szImeKey[0] != L'E' && szImeKey[0] != L'e')
711  continue; /* Not an IME layout */
712 
713  if (pLayouts == NULL) /* for counting only */
714  {
715  ++nCount;
716  continue;
717  }
718 
719  if (cLayouts <= nCount)
720  break;
721 
722  lError = RegOpenKeyW(hkeyLayouts, szImeKey, &hkeyIME); /* Open the IME key */
723  if (lError != ERROR_SUCCESS)
724  break;
725 
726  /* Load the "Ime File" value */
727  szImeFileName[0] = 0;
728  cbData = sizeof(szImeFileName);
729  RegQueryValueExW(hkeyIME, L"Ime File", NULL, NULL, (LPBYTE)szImeFileName, &cbData);
730  szImeFileName[_countof(szImeFileName) - 1] = 0;
731 
732  RegCloseKey(hkeyIME);
733 
734  if (!szImeFileName[0])
735  break;
736 
737  Imm32StrToUInt(szImeKey, &Value, 16);
738  hKL = (HKL)(DWORD_PTR)Value;
739  if (!IS_IME_HKL(hKL))
740  break;
741 
742  /* Store the IME key and the IME filename */
743  pLayouts[nCount].hKL = hKL;
744  StringCchCopyW(pLayouts[nCount].szImeKey, _countof(pLayouts[nCount].szImeKey), szImeKey);
745  CharUpperW(szImeFileName);
746  StringCchCopyW(pLayouts[nCount].szFileName, _countof(pLayouts[nCount].szFileName),
747  szImeFileName);
748  ++nCount;
749  }
750 
751  RegCloseKey(hkeyLayouts);
752  return nCount;
753 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
Definition: utils.c:20
HKL hKL
Definition: precomp.h:67
LPWSTR WINAPI CharUpperW(_Inout_ LPWSTR)
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RegCloseKey(hKey)
Definition: registry.h:40
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ImmInstallIMEW().

◆ Imm32GetSystemLibraryPath()

BOOL Imm32GetSystemLibraryPath ( LPWSTR  pszPath,
DWORD  cchPath,
LPCWSTR  pszFileName 
)

Definition at line 111 of file utils.c.

112 {
113  if (!pszFileName[0] || !GetSystemDirectoryW(pszPath, cchPath))
114  return FALSE;
115  StringCchCatW(pszPath, cchPath, L"\\");
116  StringCchCatW(pszPath, cchPath, pszFileName);
117  return TRUE;
118 }
#define TRUE
Definition: types.h:120
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312

Referenced by Imm32CopyFile(), Imm32LoadImeInfo(), Imm32LoadImeVerInfo(), and ImmInstallIMEW().

◆ Imm32GetVerInfoValue()

static LPWSTR APIENTRY Imm32GetVerInfoValue ( LPCVOID  pVerInfo,
LPWSTR  pszKey,
DWORD  cchKey,
LPCWSTR  pszName 
)
static

Definition at line 537 of file utils.c.

538 {
539  size_t cchExtra;
540  LPWSTR pszValue;
541  UINT cbValue = 0;
542 
543  StringCchLengthW(pszKey, cchKey, &cchExtra);
544 
545  StringCchCatW(pszKey, cchKey, pszName);
546  s_fnVerQueryValueW(pVerInfo, pszKey, (LPVOID*)&pszValue, &cbValue);
547  pszKey[cchExtra] = 0;
548 
549  return (cbValue ? pszValue : NULL);
550 }
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
static FN_VerQueryValueW s_fnVerQueryValueW
Definition: utils.c:518
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
STRSAFEAPI StringCchLengthW(STRSAFE_LPCWSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:842
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Imm32LoadImeLangAndDesc().

◆ Imm32HeapAlloc()

◆ Imm32ImeMenuAnsiToWide()

INT APIENTRY Imm32ImeMenuAnsiToWide ( const IMEMENUITEMINFOA pItemA,
LPIMEMENUITEMINFOW  pItemW,
UINT  uCodePage,
BOOL  bBitmap 
)

Definition at line 275 of file utils.c.

277 {
278  INT ret;
279  pItemW->cbSize = pItemA->cbSize;
280  pItemW->fType = pItemA->fType;
281  pItemW->fState = pItemA->fState;
282  pItemW->wID = pItemA->wID;
283  if (bBitmap)
284  {
285  pItemW->hbmpChecked = pItemA->hbmpChecked;
286  pItemW->hbmpUnchecked = pItemA->hbmpUnchecked;
287  pItemW->hbmpItem = pItemA->hbmpItem;
288  }
289  pItemW->dwItemData = pItemA->dwItemData;
290  ret = MultiByteToWideChar(uCodePage, 0, pItemA->szString, -1,
291  pItemW->szString, _countof(pItemW->szString));
292  if (ret >= _countof(pItemW->szString))
293  {
294  ret = 0;
295  pItemW->szString[0] = 0;
296  }
297  return ret;
298 }
HBITMAP hbmpChecked
Definition: imm.h:129
DWORD dwItemData
Definition: imm.h:131
int32_t INT
Definition: typedefs.h:58
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:132
HBITMAP hbmpUnchecked
Definition: dimm.idl:123
#define _countof(array)
Definition: sndvol32.h:68
int ret
DWORD dwItemData
Definition: dimm.idl:124
HBITMAP hbmpItem
Definition: dimm.idl:126
#define MultiByteToWideChar
Definition: compat.h:110
HBITMAP hbmpChecked
Definition: dimm.idl:122
HBITMAP hbmpItem
Definition: imm.h:133
HBITMAP hbmpUnchecked
Definition: imm.h:130
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:125

Referenced by Imm32GetImeMenuItemsAW().

◆ Imm32ImeMenuWideToAnsi()

INT APIENTRY Imm32ImeMenuWideToAnsi ( const IMEMENUITEMINFOW pItemW,
LPIMEMENUITEMINFOA  pItemA,
UINT  uCodePage 
)

Definition at line 301 of file utils.c.

303 {
304  INT ret;
305  pItemA->cbSize = pItemW->cbSize;
306  pItemA->fType = pItemW->fType;
307  pItemA->fState = pItemW->fState;
308  pItemA->wID = pItemW->wID;
309  pItemA->hbmpChecked = pItemW->hbmpChecked;
310  pItemA->hbmpUnchecked = pItemW->hbmpUnchecked;
311  pItemA->dwItemData = pItemW->dwItemData;
312  pItemA->hbmpItem = pItemW->hbmpItem;
313  ret = WideCharToMultiByte(uCodePage, 0, pItemW->szString, -1,
314  pItemA->szString, _countof(pItemA->szString), NULL, NULL);
315  if (ret >= _countof(pItemA->szString))
316  {
317  ret = 0;
318  pItemA->szString[0] = 0;
319  }
320  return ret;
321 }
#define WideCharToMultiByte
Definition: compat.h:111
HBITMAP hbmpChecked
Definition: dimm.idl:134
HBITMAP hbmpUnchecked
Definition: imm.h:117
int32_t INT
Definition: typedefs.h:58
HBITMAP hbmpUnchecked
Definition: dimm.idl:135
DWORD dwItemData
Definition: dimm.idl:136
DWORD dwItemData
Definition: imm.h:118
HBITMAP hbmpItem
Definition: dimm.idl:138
#define _countof(array)
Definition: sndvol32.h:68
HBITMAP hbmpChecked
Definition: imm.h:116
int ret
HBITMAP hbmpItem
Definition: imm.h:120
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:119
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:137
#define NULL
Definition: types.h:112

Referenced by Imm32GetImeMenuItemsAW().

◆ Imm32IsImcAnsi()

BOOL WINAPI Imm32IsImcAnsi ( HIMC  hIMC)

Definition at line 44 of file utils.c.

45 {
46  BOOL ret;
47  PCLIENTIMC pClientImc = ImmLockClientImc(hIMC);
48  if (!pClientImc)
49  return -1;
50  ret = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
51  ImmUnlockClientImc(pClientImc);
52  return ret;
53 }
#define CLIENTIMC_WIDE
Definition: ntuser.h:1314
unsigned int BOOL
Definition: ntddk_ex.h:94
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
int ret
DWORD dwFlags
Definition: ntuser.h:1295
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952

Referenced by Imm32GetImeMenuItemsAW().

◆ Imm32LoadImeFixedInfo()

static BOOL APIENTRY Imm32LoadImeFixedInfo ( PIMEINFOEX  pInfoEx,
LPCVOID  pVerInfo 
)
static

Definition at line 520 of file utils.c.

521 {
522  UINT cbFixed = 0;
523  VS_FIXEDFILEINFO *pFixed;
524  if (!s_fnVerQueryValueW(pVerInfo, L"\\", (LPVOID*)&pFixed, &cbFixed) || !cbFixed)
525  return FALSE;
526 
527  /* NOTE: The IME module must contain a version info of input method driver. */
528  if (pFixed->dwFileType != VFT_DRV || pFixed->dwFileSubtype != VFT2_DRV_INPUTMETHOD)
529  return FALSE;
530 
531  pInfoEx->dwProdVersion = pFixed->dwProductVersionMS;
532  pInfoEx->dwImeWinVersion = 0x40000;
533  return TRUE;
534 }
DWORD dwProdVersion
Definition: ntuser.h:1175
#define TRUE
Definition: types.h:120
#define VFT_DRV
Definition: verrsrc.h:77
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
static FN_VerQueryValueW s_fnVerQueryValueW
Definition: utils.c:518
unsigned int UINT
Definition: ndis.h:50
#define VFT2_DRV_INPUTMETHOD
Definition: verrsrc.h:95
DWORD dwImeWinVersion
Definition: ntuser.h:1176

Referenced by Imm32LoadImeVerInfo().

◆ Imm32LoadImeLangAndDesc()

BOOL APIENTRY Imm32LoadImeLangAndDesc ( PIMEINFOEX  pInfoEx,
LPCVOID  pVerInfo 
)

Definition at line 552 of file utils.c.

553 {
554  BOOL ret;
555  WCHAR szKey[80];
556  LPWSTR pszDesc;
557  LPWORD pw;
558  UINT cbData;
559  LANGID LangID;
560 
561  /* Getting the version info. See VerQueryValue */
562  ret = s_fnVerQueryValueW(pVerInfo, L"\\VarFileInfo\\Translation", (LPVOID*)&pw, &cbData);
563  if (!ret || !cbData)
564  return FALSE;
565 
566  if (pInfoEx->hkl == NULL)
567  pInfoEx->hkl = (HKL)(DWORD_PTR)*pw; /* This is an invalid HKL */
568 
569  /* Try the current language and the Unicode codepage (0x04B0) */
571  StringCchPrintfW(szKey, _countof(szKey), L"\\StringFileInfo\\%04X04B0\\", LangID);
572  pszDesc = Imm32GetVerInfoValue(pVerInfo, szKey, _countof(szKey), L"FileDescription");
573  if (!pszDesc)
574  {
575  /* Retry the language and codepage of the IME module */
576  StringCchPrintfW(szKey, _countof(szKey), L"\\StringFileInfo\\%04X%04X\\", pw[0], pw[1]);
577  pszDesc = Imm32GetVerInfoValue(pVerInfo, szKey, _countof(szKey), L"FileDescription");
578  }
579 
580  /* The description */
581  if (pszDesc)
582  StringCchCopyW(pInfoEx->wszImeDescription, _countof(pInfoEx->wszImeDescription), pszDesc);
583  else
584  pInfoEx->wszImeDescription[0] = 0;
585 
586  return TRUE;
587 }
#define TRUE
Definition: types.h:120
WORD LANGID
Definition: typedefs.h:81
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
int ret
#define LANGIDFROMLCID(l)
Definition: nls.h:18
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
static LPWSTR APIENTRY Imm32GetVerInfoValue(LPCVOID pVerInfo, LPWSTR pszKey, DWORD cchKey, LPCWSTR pszName)
Definition: utils.c:537
uint16_t * LPWORD
Definition: typedefs.h:56
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
WCHAR wszImeDescription[50]
Definition: ntuser.h:1177
static FN_VerQueryValueW s_fnVerQueryValueW
Definition: utils.c:518
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_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
LCID WINAPI GetThreadLocale(void)
Definition: lang.c:1453

Referenced by Imm32LoadImeVerInfo().

◆ Imm32LoadImeStateSentence()

BOOL APIENTRY Imm32LoadImeStateSentence ( LPINPUTCONTEXTDX  pIC,
PIME_STATE  pState,
HKL  hKL 
)

Definition at line 366 of file utils.c.

367 {
368  PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
369  if (pSubState)
370  {
371  pIC->fdwSentence |= pSubState->dwValue;
372  return TRUE;
373  }
374  return FALSE;
375 }
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:347
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD dwValue
Definition: imm.h:171

Referenced by Imm32SelectLayout().

◆ Imm32LoadImeVerInfo()

BOOL APIENTRY Imm32LoadImeVerInfo ( PIMEINFOEX  pImeInfoEx)

Definition at line 589 of file utils.c.

590 {
591  HINSTANCE hinstVersion;
592  BOOL ret = FALSE, bLoaded = FALSE;
594  LPVOID pVerInfo;
595  DWORD cbVerInfo, dwHandle;
596 
597  /* Load version.dll to use the version info API */
599  hinstVersion = GetModuleHandleW(szPath);
600  if (!hinstVersion)
601  {
602  hinstVersion = LoadLibraryW(szPath);
603  if (!hinstVersion)
604  return FALSE;
605  bLoaded = TRUE;
606  }
607 
608 #define GET_FN(name) do { \
609  s_fn##name = (FN_##name)GetProcAddress(hinstVersion, #name); \
610  if (!s_fn##name) goto Quit; \
611 } while (0)
615 #undef GET_FN
616 
617  /* The path of the IME module */
619 
620  cbVerInfo = s_fnGetFileVersionInfoSizeW(szPath, &dwHandle);
621  if (!cbVerInfo)
622  goto Quit;
623 
624  pVerInfo = Imm32HeapAlloc(0, cbVerInfo);
625  if (!pVerInfo)
626  goto Quit;
627 
628  /* Load the version info of the IME module */
629  if (s_fnGetFileVersionInfoW(szPath, dwHandle, cbVerInfo, pVerInfo) &&
630  Imm32LoadImeFixedInfo(pImeInfoEx, pVerInfo))
631  {
632  ret = Imm32LoadImeLangAndDesc(pImeInfoEx, pVerInfo);
633  }
634 
635  Imm32HeapFree(pVerInfo);
636 
637 Quit:
638  if (bLoaded)
639  FreeLibrary(hinstVersion);
640  return ret;
641 }
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LoadLibraryW(x)
Definition: compat.h:606
static FN_GetFileVersionInfoSizeW s_fnGetFileVersionInfoSizeW
Definition: utils.c:517
#define FreeLibrary(x)
Definition: compat.h:607
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
static BOOL APIENTRY Imm32LoadImeFixedInfo(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:520
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GET_FN(name)
int ret
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:111
static FN_GetFileVersionInfoW s_fnGetFileVersionInfoW
Definition: utils.c:516
WCHAR wszImeFile[80]
Definition: ntuser.h:1178
LPCWSTR szPath
Definition: env.c:37
BOOL APIENTRY Imm32LoadImeLangAndDesc(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:552
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049

Referenced by ImmInstallIMEW(), and ImmLoadLayout().

◆ Imm32NotifyAction()

BOOL APIENTRY Imm32NotifyAction ( HIMC  hIMC,
HWND  hwnd,
DWORD  dwAction,
DWORD_PTR  dwIndex,
DWORD_PTR  dwValue,
DWORD_PTR  dwCommand,
DWORD_PTR  dwData 
)

Definition at line 205 of file utils.c.

207 {
209  HKL hKL;
210  PIMEDPI pImeDpi;
211 
212  if (dwAction)
213  {
215  if (dwThreadId)
216  {
217  /* find keyboard layout and lock it */
219  pImeDpi = ImmLockImeDpi(hKL);
220  if (pImeDpi)
221  {
222  /* do notify */
223  pImeDpi->NotifyIME(hIMC, dwAction, dwIndex, dwValue);
224 
225  ImmUnlockImeDpi(pImeDpi); /* unlock */
226  }
227  }
228  }
229 
230  if (hwnd && dwCommand)
231  SendMessageW(hwnd, WM_IME_NOTIFY, dwCommand, dwData);
232 
233  return TRUE;
234 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:755
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_IME_NOTIFY
Definition: winuser.h:1817
#define TRUE
Definition: types.h:120
static HANDLE ULONG_PTR dwData
Definition: file.c:35
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
UINT_PTR HKL
Definition: msctf.idl:101
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:652

Referenced by ImmSetCandidateWindow(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), ImmSetCompositionWindow(), ImmSetConversionStatus(), ImmSetOpenStatus(), and ImmSetStatusWindowPos().

◆ Imm32ReconvertAnsiFromWide()

DWORD APIENTRY Imm32ReconvertAnsiFromWide ( LPRECONVERTSTRING  pDest,
const RECONVERTSTRING pSrc,
UINT  uCodePage 
)

Definition at line 455 of file utils.c.

456 {
457  DWORD cch0, cch1, cchDest, cbDest;
458  LPCWSTR pchSrc = (LPCWSTR)((LPCSTR)pSrc + pSrc->dwStrOffset);
459  LPSTR pchDest;
460 
461  if (pSrc->dwVersion != 0)
462  return 0;
463 
464  cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
465  NULL, 0, NULL, NULL);
466  cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(CHAR);
467  if (!pDest)
468  return cbDest;
469 
470  if (pDest->dwSize < cbDest)
471  return 0;
472 
473  /* dwSize */
474  pDest->dwSize = cbDest;
475 
476  /* dwVersion */
477  pDest->dwVersion = 0;
478 
479  /* dwStrOffset */
480  pDest->dwStrOffset = sizeof(RECONVERTSTRING);
481 
482  /* dwCompStrOffset */
483  cch1 = pSrc->dwCompStrOffset / sizeof(WCHAR);
484  cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
485  pDest->dwCompStrOffset = cch0 * sizeof(CHAR);
486 
487  /* dwCompStrLen */
488  cch0 = IchAnsiFromWide(cch1 + pSrc->dwCompStrLen, pchSrc, uCodePage);
489  pDest->dwCompStrLen = cch0 * sizeof(CHAR) - pDest->dwCompStrOffset;
490 
491  /* dwTargetStrOffset */
492  cch1 = pSrc->dwTargetStrOffset / sizeof(WCHAR);
493  cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
494  pDest->dwTargetStrOffset = cch0 * sizeof(CHAR);
495 
496  /* dwTargetStrLen */
497  cch0 = IchAnsiFromWide(cch1 + pSrc->dwTargetStrLen, pchSrc, uCodePage);
498  pDest->dwTargetStrLen = cch0 * sizeof(CHAR) - pDest->dwTargetStrOffset;
499 
500  /* dwStrLen */
501  pDest->dwStrLen = cchDest;
502 
503  /* the string */
504  pchDest = (LPSTR)pDest + pDest->dwStrOffset;
505  cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
506  pchDest, cchDest, NULL, NULL);
507  pchDest[cchDest] = 0;
508 
509  return cbDest;
510 }
DWORD dwTargetStrOffset
Definition: imm.h:104
#define WideCharToMultiByte
Definition: compat.h:111
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
DWORD dwSize
Definition: imm.h:97
DWORD dwCompStrOffset
Definition: imm.h:102
char * LPSTR
Definition: xmlstorage.h:182
DWORD dwVersion
Definition: imm.h:98
DWORD dwCompStrLen
Definition: imm.h:101
struct tagRECONVERTSTRING RECONVERTSTRING
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwStrLen
Definition: imm.h:99
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwTargetStrLen
Definition: imm.h:103
DWORD dwStrOffset
Definition: imm.h:100
#define NULL
Definition: types.h:112
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:99
#define CHAR(Char)

Referenced by Imm32ProcessRequest(), and Imm32SetCompositionStringAW().

◆ Imm32ReconvertWideFromAnsi()

DWORD APIENTRY Imm32ReconvertWideFromAnsi ( LPRECONVERTSTRING  pDest,
const RECONVERTSTRING pSrc,
UINT  uCodePage 
)

Definition at line 399 of file utils.c.

400 {
401  DWORD cch0, cchDest, cbDest;
402  LPCSTR pchSrc = (LPCSTR)pSrc + pSrc->dwStrOffset;
403  LPWSTR pchDest;
404 
405  if (pSrc->dwVersion != 0)
406  return 0;
407 
408  cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
409  NULL, 0);
410  cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(WCHAR);
411  if (!pDest)
412  return cbDest;
413 
414  if (pDest->dwSize < cbDest)
415  return 0;
416 
417  /* dwSize */
418  pDest->dwSize = cbDest;
419 
420  /* dwVersion */
421  pDest->dwVersion = 0;
422 
423  /* dwStrOffset */
424  pDest->dwStrOffset = sizeof(RECONVERTSTRING);
425 
426  /* dwCompStrOffset */
427  cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset, pchSrc, uCodePage);
428  pDest->dwCompStrOffset = cch0 * sizeof(WCHAR);
429 
430  /* dwCompStrLen */
431  cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset + pSrc->dwCompStrLen, pchSrc, uCodePage);
432  pDest->dwCompStrLen = (cch0 * sizeof(WCHAR) - pDest->dwCompStrOffset) / sizeof(WCHAR);
433 
434  /* dwTargetStrOffset */
435  cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset, pchSrc, uCodePage);
436  pDest->dwTargetStrOffset = cch0 * sizeof(WCHAR);
437 
438  /* dwTargetStrLen */
439  cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset + pSrc->dwTargetStrLen, pchSrc, uCodePage);
440  pDest->dwTargetStrLen = (cch0 * sizeof(WCHAR) - pSrc->dwTargetStrOffset) / sizeof(WCHAR);
441 
442  /* dwStrLen */
443  pDest->dwStrLen = cchDest;
444 
445  /* the string */
446  pchDest = (LPWSTR)((LPBYTE)pDest + pDest->dwStrOffset);
447  cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
448  pchDest, cchDest);
449  pchDest[cchDest] = 0;
450 
451  return cbDest;
452 }
DWORD dwTargetStrOffset
Definition: imm.h:104
DWORD dwSize
Definition: imm.h:97
DWORD dwCompStrOffset
Definition: imm.h:102
#define MB_PRECOMPOSED
Definition: winnls.h:281
if(dx==0 &&dy==0)
Definition: linetemp.h:174
DWORD dwVersion
Definition: imm.h:98
DWORD dwCompStrLen
Definition: imm.h:101
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:79
struct tagRECONVERTSTRING RECONVERTSTRING
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwStrLen
Definition: imm.h:99
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwTargetStrLen
Definition: imm.h:103
DWORD dwStrOffset
Definition: imm.h:100
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Imm32ProcessRequest(), and Imm32SetCompositionStringAW().

◆ Imm32SaveImeStateSentence()

BOOL APIENTRY Imm32SaveImeStateSentence ( LPINPUTCONTEXTDX  pIC,
PIME_STATE  pState,
HKL  hKL 
)

Definition at line 378 of file utils.c.

379 {
380  PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
381  if (pSubState)
382  {
383  pSubState->dwValue = (pIC->fdwSentence & 0xffff0000);
384  return TRUE;
385  }
386  return FALSE;
387 }
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:347
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD dwValue
Definition: imm.h:171

Referenced by Imm32SelectLayout().

◆ Imm32StrToUInt()

HRESULT APIENTRY Imm32StrToUInt ( LPCWSTR  pszText,
LPDWORD  pdwValue,
ULONG  nBase 
)

Definition at line 20 of file utils.c.

21 {
25  Status = RtlUnicodeStringToInteger(&UnicodeString, nBase, pdwValue);
26  if (!NT_SUCCESS(Status))
27  return E_FAIL;
28  return S_OK;
29 }
LONG NTSTATUS
Definition: precomp.h:26
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
#define E_FAIL
Definition: ddrawi.h:102
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define S_OK
Definition: intsafe.h:52
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by Imm32GetRegImes().

◆ Imm32UIntToStr()

HRESULT APIENTRY Imm32UIntToStr ( DWORD  dwValue,
ULONG  nBase,
LPWSTR  pszBuff,
USHORT  cchBuff 
)

Definition at line 32 of file utils.c.

33 {
36  UnicodeString.Buffer = pszBuff;
37  UnicodeString.MaximumLength = cchBuff * sizeof(WCHAR);
39  if (!NT_SUCCESS(Status))
40  return E_FAIL;
41  return S_OK;
42 }
LONG NTSTATUS
Definition: precomp.h:26
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
#define E_FAIL
Definition: ddrawi.h:102
Status
Definition: gdiplustypes.h:24
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define S_OK
Definition: intsafe.h:52

Referenced by Imm32WriteRegIme(), ImmInstallIMEW(), and ImmLoadLayout().

◆ Imm32WideFromAnsi()

LPWSTR APIENTRY Imm32WideFromAnsi ( LPCSTR  pszA)

Definition at line 55 of file utils.c.

56 {
57  INT cch = lstrlenA(pszA);
58  LPWSTR pszW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
59  if (pszW == NULL)
60  return NULL;
61  cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszA, cch, pszW, cch + 1);
62  pszW[cch] = 0;
63  return pszW;
64 }
#define CP_ACP
Definition: compat.h:109
#define MB_PRECOMPOSED
Definition: winnls.h:281
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
IN PCTCH IN DWORD cch
Definition: pager.h:36

Referenced by Imm32EnumWordProcA2W(), ImmConfigureIMEA(), ImmEnumRegisterWordA(), ImmGetConversionListA(), ImmInstallIMEA(), ImmRegisterWordA(), and ImmUnregisterWordA().

◆ Imm32WriteRegIme()

BOOL APIENTRY Imm32WriteRegIme ( HKL  hKL,
LPCWSTR  pchFilePart,
LPCWSTR  pszLayout 
)

Definition at line 755 of file utils.c.

756 {
757  UINT iPreload;
758  HKEY hkeyLayouts, hkeyIME, hkeyPreload;
759  WCHAR szImeKey[20], szPreloadNumber[20], szPreloadKey[20], szImeFileName[80];
760  DWORD cbData;
761  LANGID LangID;
762  LONG lError;
763  LPCWSTR pszLayoutFile;
764 
765  /* Open the registry keyboard layouts */
766  lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
767  if (lError != ERROR_SUCCESS)
768  return FALSE;
769 
770  /* Get the IME key from hKL */
771  Imm32UIntToStr((DWORD)(DWORD_PTR)hKL, 16, szImeKey, _countof(szImeKey));
772 
773  /* Create a registry IME key */
774  lError = RegCreateKeyW(hkeyLayouts, szImeKey, &hkeyIME);
775  if (lError != ERROR_SUCCESS)
776  goto Failure;
777 
778  /* Write "Ime File" */
779  cbData = (wcslen(pchFilePart) + 1) * sizeof(WCHAR);
780  lError = RegSetValueExW(hkeyIME, L"Ime File", 0, REG_SZ, (LPBYTE)pchFilePart, cbData);
781  if (lError != ERROR_SUCCESS)
782  goto Failure;
783 
784  /* Write "Layout Text" */
785  cbData = (wcslen(pszLayout) + 1) * sizeof(WCHAR);
786  lError = RegSetValueExW(hkeyIME, L"Layout Text", 0, REG_SZ, (LPBYTE)pszLayout, cbData);
787  if (lError != ERROR_SUCCESS)
788  goto Failure;
789 
790  /* Choose "Layout File" from hKL */
791  LangID = LOWORD(hKL);
792  switch (LOBYTE(LangID))
793  {
794  case LANG_JAPANESE: pszLayoutFile = L"kbdjpn.dll"; break;
795  case LANG_KOREAN: pszLayoutFile = L"kbdkor.dll"; break;
796  default: pszLayoutFile = L"kbdus.dll"; break;
797  }
798  StringCchCopyW(szImeFileName, _countof(szImeFileName), pszLayoutFile);
799 
800  /* Write "Layout File" */
801  cbData = (wcslen(szImeFileName) + 1) * sizeof(WCHAR);
802  lError = RegSetValueExW(hkeyIME, L"Layout File", 0, REG_SZ, (LPBYTE)szImeFileName, cbData);
803  if (lError != ERROR_SUCCESS)
804  goto Failure;
805 
806  RegCloseKey(hkeyIME);
807  RegCloseKey(hkeyLayouts);
808 
809  /* Create "Preload" key */
810  RegCreateKeyW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", &hkeyPreload);
811 
812 #define MAX_PRELOAD 0x400
813  for (iPreload = 1; iPreload < MAX_PRELOAD; ++iPreload)
814  {
815  Imm32UIntToStr(iPreload, 10, szPreloadNumber, _countof(szPreloadNumber));
816 
817  /* Load the key of the preload number */
818  cbData = sizeof(szPreloadKey);
819  lError = RegQueryValueExW(hkeyPreload, szPreloadNumber, NULL, NULL,
820  (LPBYTE)szPreloadKey, &cbData);
821  szPreloadKey[_countof(szPreloadKey) - 1] = 0;
822 
823  if (lError != ERROR_SUCCESS || lstrcmpiW(szImeKey, szPreloadKey) == 0)
824  break; /* Found an empty room or the same key */
825  }
826 
827  if (iPreload >= MAX_PRELOAD) /* Not found */
828  {
829  RegCloseKey(hkeyPreload);
830  return FALSE;
831  }
832 #undef MAX_PRELOAD
833 
834  /* Write the IME key to the preload number */
835  cbData = (wcslen(szImeKey) + 1) * sizeof(WCHAR);
836  lError = RegSetValueExW(hkeyPreload, szPreloadNumber, 0, REG_SZ, (LPBYTE)szImeKey, cbData);
837  RegCloseKey(hkeyPreload);
838  return lError == ERROR_SUCCESS;
839 
840 Failure:
841  RegCloseKey(hkeyIME);
842  RegDeleteKeyW(hkeyLayouts, szImeKey);
843  RegCloseKey(hkeyLayouts);
844  return FALSE;
845 }
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
WORD LANGID
Definition: typedefs.h:81
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define LANG_JAPANESE
Definition: nls.h:76
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
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
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MAX_PRELOAD
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define LANG_KOREAN
Definition: nls.h:84
_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 LOWORD(l)
Definition: pedump.c:82
#define RegCloseKey(hKey)
Definition: registry.h:40
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by ImmInstallIMEW().

◆ ImmCreateIMCC()

HIMCC WINAPI ImmCreateIMCC ( DWORD  size)

Definition at line 917 of file utils.c.

918 {
919  if (size < sizeof(DWORD))
920  size = sizeof(DWORD);
921  return LocalAlloc(LHND, size);
922 }
#define DWORD
Definition: nt_native.h:44
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LHND
Definition: winbase.h:379
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by Imm32InitContext(), Imm32SelectLayout(), START_TEST(), test_ImmDestroyIMCC(), and test_ImmGetIMCCLockCount().

◆ ImmDestroyIMCC()

HIMCC WINAPI ImmDestroyIMCC ( HIMCC  block)

Definition at line 927 of file utils.c.

928 {
929  if (block)
930  return LocalFree(block);
931  return NULL;
932 }
static unsigned int block
Definition: xmlmemory.c:118
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define NULL
Definition: types.h:112

Referenced by Imm32CleanupContext(), Imm32InitContext(), Imm32SelectLayout(), START_TEST(), test_ImmDestroyIMCC(), and test_ImmGetIMCCLockCount().

◆ ImmGetIMCCLockCount()

DWORD WINAPI ImmGetIMCCLockCount ( HIMCC  imcc)

Definition at line 957 of file utils.c.

958 {
959  return LocalFlags(imcc) & LMEM_LOCKCOUNT;
960 }
#define LMEM_LOCKCOUNT
Definition: winbase.h:376
UINT NTAPI LocalFlags(HLOCAL hMem)
Definition: heapmem.c:1503

Referenced by Imm32SelectLayout(), START_TEST(), test_ImmDestroyIMCC(), and test_ImmGetIMCCLockCount().

◆ ImmGetIMCCSize()

DWORD WINAPI ImmGetIMCCSize ( HIMCC  imcc)

Definition at line 975 of file utils.c.

976 {
977  if (imcc)
978  return LocalSize(imcc);
979  return 0;
980 }
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777

Referenced by Imm32SelectLayout(), START_TEST(), and test_ImmDestroyIMCC().

◆ ImmGetIMCLockCount()

DWORD WINAPI ImmGetIMCLockCount ( HIMC  hIMC)

Definition at line 985 of file utils.c.

986 {
987  DWORD ret;
988  HANDLE hInputContext;
989  PCLIENTIMC pClientImc;
990 
991  pClientImc = ImmLockClientImc(hIMC);
992  if (pClientImc == NULL)
993  return 0;
994 
995  ret = 0;
996  hInputContext = pClientImc->hInputContext;
997  if (hInputContext)
998  ret = (LocalFlags(hInputContext) & LMEM_LOCKCOUNT);
999 
1000  ImmUnlockClientImc(pClientImc);
1001  return ret;
1002 }
#define LMEM_LOCKCOUNT
Definition: winbase.h:376
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
HANDLE hInputContext
Definition: ntuser.h:1293
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define NULL
Definition: types.h:112
UINT NTAPI LocalFlags(HLOCAL hMem)
Definition: heapmem.c:1503
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952

Referenced by test_ImmDestroyContext(), and test_ImmGetIMCLockCount().

◆ ImmIMPGetIMEA()

BOOL WINAPI ImmIMPGetIMEA ( HWND  hWnd,
LPIMEPROA  pImePro 
)

Definition at line 1007 of file utils.c.

1008 {
1009  FIXME("(%p, %p)\n", hWnd, pImePro);
1010  return FALSE;
1011 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by IMPGetIMEA().

◆ ImmIMPGetIMEW()

BOOL WINAPI ImmIMPGetIMEW ( HWND  hWnd,
LPIMEPROW  pImePro 
)

Definition at line 1016 of file utils.c.

1017 {
1018  FIXME("(%p, %p)\n", hWnd, pImePro);
1019  return FALSE;
1020 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by IMPGetIMEW().

◆ ImmIMPQueryIMEA()

BOOL WINAPI ImmIMPQueryIMEA ( LPIMEPROA  pImePro)

Definition at line 1025 of file utils.c.

1026 {
1027  FIXME("(%p)\n", pImePro);
1028  return FALSE;
1029 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by IMPQueryIMEA().

◆ ImmIMPQueryIMEW()

BOOL WINAPI ImmIMPQueryIMEW ( LPIMEPROW  pImePro)

Definition at line 1034 of file utils.c.

1035 {
1036  FIXME("(%p)\n", pImePro);
1037  return FALSE;
1038 }
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by IMPQueryIMEW().

◆ ImmIMPSetIMEA()

BOOL WINAPI ImmIMPSetIMEA ( HWND  hWnd,
LPIMEPROA  pImePro 
)

Definition at line 1043 of file utils.c.

1044 {
1045  FIXME("(%p, %p)\n", hWnd, pImePro);
1046  return FALSE;
1047 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by IMPSetIMEA().

◆ ImmIMPSetIMEW()

BOOL WINAPI ImmIMPSetIMEW ( HWND  hWnd,
LPIMEPROW  pImePro 
)

Definition at line 1052 of file utils.c.

1053 {
1054  FIXME("(%p, %p)\n", hWnd, pImePro);
1055  return FALSE;
1056 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by IMPSetIMEW().

◆ ImmLockIMCC()

◆ ImmReSizeIMCC()

HIMCC WINAPI ImmReSizeIMCC ( HIMCC  imcc,
DWORD  size 
)

Definition at line 965 of file utils.c.

966 {
967  if (!imcc)
968  return NULL;
969  return LocalReAlloc(imcc, size, LHND);
970 }
GLsizeiptr size
Definition: glext.h:5919
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1608
#define LHND
Definition: winbase.h:379
#define NULL
Definition: types.h:112

Referenced by Imm32SelectLayout(), and test_ImmMessages().

◆ ImmUnlockIMCC()

◆ LogFontAnsiToWide()

VOID APIENTRY LogFontAnsiToWide ( const LOGFONTA plfA,
LPLOGFONTW  plfW 
)

Definition at line 120 of file utils.c.

121 {
122  size_t cch;
123  RtlCopyMemory(plfW, plfA, offsetof(LOGFONTA, lfFaceName));
126  plfW->lfFaceName, _countof(plfW->lfFaceName));
127  if (cch > _countof(plfW->lfFaceName) - 1)
128  cch = _countof(plfW->lfFaceName) - 1;
129  plfW->lfFaceName[cch] = 0;
130 }
#define CP_ACP
Definition: compat.h:109
#define MB_PRECOMPOSED
Definition: winnls.h:281
int32_t INT
Definition: typedefs.h:58
#define offsetof(TYPE, MEMBER)
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:832
#define MultiByteToWideChar
Definition: compat.h:110
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
WCHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1910
IN PCTCH IN DWORD cch
Definition: pager.h:36

Referenced by Imm32ProcessRequest(), Imm32SelectLayout(), ImmGetCompositionFontW(), and ImmSetCompositionFontA().

◆ LogFontWideToAnsi()

VOID APIENTRY LogFontWideToAnsi ( const LOGFONTW plfW,
LPLOGFONTA  plfA 
)

Definition at line 132 of file utils.c.

133 {
134  size_t cch;
135  RtlCopyMemory(plfA, plfW, offsetof(LOGFONTW, lfFaceName));
138  plfA->lfFaceName, _countof(plfA->lfFaceName), NULL, NULL);
139  if (cch > _countof(plfA->lfFaceName) - 1)
140  cch = _countof(plfA->lfFaceName) - 1;
141  plfA->lfFaceName[cch] = 0;
142 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
int32_t INT
Definition: typedefs.h:58
CHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1894
#define offsetof(TYPE, MEMBER)
#define _countof(array)
Definition: sndvol32.h:68
#define NULL
Definition: types.h:112
STRSAFEAPI StringCchLengthW(STRSAFE_LPCWSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:842
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
IN PCTCH IN DWORD cch
Definition: pager.h:36

Referenced by Imm32ProcessRequest(), Imm32SelectLayout(), ImmGetCompositionFontA(), and ImmSetCompositionFontW().

◆ ValidateHandleNoErr()

LPVOID FASTCALL ValidateHandleNoErr ( HANDLE  hObject,
UINT  uType 
)

Definition at line 144 of file utils.c.

145 {
146  INT index;
150 
151  if (!NtUserValidateHandleSecure(hObject))
152  return NULL;
153 
154  ht = g_SharedInfo.aheList; /* handle table */
155  ASSERT(ht);
156  /* ReactOS-Specific! */
159 
160  index = (LOWORD(hObject) - FIRST_USER_HANDLE) >> 1;
161  if (index < 0 || ht->nb_handles <= index || he[index].type != uType)
162  return NULL;
163 
164  generation = HIWORD(hObject);
165  if (generation != he[index].generation && generation && generation != 0xFFFF)
166  return NULL;
167 
168  return &he[index];
169 }
#define FIRST_USER_HANDLE
Definition: ntuser.h:10
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
GLuint index
Definition: glext.h:6031
BOOL NTAPI NtUserValidateHandleSecure(HANDLE hHdl)
Definition: object.c:758
Definition: ntuser.h:16
struct _USER_HANDLE_ENTRY * PUSER_HANDLE_ENTRY
#define ASSERT(a)
Definition: mode.c:44
unsigned short WORD
Definition: ntddk_ex.h:93
#define index(s, c)
Definition: various.h:29
SHAREDINFO g_SharedInfo
Definition: imm.c:19
ULONG_PTR ulSharedDelta
Definition: ntuser.h:1091
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2929
static const struct newhuff ht[]
Definition: huffman.h:296
#define NULL
Definition: types.h:112
#define HIWORD(l)
Definition: typedefs.h:247
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define LOWORD(l)
Definition: pedump.c:82
PVOID aheList
Definition: ntuser.h:1089

Referenced by ValidateHwndNoErr().

◆ ValidateHwndNoErr()

PWND FASTCALL ValidateHwndNoErr ( HWND  hwnd)

Definition at line 171 of file utils.c.

172 {
173  /* See if the window is cached */
175  if (hwnd == ClientInfo->CallbackWnd.hWnd)
176  return ClientInfo->CallbackWnd.pWnd;
177 
179 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GetWin32ClientInfo()
Definition: ntuser.h:326
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:144
CLIENT_DATA ClientInfo

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( imm  )

Variable Documentation

◆ g_hImm32Heap

HANDLE g_hImm32Heap = NULL

Definition at line 17 of file utils.c.

Referenced by Imm32HeapAlloc().

◆ s_fnGetFileVersionInfoSizeW

FN_GetFileVersionInfoSizeW s_fnGetFileVersionInfoSizeW = NULL
static

Definition at line 517 of file utils.c.

Referenced by Imm32LoadImeVerInfo().

◆ s_fnGetFileVersionInfoW

FN_GetFileVersionInfoW s_fnGetFileVersionInfoW = NULL
static

Definition at line 516 of file utils.c.

Referenced by Imm32LoadImeVerInfo().

◆ s_fnVerQueryValueW

FN_VerQueryValueW s_fnVerQueryValueW = NULL
static

Definition at line 518 of file utils.c.

Referenced by Imm32GetVerInfoValue(), Imm32LoadImeFixedInfo(), and Imm32LoadImeLangAndDesc().