ReactOS  0.4.15-dev-3308-g9455def
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-2021 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 <ddk/imm.h>
31 
32 #define NTOS_MODE_USER
33 #include <ndk/umtypes.h>
34 #include <ndk/pstypes.h>
35 #include <ndk/rtlfuncs.h>
36 
37 /* Public Win32K Headers */
38 #include "ntuser.h"
39 #include "ntwin32.h"
40 
41 /* Undocumented user definitions */
42 #include <undocuser.h>
43 #include <imm32_undoc.h>
44 
45 #include <strsafe.h>
46 
47 #include <wine/debug.h>
48 #include <wine/list.h>
49 
50 #define IMM_INIT_MAGIC 0x19650412
51 #define IMM_INVALID_CANDFORM ULONG_MAX
52 #define INVALID_HOTKEY_ID 0xFFFFFFFF
53 #define MAX_CANDIDATEFORM 4
54 #define MAX_IMM_FILENAME 80
55 
56 #define LANGID_CHINESE_SIMPLIFIED MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
57 #define LANGID_CHINESE_TRADITIONAL MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
58 #define LANGID_JAPANESE MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)
59 
60 #define REGKEY_KEYBOARD_LAYOUTS L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
61 #define REGKEY_IMM L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"
62 
63 #define ROUNDUP4(n) (((n) + 3) & ~3) /* DWORD alignment */
64 
65 typedef struct REG_IME
66 {
68  WCHAR szImeKey[20]; /* "E0XXYYYY": "E0XX" is the device handle. "YYYY" is a LANGID. */
69  WCHAR szFileName[80]; /* The IME module filename */
70 } REG_IME, *PREG_IME;
71 
72 extern HMODULE g_hImm32Inst;
74 extern PIMEDPI g_pImeDpiList;
75 extern PSERVERINFO g_psi;
77 extern BYTE g_bClientRegd;
78 extern HANDLE g_hImm32Heap;
79 
86 
88 #define Imm32HeapFree(lpData) HeapFree(g_hImm32Heap, 0, (lpData))
89 
92 LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage);
93 LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage);
97 
98 static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
99 {
100  DWORD dwImeThreadId = NtUserQueryInputContext(hIMC, 1);
102  return (dwImeThreadId != dwThreadId);
103 }
104 
106 {
109 }
110 
112 
113 #define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
114 #define Imm32IsImmMode() (g_psi && (g_psi->dwSRVIFlags & SRVINFO_IMM32))
115 #define Imm32IsCiceroMode() (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
116 #define Imm32Is16BitMode() (GetWin32ClientInfo()->dwTIFlags & TIF_16BIT)
117 
120  UINT uCodePage);
123  UINT uCodePage);
124 
126 Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue,
127  DWORD_PTR dwCommand, DWORD_PTR dwData);
128 
130 
133  UINT uCodePage, BOOL bBitmap);
136  UINT uCodePage);
137 
140 
145 
150 
151 HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase);
152 HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff);
154 UINT APIENTRY Imm32GetRegImes(PREG_IME pLayouts, UINT cLayouts);
155 BOOL APIENTRY Imm32WriteRegIme(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout);
156 HKL APIENTRY Imm32GetNextHKL(UINT cKLs, const REG_IME *pLayouts, WORD wLangID);
157 BOOL APIENTRY Imm32CopyFile(LPWSTR pszOldFile, LPCWSTR pszNewFile);
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff)
Definition: utils.c:32
UINT APIENTRY Imm32GetRegImes(PREG_IME pLayouts, UINT cLayouts)
Definition: utils.c:688
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2900
LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes)
Definition: utils.c:193
BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Definition: utils.c:589
DWORD APIENTRY Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:455
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW)
Definition: utils.c:120
BOOL APIENTRY Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:366
Definition: ntuser.h:190
HWND hWnd
Definition: settings.c:17
WCHAR szImeKey[20]
Definition: precomp.h:68
static HANDLE ULONG_PTR dwData
Definition: file.c:35
PSERVERINFO g_psi
Definition: imm.c:18
char * LPSTR
Definition: xmlstorage.h:182
HANDLE UniqueProcess
Definition: compat.h:684
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL)
Definition: utils.c:347
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4245
#define FASTCALL
Definition: nt_native.h:50
HKL hKL
Definition: precomp.h:67
int32_t INT
Definition: typedefs.h:58
BYTE g_bClientRegd
Definition: imm.c:20
DWORD APIENTRY Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage)
Definition: utils.c:399
LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW)
Definition: utils.c:66
INT APIENTRY Imm32ImeMenuAnsiToWide(const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW, UINT uCodePage, BOOL bBitmap)
Definition: utils.c:275
HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
Definition: utils.c:20
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3929
PIME_STATE APIENTRY Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL)
Definition: utils.c:324
BOOL APIENTRY Imm32ReleaseIME(HKL hKL)
Definition: ime.c:306
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: imm.h:178
RTL_CRITICAL_SECTION g_csImeDpi
Definition: ime.c:17
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC)
Definition: utils.c:44
SHAREDINFO g_SharedInfo
Definition: imm.c:19
BOOL APIENTRY Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue, DWORD_PTR dwCommand, DWORD_PTR dwData)
Definition: utils.c:205
HKL APIENTRY Imm32GetNextHKL(UINT cKLs, const REG_IME *pLayouts, WORD wLangID)
Definition: utils.c:643
const char * LPCSTR
Definition: xmlstorage.h:183
DWORD HIMC
Definition: dimm.idl:75
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1163
struct REG_IME REG_IME
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
Definition: utils.c:144
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR szFileName[80]
Definition: precomp.h:69
LONG HRESULT
Definition: typedefs.h:79
BOOL APIENTRY Imm32WriteRegIme(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout)
Definition: utils.c:755
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA)
Definition: utils.c:132
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList)
Definition: utils.c:236
static BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
Definition: precomp.h:98
DWORD dwThreadId
Definition: fdebug.c:31
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL APIENTRY Imm32CopyFile(LPWSTR pszOldFile, LPCWSTR pszNewFile)
Definition: utils.c:851
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage)
Definition: utils.c:79
PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
Definition: utils.c:171
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage)
Definition: utils.c:99
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
Definition: utils.c:111
unsigned char BYTE
Definition: xxhash.c:193
HANDLE g_hImm32Heap
Definition: utils.c:17
DWORD APIENTRY CandidateListAnsiToWide(const CANDIDATELIST *pAnsiCL, LPCANDIDATELIST pWideCL, DWORD dwBufLen, UINT uCodePage)
Definition: candidate.c:82
PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL)
Definition: ime.c:281
Definition: ntuser.h:663
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
unsigned short USHORT
Definition: pedump.c:61
unsigned int UINT
Definition: ndis.h:50
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
Definition: utils.c:181
struct REG_IME * PREG_IME
PIMEDPI g_pImeDpiList
Definition: ime.c:18
uint32_t * LPDWORD
Definition: typedefs.h:59
unsigned int ULONG
Definition: retypes.h:1
HMODULE g_hImm32Inst
Definition: imm.c:17
BOOL APIENTRY Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
Definition: utils.c:378
static BOOL Imm32IsCrossProcessAccess(HWND hWnd)
Definition: precomp.h:105
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect)
Definition: imm.c:802
INT APIENTRY Imm32ImeMenuWideToAnsi(const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA, UINT uCodePage)
Definition: utils.c:301
DWORD NTAPI NtUserQueryInputContext(HIMC hIMC, DWORD dwUnknown2)
Definition: ntstubs.c:660
LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA)
Definition: utils.c:55
#define APIENTRY
Definition: api.h:79
DWORD APIENTRY CandidateListWideToAnsi(const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen, UINT uCodePage)
Definition: candidate.c:13