ReactOS 0.4.16-dev-1260-g901af6a
precomp.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS IMM32
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Implementing IMM32
5 * COPYRIGHT: Copyright 1998 Patrik Stridvall
6 * Copyright 2002, 2003, 2007 CodeWeavers, Aric Stewart
7 * Copyright 2017 James Tabor <james.tabor@reactos.org>
8 * Copyright 2018 Amine Khaldi <amine.khaldi@reactos.org>
9 * Copyright 2020 Oleg Dubinskiy <oleg.dubinskij2013@yandex.ua>
10 * Copyright 2020-2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
11 */
12
13#pragma once
14
15#include <stdio.h>
16#include <stdlib.h>
17
18/* PSDK/NDK Headers */
19#define WIN32_NO_STATUS
20#include <windef.h>
21#include <winbase.h>
22#include <wingdi.h>
23#include <winuser.h>
24#include <winnls.h>
25#include <winreg.h>
26#include <winnls32.h>
27#include <winver.h>
28
29#include <imm.h>
30#include <immdev.h>
31#include <imm32_undoc.h>
32
33#define NTOS_MODE_USER
34#include <ndk/umtypes.h>
35#include <ndk/pstypes.h>
36#include <ndk/rtlfuncs.h>
37
38/* Public Win32K Headers */
39#include "ntuser.h"
40#include "ntwin32.h"
41
42/* Undocumented user definitions */
43#include <undocuser.h>
44
45#include <strsafe.h>
46
47#include <wine/debug.h>
48
49#define ERR_PRINTF(fmt, ...) (__WINE_IS_DEBUG_ON(_ERR, __wine_dbch___default) ? \
50 (wine_dbg_printf("err:(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__), TRUE) : TRUE)
51
52/* Unexpected Condition Checkers */
53#if DBG
54 #define FAILED_UNEXPECTEDLY(hr) \
55 (FAILED(hr) ? ERR_PRINTF("FAILED(0x%08X)\n", hr) : FALSE)
56 #define IS_NULL_UNEXPECTEDLY(p) \
57 (!(p) ? ERR_PRINTF("%s was NULL\n", #p) : FALSE)
58 #define IS_ZERO_UNEXPECTEDLY(p) \
59 (!(p) ? ERR_PRINTF("%s was zero\n", #p) : FALSE)
60 #define IS_TRUE_UNEXPECTEDLY(x) \
61 ((x) ? ERR_PRINTF("%s was non-zero\n", #x) : FALSE)
62 #define IS_ERROR_UNEXPECTEDLY(x) \
63 ((x) != ERROR_SUCCESS ? ERR_PRINTF("%s was %d\n", #x, (int)(x)) : FALSE)
64#else
65 #define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
66 #define IS_NULL_UNEXPECTEDLY(p) (!(p))
67 #define IS_ZERO_UNEXPECTEDLY(p) (!(p))
68 #define IS_TRUE_UNEXPECTEDLY(x) (x)
69 #define IS_ERROR_UNEXPECTEDLY(x) ((x) != ERROR_SUCCESS)
70#endif
71
72#define IS_CROSS_THREAD_HIMC(hIMC) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))
73#define IS_CROSS_PROCESS_HWND(hWnd) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))
74
75#define IMM_INIT_MAGIC 0x19650412
76#define IMM_INVALID_CANDFORM ULONG_MAX
77#define INVALID_HOTKEY_ID 0xFFFFFFFF
78#define MAX_CANDIDATEFORM 4
79#define MAX_IMM_FILENAME 80
80
81#define LANGID_CHINESE_SIMPLIFIED MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
82#define LANGID_CHINESE_TRADITIONAL MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
83#define LANGID_JAPANESE MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)
84
85#define REGKEY_KEYBOARD_LAYOUTS L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
86
87extern HMODULE ghImm32Inst;
90extern PSERVERINFO gpsi;
92extern HANDLE ghImmHeap;
94
96VOID LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW);
97VOID LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA);
100#define ValidateHwndNoErr(hwnd) ValidateHandleNoErr((hwnd), TYPE_WINDOW)
101#define ValidateHwnd(hwnd) ValidateHandle((hwnd), TYPE_WINDOW)
103
105#define ImmLocalFree(lpData) HeapFree(ghImmHeap, 0, (lpData))
106
107LPWSTR Imm32WideFromAnsi(UINT uCodePage, LPCSTR pszA);
108LPSTR Imm32AnsiFromWide(UINT uCodePage, LPCWSTR pszW);
109LONG IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage);
110LONG IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage);
119
120#define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
121
122DWORD
124 UINT uCodePage);
125DWORD
127 UINT uCodePage);
128
129BOOL
131 _In_ HIMC hIMC,
132 _In_ HWND hwnd,
133 _In_ DWORD dwAction,
134 _In_ DWORD dwIndex,
135 _Inout_opt_ DWORD_PTR dwValue,
136 _In_ DWORD dwCommand,
138
140
143
144BOOL
146BOOL
148
149DWORD
150Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage);
151DWORD
152Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage);
153
156 _In_ PCWSTR pszText,
157 _Out_ PDWORD pdwValue,
158 _In_ ULONG nBase);
159
162 _In_ DWORD dwValue,
163 _In_ ULONG nBase,
164 _Out_ PWSTR pszBuff,
165 _In_ USHORT cchBuff);
166
168
175
178 _In_ HIMC hIMC,
179 _In_ BOOL fActive,
180 _In_ HWND hWnd,
181 _In_ HKL hKL);
182
183BOOL
185 _In_ HIMC hIMC,
186 _In_ UINT vKey,
188
191 _In_ HWND hWnd,
192 _In_ BOOL fSet);
HWND hWnd
Definition: settings.c:17
LPARAM lParam
Definition: combotst.c:139
DWORD HIMC
Definition: dimm.idl:75
DWORD dwThreadId
Definition: fdebug.c:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE ULONG_PTR dwData
Definition: file.c:35
UINT_PTR HKL
Definition: msctf.idl:125
unsigned int UINT
Definition: ndis.h:50
#define _Inout_opt_
Definition: no_sal2.h:216
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define FASTCALL
Definition: nt_native.h:50
DWORD * PDWORD
Definition: pedump.c:68
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1528
Definition: ntuser.h:199
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
BOOL Imm32LoadImeVerInfo(_Out_ PIMEINFOEX pImeInfoEx)
DWORD Imm32BuildHimcList(DWORD dwThreadId, HIMC **pphList)
Definition: utils.c:338
DWORD CandidateListAnsiToWide(const CANDIDATELIST *pAnsiCL, LPCANDIDATELIST pWideCL, DWORD dwBufLen, UINT uCodePage)
Definition: candidate.c:84
BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: utils.c:25
LONG IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:140
DWORD CandidateListWideToAnsi(const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen, UINT uCodePage)
Definition: candidate.c:15
HRESULT CtfImeSetActiveContextAlways(_In_ HIMC hIMC, _In_ BOOL fActive, _In_ HWND hWnd, _In_ HKL hKL)
Definition: msctfime.cpp:775
PIME_SUBSTATE Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:401
HANDLE ghImmHeap
Definition: utils.c:16
LPINPUTCONTEXT Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect)
Definition: imm.c:852
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:201
BOOL Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:420
RTL_CRITICAL_SECTION gcsImeDpi
Definition: ime.c:16
DWORD Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:451
HRESULT CtfImeCreateThreadMgr(VOID)
Definition: msctfime.cpp:666
HRESULT CtfImmCoInitialize(VOID)
Definition: ctf.c:574
HRESULT CtfImeDestroyThreadMgr(VOID)
Definition: msctfime.cpp:705
HMODULE ghImm32Inst
Definition: imm.c:17
LPWSTR Imm32WideFromAnsi(UINT uCodePage, LPCSTR pszA)
Definition: utils.c:96
PIMEDPI gpImeDpiList
Definition: ime.c:17
HRESULT CtfImmTIMCreateInputContext(_In_ HIMC hIMC)
Definition: ctf.c:939
PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
Definition: utils.c:18
HRESULT Imm32ActivateOrDeactivateTIM(_In_ BOOL bCreate)
Definition: ctf.c:895
BOOL Imm32MakeIMENotify(_In_ HIMC hIMC, _In_ HWND hwnd, _In_ DWORD dwAction, _In_ DWORD dwIndex, _Inout_opt_ DWORD_PTR dwValue, _In_ DWORD dwCommand, _Inout_opt_ DWORD_PTR dwData)
Definition: utils.c:287
LONG IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:120
VOID LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:164
BOOL Imm32ReleaseIME(_In_ HKL hKL)
Definition: ime.c:378
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:152
BOOL Imm32IsImcAnsi(HIMC hIMC)
Definition: utils.c:85
HRESULT Imm32UIntToStr(_In_ DWORD dwValue, _In_ ULONG nBase, _Out_ PWSTR pszBuff, _In_ USHORT cchBuff)
Definition: utils.c:56
BOOL Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:431
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:239
LPSTR Imm32AnsiFromWide(UINT uCodePage, LPCWSTR pszW)
Definition: utils.c:107
HRESULT CtfImmTIMDestroyInputContext(_In_ HIMC hIMC)
Definition: ctf.c:929
BOOL Imm32IsSystemJapaneseOrKorean(VOID)
Definition: utils.c:72
SHAREDINFO gSharedInfo
Definition: imm.c:19
BOOL CtfImeProcessCicHotkey(_In_ HIMC hIMC, _In_ UINT vKey, _In_ LPARAM lParam)
Definition: msctfime.cpp:795
PIMEDPI Imm32FindOrLoadImeDpi(HKL hKL)
Definition: ime.c:350
BOOL Imm32IsCrossProcessAccess(HWND hWnd)
Definition: utils.c:32
PIME_STATE Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL)
Definition: utils.c:378
PSERVERINFO gpsi
Definition: imm.c:18
DWORD Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:514
LRESULT CtfImmSetLangBand(_In_ HWND hWnd, _In_ BOOL fSet)
Definition: ctf.c:1234
LPVOID ImmLocalAlloc(_In_ DWORD dwFlags, _In_ DWORD dwBytes)
Definition: utils.c:275
DWORD g_aimm_compat_flags
Definition: ctf.c:204
VOID LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:176
HRESULT Imm32StrToUInt(_In_ PCWSTR pszText, _Out_ PDWORD pdwValue, _In_ ULONG nBase)
Definition: utils.c:40
BOOL Imm32CheckImcProcess(PIMC pIMC)
Definition: utils.c:252
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4246
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185