https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f848343bffa662c6c4fc8…
commit f848343bffa662c6c4fc81b0198256d1d1edcbbc
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Apr 14 14:10:19 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Thu Apr 14 14:10:19 2022 +0900
[IMM32] Improve ImmLockClientImc (#4450)
CORE-11700
---
dll/win32/imm32/imm.c | 35 +++++++++++++++++------------------
dll/win32/imm32/utils.c | 1 +
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 4a440d9fb41..5d199630229 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -907,38 +907,37 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
TRACE("(%p)\n", hImc);
- if (hImc == NULL)
+ if (!hImc)
return NULL;
pIMC = ValidateHandleNoErr(hImc, TYPE_INPUTCONTEXT);
- if (pIMC == NULL || !Imm32CheckImcProcess(pIMC))
+ if (!pIMC || !Imm32CheckImcProcess(pIMC))
return NULL;
pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
- if (!pClientImc)
+ if (pClientImc)
{
- pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
- if (!pClientImc)
+ if (pClientImc->dwFlags & CLIENTIMC_DESTROY)
return NULL;
+ goto Finish;
+ }
- RtlInitializeCriticalSection(&pClientImc->cs);
-
- pClientImc->dwCompatFlags =
(DWORD)NtUserGetThreadState(THREADSTATE_IMECOMPATFLAGS);
+ pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
+ if (!pClientImc)
+ return NULL;
- if (!NtUserUpdateInputContext(hImc, UIC_CLIENTIMCDATA, (DWORD_PTR)pClientImc))
- {
- ImmLocalFree(pClientImc);
- return NULL;
- }
+ RtlInitializeCriticalSection(&pClientImc->cs);
+ pClientImc->dwCompatFlags =
(DWORD)NtUserGetThreadState(THREADSTATE_IMECOMPATFLAGS);
- pClientImc->dwFlags |= CLIENTIMC_UNKNOWN2;
- }
- else
+ if (!NtUserUpdateInputContext(hImc, UIC_CLIENTIMCDATA, (DWORD_PTR)pClientImc))
{
- if (pClientImc->dwFlags & CLIENTIMC_DESTROY)
- return NULL;
+ ImmLocalFree(pClientImc);
+ return NULL;
}
+ pClientImc->dwFlags |= CLIENTIMC_UNKNOWN2;
+
+Finish:
InterlockedIncrement(&pClientImc->cLockObj);
return pClientImc;
}
diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c
index 26f6715f4fc..b3618536782 100644
--- a/dll/win32/imm32/utils.c
+++ b/dll/win32/imm32/utils.c
@@ -213,6 +213,7 @@ PWND FASTCALL ValidateHwndNoErr(HWND hwnd)
return ValidateHandleNoErr(hwnd, TYPE_WINDOW);
}
+// Win: TestInputContextProcess
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
{
HIMC hIMC;