https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba3affe5f7f7f8818cc90…
commit ba3affe5f7f7f8818cc90a884a3ddcf8257d4d85
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Jan 1 20:57:51 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Jan 1 20:57:51 2022 +0900
[NTUSER] Implement NtUserUpdateInputContext (#4228)
- Modify NtUserUpdateInputContext prototype.
- Implement NtUserUpdateInputContext function.
- Add enum UPDATE_INPUT_CONTEXT (UIC_*) to undocuser.h.
CORE-11700
---
dll/win32/imm32/imm.c | 2 +-
sdk/include/reactos/undocuser.h | 6 +++++
win32ss/include/ntuser.h | 6 ++---
win32ss/user/ntuser/ntstubs.c | 55 +++++++++++++++++++++++++++++++++++++----
4 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 4ac2cdebb6e..e24806c86d4 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -928,7 +928,7 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
// FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken.
pClientImc->unknown = NtUserGetThreadState(13);
- if (!NtUserUpdateInputContext(hImc, 0, pClientImc))
+ if (!NtUserUpdateInputContext(hImc, UIC_CLIENTIMCDATA, (DWORD_PTR)pClientImc))
{
Imm32HeapFree(pClientImc);
return NULL;
diff --git a/sdk/include/reactos/undocuser.h b/sdk/include/reactos/undocuser.h
index ca13a8b0239..3c0ebb3c149 100644
--- a/sdk/include/reactos/undocuser.h
+++ b/sdk/include/reactos/undocuser.h
@@ -296,6 +296,12 @@ MessageBoxTimeoutW(
LPCWSTR WINAPI MB_GetString(IN UINT wBtn);
+/* dwType for NtUserUpdateInputContext */
+typedef enum _UPDATE_INPUT_CONTEXT
+{
+ UIC_CLIENTIMCDATA = 0,
+ UIC_IMEWINDOW
+} UPDATE_INPUT_CONTEXT;
//
// User api hook
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h
index 0e6d4c3b4d9..1e6234f84c1 100644
--- a/win32ss/include/ntuser.h
+++ b/win32ss/include/ntuser.h
@@ -3533,12 +3533,12 @@ BOOL
NTAPI
NtUserUnregisterUserApiHook(VOID);
-DWORD
+BOOL
NTAPI
NtUserUpdateInputContext(
HIMC hIMC,
- DWORD Unknown1,
- LPVOID pClientImc);
+ DWORD dwType,
+ DWORD_PTR dwValue);
DWORD
NTAPI
diff --git a/win32ss/user/ntuser/ntstubs.c b/win32ss/user/ntuser/ntstubs.c
index 1a173714958..95a87900242 100644
--- a/win32ss/user/ntuser/ntstubs.c
+++ b/win32ss/user/ntuser/ntstubs.c
@@ -346,16 +346,61 @@ NtUserSetSysColors(
return Ret;
}
-DWORD
+BOOL FASTCALL UserUpdateInputContext(PIMC pIMC, DWORD dwType, DWORD_PTR dwValue)
+{
+ PTHREADINFO pti = GetW32ThreadInfo();
+ PTHREADINFO ptiIMC = pIMC->head.pti;
+
+ if (pti->ppi != ptiIMC->ppi) // Different process?
+ return FALSE;
+
+ switch (dwType)
+ {
+ case UIC_CLIENTIMCDATA:
+ if (pIMC->dwClientImcData)
+ return FALSE; // Already set
+
+ pIMC->dwClientImcData = dwValue;
+ break;
+
+ case UIC_IMEWINDOW:
+ if (!ValidateHwndNoErr((HWND)dwValue))
+ return FALSE; // Invalid HWND
+
+ pIMC->hImeWnd = (HWND)dwValue;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+BOOL
APIENTRY
NtUserUpdateInputContext(
HIMC hIMC,
- DWORD Unknown1,
- LPVOID pClientImc)
+ DWORD dwType,
+ DWORD_PTR dwValue)
{
- STUB
+ PIMC pIMC;
+ BOOL ret = FALSE;
- return 0;
+ UserEnterExclusive();
+
+ if (!IS_IMM_MODE())
+ goto Quit;
+
+ pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
+ if (!pIMC)
+ goto Quit;
+
+ ret = UserUpdateInputContext(pIMC, dwType, dwValue);
+
+Quit:
+ UserLeave();
+ return ret;
}
DWORD