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

Go to the source code of this file.

Classes

struct  tagBITMAPCOREINFO256
 

Macros

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

Typedefs

typedef struct tagBITMAPCOREINFO256 BITMAPCOREINFO256
 
typedef struct tagBITMAPCOREINFO256PBITMAPCOREINFO256
 
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)
 
PTHREADINFO FASTCALL Imm32CurrentPti (VOID)
 
BOOL APIENTRY Imm32IsCrossThreadAccess (HIMC hIMC)
 
BOOL APIENTRY Imm32IsCrossProcessAccess (HWND hWnd)
 
HRESULT APIENTRY Imm32StrToUInt (LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
 
HRESULT APIENTRY Imm32UIntToStr (DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
 
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean (VOID)
 
HBITMAP Imm32LoadBitmapFromBytes (const BYTE *pb)
 
BOOL Imm32StoreBitmapToBytes (HBITMAP hbm, LPBYTE pbData, DWORD cbDataMax)
 
BOOL WINAPI Imm32IsImcAnsi (HIMC hIMC)
 
LPWSTR APIENTRY Imm32WideFromAnsi (UINT uCodePage, LPCSTR pszA)
 
LPSTR APIENTRY Imm32AnsiFromWide (UINT uCodePage, 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 pszLayoutText)
 
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)
#define GetProcAddress(x, y)
Definition: compat.h:753
Definition: name.c:39

◆ 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

◆ INITIAL_COUNT

#define INITIAL_COUNT   0x40

◆ MAX_PRELOAD

#define MAX_PRELOAD   0x400

◆ MAX_RETRY

#define MAX_RETRY   10

Typedef Documentation

◆ BITMAPCOREINFO256

◆ FN_GetFileVersionInfoSizeW

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

Definition at line 756 of file utils.c.

◆ FN_GetFileVersionInfoW

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

Definition at line 755 of file utils.c.

◆ FN_LZClose

typedef VOID(WINAPI * FN_LZClose) (INT)

Definition at line 1117 of file utils.c.

◆ FN_LZCopy

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

Definition at line 1116 of file utils.c.

◆ FN_LZOpenFileW

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

Definition at line 1115 of file utils.c.

◆ FN_VerQueryValueW

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

Definition at line 757 of file utils.c.

◆ PBITMAPCOREINFO256

Function Documentation

◆ DesktopPtrToUser()

static PVOID FASTCALL DesktopPtrToUser ( PVOID  ptr)
static

Definition at line 324 of file utils.c.

325{
328
329 ASSERT(ptr != NULL);
330 ASSERT(pdi != NULL);
331 if (pdi->pvDesktopBase <= ptr && ptr < pdi->pvDesktopLimit)
332 return (PVOID)((ULONG_PTR)ptr - pci->ulClientDelta);
333 else
335}
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
DWORD_PTR NTAPI NtUserCallOneParam(DWORD_PTR Param, DWORD Routine)
Definition: simplecall.c:153
#define ONEPARAM_ROUTINE_GETDESKTOPMAPPING
Definition: ntuser.h:3576
#define GetWin32ClientInfo()
Definition: ntuser.h:352
#define ASSERT(a)
Definition: mode.c:44
static PVOID ptr
Definition: dispmode.c:27
ULONG_PTR ulClientDelta
Definition: ntuser.h:326
PDESKTOPINFO pDeskInfo
Definition: ntuser.h:325
uint32_t DWORD_PTR
Definition: typedefs.h:65
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO * pdi
Definition: winddi.h:3554

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 273 of file utils.c.

274{
275 LONG cb, cchAnsi;
276 for (cchAnsi = 0; cchWide > 0; ++cchAnsi, ++pchWide, --cchWide)
277 {
278 cb = WideCharToMultiByte(uCodePage, 0, pchWide, 1, NULL, 0, NULL, NULL);
279 if (cb > 1)
280 ++cchAnsi;
281 }
282 return cchAnsi;
283}
#define WideCharToMultiByte
Definition: compat.h:111
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
long LONG
Definition: pedump.c:60

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

◆ IchWideFromAnsi()

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

Definition at line 252 of file utils.c.

253{
254 LONG cchWide;
255 for (cchWide = 0; cchAnsi > 0; ++cchWide)
256 {
257 if (IsDBCSLeadByteEx(uCodePage, *pchAnsi) && pchAnsi[1])
258 {
259 cchAnsi -= 2;
260 pchAnsi += 2;
261 }
262 else
263 {
264 --cchAnsi;
265 ++pchAnsi;
266 }
267 }
268 return cchWide;
269}
BOOL WINAPI IsDBCSLeadByteEx(UINT codepage, BYTE testchar)
Definition: locale.c:2103

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

◆ Imm32AnsiFromWide()

LPSTR APIENTRY Imm32AnsiFromWide ( UINT  uCodePage,
LPCWSTR  pszW 
)

Definition at line 238 of file utils.c.

239{
240 INT cchW = lstrlenW(pszW);
241 INT cchA = (cchW + 1) * sizeof(WCHAR);
242 LPSTR pszA = ImmLocalAlloc(0, cchA);
243 if (IS_NULL_UNEXPECTEDLY(pszA))
244 return NULL;
245 cchA = WideCharToMultiByte(uCodePage, 0, pszW, cchW, pszA, cchA, NULL, NULL);
246 pszA[cchA] = 0;
247 return pszA;
248}
#define lstrlenW
Definition: compat.h:750
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:125
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
int32_t INT
Definition: typedefs.h:58
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

◆ Imm32AssignNewLayout()

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

Definition at line 902 of file utils.c.

903{
904 UINT iKL, wID, wLow = 0xE0FF, wHigh = 0xE01F, wNextID = 0;
905
906 for (iKL = 0; iKL < cKLs; ++iKL)
907 {
908 wHigh = max(wHigh, HIWORD(pLayouts[iKL].hKL));
909 wLow = min(wLow, HIWORD(pLayouts[iKL].hKL));
910 }
911
912 if (wHigh < 0xE0FF)
913 {
914 wNextID = wHigh + 1;
915 }
916 else if (wLow > 0xE001)
917 {
918 wNextID = wLow - 1;
919 }
920 else
921 {
922 for (wID = 0xE020; wID <= 0xE0FF; ++wID)
923 {
924 for (iKL = 0; iKL < cKLs; ++iKL)
925 {
926 if (LOWORD(pLayouts[iKL].hKL) == wLangID &&
927 HIWORD(pLayouts[iKL].hKL) == wID)
928 {
929 break;
930 }
931 }
932
933 if (iKL >= cKLs)
934 break;
935 }
936
937 if (wID <= 0xE0FF)
938 wNextID = wID;
939 }
940
941 if (!wNextID)
942 return NULL;
943
944 return (HKL)(DWORD_PTR)MAKELONG(wLangID, wNextID);
945}
#define min(a, b)
Definition: monoChain.cc:55
UINT_PTR HKL
Definition: msctf.idl:143
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define max(a, b)
Definition: svc.c:63
#define DWORD_PTR
Definition: treelist.c:76
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by ImmInstallIMEW().

◆ Imm32BuildHimcList()

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

Definition at line 460 of file utils.c.

461{
462#define INITIAL_COUNT 0x40
463#define MAX_RETRY 10
465 DWORD dwCount = INITIAL_COUNT, cRetry = 0;
466 HIMC *phNewList;
467
468 phNewList = ImmLocalAlloc(0, dwCount * sizeof(HIMC));
469 if (IS_NULL_UNEXPECTEDLY(phNewList))
470 return 0;
471
472 Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
474 {
475 ImmLocalFree(phNewList);
476 if (cRetry++ >= MAX_RETRY)
477 return 0;
478
479 phNewList = ImmLocalAlloc(0, dwCount * sizeof(HIMC));
480 if (IS_NULL_UNEXPECTEDLY(phNewList))
481 return 0;
482
483 Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
484 }
485
486 if (NT_ERROR(Status) || !dwCount)
487 {
488 ERR("Abnormal status\n");
489 ImmLocalFree(phNewList);
490 return 0;
491 }
492
493 *pphList = phNewList;
494 return dwCount;
495#undef INITIAL_COUNT
496#undef MAX_RETRY
497}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD HIMC
Definition: dimm.idl:75
#define ImmLocalFree(lpData)
Definition: precomp.h:89
#define MAX_RETRY
#define INITIAL_COUNT
DWORD dwThreadId
Definition: fdebug.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCount)
Definition: ime.c:690
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define NT_ERROR(Status)
Definition: umtypes.h:106

Referenced by ImmEnumInputContext().

◆ Imm32CheckImcProcess()

BOOL APIENTRY Imm32CheckImcProcess ( PIMC  pIMC)

Definition at line 391 of file utils.c.

392{
393 HIMC hIMC;
394 DWORD_PTR dwPID1, dwPID2;
395
396 if (IS_NULL_UNEXPECTEDLY(pIMC))
397 return FALSE;
398
399 if (pIMC->head.pti == Imm32CurrentPti())
400 return TRUE;
401
402 hIMC = pIMC->head.h;
404 dwPID2 = (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
405 if (dwPID1 != dwPID2)
406 {
407 WARN("PID 0x%X != 0x%X\n", dwPID1, dwPID2);
408 return FALSE;
409 }
410
411 return TRUE;
412}
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: utils.c:19
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1791
#define NtCurrentTeb
#define DWORD
Definition: nt_native.h:44
THRDESKHEAD head
Definition: ntuser.h:200
@ QIC_INPUTPROCESSID
Definition: undocuser.h:392

Referenced by ImmLockClientImc().

◆ Imm32CopyImeFile()

BOOL APIENTRY Imm32CopyImeFile ( LPWSTR  pszOldFile,
LPCWSTR  pszNewFile 
)

Definition at line 1120 of file utils.c.

1121{
1122 BOOL ret = FALSE, bLoaded = FALSE;
1123 HMODULE hinstLZ32;
1124 WCHAR szLZ32Path[MAX_PATH];
1125 CHAR szDestA[MAX_PATH];
1126 OFSTRUCT OFStruct;
1127 FN_LZOpenFileW fnLZOpenFileW;
1128 FN_LZCopy fnLZCopy;
1129 FN_LZClose fnLZClose;
1130 HFILE hfDest, hfSrc;
1131
1132 /* Load LZ32.dll for copying/decompressing file */
1133 Imm32GetSystemLibraryPath(szLZ32Path, _countof(szLZ32Path), L"LZ32");
1134 hinstLZ32 = GetModuleHandleW(szLZ32Path);
1135 if (!hinstLZ32)
1136 {
1137 hinstLZ32 = LoadLibraryW(szLZ32Path);
1138 if (IS_NULL_UNEXPECTEDLY(hinstLZ32))
1139 return FALSE;
1140 bLoaded = TRUE;
1141 }
1142
1143#define GET_FN(name) do { \
1144 fn##name = (FN_##name)GetProcAddress(hinstLZ32, #name); \
1145 if (!fn##name) goto Quit; \
1146} while (0)
1148 GET_FN(LZCopy);
1149 GET_FN(LZClose);
1150#undef GET_FN
1151
1152 if (!WideCharToMultiByte(CP_ACP, 0, pszNewFile, -1, szDestA, _countof(szDestA), NULL, NULL))
1153 goto Quit;
1154 szDestA[_countof(szDestA) - 1] = 0;
1155
1156 hfSrc = fnLZOpenFileW(pszOldFile, &OFStruct, OF_READ);
1157 if (hfSrc < 0)
1158 goto Quit;
1159
1160 hfDest = OpenFile(szDestA, &OFStruct, OF_CREATE);
1161 if (hfDest != HFILE_ERROR)
1162 {
1163 ret = (fnLZCopy(hfSrc, hfDest) >= 0);
1164 _lclose(hfDest);
1165 }
1166
1167 fnLZClose(hfSrc);
1168
1169Quit:
1170 if (bLoaded)
1171 FreeLibrary(hinstLZ32);
1172 return ret;
1173}
#define CP_ACP
Definition: compat.h:109
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define LoadLibraryW(x)
Definition: compat.h:747
INT(WINAPI * FN_LZOpenFileW)(LPWSTR, LPOFSTRUCT, WORD)
Definition: utils.c:1115
#define GET_FN(name)
LONG(WINAPI * FN_LZCopy)(INT, INT)
Definition: utils.c:1116
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:286
VOID(WINAPI * FN_LZClose)(INT)
Definition: utils.c:1117
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle)
Definition: create.c:368
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI _lclose(HFILE hFile)
Definition: lfile.c:138
HFILE WINAPI LZOpenFileW(LPWSTR fn, LPOFSTRUCT ofs, WORD mode)
Definition: lzexpand.c:580
LONG WINAPI LZCopy(HFILE src, HFILE dest)
Definition: lzexpand.c:467
void WINAPI LZClose(HFILE fd)
Definition: lzexpand.c:595
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:70
int ret
#define HFILE_ERROR
Definition: winbase.h:111
#define OF_READ
Definition: winbase.h:116
#define OF_CREATE
Definition: winbase.h:125
int HFILE
Definition: windef.h:298
char CHAR
Definition: xmlstorage.h:175

Referenced by ImmInstallIMEW().

◆ Imm32CurrentPti()

PTHREADINFO FASTCALL Imm32CurrentPti ( VOID  )

Definition at line 19 of file utils.c.

20{
21 if (NtCurrentTeb()->Win32ThreadInfo == NULL)
23 return NtCurrentTeb()->Win32ThreadInfo;
24}
@ THREADSTATE_GETTHREADINFO
Definition: ntuser.h:2490
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:240

Referenced by Imm32CheckImcProcess(), Imm32DestroyInputContext(), and ImmRequestMessageAW().

◆ Imm32FetchImeState()

PIME_STATE APIENTRY Imm32FetchImeState ( LPINPUTCONTEXTDX  pIC,
HKL  hKL 
)

Definition at line 552 of file utils.c.

553{
554 PIME_STATE pState;
555 WORD Lang = PRIMARYLANGID(LOWORD(hKL));
556 for (pState = pIC->pState; pState; pState = pState->pNext)
557 {
558 if (pState->wLang == Lang)
559 break;
560 }
561 if (!pState)
562 {
563 pState = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(IME_STATE));
564 if (pState)
565 {
566 pState->wLang = Lang;
567 pState->pNext = pIC->pState;
568 pIC->pState = pState;
569 }
570 }
571 return pState;
572}
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned short WORD
Definition: ntddk_ex.h:93
#define PRIMARYLANGID(l)
Definition: nls.h:16
WORD wLang
Definition: imm32_undoc.h:183
struct IME_STATE * pNext
Definition: imm32_undoc.h:182
struct IME_STATE * pState
Definition: imm32_undoc.h:164

Referenced by Imm32SelectInputContext().

◆ Imm32FetchImeSubState()

PIME_SUBSTATE APIENTRY Imm32FetchImeSubState ( PIME_STATE  pState,
HKL  hKL 
)

Definition at line 576 of file utils.c.

577{
578 PIME_SUBSTATE pSubState;
579 for (pSubState = pState->pSubState; pSubState; pSubState = pSubState->pNext)
580 {
581 if (pSubState->hKL == hKL)
582 return pSubState;
583 }
584 pSubState = ImmLocalAlloc(0, sizeof(IME_SUBSTATE));
585 if (!pSubState)
586 return NULL;
587 pSubState->dwValue = 0;
588 pSubState->hKL = hKL;
589 pSubState->pNext = pState->pSubState;
590 pState->pSubState = pSubState;
591 return pSubState;
592}
PIME_SUBSTATE pSubState
Definition: imm32_undoc.h:188
struct IME_SUBSTATE * pNext
Definition: imm32_undoc.h:171

Referenced by Imm32LoadImeStateSentence(), and Imm32SaveImeStateSentence().

◆ Imm32GetImeLayout()

UINT APIENTRY Imm32GetImeLayout ( PREG_IME  pLayouts,
UINT  cLayouts 
)

Definition at line 948 of file utils.c.

949{
950 HKEY hkeyLayouts, hkeyIME;
951 WCHAR szImeFileName[80], szImeKey[20];
952 UINT iKey, nCount;
953 DWORD cbData;
954 LONG lError;
955 ULONG Value;
956 HKL hKL;
957
958 /* Open the registry keyboard layouts */
960 if (IS_ERROR_UNEXPECTEDLY(lError))
961 return 0;
962
963 for (iKey = nCount = 0; ; ++iKey)
964 {
965 /* Get the key name */
966 lError = RegEnumKeyW(hkeyLayouts, iKey, szImeKey, _countof(szImeKey));
967 if (lError != ERROR_SUCCESS)
968 break;
969
970 if (szImeKey[0] != L'E' && szImeKey[0] != L'e')
971 continue; /* Not an IME layout */
972
973 if (pLayouts == NULL) /* for counting only */
974 {
975 ++nCount;
976 continue;
977 }
978
979 if (cLayouts <= nCount)
980 break;
981
982 lError = RegOpenKeyW(hkeyLayouts, szImeKey, &hkeyIME); /* Open the IME key */
983 if (IS_ERROR_UNEXPECTEDLY(lError))
984 continue;
985
986 /* Load the "Ime File" value */
987 szImeFileName[0] = 0;
988 cbData = sizeof(szImeFileName);
989 RegQueryValueExW(hkeyIME, L"Ime File", NULL, NULL, (LPBYTE)szImeFileName, &cbData);
990 szImeFileName[_countof(szImeFileName) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
991
992 RegCloseKey(hkeyIME);
993
994 /* We don't allow the invalid "IME File" values for security reason */
995 if (!szImeFileName[0] || wcscspn(szImeFileName, L":\\/") != wcslen(szImeFileName))
996 {
997 WARN("\n");
998 continue;
999 }
1000
1001 Imm32StrToUInt(szImeKey, &Value, 16);
1002 hKL = (HKL)(DWORD_PTR)Value;
1003 if (!IS_IME_HKL(hKL)) /* Not an IME */
1004 {
1005 WARN("\n");
1006 continue;
1007 }
1008
1009 /* Store the IME key and the IME filename */
1010 pLayouts[nCount].hKL = hKL;
1011 StringCchCopyW(pLayouts[nCount].szImeKey, _countof(pLayouts[nCount].szImeKey), szImeKey);
1012 CharUpperW(szImeFileName);
1013 StringCchCopyW(pLayouts[nCount].szFileName, _countof(pLayouts[nCount].szFileName),
1014 szImeFileName);
1015 ++nCount;
1016 }
1017
1018 RegCloseKey(hkeyLayouts);
1019 return nCount;
1020}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
#define IS_ERROR_UNEXPECTEDLY(x)
Definition: precomp.h:141
HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
Definition: utils.c:43
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:20
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
_Check_return_ _CRTIMP size_t __cdecl wcscspn(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
HKL hKL
Definition: precomp.h:66
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
LPWSTR WINAPI CharUpperW(_Inout_ LPWSTR)

Referenced by ImmInstallIMEW().

◆ Imm32GetSystemLibraryPath()

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

Definition at line 286 of file utils.c.

287{
288 if (!pszFileName[0] || !GetSystemDirectoryW(pszPath, cchPath))
289 {
290 ERR("Invalid filename\n");
291 return FALSE;
292 }
293 StringCchCatW(pszPath, cchPath, L"\\");
294 StringCchCatW(pszPath, cchPath, pszFileName);
295 return TRUE;
296}
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44

Referenced by Imm32CopyImeFile(), Imm32GetFn(), Imm32LoadCtfIme(), Imm32LoadIME(), Imm32LoadImeVerInfo(), and ImmInstallIMEW().

◆ Imm32GetVerInfoValue()

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

Definition at line 788 of file utils.c.

789{
790 size_t cchExtra;
791 LPWSTR pszValue;
792 UINT cbValue = 0;
793
794 StringCchLengthW(pszKey, cchKey, &cchExtra);
795
796 StringCchCatW(pszKey, cchKey, pszName);
797 s_fnVerQueryValueW(pVerInfo, pszKey, (LPVOID*)&pszValue, &cbValue);
798 pszKey[cchExtra] = 0;
799
800 return (cbValue ? pszValue : NULL);
801}
static FN_VerQueryValueW s_fnVerQueryValueW
Definition: utils.c:761
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 501 of file utils.c.

503{
504 INT ret;
505 pItemW->cbSize = pItemA->cbSize;
506 pItemW->fType = pItemA->fType;
507 pItemW->fState = pItemA->fState;
508 pItemW->wID = pItemA->wID;
509 if (bBitmap)
510 {
511 pItemW->hbmpChecked = pItemA->hbmpChecked;
512 pItemW->hbmpUnchecked = pItemA->hbmpUnchecked;
513 pItemW->hbmpItem = pItemA->hbmpItem;
514 }
515 pItemW->dwItemData = pItemA->dwItemData;
516 ret = MultiByteToWideChar(uCodePage, 0, pItemA->szString, -1,
517 pItemW->szString, _countof(pItemW->szString));
518 if (ret >= _countof(pItemW->szString))
519 {
520 ret = 0;
521 pItemW->szString[0] = 0;
522 }
523 return ret;
524}
#define MultiByteToWideChar
Definition: compat.h:110
DWORD dwItemData
Definition: dimm.idl:124
HBITMAP hbmpItem
Definition: dimm.idl:126
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:125
HBITMAP hbmpChecked
Definition: dimm.idl:122
HBITMAP hbmpUnchecked
Definition: dimm.idl:123

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32ImeMenuWideToAnsi()

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

Definition at line 528 of file utils.c.

530{
531 INT ret;
532 pItemA->cbSize = pItemW->cbSize;
533 pItemA->fType = pItemW->fType;
534 pItemA->fState = pItemW->fState;
535 pItemA->wID = pItemW->wID;
536 pItemA->hbmpChecked = pItemW->hbmpChecked;
537 pItemA->hbmpUnchecked = pItemW->hbmpUnchecked;
538 pItemA->dwItemData = pItemW->dwItemData;
539 pItemA->hbmpItem = pItemW->hbmpItem;
540 ret = WideCharToMultiByte(uCodePage, 0, pItemW->szString, -1,
541 pItemA->szString, _countof(pItemA->szString), NULL, NULL);
542 if (ret >= _countof(pItemA->szString))
543 {
544 ret = 0;
545 pItemA->szString[0] = 0;
546 }
547 return ret;
548}
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:137
HBITMAP hbmpUnchecked
Definition: dimm.idl:135
HBITMAP hbmpItem
Definition: dimm.idl:138
DWORD dwItemData
Definition: dimm.idl:136
HBITMAP hbmpChecked
Definition: dimm.idl:134

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32IsCrossProcessAccess()

BOOL APIENTRY Imm32IsCrossProcessAccess ( HWND  hWnd)

Definition at line 34 of file utils.c.

35{
37 DWORD_PTR CurrentPID = (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
38 return WndPID != CurrentPID;
39}
HWND hWnd
Definition: settings.c:17
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:4189
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2827

◆ Imm32IsCrossThreadAccess()

BOOL APIENTRY Imm32IsCrossThreadAccess ( HIMC  hIMC)

Definition at line 26 of file utils.c.

27{
29 DWORD_PTR dwCurrentThreadId = GetCurrentThreadId();
30 return dwImeThreadId != dwCurrentThreadId;
31}
@ QIC_INPUTTHREADID
Definition: undocuser.h:393
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by ImmSetCompositionWindow().

◆ Imm32IsImcAnsi()

BOOL WINAPI Imm32IsImcAnsi ( HIMC  hIMC)

Definition at line 216 of file utils.c.

217{
218 BOOL ret;
219 PCLIENTIMC pClientImc = ImmLockClientImc(hIMC);
220 if (IS_NULL_UNEXPECTEDLY(pClientImc))
221 return -1;
222 ret = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
223 ImmUnlockClientImc(pClientImc);
224 return ret;
225}
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:983
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:937
#define CLIENTIMC_WIDE
Definition: imm32_undoc.h:138

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32IsSystemJapaneseOrKorean()

BOOL APIENTRY Imm32IsSystemJapaneseOrKorean ( VOID  )

Definition at line 69 of file utils.c.

70{
73 WORD wPrimary = PRIMARYLANGID(LangID);
74 if (wPrimary != LANG_JAPANESE || wPrimary != LANG_KOREAN)
75 {
76 TRACE("The country has no special IME support\n");
77 return FALSE;
78 }
79 return TRUE;
80}
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1229
USHORT LANGID
Definition: mui.h:9
#define LANGIDFROMLCID(l)
Definition: nls.h:18
DWORD LCID
Definition: nls.h:13
#define LANG_JAPANESE
Definition: nls.h:76
#define LANG_KOREAN
Definition: nls.h:84
#define TRACE(s)
Definition: solgame.cpp:4
_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:1083

Referenced by ImmWINNLSEnableIME(), and ImmWINNLSGetEnableStatus().

◆ Imm32LoadBitmapFromBytes()

HBITMAP Imm32LoadBitmapFromBytes ( const BYTE pb)

Definition at line 88 of file utils.c.

89{
91 const BITMAPCOREINFO256 *pbmci;
92 LPVOID pvBits;
93 DWORD ib, cbBytes, cColors;
94 BITMAP bm;
95
96 cbBytes = *(const DWORD *)pb;
97 if (cbBytes == 0)
98 return NULL;
99
100 pb += sizeof(DWORD);
101 ib = sizeof(DWORD);
102
103 pbmci = (const BITMAPCOREINFO256 *)pb;
104 hbm = CreateDIBSection(NULL, (LPBITMAPINFO)pbmci, DIB_RGB_COLORS, &pvBits, NULL, 0);
105 if (!hbm || !GetObject(hbm, sizeof(BITMAP), &bm))
106 {
107 ERR("Invalid bitmap\n");
108 return NULL;
109 }
110
111 switch (pbmci->bmciHeader.bcBitCount)
112 {
113 case 1: cColors = 2; break;
114 case 4: cColors = 16; break;
115 case 8: cColors = 256; break;
116 case 24: case 32:
117 cColors = 0;
118 break;
119 default:
120 ERR("Invalid bitmap\n");
122 return NULL;
123 }
124
125 ib += sizeof(BITMAPCOREHEADER);
126 pb += sizeof(BITMAPCOREHEADER);
127
128 ib += cColors * sizeof(RGBTRIPLE);
129 pb += cColors * sizeof(RGBTRIPLE);
130
131 ib += bm.bmWidthBytes * bm.bmHeight;
132 if (ib > cbBytes)
133 {
134 ERR("Invalid bitmap\n");
136 return NULL;
137 }
138 RtlCopyMemory(pvBits, pb, bm.bmWidthBytes * bm.bmHeight);
139
140 return hbm;
141}
pKey DeleteObject()
static HBITMAP
Definition: button.c:44
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
Definition: bl.h:1331
BITMAPCOREHEADER bmciHeader
Definition: utils.c:84
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
struct tagRGBTRIPLE RGBTRIPLE
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
#define GetObject
Definition: wingdi.h:4468

Referenced by Imm32GetImeMenuItemWInterProcess().

◆ Imm32LoadImeFixedInfo()

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

Definition at line 764 of file utils.c.

765{
766 UINT cbFixed = 0;
767 VS_FIXEDFILEINFO *pFixed;
768 if (!s_fnVerQueryValueW(pVerInfo, L"\\", (LPVOID*)&pFixed, &cbFixed) || !cbFixed)
769 {
770 ERR("Fixed version info not available\n");
771 return FALSE;
772 }
773
774 /* NOTE: The IME module must contain a version info of input method driver. */
775 if (pFixed->dwFileType != VFT_DRV || pFixed->dwFileSubtype != VFT2_DRV_INPUTMETHOD)
776 {
777 ERR("DLL %S is not an IME\n", pInfoEx->wszImeFile);
778 return FALSE;
779 }
780
781 pInfoEx->dwProdVersion = pFixed->dwProductVersionMS;
782 pInfoEx->dwImeWinVersion = 0x40000;
783 return TRUE;
784}
DWORD dwProdVersion
Definition: imm32_undoc.h:35
WCHAR wszImeFile[80]
Definition: imm32_undoc.h:38
DWORD dwImeWinVersion
Definition: imm32_undoc.h:36
#define VFT_DRV
Definition: verrsrc.h:77
#define VFT2_DRV_INPUTMETHOD
Definition: verrsrc.h:95

Referenced by Imm32LoadImeVerInfo().

◆ Imm32LoadImeLangAndDesc()

BOOL APIENTRY Imm32LoadImeLangAndDesc ( PIMEINFOEX  pInfoEx,
LPCVOID  pVerInfo 
)

Definition at line 804 of file utils.c.

805{
806 BOOL ret;
807 WCHAR szKey[80];
808 LPWSTR pszDesc;
809 LPWORD pw;
810 UINT cbData;
812
813 /* Getting the version info. See VerQueryValue */
814 ret = s_fnVerQueryValueW(pVerInfo, L"\\VarFileInfo\\Translation", (LPVOID*)&pw, &cbData);
815 if (!ret || !cbData)
816 {
817 ERR("Translation not available\n");
818 return FALSE;
819 }
820
821 if (pInfoEx->hkl == NULL)
822 pInfoEx->hkl = (HKL)(DWORD_PTR)*pw;
823
824 /* Try the current language and the Unicode codepage (0x04B0) */
826 StringCchPrintfW(szKey, _countof(szKey), L"\\StringFileInfo\\%04X04B0\\", LangID);
827 pszDesc = Imm32GetVerInfoValue(pVerInfo, szKey, _countof(szKey), L"FileDescription");
828 if (!pszDesc)
829 {
830 /* Retry the language and codepage of the IME module */
831 StringCchPrintfW(szKey, _countof(szKey), L"\\StringFileInfo\\%04X%04X\\", pw[0], pw[1]);
832 pszDesc = Imm32GetVerInfoValue(pVerInfo, szKey, _countof(szKey), L"FileDescription");
833 }
834
835 /* The description */
836 if (pszDesc)
837 StringCchCopyW(pInfoEx->wszImeDescription, _countof(pInfoEx->wszImeDescription), pszDesc);
838 else
839 pInfoEx->wszImeDescription[0] = 0;
840
841 return TRUE;
842}
static LPWSTR APIENTRY Imm32GetVerInfoValue(LPCVOID pVerInfo, LPWSTR pszKey, DWORD cchKey, LPCWSTR pszName)
Definition: utils.c:788
LCID WINAPI GetThreadLocale(void)
Definition: locale.c:2800
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
WCHAR wszImeDescription[50]
Definition: imm32_undoc.h:37
uint16_t * LPWORD
Definition: typedefs.h:56

Referenced by Imm32LoadImeVerInfo().

◆ Imm32LoadImeStateSentence()

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

Definition at line 596 of file utils.c.

597{
598 PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
599 if (IS_NULL_UNEXPECTEDLY(pSubState))
600 return FALSE;
601
602 pIC->fdwSentence |= pSubState->dwValue;
603 return TRUE;
604}
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:576

Referenced by Imm32SelectInputContext().

◆ Imm32LoadImeVerInfo()

BOOL APIENTRY Imm32LoadImeVerInfo ( PIMEINFOEX  pImeInfoEx)

Definition at line 845 of file utils.c.

846{
847 HINSTANCE hinstVersion;
848 BOOL ret = FALSE, bLoaded = FALSE;
850 LPVOID pVerInfo;
851 DWORD cbVerInfo, dwHandle;
852
853 /* Load version.dll to use the version info API */
855 hinstVersion = GetModuleHandleW(szPath);
856 if (!hinstVersion)
857 {
858 hinstVersion = LoadLibraryW(szPath);
859 if (IS_NULL_UNEXPECTEDLY(hinstVersion))
860 return FALSE;
861
862 bLoaded = TRUE;
863 }
864
865#define GET_FN(name) do { \
866 s_fn##name = (FN_##name)GetProcAddress(hinstVersion, #name); \
867 if (!s_fn##name) goto Quit; \
868} while (0)
872#undef GET_FN
873
874 /* The path of the IME module */
876
877 cbVerInfo = s_fnGetFileVersionInfoSizeW(szPath, &dwHandle);
878 if (IS_ZERO_UNEXPECTEDLY(cbVerInfo))
879 goto Quit;
880
881 pVerInfo = ImmLocalAlloc(0, cbVerInfo);
882 if (IS_NULL_UNEXPECTEDLY(pVerInfo))
883 goto Quit;
884
885 /* Load the version info of the IME module */
886 if (s_fnGetFileVersionInfoW(szPath, dwHandle, cbVerInfo, pVerInfo) &&
887 Imm32LoadImeFixedInfo(pImeInfoEx, pVerInfo))
888 {
889 ret = Imm32LoadImeLangAndDesc(pImeInfoEx, pVerInfo);
890 }
891
892 ImmLocalFree(pVerInfo);
893
894Quit:
895 if (bLoaded)
896 FreeLibrary(hinstVersion);
897 TRACE("ret: %d\n", ret);
898 return ret;
899}
#define IS_ZERO_UNEXPECTEDLY(p)
Definition: precomp.h:129
static FN_GetFileVersionInfoW s_fnGetFileVersionInfoW
Definition: utils.c:759
static FN_GetFileVersionInfoSizeW s_fnGetFileVersionInfoSizeW
Definition: utils.c:760
BOOL APIENTRY Imm32LoadImeLangAndDesc(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:804
static BOOL APIENTRY Imm32LoadImeFixedInfo(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:764
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
LPCWSTR szPath
Definition: env.c:37

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 428 of file utils.c.

430{
432 HKL hKL;
433 PIMEDPI pImeDpi;
434
435 if (dwAction != 0)
436 {
438 if (dwThreadId)
439 {
440 /* find keyboard layout and lock it */
442 pImeDpi = ImmLockImeDpi(hKL);
443 if (pImeDpi)
444 {
445 /* do notify */
446 pImeDpi->NotifyIME(hIMC, dwAction, dwIndex, dwValue);
447
448 ImmUnlockImeDpi(pImeDpi); /* unlock */
449 }
450 }
451 }
452
453 if (hwnd && dwCommand)
455
456 return TRUE;
457}
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:978
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:1007
static HANDLE ULONG_PTR dwData
Definition: file.c:35
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
#define WM_IME_NOTIFY
Definition: winuser.h:1830
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

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

◆ Imm32ReconvertAnsiFromWide()

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

Definition at line 691 of file utils.c.

692{
693 DWORD cch0, cch1, cchDest, cbDest;
694 LPCWSTR pchSrc = (LPCWSTR)((LPCSTR)pSrc + pSrc->dwStrOffset);
695 LPSTR pchDest;
696
697 if (pSrc->dwVersion != 0)
698 {
699 ERR("\n");
700 return 0;
701 }
702
703 cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
704 NULL, 0, NULL, NULL);
705 cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(CHAR);
706 if (!pDest)
707 return cbDest;
708
709 if (pDest->dwSize < cbDest)
710 {
711 ERR("Too small\n");
712 return 0;
713 }
714
715 /* dwSize */
716 pDest->dwSize = cbDest;
717
718 /* dwVersion */
719 pDest->dwVersion = 0;
720
721 /* dwStrOffset */
722 pDest->dwStrOffset = sizeof(RECONVERTSTRING);
723
724 /* dwCompStrOffset */
725 cch1 = pSrc->dwCompStrOffset / sizeof(WCHAR);
726 cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
727 pDest->dwCompStrOffset = cch0 * sizeof(CHAR);
728
729 /* dwCompStrLen */
730 cch0 = IchAnsiFromWide(cch1 + pSrc->dwCompStrLen, pchSrc, uCodePage);
731 pDest->dwCompStrLen = cch0 * sizeof(CHAR) - pDest->dwCompStrOffset;
732
733 /* dwTargetStrOffset */
734 cch1 = pSrc->dwTargetStrOffset / sizeof(WCHAR);
735 cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
736 pDest->dwTargetStrOffset = cch0 * sizeof(CHAR);
737
738 /* dwTargetStrLen */
739 cch0 = IchAnsiFromWide(cch1 + pSrc->dwTargetStrLen, pchSrc, uCodePage);
740 pDest->dwTargetStrLen = cch0 * sizeof(CHAR) - pDest->dwTargetStrOffset;
741
742 /* dwStrLen */
743 pDest->dwStrLen = cchDest;
744
745 /* the string */
746 pchDest = (LPSTR)pDest + pDest->dwStrOffset;
747 cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
748 pchDest, cchDest, NULL, NULL);
749 pchDest[cchDest] = 0;
750
751 TRACE("cchDest: 0x%X\n", cchDest);
752 return cbDest;
753}
#define CHAR(Char)
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:273
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32ReconvertWideFromAnsi()

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

Definition at line 628 of file utils.c.

629{
630 DWORD cch0, cchDest, cbDest;
631 LPCSTR pchSrc = (LPCSTR)pSrc + pSrc->dwStrOffset;
632 LPWSTR pchDest;
633
634 if (pSrc->dwVersion != 0)
635 {
636 ERR("\n");
637 return 0;
638 }
639
640 cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
641 NULL, 0);
642 cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(WCHAR);
643 if (!pDest)
644 return cbDest;
645
646 if (pDest->dwSize < cbDest)
647 {
648 ERR("Too small\n");
649 return 0;
650 }
651
652 /* dwSize */
653 pDest->dwSize = cbDest;
654
655 /* dwVersion */
656 pDest->dwVersion = 0;
657
658 /* dwStrOffset */
659 pDest->dwStrOffset = sizeof(RECONVERTSTRING);
660
661 /* dwCompStrOffset */
662 cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset, pchSrc, uCodePage);
663 pDest->dwCompStrOffset = cch0 * sizeof(WCHAR);
664
665 /* dwCompStrLen */
666 cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset + pSrc->dwCompStrLen, pchSrc, uCodePage);
667 pDest->dwCompStrLen = (cch0 * sizeof(WCHAR) - pDest->dwCompStrOffset) / sizeof(WCHAR);
668
669 /* dwTargetStrOffset */
670 cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset, pchSrc, uCodePage);
671 pDest->dwTargetStrOffset = cch0 * sizeof(WCHAR);
672
673 /* dwTargetStrLen */
674 cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset + pSrc->dwTargetStrLen, pchSrc, uCodePage);
675 pDest->dwTargetStrLen = (cch0 * sizeof(WCHAR) - pSrc->dwTargetStrOffset) / sizeof(WCHAR);
676
677 /* dwStrLen */
678 pDest->dwStrLen = cchDest;
679
680 /* the string */
681 pchDest = (LPWSTR)((LPBYTE)pDest + pDest->dwStrOffset);
682 cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
683 pchDest, cchDest);
684 pchDest[cchDest] = 0;
685
686 TRACE("cbDest: 0x%X\n", cbDest);
687 return cbDest;
688}
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:252
if(dx< 0)
Definition: linetemp.h:194
#define MB_PRECOMPOSED
Definition: winnls.h:281

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32SaveImeStateSentence()

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

Definition at line 608 of file utils.c.

609{
610 PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
611 if (IS_NULL_UNEXPECTEDLY(pSubState))
612 return FALSE;
613
614 pSubState->dwValue = (pIC->fdwSentence & 0xffff0000);
615 return TRUE;
616}

Referenced by Imm32SelectInputContext().

◆ Imm32StoreBitmapToBytes()

BOOL Imm32StoreBitmapToBytes ( HBITMAP  hbm,
LPBYTE  pbData,
DWORD  cbDataMax 
)

Definition at line 143 of file utils.c.

144{
145 HDC hDC;
146 BITMAP bm;
147 DWORD cbBytes, cColors;
149 BOOL ret;
150 LPBYTE pb = pbData;
151
152 *(LPDWORD)pb = 0;
153
154 if (!GetObject(hbm, sizeof(BITMAP), &bm))
155 {
156 ERR("Invalid bitmap\n");
157 return FALSE;
158 }
159
160 ZeroMemory(&bmci, sizeof(bmci));
161 bmci.bmciHeader.bcSize = sizeof(BITMAPCOREHEADER);
162 bmci.bmciHeader.bcWidth = bm.bmWidth;
163 bmci.bmciHeader.bcHeight = bm.bmHeight;
164 bmci.bmciHeader.bcPlanes = 1;
165 bmci.bmciHeader.bcBitCount = bm.bmBitsPixel;
166
167 switch (bm.bmBitsPixel)
168 {
169 case 1: cColors = 2; break;
170 case 4: cColors = 16; break;
171 case 8: cColors = 256; break;
172 case 24: case 32:
173 cColors = 0;
174 break;
175 default:
176 ERR("Invalid bitmap\n");
177 return FALSE;
178 }
179
180 cbBytes = sizeof(DWORD);
181 cbBytes += sizeof(BITMAPCOREHEADER);
182 cbBytes += cColors * sizeof(RGBTRIPLE);
183 cbBytes += bm.bmWidthBytes * bm.bmHeight;
184 if (cbBytes > cbDataMax)
185 {
186 ERR("Too small\n");
187 return FALSE;
188 }
189
191
192 ret = GetDIBits(hDC, hbm, 0, bm.bmHeight, NULL, (LPBITMAPINFO)&bmci, DIB_RGB_COLORS);
193
194 if (ret)
195 {
196 *(LPDWORD)pb = cbBytes;
197 pb += sizeof(DWORD);
198
199 RtlCopyMemory(pb, &bmci.bmciHeader, sizeof(BITMAPCOREHEADER));
200 pb += sizeof(BITMAPCOREHEADER);
201
202 RtlCopyMemory(pb, &bmci.bmciColors, cColors * sizeof(RGBTRIPLE));
203 pb += cColors * sizeof(RGBTRIPLE);
204
205 ret = GetDIBits(hDC, hbm, 0, bm.bmHeight, pb, (LPBITMAPINFO)&bmci, DIB_RGB_COLORS);
206 if (!ret)
207 *(LPDWORD)pbData = 0;
208 }
209
210 DeleteDC(hDC);
211
212 return ret;
213}
static HDC hDC
Definition: 3dtext.c:33
static HDC
Definition: imagelist.c:92
#define LPDWORD
Definition: nt_native.h:46
RGBTRIPLE bmciColors[256]
Definition: utils.c:85
#define ZeroMemory
Definition: winbase.h:1712
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by ImmPutImeMenuItemsIntoMappedFile().

◆ Imm32StrToUInt()

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

Definition at line 43 of file utils.c.

44{
49 if (!NT_SUCCESS(Status))
50 return E_FAIL;
51 return S_OK;
52}
#define E_FAIL
Definition: ddrawi.h:102
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define S_OK
Definition: intsafe.h:52
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)

Referenced by Imm32GetImeLayout(), and Imm32UnitTest().

◆ Imm32UIntToStr()

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

Definition at line 56 of file utils.c.

57{
60 UnicodeString.Buffer = pszBuff;
61 UnicodeString.MaximumLength = cchBuff * sizeof(WCHAR);
63 if (!NT_SUCCESS(Status))
64 return E_FAIL;
65 return S_OK;
66}
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)

Referenced by Imm32UnitTest(), and Imm32WriteImeLayout().

◆ Imm32WideFromAnsi()

LPWSTR APIENTRY Imm32WideFromAnsi ( UINT  uCodePage,
LPCSTR  pszA 
)

Definition at line 227 of file utils.c.

228{
229 INT cch = lstrlenA(pszA);
230 LPWSTR pszW = ImmLocalAlloc(0, (cch + 1) * sizeof(WCHAR));
231 if (IS_NULL_UNEXPECTEDLY(pszW))
232 return NULL;
233 cch = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pszA, cch, pszW, cch + 1);
234 pszW[cch] = 0;
235 return pszW;
236}
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202

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

◆ Imm32WriteImeLayout()

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

Definition at line 1023 of file utils.c.

1024{
1025 UINT iPreload;
1026 HKEY hkeyLayouts, hkeyIME, hkeyPreload;
1027 WCHAR szImeKey[20], szPreloadNumber[20], szPreloadKey[20];
1028 DWORD cbData;
1029 LANGID LangID;
1030 LONG lError;
1031 LPCWSTR pszLayoutFile;
1032
1033 /* Open the registry keyboard layouts */
1035 if (IS_ERROR_UNEXPECTEDLY(lError))
1036 return FALSE;
1037
1038 /* Get the IME key from hKL */
1039 StringCchPrintf(szImeKey, _countof(szImeKey), L"%08X", (DWORD)(DWORD_PTR)hKL);
1040
1041 /* Create a registry IME key */
1042 lError = RegCreateKeyW(hkeyLayouts, szImeKey, &hkeyIME);
1043 if (IS_ERROR_UNEXPECTEDLY(lError))
1044 goto Failure;
1045
1046 /* Write "Ime File" */
1047 cbData = (wcslen(pchFilePart) + 1) * sizeof(WCHAR);
1048 lError = RegSetValueExW(hkeyIME, L"Ime File", 0, REG_SZ, (LPBYTE)pchFilePart, cbData);
1049 if (IS_ERROR_UNEXPECTEDLY(lError))
1050 goto Failure;
1051
1052 /* Write "Layout Text" */
1053 cbData = (wcslen(pszLayoutText) + 1) * sizeof(WCHAR);
1054 lError = RegSetValueExW(hkeyIME, L"Layout Text", 0, REG_SZ, (LPBYTE)pszLayoutText, cbData);
1055 if (IS_ERROR_UNEXPECTEDLY(lError))
1056 goto Failure;
1057
1058 /* Choose "Layout File" from hKL */
1059 LangID = LOWORD(hKL);
1060 switch (LOBYTE(LangID))
1061 {
1062 case LANG_JAPANESE: pszLayoutFile = L"kbdjpn.dll"; break;
1063 case LANG_KOREAN: pszLayoutFile = L"kbdkor.dll"; break;
1064 default: pszLayoutFile = L"kbdus.dll"; break;
1065 }
1066
1067 /* Write "Layout File" */
1068 cbData = (wcslen(pszLayoutFile) + 1) * sizeof(WCHAR);
1069 lError = RegSetValueExW(hkeyIME, L"Layout File", 0, REG_SZ, (LPBYTE)pszLayoutFile, cbData);
1070 if (IS_ERROR_UNEXPECTEDLY(lError))
1071 goto Failure;
1072
1073 RegCloseKey(hkeyIME);
1074 RegCloseKey(hkeyLayouts);
1075
1076 /* Create "Preload" key */
1077 RegCreateKeyW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", &hkeyPreload);
1078
1079#define MAX_PRELOAD 0x400
1080 for (iPreload = 1; iPreload < MAX_PRELOAD; ++iPreload)
1081 {
1082 Imm32UIntToStr(iPreload, 10, szPreloadNumber, _countof(szPreloadNumber));
1083
1084 /* Load the key of the preload number */
1085 cbData = sizeof(szPreloadKey);
1086 lError = RegQueryValueExW(hkeyPreload, szPreloadNumber, NULL, NULL,
1087 (LPBYTE)szPreloadKey, &cbData);
1088 szPreloadKey[_countof(szPreloadKey) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
1089
1090 if (lError != ERROR_SUCCESS || lstrcmpiW(szImeKey, szPreloadKey) == 0)
1091 break; /* Found an empty room or the same key */
1092 }
1093
1094 if (iPreload >= MAX_PRELOAD) /* Not found */
1095 {
1096 ERR("\n");
1097 RegCloseKey(hkeyPreload);
1098 return FALSE;
1099 }
1100#undef MAX_PRELOAD
1101
1102 /* Write the IME key to the preload number */
1103 cbData = (wcslen(szImeKey) + 1) * sizeof(WCHAR);
1104 lError = RegSetValueExW(hkeyPreload, szPreloadNumber, 0, REG_SZ, (LPBYTE)szImeKey, cbData);
1105 RegCloseKey(hkeyPreload);
1106 return lError == ERROR_SUCCESS;
1107
1108Failure:
1109 RegCloseKey(hkeyIME);
1110 RegDeleteKeyW(hkeyLayouts, szImeKey);
1111 RegCloseKey(hkeyLayouts);
1112 return FALSE;
1113}
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:4882
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
#define MAX_PRELOAD
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:56
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
#define LOBYTE(W)
Definition: jmemdos.c:487
#define REG_SZ
Definition: layer.c:22
#define StringCchPrintf
Definition: strsafe.h:517
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by ImmInstallIMEW().

◆ ImmCreateIMCC()

HIMCC WINAPI ImmCreateIMCC ( DWORD  size)

Definition at line 1178 of file utils.c.

1179{
1180 if (size < sizeof(DWORD))
1181 size = sizeof(DWORD);
1182 return LocalAlloc(LHND, size);
1183}
GLsizeiptr size
Definition: glext.h:5919
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
#define LHND
Definition: winbase.h:382

Referenced by CicIMCLock::ClearCand(), CicBridge::CreateInputContext(), Imm32CreateInputContext(), Imm32SelectInputContext(), START_TEST(), test_ImmDestroyIMCC(), and test_ImmGetIMCCLockCount().

◆ ImmDestroyIMCC()

HIMCC WINAPI ImmDestroyIMCC ( HIMCC  block)

Definition at line 1188 of file utils.c.

1189{
1190 if (block)
1191 return LocalFree(block);
1192 return NULL;
1193}
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static unsigned int block
Definition: xmlmemory.c:101

Referenced by CicIMCLock::ClearCand(), CicBridge::DestroyInputContext(), Imm32CreateInputContext(), Imm32DestroyInputContext(), Imm32SelectInputContext(), START_TEST(), test_ImmDestroyIMCC(), and test_ImmGetIMCCLockCount().

◆ ImmGetIMCCLockCount()

DWORD WINAPI ImmGetIMCCLockCount ( HIMCC  imcc)

Definition at line 1218 of file utils.c.

1219{
1220 return LocalFlags(imcc) & LMEM_LOCKCOUNT;
1221}
UINT NTAPI LocalFlags(HLOCAL hMem)
Definition: heapmem.c:1520
#define LMEM_LOCKCOUNT
Definition: winbase.h:379

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

◆ ImmGetIMCCSize()

DWORD WINAPI ImmGetIMCCSize ( HIMCC  imcc)

Definition at line 1236 of file utils.c.

1237{
1238 if (imcc)
1239 return LocalSize(imcc);
1240 return 0;
1241}
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1794

Referenced by Imm32SelectInputContext(), START_TEST(), Test1(), test_ImmDestroyIMCC(), and CicIMCLock::ValidCompositionString().

◆ ImmGetIMCLockCount()

DWORD WINAPI ImmGetIMCLockCount ( HIMC  hIMC)

Definition at line 1246 of file utils.c.

1247{
1248 DWORD ret;
1249 HANDLE hInputContext;
1250 PCLIENTIMC pClientImc;
1251
1252 pClientImc = ImmLockClientImc(hIMC);
1253 if (IS_NULL_UNEXPECTEDLY(pClientImc))
1254 return 0;
1255
1256 ret = 0;
1257 hInputContext = pClientImc->hInputContext;
1258 if (hInputContext)
1259 ret = (LocalFlags(hInputContext) & LMEM_LOCKCOUNT);
1260
1261 ImmUnlockClientImc(pClientImc);
1262 return ret;
1263}
HANDLE hInputContext
Definition: imm32_undoc.h:116

Referenced by test_ImmDestroyContext(), and test_ImmGetIMCLockCount().

◆ ImmIMPGetIMEA()

BOOL WINAPI ImmIMPGetIMEA ( HWND  hWnd,
LPIMEPROA  pImePro 
)

Definition at line 1268 of file utils.c.

1269{
1270 FIXME("(%p, %p)\n", hWnd, pImePro);
1271 return FALSE;
1272}
#define FIXME(fmt,...)
Definition: precomp.h:53

Referenced by IMPGetIMEA().

◆ ImmIMPGetIMEW()

BOOL WINAPI ImmIMPGetIMEW ( HWND  hWnd,
LPIMEPROW  pImePro 
)

Definition at line 1277 of file utils.c.

1278{
1279 FIXME("(%p, %p)\n", hWnd, pImePro);
1280 return FALSE;
1281}

Referenced by IMPGetIMEW().

◆ ImmIMPQueryIMEA()

BOOL WINAPI ImmIMPQueryIMEA ( LPIMEPROA  pImePro)

Definition at line 1286 of file utils.c.

1287{
1288 FIXME("(%p)\n", pImePro);
1289 return FALSE;
1290}

Referenced by IMPQueryIMEA().

◆ ImmIMPQueryIMEW()

BOOL WINAPI ImmIMPQueryIMEW ( LPIMEPROW  pImePro)

Definition at line 1295 of file utils.c.

1296{
1297 FIXME("(%p)\n", pImePro);
1298 return FALSE;
1299}

Referenced by IMPQueryIMEW().

◆ ImmIMPSetIMEA()

BOOL WINAPI ImmIMPSetIMEA ( HWND  hWnd,
LPIMEPROA  pImePro 
)

Definition at line 1304 of file utils.c.

1305{
1306 FIXME("(%p, %p)\n", hWnd, pImePro);
1307 return FALSE;
1308}

Referenced by IMPSetIMEA().

◆ ImmIMPSetIMEW()

BOOL WINAPI ImmIMPSetIMEW ( HWND  hWnd,
LPIMEPROW  pImePro 
)

Definition at line 1313 of file utils.c.

1314{
1315 FIXME("(%p, %p)\n", hWnd, pImePro);
1316 return FALSE;
1317}

Referenced by IMPSetIMEW().

◆ ImmLocalAlloc()

◆ ImmLockIMCC()

◆ ImmReSizeIMCC()

HIMCC WINAPI ImmReSizeIMCC ( HIMCC  imcc,
DWORD  size 
)

Definition at line 1226 of file utils.c.

1227{
1228 if (!imcc)
1229 return NULL;
1230 return LocalReAlloc(imcc, size, LHND);
1231}
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1625

Referenced by CicIMCLock::ClearCand(), Imm32SelectInputContext(), and test_ImmMessages().

◆ ImmUnlockIMCC()

◆ LogFontAnsiToWide()

VOID APIENTRY LogFontAnsiToWide ( const LOGFONTA plfA,
LPLOGFONTW  plfW 
)

Definition at line 299 of file utils.c.

300{
301 size_t cch;
302 RtlCopyMemory(plfW, plfA, offsetof(LOGFONTA, lfFaceName));
305 plfW->lfFaceName, _countof(plfW->lfFaceName));
306 if (cch > _countof(plfW->lfFaceName) - 1)
307 cch = _countof(plfW->lfFaceName) - 1;
308 plfW->lfFaceName[cch] = 0;
309}
#define offsetof(TYPE, MEMBER)
STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:832
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
WCHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1910

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

◆ LogFontWideToAnsi()

VOID APIENTRY LogFontWideToAnsi ( const LOGFONTW plfW,
LPLOGFONTA  plfA 
)

Definition at line 312 of file utils.c.

313{
314 size_t cch;
315 RtlCopyMemory(plfA, plfW, offsetof(LOGFONTW, lfFaceName));
318 plfA->lfFaceName, _countof(plfA->lfFaceName), NULL, NULL);
319 if (cch > _countof(plfA->lfFaceName) - 1)
320 cch = _countof(plfA->lfFaceName) - 1;
321 plfA->lfFaceName[cch] = 0;
322}
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
CHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1894

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

◆ ValidateHandle()

LPVOID FASTCALL ValidateHandle ( HANDLE  hObject,
UINT  uType 
)

Definition at line 377 of file utils.c.

378{
379 LPVOID pvObj = ValidateHandleNoErr(hObject, uType);
380 if (pvObj)
381 return pvObj;
382
383 if (uType == TYPE_WINDOW)
385 else
387 return NULL;
388}
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:338
@ TYPE_WINDOW
Definition: ntuser.h:41
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881

◆ ValidateHandleNoErr()

LPVOID FASTCALL ValidateHandleNoErr ( HANDLE  hObject,
UINT  uType 
)

Definition at line 338 of file utils.c.

339{
340 UINT index;
344 LPVOID ptr;
345
346 if (!NtUserValidateHandleSecure(hObject))
347 {
348 WARN("Not a handle\n");
349 return NULL;
350 }
351
352 ht = gSharedInfo.aheList; /* handle table */
353 ASSERT(ht);
354 /* ReactOS-Specific! */
357
358 index = (LOWORD(hObject) - FIRST_USER_HANDLE) >> 1;
359 if ((INT)index < 0 || ht->nb_handles <= index || he[index].type != uType)
360 return NULL;
361
363 return NULL;
364
365 generation = HIWORD(hObject);
366 if (generation != he[index].generation && generation && generation != 0xFFFF)
367 return NULL;
368
369 ptr = he[index].ptr;
370 if (ptr)
372
373 return ptr;
374}
#define index(s, c)
Definition: various.h:29
SHAREDINFO gSharedInfo
Definition: imm.c:19
static PVOID FASTCALL DesktopPtrToUser(PVOID ptr)
Definition: utils.c:324
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2996
GLuint index
Definition: glext.h:6031
GLbitfield flags
Definition: glext.h:7161
static const struct newhuff ht[]
Definition: huffman.h:296
#define HANDLEENTRY_DESTROY
Definition: ntuser.h:13
BOOL NTAPI NtUserValidateHandleSecure(HANDLE hHdl)
Definition: object.c:792
struct _USER_HANDLE_ENTRY * PUSER_HANDLE_ENTRY
#define FIRST_USER_HANDLE
Definition: ntuser.h:10
PVOID aheList
Definition: ntuser.h:1131
ULONG_PTR ulSharedDelta
Definition: ntuser.h:1133
Definition: ntuser.h:17
void * ptr
Definition: ntuser.h:18
unsigned char type
Definition: ntuser.h:25
uint32_t ULONG_PTR
Definition: typedefs.h:65

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 760 of file utils.c.

Referenced by Imm32LoadImeVerInfo().

◆ s_fnGetFileVersionInfoW

FN_GetFileVersionInfoW s_fnGetFileVersionInfoW = NULL
static

Definition at line 759 of file utils.c.

Referenced by Imm32LoadImeVerInfo().

◆ s_fnVerQueryValueW

FN_VerQueryValueW s_fnVerQueryValueW = NULL
static

Definition at line 761 of file utils.c.

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