https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3e42f7b47844dc4764c11…
commit 3e42f7b47844dc4764c11d8641a8f816d6a493a0
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Aug 6 08:02:31 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Aug 6 08:02:31 2022 +0900
[NTUSER][USER32] NtUserGetKeyboardLayoutName and GetKeyboardLayoutNameW (#4595)
#4594 has proved that the 1st argument of NtUserGetKeyboardLayoutName has type
PUNICODE_STRING.
CORE-11700
---
.../win32u/win32u_2k3sp2/win32u_2k3sp2.spec | 2 +-
.../apitests/win32u/win32u_ros/win32u_ros.spec | 2 +-
.../apitests/win32u/win32u_vista/win32u_vista.spec | 2 +-
.../apitests/win32u/win32u_xpsp2/win32u_xpsp2.spec | 2 +-
win32ss/include/ntuser.h | 2 +-
win32ss/user/ntuser/kbdlayout.c | 23 +++++++++++++++++++---
win32ss/user/user32/windows/input.c | 8 +++++++-
7 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/modules/rostests/apitests/win32u/win32u_2k3sp2/win32u_2k3sp2.spec
b/modules/rostests/apitests/win32u/win32u_2k3sp2/win32u_2k3sp2.spec
index d09cec87675..f3bd7079f1f 100644
--- a/modules/rostests/apitests/win32u/win32u_2k3sp2/win32u_2k3sp2.spec
+++ b/modules/rostests/apitests/win32u/win32u_2k3sp2/win32u_2k3sp2.spec
@@ -417,7 +417,7 @@
@ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr)
-@ stdcall NtUserGetKeyboardLayoutName(str)
+@ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long)
diff --git a/modules/rostests/apitests/win32u/win32u_ros/win32u_ros.spec
b/modules/rostests/apitests/win32u/win32u_ros/win32u_ros.spec
index 6fe82b27349..d307cec4ac0 100644
--- a/modules/rostests/apitests/win32u/win32u_ros/win32u_ros.spec
+++ b/modules/rostests/apitests/win32u/win32u_ros/win32u_ros.spec
@@ -418,7 +418,7 @@
@ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr)
-@ stdcall NtUserGetKeyboardLayoutName(str)
+@ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long)
diff --git a/modules/rostests/apitests/win32u/win32u_vista/win32u_vista.spec
b/modules/rostests/apitests/win32u/win32u_vista/win32u_vista.spec
index 8b716bb120f..2c39932a2b6 100644
--- a/modules/rostests/apitests/win32u/win32u_vista/win32u_vista.spec
+++ b/modules/rostests/apitests/win32u/win32u_vista/win32u_vista.spec
@@ -431,7 +431,7 @@
@ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr)
-@ stdcall NtUserGetKeyboardLayoutName(str)
+@ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long)
diff --git a/modules/rostests/apitests/win32u/win32u_xpsp2/win32u_xpsp2.spec
b/modules/rostests/apitests/win32u/win32u_xpsp2/win32u_xpsp2.spec
index bd059a8c0e4..ecf140ad399 100644
--- a/modules/rostests/apitests/win32u/win32u_xpsp2/win32u_xpsp2.spec
+++ b/modules/rostests/apitests/win32u/win32u_xpsp2/win32u_xpsp2.spec
@@ -417,7 +417,7 @@
@ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr)
-@ stdcall NtUserGetKeyboardLayoutName(str)
+@ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long)
diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h
index 7dde3b3810f..531d83392ef 100644
--- a/win32ss/include/ntuser.h
+++ b/win32ss/include/ntuser.h
@@ -2431,7 +2431,7 @@ NtUserGetKeyboardLayoutList(
BOOL
NTAPI
NtUserGetKeyboardLayoutName(
- LPWSTR lpszName);
+ _Inout_ PUNICODE_STRING pustrName);
DWORD
NTAPI
diff --git a/win32ss/user/ntuser/kbdlayout.c b/win32ss/user/ntuser/kbdlayout.c
index bca41faef3b..a91a641e994 100644
--- a/win32ss/user/ntuser/kbdlayout.c
+++ b/win32ss/user/ntuser/kbdlayout.c
@@ -649,11 +649,12 @@ Quit:
BOOL
APIENTRY
NtUserGetKeyboardLayoutName(
- LPWSTR pwszName)
+ _Inout_ PUNICODE_STRING pustrName)
{
BOOL bRet = FALSE;
PKL pKl;
PTHREADINFO pti;
+ UNICODE_STRING ustrTemp;
UserEnterShared();
@@ -665,8 +666,24 @@ NtUserGetKeyboardLayoutName(
_SEH2_TRY
{
- ProbeForWrite(pwszName, KL_NAMELENGTH*sizeof(WCHAR), 1);
- wcscpy(pwszName, pKl->spkf->awchKF);
+ ProbeForWriteUnicodeString(pustrName);
+ ProbeForWrite(pustrName->Buffer, pustrName->MaximumLength, 1);
+
+ if (IS_IME_HKL(pKl->hkl))
+ {
+ RtlIntegerToUnicodeString((ULONG)(ULONG_PTR)pKl->hkl, 16, pustrName);
+ }
+ else
+ {
+ if (pustrName->MaximumLength < KL_NAMELENGTH * sizeof(WCHAR))
+ {
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ goto cleanup;
+ }
+ RtlInitUnicodeString(&ustrTemp, pKl->spkf->awchKF); /* FIXME: Do
not use awchKF */
+ RtlCopyUnicodeString(pustrName, &ustrTemp);
+ }
+
bRet = TRUE;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
diff --git a/win32ss/user/user32/windows/input.c b/win32ss/user/user32/windows/input.c
index 50189f831f4..1de1dc0f293 100644
--- a/win32ss/user/user32/windows/input.c
+++ b/win32ss/user/user32/windows/input.c
@@ -584,7 +584,13 @@ GetKeyboardLayoutNameA(LPSTR pwszKLID)
BOOL WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID)
{
- return NtUserGetKeyboardLayoutName(pwszKLID);
+ UNICODE_STRING Name;
+
+ RtlInitEmptyUnicodeString(&Name,
+ pwszKLID,
+ KL_NAMELENGTH * sizeof(WCHAR));
+
+ return NtUserGetKeyboardLayoutName(&Name);
}
/*