1 /* 2 * PROJECT: ReactOS headers 3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later) 4 * PURPOSE: Providing DDK-compatible <immdev.h> and IME/IMM development helper 5 * COPYRIGHT: Copyright 2021-2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 8 #ifndef _IMMDEV_ 9 #define _IMMDEV_ 10 11 #pragma once 12 13 #include <wingdi.h> 14 #include <imm.h> 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 BOOL WINAPI ImmDisableTextFrameService(_In_ DWORD dwThreadId); 21 22 typedef struct tagSOFTKBDDATA 23 { 24 UINT uCount; 25 WORD wCode[1][256]; 26 } SOFTKBDDATA, *PSOFTKBDDATA, *LPSOFTKBDDATA; 27 28 /* wParam for WM_IME_CONTROL */ 29 #define IMC_GETCONVERSIONMODE 0x0001 30 #define IMC_GETSENTENCEMODE 0x0003 31 #define IMC_GETOPENSTATUS 0x0005 32 #define IMC_GETSOFTKBDFONT 0x0011 33 #define IMC_SETSOFTKBDFONT 0x0012 34 #define IMC_GETSOFTKBDPOS 0x0013 35 #define IMC_SETSOFTKBDPOS 0x0014 36 #define IMC_GETSOFTKBDSUBTYPE 0x0015 37 #define IMC_SETSOFTKBDSUBTYPE 0x0016 38 #define IMC_SETSOFTKBDDATA 0x0018 39 40 /* wParam for WM_IME_SYSTEM */ 41 #define IMS_NOTIFYIMESHOW 0x05 42 #define IMS_UPDATEIMEUI 0x06 43 #define IMS_SETCANDFORM 0x09 44 #define IMS_SETCOMPFONT 0x0A 45 #define IMS_SETCOMPFORM 0x0B 46 #define IMS_CONFIGURE 0x0D 47 #define IMS_SETOPENSTATUS 0x0F 48 #define IMS_FREELAYOUT 0x11 49 #define IMS_GETCONVSTATUS 0x14 50 #define IMS_IMEHELP 0x15 51 #define IMS_IMEACTIVATE 0x17 52 #define IMS_IMEDEACTIVATE 0x18 53 #define IMS_ACTIVATELAYOUT 0x19 54 #define IMS_GETIMEMENU 0x1C 55 #define IMS_GETCONTEXT 0x1E 56 #define IMS_SENDNOTIFICATION 0x1F 57 #define IMS_COMPLETECOMPSTR 0x20 58 #define IMS_LOADTHREADLAYOUT 0x21 59 #define IMS_SETLANGBAND 0x23 60 #define IMS_UNSETLANGBAND 0x24 61 62 /* wParam for WM_IME_NOTIFY */ 63 #define IMN_SOFTKBDDESTROYED 0x0011 64 65 #define IMMGWL_IMC 0 66 #define IMMGWL_PRIVATE (sizeof(LONG)) 67 68 #define IMMGWLP_IMC 0 69 #define IMMGWLP_PRIVATE (sizeof(LONG_PTR)) 70 71 typedef struct _tagINPUTCONTEXT { 72 HWND hWnd; 73 BOOL fOpen; 74 POINT ptStatusWndPos; 75 POINT ptSoftKbdPos; 76 DWORD fdwConversion; 77 DWORD fdwSentence; 78 union { 79 LOGFONTA A; 80 LOGFONTW W; 81 } lfFont; 82 COMPOSITIONFORM cfCompForm; 83 CANDIDATEFORM cfCandForm[4]; 84 HIMCC hCompStr; 85 HIMCC hCandInfo; 86 HIMCC hGuideLine; 87 HIMCC hPrivate; 88 DWORD dwNumMsgBuf; 89 HIMCC hMsgBuf; 90 DWORD fdwInit; 91 DWORD dwReserve[3]; 92 } INPUTCONTEXT, *PINPUTCONTEXT, *LPINPUTCONTEXT; 93 94 #ifdef _WIN64 95 C_ASSERT(offsetof(INPUTCONTEXT, hWnd) == 0x0); 96 C_ASSERT(offsetof(INPUTCONTEXT, fOpen) == 0x8); 97 C_ASSERT(offsetof(INPUTCONTEXT, ptStatusWndPos) == 0xc); 98 C_ASSERT(offsetof(INPUTCONTEXT, ptSoftKbdPos) == 0x14); 99 C_ASSERT(offsetof(INPUTCONTEXT, fdwConversion) == 0x1c); 100 C_ASSERT(offsetof(INPUTCONTEXT, fdwSentence) == 0x20); 101 C_ASSERT(offsetof(INPUTCONTEXT, lfFont) == 0x24); 102 C_ASSERT(offsetof(INPUTCONTEXT, cfCompForm) == 0x80); 103 C_ASSERT(offsetof(INPUTCONTEXT, cfCandForm) == 0x9c); 104 C_ASSERT(offsetof(INPUTCONTEXT, hCompStr) == 0x120); 105 C_ASSERT(offsetof(INPUTCONTEXT, hCandInfo) == 0x128); 106 C_ASSERT(offsetof(INPUTCONTEXT, hGuideLine) == 0x130); 107 C_ASSERT(offsetof(INPUTCONTEXT, hPrivate) == 0x138); 108 C_ASSERT(offsetof(INPUTCONTEXT, dwNumMsgBuf) == 0x140); 109 C_ASSERT(offsetof(INPUTCONTEXT, hMsgBuf) == 0x148); 110 C_ASSERT(offsetof(INPUTCONTEXT, fdwInit) == 0x150); 111 C_ASSERT(offsetof(INPUTCONTEXT, dwReserve) == 0x154); 112 C_ASSERT(sizeof(INPUTCONTEXT) == 0x160); 113 #else 114 C_ASSERT(offsetof(INPUTCONTEXT, hWnd) == 0x0); 115 C_ASSERT(offsetof(INPUTCONTEXT, fOpen) == 0x4); 116 C_ASSERT(offsetof(INPUTCONTEXT, ptStatusWndPos) == 0x8); 117 C_ASSERT(offsetof(INPUTCONTEXT, ptSoftKbdPos) == 0x10); 118 C_ASSERT(offsetof(INPUTCONTEXT, fdwConversion) == 0x18); 119 C_ASSERT(offsetof(INPUTCONTEXT, fdwSentence) == 0x1c); 120 C_ASSERT(offsetof(INPUTCONTEXT, lfFont) == 0x20); 121 C_ASSERT(offsetof(INPUTCONTEXT, cfCompForm) == 0x7c); 122 C_ASSERT(offsetof(INPUTCONTEXT, cfCandForm) == 0x98); 123 C_ASSERT(offsetof(INPUTCONTEXT, hCompStr) == 0x118); 124 C_ASSERT(offsetof(INPUTCONTEXT, hCandInfo) == 0x11c); 125 C_ASSERT(offsetof(INPUTCONTEXT, hGuideLine) == 0x120); 126 C_ASSERT(offsetof(INPUTCONTEXT, hPrivate) == 0x124); 127 C_ASSERT(offsetof(INPUTCONTEXT, dwNumMsgBuf) == 0x128); 128 C_ASSERT(offsetof(INPUTCONTEXT, hMsgBuf) == 0x12c); 129 C_ASSERT(offsetof(INPUTCONTEXT, fdwInit) == 0x130); 130 C_ASSERT(offsetof(INPUTCONTEXT, dwReserve) == 0x134); 131 C_ASSERT(sizeof(INPUTCONTEXT) == 0x140); 132 #endif 133 134 struct IME_STATE; 135 136 /* unconfirmed */ 137 #ifdef __cplusplus 138 typedef struct INPUTCONTEXTDX : INPUTCONTEXT 139 { 140 #else 141 typedef struct INPUTCONTEXTDX 142 { 143 INPUTCONTEXT; 144 #endif 145 UINT nVKey; 146 BOOL bNeedsTrans; 147 DWORD dwUnknown1; 148 DWORD dwUIFlags; 149 DWORD dwUnknown2; 150 struct IME_STATE *pState; 151 DWORD dwChange; 152 DWORD dwUnknown5; 153 } INPUTCONTEXTDX, *PINPUTCONTEXTDX, *LPINPUTCONTEXTDX; 154 155 #ifndef _WIN64 156 C_ASSERT(offsetof(INPUTCONTEXTDX, nVKey) == 0x140); 157 C_ASSERT(offsetof(INPUTCONTEXTDX, bNeedsTrans) == 0x144); 158 C_ASSERT(offsetof(INPUTCONTEXTDX, dwUIFlags) == 0x14c); 159 C_ASSERT(offsetof(INPUTCONTEXTDX, pState) == 0x154); 160 C_ASSERT(offsetof(INPUTCONTEXTDX, dwChange) == 0x158); 161 C_ASSERT(sizeof(INPUTCONTEXTDX) == 0x160); 162 #endif 163 164 // bits of fdwInit of INPUTCONTEXT 165 #define INIT_STATUSWNDPOS 0x00000001 166 #define INIT_CONVERSION 0x00000002 167 #define INIT_SENTENCE 0x00000004 168 #define INIT_LOGFONT 0x00000008 169 #define INIT_COMPFORM 0x00000010 170 #define INIT_SOFTKBDPOS 0x00000020 171 172 // bits for INPUTCONTEXTDX.dwChange 173 #define INPUTCONTEXTDX_CHANGE_OPEN 0x1 174 #define INPUTCONTEXTDX_CHANGE_CONVERSION 0x2 175 #define INPUTCONTEXTDX_CHANGE_SENTENCE 0x4 176 #define INPUTCONTEXTDX_CHANGE_FORCE_OPEN 0x100 177 178 #ifndef WM_IME_REPORT 179 #define WM_IME_REPORT 0x280 180 #endif 181 182 // WM_IME_REPORT wParam 183 #define IR_STRINGSTART 0x100 184 #define IR_STRINGEND 0x101 185 #define IR_OPENCONVERT 0x120 186 #define IR_CHANGECONVERT 0x121 187 #define IR_CLOSECONVERT 0x122 188 #define IR_FULLCONVERT 0x123 189 #define IR_IMESELECT 0x130 190 #define IR_STRING 0x140 191 #define IR_DBCSCHAR 0x160 192 #define IR_UNDETERMINE 0x170 193 #define IR_STRINGEX 0x180 194 #define IR_MODEINFO 0x190 195 196 // for IR_UNDETERMINE 197 typedef struct tagUNDETERMINESTRUCT 198 { 199 DWORD dwSize; 200 UINT uDefIMESize; 201 UINT uDefIMEPos; 202 UINT uUndetTextLen; 203 UINT uUndetTextPos; 204 UINT uUndetAttrPos; 205 UINT uCursorPos; 206 UINT uDeltaStart; 207 UINT uDetermineTextLen; 208 UINT uDetermineTextPos; 209 UINT uDetermineDelimPos; 210 UINT uYomiTextLen; 211 UINT uYomiTextPos; 212 UINT uYomiDelimPos; 213 } UNDETERMINESTRUCT, *PUNDETERMINESTRUCT, *LPUNDETERMINESTRUCT; 214 215 LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC); 216 217 typedef struct IME_SUBSTATE 218 { 219 struct IME_SUBSTATE *pNext; 220 HKL hKL; 221 DWORD dwValue; 222 } IME_SUBSTATE, *PIME_SUBSTATE; 223 224 #ifndef _WIN64 225 C_ASSERT(sizeof(IME_SUBSTATE) == 0xc); 226 #endif 227 228 typedef struct IME_STATE 229 { 230 struct IME_STATE *pNext; 231 WORD wLang; 232 WORD fOpen; 233 DWORD dwConversion; 234 DWORD dwSentence; 235 DWORD dwInit; 236 PIME_SUBSTATE pSubState; 237 } IME_STATE, *PIME_STATE; 238 239 #ifndef _WIN64 240 C_ASSERT(sizeof(IME_STATE) == 0x18); 241 #endif 242 243 typedef struct _tagTRANSMSG 244 { 245 UINT message; 246 WPARAM wParam; 247 LPARAM lParam; 248 } TRANSMSG, *PTRANSMSG, *LPTRANSMSG; 249 250 typedef struct _tagTRANSMSGLIST 251 { 252 UINT uMsgCount; 253 TRANSMSG TransMsg[ANYSIZE_ARRAY]; 254 } TRANSMSGLIST, *PTRANSMSGLIST, *LPTRANSMSGLIST; 255 256 #define DEFINE_IME_ENTRY(type, name, params, extended) typedef type (WINAPI *FN_##name) params; 257 #include <imetable.h> 258 #undef DEFINE_IME_ENTRY 259 260 typedef struct IMEDPI 261 { 262 struct IMEDPI *pNext; 263 HINSTANCE hInst; 264 HKL hKL; 265 IMEINFO ImeInfo; 266 UINT uCodePage; 267 WCHAR szUIClass[16]; 268 DWORD cLockObj; 269 DWORD dwFlags; 270 #define DEFINE_IME_ENTRY(type, name, params, extended) FN_##name name; 271 #include <imetable.h> 272 #undef DEFINE_IME_ENTRY 273 } IMEDPI, *PIMEDPI; 274 275 #ifndef _WIN64 276 C_ASSERT(offsetof(IMEDPI, pNext) == 0x0); 277 C_ASSERT(offsetof(IMEDPI, hInst) == 0x4); 278 C_ASSERT(offsetof(IMEDPI, hKL) == 0x8); 279 C_ASSERT(offsetof(IMEDPI, ImeInfo) == 0xc); 280 C_ASSERT(offsetof(IMEDPI, uCodePage) == 0x28); 281 C_ASSERT(offsetof(IMEDPI, szUIClass) == 0x2c); 282 C_ASSERT(offsetof(IMEDPI, cLockObj) == 0x4c); 283 C_ASSERT(offsetof(IMEDPI, dwFlags) == 0x50); 284 C_ASSERT(offsetof(IMEDPI, ImeInquire) == 0x54); 285 C_ASSERT(offsetof(IMEDPI, ImeConversionList) == 0x58); 286 C_ASSERT(offsetof(IMEDPI, ImeRegisterWord) == 0x5c); 287 C_ASSERT(offsetof(IMEDPI, ImeUnregisterWord) == 0x60); 288 C_ASSERT(offsetof(IMEDPI, ImeGetRegisterWordStyle) == 0x64); 289 C_ASSERT(offsetof(IMEDPI, ImeEnumRegisterWord) == 0x68); 290 C_ASSERT(offsetof(IMEDPI, ImeConfigure) == 0x6c); 291 C_ASSERT(offsetof(IMEDPI, ImeDestroy) == 0x70); 292 C_ASSERT(offsetof(IMEDPI, ImeEscape) == 0x74); 293 C_ASSERT(offsetof(IMEDPI, ImeProcessKey) == 0x78); 294 C_ASSERT(offsetof(IMEDPI, ImeSelect) == 0x7c); 295 C_ASSERT(offsetof(IMEDPI, ImeSetActiveContext) == 0x80); 296 C_ASSERT(offsetof(IMEDPI, ImeToAsciiEx) == 0x84); 297 C_ASSERT(offsetof(IMEDPI, NotifyIME) == 0x88); 298 C_ASSERT(offsetof(IMEDPI, ImeSetCompositionString) == 0x8c); 299 C_ASSERT(offsetof(IMEDPI, ImeGetImeMenuItems) == 0x90); 300 C_ASSERT(offsetof(IMEDPI, CtfImeInquireExW) == 0x94); 301 C_ASSERT(offsetof(IMEDPI, CtfImeSelectEx) == 0x98); 302 C_ASSERT(offsetof(IMEDPI, CtfImeEscapeEx) == 0x9c); 303 C_ASSERT(offsetof(IMEDPI, CtfImeGetGuidAtom) == 0xa0); 304 C_ASSERT(offsetof(IMEDPI, CtfImeIsGuidMapEnable) == 0xa4); 305 C_ASSERT(sizeof(IMEDPI) == 0xa8); 306 #endif 307 308 /* flags for IMEDPI.dwFlags */ 309 #define IMEDPI_FLAG_UNLOADED 0x1 310 #define IMEDPI_FLAG_LOCKED 0x2 311 312 /* unconfirmed */ 313 typedef struct tagCLIENTIMC 314 { 315 HANDLE hInputContext; /* LocalAlloc'ed LHND */ 316 LONG cLockObj; 317 DWORD dwFlags; 318 DWORD dwCompatFlags; 319 RTL_CRITICAL_SECTION cs; 320 UINT uCodePage; 321 HKL hKL; 322 BOOL bCtfIme; 323 } CLIENTIMC, *PCLIENTIMC; 324 325 #ifndef _WIN64 326 C_ASSERT(offsetof(CLIENTIMC, hInputContext) == 0x0); 327 C_ASSERT(offsetof(CLIENTIMC, cLockObj) == 0x4); 328 C_ASSERT(offsetof(CLIENTIMC, dwFlags) == 0x8); 329 C_ASSERT(offsetof(CLIENTIMC, dwCompatFlags) == 0xc); 330 C_ASSERT(offsetof(CLIENTIMC, cs) == 0x10); 331 C_ASSERT(offsetof(CLIENTIMC, uCodePage) == 0x28); 332 C_ASSERT(offsetof(CLIENTIMC, hKL) == 0x2c); 333 C_ASSERT(sizeof(CLIENTIMC) == 0x34); 334 #endif 335 336 /* flags for CLIENTIMC */ 337 #define CLIENTIMC_WIDE 0x1 338 #define CLIENTIMC_ACTIVE 0x2 339 #define CLIENTIMC_UNKNOWN4 0x20 340 #define CLIENTIMC_DESTROY 0x40 341 #define CLIENTIMC_DISABLEIME 0x80 342 #define CLIENTIMC_UNKNOWN2 0x100 343 344 #ifdef __cplusplus 345 } // extern "C" 346 #endif 347 348 #endif /* ndef _IMMDEV_ */ 349