2021-09-10 14:39:15 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS IMM32
|
|
|
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
|
|
|
* PURPOSE: Implementing IMM32
|
|
|
|
* COPYRIGHT: Copyright 1998 Patrik Stridvall
|
|
|
|
* Copyright 2002, 2003, 2007 CodeWeavers, Aric Stewart
|
|
|
|
* Copyright 2017 James Tabor <james.tabor@reactos.org>
|
|
|
|
* Copyright 2018 Amine Khaldi <amine.khaldi@reactos.org>
|
|
|
|
* Copyright 2020 Oleg Dubinskiy <oleg.dubinskij2013@yandex.ua>
|
2022-10-23 00:51:24 +00:00
|
|
|
* Copyright 2020-2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
2021-09-10 14:39:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
/* PSDK/NDK Headers */
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
|
|
|
#include <winnls.h>
|
|
|
|
#include <winreg.h>
|
2021-10-05 05:07:58 +00:00
|
|
|
#include <winnls32.h>
|
2021-10-21 01:28:04 +00:00
|
|
|
#include <winver.h>
|
2021-09-10 14:39:15 +00:00
|
|
|
|
|
|
|
#include <imm.h>
|
2022-01-30 00:38:04 +00:00
|
|
|
#include <ddk/immdev.h>
|
2021-09-10 14:39:15 +00:00
|
|
|
|
|
|
|
#define NTOS_MODE_USER
|
|
|
|
#include <ndk/umtypes.h>
|
|
|
|
#include <ndk/pstypes.h>
|
|
|
|
#include <ndk/rtlfuncs.h>
|
|
|
|
|
|
|
|
/* Public Win32K Headers */
|
|
|
|
#include "ntuser.h"
|
|
|
|
#include "ntwin32.h"
|
|
|
|
|
|
|
|
/* Undocumented user definitions */
|
|
|
|
#include <undocuser.h>
|
|
|
|
#include <imm32_undoc.h>
|
|
|
|
|
|
|
|
#include <strsafe.h>
|
|
|
|
|
|
|
|
#include <wine/debug.h>
|
|
|
|
#include <wine/list.h>
|
|
|
|
|
|
|
|
#define IMM_INIT_MAGIC 0x19650412
|
|
|
|
#define IMM_INVALID_CANDFORM ULONG_MAX
|
|
|
|
#define INVALID_HOTKEY_ID 0xFFFFFFFF
|
|
|
|
#define MAX_CANDIDATEFORM 4
|
2021-09-16 10:27:43 +00:00
|
|
|
#define MAX_IMM_FILENAME 80
|
2021-09-10 14:39:15 +00:00
|
|
|
|
|
|
|
#define LANGID_CHINESE_SIMPLIFIED MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
|
|
|
|
#define LANGID_CHINESE_TRADITIONAL MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
|
|
|
|
#define LANGID_JAPANESE MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)
|
|
|
|
|
|
|
|
#define REGKEY_KEYBOARD_LAYOUTS L"System\\CurrentControlSet\\Control\\Keyboard Layouts"
|
|
|
|
#define REGKEY_IMM L"Software\\Microsoft\\Windows NT\\CurrentVersion\\IMM"
|
|
|
|
|
|
|
|
#define ROUNDUP4(n) (((n) + 3) & ~3) /* DWORD alignment */
|
|
|
|
|
2021-10-21 01:28:04 +00:00
|
|
|
typedef struct REG_IME
|
|
|
|
{
|
|
|
|
HKL hKL;
|
|
|
|
WCHAR szImeKey[20]; /* "E0XXYYYY": "E0XX" is the device handle. "YYYY" is a LANGID. */
|
|
|
|
WCHAR szFileName[80]; /* The IME module filename */
|
|
|
|
} REG_IME, *PREG_IME;
|
|
|
|
|
2022-04-09 01:41:39 +00:00
|
|
|
extern HMODULE ghImm32Inst;
|
2022-04-08 09:21:54 +00:00
|
|
|
extern RTL_CRITICAL_SECTION gcsImeDpi;
|
2022-04-08 10:02:08 +00:00
|
|
|
extern PIMEDPI gpImeDpiList;
|
2022-03-29 08:57:28 +00:00
|
|
|
extern PSERVERINFO gpsi;
|
2022-03-31 01:00:06 +00:00
|
|
|
extern SHAREDINFO gSharedInfo;
|
2022-03-31 00:11:13 +00:00
|
|
|
extern HANDLE ghImmHeap;
|
2021-09-10 14:39:15 +00:00
|
|
|
|
|
|
|
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName);
|
|
|
|
VOID APIENTRY LogFontAnsiToWide(const LOGFONTA *plfA, LPLOGFONTW plfW);
|
|
|
|
VOID APIENTRY LogFontWideToAnsi(const LOGFONTW *plfW, LPLOGFONTA plfA);
|
2021-09-27 00:31:16 +00:00
|
|
|
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType);
|
2022-04-22 23:16:53 +00:00
|
|
|
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType);
|
|
|
|
#define ValidateHwndNoErr(hwnd) ValidateHandleNoErr((hwnd), TYPE_WINDOW)
|
|
|
|
#define ValidateHwnd(hwnd) ValidateHandle((hwnd), TYPE_WINDOW)
|
2021-09-27 00:31:16 +00:00
|
|
|
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC);
|
2021-09-18 16:52:05 +00:00
|
|
|
|
2022-03-29 09:02:25 +00:00
|
|
|
LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes);
|
2022-03-31 00:11:13 +00:00
|
|
|
#define ImmLocalFree(lpData) HeapFree(ghImmHeap, 0, (lpData))
|
2021-09-18 16:52:05 +00:00
|
|
|
|
2022-10-21 07:04:59 +00:00
|
|
|
LPWSTR APIENTRY Imm32WideFromAnsi(UINT uCodePage, LPCSTR pszA);
|
|
|
|
LPSTR APIENTRY Imm32AnsiFromWide(UINT uCodePage, LPCWSTR pszW);
|
2021-10-15 01:31:08 +00:00
|
|
|
LONG APIENTRY IchWideFromAnsi(LONG cchAnsi, LPCSTR pchAnsi, UINT uCodePage);
|
|
|
|
LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT uCodePage);
|
2022-03-31 10:35:31 +00:00
|
|
|
PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL);
|
2022-04-08 13:23:30 +00:00
|
|
|
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect);
|
2021-09-30 18:10:26 +00:00
|
|
|
BOOL APIENTRY Imm32ReleaseIME(HKL hKL);
|
2022-02-10 06:18:44 +00:00
|
|
|
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean(VOID);
|
2022-10-23 00:51:24 +00:00
|
|
|
BOOL APIENTRY Imm32IsCrossThreadAccess(HIMC hIMC);
|
|
|
|
BOOL APIENTRY Imm32IsCrossProcessAccess(HWND hWnd);
|
2021-09-30 18:04:00 +00:00
|
|
|
BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC);
|
|
|
|
|
2022-10-23 03:49:37 +00:00
|
|
|
#if 0
|
|
|
|
#define UNEXPECTED() ASSERT(FALSE)
|
|
|
|
#else
|
|
|
|
#define UNEXPECTED() 0
|
|
|
|
#endif
|
|
|
|
|
2022-10-23 00:51:24 +00:00
|
|
|
/*
|
|
|
|
* Unexpected Condition Checkers
|
|
|
|
* --- Examine the condition, and then generate trace log if necessary.
|
|
|
|
*/
|
|
|
|
#ifdef NDEBUG /* on Release */
|
|
|
|
#define IS_NULL_UNEXPECTEDLY(p) (!(p))
|
|
|
|
#define IS_ZERO_UNEXPECTEDLY(p) (!(p))
|
|
|
|
#define IS_TRUE_UNEXPECTEDLY(x) (x)
|
|
|
|
#define IS_FALSE_UNEXPECTEDLY(x) (!(x))
|
|
|
|
#define IS_ERROR_UNEXPECTEDLY(x) (!(x))
|
|
|
|
#else /* on Debug */
|
|
|
|
#define IS_NULL_UNEXPECTEDLY(p) \
|
|
|
|
(!(p) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
|
2022-10-23 03:49:37 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, "%s was NULL\n", #p), UNEXPECTED(), TRUE) \
|
2022-10-23 00:51:24 +00:00
|
|
|
: FALSE)
|
|
|
|
#define IS_ZERO_UNEXPECTEDLY(p) \
|
|
|
|
(!(p) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
|
2022-10-23 03:49:37 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, "%s was zero\n", #p), UNEXPECTED(), TRUE) \
|
2022-10-23 00:51:24 +00:00
|
|
|
: FALSE)
|
|
|
|
#define IS_TRUE_UNEXPECTEDLY(x) \
|
|
|
|
((x) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
|
2022-10-23 03:49:37 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, "%s was non-zero\n", #x), UNEXPECTED(), TRUE) \
|
2022-10-23 00:51:24 +00:00
|
|
|
: FALSE)
|
|
|
|
#define IS_FALSE_UNEXPECTEDLY(x) \
|
|
|
|
((!(x)) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
|
2022-10-23 03:49:37 +00:00
|
|
|
__FILE__, __FUNCTION__, __LINE__, "%s was FALSE\n", #x), UNEXPECTED(), TRUE) \
|
2022-10-23 00:51:24 +00:00
|
|
|
: FALSE)
|
|
|
|
#define IS_ERROR_UNEXPECTEDLY(x) \
|
|
|
|
((x) != ERROR_SUCCESS ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
|
|
|
|
__FILE__, __FUNCTION__, __LINE__, \
|
|
|
|
"%s was 0x%X\n", #x, (x)), TRUE) \
|
|
|
|
: FALSE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define IS_CROSS_THREAD_HIMC(hIMC) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))
|
|
|
|
#define IS_CROSS_PROCESS_HWND(hWnd) IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))
|
|
|
|
#define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
|
|
|
|
#define IS_16BIT_MODE() (GetWin32ClientInfo()->dwTIFlags & TIF_16BIT)
|
2021-09-21 03:20:10 +00:00
|
|
|
|
2021-09-10 14:39:15 +00:00
|
|
|
DWORD APIENTRY
|
|
|
|
CandidateListWideToAnsi(const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD dwBufLen,
|
|
|
|
UINT uCodePage);
|
|
|
|
DWORD APIENTRY
|
|
|
|
CandidateListAnsiToWide(const CANDIDATELIST *pAnsiCL, LPCANDIDATELIST pWideCL, DWORD dwBufLen,
|
|
|
|
UINT uCodePage);
|
|
|
|
|
|
|
|
BOOL APIENTRY
|
2022-03-31 04:52:16 +00:00
|
|
|
Imm32MakeIMENotify(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD_PTR dwValue,
|
|
|
|
DWORD_PTR dwCommand, DWORD_PTR dwData);
|
2021-09-10 14:39:15 +00:00
|
|
|
|
2022-04-09 01:41:39 +00:00
|
|
|
DWORD APIENTRY Imm32BuildHimcList(DWORD dwThreadId, HIMC **pphList);
|
2021-09-30 18:04:00 +00:00
|
|
|
|
|
|
|
INT APIENTRY
|
|
|
|
Imm32ImeMenuAnsiToWide(const IMEMENUITEMINFOA *pItemA, LPIMEMENUITEMINFOW pItemW,
|
|
|
|
UINT uCodePage, BOOL bBitmap);
|
|
|
|
INT APIENTRY
|
|
|
|
Imm32ImeMenuWideToAnsi(const IMEMENUITEMINFOW *pItemW, LPIMEMENUITEMINFOA pItemA,
|
|
|
|
UINT uCodePage);
|
2021-10-03 22:33:15 +00:00
|
|
|
|
|
|
|
PIME_STATE APIENTRY Imm32FetchImeState(LPINPUTCONTEXTDX pIC, HKL hKL);
|
|
|
|
PIME_SUBSTATE APIENTRY Imm32FetchImeSubState(PIME_STATE pState, HKL hKL);
|
|
|
|
|
|
|
|
BOOL APIENTRY
|
|
|
|
Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL);
|
|
|
|
BOOL APIENTRY
|
|
|
|
Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL);
|
2021-10-15 13:46:58 +00:00
|
|
|
|
|
|
|
DWORD APIENTRY
|
|
|
|
Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage);
|
|
|
|
DWORD APIENTRY
|
|
|
|
Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const RECONVERTSTRING *pSrc, UINT uCodePage);
|
2021-10-21 01:28:04 +00:00
|
|
|
|
|
|
|
HRESULT APIENTRY Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase);
|
|
|
|
HRESULT APIENTRY Imm32UIntToStr(DWORD dwValue, ULONG nBase, LPWSTR pszBuff, USHORT cchBuff);
|
|
|
|
BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx);
|
2022-03-31 04:52:16 +00:00
|
|
|
UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts);
|
2022-10-21 01:11:59 +00:00
|
|
|
BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayoutText);
|
2022-03-31 04:52:16 +00:00
|
|
|
HKL APIENTRY Imm32AssignNewLayout(UINT cKLs, const REG_IME *pLayouts, WORD wLangID);
|
|
|
|
BOOL APIENTRY Imm32CopyImeFile(LPWSTR pszOldFile, LPCWSTR pszNewFile);
|
2022-10-23 00:51:24 +00:00
|
|
|
PTHREADINFO FASTCALL Imm32CurrentPti(VOID);
|
2022-07-22 20:58:17 +00:00
|
|
|
|
|
|
|
HBITMAP Imm32LoadBitmapFromBytes(const BYTE *pb);
|
|
|
|
BOOL Imm32StoreBitmapToBytes(HBITMAP hbm, LPBYTE pbData, DWORD cbDataMax);
|