[NTUSER] Implement NtUserQueryInputContext (#4227)

Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
- Modify NtUserQueryInputContext prototype.
- Implement NtUserQueryInputContext function.
- Add enum QUERY_INPUT_CONTEXT (QIC_*) to undocuser.h.
CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-01-01 20:56:50 +09:00 committed by GitHub
parent 0d00a5d6eb
commit cdf3b5e85a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 14 deletions

View file

@ -527,7 +527,7 @@ Imm32SetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwComp
UINT uCodePage;
LPRECONVERTSTRING pRS;
dwThreadId = NtUserQueryInputContext(hIMC, 1);
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
if (dwThreadId != GetCurrentThreadId())
return FALSE;

View file

@ -376,7 +376,7 @@ Imm32GetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID lpImeParen
if (!hIMC)
return 0;
dwProcessId = NtUserQueryInputContext(hIMC, 0);
dwProcessId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTPROCESSID);
if (dwProcessId == 0)
return 0;
@ -392,7 +392,7 @@ Imm32GetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID lpImeParen
if (pIC == NULL)
return 0;
dwThreadId = NtUserQueryInputContext(hIMC, 1);
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
if (dwThreadId == 0)
{
ImmUnlockIMC(hIMC);

View file

@ -818,7 +818,7 @@ LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect)
if (!pClientImc->hInputContext)
{
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, 1);
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
if (dwThreadId == GetCurrentThreadId() && Imm32IsCiceroMode() && !Imm32Is16BitMode())
{
@ -833,7 +833,7 @@ LPINPUTCONTEXT APIENTRY Imm32LockIMCEx(HIMC hIMC, BOOL fSelect)
}
}
if (!NtUserQueryInputContext(hIMC, 2))
if (!NtUserQueryInputContext(hIMC, QIC_DEFAULTWINDOWIME))
{
RtlLeaveCriticalSection(&pClientImc->cs);
goto Quit;

View file

@ -97,7 +97,7 @@ BOOL APIENTRY Imm32ReleaseIME(HKL hKL);
static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
{
DWORD dwImeThreadId = NtUserQueryInputContext(hIMC, 1);
DWORD dwImeThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
DWORD dwThreadId = GetCurrentThreadId();
return (dwImeThreadId != dwThreadId);
}

View file

@ -186,7 +186,7 @@ BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
return TRUE;
hIMC = pIMC->head.h;
dwProcessID = NtUserQueryInputContext(hIMC, 0);
dwProcessID = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTPROCESSID);
return dwProcessID == (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
}
@ -211,7 +211,7 @@ Imm32NotifyAction(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR dwIndex, DWORD
if (dwAction)
{
dwThreadId = NtUserQueryInputContext(hIMC, 1);
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
if (dwThreadId)
{
/* find keyboard layout and lock it */

View file

@ -379,6 +379,15 @@ BOOL WINAPI RegisterUserApiHook(PUSERAPIHOOKINFO puah);
BOOL WINAPI UnregisterUserApiHook(VOID);
/* dwType for NtUserQueryInputContext */
typedef enum _QUERY_INPUT_CONTEXT
{
QIC_INPUTPROCESSID = 0,
QIC_INPUTTHREADID,
QIC_DEFAULTWINDOWIME,
QIC_DEFAULTIMC
} QUERY_INPUT_CONTEXT;
#ifdef __cplusplus
} /* extern "C" */
#endif /* defined(__cplusplus) */

View file

@ -2877,11 +2877,11 @@ NtUserQueryInformationThread(
OUT PVOID ThreadInformation,
IN ULONG ThreadInformationLength);
DWORD
DWORD_PTR
NTAPI
NtUserQueryInputContext(
HIMC hIMC,
DWORD dwUnknown2);
DWORD dwType);
DWORD
NTAPI

View file

@ -647,14 +647,51 @@ Quit:
return Status;
}
DWORD
DWORD_PTR
APIENTRY
NtUserQueryInputContext(
HIMC hIMC,
DWORD dwUnknown2)
DWORD dwType)
{
TRACE("NtUserQueryInputContext(%p, 0x%lX)\n", hIMC, dwUnknown2);
return 0;
PIMC pIMC;
PTHREADINFO ptiIMC;
DWORD_PTR ret = 0;
UserEnterExclusive();
if (!IS_IMM_MODE())
goto Quit;
pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT);
if (!pIMC)
goto Quit;
ptiIMC = pIMC->head.pti;
switch (dwType)
{
case QIC_INPUTPROCESSID:
ret = (DWORD_PTR)PsGetThreadProcessId(ptiIMC->pEThread);
break;
case QIC_INPUTTHREADID:
ret = (DWORD_PTR)PsGetThreadId(ptiIMC->pEThread);
break;
case QIC_DEFAULTWINDOWIME:
if (ptiIMC->spwndDefaultIme)
ret = (DWORD_PTR)UserHMGetHandle(ptiIMC->spwndDefaultIme);
break;
case QIC_DEFAULTIMC:
if (ptiIMC->spDefaultImc)
ret = (DWORD_PTR)UserHMGetHandle(ptiIMC->spDefaultImc);
break;
}
Quit:
UserLeave();
return ret;
}
BOOL