ReactOS  0.4.15-dev-4594-g505ac65
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 ImeDpi_IsUnicode(pImeDpi)   ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
 
#define IS_IMM_MODE()   (gpsi && (gpsi->dwSRVIFlags & SRVINFO_IMM32))
 
#define Imm32IsCiceroMode()   (gpsi && (gpsi->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)
 
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 (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 Imm32FindOrLoadImeDpi (HKL hKL)
 
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC (HIMC hIMC, BOOL fSelect)
 
BOOL APIENTRY Imm32ReleaseIME (HKL hKL)
 
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean (VOID)
 
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 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 pszLayout)
 
HKL APIENTRY Imm32AssignNewLayout (UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
 
BOOL APIENTRY Imm32CopyImeFile (LPWSTR pszOldFile, LPCWSTR pszNewFile)
 
static PTHREADINFO FASTCALL Imm32CurrentPti (VOID)
 

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 116 of file precomp.h.

◆ Imm32Is16BitMode

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

Definition at line 119 of file precomp.h.

◆ Imm32IsCiceroMode

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

Definition at line 118 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_IMM_MODE

#define IS_IMM_MODE ( )    (gpsi && (gpsi->dwSRVIFlags & SRVINFO_IMM32))

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

◆ 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 }
DWORD dwCount
Definition: dimm.idl:94
DWORD dwPageSize
Definition: dimm.idl:97
struct tagCANDIDATELIST CANDIDATELIST
#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
__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 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 }
DWORD dwCount
Definition: dimm.idl:94
DWORD dwPageSize
Definition: dimm.idl:97
struct tagCANDIDATELIST CANDIDATELIST
#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
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 109 of file utils.c.

110 {
111  LONG cb, cchAnsi;
112  for (cchAnsi = 0; cchWide > 0; ++cchAnsi, ++pchWide, --cchWide)
113  {
114  cb = WideCharToMultiByte(uCodePage, 0, pchWide, 1, NULL, 0, NULL, NULL);
115  if (cb > 1)
116  ++cchAnsi;
117  }
118  return cchAnsi;
119 }
#define WideCharToMultiByte
Definition: compat.h:111
long LONG
Definition: pedump.c:60
#define NULL
Definition: types.h:112
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

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

◆ IchWideFromAnsi()

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

Definition at line 89 of file utils.c.

90 {
91  LONG cchWide;
92  for (cchWide = 0; cchAnsi > 0; ++cchWide)
93  {
94  if (IsDBCSLeadByteEx(uCodePage, *pchAnsi) && pchAnsi[1])
95  {
96  cchAnsi -= 2;
97  pchAnsi += 2;
98  }
99  else
100  {
101  --cchAnsi;
102  ++pchAnsi;
103  }
104  }
105  return cchWide;
106 }
BOOL WINAPI IsDBCSLeadByteEx(UINT CodePage, BYTE TestByte)
Definition: nls.c:2248
long LONG
Definition: pedump.c:60

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

◆ Imm32AnsiFromWide()

LPSTR APIENTRY Imm32AnsiFromWide ( LPCWSTR  pszW)

Definition at line 76 of file utils.c.

77 {
78  INT cchW = lstrlenW(pszW);
79  INT cchA = (cchW + 1) * sizeof(WCHAR);
80  LPSTR pszA = ImmLocalAlloc(0, cchA);
81  if (!pszA)
82  return NULL;
83  cchA = WideCharToMultiByte(CP_ACP, 0, pszW, cchW, pszA, cchA, NULL, NULL);
84  pszA[cchA] = 0;
85  return pszA;
86 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
char * LPSTR
Definition: xmlstorage.h:182
#define lstrlenW
Definition: compat.h:609
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#define NULL
Definition: types.h:112

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

◆ Imm32AssignNewLayout()

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

Definition at line 697 of file utils.c.

698 {
699  UINT iKL, wID, wLow = 0xE0FF, wHigh = 0xE01F, wNextID = 0;
700 
701  for (iKL = 0; iKL < cKLs; ++iKL)
702  {
703  wHigh = max(wHigh, HIWORD(pLayouts[iKL].hKL));
704  wLow = min(wLow, HIWORD(pLayouts[iKL].hKL));
705  }
706 
707  if (wHigh < 0xE0FF)
708  {
709  wNextID = wHigh + 1;
710  }
711  else if (wLow > 0xE001)
712  {
713  wNextID = wLow - 1;
714  }
715  else
716  {
717  for (wID = 0xE020; wID <= 0xE0FF; ++wID)
718  {
719  for (iKL = 0; iKL < cKLs; ++iKL)
720  {
721  if (LOWORD(pLayouts[iKL].hKL) == wLangID &&
722  HIWORD(pLayouts[iKL].hKL) == wID)
723  {
724  break;
725  }
726  }
727 
728  if (iKL >= cKLs)
729  break;
730  }
731 
732  if (wID <= 0xE0FF)
733  wNextID = wID;
734  }
735 
736  if (!wNextID)
737  return NULL;
738 
739  return (HKL)(DWORD_PTR)MAKELONG(wLangID, wNextID);
740 }
#define max(a, b)
Definition: svc.c:63
#define DWORD_PTR
Definition: treelist.c:76
#define MAKELONG(a, b)
Definition: typedefs.h:249
UINT_PTR HKL
Definition: msctf.idl:101
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HIWORD(l)
Definition: typedefs.h:247
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ImmInstallIMEW().

◆ Imm32BuildHimcList()

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

Definition at line 279 of file utils.c.

280 {
281 #define INITIAL_COUNT 0x40
282 #define MAX_RETRY 10
284  DWORD dwCount = INITIAL_COUNT, cRetry = 0;
285  HIMC *phNewList;
286 
287  phNewList = ImmLocalAlloc(0, dwCount * sizeof(HIMC));
288  if (phNewList == NULL)
289  return 0;
290 
291  Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
293  {
294  ImmLocalFree(phNewList);
295  if (cRetry++ >= MAX_RETRY)
296  return 0;
297 
298  phNewList = ImmLocalAlloc(0, dwCount * sizeof(HIMC));
299  if (phNewList == NULL)
300  return 0;
301 
302  Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
303  }
304 
305  if (NT_ERROR(Status) || !dwCount)
306  {
307  ImmLocalFree(phNewList);
308  return 0;
309  }
310 
311  *pphList = phNewList;
312  return dwCount;
313 #undef INITIAL_COUNT
314 #undef MAX_RETRY
315 }
NTSTATUS NTAPI NtUserBuildHimcList(DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCount)
Definition: ime.c:697
#define MAX_RETRY
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
DWORD HIMC
Definition: dimm.idl:75
Status
Definition: gdiplustypes.h:24
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NT_ERROR(Status)
Definition: umtypes.h:106
#define ImmLocalFree(lpData)
Definition: precomp.h:89
DWORD dwThreadId
Definition: fdebug.c:31
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#define NULL
Definition: types.h:112
#define INITIAL_COUNT

Referenced by ImmEnumInputContext().

◆ Imm32CheckImcProcess()

BOOL APIENTRY Imm32CheckImcProcess ( PIMC  pIMC)

Definition at line 221 of file utils.c.

222 {
223  HIMC hIMC;
224  DWORD dwProcessID;
225  if (pIMC->head.pti == Imm32CurrentPti())
226  return TRUE;
227 
228  hIMC = pIMC->head.h;
229  dwProcessID = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTPROCESSID);
230  return dwProcessID == (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
231 }
#define DWORD_PTR
Definition: treelist.c:76
#define TRUE
Definition: types.h:120
static PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: precomp.h:162
#define DWORD
Definition: nt_native.h:44
DWORD HIMC
Definition: dimm.idl:75
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1773
unsigned long DWORD
Definition: ntddk_ex.h:95
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
THRDESKHEAD head
Definition: ntuser.h:192

Referenced by ImmLockClientImc().

◆ Imm32CopyImeFile()

BOOL APIENTRY Imm32CopyImeFile ( LPWSTR  pszOldFile,
LPCWSTR  pszNewFile 
)

Definition at line 908 of file utils.c.

909 {
910  BOOL ret = FALSE, bLoaded = FALSE;
911  HMODULE hinstLZ32;
912  WCHAR szLZ32Path[MAX_PATH];
913  CHAR szDestA[MAX_PATH];
914  OFSTRUCT OFStruct;
915  FN_LZOpenFileW fnLZOpenFileW;
916  FN_LZCopy fnLZCopy;
917  FN_LZClose fnLZClose;
918  HFILE hfDest, hfSrc;
919 
920  /* Load LZ32.dll for copying/decompressing file */
921  Imm32GetSystemLibraryPath(szLZ32Path, _countof(szLZ32Path), L"LZ32");
922  hinstLZ32 = GetModuleHandleW(szLZ32Path);
923  if (!hinstLZ32)
924  {
925  hinstLZ32 = LoadLibraryW(szLZ32Path);
926  if (!hinstLZ32)
927  return FALSE;
928  bLoaded = TRUE;
929  }
930 
931 #define GET_FN(name) do { \
932  fn##name = (FN_##name)GetProcAddress(hinstLZ32, #name); \
933  if (!fn##name) goto Quit; \
934 } while (0)
936  GET_FN(LZCopy);
937  GET_FN(LZClose);
938 #undef GET_FN
939 
940  if (!WideCharToMultiByte(CP_ACP, 0, pszNewFile, -1, szDestA, _countof(szDestA), NULL, NULL))
941  goto Quit;
942  szDestA[_countof(szDestA) - 1] = 0;
943 
944  hfSrc = fnLZOpenFileW(pszOldFile, &OFStruct, OF_READ);
945  if (hfSrc < 0)
946  goto Quit;
947 
948  hfDest = OpenFile(szDestA, &OFStruct, OF_CREATE);
949  if (hfDest != HFILE_ERROR)
950  {
951  ret = (fnLZCopy(hfSrc, hfDest) >= 0);
952  _lclose(hfDest);
953  }
954 
955  fnLZClose(hfSrc);
956 
957 Quit:
958  if (bLoaded)
959  FreeLibrary(hinstLZ32);
960  return ret;
961 }
#define OF_READ
Definition: winbase.h:116
#define WideCharToMultiByte
Definition: compat.h:111
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
HFILE WINAPI LZOpenFileW(LPWSTR fn, LPOFSTRUCT ofs, WORD mode)
Definition: lzexpand.c:585
int WINAPI _lclose(HFILE hFile)
Definition: lfile.c:138
void WINAPI LZClose(HFILE fd)
Definition: lzexpand.c:600
#define L(x)
Definition: ntvdm.h:50
#define HFILE_ERROR
Definition: winbase.h:111
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
INT(WINAPI * FN_LZOpenFileW)(LPWSTR, LPOFSTRUCT, WORD)
Definition: utils.c:903
LONG(WINAPI * FN_LZCopy)(INT, INT)
Definition: utils.c:904
#define LoadLibraryW(x)
Definition: compat.h:606
VOID(WINAPI * FN_LZClose)(INT)
Definition: utils.c:905
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle)
Definition: create.c:368
#define FreeLibrary(x)
Definition: compat.h:607
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define GET_FN(name)
int ret
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:122
LONG WINAPI LZCopy(HFILE src, HFILE dest)
Definition: lzexpand.c:472
#define NULL
Definition: types.h:112
#define OF_CREATE
Definition: winbase.h:125
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
int HFILE
Definition: windef.h:298

Referenced by ImmInstallIMEW().

◆ Imm32CurrentPti()

static PTHREADINFO FASTCALL Imm32CurrentPti ( VOID  )
inlinestatic

Definition at line 162 of file precomp.h.

163 {
164  if (NtCurrentTeb()->Win32ThreadInfo == NULL)
166  return NtCurrentTeb()->Win32ThreadInfo;
167 }
DWORD_PTR NTAPI NtUserGetThreadState(DWORD Routine)
Definition: misc.c:232
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define NULL
Definition: types.h:112

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

◆ Imm32FetchImeState()

PIME_STATE APIENTRY Imm32FetchImeState ( LPINPUTCONTEXTDX  pIC,
HKL  hKL 
)

Definition at line 370 of file utils.c.

371 {
372  PIME_STATE pState;
373  WORD Lang = PRIMARYLANGID(LOWORD(hKL));
374  for (pState = pIC->pState; pState; pState = pState->pNext)
375  {
376  if (pState->wLang == Lang)
377  break;
378  }
379  if (!pState)
380  {
381  pState = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(IME_STATE));
382  if (pState)
383  {
384  pState->wLang = Lang;
385  pState->pNext = pIC->pState;
386  pIC->pState = pState;
387  }
388  }
389  return pState;
390 }
WORD wLang
Definition: immdev.h:192
unsigned short WORD
Definition: ntddk_ex.h:93
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
struct IME_STATE * pState
Definition: immdev.h:111
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
struct IME_STATE * pNext
Definition: immdev.h:191
#define LOWORD(l)
Definition: pedump.c:82
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by Imm32SelectInputContext().

◆ Imm32FetchImeSubState()

PIME_SUBSTATE APIENTRY Imm32FetchImeSubState ( PIME_STATE  pState,
HKL  hKL 
)

Definition at line 394 of file utils.c.

395 {
396  PIME_SUBSTATE pSubState;
397  for (pSubState = pState->pSubState; pSubState; pSubState = pSubState->pNext)
398  {
399  if (pSubState->hKL == hKL)
400  return pSubState;
401  }
402  pSubState = ImmLocalAlloc(0, sizeof(IME_SUBSTATE));
403  if (!pSubState)
404  return NULL;
405  pSubState->dwValue = 0;
406  pSubState->hKL = hKL;
407  pSubState->pNext = pState->pSubState;
408  pState->pSubState = pSubState;
409  return pSubState;
410 }
PIME_SUBSTATE pSubState
Definition: immdev.h:197
DWORD dwValue
Definition: immdev.h:182
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#define NULL
Definition: types.h:112
struct IME_SUBSTATE * pNext
Definition: immdev.h:180

Referenced by Imm32LoadImeStateSentence(), and Imm32SaveImeStateSentence().

◆ Imm32FindOrLoadImeDpi()

PIMEDPI APIENTRY Imm32FindOrLoadImeDpi ( HKL  hKL)

Definition at line 285 of file ime.c.

286 {
287  PIMEDPI pImeDpi;
288 
289  if (!IS_IME_HKL(hKL) && (!Imm32IsCiceroMode() || Imm32Is16BitMode()))
290  return NULL;
291 
292  pImeDpi = ImmLockImeDpi(hKL);
293  if (pImeDpi == NULL)
294  pImeDpi = Ime32LoadImeDpi(hKL, TRUE);
295  return pImeDpi;
296 }
#define TRUE
Definition: types.h:120
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1203
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:729
PIMEDPI APIENTRY Ime32LoadImeDpi(HKL hKL, BOOL bLock)
Definition: ime.c:222
#define NULL
Definition: types.h:112
#define Imm32Is16BitMode()
Definition: precomp.h:119
#define Imm32IsCiceroMode()
Definition: precomp.h:118

Referenced by 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 743 of file utils.c.

744 {
745  HKEY hkeyLayouts, hkeyIME;
746  WCHAR szImeFileName[80], szImeKey[20];
747  UINT iKey, nCount;
748  DWORD cbData;
749  LONG lError;
750  ULONG Value;
751  HKL hKL;
752 
753  /* Open the registry keyboard layouts */
754  lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
755  if (lError != ERROR_SUCCESS)
756  return 0;
757 
758  for (iKey = nCount = 0; ; ++iKey)
759  {
760  /* Get the key name */
761  lError = RegEnumKeyW(hkeyLayouts, iKey, szImeKey, _countof(szImeKey));
762  if (lError != ERROR_SUCCESS)
763  break;
764 
765  if (szImeKey[0] != L'E' && szImeKey[0] != L'e')
766  continue; /* Not an IME layout */
767 
768  if (pLayouts == NULL) /* for counting only */
769  {
770  ++nCount;
771  continue;
772  }
773 
774  if (cLayouts <= nCount)
775  break;
776 
777  lError = RegOpenKeyW(hkeyLayouts, szImeKey, &hkeyIME); /* Open the IME key */
778  if (lError != ERROR_SUCCESS)
779  break;
780 
781  /* Load the "Ime File" value */
782  szImeFileName[0] = 0;
783  cbData = sizeof(szImeFileName);
784  RegQueryValueExW(hkeyIME, L"Ime File", NULL, NULL, (LPBYTE)szImeFileName, &cbData);
785  szImeFileName[_countof(szImeFileName) - 1] = 0;
786 
787  RegCloseKey(hkeyIME);
788 
789  if (!szImeFileName[0])
790  break;
791 
792  Imm32StrToUInt(szImeKey, &Value, 16);
793  hKL = (HKL)(DWORD_PTR)Value;
794  if (!IS_IME_HKL(hKL))
795  break;
796 
797  /* Store the IME key and the IME filename */
798  pLayouts[nCount].hKL = hKL;
799  StringCchCopyW(pLayouts[nCount].szImeKey, _countof(pLayouts[nCount].szImeKey), szImeKey);
800  CharUpperW(szImeFileName);
801  StringCchCopyW(pLayouts[nCount].szFileName, _countof(pLayouts[nCount].szFileName),
802  szImeFileName);
803  ++nCount;
804  }
805 
806  RegCloseKey(hkeyLayouts);
807  return nCount;
808 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
Definition: utils.c:20
HKL hKL
Definition: precomp.h:67
LPWSTR WINAPI CharUpperW(_Inout_ LPWSTR)
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define IS_IME_HKL(hkl)
Definition: ntuser.h:1203
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RegCloseKey(hKey)
Definition: registry.h:47
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ImmInstallIMEW().

◆ Imm32GetSystemLibraryPath()

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

Definition at line 122 of file utils.c.

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

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

◆ Imm32ImeMenuAnsiToWide()

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

Definition at line 319 of file utils.c.

321 {
322  INT ret;
323  pItemW->cbSize = pItemA->cbSize;
324  pItemW->fType = pItemA->fType;
325  pItemW->fState = pItemA->fState;
326  pItemW->wID = pItemA->wID;
327  if (bBitmap)
328  {
329  pItemW->hbmpChecked = pItemA->hbmpChecked;
330  pItemW->hbmpUnchecked = pItemA->hbmpUnchecked;
331  pItemW->hbmpItem = pItemA->hbmpItem;
332  }
333  pItemW->dwItemData = pItemA->dwItemData;
334  ret = MultiByteToWideChar(uCodePage, 0, pItemA->szString, -1,
335  pItemW->szString, _countof(pItemW->szString));
336  if (ret >= _countof(pItemW->szString))
337  {
338  ret = 0;
339  pItemW->szString[0] = 0;
340  }
341  return ret;
342 }
HBITMAP hbmpChecked
Definition: imm.h:129
DWORD dwItemData
Definition: imm.h:131
int32_t INT
Definition: typedefs.h:58
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:132
HBITMAP hbmpUnchecked
Definition: dimm.idl:123
#define _countof(array)
Definition: sndvol32.h:68
int ret
DWORD dwItemData
Definition: dimm.idl:124
HBITMAP hbmpItem
Definition: dimm.idl:126
#define MultiByteToWideChar
Definition: compat.h:110
HBITMAP hbmpChecked
Definition: dimm.idl:122
HBITMAP hbmpItem
Definition: imm.h:133
HBITMAP hbmpUnchecked
Definition: imm.h:130
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:125

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32ImeMenuWideToAnsi()

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

Definition at line 346 of file utils.c.

348 {
349  INT ret;
350  pItemA->cbSize = pItemW->cbSize;
351  pItemA->fType = pItemW->fType;
352  pItemA->fState = pItemW->fState;
353  pItemA->wID = pItemW->wID;
354  pItemA->hbmpChecked = pItemW->hbmpChecked;
355  pItemA->hbmpUnchecked = pItemW->hbmpUnchecked;
356  pItemA->dwItemData = pItemW->dwItemData;
357  pItemA->hbmpItem = pItemW->hbmpItem;
358  ret = WideCharToMultiByte(uCodePage, 0, pItemW->szString, -1,
359  pItemA->szString, _countof(pItemA->szString), NULL, NULL);
360  if (ret >= _countof(pItemA->szString))
361  {
362  ret = 0;
363  pItemA->szString[0] = 0;
364  }
365  return ret;
366 }
#define WideCharToMultiByte
Definition: compat.h:111
HBITMAP hbmpChecked
Definition: dimm.idl:134
HBITMAP hbmpUnchecked
Definition: imm.h:117
int32_t INT
Definition: typedefs.h:58
HBITMAP hbmpUnchecked
Definition: dimm.idl:135
DWORD dwItemData
Definition: dimm.idl:136
DWORD dwItemData
Definition: imm.h:118
HBITMAP hbmpItem
Definition: dimm.idl:138
#define _countof(array)
Definition: sndvol32.h:68
HBITMAP hbmpChecked
Definition: imm.h:116
int ret
HBITMAP hbmpItem
Definition: imm.h:120
CHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: imm.h:119
WCHAR szString[IMEMENUITEM_STRING_SIZE]
Definition: dimm.idl:137
#define NULL
Definition: types.h:112

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32InternalLockIMC()

LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC ( HIMC  hIMC,
BOOL  fSelect 
)

Definition at line 816 of file imm.c.

817 {
818  HANDLE hIC;
819  LPINPUTCONTEXT pIC = NULL;
820  PCLIENTIMC pClientImc;
821  WORD LangID;
823  HKL hOldKL, hNewKL;
824  PIMEDPI pImeDpi = NULL;
825 
826  pClientImc = ImmLockClientImc(hIMC);
827  if (!pClientImc)
828  return NULL;
829 
830  RtlEnterCriticalSection(&pClientImc->cs);
831 
832  if (pClientImc->hInputContext)
833  {
834  pIC = LocalLock(pClientImc->hInputContext);
835  if (pIC)
836  goto Success;
837  else
838  goto Failure;
839  }
840 
843  {
844  hOldKL = GetKeyboardLayout(0);
845  LangID = LOWORD(hOldKL);
846  hNewKL = (HKL)(DWORD_PTR)MAKELONG(LangID, LangID);
847 
848  pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
849  if (pImeDpi)
850  {
851  CtfImmTIMActivate(hNewKL);
852  }
853  }
854 
856  goto Failure;
857 
858  hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
859  pIC = LocalLock(hIC);
860  if (!pIC)
861  {
862  LocalFree(hIC);
863  goto Failure;
864  }
865  pClientImc->hInputContext = hIC;
866 
867  hNewKL = GetKeyboardLayout(dwThreadId);
868  if (!Imm32CreateInputContext(hIMC, pIC, pClientImc, hNewKL, fSelect))
869  {
870  pClientImc->hInputContext = LocalFree(pClientImc->hInputContext);
871  goto Failure;
872  }
873 
874 Success:
876  RtlLeaveCriticalSection(&pClientImc->cs);
877  InterlockedIncrement(&pClientImc->cLockObj);
878  ImmUnlockClientImc(pClientImc);
879  return pIC;
880 
881 Failure:
882  RtlLeaveCriticalSection(&pClientImc->cs);
883  ImmUnlockClientImc(pClientImc);
884  return NULL;
885 }
LONG cLockObj
Definition: ntuser.h:1304
HRESULT APIENTRY CtfImmTIMCreateInputContext(HIMC hIMC)
Definition: ctf.c:42
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
BOOL APIENTRY Imm32CreateInputContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
Definition: imm.c:722
#define DWORD
Definition: nt_native.h:44
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define MAKELONG(a, b)
Definition: typedefs.h:249
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:459
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1773
HANDLE hInputContext
Definition: ntuser.h:1303
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:1307
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:119
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL)
Definition: ime.c:285
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
_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 Imm32IsCiceroMode()
Definition: precomp.h:118
#define LOWORD(l)
Definition: pedump.c:82
HRESULT WINAPI CtfImmTIMActivate(HKL hKL)
Definition: ctf.c:67
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

Referenced by Imm32SelectInputContext(), and ImmLockIMC().

◆ Imm32IsCrossProcessAccess()

static BOOL Imm32IsCrossProcessAccess ( HWND  hWnd)
inlinestatic

Definition at line 108 of file precomp.h.

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

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

◆ Imm32IsCrossThreadAccess()

static BOOL Imm32IsCrossThreadAccess ( HIMC  hIMC)
inlinestatic

Definition at line 100 of file precomp.h.

101 {
102  DWORD dwImeThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
104  return (dwImeThreadId != dwThreadId);
105 }
#define DWORD
Definition: nt_native.h:44
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:459
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1773
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31

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

◆ Imm32IsImcAnsi()

BOOL WINAPI Imm32IsImcAnsi ( HIMC  hIMC)

Definition at line 54 of file utils.c.

55 {
56  BOOL ret;
57  PCLIENTIMC pClientImc = ImmLockClientImc(hIMC);
58  if (!pClientImc)
59  return -1;
60  ret = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
61  ImmUnlockClientImc(pClientImc);
62  return ret;
63 }
#define CLIENTIMC_WIDE
Definition: ntuser.h:1325
unsigned int BOOL
Definition: ntddk_ex.h:94
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:909
int ret
DWORD dwFlags
Definition: ntuser.h:1305
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:954

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32IsSystemJapaneseOrKorean()

BOOL APIENTRY Imm32IsSystemJapaneseOrKorean ( VOID  )

Definition at line 45 of file utils.c.

46 {
47  LCID lcid = GetSystemDefaultLCID();
49  WORD wPrimary = PRIMARYLANGID(LangID);
50  return (wPrimary == LANG_JAPANESE || wPrimary == LANG_KOREAN);
51 }
DWORD LCID
Definition: nls.h:13
WORD LANGID
Definition: typedefs.h:81
#define LANG_JAPANESE
Definition: nls.h:76
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:791
unsigned short WORD
Definition: ntddk_ex.h:93
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define LANG_KOREAN
Definition: nls.h:84
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by ImmWINNLSGetEnableStatus().

◆ Imm32LoadImeStateSentence()

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

Definition at line 414 of file utils.c.

415 {
416  PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
417  if (pSubState)
418  {
419  pIC->fdwSentence |= pSubState->dwValue;
420  return TRUE;
421  }
422  return FALSE;
423 }
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:394
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD dwValue
Definition: immdev.h:182

Referenced by Imm32SelectInputContext().

◆ Imm32LoadImeVerInfo()

BOOL APIENTRY Imm32LoadImeVerInfo ( PIMEINFOEX  pImeInfoEx)

Definition at line 642 of file utils.c.

643 {
644  HINSTANCE hinstVersion;
645  BOOL ret = FALSE, bLoaded = FALSE;
647  LPVOID pVerInfo;
648  DWORD cbVerInfo, dwHandle;
649 
650  /* Load version.dll to use the version info API */
652  hinstVersion = GetModuleHandleW(szPath);
653  if (!hinstVersion)
654  {
655  hinstVersion = LoadLibraryW(szPath);
656  if (!hinstVersion)
657  return FALSE;
658  bLoaded = TRUE;
659  }
660 
661 #define GET_FN(name) do { \
662  s_fn##name = (FN_##name)GetProcAddress(hinstVersion, #name); \
663  if (!s_fn##name) goto Quit; \
664 } while (0)
668 #undef GET_FN
669 
670  /* The path of the IME module */
672 
673  cbVerInfo = s_fnGetFileVersionInfoSizeW(szPath, &dwHandle);
674  if (!cbVerInfo)
675  goto Quit;
676 
677  pVerInfo = ImmLocalAlloc(0, cbVerInfo);
678  if (!pVerInfo)
679  goto Quit;
680 
681  /* Load the version info of the IME module */
682  if (s_fnGetFileVersionInfoW(szPath, dwHandle, cbVerInfo, pVerInfo) &&
683  Imm32LoadImeFixedInfo(pImeInfoEx, pVerInfo))
684  {
685  ret = Imm32LoadImeLangAndDesc(pImeInfoEx, pVerInfo);
686  }
687 
688  ImmLocalFree(pVerInfo);
689 
690 Quit:
691  if (bLoaded)
692  FreeLibrary(hinstVersion);
693  return ret;
694 }
#define TRUE
Definition: types.h:120
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LoadLibraryW(x)
Definition: compat.h:606
static FN_GetFileVersionInfoSizeW s_fnGetFileVersionInfoSizeW
Definition: utils.c:566
#define FreeLibrary(x)
Definition: compat.h:607
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
static BOOL APIENTRY Imm32LoadImeFixedInfo(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:570
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GET_FN(name)
#define ImmLocalFree(lpData)
Definition: precomp.h:89
int ret
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:122
static FN_GetFileVersionInfoW s_fnGetFileVersionInfoW
Definition: utils.c:565
WCHAR wszImeFile[80]
Definition: ntuser.h:1187
LPCWSTR szPath
Definition: env.c:37
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
BOOL APIENTRY Imm32LoadImeLangAndDesc(PIMEINFOEX pInfoEx, LPCVOID pVerInfo)
Definition: utils.c:604
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049

Referenced by ImmInstallIMEW(), and ImmLoadLayout().

◆ Imm32MakeIMENotify()

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

Definition at line 247 of file utils.c.

249 {
251  HKL hKL;
252  PIMEDPI pImeDpi;
253 
254  if (dwAction)
255  {
257  if (dwThreadId)
258  {
259  /* find keyboard layout and lock it */
261  pImeDpi = ImmLockImeDpi(hKL);
262  if (pImeDpi)
263  {
264  /* do notify */
265  pImeDpi->NotifyIME(hIMC, dwAction, dwIndex, dwValue);
266 
267  ImmUnlockImeDpi(pImeDpi); /* unlock */
268  }
269  }
270  }
271 
272  if (hwnd && dwCommand)
273  SendMessageW(hwnd, WM_IME_NOTIFY, dwCommand, dwData);
274 
275  return TRUE;
276 }
VOID WINAPI ImmUnlockImeDpi(PIMEDPI pImeDpi)
Definition: ime.c:758
#define WM_IME_NOTIFY
Definition: winuser.h:1817
#define TRUE
Definition: types.h:120
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define DWORD
Definition: nt_native.h:44
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1773
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:729
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
UINT_PTR HKL
Definition: msctf.idl:101
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022

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

◆ Imm32ReconvertAnsiFromWide()

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

Definition at line 504 of file utils.c.

505 {
506  DWORD cch0, cch1, cchDest, cbDest;
507  LPCWSTR pchSrc = (LPCWSTR)((LPCSTR)pSrc + pSrc->dwStrOffset);
508  LPSTR pchDest;
509 
510  if (pSrc->dwVersion != 0)
511  return 0;
512 
513  cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
514  NULL, 0, NULL, NULL);
515  cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(CHAR);
516  if (!pDest)
517  return cbDest;
518 
519  if (pDest->dwSize < cbDest)
520  return 0;
521 
522  /* dwSize */
523  pDest->dwSize = cbDest;
524 
525  /* dwVersion */
526  pDest->dwVersion = 0;
527 
528  /* dwStrOffset */
529  pDest->dwStrOffset = sizeof(RECONVERTSTRING);
530 
531  /* dwCompStrOffset */
532  cch1 = pSrc->dwCompStrOffset / sizeof(WCHAR);
533  cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
534  pDest->dwCompStrOffset = cch0 * sizeof(CHAR);
535 
536  /* dwCompStrLen */
537  cch0 = IchAnsiFromWide(cch1 + pSrc->dwCompStrLen, pchSrc, uCodePage);
538  pDest->dwCompStrLen = cch0 * sizeof(CHAR) - pDest->dwCompStrOffset;
539 
540  /* dwTargetStrOffset */
541  cch1 = pSrc->dwTargetStrOffset / sizeof(WCHAR);
542  cch0 = IchAnsiFromWide(cch1, pchSrc, uCodePage);
543  pDest->dwTargetStrOffset = cch0 * sizeof(CHAR);
544 
545  /* dwTargetStrLen */
546  cch0 = IchAnsiFromWide(cch1 + pSrc->dwTargetStrLen, pchSrc, uCodePage);
547  pDest->dwTargetStrLen = cch0 * sizeof(CHAR) - pDest->dwTargetStrOffset;
548 
549  /* dwStrLen */
550  pDest->dwStrLen = cchDest;
551 
552  /* the string */
553  pchDest = (LPSTR)pDest + pDest->dwStrOffset;
554  cchDest = WideCharToMultiByte(uCodePage, 0, pchSrc, pSrc->dwStrLen,
555  pchDest, cchDest, NULL, NULL);
556  pchDest[cchDest] = 0;
557 
558  return cbDest;
559 }
DWORD dwTargetStrOffset
Definition: imm.h:104
#define WideCharToMultiByte
Definition: compat.h:111
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
DWORD dwSize
Definition: imm.h:97
struct tagRECONVERTSTRING RECONVERTSTRING
DWORD dwCompStrOffset
Definition: imm.h:102
char * LPSTR
Definition: xmlstorage.h:182
DWORD dwVersion
Definition: imm.h:98
DWORD dwCompStrLen
Definition: imm.h:101
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwStrLen
Definition: imm.h:99
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwTargetStrLen
Definition: imm.h:103
DWORD dwStrOffset
Definition: imm.h:100
#define NULL
Definition: types.h:112
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:109
#define CHAR(Char)

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32ReconvertWideFromAnsi()

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

Definition at line 448 of file utils.c.

449 {
450  DWORD cch0, cchDest, cbDest;
451  LPCSTR pchSrc = (LPCSTR)pSrc + pSrc->dwStrOffset;
452  LPWSTR pchDest;
453 
454  if (pSrc->dwVersion != 0)
455  return 0;
456 
457  cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
458  NULL, 0);
459  cbDest = sizeof(RECONVERTSTRING) + (cchDest + 1) * sizeof(WCHAR);
460  if (!pDest)
461  return cbDest;
462 
463  if (pDest->dwSize < cbDest)
464  return 0;
465 
466  /* dwSize */
467  pDest->dwSize = cbDest;
468 
469  /* dwVersion */
470  pDest->dwVersion = 0;
471 
472  /* dwStrOffset */
473  pDest->dwStrOffset = sizeof(RECONVERTSTRING);
474 
475  /* dwCompStrOffset */
476  cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset, pchSrc, uCodePage);
477  pDest->dwCompStrOffset = cch0 * sizeof(WCHAR);
478 
479  /* dwCompStrLen */
480  cch0 = IchWideFromAnsi(pSrc->dwCompStrOffset + pSrc->dwCompStrLen, pchSrc, uCodePage);
481  pDest->dwCompStrLen = (cch0 * sizeof(WCHAR) - pDest->dwCompStrOffset) / sizeof(WCHAR);
482 
483  /* dwTargetStrOffset */
484  cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset, pchSrc, uCodePage);
485  pDest->dwTargetStrOffset = cch0 * sizeof(WCHAR);
486 
487  /* dwTargetStrLen */
488  cch0 = IchWideFromAnsi(pSrc->dwTargetStrOffset + pSrc->dwTargetStrLen, pchSrc, uCodePage);
489  pDest->dwTargetStrLen = (cch0 * sizeof(WCHAR) - pSrc->dwTargetStrOffset) / sizeof(WCHAR);
490 
491  /* dwStrLen */
492  pDest->dwStrLen = cchDest;
493 
494  /* the string */
495  pchDest = (LPWSTR)((LPBYTE)pDest + pDest->dwStrOffset);
496  cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
497  pchDest, cchDest);
498  pchDest[cchDest] = 0;
499 
500  return cbDest;
501 }
DWORD dwTargetStrOffset
Definition: imm.h:104
DWORD dwSize
Definition: imm.h:97
struct tagRECONVERTSTRING RECONVERTSTRING
DWORD dwCompStrOffset
Definition: imm.h:102
#define MB_PRECOMPOSED
Definition: winnls.h:281
if(dx==0 &&dy==0)
Definition: linetemp.h:174
DWORD dwVersion
Definition: imm.h:98
DWORD dwCompStrLen
Definition: imm.h:101
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:89
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwStrLen
Definition: imm.h:99
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwTargetStrLen
Definition: imm.h:103
DWORD dwStrOffset
Definition: imm.h:100
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32ReleaseIME()

BOOL APIENTRY Imm32ReleaseIME ( HKL  hKL)

Definition at line 311 of file ime.c.

312 {
313  BOOL ret = TRUE;
314  PIMEDPI pImeDpi0, pImeDpi1;
315 
317 
318  for (pImeDpi0 = gpImeDpiList; pImeDpi0; pImeDpi0 = pImeDpi0->pNext)
319  {
320  if (pImeDpi0->hKL == hKL)
321  break;
322  }
323 
324  if (!pImeDpi0)
325  goto Quit;
326 
327  if (pImeDpi0->cLockObj)
328  {
329  pImeDpi0->dwFlags |= IMEDPI_FLAG_UNKNOWN;
330  ret = FALSE;
331  goto Quit;
332  }
333 
334  if (gpImeDpiList == pImeDpi0)
335  {
336  gpImeDpiList = pImeDpi0->pNext;
337  }
338  else if (gpImeDpiList)
339  {
340  for (pImeDpi1 = gpImeDpiList; pImeDpi1; pImeDpi1 = pImeDpi1->pNext)
341  {
342  if (pImeDpi1->pNext == pImeDpi0)
343  {
344  pImeDpi1->pNext = pImeDpi0->pNext;
345  break;
346  }
347  }
348  }
349 
350  Imm32FreeIME(pImeDpi0, TRUE);
351  ImmLocalFree(pImeDpi0);
352 
353 Quit:
355  return ret;
356 }
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
PIMEDPI gpImeDpiList
Definition: ime.c:17
#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:1256
RTL_CRITICAL_SECTION gcsImeDpi
Definition: ime.c:16
#define ImmLocalFree(lpData)
Definition: precomp.h:89
int ret
struct IMEDPI * pNext
Definition: ntuser.h:1250
DWORD dwFlags
Definition: ntuser.h:1257
VOID APIENTRY Imm32FreeIME(PIMEDPI pImeDpi, BOOL bDestroy)
Definition: ime.c:36
#define IMEDPI_FLAG_UNKNOWN
Definition: ntuser.h:1297
HKL hKL
Definition: ntuser.h:1252

Referenced by ImmFreeLayout().

◆ Imm32SaveImeStateSentence()

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

Definition at line 427 of file utils.c.

428 {
429  PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
430  if (pSubState)
431  {
432  pSubState->dwValue = (pIC->fdwSentence & 0xffff0000);
433  return TRUE;
434  }
435  return FALSE;
436 }
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:394
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD dwValue
Definition: immdev.h:182

Referenced by Imm32SelectInputContext().

◆ Imm32StrToUInt()

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

Definition at line 20 of file utils.c.

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

Referenced by Imm32GetImeLayout().

◆ Imm32UIntToStr()

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

Definition at line 33 of file utils.c.

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

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

◆ Imm32WideFromAnsi()

LPWSTR APIENTRY Imm32WideFromAnsi ( LPCSTR  pszA)

Definition at line 65 of file utils.c.

66 {
67  INT cch = lstrlenA(pszA);
68  LPWSTR pszW = ImmLocalAlloc(0, (cch + 1) * sizeof(WCHAR));
69  if (pszW == NULL)
70  return NULL;
71  cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pszA, cch, pszW, cch + 1);
72  pszW[cch] = 0;
73  return pszW;
74 }
#define CP_ACP
Definition: compat.h:109
#define MB_PRECOMPOSED
Definition: winnls.h:281
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:234
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
IN PCTCH IN DWORD cch
Definition: pager.h:36

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

◆ Imm32WriteImeLayout()

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

Definition at line 811 of file utils.c.

812 {
813  UINT iPreload;
814  HKEY hkeyLayouts, hkeyIME, hkeyPreload;
815  WCHAR szImeKey[20], szPreloadNumber[20], szPreloadKey[20], szImeFileName[80];
816  DWORD cbData;
817  LANGID LangID;
818  LONG lError;
819  LPCWSTR pszLayoutFile;
820 
821  /* Open the registry keyboard layouts */
822  lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
823  if (lError != ERROR_SUCCESS)
824  return FALSE;
825 
826  /* Get the IME key from hKL */
827  Imm32UIntToStr((DWORD)(DWORD_PTR)hKL, 16, szImeKey, _countof(szImeKey));
828 
829  /* Create a registry IME key */
830  lError = RegCreateKeyW(hkeyLayouts, szImeKey, &hkeyIME);
831  if (lError != ERROR_SUCCESS)
832  goto Failure;
833 
834  /* Write "Ime File" */
835  cbData = (wcslen(pchFilePart) + 1) * sizeof(WCHAR);
836  lError = RegSetValueExW(hkeyIME, L"Ime File", 0, REG_SZ, (LPBYTE)pchFilePart, cbData);
837  if (lError != ERROR_SUCCESS)
838  goto Failure;
839 
840  /* Write "Layout Text" */
841  cbData = (wcslen(pszLayout) + 1) * sizeof(WCHAR);
842  lError = RegSetValueExW(hkeyIME, L"Layout Text", 0, REG_SZ, (LPBYTE)pszLayout, cbData);
843  if (lError != ERROR_SUCCESS)
844  goto Failure;
845 
846  /* Choose "Layout File" from hKL */
847  LangID = LOWORD(hKL);
848  switch (LOBYTE(LangID))
849  {
850  case LANG_JAPANESE: pszLayoutFile = L"kbdjpn.dll"; break;
851  case LANG_KOREAN: pszLayoutFile = L"kbdkor.dll"; break;
852  default: pszLayoutFile = L"kbdus.dll"; break;
853  }
854  StringCchCopyW(szImeFileName, _countof(szImeFileName), pszLayoutFile);
855 
856  /* Write "Layout File" */
857  cbData = (wcslen(szImeFileName) + 1) * sizeof(WCHAR);
858  lError = RegSetValueExW(hkeyIME, L"Layout File", 0, REG_SZ, (LPBYTE)szImeFileName, cbData);
859  if (lError != ERROR_SUCCESS)
860  goto Failure;
861 
862  RegCloseKey(hkeyIME);
863  RegCloseKey(hkeyLayouts);
864 
865  /* Create "Preload" key */
866  RegCreateKeyW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", &hkeyPreload);
867 
868 #define MAX_PRELOAD 0x400
869  for (iPreload = 1; iPreload < MAX_PRELOAD; ++iPreload)
870  {
871  Imm32UIntToStr(iPreload, 10, szPreloadNumber, _countof(szPreloadNumber));
872 
873  /* Load the key of the preload number */
874  cbData = sizeof(szPreloadKey);
875  lError = RegQueryValueExW(hkeyPreload, szPreloadNumber, NULL, NULL,
876  (LPBYTE)szPreloadKey, &cbData);
877  szPreloadKey[_countof(szPreloadKey) - 1] = 0;
878 
879  if (lError != ERROR_SUCCESS || lstrcmpiW(szImeKey, szPreloadKey) == 0)
880  break; /* Found an empty room or the same key */
881  }
882 
883  if (iPreload >= MAX_PRELOAD) /* Not found */
884  {
885  RegCloseKey(hkeyPreload);
886  return FALSE;
887  }
888 #undef MAX_PRELOAD
889 
890  /* Write the IME key to the preload number */
891  cbData = (wcslen(szImeKey) + 1) * sizeof(WCHAR);
892  lError = RegSetValueExW(hkeyPreload, szPreloadNumber, 0, REG_SZ, (LPBYTE)szImeKey, cbData);
893  RegCloseKey(hkeyPreload);
894  return lError == ERROR_SUCCESS;
895 
896 Failure:
897  RegCloseKey(hkeyIME);
898  RegDeleteKeyW(hkeyLayouts, szImeKey);
899  RegCloseKey(hkeyLayouts);
900  return FALSE;
901 }
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
WORD LANGID
Definition: typedefs.h:81
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define LANG_JAPANESE
Definition: nls.h:76
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4899
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define REGKEY_KEYBOARD_LAYOUTS
Definition: precomp.h:60
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:33
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MAX_PRELOAD
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
uint32_t DWORD_PTR
Definition: typedefs.h:65
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define LANG_KOREAN
Definition: nls.h:84
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define LOWORD(l)
Definition: pedump.c:82
#define RegCloseKey(hKey)
Definition: registry.h:47
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by ImmInstallIMEW().

◆ ImmLocalAlloc()

LPVOID APIENTRY ImmLocalAlloc ( DWORD  dwFlags,
DWORD  dwBytes 
)

◆ LogFontAnsiToWide()

VOID APIENTRY LogFontAnsiToWide ( const LOGFONTA plfA,
LPLOGFONTW  plfW 
)

Definition at line 132 of file utils.c.

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

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

◆ LogFontWideToAnsi()

VOID APIENTRY LogFontWideToAnsi ( const LOGFONTW plfW,
LPLOGFONTA  plfA 
)

Definition at line 145 of file utils.c.

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

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

◆ ValidateHandle()

◆ ValidateHandleNoErr()

LPVOID FASTCALL ValidateHandleNoErr ( HANDLE  hObject,
UINT  uType 
)

Definition at line 171 of file utils.c.

172 {
173  UINT index;
177  LPVOID ptr;
178 
179  if (!NtUserValidateHandleSecure(hObject))
180  return NULL;
181 
182  ht = gSharedInfo.aheList; /* handle table */
183  ASSERT(ht);
184  /* ReactOS-Specific! */
187 
188  index = (LOWORD(hObject) - FIRST_USER_HANDLE) >> 1;
189  if ((INT)index < 0 || ht->nb_handles <= index || he[index].type != uType)
190  return NULL;
191 
192  if (he[index].flags & HANDLEENTRY_DESTROY)
193  return NULL;
194 
195  generation = HIWORD(hObject);
196  if (generation != he[index].generation && generation && generation != 0xFFFF)
197  return NULL;
198 
199  ptr = he[index].ptr;
200  if (ptr)
202 
203  return ptr;
204 }
unsigned char type
Definition: ntuser.h:25
#define FIRST_USER_HANDLE
Definition: ntuser.h:10
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
static PVOID ptr
Definition: dispmode.c:27
GLuint index
Definition: glext.h:6031
BOOL NTAPI NtUserValidateHandleSecure(HANDLE hHdl)
Definition: object.c:792
Definition: ntuser.h:16
struct _USER_HANDLE_ENTRY * PUSER_HANDLE_ENTRY
#define ASSERT(a)
Definition: mode.c:44
unsigned short WORD
Definition: ntddk_ex.h:93
GLbitfield flags
Definition: glext.h:7161
SHAREDINFO gSharedInfo
Definition: imm.c:18
#define index(s, c)
Definition: various.h:29
ULONG_PTR ulSharedDelta
Definition: ntuser.h:1100
#define HANDLEENTRY_DESTROY
Definition: ntuser.h:13
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2964
static const struct newhuff ht[]
Definition: huffman.h:296
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static PVOID FASTCALL DesktopPtrToUser(PVOID ptr)
Definition: utils.c:157
#define HIWORD(l)
Definition: typedefs.h:247
void * ptr
Definition: ntuser.h:18
#define LOWORD(l)
Definition: pedump.c:82
PVOID aheList
Definition: ntuser.h:1098

Referenced by MENU_GetMenu().

Variable Documentation

◆ gcsImeDpi

◆ ghImm32Inst

HMODULE ghImm32Inst

Definition at line 16 of file imm.c.

Referenced by ImmInitializeGlobals().

◆ ghImmHeap

HANDLE ghImmHeap

Definition at line 16 of file utils.c.

Referenced by ImmLocalAlloc().

◆ gpImeDpiList

PIMEDPI gpImeDpiList

◆ gpsi

Definition at line 17 of file imm.c.

◆ gSharedInfo

SHAREDINFO gSharedInfo

Definition at line 18 of file imm.c.