ReactOS  0.4.15-dev-3331-g8ebe441
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/imm.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 Imm32HeapFree(lpData)   HeapFree(g_hImm32Heap, 0, (lpData))
 
#define ImeDpi_IsUnicode(pImeDpi)   ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
 
#define Imm32IsImmMode()   (g_psi && (g_psi->dwSRVIFlags & SRVINFO_IMM32))
 
#define Imm32IsCiceroMode()   (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
 
#define Imm32Is16BitMode()   (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)
 
PWND FASTCALL ValidateHwndNoErr (HWND hwnd)
 
LPVOID FASTCALL ValidateHandleNoErr (HANDLE hObject, UINT uType)
 
BOOL APIENTRY Imm32CheckImcProcess (PIMC pIMC)
 
LPVOID APIENTRY Imm32HeapAlloc (DWORD dwFlags, DWORD dwBytes)
 
LPWSTR APIENTRY Imm32WideFromAnsi (LPCSTR pszA)
 
LPSTR APIENTRY Imm32AnsiFromWide (LPCWSTR pszW)
 
LONG APIENTRY IchWideFromAnsi (LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
 
LONG APIENTRY IchAnsiFromWide (LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
 
PIMEDPI APIENTRY ImmLockOrLoadImeDpi (HKL hKL)
 
LPINPUTCONTEXT APIENTRY Imm32LockIMCEx (HIMC hIMC, BOOL fSelect)
 
BOOL APIENTRY Imm32ReleaseIME (HKL hKL)
 
static BOOL Imm32IsCrossThreadAccess (HIMC hIMC)
 
static BOOL 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 Imm32NotifyAction (HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue, DWORD_PTR dwCommand, DWORD_PTR dwData)
 
DWORD APIENTRY Imm32AllocAndBuildHimcList (DWORD dwThreadId, HIMC **pphList)
 
INT APIENTRY Imm32ImeMenuAnsiToWide (const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW, UINT uCodePage, BOOL bBitmap)
 
INT APIENTRY Imm32ImeMenuWideToAnsi (const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA, UINT uCodePage)
 
PIME_STATE APIENTRY Imm32FetchImeState (LPINPUTCONTEXTDX pIC, HKL hKL)
 
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState (PIME_STATE pState, HKL hKL)
 
BOOL APIENTRY Imm32LoadImeStateSentence (LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
 
BOOL APIENTRY Imm32SaveImeStateSentence (LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
 
DWORD APIENTRY 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 Imm32GetRegImes (PREG_IME pLayouts, UINT cLayouts)
 
BOOL APIENTRY Imm32WriteRegIme (HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout)
 
HKL APIENTRY Imm32GetNextHKL (UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
 
BOOL APIENTRY Imm32CopyFile (LPWSTR pszOldFile, LPCWSTR pszNewFile)
 

Variables

HMODULE g_hImm32Inst
 
RTL_CRITICAL_SECTION g_csImeDpi
 
PIMEDPI g_pImeDpiList
 
PSERVERINFO g_psi
 
SHAREDINFO g_SharedInfo
 
BYTE g_bClientRegd
 
HANDLE g_hImm32Heap
 

Macro Definition Documentation

◆ ImeDpi_IsUnicode

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

Definition at line 113 of file precomp.h.

◆ Imm32HeapFree

#define Imm32HeapFree (   lpData)    HeapFree(g_hImm32Heap, 0, (lpData))

Definition at line 88 of file precomp.h.

◆ Imm32Is16BitMode

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

Definition at line 116 of file precomp.h.

◆ Imm32IsCiceroMode

#define Imm32IsCiceroMode ( )    (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))

Definition at line 115 of file precomp.h.

◆ Imm32IsImmMode

#define Imm32IsImmMode ( )    (g_psi && (g_psi->dwSRVIFlags & SRVINFO_IMM32))

Definition at line 114 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.

◆ INVALID_HOTKEY_ID

#define INVALID_HOTKEY_ID   0xFFFFFFFF

Definition at line 52 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.

◆ 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 82 of file candidate.c.

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

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

◆ CandidateListWideToAnsi()

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

Definition at line 13 of file candidate.c.

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

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

◆ IchAnsiFromWide()

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

Definition at line 99 of file utils.c.

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

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

◆ IchWideFromAnsi()

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

Definition at line 79 of file utils.c.

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

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

◆ Imm32AllocAndBuildHimcList()

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

Definition at line 236 of file utils.c.

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

Referenced by ImmEnumInputContext().

◆ Imm32AnsiFromWide()

LPSTR APIENTRY Imm32AnsiFromWide ( LPCWSTR  pszW)

Definition at line 66 of file utils.c.

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

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

◆ Imm32CheckImcProcess()

BOOL APIENTRY Imm32CheckImcProcess ( PIMC  pIMC)

Definition at line 181 of file utils.c.

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

Referenced by ImmLockClientImc().

◆ Imm32CopyFile()

BOOL APIENTRY Imm32CopyFile ( LPWSTR  pszOldFile,
LPCWSTR  pszNewFile 
)

Definition at line 851 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ Imm32FetchImeState()

PIME_STATE APIENTRY Imm32FetchImeState ( LPINPUTCONTEXTDX  pIC,
HKL  hKL 
)

Definition at line 324 of file utils.c.

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

Referenced by Imm32SelectLayout().

◆ Imm32FetchImeSubState()

PIME_SUBSTATE APIENTRY Imm32FetchImeSubState ( PIME_STATE  pState,
HKL  hKL 
)

Definition at line 347 of file utils.c.

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

Referenced by Imm32LoadImeStateSentence(), and Imm32SaveImeStateSentence().

◆ Imm32GetNextHKL()

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

Definition at line 643 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ Imm32GetRegImes()

UINT APIENTRY Imm32GetRegImes ( PREG_IME  pLayouts,
UINT  cLayouts 
)

Definition at line 688 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ Imm32GetSystemLibraryPath()

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

Definition at line 111 of file utils.c.

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

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

◆ Imm32HeapAlloc()

◆ Imm32ImeMenuAnsiToWide()

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

Definition at line 275 of file utils.c.

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

Referenced by Imm32GetImeMenuItemsAW().

◆ Imm32ImeMenuWideToAnsi()

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

Definition at line 301 of file utils.c.

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

Referenced by Imm32GetImeMenuItemsAW().

◆ Imm32IsCrossProcessAccess()

static BOOL Imm32IsCrossProcessAccess ( HWND  hWnd)
inlinestatic

Definition at line 105 of file precomp.h.

106 {
109 }
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2900
HWND hWnd
Definition: settings.c:17
HANDLE UniqueProcess
Definition: compat.h:684
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3929
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1163
uint32_t DWORD_PTR
Definition: typedefs.h:65
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by Imm32GetContextEx(), ImmConfigureIMEA(), and ImmConfigureIMEW().

◆ Imm32IsCrossThreadAccess()

static BOOL Imm32IsCrossThreadAccess ( HIMC  hIMC)
inlinestatic

Definition at line 98 of file precomp.h.

99 {
100  DWORD dwImeThreadId = NtUserQueryInputContext(hIMC, 1);
102  return (dwImeThreadId != dwThreadId);
103 }
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:660

Referenced by Imm32ProcessHotKey(), Imm32RequestMessageAW(), ImmAssociateContext(), ImmAssociateContextEx(), ImmDestroyContext(), ImmGenerateMessage(), ImmNotifyIME(), ImmSetCandidateWindow(), ImmSetCompositionFontA(), ImmSetCompositionFontW(), ImmSetCompositionWindow(), ImmSetConversionStatus(), ImmSetOpenStatus(), and ImmSetStatusWindowPos().

◆ Imm32IsImcAnsi()

BOOL WINAPI Imm32IsImcAnsi ( HIMC  hIMC)

Definition at line 44 of file utils.c.

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

Referenced by Imm32GetImeMenuItemsAW().

◆ Imm32LoadImeStateSentence()

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

Definition at line 366 of file utils.c.

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

Referenced by Imm32SelectLayout().

◆ Imm32LoadImeVerInfo()

BOOL APIENTRY Imm32LoadImeVerInfo ( PIMEINFOEX  pImeInfoEx)

Definition at line 589 of file utils.c.

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

Referenced by ImmInstallIMEW(), and ImmLoadLayout().

◆ Imm32LockIMCEx()

LPINPUTCONTEXT APIENTRY Imm32LockIMCEx ( HIMC  hIMC,
BOOL  fSelect 
)

Definition at line 802 of file imm.c.

803 {
804  HANDLE hIC;
805  LPINPUTCONTEXT pIC = NULL;
806  PCLIENTIMC pClientImc;
807  WORD Word;
809  HKL hKL, hNewKL;
810  PIMEDPI pImeDpi = NULL;
811  BOOL bInited;
812 
813  pClientImc = ImmLockClientImc(hIMC);
814  if (!pClientImc)
815  return NULL;
816 
817  RtlEnterCriticalSection(&pClientImc->cs);
818 
819  if (!pClientImc->hInputContext)
820  {
822 
824  {
825  hKL = GetKeyboardLayout(0);
826  Word = LOWORD(hKL);
827  hNewKL = (HKL)(DWORD_PTR)MAKELONG(Word, Word);
828 
829  pImeDpi = ImmLockOrLoadImeDpi(hNewKL);
830  if (pImeDpi)
831  {
832  FIXME("We have to do something here\n");
833  }
834  }
835 
836  if (!NtUserQueryInputContext(hIMC, 2))
837  {
838  RtlLeaveCriticalSection(&pClientImc->cs);
839  goto Quit;
840  }
841 
842  hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
843  if (!hIC)
844  {
845  RtlLeaveCriticalSection(&pClientImc->cs);
846  goto Quit;
847  }
848  pClientImc->hInputContext = hIC;
849 
850  pIC = LocalLock(pClientImc->hInputContext);
851  if (!pIC)
852  {
853  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
854  RtlLeaveCriticalSection(&pClientImc->cs);
855  goto Quit;
856  }
857 
859  // bInited = Imm32InitContext(hIMC, hKL, fSelect);
860  bInited = Imm32InitContext(hIMC, pIC, pClientImc, hKL, fSelect);
861  LocalUnlock(pClientImc->hInputContext);
862 
863  if (!bInited)
864  {
865  pIC = NULL;
866  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
867  RtlLeaveCriticalSection(&pClientImc->cs);
868  goto Quit;
869  }
870  }
871 
872  FIXME("We have to do something here\n");
873 
874  RtlLeaveCriticalSection(&pClientImc->cs);
875  pIC = LocalLock(pClientImc->hInputContext);
876  InterlockedIncrement(&pClientImc->cLockObj);
877 
878 Quit:
879  ImmUnlockClientImc(pClientImc);
880  return pIC;
881 }
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
LONG cLockObj
Definition: ntuser.h:1294
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOL APIENTRY Imm32InitContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
Definition: imm.c:708
#define DWORD
Definition: nt_native.h:44
USHORT Word[8]
Definition: in6addr.h:6
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define FIXME(fmt,...)
Definition: debug.h:111
#define MAKELONG(a, b)
Definition: typedefs.h:249
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:905
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
HANDLE hInputContext
Definition: ntuser.h:1293
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
RTL_CRITICAL_SECTION cs
Definition: ntuser.h:1297
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define InterlockedIncrement
Definition: armddk.h:53
#define LHND
Definition: winbase.h:379
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define NULL
Definition: types.h:112
#define Imm32Is16BitMode()
Definition: precomp.h:116
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL)
Definition: ime.c:281
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define Imm32IsCiceroMode()
Definition: precomp.h:115
#define LOWORD(l)
Definition: pedump.c:82
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:660
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:952

Referenced by Imm32SelectLayout(), and ImmLockIMC().

◆ Imm32NotifyAction()

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

Definition at line 205 of file utils.c.

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

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

◆ Imm32ReconvertAnsiFromWide()

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

Definition at line 455 of file utils.c.

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

Referenced by Imm32ProcessRequest(), and Imm32SetCompositionStringAW().

◆ Imm32ReconvertWideFromAnsi()

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

Definition at line 399 of file utils.c.

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

Referenced by Imm32ProcessRequest(), and Imm32SetCompositionStringAW().

◆ Imm32ReleaseIME()

BOOL APIENTRY Imm32ReleaseIME ( HKL  hKL)

Definition at line 306 of file ime.c.

307 {
308  BOOL ret = TRUE;
309  PIMEDPI pImeDpi0, pImeDpi1;
310 
312 
313  for (pImeDpi0 = g_pImeDpiList; pImeDpi0; pImeDpi0 = pImeDpi0->pNext)
314  {
315  if (pImeDpi0->hKL == hKL)
316  break;
317  }
318 
319  if (!pImeDpi0)
320  goto Quit;
321 
322  if (pImeDpi0->cLockObj)
323  {
324  pImeDpi0->dwFlags |= IMEDPI_FLAG_UNKNOWN;
325  ret = FALSE;
326  goto Quit;
327  }
328 
329  if (g_pImeDpiList == pImeDpi0)
330  {
331  g_pImeDpiList = pImeDpi0->pNext;
332  }
333  else if (g_pImeDpiList)
334  {
335  for (pImeDpi1 = g_pImeDpiList; pImeDpi1; pImeDpi1 = pImeDpi1->pNext)
336  {
337  if (pImeDpi1->pNext == pImeDpi0)
338  {
339  pImeDpi1->pNext = pImeDpi0->pNext;
340  break;
341  }
342  }
343  }
344 
345  Imm32FreeImeDpi(pImeDpi0, TRUE);
346  Imm32HeapFree(pImeDpi0);
347 
348 Quit:
350  return ret;
351 }
RTL_CRITICAL_SECTION g_csImeDpi
Definition: ime.c:17
#define Imm32HeapFree(lpData)
Definition: precomp.h:88
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
DWORD cLockObj
Definition: ntuser.h:1246
VOID APIENTRY Imm32FreeImeDpi(PIMEDPI pImeDpi, BOOL bDestroy)
Definition: ime.c:35
int ret
struct IMEDPI * pNext
Definition: ntuser.h:1240
PIMEDPI g_pImeDpiList
Definition: ime.c:18
DWORD dwFlags
Definition: ntuser.h:1247
#define IMEDPI_FLAG_UNKNOWN
Definition: ntuser.h:1287
HKL hKL
Definition: ntuser.h:1242

Referenced by ImmFreeLayout().

◆ Imm32SaveImeStateSentence()

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

Definition at line 378 of file utils.c.

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

Referenced by Imm32SelectLayout().

◆ Imm32StrToUInt()

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

Definition at line 20 of file utils.c.

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

Referenced by Imm32GetRegImes().

◆ Imm32UIntToStr()

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

Definition at line 32 of file utils.c.

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

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

◆ Imm32WideFromAnsi()

LPWSTR APIENTRY Imm32WideFromAnsi ( LPCSTR  pszA)

Definition at line 55 of file utils.c.

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

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

◆ Imm32WriteRegIme()

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

Definition at line 755 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ ImmLockOrLoadImeDpi()

PIMEDPI APIENTRY ImmLockOrLoadImeDpi ( HKL  hKL)

Definition at line 281 of file ime.c.

282 {
283  PIMEDPI pImeDpi;
284 
285  if (!IS_IME_HKL(hKL) && (!Imm32IsCiceroMode() || Imm32Is16BitMode()))
286  return NULL;
287 
288  pImeDpi = ImmLockImeDpi(hKL);
289  if (pImeDpi == NULL)
290  pImeDpi = Ime32LoadImeDpi(hKL, TRUE);
291  return pImeDpi;
292 }
#define TRUE
Definition: types.h:120
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1193
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:726
PIMEDPI APIENTRY Ime32LoadImeDpi(HKL hKL, BOOL bLock)
Definition: ime.c:218
#define NULL
Definition: types.h:112
#define Imm32Is16BitMode()
Definition: precomp.h:116
#define Imm32IsCiceroMode()
Definition: precomp.h:115

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

◆ LogFontAnsiToWide()

VOID APIENTRY LogFontAnsiToWide ( const LOGFONTA plfA,
LPLOGFONTW  plfW 
)

Definition at line 120 of file utils.c.

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

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

◆ LogFontWideToAnsi()

VOID APIENTRY LogFontWideToAnsi ( const LOGFONTW plfW,
LPLOGFONTA  plfA 
)

Definition at line 132 of file utils.c.

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

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

◆ ValidateHandleNoErr()

LPVOID FASTCALL ValidateHandleNoErr ( HANDLE  hObject,
UINT  uType 
)

Definition at line 144 of file utils.c.

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

Referenced by Imm32CleanupContext(), ImmLockClientImc(), and MENU_GetMenu().

◆ ValidateHwndNoErr()

PWND FASTCALL ValidateHwndNoErr ( HWND  hwnd)

Definition at line 171 of file utils.c.

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

Referenced by co_IntDestroyCaret(), co_IntFixCaret(), co_IntProcessKeyboardMessage(), co_IntProcessMouseMessage(), co_IntSendActivateMessages(), co_IntSendDeactivateMessages(), co_MsqSendMessage(), co_UserProcessHotKeys(), co_UserShowCaret(), co_WinPosSearchChildren(), co_WinPosSetWindowPos(), DefWndHandleSysCommand(), get_win_sys_menu(), Imm32GetContextEx(), Imm32RequestMessageAW(), Imm32UnknownProcess1(), ImmAssociateContext(), ImmAssociateContextEx(), ImmConfigureIMEA(), ImmConfigureIMEW(), IntChildWindowFromPointEx(), IntDeactivateWindow(), IntDestroyMenuObject(), IntEndDeferWindowPosEx(), IntGetMenu(), IntGhostWindowFromHungWindow(), IntHungWindowFromGhostWindow(), IntMakeHungWindowGhosted(), IntRealChildWindowFromPoint(), IntTrackPopupMenuEx(), MENU_DoNextMenu(), MENU_DrawBitmapItem(), MENU_EnsureMenuItemVisible(), MENU_FindItemByCoords(), MENU_HideSubPopups(), MENU_IsMenuActive(), MENU_PtMenu(), MENU_SelectItem(), MENU_ShowPopup(), MENU_ShowSubPopup(), MENU_TrackMenu(), MsqSetStateWindow(), NtUserFlashWindowEx(), UserGhostWindowFromHungWindow(), UserHungWindowFromGhostWindow(), WinPosDoOwnedPopups(), and WinPosFixupFlags().

Variable Documentation

◆ g_bClientRegd

BYTE g_bClientRegd

Definition at line 20 of file imm.c.

Referenced by Imm32InitInstance().

◆ g_csImeDpi

◆ g_hImm32Heap

HANDLE g_hImm32Heap

Definition at line 17 of file utils.c.

Referenced by Imm32HeapAlloc().

◆ g_hImm32Inst

HMODULE g_hImm32Inst

Definition at line 17 of file imm.c.

Referenced by Imm32InitInstance().

◆ g_pImeDpiList

PIMEDPI g_pImeDpiList

◆ g_psi

PSERVERINFO g_psi

Definition at line 18 of file imm.c.

Referenced by Imm32UnknownProcess1(), and ImmRegisterClient().

◆ g_SharedInfo

SHAREDINFO g_SharedInfo

Definition at line 19 of file imm.c.

Referenced by ImmRegisterClient(), and ValidateHandleNoErr().