#4594 has proved that the 1st argument of NtUserGetKeyboardLayoutName has type PUNICODE_STRING.
CORE-11700
@ 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)
@ 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)
@ 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)
@ 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)
BOOL
NTAPI
NtUserGetKeyboardLayoutName(
- LPWSTR lpszName);
+ _Inout_ PUNICODE_STRING pustrName);
DWORD
NTAPI
BOOL
APIENTRY
NtUserGetKeyboardLayoutName(
- LPWSTR pwszName)
+ _Inout_ PUNICODE_STRING pustrName)
{
BOOL bRet = FALSE;
PKL pKl;
PTHREADINFO pti;
+ UNICODE_STRING ustrTemp;
UserEnterShared();
_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)
BOOL WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID)
{
- return NtUserGetKeyboardLayoutName(pwszKLID);
+ UNICODE_STRING Name;
+
+ RtlInitEmptyUnicodeString(&Name,
+ pwszKLID,
+ KL_NAMELENGTH * sizeof(WCHAR));
+
+ return NtUserGetKeyboardLayoutName(&Name);
}
/*