[NTUSER] Implement NtUserUpdateInputContext (#4228)

- Modify NtUserUpdateInputContext prototype.
- Implement NtUserUpdateInputContext function.
- Add enum UPDATE_INPUT_CONTEXT (UIC_*) to undocuser.h.
CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-01-01 20:57:51 +09:00 committed by GitHub
parent cdf3b5e85a
commit ba3affe5f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 9 deletions

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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