ReactOS  0.4.15-dev-5122-g72bdbdd
ime.c File Reference
#include <win32k.h>
Include dependency graph for ime.c:

Go to the source code of this file.

Classes

struct  tagIMEHOTKEY
 

Macros

#define INVALID_THREAD_ID   ((ULONG)-1)
 
#define INVALID_HOTKEY   ((UINT)-1)
 
#define MOD_KEYS   (MOD_CONTROL | MOD_SHIFT | MOD_ALT | MOD_WIN)
 
#define MOD_LEFT_RIGHT   (MOD_LEFT | MOD_RIGHT)
 
#define LANGID_CHINESE_SIMPLIFIED   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
 
#define LANGID_JAPANESE   MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT)
 
#define LANGID_KOREAN   MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN)
 
#define LANGID_CHINESE_TRADITIONAL   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
 
#define LANGID_NEUTRAL   MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)
 
#define VK_DBE_ALPHANUMERIC   0xF0
 
#define VK_DBE_KATAKANA   0xF1
 
#define VK_DBE_HIRAGANA   0xF2
 
#define VK_DBE_SBCSCHAR   0xF3
 
#define VK_DBE_DBCSCHAR   0xF4
 
#define VK_DBE_ROMAN   0xF5
 
#define VK_DBE_NOROMAN   0xF6
 
#define VK_DBE_ENTERWORDREGISTERMODE   0xF7
 
#define VK_DBE_ENTERCONFIGMODE   0xF8
 
#define VK_DBE_FLUSHSTRING   0xF9
 
#define VK_DBE_CODEINPUT   0xFA
 
#define VK_DBE_NOCODEINPUT   0xFB
 
#define VK_DBE_DETERINESTRING   0xFC
 
#define VK_DBE_ENTERDLGCONVERSIONMODE   0xFD
 
#define IME_CHOTKEY   0x10
 
#define IME_JHOTKEY   0x30
 
#define IME_KHOTKEY   0x50
 
#define IME_THOTKEY   0x70
 
#define IME_XHOTKEY   0x90
 

Typedefs

typedef struct tagIMEHOTKEY IMEHOTKEY
 
typedef struct tagIMEHOTKEYPIMEHOTKEY
 

Functions

 DBG_DEFAULT_CHANNEL (UserMisc)
 
DWORD FASTCALL IntGetImeCompatFlags (PTHREADINFO pti)
 
UINT FASTCALL IntGetImeHotKeyLanguageScore (HKL hKL, LANGID HotKeyLangId)
 
HKL FASTCALL IntGetActiveKeyboardLayout (VOID)
 
static LANGID FASTCALL IntGetImeHotKeyLangId (DWORD dwHotKeyId)
 
static VOID FASTCALL IntAddImeHotKey (PIMEHOTKEY *ppList, PIMEHOTKEY pHotKey)
 
static PIMEHOTKEY FASTCALL IntGetImeHotKeyById (PIMEHOTKEY pList, DWORD dwHotKeyId)
 
static PIMEHOTKEY APIENTRY IntGetImeHotKeyByKeyAndLang (PIMEHOTKEY pList, UINT uModKeys, UINT uLeftRight, UINT uVirtualKey, LANGID TargetLangId)
 
static VOID FASTCALL IntDeleteImeHotKey (PIMEHOTKEY *ppList, PIMEHOTKEY pHotKey)
 
PIMEHOTKEY IntGetImeHotKeyByKey (PIMEHOTKEY pList, UINT uModKeys, UINT uLeftRight, UINT uVirtualKey)
 
PIMEHOTKEY IntCheckImeHotKey (PUSER_MESSAGE_QUEUE MessageQueue, UINT uVirtualKey, LPARAM lParam)
 
VOID FASTCALL IntFreeImeHotKeys (VOID)
 
static BOOL APIENTRY IntSetImeHotKey (DWORD dwHotKeyId, UINT uModifiers, UINT uVirtualKey, HKL hKL, DWORD dwAction)
 
BOOL NTAPI NtUserGetImeHotKey (DWORD dwHotKeyId, LPUINT lpuModifiers, LPUINT lpuVirtualKey, LPHKL lphKL)
 
BOOL NTAPI NtUserSetImeHotKey (DWORD dwHotKeyId, UINT uModifiers, UINT uVirtualKey, HKL hKL, DWORD dwAction)
 
DWORD NTAPI NtUserCheckImeHotKey (UINT uVirtualKey, LPARAM lParam)
 
PWND FASTCALL IntGetTopLevelWindow (PWND pwnd)
 
HIMC FASTCALL IntAssociateInputContext (PWND pWnd, PIMC pImc)
 
DWORD NTAPI NtUserSetThreadLayoutHandles (HKL hNewKL, HKL hOldKL)
 
DWORD FASTCALL UserBuildHimcList (PTHREADINFO pti, DWORD dwCount, HIMC *phList)
 
UINT FASTCALL IntImmProcessKey (PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
NTSTATUS NTAPI NtUserBuildHimcList (DWORD dwThreadId, DWORD dwCount, HIMC *phList, LPDWORD pdwCount)
 
static VOID FASTCALL UserSetImeConversionKeyState (PTHREADINFO pti, DWORD dwConversion)
 
DWORD NTAPI NtUserNotifyIMEStatus (HWND hwnd, BOOL fOpen, DWORD dwConversion)
 
BOOL NTAPI NtUserDisableThreadIme (DWORD dwThreadID)
 
DWORD NTAPI NtUserGetAppImeLevel (HWND hWnd)
 
BOOL FASTCALL UserGetImeInfoEx (_Inout_ PWINSTATION_OBJECT pWinSta, _Inout_ PIMEINFOEX pInfoEx, _In_ IMEINFOEXCLASS SearchType)
 
BOOL NTAPI NtUserGetImeInfoEx (PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType)
 
BOOL NTAPI NtUserSetAppImeLevel (HWND hWnd, DWORD dwLevel)
 
BOOL FASTCALL UserSetImeInfoEx (_Inout_ PWINSTATION_OBJECT pWinSta, _Inout_ PIMEINFOEX pImeInfoEx)
 
BOOL NTAPI NtUserSetImeInfoEx (PIMEINFOEX pImeInfoEx)
 
VOID FASTCALL IntImeSetFutureOwner (PWND pImeWnd, PWND pwndOwner)
 
PWND FASTCALL IntGetLastTopMostWindowNoIME (PWND pImeWnd)
 
VOID FASTCALL IntImeSetTopMost (PWND pImeWnd, BOOL bTopMost, PWND pwndInsertBefore)
 
VOID FASTCALL IntImeCheckTopmost (PWND pImeWnd)
 
BOOL NTAPI NtUserSetImeOwnerWindow (HWND hImeWnd, HWND hwndFocus)
 
PVOID AllocInputContextObject (PDESKTOP pDesk, PTHREADINFO pti, SIZE_T Size, PVOID *HandleOwner)
 
VOID UserFreeInputContext (PVOID Object)
 
BOOLEAN UserDestroyInputContext (PVOID Object)
 
BOOL IntDestroyInputContext (PIMC pIMC)
 
BOOL NTAPI NtUserDestroyInputContext (HIMC hIMC)
 
PIMC FASTCALL UserCreateInputContext (ULONG_PTR dwClientImcData)
 
HIMC NTAPI NtUserCreateInputContext (ULONG_PTR dwClientImcData)
 
DWORD FASTCALL IntAssociateInputContextEx (PWND pWnd, PIMC pIMC, DWORD dwFlags)
 
DWORD NTAPI NtUserAssociateInputContext (HWND hWnd, HIMC hIMC, DWORD dwFlags)
 
BOOL FASTCALL UserUpdateInputContext (PIMC pIMC, DWORD dwType, DWORD_PTR dwValue)
 
BOOL NTAPI NtUserUpdateInputContext (HIMC hIMC, DWORD dwType, DWORD_PTR dwValue)
 
DWORD_PTR NTAPI NtUserQueryInputContext (HIMC hIMC, DWORD dwType)
 
BOOL IntFindNonImeRelatedWndOfSameThread (PWND pwndParent, PWND pwndTarget)
 
BOOL FASTCALL IntWantImeWindow (PWND pwndTarget)
 
PWND FASTCALL co_IntCreateDefaultImeWindow (PWND pwndTarget, HINSTANCE hInst)
 
BOOL FASTCALL IntImeCanDestroyDefIMEforChild (PWND pImeWnd, PWND pwndTarget)
 
BOOL FASTCALL IntImeCanDestroyDefIME (PWND pImeWnd, PWND pwndTarget)
 
BOOL FASTCALL IntCheckImeShowStatus (PWND pwndIme, PTHREADINFO pti)
 
LRESULT FASTCALL IntSendMessageToUI (PTHREADINFO ptiIME, PIMEUI pimeui, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID FASTCALL IntSendOpenStatusNotify (PTHREADINFO ptiIME, PIMEUI pimeui, PWND pWnd, BOOL bOpen)
 
VOID FASTCALL IntNotifyImeShowStatus (PWND pImeWnd)
 
BOOL FASTCALL IntBroadcastImeShowStatusChange (PWND pImeWnd, BOOL bShow)
 

Variables

HIMC ghIMC = NULL
 
BOOL gfImeOpen = (BOOL)-1
 
DWORD gdwImeConversion = (DWORD)-1
 
BOOL gfIMEShowStatus = (BOOL)-1
 
PIMEHOTKEY gpImeHotKeyList = NULL
 
LCID glcidSystem = 0
 

Macro Definition Documentation

◆ IME_CHOTKEY

#define IME_CHOTKEY   0x10

◆ IME_JHOTKEY

#define IME_JHOTKEY   0x30

◆ IME_KHOTKEY

#define IME_KHOTKEY   0x50

◆ IME_THOTKEY

#define IME_THOTKEY   0x70

◆ IME_XHOTKEY

#define IME_XHOTKEY   0x90

◆ INVALID_HOTKEY

#define INVALID_HOTKEY   ((UINT)-1)

Definition at line 14 of file ime.c.

◆ INVALID_THREAD_ID

#define INVALID_THREAD_ID   ((ULONG)-1)

Definition at line 13 of file ime.c.

◆ LANGID_CHINESE_SIMPLIFIED

#define LANGID_CHINESE_SIMPLIFIED   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)

Definition at line 18 of file ime.c.

◆ LANGID_CHINESE_TRADITIONAL

#define LANGID_CHINESE_TRADITIONAL   MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)

Definition at line 21 of file ime.c.

◆ LANGID_JAPANESE

Definition at line 19 of file ime.c.

◆ LANGID_KOREAN

Definition at line 20 of file ime.c.

◆ LANGID_NEUTRAL

Definition at line 22 of file ime.c.

◆ MOD_KEYS

#define MOD_KEYS   (MOD_CONTROL | MOD_SHIFT | MOD_ALT | MOD_WIN)

Definition at line 15 of file ime.c.

◆ MOD_LEFT_RIGHT

#define MOD_LEFT_RIGHT   (MOD_LEFT | MOD_RIGHT)

Definition at line 16 of file ime.c.

◆ VK_DBE_ALPHANUMERIC

#define VK_DBE_ALPHANUMERIC   0xF0

Definition at line 26 of file ime.c.

◆ VK_DBE_CODEINPUT

#define VK_DBE_CODEINPUT   0xFA

Definition at line 36 of file ime.c.

◆ VK_DBE_DBCSCHAR

#define VK_DBE_DBCSCHAR   0xF4

Definition at line 30 of file ime.c.

◆ VK_DBE_DETERINESTRING

#define VK_DBE_DETERINESTRING   0xFC

Definition at line 38 of file ime.c.

◆ VK_DBE_ENTERCONFIGMODE

#define VK_DBE_ENTERCONFIGMODE   0xF8

Definition at line 34 of file ime.c.

◆ VK_DBE_ENTERDLGCONVERSIONMODE

#define VK_DBE_ENTERDLGCONVERSIONMODE   0xFD

Definition at line 39 of file ime.c.

◆ VK_DBE_ENTERWORDREGISTERMODE

#define VK_DBE_ENTERWORDREGISTERMODE   0xF7

Definition at line 33 of file ime.c.

◆ VK_DBE_FLUSHSTRING

#define VK_DBE_FLUSHSTRING   0xF9

Definition at line 35 of file ime.c.

◆ VK_DBE_HIRAGANA

#define VK_DBE_HIRAGANA   0xF2

Definition at line 28 of file ime.c.

◆ VK_DBE_KATAKANA

#define VK_DBE_KATAKANA   0xF1

Definition at line 27 of file ime.c.

◆ VK_DBE_NOCODEINPUT

#define VK_DBE_NOCODEINPUT   0xFB

Definition at line 37 of file ime.c.

◆ VK_DBE_NOROMAN

#define VK_DBE_NOROMAN   0xF6

Definition at line 32 of file ime.c.

◆ VK_DBE_ROMAN

#define VK_DBE_ROMAN   0xF5

Definition at line 31 of file ime.c.

◆ VK_DBE_SBCSCHAR

#define VK_DBE_SBCSCHAR   0xF3

Definition at line 29 of file ime.c.

Typedef Documentation

◆ IMEHOTKEY

◆ PIMEHOTKEY

Function Documentation

◆ AllocInputContextObject()

PVOID AllocInputContextObject ( PDESKTOP  pDesk,
PTHREADINFO  pti,
SIZE_T  Size,
PVOID HandleOwner 
)

Definition at line 1431 of file ime.c.

1435 {
1436  PTHRDESKHEAD ObjHead;
1437 
1438  ASSERT(Size > sizeof(*ObjHead));
1439  ASSERT(pti != NULL);
1440 
1441  if (!pDesk)
1442  pDesk = pti->rpdesk;
1443 
1444  ObjHead = DesktopHeapAlloc(pDesk, Size);
1445  if (!ObjHead)
1446  return NULL;
1447 
1448  RtlZeroMemory(ObjHead, Size);
1449 
1450  ObjHead->pSelf = ObjHead;
1451  ObjHead->rpdesk = pDesk;
1452  ObjHead->pti = pti;
1454  *HandleOwner = pti;
1455  pti->ppi->UserHandleCount++;
1456 
1457  return ObjHead;
1458 }
PVOID pSelf
Definition: ntuser.h:187
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
struct _DESKTOP * rpdesk
Definition: win32.h:88
PPROCESSINFO ppi
Definition: win32.h:84
static __inline PVOID DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes)
Definition: desktop.h:204
#define IntReferenceThreadInfo(pti)
Definition: win32.h:162
#define ASSERT(a)
Definition: mode.c:44
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ co_IntCreateDefaultImeWindow()

PWND FASTCALL co_IntCreateDefaultImeWindow ( PWND  pwndTarget,
HINSTANCE  hInst 
)

Definition at line 1960 of file ime.c.

1961 {
1962  LARGE_UNICODE_STRING WindowName;
1963  UNICODE_STRING ClassName;
1964  PWND pImeWnd;
1965  PIMEUI pimeui;
1966  CREATESTRUCTW Cs;
1969  HANDLE pid = PsGetThreadProcessId(pti->pEThread);
1970 
1971  if (!(pti->spDefaultImc) && pid == gpidLogon)
1973 
1974  if (!(pti->spDefaultImc) || IS_WND_IMELIKE(pwndTarget) || !(pti->rpdesk->pheapDesktop))
1975  return NULL;
1976 
1977  if (IS_WND_CHILD(pwndTarget) && !(pwndTarget->style & WS_VISIBLE) &&
1978  pwndTarget->spwndParent->head.pti->ppi != pti->ppi)
1979  {
1980  return NULL;
1981  }
1982 
1983  RtlInitLargeUnicodeString(&WindowName, L"Default IME", 0);
1984 
1985  ClassName.Buffer = (PWCH)(ULONG_PTR)gpsi->atomSysClass[ICLS_IME];
1986  ClassName.Length = 0;
1987  ClassName.MaximumLength = 0;
1988 
1989  UserRefObjectCo(pwndTarget, &Ref);
1990 
1991  RtlZeroMemory(&Cs, sizeof(Cs));
1992  Cs.style = WS_POPUP | WS_DISABLED;
1993  Cs.hInstance = hInst;
1994  Cs.hwndParent = UserHMGetHandle(pwndTarget);
1995  Cs.lpszName = WindowName.Buffer;
1996  Cs.lpszClass = ClassName.Buffer;
1997 
1998  // NOTE: LARGE_UNICODE_STRING is compatible to LARGE_STRING.
1999  pImeWnd = co_UserCreateWindowEx(&Cs, &ClassName, (PLARGE_STRING)&WindowName, NULL, WINVER);
2000  if (pImeWnd)
2001  {
2002  pimeui = ((PIMEWND)pImeWnd)->pimeui;
2003  _SEH2_TRY
2004  {
2005  ProbeForWrite(pimeui, sizeof(IMEUI), 1);
2006  pimeui->fDefault = TRUE;
2007  if (IS_WND_CHILD(pwndTarget) && pwndTarget->spwndParent->head.pti != pti)
2008  pimeui->fChildThreadDef = TRUE;
2009  }
2011  {
2012  NOTHING;
2013  }
2014  _SEH2_END;
2015  }
2016 
2017  UserDerefObjectCo(pwndTarget);
2018  return pImeWnd;
2019 }
VOID NTAPI RtlInitLargeUnicodeString(IN OUT PLARGE_UNICODE_STRING, IN PCWSTR, IN INT)
Definition: rtlstr.c:42
#define WS_DISABLED
Definition: pedump.c:621
#define IS_WND_CHILD(pWnd)
Definition: window.h:107
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
#define NOTHING
Definition: input_list.c:10
struct tagIMC * spDefaultImc
Definition: win32.h:128
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define WINVER
Definition: targetver.h:11
PSERVERINFO gpsi
Definition: imm.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
struct _DESKTOP * rpdesk
Definition: win32.h:88
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
PPROCESSINFO ppi
Definition: win32.h:84
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define L(x)
Definition: ntvdm.h:50
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
Definition: object.h:3
HINSTANCE hInstance
Definition: winuser.h:2946
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE NTAPI PsGetThreadProcessId(IN PETHREAD Thread)
Definition: thread.c:745
WCHAR * PWCH
Definition: ntbasedef.h:410
UINT fChildThreadDef
Definition: ntuser.h:1220
#define ICLS_IME
Definition: ntuser.h:906
LPCWSTR lpszName
Definition: winuser.h:2954
Definition: ntuser.h:672
struct _IMEWND * PIMEWND
_SEH2_END
Definition: create.c:4400
HINSTANCE hInst
Definition: dxdiag.c:13
UINT fDefault
Definition: ntuser.h:1219
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
struct _WND * spwndParent
Definition: ntuser.h:692
LPCWSTR lpszClass
Definition: winuser.h:2955
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define WS_VISIBLE
Definition: pedump.c:620
PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
Definition: ime.c:1561
HANDLE gpidLogon
Definition: simplecall.c:15
PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW *Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, PVOID acbiBuffer, DWORD dwVer)
Definition: window.c:2185
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1031
DWORD style
Definition: ntuser.h:685

Referenced by IntCreateWindow().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserMisc  )

◆ IntAddImeHotKey()

static VOID FASTCALL IntAddImeHotKey ( PIMEHOTKEY ppList,
PIMEHOTKEY  pHotKey 
)
static

Definition at line 139 of file ime.c.

140 {
141  PIMEHOTKEY pNode;
142 
143  if (!*ppList)
144  {
145  *ppList = pHotKey;
146  return;
147  }
148 
149  for (pNode = *ppList; pNode; pNode = pNode->pNext)
150  {
151  if (!pNode->pNext)
152  {
153  pNode->pNext = pHotKey;
154  return;
155  }
156  }
157 }
struct tagIMEHOTKEY * pNext
Definition: ime.c:48

Referenced by IntSetImeHotKey().

◆ IntAssociateInputContext()

HIMC FASTCALL IntAssociateInputContext ( PWND  pWnd,
PIMC  pImc 
)

Definition at line 507 of file ime.c.

508 {
509  HIMC hOldImc = pWnd->hImc;
510  pWnd->hImc = (pImc ? UserHMGetHandle(pImc) : NULL);
511  return hOldImc;
512 }
HIMC hImc
Definition: ntuser.h:719
DWORD HIMC
Definition: dimm.idl:75
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define NULL
Definition: types.h:112

Referenced by IntAssociateInputContextEx(), and IntDestroyInputContext().

◆ IntAssociateInputContextEx()

DWORD FASTCALL IntAssociateInputContextEx ( PWND  pWnd,
PIMC  pIMC,
DWORD  dwFlags 
)

Definition at line 1639 of file ime.c.

1640 {
1641  DWORD ret = 0;
1642  PWINDOWLIST pwl;
1643  BOOL bIgnoreNullImc = (dwFlags & IACE_IGNORENOCONTEXT);
1644  PTHREADINFO pti = pWnd->head.pti;
1645  PWND pwndTarget, pwndFocus = pti->MessageQueue->spwndFocus;
1646  HWND *phwnd;
1647  HIMC hIMC;
1648 
1649  if (dwFlags & IACE_DEFAULT)
1650  {
1651  pIMC = pti->spDefaultImc;
1652  }
1653  else
1654  {
1655  if (pIMC && pti != pIMC->head.pti)
1656  return 2;
1657  }
1658 
1659  if (pWnd->head.pti->ppi != GetW32ThreadInfo()->ppi ||
1660  (pIMC && pIMC->head.rpdesk != pWnd->head.rpdesk))
1661  {
1662  return 2;
1663  }
1664 
1665  if ((dwFlags & IACE_CHILDREN) && pWnd->spwndChild)
1666  {
1667  pwl = IntBuildHwndList(pWnd->spwndChild, IACE_CHILDREN | IACE_LIST, pti);
1668  if (pwl)
1669  {
1670  for (phwnd = pwl->ahwnd; *phwnd != HWND_TERMINATOR; ++phwnd)
1671  {
1672  pwndTarget = ValidateHwndNoErr(*phwnd);
1673  if (!pwndTarget)
1674  continue;
1675 
1676  hIMC = (pIMC ? UserHMGetHandle(pIMC) : NULL);
1677  if (pwndTarget->hImc == hIMC || (bIgnoreNullImc && !pwndTarget->hImc))
1678  continue;
1679 
1680  IntAssociateInputContext(pwndTarget, pIMC);
1681  if (pwndTarget == pwndFocus)
1682  ret = 1;
1683  }
1684 
1685  IntFreeHwndList(pwl);
1686  }
1687  }
1688 
1689  if (!bIgnoreNullImc || pWnd->hImc)
1690  {
1691  hIMC = (pIMC ? UserHMGetHandle(pIMC) : NULL);
1692  if (pWnd->hImc != hIMC)
1693  {
1694  IntAssociateInputContext(pWnd, pIMC);
1695  if (pWnd == pwndFocus)
1696  ret = 1;
1697  }
1698  }
1699 
1700  return ret;
1701 }
#define HWND_TERMINATOR
Definition: window.h:82
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
struct tagIMC * spDefaultImc
Definition: win32.h:128
PWINDOWLIST FASTCALL IntBuildHwndList(PWND pwnd, DWORD dwFlags, PTHREADINFO pti)
Definition: window.c:1410
HIMC hImc
Definition: ntuser.h:719
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
#define IACE_LIST
Definition: window.h:105
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IACE_CHILDREN
Definition: imm.h:581
THRDESKHEAD head
Definition: ntuser.h:674
VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget)
Definition: window.c:1456
HWND ahwnd[ANYSIZE_ARRAY]
Definition: window.h:90
DWORD HIMC
Definition: dimm.idl:75
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: ntuser.h:672
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:85
HIMC FASTCALL IntAssociateInputContext(PWND pWnd, PIMC pImc)
Definition: ime.c:507
#define IACE_IGNORENOCONTEXT
Definition: imm.h:583
THRDESKHEAD head
Definition: ntuser.h:192
#define NULL
Definition: types.h:112
struct _WND * spwndChild
Definition: ntuser.h:693
#define IACE_DEFAULT
Definition: imm.h:582

Referenced by NtUserAssociateInputContext().

◆ IntBroadcastImeShowStatusChange()

BOOL FASTCALL IntBroadcastImeShowStatusChange ( PWND  pImeWnd,
BOOL  bShow 
)

Definition at line 2384 of file ime.c.

2385 {
2386  if (gfIMEShowStatus == bShow || !IS_IMM_MODE())
2387  return TRUE;
2388 
2389  gfIMEShowStatus = bShow;
2390  IntNotifyImeShowStatus(pImeWnd);
2391  return TRUE;
2392 }
VOID FASTCALL IntNotifyImeShowStatus(PWND pImeWnd)
Definition: ime.c:2327
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
BOOL gfIMEShowStatus
Definition: ime.c:44

Referenced by NtUserCallHwndParamLock().

◆ IntCheckImeHotKey()

PIMEHOTKEY IntCheckImeHotKey ( PUSER_MESSAGE_QUEUE  MessageQueue,
UINT  uVirtualKey,
LPARAM  lParam 
)

Definition at line 289 of file ime.c.

290 {
291  PIMEHOTKEY pHotKey;
292  UINT uModifiers;
293  BOOL bKeyUp = (lParam & 0x80000000);
294  const BYTE *KeyState = MessageQueue->afKeyState;
295  static UINT s_uKeyUpVKey = 0;
296 
297  if (bKeyUp)
298  {
299  if (s_uKeyUpVKey != uVirtualKey)
300  {
301  s_uKeyUpVKey = 0;
302  return NULL;
303  }
304 
305  s_uKeyUpVKey = 0;
306  }
307 
308  uModifiers = 0;
309  if (IS_KEY_DOWN(KeyState, VK_LSHIFT)) uModifiers |= (MOD_SHIFT | MOD_LEFT);
310  if (IS_KEY_DOWN(KeyState, VK_RSHIFT)) uModifiers |= (MOD_SHIFT | MOD_RIGHT);
311  if (IS_KEY_DOWN(KeyState, VK_LCONTROL)) uModifiers |= (MOD_CONTROL | MOD_LEFT);
312  if (IS_KEY_DOWN(KeyState, VK_RCONTROL)) uModifiers |= (MOD_CONTROL | MOD_RIGHT);
313  if (IS_KEY_DOWN(KeyState, VK_LMENU)) uModifiers |= (MOD_ALT | MOD_LEFT);
314  if (IS_KEY_DOWN(KeyState, VK_RMENU)) uModifiers |= (MOD_ALT | MOD_RIGHT);
315 
317  (uModifiers & MOD_KEYS),
318  (uModifiers & MOD_LEFT_RIGHT),
319  uVirtualKey);
320  if (pHotKey)
321  {
322  if (bKeyUp)
323  {
324  if (pHotKey->uModifiers & MOD_ON_KEYUP)
325  return pHotKey;
326  }
327  else
328  {
329  if (pHotKey->uModifiers & MOD_ON_KEYUP)
330  s_uKeyUpVKey = uVirtualKey;
331  else
332  return pHotKey;
333  }
334  }
335 
336  return NULL;
337 }
#define MOD_ALT
Definition: imm.h:319
#define VK_RMENU
Definition: winuser.h:2277
#define VK_LSHIFT
Definition: winuser.h:2272
#define MOD_LEFT_RIGHT
Definition: ime.c:16
UINT uModifiers
Definition: ime.c:51
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MOD_KEYS
Definition: ime.c:15
#define MOD_LEFT
Definition: imm.h:323
#define MOD_SHIFT
Definition: imm.h:321
#define MOD_ON_KEYUP
Definition: imm.h:326
#define VK_RCONTROL
Definition: winuser.h:2275
#define VK_LMENU
Definition: winuser.h:2276
#define VK_RSHIFT
Definition: winuser.h:2273
BYTE afKeyState[256 *2/8]
Definition: msgqueue.h:84
unsigned char BYTE
Definition: xxhash.c:193
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
PIMEHOTKEY gpImeHotKeyList
Definition: ime.c:55
#define MOD_RIGHT
Definition: imm.h:324
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:99
#define VK_LCONTROL
Definition: winuser.h:2274
#define MOD_CONTROL
Definition: imm.h:320
LPARAM lParam
Definition: combotst.c:139
PIMEHOTKEY IntGetImeHotKeyByKey(PIMEHOTKEY pList, UINT uModKeys, UINT uLeftRight, UINT uVirtualKey)
Definition: ime.c:228

Referenced by IntImmProcessKey(), and NtUserCheckImeHotKey().

◆ IntCheckImeShowStatus()

BOOL FASTCALL IntCheckImeShowStatus ( PWND  pwndIme,
PTHREADINFO  pti 
)

Definition at line 2132 of file ime.c.

2133 {
2134  BOOL ret = FALSE, bDifferent;
2135  PWINDOWLIST pwl;
2136  HWND *phwnd;
2137  PWND pwndNode, pwndIMC;
2138  PTHREADINFO ptiCurrent = GetW32ThreadInfo();
2139  PIMEUI pimeui;
2140  IMEUI SafeImeUI;
2141 
2142  if (pwndIme->state2 & WNDS2_INDESTROY)
2143  return FALSE;
2144 
2145  // Build a window list
2146  pwl = IntBuildHwndList(pwndIme->spwndParent->spwndChild, IACE_LIST, NULL);
2147  if (!pwl)
2148  return FALSE;
2149 
2150  ret = TRUE;
2151  for (phwnd = pwl->ahwnd; *phwnd != HWND_TERMINATOR; ++phwnd)
2152  {
2153  pwndNode = ValidateHwndNoErr(*phwnd);
2154 
2155  if (!pwndNode || pwndIme == pwndNode)
2156  continue;
2157 
2158  if (pwndNode->pcls->atomClassName != gpsi->atomSysClass[ICLS_IME] ||
2159  (pwndNode->state2 & WNDS2_INDESTROY))
2160  {
2161  continue;
2162  }
2163 
2164  pimeui = ((PIMEWND)pwndNode)->pimeui;
2165  if (!pimeui || pimeui == (PIMEUI)-1)
2166  continue;
2167 
2168  if (pti && pti != pwndNode->head.pti)
2169  continue;
2170 
2171  // Attach to the process if necessary
2172  bDifferent = FALSE;
2173  if (pwndNode->head.pti->ppi != ptiCurrent->ppi)
2174  {
2175  KeAttachProcess(&(pwndNode->head.pti->ppi->peProcess->Pcb));
2176  bDifferent = TRUE;
2177  }
2178 
2179  // Get pwndIMC and update IMEUI.fShowStatus flag
2180  _SEH2_TRY
2181  {
2182  ProbeForWrite(pimeui, sizeof(IMEUI), 1);
2183  SafeImeUI = *pimeui;
2184  if (SafeImeUI.fShowStatus)
2185  {
2186  pwndIMC = ValidateHwndNoErr(pimeui->hwndIMC);
2187  if (pwndIMC)
2188  pimeui->fShowStatus = FALSE;
2189  }
2190  else
2191  {
2192  pwndIMC = NULL;
2193  }
2194  }
2196  {
2197  pwndIMC = NULL;
2198  }
2199  _SEH2_END;
2200 
2201  // Detach from the process if necessary
2202  if (bDifferent)
2203  KeDetachProcess();
2204 
2205  // Send the WM_IME_NOTIFY message
2206  if (pwndIMC && pwndIMC->head.pti && !(pwndIMC->head.pti->TIF_flags & TIF_INCLEANUP))
2207  {
2208  HWND hImeWnd;
2210 
2211  UserRefObjectCo(pwndIMC, &Ref);
2212 
2213  hImeWnd = UserHMGetHandle(pwndIMC);
2215 
2216  UserDerefObjectCo(pwndIMC);
2217  }
2218  }
2219 
2220  // Free the window list
2221  IntFreeHwndList(pwl);
2222  return ret;
2223 }
#define HWND_TERMINATOR
Definition: window.h:82
#define WM_IME_NOTIFY
Definition: winuser.h:1820
#define IMN_CLOSESTATUSWINDOW
Definition: imm.h:521
#define TRUE
Definition: types.h:120
PSERVERINFO gpsi
Definition: imm.c:17
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
PWINDOWLIST FASTCALL IntBuildHwndList(PWND pwnd, DWORD dwFlags, PTHREADINFO pti)
Definition: window.c:1410
RTL_ATOM atomClassName
Definition: ntuser.h:551
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:84
#define IACE_LIST
Definition: window.h:105
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
THRDESKHEAD head
Definition: ntuser.h:674
Definition: object.h:3
VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget)
Definition: window.c:1456
HWND ahwnd[ANYSIZE_ARRAY]
Definition: window.h:90
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
int ret
#define ICLS_IME
Definition: ntuser.h:906
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
Definition: ntuser.h:672
struct _IMEWND * PIMEWND
_SEH2_END
Definition: create.c:4400
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582
#define NULL
Definition: types.h:112
UINT fShowStatus
Definition: ntuser.h:1216
struct _WND * spwndParent
Definition: ntuser.h:692
DWORD state2
Definition: ntuser.h:681
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
HWND hwndIMC
Definition: ntuser.h:1211
#define TIF_INCLEANUP
Definition: ntuser.h:254
#define WNDS2_INDESTROY
Definition: ntuser.h:631
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1031
PCLS pcls
Definition: ntuser.h:699

Referenced by IntNotifyImeShowStatus().

◆ IntDeleteImeHotKey()

static VOID FASTCALL IntDeleteImeHotKey ( PIMEHOTKEY ppList,
PIMEHOTKEY  pHotKey 
)
static

Definition at line 204 of file ime.c.

205 {
206  PIMEHOTKEY pNode;
207 
208  if (*ppList == pHotKey)
209  {
210  *ppList = pHotKey->pNext;
212  return;
213  }
214 
215  for (pNode = *ppList; pNode; pNode = pNode->pNext)
216  {
217  if (pNode->pNext == pHotKey)
218  {
219  pNode->pNext = pHotKey->pNext;
221  return;
222  }
223  }
224 }
struct tagIMEHOTKEY * pNext
Definition: ime.c:48
#define USERTAG_IMEHOTKEY
Definition: tags.h:239
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by IntSetImeHotKey().

◆ IntDestroyInputContext()

BOOL IntDestroyInputContext ( PIMC  pIMC)

Definition at line 1499 of file ime.c.

1500 {
1501  HIMC hIMC = UserHMGetHandle(pIMC);
1502  PTHREADINFO pti = pIMC->head.pti;
1503  PWND pwndChild;
1504  PWINDOWLIST pwl;
1505  HWND *phwnd;
1506  PWND pWnd;
1507 
1508  if (pti != gptiCurrent)
1509  {
1511  return FALSE;
1512  }
1513 
1514  if (pIMC == pti->spDefaultImc)
1515  {
1517  return FALSE;
1518  }
1519 
1520  pwndChild = pti->rpdesk->pDeskInfo->spwnd->spwndChild;
1521  pwl = IntBuildHwndList(pwndChild, IACE_LIST | IACE_CHILDREN, pti);
1522  if (pwl)
1523  {
1524  for (phwnd = pwl->ahwnd; *phwnd != HWND_TERMINATOR; ++phwnd)
1525  {
1526  pWnd = UserGetObjectNoErr(gHandleTable, *phwnd, TYPE_WINDOW);
1527  if (pWnd && pWnd->hImc == hIMC)
1529  }
1530 
1531  IntFreeHwndList(pwl);
1532  }
1533 
1535  return TRUE;
1536 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HWND_TERMINATOR
Definition: window.h:82
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717
struct tagIMC * spDefaultImc
Definition: win32.h:128
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:481
#define TRUE
Definition: types.h:120
PWINDOWLIST FASTCALL IntBuildHwndList(PWND pwnd, DWORD dwFlags, PTHREADINFO pti)
Definition: window.c:1410
HIMC hImc
Definition: ntuser.h:719
struct _DESKTOP * rpdesk
Definition: win32.h:88
#define IACE_LIST
Definition: window.h:105
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define IACE_CHILDREN
Definition: imm.h:581
VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget)
Definition: window.c:1456
HWND ahwnd[ANYSIZE_ARRAY]
Definition: window.h:90
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
DWORD HIMC
Definition: dimm.idl:75
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
Definition: ntuser.h:672
HIMC FASTCALL IntAssociateInputContext(PWND pWnd, PIMC pImc)
Definition: ime.c:507
THRDESKHEAD head
Definition: ntuser.h:192
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by NtUserDestroyInputContext().

◆ IntFindNonImeRelatedWndOfSameThread()

BOOL IntFindNonImeRelatedWndOfSameThread ( PWND  pwndParent,
PWND  pwndTarget 
)

Definition at line 1844 of file ime.c.

1845 {
1846  PWND pwnd, pwndOwner, pwndNode;
1847  PTHREADINFO ptiTarget = pwndTarget->head.pti;
1848 
1849  // For all the children of pwndParent, ...
1850  for (pwnd = pwndParent->spwndChild; pwnd; pwnd = pwnd->spwndNext)
1851  {
1852  if (pwnd == pwndTarget || pwnd->head.pti != ptiTarget || IS_WND_MENU(pwnd))
1853  continue;
1854 
1855  if (!IS_WND_CHILD(pwnd))
1856  {
1857  // Check if any IME-like owner.
1858  BOOL bFound1 = FALSE;
1859  for (pwndOwner = pwnd; pwndOwner; pwndOwner = pwndOwner->spwndOwner)
1860  {
1861  if (IS_WND_IMELIKE(pwndOwner))
1862  {
1863  bFound1 = TRUE;
1864  break;
1865  }
1866  }
1867  if (bFound1)
1868  continue; // Skip if any IME-like owner.
1869  }
1870 
1871  pwndNode = pwnd;
1872 
1873  if (IS_WND_CHILD(pwndNode))
1874  {
1875  // Check if any same-thread IME-like ancestor.
1876  BOOL bFound2 = FALSE;
1877  for (; IS_WND_CHILD(pwndNode); pwndNode = pwndNode->spwndParent)
1878  {
1879  if (pwndNode->head.pti != ptiTarget)
1880  break;
1881 
1882  if (IS_WND_IMELIKE(pwndNode))
1883  {
1884  bFound2 = TRUE;
1885  break;
1886  }
1887  }
1888  if (bFound2)
1889  continue;
1890  // Now, pwndNode is non-child or non-same-thread window.
1891  }
1892 
1893  if (!IS_WND_CHILD(pwndNode)) // pwndNode is non-child
1894  {
1895  // Check if any same-thread IME-like owner.
1896  BOOL bFound3 = FALSE;
1897  for (; pwndNode; pwndNode = pwndNode->spwndOwner)
1898  {
1899  if (pwndNode->head.pti != ptiTarget)
1900  break;
1901 
1902  if (IS_WND_IMELIKE(pwndNode))
1903  {
1904  bFound3 = TRUE;
1905  break;
1906  }
1907  }
1908  if (bFound3)
1909  continue;
1910  }
1911 
1912  return TRUE;
1913  }
1914 
1915  return FALSE;
1916 }
#define IS_WND_CHILD(pWnd)
Definition: window.h:107
#define IS_WND_MENU(pWnd)
Definition: window.h:108
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
struct _WND * spwndNext
Definition: ntuser.h:690
Definition: ntuser.h:672
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
struct _WND * spwndParent
Definition: ntuser.h:692
struct _WND * spwndChild
Definition: ntuser.h:693

Referenced by IntImeCanDestroyDefIMEforChild().

◆ IntFreeImeHotKeys()

VOID FASTCALL IntFreeImeHotKeys ( VOID  )

Definition at line 340 of file ime.c.

341 {
342  PIMEHOTKEY pNode, pNext;
343  for (pNode = gpImeHotKeyList; pNode; pNode = pNext)
344  {
345  pNext = pNode->pNext;
347  }
349 }
struct tagIMEHOTKEY * pNext
Definition: ime.c:48
#define USERTAG_IMEHOTKEY
Definition: tags.h:239
#define NULL
Definition: types.h:112
PIMEHOTKEY gpImeHotKeyList
Definition: ime.c:55
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by IntSetImeHotKey(), and UserProcessDestroy().

◆ IntGetActiveKeyboardLayout()

HKL FASTCALL IntGetActiveKeyboardLayout ( VOID  )

Definition at line 98 of file ime.c.

99 {
100  PTHREADINFO pti;
101 
103  {
104  pti = gpqForeground->spwndActive->head.pti;
105  if (pti && pti->KeyboardLayout)
106  return pti->KeyboardLayout->hkl;
107  }
108 
109  return UserGetKeyboardLayout(0);
110 }
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
THRDESKHEAD head
Definition: ntuser.h:674
HKL FASTCALL UserGetKeyboardLayout(DWORD dwThreadId)
Definition: kbdlayout.c:857
struct tagKL * KeyboardLayout
Definition: win32.h:86

Referenced by IntGetImeHotKeyByKey().

◆ IntGetImeCompatFlags()

DWORD FASTCALL IntGetImeCompatFlags ( PTHREADINFO  pti)

Definition at line 59 of file ime.c.

60 {
61  if (!pti)
63 
64  return pti->ppi->dwImeCompatFlags;
65 }
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
PPROCESSINFO ppi
Definition: win32.h:84
DWORD dwImeCompatFlags
Definition: win32.h:267

Referenced by IntImmProcessKey().

◆ IntGetImeHotKeyById()

static PIMEHOTKEY FASTCALL IntGetImeHotKeyById ( PIMEHOTKEY  pList,
DWORD  dwHotKeyId 
)
static

Definition at line 160 of file ime.c.

161 {
162  PIMEHOTKEY pNode;
163  for (pNode = pList; pNode; pNode = pNode->pNext)
164  {
165  if (pNode->dwHotKeyId == dwHotKeyId)
166  return pNode;
167  }
168  return NULL;
169 }
FxChildList * pList
struct tagIMEHOTKEY * pNext
Definition: ime.c:48
DWORD dwHotKeyId
Definition: ime.c:49
#define NULL
Definition: types.h:112

Referenced by IntSetImeHotKey(), and NtUserGetImeHotKey().

◆ IntGetImeHotKeyByKey()

PIMEHOTKEY IntGetImeHotKeyByKey ( PIMEHOTKEY  pList,
UINT  uModKeys,
UINT  uLeftRight,
UINT  uVirtualKey 
)

Definition at line 228 of file ime.c.

229 {
230  PIMEHOTKEY pNode, ret = NULL;
232  LANGID LangId;
234  BOOL fKorean = (PRIMARYLANGID(LOWORD(hKL)) == LANG_KOREAN);
235  UINT nScore, nMaxScore = 0;
236 
237  for (pNode = pList; pNode; pNode = pNode->pNext)
238  {
239  if (pNode->uVirtualKey != uVirtualKey)
240  continue;
241 
242  if ((pNode->uModifiers & MOD_IGNORE_ALL_MODIFIER))
243  {
244  ;
245  }
246  else if ((pNode->uModifiers & MOD_KEYS) != uModKeys)
247  {
248  continue;
249  }
250  else if ((pNode->uModifiers & uLeftRight) ||
251  (pNode->uModifiers & MOD_LEFT_RIGHT) == uLeftRight)
252  {
253  ;
254  }
255  else
256  {
257  continue;
258  }
259 
260  LangId = IntGetImeHotKeyLangId(pNode->dwHotKeyId);
261  nScore = IntGetImeHotKeyLanguageScore(hKL, LangId);
262  if (nScore >= 3)
263  return pNode;
264 
265  if (fKorean)
266  continue;
267 
268  if (nScore == 0)
269  {
272  {
273  if (LOWORD(pti->hklPrev) == LangId)
274  return pNode;
275  }
276  }
277 
278  if (nMaxScore < nScore)
279  {
280  nMaxScore = nScore;
281  ret = pNode;
282  }
283  }
284 
285  return ret;
286 }
#define IME_CHOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:331
WORD LANGID
Definition: typedefs.h:81
#define MOD_LEFT_RIGHT
Definition: ime.c:16
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
UINT uModifiers
Definition: ime.c:51
unsigned int BOOL
Definition: ntddk_ex.h:94
FxChildList * pList
struct tagIMEHOTKEY * pNext
Definition: ime.c:48
HKL hklPrev
Definition: win32.h:129
#define MOD_KEYS
Definition: ime.c:15
#define MOD_IGNORE_ALL_MODIFIER
Definition: imm.h:327
#define IME_THOTKEY_IME_NONIME_TOGGLE
Definition: imm.h:343
int ret
DWORD dwHotKeyId
Definition: ime.c:49
UINT_PTR HKL
Definition: msctf.idl:101
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
UINT uVirtualKey
Definition: ime.c:50
#define LANG_KOREAN
Definition: nls.h:84
#define LOWORD(l)
Definition: pedump.c:82
HKL FASTCALL IntGetActiveKeyboardLayout(VOID)
Definition: ime.c:98
#define PRIMARYLANGID(l)
Definition: nls.h:16
static LANGID FASTCALL IntGetImeHotKeyLangId(DWORD dwHotKeyId)
Definition: ime.c:113
UINT FASTCALL IntGetImeHotKeyLanguageScore(HKL hKL, LANGID HotKeyLangId)
Definition: ime.c:68

Referenced by IntCheckImeHotKey().

◆ IntGetImeHotKeyByKeyAndLang()

static PIMEHOTKEY APIENTRY IntGetImeHotKeyByKeyAndLang ( PIMEHOTKEY  pList,
UINT  uModKeys,
UINT  uLeftRight,
UINT  uVirtualKey,
LANGID  TargetLangId 
)
static

Definition at line 173 of file ime.c.

175 {
176  PIMEHOTKEY pNode;
177  LANGID LangID;
178  UINT uModifiers;
179 
180  for (pNode = pList; pNode; pNode = pNode->pNext)
181  {
182  if (pNode->uVirtualKey != uVirtualKey)
183  continue;
184 
186  if (LangID != TargetLangId)
187  continue;
188 
189  uModifiers = pNode->uModifiers;
190  if (uModifiers & MOD_IGNORE_ALL_MODIFIER)
191  return pNode;
192 
193  if ((uModifiers & MOD_KEYS) != uModKeys)
194  continue;
195 
196  if ((uModifiers & uLeftRight) || (uModifiers & MOD_LEFT_RIGHT) == uLeftRight)
197  return pNode;
198  }
199 
200  return NULL;
201 }
WORD LANGID
Definition: typedefs.h:81
#define MOD_LEFT_RIGHT
Definition: ime.c:16
UINT uModifiers
Definition: ime.c:51
FxChildList * pList
struct tagIMEHOTKEY * pNext
Definition: ime.c:48
#define MOD_KEYS
Definition: ime.c:15
#define MOD_IGNORE_ALL_MODIFIER
Definition: imm.h:327
DWORD dwHotKeyId
Definition: ime.c:49
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
UINT uVirtualKey
Definition: ime.c:50
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
static LANGID FASTCALL IntGetImeHotKeyLangId(DWORD dwHotKeyId)
Definition: ime.c:113

Referenced by IntSetImeHotKey().

◆ IntGetImeHotKeyLangId()

static LANGID FASTCALL IntGetImeHotKeyLangId ( DWORD  dwHotKeyId)
static

Definition at line 113 of file ime.c.

114 {
115 #define IME_CHOTKEY 0x10
116 #define IME_JHOTKEY 0x30
117 #define IME_KHOTKEY 0x50
118 #define IME_THOTKEY 0x70
119 #define IME_XHOTKEY 0x90
120  static const LANGID s_array[] =
121  {
122  /* 0x00 */ (WORD)-1,
123  /* 0x10 */ LANGID_CHINESE_SIMPLIFIED,
124  /* 0x20 */ LANGID_CHINESE_SIMPLIFIED,
125  /* 0x30 */ LANGID_JAPANESE,
126  /* 0x40 */ LANGID_JAPANESE,
127  /* 0x50 */ LANGID_KOREAN,
128  /* 0x60 */ LANGID_KOREAN,
129  /* 0x70 */ LANGID_CHINESE_TRADITIONAL,
130  /* 0x80 */ LANGID_CHINESE_TRADITIONAL
131  };
132 
133  if (IME_CHOTKEY <= dwHotKeyId && dwHotKeyId < IME_XHOTKEY)
134  return s_array[(dwHotKeyId & 0xF0) >> 4];
135  return LANGID_NEUTRAL;
136 }
#define LANGID_KOREAN
Definition: ime.c:20
#define LANGID_CHINESE_TRADITIONAL
Definition: ime.c:21
WORD LANGID
Definition: typedefs.h:81
#define LANGID_NEUTRAL
Definition: ime.c:22
#define LANGID_JAPANESE
Definition: ime.c:19
#define LANGID_CHINESE_SIMPLIFIED
Definition: ime.c:18
#define IME_CHOTKEY
#define IME_XHOTKEY
unsigned short WORD
Definition: ntddk_ex.h:93

Referenced by IntGetImeHotKeyByKey(), IntGetImeHotKeyByKeyAndLang(), and IntSetImeHotKey().

◆ IntGetImeHotKeyLanguageScore()

UINT FASTCALL IntGetImeHotKeyLanguageScore ( HKL  hKL,
LANGID  HotKeyLangId 
)

Definition at line 68 of file ime.c.

69 {
70  LCID lcid;
71 
72  if (HotKeyLangId == LANGID_NEUTRAL || HotKeyLangId == LOWORD(hKL))
73  return 3;
74 
75  _SEH2_TRY
76  {
77  lcid = NtCurrentTeb()->CurrentLocale;
78  }
80  {
82  }
83  _SEH2_END;
84 
85  if (HotKeyLangId == LANGIDFROMLCID(lcid))
86  return 2;
87 
88  if (glcidSystem == 0)
90 
91  if (HotKeyLangId == LANGIDFROMLCID(glcidSystem))
92  return 1;
93 
94  return 0;
95 }
#define MAKELCID(lgid, srtid)
NTSYSAPI NTSTATUS NTAPI ZwQueryDefaultLocale(_In_ BOOLEAN UserProfile, _Out_ PLCID DefaultLocaleId)
DWORD LCID
Definition: nls.h:13
#define LANGID_NEUTRAL
Definition: ime.c:22
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
#define SORT_DEFAULT
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define LANGIDFROMLCID(l)
Definition: nls.h:18
LCID glcidSystem
Definition: ime.c:56
_SEH2_END
Definition: create.c:4400
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define LOWORD(l)
Definition: pedump.c:82

Referenced by IntGetImeHotKeyByKey().

◆ IntGetLastTopMostWindowNoIME()

PWND FASTCALL IntGetLastTopMostWindowNoIME ( PWND  pImeWnd)

Definition at line 1222 of file ime.c.

1223 {
1224  PWND pwndNode, pwndOwner, pwndLastTopMost = NULL;
1225  BOOL bFound;
1226 
1227  pwndNode = UserGetDesktopWindow();
1228  if (!pwndNode || pwndNode->spwndChild == NULL)
1229  return NULL;
1230 
1231  for (pwndNode = pwndNode->spwndChild;
1232  pwndNode && (pwndNode->ExStyle & WS_EX_TOPMOST);
1233  pwndNode = pwndNode->spwndNext)
1234  {
1235  bFound = FALSE;
1236 
1237  if (IS_WND_IMELIKE(pwndNode)) // An IME-like window
1238  {
1239  // Search the IME window from owners
1240  for (pwndOwner = pwndNode; pwndOwner; pwndOwner = pwndOwner->spwndOwner)
1241  {
1242  if (pImeWnd == pwndOwner)
1243  {
1244  bFound = TRUE;
1245  break;
1246  }
1247  }
1248  }
1249 
1250  if (!bFound)
1251  pwndLastTopMost = pwndNode;
1252  }
1253 
1254  return pwndLastTopMost;
1255 }
DWORD ExStyle
Definition: ntuser.h:683
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WND * spwndOwner
Definition: ntuser.h:694
struct _WND * spwndNext
Definition: ntuser.h:690
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
#define WS_EX_TOPMOST
Definition: pedump.c:647
Definition: ntuser.h:672
#define NULL
Definition: types.h:112
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
struct _WND * spwndChild
Definition: ntuser.h:693

Referenced by IntImeSetTopMost().

◆ IntGetTopLevelWindow()

PWND FASTCALL IntGetTopLevelWindow ( PWND  pwnd)

Definition at line 495 of file ime.c.

496 {
497  if (!pwnd)
498  return NULL;
499 
500  while (pwnd->style & WS_CHILD)
501  pwnd = pwnd->spwndParent;
502 
503  return pwnd;
504 }
#define WS_CHILD
Definition: pedump.c:617
#define NULL
Definition: types.h:112
struct _WND * spwndParent
Definition: ntuser.h:692
DWORD style
Definition: ntuser.h:685

Referenced by NtUserSetImeOwnerWindow().

◆ IntImeCanDestroyDefIME()

BOOL FASTCALL IntImeCanDestroyDefIME ( PWND  pImeWnd,
PWND  pwndTarget 
)

Definition at line 2068 of file ime.c.

2069 {
2070  PWND pwndNode;
2071  PIMEUI pimeui;
2072  IMEUI SafeImeUI;
2073 
2074  pimeui = ((PIMEWND)pImeWnd)->pimeui;
2075  if (!pimeui || (LONG_PTR)pimeui == (LONG_PTR)-1)
2076  return FALSE;
2077 
2078  // Check IMEUI.fDestroy
2079  _SEH2_TRY
2080  {
2081  ProbeForRead(pimeui, sizeof(IMEUI), 1);
2082  SafeImeUI = *pimeui;
2083  if (SafeImeUI.fDestroy)
2084  return FALSE;
2085  }
2087  {
2088  NOTHING;
2089  }
2090  _SEH2_END;
2091 
2092  // Any ancestor of pImeWnd is pwndTarget?
2093  if (pImeWnd->spwndOwner)
2094  {
2095  for (pwndNode = pImeWnd->spwndOwner; pwndNode; pwndNode = pwndNode->spwndOwner)
2096  {
2097  if (pwndNode == pwndTarget)
2098  break;
2099  }
2100 
2101  if (!pwndNode)
2102  return FALSE;
2103  }
2104 
2105  // Any ancestor of pwndTarget is IME-like?
2106  for (pwndNode = pwndTarget; pwndNode; pwndNode = pwndNode->spwndOwner)
2107  {
2108  if (IS_WND_IMELIKE(pwndNode))
2109  return FALSE;
2110  }
2111 
2112  // Adjust the ordering and top-mode status
2113  IntImeSetFutureOwner(pImeWnd, pwndTarget);
2114  for (pwndNode = pImeWnd->spwndOwner; pwndNode; pwndNode = pwndNode->spwndNext)
2115  {
2116  if (pwndNode == pImeWnd)
2117  break;
2118  }
2119  if (pwndNode == pImeWnd)
2120  IntImeCheckTopmost(pImeWnd);
2121 
2122  // Is the owner of pImeWnd NULL or pwndTarget?
2123  if (pImeWnd->spwndOwner && pwndTarget != pImeWnd->spwndOwner)
2124  return FALSE;
2125 
2126  pImeWnd->spwndOwner = NULL;
2127  return TRUE;
2128 }
#define LONG_PTR
Definition: treelist.c:79
#define NOTHING
Definition: input_list.c:10
#define TRUE
Definition: types.h:120
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
struct _WND * spwndOwner
Definition: ntuser.h:694
UINT fDestroy
Definition: ntuser.h:1218
struct _WND * spwndNext
Definition: ntuser.h:690
VOID FASTCALL IntImeCheckTopmost(PWND pImeWnd)
Definition: ime.c:1349
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
Definition: ntuser.h:672
struct _IMEWND * PIMEWND
_SEH2_END
Definition: create.c:4400
VOID FASTCALL IntImeSetFutureOwner(PWND pImeWnd, PWND pwndOwner)
Definition: ime.c:1165
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define NULL
Definition: types.h:112
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40

Referenced by co_UserDestroyWindow().

◆ IntImeCanDestroyDefIMEforChild()

BOOL FASTCALL IntImeCanDestroyDefIMEforChild ( PWND  pImeWnd,
PWND  pwndTarget 
)

Definition at line 2023 of file ime.c.

2024 {
2025  PWND pwndNode;
2026  PIMEUI pimeui;
2027  IMEUI SafeImeUI;
2028 
2029  pimeui = ((PIMEWND)pImeWnd)->pimeui;
2030  if (!pimeui || (LONG_PTR)pimeui == (LONG_PTR)-1)
2031  return FALSE;
2032 
2033  // Check IMEUI.fChildThreadDef
2034  _SEH2_TRY
2035  {
2036  ProbeForRead(pimeui, sizeof(IMEUI), 1);
2037  SafeImeUI = *pimeui;
2038  if (!SafeImeUI.fChildThreadDef)
2039  return FALSE;
2040  }
2042  {
2043  NOTHING;
2044  }
2045  _SEH2_END;
2046 
2047  // The parent of pwndTarget is NULL or of the same thread of pwndTarget?
2048  if (pwndTarget->spwndParent == NULL ||
2049  pwndTarget->head.pti == pwndTarget->spwndParent->head.pti)
2050  {
2051  return FALSE;
2052  }
2053 
2054  for (pwndNode = pwndTarget; pwndNode; pwndNode = pwndNode->spwndParent)
2055  {
2056  if (pwndNode == pwndNode->head.rpdesk->pDeskInfo->spwnd)
2057  break;
2058 
2059  if (IntFindNonImeRelatedWndOfSameThread(pwndNode->spwndParent, pwndTarget))
2060  return FALSE;
2061  }
2062 
2063  return TRUE;
2064 }
#define LONG_PTR
Definition: treelist.c:79
#define NOTHING
Definition: input_list.c:10
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
#define TRUE
Definition: types.h:120
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
THRDESKHEAD head
Definition: ntuser.h:674
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
UINT fChildThreadDef
Definition: ntuser.h:1220
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
Definition: ntuser.h:672
struct _IMEWND * PIMEWND
BOOL IntFindNonImeRelatedWndOfSameThread(PWND pwndParent, PWND pwndTarget)
Definition: ime.c:1844
_SEH2_END
Definition: create.c:4400
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define NULL
Definition: types.h:112
struct _WND * spwndParent
Definition: ntuser.h:692
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40

Referenced by co_UserDestroyWindow().

◆ IntImeCheckTopmost()

VOID FASTCALL IntImeCheckTopmost ( PWND  pImeWnd)

Definition at line 1349 of file ime.c.

1350 {
1351  BOOL bTopMost;
1352  PWND pwndOwner = pImeWnd->spwndOwner, pwndInsertBefore = NULL;
1353 
1354  if (!pwndOwner)
1355  return;
1356 
1357  if (pImeWnd->head.pti != gptiForeground)
1358  pwndInsertBefore = pwndOwner;
1359 
1360  bTopMost = !!(pwndOwner->ExStyle & WS_EX_TOPMOST);
1361  IntImeSetTopMost(pImeWnd, bTopMost, pwndInsertBefore);
1362 }
DWORD ExStyle
Definition: ntuser.h:683
PTHREADINFO gptiForeground
Definition: focus.c:15
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
#define WS_EX_TOPMOST
Definition: pedump.c:647
Definition: ntuser.h:672
#define NULL
Definition: types.h:112
VOID FASTCALL IntImeSetTopMost(PWND pImeWnd, BOOL bTopMost, PWND pwndInsertBefore)
Definition: ime.c:1259

Referenced by IntImeCanDestroyDefIME(), and NtUserSetImeOwnerWindow().

◆ IntImeSetFutureOwner()

VOID FASTCALL IntImeSetFutureOwner ( PWND  pImeWnd,
PWND  pwndOwner 
)

Definition at line 1165 of file ime.c.

1166 {
1167  PWND pwndNode, pwndNextOwner, pwndParent, pwndSibling;
1168  PTHREADINFO pti = pImeWnd->head.pti;
1169 
1170  if (!pwndOwner || (pwndOwner->style & WS_CHILD)) // invalid owner
1171  return;
1172 
1173  // Get the top-level owner of the same thread
1174  for (pwndNode = pwndOwner; ; pwndNode = pwndNextOwner)
1175  {
1176  pwndNextOwner = pwndNode->spwndOwner;
1177  if (!pwndNextOwner || pwndNextOwner->head.pti != pti)
1178  break;
1179  }
1180 
1181  // Don't choose the IME-like windows and the bottom-most windows unless necessary.
1182  if (IS_WND_IMELIKE(pwndNode) ||
1183  ((pwndNode->state2 & WNDS2_BOTTOMMOST) && !(pwndOwner->state2 & WNDS2_BOTTOMMOST)))
1184  {
1185  pwndNode = pwndOwner;
1186  }
1187 
1188  pwndParent = pwndNode->spwndParent;
1189  if (!pwndParent || pwndOwner != pwndNode)
1190  {
1191  pImeWnd->spwndOwner = pwndNode;
1192  return;
1193  }
1194 
1195  for (pwndSibling = pwndParent->spwndChild; pwndSibling; pwndSibling = pwndSibling->spwndNext)
1196  {
1197  if (pwndNode->head.pti != pwndSibling->head.pti)
1198  continue;
1199 
1200  if (IS_WND_MENU(pwndSibling) || IS_WND_IMELIKE(pwndSibling))
1201  continue;
1202 
1203  if (pwndSibling->state2 & WNDS2_INDESTROY)
1204  continue;
1205 
1206  if (pwndNode == pwndSibling || (pwndSibling->style & WS_CHILD))
1207  continue;
1208 
1209  if (pwndSibling->spwndOwner == NULL ||
1210  pwndSibling->head.pti != pwndSibling->spwndOwner->head.pti)
1211  {
1212  pwndNode = pwndSibling;
1213  break;
1214  }
1215  }
1216 
1217  pImeWnd->spwndOwner = pwndNode;
1218 }
#define IS_WND_MENU(pWnd)
Definition: window.h:108
#define WNDS2_BOTTOMMOST
Definition: ntuser.h:629
#define WS_CHILD
Definition: pedump.c:617
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
struct _WND * spwndNext
Definition: ntuser.h:690
Definition: ntuser.h:672
#define NULL
Definition: types.h:112
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
struct _WND * spwndParent
Definition: ntuser.h:692
DWORD state2
Definition: ntuser.h:681
struct _WND * spwndChild
Definition: ntuser.h:693
#define WNDS2_INDESTROY
Definition: ntuser.h:631
DWORD style
Definition: ntuser.h:685

Referenced by IntImeCanDestroyDefIME(), and NtUserSetImeOwnerWindow().

◆ IntImeSetTopMost()

VOID FASTCALL IntImeSetTopMost ( PWND  pImeWnd,
BOOL  bTopMost,
PWND  pwndInsertBefore 
)

Definition at line 1259 of file ime.c.

1260 {
1261  PWND pwndParent, pwndChild, pwndNode, pwndNext, pwndInsertAfter = NULL;
1262  PWND pwndInsertAfterSave;
1263 
1264  pwndParent = pImeWnd->spwndParent;
1265  if (!pwndParent)
1266  return;
1267 
1268  pwndChild = pwndParent->spwndChild;
1269 
1270  if (!bTopMost)
1271  {
1272  // Calculate pwndInsertAfter
1273  pwndInsertAfter = IntGetLastTopMostWindowNoIME(pImeWnd);
1274  if (pwndInsertBefore)
1275  {
1276  for (pwndNode = pwndInsertAfter; pwndNode; pwndNode = pwndNode->spwndNext)
1277  {
1278  if (pwndNode->spwndNext == pwndInsertBefore)
1279  break;
1280 
1281  if (pwndNode == pImeWnd)
1282  return;
1283  }
1284 
1285  if (!pwndNode)
1286  return;
1287 
1288  pwndInsertAfter = pwndNode;
1289  }
1290 
1291  // Adjust pwndInsertAfter if the owner is bottom-most
1292  if (pImeWnd->spwndOwner->state2 & WNDS2_BOTTOMMOST)
1293  {
1294  for (pwndNode = pwndInsertAfter; pwndNode; pwndNode = pwndNode->spwndNext)
1295  {
1296  if (pwndNode == pImeWnd->spwndOwner)
1297  break;
1298 
1299  if (!IS_WND_IMELIKE(pwndNode))
1300  pwndInsertAfter = pwndNode;
1301  }
1302  }
1303  }
1304 
1305  pwndInsertAfterSave = pwndInsertAfter;
1306 
1307  while (pwndChild)
1308  {
1309  pwndNext = pwndChild->spwndNext;
1310 
1311  // If pwndChild is a good IME-like window, ...
1312  if (IS_WND_IMELIKE(pwndChild) && pwndChild != pwndInsertAfter &&
1313  pwndChild->head.pti == pImeWnd->head.pti)
1314  {
1315  // Find pImeWnd from the owners
1316  for (pwndNode = pwndChild; pwndNode; pwndNode = pwndNode->spwndOwner)
1317  {
1318  if (pwndNode != pImeWnd)
1319  continue;
1320 
1321  // Adjust the ordering and the linking
1322  IntUnlinkWindow(pwndChild);
1323 
1324  if (bTopMost)
1325  pwndChild->ExStyle |= WS_EX_TOPMOST;
1326  else
1327  pwndChild->ExStyle &= ~WS_EX_TOPMOST;
1328 
1329  if (!pwndInsertAfter)
1330  IntLinkHwnd(pwndChild, HWND_TOP);
1331  else
1332  IntLinkHwnd(pwndChild, UserHMGetHandle(pwndInsertAfter));
1333 
1334  // Update the preferred position
1335  pwndInsertAfter = pwndChild;
1336  break;
1337  }
1338  }
1339 
1340  // Get the next child, with ignoring pwndInsertAfterSave
1341  pwndChild = pwndNext;
1342  if (pwndChild && pwndChild == pwndInsertAfterSave && pwndInsertAfter)
1343  pwndChild = pwndInsertAfter->spwndNext;
1344  }
1345 }
DWORD ExStyle
Definition: ntuser.h:683
VOID FASTCALL IntUnlinkWindow(PWND Wnd)
Definition: window.c:1341
#define WNDS2_BOTTOMMOST
Definition: ntuser.h:629
PWND FASTCALL IntGetLastTopMostWindowNoIME(PWND pImeWnd)
Definition: ime.c:1222
#define HWND_TOP
Definition: winuser.h:1197
VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
Definition: window.c:971
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
struct _WND * spwndNext
Definition: ntuser.h:690
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define WS_EX_TOPMOST
Definition: pedump.c:647
Definition: ntuser.h:672
#define NULL
Definition: types.h:112
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
struct _WND * spwndParent
Definition: ntuser.h:692
struct _WND * spwndChild
Definition: ntuser.h:693

Referenced by IntImeCheckTopmost().

◆ IntImmProcessKey()

UINT FASTCALL IntImmProcessKey ( PUSER_MESSAGE_QUEUE  MessageQueue,
PWND  pWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 578 of file ime.c.

580 {
581  UINT uVirtualKey, ret = 0;
582  DWORD dwHotKeyId;
583  PKL pKL;
584  PIMC pIMC = NULL;
585  PIMEHOTKEY pImeHotKey;
586  HKL hKL;
587  HWND hWnd;
588 
589  ASSERT_REFS_CO(pWnd);
590 
591  switch (uMsg)
592  {
593  case WM_KEYDOWN:
594  case WM_KEYUP:
595  case WM_SYSKEYDOWN:
596  case WM_SYSKEYUP:
597  break;
598 
599  default:
600  return 0;
601  }
602 
603  hWnd = UserHMGetHandle(pWnd);
604  pKL = pWnd->head.pti->KeyboardLayout;
605  if (!pKL)
606  return 0;
607 
608  uVirtualKey = LOBYTE(wParam);
609  pImeHotKey = IntCheckImeHotKey(MessageQueue, uVirtualKey, lParam);
610  if (pImeHotKey)
611  {
612  dwHotKeyId = pImeHotKey->dwHotKeyId;
613  hKL = pImeHotKey->hKL;
614  }
615  else
616  {
617  dwHotKeyId = INVALID_HOTKEY;
618  hKL = NULL;
619  }
620 
621  if (IME_HOTKEY_DSWITCH_FIRST <= dwHotKeyId && dwHotKeyId <= IME_HOTKEY_DSWITCH_LAST)
622  {
623  if (pKL->hkl != hKL)
624  {
625  UserPostMessage(hWnd, WM_INPUTLANGCHANGEREQUEST,
626  ((pKL->dwFontSigs & gSystemFS) ? INPUTLANGCHANGE_SYSCHARSET : 0),
627  (LPARAM)hKL);
628  }
629 
630  if (IntGetImeCompatFlags(pWnd->head.pti) & 0x800000)
631  return 0;
632 
633  return IPHK_HOTKEY;
634  }
635 
636  if (!IS_IMM_MODE())
637  return 0;
638 
639  if (dwHotKeyId == INVALID_HOTKEY)
640  {
641  if (!pKL->piiex)
642  return 0;
643 
644  if (pWnd->hImc)
646  if (!pIMC)
647  return 0;
648 
649  if ((lParam & 0x80000000) &&
651  {
652  return 0;
653  }
654 
655  switch (uVirtualKey)
656  {
657  case VK_DBE_CODEINPUT:
660  case VK_DBE_HIRAGANA:
661  case VK_DBE_KATAKANA:
662  case VK_DBE_NOCODEINPUT:
663  case VK_DBE_NOROMAN:
664  case VK_DBE_ROMAN:
665  break;
666 
667  default:
668  {
669  if (uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP)
670  {
671  if (uVirtualKey != VK_MENU && uVirtualKey != VK_F10)
672  return 0;
673  }
674 
676  {
677  if (uVirtualKey == VK_MENU || (lParam & 0x20000000))
678  return 0;
679  }
680  break;
681  }
682  }
683  }
684 
685  if (LOBYTE(uVirtualKey) == VK_PACKET)
686  uVirtualKey = MAKELONG(wParam, GetW32ThreadInfo()->wchInjected);
687 
688  ret = co_IntImmProcessKey(hWnd, pKL->hkl, uVirtualKey, lParam, dwHotKeyId);
689 
690  if (IntGetImeCompatFlags(pWnd->head.pti) & 0x800000)
691  ret &= ~IPHK_HOTKEY;
692 
693  return ret;
694 }
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
#define LOBYTE(W)
Definition: jmemdos.c:487
DWORD APIENTRY co_IntImmProcessKey(HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD dwHotKeyID)
Definition: callback.c:1253
#define IS_IMM_MODE()
Definition: ntuser.h:1204
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
#define VK_DBE_ENTERWORDREGISTERMODE
Definition: ime.c:33
Definition: ntuser.h:190
HWND hWnd
Definition: settings.c:17
#define VK_DBE_HIRAGANA
Definition: ime.c:28
PIMEINFOEX piiex
Definition: input.h:38
#define VK_MENU
Definition: winuser.h:2194
HIMC hImc
Definition: ntuser.h:719
WPARAM wParam
Definition: combotst.c:138
#define IME_PROP_NEED_ALTKEY
Definition: imm.h:216
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
#define VK_F10
Definition: winuser.h:2254
HKL hKL
Definition: ime.c:52
#define VK_DBE_ROMAN
Definition: ime.c:31
#define VK_DBE_KATAKANA
Definition: ime.c:27
#define INVALID_HOTKEY
Definition: ime.c:14
THRDESKHEAD head
Definition: ntuser.h:674
#define IME_HOTKEY_DSWITCH_LAST
Definition: imm.h:349
#define MAKELONG(a, b)
Definition: typedefs.h:249
DWORD gSystemFS
Definition: kbdlayout.c:24
Definition: input.h:26
#define WM_KEYDOWN
Definition: winuser.h:1705
LONG_PTR LPARAM
Definition: windef.h:208
#define IME_PROP_IGNORE_UPKEYS
Definition: imm.h:215
#define VK_DBE_CODEINPUT
Definition: ime.c:36
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
DWORD fdwProperty
Definition: imm.h:158
HKL hkl
Definition: input.h:32
#define WM_KEYUP
Definition: winuser.h:1706
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VK_DBE_ENTERCONFIGMODE
Definition: ime.c:34
int ret
DWORD dwFontSigs
Definition: input.h:34
DWORD dwHotKeyId
Definition: ime.c:49
#define VK_DBE_NOROMAN
Definition: ime.c:32
UINT_PTR HKL
Definition: msctf.idl:101
IMEINFO ImeInfo
Definition: ntuser.h:1179
#define IME_HOTKEY_DSWITCH_FIRST
Definition: imm.h:348
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
#define WM_SYSKEYUP
Definition: winuser.h:1710
#define VK_DBE_NOCODEINPUT
Definition: ime.c:37
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define IPHK_HOTKEY
Definition: undocuser.h:138
#define WM_SYSKEYDOWN
Definition: winuser.h:1709
PIMEHOTKEY IntCheckImeHotKey(PUSER_MESSAGE_QUEUE MessageQueue, UINT uVirtualKey, LPARAM lParam)
Definition: ime.c:289
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
LPARAM lParam
Definition: combotst.c:139
DWORD FASTCALL IntGetImeCompatFlags(PTHREADINFO pti)
Definition: ime.c:59

Referenced by co_IntProcessKeyboardMessage().

◆ IntNotifyImeShowStatus()

VOID FASTCALL IntNotifyImeShowStatus ( PWND  pImeWnd)

Definition at line 2327 of file ime.c.

2328 {
2329  PIMEUI pimeui;
2330  PWND pWnd;
2331  PTHREADINFO pti, ptiIME;
2332  BOOL bShow, bSendNotify = FALSE;
2333  IMEUI SafeImeUI;
2334 
2335  if (!IS_IMM_MODE() || (pImeWnd->state2 & WNDS2_INDESTROY))
2336  return;
2337 
2339  ptiIME = pImeWnd->head.pti;
2340 
2341  // Attach to the process if necessary
2342  if (pti != ptiIME)
2343  KeAttachProcess(&(ptiIME->ppi->peProcess->Pcb));
2344 
2345  // Get an IMEUI and check whether hwndIMC is valid and update fShowStatus
2346  _SEH2_TRY
2347  {
2348  ProbeForWrite(pImeWnd, sizeof(IMEWND), 1);
2349  pimeui = ((PIMEWND)pImeWnd)->pimeui;
2350  SafeImeUI = *pimeui;
2351 
2352  bShow = (gfIMEShowStatus == TRUE) && SafeImeUI.fCtrlShowStatus;
2353 
2354  pWnd = ValidateHwndNoErr(SafeImeUI.hwndIMC);
2355  if (!pWnd)
2356  pWnd = ptiIME->MessageQueue->spwndFocus;
2357 
2358  if (pWnd)
2359  {
2360  bSendNotify = TRUE;
2361  pimeui->fShowStatus = bShow;
2362  }
2363  }
2365  {
2366  if (pti != ptiIME)
2367  KeDetachProcess();
2368  return;
2369  }
2370  _SEH2_END;
2371 
2372  // Detach from the process if necessary
2373  if (pti != ptiIME)
2374  KeDetachProcess();
2375 
2376  if (bSendNotify)
2377  IntSendOpenStatusNotify(ptiIME, &SafeImeUI, pWnd, bShow);
2378 
2379  if (!(pImeWnd->state2 & WNDS2_INDESTROY))
2380  IntCheckImeShowStatus(pImeWnd, NULL);
2381 }
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
PPROCESSINFO ppi
Definition: win32.h:84
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:674
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
BOOL gfIMEShowStatus
Definition: ime.c:44
Definition: ntuser.h:672
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:85
struct _IMEWND * PIMEWND
_SEH2_END
Definition: create.c:4400
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582
BOOL FASTCALL IntCheckImeShowStatus(PWND pwndIme, PTHREADINFO pti)
Definition: ime.c:2132
VOID FASTCALL IntSendOpenStatusNotify(PTHREADINFO ptiIME, PIMEUI pimeui, PWND pWnd, BOOL bOpen)
Definition: ime.c:2307
#define NULL
Definition: types.h:112
UINT fShowStatus
Definition: ntuser.h:1216
DWORD state2
Definition: ntuser.h:681
UINT fCtrlShowStatus
Definition: ntuser.h:1221
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
HWND hwndIMC
Definition: ntuser.h:1211
#define WNDS2_INDESTROY
Definition: ntuser.h:631

Referenced by IntBroadcastImeShowStatusChange().

◆ IntSendMessageToUI()

LRESULT FASTCALL IntSendMessageToUI ( PTHREADINFO  ptiIME,
PIMEUI  pimeui,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 2228 of file ime.c.

2229 {
2230  PWND pwndUI;
2231  LRESULT ret = 0;
2232  IMEUI SafeImeUI;
2233  BOOL bDifferent = FALSE;
2235 
2236  // Attach to the process if necessary
2237  if (ptiIME != GetW32ThreadInfo())
2238  {
2239  bDifferent = TRUE;
2240  KeAttachProcess(&(ptiIME->ppi->peProcess->Pcb));
2241  }
2242 
2243  // Get the pwndUI
2244  _SEH2_TRY
2245  {
2246  ProbeForRead(pimeui, sizeof(IMEUI), 1);
2247  SafeImeUI = *pimeui;
2248  pwndUI = ValidateHwndNoErr(SafeImeUI.hwndUI);
2249  }
2251  {
2252  pwndUI = NULL;
2253  }
2254  _SEH2_END;
2255 
2256  if (!pwndUI)
2257  goto Quit;
2258 
2259  // Increment the recursion count of the IME procedure.
2260  // See also ImeWndProc_common of user32.
2261  _SEH2_TRY
2262  {
2263  ProbeForWrite(&pimeui->nCntInIMEProc, sizeof(LONG), 1);
2265  }
2267  {
2268  goto Quit;
2269  }
2270  _SEH2_END;
2271 
2272  // Detach from the process if necessary
2273  if (bDifferent)
2274  KeDetachProcess();
2275 
2276  UserRefObjectCo(pwndUI, &Ref);
2277  ret = co_IntSendMessage(UserHMGetHandle(pwndUI), uMsg, wParam, lParam);
2278  UserDerefObjectCo(pwndUI);
2279 
2280  // Attach to the process if necessary
2281  if (bDifferent)
2282  KeAttachProcess(&(ptiIME->ppi->peProcess->Pcb));
2283 
2284  // Decrement the recursion count of the IME procedure
2285  _SEH2_TRY
2286  {
2287  ProbeForWrite(&pimeui->nCntInIMEProc, sizeof(LONG), 1);
2289  }
2291  {
2292  goto Quit;
2293  }
2294  _SEH2_END;
2295 
2296 Quit:
2297  // Detach from the process if necessary
2298  if (bDifferent)
2299  KeDetachProcess();
2300 
2301  return ret;
2302 }
#define TRUE
Definition: types.h:120
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
LONG nCntInIMEProc
Definition: ntuser.h:1214
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
WPARAM wParam
Definition: combotst.c:138
_SEH2_TRY
Definition: create.c:4226
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:84
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
HWND hwndUI
Definition: ntuser.h:1213
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
Definition: object.h:3
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
VOID NTAPI KeDetachProcess(VOID)
Definition: procobj.c:621
int ret
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define InterlockedDecrement
Definition: armddk.h:52
Definition: ntuser.h:672
_SEH2_END
Definition: create.c:4400
#define InterlockedIncrement
Definition: armddk.h:53
VOID NTAPI KeAttachProcess(IN PKPROCESS Process)
Definition: procobj.c:582
#define NULL
Definition: types.h:112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

Referenced by IntSendOpenStatusNotify().

◆ IntSendOpenStatusNotify()

VOID FASTCALL IntSendOpenStatusNotify ( PTHREADINFO  ptiIME,
PIMEUI  pimeui,
PWND  pWnd,
BOOL  bOpen 
)

Definition at line 2307 of file ime.c.

2308 {
2310  PTHREADINFO ptiWnd = pWnd->head.pti;
2312 
2313  if (ptiWnd->dwExpWinVer >= WINVER_WINNT4 && pWnd->hImc)
2314  {
2315  UserRefObjectCo(pWnd, &Ref);
2317  UserDerefObjectCo(pWnd);
2318  }
2319  else
2320  {
2321  IntSendMessageToUI(ptiIME, pimeui, WM_IME_NOTIFY, wParam, 0);
2322  }
2323 }
#define WM_IME_NOTIFY
Definition: winuser.h:1820
#define IMN_CLOSESTATUSWINDOW
Definition: imm.h:521
#define IMN_OPENSTATUSWINDOW
Definition: imm.h:522
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
Definition: object.h:27
UINT_PTR WPARAM
Definition: windef.h:207
HIMC hImc
Definition: ntuser.h:719
WPARAM wParam
Definition: combotst.c:138
#define WINVER_WINNT4
Definition: window.h:56
static __inline VOID UserDerefObjectCo(PVOID obj)
Definition: object.h:40
THRDESKHEAD head
Definition: ntuser.h:674
Definition: object.h:3
DWORD dwExpWinVer
Definition: win32.h:108
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
LRESULT FASTCALL IntSendMessageToUI(PTHREADINFO ptiIME, PIMEUI pimeui, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ime.c:2228

Referenced by IntNotifyImeShowStatus().

◆ IntSetImeHotKey()

static BOOL APIENTRY IntSetImeHotKey ( DWORD  dwHotKeyId,
UINT  uModifiers,
UINT  uVirtualKey,
HKL  hKL,
DWORD  dwAction 
)
static

Definition at line 353 of file ime.c.

354 {
355  PIMEHOTKEY pNode;
356  LANGID LangId;
357 
358  switch (dwAction)
359  {
360  case SETIMEHOTKEY_DELETE:
361  pNode = IntGetImeHotKeyById(gpImeHotKeyList, dwHotKeyId);
362  if (!pNode)
363  {
364  ERR("dwHotKeyId: 0x%lX\n", dwHotKeyId);
365  return FALSE;
366  }
367 
369  return TRUE;
370 
371  case SETIMEHOTKEY_ADD:
372  if (uVirtualKey == VK_PACKET)
373  return FALSE;
374 
375  LangId = IntGetImeHotKeyLangId(dwHotKeyId);
376  if (LangId == LANGID_KOREAN)
377  return FALSE;
378 
380  (uModifiers & MOD_KEYS),
381  (uModifiers & MOD_LEFT_RIGHT),
382  uVirtualKey, LangId);
383  if (!pNode)
384  pNode = IntGetImeHotKeyById(gpImeHotKeyList, dwHotKeyId);
385 
386  if (pNode)
387  {
388  pNode->uModifiers = uModifiers;
389  pNode->uVirtualKey = uVirtualKey;
390  pNode->hKL = hKL;
391  return TRUE;
392  }
393 
395  if (!pNode)
396  return FALSE;
397 
398  pNode->pNext = NULL;
399  pNode->dwHotKeyId = dwHotKeyId;
400  pNode->uModifiers = uModifiers;
401  pNode->uVirtualKey = uVirtualKey;
402  pNode->hKL = hKL;
404  return TRUE;
405 
408  return TRUE;
409 
410  default:
411  return FALSE;
412  }
413 }
static PIMEHOTKEY APIENTRY IntGetImeHotKeyByKeyAndLang(PIMEHOTKEY pList, UINT uModKeys, UINT uLeftRight, UINT uVirtualKey, LANGID TargetLangId)
Definition: ime.c:173
#define LANGID_KOREAN
Definition: ime.c:20
#define TRUE
Definition: types.h:120
WORD LANGID
Definition: typedefs.h:81
#define MOD_LEFT_RIGHT
Definition: ime.c:16
HKL hKL
Definition: ime.c:52
#define FALSE
Definition: types.h:117
UINT uModifiers
Definition: ime.c:51
struct tagIMEHOTKEY * pNext
Definition: ime.c:48
#define MOD_KEYS
Definition: ime.c:15
static VOID FASTCALL IntDeleteImeHotKey(PIMEHOTKEY *ppList, PIMEHOTKEY pHotKey)
Definition: ime.c:204
static VOID FASTCALL IntAddImeHotKey(PIMEHOTKEY *ppList, PIMEHOTKEY pHotKey)
Definition: ime.c:139
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
DWORD dwHotKeyId
Definition: ime.c:49
#define ERR(fmt,...)
Definition: debug.h:110
#define USERTAG_IMEHOTKEY
Definition: tags.h:239
#define NULL
Definition: types.h:112
PIMEHOTKEY gpImeHotKeyList
Definition: ime.c:55
UINT uVirtualKey
Definition: ime.c:50
static PIMEHOTKEY FASTCALL IntGetImeHotKeyById(PIMEHOTKEY pList, DWORD dwHotKeyId)
Definition: ime.c:160
VOID FASTCALL IntFreeImeHotKeys(VOID)
Definition: ime.c:340
static LANGID FASTCALL IntGetImeHotKeyLangId(DWORD dwHotKeyId)
Definition: ime.c:113

Referenced by NtUserSetImeHotKey().

◆ IntWantImeWindow()

BOOL FASTCALL IntWantImeWindow ( PWND  pwndTarget)

Definition at line 1920 of file ime.c.

1921 {
1922  PDESKTOP rpdesk;
1923  PWINSTATION_OBJECT rpwinstaParent;
1924  PWND pwndNode, pwndParent = pwndTarget->spwndParent;
1925 
1927  return FALSE;
1928 
1929  if (IS_WND_IMELIKE(pwndTarget))
1930  return FALSE;
1931 
1932  if (pwndTarget->fnid == FNID_DESKTOP || pwndTarget->fnid == FNID_MESSAGEWND)
1933  return FALSE;
1934 
1935  if (pwndTarget->state & WNDS_SERVERSIDEWINDOWPROC)
1936  return FALSE;
1937 
1938  rpdesk = pwndTarget->head.rpdesk;
1939  if (!rpdesk)
1940  return FALSE;
1941 
1942  rpwinstaParent = rpdesk->rpwinstaParent;
1943  if (!rpwinstaParent || (rpwinstaParent->Flags & WSS_NOIO))
1944  return FALSE;
1945 
1946  for (pwndNode = pwndParent; pwndNode; pwndNode = pwndNode->spwndParent)
1947  {
1948  if (rpdesk != pwndNode->head.rpdesk)
1949  break;
1950 
1951  if (pwndNode == rpdesk->spwndMessage)
1952  return FALSE;
1953  }
1954 
1955  return TRUE;
1956 }
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
#define TRUE
Definition: types.h:120
FLONG TIF_flags
Definition: win32.h:91
#define FNID_MESSAGEWND
Definition: ntuser.h:843
#define FALSE
Definition: types.h:117
DWORD fnid
Definition: ntuser.h:688
#define FNID_DESKTOP
Definition: ntuser.h:841
THRDESKHEAD head
Definition: ntuser.h:674
#define WSS_NOIO
Definition: winsta.h:9
struct _WINSTATION_OBJECT * rpwinstaParent
Definition: desktop.h:11
PTHREADINFO gptiCurrent
Definition: ntuser.c:15
#define TIF_DISABLEIME
Definition: ntuser.h:279
PWND spwndMessage
Definition: desktop.h:20
Definition: ntuser.h:672
DWORD state
Definition: ntuser.h:680
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
struct _WND * spwndParent
Definition: ntuser.h:692
#define WNDS_SERVERSIDEWINDOWPROC
Definition: ntuser.h:606

Referenced by IntCreateWindow().

◆ NtUserAssociateInputContext()

DWORD NTAPI NtUserAssociateInputContext ( HWND  hWnd,
HIMC  hIMC,
DWORD  dwFlags 
)

Definition at line 1705 of file ime.c.

1706 {
1707  DWORD ret = 2;
1708  PWND pWnd;
1709  PIMC pIMC;
1710 
1712 
1713  if (!IS_IMM_MODE())
1714  {
1715  ERR("!IS_IMM_MODE()\n");
1716  goto Quit;
1717  }
1718 
1719  pWnd = ValidateHwndNoErr(hWnd);
1720  if (!pWnd)
1721  goto Quit;
1722 
1723  pIMC = (hIMC ? UserGetObjectNoErr(gHandleTable, hIMC, TYPE_INPUTCONTEXT) : NULL);
1724  ret = IntAssociateInputContextEx(pWnd, pIMC, dwFlags);
1725 
1726 Quit:
1727  UserLeave();
1728  return ret;
1729 }
DWORD FASTCALL IntAssociateInputContextEx(PWND pWnd, PIMC pIMC, DWORD dwFlags)
Definition: ime.c:1639
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:481
#define IS_IMM_MODE()
Definition: ntuser.h:1204
Definition: ntuser.h:190
HWND hWnd
Definition: settings.c:17
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
#define NULL
Definition: types.h:112
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13

Referenced by ImmAssociateContext(), and ImmAssociateContextEx().

◆ NtUserBuildHimcList()

NTSTATUS NTAPI NtUserBuildHimcList ( DWORD  dwThreadId,
DWORD  dwCount,
HIMC phList,
LPDWORD  pdwCount 
)

Definition at line 698 of file ime.c.

699 {
701  DWORD dwRealCount;
702  PTHREADINFO pti;
703 
705 
706  if (!IS_IMM_MODE())
707  {
708  ERR("!IS_IMM_MODE()\n");
710  goto Quit;
711  }
712 
713  if (dwThreadId == 0)
714  {
715  pti = GetW32ThreadInfo();
716  }
717  else if (dwThreadId == INVALID_THREAD_ID)
718  {
719  pti = NULL;
720  }
721  else
722  {
724  if (!pti || !pti->rpdesk)
725  goto Quit;
726  }
727 
728  _SEH2_TRY
729  {
730  ProbeForWrite(phList, dwCount * sizeof(HIMC), 1);
731  ProbeForWrite(pdwCount, sizeof(DWORD), 1);
732  *pdwCount = dwRealCount = UserBuildHimcList(pti, dwCount, phList);
733  }
735  {
736  goto Quit;
737  }
738  _SEH2_END;
739 
740  if (dwCount < dwRealCount)
742  else
744 
745 Quit:
746  UserLeave();
747  return ret;
748 }
#define INVALID_THREAD_ID
Definition: ime.c:13
#define IS_IMM_MODE()
Definition: ntuser.h:1204
LONG NTSTATUS
Definition: precomp.h:26
struct _DESKTOP * rpdesk
Definition: win32.h:88
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_SEH2_TRY
Definition: create.c:4226
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PTHREADINFO FASTCALL IntTID2PTI(HANDLE id)
Definition: misc.c:42
DWORD HIMC
Definition: dimm.idl:75
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define UlongToHandle(ul)
Definition: basetsd.h:97
DWORD FASTCALL UserBuildHimcList(PTHREADINFO pti, DWORD dwCount, HIMC *phList)
Definition: ime.c:544
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
int ret
DWORD dwThreadId
Definition: fdebug.c:31
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by Imm32BuildHimcList().

◆ NtUserCheckImeHotKey()

DWORD NTAPI NtUserCheckImeHotKey ( UINT  uVirtualKey,
LPARAM  lParam 
)

Definition at line 475 of file ime.c.

476 {
477  PIMEHOTKEY pNode;
479 
481 
482  if (!gpqForeground || !IS_IMM_MODE())
483  goto Quit;
484 
485  pNode = IntCheckImeHotKey(gpqForeground, uVirtualKey, lParam);
486  if (pNode)
487  ret = pNode->dwHotKeyId;
488 
489 Quit:
490  UserLeave();
491  return ret;
492 }
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
#define IS_IMM_MODE()
Definition: ntuser.h:1204
#define INVALID_HOTKEY
Definition: ime.c:14
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD dwHotKeyId
Definition: ime.c:49
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
PIMEHOTKEY IntCheckImeHotKey(PUSER_MESSAGE_QUEUE MessageQueue, UINT uVirtualKey, LPARAM lParam)
Definition: ime.c:289
LPARAM lParam
Definition: combotst.c:139

◆ NtUserCreateInputContext()

HIMC NTAPI NtUserCreateInputContext ( ULONG_PTR  dwClientImcData)

Definition at line 1609 of file ime.c.

1610 {
1611  PIMC pIMC;
1612  HIMC ret = NULL;
1613 
1615 
1616  if (!IS_IMM_MODE())
1617  {
1618  ERR("!IS_IMM_MODE()\n");
1620  goto Quit;
1621  }
1622 
1623  if (!dwClientImcData)
1624  {
1626  goto Quit;
1627  }
1628 
1629  pIMC = UserCreateInputContext(dwClientImcData);
1630  if (pIMC)
1631  ret = UserHMGetHandle(pIMC);
1632 
1633 Quit:
1634  UserLeave();
1635  return ret;
1636 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define IS_IMM_MODE()
Definition: ntuser.h:1204
Definition: ntuser.h:190
DWORD HIMC
Definition: dimm.idl:75
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
int ret
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
#define NULL
Definition: types.h:112
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
Definition: ime.c:1561
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by ImmCreateContext().

◆ NtUserDestroyInputContext()

BOOL NTAPI NtUserDestroyInputContext ( HIMC  hIMC)

Definition at line 1538 of file ime.c.

1539 {
1540  BOOL ret = FALSE;
1541  PIMC pIMC;
1542 
1544 
1545  if (!IS_IMM_MODE())
1546  {
1548  goto Quit;
1549  }
1550 
1552  if (pIMC)
1553  ret = IntDestroyInputContext(pIMC);
1554 
1555 Quit:
1556  UserLeave();
1557  return ret;
1558 }
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:481
#define IS_IMM_MODE()
Definition: ntuser.h:1204
Definition: ntuser.h:190
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
int ret
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
BOOL IntDestroyInputContext(PIMC pIMC)
Definition: ime.c:1499
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by Imm32DestroyInputContext().

◆ NtUserDisableThreadIme()

BOOL NTAPI NtUserDisableThreadIme ( DWORD  dwThreadID)

Definition at line 859 of file ime.c.

861 {
862  PTHREADINFO pti, ptiCurrent;
863  PPROCESSINFO ppi;
864  BOOL ret = FALSE;
865 
867 
868  if (!IS_IMM_MODE())
869  {
870  ERR("!IS_IMM_MODE()\n");
872  goto Quit;
873  }
874 
875  ptiCurrent = GetW32ThreadInfo();
876 
877  if (dwThreadID == INVALID_THREAD_ID)
878  {
879  ppi = ptiCurrent->ppi;
880  ppi->W32PF_flags |= W32PF_DISABLEIME;
881 
882 Retry:
883  for (pti = ppi->ptiList; pti; pti = pti->ptiSibling)
884  {
885  pti->TIF_flags |= TIF_DISABLEIME;
886 
887  if (pti->spwndDefaultIme)
888  {
890  pti->spwndDefaultIme = NULL;
891  goto Retry; /* The contents of ppi->ptiList may be changed. */
892  }
893  }
894  }
895  else
896  {
897  if (dwThreadID == 0)
898  {
899  pti = ptiCurrent;
900  }
901  else
902  {
903  pti = IntTID2PTI(UlongToHandle(dwThreadID));
904 
905  /* The thread needs to reside in the current process. */
906  if (!pti || pti->ppi != ptiCurrent->ppi)
907  goto Quit;
908  }
909 
910  pti->TIF_flags |= TIF_DISABLEIME;
911 
912  if (pti->spwndDefaultIme)
913  {
915  pti->spwndDefaultIme = NULL;
916  }
917  }
918 
919  ret = TRUE;
920 
921 Quit:
922  UserLeave();
923  return ret;
924 }
#define INVALID_THREAD_ID
Definition: ime.c:13
#define TRUE
Definition: types.h:120
PTHREADINFO ptiSibling
Definition: win32.h:112
#define IS_IMM_MODE()
Definition: ntuser.h:1204
FLONG TIF_flags
Definition: win32.h:91
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:84
PTHREADINFO FASTCALL IntTID2PTI(HANDLE id)
Definition: misc.c:42
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOLEAN co_UserDestroyWindow(PVOID Object)
Definition: window.c:2841
struct _WND * spwndDefaultIme
Definition: win32.h:127
#define TIF_DISABLEIME
Definition: ntuser.h:279
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define UlongToHandle(ul)
Definition: basetsd.h:97
int ret
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEAN * Retry
Definition: classpnp.h:310
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
#define W32PF_DISABLEIME
Definition: win32.h:28
#define NULL
Definition: types.h:112
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
PTHREADINFO ptiList
Definition: win32.h:247
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by ImmDisableIME().

◆ NtUserGetAppImeLevel()

DWORD NTAPI NtUserGetAppImeLevel ( HWND  hWnd)

Definition at line 928 of file ime.c.

929 {
930  DWORD ret = 0;
931  PWND pWnd;
932  PTHREADINFO pti;
933 
934  UserEnterShared();
935 
936  pWnd = ValidateHwndNoErr(hWnd);
937  if (!pWnd)
938  goto Quit;
939 
940  if (!IS_IMM_MODE())
941  {
942  ERR("!IS_IMM_MODE()\n");
944  goto Quit;
945  }
946 
948  if (pWnd->head.pti->ppi == pti->ppi)
950 
951 Quit:
952  UserLeave();
953  return ret;
954 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
#define DWORD
Definition: nt_native.h:44
PPROCESSINFO ppi
Definition: win32.h:84
uint32_t ULONG_PTR
Definition: typedefs.h:65
THRDESKHEAD head
Definition: ntuser.h:674
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
ATOM AtomImeLevel
Definition: ntuser.c:28
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

Referenced by Imm32PostMessages(), and ImmGenerateMessage().

◆ NtUserGetImeHotKey()

BOOL NTAPI NtUserGetImeHotKey ( DWORD  dwHotKeyId,
LPUINT  lpuModifiers,
LPUINT  lpuVirtualKey,
LPHKL  lphKL 
)

Definition at line 416 of file ime.c.

417 {
418  PIMEHOTKEY pNode = NULL;
419 
421 
422  _SEH2_TRY
423  {
424  ProbeForWrite(lpuModifiers, sizeof(UINT), 1);
425  ProbeForWrite(lpuVirtualKey, sizeof(UINT), 1);
426  if (lphKL)
427  ProbeForWrite(lphKL, sizeof(HKL), 1);
428  }
430  {
431  goto Quit;
432  }
433  _SEH2_END;
434 
435  pNode = IntGetImeHotKeyById(gpImeHotKeyList, dwHotKeyId);
436  if (!pNode)
437  goto Quit;
438 
439  _SEH2_TRY
440  {
441  *lpuModifiers = pNode->uModifiers;
442  *lpuVirtualKey = pNode->uVirtualKey;
443  if (lphKL)
444  *lphKL = pNode->hKL;
445  }
447  {
448  pNode = NULL;
449  }
450  _SEH2_END;
451 
452 Quit:
453  UserLeave();
454  return !!pNode;
455 }
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
HKL hKL
Definition: ime.c:52
UINT uModifiers
Definition: ime.c:51
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
UINT_PTR HKL
Definition: msctf.idl:101
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
_SEH2_END
Definition: create.c:4400
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
PIMEHOTKEY gpImeHotKeyList
Definition: ime.c:55
UINT uVirtualKey
Definition: ime.c:50
static PIMEHOTKEY FASTCALL IntGetImeHotKeyById(PIMEHOTKEY pList, DWORD dwHotKeyId)
Definition: ime.c:160
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40

Referenced by CliSetDefaultImeHotKeys(), and ImmGetHotKey().

◆ NtUserGetImeInfoEx()

BOOL NTAPI NtUserGetImeInfoEx ( PIMEINFOEX  pImeInfoEx,
IMEINFOEXCLASS  SearchType 
)

Definition at line 1015 of file ime.c.

1018 {
1019  IMEINFOEX ImeInfoEx;
1020  BOOL ret = FALSE;
1021  PWINSTATION_OBJECT pWinSta;
1022 
1023  UserEnterShared();
1024 
1025  if (!IS_IMM_MODE())
1026  {
1027  ERR("!IS_IMM_MODE()\n");
1028  goto Quit;
1029  }
1030 
1031  _SEH2_TRY
1032  {
1033  ProbeForWrite(pImeInfoEx, sizeof(*pImeInfoEx), 1);
1034  ImeInfoEx = *pImeInfoEx;
1035  }
1037  {
1038  goto Quit;
1039  }
1040  _SEH2_END;
1041 
1042  pWinSta = IntGetProcessWindowStation(NULL);
1043  ret = UserGetImeInfoEx(pWinSta, &ImeInfoEx, SearchType);
1044  if (!ret)
1045  goto Quit;
1046 
1047  _SEH2_TRY
1048  {
1049  *pImeInfoEx = ImeInfoEx;
1050  }
1052  {
1053  ret = FALSE;
1054  }
1055  _SEH2_END;
1056 
1057 Quit:
1058  UserLeave();
1059  return ret;
1060 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
#define IS_IMM_MODE()
Definition: ntuser.h:1204
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
int ret
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
BOOL FASTCALL UserGetImeInfoEx(_Inout_ PWINSTATION_OBJECT pWinSta, _Inout_ PIMEINFOEX pInfoEx, _In_ IMEINFOEXCLASS SearchType)
Definition: ime.c:958
PWINSTATION_OBJECT FASTCALL IntGetProcessWindowStation(HWINSTA *phWinSta OPTIONAL)
Definition: winsta.c:400

Referenced by ImmGetImeInfoEx().

◆ NtUserNotifyIMEStatus()

DWORD NTAPI NtUserNotifyIMEStatus ( HWND  hwnd,
BOOL  fOpen,
DWORD  dwConversion 
)

Definition at line 810 of file ime.c.

811 {
812  PWND pwnd;
813  PTHREADINFO pti;
814  HKL hKL;
815 
817 
818  if (!IS_IMM_MODE())
819  {
820  ERR("!IS_IMM_MODE()\n");
821  goto Quit;
822  }
823 
824  pwnd = ValidateHwndNoErr(hwnd);
825  if (!pwnd)
826  goto Quit;
827 
828  pti = pwnd->head.pti;
829  if (!pti || !gptiForeground)
830  goto Quit;
832  goto Quit;
833  if (ghIMC == pwnd->hImc && gfImeOpen == !!fOpen && gdwImeConversion == dwConversion)
834  goto Quit;
835 
836  ghIMC = pwnd->hImc;
837  if (ghIMC)
838  {
839  gfImeOpen = !!fOpen;
840  gdwImeConversion = dwConversion;
841  UserSetImeConversionKeyState(pti, (fOpen ? dwConversion : IME_CMODE_ALPHANUMERIC));
842  }
843 
844  if (ISITHOOKED(WH_SHELL))
845  {
846  hKL = (pti->KeyboardLayout ? pti->KeyboardLayout->hkl : NULL);
847  co_HOOK_CallHooks(WH_SHELL, HSHELL_LANGUAGE, (WPARAM)hwnd, (LPARAM)hKL);
848  }
849 
850  // TODO:
851 
852 Quit:
853  UserLeave();
854  return 0;
855 }
BOOL gfImeOpen
Definition: ime.c:42
#define IS_IMM_MODE()
Definition: ntuser.h:1204
#define WH_SHELL
Definition: winuser.h:40
UINT_PTR WPARAM
Definition: windef.h:207
HIMC hImc
Definition: ntuser.h:719
PTHREADINFO gptiForeground
Definition: focus.c:15
THRDESKHEAD head
Definition: ntuser.h:674
LONG_PTR LPARAM
Definition: windef.h:208
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define IME_CMODE_ALPHANUMERIC
Definition: imm.h:484
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
#define ISITHOOKED(HookId)
Definition: hook.h:6
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
UINT_PTR HKL
Definition: msctf.idl:101
struct tagKL * KeyboardLayout
Definition: win32.h:86
#define ERR(fmt,...)
Definition: debug.h:110
HIMC ghIMC
Definition: ime.c:41
Definition: ntuser.h:672
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:85
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
#define NULL
Definition: types.h:112
static VOID FASTCALL UserSetImeConversionKeyState(PTHREADINFO pti, DWORD dwConversion)
Definition: ime.c:751
DWORD gdwImeConversion
Definition: ime.c:43
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022

Referenced by ImeWnd_OnImeNotify(), Imm32SendNotificationProc(), ImmSetActiveContext(), ImmSetConversionStatus(), and ImmSetOpenStatus().

◆ NtUserQueryInputContext()

DWORD_PTR NTAPI NtUserQueryInputContext ( HIMC  hIMC,
DWORD  dwType 
)

Definition at line 1794 of file ime.c.

1795 {
1796  PIMC pIMC;
1797  PTHREADINFO ptiIMC;
1798  DWORD_PTR ret = 0;
1799 
1801 
1802  if (!IS_IMM_MODE())
1803  {
1804  ERR("!IS_IMM_MODE()\n");
1805  goto Quit;
1806  }
1807 
1809  if (!pIMC)
1810  goto Quit;
1811 
1812  ptiIMC = pIMC->head.pti;
1813 
1814  switch (dwType)
1815  {
1816  case QIC_INPUTPROCESSID:
1817  ret = (DWORD_PTR)PsGetThreadProcessId(ptiIMC->pEThread);
1818  break;
1819 
1820  case QIC_INPUTTHREADID:
1821  ret = (DWORD_PTR)PsGetThreadId(ptiIMC->pEThread);
1822  break;
1823 
1824  case QIC_DEFAULTWINDOWIME:
1825  if (ptiIMC->spwndDefaultIme)
1827  break;
1828 
1829  case QIC_DEFAULTIMC:
1830  if (ptiIMC->spDefaultImc)
1832  break;
1833  }
1834 
1835 Quit:
1836  UserLeave();
1837  return ret;
1838 }
struct tagIMC * spDefaultImc
Definition: win32.h:128
#define DWORD_PTR
Definition: treelist.c:76
#define IS_IMM_MODE()
Definition: ntuser.h:1204
Definition: ntuser.h:190
struct _WND * spwndDefaultIme
Definition: win32.h:127
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
HANDLE NTAPI PsGetThreadProcessId(IN PETHREAD Thread)
Definition: thread.c:745
int ret
HANDLE NTAPI PsGetThreadId(IN PETHREAD Thread)
Definition: thread.c:705
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
THRDESKHEAD head
Definition: ntuser.h:192
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13

Referenced by CtfImmGetGuidAtom(), CtfImmIsGuidMapEnable(), Imm32CheckImcProcess(), Imm32GetImeMenuItemWInterProcess(), Imm32InternalLockIMC(), Imm32IsCrossThreadAccess(), Imm32MakeIMENotify(), ImmGetImeMenuItemsAW(), and ImmSetCompositionStringAW().

◆ NtUserSetAppImeLevel()

BOOL NTAPI NtUserSetAppImeLevel ( HWND  hWnd,
DWORD  dwLevel 
)

Definition at line 1064 of file ime.c.

1065 {
1066  BOOL ret = FALSE;
1067  PWND pWnd;
1068  PTHREADINFO pti;
1069 
1071 
1072  if (!IS_IMM_MODE())
1073  {
1074  ERR("!IS_IMM_MODE()\n");
1076  goto Quit;
1077  }
1078 
1079  pWnd = ValidateHwndNoErr(hWnd);
1080  if (!pWnd)
1081  goto Quit;
1082 
1084  if (pWnd->head.pti->ppi == pti->ppi)
1085  ret = UserSetProp(pWnd, AtomImeLevel, (HANDLE)(ULONG_PTR)dwLevel, TRUE);
1086 
1087 Quit:
1088  UserLeave();
1089  return ret;
1090 }
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
HWND hWnd
Definition: settings.c:17
PPROCESSINFO ppi
Definition: win32.h:84
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
THRDESKHEAD head
Definition: ntuser.h:674
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
int ret
ATOM AtomImeLevel
Definition: ntuser.c:28
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:28

◆ NtUserSetImeHotKey()

BOOL NTAPI NtUserSetImeHotKey ( DWORD  dwHotKeyId,
UINT  uModifiers,
UINT  uVirtualKey,
HKL  hKL,
DWORD  dwAction 
)

Definition at line 459 of file ime.c.

465 {
466  BOOL ret;
468  ret = IntSetImeHotKey(dwHotKeyId, uModifiers, uVirtualKey, hKL, dwAction);
469  UserLeave();
470  return ret;
471 }
static BOOL APIENTRY IntSetImeHotKey(DWORD dwHotKeyId, UINT uModifiers, UINT uVirtualKey, HKL hKL, DWORD dwAction)
Definition: ime.c:353
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
int ret
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258

Referenced by CliImmInitializeHotKeys(), and CliImmSetHotKeyWorker().

◆ NtUserSetImeInfoEx()

BOOL NTAPI NtUserSetImeInfoEx ( PIMEINFOEX  pImeInfoEx)

Definition at line 1130 of file ime.c.

1131 {
1132  BOOL ret = FALSE;
1133  IMEINFOEX ImeInfoEx;
1134  PWINSTATION_OBJECT pWinSta;
1135 
1137 
1138  if (!IS_IMM_MODE())
1139  {
1140  ERR("!IS_IMM_MODE()\n");
1141  goto Quit;
1142  }
1143 
1144  _SEH2_TRY
1145  {
1146  ProbeForRead(pImeInfoEx, sizeof(*pImeInfoEx), 1);
1147  ImeInfoEx = *pImeInfoEx;
1148  }
1150  {
1151  goto Quit;
1152  }
1153  _SEH2_END;
1154 
1155  pWinSta = IntGetProcessWindowStation(NULL);
1156  ret = UserSetImeInfoEx(pWinSta, &ImeInfoEx);
1157 
1158 Quit:
1159  UserLeave();
1160  return ret;
1161 }
BOOL FASTCALL UserSetImeInfoEx(_Inout_ PWINSTATION_OBJECT pWinSta, _Inout_ PIMEINFOEX pImeInfoEx)
Definition: ime.c:1094
#define IS_IMM_MODE()
Definition: ntuser.h:1204
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
int ret
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
_SEH2_END
Definition: create.c:4400
#define NULL
Definition: types.h:112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
PWINSTATION_OBJECT FASTCALL IntGetProcessWindowStation(HWINSTA *phWinSta OPTIONAL)
Definition: winsta.c:400

Referenced by Imm32LoadIME().

◆ NtUserSetImeOwnerWindow()

BOOL NTAPI NtUserSetImeOwnerWindow ( HWND  hImeWnd,
HWND  hwndFocus 
)

Definition at line 1365 of file ime.c.

1366 {
1367  BOOL ret = FALSE;
1368  PWND pImeWnd, pwndFocus, pwndTopLevel, pwndNode, pwndActive;
1369  PTHREADINFO ptiIme;
1370 
1372 
1373  if (!IS_IMM_MODE())
1374  {
1375  ERR("!IS_IMM_MODE()\n");
1376  goto Quit;
1377  }
1378 
1379  pImeWnd = ValidateHwndNoErr(hImeWnd);
1380  if (!pImeWnd || pImeWnd->fnid != FNID_IME)
1381  goto Quit;
1382 
1383  pwndFocus = ValidateHwndNoErr(hwndFocus);
1384  if (pwndFocus)
1385  {
1386  if (IS_WND_IMELIKE(pwndFocus))
1387  goto Quit;
1388 
1389  pwndTopLevel = IntGetTopLevelWindow(pwndFocus);
1390 
1391  for (pwndNode = pwndTopLevel; pwndNode; pwndNode = pwndNode->spwndOwner)
1392  {
1393  if (pwndNode->pcls->atomClassName == gpsi->atomSysClass[ICLS_IME])
1394  {
1395  pwndTopLevel = NULL;
1396  break;
1397  }
1398  }
1399 
1400  pImeWnd->spwndOwner = pwndTopLevel;
1401  IntImeCheckTopmost(pImeWnd);
1402  }
1403  else
1404  {
1405  ptiIme = pImeWnd->head.pti;
1406  pwndActive = ptiIme->MessageQueue->spwndActive;
1407 
1408  if (!pwndActive || pwndActive != pImeWnd->spwndOwner)
1409  {
1410  if (pwndActive && ptiIme == pwndActive->head.pti && !IS_WND_IMELIKE(pwndActive))
1411  {
1412  pImeWnd->spwndOwner = pwndActive;
1413  }
1414  else
1415  {
1416  IntImeSetFutureOwner(pImeWnd, pImeWnd->spwndOwner);
1417  }
1418 
1419  IntImeCheckTopmost(pImeWnd);
1420  }
1421  }
1422 
1423  ret = TRUE;
1424 
1425 Quit:
1426  UserLeave();
1427  return ret;
1428 }
#define TRUE
Definition: types.h:120
#define IS_IMM_MODE()
Definition: ntuser.h:1204
PSERVERINFO gpsi
Definition: imm.c:17
RTL_ATOM atomClassName
Definition: ntuser.h:551
#define FALSE
Definition: types.h:117
DWORD fnid
Definition: ntuser.h:688
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _WND * spwndOwner
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:674
VOID FASTCALL IntImeCheckTopmost(PWND pImeWnd)
Definition: ime.c:1349
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
int ret
#define ICLS_IME
Definition: ntuser.h:906
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:672
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:85
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL IntImeSetFutureOwner(PWND pImeWnd, PWND pwndOwner)
Definition: ime.c:1165
#define NULL
Definition: types.h:112
#define IS_WND_IMELIKE(pWnd)
Definition: window.h:113
PWND FASTCALL IntGetTopLevelWindow(PWND pwnd)
Definition: ime.c:495
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1031
#define FNID_IME
Definition: ntuser.h:853
PCLS pcls
Definition: ntuser.h:699

Referenced by ImeWnd_OnImeSetContext().

◆ NtUserSetThreadLayoutHandles()

DWORD NTAPI NtUserSetThreadLayoutHandles ( HKL  hNewKL,
HKL  hOldKL 
)

Definition at line 516 of file ime.c.

517 {
518  PTHREADINFO pti;
519  PKL pOldKL, pNewKL;
520 
522 
523  pti = GetW32ThreadInfo();
524  pOldKL = pti->KeyboardLayout;
525  if (pOldKL && pOldKL->hkl != hOldKL)
526  goto Quit;
527 
528  pNewKL = UserHklToKbl(hNewKL);
529  if (!pNewKL)
530  goto Quit;
531 
532  if (IS_IME_HKL(hNewKL) != IS_IME_HKL(hOldKL))
533  pti->hklPrev = hOldKL;
534 
535  UserAssignmentLock((PVOID*)&pti->KeyboardLayout, pNewKL);
536  pti->pClientInfo->hKL = pNewKL->hkl;
537 
538 Quit:
539  UserLeave();
540  return 0;
541 }
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:840
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
HKL hklPrev
Definition: win32.h:129
Definition: input.h:26
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
HKL hkl
Definition: input.h:32
struct _CLIENTINFO * pClientInfo
Definition: win32.h:90
struct tagKL * KeyboardLayout
Definition: win32.h:86
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
#define IS_IME_HKL(hKL)
Definition: input.h:88
PKL NTAPI UserHklToKbl(HKL hKl)
Definition: kbdlayout.c:541

Referenced by ImmActivateLayout().

◆ NtUserUpdateInputContext()

BOOL NTAPI NtUserUpdateInputContext ( HIMC  hIMC,
DWORD  dwType,
DWORD_PTR  dwValue 
)

Definition at line 1765 of file ime.c.

1769 {
1770  PIMC pIMC;
1771  BOOL ret = FALSE;
1772 
1774 
1775  if (!IS_IMM_MODE())
1776  {
1777  ERR("!IS_IMM_MODE()\n");
1778  goto Quit;
1779  }
1780 
1782  if (!pIMC)
1783  goto Quit;
1784 
1785  ret = UserUpdateInputContext(pIMC, dwType, dwValue);
1786 
1787 Quit:
1788  UserLeave();
1789  return ret;
1790 }
#define IS_IMM_MODE()
Definition: ntuser.h:1204
Definition: ntuser.h:190
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
BOOL FASTCALL UserUpdateInputContext(PIMC pIMC, DWORD dwType, DWORD_PTR dwValue)
Definition: ime.c:1732
int ret
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13

Referenced by ImmLockClientImc(), and User32SetImeWindowOfImc().

◆ UserBuildHimcList()

DWORD FASTCALL UserBuildHimcList ( PTHREADINFO  pti,
DWORD  dwCount,
HIMC phList 
)

Definition at line 544 of file ime.c.

545 {
546  PIMC pIMC;
547  DWORD dwRealCount = 0;
548 
549  if (pti)
550  {
551  for (pIMC = pti->spDefaultImc; pIMC; pIMC = pIMC->pImcNext)
552  {
553  if (dwRealCount < dwCount)
554  phList[dwRealCount] = UserHMGetHandle(pIMC);
555 
556  ++dwRealCount;
557  }
558  }
559  else
560  {
561  for (pti = GetW32ThreadInfo()->ppi->ptiList; pti; pti = pti->ptiSibling)
562  {
563  for (pIMC = pti->spDefaultImc; pIMC; pIMC = pIMC->pImcNext)
564  {
565  if (dwRealCount < dwCount)
566  phList[dwRealCount] = UserHMGetHandle(pIMC);
567 
568  ++dwRealCount;
569  }
570  }
571  }
572 
573  return dwRealCount;
574 }
struct tagIMC * spDefaultImc
Definition: win32.h:128
PTHREADINFO ptiSibling
Definition: win32.h:112
Definition: ntuser.h:190
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
unsigned long DWORD
Definition: ntddk_ex.h:95
struct tagIMC * pImcNext
Definition: ntuser.h:193

Referenced by NtUserBuildHimcList().

◆ UserCreateInputContext()

PIMC FASTCALL UserCreateInputContext ( ULONG_PTR  dwClientImcData)

Definition at line 1561 of file ime.c.

1562 {
1563  PIMC pIMC;
1565  PDESKTOP pdesk = pti->rpdesk;
1566 
1567  if (!IS_IMM_MODE() || (pti->TIF_flags & TIF_DISABLEIME)) // Disabled?
1568  {
1569  ERR("IME is disabled\n");
1570  return NULL;
1571  }
1572 
1573  if (!pdesk) // No desktop?
1574  return NULL;
1575 
1576  // pti->spDefaultImc should be already set if non-first time.
1577  if (dwClientImcData && !pti->spDefaultImc)
1578  return NULL;
1579 
1580  // Create an input context user object.
1581  pIMC = UserCreateObject(gHandleTable, pdesk, pti, NULL, TYPE_INPUTCONTEXT, sizeof(IMC));
1582  if (!pIMC)
1583  return NULL;
1584 
1585  // Release the extra reference (UserCreateObject added 2 references).
1586  UserDereferenceObject(pIMC);
1587  ASSERT(pIMC->head.cLockObj == 1);
1588 
1589  if (dwClientImcData) // Non-first time.
1590  {
1591  // Insert pIMC to the second position (non-default) of the list.
1592  pIMC->pImcNext = pti->spDefaultImc->pImcNext;
1593  pti->spDefaultImc->pImcNext = pIMC;
1594  }
1595  else // First time. It's the default IMC.
1596  {
1597  // Add the first one (default) to the list.
1598  UserAssignmentLock((PVOID*)&pti->spDefaultImc, pIMC);
1599  pIMC->pImcNext = NULL;
1600  ASSERT(pIMC->head.cLockObj == 2); // UserAssignmentUnlock'ed at ExitThreadCallback
1601  }
1602 
1603  pIMC->dwClientImcData = dwClientImcData; // Set it.
1604  return pIMC;
1605 }
struct tagIMC * spDefaultImc
Definition: win32.h:128
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:840
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
#define IS_IMM_MODE()
Definition: ntuser.h:1204
FLONG TIF_flags
Definition: win32.h:91
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
Definition: ntuser.h:190
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
struct _DESKTOP * rpdesk
Definition: win32.h:88
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568
#define TIF_DISABLEIME
Definition: ntuser.h:279
#define ASSERT(a)
Definition: mode.c:44
#define ERR(fmt,...)
Definition: debug.h:110
THRDESKHEAD head
Definition: ntuser.h:192
#define NULL
Definition: types.h:112
struct tagIMC * pImcNext
Definition: ntuser.h:193
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13

Referenced by co_IntCreateDefaultImeWindow(), InitThreadCallback(), and NtUserCreateInputContext().

◆ UserDestroyInputContext()

BOOLEAN UserDestroyInputContext ( PVOID  Object)

Definition at line 1487 of file ime.c.

1488 {
1489  PIMC pIMC = Object;
1490  if (!pIMC)
1491  return TRUE;
1492 
1493  UserMarkObjectDestroy(pIMC);
1495  return TRUE;
1496 }
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717
#define TRUE
Definition: types.h:120
Definition: ntuser.h:190
#define UserHMGetHandle(obj)
Definition: ntuser.h:222
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
BOOL FASTCALL UserMarkObjectDestroy(PVOID Object)
Definition: object.c:621

◆ UserFreeInputContext()

VOID UserFreeInputContext ( PVOID  Object)

Definition at line 1460 of file ime.c.

1461 {
1462  PTHRDESKHEAD ObjHead = Object;
1463  PDESKTOP pDesk = ObjHead->rpdesk;
1464  PIMC pNode, pIMC = Object;
1465  PTHREADINFO pti;
1466 
1467  if (!pIMC)
1468  return;
1469 
1470  // Remove pIMC from the list except spDefaultImc
1471  pti = pIMC->head.pti;
1472  for (pNode = pti->spDefaultImc; pNode; pNode = pNode->pImcNext)
1473  {
1474  if (pNode->pImcNext == pIMC)
1475  {
1476  pNode->pImcNext = pIMC->pImcNext;
1477  break;
1478  }
1479  }
1480 
1481  DesktopHeapFree(pDesk, Object);
1482 
1483  pti->ppi->UserHandleCount--;
1485 }
struct _DESKTOP * rpdesk
Definition: ntuser.h:186
struct tagIMC * spDefaultImc
Definition: win32.h:128
Definition: ntuser.h:190
PPROCESSINFO ppi
Definition: win32.h:84
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
THRDESKHEAD head
Definition: ntuser.h:192
struct tagIMC * pImcNext
Definition: ntuser.h:193
static __inline BOOL DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem)
Definition: desktop.h:215
#define IntDereferenceThreadInfo(pti)
Definition: win32.h:167

◆ UserGetImeInfoEx()

BOOL FASTCALL UserGetImeInfoEx ( _Inout_ PWINSTATION_OBJECT  pWinSta,
_Inout_ PIMEINFOEX  pInfoEx,
_In_ IMEINFOEXCLASS  SearchType 
)

Definition at line 958 of file ime.c.

962 {
963  PKL pkl, pklHead;
964 
965  if (!pWinSta || !gspklBaseLayout)
966  return FALSE;
967 
968  pkl = pklHead = gspklBaseLayout;
969 
970  /* Find the matching entry from the list and get info */
971  if (SearchType == ImeInfoExKeyboardLayout)
972  {
973  do
974  {
975  if (pInfoEx->hkl == pkl->hkl)
976  {
977  if (!pkl->piiex)
978  {
979  ERR("!pkl->piiex at %p\n", pkl->hkl);
980  break;
981  }
982 
983  *pInfoEx = *pkl->piiex;
984  return TRUE;
985  }
986 
987  pkl = pkl->pklNext;
988  } while (pkl != pklHead);
989  }
990  else if (SearchType == ImeInfoExImeFileName)
991  {
992  do
993  {
994  if (pkl->piiex &&
995  _wcsnicmp(pkl->piiex->wszImeFile, pInfoEx->wszImeFile,
996  RTL_NUMBER_OF(pkl->piiex->wszImeFile)) == 0)
997  {
998  *pInfoEx = *pkl->piiex;
999  return TRUE;
1000  }
1001 
1002  pkl = pkl->pklNext;
1003  } while (pkl != pklHead);
1004  }
1005  else
1006  {
1007  ERR("SearchType: %d\n", SearchType);
1008  }
1009 
1010  return FALSE;
1011 }
#define TRUE
Definition: types.h:120
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
PIMEINFOEX piiex
Definition: input.h:38
#define FALSE
Definition: types.h:117
Definition: input.h:26
HKL hkl
Definition: input.h:32
struct tagKL * pklNext
Definition: input.h:29
#define ERR(fmt,...)
Definition: debug.h:110
WCHAR wszImeFile[80]
Definition: ntuser.h:1187
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
PKL gspklBaseLayout
Definition: kbdlayout.c:22

Referenced by NtUserGetImeInfoEx().

◆ UserSetImeConversionKeyState()

static VOID FASTCALL UserSetImeConversionKeyState ( PTHREADINFO  pti,
DWORD  dwConversion 
)
static

Definition at line 751 of file ime.c.

752 {
753  HKL hKL;
754  LANGID LangID;
755  LPBYTE KeyState;
756  BOOL bAlphaNumeric, bKatakana, bHiragana, bFullShape, bRoman, bCharCode;
757 
758  if (!pti->KeyboardLayout)
759  return;
760 
761  hKL = pti->KeyboardLayout->hkl;
762  LangID = LOWORD(hKL);
763  KeyState = pti->MessageQueue->afKeyState;
764 
765  switch (PRIMARYLANGID(LangID))
766  {
767  case LANG_JAPANESE:
768  bAlphaNumeric = !(dwConversion & IME_CMODE_NATIVE);
769  bKatakana = !bAlphaNumeric && (dwConversion & IME_CMODE_KATAKANA);
770  bHiragana = !bAlphaNumeric && !(dwConversion & IME_CMODE_KATAKANA);
771  SET_KEY_DOWN(KeyState, VK_DBE_ALPHANUMERIC, bAlphaNumeric);
772  SET_KEY_LOCKED(KeyState, VK_DBE_ALPHANUMERIC, bAlphaNumeric);
773  SET_KEY_DOWN(KeyState, VK_DBE_HIRAGANA, bHiragana);
774  SET_KEY_LOCKED(KeyState, VK_DBE_HIRAGANA, bHiragana);
775  SET_KEY_DOWN(KeyState, VK_DBE_KATAKANA, bKatakana);
776  SET_KEY_LOCKED(KeyState, VK_DBE_KATAKANA, bKatakana);
777 
778  bFullShape = (dwConversion & IME_CMODE_FULLSHAPE);
779  SET_KEY_DOWN(KeyState, VK_DBE_DBCSCHAR, bFullShape);
780  SET_KEY_LOCKED(KeyState, VK_DBE_DBCSCHAR, bFullShape);
781  SET_KEY_DOWN(KeyState, VK_DBE_SBCSCHAR, !bFullShape);
782  SET_KEY_LOCKED(KeyState, VK_DBE_SBCSCHAR, !bFullShape);
783 
784  bRoman = (dwConversion & IME_CMODE_ROMAN);
785  SET_KEY_DOWN(KeyState, VK_DBE_ROMAN, bRoman);
786  SET_KEY_LOCKED(KeyState, VK_DBE_ROMAN, bRoman);
787  SET_KEY_DOWN(KeyState, VK_DBE_NOROMAN, !bRoman);
788  SET_KEY_LOCKED(KeyState, VK_DBE_NOROMAN, !bRoman);
789 
790  bCharCode = (dwConversion & IME_CMODE_CHARCODE);
791  SET_KEY_DOWN(KeyState, VK_DBE_CODEINPUT, bCharCode);
792  SET_KEY_LOCKED(KeyState, VK_DBE_CODEINPUT, bCharCode);
793  SET_KEY_DOWN(KeyState, VK_DBE_NOCODEINPUT, !bCharCode);
794  SET_KEY_LOCKED(KeyState, VK_DBE_NOCODEINPUT, !bCharCode);
795  break;
796 
797  case LANG_KOREAN:
798  SET_KEY_LOCKED(KeyState, VK_HANGUL, (dwConversion & IME_CMODE_NATIVE));
799  SET_KEY_LOCKED(KeyState, VK_JUNJA, (dwConversion & IME_CMODE_FULLSHAPE));
800  SET_KEY_LOCKED(KeyState, VK_HANJA, (dwConversion & IME_CMODE_HANJACONVERT));
801  break;
802 
803  default:
804  break;
805  }
806 }
#define IME_CMODE_CHARCODE
Definition: imm.h:495
#define VK_DBE_SBCSCHAR
Definition: ime.c:29
#define VK_DBE_HIRAGANA
Definition: ime.c:28
#define VK_HANGUL
Definition: winuser.h:2199
WORD LANGID
Definition: typedefs.h:81
#define VK_DBE_ROMAN
Definition: ime.c:31
unsigned char * LPBYTE
Definition: typedefs.h:53
#define LANG_JAPANESE
Definition: nls.h:76
#define IME_CMODE_NATIVE
Definition: imm.h:485
unsigned int BOOL
Definition: ntddk_ex.h:94
#define VK_DBE_KATAKANA
Definition: ime.c:27
#define SET_KEY_DOWN(ks, vk, down)
Definition: input.h:101
#define VK_DBE_CODEINPUT
Definition: ime.c:36
#define IME_CMODE_FULLSHAPE
Definition: imm.h:493
#define IME_CMODE_KATAKANA
Definition: imm.h:491
#define VK_DBE_NOROMAN
Definition: ime.c:32
UINT_PTR HKL
Definition: msctf.idl:101
#define VK_DBE_ALPHANUMERIC
Definition: ime.c:26
struct tagKL * KeyboardLayout
Definition: win32.h:86
#define IME_CMODE_HANJACONVERT
Definition: imm.h:496
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:85
#define VK_HANJA
Definition: winuser.h:2202
#define VK_JUNJA
Definition: winuser.h:2200
#define VK_DBE_NOCODEINPUT
Definition: ime.c:37
#define IME_CMODE_ROMAN
Definition: imm.h:494
#define LANG_KOREAN
Definition: nls.h:84
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define SET_KEY_LOCKED(ks, vk, down)
Definition: input.h:104
#define LOWORD(l)
Definition: pedump.c:82
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define VK_DBE_DBCSCHAR
Definition: ime.c:30

Referenced by NtUserNotifyIMEStatus().

◆ UserSetImeInfoEx()

BOOL FASTCALL UserSetImeInfoEx ( _Inout_ PWINSTATION_OBJECT  pWinSta,
_Inout_ PIMEINFOEX  pImeInfoEx 
)

Definition at line 1094 of file ime.c.

1097 {
1098  PKL pklHead, pkl;
1099 
1100  if (!pWinSta || !gspklBaseLayout)
1101  return FALSE;
1102 
1103  pkl = pklHead = gspklBaseLayout;
1104 
1105  do
1106  {
1107  if (pkl->hkl != pImeInfoEx->hkl)
1108  {
1109  pkl = pkl->pklNext;
1110  continue;
1111  }
1112 
1113  if (!pkl->piiex)
1114  {
1115  ERR("!pkl->piiex at %p\n", pkl->hkl);
1116  return FALSE;
1117  }
1118 
1119  if (!pkl->piiex->fLoadFlag)
1120  *pkl->piiex = *pImeInfoEx;
1121 
1122  return TRUE;
1123  } while (pkl != pklHead);
1124 
1125  return FALSE;
1126 }
#define TRUE
Definition: types.h:120
PIMEINFOEX piiex
Definition: input.h:38
#define FALSE
Definition: types.h:117
Definition: input.h:26
HKL hkl
Definition: input.h:32
struct tagKL * pklNext
Definition: input.h:29
#define ERR(fmt,...)
Definition: debug.h:110
INT fLoadFlag
Definition: ntuser.h:1183
PKL gspklBaseLayout
Definition: kbdlayout.c:22

Referenced by NtUserSetImeInfoEx().

◆ UserUpdateInputContext()

BOOL FASTCALL UserUpdateInputContext ( PIMC  pIMC,
DWORD  dwType,
DWORD_PTR  dwValue 
)

Definition at line 1732 of file ime.c.

1733 {
1734  PTHREADINFO pti = GetW32ThreadInfo();
1735  PTHREADINFO ptiIMC = pIMC->head.pti;
1736 
1737  if (pti->ppi != ptiIMC->ppi) // Different process?
1738  return FALSE;
1739 
1740  switch (dwType)
1741  {
1742  case UIC_CLIENTIMCDATA:
1743  if (pIMC->dwClientImcData)
1744  return FALSE; // Already set
1745 
1746  pIMC->dwClientImcData = dwValue;
1747  break;
1748 
1749  case UIC_IMEWINDOW:
1750  if (!ValidateHwndNoErr((HWND)dwValue))
1751  return FALSE; // Invalid HWND
1752 
1753  pIMC->hImeWnd = (HWND)dwValue;
1754  break;
1755 
1756  default:
1757  return FALSE;
1758  }
1759 
1760  return TRUE;
1761 }
#define TRUE
Definition: types.h:120
ULONG_PTR dwClientImcData
Definition: ntuser.h:194
HANDLE HWND
Definition: compat.h:19
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:801
PPROCESSINFO ppi
Definition: win32.h:84
#define FALSE
Definition: types.h:117
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
HWND hImeWnd
Definition: ntuser.h:195
THRDESKHEAD head
Definition: ntuser.h:192

Referenced by NtUserUpdateInputContext().

Variable Documentation

◆ gdwImeConversion

DWORD gdwImeConversion = (DWORD)-1

Definition at line 43 of file ime.c.

Referenced by NtUserNotifyIMEStatus().

◆ gfImeOpen

BOOL gfImeOpen = (BOOL)-1

Definition at line 42 of file ime.c.

Referenced by NtUserNotifyIMEStatus().

◆ gfIMEShowStatus

BOOL gfIMEShowStatus = (BOOL)-1

◆ ghIMC

HIMC ghIMC = NULL

Definition at line 41 of file ime.c.

Referenced by NtUserNotifyIMEStatus().

◆ glcidSystem

LCID glcidSystem = 0

Definition at line 56 of file ime.c.

Referenced by IntGetImeHotKeyLanguageScore().

◆ gpImeHotKeyList

PIMEHOTKEY gpImeHotKeyList = NULL

Definition at line 55 of file ime.c.

Referenced by IntCheckImeHotKey(), IntFreeImeHotKeys(), IntSetImeHotKey(), and NtUserGetImeHotKey().