ReactOS 0.4.16-dev-197-g92996da
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 <immdev.h>
#include <imm32_undoc.h>
#include <ndk/umtypes.h>
#include <ndk/pstypes.h>
#include <ndk/rtlfuncs.h>
#include "ntuser.h"
#include "ntwin32.h"
#include <undocuser.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 ROUNDUP4(n)   (((n) + 3) & ~3) /* DWORD alignment */
 
#define ValidateHwndNoErr(hwnd)   ValidateHandleNoErr((hwnd), TYPE_WINDOW)
 
#define ValidateHwnd(hwnd)   ValidateHandle((hwnd), TYPE_WINDOW)
 
#define ImmLocalFree(lpData)   HeapFree(ghImmHeap, 0, (lpData))
 
#define UNEXPECTED()   0
 
#define FAILED_UNEXPECTEDLY(hr)
 
#define IS_NULL_UNEXPECTEDLY(p)
 
#define IS_ZERO_UNEXPECTEDLY(p)
 
#define IS_TRUE_UNEXPECTEDLY(x)
 
#define IS_FALSE_UNEXPECTEDLY(x)
 
#define IS_ERROR_UNEXPECTEDLY(x)
 
#define IS_CROSS_THREAD_HIMC(hIMC)   IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))
 
#define IS_CROSS_PROCESS_HWND(hWnd)   IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))
 
#define ImeDpi_IsUnicode(pImeDpi)   ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
 

Typedefs

typedef struct REG_IME REG_IME
 
typedef struct REG_IMEPREG_IME
 

Functions

BOOL Imm32GetSystemLibraryPath (LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
 
VOID APIENTRY LogFontAnsiToWide (const LOGFONTA *plfA, LPLOGFONTW plfW)
 
VOID APIENTRY LogFontWideToAnsi (const LOGFONTW *plfW, LPLOGFONTA plfA)
 
LPVOID FASTCALL ValidateHandleNoErr (HANDLE hObject, UINT uType)
 
LPVOID FASTCALL ValidateHandle (HANDLE hObject, UINT uType)
 
BOOL APIENTRY Imm32CheckImcProcess (PIMC pIMC)
 
LPVOID APIENTRY ImmLocalAlloc (DWORD dwFlags, DWORD dwBytes)
 
LPWSTR APIENTRY Imm32WideFromAnsi (UINT uCodePage, LPCSTR pszA)
 
LPSTR APIENTRY Imm32AnsiFromWide (UINT uCodePage, LPCWSTR pszW)
 
LONG APIENTRY IchWideFromAnsi (LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
 
LONG APIENTRY IchAnsiFromWide (LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
 
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi (HKL hKL)
 
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC (HIMC hIMC, BOOL fSelect)
 
BOOL APIENTRY Imm32ReleaseIME (HKL hKL)
 
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean (VOID)
 
BOOL APIENTRY Imm32IsCrossThreadAccess (HIMC hIMC)
 
BOOL APIENTRY Imm32IsCrossProcessAccess (HWND hWnd)
 
BOOL WINAPI Imm32IsImcAnsi (HIMC hIMC)
 
DWORD APIENTRY CandidateListWideToAnsi (const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen, UINT uCodePage)
 
DWORD APIENTRY CandidateListAnsiToWide (const CANDIDATELIST *pAnsiCL, LPCANDIDATELIST pWideCL, DWORD dwBufLen, UINT uCodePage)
 
BOOL APIENTRY Imm32MakeIMENotify (HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue, DWORD_PTR dwCommand, DWORD_PTR dwData)
 
DWORD APIENTRY Imm32BuildHimcList (DWORD dwThreadId, HIMC **pphList)
 
INT APIENTRY Imm32ImeMenuAnsiToWide (const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW, UINT uCodePage, BOOL bBitmap)
 
INT APIENTRY Imm32ImeMenuWideToAnsi (const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA, UINT uCodePage)
 
PIME_STATE APIENTRY Imm32FetchImeState (LPINPUTCONTEXTDX pIC, HKL hKL)
 
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState (PIME_STATE pState, HKL hKL)
 
BOOL APIENTRY Imm32LoadImeStateSentence (LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
 
BOOL APIENTRY Imm32SaveImeStateSentence (LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
 
DWORD APIENTRY Imm32ReconvertAnsiFromWide (LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
 
DWORD APIENTRY Imm32ReconvertWideFromAnsi (LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
 
HRESULT APIENTRY Imm32StrToUInt (LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
 
HRESULT APIENTRY Imm32UIntToStr (DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
 
BOOL APIENTRY Imm32LoadImeVerInfo (PIMEINFOEX pImeInfoEx)
 
UINT APIENTRY Imm32GetImeLayout (PREG_IME pLayouts, UINT cLayouts)
 
BOOL APIENTRY Imm32WriteImeLayout (HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayoutText)
 
HKL APIENTRY Imm32AssignNewLayout (UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
 
BOOL APIENTRY Imm32CopyImeFile (LPWSTR pszOldFile, LPCWSTR pszNewFile)
 
PTHREADINFO FASTCALL Imm32CurrentPti (VOID)
 
HBITMAP Imm32LoadBitmapFromBytes (const BYTE *pb)
 
BOOL Imm32StoreBitmapToBytes (HBITMAP hbm, LPBYTE pbData, DWORD cbDataMax)
 
HRESULT CtfImmTIMCreateInputContext (_In_ HIMC hIMC)
 
HRESULT CtfImmTIMDestroyInputContext (_In_ HIMC hIMC)
 
HRESULT CtfImmCoInitialize (VOID)
 
HRESULT CtfImeCreateThreadMgr (VOID)
 
HRESULT CtfImeDestroyThreadMgr (VOID)
 
HRESULT Imm32ActivateOrDeactivateTIM (_In_ BOOL bCreate)
 
HRESULT CtfImeSetActiveContextAlways (_In_ HIMC hIMC, _In_ BOOL fActive, _In_ HWND hWnd, _In_ HKL hKL)
 
BOOL CtfImeProcessCicHotkey (_In_ HIMC hIMC, _In_ UINT vKey, _In_ LPARAM lParam)
 
LRESULT CtfImmSetLangBand (_In_ HWND hWnd, _In_ BOOL fSet)
 

Variables

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

Macro Definition Documentation

◆ FAILED_UNEXPECTEDLY

#define FAILED_UNEXPECTEDLY (   hr)
Value:
(FAILED(hr) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
__FILE__, __FUNCTION__, __LINE__, "FAILED(%s)\n", #hr), UNEXPECTED(), TRUE) \
: FALSE)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define UNEXPECTED()
Definition: precomp.h:106
#define __FUNCTION__
Definition: types.h:116
#define FAILED(hr)
Definition: intsafe.h:51
@ __WINE_DBCL_ERR
Definition: debug.h:52
const char int int int ros_dbg_log(enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *file, const char *func, const int line, const char *format,...) __WINE_PRINTF_ATTR(6
HRESULT hr
Definition: shlfolder.c:183

Definition at line 121 of file precomp.h.

◆ ImeDpi_IsUnicode

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

Definition at line 150 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_CROSS_PROCESS_HWND

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

Definition at line 149 of file precomp.h.

◆ IS_CROSS_THREAD_HIMC

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

Definition at line 148 of file precomp.h.

◆ IS_ERROR_UNEXPECTEDLY

#define IS_ERROR_UNEXPECTEDLY (   x)
Value:
((x) != ERROR_SUCCESS ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
__FILE__, __FUNCTION__, __LINE__, \
"%s was 0x%X\n", #x, (x)), TRUE) \
: FALSE)
#define ERROR_SUCCESS
Definition: deptool.c:10
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Definition at line 141 of file precomp.h.

◆ IS_FALSE_UNEXPECTEDLY

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

Definition at line 137 of file precomp.h.

◆ IS_NULL_UNEXPECTEDLY

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

Definition at line 125 of file precomp.h.

◆ IS_TRUE_UNEXPECTEDLY

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

Definition at line 133 of file precomp.h.

◆ IS_ZERO_UNEXPECTEDLY

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

Definition at line 129 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 33 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 62 of file precomp.h.

◆ UNEXPECTED

#define UNEXPECTED ( )    0

Definition at line 106 of file precomp.h.

◆ ValidateHwnd

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

Definition at line 85 of file precomp.h.

◆ ValidateHwndNoErr

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

Definition at line 84 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 19 of file precomp.h.

Typedef Documentation

◆ PREG_IME

typedef struct REG_IME * PREG_IME

◆ REG_IME

Function Documentation

◆ CandidateListAnsiToWide()

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

Definition at line 84 of file candidate.c.

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

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

◆ CandidateListWideToAnsi()

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

Definition at line 14 of file candidate.c.

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

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

◆ CtfImeCreateThreadMgr()

HRESULT CtfImeCreateThreadMgr ( VOID  )

Definition at line 666 of file msctfime.cpp.

667{
668 TRACE("()\n");
669
670 TLS *pTLS = TLS::GetTLS();
671 if (!pTLS)
672 return E_OUTOFMEMORY;
673
674 if (!pTLS->m_pBridge)
675 {
676 pTLS->m_pBridge = new(cicNoThrow) CicBridge();
677 if (!pTLS->m_pBridge)
678 return E_OUTOFMEMORY;
679 }
680
681 HRESULT hr = S_OK;
683 {
684 hr = pTLS->m_pBridge->InitIMMX(pTLS);
685 if (SUCCEEDED(hr))
686 {
687 if (!pTLS->m_pThreadMgr)
688 return E_OUTOFMEMORY;
689
690 hr = pTLS->m_pBridge->ActivateIMMX(pTLS, pTLS->m_pThreadMgr);
691 if (FAILED(hr))
692 pTLS->m_pBridge->UnInitIMMX(pTLS);
693 }
694 }
695
696 return hr;
697}
#define cicNoThrow
Definition: cicbase.h:34
HRESULT ActivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr)
@implemented
Definition: bridge.cpp:277
BOOL UnInitIMMX(_Inout_ TLS *pTLS)
@implemented
Definition: bridge.cpp:453
HRESULT InitIMMX(_Inout_ TLS *pTLS)
@implemented
Definition: bridge.cpp:386
Definition: tls.h:14
DWORD m_dwSystemInfoFlags
Definition: tls.h:18
ITfThreadMgr_P * m_pThreadMgr
Definition: tls.h:21
static TLS * GetTLS()
@implemented
Definition: tls.cpp:32
CicBridge * m_pBridge
Definition: tls.h:19
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define IME_SYSINFO_WINLOGON
Definition: immdev.h:409
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
BOOL g_bWinLogon
Definition: msctfime.cpp:13
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CtfAImmActivate(), CtfImeCreateThreadMgr(), CtfImmTIMActivate(), and Imm32ActivateOrDeactivateTIM().

◆ CtfImeDestroyThreadMgr()

HRESULT CtfImeDestroyThreadMgr ( VOID  )

Definition at line 705 of file msctfime.cpp.

706{
707 TRACE("()\n");
708
709 TLS *pTLS = TLS::PeekTLS();
710 if (!pTLS)
711 return E_OUTOFMEMORY;
712
713 if (pTLS->m_pBridge)
714 {
715 pTLS->m_pBridge = new(cicNoThrow) CicBridge();
716 if (!pTLS->m_pBridge)
717 return E_OUTOFMEMORY;
718 }
719
720 if (!pTLS->m_pThreadMgr)
721 return E_OUTOFMEMORY;
722
724 return S_OK;
725
726 HRESULT hr = pTLS->m_pBridge->DeactivateIMMX(pTLS, pTLS->m_pThreadMgr);
727 if (hr == S_OK)
728 pTLS->m_pBridge->UnInitIMMX(pTLS);
729
730 return hr;
731}
HRESULT DeactivateIMMX(_Inout_ TLS *pTLS, _Inout_ ITfThreadMgr_P *pThreadMgr)
@implemented
Definition: bridge.cpp:340
static TLS * PeekTLS()
@implemented
Definition: tls.cpp:41

Referenced by CtfAImmDeactivate(), CtfImeDestroyThreadMgr(), Imm32ActivateOrDeactivateTIM(), and ImmDisableTextFrameService().

◆ CtfImeProcessCicHotkey()

BOOL CtfImeProcessCicHotkey ( _In_ HIMC  hIMC,
_In_ UINT  vKey,
_In_ LPARAM  lParam 
)

Definition at line 795 of file msctfime.cpp.

799{
800 TRACE("(%p, %u, %p)\n", hIMC, vKey, lParam);
801
802 TLS *pTLS = TLS::GetTLS();
803 if (!pTLS)
804 return S_OK;
805
806 HRESULT hr = S_OK;
807 ITfThreadMgr *pThreadMgr = NULL;
808 ITfThreadMgr_P *pThreadMgr_P = NULL;
809 if ((TF_GetThreadMgr(&pThreadMgr) == S_OK) &&
810 (pThreadMgr->QueryInterface(IID_ITfThreadMgr_P, (void**)&pThreadMgr_P) == S_OK) &&
812 {
813 HRESULT hr2;
814 if (SUCCEEDED(pThreadMgr_P->CallImm32HotkeyHandler(vKey, lParam, &hr2)))
815 hr = hr2;
816 }
817
818 if (pThreadMgr)
819 pThreadMgr->Release();
820 if (pThreadMgr_P)
821 pThreadMgr_P->Release();
822
823 return hr;
824}
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI CtfImmIsCiceroStartedInThread(VOID)
Definition: ctf.c:781
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsrefcnt Release()
HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim)
Definition: msctf.c:628

Referenced by CtfImeProcessCicHotkey(), and ImmProcessKey().

◆ CtfImeSetActiveContextAlways()

HRESULT CtfImeSetActiveContextAlways ( _In_ HIMC  hIMC,
_In_ BOOL  fActive,
_In_ HWND  hWnd,
_In_ HKL  hKL 
)

Definition at line 775 of file msctfime.cpp.

780{
781 TRACE("(%p, %d, %p, %p)\n", hIMC, fActive, hWnd, hKL);
782
783 TLS *pTLS = TLS::GetTLS();
784 if (!pTLS || !pTLS->m_pBridge)
785 return E_OUTOFMEMORY;
786 return pTLS->m_pBridge->SetActiveContextAlways(pTLS, hIMC, fActive, hWnd, hKL);
787}
HWND hWnd
Definition: settings.c:17
HRESULT SetActiveContextAlways(TLS *pTLS, HIMC hIMC, BOOL fActive, HWND hWnd, HKL hKL)
Definition: bridge.cpp:622

Referenced by CtfImeSetActiveContextAlways(), and ImmSetActiveContext().

◆ CtfImmCoInitialize()

HRESULT CtfImmCoInitialize ( VOID  )

Definition at line 574 of file ctf.c.

575{
576 HRESULT hr;
578 ISPY *pSpy;
579
580 if (GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT)
581 return S_OK; /* Already initialized */
582
585 return hr; /* CoInitializeEx failed */
586
587 GetWin32ClientInfo()->CI_flags |= CI_CTFCOINIT;
588 Imm32InitTLS();
589
591 if (!pData || pData->pSpy)
592 return S_OK; /* Cannot allocate or already it has a spy */
593
594 pSpy = Imm32AllocIMMISPY();
595 pData->pSpy = (IInitializeSpy*)pSpy;
596 if (IS_NULL_UNEXPECTEDLY(pSpy))
597 return S_OK; /* Cannot allocate a spy */
598
600 {
601 /* Failed to register the spy */
603 pData->pSpy = NULL;
604 pData->uliCookie.QuadPart = 0;
605 }
606
607 return S_OK;
608}
static IMMTLSDATA * Imm32AllocateTLS(VOID)
Definition: ctf.c:296
static ISPY * Imm32AllocIMMISPY(VOID)
Definition: ctf.c:557
#define Imm32DeleteIMMISPY(pSpy)
Definition: ctf.c:568
HRESULT Imm32CoInitializeEx(VOID)
Definition: ctf.c:130
HRESULT Imm32CoRegisterInitializeSpy(IInitializeSpy *spy, ULARGE_INTEGER *cookie)
Definition: ctf.c:146
static VOID Imm32InitTLS(VOID)
Definition: ctf.c:285
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
#define IS_NULL_UNEXPECTEDLY(p)
Definition: precomp.h:125
#define GetWin32ClientInfo()
Definition: ntuser.h:352
#define CI_CTFCOINIT
Definition: ntuser.h:307
Definition: ctf.c:416
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by CtfImmTIMActivate().

◆ CtfImmSetLangBand()

LRESULT CtfImmSetLangBand ( _In_ HWND  hWnd,
_In_ BOOL  fSet 
)

Definition at line 1233 of file ctf.c.

1236{
1238 PWND pWnd = NULL;
1239 PIMM_DELAY_SET_LANG_BAND pSetBand;
1240 DWORD_PTR lResult = 0;
1241
1242 if (hWnd && gpsi)
1243 pWnd = ValidateHwndNoErr(hWnd);
1244
1245 if (IS_NULL_UNEXPECTEDLY(pWnd))
1246 return 0;
1247
1249 {
1251 5000, &lResult);
1252 return lResult;
1253 }
1254
1255 pSetBand = ImmLocalAlloc(0, sizeof(IMM_DELAY_SET_LANG_BAND));
1256 if (IS_NULL_UNEXPECTEDLY(pSetBand))
1257 return 0;
1258
1259 pSetBand->hWnd = hWnd;
1260 pSetBand->fSet = fSet;
1261
1263 if (hThread)
1265 return 0;
1266}
static DWORD APIENTRY Imm32DelaySetLangBandProc(LPVOID arg)
Definition: ctf.c:1211
#define CloseHandle
Definition: compat.h:739
PSERVERINFO gpsi
Definition: imm.c:18
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:415
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define WNDS2_WMCREATEMSGPROCESSED
Definition: ntuser.h:670
HANDLE hThread
Definition: wizard.c:28
Definition: ntuser.h:694
DWORD state2
Definition: ntuser.h:702
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define SMTO_BLOCK
Definition: winuser.h:1227
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1226
#define WM_USER
Definition: winuser.h:1898

Referenced by ImmSystemHandler().

◆ CtfImmTIMCreateInputContext()

HRESULT CtfImmTIMCreateInputContext ( _In_ HIMC  hIMC)

Definition at line 939 of file ctf.c.

941{
942 PCLIENTIMC pClientImc;
943 DWORD_PTR dwImeThreadId, dwCurrentThreadId;
945
946 TRACE("(%p)\n", hIMC);
947
948 pClientImc = ImmLockClientImc(hIMC);
949 if (!pClientImc)
950 return E_FAIL;
951
952 if (GetWin32ClientInfo()->CI_flags & CI_AIMMACTIVATED)
953 {
954 if (!pClientImc->bCtfIme)
955 {
956 dwImeThreadId = NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
957 dwCurrentThreadId = GetCurrentThreadId();
958 if (dwImeThreadId == dwCurrentThreadId)
959 {
960 pClientImc->bCtfIme = TRUE;
963 pClientImc->bCtfIme = FALSE;
964 }
965 }
966 }
967 else
968 {
969 if (!(GetWin32ClientInfo()->CI_flags & CI_CTFTIM))
970 return S_OK;
971
972 if (!pClientImc->bCtfIme)
973 {
974 dwImeThreadId = NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
975 dwCurrentThreadId = GetCurrentThreadId();
976 if ((dwImeThreadId == dwCurrentThreadId) && IS_CICERO_MODE() && !IS_16BIT_MODE())
977 {
978 pClientImc->bCtfIme = TRUE;
981 pClientImc->bCtfIme = FALSE;
982 }
983 }
984 }
985
986 ImmUnlockClientImc(pClientImc);
987 return hr;
988}
HRESULT CtfImeCreateInputContext(_In_ HIMC hIMC)
Definition: ctf.c:816
#define E_FAIL
Definition: ddrawi.h:102
VOID WINAPI ImmUnlockClientImc(PCLIENTIMC pClientImc)
Definition: imm.c:984
PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
Definition: imm.c:938
#define CI_AIMMACTIVATED
Definition: ntuser.h:311
#define CI_CTFTIM
Definition: ntuser.h:308
DWORD_PTR NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwType)
Definition: ime.c:1791
#define IS_16BIT_MODE()
Definition: ntuser.h:1211
#define IS_CICERO_MODE()
Definition: ntuser.h:1210
@ QIC_INPUTTHREADID
Definition: undocuser.h:399
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define S_FALSE
Definition: winerror.h:2357

Referenced by Imm32CreateInputContext(), and Imm32InternalLockIMC().

◆ CtfImmTIMDestroyInputContext()

HRESULT CtfImmTIMDestroyInputContext ( _In_ HIMC  hIMC)

Definition at line 929 of file ctf.c.

931{
932 if (!IS_CICERO_MODE() || (GetWin32ClientInfo()->dwCompatFlags2 & 2))
933 return E_NOINTERFACE;
934
935 return CtfImeDestroyInputContext(hIMC);
936}
HRESULT CtfImeDestroyInputContext(_In_ HIMC hIMC)
Definition: ctf.c:831
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by Imm32DestroyInputContext().

◆ IchAnsiFromWide()

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

Definition at line 273 of file utils.c.

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

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

◆ IchWideFromAnsi()

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

Definition at line 252 of file utils.c.

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

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

◆ Imm32ActivateOrDeactivateTIM()

HRESULT Imm32ActivateOrDeactivateTIM ( _In_ BOOL  bCreate)

Definition at line 895 of file ctf.c.

897{
898 HRESULT hr = S_OK;
899
900 if (!IS_CICERO_MODE() || IS_16BIT_MODE() ||
901 !(GetWin32ClientInfo()->CI_flags & CI_CTFCOINIT))
902 {
903 return S_OK; /* No need to activate/de-activate TIM */
904 }
905
906 if (bCreate)
907 {
908 if (!(GetWin32ClientInfo()->CI_flags & CI_CTFTIM))
909 {
911 if (SUCCEEDED(hr))
912 GetWin32ClientInfo()->CI_flags |= CI_CTFTIM;
913 }
914 }
915 else /* Destroy */
916 {
917 if (GetWin32ClientInfo()->CI_flags & CI_CTFTIM)
918 {
920 if (SUCCEEDED(hr))
921 GetWin32ClientInfo()->CI_flags &= ~CI_CTFTIM;
922 }
923 }
924
925 return hr;
926}
HRESULT CtfImeCreateThreadMgr(VOID)
Definition: ctf.c:723
HRESULT CtfImeDestroyThreadMgr(VOID)
Definition: ctf.c:751
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1520

Referenced by CtfImmLastEnabledWndDestroy(), and ISPY_PreInitialize().

◆ Imm32AnsiFromWide()

LPSTR APIENTRY Imm32AnsiFromWide ( UINT  uCodePage,
LPCWSTR  pszW 
)

Definition at line 238 of file utils.c.

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

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

◆ Imm32AssignNewLayout()

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

Definition at line 902 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ Imm32BuildHimcList()

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

Definition at line 460 of file utils.c.

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

Referenced by ImmEnumInputContext().

◆ Imm32CheckImcProcess()

BOOL APIENTRY Imm32CheckImcProcess ( PIMC  pIMC)

Definition at line 391 of file utils.c.

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

Referenced by ImmLockClientImc().

◆ Imm32CopyImeFile()

BOOL APIENTRY Imm32CopyImeFile ( LPWSTR  pszOldFile,
LPCWSTR  pszNewFile 
)

Definition at line 1120 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ Imm32CurrentPti()

PTHREADINFO FASTCALL Imm32CurrentPti ( VOID  )

Definition at line 19 of file utils.c.

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

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

◆ Imm32FetchImeState()

PIME_STATE APIENTRY Imm32FetchImeState ( LPINPUTCONTEXTDX  pIC,
HKL  hKL 
)

Definition at line 552 of file utils.c.

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

Referenced by Imm32SelectInputContext().

◆ Imm32FetchImeSubState()

PIME_SUBSTATE APIENTRY Imm32FetchImeSubState ( PIME_STATE  pState,
HKL  hKL 
)

Definition at line 576 of file utils.c.

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

Referenced by Imm32LoadImeStateSentence(), and Imm32SaveImeStateSentence().

◆ Imm32FindOrLoadImeDpi()

PIMEDPI APIENTRY Imm32FindOrLoadImeDpi ( HKL  hKL)

Definition at line 343 of file ime.c.

344{
345 PIMEDPI pImeDpi;
346
347 if (!IS_IME_HKL(hKL) && (!IS_CICERO_MODE() || IS_16BIT_MODE()))
348 {
349 TRACE("\n");
350 return NULL;
351 }
352
353 pImeDpi = ImmLockImeDpi(hKL);
354 if (pImeDpi == NULL)
355 pImeDpi = Imm32LoadImeDpi(hKL, TRUE);
356 return pImeDpi;
357}
PIMEDPI APIENTRY Imm32LoadImeDpi(HKL hKL, BOOL bLock)
Definition: ime.c:267
PIMEDPI WINAPI ImmLockImeDpi(HKL hKL)
Definition: ime.c:978
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:20

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

◆ Imm32GetImeLayout()

UINT APIENTRY Imm32GetImeLayout ( PREG_IME  pLayouts,
UINT  cLayouts 
)

Definition at line 948 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ Imm32GetSystemLibraryPath()

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

Definition at line 286 of file utils.c.

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

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

◆ Imm32ImeMenuAnsiToWide()

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

Definition at line 501 of file utils.c.

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

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32ImeMenuWideToAnsi()

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

Definition at line 528 of file utils.c.

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

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32InternalLockIMC()

LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC ( HIMC  hIMC,
BOOL  fSelect 
)

Definition at line 838 of file imm.c.

839{
840 HANDLE hIC;
841 LPINPUTCONTEXT pIC = NULL;
842 PCLIENTIMC pClientImc;
843 WORD LangID;
845 HKL hOldKL, hNewKL;
846 PIMEDPI pImeDpi = NULL;
847
848 pClientImc = ImmLockClientImc(hIMC);
849 if (!pClientImc)
850 return NULL;
851
852 RtlEnterCriticalSection(&pClientImc->cs);
853
854 if (pClientImc->hInputContext)
855 {
856 pIC = LocalLock(pClientImc->hInputContext);
857 if (IS_NULL_UNEXPECTEDLY(pIC))
858 goto Failure;
859
861 goto Success;
862 }
863
866 {
867 hOldKL = GetKeyboardLayout(0);
868 LangID = LOWORD(hOldKL);
870
871 pImeDpi = Imm32FindOrLoadImeDpi(hNewKL);
872 if (pImeDpi)
873 {
874 CtfImmTIMActivate(hNewKL);
875 }
876 }
877
879 {
880 ERR("No default IME window\n");
881 goto Failure;
882 }
883
884 hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
885 pIC = LocalLock(hIC);
886 if (IS_NULL_UNEXPECTEDLY(pIC))
887 {
888 LocalFree(hIC);
889 goto Failure;
890 }
891 pClientImc->hInputContext = hIC;
892
894 if (!Imm32CreateInputContext(hIMC, pIC, pClientImc, hNewKL, fSelect))
895 {
896 LocalUnlock(hIC);
897 pClientImc->hInputContext = LocalFree(hIC);
898 goto Failure;
899 }
900
901Success:
902 RtlLeaveCriticalSection(&pClientImc->cs);
903 InterlockedIncrement(&pClientImc->cLockObj);
904 ImmUnlockClientImc(pClientImc);
905 return pIC;
906
907Failure:
908 RtlLeaveCriticalSection(&pClientImc->cs);
909 ImmUnlockClientImc(pClientImc);
910 return NULL;
911}
#define InterlockedIncrement
Definition: armddk.h:53
HRESULT WINAPI CtfImmTIMActivate(_In_ HKL hKL)
Definition: ctf.c:1123
HRESULT CtfImmTIMCreateInputContext(_In_ HIMC hIMC)
Definition: ctf.c:939
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL)
Definition: ime.c:343
BOOL APIENTRY Imm32CreateInputContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC pClientImc, HKL hKL, BOOL fSelect)
Definition: imm.c:738
@ Success
Definition: eventcreate.c:712
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1616
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1805
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION cs
Definition: imm32_undoc.h:124
HANDLE hInputContext
Definition: imm32_undoc.h:120
@ QIC_DEFAULTWINDOWIME
Definition: undocuser.h:400
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
#define LHND
Definition: winbase.h:407
HKL WINAPI GetKeyboardLayout(_In_ DWORD)

Referenced by Imm32SelectInputContext(), and ImmLockIMC().

◆ Imm32IsCrossProcessAccess()

BOOL APIENTRY Imm32IsCrossProcessAccess ( HWND  hWnd)

Definition at line 34 of file utils.c.

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

◆ Imm32IsCrossThreadAccess()

BOOL APIENTRY Imm32IsCrossThreadAccess ( HIMC  hIMC)

Definition at line 26 of file utils.c.

27{
29 DWORD_PTR dwCurrentThreadId = GetCurrentThreadId();
30 return dwImeThreadId != dwCurrentThreadId;
31}

Referenced by ImmSetCompositionWindow().

◆ Imm32IsImcAnsi()

BOOL WINAPI Imm32IsImcAnsi ( HIMC  hIMC)

Definition at line 216 of file utils.c.

217{
218 BOOL ret;
219 PCLIENTIMC pClientImc = ImmLockClientImc(hIMC);
220 if (IS_NULL_UNEXPECTEDLY(pClientImc))
221 return -1;
222 ret = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
223 ImmUnlockClientImc(pClientImc);
224 return ret;
225}
#define CLIENTIMC_WIDE
Definition: imm32_undoc.h:142

Referenced by ImmGetImeMenuItemsAW().

◆ Imm32IsSystemJapaneseOrKorean()

BOOL APIENTRY Imm32IsSystemJapaneseOrKorean ( VOID  )

Definition at line 69 of file utils.c.

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

Referenced by ImmWINNLSEnableIME(), and ImmWINNLSGetEnableStatus().

◆ Imm32LoadBitmapFromBytes()

HBITMAP Imm32LoadBitmapFromBytes ( const BYTE pb)

Definition at line 88 of file utils.c.

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

Referenced by Imm32GetImeMenuItemWInterProcess().

◆ Imm32LoadImeStateSentence()

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

Definition at line 596 of file utils.c.

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

Referenced by Imm32SelectInputContext().

◆ Imm32LoadImeVerInfo()

BOOL APIENTRY Imm32LoadImeVerInfo ( PIMEINFOEX  pImeInfoEx)

Definition at line 845 of file utils.c.

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

Referenced by ImmInstallIMEW(), and ImmLoadLayout().

◆ Imm32MakeIMENotify()

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

Definition at line 428 of file utils.c.

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

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

◆ Imm32ReconvertAnsiFromWide()

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

Definition at line 691 of file utils.c.

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

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32ReconvertWideFromAnsi()

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

Definition at line 628 of file utils.c.

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

Referenced by Imm32ProcessRequest(), and ImmSetCompositionStringAW().

◆ Imm32ReleaseIME()

BOOL APIENTRY Imm32ReleaseIME ( HKL  hKL)

Definition at line 371 of file ime.c.

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

Referenced by ImmFreeLayout().

◆ Imm32SaveImeStateSentence()

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

Definition at line 608 of file utils.c.

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

Referenced by Imm32SelectInputContext().

◆ Imm32StoreBitmapToBytes()

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

Definition at line 143 of file utils.c.

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

Referenced by ImmPutImeMenuItemsIntoMappedFile().

◆ Imm32StrToUInt()

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

Definition at line 43 of file utils.c.

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

Referenced by Imm32GetImeLayout(), and Imm32UnitTest().

◆ Imm32UIntToStr()

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

Definition at line 56 of file utils.c.

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

Referenced by Imm32UnitTest(), and Imm32WriteImeLayout().

◆ Imm32WideFromAnsi()

LPWSTR APIENTRY Imm32WideFromAnsi ( UINT  uCodePage,
LPCSTR  pszA 
)

Definition at line 227 of file utils.c.

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

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

◆ Imm32WriteImeLayout()

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

Definition at line 1023 of file utils.c.

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

Referenced by ImmInstallIMEW().

◆ ImmLocalAlloc()

◆ LogFontAnsiToWide()

VOID APIENTRY LogFontAnsiToWide ( const LOGFONTA plfA,
LPLOGFONTW  plfW 
)

Definition at line 299 of file utils.c.

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

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

◆ LogFontWideToAnsi()

VOID APIENTRY LogFontWideToAnsi ( const LOGFONTW plfW,
LPLOGFONTA  plfA 
)

Definition at line 312 of file utils.c.

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

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

◆ ValidateHandle()

◆ ValidateHandleNoErr()

LPVOID FASTCALL ValidateHandleNoErr ( HANDLE  hObject,
UINT  uType 
)

Definition at line 338 of file utils.c.

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

Referenced by ImmCallImeConsoleIME(), and MENU_GetMenu().

Variable Documentation

◆ g_aimm_compat_flags

DWORD g_aimm_compat_flags
extern

Definition at line 204 of file ctf.c.

Referenced by CtfImmSetAppCompatFlags(), and ImmGetAppCompatFlags().

◆ gcsImeDpi

◆ ghImm32Inst

◆ ghImmHeap

HANDLE ghImmHeap
extern

Definition at line 16 of file utils.c.

Referenced by ImmLocalAlloc().

◆ gpImeDpiList

PIMEDPI gpImeDpiList
extern

◆ gpsi

PSERVERINFO gpsi
extern

Definition at line 18 of file imm.c.

◆ gSharedInfo

SHAREDINFO gSharedInfo
extern

Definition at line 19 of file imm.c.