Author: rharabien
Date: Fri Oct 14 19:01:35 2011
New Revision: 54141
URL:
http://svn.reactos.org/svn/reactos?rev=54141&view=rev
Log:
[WIN32K]
- Get rid of RETURN macro in input functions
- Don't check functions parameters when USER lock is held
- Improve formatting
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/input.c
trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Fri Oct 14 19:01:35
2011
@@ -475,16 +475,16 @@
if (pti == ptiTo) return FALSE;
/* Do not attach to system threads or between different desktops. */
- if ( pti->TIF_flags & TIF_DONTATTACHQUEUE ||
+ if (pti->TIF_flags & TIF_DONTATTACHQUEUE ||
ptiTo->TIF_flags & TIF_DONTATTACHQUEUE ||
- pti->rpdesk != ptiTo->rpdesk )
+ pti->rpdesk != ptiTo->rpdesk)
return FALSE;
/* If Attach set, allocate and link. */
- if ( fAttach )
+ if (fAttach)
{
pai = ExAllocatePoolWithTag(PagedPool, sizeof(ATTACHINFO), USERTAG_ATTACHINFO);
- if ( !pai ) return FALSE;
+ if (!pai) return FALSE;
pai->paiNext = gpai;
pai->pti1 = pti;
@@ -495,19 +495,19 @@
{
PATTACHINFO paiprev = NULL;
- if ( !gpai ) return FALSE;
+ if (!gpai) return FALSE;
pai = gpai;
/* Search list and free if found or return false. */
do
{
- if ( pai->pti2 == ptiTo && pai->pti1 == pti ) break;
+ if (pai->pti2 == ptiTo && pai->pti1 == pti) break;
paiprev = pai;
pai = pai->paiNext;
} while (pai);
- if ( !pai ) return FALSE;
+ if (!pai) return FALSE;
if (paiprev) paiprev->paiNext = pai->paiNext;
@@ -525,8 +525,7 @@
INT cbSize)
{
PTHREADINFO pti;
- UINT cnt;
- DECLARE_RETURN(UINT);
+ UINT uRet = 0;
TRACE("Enter NtUserSendInput\n");
UserEnterExclusive();
@@ -536,13 +535,13 @@
if (!pti->rpdesk)
{
- RETURN( 0);
+ goto cleanup;
}
if (!nInputs || !pInput || cbSize != sizeof(INPUT))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
- RETURN( 0);
+ goto cleanup;
}
/*
@@ -553,10 +552,9 @@
!IntIsActiveDesktop(pti->rpdesk))
{
EngSetLastError(ERROR_ACCESS_DENIED);
- RETURN( 0);
- }
-
- cnt = 0;
+ goto cleanup;
+ }
+
while (nInputs--)
{
INPUT SafeInput;
@@ -566,18 +564,18 @@
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- RETURN( cnt);
+ goto cleanup;
}
switch (SafeInput.type)
{
case INPUT_MOUSE:
if (IntMouseInput(&SafeInput.mi, TRUE))
- cnt++;
+ uRet++;
break;
case INPUT_KEYBOARD:
if (UserSendKeyboardInput(&SafeInput.ki, TRUE))
- cnt++;
+ uRet++;
break;
case INPUT_HARDWARE:
FIXME("INPUT_HARDWARE not supported!");
@@ -588,12 +586,10 @@
}
}
- RETURN( cnt);
-
-CLEANUP:
- TRACE("Leave NtUserSendInput, ret=%i\n", _ret_);
+cleanup:
+ TRACE("Leave NtUserSendInput, ret=%i\n", uRet);
UserLeave();
- END_CLEANUP;
+ return uRet;
}
/* EOF */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c [iso-8859-1] Fri Oct 14 19:01:35
2011
@@ -298,17 +298,17 @@
RtlZeroMemory(lpEventTrack , sizeof(TRACKMOUSEEVENT));
lpEventTrack->cbSize = sizeof(TRACKMOUSEEVENT);
- if ( pDesk->dwDTFlags & (DF_TME_LEAVE | DF_TME_HOVER) &&
- pDesk->spwndTrack &&
- pti->MessageQueue == pDesk->spwndTrack->head.pti->MessageQueue )
- {
- if ( pDesk->htEx != HTCLIENT )
+ if (pDesk->dwDTFlags & (DF_TME_LEAVE | DF_TME_HOVER) &&
+ pDesk->spwndTrack &&
+ pti->MessageQueue == pDesk->spwndTrack->head.pti->MessageQueue)
+ {
+ if (pDesk->htEx != HTCLIENT)
lpEventTrack->dwFlags |= TME_NONCLIENT;
- if ( pDesk->dwDTFlags & DF_TME_LEAVE )
+ if (pDesk->dwDTFlags & DF_TME_LEAVE)
lpEventTrack->dwFlags |= TME_LEAVE;
- if ( pDesk->dwDTFlags & DF_TME_HOVER )
+ if (pDesk->dwDTFlags & DF_TME_HOVER)
{
lpEventTrack->dwFlags |= TME_HOVER;
lpEventTrack->dwHoverTime = pDesk->dwMouseHoverTime;
@@ -335,14 +335,14 @@
return FALSE;
/* Tracking spwndTrack same as pWnd */
- if ( lpEventTrack->dwFlags & TME_CANCEL ) // Canceled mode.
- {
- if ( lpEventTrack->dwFlags & TME_LEAVE )
+ if (lpEventTrack->dwFlags & TME_CANCEL) // Canceled mode.
+ {
+ if (lpEventTrack->dwFlags & TME_LEAVE)
pDesk->dwDTFlags &= ~DF_TME_LEAVE;
- if ( lpEventTrack->dwFlags & TME_HOVER )
- {
- if ( pDesk->dwDTFlags & DF_TME_HOVER )
+ if (lpEventTrack->dwFlags & TME_HOVER)
+ {
+ if (pDesk->dwDTFlags & DF_TME_HOVER)
{ // Kill hover timer.
IntKillTimer(pWnd, ID_EVENT_SYSTIMER_MOUSEHOVER, TRUE);
pDesk->dwDTFlags &= ~DF_TME_HOVER;
@@ -351,20 +351,20 @@
}
else // Not Canceled.
{
- pDesk->spwndTrack = pWnd;
- if ( lpEventTrack->dwFlags & TME_LEAVE )
+ pDesk->spwndTrack = pWnd;
+ if (lpEventTrack->dwFlags & TME_LEAVE)
pDesk->dwDTFlags |= DF_TME_LEAVE;
- if ( lpEventTrack->dwFlags & TME_HOVER )
+ if (lpEventTrack->dwFlags & TME_HOVER)
{
pDesk->dwDTFlags |= DF_TME_HOVER;
- if ( !lpEventTrack->dwHoverTime || lpEventTrack->dwHoverTime ==
HOVER_DEFAULT )
+ if (!lpEventTrack->dwHoverTime || lpEventTrack->dwHoverTime ==
HOVER_DEFAULT)
pDesk->dwMouseHoverTime = gspv.iMouseHoverTime; // use the system
default hover time-out.
else
pDesk->dwMouseHoverTime = lpEventTrack->dwHoverTime;
// Start timer for the hover period.
- IntSetTimer( pWnd, ID_EVENT_SYSTIMER_MOUSEHOVER, pDesk->dwMouseHoverTime,
SystemTimerProc, TMRF_SYSTEM);
+ IntSetTimer(pWnd, ID_EVENT_SYSTIMER_MOUSEHOVER, pDesk->dwMouseHoverTime,
SystemTimerProc, TMRF_SYSTEM);
// Get windows thread message points.
point = pWnd->head.pti->ptLast;
// Set desktop mouse hover from the system default hover rectangle.
@@ -383,60 +383,60 @@
NtUserTrackMouseEvent(
LPTRACKMOUSEEVENT lpEventTrack)
{
- TRACKMOUSEEVENT saveTME;
- BOOL Ret = FALSE;
+ TRACKMOUSEEVENT SafeTME;
+ BOOL bRet = FALSE;
TRACE("Enter NtUserTrackMouseEvent\n");
+
+ _SEH2_TRY
+ {
+ ProbeForRead(lpEventTrack, sizeof(TRACKMOUSEEVENT), 1);
+ RtlCopyMemory(&SafeTME, lpEventTrack, sizeof(TRACKMOUSEEVENT));
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ SetLastNtError(_SEH2_GetExceptionCode());
+ _SEH2_YIELD(return FALSE);
+ }
+ _SEH2_END;
+
+ if (SafeTME.cbSize != sizeof(TRACKMOUSEEVENT))
+ {
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (SafeTME.dwFlags & ~(TME_CANCEL | TME_QUERY | TME_NONCLIENT | TME_LEAVE |
TME_HOVER) )
+ {
+ EngSetLastError(ERROR_INVALID_FLAGS);
+ return FALSE;
+ }
+
UserEnterExclusive();
- _SEH2_TRY
- {
- ProbeForRead(lpEventTrack, sizeof(TRACKMOUSEEVENT), 1);
- RtlCopyMemory(&saveTME, lpEventTrack, sizeof(TRACKMOUSEEVENT));
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- SetLastNtError(_SEH2_GetExceptionCode());
- _SEH2_YIELD(goto Exit;)
- }
- _SEH2_END;
-
- if ( saveTME.cbSize != sizeof(TRACKMOUSEEVENT) )
- {
- EngSetLastError(ERROR_INVALID_PARAMETER);
- goto Exit;
- }
-
- if (saveTME.dwFlags & ~(TME_CANCEL | TME_QUERY | TME_NONCLIENT | TME_LEAVE |
TME_HOVER) )
- {
- EngSetLastError(ERROR_INVALID_FLAGS);
- goto Exit;
- }
-
- if ( saveTME.dwFlags & TME_QUERY )
- {
- Ret = IntQueryTrackMouseEvent(&saveTME);
+ if (SafeTME.dwFlags & TME_QUERY)
+ {
+ bRet = IntQueryTrackMouseEvent(&SafeTME);
_SEH2_TRY
{
ProbeForWrite(lpEventTrack, sizeof(TRACKMOUSEEVENT), 1);
- RtlCopyMemory(lpEventTrack, &saveTME, sizeof(TRACKMOUSEEVENT));
+ RtlCopyMemory(lpEventTrack, &SafeTME, sizeof(TRACKMOUSEEVENT));
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
- Ret = FALSE;
+ bRet = FALSE;
}
_SEH2_END;
}
else
{
- Ret = IntTrackMouseEvent(&saveTME);
- }
-
-Exit:
- TRACE("Leave NtUserTrackMouseEvent, ret=%i\n", Ret);
+ bRet = IntTrackMouseEvent(&SafeTME);
+ }
+
+ TRACE("Leave NtUserTrackMouseEvent, ret=%i\n", bRet);
UserLeave();
- return Ret;
+ return bRet;
}
extern MOUSEMOVEPOINT MouseHistoryOfMoves[];
@@ -453,66 +453,66 @@
{
MOUSEMOVEPOINT Safeppt;
//BOOL Hit;
- INT Count = -1;
- DECLARE_RETURN(DWORD);
+ INT iRet = -1;
TRACE("Enter NtUserGetMouseMovePointsEx\n");
- UserEnterExclusive();
if ((cbSize != sizeof(MOUSEMOVEPOINT)) || (nBufPoints < 0) || (nBufPoints >
64))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
- RETURN( -1);
+ return (DWORD)-1;
}
if (!lpptIn || (!lpptOut && nBufPoints))
{
EngSetLastError(ERROR_NOACCESS);
- RETURN( -1);
+ return (DWORD)-1;
}
_SEH2_TRY
{
- ProbeForRead( lpptIn, cbSize, 1);
+ ProbeForRead(lpptIn, cbSize, 1);
RtlCopyMemory(&Safeppt, lpptIn, cbSize);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
- _SEH2_YIELD(RETURN( -1))
+ _SEH2_YIELD(return (DWORD)-1);
}
_SEH2_END;
+
+ UserEnterShared();
//
http://msdn.microsoft.com/en-us/library/ms646259(v=vs.85).aspx
// This explains the math issues in transforming points.
- Count = gcur_count; // FIFO is forward so retrieve backward.
+ iRet = gcur_count; // FIFO is forward so retrieve backward.
//Hit = FALSE;
do
{
if (Safeppt.x == 0 && Safeppt.y == 0)
break; // No test.
// Finds the point, it returns the last nBufPoints prior to and including the
supplied point.
- if (MouseHistoryOfMoves[Count].x == Safeppt.x &&
MouseHistoryOfMoves[Count].y == Safeppt.y)
- {
- if ( Safeppt.time ) // Now test time and it seems to be absolute.
- {
- if (Safeppt.time == MouseHistoryOfMoves[Count].time)
+ if (MouseHistoryOfMoves[iRet].x == Safeppt.x &&
MouseHistoryOfMoves[iRet].y == Safeppt.y)
+ {
+ if (Safeppt.time) // Now test time and it seems to be absolute.
+ {
+ if (Safeppt.time == MouseHistoryOfMoves[iRet].time)
{
//Hit = TRUE;
break;
}
else
{
- if (--Count < 0) Count = 63;
+ if (--iRet < 0) iRet = 63;
continue;
}
}
//Hit = TRUE;
break;
}
- if (--Count < 0) Count = 63;
- }
- while ( Count != gcur_count);
+ if (--iRet < 0) iRet = 63;
+ }
+ while (iRet != gcur_count);
switch(resolution)
{
@@ -526,23 +526,22 @@
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
- _SEH2_YIELD(RETURN( -1))
+ iRet = -1;
+ _SEH2_YIELD(goto cleanup);
}
_SEH2_END;
}
- Count = nBufPoints;
+ iRet = nBufPoints;
break;
case GMMP_USE_HIGH_RESOLUTION_POINTS:
break;
default:
EngSetLastError(ERROR_POINT_NOT_FOUND);
- RETURN( -1);
- }
-
- RETURN( Count);
-
-CLEANUP:
- TRACE("Leave NtUserGetMouseMovePointsEx, ret=%i\n", _ret_);
+ iRet = -1;
+ }
+
+cleanup:
+ TRACE("Leave NtUserGetMouseMovePointsEx, ret=%i\n", iRet);
UserLeave();
- END_CLEANUP;
+ return (DWORD)iRet;
}