Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

534 lines
13 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: immcli.h
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Typedefs, defines, and prototypes that are used exclusively by the IMM
  7. * client-side DLL.
  8. *
  9. * History:
  10. * 11-Jan-96 wkwok Created
  11. \***************************************************************************/
  12. #ifndef _IMMCLI_
  13. #define _IMMCLI_
  14. #pragma once
  15. #define OEMRESOURCE 1
  16. #include <windows.h>
  17. #include <stddef.h>
  18. #include <w32err.h>
  19. #include <w32gdip.h>
  20. #include "winuserp.h"
  21. #include "winuserk.h"
  22. #include "kbd.h"
  23. #include <wowuserp.h>
  24. #include <memory.h>
  25. #include <string.h>
  26. #include <imm.h>
  27. #include <immp.h>
  28. #include <ime.h>
  29. #include <imep.h>
  30. #include <winnls32.h>
  31. #include "immstruc.h"
  32. #include "immuser.h"
  33. #include "user.h"
  34. typedef struct _ENUMREGWORDDATA {
  35. union {
  36. REGISTERWORDENUMPROCW w;
  37. REGISTERWORDENUMPROCA a;
  38. } lpfn;
  39. LPVOID lpData;
  40. DWORD dwCodePage;
  41. } ENUMREGWORDDATA, *PENUMREGWORDDATA;
  42. #define HEX_ASCII_SIZE 20
  43. typedef struct tagIMELAYOUT {
  44. HKL hImeKL;
  45. WCHAR szKeyName[HEX_ASCII_SIZE];
  46. WCHAR szImeName[IM_FILE_SIZE];
  47. } IMELAYOUT, *PIMELAYOUT;
  48. #define ImmAssert UserAssert
  49. typedef struct tagFE_KEYBOARDS {
  50. BOOLEAN fJPN : 1;
  51. BOOLEAN fCHT : 1;
  52. BOOLEAN fCHS : 1;
  53. BOOLEAN fKOR : 1;
  54. } FE_KEYBOARDS;
  55. /*
  56. * Function pointers to registry routines in advapi32.dll.
  57. */
  58. typedef struct {
  59. LONG (WINAPI* RegCreateKeyW)(HKEY, LPCWSTR, PHKEY);
  60. LONG (WINAPI* RegOpenKeyW)(HKEY, LPCWSTR, PHKEY);
  61. LONG (WINAPI* RegCloseKey)(HKEY);
  62. LONG (WINAPI* RegDeleteKeyW)(HKEY, LPCWSTR);
  63. LONG (WINAPI* RegCreateKeyExW)(HKEY, LPCWSTR, DWORD, LPWSTR, DWORD, REGSAM, LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD);
  64. LONG (WINAPI* RegSetValueExW)(HKEY, LPCWSTR, DWORD Reserved, DWORD, CONST BYTE*, DWORD);
  65. LONG (WINAPI* RegQueryValueExW)(HKEY, LPCWSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD);
  66. HMODULE hModule;
  67. BOOLEAN fOk;
  68. } ADVAPI_FN;
  69. /***************************************************************************\
  70. *
  71. * Globals declarations
  72. *
  73. \***************************************************************************/
  74. extern BOOLEAN gfInitialized;
  75. extern HINSTANCE ghInst;
  76. extern PVOID pImmHeap;
  77. extern PSERVERINFO gpsi;
  78. extern SHAREDINFO gSharedInfo;
  79. extern PIMEDPI gpImeDpi;
  80. extern CRITICAL_SECTION gcsImeDpi;
  81. extern POINT gptWorkArea;
  82. extern POINT gptRaiseEdge;
  83. extern UINT guScanCode[0XFF];
  84. extern CONST WCHAR gszRegKbdLayout[];
  85. #ifdef CUAS_ENABLE
  86. extern CONST WCHAR gszRegCiceroIME[];
  87. extern CONST WCHAR gszRegCtfShared[];
  88. extern CONST WCHAR gszValCUASEnable[];
  89. #endif // CUAS_ENABLE
  90. #ifdef LATER
  91. extern CONST INT sizeof_gszRegKbdLayout;
  92. #endif
  93. extern CONST WCHAR gszRegKbdOrder[];
  94. extern CONST WCHAR gszValLayoutText[];
  95. extern CONST WCHAR gszValLayoutFile[];
  96. extern CONST WCHAR gszValImeFile[];
  97. #ifdef CUAS_ENABLE
  98. extern DWORD g_aimm_compat_flags;
  99. #endif // CUAS_ENABLE
  100. /***************************************************************************\
  101. *
  102. * Validation handling
  103. *
  104. \***************************************************************************/
  105. #define bUser32Initialized (gpsi != NULL)
  106. #define ValidateHwnd(hwnd) (((hwnd) == (HWND)NULL || !bUser32Initialized) \
  107. ? (PWND)NULL : HMValidateHandle(hwnd, TYPE_WINDOW))
  108. #define ValidateHimc(himc) (((himc) == (HIMC)NULL || !bUser32Initialized) \
  109. ? (PIMC)NULL : HMValidateHandle((HANDLE)himc, TYPE_INPUTCONTEXT))
  110. #define RevalidateHimc(himc) (((himc) == (HIMC)NULL || !bUser32Initialized) \
  111. ? (PIMC)NULL : HMValidateHandleNoRip((HANDLE)himc, TYPE_INPUTCONTEXT))
  112. /***************************************************************************\
  113. *
  114. * Memory management macros
  115. *
  116. \***************************************************************************/
  117. LPVOID ImmLocalAlloc(DWORD uFlag, DWORD uBytes);
  118. #define ImmLocalReAlloc(p, uBytes, uFlags) HeapReAlloc(pImmHeap, uFlags, (LPSTR)(p), (uBytes))
  119. #define ImmLocalFree(p) HeapFree(pImmHeap, 0, (LPSTR)(p))
  120. #define ImmLocalSize(p) HeapSize(pImmHeap, 0, (LPSTR)(p))
  121. #define ImmLocalLock(p) (LPSTR)(p)
  122. #define ImmLocalUnlock(p)
  123. #define ImmLocalFlags(p) 0
  124. #define ImmLocalHandle(p) (HLOCAL)(p)
  125. /***************************************************************************\
  126. *
  127. * Other Typedefs and Macros
  128. *
  129. \***************************************************************************/
  130. #define GetInputContextProcess(himc) \
  131. (DWORD)NtUserQueryInputContext(himc, InputContextProcess)
  132. #define GetInputContextThread(himc) \
  133. (DWORD)NtUserQueryInputContext(himc, InputContextThread)
  134. #define GetWindowProcess(hwnd) \
  135. (ULONG_PTR)NtUserQueryWindow(hwnd, WindowProcess)
  136. #define GETPROCESSID() (ULONG_PTR)(NtCurrentTeb()->ClientId.UniqueProcess)
  137. #define DWORD_ALIGN(x) ((x+3)&~3)
  138. #define SetICF(pClientImc, flag) ((pClientImc)->dwFlags |= flag)
  139. #define ClrICF(pClientImc, flag) ((pClientImc)->dwFlags &= ~flag)
  140. #define TestICF(pClientImc, flag) ((pClientImc)->dwFlags & flag)
  141. #define IsWndEqual(hWnd1, hWnd2) (LOWORD(HandleToUlong(hWnd1)) == LOWORD(HandleToUlong(hWnd2)) && \
  142. ValidateHwnd(hWnd1) == ValidateHwnd(hWnd2))
  143. #define HKL_TO_LANGID(hkl) (LOWORD(HandleToUlong(hkl)))
  144. /*
  145. * Obsolete, but keep this for backward compat. for a while
  146. */
  147. #define LANGIDFROMHKL(hkl) (LOBYTE(LOWORD((ULONG_PTR)hkl)))
  148. #ifdef IMM_CONV_ON_HKL
  149. #define IMECodePage(pImeDpi) ((pImeDpi)->dwCodePage)
  150. #define CImcCodePage(pClientImc) ((pClientImc)->dwCodePage)
  151. #else
  152. #define IMECodePage(pImeDpi) (CP_ACP)
  153. #define CImcCodePage(pClientImc) (CP_ACP)
  154. #endif
  155. /***************************************************************************\
  156. *
  157. * Function declarations
  158. *
  159. \***************************************************************************/
  160. /*
  161. * context.c
  162. */
  163. BOOL CreateInputContext(
  164. HIMC hImc,
  165. HKL hKL,
  166. BOOL fCanCallImeSelect);
  167. BOOL DestroyInputContext(
  168. HIMC hImc,
  169. HKL hKL,
  170. BOOL bTerminate);
  171. VOID SelectInputContext(
  172. HKL hSelKL,
  173. HKL hUnSelKL,
  174. HIMC hImc);
  175. DWORD BuildHimcList(
  176. DWORD idThread,
  177. HIMC **pphimcFirst);
  178. HIMC ImmGetSaveContext(
  179. HWND hWnd,
  180. DWORD dwFlag);
  181. /*
  182. * ctxtinfo.c
  183. */
  184. BOOL ImmSetCompositionStringWorker(
  185. HIMC hImc,
  186. DWORD dwIndex,
  187. LPVOID lpComp,
  188. DWORD dwCompLen,
  189. LPVOID lpRead,
  190. DWORD dwReadLen,
  191. BOOL fAnsi);
  192. DWORD ImmGetCandidateListCountWorker(
  193. HIMC hImc,
  194. LPDWORD lpdwListCount,
  195. BOOL fAnsi);
  196. DWORD ImmGetCandidateListWorker(
  197. HIMC hImc,
  198. DWORD dwIndex,
  199. LPCANDIDATELIST lpCandList,
  200. DWORD dwBufLen,
  201. BOOL fAnsi);
  202. DWORD ImmGetGuideLineWorker(
  203. HIMC hImc,
  204. DWORD dwIndex,
  205. LPBYTE lpBuf,
  206. DWORD dwBufLen,
  207. BOOL fAnsi);
  208. LONG InternalGetCompositionStringA(
  209. #ifdef CUAS_ENABLE
  210. HIMC hImc,
  211. #endif // CUAS_ENABLE
  212. LPCOMPOSITIONSTRING lpCompStr,
  213. DWORD dwIndex,
  214. LPVOID lpBuf,
  215. DWORD dwBufLen,
  216. BOOL fAnsiImc,
  217. DWORD dwCodePage);
  218. LONG InternalGetCompositionStringW(
  219. #ifdef CUAS_ENABLE
  220. HIMC hImc,
  221. #endif // CUAS_ENABLE
  222. LPCOMPOSITIONSTRING lpCompStr,
  223. DWORD dwIndex,
  224. LPVOID lpBuf,
  225. DWORD dwBufLen,
  226. BOOL fAnsiImc,
  227. DWORD dwCodePage);
  228. DWORD InternalGetCandidateListAtoW(
  229. LPCANDIDATELIST lpCandListA,
  230. LPCANDIDATELIST lpCandListW,
  231. DWORD dwBufLen,
  232. DWORD dwCodePage);
  233. DWORD InternalGetCandidateListWtoA(
  234. LPCANDIDATELIST lpCandListW,
  235. LPCANDIDATELIST lpCandListA,
  236. DWORD dwBufLen,
  237. DWORD dwCodePage);
  238. DWORD CalcCharacterPositionAtoW(
  239. DWORD dwCharPosA,
  240. LPSTR lpszCharStr,
  241. DWORD dwCodePage);
  242. DWORD CalcCharacterPositionWtoA(
  243. DWORD dwCharPosW,
  244. LPWSTR lpwszCharStr,
  245. DWORD dwCodePage);
  246. VOID LFontAtoLFontW(
  247. LPLOGFONTA lfFontA,
  248. LPLOGFONTW lfFontW);
  249. VOID LFontWtoLFontA(
  250. LPLOGFONTW lfFontW,
  251. LPLOGFONTA lfFontA);
  252. BOOL MakeIMENotify(
  253. HIMC hImc,
  254. HWND hWnd,
  255. DWORD dwAction,
  256. DWORD dwIndex,
  257. DWORD dwValue,
  258. WPARAM wParam,
  259. LPARAM lParam);
  260. VOID ImmSendNotification(
  261. BOOL fForProcess);
  262. /*
  263. * immime.c
  264. */
  265. BOOL InquireIme(
  266. PIMEDPI pImeDpi);
  267. BOOL LoadIME(
  268. PIMEINFOEX piiex,
  269. PIMEDPI pImeDpi);
  270. VOID UnloadIME(
  271. PIMEDPI pImeDpi,
  272. BOOL fTerminateIme);
  273. PIMEDPI LoadImeDpi(
  274. HKL hKL,
  275. BOOL fLock);
  276. PIMEDPI FindOrLoadImeDpi(
  277. HKL hKL);
  278. /*
  279. * layime.c
  280. */
  281. VOID GetSystemPathName(PWSTR /*OUT*/ pwszPath, PWSTR pwszFileName, UINT maxChar);
  282. BOOL LoadVersionInfo(
  283. PIMEINFOEX piiex);
  284. LPWSTR MakeStringFromRegFullInfo(PKEY_VALUE_FULL_INFORMATION pKey, size_t limit);
  285. /*
  286. * misc.c
  287. */
  288. PINPUTCONTEXT InternalImmLockIMC(
  289. HIMC hImc,
  290. BOOL fCanCallImeSelect);
  291. BOOL ImmIsUIMessageWorker(
  292. HWND hIMEWnd,
  293. UINT message,
  294. WPARAM wParam,
  295. LPARAM lParam,
  296. BOOL fAnsi);
  297. PTHREADINFO PtiCurrent(VOID);
  298. BOOL TestInputContextProcess(
  299. PIMC pImc);
  300. PIMEDPI ImmGetImeDpi(HKL hKL);
  301. DWORD ImmGetAppCompatFlags(HIMC hImc);
  302. BOOL ImmPtInRect(
  303. int left,
  304. int top,
  305. int width,
  306. int height,
  307. LPPOINT lppt);
  308. UINT GetKeyboardLayoutCP(
  309. HKL hKL);
  310. /*
  311. * regword.c
  312. */
  313. UINT CALLBACK EnumRegisterWordProcA(
  314. LPCSTR lpszReading,
  315. DWORD dwStyle,
  316. LPCSTR lpszString,
  317. PENUMREGWORDDATA pEnumRegWordData);
  318. UINT CALLBACK EnumRegisterWordProcW(
  319. LPCWSTR lpwszReading,
  320. DWORD dwStyle,
  321. LPCWSTR lpwszString,
  322. PENUMREGWORDDATA pEnumRegWordData);
  323. /*
  324. * hotkey.c
  325. */
  326. VOID ImmPostMessages(
  327. HWND hwnd,
  328. HIMC hImc,
  329. INT iNum,
  330. PTRANSMSG pTransMsg);
  331. BOOL HotKeyIDDispatcher( HWND hWnd, HIMC hImc, HKL hKL, DWORD dwHotKeyID );
  332. BOOL OpenRegApi(ADVAPI_FN* pfn);
  333. void CloseRegApi(ADVAPI_FN* pfn);
  334. /*
  335. * transsub.c
  336. */
  337. LRESULT TranslateIMESubFunctions(
  338. HWND hWndApp,
  339. LPIMESTRUCT lpIme,
  340. BOOL fAnsi);
  341. LRESULT TransGetLevel( HWND hWndApp );
  342. LRESULT TransSetLevel( HWND hWndApp, LPIMESTRUCT lpIme);
  343. /*
  344. * kcodecnv.c
  345. */
  346. LRESULT TransCodeConvert( HIMC hImc, LPIMESTRUCT lpIme);
  347. LRESULT TransConvertList( HIMC hImc, LPIMESTRUCT lpIme);
  348. LRESULT TransGetMNTable( HIMC hImc, LPIMESTRUCT lpIme);
  349. /*
  350. * ktranmsg.c
  351. */
  352. UINT WINNLSTranslateMessageK(
  353. int iNumMsg,
  354. PTRANSMSG pTransMsg,
  355. LPINPUTCONTEXT lpIMC,
  356. LPCOMPOSITIONSTRING lpCompStr,
  357. BOOL bAnsiIMC);
  358. /*
  359. * jtranmsg.c
  360. */
  361. UINT WINNLSTranslateMessageJ(
  362. UINT uiNumMsg,
  363. PTRANSMSG pTransMsg,
  364. LPINPUTCONTEXT lpIMC,
  365. LPCOMPOSITIONSTRING lpCompStr,
  366. BOOL bAnsiIMC );
  367. /*
  368. * input.c
  369. */
  370. UINT WINNLSTranslateMessage(
  371. INT iNum, // number of messages in the source buffer
  372. PTRANSMSG pTransMsg, // source buffer that contains 4.0 style messages
  373. HIMC hImc, // input context handle
  374. BOOL fAnsi, // TRUE if pdwt contains ANSI messages
  375. DWORD dwLangId ); // language ID ( KOREAN or JAPANESE )
  376. /*
  377. * support routine: IsAnsiClientIMC
  378. */
  379. __inline int IsAnsiIMC(HIMC hIMC)
  380. {
  381. BOOL bAnsi;
  382. // get ansi mode of origin IMC
  383. PCLIENTIMC pClientIMC = ImmLockClientImc(hIMC);
  384. if (pClientIMC == NULL) {
  385. return -1;
  386. }
  387. bAnsi = !TestICF(pClientIMC, IMCF_UNICODE);
  388. ImmUnlockClientImc(pClientIMC);
  389. return bAnsi;
  390. }
  391. #ifdef CUAS_ENABLE
  392. /*
  393. * com.c
  394. */
  395. HRESULT CtfImmTIMCreateInputContext(HIMC hImc);
  396. HRESULT CtfImmTIMDestroyInputContext(HIMC hImc);
  397. HRESULT CtfImmLastEnabledWndDestroy(LPARAM lParam);
  398. LRESULT CtfImmSetLangBand(HWND hwndTray, BOOL fLangBand);
  399. HRESULT Internal_CtfImeCreateThreadMgr();
  400. HRESULT Internal_CtfImeDestroyThreadMgr();
  401. BOOL Internal_CtfImeProcessCicHotkey(HIMC hIMC, UINT uVKey, LPARAM lParam);
  402. HRESULT Internal_CtfImeCreateInputContext(HIMC himc);
  403. HRESULT Internal_CtfImeDestroyInputContext(HIMC himc);
  404. HRESULT Internal_CtfImeSetActiveContextAlways(HIMC himc, BOOL fActive, HWND hwnd, HKL hkl);
  405. BOOL IsCUASEnabled();
  406. BOOL IsDisabledTextServices();
  407. BOOL IsInteractiveUserLogon();
  408. BOOL IsRunningInMsoobe();
  409. #endif // CUAS_ENABLE
  410. #define TRACE(x)
  411. //
  412. // Resources
  413. //
  414. // CHT software keyboard bitmaps
  415. #define BACK_T1 100
  416. #define TAB_T1 101
  417. #define CAPS_T1 102
  418. #define ENTER_T1 103
  419. #define SHIFT_T1 104
  420. #define CTRL_T1 105
  421. #define ESC_T1 106
  422. #define ALT_T1 107
  423. #define LABEL_T1 108
  424. // CHS software keyboard bitmaps
  425. #define BACKSP_C1 201
  426. #define TAB_C1 202
  427. #define CAPS_C1 203
  428. #define ENTER_C1 204
  429. #define SHIFT_C1 205
  430. #define INS_C1 206
  431. #define DEL_C1 207
  432. #define ESC_C1 208
  433. #define LABEL_C1 209
  434. #endif // _IMMCLI_