xref: /reactos/dll/win32/imm32/precomp.h (revision fec35dc8)
1b4557a60SKatayama Hirofumi MZ /*
2b4557a60SKatayama Hirofumi MZ  * PROJECT:     ReactOS IMM32
3b4557a60SKatayama Hirofumi MZ  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4b4557a60SKatayama Hirofumi MZ  * PURPOSE:     Implementing IMM32
5b4557a60SKatayama Hirofumi MZ  * COPYRIGHT:   Copyright 1998 Patrik Stridvall
6b4557a60SKatayama Hirofumi MZ  *              Copyright 2002, 2003, 2007 CodeWeavers, Aric Stewart
7b4557a60SKatayama Hirofumi MZ  *              Copyright 2017 James Tabor <james.tabor@reactos.org>
8b4557a60SKatayama Hirofumi MZ  *              Copyright 2018 Amine Khaldi <amine.khaldi@reactos.org>
9b4557a60SKatayama Hirofumi MZ  *              Copyright 2020 Oleg Dubinskiy <oleg.dubinskij2013@yandex.ua>
10b4557a60SKatayama Hirofumi MZ  *              Copyright 2020-2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
11b4557a60SKatayama Hirofumi MZ  */
12b4557a60SKatayama Hirofumi MZ 
13b4557a60SKatayama Hirofumi MZ #pragma once
14b4557a60SKatayama Hirofumi MZ 
15b4557a60SKatayama Hirofumi MZ #include <stdio.h>
16b4557a60SKatayama Hirofumi MZ #include <stdlib.h>
17b4557a60SKatayama Hirofumi MZ 
18b4557a60SKatayama Hirofumi MZ /* PSDK/NDK Headers */
19b4557a60SKatayama Hirofumi MZ #define WIN32_NO_STATUS
20b4557a60SKatayama Hirofumi MZ #include <windef.h>
21b4557a60SKatayama Hirofumi MZ #include <winbase.h>
22b4557a60SKatayama Hirofumi MZ #include <wingdi.h>
23b4557a60SKatayama Hirofumi MZ #include <winuser.h>
24b4557a60SKatayama Hirofumi MZ #include <winnls.h>
25b4557a60SKatayama Hirofumi MZ #include <winreg.h>
264f006ec7SKatayama Hirofumi MZ #include <winnls32.h>
27b4557a60SKatayama Hirofumi MZ 
28b4557a60SKatayama Hirofumi MZ #include <imm.h>
29b4557a60SKatayama Hirofumi MZ #include <ddk/imm.h>
30b4557a60SKatayama Hirofumi MZ 
31b4557a60SKatayama Hirofumi MZ #define NTOS_MODE_USER
32b4557a60SKatayama Hirofumi MZ #include <ndk/umtypes.h>
33b4557a60SKatayama Hirofumi MZ #include <ndk/pstypes.h>
34b4557a60SKatayama Hirofumi MZ #include <ndk/rtlfuncs.h>
35b4557a60SKatayama Hirofumi MZ 
36b4557a60SKatayama Hirofumi MZ /* Public Win32K Headers */
37b4557a60SKatayama Hirofumi MZ #include "ntuser.h"
38b4557a60SKatayama Hirofumi MZ #include "ntwin32.h"
39b4557a60SKatayama Hirofumi MZ 
40b4557a60SKatayama Hirofumi MZ /* Undocumented user definitions */
41b4557a60SKatayama Hirofumi MZ #include <undocuser.h>
42b4557a60SKatayama Hirofumi MZ #include <imm32_undoc.h>
43b4557a60SKatayama Hirofumi MZ 
44b4557a60SKatayama Hirofumi MZ #include <strsafe.h>
45b4557a60SKatayama Hirofumi MZ 
46b4557a60SKatayama Hirofumi MZ #include <wine/debug.h>
47b4557a60SKatayama Hirofumi MZ #include <wine/list.h>
48b4557a60SKatayama Hirofumi MZ 
49b4557a60SKatayama Hirofumi MZ #define IMM_INIT_MAGIC          0x19650412
50b4557a60SKatayama Hirofumi MZ #define IMM_INVALID_CANDFORM    ULONG_MAX
51b4557a60SKatayama Hirofumi MZ #define INVALID_HOTKEY_ID       0xFFFFFFFF
52b4557a60SKatayama Hirofumi MZ #define MAX_CANDIDATEFORM       4
53afb6c8a1SKatayama Hirofumi MZ #define MAX_IMM_FILENAME        80
54b4557a60SKatayama Hirofumi MZ 
55b4557a60SKatayama Hirofumi MZ #define LANGID_CHINESE_SIMPLIFIED   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
56b4557a60SKatayama Hirofumi MZ #define LANGID_CHINESE_TRADITIONAL  MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
57b4557a60SKatayama Hirofumi MZ #define LANGID_JAPANESE             MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)
58b4557a60SKatayama Hirofumi MZ 
59b4557a60SKatayama Hirofumi MZ #define REGKEY_KEYBOARD_LAYOUTS     L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
60b4557a60SKatayama Hirofumi MZ #define REGKEY_IMM                  L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"
61b4557a60SKatayama Hirofumi MZ 
62b4557a60SKatayama Hirofumi MZ #define ROUNDUP4(n) (((n) + 3) & ~3)  /* DWORD alignment */
63b4557a60SKatayama Hirofumi MZ 
64b4557a60SKatayama Hirofumi MZ extern HMODULE g_hImm32Inst;
65b4557a60SKatayama Hirofumi MZ extern RTL_CRITICAL_SECTION g_csImeDpi;
66b4557a60SKatayama Hirofumi MZ extern PIMEDPI g_pImeDpiList;
67b4557a60SKatayama Hirofumi MZ extern PSERVERINFO g_psi;
68b4557a60SKatayama Hirofumi MZ extern SHAREDINFO g_SharedInfo;
69b4557a60SKatayama Hirofumi MZ extern BYTE g_bClientRegd;
70b4557a60SKatayama Hirofumi MZ extern HANDLE g_hImm32Heap;
71b4557a60SKatayama Hirofumi MZ 
72b4557a60SKatayama Hirofumi MZ BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName);
73b4557a60SKatayama Hirofumi MZ VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW);
74b4557a60SKatayama Hirofumi MZ VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA);
75b4557a60SKatayama Hirofumi MZ PWND FASTCALL ValidateHwndNoErr(HWND hwnd);
76be9a788fSKatayama Hirofumi MZ LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType);
77be9a788fSKatayama Hirofumi MZ BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC);
785b522667SKatayama Hirofumi MZ 
79b4557a60SKatayama Hirofumi MZ LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes);
805b522667SKatayama Hirofumi MZ #define Imm32HeapFree(lpData) HeapFree(g_hImm32Heap, 0, (lpData))
815b522667SKatayama Hirofumi MZ 
82b4557a60SKatayama Hirofumi MZ LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA);
83b4557a60SKatayama Hirofumi MZ LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW);
84*fec35dc8SKatayama Hirofumi MZ LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage);
85*fec35dc8SKatayama Hirofumi MZ LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage);
86b4557a60SKatayama Hirofumi MZ PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL);
8766ef3149SKatayama Hirofumi MZ LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect);
88e6a51b54SKatayama Hirofumi MZ BOOL APIENTRY Imm32ReleaseIME(HKL hKL);
89b4557a60SKatayama Hirofumi MZ 
90b4557a60SKatayama Hirofumi MZ static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
91b4557a60SKatayama Hirofumi MZ {
92b4557a60SKatayama Hirofumi MZ     DWORD dwImeThreadId = NtUserQueryInputContext(hIMC, 1);
93b4557a60SKatayama Hirofumi MZ     DWORD dwThreadId = GetCurrentThreadId();
94b4557a60SKatayama Hirofumi MZ     return (dwImeThreadId != dwThreadId);
95b4557a60SKatayama Hirofumi MZ }
96b4557a60SKatayama Hirofumi MZ 
97b4557a60SKatayama Hirofumi MZ static inline BOOL Imm32IsCrossProcessAccess(HWND hWnd)
98b4557a60SKatayama Hirofumi MZ {
99b4557a60SKatayama Hirofumi MZ     return (NtUserQueryWindow(hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) !=
100b4557a60SKatayama Hirofumi MZ             (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess);
101b4557a60SKatayama Hirofumi MZ }
102b4557a60SKatayama Hirofumi MZ 
10333affbfeSKatayama Hirofumi MZ BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC);
10433affbfeSKatayama Hirofumi MZ 
105e0da6437SKatayama Hirofumi MZ #define ImeDpi_IsUnicode(pImeDpi)   ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
106ca3fa719SKatayama Hirofumi MZ #define Imm32IsImmMode()            (g_psi && (g_psi->dwSRVIFlags & SRVINFO_IMM32))
107ca3fa719SKatayama Hirofumi MZ #define Imm32IsCiceroMode()         (g_psi && (g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
108ca3fa719SKatayama Hirofumi MZ #define Imm32Is16BitMode()          (GetWin32ClientInfo()->dwTIFlags & TIF_16BIT)
109e0da6437SKatayama Hirofumi MZ 
110b4557a60SKatayama Hirofumi MZ DWORD APIENTRY
111b4557a60SKatayama Hirofumi MZ CandidateListWideToAnsi(const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen,
112b4557a60SKatayama Hirofumi MZ                         UINT uCodePage);
113b4557a60SKatayama Hirofumi MZ DWORD APIENTRY
114b4557a60SKatayama Hirofumi MZ CandidateListAnsiToWide(const CANDIDATELIST *pAnsiCL, LPCANDIDATELIST pWideCL, DWORD dwBufLen,
115b4557a60SKatayama Hirofumi MZ                         UINT uCodePage);
116b4557a60SKatayama Hirofumi MZ 
117b4557a60SKatayama Hirofumi MZ BOOL APIENTRY
118b4557a60SKatayama Hirofumi MZ Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue,
119b4557a60SKatayama Hirofumi MZ                   DWORD_PTR dwCommand, DWORD_PTR dwData);
120b4557a60SKatayama Hirofumi MZ 
121b4557a60SKatayama Hirofumi MZ DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList);
12233affbfeSKatayama Hirofumi MZ 
12333affbfeSKatayama Hirofumi MZ INT APIENTRY
12433affbfeSKatayama Hirofumi MZ Imm32ImeMenuAnsiToWide(const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW,
12533affbfeSKatayama Hirofumi MZ                        UINT uCodePage, BOOL bBitmap);
12633affbfeSKatayama Hirofumi MZ INT APIENTRY
12733affbfeSKatayama Hirofumi MZ Imm32ImeMenuWideToAnsi(const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA,
12833affbfeSKatayama Hirofumi MZ                        UINT uCodePage);
12966ef3149SKatayama Hirofumi MZ 
13066ef3149SKatayama Hirofumi MZ PIME_STATE APIENTRY Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL);
13166ef3149SKatayama Hirofumi MZ PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL);
13266ef3149SKatayama Hirofumi MZ 
13366ef3149SKatayama Hirofumi MZ BOOL APIENTRY
13466ef3149SKatayama Hirofumi MZ Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL);
13566ef3149SKatayama Hirofumi MZ BOOL APIENTRY
13666ef3149SKatayama Hirofumi MZ Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL);
137