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>
|
|
|
|
* Copyright 2020-2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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);
|
|
|
|
PWND FASTCALL ValidateHwndNoErr(HWND hwnd);
|
2021-09-27 00:31:16 +00:00
|
|
|
LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType);
|
|
|
|
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
|
|
|
|
2021-09-10 14:39:15 +00:00
|
|
|
LPWSTR APIENTRY Imm32WideFromAnsi(LPCSTR pszA);
|
|
|
|
LPSTR APIENTRY Imm32AnsiFromWide(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);
|
2021-09-10 14:39:15 +00:00
|
|
|
|
|
|
|
static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
|
|
|
|
{
|
2022-01-01 11:56:50 +00:00
|
|
|
DWORD dwImeThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
|
2021-09-10 14:39:15 +00:00
|
|
|
DWORD dwThreadId = GetCurrentThreadId();
|
|
|
|
return (dwImeThreadId != dwThreadId);
|
|
|
|
}
|
|
|
|
|
2022-04-14 02:23:16 +00:00
|
|
|
// Win: TestWindowProcess
|
2021-09-10 14:39:15 +00:00
|
|
|
static inline BOOL Imm32IsCrossProcessAccess(HWND hWnd)
|
|
|
|
{
|
|
|
|
return (NtUserQueryWindow(hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) !=
|
|
|
|
(DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess);
|
|
|
|
}
|
|
|
|
|
2021-09-30 18:04:00 +00:00
|
|
|
BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC);
|
|
|
|
|
2021-09-24 13:06:29 +00:00
|
|
|
#define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty & IME_PROP_UNICODE)
|
2022-03-29 08:57:28 +00:00
|
|
|
#define IS_IMM_MODE() (gpsi && (gpsi->dwSRVIFlags & SRVINFO_IMM32))
|
|
|
|
#define Imm32IsCiceroMode() (gpsi && (gpsi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
|
2021-09-24 13:06:29 +00:00
|
|
|
#define Imm32Is16BitMode() (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);
|
|
|
|
BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayout);
|
|
|
|
HKL APIENTRY Imm32AssignNewLayout(UINT cKLs, const REG_IME *pLayouts, WORD wLangID);
|
|
|
|
BOOL APIENTRY Imm32CopyImeFile(LPWSTR pszOldFile, LPCWSTR pszNewFile);
|
2022-02-13 06:51:53 +00:00
|
|
|
|
|
|
|
static inline PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
|
|
|
|
{
|
|
|
|
if (NtCurrentTeb()->Win32ThreadInfo == NULL)
|
|
|
|
NtUserGetThreadState(THREADSTATE_GETTHREADINFO);
|
|
|
|
return NtCurrentTeb()->Win32ThreadInfo;
|
|
|
|
}
|