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