ReactOS 0.4.15-dev-5669-g09dde2c
precomp.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <winnls.h>
#include <winreg.h>
#include <winnls32.h>
#include <winver.h>
#include <imm.h>
#include <ddk/immdev.h>
#include <ndk/umtypes.h>
#include <ndk/pstypes.h>
#include <ndk/rtlfuncs.h>
#include "ntuser.h"
#include "ntwin32.h"
#include <undocuser.h>
#include <imm32_undoc.h>
#include <strsafe.h>
#include <wine/debug.h>
#include <wine/list.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  REG_IME
 

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define IMM_INIT_MAGIC   0x19650412
 
#define IMM_INVALID_CANDFORM   ULONG_MAX
 
#define INVALID_HOTKEY_ID   0xFFFFFFFF
 
#define MAX_CANDIDATEFORM   4
 
#define MAX_IMM_FILENAME   80
 
#define LANGID_CHINESE_SIMPLIFIED   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
 
#define LANGID_CHINESE_TRADITIONAL   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
 
#define LANGID_JAPANESE   MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)
 
#define REGKEY_KEYBOARD_LAYOUTS   L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
 
#define REGKEY_IMM   L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"
 
#define ROUNDUP4(n)   (((n) + 3) & ~3) /* DWORD alignment */
 
#define ValidateHwndNoErr(hwnd)   ValidateHandleNoErr((hwnd), TYPE_WINDOW)
 
#define ValidateHwnd(hwnd)   ValidateHandle((hwnd), TYPE_WINDOW)
 
#define ImmLocalFree(lpData)   HeapFree(ghImmHeap, 0, (lpData))
 
#define UNEXPECTED()   0
 
#define IS_NULL_UNEXPECTEDLY(p)
 
#define IS_ZERO_UNEXPECTEDLY(p)
 
#define IS_TRUE_UNEXPECTEDLY(x)
 
#define IS_FALSE_UNEXPECTEDLY(x)
 
#define IS_ERROR_UNEXPECTEDLY(x)
 
#define IS_CROSS_THREAD_HIMC(hIMC)   IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))
 
#define IS_CROSS_PROCESS_HWND(hWnd)   IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))
 
#define ImeDpi_IsUnicode(pImeDpi)   ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
 
#define IS_16BIT_MODE()   (GetWin32ClientInfo()->dwTIFlags & TIF_16BIT)
 

Typedefs

typedef struct REG_IME REG_IME
 
typedef struct REG_IMEPREG_IME
 

Functions

BOOL Imm32GetSystemLibraryPath (LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
 
VOID APIENTRY LogFontAnsiToWide (const LOGFONTA *plfA, LPLOGFONTW plfW)
 
VOID APIENTRY LogFontWideToAnsi (const LOGFONTW *plfW, LPLOGFONTA plfA)
 
LPVOID FASTCALL ValidateHandleNoErr (HANDLE hObject, UINT uType)
 
LPVOID FASTCALL ValidateHandle (HANDLE hObject, UINT uType)
 
BOOL APIENTRY Imm32CheckImcProcess (PIMC pIMC)
 
LPVOID APIENTRY ImmLocalAlloc (DWORD dwFlags, DWORD dwBytes)
 
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)
 
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi (HKL hKL)
 
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC (HIMC hIMC, BOOL fSelect)
 
BOOL APIENTRY Imm32ReleaseIME (HKL hKL)
 
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean (VOID)
 
BOOL APIENTRY Imm32IsCrossThreadAccess (HIMC hIMC)
 
BOOL APIENTRY Imm32IsCrossProcessAccess (HWND hWnd)
 
BOOL WINAPI Imm32IsImcAnsi (HIMC hIMC)
 
DWORD APIENTRY CandidateListWideToAnsi (const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen, UINT uCodePage)
 
DWORD APIENTRY CandidateListAnsiToWide (const CANDIDATELIST *pAnsiCL, LPCANDIDATELIST pWideCL, DWORD dwBufLen, UINT uCodePage)
 
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 Imm32ReconvertAnsiFromWide (LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
 
DWORD APIENTRY Imm32ReconvertWideFromAnsi (LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
 
HRESULT APIENTRY Imm32StrToUInt (LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
 
HRESULT APIENTRY Imm32UIntToStr (DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
 
BOOL APIENTRY Imm32LoadImeVerInfo (PIMEINFOEX pImeInfoEx)
 
UINT APIENTRY Imm32GetImeLayout (PREG_IME pLayouts, UINT cLayouts)
 
BOOL APIENTRY Imm32WriteImeLayout (HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayoutText)
 
HKL APIENTRY Imm32AssignNewLayout (UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
 
BOOL APIENTRY Imm32CopyImeFile (LPWSTR pszOldFile, LPCWSTR pszNewFile)
 
PTHREADINFO FASTCALL Imm32CurrentPti (VOID)
 
HBITMAP Imm32LoadBitmapFromBytes (const BYTE *pb)
 
BOOL Imm32StoreBitmapToBytes (HBITMAP hbm, LPBYTE pbData, DWORD cbDataMax)
 

Variables

HMODULE ghImm32Inst
 
RTL_CRITICAL_SECTION gcsImeDpi
 
PIMEDPI gpImeDpiList
 
PSERVERINFO gpsi
 
SHAREDINFO gSharedInfo
 
HANDLE ghImmHeap
 

Macro Definition Documentation

◆ ImeDpi_IsUnicode

#define ImeDpi_IsUnicode (   pImeDpi)    ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)

Definition at line 145 of file precomp.h.

◆ IMM_INIT_MAGIC

#define IMM_INIT_MAGIC   0x19650412

Definition at line 50 of file precomp.h.

◆ IMM_INVALID_CANDFORM

#define IMM_INVALID_CANDFORM   ULONG_MAX

Definition at line 51 of file precomp.h.

◆ ImmLocalFree

#define ImmLocalFree (   lpData)    HeapFree(ghImmHeap, 0, (lpData))

Definition at line 89 of file precomp.h.

◆ INVALID_HOTKEY_ID

#define INVALID_HOTKEY_ID   0xFFFFFFFF

Definition at line 52 of file precomp.h.

◆ IS_16BIT_MODE

#define IS_16BIT_MODE ( )    (GetWin32ClientInfo()->dwTIFlags & TIF_16BIT)

Definition at line 146 of file precomp.h.

◆ IS_CROSS_PROCESS_HWND

#define IS_CROSS_PROCESS_HWND (   hWnd)    IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))

Definition at line 144 of file precomp.h.

◆ IS_CROSS_THREAD_HIMC

#define IS_CROSS_THREAD_HIMC (   hIMC)    IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))

Definition at line 143 of file precomp.h.

◆ IS_ERROR_UNEXPECTEDLY

#define IS_ERROR_UNEXPECTEDLY (   x)
Value:
((x) != ERROR_SUCCESS ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
__FILE__, __FUNCTION__, __LINE__, \
"%s was 0x%X\n", #x, (x)), TRUE) \
: FALSE)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define __FUNCTION__
Definition: types.h:112
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
@ __WINE_DBCL_ERR
Definition: debug.h:52
const char int int int ros_dbg_log(enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *file, const char *func, const int line, const char *format,...) __WINE_PRINTF_ATTR(6

Definition at line 136 of file precomp.h.

◆ IS_FALSE_UNEXPECTEDLY

#define IS_FALSE_UNEXPECTEDLY (   x)
Value:
((!(x)) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
__FILE__, __FUNCTION__, __LINE__, "%s was FALSE\n", #x), UNEXPECTED(), TRUE) \
: FALSE)
#define UNEXPECTED()
Definition: precomp.h:106

Definition at line 132 of file precomp.h.

◆ IS_NULL_UNEXPECTEDLY

#define IS_NULL_UNEXPECTEDLY (   p)
Value:
(!(p) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
__FILE__, __FUNCTION__, __LINE__, "%s was NULL\n", #p), UNEXPECTED(), TRUE) \
: FALSE)
GLfloat GLfloat p
Definition: glext.h:8902

Definition at line 120 of file precomp.h.

◆ IS_TRUE_UNEXPECTEDLY

#define IS_TRUE_UNEXPECTEDLY (   x)
Value:
((x) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
__FILE__, __FUNCTION__, __LINE__, "%s was non-zero\n", #x), UNEXPECTED(), TRUE) \
: FALSE)

Definition at line 128 of file precomp.h.

◆ IS_ZERO_UNEXPECTEDLY

#define IS_ZERO_UNEXPECTEDLY (   p)
Value:
(!(p) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
__FILE__, __FUNCTION__, __LINE__, "%s was zero\n", #p), UNEXPECTED(), TRUE) \
: FALSE)

Definition at line 124 of file precomp.h.

◆ LANGID_CHINESE_SIMPLIFIED

#define LANGID_CHINESE_SIMPLIFIED   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)

Definition at line 56 of file precomp.h.

◆ LANGID_CHINESE_TRADITIONAL

#define LANGID_CHINESE_TRADITIONAL   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)

Definition at line 57 of file precomp.h.

◆ LANGID_JAPANESE

Definition at line 58 of file precomp.h.

◆ MAX_CANDIDATEFORM

#define MAX_CANDIDATEFORM   4

Definition at line 53 of file precomp.h.

◆ MAX_IMM_FILENAME

#define MAX_IMM_FILENAME   80

Definition at line 54 of file precomp.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 32 of file precomp.h.

◆ REGKEY_IMM

#define REGKEY_IMM   L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"

Definition at line 61 of file precomp.h.

◆ REGKEY_KEYBOARD_LAYOUTS

#define REGKEY_KEYBOARD_LAYOUTS   L"System\\CurrentControlSet\\Control\\Keyboard Layouts"

Definition at line 60 of file precomp.h.

◆ ROUNDUP4

#define ROUNDUP4 (   n)    (((n) + 3) & ~3) /* DWORD alignment */

Definition at line 63 of file precomp.h.

◆ UNEXPECTED

#define UNEXPECTED ( )    0

Definition at line 106 of file precomp.h.

◆ ValidateHwnd

#define ValidateHwnd (   hwnd)    ValidateHandle((hwnd), TYPE_WINDOW)

Definition at line 85 of file precomp.h.

◆ ValidateHwndNoErr

#define ValidateHwndNoErr (   hwnd)    ValidateHandleNoErr((hwnd), TYPE_WINDOW)

Definition at line 84 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 19 of file precomp.h.

Typedef Documentation

◆ PREG_IME

typedef struct REG_IME * PREG_IME

◆ REG_IME

Function Documentation

◆ CandidateListAnsiToWide()

DWORD APIENTRY CandidateListAnsiToWide ( const CANDIDATELIST pAnsiCL,
LPCANDIDATELIST  pWideCL,
DWORD  dwBufLen,
UINT  uCodePage 
)

Definition at line 84 of file candidate.c.

86{
87 DWORD dwSize, dwIndex, cchGot, cbGot, cbLeft;
88 const BYTE *pbAnsi;
89 LPBYTE pbWide;
90 LPDWORD pibOffsets;
91
92 /* calculate total wide size */
93 if (pAnsiCL->dwCount > 0)
94 {
95 dwSize = sizeof(CANDIDATELIST) + ((pAnsiCL->dwCount - 1) * sizeof(DWORD));
96 for (dwIndex = 0; dwIndex < pAnsiCL->dwCount; ++dwIndex)
97 {
98 pbAnsi = (const BYTE *)pAnsiCL + pAnsiCL->dwOffset[dwIndex];
99 cchGot = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, (LPCSTR)pbAnsi, -1, NULL, 0);
100 dwSize += cchGot * sizeof(WCHAR);
101 }
102 }
103 else
104 {
105 dwSize = sizeof(CANDIDATELIST);
106 }
107
109 if (dwBufLen == 0)
110 return dwSize;
111 if (dwBufLen < dwSize)
112 return 0;
113
114 /* store to wide */
115 pWideCL->dwSize = dwBufLen;
116 pWideCL->dwStyle = pAnsiCL->dwStyle;
117 pWideCL->dwCount = pAnsiCL->dwCount;
118 pWideCL->dwSelection = pAnsiCL->dwSelection;
119 pWideCL->dwPageStart = pAnsiCL->dwPageStart;
120 pWideCL->dwPageSize = pAnsiCL->dwPageSize;
121
122 pibOffsets = pWideCL->dwOffset;
123 if (pAnsiCL->dwCount > 0)
124 {
125 pibOffsets[0] = sizeof(CANDIDATELIST) + ((pWideCL->dwCount - 1) * sizeof(DWORD));
126 cbLeft = dwBufLen - pibOffsets[0];
127
128 for (dwIndex = 0; dwIndex < pAnsiCL->dwCount; ++dwIndex)
129 {
130 pbAnsi = (const BYTE *)pAnsiCL + pAnsiCL->dwOffset[dwIndex];
131 pbWide = (LPBYTE)pWideCL + pibOffsets[dwIndex];
132
133 /* convert to wide */
134 cchGot = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, (LPCSTR)pbAnsi, -1,
135 (LPWSTR)pbWide, cbLeft / sizeof(WCHAR));
136 cbGot = cchGot * sizeof(WCHAR);
137 cbLeft -= cbGot;
138
139 if (dwIndex + 1 < pAnsiCL->dwCount)
140 pibOffsets[dwIndex + 1] = pibOffsets[dwIndex] + cbGot;
141 }
142 }
143 else
144 {
145 pibOffsets[0] = sizeof(CANDIDATELIST);
146 }
147
148 return dwBufLen;
149}
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define ROUNDUP4(n)
Definition: precomp.h:63
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define DWORD
Definition: nt_native.h:44
DWORD dwSelection
Definition: dimm.idl:95
DWORD dwPageSize
Definition: dimm.idl:97
DWORD dwCount
Definition: dimm.idl:94
DWORD dwStyle
Definition: dimm.idl:93
DWORD dwPageStart
Definition: dimm.idl:96
DWORD dwOffset[1]
Definition: dimm.idl:98
DWORD dwPageSize
Definition: imm.h:76
DWORD dwCount
Definition: imm.h:73
DWORD dwStyle
Definition: imm.h:72
DWORD dwPageStart
Definition: imm.h:75
DWORD dwOffset[1]
Definition: imm.h:77
DWORD dwSelection
Definition: imm.h:74
DWORD dwSize
Definition: imm.h:71
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t * LPDWORD
Definition: typedefs.h:59
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4246
#define MB_PRECOMPOSED
Definition: winnls.h:281
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetConversionListW(), and ImmGetGuideLineAW().

◆ CandidateListWideToAnsi()

DWORD APIENTRY CandidateListWideToAnsi ( const CANDIDATELIST pWideCL,
LPCANDIDATELIST  pAnsiCL,
DWORD  dwBufLen,
UINT  uCodePage 
)

Definition at line 14 of file candidate.c.

16{
17 BOOL bUsedDefault;
18 DWORD dwSize, dwIndex, cbGot, cbLeft;
19 const BYTE *pbWide;
20 LPBYTE pbAnsi;
21 LPDWORD pibOffsets;
22
23 /* calculate total ansi size */
24 if (pWideCL->dwCount > 0)
25 {
26 dwSize = sizeof(CANDIDATELIST) + ((pWideCL->dwCount - 1) * sizeof(DWORD));
27 for (dwIndex = 0; dwIndex < pWideCL->dwCount; ++dwIndex)
28 {
29 pbWide = (const BYTE *)pWideCL + pWideCL->dwOffset[dwIndex];
30 cbGot = WideCharToMultiByte(uCodePage, 0, (LPCWSTR)pbWide, -1, NULL, 0,
31 NULL, &bUsedDefault);
32 dwSize += cbGot;
33 }
34 }
35 else
36 {
37 dwSize = sizeof(CANDIDATELIST);
38 }
39
41 if (dwBufLen == 0)
42 return dwSize;
43 if (dwBufLen < dwSize)
44 return 0;
45
46 /* store to ansi */
47 pAnsiCL->dwSize = dwBufLen;
48 pAnsiCL->dwStyle = pWideCL->dwStyle;
49 pAnsiCL->dwCount = pWideCL->dwCount;
50 pAnsiCL->dwSelection = pWideCL->dwSelection;
51 pAnsiCL->dwPageStart = pWideCL->dwPageStart;
52 pAnsiCL->dwPageSize = pWideCL->dwPageSize;
53
54 pibOffsets = pAnsiCL->dwOffset;
55 if (pWideCL->dwCount > 0)
56 {
57 pibOffsets[0] = sizeof(CANDIDATELIST) + ((pWideCL->dwCount - 1) * sizeof(DWORD));
58 cbLeft = dwBufLen - pibOffsets[0];
59
60 for (dwIndex = 0; dwIndex < pWideCL->dwCount; ++dwIndex)
61 {
62 pbWide = (const BYTE *)pWideCL + pWideCL->dwOffset[dwIndex];
63 pbAnsi = (LPBYTE)pAnsiCL + pibOffsets[dwIndex];
64
65 /* convert to ansi */
66 cbGot = WideCharToMultiByte(uCodePage, 0, (LPCWSTR)pbWide, -1,
67 (LPSTR)pbAnsi, cbLeft, NULL, &bUsedDefault);
68 cbLeft -= cbGot;
69
70 if (dwIndex < pWideCL->dwCount - 1)
71 pibOffsets[dwIndex + 1] = pibOffsets[dwIndex] + cbGot;
72 }
73 }
74 else
75 {
76 pibOffsets[0] = sizeof(CANDIDATELIST);
77 }
78
79 return dwBufLen;
80}
#define WideCharToMultiByte
Definition: compat.h:111
unsigned int BOOL
Definition: ntddk_ex.h:94
char * LPSTR
Definition: xmlstorage.h:182
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ImmGetCandidateListAW(), ImmGetCandidateListCountAW(), ImmGetConversionListA(), and ImmGetGuideLineAW().

◆ 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}
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 TestByte)
Definition: nls.c:2337

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:120
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
int32_t INT
Definition: typedefs.h:58

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:104
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: debug.h:110
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
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCount)
Definition: ime.c:702
#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: debug.h:112
PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: utils.c:19
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1798
#define NtCurrentTeb
THRDESKHEAD head
Definition: ntuser.h:200
uint32_t DWORD_PTR
Definition: typedefs.h:65
@ 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
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:68
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:2613
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232

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: immdev.h:215
struct IME_STATE * pNext
Definition: immdev.h:214
struct IME_STATE * pState
Definition: immdev.h:134

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: immdev.h:220
struct IME_SUBSTATE * pNext
Definition: immdev.h:203
DWORD dwValue
Definition: immdev.h:205

Referenced by Imm32LoadImeStateSentence(), and Imm32SaveImeStateSentence().

◆ Imm32FindOrLoadImeDpi()

PIMEDPI APIENTRY Imm32FindOrLoadImeDpi ( HKL  hKL)

Definition at line 343 of file ime.c.

344{
345 PIMEDPI pImeDpi;
346
347 if (!IS_IME_HKL(hKL) && (!IS_CICERO_MODE() || IS_16BIT_MODE()))
348 {
349 TRACE("\n");
350 return NULL;
351 }
352
353 pImeDpi = ImmLockImeDpi(hKL);
354 if (pImeDpi == NULL)
355 pImeDpi = Imm32LoadImeDpi(hKL, TRUE);
356 return pImeDpi;
357}
#define IS_IME_HKL(hKL)
Definition: input.h:88
PIMEDPI APIENTRY Imm32LoadImeDpi(HKL hKL, BOOL bLock)
Definition: ime.c:267
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:987
#define IS_16BIT_MODE()
Definition: precomp.h:146
#define IS_CICERO_MODE()
Definition: ntuser.h:1233
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CtfImmGetGuidAtom(), CtfImmIsGuidMapEnable(), Imm32InternalLockIMC(), ImmConfigureIMEA(), ImmConfigureIMEW(), ImmEnumRegisterWordA(), ImmEnumRegisterWordW(), ImmEscapeA(), ImmEscapeW(), ImmGetConversionListA(), ImmGetConversionListW(), ImmGetProperty(), ImmGetRegisterWordStyleA(), ImmGetRegisterWordStyleW(), ImmRegisterWordA(), ImmRegisterWordW(), ImmUnregisterWordA(), and ImmUnregisterWordW().

◆ 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:47
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
#define IS_ERROR_UNEXPECTEDLY(x)
Definition: precomp.h:136
HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
Definition: utils.c:43
_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:67
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(), Imm32LoadIME(), Imm32LoadImeVerInfo(), and ImmInstallIMEW().

◆ 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}
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
HBITMAP hbmpChecked
Definition: imm.h:129
HBITMAP hbmpUnchecked
Definition: imm.h:130
HBITMAP hbmpItem
Definition: imm.h:133
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:132
DWORD dwItemData
Definition: imm.h:131

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
HBITMAP hbmpUnchecked
Definition: imm.h:117
HBITMAP hbmpChecked
Definition: imm.h:116
DWORD dwItemData
Definition: imm.h:118
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:119
HBITMAP hbmpItem
Definition: imm.h:120

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32InternalLockIMC()

LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC ( HIMC  hIMC,
BOOL  fSelect 
)

Definition at line 850 of file imm.c.

851{
852 HANDLE hIC;
853 LPINPUTCONTEXT pIC = NULL;
854 PCLIENTIMC pClientImc;
855 WORD LangID;
857 HKL hOldKL, hNewKL;
858 PIMEDPI pImeDpi = NULL;
859
860 pClientImc = ImmLockClientImc(hIMC);
861 if (IS_NULL_UNEXPECTEDLY(pClientImc))
862 return NULL;
863
864 RtlEnterCriticalSection(&pClientImc->cs);
865
866 if (pClientImc->hInputContext)
867 {
868 pIC = LocalLock(pClientImc->hInputContext);
869 if (IS_NULL_UNEXPECTEDLY(pIC))
870 goto Failure;
871
873 goto Success;
874 }
875
878 {
879 hOldKL = GetKeyboardLayout(0);
880 LangID = LOWORD(hOldKL);
881 hNewKL = (HKL)(DWORD_PTR)MAKELONG(LangID, LangID);
882
883 pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
884 if (pImeDpi)
885 {
886 CtfImmTIMActivate(hNewKL);
887 }
888 }
889
891 {
892 ERR("No default IME window\n");
893 goto Failure;
894 }
895
896 hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
897 pIC = LocalLock(hIC);
898 if (IS_NULL_UNEXPECTEDLY(pIC))
899 {
900 LocalFree(hIC);
901 goto Failure;
902 }
903 pClientImc->hInputContext = hIC;
904
906 if (!Imm32CreateInputContext(hIMC, pIC, pClientImc, hNewKL, fSelect))
907 {
908 LocalUnlock(hIC);
909 pClientImc->hInputContext = LocalFree(hIC);
910 goto Failure;
911 }
912
913Success:
914 RtlLeaveCriticalSection(&pClientImc->cs);
915 InterlockedIncrement(&pClientImc->cLockObj);
916 ImmUnlockClientImc(pClientImc);
917 return pIC;
918
919Failure:
920 RtlLeaveCriticalSection(&pClientImc->cs);
921 ImmUnlockClientImc(pClientImc);
922 return NULL;
923}
#define InterlockedIncrement
Definition: armddk.h:53
HRESULT APIENTRY CtfImmTIMCreateInputContext(HIMC hIMC)
Definition: ctf.c:50
HRESULT WINAPI CtfImmTIMActivate(HKL hKL)
Definition: ctf.c:75
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL)
Definition: ime.c:343
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:996
BOOL APIENTRY Imm32CreateInputContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
Definition: imm.c:749
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:950
@ Success
Definition: eventcreate.c:712
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1338
HANDLE hInputContext
Definition: ntuser.h:1334
LONG cLockObj
Definition: ntuser.h:1335
@ QIC_DEFAULTWINDOWIME
Definition: undocuser.h:394
@ QIC_INPUTTHREADID
Definition: undocuser.h:393
_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
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define LHND
Definition: winbase.h:382
HKL WINAPI GetKeyboardLayout(_In_ DWORD)

Referenced by Imm32SelectInputContext(), and ImmLockIMC().

◆ 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:4185
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2950

◆ 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}

◆ 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}
#define CLIENTIMC_WIDE
Definition: ntuser.h:1356
DWORD dwFlags
Definition: ntuser.h:1336

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: lang.c:791
#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
WORD LANGID
Definition: typedefs.h:81

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 CopyMemory(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
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
#define CopyMemory
Definition: winbase.h:1668
#define DIB_RGB_COLORS
Definition: wingdi.h:367
struct tagRGBTRIPLE RGBTRIPLE
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
#define GetObject
Definition: wingdi.h:4468

Referenced by Imm32GetImeMenuItemWInterProcess().

◆ 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:124
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
WCHAR wszImeFile[80]
Definition: ntuser.h:1215

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}
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:1016
static HANDLE ULONG_PTR dwData
Definition: file.c:35
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WM_IME_NOTIFY
Definition: winuser.h:1820
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
struct tagRECONVERTSTRING RECONVERTSTRING
DWORD dwStrLen
Definition: imm.h:99
DWORD dwTargetStrOffset
Definition: imm.h:104
DWORD dwCompStrLen
Definition: imm.h:101
DWORD dwSize
Definition: imm.h:97
DWORD dwTargetStrLen
Definition: imm.h:103
DWORD dwCompStrOffset
Definition: imm.h:102
DWORD dwStrOffset
Definition: imm.h:100
DWORD dwVersion
Definition: imm.h:98

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

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32ReleaseIME()

BOOL APIENTRY Imm32ReleaseIME ( HKL  hKL)

Definition at line 371 of file ime.c.

372{
373 BOOL ret = TRUE;
374 PIMEDPI pImeDpi0, pImeDpi1;
375
377
378 for (pImeDpi0 = gpImeDpiList; pImeDpi0; pImeDpi0 = pImeDpi0->pNext)
379 {
380 if (pImeDpi0->hKL == hKL)
381 break;
382 }
383
384 if (!pImeDpi0)
385 goto Quit;
386
387 if (pImeDpi0->cLockObj)
388 {
389 pImeDpi0->dwFlags |= IMEDPI_FLAG_UNLOADED;
390 ret = FALSE;
391 goto Quit;
392 }
393
394 if (gpImeDpiList == pImeDpi0)
395 {
396 gpImeDpiList = pImeDpi0->pNext;
397 }
398 else if (gpImeDpiList)
399 {
400 for (pImeDpi1 = gpImeDpiList; pImeDpi1; pImeDpi1 = pImeDpi1->pNext)
401 {
402 if (pImeDpi1->pNext == pImeDpi0)
403 {
404 pImeDpi1->pNext = pImeDpi0->pNext;
405 break;
406 }
407 }
408 }
409
410 Imm32FreeIME(pImeDpi0, TRUE);
411 ImmLocalFree(pImeDpi0);
412
413Quit:
415 return ret;
416}
VOID APIENTRY Imm32FreeIME(PIMEDPI pImeDpi, BOOL bDestroy)
Definition: ime.c:36
RTL_CRITICAL_SECTION gcsImeDpi
Definition: ime.c:16
PIMEDPI gpImeDpiList
Definition: ime.c:17
#define IMEDPI_FLAG_UNLOADED
Definition: ntuser.h:1328
DWORD dwFlags
Definition: ntuser.h:1288
HKL hKL
Definition: ntuser.h:1283
struct IMEDPI * pNext
Definition: ntuser.h:1281
DWORD cLockObj
Definition: ntuser.h:1287

Referenced by ImmFreeLayout().

◆ 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 CopyMemory(pb, &bmci.bmciHeader, sizeof(BITMAPCOREHEADER));
200 pb += sizeof(BITMAPCOREHEADER);
201
202 CopyMemory(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:1670
_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:32
#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:4900
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define MAX_PRELOAD
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:56
#define LOBYTE(W)
Definition: jmemdos.c:487
#define REG_SZ
Definition: layer.c:22
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define StringCchPrintf
Definition: strsafe.h:517
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by ImmInstallIMEW().

◆ ImmLocalAlloc()

◆ 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
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

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}
STRSAFEAPI StringCchLengthW(STRSAFE_LPCWSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:842
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
CHAR lfFaceName[LF_FACESIZE]
Definition: wingdi.h:1894

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

◆ ValidateHandle()

◆ 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
#define ASSERT(a)
Definition: mode.c:44
static PVOID ptr
Definition: dispmode.c:27
PVOID aheList
Definition: ntuser.h:1126
ULONG_PTR ulSharedDelta
Definition: ntuser.h:1128
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 MENU_GetMenu().

Variable Documentation

◆ gcsImeDpi

◆ ghImm32Inst

HMODULE ghImm32Inst
extern

Definition at line 17 of file imm.c.

Referenced by ImmInitializeGlobals().

◆ ghImmHeap

HANDLE ghImmHeap
extern

Definition at line 16 of file utils.c.

Referenced by ImmLocalAlloc().

◆ gpImeDpiList

PIMEDPI gpImeDpiList
extern

◆ gpsi

PSERVERINFO gpsi
extern

Definition at line 18 of file imm.c.

◆ gSharedInfo

SHAREDINFO gSharedInfo
extern

Definition at line 19 of file imm.c.