https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1e62771c7821b3ab221e4…
commit 1e62771c7821b3ab221e47d786c1323f266e4208
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Aug 10 08:08:23 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Aug 10 08:08:23 2021 +0900
[IMM32] Rewrite ImmRegisterWordA (#3881)
- Rewrite ImmRegisterWordA function.
- Modify imetable.h.
CORE-11700
---
dll/win32/imm32/imm.c | 87 ++++++++++++++++++++++++++++++++++++----------
win32ss/include/imetable.h | 10 +++---
2 files changed, 73 insertions(+), 24 deletions(-)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 7ae9094844c..963ebb9acab 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -437,6 +437,27 @@ BOOL WINAPI ImmLoadIME(HKL hKL)
return (pImeDpi != NULL);
}
+PIMEDPI APIENTRY ImmLockOrLoadImeDpi(HKL hKL)
+{
+ PW32CLIENTINFO pInfo;
+ PIMEDPI pImeDpi;
+
+ if (!IS_IME_HKL(hKL))
+ {
+ if (!g_psi || !(g_psi->dwSRVIFlags & SRVINFO_CICERO_ENABLED))
+ return NULL;
+
+ pInfo = (PW32CLIENTINFO)(NtCurrentTeb()->Win32ClientInfo);
+ if ((pInfo->W32ClientInfo[0] & 2))
+ return NULL;
+ }
+
+ pImeDpi = ImmLockImeDpi(hKL);
+ if (pImeDpi == NULL)
+ pImeDpi = Ime32LoadImeDpi(hKL, TRUE);
+ return pImeDpi;
+}
+
HKL WINAPI ImmLoadLayout(HKL hKL, PIMEINFOEX pImeInfoEx)
{
DWORD cbData;
@@ -3332,28 +3353,56 @@ BOOL WINAPI ImmNotifyIME(
BOOL WINAPI ImmRegisterWordA(
HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister)
{
- ImmHkl *immHkl = IMM_GetImmHkl(hKL);
- TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle,
- debugstr_a(lpszRegister));
- if (immHkl->hIME && immHkl->pImeRegisterWord)
+ BOOL ret = FALSE;
+ PIMEDPI pImeDpi;
+ LPWSTR pszReadingW = NULL, pszRegisterW = NULL;
+ INT cch;
+
+ TRACE("(%p, %s, 0x%lX, %s)\n", hKL, debugstr_a(lpszReading), dwStyle,
+ debugstr_a(lpszRegister));
+
+ pImeDpi = ImmLockOrLoadImeDpi(hKL);
+ if (!pImeDpi)
+ return FALSE;
+
+ if (!(pImeDpi->ImeInfo.fdwProperty & IME_PROP_UNICODE))
{
- if (!is_kbd_ime_unicode(immHkl))
- return immHkl->pImeRegisterWord((LPCWSTR)lpszReading,dwStyle,
- (LPCWSTR)lpszRegister);
- else
- {
- LPWSTR lpszwReading = strdupAtoW(lpszReading);
- LPWSTR lpszwRegister = strdupAtoW(lpszRegister);
- BOOL rc;
+ ret = pImeDpi->ImeRegisterWord(lpszReading, dwStyle, lpszRegister);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
+ }
- rc = immHkl->pImeRegisterWord(lpszwReading,dwStyle,lpszwRegister);
- HeapFree(GetProcessHeap(),0,lpszwReading);
- HeapFree(GetProcessHeap(),0,lpszwRegister);
- return rc;
- }
+ if (lpszReading)
+ {
+ cch = lstrlenA(lpszReading);
+ pszReadingW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
+ if (pszReadingW == NULL)
+ goto Quit;
+ cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszReading, cch,
+ pszReadingW, cch + 1);
+ pszReadingW[cch] = 0;
}
- else
- return FALSE;
+
+ if (lpszRegister)
+ {
+ cch = lstrlenA(lpszRegister);
+ pszRegisterW = Imm32HeapAlloc(0, (cch + 1) * sizeof(WCHAR));
+ if (pszRegisterW == NULL)
+ goto Quit;
+ cch = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszRegister, cch,
+ pszRegisterW, cch + 1);
+ pszRegisterW[cch] = 0;
+ }
+
+ ret = ImmRegisterWordW(hKL, pszReadingW, dwStyle, pszRegisterW);
+
+Quit:
+ if (pszReadingW)
+ HeapFree(g_hImm32Heap, 0, pszReadingW);
+ if (pszRegisterW)
+ HeapFree(g_hImm32Heap, 0, pszRegisterW);
+ ImmUnlockImeDpi(pImeDpi);
+ return ret;
}
/***********************************************************************
diff --git a/win32ss/include/imetable.h b/win32ss/include/imetable.h
index 5157ec43030..3bfd5c1d562 100644
--- a/win32ss/include/imetable.h
+++ b/win32ss/include/imetable.h
@@ -1,10 +1,10 @@
/* DEFINE_IME_ENTRY(type, name, params, extended) */
-DEFINE_IME_ENTRY(BOOL, ImeInquire, (LPIMEINFO lpIMEInfo, LPWSTR lpszWndClass, DWORD
dwSystemInfoFlags), FALSE)
-DEFINE_IME_ENTRY(DWORD, ImeConversionList, (HIMC hIMC, LPCWSTR lpSrc, LPCANDIDATELIST
lpDst, DWORD dwBufLen, UINT uFlag), FALSE)
-DEFINE_IME_ENTRY(BOOL, ImeRegisterWord, (LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR
lpszString), FALSE)
-DEFINE_IME_ENTRY(BOOL, ImeUnregisterWord, (LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR
lpszString), FALSE)
+DEFINE_IME_ENTRY(BOOL, ImeInquire, (LPIMEINFO lpIMEInfo, LPVOID lpszWndClass, DWORD
dwSystemInfoFlags), FALSE)
+DEFINE_IME_ENTRY(DWORD, ImeConversionList, (HIMC hIMC, LPCVOID lpSrc, LPCANDIDATELIST
lpDst, DWORD dwBufLen, UINT uFlag), FALSE)
+DEFINE_IME_ENTRY(BOOL, ImeRegisterWord, (LPCVOID lpszReading, DWORD dwStyle, LPCVOID
lpszString), FALSE)
+DEFINE_IME_ENTRY(BOOL, ImeUnregisterWord, (LPCVOID lpszReading, DWORD dwStyle, LPCVOID
lpszString), FALSE)
DEFINE_IME_ENTRY(UINT, ImeGetRegisterWordStyle, (UINT nItem, LPSTYLEBUFW lpStyleBuf),
FALSE)
-DEFINE_IME_ENTRY(UINT, ImeEnumRegisterWord, (HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszString, LPVOID lpData), FALSE)
+DEFINE_IME_ENTRY(UINT, ImeEnumRegisterWord, (HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
LPCVOID lpszReading, DWORD dwStyle, LPCVOID lpszString, LPVOID lpData), FALSE)
DEFINE_IME_ENTRY(BOOL, ImeConfigure, (HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData),
FALSE)
DEFINE_IME_ENTRY(BOOL, ImeDestroy, (UINT uReserved), FALSE)
DEFINE_IME_ENTRY(LRESULT, ImeEscape, (HIMC hIMC, UINT uEscape, LPVOID lpData), FALSE)