[NTUSER][USER32] NtUserGetKeyboardLayoutName and GetKeyboardLayoutNameW (#4595)

#4594 has proved that the 1st argument of NtUserGetKeyboardLayoutName has type PUNICODE_STRING.
CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-08-06 08:02:31 +09:00 committed by GitHub
parent 786017c5b6
commit 3e42f7b478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 9 deletions

View file

@ -417,7 +417,7 @@
@ stdcall NtUserGetImeInfoEx(long long) @ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr) @ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr) @ stdcall NtUserGetKeyboardLayoutList(long ptr)
@ stdcall NtUserGetKeyboardLayoutName(str) @ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr) @ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long) @ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long) @ stdcall NtUserGetKeyState(long)

View file

@ -418,7 +418,7 @@
@ stdcall NtUserGetImeInfoEx(long long) @ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr) @ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr) @ stdcall NtUserGetKeyboardLayoutList(long ptr)
@ stdcall NtUserGetKeyboardLayoutName(str) @ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr) @ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long) @ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long) @ stdcall NtUserGetKeyState(long)

View file

@ -431,7 +431,7 @@
@ stdcall NtUserGetImeInfoEx(long long) @ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr) @ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr) @ stdcall NtUserGetKeyboardLayoutList(long ptr)
@ stdcall NtUserGetKeyboardLayoutName(str) @ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr) @ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long) @ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long) @ stdcall NtUserGetKeyState(long)

View file

@ -417,7 +417,7 @@
@ stdcall NtUserGetImeInfoEx(long long) @ stdcall NtUserGetImeInfoEx(long long)
@ stdcall NtUserGetInternalWindowPos(ptr ptr ptr) @ stdcall NtUserGetInternalWindowPos(ptr ptr ptr)
@ stdcall NtUserGetKeyboardLayoutList(long ptr) @ stdcall NtUserGetKeyboardLayoutList(long ptr)
@ stdcall NtUserGetKeyboardLayoutName(str) @ stdcall NtUserGetKeyboardLayoutName(ptr)
@ stdcall NtUserGetKeyboardState(ptr) @ stdcall NtUserGetKeyboardState(ptr)
@ stdcall NtUserGetKeyNameText(long wstr long) @ stdcall NtUserGetKeyNameText(long wstr long)
@ stdcall NtUserGetKeyState(long) @ stdcall NtUserGetKeyState(long)

View file

@ -2431,7 +2431,7 @@ NtUserGetKeyboardLayoutList(
BOOL BOOL
NTAPI NTAPI
NtUserGetKeyboardLayoutName( NtUserGetKeyboardLayoutName(
LPWSTR lpszName); _Inout_ PUNICODE_STRING pustrName);
DWORD DWORD
NTAPI NTAPI

View file

@ -649,11 +649,12 @@ Quit:
BOOL BOOL
APIENTRY APIENTRY
NtUserGetKeyboardLayoutName( NtUserGetKeyboardLayoutName(
LPWSTR pwszName) _Inout_ PUNICODE_STRING pustrName)
{ {
BOOL bRet = FALSE; BOOL bRet = FALSE;
PKL pKl; PKL pKl;
PTHREADINFO pti; PTHREADINFO pti;
UNICODE_STRING ustrTemp;
UserEnterShared(); UserEnterShared();
@ -665,8 +666,24 @@ NtUserGetKeyboardLayoutName(
_SEH2_TRY _SEH2_TRY
{ {
ProbeForWrite(pwszName, KL_NAMELENGTH*sizeof(WCHAR), 1); ProbeForWriteUnicodeString(pustrName);
wcscpy(pwszName, pKl->spkf->awchKF); 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; bRet = TRUE;
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)

View file

@ -584,7 +584,13 @@ GetKeyboardLayoutNameA(LPSTR pwszKLID)
BOOL WINAPI BOOL WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID) GetKeyboardLayoutNameW(LPWSTR pwszKLID)
{ {
return NtUserGetKeyboardLayoutName(pwszKLID); UNICODE_STRING Name;
RtlInitEmptyUnicodeString(&Name,
pwszKLID,
KL_NAMELENGTH * sizeof(WCHAR));
return NtUserGetKeyboardLayoutName(&Name);
} }
/* /*