6efcbf70fe1bfcaf76450b63c8fd1aee21c1bbeb
[reactos.git] / dll / win32 / imm32 / precomp.h
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
27 #include <imm.h>
28 #include <ddk/imm.h>
29
30 #define NTOS_MODE_USER
31 #include <ndk/umtypes.h>
32 #include <ndk/pstypes.h>
33 #include <ndk/rtlfuncs.h>
34
35 /* Public Win32K Headers */
36 #include "ntuser.h"
37 #include "ntwin32.h"
38
39 /* Undocumented user definitions */
40 #include <undocuser.h>
41 #include <imm32_undoc.h>
42
43 #include <strsafe.h>
44
45 #include <wine/debug.h>
46 #include <wine/list.h>
47
48 #define IMM_INIT_MAGIC 0x19650412
49 #define IMM_INVALID_CANDFORM ULONG_MAX
50 #define INVALID_HOTKEY_ID 0xFFFFFFFF
51 #define MAX_CANDIDATEFORM 4
52
53 #define LANGID_CHINESE_SIMPLIFIED MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
54 #define LANGID_CHINESE_TRADITIONAL MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
55 #define LANGID_JAPANESE MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)
56
57 #define REGKEY_KEYBOARD_LAYOUTS L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
58 #define REGKEY_IMM L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"
59
60 #define ROUNDUP4(n) (((n) + 3) & ~3) /* DWORD alignment */
61
62 extern HMODULE g_hImm32Inst;
63 extern RTL_CRITICAL_SECTION g_csImeDpi;
64 extern PIMEDPI g_pImeDpiList;
65 extern PSERVERINFO g_psi;
66 extern SHAREDINFO g_SharedInfo;
67 extern BYTE g_bClientRegd;
68 extern HANDLE g_hImm32Heap;
69
70 BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName);
71 VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW);
72 VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA);
73 PWND FASTCALL ValidateHwndNoErr(HWND hwnd);
74 LPVOID APIENTRY Imm32HeapAlloc(DWORD dwFlags, DWORD dwBytes);
75 LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA);
76 LPSTR APIENTRY Imm32AnsiFromWide(LPCWSTR pszW);
77 PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL);
78
79 static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
80 {
81 DWORD dwImeThreadId = NtUserQueryInputContext(hIMC, 1);
82 DWORD dwThreadId = GetCurrentThreadId();
83 return (dwImeThreadId != dwThreadId);
84 }
85
86 static inline BOOL Imm32IsCrossProcessAccess(HWND hWnd)
87 {
88 return (NtUserQueryWindow(hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) !=
89 (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess);
90 }
91
92 DWORD APIENTRY
93 CandidateListWideToAnsi(const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen,
94 UINT uCodePage);
95 DWORD APIENTRY
96 CandidateListAnsiToWide(const CANDIDATELIST *pAnsiCL, LPCANDIDATELIST pWideCL, DWORD dwBufLen,
97 UINT uCodePage);
98
99 BOOL APIENTRY
100 Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue,
101 DWORD_PTR dwCommand, DWORD_PTR dwData);
102
103 DWORD APIENTRY Imm32AllocAndBuildHimcList(DWORD dwThreadId, HIMC **pphList);