https://git.reactos.org/?p=reactos.git;a=commitdiff;h=89f5f5bb95c6109a6fcea…
commit 89f5f5bb95c6109a6fcea95a45b68cc24ae16cef
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Jul 4 08:18:15 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sun Jul 4 08:18:15 2021 +0900
[IMM32] Rewrite ImmGetDescriptionA/W (#3780)
CORE-11700
---
dll/win32/imm32/imm.c | 36 ++++++++++++++++++++++++++++++++++++
sdk/include/reactos/imm32_undoc.h | 23 +++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index 45be160a528..ca026d473f0 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -37,9 +37,12 @@
#include "winreg.h"
#include "wine/list.h"
#ifdef __REACTOS__
+#include <stdlib.h>
#include <ndk/umtypes.h>
#include <ndk/pstypes.h>
#include "../../../win32ss/include/ntuser.h"
+#include <imm32_undoc.h>
+#include <strsafe.h>
#endif
WINE_DEFAULT_DEBUG_CHANNEL(imm);
@@ -1765,6 +1768,22 @@ HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
UINT WINAPI ImmGetDescriptionA(
HKL hKL, LPSTR lpszDescription, UINT uBufLen)
{
+#ifdef __REACTOS__
+ IMEINFOEX info;
+ size_t cch;
+
+ TRACE("ImmGetDescriptionA(%p,%p,%d)\n", hKL, lpszDescription, uBufLen);
+
+ if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL) ||
!IS_IME_KBDLAYOUT(hKL))
+ return 0;
+
+ StringCchLengthW(info.wszImeDescription, _countof(info.wszImeDescription),
&cch);
+ cch = WideCharToMultiByte(CP_ACP, 0, info.wszImeDescription, (INT)cch,
+ lpszDescription, uBufLen, NULL, NULL);
+ if (uBufLen)
+ lpszDescription[cch] = 0;
+ return cch;
+#else
WCHAR *buf;
DWORD len;
@@ -1793,6 +1812,7 @@ UINT WINAPI ImmGetDescriptionA(
return 0;
return len - 1;
+#endif
}
/***********************************************************************
@@ -1800,6 +1820,21 @@ UINT WINAPI ImmGetDescriptionA(
*/
UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription, UINT uBufLen)
{
+#ifdef __REACTOS__
+ IMEINFOEX info;
+ size_t cch;
+
+ TRACE("ImmGetDescriptionW(%p, %p, %d)\n", hKL, lpszDescription, uBufLen);
+
+ if (!ImmGetImeInfoEx(&info, ImeInfoExKeyboardLayout, &hKL) ||
!IS_IME_KBDLAYOUT(hKL))
+ return 0;
+
+ if (uBufLen != 0)
+ StringCchCopyW(lpszDescription, uBufLen, info.wszImeDescription);
+
+ StringCchLengthW(info.wszImeDescription, _countof(info.wszImeDescription),
&cch);
+ return (UINT)cch;
+#else
static const WCHAR name[] = { 'W','i','n','e','
','X','I','M',0 };
FIXME("(%p, %p, %d): semi stub\n", hKL, lpszDescription, uBufLen);
@@ -1808,6 +1843,7 @@ UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription, UINT
uBufLen)
if (!uBufLen) return lstrlenW( name );
lstrcpynW( lpszDescription, name, uBufLen );
return lstrlenW( lpszDescription );
+#endif
}
/***********************************************************************
diff --git a/sdk/include/reactos/imm32_undoc.h b/sdk/include/reactos/imm32_undoc.h
new file mode 100644
index 00000000000..32858af1068
--- /dev/null
+++ b/sdk/include/reactos/imm32_undoc.h
@@ -0,0 +1,23 @@
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE: Private header for imm32.dll
+ * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ
<katayama.hirofumi.mz(a)gmail.com>
+ */
+
+#pragma once
+
+#define KBDLAYOUT_MASK 0xF000
+#define KBDLAYOUT_IME 0xE000
+#define IS_IME_KBDLAYOUT(hKL) ((HIWORD(hKL) & KBDLAYOUT_MASK) == KBDLAYOUT_IME)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+BOOL WINAPI
+ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType, PVOID pvSearchKey);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif