- do not use RETURN macro in keyboard functions

svn path=/trunk/; revision=54085
This commit is contained in:
Giannis Adamopoulos 2011-10-11 19:22:07 +00:00
parent daa8000263
commit 9adbc29775
2 changed files with 64 additions and 81 deletions

View file

@ -617,17 +617,17 @@ APIENTRY
NtUserBlockInput( NtUserBlockInput(
BOOL BlockIt) BOOL BlockIt)
{ {
DECLARE_RETURN(BOOLEAN); BOOL ret;
TRACE("Enter NtUserBlockInput\n"); TRACE("Enter NtUserBlockInput\n");
UserEnterExclusive(); UserEnterExclusive();
RETURN( IntBlockInput(PsGetCurrentThreadWin32Thread(), BlockIt)); ret = IntBlockInput(PsGetCurrentThreadWin32Thread(), BlockIt);
CLEANUP:
TRACE("Leave NtUserBlockInput, ret=%i\n", _ret_);
UserLeave(); UserLeave();
END_CLEANUP; TRACE("Leave NtUserBlockInput, ret=%i\n", ret);
return ret;
} }
BOOL FASTCALL BOOL FASTCALL

View file

@ -591,30 +591,28 @@ APIENTRY
NtUserGetAsyncKeyState(INT Key) NtUserGetAsyncKeyState(INT Key)
{ {
WORD wRet = 0; WORD wRet = 0;
DECLARE_RETURN(SHORT);
TRACE("Enter NtUserGetAsyncKeyState\n"); TRACE("Enter NtUserGetAsyncKeyState\n");
if (Key >= 0x100)
{
EngSetLastError(ERROR_INVALID_PARAMETER);
ERR("Invalid parameter Key\n");
return 0;
}
UserEnterExclusive(); UserEnterExclusive();
if (Key < 0x100)
{
if (IS_KEY_DOWN(gafAsyncKeyState, Key)) if (IS_KEY_DOWN(gafAsyncKeyState, Key))
wRet |= 0x8000; // If down, windows returns 0x8000. wRet |= 0x8000; // If down, windows returns 0x8000.
if (gafAsyncKeyStateRecentDown[Key / 8] & (1 << (Key % 8))) if (gafAsyncKeyStateRecentDown[Key / 8] & (1 << (Key % 8)))
wRet |= 0x1; wRet |= 0x1;
gafAsyncKeyStateRecentDown[Key / 8] &= ~(1 << (Key % 8)); gafAsyncKeyStateRecentDown[Key / 8] &= ~(1 << (Key % 8));
}
else
{
EngSetLastError(ERROR_INVALID_PARAMETER);
}
RETURN(wRet);
CLEANUP:
TRACE("Leave NtUserGetAsyncKeyState, ret=%i\n", _ret_);
UserLeave(); UserLeave();
END_CLEANUP;
TRACE("Leave NtUserGetAsyncKeyState, ret=%i\n", wRet);
return wRet;
} }
/* /*
@ -1101,7 +1099,7 @@ APIENTRY
NtUserMapVirtualKeyEx(UINT uCode, UINT uType, DWORD keyboardId, HKL dwhkl) NtUserMapVirtualKeyEx(UINT uCode, UINT uType, DWORD keyboardId, HKL dwhkl)
{ {
PKBDTABLES pKbdTbl = NULL; PKBDTABLES pKbdTbl = NULL;
DECLARE_RETURN(UINT); UINT ret = 0;
TRACE("Enter NtUserMapVirtualKeyEx\n"); TRACE("Enter NtUserMapVirtualKeyEx\n");
UserEnterExclusive(); UserEnterExclusive();
@ -1123,15 +1121,12 @@ NtUserMapVirtualKeyEx(UINT uCode, UINT uType, DWORD keyboardId, HKL dwhkl)
pKbdTbl = pKbl->KBTables; pKbdTbl = pKbl->KBTables;
} }
if (!pKbdTbl) if (pKbdTbl)
RETURN(0); ret = IntMapVirtualKeyEx(uCode, uType, pKbdTbl);
RETURN(IntMapVirtualKeyEx(uCode, uType, pKbdTbl));
CLEANUP:
TRACE("Leave NtUserMapVirtualKeyEx, ret=%i\n", _ret_);
UserLeave(); UserLeave();
END_CLEANUP; TRACE("Leave NtUserMapVirtualKeyEx, ret=%i\n", ret);
return ret;
} }
/* /*
@ -1155,16 +1150,14 @@ NtUserToUnicodeEx(
PWCHAR pwszBuff = NULL; PWCHAR pwszBuff = NULL;
INT i, iRet = 0; INT i, iRet = 0;
PKBL pKbl = NULL; PKBL pKbl = NULL;
NTSTATUS Status = STATUS_SUCCESS;
DECLARE_RETURN(INT);
TRACE("Enter NtUserSetKeyboardState\n"); TRACE("Enter NtUserSetKeyboardState\n");
UserEnterShared();
/* Return 0 if SC_KEY_UP bit is set */ /* Return 0 if SC_KEY_UP bit is set */
if (wScanCode & SC_KEY_UP) if (wScanCode & SC_KEY_UP || wVirtKey >= 0x100)
{ {
RETURN(0); ERR("Invalid parameter\n");
return 0;
} }
_SEH2_TRY _SEH2_TRY
@ -1181,28 +1174,22 @@ NtUserToUnicodeEx(
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
Status = _SEH2_GetExceptionCode(); ERR("Cannot copy key state\n");
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(return 0);
} }
_SEH2_END; _SEH2_END;
if (!NT_SUCCESS(Status))
{
ERR("Cannot copy key state\n");
SetLastNtError(Status);
RETURN(0);
}
/* Virtual code is correct? */
if (wVirtKey < 0x100)
{
pwszBuff = ExAllocatePoolWithTag(NonPagedPool, sizeof(WCHAR) * cchBuff, TAG_STRING); pwszBuff = ExAllocatePoolWithTag(NonPagedPool, sizeof(WCHAR) * cchBuff, TAG_STRING);
if (!pwszBuff) if (!pwszBuff)
{ {
ERR("ExAllocatePoolWithTag(%d) failed\n", sizeof(WCHAR) * cchBuff); ERR("ExAllocatePoolWithTag(%d) failed\n", sizeof(WCHAR) * cchBuff);
RETURN(0); return 0;
} }
RtlZeroMemory(pwszBuff, sizeof(WCHAR) * cchBuff); RtlZeroMemory(pwszBuff, sizeof(WCHAR) * cchBuff);
UserEnterShared();
if (dwhkl) if (dwhkl)
pKbl = UserHklToKbl(dwhkl); pKbl = UserHklToKbl(dwhkl);
@ -1222,14 +1209,10 @@ NtUserToUnicodeEx(
MmCopyToCaller(pwszBuffUnsafe, pwszBuff, cchBuff * sizeof(WCHAR)); MmCopyToCaller(pwszBuffUnsafe, pwszBuff, cchBuff * sizeof(WCHAR));
ExFreePoolWithTag(pwszBuff, TAG_STRING); ExFreePoolWithTag(pwszBuff, TAG_STRING);
}
RETURN(iRet);
CLEANUP:
TRACE("Leave NtUserSetKeyboardState, ret=%i\n", _ret_);
UserLeave(); UserLeave();
END_CLEANUP; TRACE("Leave NtUserSetKeyboardState, ret=%i\n", iRet);
return iRet;
} }
/* /*
@ -1249,17 +1232,20 @@ NtUserGetKeyNameText(LONG lParam, LPWSTR lpString, int cchSize)
VSC_LPWSTR *pKeyNames = NULL; VSC_LPWSTR *pKeyNames = NULL;
CONST WCHAR *pKeyName = NULL; CONST WCHAR *pKeyName = NULL;
WCHAR KeyNameBuf[2]; WCHAR KeyNameBuf[2];
DECLARE_RETURN(DWORD);
TRACE("Enter NtUserGetKeyNameText\n"); TRACE("Enter NtUserGetKeyNameText\n");
UserEnterShared();
/* Get current keyboard layout */ /* Get current keyboard layout */
pti = PsGetCurrentThreadWin32Thread(); pti = PsGetCurrentThreadWin32Thread();
pKbdTbl = pti ? pti->KeyboardLayout->KBTables : 0; pKbdTbl = pti ? pti->KeyboardLayout->KBTables : 0;
if (!pKbdTbl || cchSize < 1) if (!pKbdTbl || cchSize < 1)
RETURN(0); {
ERR("Invalid parameter\n");
return 0;
}
UserEnterShared();
/* "Do not care" flag */ /* "Do not care" flag */
if(lParam & LP_DO_NOT_CARE_BIT) if(lParam & LP_DO_NOT_CARE_BIT)
@ -1323,12 +1309,9 @@ NtUserGetKeyNameText(LONG lParam, LPWSTR lpString, int cchSize)
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
} }
RETURN(dwRet);
CLEANUP:
TRACE("Leave NtUserGetKeyNameText, ret=%i\n", _ret_);
UserLeave(); UserLeave();
END_CLEANUP; TRACE("Leave NtUserGetKeyNameText, ret=%i\n", dwRet);
return dwRet;
} }
/* /*