[NTUSER] Remove RETURN() macro (#6194)

Remove macro definition and the remaining uses.
RETURN() macro is just a wrapper for goto, most of the time it makes the code more complicated than using goto directly.
This commit is contained in:
Thamatip Chitpong 2023-12-21 11:10:46 +07:00 committed by GitHub
parent f5b0c66a05
commit 533d877aaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 357 additions and 413 deletions

View file

@ -316,20 +316,20 @@ NtUserCreateCaret(
PWND Window;
PTHREADINFO pti;
PUSER_MESSAGE_QUEUE ThreadQueue;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("Enter NtUserCreateCaret\n");
UserEnterExclusive();
if(!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
goto Exit; // Return FALSE
}
if(Window->head.pti->pEThread != PsGetCurrentThread())
{
EngSetLastError(ERROR_ACCESS_DENIED);
RETURN(FALSE);
goto Exit; // Return FALSE
}
pti = PsGetCurrentThreadWin32Thread();
@ -368,12 +368,12 @@ NtUserCreateCaret(
IntNotifyWinEvent(EVENT_OBJECT_CREATE, Window, OBJID_CARET, CHILDID_SELF, 0);
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserCreateCaret, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserCreateCaret, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
UINT
@ -399,7 +399,7 @@ NtUserGetCaretPos(
PTHREADINFO pti;
PUSER_MESSAGE_QUEUE ThreadQueue;
NTSTATUS Status;
DECLARE_RETURN(BOOL);
BOOL Ret = TRUE;
TRACE("Enter NtUserGetCaretPos\n");
UserEnterShared();
@ -411,15 +411,12 @@ NtUserGetCaretPos(
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
Ret = FALSE;
}
RETURN(TRUE);
CLEANUP:
TRACE("Leave NtUserGetCaretPos, ret=%i\n",_ret_);
TRACE("Leave NtUserGetCaretPos, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL
@ -428,15 +425,14 @@ NtUserShowCaret(HWND hWnd OPTIONAL)
{
PWND Window = NULL;
USER_REFERENCE_ENTRY Ref;
DECLARE_RETURN(BOOL);
BOOL ret;
BOOL ret = FALSE;
TRACE("Enter NtUserShowCaret\n");
UserEnterExclusive();
if(hWnd && !(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
goto Exit; // Return FALSE
}
if (Window) UserRefObjectCo(Window, &Ref);
@ -445,12 +441,10 @@ NtUserShowCaret(HWND hWnd OPTIONAL)
if (Window) UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP:
TRACE("Leave NtUserShowCaret, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserShowCaret, ret=%i\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}
BOOL
@ -459,15 +453,14 @@ NtUserHideCaret(HWND hWnd OPTIONAL)
{
PWND Window = NULL;
USER_REFERENCE_ENTRY Ref;
DECLARE_RETURN(BOOL);
BOOL ret;
BOOL ret = FALSE;
TRACE("Enter NtUserHideCaret\n");
UserEnterExclusive();
if(hWnd && !(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
goto Exit; // Return FALSE
}
if (Window) UserRefObjectCo(Window, &Ref);
@ -476,10 +469,8 @@ NtUserHideCaret(HWND hWnd OPTIONAL)
if (Window) UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP:
TRACE("Leave NtUserHideCaret, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserHideCaret, ret=%i\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}

View file

@ -650,7 +650,6 @@ NtUserGetCursorInfo(
NTSTATUS Status = STATUS_SUCCESS;
PCURICON_OBJECT CurIcon;
BOOL Ret = FALSE;
DECLARE_RETURN(BOOL);
TRACE("Enter NtUserGetCursorInfo\n");
UserEnterShared();
@ -687,12 +686,9 @@ NtUserGetCursorInfo(
SetLastNtError(Status);
}
RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserGetCursorInfo, ret=%i\n",_ret_);
TRACE("Leave NtUserGetCursorInfo, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL
@ -999,18 +995,18 @@ NtUserGetClipCursor(
PSYSTEM_CURSORINFO CurInfo;
RECTL Rect;
NTSTATUS Status;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("Enter NtUserGetClipCursor\n");
UserEnterShared();
if (!CheckWinstaAttributeAccess(WINSTA_READATTRIBUTES))
{
RETURN(FALSE);
goto Exit; // Return FALSE
}
if (!lpRect)
RETURN(FALSE);
goto Exit; // Return FALSE
CurInfo = IntGetSysCursorInfo();
if (CurInfo->bClipped)
@ -1029,15 +1025,15 @@ NtUserGetClipCursor(
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
goto Exit; // Return FALSE
}
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserGetClipCursor, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserGetClipCursor, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}

View file

@ -2535,8 +2535,7 @@ NtUserCreateDesktop(
{
NTSTATUS Status;
HDESK hDesk;
DECLARE_RETURN(HDESK);
HDESK Ret = NULL;
TRACE("Enter NtUserCreateDesktop\n");
UserEnterExclusive();
@ -2552,15 +2551,15 @@ NtUserCreateDesktop(
{
ERR("IntCreateDesktop failed, Status 0x%08lx\n", Status);
// SetLastNtError(Status);
RETURN(NULL);
goto Exit; // Return NULL
}
RETURN(hDesk);
Ret = hDesk;
CLEANUP:
TRACE("Leave NtUserCreateDesktop, ret=0x%p\n", _ret_);
Exit:
TRACE("Leave NtUserCreateDesktop, ret=0x%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -2724,7 +2723,7 @@ NtUserCloseDesktop(HDESK hDesktop)
{
PDESKTOP pdesk;
NTSTATUS Status;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("NtUserCloseDesktop(0x%p) called\n", hDesktop);
UserEnterExclusive();
@ -2733,14 +2732,14 @@ NtUserCloseDesktop(HDESK hDesktop)
{
ERR("Attempted to close thread desktop\n");
EngSetLastError(ERROR_BUSY);
RETURN(FALSE);
goto Exit; // Return FALSE
}
Status = IntValidateDesktopHandle(hDesktop, UserMode, 0, &pdesk);
if (!NT_SUCCESS(Status))
{
ERR("Validation of desktop handle 0x%p failed\n", hDesktop);
RETURN(FALSE);
goto Exit; // Return FALSE
}
ObDereferenceObject(pdesk);
@ -2750,15 +2749,15 @@ NtUserCloseDesktop(HDESK hDesktop)
{
ERR("Failed to close desktop handle 0x%p\n", hDesktop);
SetLastNtError(Status);
RETURN(FALSE);
goto Exit; // Return FALSE
}
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserCloseDesktop, ret=%i\n", _ret_);
Exit:
TRACE("Leave NtUserCloseDesktop, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -2939,7 +2938,7 @@ NtUserSwitchDesktop(HDESK hdesk)
PDESKTOP pdesk;
NTSTATUS Status;
BOOL bRedrawDesktop;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
UserEnterExclusive();
TRACE("Enter NtUserSwitchDesktop(0x%p)\n", hdesk);
@ -2948,21 +2947,22 @@ NtUserSwitchDesktop(HDESK hdesk)
if (!NT_SUCCESS(Status))
{
ERR("Validation of desktop handle 0x%p failed\n", hdesk);
RETURN(FALSE);
goto Exit; // Return FALSE
}
if (PsGetCurrentProcessSessionId() != pdesk->rpwinstaParent->dwSessionId)
{
ObDereferenceObject(pdesk);
ERR("NtUserSwitchDesktop called for a desktop of a different session\n");
RETURN(FALSE);
goto Exit; // Return FALSE
}
if (pdesk == gpdeskInputDesktop)
{
ObDereferenceObject(pdesk);
WARN("NtUserSwitchDesktop called for active desktop\n");
RETURN(TRUE);
Ret = TRUE;
goto Exit;
}
/*
@ -2974,14 +2974,14 @@ NtUserSwitchDesktop(HDESK hdesk)
{
ObDereferenceObject(pdesk);
ERR("Switching desktop 0x%p denied because the window station is locked!\n", hdesk);
RETURN(FALSE);
goto Exit; // Return FALSE
}
if (pdesk->rpwinstaParent != InputWindowStation)
{
ObDereferenceObject(pdesk);
ERR("Switching desktop 0x%p denied because desktop doesn't belong to the interactive winsta!\n", hdesk);
RETURN(FALSE);
goto Exit; // Return FALSE
}
/* FIXME: Fail if the process is associated with a secured
@ -3014,12 +3014,12 @@ NtUserSwitchDesktop(HDESK hdesk)
TRACE("SwitchDesktop gpdeskInputDesktop 0x%p\n", gpdeskInputDesktop);
ObDereferenceObject(pdesk);
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserSwitchDesktop, ret=%i\n", _ret_);
Exit:
TRACE("Leave NtUserSwitchDesktop, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*

View file

@ -1441,17 +1441,16 @@ IntGetCapture(VOID)
{
PTHREADINFO pti;
PUSER_MESSAGE_QUEUE ThreadQueue;
DECLARE_RETURN(HWND);
HWND Ret;
TRACE("Enter IntGetCapture\n");
pti = PsGetCurrentThreadWin32Thread();
ThreadQueue = pti->MessageQueue;
RETURN( ThreadQueue ? (ThreadQueue->spwndCapture ? UserHMGetHandle(ThreadQueue->spwndCapture) : 0) : 0);
Ret = ((ThreadQueue && ThreadQueue->spwndCapture) ? UserHMGetHandle(ThreadQueue->spwndCapture) : NULL);
CLEANUP:
TRACE("Leave IntGetCapture, ret=%p\n", _ret_);
END_CLEANUP;
TRACE("Leave IntGetCapture, ret=%p\n", Ret);
return Ret;
}
HWND FASTCALL
@ -1647,17 +1646,16 @@ IntAllowSetForegroundWindow(DWORD dwProcessId)
HWND APIENTRY
NtUserGetForegroundWindow(VOID)
{
DECLARE_RETURN(HWND);
HWND Ret;
TRACE("Enter NtUserGetForegroundWindow\n");
UserEnterExclusive();
RETURN( UserGetForegroundWindow());
Ret = UserGetForegroundWindow();
CLEANUP:
TRACE("Leave NtUserGetForegroundWindow, ret=%p\n",_ret_);
TRACE("Leave NtUserGetForegroundWindow, ret=%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
HWND APIENTRY
@ -1666,7 +1664,7 @@ NtUserSetActiveWindow(HWND hWnd)
USER_REFERENCE_ENTRY Ref;
HWND hWndPrev;
PWND Window, pwndPrev;
DECLARE_RETURN(HWND);
HWND Ret = NULL;
TRACE("Enter NtUserSetActiveWindow(%p)\n", hWnd);
UserEnterExclusive();
@ -1677,7 +1675,7 @@ NtUserSetActiveWindow(HWND hWnd)
if (!(Window = UserGetWindowObject(hWnd)))
{
ERR("NtUserSetActiveWindow: Invalid handle 0x%p!\n",hWnd);
RETURN( NULL);
goto Exit; // Return NULL
}
}
@ -1689,14 +1687,13 @@ NtUserSetActiveWindow(HWND hWnd)
if (Window) UserRefObjectCo(Window, &Ref);
UserSetActiveWindow(Window);
if (Window) UserDerefObjectCo(Window);
RETURN(hWndPrev ? (IntIsWindow(hWndPrev) ? hWndPrev : NULL) : NULL);
Ret = ((hWndPrev && IntIsWindow(hWndPrev)) ? hWndPrev : NULL);
}
RETURN( NULL);
CLEANUP:
TRACE("Leave NtUserSetActiveWindow, ret=%p\n",_ret_);
Exit:
TRACE("Leave NtUserSetActiveWindow, ret=%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -1705,17 +1702,16 @@ CLEANUP:
HWND APIENTRY
NtUserSetCapture(HWND hWnd)
{
DECLARE_RETURN(HWND);
HWND Ret;
TRACE("Enter NtUserSetCapture(%p)\n", hWnd);
UserEnterExclusive();
RETURN( co_UserSetCapture(hWnd));
Ret = co_UserSetCapture(hWnd);
CLEANUP:
TRACE("Leave NtUserSetCapture, ret=%p\n", _ret_);
TRACE("Leave NtUserSetCapture, ret=%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -1726,8 +1722,7 @@ NtUserSetFocus(HWND hWnd)
{
PWND Window;
USER_REFERENCE_ENTRY Ref;
DECLARE_RETURN(HWND);
HWND ret;
HWND ret = NULL;
TRACE("Enter NtUserSetFocus(%p)\n", hWnd);
UserEnterExclusive();
@ -1737,24 +1732,22 @@ NtUserSetFocus(HWND hWnd)
if (!(Window = UserGetWindowObject(hWnd)))
{
ERR("NtUserSetFocus: Invalid handle 0x%p!\n",hWnd);
RETURN(NULL);
goto Exit; // Return NULL
}
UserRefObjectCo(Window, &Ref);
ret = co_UserSetFocus(Window);
UserDerefObjectCo(Window);
RETURN(ret);
}
else
{
RETURN( co_UserSetFocus(0));
ret = co_UserSetFocus(NULL);
}
CLEANUP:
TRACE("Leave NtUserSetFocus, ret=%p\n",_ret_);
Exit:
TRACE("Leave NtUserSetFocus, ret=%p\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}
/* EOF */

View file

@ -1376,7 +1376,6 @@ NtUserCallNextHookEx( int Code,
PHOOK HookObj, NextObj;
PCLIENTINFO ClientInfo;
LRESULT lResult = 0;
DECLARE_RETURN(LRESULT);
TRACE("Enter NtUserCallNextHookEx\n");
UserEnterExclusive();
@ -1385,7 +1384,8 @@ NtUserCallNextHookEx( int Code,
HookObj = pti->sphkCurrent;
if (!HookObj) RETURN( 0);
if (!HookObj)
goto Exit; // Return 0
NextObj = HookObj->phkNext;
@ -1407,12 +1407,11 @@ NtUserCallNextHookEx( int Code,
NextObj->phkNext = IntGetNextHook(NextObj);
lResult = co_UserCallNextHookEx( NextObj, Code, wParam, lParam, NextObj->Ansi);
}
RETURN( lResult);
CLEANUP:
TRACE("Leave NtUserCallNextHookEx, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserCallNextHookEx, ret=%i\n", lResult);
UserLeave();
END_CLEANUP;
return lResult;
}
HHOOK
@ -1450,7 +1449,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
NTSTATUS Status;
HHOOK Handle;
PTHREADINFO pti, ptiHook = NULL;
DECLARE_RETURN(HHOOK);
HHOOK Ret = NULL;
TRACE("Enter NtUserSetWindowsHookEx\n");
UserEnterExclusive();
@ -1460,13 +1459,13 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
if (HookId < WH_MINHOOK || WH_MAXHOOK < HookId )
{
EngSetLastError(ERROR_INVALID_HOOK_FILTER);
RETURN( NULL);
goto Cleanup; // Return NULL
}
if (!HookProc)
{
EngSetLastError(ERROR_INVALID_FILTER_PROC);
RETURN( NULL);
goto Cleanup; // Return NULL
}
if (ThreadId) /* thread-local hook */
@ -1480,21 +1479,21 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
TRACE("Local hook installing Global HookId: %d\n",HookId);
/* these can only be global */
EngSetLastError(ERROR_GLOBAL_ONLY_HOOK);
RETURN( NULL);
goto Cleanup; // Return NULL
}
if ( !(ptiHook = IntTID2PTI( UlongToHandle(ThreadId) )))
{
ERR("Invalid thread id 0x%x\n", ThreadId);
EngSetLastError(ERROR_INVALID_PARAMETER);
RETURN( NULL);
goto Cleanup; // Return NULL
}
if ( ptiHook->rpdesk != pti->rpdesk) // gptiCurrent->rpdesk)
{
ERR("Local hook wrong desktop HookId: %d\n",HookId);
EngSetLastError(ERROR_ACCESS_DENIED);
RETURN( NULL);
goto Cleanup; // Return NULL
}
if (ptiHook->ppi != pti->ppi)
@ -1511,7 +1510,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
{
ERR("Local hook needs hMod HookId: %d\n",HookId);
EngSetLastError(ERROR_HOOK_NEEDS_HMOD);
RETURN( NULL);
goto Cleanup; // Return NULL
}
if ( (ptiHook->TIF_flags & (TIF_CSRSSTHREAD|TIF_SYSTEMTHREAD)) &&
@ -1525,7 +1524,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
HookId == WH_CALLWNDPROCRET) )
{
EngSetLastError(ERROR_HOOK_TYPE_NOT_ALLOWED);
RETURN( NULL);
goto Cleanup; // Return NULL
}
}
}
@ -1545,7 +1544,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
{
ERR("Global hook needs hMod HookId: %d\n",HookId);
EngSetLastError(ERROR_HOOK_NEEDS_HMOD);
RETURN( NULL);
goto Cleanup; // Return NULL
}
}
@ -1558,7 +1557,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( NULL);
goto Cleanup; // Return NULL
}
ObDereferenceObject(WinStaObj);
@ -1566,7 +1565,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
if (!Hook)
{
RETURN( NULL);
goto Cleanup; // Return NULL
}
Hook->ihmod = (INT_PTR)Mod; // Module Index from atom table, Do this for now.
@ -1640,7 +1639,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
{
IntRemoveHook(Hook);
SetLastNtError(Status);
RETURN( NULL);
goto Cleanup; // Return NULL
}
Hook->ModuleName.Buffer = ExAllocatePoolWithTag( PagedPool,
@ -1650,7 +1649,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
{
IntRemoveHook(Hook);
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
RETURN( NULL);
goto Cleanup; // Return NULL
}
Hook->ModuleName.MaximumLength = ModuleName.MaximumLength;
@ -1663,7 +1662,7 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
Hook->ModuleName.Buffer = NULL;
IntRemoveHook(Hook);
SetLastNtError(Status);
RETURN( NULL);
goto Cleanup; // Return NULL
}
Hook->ModuleName.Length = ModuleName.Length;
@ -1677,14 +1676,14 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
Hook->offPfn = 0;
TRACE("Installing: HookId %d Global %s\n", HookId, !ThreadId ? "TRUE" : "FALSE");
RETURN( Handle);
Ret = Handle;
CLEANUP:
Cleanup:
if (Hook)
UserDereferenceObject(Hook);
TRACE("Leave NtUserSetWindowsHookEx, ret=%p\n", _ret_);
TRACE("Leave NtUserSetWindowsHookEx, ret=%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL
@ -1692,7 +1691,7 @@ APIENTRY
NtUserUnhookWindowsHookEx(HHOOK Hook)
{
PHOOK HookObj;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("Enter NtUserUnhookWindowsHookEx\n");
UserEnterExclusive();
@ -1701,7 +1700,7 @@ NtUserUnhookWindowsHookEx(HHOOK Hook)
{
ERR("Invalid handle passed to NtUserUnhookWindowsHookEx\n");
/* SetLastNtError(Status); */
RETURN( FALSE);
goto Exit; // Return FALSE
}
ASSERT(Hook == UserHMGetHandle(HookObj));
@ -1710,12 +1709,12 @@ NtUserUnhookWindowsHookEx(HHOOK Hook)
UserDereferenceObject(HookObj);
RETURN( TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserUnhookWindowsHookEx, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserUnhookWindowsHookEx, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL

View file

@ -1466,20 +1466,20 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
ULONG_PTR *uResult )
{
NTSTATUS Status = STATUS_SUCCESS;
PWND Window = NULL;
PWND Window;
PMSGMEMORY MsgMemoryEntry;
INT lParamBufferSize;
LPARAM lParamPacked;
PTHREADINFO Win32Thread, ptiSendTo = NULL;
ULONG_PTR Result = 0;
DECLARE_RETURN(LRESULT);
LRESULT Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
BOOL DoCallBack = TRUE;
if (!(Window = UserGetWindowObject(hWnd)))
{
TRACE("SendMessageTimeoutSingle: Invalid handle 0x%p!\n",hWnd);
RETURN( FALSE);
return FALSE;
}
UserRefObjectCo(Window, &Ref);
@ -1493,7 +1493,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (!IntDdeSendMessageHook(Window, Msg, wParam, lParam))
{
ERR("Sending Exit DDE 0x%x\n",Msg);
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
}
@ -1502,7 +1502,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (Win32Thread->TIF_flags & TIF_INCLEANUP)
{
/* Never send messages to exiting threads */
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
if (Msg & 0x80000000)
@ -1510,7 +1510,8 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
TRACE("SMTS: Internal Message!\n");
Result = (ULONG_PTR)handle_internal_message( Window, Msg, wParam, lParam );
if (uResult) *uResult = Result;
RETURN( TRUE);
Ret = TRUE;
goto Cleanup;
}
// Only happens when calling the client!
@ -1523,7 +1524,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (IoGetRemainingStackSize() < PAGE_SIZE)
{
ERR("Server Callback Exceeded Stack!\n");
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
/* Return after server side call, IntCallWndProcRet will not be called. */
switch(Window->fnid)
@ -1541,7 +1542,8 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (!DoCallBack)
{
if (uResult) *uResult = Result;
RETURN( TRUE);
Ret = TRUE;
goto Cleanup;
}
}
/* See if this message type is present in the table */
@ -1560,7 +1562,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, FALSE)))
{
ERR("Failed to pack message parameters\n");
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
Result = (ULONG_PTR)co_IntCallWindowProc( Window->lpfnWndProc,
@ -1578,20 +1580,22 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE)))
{
ERR("Failed to unpack message parameters\n");
RETURN( TRUE);
Ret = TRUE;
goto Cleanup;
}
// Only happens when calling the client!
IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, (LRESULT *)uResult);
RETURN( TRUE);
Ret = TRUE;
goto Cleanup;
}
if (Window->state & WNDS_DESTROYED)
{
/* FIXME: Last error? */
ERR("Attempted to send message to window %p that is being destroyed!\n", hWnd);
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
if ((uFlags & SMTO_ABORTIFHUNG) && MsqIsHung(ptiSendTo, 4 * MSQ_HUNG))
@ -1599,7 +1603,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
// FIXME: Set window hung and add to a list.
/* FIXME: Set a LastError? */
ERR("Window %p (%p) (pti %p) is hung!\n", hWnd, Window, ptiSendTo);
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
do
@ -1634,19 +1638,19 @@ co_IntSendMessageTimeoutSingle( HWND hWnd,
* returns ERROR_TIMEOUT, then the function timed out.
*/
EngSetLastError(ERROR_TIMEOUT);
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
else if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
goto Cleanup; // Return FALSE
}
RETURN( TRUE);
Ret = TRUE;
CLEANUP:
if (Window) UserDerefObjectCo(Window);
END_CLEANUP;
Cleanup:
UserDerefObjectCo(Window);
return Ret;
}
LRESULT FASTCALL
@ -1737,12 +1741,12 @@ co_IntSendMessageWithCallBack(HWND hWnd,
ULONG_PTR *uResult)
{
ULONG_PTR Result;
PWND Window = NULL;
PWND Window;
PMSGMEMORY MsgMemoryEntry;
INT lParamBufferSize;
LPARAM lParamPacked;
PTHREADINFO Win32Thread, ptiSendTo = NULL;
DECLARE_RETURN(LRESULT);
LRESULT Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
PUSER_SENT_MESSAGE Message;
BOOL DoCallBack = TRUE;
@ -1750,7 +1754,7 @@ co_IntSendMessageWithCallBack(HWND hWnd,
if (!(Window = UserGetWindowObject(hWnd)))
{
TRACE("SendMessageWithCallBack: Invalid handle 0x%p\n",hWnd);
RETURN(FALSE);
return FALSE;
}
UserRefObjectCo(Window, &Ref);
@ -1759,25 +1763,27 @@ co_IntSendMessageWithCallBack(HWND hWnd,
{
/* FIXME: last error? */
ERR("Attempted to send message to window %p that is being destroyed\n", hWnd);
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
Win32Thread = PsGetCurrentThreadWin32Thread();
if (Win32Thread == NULL || Win32Thread->TIF_flags & TIF_INCLEANUP)
RETURN(FALSE);
goto Cleanup; // Return FALSE
ptiSendTo = IntSendTo(Window, Win32Thread, Msg);
if (Msg & 0x80000000 &&
!ptiSendTo)
{
if (Win32Thread->TIF_flags & TIF_INCLEANUP) RETURN(FALSE);
if (Win32Thread->TIF_flags & TIF_INCLEANUP)
goto Cleanup; // Return FALSE
TRACE("SMWCB: Internal Message\n");
Result = (ULONG_PTR)handle_internal_message(Window, Msg, wParam, lParam);
if (uResult) *uResult = Result;
RETURN(TRUE);
Ret = TRUE;
goto Cleanup;
}
/* See if this message type is present in the table */
@ -1795,7 +1801,7 @@ co_IntSendMessageWithCallBack(HWND hWnd,
if (!NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam, !!ptiSendTo)))
{
ERR("Failed to pack message parameters\n");
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
/* If it can be sent now, then send it. */
@ -1805,7 +1811,7 @@ co_IntSendMessageWithCallBack(HWND hWnd,
{
UnpackParam(lParamPacked, Msg, wParam, lParam, FALSE);
/* Never send messages to exiting threads */
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
IntCallWndProc(Window, hWnd, Msg, wParam, lParam);
@ -1858,13 +1864,14 @@ co_IntSendMessageWithCallBack(HWND hWnd,
{
ERR("Failed to unpack message parameters\n");
}
RETURN(TRUE);
Ret = TRUE;
goto Cleanup;
}
if(!(Message = AllocateUserMessage(FALSE)))
{
ERR("Failed to allocate message\n");
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
Message->Msg.hwnd = hWnd;
@ -1890,11 +1897,11 @@ co_IntSendMessageWithCallBack(HWND hWnd,
InsertTailList(&ptiSendTo->SentMessagesListHead, &Message->ListEntry);
MsqWakeQueue(ptiSendTo, QS_SENDMESSAGE, TRUE);
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
if (Window) UserDerefObjectCo(Window);
END_CLEANUP;
Cleanup:
UserDerefObjectCo(Window);
return Ret;
}
#if 0
@ -2156,7 +2163,7 @@ NtUserDragDetect(
MSG msg;
RECT rect;
ULONG wDragWidth, wDragHeight;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("Enter NtUserDragDetect(%p)\n", hWnd);
UserEnterExclusive();
@ -2181,7 +2188,7 @@ NtUserDragDetect(
if ( msg.message == WM_LBUTTONUP )
{
co_UserSetCapture(NULL);
RETURN( FALSE);
goto Exit; // Return FALSE
}
if ( msg.message == WM_MOUSEMOVE )
{
@ -2191,7 +2198,8 @@ NtUserDragDetect(
if( !RECTL_bPointInRect( &rect, tmp.x, tmp.y ) )
{
co_UserSetCapture(NULL);
RETURN( TRUE);
Ret = TRUE;
goto Exit;
}
}
if ( msg.message == WM_KEYDOWN )
@ -2199,7 +2207,8 @@ NtUserDragDetect(
if ( msg.wParam == VK_ESCAPE )
{
co_UserSetCapture(NULL);
RETURN( TRUE);
Ret = TRUE;
goto Exit;
}
}
if ( msg.message == WM_QUEUESYNC )
@ -2209,12 +2218,11 @@ NtUserDragDetect(
}
co_IntWaitMessage(NULL, 0, 0);
}
RETURN( FALSE);
CLEANUP:
TRACE("Leave NtUserDragDetect, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserDragDetect, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL APIENTRY

View file

@ -410,8 +410,7 @@ NtUserGetGUIThreadInfo(
PDESKTOP Desktop;
PUSER_MESSAGE_QUEUE MsgQueue;
PTHREADINFO W32Thread, pti;
DECLARE_RETURN(BOOLEAN);
BOOL Ret = FALSE;
TRACE("Enter NtUserGetGUIThreadInfo\n");
UserEnterShared();
@ -420,13 +419,13 @@ NtUserGetGUIThreadInfo(
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
goto Exit; // Return FALSE
}
if(SafeGui.cbSize != sizeof(GUITHREADINFO))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
RETURN( FALSE);
goto Exit; // Return FALSE
}
if (idThread)
@ -439,7 +438,7 @@ NtUserGetGUIThreadInfo(
if ( !W32Thread )
{
EngSetLastError(ERROR_ACCESS_DENIED);
RETURN( FALSE);
goto Exit; // Return FALSE
}
Desktop = W32Thread->rpdesk;
@ -448,7 +447,7 @@ NtUserGetGUIThreadInfo(
if ( !Desktop || Desktop != pti->rpdesk )
{
EngSetLastError(ERROR_ACCESS_DENIED);
RETURN( FALSE);
goto Exit; // Return FALSE
}
if ( W32Thread->MessageQueue )
@ -465,7 +464,7 @@ NtUserGetGUIThreadInfo(
if(!MsgQueue)
{
EngSetLastError(ERROR_ACCESS_DENIED);
RETURN( FALSE);
goto Exit; // Return FALSE
}
}
@ -518,15 +517,15 @@ NtUserGetGUIThreadInfo(
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
goto Exit; // Return FALSE
}
RETURN( TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserGetGUIThreadInfo, ret=%u\n",_ret_);
Exit:
TRACE("Leave NtUserGetGUIThreadInfo, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
@ -540,7 +539,6 @@ NtUserGetGuiResources(
PPROCESSINFO W32Process;
NTSTATUS Status;
DWORD Ret = 0;
DECLARE_RETURN(DWORD);
TRACE("Enter NtUserGetGuiResources\n");
UserEnterShared();
@ -555,7 +553,7 @@ NtUserGetGuiResources(
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( 0);
goto Exit; // Return 0
}
W32Process = (PPROCESSINFO)Process->Win32Process;
@ -563,7 +561,7 @@ NtUserGetGuiResources(
{
ObDereferenceObject(Process);
EngSetLastError(ERROR_INVALID_PARAMETER);
RETURN( 0);
goto Exit; // Return 0
}
switch(uiFlags)
@ -587,12 +585,10 @@ NtUserGetGuiResources(
ObDereferenceObject(Process);
RETURN( Ret);
CLEANUP:
TRACE("Leave NtUserGetGuiResources, ret=%lu\n",_ret_);
Exit:
TRACE("Leave NtUserGetGuiResources, ret=%lu\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
VOID FASTCALL

View file

@ -1,10 +1,5 @@
#pragma once
#define DECLARE_RETURN(type) type _ret_
#define RETURN(value) { _ret_ = value; goto _cleanup_; }
#define CLEANUP /*unreachable*/ ASSERT(FALSE); _cleanup_
#define END_CLEANUP return _ret_;
#define UserEnterCo UserEnterExclusive
#define UserLeaveCo UserLeave

View file

@ -795,14 +795,14 @@ NtUserValidateHandleSecure(
UINT uType;
PPROCESSINFO ppi;
PUSER_HANDLE_ENTRY entry;
BOOL Ret = FALSE;
DECLARE_RETURN(BOOL);
UserEnterExclusive();
if (!(entry = handle_to_entry(gHandleTable, handle )))
{
EngSetLastError(ERROR_INVALID_HANDLE);
RETURN( FALSE);
goto Exit; // Return FALSE
}
uType = entry->type;
switch (uType)
@ -824,16 +824,15 @@ NtUserValidateHandleSecure(
break;
}
if (!ppi) RETURN( FALSE);
if (!ppi)
goto Exit; // Return FALSE
// Same process job returns TRUE.
if (gptiCurrent->ppi->pW32Job == ppi->pW32Job) RETURN( TRUE);
if (gptiCurrent->ppi->pW32Job == ppi->pW32Job) Ret = TRUE;
RETURN( FALSE);
CLEANUP:
Exit:
UserLeave();
END_CLEANUP;
return Ret;
}
// Win: HMAssignmentLock

View file

@ -1607,19 +1607,19 @@ IntFillWindow(PWND pWndParent,
HDC APIENTRY
NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
{
PWND Window = NULL;
PWND Window;
PAINTSTRUCT Ps;
NTSTATUS Status;
HDC hDC;
USER_REFERENCE_ENTRY Ref;
DECLARE_RETURN(HDC);
HDC Ret = NULL;
TRACE("Enter NtUserBeginPaint\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( NULL);
goto Cleanup; // Return NULL
}
UserRefObjectCo(Window, &Ref);
@ -1630,18 +1630,17 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
if (! NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(NULL);
goto Cleanup; // Return NULL
}
RETURN(hDC);
Ret = hDC;
CLEANUP:
Cleanup:
if (Window) UserDerefObjectCo(Window);
TRACE("Leave NtUserBeginPaint, ret=%p\n",_ret_);
TRACE("Leave NtUserBeginPaint, ret=%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -1655,17 +1654,17 @@ BOOL APIENTRY
NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* pUnsafePs)
{
NTSTATUS Status = STATUS_SUCCESS;
PWND Window = NULL;
PWND Window;
PAINTSTRUCT Ps;
USER_REFERENCE_ENTRY Ref;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("Enter NtUserEndPaint\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
UserRefObjectCo(Window, &Ref); // Here for the exception.
@ -1682,17 +1681,17 @@ NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* pUnsafePs)
_SEH2_END
if (!NT_SUCCESS(Status))
{
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
RETURN(IntEndPaint(Window, &Ps));
Ret = IntEndPaint(Window, &Ps);
CLEANUP:
Cleanup:
if (Window) UserDerefObjectCo(Window);
TRACE("Leave NtUserEndPaint, ret=%i\n",_ret_);
TRACE("Leave NtUserEndPaint, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -1928,26 +1927,21 @@ co_UserGetUpdateRect(PWND Window, PRECT pRect, BOOL bErase)
INT APIENTRY
NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase)
{
DECLARE_RETURN(INT);
PWND Window;
INT ret;
INT ret = ERROR;
TRACE("Enter NtUserGetUpdateRgn\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
Window = UserGetWindowObject(hWnd);
if (Window)
{
RETURN(ERROR);
ret = co_UserGetUpdateRgn(Window, hRgn, bErase);
}
ret = co_UserGetUpdateRgn(Window, hRgn, bErase);
RETURN(ret);
CLEANUP:
TRACE("Leave NtUserGetUpdateRgn, ret=%i\n",_ret_);
TRACE("Leave NtUserGetUpdateRgn, ret=%i\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}
/*
@ -1963,15 +1957,14 @@ NtUserGetUpdateRect(HWND hWnd, LPRECT UnsafeRect, BOOL bErase)
PWND Window;
RECTL Rect;
NTSTATUS Status;
BOOL Ret;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("Enter NtUserGetUpdateRect\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
goto Exit; // Return FALSE
}
Ret = co_UserGetUpdateRect(Window, &Rect, bErase);
@ -1982,16 +1975,14 @@ NtUserGetUpdateRect(HWND hWnd, LPRECT UnsafeRect, BOOL bErase)
if (!NT_SUCCESS(Status))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
RETURN(FALSE);
Ret = FALSE;
}
}
RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserGetUpdateRect, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserGetUpdateRect, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -2010,18 +2001,17 @@ NtUserRedrawWindow(
{
RECTL SafeUpdateRect;
PWND Wnd;
BOOL Ret;
BOOL Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
NTSTATUS Status = STATUS_SUCCESS;
PREGION RgnUpdate = NULL;
DECLARE_RETURN(BOOL);
TRACE("Enter NtUserRedrawWindow\n");
UserEnterExclusive();
if (!(Wnd = UserGetWindowObject(hWnd ? hWnd : IntGetDesktopWindow())))
{
RETURN( FALSE);
goto Exit; // Return FALSE
}
if (lprcUpdate)
@ -2039,7 +2029,7 @@ NtUserRedrawWindow(
if (!NT_SUCCESS(Status))
{
EngSetLastError(RtlNtStatusToDosError(Status));
RETURN( FALSE);
goto Exit; // Return FALSE
}
}
@ -2049,7 +2039,7 @@ NtUserRedrawWindow(
{
/* RedrawWindow fails only in case that flags are invalid */
EngSetLastError(ERROR_INVALID_FLAGS);
RETURN( FALSE);
goto Exit; // Return FALSE
}
/* We can't hold lock on GDI objects while doing roundtrips to user mode,
@ -2061,7 +2051,7 @@ NtUserRedrawWindow(
if (!RgnUpdate)
{
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
RETURN(FALSE);
goto Exit; // Return FALSE
}
REGION_UnlockRgn(RgnUpdate);
}
@ -2079,12 +2069,10 @@ NtUserRedrawWindow(
UserDerefObjectCo(Wnd);
RETURN( Ret);
CLEANUP:
TRACE("Leave NtUserRedrawWindow, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserRedrawWindow, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL

View file

@ -1144,8 +1144,7 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
NTSTATUS Status;
SCROLLBARINFO sbi;
PWND Window;
BOOL Ret;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserGetScrollBarInfo\n");
@ -1155,11 +1154,11 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO)))
{
SetLastNtError(Status);
RETURN(FALSE);
goto Exit; // Return FALSE
}
if(!(Window = UserGetWindowObject(hWnd)))
RETURN(FALSE);
goto Exit; // Return FALSE
UserRefObjectCo(Window, &Ref);
Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi);
@ -1172,12 +1171,10 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
Ret = FALSE;
}
RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL
@ -1190,9 +1187,8 @@ NtUserSBGetParms(
{
PWND Window;
SCROLLINFO psi;
BOOL Ret;
BOOL Ret = FALSE;
SBDATA SBDataSafe;
DECLARE_RETURN(BOOL);
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserGetScrollInfo\n");
@ -1208,14 +1204,14 @@ NtUserSBGetParms(
{
ERR("NtUserGetScrollInfo Failed size\n");
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN(FALSE));
_SEH2_YIELD(goto Exit); // Return FALSE
}
_SEH2_END
if(!(Window = UserGetWindowObject(hWnd)))
{
ERR("NtUserGetScrollInfo Bad window\n");
RETURN(FALSE);
goto Exit; // Return FALSE
}
UserRefObjectCo(Window, &Ref);
@ -1230,16 +1226,15 @@ NtUserSBGetParms(
{
ERR("NtUserGetScrollInfo Failed copy to user\n");
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN(FALSE));
Ret = FALSE;
_SEH2_YIELD(goto Exit);
}
_SEH2_END
RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserGetScrollInfo, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserGetScrollInfo, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
BOOL
@ -1253,19 +1248,19 @@ NtUserEnableScrollBar(
PWND Window = NULL;
PSCROLLBARINFO InfoV = NULL, InfoH = NULL;
BOOL Chg = FALSE;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserEnableScrollBar\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)) || UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
RETURN(FALSE);
goto Cleanup; // Return FALSE
UserRefObjectCo(Window, &Ref);
if (!co_IntCreateScrollBars(Window))
RETURN(FALSE);
goto Cleanup; // Return FALSE
OrigArrows = Window->pSBInfo->WSBflags;
Window->pSBInfo->WSBflags = wArrows;
@ -1275,14 +1270,15 @@ NtUserEnableScrollBar(
if ((wArrows == ESB_DISABLE_BOTH || wArrows == ESB_ENABLE_BOTH))
IntEnableWindow(hWnd, (wArrows == ESB_ENABLE_BOTH));
RETURN(TRUE);
Ret = TRUE;
goto Cleanup;
}
if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags))
{
EngSetLastError(ERROR_INVALID_PARAMETER);
ERR("Trying to set scrollinfo for unknown scrollbar type %u\n", wSBflags);
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
switch(wSBflags)
@ -1297,7 +1293,7 @@ NtUserEnableScrollBar(
InfoV = IntGetScrollbarInfoFromWindow(Window, SB_VERT);
break;
default:
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
if(InfoV)
@ -1310,17 +1306,24 @@ NtUserEnableScrollBar(
// Done in user32:
// SCROLL_RefreshScrollBar(hwnd, nBar, TRUE, TRUE);
RETURN(Chg);
if (OrigArrows == wArrows) RETURN(FALSE);
RETURN(TRUE);
Ret = Chg;
goto Cleanup; // FIXME
CLEANUP:
if (OrigArrows == wArrows)
{
Ret = FALSE;
goto Cleanup;
}
Ret = TRUE;
Cleanup:
if (Window)
UserDerefObjectCo(Window);
TRACE("Leave NtUserEnableScrollBar, ret=%i\n",_ret_);
TRACE("Leave NtUserEnableScrollBar, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
DWORD
@ -1334,14 +1337,14 @@ NtUserSetScrollInfo(
PWND Window = NULL;
NTSTATUS Status;
SCROLLINFO ScrollInfo;
DECLARE_RETURN(DWORD);
DWORD Ret = 0;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserSetScrollInfo\n");
UserEnterExclusive();
if(!(Window = UserGetWindowObject(hWnd)) || UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
RETURN(0);
goto Cleanup; // Return 0
UserRefObjectCo(Window, &Ref);
@ -1349,45 +1352,42 @@ NtUserSetScrollInfo(
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(0);
goto Cleanup; // Return 0
}
RETURN(co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw));
Ret = co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw);
CLEANUP:
Cleanup:
if (Window)
UserDerefObjectCo(Window);
TRACE("Leave NtUserSetScrollInfo, ret=%lu\n", _ret_);
TRACE("Leave NtUserSetScrollInfo, ret=%lu\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
DWORD APIENTRY
NtUserShowScrollBar(HWND hWnd, int nBar, DWORD bShow)
{
PWND Window;
DECLARE_RETURN(DWORD);
DWORD ret;
DWORD ret = 0;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserShowScrollBar\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
RETURN(0);
Window = UserGetWindowObject(hWnd);
if (Window)
{
UserRefObjectCo(Window, &Ref);
ret = co_UserShowScrollBar(Window, nBar, (nBar == SB_VERT) ? 0 : bShow,
(nBar == SB_HORZ) ? 0 : bShow);
UserDerefObjectCo(Window);
}
UserRefObjectCo(Window, &Ref);
ret = co_UserShowScrollBar(Window, nBar, (nBar == SB_VERT) ? 0 : bShow,
(nBar == SB_HORZ) ? 0 : bShow);
UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP:
TRACE("Leave NtUserShowScrollBar, ret%lu\n", _ret_);
TRACE("Leave NtUserShowScrollBar, ret=%lu\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}
// Ugly NtUser API
@ -1405,14 +1405,14 @@ NtUserSetScrollBarInfo(
LPSCROLLINFO psi;
NTSTATUS Status;
LONG Obj;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserSetScrollBarInfo\n");
UserEnterExclusive();
if(!(Window = UserGetWindowObject(hWnd)))
RETURN(FALSE);
goto Cleanup; // Return FALSE
UserRefObjectCo(Window, &Ref);
@ -1421,17 +1421,17 @@ NtUserSetScrollBarInfo(
{
EngSetLastError(ERROR_INVALID_PARAMETER);
ERR("Trying to set scrollinfo for unknown scrollbar type %d\n", Obj);
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
if(!co_IntCreateScrollBars(Window))
RETURN(FALSE);
goto Cleanup; // Return FALSE
Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
goto Cleanup; // Return FALSE
}
sbi = IntGetScrollbarInfoFromWindow(Window, Obj);
@ -1441,15 +1441,15 @@ NtUserSetScrollBarInfo(
sbi->reserved = Safeinfo.reserved;
RtlCopyMemory(&sbi->rgstate, &Safeinfo.rgstate, sizeof(Safeinfo.rgstate));
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
Cleanup:
if (Window)
UserDerefObjectCo(Window);
TRACE("Leave NtUserSetScrollBarInfo, ret=%i\n",_ret_);
TRACE("Leave NtUserSetScrollBarInfo, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/* EOF */

View file

@ -481,7 +481,7 @@ NtUserScrollDC(
HRGN hrgnUpdate,
LPRECT prcUnsafeUpdate)
{
DECLARE_RETURN(DWORD);
BOOL Ret = FALSE;
DWORD Result;
NTSTATUS Status = STATUS_SUCCESS;
RECTL rcScroll, rcClip, rcUpdate;
@ -515,7 +515,7 @@ NtUserScrollDC(
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
goto Exit; // Return FALSE
}
Result = UserScrollDC( hDC,
@ -529,7 +529,7 @@ NtUserScrollDC(
if(Result == ERROR)
{
/* FIXME: Only if hRgnUpdate is invalid we should SetLastError(ERROR_INVALID_HANDLE) */
RETURN(FALSE);
goto Exit; // Return FALSE
}
if (prcUnsafeUpdate)
@ -548,16 +548,16 @@ NtUserScrollDC(
{
/* FIXME: SetLastError? */
/* FIXME: correct? We have already scrolled! */
RETURN(FALSE);
goto Exit; // Return FALSE
}
}
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserScrollDC, ret=%lu\n",_ret_);
Exit:
TRACE("Leave NtUserScrollDC, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -578,8 +578,7 @@ NtUserScrollWindowEx(
LPRECT prcUnsafeUpdate,
UINT flags)
{
DECLARE_RETURN(DWORD);
INT Result;
DWORD Result = ERROR;
NTSTATUS Status = STATUS_SUCCESS;
PWND Window = NULL;
RECTL rcScroll, rcClip, rcUpdate;
@ -592,7 +591,7 @@ NtUserScrollWindowEx(
if (!Window || !IntIsWindowDrawable(Window))
{
Window = NULL; /* prevent deref at cleanup */
RETURN(ERROR);
goto Cleanup; // Return ERROR
}
UserRefObjectCo(Window, &Ref);
@ -619,7 +618,7 @@ NtUserScrollWindowEx(
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(ERROR);
goto Cleanup; // Return ERROR
}
Result = IntScrollWindowEx(Window,
@ -647,19 +646,17 @@ NtUserScrollWindowEx(
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(ERROR);
Result = ERROR;
}
}
RETURN(Result);
CLEANUP:
Cleanup:
if (Window)
UserDerefObjectCo(Window);
TRACE("Leave NtUserScrollWindowEx, ret=%lu\n",_ret_);
TRACE("Leave NtUserScrollWindowEx, ret=%lu\n", Result);
UserLeave();
END_CLEANUP;
return Result;
}
/* EOF */

View file

@ -974,7 +974,7 @@ HDC APIENTRY
NtUserGetDCEx(HWND hWnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
{
PWND Wnd=NULL;
DECLARE_RETURN(HDC);
HDC Ret = NULL;
TRACE("Enter NtUserGetDCEx: hWnd %p, ClipRegion %p, Flags %x.\n",
hWnd, ClipRegion, Flags);
@ -982,14 +982,14 @@ NtUserGetDCEx(HWND hWnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
if (hWnd && !(Wnd = UserGetWindowObject(hWnd)))
{
RETURN(NULL);
goto Exit; // Return NULL
}
RETURN( UserGetDCEx(Wnd, ClipRegion, Flags));
Ret = UserGetDCEx(Wnd, ClipRegion, Flags);
CLEANUP:
TRACE("Leave NtUserGetDCEx, ret=%p\n", _ret_);
Exit:
TRACE("Leave NtUserGetDCEx, ret=%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*

View file

@ -3392,21 +3392,21 @@ NtUserGetWindowPlacement(HWND hWnd,
PWND Wnd;
WINDOWPLACEMENT Safepl;
NTSTATUS Status;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
TRACE("Enter NtUserGetWindowPlacement\n");
UserEnterShared();
if (!(Wnd = UserGetWindowObject(hWnd)))
{
RETURN( FALSE);
goto Exit; // Return FALSE
}
Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
goto Exit; // Return FALSE
}
Safepl.length = sizeof(WINDOWPLACEMENT);
@ -3417,15 +3417,15 @@ NtUserGetWindowPlacement(HWND hWnd,
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
goto Exit; // Return FALSE
}
RETURN( TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserGetWindowPlacement, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
DWORD
@ -3512,9 +3512,8 @@ NtUserSetWindowPos(
int cy,
UINT uFlags)
{
DECLARE_RETURN(BOOL);
PWND Window, pWndIA;
BOOL ret;
BOOL ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserSetWindowPos\n");
@ -3524,7 +3523,7 @@ NtUserSetWindowPos(
UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
{
ERR("NtUserSetWindowPos bad window handle!\n");
RETURN(FALSE);
goto Exit; // Return FALSE
}
if ( hWndInsertAfter != HWND_TOP &&
@ -3536,7 +3535,7 @@ NtUserSetWindowPos(
UserIsDesktopWindow(pWndIA) || UserIsMessageWindow(pWndIA))
{
ERR("NtUserSetWindowPos bad insert window handle!\n");
RETURN(FALSE);
goto Exit; // Return FALSE
}
}
@ -3560,12 +3559,10 @@ NtUserSetWindowPos(
ret = co_WinPosSetWindowPos(Window, hWndInsertAfter, X, Y, cx, cy, uFlags);
UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP:
TRACE("Leave NtUserSetWindowPos, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserSetWindowPos, ret=%i\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}
/*
@ -3580,8 +3577,7 @@ NtUserSetWindowRgn(
HRGN hrgnCopy = NULL;
PWND Window;
INT flags = (SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE);
BOOLEAN Ret = FALSE;
DECLARE_RETURN(INT);
INT Ret = 0;
TRACE("Enter NtUserSetWindowRgn\n");
UserEnterExclusive();
@ -3589,7 +3585,7 @@ NtUserSetWindowRgn(
if (!(Window = UserGetWindowObject(hWnd)) ||
UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
{
RETURN( 0);
goto Exit; // Return 0
}
if (hRgn) // The region will be deleted in user32.
@ -3602,7 +3598,7 @@ NtUserSetWindowRgn(
NtGdiCombineRgn( hrgnCopy, hRgn, 0, RGN_COPY);
}
else
RETURN( 0);
goto Exit; // Return 0
}
//// HACK 1 : Work around the lack of supporting DeferWindowPos.
@ -3615,14 +3611,12 @@ NtUserSetWindowRgn(
Window->hrgnNewFrame = HRGN_WINDOW;
}
//// HACK 2
Ret = co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, bRedraw ? flags : (flags|SWP_NOREDRAW) );
Ret = (INT)co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, bRedraw ? flags : (flags | SWP_NOREDRAW));
RETURN( (INT)Ret);
CLEANUP:
TRACE("Leave NtUserSetWindowRgn, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserSetWindowRgn, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -3640,7 +3634,7 @@ NtUserSetInternalWindowPos(
PWND Wnd;
RECT rect;
POINT pt = {0};
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserSetWindowPlacement\n");
@ -3649,7 +3643,7 @@ NtUserSetInternalWindowPos(
if (!(Wnd = UserGetWindowObject(hwnd)) || // FIXME:
UserIsDesktopWindow(Wnd) || UserIsMessageWindow(Wnd))
{
RETURN( FALSE);
goto Exit; // Return FALSE
}
_SEH2_TRY
@ -3668,7 +3662,7 @@ NtUserSetInternalWindowPos(
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN( FALSE));
_SEH2_YIELD(goto Exit); // Return FALSE
}
_SEH2_END
@ -3691,12 +3685,12 @@ NtUserSetInternalWindowPos(
UserRefObjectCo(Wnd, &Ref);
IntSetWindowPlacement(Wnd, &wndpl, flags);
UserDerefObjectCo(Wnd);
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserSetWindowPlacement, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -3709,7 +3703,7 @@ NtUserSetWindowPlacement(HWND hWnd,
PWND Wnd;
WINDOWPLACEMENT Safepl;
UINT Flags;
DECLARE_RETURN(BOOL);
BOOL Ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserSetWindowPlacement\n");
@ -3718,7 +3712,7 @@ NtUserSetWindowPlacement(HWND hWnd,
if (!(Wnd = UserGetWindowObject(hWnd)) ||
UserIsDesktopWindow(Wnd) || UserIsMessageWindow(Wnd))
{
RETURN( FALSE);
goto Exit; // Return FALSE
}
_SEH2_TRY
@ -3729,13 +3723,13 @@ NtUserSetWindowPlacement(HWND hWnd,
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(RETURN( FALSE));
_SEH2_YIELD(goto Exit); // Return FALSE
}
_SEH2_END
if(Safepl.length != sizeof(WINDOWPLACEMENT))
{
RETURN( FALSE);
goto Exit; // Return FALSE
}
Flags = PLACE_MAX | PLACE_RECT;
@ -3743,12 +3737,12 @@ NtUserSetWindowPlacement(HWND hWnd,
UserRefObjectCo(Wnd, &Ref);
IntSetWindowPlacement(Wnd, &Safepl, Flags);
UserDerefObjectCo(Wnd);
RETURN(TRUE);
Ret = TRUE;
CLEANUP:
TRACE("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserSetWindowPlacement, ret=%i\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/*
@ -3758,8 +3752,8 @@ BOOL APIENTRY
NtUserShowWindowAsync(HWND hWnd, LONG nCmdShow)
{
PWND Window;
BOOL ret;
DECLARE_RETURN(BOOL);
LRESULT Result;
BOOL ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserShowWindowAsync\n");
@ -3768,26 +3762,24 @@ NtUserShowWindowAsync(HWND hWnd, LONG nCmdShow)
if (!(Window = UserGetWindowObject(hWnd)) ||
UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
{
RETURN(FALSE);
goto Exit; // Return FALSE
}
if ( nCmdShow > SW_MAX )
{
EngSetLastError(ERROR_INVALID_PARAMETER);
RETURN(FALSE);
goto Exit; // Return FALSE
}
UserRefObjectCo(Window, &Ref);
ret = co_IntSendMessageNoWait( hWnd, WM_ASYNC_SHOWWINDOW, nCmdShow, 0 );
Result = co_IntSendMessageNoWait( hWnd, WM_ASYNC_SHOWWINDOW, nCmdShow, 0 );
UserDerefObjectCo(Window);
if (-1 == (int) ret || !ret) ret = FALSE;
if (Result != -1 && Result != 0) ret = TRUE;
RETURN(ret);
CLEANUP:
TRACE("Leave NtUserShowWindowAsync, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserShowWindowAsync, ret=%i\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}
/*
@ -3797,8 +3789,7 @@ BOOL APIENTRY
NtUserShowWindow(HWND hWnd, LONG nCmdShow)
{
PWND Window;
BOOL ret;
DECLARE_RETURN(BOOL);
BOOL ret = FALSE;
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserShowWindow hWnd %p SW_ %d\n",hWnd, nCmdShow);
@ -3807,25 +3798,23 @@ NtUserShowWindow(HWND hWnd, LONG nCmdShow)
if (!(Window = UserGetWindowObject(hWnd)) ||
UserIsDesktopWindow(Window) || UserIsMessageWindow(Window))
{
RETURN(FALSE);
goto Exit; // Return FALSE
}
if ( nCmdShow > SW_MAX || Window->state2 & WNDS2_INDESTROY)
{
EngSetLastError(ERROR_INVALID_PARAMETER);
RETURN(FALSE);
goto Exit; // Return FALSE
}
UserRefObjectCo(Window, &Ref);
ret = co_WinPosShowWindow(Window, nCmdShow);
UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP:
TRACE("Leave NtUserShowWindow, ret=%i\n",_ret_);
Exit:
TRACE("Leave NtUserShowWindow, ret=%i\n", ret);
UserLeave();
END_CLEANUP;
return ret;
}
@ -3836,10 +3825,9 @@ HWND APIENTRY
NtUserWindowFromPoint(LONG X, LONG Y)
{
POINT pt;
HWND Ret;
PWND DesktopWindow = NULL, Window = NULL;
HWND Ret = NULL;
PWND DesktopWindow, Window;
USHORT hittest;
DECLARE_RETURN(HWND);
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserWindowFromPoint\n");
@ -3858,23 +3846,17 @@ NtUserWindowFromPoint(LONG X, LONG Y)
//pti = PsGetCurrentThreadWin32Thread();
Window = co_WinPosWindowFromPoint(DesktopWindow, &pt, &hittest, FALSE);
if (Window)
{
Ret = UserHMGetHandle(Window);
RETURN( Ret);
}
UserDerefObjectCo(DesktopWindow);
}
RETURN( NULL);
CLEANUP:
if (DesktopWindow) UserDerefObjectCo(DesktopWindow);
TRACE("Leave NtUserWindowFromPoint, ret=%p\n", _ret_);
TRACE("Leave NtUserWindowFromPoint, ret=%p\n", Ret);
UserLeave();
END_CLEANUP;
return Ret;
}
/* EOF */