ReactOS  0.4.15-dev-4570-g4f8bbd1
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 APIENTRY Imm32IsSystemJapaneseOrKorean (VOID)
 
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)
 
static PVOID FASTCALL DesktopPtrToUser (PVOID ptr)
 
LPVOID FASTCALL ValidateHandleNoErr (HANDLE hObject, UINT uType)
 
LPVOID FASTCALL ValidateHandle (HANDLE hObject, UINT uType)
 
BOOL APIENTRY Imm32CheckImcProcess (PIMC pIMC)
 
LPVOID APIENTRY ImmLocalAlloc (DWORD dwFlags, DWORD dwBytes)
 
BOOL APIENTRY Imm32MakeIMENotify (HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue, DWORD_PTR dwCommand, DWORD_PTR dwData)
 
DWORD APIENTRY Imm32BuildHimcList (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 Imm32AssignNewLayout (UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
 
UINT APIENTRY Imm32GetImeLayout (PREG_IME pLayouts, UINT cLayouts)
 
BOOL APIENTRY Imm32WriteImeLayout (HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout)
 
BOOL APIENTRY Imm32CopyImeFile (LPWSTR pszOldFile, LPCWSTR pszNewFile)
 
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 ghImmHeap = 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 562 of file utils.c.

◆ FN_GetFileVersionInfoW

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

Definition at line 561 of file utils.c.

◆ FN_LZClose

typedef VOID(WINAPI * FN_LZClose) (INT)

Definition at line 905 of file utils.c.

◆ FN_LZCopy

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

Definition at line 904 of file utils.c.

◆ FN_LZOpenFileW

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

Definition at line 903 of file utils.c.

◆ FN_VerQueryValueW

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

Definition at line 563 of file utils.c.

Function Documentation

◆ DesktopPtrToUser()

static PVOID FASTCALL DesktopPtrToUser ( PVOID  ptr)
static

Definition at line 157 of file utils.c.

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 }
DWORD_PTR NTAPI NtUserCallOneParam(DWORD_PTR Param, DWORD Routine)
Definition: simplecall.c:149
#define GetWin32ClientInfo()
Definition: ntuser.h:335
static PVOID ptr
Definition: dispmode.c:27
ULONG_PTR ulClientDelta
Definition: ntuser.h:309
#define ASSERT(a)
Definition: mode.c:44
PDESKTOPINFO pDeskInfo
Definition: ntuser.h:308
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define ONEPARAM_ROUTINE_GETDESKTOPMAPPING
Definition: ntuser.h:3661
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3553

Referenced by CallNextHookEx(), GetAncestor(), GetClassLongA(), GetClassLongW(), GetClassWord(), GetLastActivePopup(), GetMenuItemInfo_common(), GetMenuState(), GetMenuStringA(), GetMenuStringW(), GetParent(), GetSubMenu(), GetThreadDesktopWnd(), GetWindow(), GetWindowInfo(), IntCallMessageProc(), IntFindChildWindowToOwner(), IntGetMenuDefaultItem(), IntGetSBData(), IntGetWndProc(), IntScrollGetScrollBarRect(), IsChild(), IsWindowVisible(), MENU_FindItem(), RealDefWindowProcA(), RealDefWindowProcW(), User32DefWindowProc(), ValidateHandle(), and ValidateHandleNoErr().

◆ IchAnsiFromWide()

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

Definition at line 109 of file utils.c.

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 }
#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 89 of file utils.c.

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 }
BOOL WINAPI IsDBCSLeadByteEx(UINT CodePage, BYTE TestByte)
Definition: nls.c:2248
long LONG
Definition: pedump.c:60

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

◆ Imm32AnsiFromWide()

LPSTR APIENTRY Imm32AnsiFromWide ( LPCWSTR  pszW)

Definition at line 76 of file utils.c.

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 }
#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 ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#define NULL
Definition: types.h:112

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

◆ Imm32AssignNewLayout()

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

Definition at line 697 of file utils.c.

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 }
#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().

◆ Imm32BuildHimcList()

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

Definition at line 279 of file utils.c.

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 }
NTSTATUS NTAPI NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCount)
Definition: ime.c:697
#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
#define ImmLocalFree(lpData)
Definition: precomp.h:89
DWORD dwThreadId
Definition: fdebug.c:31
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#define NULL
Definition: types.h:112
#define INITIAL_COUNT

Referenced by ImmEnumInputContext().

◆ Imm32CheckImcProcess()

BOOL APIENTRY Imm32CheckImcProcess ( PIMC  pIMC)

Definition at line 221 of file utils.c.

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 }
#define DWORD_PTR
Definition: treelist.c:76
#define TRUE
Definition: types.h:120
static PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: precomp.h:162
#define DWORD
Definition: nt_native.h:44
DWORD HIMC
Definition: dimm.idl:75
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1773
unsigned long DWORD
Definition: ntddk_ex.h:95
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
THRDESKHEAD head
Definition: ntuser.h:192

Referenced by ImmLockClientImc().

◆ Imm32CopyImeFile()

BOOL APIENTRY Imm32CopyImeFile ( LPWSTR  pszOldFile,
LPCWSTR  pszNewFile 
)

Definition at line 908 of file utils.c.

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 }
#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:903
LONG(WINAPI * FN_LZCopy)(INT, INT)
Definition: utils.c:904
#define LoadLibraryW(x)
Definition: compat.h:606
VOID(WINAPI * FN_LZClose)(INT)
Definition: utils.c:905
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:122
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 370 of file utils.c.

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 }
WORD wLang
Definition: immdev.h:192
unsigned short WORD
Definition: ntddk_ex.h:93
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
struct IME_STATE * pState
Definition: immdev.h:111
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
struct IME_STATE * pNext
Definition: immdev.h:191
#define LOWORD(l)
Definition: pedump.c:82
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by Imm32SelectInputContext().

◆ Imm32FetchImeSubState()

PIME_SUBSTATE APIENTRY Imm32FetchImeSubState ( PIME_STATE  pState,
HKL  hKL 
)

Definition at line 394 of file utils.c.

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 }
PIME_SUBSTATE pSubState
Definition: immdev.h:197
DWORD dwValue
Definition: immdev.h:182
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#define NULL
Definition: types.h:112
struct IME_SUBSTATE * pNext
Definition: immdev.h:180

Referenced by Imm32LoadImeStateSentence(), and Imm32SaveImeStateSentence().

◆ Imm32GetImeLayout()

UINT APIENTRY Imm32GetImeLayout ( PREG_IME  pLayouts,
UINT  cLayouts 
)

Definition at line 743 of file utils.c.

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 }
#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:1203
_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:47
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ImmInstallIMEW().

◆ Imm32GetSystemLibraryPath()

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

Definition at line 122 of file utils.c.

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 }
#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 Imm32CopyImeFile(), Imm32LoadIME(), Imm32LoadImeVerInfo(), and ImmInstallIMEW().

◆ Imm32GetVerInfoValue()

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

Definition at line 588 of file utils.c.

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 }
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
static FN_VerQueryValueW s_fnVerQueryValueW
Definition: utils.c:567
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().

◆ Imm32ImeMenuAnsiToWide()

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

Definition at line 319 of file utils.c.

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 }
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 ImmGetImeMenuItemsAW().

◆ Imm32ImeMenuWideToAnsi()

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

Definition at line 346 of file utils.c.

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 }
#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 ImmGetImeMenuItemsAW().

◆ Imm32IsImcAnsi()

BOOL WINAPI Imm32IsImcAnsi ( HIMC  hIMC)

Definition at line 54 of file utils.c.

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 }
#define CLIENTIMC_WIDE
Definition: ntuser.h:1325
unsigned int BOOL
Definition: ntddk_ex.h:94
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
int ret
DWORD dwFlags
Definition: ntuser.h:1305
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32IsSystemJapaneseOrKorean()

BOOL APIENTRY Imm32IsSystemJapaneseOrKorean ( VOID  )

Definition at line 45 of file utils.c.

46 {
47  LCID lcid = GetSystemDefaultLCID();
49  WORD wPrimary = PRIMARYLANGID(LangID);
50  return (wPrimary == LANG_JAPANESE || wPrimary == LANG_KOREAN);
51 }
DWORD LCID
Definition: nls.h:13
WORD LANGID
Definition: typedefs.h:81
#define LANG_JAPANESE
Definition: nls.h:76
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
unsigned short WORD
Definition: ntddk_ex.h:93
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#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 PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by ImmWINNLSGetEnableStatus().

◆ Imm32LoadImeFixedInfo()

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

Definition at line 570 of file utils.c.

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 }
DWORD dwProdVersion
Definition: ntuser.h:1184
#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:567
unsigned int UINT
Definition: ndis.h:50
#define VFT2_DRV_INPUTMETHOD
Definition: verrsrc.h:95
DWORD dwImeWinVersion
Definition: ntuser.h:1185

Referenced by Imm32LoadImeVerInfo().

◆ Imm32LoadImeLangAndDesc()

BOOL APIENTRY Imm32LoadImeLangAndDesc ( PIMEINFOEX  pInfoEx,
LPCVOID  pVerInfo 
)

Definition at line 604 of file utils.c.

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 }
#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:588
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:1186
static FN_VerQueryValueW s_fnVerQueryValueW
Definition: utils.c:567
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 414 of file utils.c.

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 }
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:394
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD dwValue
Definition: immdev.h:182

Referenced by Imm32SelectInputContext().

◆ Imm32LoadImeVerInfo()

BOOL APIENTRY Imm32LoadImeVerInfo ( PIMEINFOEX  pImeInfoEx)

Definition at line 642 of file utils.c.

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 }
#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:566
#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:570
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GET_FN(name)
#define ImmLocalFree(lpData)
Definition: precomp.h:89
int ret
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:122
static FN_GetFileVersionInfoW s_fnGetFileVersionInfoW
Definition: utils.c:565
WCHAR wszImeFile[80]
Definition: ntuser.h:1187
LPCWSTR szPath
Definition: env.c:37
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
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
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().

◆ Imm32MakeIMENotify()

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

Definition at line 247 of file utils.c.

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 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:758
#define WM_IME_NOTIFY
Definition: winuser.h:1817
#define TRUE
Definition: types.h:120
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define DWORD
Definition: nt_native.h:44
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1773
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:729
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
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022

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

◆ Imm32ReconvertAnsiFromWide()

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

Definition at line 504 of file utils.c.

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 }
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
struct tagRECONVERTSTRING RECONVERTSTRING
DWORD dwCompStrOffset
Definition: imm.h:102
char * LPSTR
Definition: xmlstorage.h:182
DWORD dwVersion
Definition: imm.h:98
DWORD dwCompStrLen
Definition: imm.h:101
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:109
#define CHAR(Char)

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32ReconvertWideFromAnsi()

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

Definition at line 448 of file utils.c.

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 }
DWORD dwTargetStrOffset
Definition: imm.h:104
DWORD dwSize
Definition: imm.h:97
struct tagRECONVERTSTRING RECONVERTSTRING
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:89
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 ImmSetCompositionStringAW().

◆ Imm32SaveImeStateSentence()

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

Definition at line 427 of file utils.c.

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 }
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:394
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD dwValue
Definition: immdev.h:182

Referenced by Imm32SelectInputContext().

◆ 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 Imm32GetImeLayout().

◆ Imm32UIntToStr()

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

Definition at line 33 of file utils.c.

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 }
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 Imm32WriteImeLayout(), ImmInstallIMEW(), and ImmLoadLayout().

◆ Imm32WideFromAnsi()

LPWSTR APIENTRY Imm32WideFromAnsi ( LPCSTR  pszA)

Definition at line 65 of file utils.c.

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 }
#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
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#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().

◆ Imm32WriteImeLayout()

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

Definition at line 811 of file utils.c.

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 }
#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:33
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:47
#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 966 of file utils.c.

967 {
968  if (size < sizeof(DWORD))
969  size = sizeof(DWORD);
970  return LocalAlloc(LHND, size);
971 }
#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 Imm32CreateInputContext(), Imm32SelectInputContext(), START_TEST(), test_ImmDestroyIMCC(), and test_ImmGetIMCCLockCount().

◆ ImmDestroyIMCC()

HIMCC WINAPI ImmDestroyIMCC ( HIMCC  block)

Definition at line 976 of file utils.c.

977 {
978  if (block)
979  return LocalFree(block);
980  return NULL;
981 }
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 Imm32CreateInputContext(), Imm32DestroyInputContext(), Imm32SelectInputContext(), START_TEST(), test_ImmDestroyIMCC(), and test_ImmGetIMCCLockCount().

◆ ImmGetIMCCLockCount()

DWORD WINAPI ImmGetIMCCLockCount ( HIMCC  imcc)

Definition at line 1006 of file utils.c.

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

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

◆ ImmGetIMCCSize()

DWORD WINAPI ImmGetIMCCSize ( HIMCC  imcc)

Definition at line 1024 of file utils.c.

1025 {
1026  if (imcc)
1027  return LocalSize(imcc);
1028  return 0;
1029 }
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777

Referenced by Imm32SelectInputContext(), START_TEST(), Test1(), and test_ImmDestroyIMCC().

◆ ImmGetIMCLockCount()

DWORD WINAPI ImmGetIMCLockCount ( HIMC  hIMC)

Definition at line 1034 of file utils.c.

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 }
#define LMEM_LOCKCOUNT
Definition: winbase.h:376
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
HANDLE hInputContext
Definition: ntuser.h:1303
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:954

Referenced by test_ImmDestroyContext(), and test_ImmGetIMCLockCount().

◆ ImmIMPGetIMEA()

BOOL WINAPI ImmIMPGetIMEA ( HWND  hWnd,
LPIMEPROA  pImePro 
)

Definition at line 1056 of file utils.c.

1057 {
1058  FIXME("(%p, %p)\n", hWnd, pImePro);
1059  return FALSE;
1060 }
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 1065 of file utils.c.

1066 {
1067  FIXME("(%p, %p)\n", hWnd, pImePro);
1068  return FALSE;
1069 }
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 1074 of file utils.c.

1075 {
1076  FIXME("(%p)\n", pImePro);
1077  return FALSE;
1078 }
#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 1083 of file utils.c.

1084 {
1085  FIXME("(%p)\n", pImePro);
1086  return FALSE;
1087 }
#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 1092 of file utils.c.

1093 {
1094  FIXME("(%p, %p)\n", hWnd, pImePro);
1095  return FALSE;
1096 }
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 1101 of file utils.c.

1102 {
1103  FIXME("(%p, %p)\n", hWnd, pImePro);
1104  return FALSE;
1105 }
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

Referenced by IMPSetIMEW().

◆ ImmLocalAlloc()

LPVOID APIENTRY ImmLocalAlloc ( DWORD  dwFlags,
DWORD  dwBytes 
)

◆ ImmLockIMCC()

◆ ImmReSizeIMCC()

HIMCC WINAPI ImmReSizeIMCC ( HIMCC  imcc,
DWORD  size 
)

Definition at line 1014 of file utils.c.

1015 {
1016  if (!imcc)
1017  return NULL;
1018  return LocalReAlloc(imcc, size, LHND);
1019 }
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 Imm32SelectInputContext(), and test_ImmMessages().

◆ ImmUnlockIMCC()

◆ LogFontAnsiToWide()

VOID APIENTRY LogFontAnsiToWide ( const LOGFONTA plfA,
LPLOGFONTW  plfW 
)

Definition at line 132 of file utils.c.

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 }
#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(), Imm32SelectInputContext(), ImmGetCompositionFontW(), and ImmSetCompositionFontA().

◆ LogFontWideToAnsi()

VOID APIENTRY LogFontWideToAnsi ( const LOGFONTW plfW,
LPLOGFONTA  plfA 
)

Definition at line 145 of file utils.c.

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 }
#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(), Imm32SelectInputContext(), ImmGetCompositionFontA(), and ImmSetCompositionFontW().

◆ ValidateHandle()

LPVOID FASTCALL ValidateHandle ( HANDLE  hObject,
UINT  uType 
)

Definition at line 207 of file utils.c.

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 }
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:171
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define SetLastError(x)
Definition: compat.h:611
#define NULL
Definition: types.h:112

◆ ValidateHandleNoErr()

LPVOID FASTCALL ValidateHandleNoErr ( HANDLE  hObject,
UINT  uType 
)

Definition at line 171 of file utils.c.

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 }
unsigned char type
Definition: ntuser.h:25
#define FIRST_USER_HANDLE
Definition: ntuser.h:10
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
static PVOID ptr
Definition: dispmode.c:27
GLuint index
Definition: glext.h:6031
BOOL NTAPI NtUserValidateHandleSecure(HANDLE hHdl)
Definition: object.c:792
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
GLbitfield flags
Definition: glext.h:7161
SHAREDINFO gSharedInfo
Definition: imm.c:18
#define index(s, c)
Definition: various.h:29
ULONG_PTR ulSharedDelta
Definition: ntuser.h:1100
#define HANDLEENTRY_DESTROY
Definition: ntuser.h:13
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2964
static const struct newhuff ht[]
Definition: huffman.h:296
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static PVOID FASTCALL DesktopPtrToUser(PVOID ptr)
Definition: utils.c:157
#define HIWORD(l)
Definition: typedefs.h:247
void * ptr
Definition: ntuser.h:18
#define LOWORD(l)
Definition: pedump.c:82
PVOID aheList
Definition: ntuser.h:1098

Referenced by ValidateHandle().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( imm  )

Variable Documentation

◆ ghImmHeap

HANDLE ghImmHeap = NULL

Definition at line 16 of file utils.c.

Referenced by ImmLocalAlloc().

◆ s_fnGetFileVersionInfoSizeW

FN_GetFileVersionInfoSizeW s_fnGetFileVersionInfoSizeW = NULL
static

Definition at line 566 of file utils.c.

Referenced by Imm32LoadImeVerInfo().

◆ s_fnGetFileVersionInfoW

FN_GetFileVersionInfoW s_fnGetFileVersionInfoW = NULL
static

Definition at line 565 of file utils.c.

Referenced by Imm32LoadImeVerInfo().

◆ s_fnVerQueryValueW

FN_VerQueryValueW s_fnVerQueryValueW = NULL
static

Definition at line 567 of file utils.c.

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