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 /* wParam for WM_IME_CONTROL */ 21 #define IMC_GETCONVERSIONMODE 0x0001 22 #define IMC_GETSENTENCEMODE 0x0003 23 #define IMC_GETOPENSTATUS 0x0005 24 #define IMC_GETSOFTKBDPOS 0x0013 25 #define IMC_SETSOFTKBDPOS 0x0014 26 27 /* wParam for WM_IME_SYSTEM */ 28 #define IMS_IMEACTIVATE 0x17 29 #define IMS_IMEDEACTIVATE 0x18 30 #define IMS_ACTIVATELAYOUT 0x19 31 32 #define IMMGWL_IMC 0 33 #define IMMGWL_PRIVATE (sizeof(LONG)) 34 35 #define IMMGWLP_IMC 0 36 #define IMMGWLP_PRIVATE (sizeof(LONG_PTR)) 37 38 typedef struct _tagINPUTCONTEXT { 39 HWND hWnd; 40 BOOL fOpen; 41 POINT ptStatusWndPos; 42 POINT ptSoftKbdPos; 43 DWORD fdwConversion; 44 DWORD fdwSentence; 45 union { 46 LOGFONTA A; 47 LOGFONTW W; 48 } lfFont; 49 COMPOSITIONFORM cfCompForm; 50 CANDIDATEFORM cfCandForm[4]; 51 HIMCC hCompStr; 52 HIMCC hCandInfo; 53 HIMCC hGuideLine; 54 HIMCC hPrivate; 55 DWORD dwNumMsgBuf; 56 HIMCC hMsgBuf; 57 DWORD fdwInit; 58 DWORD dwReserve[3]; 59 } INPUTCONTEXT, *PINPUTCONTEXT, *LPINPUTCONTEXT; 60 61 #ifdef _WIN64 62 C_ASSERT(offsetof(INPUTCONTEXT, hWnd) == 0x0); 63 C_ASSERT(offsetof(INPUTCONTEXT, fOpen) == 0x8); 64 C_ASSERT(offsetof(INPUTCONTEXT, ptStatusWndPos) == 0xc); 65 C_ASSERT(offsetof(INPUTCONTEXT, ptSoftKbdPos) == 0x14); 66 C_ASSERT(offsetof(INPUTCONTEXT, fdwConversion) == 0x1c); 67 C_ASSERT(offsetof(INPUTCONTEXT, fdwSentence) == 0x20); 68 C_ASSERT(offsetof(INPUTCONTEXT, lfFont) == 0x24); 69 C_ASSERT(offsetof(INPUTCONTEXT, cfCompForm) == 0x80); 70 C_ASSERT(offsetof(INPUTCONTEXT, cfCandForm) == 0x9c); 71 C_ASSERT(offsetof(INPUTCONTEXT, hCompStr) == 0x120); 72 C_ASSERT(offsetof(INPUTCONTEXT, hCandInfo) == 0x128); 73 C_ASSERT(offsetof(INPUTCONTEXT, hGuideLine) == 0x130); 74 C_ASSERT(offsetof(INPUTCONTEXT, hPrivate) == 0x138); 75 C_ASSERT(offsetof(INPUTCONTEXT, dwNumMsgBuf) == 0x140); 76 C_ASSERT(offsetof(INPUTCONTEXT, hMsgBuf) == 0x148); 77 C_ASSERT(offsetof(INPUTCONTEXT, fdwInit) == 0x150); 78 C_ASSERT(offsetof(INPUTCONTEXT, dwReserve) == 0x154); 79 C_ASSERT(sizeof(INPUTCONTEXT) == 0x160); 80 #else 81 C_ASSERT(offsetof(INPUTCONTEXT, hWnd) == 0x0); 82 C_ASSERT(offsetof(INPUTCONTEXT, fOpen) == 0x4); 83 C_ASSERT(offsetof(INPUTCONTEXT, ptStatusWndPos) == 0x8); 84 C_ASSERT(offsetof(INPUTCONTEXT, ptSoftKbdPos) == 0x10); 85 C_ASSERT(offsetof(INPUTCONTEXT, fdwConversion) == 0x18); 86 C_ASSERT(offsetof(INPUTCONTEXT, fdwSentence) == 0x1c); 87 C_ASSERT(offsetof(INPUTCONTEXT, lfFont) == 0x20); 88 C_ASSERT(offsetof(INPUTCONTEXT, cfCompForm) == 0x7c); 89 C_ASSERT(offsetof(INPUTCONTEXT, cfCandForm) == 0x98); 90 C_ASSERT(offsetof(INPUTCONTEXT, hCompStr) == 0x118); 91 C_ASSERT(offsetof(INPUTCONTEXT, hCandInfo) == 0x11c); 92 C_ASSERT(offsetof(INPUTCONTEXT, hGuideLine) == 0x120); 93 C_ASSERT(offsetof(INPUTCONTEXT, hPrivate) == 0x124); 94 C_ASSERT(offsetof(INPUTCONTEXT, dwNumMsgBuf) == 0x128); 95 C_ASSERT(offsetof(INPUTCONTEXT, hMsgBuf) == 0x12c); 96 C_ASSERT(offsetof(INPUTCONTEXT, fdwInit) == 0x130); 97 C_ASSERT(offsetof(INPUTCONTEXT, dwReserve) == 0x134); 98 C_ASSERT(sizeof(INPUTCONTEXT) == 0x140); 99 #endif 100 101 struct IME_STATE; 102 103 typedef struct INPUTCONTEXTDX /* unconfirmed */ 104 { 105 INPUTCONTEXT; 106 UINT nVKey; 107 BOOL bNeedsTrans; 108 DWORD dwUnknown1; 109 DWORD dwUIFlags; 110 DWORD dwUnknown2; 111 struct IME_STATE *pState; 112 DWORD dwChange; 113 DWORD dwUnknown5; 114 } INPUTCONTEXTDX, *LPINPUTCONTEXTDX; 115 116 #ifndef _WIN64 117 C_ASSERT(offsetof(INPUTCONTEXTDX, nVKey) == 0x140); 118 C_ASSERT(offsetof(INPUTCONTEXTDX, bNeedsTrans) == 0x144); 119 C_ASSERT(offsetof(INPUTCONTEXTDX, dwUIFlags) == 0x14c); 120 C_ASSERT(offsetof(INPUTCONTEXTDX, pState) == 0x154); 121 C_ASSERT(offsetof(INPUTCONTEXTDX, dwChange) == 0x158); 122 C_ASSERT(sizeof(INPUTCONTEXTDX) == 0x160); 123 #endif 124 125 // bits of fdwInit of INPUTCONTEXT 126 #define INIT_STATUSWNDPOS 0x00000001 127 #define INIT_CONVERSION 0x00000002 128 #define INIT_SENTENCE 0x00000004 129 #define INIT_LOGFONT 0x00000008 130 #define INIT_COMPFORM 0x00000010 131 #define INIT_SOFTKBDPOS 0x00000020 132 133 // bits for INPUTCONTEXTDX.dwChange 134 #define INPUTCONTEXTDX_CHANGE_OPEN 0x1 135 #define INPUTCONTEXTDX_CHANGE_CONVERSION 0x2 136 #define INPUTCONTEXTDX_CHANGE_SENTENCE 0x4 137 #define INPUTCONTEXTDX_CHANGE_FORCE_OPEN 0x100 138 139 #ifndef WM_IME_REPORT 140 #define WM_IME_REPORT 0x280 141 #endif 142 143 // WM_IME_REPORT wParam 144 #define IR_STRINGSTART 0x100 145 #define IR_STRINGEND 0x101 146 #define IR_OPENCONVERT 0x120 147 #define IR_CHANGECONVERT 0x121 148 #define IR_CLOSECONVERT 0x122 149 #define IR_FULLCONVERT 0x123 150 #define IR_IMESELECT 0x130 151 #define IR_STRING 0x140 152 #define IR_DBCSCHAR 0x160 153 #define IR_UNDETERMINE 0x170 154 #define IR_STRINGEX 0x180 155 #define IR_MODEINFO 0x190 156 157 // for IR_UNDETERMINE 158 typedef struct tagUNDETERMINESTRUCT 159 { 160 DWORD dwSize; 161 UINT uDefIMESize; 162 UINT uDefIMEPos; 163 UINT uUndetTextLen; 164 UINT uUndetTextPos; 165 UINT uUndetAttrPos; 166 UINT uCursorPos; 167 UINT uDeltaStart; 168 UINT uDetermineTextLen; 169 UINT uDetermineTextPos; 170 UINT uDetermineDelimPos; 171 UINT uYomiTextLen; 172 UINT uYomiTextPos; 173 UINT uYomiDelimPos; 174 } UNDETERMINESTRUCT, *PUNDETERMINESTRUCT, *LPUNDETERMINESTRUCT; 175 176 LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC); 177 178 typedef struct IME_SUBSTATE 179 { 180 struct IME_SUBSTATE *pNext; 181 HKL hKL; 182 DWORD dwValue; 183 } IME_SUBSTATE, *PIME_SUBSTATE; 184 185 #ifndef _WIN64 186 C_ASSERT(sizeof(IME_SUBSTATE) == 0xc); 187 #endif 188 189 typedef struct IME_STATE 190 { 191 struct IME_STATE *pNext; 192 WORD wLang; 193 WORD fOpen; 194 DWORD dwConversion; 195 DWORD dwSentence; 196 DWORD dwInit; 197 PIME_SUBSTATE pSubState; 198 } IME_STATE, *PIME_STATE; 199 200 #ifndef _WIN64 201 C_ASSERT(sizeof(IME_STATE) == 0x18); 202 #endif 203 204 #ifdef __cplusplus 205 } // extern "C" 206 #endif 207 208 #endif /* ndef _IMMDEV_ */ 209