https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c2a943653e1f4881a10d2…
commit c2a943653e1f4881a10d20054ae951bd53cc1a1c
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Oct 23 09:51:24 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Oct 23 09:51:24 2022 +0900
[IMM32] Improve debuggability at all (#4798)
- Strengthen tracing.
- Introduce IS_NULL_UNEXPECTEDLY, IS_ZERO_UNEXPECTEDLY etc. macros to manage tracing.
CORE-11700
---
dll/win32/imm32/candidate.c | 36 ++++--
dll/win32/imm32/compstr.c | 69 +++++-----
dll/win32/imm32/ctf.c | 6 +-
dll/win32/imm32/guideline.c | 6 +-
dll/win32/imm32/ime.c | 300 ++++++++++++++++++++++++++++++--------------
dll/win32/imm32/imm.c | 169 +++++++++++++++++--------
dll/win32/imm32/keymsg.c | 126 +++++++++++--------
dll/win32/imm32/precomp.h | 68 ++++++----
dll/win32/imm32/regword.c | 75 ++++++-----
dll/win32/imm32/utils.c | 161 ++++++++++++++++++------
dll/win32/imm32/win3.c | 23 ++--
11 files changed, 685 insertions(+), 354 deletions(-)
diff --git a/dll/win32/imm32/candidate.c b/dll/win32/imm32/candidate.c
index f816500d75d..a1df77e7b33 100644
--- a/dll/win32/imm32/candidate.c
+++ b/dll/win32/imm32/candidate.c
@@ -161,19 +161,19 @@ ImmGetCandidateListAW(HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST
lpCandList, DWOR
LPCANDIDATELIST pCL;
pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return 0;
uCodePage = pClientImc->uCodePage;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
{
ImmUnlockClientImc(pClientImc);
return 0;
}
pCI = ImmLockIMCC(pIC->hCandInfo);
- if (pCI == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pCI))
{
ImmUnlockIMC(hIMC);
ImmUnlockClientImc(pClientImc);
@@ -181,7 +181,10 @@ ImmGetCandidateListAW(HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST
lpCandList, DWOR
}
if (pCI->dwSize < sizeof(CANDIDATEINFO) || pCI->dwCount <= dwIndex)
+ {
+ ERR("\n");
goto Quit;
+ }
/* get required size */
pCL = (LPCANDIDATELIST)((LPBYTE)pCI + pCI->dwOffset[dwIndex]);
@@ -245,17 +248,17 @@ ImmGetCandidateListCountAW(HIMC hIMC, LPDWORD lpdwListCount, BOOL
bAnsi)
const CANDIDATELIST *pCL;
const DWORD *pdwOffsets;
- if (lpdwListCount == NULL)
+ if (IS_NULL_UNEXPECTEDLY(lpdwListCount))
return 0;
*lpdwListCount = 0;
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return 0;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
{
ImmUnlockClientImc(pClientImc);
return 0;
@@ -264,7 +267,7 @@ ImmGetCandidateListCountAW(HIMC hIMC, LPDWORD lpdwListCount, BOOL
bAnsi)
uCodePage = pClientImc->uCodePage;
pCI = ImmLockIMCC(pIC->hCandInfo);
- if (pCI == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pCI))
{
ImmUnlockIMC(hIMC);
ImmUnlockClientImc(pClientImc);
@@ -272,7 +275,10 @@ ImmGetCandidateListCountAW(HIMC hIMC, LPDWORD lpdwListCount, BOOL
bAnsi)
}
if (pCI->dwSize < sizeof(CANDIDATEINFO))
+ {
+ ERR("\n");
goto Quit;
+ }
*lpdwListCount = pCI->dwCount; /* the number of candidate lists */
@@ -371,10 +377,13 @@ ImmGetCandidateWindow(HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM
lpCandidate)
TRACE("(%p, %lu, %p)\n", hIMC, dwIndex, lpCandidate);
if (dwIndex >= MAX_CANDIDATEFORM) /* Windows didn't check but we do for
security reason */
+ {
+ ERR("\n");
return FALSE;
+ }
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
pCF = &pIC->cfCandForm[dwIndex];
@@ -383,6 +392,10 @@ ImmGetCandidateWindow(HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM
lpCandidate)
*lpCandidate = *pCF;
ret = TRUE;
}
+ else
+ {
+ ERR("\n");
+ }
ImmUnlockIMC(hIMC);
TRACE("ret: %d\n", ret);
@@ -400,13 +413,16 @@ BOOL WINAPI ImmSetCandidateWindow(HIMC hIMC, LPCANDIDATEFORM
lpCandidate)
TRACE("(%p, %p)\n", hIMC, lpCandidate);
if (lpCandidate->dwIndex >= MAX_CANDIDATEFORM)
+ {
+ ERR("\n");
return FALSE;
+ }
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
hWnd = pIC->hWnd;
diff --git a/dll/win32/imm32/compstr.c b/dll/win32/imm32/compstr.c
index 2230a0858bc..980e904e1c6 100644
--- a/dll/win32/imm32/compstr.c
+++ b/dll/win32/imm32/compstr.c
@@ -23,11 +23,11 @@ Imm32OpenICAndCS(HIMC hIMC, LPINPUTCONTEXT *ppIC, LPCOMPOSITIONSTRING
*ppCS)
*ppCS = NULL;
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
pCS = ImmLockIMCC(pIC->hCompStr);
- if (!pCS)
+ if (IS_NULL_UNEXPECTEDLY(pCS))
{
ImmUnlockIMC(hIMC);
return FALSE;
@@ -272,7 +272,7 @@ Imm32GetCompStrA(HIMC hIMC, const COMPOSITIONSTRING *pCS, DWORD
dwIndex,
break;
default:
- FIXME("TODO:\n");
+ FIXME("\n");
return IMM_ERROR_GENERAL;
}
}
@@ -357,7 +357,7 @@ Imm32GetCompStrA(HIMC hIMC, const COMPOSITIONSTRING *pCS, DWORD
dwIndex,
break;
default:
- FIXME("TODO:\n");
+ FIXME("\n");
return IMM_ERROR_GENERAL;
}
}
@@ -449,7 +449,7 @@ Imm32GetCompStrW(HIMC hIMC, const COMPOSITIONSTRING *pCS, DWORD
dwIndex,
break;
default:
- FIXME("TODO:\n");
+ FIXME("\n");
return IMM_ERROR_GENERAL;
}
}
@@ -506,7 +506,7 @@ Imm32GetCompStrW(HIMC hIMC, const COMPOSITIONSTRING *pCS, DWORD
dwIndex,
break;
default:
- FIXME("TODO:\n");
+ FIXME("\n");
return IMM_ERROR_GENERAL;
}
}
@@ -531,11 +531,14 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
if (dwThreadId != GetCurrentThreadId())
+ {
+ ERR("\n");
return FALSE;
+ }
hKL = GetKeyboardLayout(dwThreadId);
pImeDpi = ImmLockImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
uCodePage = pImeDpi->uCodePage;
@@ -551,11 +554,12 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
break;
/* FALL THROUGH */
default:
+ ERR("\n");
ImmUnlockImeDpi(pImeDpi);
return FALSE;
}
- if (bAnsiAPI == bAnsiClient || (!pComp && !pRead))
+ if (bAnsiAPI == bAnsiClient || (!pComp && !pRead)) /* No conversion needed
*/
{
ret = pImeDpi->ImeSetCompositionString(hIMC, dwIndex, pComp, dwCompLen,
pRead, dwReadLen);
@@ -565,6 +569,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
if (!Imm32OpenICAndCS(hIMC, &pIC, &pCS))
{
+ ERR("\n");
ImmUnlockImeDpi(pImeDpi);
return FALSE;
}
@@ -585,7 +590,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbCompNew = Imm32CompStrWideToAnsi(pComp, dwCompLen, NULL, 0,
uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
Imm32CompStrWideToAnsi(pComp, dwCompLen, pCompNew, cbCompNew,
uCodePage);
@@ -594,7 +599,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbCompNew = Imm32CompStrAnsiToWide(pComp, dwCompLen, NULL, 0,
uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
Imm32CompStrAnsiToWide(pComp, dwCompLen, pCompNew, cbCompNew,
uCodePage);
@@ -607,7 +612,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbReadNew = Imm32CompStrWideToAnsi(pRead, dwReadLen, NULL, 0,
uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
Imm32CompStrWideToAnsi(pRead, dwReadLen, pReadNew, cbReadNew,
uCodePage);
@@ -616,7 +621,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbReadNew = Imm32CompStrAnsiToWide(pRead, dwReadLen, NULL, 0,
uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
Imm32CompStrAnsiToWide(pRead, dwReadLen, pReadNew, cbReadNew,
uCodePage);
@@ -634,7 +639,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
CS_SizeW(pCS, CompStr),
NULL, 0, uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
Imm32CompAttrWideToAnsi(pComp, dwCompLen,
@@ -648,7 +653,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
CS_SizeA(pCS, CompStr),
NULL, 0, uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
Imm32CompAttrAnsiToWide(pComp, dwCompLen,
@@ -666,7 +671,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
CS_SizeW(pCS, CompReadStr),
NULL, 0, uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
Imm32CompAttrWideToAnsi(pRead, dwReadLen,
@@ -680,7 +685,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
CS_SizeA(pCS, CompReadStr),
NULL, 0, uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
Imm32CompAttrAnsiToWide(pRead, dwReadLen,
@@ -698,7 +703,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
cbCompNew = Imm32CompClauseWideToAnsi(pComp, dwCompLen, CS_StrW(pCS,
CompStr),
NULL, 0, uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
Imm32CompClauseWideToAnsi(pComp, dwCompLen, CS_StrW(pCS, CompStr),
@@ -709,7 +714,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
cbCompNew = Imm32CompClauseAnsiToWide(pComp, dwCompLen, CS_StrA(pCS,
CompStr),
NULL, 0, uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
Imm32CompClauseAnsiToWide(pComp, dwCompLen, CS_StrA(pCS, CompStr),
@@ -724,7 +729,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
cbReadNew = Imm32CompClauseWideToAnsi(pRead, dwReadLen, CS_StrW(pCS,
CompReadStr),
NULL, 0, uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
Imm32CompClauseWideToAnsi(pRead, dwReadLen,
@@ -736,7 +741,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
cbReadNew = Imm32CompClauseAnsiToWide(pRead, dwReadLen, CS_StrA(pCS,
CompReadStr),
NULL, 0, uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
Imm32CompClauseAnsiToWide(pRead, dwReadLen, CS_StrA(pCS,
CompReadStr),
@@ -753,7 +758,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbCompNew = Imm32ReconvertAnsiFromWide(NULL, pComp, uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
pRS = pCompNew;
@@ -765,7 +770,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbCompNew = Imm32ReconvertWideFromAnsi(NULL, pComp, uCodePage);
pCompNew = ImmLocalAlloc(0, cbCompNew);
- if (!pCompNew)
+ if (IS_NULL_UNEXPECTEDLY(pCompNew))
goto Quit;
pRS = pCompNew;
@@ -781,7 +786,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbReadNew = Imm32ReconvertAnsiFromWide(NULL, pRead, uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
pRS = pReadNew;
@@ -793,7 +798,7 @@ ImmSetCompositionStringAW(HIMC hIMC, DWORD dwIndex, LPVOID pComp,
DWORD dwCompLe
{
cbReadNew = Imm32ReconvertWideFromAnsi(NULL, pRead, uCodePage);
pReadNew = ImmLocalAlloc(0, cbReadNew);
- if (!pReadNew)
+ if (IS_NULL_UNEXPECTEDLY(pReadNew))
goto Quit;
pRS = pReadNew;
@@ -859,11 +864,11 @@ LONG WINAPI ImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex,
LPVOID lpBuf, DWO
TRACE("(%p, %lu, %p, %lu)\n", hIMC, dwIndex, lpBuf, dwBufLen);
- if (dwBufLen && !lpBuf)
+ if (dwBufLen && IS_NULL_UNEXPECTEDLY(lpBuf))
return 0;
pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return 0;
bAnsiClient = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
@@ -871,11 +876,11 @@ LONG WINAPI ImmGetCompositionStringA(HIMC hIMC, DWORD dwIndex,
LPVOID lpBuf, DWO
ImmUnlockClientImc(pClientImc);
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return 0;
pCS = ImmLockIMCC(pIC->hCompStr);
- if (!pCS)
+ if (IS_NULL_UNEXPECTEDLY(pCS))
{
ImmUnlockIMC(hIMC);
return 0;
@@ -902,11 +907,11 @@ LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex,
LPVOID lpBuf, DWO
TRACE("(%p, %lu, %p, %lu)\n", hIMC, dwIndex, lpBuf, dwBufLen);
- if (dwBufLen && !lpBuf)
+ if (dwBufLen && IS_NULL_UNEXPECTEDLY(lpBuf))
return 0;
pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return 0;
bAnsiClient = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
@@ -914,11 +919,11 @@ LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex,
LPVOID lpBuf, DWO
ImmUnlockClientImc(pClientImc);
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return 0;
pCS = ImmLockIMCC(pIC->hCompStr);
- if (!pCS)
+ if (IS_NULL_UNEXPECTEDLY(pCS))
{
ImmUnlockIMC(hIMC);
return 0;
diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c
index 711e2d5cadf..8495725ed0f 100644
--- a/dll/win32/imm32/ctf.c
+++ b/dll/win32/imm32/ctf.c
@@ -20,7 +20,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm);
// Win: LoadCtfIme
HMODULE APIENTRY Imm32LoadCtfIme(VOID)
{
- FIXME("()\n");
return NULL;
}
@@ -29,6 +28,7 @@ HRESULT APIENTRY Imm32CtfImeDestroyInputContext(HIMC hIMC)
{
if (!Imm32LoadCtfIme())
return E_FAIL;
+
#if 1
FIXME("(%p)\n", hIMC);
return E_NOTIMPL;
@@ -126,7 +126,7 @@ BOOL WINAPI CtfImmIsGuidMapEnable(HIMC hIMC)
return ret;
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return ret;
ret = pImeDpi->CtfImeIsGuidMapEnable(hIMC);
@@ -158,7 +158,7 @@ HRESULT WINAPI CtfImmGetGuidAtom(HIMC hIMC, DWORD dwUnknown, LPDWORD
pdwGuidAtom
return S_OK;
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return hr;
hr = pImeDpi->CtfImeGetGuidAtom(hIMC, dwUnknown, pdwGuidAtom);
diff --git a/dll/win32/imm32/guideline.c b/dll/win32/imm32/guideline.c
index ea0658e0505..7a3e26b63a2 100644
--- a/dll/win32/imm32/guideline.c
+++ b/dll/win32/imm32/guideline.c
@@ -22,20 +22,20 @@ ImmGetGuideLineAW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD
dwBufLen, BOOL b
UINT uCodePage;
pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return 0;
uCodePage = pClientImc->uCodePage;
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
{
ImmUnlockClientImc(pClientImc);
return 0;
}
pGuideLine = ImmLockIMCC(pIC->hGuideLine);
- if (!pGuideLine)
+ if (IS_NULL_UNEXPECTEDLY(pGuideLine))
{
ImmUnlockIMC(hIMC);
ImmUnlockClientImc(pClientImc);
diff --git a/dll/win32/imm32/ime.c b/dll/win32/imm32/ime.c
index 45cde47c7f1..9bc3cd6830a 100644
--- a/dll/win32/imm32/ime.c
+++ b/dll/win32/imm32/ime.c
@@ -60,21 +60,28 @@ BOOL APIENTRY Imm32InquireIme(PIMEDPI pImeDpi)
if (IS_IME_HKL(pImeDpi->hKL))
{
if (!pImeDpi->ImeInquire(pImeInfo, szUIClass, dwSysInfoFlags))
+ {
+ ERR("\n");
return FALSE;
+ }
}
else if (IS_CICERO_MODE() && !IS_16BIT_MODE())
{
if (!pImeDpi->CtfImeInquireExW(pImeInfo, szUIClass, dwSysInfoFlags,
pImeDpi->hKL))
+ {
+ ERR("\n");
return FALSE;
+ }
}
else
{
+ ERR("\n");
return FALSE;
}
szUIClass[_countof(szUIClass) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
- if (pImeInfo->dwPrivateDataSize == 0)
+ if (pImeInfo->dwPrivateDataSize < sizeof(DWORD))
pImeInfo->dwPrivateDataSize = sizeof(DWORD);
#define VALID_IME_PROP (IME_PROP_AT_CARET | \
@@ -117,17 +124,35 @@ BOOL APIENTRY Imm32InquireIme(PIMEDPI pImeDpi)
#define VALID_SELECT_CAPS (SELECT_CAP_CONVERSION | SELECT_CAP_SENTENCE)
if (pImeInfo->fdwProperty & ~VALID_IME_PROP)
+ {
+ ERR("\n");
return FALSE;
+ }
if (pImeInfo->fdwConversionCaps & ~VALID_CMODE_CAPS)
+ {
+ ERR("\n");
return FALSE;
+ }
if (pImeInfo->fdwSentenceCaps & ~VALID_SMODE_CAPS)
+ {
+ ERR("\n");
return FALSE;
+ }
if (pImeInfo->fdwUICaps & ~VALID_UI_CAPS)
+ {
+ ERR("\n");
return FALSE;
+ }
if (pImeInfo->fdwSCSCaps & ~VALID_SCS_CAPS)
+ {
+ ERR("\n");
return FALSE;
+ }
if (pImeInfo->fdwSelectCaps & ~VALID_SELECT_CAPS)
+ {
+ ERR("\n");
return FALSE;
+ }
#undef VALID_IME_PROP
#undef VALID_CMODE_CAPS
@@ -151,7 +176,13 @@ BOOL APIENTRY Imm32InquireIme(PIMEDPI pImeDpi)
pImeDpi->szUIClass[_countof(pImeDpi->szUIClass) - 1] = UNICODE_NULL;
}
- return GetClassInfoW(pImeDpi->hInst, pImeDpi->szUIClass, &wcW);
+ if (!GetClassInfoW(pImeDpi->hInst, pImeDpi->szUIClass, &wcW))
+ {
+ ERR("\n");
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Define stub IME functions */
@@ -177,7 +208,7 @@ BOOL APIENTRY Imm32LoadIME(PIMEINFOEX pImeInfoEx, PIMEDPI pImeDpi)
pImeDpi->hInst = hIME = LoadLibraryW(szPath);
if (hIME == NULL)
{
- ERR("Imm32LoadIME: LoadLibraryW(%s) failed\n", debugstr_w(szPath));
+ ERR("LoadLibraryW(%s) failed\n", debugstr_w(szPath));
return FALSE;
}
@@ -242,14 +273,23 @@ PIMEDPI APIENTRY Imm32LoadImeDpi(HKL hKL, BOOL bLock)
UINT uCodePage;
LCID lcid;
- if (!ImmGetImeInfoEx(&ImeInfoEx, ImeInfoExKeyboardLayout, &hKL) ||
- ImeInfoEx.fLoadFlag == 1)
+ if (!IS_IME_HKL(hKL))
+ return NULL;
+
+ if (!ImmGetImeInfoEx(&ImeInfoEx, ImeInfoExKeyboardLayout, &hKL))
+ {
+ ERR("\n");
+ return NULL;
+ }
+
+ if (ImeInfoEx.fLoadFlag == 1)
{
+ ERR("\n");
return NULL;
}
pImeDpiNew = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(IMEDPI));
- if (pImeDpiNew == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpiNew))
return NULL;
pImeDpiNew->hKL = hKL;
@@ -263,6 +303,7 @@ PIMEDPI APIENTRY Imm32LoadImeDpi(HKL hKL, BOOL bLock)
if (!Imm32LoadIME(&ImeInfoEx, pImeDpiNew))
{
+ ERR("\n");
ImmLocalFree(pImeDpiNew);
return FALSE;
}
@@ -302,7 +343,10 @@ PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL)
PIMEDPI pImeDpi;
if (!IS_IME_HKL(hKL) && (!IS_CICERO_MODE() || IS_16BIT_MODE()))
+ {
+ ERR("\n");
return NULL;
+ }
pImeDpi = ImmLockImeDpi(hKL);
if (pImeDpi == NULL)
@@ -315,7 +359,6 @@ ImeDpi_Escape(PIMEDPI pImeDpi, HIMC hIMC, UINT uSubFunc, LPVOID
lpData, HKL hKL)
{
if (IS_IME_HKL(hKL))
return pImeDpi->ImeEscape(hIMC, uSubFunc, lpData);
-
if (IS_CICERO_MODE() && !IS_16BIT_MODE())
return pImeDpi->CtfImeEscapeEx(hIMC, uSubFunc, lpData, hKL);
@@ -412,7 +455,7 @@ LRESULT WINAPI ImmPutImeMenuItemsIntoMappedFile(HIMC hIMC)
pView = MapViewOfFile(hMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (!pView || pView->dwVersion != 1)
{
- ERR("hMapping %p, pView %p\n", hMapping, pView);
+ ERR("\n");
goto Quit;
}
@@ -423,16 +466,13 @@ LRESULT WINAPI ImmPutImeMenuItemsIntoMappedFile(HIMC hIMC)
{
cbItems = pView->dwItemCount * sizeof(IMEMENUITEMINFOW);
pItems = ImmLocalAlloc(HEAP_ZERO_MEMORY, cbItems);
- if (!pItems)
- {
- ERR("!pItems\n");
+ if (IS_NULL_UNEXPECTEDLY(pItems))
goto Quit;
- }
}
cItems = ImmGetImeMenuItemsW(hIMC, pView->dwFlags, pView->dwType, pParent,
pItems, cbItems);
pView->dwItemCount = cItems;
- if (cItems == 0)
+ if (IS_ZERO_UNEXPECTEDLY(cItems))
goto Quit;
if (pItems)
@@ -490,7 +530,7 @@ Imm32GetImeMenuItemWInterProcess(HIMC hIMC, DWORD dwFlags, DWORD
dwType, LPVOID
hImeWnd = (HWND)NtUserQueryInputContext(hIMC, QIC_DEFAULTWINDOWIME);
if (!hImeWnd || !IsWindow(hImeWnd))
{
- ERR("hImeWnd %p\n", hImeWnd);
+ ERR("\n");
return 0;
}
@@ -503,11 +543,8 @@ Imm32GetImeMenuItemWInterProcess(HIMC hIMC, DWORD dwFlags, DWORD
dwType, LPVOID
hMapping = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
0, cbView, L"ImmMenuInfo");
pView = MapViewOfFile(hMapping, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
- if (!pView)
- {
- ERR("hMapping %p, pView %p\n", hMapping, pView);
+ if (IS_NULL_UNEXPECTEDLY(pView))
goto Quit;
- }
ZeroMemory(pView, cbView);
pView->dwVersion = 1;
@@ -521,7 +558,10 @@ Imm32GetImeMenuItemWInterProcess(HIMC hIMC, DWORD dwFlags, DWORD
dwType, LPVOID
}
if (!SendMessageW(hImeWnd, WM_IME_SYSTEM, IMS_GETIMEMENU, (LPARAM)hIMC))
+ {
+ ERR("\n");
goto Quit;
+ }
ret = pView->dwItemCount;
@@ -575,11 +615,11 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
BOOL bImcIsAnsi;
HKL hKL;
- if (!hIMC)
+ if (IS_NULL_UNEXPECTEDLY(hIMC))
return 0;
dwProcessId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTPROCESSID);
- if (dwProcessId == 0)
+ if (IS_ZERO_UNEXPECTEDLY(dwProcessId))
return 0;
if (dwProcessId != GetCurrentProcessId())
@@ -591,11 +631,11 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
}
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return 0;
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
- if (dwThreadId == 0)
+ if (IS_ZERO_UNEXPECTEDLY(dwThreadId))
{
ImmUnlockIMC(hIMC);
return 0;
@@ -603,7 +643,7 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
hKL = GetKeyboardLayout(dwThreadId);
pImeDpi = ImmLockImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
{
ImmUnlockIMC(hIMC);
return 0;
@@ -622,7 +662,7 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
{
cbTotal = ((dwSize / sizeof(IMEMENUITEMINFOA)) *
sizeof(IMEMENUITEMINFOW));
pNewItems = ImmLocalAlloc(0, cbTotal);
- if (!pNewItems)
+ if (IS_NULL_UNEXPECTEDLY(pNewItems))
goto Quit;
}
}
@@ -635,7 +675,7 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
{
cbTotal = ((dwSize / sizeof(IMEMENUITEMINFOW)) *
sizeof(IMEMENUITEMINFOA));
pNewItems = ImmLocalAlloc(0, cbTotal);
- if (!pNewItems)
+ if (IS_NULL_UNEXPECTEDLY(pNewItems))
goto Quit;
}
}
@@ -647,7 +687,7 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
}
ret = pImeDpi->ImeGetImeMenuItems(hIMC, dwFlags, dwType, pNewParent, pNewItems,
dwSize);
- if (!ret || !lpImeMenu)
+ if (IS_ZERO_UNEXPECTEDLY(ret) || !lpImeMenu)
goto Quit;
if (bImcIsAnsi != bTargetIsAnsi)
@@ -663,6 +703,7 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
{
if (!Imm32ImeMenuWideToAnsi(pItemW, pItemA, pImeDpi->uCodePage))
{
+ ERR("\n");
ret = 0;
break;
}
@@ -679,6 +720,7 @@ ImmGetImeMenuItemsAW(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPVOID
lpImeParentM
{
if (!Imm32ImeMenuAnsiToWide(pItemA, pItemW, pImeDpi->uCodePage,
TRUE))
{
+ ERR("\n");
ret = 0;
break;
}
@@ -691,6 +733,7 @@ Quit:
ImmLocalFree(pNewItems);
ImmUnlockImeDpi(pImeDpi);
ImmUnlockIMC(hIMC);
+ TRACE("ret: 0x%X\n", ret);
return ret;
}
@@ -705,11 +748,11 @@ HKL WINAPI ImmInstallIMEA(LPCSTR lpszIMEFileName, LPCSTR
lpszLayoutText)
TRACE("(%s, %s)\n", debugstr_a(lpszIMEFileName),
debugstr_a(lpszLayoutText));
pszFileNameW = Imm32WideFromAnsi(CP_ACP, lpszIMEFileName);
- if (!pszFileNameW)
+ if (IS_NULL_UNEXPECTEDLY(pszFileNameW))
goto Quit;
pszLayoutTextW = Imm32WideFromAnsi(CP_ACP, lpszLayoutText);
- if (!pszLayoutTextW)
+ if (IS_NULL_UNEXPECTEDLY(pszLayoutTextW))
goto Quit;
hKL = ImmInstallIMEW(pszFileNameW, pszLayoutTextW);
@@ -737,16 +780,18 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
GetFullPathNameW(lpszIMEFileName, _countof(szImeFileName), szImeFileName,
&pchFilePart);
CharUpperW(szImeFileName);
- if (!pchFilePart)
+ if (IS_NULL_UNEXPECTEDLY(pchFilePart))
return NULL;
/* Load the IME version info */
InfoEx.hkl = hNewKL = NULL;
StringCchCopyW(InfoEx.wszImeFile, _countof(InfoEx.wszImeFile), pchFilePart);
- if (Imm32LoadImeVerInfo(&InfoEx) && InfoEx.hkl)
- wLangID = LOWORD(InfoEx.hkl);
- else
+ if (!Imm32LoadImeVerInfo(&InfoEx) || !InfoEx.hkl)
+ {
+ ERR("\n");
return NULL;
+ }
+ wLangID = LOWORD(InfoEx.hkl);
/* Get the IME layouts from registry */
cLayouts = Imm32GetImeLayout(NULL, 0);
@@ -755,6 +800,7 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
pLayouts = ImmLocalAlloc(0, cLayouts * sizeof(REG_IME));
if (!pLayouts || !Imm32GetImeLayout(pLayouts, cLayouts))
{
+ ERR("\n");
ImmLocalFree(pLayouts);
return NULL;
}
@@ -764,7 +810,10 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
if (lstrcmpiW(pLayouts[iLayout].szFileName, pchFilePart) == 0)
{
if (wLangID != LOWORD(pLayouts[iLayout].hKL))
+ {
+ ERR("\n");
goto Quit; /* The language is different */
+ }
hNewKL = pLayouts[iLayout].hKL; /* Found */
break;
@@ -776,6 +825,7 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
if (ImmGetImeInfoEx(&InfoEx, ImeInfoExImeFileName, pchFilePart) &&
!UnloadKeyboardLayout(InfoEx.hkl))
{
+ ERR("\n");
hNewKL = NULL;
goto Quit;
}
@@ -787,6 +837,7 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
if (lstrcmpiW(szImeFileName, szImeDestPath) != 0 &&
!Imm32CopyImeFile(szImeFileName, szImeDestPath))
{
+ ERR("\n");
hNewKL = NULL;
goto Quit;
}
@@ -800,11 +851,12 @@ HKL WINAPI ImmInstallIMEW(LPCWSTR lpszIMEFileName, LPCWSTR
lpszLayoutText)
if (Imm32WriteImeLayout(hNewKL, pchFilePart, lpszLayoutText))
{
/* Load the keyboard layout */
- Imm32UIntToStr((DWORD)(DWORD_PTR)hNewKL, 16, szImeKey, _countof(szImeKey));
+ StringCchPrintfW(szImeKey, _countof(szImeKey), L"%08X",
(DWORD)(DWORD_PTR)hNewKL);
hNewKL = LoadKeyboardLayoutW(szImeKey, KLF_REPLACELANG);
}
else
{
+ ERR("\n");
hNewKL = NULL;
}
}
@@ -830,7 +882,10 @@ BOOL WINAPI ImmIsIME(HKL hKL)
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
{
if (!IS_IMM_MODE())
+ {
+ WARN("\n");
return NULL;
+ }
if (hWnd == NULL)
return (HWND)NtUserGetThreadState(THREADSTATE_DEFAULTIMEWINDOW);
@@ -849,12 +904,12 @@ BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex,
DWORD dwValue
TRACE("(%p, %lu, %lu, %lu)\n", hIMC, dwAction, dwIndex, dwValue);
- if (hIMC && Imm32IsCrossThreadAccess(hIMC))
+ if (hIMC && IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
hKL = GetKeyboardLayout(0);
pImeDpi = ImmLockImeDpi(hKL);
- if (pImeDpi == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
ret = pImeDpi->NotifyIME(hIMC, dwAction, dwIndex, dwValue);
@@ -888,7 +943,10 @@ ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType,
PVOID pvSearch
if (!IS_IME_HKL(hKL))
{
if (CtfImmIsTextFrameServiceDisabled() || !IS_CICERO_MODE() ||
IS_16BIT_MODE())
+ {
+ TRACE("\n");
return FALSE;
+ }
}
SearchType = ImeInfoExKeyboardLayout;
@@ -896,7 +954,10 @@ ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType,
PVOID pvSearch
else
{
if (!IS_IME_HKL(hKL))
+ {
+ TRACE("\n");
return FALSE;
+ }
}
}
else if (SearchType == ImeInfoExImeFileName)
@@ -997,7 +1058,10 @@ BOOL WINAPI ImmLoadIME(HKL hKL)
PIMEDPI pImeDpi;
if (!IS_IME_HKL(hKL) && (!IS_CICERO_MODE() || IS_16BIT_MODE()))
+ {
+ TRACE("\n");
return FALSE;
+ }
pImeDpi = Imm32FindImeDpi(hKL);
if (pImeDpi == NULL)
@@ -1023,9 +1087,15 @@ UINT WINAPI ImmGetDescriptionA(HKL hKL, LPSTR lpszDescription, UINT
uBufLen)
TRACE("(%p,%p,%d)\n", hKL, lpszDescription, uBufLen);
- if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL) ||
!IS_IME_HKL(hKL))
+ if (!IS_IME_HKL(hKL))
return 0;
+ if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL))
+ {
+ ERR("\n");
+ return 0;
+ }
+
StringCchLengthW(info.wszImeDescription, _countof(info.wszImeDescription),
&cch);
cch = WideCharToMultiByte(CP_ACP, 0, info.wszImeDescription, (INT)cch,
lpszDescription, uBufLen, NULL, NULL);
@@ -1044,9 +1114,15 @@ UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription,
UINT uBufLen)
TRACE("(%p, %p, %d)\n", hKL, lpszDescription, uBufLen);
- if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL) ||
!IS_IME_HKL(hKL))
+ if (!IS_IME_HKL(hKL))
return 0;
+ if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL))
+ {
+ ERR("\n");
+ return 0;
+ }
+
if (uBufLen != 0)
StringCchCopyW(lpszDescription, uBufLen, info.wszImeDescription);
@@ -1065,8 +1141,16 @@ UINT WINAPI ImmGetIMEFileNameA( HKL hKL, LPSTR lpszFileName, UINT
uBufLen)
TRACE("(%p, %p, %u)\n", hKL, lpszFileName, uBufLen);
- if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL) ||
!IS_IME_HKL(hKL))
+ if (!IS_IME_HKL(hKL))
+ {
+ if (uBufLen > 0)
+ lpszFileName[0] = 0;
+ return 0;
+ }
+
+ if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL))
{
+ ERR("\n");
if (uBufLen > 0)
lpszFileName[0] = 0;
return 0;
@@ -1096,13 +1180,21 @@ UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT
uBufLen)
TRACE("(%p, %p, %u)\n", hKL, lpszFileName, uBufLen);
- if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL) ||
!IS_IME_HKL(hKL))
+ if (!IS_IME_HKL(hKL))
{
if (uBufLen > 0)
lpszFileName[0] = 0;
return 0;
}
+ if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL))
+ {
+ ERR("\n");
+ if (uBufLen > 0)
+ lpszFileName[0] = 0;
+ return 0;
+ }
+
StringCchLengthW(info.wszImeFile, _countof(info.wszImeFile), &cch);
if (uBufLen == 0)
return (UINT)cch;
@@ -1128,8 +1220,14 @@ DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex)
TRACE("(%p, %lu)\n", hKL, fdwIndex);
+ if (!IS_IME_HKL(hKL))
+ return FALSE;
+
if (!ImmGetImeInfoEx(&ImeInfoEx, ImeInfoExKeyboardLayout, &hKL))
+ {
+ ERR("\n");
return FALSE;
+ }
if (fdwIndex == IGP_GETIMEVERSION)
return ImeInfoEx.dwImeWinVersion;
@@ -1137,7 +1235,7 @@ DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex)
if (ImeInfoEx.fLoadFlag != 2)
{
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (pImeDpi == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
pImeInfo = &pImeDpi->ImeInfo;
@@ -1177,10 +1275,10 @@ LRESULT WINAPI ImmEscapeA(HKL hKL, HIMC hIMC, UINT uSubFunc,
LPVOID lpData)
TRACE("(%p, %p, %u, %p)\n", hKL, hIMC, uSubFunc, lpData);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (!ImeDpi_IsUnicode(pImeDpi) || !lpData)
+ if (!ImeDpi_IsUnicode(pImeDpi) || !lpData) /* No conversion needed */
{
ret = ImeDpi_Escape(pImeDpi, hIMC, uSubFunc, lpData, hKL);
ImmUnlockImeDpi(pImeDpi);
@@ -1247,6 +1345,7 @@ LRESULT WINAPI ImmEscapeA(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID
lpData)
}
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %p\n", ret);
return ret;
}
@@ -1265,10 +1364,10 @@ LRESULT WINAPI ImmEscapeW(HKL hKL, HIMC hIMC, UINT uSubFunc,
LPVOID lpData)
TRACE("(%p, %p, %u, %p)\n", hKL, hIMC, uSubFunc, lpData);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (ImeDpi_IsUnicode(pImeDpi) || !lpData)
+ if (ImeDpi_IsUnicode(pImeDpi) || !lpData) /* No conversion needed */
{
ret = ImeDpi_Escape(pImeDpi, hIMC, uSubFunc, lpData, hKL);
ImmUnlockImeDpi(pImeDpi);
@@ -1324,6 +1423,7 @@ LRESULT WINAPI ImmEscapeW(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID
lpData)
}
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %p\n", ret);
return ret;
}
@@ -1337,16 +1437,16 @@ BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
TRACE("(%p)\n", hIMC);
- if (!hIMC)
+ if (IS_NULL_UNEXPECTEDLY(hIMC))
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
ret = pIC->fOpen;
-
ImmUnlockIMC(hIMC);
+ TRACE("ret: %d\n", ret);
return ret;
}
@@ -1362,11 +1462,11 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
TRACE("(%p, %d)\n", hIMC, fOpen);
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (pIC->fOpen != fOpen)
@@ -1385,6 +1485,10 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
IMC_SETOPENSTATUS, IMN_SETOPENSTATUS, 0);
NtUserNotifyIMEStatus(hWnd, fOpen, dwConversion);
}
+ else
+ {
+ TRACE("No change.\n");
+ }
return TRUE;
}
@@ -1400,7 +1504,7 @@ BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
TRACE("(%p, %p)\n", hIMC, lpptPos);
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
ret = !!(pIC->fdwInit & INIT_STATUSWNDPOS);
@@ -1421,11 +1525,11 @@ BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
TRACE("(%p, {%ld, %ld})\n", hIMC, lpptPos->x, lpptPos->y);
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
hWnd = pIC->hWnd;
@@ -1450,7 +1554,7 @@ BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM
lpCompForm)
TRACE("(%p, %p)\n", hIMC, lpCompForm);
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (pIC->fdwInit & INIT_COMPFORM)
@@ -1471,11 +1575,11 @@ BOOL WINAPI ImmSetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM
lpCompForm)
LPINPUTCONTEXTDX pIC;
HWND hWnd;
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
pIC->cfCompForm = *lpCompForm;
@@ -1507,14 +1611,14 @@ BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
TRACE("(%p, %p)\n", hIMC, lplf);
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
bWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
ImmUnlockClientImc(pClientImc);
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (pIC->fdwInit & INIT_LOGFONT)
@@ -1544,14 +1648,14 @@ BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
TRACE("(%p, %p)\n", hIMC, lplf);
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
bWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
ImmUnlockClientImc(pClientImc);
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (pIC->fdwInit & INIT_LOGFONT)
@@ -1582,11 +1686,11 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
TRACE("(%p, %p)\n", hIMC, lplf);
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
bWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
@@ -1599,7 +1703,7 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
}
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (GetWin32ClientInfo()->dwExpWinVer < _WIN32_WINNT_NT4) /* old version (3.x)?
*/
@@ -1638,11 +1742,11 @@ BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
TRACE("(%p, %p)\n", hIMC, lplf);
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
bWide = (pClientImc->dwFlags & CLIENTIMC_WIDE);
@@ -1655,7 +1759,7 @@ BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
}
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (GetWin32ClientInfo()->dwExpWinVer < _WIN32_WINNT_NT4) /* old version (3.x)?
*/
@@ -1697,10 +1801,10 @@ ImmGetConversionListA(HKL hKL, HIMC hIMC, LPCSTR pSrc,
LPCANDIDATELIST lpDst,
lpDst, dwBufLen, uFlag);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (pImeDpi == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (!ImeDpi_IsUnicode(pImeDpi))
+ if (!ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeConversionList(hIMC, pSrc, lpDst, dwBufLen, uFlag);
ImmUnlockImeDpi(pImeDpi);
@@ -1710,20 +1814,20 @@ ImmGetConversionListA(HKL hKL, HIMC hIMC, LPCSTR pSrc,
LPCANDIDATELIST lpDst,
if (pSrc)
{
pszSrcW = Imm32WideFromAnsi(pImeDpi->uCodePage, pSrc);
- if (pszSrcW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszSrcW))
goto Quit;
}
cb = pImeDpi->ImeConversionList(hIMC, pszSrcW, NULL, 0, uFlag);
- if (cb == 0)
+ if (IS_ZERO_UNEXPECTEDLY(cb))
goto Quit;
pCL = ImmLocalAlloc(0, cb);
- if (pCL == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pCL))
goto Quit;
cb = pImeDpi->ImeConversionList(hIMC, pszSrcW, pCL, cb, uFlag);
- if (cb == 0)
+ if (IS_ZERO_UNEXPECTEDLY(cb))
goto Quit;
ret = CandidateListWideToAnsi(pCL, lpDst, dwBufLen, pImeDpi->uCodePage);
@@ -1732,6 +1836,7 @@ Quit:
ImmLocalFree(pszSrcW);
ImmLocalFree(pCL);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: 0x%X\n", ret);
return ret;
}
@@ -1752,10 +1857,10 @@ ImmGetConversionListW(HKL hKL, HIMC hIMC, LPCWSTR pSrc,
LPCANDIDATELIST lpDst,
lpDst, dwBufLen, uFlag);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (ImeDpi_IsUnicode(pImeDpi))
+ if (ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeConversionList(hIMC, pSrc, lpDst, dwBufLen, uFlag);
ImmUnlockImeDpi(pImeDpi);
@@ -1765,20 +1870,20 @@ ImmGetConversionListW(HKL hKL, HIMC hIMC, LPCWSTR pSrc,
LPCANDIDATELIST lpDst,
if (pSrc)
{
pszSrcA = Imm32AnsiFromWide(pImeDpi->uCodePage, pSrc);
- if (pszSrcA == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszSrcA))
goto Quit;
}
cb = pImeDpi->ImeConversionList(hIMC, pszSrcA, NULL, 0, uFlag);
- if (cb == 0)
+ if (IS_ZERO_UNEXPECTEDLY(cb))
goto Quit;
pCL = ImmLocalAlloc(0, cb);
- if (!pCL)
+ if (IS_NULL_UNEXPECTEDLY(pCL))
goto Quit;
cb = pImeDpi->ImeConversionList(hIMC, pszSrcA, pCL, cb, uFlag);
- if (!cb)
+ if (IS_ZERO_UNEXPECTEDLY(cb))
goto Quit;
ret = CandidateListAnsiToWide(pCL, lpDst, dwBufLen, pImeDpi->uCodePage);
@@ -1787,6 +1892,7 @@ Quit:
ImmLocalFree(pszSrcA);
ImmLocalFree(pCL);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: 0x%X\n", ret);
return ret;
}
@@ -1800,13 +1906,20 @@ BOOL WINAPI ImmGetConversionStatus(HIMC hIMC, LPDWORD
lpfdwConversion, LPDWORD l
TRACE("(%p %p %p)\n", hIMC, lpfdwConversion, lpfdwSentence);
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (lpfdwConversion)
+ {
*lpfdwConversion = pIC->fdwConversion;
+ TRACE("0x%X\n", *lpfdwConversion);
+ }
+
if (lpfdwSentence)
+ {
*lpfdwSentence = pIC->fdwSentence;
+ TRACE("0x%X\n", *lpfdwSentence);
+ }
ImmUnlockIMC(hIMC);
return TRUE;
@@ -1829,11 +1942,11 @@ BOOL WINAPI ImmSetConversionStatus(HIMC hIMC, DWORD fdwConversion,
DWORD fdwSent
if (!IS_IME_HKL(hKL) && IS_CICERO_MODE() && !IS_16BIT_MODE())
fUseCicero = TRUE;
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
if (pIC->fdwConversion != fdwConversion)
@@ -1883,31 +1996,31 @@ BOOL WINAPI ImmConfigureIMEA(HKL hKL, HWND hWnd, DWORD dwMode,
LPVOID lpData)
TRACE("(%p, %p, 0x%lX, %p)\n", hKL, hWnd, dwMode, lpData);
- if (!ValidateHwnd(hWnd) || Imm32IsCrossProcessAccess(hWnd))
+ if (IS_NULL_UNEXPECTEDLY(ValidateHwnd(hWnd)) || IS_CROSS_PROCESS_HWND(hWnd))
return FALSE;
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
RtlZeroMemory(&RegWordW, sizeof(RegWordW));
if (!ImeDpi_IsUnicode(pImeDpi) || !lpData || dwMode != IME_CONFIG_REGISTERWORD)
- goto DoIt;
+ goto DoIt; /* No conversion needed */
pRegWordA = lpData;
if (pRegWordA->lpReading)
{
RegWordW.lpReading = Imm32WideFromAnsi(pImeDpi->uCodePage,
pRegWordA->lpReading);
- if (!RegWordW.lpReading)
+ if (IS_NULL_UNEXPECTEDLY(RegWordW.lpReading))
goto Quit;
}
if (pRegWordA->lpWord)
{
RegWordW.lpWord = Imm32WideFromAnsi(pImeDpi->uCodePage,
pRegWordA->lpWord);
- if (!RegWordW.lpWord)
+ if (IS_NULL_UNEXPECTEDLY(RegWordW.lpWord))
goto Quit;
}
@@ -1922,6 +2035,7 @@ Quit:
ImmLocalFree(RegWordW.lpReading);
ImmLocalFree(RegWordW.lpWord);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %d\n", ret);
return ret;
}
@@ -1937,31 +2051,31 @@ BOOL WINAPI ImmConfigureIMEW(HKL hKL, HWND hWnd, DWORD dwMode,
LPVOID lpData)
TRACE("(%p, %p, 0x%lX, %p)\n", hKL, hWnd, dwMode, lpData);
- if (!ValidateHwnd(hWnd) || Imm32IsCrossProcessAccess(hWnd))
+ if (IS_NULL_UNEXPECTEDLY(ValidateHwnd(hWnd)) || IS_CROSS_PROCESS_HWND(hWnd))
return FALSE;
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
RtlZeroMemory(&RegWordA, sizeof(RegWordA));
if (ImeDpi_IsUnicode(pImeDpi) || !lpData || dwMode != IME_CONFIG_REGISTERWORD)
- goto DoIt;
+ goto DoIt; /* No conversion needed */
pRegWordW = lpData;
if (pRegWordW->lpReading)
{
RegWordA.lpReading = Imm32AnsiFromWide(pImeDpi->uCodePage,
pRegWordW->lpReading);
- if (!RegWordA.lpReading)
+ if (IS_NULL_UNEXPECTEDLY(RegWordA.lpReading))
goto Quit;
}
if (pRegWordW->lpWord)
{
RegWordA.lpWord = Imm32AnsiFromWide(pImeDpi->uCodePage,
pRegWordW->lpWord);
- if (!RegWordA.lpWord)
+ if (IS_NULL_UNEXPECTEDLY(RegWordA.lpWord))
goto Quit;
}
@@ -1976,6 +2090,7 @@ Quit:
ImmLocalFree(RegWordA.lpReading);
ImmLocalFree(RegWordA.lpWord);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %d\n", ret);
return ret;
}
@@ -2024,16 +2139,17 @@ BOOL WINAPI ImmWINNLSEnableIME(HWND hWnd, BOOL enable)
}
hIMC = (HIMC)NtUserGetThreadState(THREADSTATE_DEFAULTINPUTCONTEXT);
- if (!hIMC)
+ if (IS_NULL_UNEXPECTEDLY(hIMC))
return FALSE;
pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
ret = !(pClientImc->dwFlags & CLIENTIMC_DISABLEIME);
if (!!enable == ret)
{
+ TRACE("Same\n");
ImmUnlockClientImc(pClientImc);
return ret;
}
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index d6e0cb1431f..117384111be 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -31,7 +31,10 @@ static BOOL APIENTRY ImmInitializeGlobals(HMODULE hMod)
status = RtlInitializeCriticalSection(&gcsImeDpi);
if (NT_ERROR(status))
+ {
+ ERR("\n");
return FALSE;
+ }
gfImmInitialized = TRUE;
return TRUE;
@@ -68,20 +71,14 @@ BOOL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
REGKEY_KEYBOARD_LAYOUTS, HandleToUlong(hKL));
error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szLayout, 0, KEY_READ,
&hLayoutKey);
- if (error)
- {
- ERR("RegOpenKeyExW: 0x%08lX\n", error);
+ if (IS_ERROR_UNEXPECTEDLY(error))
return FALSE;
- }
}
else
{
error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, REGKEY_IMM, 0, KEY_READ,
&hLayoutKey);
- if (error)
- {
- ERR("RegOpenKeyExW: 0x%08lX\n", error);
+ if (IS_ERROR_UNEXPECTEDLY(error))
return FALSE;
- }
}
cbData = sizeof(pImeInfoEx->wszImeFile);
@@ -93,9 +90,9 @@ BOOL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
pImeInfoEx->fLoadFlag = 0;
- if (error != ERROR_SUCCESS || dwType != REG_SZ)
+ if (IS_ERROR_UNEXPECTEDLY(error) || dwType != REG_SZ)
{
- ERR("RegQueryValueExW: 0x%lX, 0x%lX\n", error, dwType);
+ ERR("\n");
return FALSE;
}
@@ -129,7 +126,7 @@ BOOL WINAPI ImmFreeLayout(DWORD dwUnknown)
if (cKLs)
{
pList = ImmLocalAlloc(0, cKLs * sizeof(HKL));
- if (pList == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pList))
return FALSE;
cKLs = GetKeyboardLayoutList(cKLs, pList);
@@ -147,7 +144,10 @@ BOOL WINAPI ImmFreeLayout(DWORD dwUnknown)
StringCchPrintfW(szKBD, _countof(szKBD), L"%08X", LangID);
if (!LoadKeyboardLayoutW(szKBD, KLF_ACTIVATE))
+ {
+ WARN("\n");
LoadKeyboardLayoutW(L"00000409", KLF_ACTIVATE | 0x200);
+ }
}
else if (dwUnknown == 2)
{
@@ -187,7 +187,7 @@ VOID APIENTRY Imm32SelectInputContext(HKL hNewKL, HKL hOldKL, HIMC
hIMC)
PIME_STATE pNewState = NULL, pOldState = NULL;
pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return;
pNewImeDpi = ImmLockImeDpi(hNewKL);
@@ -496,13 +496,16 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
TRACE("(%p, %p)\n", hWnd, hIMC);
if (!IS_IMM_MODE())
+ {
+ WARN("\n");
return NULL;
+ }
pWnd = ValidateHwnd(hWnd);
- if (!pWnd)
+ if (IS_NULL_UNEXPECTEDLY(pWnd))
return NULL;
- if (hIMC && Imm32IsCrossThreadAccess(hIMC))
+ if (hIMC && IS_CROSS_THREAD_HIMC(hIMC))
return NULL;
hOldIMC = pWnd->hImc;
@@ -542,9 +545,12 @@ BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD
dwFlags)
TRACE("(%p, %p, 0x%lX)\n", hWnd, hIMC, dwFlags);
if (!IS_IMM_MODE())
+ {
+ WARN("\n");
return FALSE;
+ }
- if (hIMC && !(dwFlags & IACE_DEFAULT) &&
Imm32IsCrossThreadAccess(hIMC))
+ if (hIMC && !(dwFlags & IACE_DEFAULT) &&
IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
hwndFocus = (HWND)NtUserQueryWindow(hWnd, QUERY_WINDOW_FOCUS);
@@ -587,14 +593,17 @@ HIMC WINAPI ImmCreateContext(void)
TRACE("()\n");
if (!IS_IMM_MODE())
+ {
+ WARN("\n");
return NULL;
+ }
pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return NULL;
hIMC = NtUserCreateInputContext((ULONG_PTR)pClientImc);
- if (hIMC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(hIMC))
{
ImmLocalFree(pClientImc);
return NULL;
@@ -637,23 +646,35 @@ BOOL APIENTRY Imm32DestroyInputContext(HIMC hIMC, HKL hKL, BOOL
bKeep)
PCLIENTIMC pClientImc;
PIMC pIMC;
- if (!hIMC || !IS_IMM_MODE())
+ if (hIMC == NULL)
+ return FALSE;
+
+ if (!IS_IMM_MODE())
+ {
+ WARN("\n");
return FALSE;
+ }
pIMC = ValidateHandle(hIMC, TYPE_INPUTCONTEXT);
- if (!pIMC || pIMC->head.pti != Imm32CurrentPti())
+ if (IS_NULL_UNEXPECTEDLY(pIMC))
+ return FALSE;
+
+ if (pIMC->head.pti != Imm32CurrentPti())
{
- ERR("invalid pIMC: %p\n", pIMC);
+ ERR("\n");
return FALSE;
}
pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
- if (!pClientImc)
+ if (pClientImc == NULL)
+ {
+ TRACE("pClientImc == NULL\n");
goto Finish;
+ }
if ((pClientImc->dwFlags & CLIENTIMC_UNKNOWN2) && !bKeep)
{
- ERR("CLIENTIMC_UNKNOWN2\n");
+ ERR("\n");
return FALSE;
}
@@ -662,14 +683,13 @@ BOOL APIENTRY Imm32DestroyInputContext(HIMC hIMC, HKL hKL, BOOL
bKeep)
InterlockedIncrement(&pClientImc->cLockObj);
- if (!pClientImc->hInputContext)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc->hInputContext))
goto Quit;
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
{
ImmUnlockClientImc(pClientImc);
- ERR("!pIC\n");
return FALSE;
}
@@ -725,24 +745,29 @@ Imm32CreateInputContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC
pClientImc, HK
pIC->hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO));
pIC->hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE));
pIC->hMsgBuf = ImmCreateIMCC(sizeof(UINT));
- if (!pIC->hCompStr || !pIC->hCandInfo || !pIC->hGuideLine ||
!pIC->hMsgBuf)
+ if (IS_NULL_UNEXPECTEDLY(pIC->hCompStr) ||
+ IS_NULL_UNEXPECTEDLY(pIC->hCandInfo) ||
+ IS_NULL_UNEXPECTEDLY(pIC->hGuideLine) ||
+ IS_NULL_UNEXPECTEDLY(pIC->hMsgBuf))
+ {
goto Fail;
+ }
/* Initialize IC components */
pCS = ImmLockIMCC(pIC->hCompStr);
- if (!pCS)
+ if (IS_NULL_UNEXPECTEDLY(pCS))
goto Fail;
pCS->dwSize = sizeof(COMPOSITIONSTRING);
ImmUnlockIMCC(pIC->hCompStr);
pCI = ImmLockIMCC(pIC->hCandInfo);
- if (!pCI)
+ if (IS_NULL_UNEXPECTEDLY(pCI))
goto Fail;
pCI->dwSize = sizeof(CANDIDATEINFO);
ImmUnlockIMCC(pIC->hCandInfo);
pGL = ImmLockIMCC(pIC->hGuideLine);
- if (!pGL)
+ if (IS_NULL_UNEXPECTEDLY(pGL))
goto Fail;
pGL->dwSize = sizeof(GUIDELINE);
ImmUnlockIMCC(pIC->hGuideLine);
@@ -772,7 +797,7 @@ Imm32CreateInputContext(HIMC hIMC, LPINPUTCONTEXT pIC, PCLIENTIMC
pClientImc, HK
/* Create private data */
pIC->hPrivate = ImmCreateIMCC(cbPrivate);
- if (!pIC->hPrivate)
+ if (IS_NULL_UNEXPECTEDLY(pIC->hPrivate))
goto Fail;
CtfImmTIMCreateInputContext(hIMC);
@@ -819,7 +844,7 @@ LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect)
PIMEDPI pImeDpi = NULL;
pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return NULL;
RtlEnterCriticalSection(&pClientImc->cs);
@@ -827,15 +852,11 @@ LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL
fSelect)
if (pClientImc->hInputContext)
{
pIC = LocalLock(pClientImc->hInputContext);
- if (pIC)
- {
- CtfImmTIMCreateInputContext(hIMC);
- goto Success;
- }
- else
- {
+ if (IS_NULL_UNEXPECTEDLY(pIC))
goto Failure;
- }
+
+ CtfImmTIMCreateInputContext(hIMC);
+ goto Success;
}
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
@@ -853,11 +874,14 @@ LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL
fSelect)
}
if (!NtUserQueryInputContext(hIMC, QIC_DEFAULTWINDOWIME))
+ {
+ ERR("\n");
goto Failure;
+ }
hIC = LocalAlloc(LHND, sizeof(INPUTCONTEXTDX));
pIC = LocalLock(hIC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
{
LocalFree(hIC);
goto Failure;
@@ -867,6 +891,7 @@ LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect)
hNewKL = GetKeyboardLayout(dwThreadId);
if (!Imm32CreateInputContext(hIMC, pIC, pClientImc, hNewKL, fSelect))
{
+ ERR("\n");
LocalUnlock(hIC);
pClientImc->hInputContext = LocalFree(hIC);
goto Failure;
@@ -894,9 +919,12 @@ BOOL WINAPI ImmDestroyContext(HIMC hIMC)
TRACE("(%p)\n", hIMC);
if (!IS_IMM_MODE())
+ {
+ WARN("\n");
return FALSE;
+ }
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
hKL = GetKeyboardLayout(0);
@@ -913,11 +941,11 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
TRACE("(%p)\n", hImc);
- if (!hImc)
+ if (IS_NULL_UNEXPECTEDLY(hImc))
return NULL;
pIMC = ValidateHandle(hImc, TYPE_INPUTCONTEXT);
- if (!pIMC || !Imm32CheckImcProcess(pIMC))
+ if (IS_NULL_UNEXPECTEDLY(pIMC) || !Imm32CheckImcProcess(pIMC))
return NULL;
pClientImc = (PCLIENTIMC)pIMC->dwClientImcData;
@@ -929,7 +957,7 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
}
pClientImc = ImmLocalAlloc(HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return NULL;
RtlInitializeCriticalSection(&pClientImc->cs);
@@ -937,6 +965,7 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc)
if (!NtUserUpdateInputContext(hImc, UIC_CLIENTIMCDATA, (DWORD_PTR)pClientImc))
{
+ ERR("\n");
ImmLocalFree(pClientImc);
return NULL;
}
@@ -978,7 +1007,10 @@ static HIMC APIENTRY ImmGetSaveContext(HWND hWnd, DWORD
dwContextFlags)
PWND pWnd;
if (!IS_IMM_MODE())
+ {
+ TRACE("Not IMM mode.\n");
return NULL;
+ }
if (!hWnd)
{
@@ -987,7 +1019,7 @@ static HIMC APIENTRY ImmGetSaveContext(HWND hWnd, DWORD
dwContextFlags)
}
pWnd = ValidateHwnd(hWnd);
- if (!pWnd || Imm32IsCrossProcessAccess(hWnd))
+ if (IS_NULL_UNEXPECTEDLY(pWnd) || IS_CROSS_PROCESS_HWND(hWnd))
return NULL;
hIMC = pWnd->hImc;
@@ -996,10 +1028,12 @@ static HIMC APIENTRY ImmGetSaveContext(HWND hWnd, DWORD
dwContextFlags)
Quit:
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return NULL;
+
if ((dwContextFlags & 2) && (pClientImc->dwFlags &
CLIENTIMC_DISABLEIME))
hIMC = NULL;
+
ImmUnlockClientImc(pClientImc);
return hIMC;
}
@@ -1010,7 +1044,7 @@ Quit:
HIMC WINAPI ImmGetContext(HWND hWnd)
{
TRACE("(%p)\n", hWnd);
- if (hWnd == NULL)
+ if (IS_NULL_UNEXPECTEDLY(hWnd))
return NULL;
return ImmGetSaveContext(hWnd, 2);
}
@@ -1034,7 +1068,7 @@ BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
PCLIENTIMC pClientImc;
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
if (pClientImc->hInputContext)
@@ -1108,7 +1142,7 @@ BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn,
LPARAM lPara
TRACE("(%lu, %p, %p)\n", dwThreadId, lpfn, lParam);
dwCount = Imm32BuildHimcList(dwThreadId, &phList);
- if (!dwCount)
+ if (IS_ZERO_UNEXPECTEDLY(dwCount))
return FALSE;
for (dwIndex = 0; dwIndex < dwCount; ++dwIndex)
@@ -1140,7 +1174,10 @@ BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL
fActive)
TRACE("(%p, %p, %d)\n", hWnd, hIMC, fActive);
if (!IS_IMM_MODE())
+ {
+ WARN("\n");
return FALSE;
+ }
pClientImc = ImmLockClientImc(hIMC);
@@ -1151,11 +1188,11 @@ BOOL WINAPI ImmSetActiveContext(HWND hWnd, HIMC hIMC, BOOL
fActive)
}
else if (hIMC)
{
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
{
ImmUnlockClientImc(pClientImc);
return FALSE;
@@ -1241,10 +1278,31 @@ BOOL WINAPI ImmSetActiveContextConsoleIME(HWND hwnd, BOOL fFlag)
TRACE("(%p, %d)\n", hwnd, fFlag);
hIMC = ImmGetContext(hwnd);
- if (hIMC)
- return ImmSetActiveContext(hwnd, hIMC, fFlag);
- return FALSE;
+ if (IS_NULL_UNEXPECTEDLY(hIMC))
+ return FALSE;
+ return ImmSetActiveContext(hwnd, hIMC, fFlag);
+}
+
+#ifndef NDEBUG
+VOID APIENTRY Imm32UnitTest(VOID)
+{
+ if (0)
+ {
+ DWORD dwValue;
+ WCHAR szText[64];
+
+ Imm32StrToUInt(L"123", &dwValue, 10);
+ ASSERT(dwValue == 123);
+ Imm32StrToUInt(L"100", &dwValue, 16);
+ ASSERT(dwValue == 0x100);
+
+ Imm32UIntToStr(123, 10, szText, _countof(szText));
+ ASSERT(lstrcmpW(szText, L"123") == 0);
+ Imm32UIntToStr(0x100, 16, szText, _countof(szText));
+ ASSERT(lstrcmpW(szText, L"100") == 0);
+ }
}
+#endif
BOOL WINAPI User32InitializeImmEntryTable(DWORD);
@@ -1273,6 +1331,9 @@ ImmDllInitialize(
ERR("User32InitializeImmEntryTable failed\n");
return FALSE;
}
+#ifndef NDEBUG
+ Imm32UnitTest();
+#endif
break;
case DLL_THREAD_ATTACH:
diff --git a/dll/win32/imm32/keymsg.c b/dll/win32/imm32/keymsg.c
index 11198aa545a..8e1cac90154 100644
--- a/dll/win32/imm32/keymsg.c
+++ b/dll/win32/imm32/keymsg.c
@@ -69,7 +69,7 @@ BOOL APIENTRY Imm32CImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd,
LANGID LangID
LPINPUTCONTEXT pIC;
BOOL fOpen;
- if (hWnd == NULL)
+ if (IS_NULL_UNEXPECTEDLY(hWnd))
return FALSE;
if (LOWORD(hKL) != LangID || !ImmIsIME(hKL))
@@ -79,7 +79,7 @@ BOOL APIENTRY Imm32CImeNonImeToggle(HIMC hIMC, HKL hKL, HWND hWnd,
LANGID LangID
}
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return TRUE;
fOpen = pIC->fOpen;
@@ -105,7 +105,7 @@ BOOL APIENTRY Imm32CShapeToggle(HIMC hIMC, HKL hKL, HWND hWnd)
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return TRUE;
fOpen = pIC->fOpen;
@@ -136,7 +136,7 @@ BOOL APIENTRY Imm32CSymbolToggle(HIMC hIMC, HKL hKL, HWND hWnd)
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return TRUE;
fOpen = pIC->fOpen;
@@ -191,7 +191,7 @@ BOOL APIENTRY Imm32KShapeToggle(HIMC hIMC)
DWORD dwConversion, dwSentence;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
dwConversion = (pIC->fdwConversion ^ IME_CMODE_FULLSHAPE);
@@ -214,7 +214,7 @@ BOOL APIENTRY Imm32KHanjaConvert(HIMC hIMC)
DWORD dwConversion, dwSentence;
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
dwConversion = (pIC->fdwConversion ^ IME_CMODE_HANJACONVERT);
@@ -233,7 +233,7 @@ BOOL APIENTRY Imm32KEnglish(HIMC hIMC)
BOOL fOpen;
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
dwConversion = (pIC->fdwConversion ^ IME_CMODE_NATIVE);
@@ -253,7 +253,7 @@ BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD
dwHotKeyID
PIMEDPI pImeDpi;
BOOL ret;
- if (hIMC && Imm32IsCrossThreadAccess(hIMC))
+ if (hIMC && IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
switch (dwHotKeyID)
@@ -289,6 +289,7 @@ BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD
dwHotKeyID
return Imm32CSymbolToggle(hIMC, hKL, hWnd);
default:
+ WARN("0x%X\n", dwHotKeyID);
break;
}
@@ -296,7 +297,7 @@ BOOL APIENTRY Imm32ProcessHotKey(HWND hWnd, HIMC hIMC, HKL hKL, DWORD
dwHotKeyID
return FALSE;
pImeDpi = ImmLockImeDpi(hKL);
- if (pImeDpi == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
ret = (BOOL)pImeDpi->ImeEscape(hIMC, IME_ESC_PRIVATE_HOTKEY, &dwHotKeyID);
@@ -318,7 +319,7 @@ ImmIsUIMessageAW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam,
BOOL bAns
return FALSE;
}
- if (!hWndIME)
+ if (IS_NULL_UNEXPECTEDLY(hWndIME))
return TRUE;
if (bAnsi)
@@ -369,7 +370,7 @@ LRESULT APIENTRY CtfImmSetLangBand(HWND hWnd, BOOL fSet)
if (hWnd && gpsi)
pWnd = ValidateHwndNoErr(hWnd);
- if (!pWnd)
+ if (IS_NULL_UNEXPECTEDLY(pWnd))
return 0;
if (pWnd->state2 & WNDS2_WMCREATEMSGPROCESSED)
@@ -380,7 +381,7 @@ LRESULT APIENTRY CtfImmSetLangBand(HWND hWnd, BOOL fSet)
}
pSetBand = ImmLocalAlloc(0, sizeof(IMM_DELAY_SET_LANG_BAND));
- if (!pSetBand)
+ if (IS_NULL_UNEXPECTEDLY(pSetBand))
return 0;
pSetBand->hWnd = hWnd;
@@ -399,12 +400,17 @@ static BOOL CALLBACK Imm32SendNotificationProc(HIMC hIMC, LPARAM
lParam)
LPINPUTCONTEXTDX pIC;
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return TRUE;
hWnd = pIC->hWnd;
- if (!IsWindow(hWnd))
+ if (hWnd == NULL || !IsWindow(hWnd))
+ {
+ ERR("\n");
goto Quit;
+ }
+
+ TRACE("dwChange: 0x%08X\n", pIC->dwChange);
if (pIC->dwChange & INPUTCONTEXTDX_CHANGE_OPEN)
SendMessageW(hWnd, WM_IME_NOTIFY, IMN_SETOPENSTATUS, 0);
@@ -426,17 +432,11 @@ BOOL APIENTRY Imm32SendNotification(BOOL bProcess)
return ImmEnumInputContext((bProcess ? -1 : 0), Imm32SendNotificationProc, 0);
}
-VOID APIENTRY Imm32RequestError(DWORD dwError)
-{
- FIXME("()\n");
- SetLastError(dwError);
-}
-
LRESULT APIENTRY
Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID pData, BOOL bAnsiAPI)
{
HWND hWnd;
- DWORD ret = 0, dwCharPos, cchCompStr;
+ DWORD ret = 0, dwCharPos, cchCompStr, dwSize;
LPVOID pCS, pTempData = pData;
LPRECONVERTSTRING pRS;
LPIMECHARPOSITION pICP;
@@ -456,10 +456,17 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
};
if (dwCommand == 0 || dwCommand > IMR_DOCUMENTFEED)
+ {
+ ERR("\n");
return 0; /* Out of range */
+ }
- if (pData && IsBadWritePtr(pData, acbData[bAnsiAPI * 7 + dwCommand - 1]))
+ dwSize = acbData[bAnsiAPI * 7 + dwCommand - 1];
+ if (pData && IsBadWritePtr(pData, dwSize))
+ {
+ ERR("\n");
return 0; /* Invalid pointer */
+ }
/* Sanity check */
switch (dwCommand)
@@ -468,7 +475,7 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
pRS = pData;
if (pRS && (pRS->dwVersion != 0 || pRS->dwSize <
sizeof(RECONVERTSTRING)))
{
- Imm32RequestError(ERROR_INVALID_PARAMETER);
+ ERR("\n");
return 0;
}
break;
@@ -477,7 +484,7 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
pRS = pData;
if (!pRS || pRS->dwVersion != 0)
{
- Imm32RequestError(ERROR_INVALID_PARAMETER);
+ ERR("\n");
return 0;
}
break;
@@ -485,7 +492,7 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
default:
if (!pData)
{
- Imm32RequestError(ERROR_INVALID_PARAMETER);
+ ERR("\n");
return 0;
}
break;
@@ -503,18 +510,20 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
{
case IMR_COMPOSITIONFONT:
if (bAnsiAPI == bAnsiWnd)
- goto DoIt;
+ goto DoIt; /* No conversion needed */
+
if (bAnsiWnd)
pTempData = ImmLocalAlloc(0, sizeof(LOGFONTA));
else
pTempData = ImmLocalAlloc(0, sizeof(LOGFONTW));
- if (!pTempData)
+
+ if (IS_NULL_UNEXPECTEDLY(pTempData))
return 0;
break;
case IMR_RECONVERTSTRING: case IMR_CONFIRMRECONVERTSTRING: case
IMR_DOCUMENTFEED:
if (bAnsiAPI == bAnsiWnd || !pData)
- goto DoIt;
+ goto DoIt; /* No conversion needed */
if (bAnsiWnd)
ret = Imm32ReconvertAnsiFromWide(NULL, pData, uCodePage);
@@ -522,7 +531,7 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
ret = Imm32ReconvertWideFromAnsi(NULL, pData, uCodePage);
pTempData = ImmLocalAlloc(0, ret + sizeof(WCHAR));
- if (!pTempData)
+ if (IS_NULL_UNEXPECTEDLY(pTempData))
return 0;
pRS = pTempData;
@@ -540,7 +549,7 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
case IMR_QUERYCHARPOSITION:
if (bAnsiAPI == bAnsiWnd)
- goto DoIt;
+ goto DoIt; /* No conversion needed */
pICP = pData;
dwCharPos = pICP->dwCharPos;
@@ -548,11 +557,11 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
if (bAnsiAPI)
{
cchCompStr = ImmGetCompositionStringA(hIMC, GCS_COMPSTR, NULL, 0);
- if (!cchCompStr)
+ if (IS_ZERO_UNEXPECTEDLY(cchCompStr))
return 0;
pCS = ImmLocalAlloc(0, (cchCompStr + 1) * sizeof(CHAR));
- if (!pCS)
+ if (IS_NULL_UNEXPECTEDLY(pCS))
return 0;
ImmGetCompositionStringA(hIMC, GCS_COMPSTR, pCS, cchCompStr);
@@ -561,11 +570,11 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
else
{
cchCompStr = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
- if (!cchCompStr)
+ if (IS_ZERO_UNEXPECTEDLY(cchCompStr))
return 0;
pCS = ImmLocalAlloc(0, (cchCompStr + 1) * sizeof(WCHAR));
- if (!pCS)
+ if (IS_NULL_UNEXPECTEDLY(pCS))
return 0;
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, pCS, cchCompStr);
@@ -576,6 +585,7 @@ Imm32ProcessRequest(HIMC hIMC, PWND pWnd, DWORD dwCommand, LPVOID
pData, BOOL bA
break;
default:
+ WARN("\n");
break;
}
@@ -588,7 +598,7 @@ DoIt:
ret = SendMessageW(hWnd, WM_IME_REQUEST, dwCommand, (LPARAM)pTempData);
if (bAnsiAPI == bAnsiWnd)
- goto Quit;
+ goto Quit; /* No conversion needed */
/* Get back to caller */
switch (dwCommand)
@@ -624,6 +634,7 @@ DoIt:
break;
default:
+ WARN("\n");
break;
}
@@ -641,11 +652,11 @@ LRESULT APIENTRY ImmRequestMessageAW(HIMC hIMC, WPARAM wParam,
LPARAM lParam, BO
HWND hWnd;
PWND pWnd = NULL;
- if (!hIMC || Imm32IsCrossThreadAccess(hIMC))
+ if (IS_NULL_UNEXPECTEDLY(hIMC) || IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pIC = ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
hWnd = pIC->hWnd;
@@ -733,7 +744,7 @@ UINT WINAPI ImmGetVirtualKey(HWND hWnd)
hIMC = ImmGetContext(hWnd);
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (!pIC)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return ret;
if (pIC->bNeedsTrans)
@@ -749,7 +760,7 @@ DWORD WINAPI ImmGetAppCompatFlags(HIMC hIMC)
DWORD dwFlags;
pClientIMC = ImmLockClientImc(hIMC);
- if (pClientIMC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientIMC))
return 0;
dwFlags = pClientIMC->dwCompatFlags;
@@ -833,8 +844,12 @@ ImmProcessKey(HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD
dwHotKeyID)
{
/* The key has been processed by IME's ImeProcessKey */
LANGID wLangID = LANGIDFROMLCID(GetSystemDefaultLCID());
- if (PRIMARYLANGID(wLangID) != LANG_KOREAN || /* Korean doesn't wanna this
code */
- (vKey != VK_PROCESSKEY && !(ret & IPHK_HOTKEY))) /* Is the key to
be processed? */
+ if (PRIMARYLANGID(wLangID) == LANG_KOREAN &&
+ (vKey == VK_PROCESSKEY || (ret & IPHK_HOTKEY)))
+ {
+ /* Korean don't want VK_PROCESSKEY and IME hot-keys */
+ }
+ else
{
/* Add WM_KEYDOWN:VK_PROCESSKEY message */
ImmTranslateMessage(hWnd, WM_KEYDOWN, VK_PROCESSKEY, lParam);
@@ -844,7 +859,7 @@ ImmProcessKey(HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD
dwHotKeyID)
}
ImmReleaseContext(hWnd, hIMC);
- return ret;
+ return ret; /* Returns IPHK_... flags */
}
/***********************************************************************
@@ -869,6 +884,7 @@ LRESULT WINAPI ImmSystemHandler(HIMC hIMC, WPARAM wParam, LPARAM
lParam)
return CtfImmSetLangBand((HWND)lParam, (wParam == IMS_SETLANGBAND));
default:
+ WARN("\n");
return 0;
}
}
@@ -888,18 +904,18 @@ BOOL WINAPI ImmGenerateMessage(HIMC hIMC)
TRACE("(%p)\n", hIMC);
- if (Imm32IsCrossThreadAccess(hIMC))
+ if (IS_CROSS_THREAD_HIMC(hIMC))
return FALSE;
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return FALSE;
bAnsi = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
ImmUnlockClientImc(pClientImc);
pIC = ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return FALSE;
dwCount = pIC->dwNumMsgBuf;
@@ -908,12 +924,12 @@ BOOL WINAPI ImmGenerateMessage(HIMC hIMC)
hMsgBuf = pIC->hMsgBuf;
pMsgs = ImmLockIMCC(hMsgBuf);
- if (pMsgs == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pMsgs))
goto Quit;
cbTrans = dwCount * sizeof(TRANSMSG);
pTrans = ImmLocalAlloc(0, cbTrans);
- if (pTrans == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pTrans))
goto Quit;
RtlCopyMemory(pTrans, pMsgs, cbTrans);
@@ -962,7 +978,7 @@ ImmPostMessages(HWND hwnd, HIMC hIMC, DWORD dwCount, LPTRANSMSG
lpTransMsg)
BOOL bAnsi;
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return;
bAnsi = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
@@ -1043,7 +1059,7 @@ BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lKeyD
hIMC = ImmGetContext(hwnd);
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
{
ImmReleaseContext(hwnd, hIMC);
return FALSE;
@@ -1071,11 +1087,14 @@ BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM
wParam, LPARAM lKeyD
dwThreadId = GetWindowThreadProcessId(hwnd, NULL);
hKL = GetKeyboardLayout(dwThreadId);
pImeDpi = ImmLockImeDpi(hKL);
- if (pImeDpi == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
goto Quit;
if (!GetKeyboardState(abKeyState)) /* get keyboard ON/OFF status */
+ {
+ WARN("\n");
goto Quit;
+ }
/* convert a virtual key if IME_PROP_KBD_CHAR_FIRST */
vk = pIC->nVKey;
@@ -1110,7 +1129,7 @@ BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lKeyD
/* allocate a list */
cbList = offsetof(TRANSMSGLIST, TransMsg) + MSG_COUNT * sizeof(TRANSMSG);
pList = ImmLocalAlloc(0, cbList);
- if (!pList)
+ if (IS_NULL_UNEXPECTEDLY(pList))
goto Quit;
/* use IME conversion engine and convert the list */
@@ -1128,7 +1147,7 @@ BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lKeyD
else
{
pTransMsg = ImmLockIMCC(pIC->hMsgBuf);
- if (pTransMsg == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pTransMsg))
goto Quit;
ImmPostMessages(hwnd, hIMC, kret, pTransMsg);
ImmUnlockIMCC(pIC->hMsgBuf);
@@ -1139,6 +1158,7 @@ Quit:
ImmUnlockImeDpi(pImeDpi);
ImmUnlockIMC(hIMC);
ImmReleaseContext(hwnd, hIMC);
+ TRACE("ret: %d\n", ret);
return ret;
#undef MSG_COUNT
}
@@ -1173,7 +1193,7 @@ ImmSendMessageToActiveDefImeWndW(UINT uMsg, WPARAM wParam, LPARAM
lParam)
return 0;
hwndIME = (HWND)NtUserQueryWindow((HWND)wParam, QUERY_WINDOW_DEFAULT_IME);
- if (!hwndIME)
+ if (IS_NULL_UNEXPECTEDLY(hwndIME))
return 0;
return SendMessageW(hwndIME, uMsg, wParam, lParam);
diff --git a/dll/win32/imm32/precomp.h b/dll/win32/imm32/precomp.h
index 8e996ab4ab0..629eaba4e4b 100644
--- a/dll/win32/imm32/precomp.h
+++ b/dll/win32/imm32/precomp.h
@@ -7,7 +7,7 @@
* Copyright 2017 James Tabor <james.tabor(a)reactos.org>
* Copyright 2018 Amine Khaldi <amine.khaldi(a)reactos.org>
* Copyright 2020 Oleg Dubinskiy <oleg.dubinskij2013(a)yandex.ua>
- * Copyright 2020-2021 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
+ * Copyright 2020-2022 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
*/
#pragma once
@@ -96,25 +96,48 @@ PIMEDPI APIENTRY Imm32FindOrLoadImeDpi(HKL hKL);
LPINPUTCONTEXT APIENTRY Imm32InternalLockIMC(HIMC hIMC, BOOL fSelect);
BOOL APIENTRY Imm32ReleaseIME(HKL hKL);
BOOL APIENTRY Imm32IsSystemJapaneseOrKorean(VOID);
-
-static inline BOOL Imm32IsCrossThreadAccess(HIMC hIMC)
-{
- DWORD dwImeThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
- DWORD dwThreadId = GetCurrentThreadId();
- return (dwImeThreadId != dwThreadId);
-}
-
-// Win: TestWindowProcess
-static inline BOOL Imm32IsCrossProcessAccess(HWND hWnd)
-{
- return (NtUserQueryWindow(hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID) !=
- (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess);
-}
-
+BOOL APIENTRY Imm32IsCrossThreadAccess(HIMC hIMC);
+BOOL APIENTRY Imm32IsCrossProcessAccess(HWND hWnd);
BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC);
-#define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty &
IME_PROP_UNICODE)
-#define IS_16BIT_MODE() (GetWin32ClientInfo()->dwTIFlags & TIF_16BIT)
+/*
+ * Unexpected Condition Checkers
+ * --- Examine the condition, and then generate trace log if necessary.
+ */
+#ifdef NDEBUG /* on Release */
+#define IS_NULL_UNEXPECTEDLY(p) (!(p))
+#define IS_ZERO_UNEXPECTEDLY(p) (!(p))
+#define IS_TRUE_UNEXPECTEDLY(x) (x)
+#define IS_FALSE_UNEXPECTEDLY(x) (!(x))
+#define IS_ERROR_UNEXPECTEDLY(x) (!(x))
+#else /* on Debug */
+#define IS_NULL_UNEXPECTEDLY(p) \
+ (!(p) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
+ __FILE__, __FUNCTION__, __LINE__, "%s was NULL\n",
#p), TRUE) \
+ : FALSE)
+#define IS_ZERO_UNEXPECTEDLY(p) \
+ (!(p) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
+ __FILE__, __FUNCTION__, __LINE__, "%s was zero\n",
#p), TRUE) \
+ : FALSE)
+#define IS_TRUE_UNEXPECTEDLY(x) \
+ ((x) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
+ __FILE__, __FUNCTION__, __LINE__, "%s was non-zero\n",
#x), TRUE) \
+ : FALSE)
+#define IS_FALSE_UNEXPECTEDLY(x) \
+ ((!(x)) ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
+ __FILE__, __FUNCTION__, __LINE__, "%s was FALSE\n",
#x), TRUE) \
+ : FALSE)
+#define IS_ERROR_UNEXPECTEDLY(x) \
+ ((x) != ERROR_SUCCESS ? (ros_dbg_log(__WINE_DBCL_ERR, __wine_dbch___default, \
+ __FILE__, __FUNCTION__, __LINE__, \
+ "%s was 0x%X\n", #x, (x)), TRUE) \
+ : FALSE)
+#endif
+
+#define IS_CROSS_THREAD_HIMC(hIMC)
IS_TRUE_UNEXPECTEDLY(Imm32IsCrossThreadAccess(hIMC))
+#define IS_CROSS_PROCESS_HWND(hWnd)
IS_TRUE_UNEXPECTEDLY(Imm32IsCrossProcessAccess(hWnd))
+#define ImeDpi_IsUnicode(pImeDpi) ((pImeDpi)->ImeInfo.fdwProperty &
IME_PROP_UNICODE)
+#define IS_16BIT_MODE() (GetWin32ClientInfo()->dwTIFlags &
TIF_16BIT)
DWORD APIENTRY
CandidateListWideToAnsi(const CANDIDATELIST *pWideCL, LPCANDIDATELIST pAnsiCL, DWORD
dwBufLen,
@@ -156,14 +179,7 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts);
BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayoutText);
HKL APIENTRY Imm32AssignNewLayout(UINT cKLs, const REG_IME *pLayouts, WORD wLangID);
BOOL APIENTRY Imm32CopyImeFile(LPWSTR pszOldFile, LPCWSTR pszNewFile);
-
-/* Win: PtiCurrent */
-static inline PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
-{
- if (NtCurrentTeb()->Win32ThreadInfo == NULL)
- NtUserGetThreadState(THREADSTATE_GETTHREADINFO);
- return NtCurrentTeb()->Win32ThreadInfo;
-}
+PTHREADINFO FASTCALL Imm32CurrentPti(VOID);
HBITMAP Imm32LoadBitmapFromBytes(const BYTE *pb);
BOOL Imm32StoreBitmapToBytes(HBITMAP hbm, LPBYTE pbData, DWORD cbDataMax);
diff --git a/dll/win32/imm32/regword.c b/dll/win32/imm32/regword.c
index dfa4114a9ed..cdda6cb3234 100644
--- a/dll/win32/imm32/regword.c
+++ b/dll/win32/imm32/regword.c
@@ -38,14 +38,14 @@ Imm32EnumWordProcA2W(LPCSTR pszReadingA, DWORD dwStyle, LPCSTR
pszRegisterA, LPV
if (pszReadingA)
{
pszReadingW = Imm32WideFromAnsi(lpEnumData->uCodePage, pszReadingA);
- if (pszReadingW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingW))
goto Quit;
}
if (pszRegisterA)
{
pszRegisterW = Imm32WideFromAnsi(lpEnumData->uCodePage, pszRegisterA);
- if (pszRegisterW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszRegisterW))
goto Quit;
}
@@ -68,14 +68,14 @@ Imm32EnumWordProcW2A(LPCWSTR pszReadingW, DWORD dwStyle, LPCWSTR
pszRegisterW, L
if (pszReadingW)
{
pszReadingA = Imm32AnsiFromWide(lpEnumData->uCodePage, pszReadingW);
- if (pszReadingW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingW))
goto Quit;
}
if (pszRegisterW)
{
pszRegisterA = Imm32AnsiFromWide(lpEnumData->uCodePage, pszRegisterW);
- if (pszRegisterA == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszRegisterA))
goto Quit;
}
@@ -105,10 +105,10 @@ ImmEnumRegisterWordA(HKL hKL, REGISTERWORDENUMPROCA lpfnEnumProc,
dwStyle, debugstr_a(lpszRegister), lpData);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (!ImeDpi_IsUnicode(pImeDpi))
+ if (!ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeEnumRegisterWord(lpfnEnumProc, lpszReading, dwStyle,
lpszRegister, lpData);
@@ -119,14 +119,14 @@ ImmEnumRegisterWordA(HKL hKL, REGISTERWORDENUMPROCA lpfnEnumProc,
if (lpszReading)
{
pszReadingW = Imm32WideFromAnsi(pImeDpi->uCodePage, lpszReading);
- if (pszReadingW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingW))
goto Quit;
}
if (lpszRegister)
{
pszRegisterW = Imm32WideFromAnsi(pImeDpi->uCodePage, lpszRegister);
- if (pszRegisterW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszRegisterW))
goto Quit;
}
@@ -162,10 +162,10 @@ ImmEnumRegisterWordW(HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
dwStyle, debugstr_w(lpszRegister), lpData);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (ImeDpi_IsUnicode(pImeDpi))
+ if (ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeEnumRegisterWord(lpfnEnumProc, lpszReading, dwStyle,
lpszRegister, lpData);
@@ -176,14 +176,14 @@ ImmEnumRegisterWordW(HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
if (lpszReading)
{
pszReadingA = Imm32AnsiFromWide(pImeDpi->uCodePage, lpszReading);
- if (pszReadingA == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingA))
goto Quit;
}
if (lpszRegister)
{
pszRegisterA = Imm32AnsiFromWide(pImeDpi->uCodePage, lpszRegister);
- if (pszRegisterA == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszRegisterA))
goto Quit;
}
@@ -199,6 +199,7 @@ Quit:
ImmLocalFree(pszReadingA);
ImmLocalFree(pszRegisterA);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %u\n", ret);
return ret;
}
@@ -217,10 +218,10 @@ UINT WINAPI ImmGetRegisterWordStyleA(HKL hKL, UINT nItem,
LPSTYLEBUFA lpStyleBuf
TRACE("(%p, %u, %p)\n", hKL, nItem, lpStyleBuf);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (!ImeDpi_IsUnicode(pImeDpi))
+ if (!ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeGetRegisterWordStyle(nItem, lpStyleBuf);
goto Quit;
@@ -229,7 +230,7 @@ UINT WINAPI ImmGetRegisterWordStyleA(HKL hKL, UINT nItem, LPSTYLEBUFA
lpStyleBuf
if (nItem > 0)
{
pNewStylesW = ImmLocalAlloc(0, nItem * sizeof(STYLEBUFW));
- if (!pNewStylesW)
+ if (IS_NULL_UNEXPECTEDLY(pNewStylesW))
goto Quit;
}
@@ -257,6 +258,7 @@ UINT WINAPI ImmGetRegisterWordStyleA(HKL hKL, UINT nItem, LPSTYLEBUFA
lpStyleBuf
Quit:
ImmLocalFree(pNewStylesW);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %u\n", ret);
return ret;
}
@@ -275,10 +277,10 @@ UINT WINAPI ImmGetRegisterWordStyleW(HKL hKL, UINT nItem,
LPSTYLEBUFW lpStyleBuf
TRACE("(%p, %u, %p)\n", hKL, nItem, lpStyleBuf);
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return 0;
- if (ImeDpi_IsUnicode(pImeDpi))
+ if (ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeGetRegisterWordStyle(nItem, lpStyleBuf);
goto Quit;
@@ -287,7 +289,7 @@ UINT WINAPI ImmGetRegisterWordStyleW(HKL hKL, UINT nItem, LPSTYLEBUFW
lpStyleBuf
if (nItem > 0)
{
pNewStylesA = ImmLocalAlloc(0, nItem * sizeof(STYLEBUFA));
- if (!pNewStylesA)
+ if (IS_NULL_UNEXPECTEDLY(pNewStylesA))
goto Quit;
}
@@ -314,6 +316,7 @@ UINT WINAPI ImmGetRegisterWordStyleW(HKL hKL, UINT nItem, LPSTYLEBUFW
lpStyleBuf
Quit:
ImmLocalFree(pNewStylesA);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %u\n", ret);
return ret;
}
@@ -331,10 +334,10 @@ ImmRegisterWordA(HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR
lpszRegister
debugstr_a(lpszRegister));
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
- if (!ImeDpi_IsUnicode(pImeDpi))
+ if (!ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeRegisterWord(lpszReading, dwStyle, lpszRegister);
ImmUnlockImeDpi(pImeDpi);
@@ -344,14 +347,14 @@ ImmRegisterWordA(HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR
lpszRegister
if (lpszReading)
{
pszReadingW = Imm32WideFromAnsi(pImeDpi->uCodePage, lpszReading);
- if (pszReadingW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingW))
goto Quit;
}
if (lpszRegister)
{
pszRegisterW = Imm32WideFromAnsi(pImeDpi->uCodePage, lpszRegister);
- if (pszRegisterW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszRegisterW))
goto Quit;
}
@@ -361,6 +364,7 @@ Quit:
ImmLocalFree(pszReadingW);
ImmLocalFree(pszRegisterW);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %d\n", ret);
return ret;
}
@@ -378,10 +382,10 @@ ImmRegisterWordW(HKL hKL, LPCWSTR lpszReading, DWORD dwStyle,
LPCWSTR lpszRegist
debugstr_w(lpszRegister));
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
- if (ImeDpi_IsUnicode(pImeDpi))
+ if (ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeRegisterWord(lpszReading, dwStyle, lpszRegister);
ImmUnlockImeDpi(pImeDpi);
@@ -391,14 +395,14 @@ ImmRegisterWordW(HKL hKL, LPCWSTR lpszReading, DWORD dwStyle,
LPCWSTR lpszRegist
if (lpszReading)
{
pszReadingA = Imm32AnsiFromWide(pImeDpi->uCodePage, lpszReading);
- if (!pszReadingA)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingA))
goto Quit;
}
if (lpszRegister)
{
pszRegisterA = Imm32AnsiFromWide(pImeDpi->uCodePage, lpszRegister);
- if (!pszRegisterA)
+ if (IS_NULL_UNEXPECTEDLY(pszRegisterA))
goto Quit;
}
@@ -408,6 +412,7 @@ Quit:
ImmLocalFree(pszReadingA);
ImmLocalFree(pszRegisterA);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %d\n", ret);
return ret;
}
@@ -425,10 +430,10 @@ ImmUnregisterWordA(HKL hKL, LPCSTR lpszReading, DWORD dwStyle,
LPCSTR lpszUnregi
debugstr_a(lpszUnregister));
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (pImeDpi == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
- if (!ImeDpi_IsUnicode(pImeDpi))
+ if (!ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeUnregisterWord(lpszReading, dwStyle, lpszUnregister);
ImmUnlockImeDpi(pImeDpi);
@@ -438,14 +443,14 @@ ImmUnregisterWordA(HKL hKL, LPCSTR lpszReading, DWORD dwStyle,
LPCSTR lpszUnregi
if (lpszReading)
{
pszReadingW = Imm32WideFromAnsi(pImeDpi->uCodePage, lpszReading);
- if (pszReadingW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingW))
goto Quit;
}
if (lpszUnregister)
{
pszUnregisterW = Imm32WideFromAnsi(pImeDpi->uCodePage, lpszUnregister);
- if (pszUnregisterW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszUnregisterW))
goto Quit;
}
@@ -455,6 +460,7 @@ Quit:
ImmLocalFree(pszReadingW);
ImmLocalFree(pszUnregisterW);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %d\n", ret);
return ret;
}
@@ -472,10 +478,10 @@ ImmUnregisterWordW(HKL hKL, LPCWSTR lpszReading, DWORD dwStyle,
LPCWSTR lpszUnre
debugstr_w(lpszUnregister));
pImeDpi = Imm32FindOrLoadImeDpi(hKL);
- if (!pImeDpi)
+ if (IS_NULL_UNEXPECTEDLY(pImeDpi))
return FALSE;
- if (ImeDpi_IsUnicode(pImeDpi))
+ if (ImeDpi_IsUnicode(pImeDpi)) /* No conversion needed */
{
ret = pImeDpi->ImeUnregisterWord(lpszReading, dwStyle, lpszUnregister);
ImmUnlockImeDpi(pImeDpi);
@@ -485,14 +491,14 @@ ImmUnregisterWordW(HKL hKL, LPCWSTR lpszReading, DWORD dwStyle,
LPCWSTR lpszUnre
if (lpszReading)
{
pszReadingA = Imm32AnsiFromWide(pImeDpi->uCodePage, lpszReading);
- if (!pszReadingA)
+ if (IS_NULL_UNEXPECTEDLY(pszReadingA))
goto Quit;
}
if (lpszUnregister)
{
pszUnregisterA = Imm32AnsiFromWide(pImeDpi->uCodePage, lpszUnregister);
- if (!pszUnregisterA)
+ if (IS_NULL_UNEXPECTEDLY(pszUnregisterA))
goto Quit;
}
@@ -502,5 +508,6 @@ Quit:
ImmLocalFree(pszReadingA);
ImmLocalFree(pszUnregisterA);
ImmUnlockImeDpi(pImeDpi);
+ TRACE("ret: %d\n", ret);
return ret;
}
diff --git a/dll/win32/imm32/utils.c b/dll/win32/imm32/utils.c
index e9906ced61e..b98697358e9 100644
--- a/dll/win32/imm32/utils.c
+++ b/dll/win32/imm32/utils.c
@@ -15,6 +15,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm);
HANDLE ghImmHeap = NULL; // Win: pImmHeap
+/* Win: PtiCurrent */
+PTHREADINFO FASTCALL Imm32CurrentPti(VOID)
+{
+ if (NtCurrentTeb()->Win32ThreadInfo == NULL)
+ NtUserGetThreadState(THREADSTATE_GETTHREADINFO);
+ return NtCurrentTeb()->Win32ThreadInfo;
+}
+
+BOOL APIENTRY Imm32IsCrossThreadAccess(HIMC hIMC)
+{
+ DWORD_PTR dwImeThreadId = NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
+ DWORD_PTR dwCurrentThreadId = GetCurrentThreadId();
+ return dwImeThreadId != dwCurrentThreadId;
+}
+
+// Win: TestWindowProcess
+BOOL APIENTRY Imm32IsCrossProcessAccess(HWND hWnd)
+{
+ DWORD_PTR WndPID = NtUserQueryWindow(hWnd, QUERY_WINDOW_UNIQUE_PROCESS_ID);
+ DWORD_PTR CurrentPID = (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
+ return WndPID != CurrentPID;
+}
+
// Win: StrToUInt
HRESULT APIENTRY
Imm32StrToUInt(LPCWSTR pszText, LPDWORD pdwValue, ULONG nBase)
@@ -48,7 +71,12 @@ BOOL APIENTRY Imm32IsSystemJapaneseOrKorean(VOID)
LCID lcid = GetSystemDefaultLCID();
LANGID LangID = LANGIDFROMLCID(lcid);
WORD wPrimary = PRIMARYLANGID(LangID);
- return (wPrimary == LANG_JAPANESE || wPrimary == LANG_KOREAN);
+ if (wPrimary != LANG_JAPANESE || wPrimary != LANG_KOREAN)
+ {
+ WARN("\n");
+ return FALSE;
+ }
+ return TRUE;
}
typedef struct tagBITMAPCOREINFO256
@@ -75,7 +103,10 @@ HBITMAP Imm32LoadBitmapFromBytes(const BYTE *pb)
pbmci = (const BITMAPCOREINFO256 *)pb;
hbm = CreateDIBSection(NULL, (LPBITMAPINFO)pbmci, DIB_RGB_COLORS, &pvBits, NULL,
0);
if (!hbm || !GetObject(hbm, sizeof(BITMAP), &bm))
+ {
+ ERR("\n");
return NULL;
+ }
switch (pbmci->bmciHeader.bcBitCount)
{
@@ -86,6 +117,7 @@ HBITMAP Imm32LoadBitmapFromBytes(const BYTE *pb)
cColors = 0;
break;
default:
+ ERR("\n");
DeleteObject(hbm);
return NULL;
}
@@ -99,6 +131,7 @@ HBITMAP Imm32LoadBitmapFromBytes(const BYTE *pb)
ib += bm.bmWidthBytes * bm.bmHeight;
if (ib > cbBytes)
{
+ ERR("\n");
DeleteObject(hbm);
return NULL;
}
@@ -119,7 +152,10 @@ BOOL Imm32StoreBitmapToBytes(HBITMAP hbm, LPBYTE pbData, DWORD
cbDataMax)
*(LPDWORD)pb = 0;
if (!GetObject(hbm, sizeof(BITMAP), &bm))
+ {
+ ERR("\n");
return FALSE;
+ }
ZeroMemory(&bmci, sizeof(bmci));
bmci.bmciHeader.bcSize = sizeof(BITMAPCOREHEADER);
@@ -137,6 +173,7 @@ BOOL Imm32StoreBitmapToBytes(HBITMAP hbm, LPBYTE pbData, DWORD
cbDataMax)
cColors = 0;
break;
default:
+ ERR("\n");
return FALSE;
}
@@ -145,7 +182,10 @@ BOOL Imm32StoreBitmapToBytes(HBITMAP hbm, LPBYTE pbData, DWORD
cbDataMax)
cbBytes += cColors * sizeof(RGBTRIPLE);
cbBytes += bm.bmWidthBytes * bm.bmHeight;
if (cbBytes > cbDataMax)
+ {
+ ERR("\n");
return FALSE;
+ }
hDC = CreateCompatibleDC(NULL);
@@ -177,7 +217,7 @@ BOOL WINAPI Imm32IsImcAnsi(HIMC hIMC)
{
BOOL ret;
PCLIENTIMC pClientImc = ImmLockClientImc(hIMC);
- if (!pClientImc)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return -1;
ret = !(pClientImc->dwFlags & CLIENTIMC_WIDE);
ImmUnlockClientImc(pClientImc);
@@ -188,7 +228,7 @@ LPWSTR APIENTRY Imm32WideFromAnsi(UINT uCodePage, LPCSTR pszA)
{
INT cch = lstrlenA(pszA);
LPWSTR pszW = ImmLocalAlloc(0, (cch + 1) * sizeof(WCHAR));
- if (pszW == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pszW))
return NULL;
cch = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pszA, cch, pszW, cch + 1);
pszW[cch] = 0;
@@ -200,7 +240,7 @@ LPSTR APIENTRY Imm32AnsiFromWide(UINT uCodePage, LPCWSTR pszW)
INT cchW = lstrlenW(pszW);
INT cchA = (cchW + 1) * sizeof(WCHAR);
LPSTR pszA = ImmLocalAlloc(0, cchA);
- if (!pszA)
+ if (IS_NULL_UNEXPECTEDLY(pszA))
return NULL;
cchA = WideCharToMultiByte(uCodePage, 0, pszW, cchW, pszA, cchA, NULL, NULL);
pszA[cchA] = 0;
@@ -246,7 +286,10 @@ LONG APIENTRY IchAnsiFromWide(LONG cchWide, LPCWSTR pchWide, UINT
uCodePage)
BOOL Imm32GetSystemLibraryPath(LPWSTR pszPath, DWORD cchPath, LPCWSTR pszFileName)
{
if (!pszFileName[0] || !GetSystemDirectoryW(pszPath, cchPath))
+ {
+ ERR("\n");
return FALSE;
+ }
StringCchCatW(pszPath, cchPath, L"\\");
StringCchCatW(pszPath, cchPath, pszFileName);
return TRUE;
@@ -301,7 +344,10 @@ LPVOID FASTCALL ValidateHandleNoErr(HANDLE hObject, UINT uType)
LPVOID ptr;
if (!NtUserValidateHandleSecure(hObject))
+ {
+ WARN("\n");
return NULL;
+ }
ht = gSharedInfo.aheList; /* handle table */
ASSERT(ht);
@@ -345,13 +391,24 @@ LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
BOOL APIENTRY Imm32CheckImcProcess(PIMC pIMC)
{
HIMC hIMC;
- DWORD dwProcessID;
+ DWORD_PTR dwPID1, dwPID2;
+
+ if (IS_NULL_UNEXPECTEDLY(pIMC))
+ return FALSE;
+
if (pIMC->head.pti == Imm32CurrentPti())
return TRUE;
hIMC = pIMC->head.h;
- dwProcessID = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTPROCESSID);
- return dwProcessID == (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
+ dwPID1 = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTPROCESSID);
+ dwPID2 = (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess;
+ if (dwPID1 != dwPID2)
+ {
+ WARN("PID 0x%X != 0x%X\n", dwPID1, dwPID2);
+ return FALSE;
+ }
+
+ return TRUE;
}
// Win: ImmLocalAlloc
@@ -360,7 +417,7 @@ LPVOID APIENTRY ImmLocalAlloc(DWORD dwFlags, DWORD dwBytes)
if (!ghImmHeap)
{
ghImmHeap = RtlGetProcessHeap();
- if (ghImmHeap == NULL)
+ if (IS_NULL_UNEXPECTEDLY(ghImmHeap))
return NULL;
}
return HeapAlloc(ghImmHeap, dwFlags, dwBytes);
@@ -375,7 +432,7 @@ Imm32MakeIMENotify(HIMC hIMC, HWND hwnd, DWORD dwAction, DWORD_PTR
dwIndex, DWOR
HKL hKL;
PIMEDPI pImeDpi;
- if (dwAction)
+ if (dwAction != 0)
{
dwThreadId = (DWORD)NtUserQueryInputContext(hIMC, QIC_INPUTTHREADID);
if (dwThreadId)
@@ -409,7 +466,7 @@ DWORD APIENTRY Imm32BuildHimcList(DWORD dwThreadId, HIMC **pphList)
HIMC *phNewList;
phNewList = ImmLocalAlloc(0, dwCount * sizeof(HIMC));
- if (phNewList == NULL)
+ if (IS_NULL_UNEXPECTEDLY(phNewList))
return 0;
Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
@@ -420,7 +477,7 @@ DWORD APIENTRY Imm32BuildHimcList(DWORD dwThreadId, HIMC **pphList)
return 0;
phNewList = ImmLocalAlloc(0, dwCount * sizeof(HIMC));
- if (phNewList == NULL)
+ if (IS_NULL_UNEXPECTEDLY(phNewList))
return 0;
Status = NtUserBuildHimcList(dwThreadId, dwCount, phNewList, &dwCount);
@@ -428,6 +485,7 @@ DWORD APIENTRY Imm32BuildHimcList(DWORD dwThreadId, HIMC **pphList)
if (NT_ERROR(Status) || !dwCount)
{
+ ERR("\n");
ImmLocalFree(phNewList);
return 0;
}
@@ -538,12 +596,11 @@ BOOL APIENTRY
Imm32LoadImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
{
PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
- if (pSubState)
- {
- pIC->fdwSentence |= pSubState->dwValue;
- return TRUE;
- }
- return FALSE;
+ if (IS_NULL_UNEXPECTEDLY(pSubState))
+ return FALSE;
+
+ pIC->fdwSentence |= pSubState->dwValue;
+ return TRUE;
}
// Win: SavePrivateMode
@@ -551,12 +608,11 @@ BOOL APIENTRY
Imm32SaveImeStateSentence(LPINPUTCONTEXTDX pIC, PIME_STATE pState, HKL hKL)
{
PIME_SUBSTATE pSubState = Imm32FetchImeSubState(pState, hKL);
- if (pSubState)
- {
- pSubState->dwValue = (pIC->fdwSentence & 0xffff0000);
- return TRUE;
- }
- return FALSE;
+ if (IS_NULL_UNEXPECTEDLY(pSubState))
+ return FALSE;
+
+ pSubState->dwValue = (pIC->fdwSentence & 0xffff0000);
+ return TRUE;
}
/*
@@ -576,7 +632,10 @@ Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const
RECONVERTSTRING *pSrc,
LPWSTR pchDest;
if (pSrc->dwVersion != 0)
+ {
+ ERR("\n");
return 0;
+ }
cchDest = MultiByteToWideChar(uCodePage, MB_PRECOMPOSED, pchSrc, pSrc->dwStrLen,
NULL, 0);
@@ -585,7 +644,10 @@ Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const
RECONVERTSTRING *pSrc,
return cbDest;
if (pDest->dwSize < cbDest)
+ {
+ ERR("\n");
return 0;
+ }
/* dwSize */
pDest->dwSize = cbDest;
@@ -621,6 +683,7 @@ Imm32ReconvertWideFromAnsi(LPRECONVERTSTRING pDest, const
RECONVERTSTRING *pSrc,
pchDest, cchDest);
pchDest[cchDest] = 0;
+ TRACE("cbDest: 0x%X\n", cbDest);
return cbDest;
}
@@ -641,7 +704,10 @@ Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const
RECONVERTSTRING *pSrc,
return cbDest;
if (pDest->dwSize < cbDest)
+ {
+ ERR("\n");
return 0;
+ }
/* dwSize */
pDest->dwSize = cbDest;
@@ -679,6 +745,7 @@ Imm32ReconvertAnsiFromWide(LPRECONVERTSTRING pDest, const
RECONVERTSTRING *pSrc,
pchDest, cchDest, NULL, NULL);
pchDest[cchDest] = 0;
+ TRACE("cchDest: 0x%X\n", cchDest);
return cbDest;
}
@@ -696,11 +763,17 @@ static BOOL APIENTRY Imm32LoadImeFixedInfo(PIMEINFOEX pInfoEx,
LPCVOID pVerInfo)
UINT cbFixed = 0;
VS_FIXEDFILEINFO *pFixed;
if (!s_fnVerQueryValueW(pVerInfo, L"\\", (LPVOID*)&pFixed,
&cbFixed) || !cbFixed)
+ {
+ ERR("\n");
return FALSE;
+ }
/* NOTE: The IME module must contain a version info of input method driver. */
if (pFixed->dwFileType != VFT_DRV || pFixed->dwFileSubtype !=
VFT2_DRV_INPUTMETHOD)
+ {
+ ERR("\n");
return FALSE;
+ }
pInfoEx->dwProdVersion = pFixed->dwProductVersionMS;
pInfoEx->dwImeWinVersion = 0x40000;
@@ -737,10 +810,13 @@ BOOL APIENTRY Imm32LoadImeLangAndDesc(PIMEINFOEX pInfoEx, LPCVOID
pVerInfo)
/* Getting the version info. See VerQueryValue */
ret = s_fnVerQueryValueW(pVerInfo, L"\\VarFileInfo\\Translation",
(LPVOID*)&pw, &cbData);
if (!ret || !cbData)
+ {
+ ERR("\n");
return FALSE;
+ }
if (pInfoEx->hkl == NULL)
- pInfoEx->hkl = (HKL)(DWORD_PTR)*pw; /* This is an invalid HKL */
+ pInfoEx->hkl = (HKL)(DWORD_PTR)*pw;
/* Try the current language and the Unicode codepage (0x04B0) */
LangID = LANGIDFROMLCID(GetThreadLocale());
@@ -777,7 +853,7 @@ BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
if (!hinstVersion)
{
hinstVersion = LoadLibraryW(szPath);
- if (!hinstVersion)
+ if (IS_NULL_UNEXPECTEDLY(hinstVersion))
return FALSE;
bLoaded = TRUE;
@@ -796,11 +872,11 @@ BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Imm32GetSystemLibraryPath(szPath, _countof(szPath), pImeInfoEx->wszImeFile);
cbVerInfo = s_fnGetFileVersionInfoSizeW(szPath, &dwHandle);
- if (!cbVerInfo)
+ if (IS_ZERO_UNEXPECTEDLY(cbVerInfo))
goto Quit;
pVerInfo = ImmLocalAlloc(0, cbVerInfo);
- if (!pVerInfo)
+ if (IS_NULL_UNEXPECTEDLY(pVerInfo))
goto Quit;
/* Load the version info of the IME module */
@@ -815,6 +891,7 @@ BOOL APIENTRY Imm32LoadImeVerInfo(PIMEINFOEX pImeInfoEx)
Quit:
if (bLoaded)
FreeLibrary(hinstVersion);
+ TRACE("ret: %d\n", ret);
return ret;
}
@@ -877,7 +954,7 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts)
/* Open the registry keyboard layouts */
lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
- if (lError != ERROR_SUCCESS)
+ if (IS_ERROR_UNEXPECTEDLY(lError))
return 0;
for (iKey = nCount = 0; ; ++iKey)
@@ -900,8 +977,11 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts)
break;
lError = RegOpenKeyW(hkeyLayouts, szImeKey, &hkeyIME); /* Open the IME key
*/
- if (lError != ERROR_SUCCESS)
+ if (IS_ERROR_UNEXPECTEDLY(lError))
+ {
+ WARN("\n");
continue;
+ }
/* Load the "Ime File" value */
szImeFileName[0] = 0;
@@ -913,12 +993,18 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts)
/* We don't allow the invalid "IME File" values for security reason
*/
if (!szImeFileName[0] || wcscspn(szImeFileName, L":\\/") !=
wcslen(szImeFileName))
+ {
+ WARN("\n");
continue;
+ }
Imm32StrToUInt(szImeKey, &Value, 16);
hKL = (HKL)(DWORD_PTR)Value;
if (!IS_IME_HKL(hKL))
+ {
+ WARN("\n");
continue;
+ }
/* Store the IME key and the IME filename */
pLayouts[nCount].hKL = hKL;
@@ -946,27 +1032,27 @@ BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart,
LPCWSTR pszLayou
/* Open the registry keyboard layouts */
lError = RegOpenKeyW(HKEY_LOCAL_MACHINE, REGKEY_KEYBOARD_LAYOUTS, &hkeyLayouts);
- if (lError != ERROR_SUCCESS)
+ if (IS_ERROR_UNEXPECTEDLY(lError))
return FALSE;
/* Get the IME key from hKL */
- Imm32UIntToStr((DWORD)(DWORD_PTR)hKL, 16, szImeKey, _countof(szImeKey));
+ StringCchPrintf(szImeKey, _countof(szImeKey), L"%08X",
(DWORD)(DWORD_PTR)hKL);
/* Create a registry IME key */
lError = RegCreateKeyW(hkeyLayouts, szImeKey, &hkeyIME);
- if (lError != ERROR_SUCCESS)
+ if (IS_ERROR_UNEXPECTEDLY(lError))
goto Failure;
/* Write "Ime File" */
cbData = (wcslen(pchFilePart) + 1) * sizeof(WCHAR);
lError = RegSetValueExW(hkeyIME, L"Ime File", 0, REG_SZ,
(LPBYTE)pchFilePart, cbData);
- if (lError != ERROR_SUCCESS)
+ if (IS_ERROR_UNEXPECTEDLY(lError))
goto Failure;
/* Write "Layout Text" */
cbData = (wcslen(pszLayoutText) + 1) * sizeof(WCHAR);
lError = RegSetValueExW(hkeyIME, L"Layout Text", 0, REG_SZ,
(LPBYTE)pszLayoutText, cbData);
- if (lError != ERROR_SUCCESS)
+ if (IS_ERROR_UNEXPECTEDLY(lError))
goto Failure;
/* Choose "Layout File" from hKL */
@@ -981,7 +1067,7 @@ BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart,
LPCWSTR pszLayou
/* Write "Layout File" */
cbData = (wcslen(pszLayoutFile) + 1) * sizeof(WCHAR);
lError = RegSetValueExW(hkeyIME, L"Layout File", 0, REG_SZ,
(LPBYTE)pszLayoutFile, cbData);
- if (lError != ERROR_SUCCESS)
+ if (IS_ERROR_UNEXPECTEDLY(lError))
goto Failure;
RegCloseKey(hkeyIME);
@@ -1007,6 +1093,7 @@ BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart,
LPCWSTR pszLayou
if (iPreload >= MAX_PRELOAD) /* Not found */
{
+ WARN("\n");
RegCloseKey(hkeyPreload);
return FALSE;
}
@@ -1048,7 +1135,7 @@ BOOL APIENTRY Imm32CopyImeFile(LPWSTR pszOldFile, LPCWSTR
pszNewFile)
if (!hinstLZ32)
{
hinstLZ32 = LoadLibraryW(szLZ32Path);
- if (!hinstLZ32)
+ if (IS_NULL_UNEXPECTEDLY(hinstLZ32))
return FALSE;
bLoaded = TRUE;
}
@@ -1163,7 +1250,7 @@ DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC)
PCLIENTIMC pClientImc;
pClientImc = ImmLockClientImc(hIMC);
- if (pClientImc == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pClientImc))
return 0;
ret = 0;
diff --git a/dll/win32/imm32/win3.c b/dll/win32/imm32/win3.c
index 68dc4861f8c..7904c751561 100644
--- a/dll/win32/imm32/win3.c
+++ b/dll/win32/imm32/win3.c
@@ -16,7 +16,7 @@ DWORD APIENTRY
Imm32JTransCompA(LPINPUTCONTEXTDX pIC, LPCOMPOSITIONSTRING pCS,
const TRANSMSG *pSrc, LPTRANSMSG pDest)
{
- // FIXME
+ FIXME("\n");
*pDest = *pSrc;
return 1;
}
@@ -26,7 +26,7 @@ DWORD APIENTRY
Imm32JTransCompW(LPINPUTCONTEXTDX pIC, LPCOMPOSITIONSTRING pCS,
const TRANSMSG *pSrc, LPTRANSMSG pDest)
{
- // FIXME
+ FIXME("\n");
*pDest = *pSrc;
return 1;
}
@@ -52,7 +52,7 @@ WINNLSTranslateMessageJ(DWORD dwCount, LPTRANSMSG pTrans,
LPINPUTCONTEXTDX pIC,
// clone the message list
cbTempList = (dwCount + 1) * sizeof(TRANSMSG);
pTempList = ImmLocalAlloc(HEAP_ZERO_MEMORY, cbTempList);
- if (pTempList == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pTempList))
return 0;
RtlCopyMemory(pTempList, pTrans, dwCount * sizeof(TRANSMSG));
@@ -188,19 +188,22 @@ WINNLSTranslateMessage(DWORD dwCount, LPTRANSMSG pEntries, HIMC
hIMC, BOOL bAnsi
LPCOMPOSITIONSTRING pCS;
pIC = (LPINPUTCONTEXTDX)ImmLockIMC(hIMC);
- if (pIC == NULL)
+ if (IS_NULL_UNEXPECTEDLY(pIC))
return 0;
pCS = ImmLockIMCC(pIC->hCompStr);
- if (pCS)
+ if (IS_NULL_UNEXPECTEDLY(pCS))
{
- if (wLang == LANG_JAPANESE)
- ret = WINNLSTranslateMessageJ(dwCount, pEntries, pIC, pCS, bAnsi);
- else if (wLang == LANG_KOREAN)
- ret = WINNLSTranslateMessageK(dwCount, pEntries, pIC, pCS, bAnsi);
- ImmUnlockIMCC(pIC->hCompStr);
+ ImmUnlockIMC(hIMC);
+ return 0;
}
+ if (wLang == LANG_JAPANESE)
+ ret = WINNLSTranslateMessageJ(dwCount, pEntries, pIC, pCS, bAnsi);
+ else if (wLang == LANG_KOREAN)
+ ret = WINNLSTranslateMessageK(dwCount, pEntries, pIC, pCS, bAnsi);
+
+ ImmUnlockIMCC(pIC->hCompStr);
ImmUnlockIMC(hIMC);
return ret;
}