mirror of
https://github.com/reactos/reactos.git
synced 2025-05-23 11:04:52 +00:00
[NTUSER] Improve NtUserSetWindowPlacement (#7096)
Splitted from #7082. Correct behavior of NtUserSetWindowPlacement function. JIRA issue: N/A - Check gptiCurrent->dwExpWinVer in NtUserSetWindowPlacement function. - Fix the last error.
This commit is contained in:
parent
bf4c09b331
commit
ef3e27e2c9
1 changed files with 33 additions and 29 deletions
|
@ -553,7 +553,6 @@ WinPosInitInternalPos(PWND Wnd, RECTL *RestoreRect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Win: _GetWindowPlacement
|
|
||||||
BOOL
|
BOOL
|
||||||
FASTCALL
|
FASTCALL
|
||||||
IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
|
IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
|
||||||
|
@ -562,6 +561,7 @@ IntGetWindowPlacement(PWND Wnd, WINDOWPLACEMENT *lpwndpl)
|
||||||
|
|
||||||
if(lpwndpl->length != sizeof(WINDOWPLACEMENT))
|
if(lpwndpl->length != sizeof(WINDOWPLACEMENT))
|
||||||
{
|
{
|
||||||
|
ERR("length mismatch: %u\n", lpwndpl->length);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3398,9 +3398,7 @@ NtUserGetWindowPlacement(HWND hWnd,
|
||||||
UserEnterShared();
|
UserEnterShared();
|
||||||
|
|
||||||
if (!(Wnd = UserGetWindowObject(hWnd)))
|
if (!(Wnd = UserGetWindowObject(hWnd)))
|
||||||
{
|
|
||||||
goto Exit; // Return FALSE
|
goto Exit; // Return FALSE
|
||||||
}
|
|
||||||
|
|
||||||
Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
|
Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -3409,6 +3407,7 @@ NtUserGetWindowPlacement(HWND hWnd,
|
||||||
goto Exit; // Return FALSE
|
goto Exit; // Return FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function doesn't check the length. Just overwrite it
|
||||||
Safepl.length = sizeof(WINDOWPLACEMENT);
|
Safepl.length = sizeof(WINDOWPLACEMENT);
|
||||||
|
|
||||||
IntGetWindowPlacement(Wnd, &Safepl);
|
IntGetWindowPlacement(Wnd, &Safepl);
|
||||||
|
@ -3709,35 +3708,40 @@ NtUserSetWindowPlacement(HWND hWnd,
|
||||||
TRACE("Enter NtUserSetWindowPlacement\n");
|
TRACE("Enter NtUserSetWindowPlacement\n");
|
||||||
UserEnterExclusive();
|
UserEnterExclusive();
|
||||||
|
|
||||||
if (!(Wnd = UserGetWindowObject(hWnd)) ||
|
_SEH2_TRY
|
||||||
UserIsDesktopWindow(Wnd) || UserIsMessageWindow(Wnd))
|
{
|
||||||
{
|
ProbeForRead(lpwndpl, sizeof(*lpwndpl), 1);
|
||||||
goto Exit; // Return FALSE
|
Safepl = *lpwndpl;
|
||||||
}
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
SetLastNtError(_SEH2_GetExceptionCode());
|
||||||
|
_SEH2_YIELD(goto Exit); // Return FALSE
|
||||||
|
}
|
||||||
|
_SEH2_END
|
||||||
|
|
||||||
_SEH2_TRY
|
/* Backwards-compatibility: Win 3.x doesn't check the length */
|
||||||
{
|
if (LOWORD(gptiCurrent->dwExpWinVer) < WINVER_WINNT4)
|
||||||
ProbeForRead(lpwndpl, sizeof(WINDOWPLACEMENT), 1);
|
Safepl.length = sizeof(Safepl);
|
||||||
RtlCopyMemory(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
|
|
||||||
}
|
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
||||||
{
|
|
||||||
SetLastNtError(_SEH2_GetExceptionCode());
|
|
||||||
_SEH2_YIELD(goto Exit); // Return FALSE
|
|
||||||
}
|
|
||||||
_SEH2_END
|
|
||||||
|
|
||||||
if(Safepl.length != sizeof(WINDOWPLACEMENT))
|
if (Safepl.length != sizeof(Safepl))
|
||||||
{
|
{
|
||||||
goto Exit; // Return FALSE
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
||||||
}
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
Flags = PLACE_MAX | PLACE_RECT;
|
Flags = PLACE_MAX | PLACE_RECT;
|
||||||
if (Safepl.flags & WPF_SETMINPOSITION) Flags |= PLACE_MIN;
|
if (Safepl.flags & WPF_SETMINPOSITION)
|
||||||
UserRefObjectCo(Wnd, &Ref);
|
Flags |= PLACE_MIN;
|
||||||
IntSetWindowPlacement(Wnd, &Safepl, Flags);
|
|
||||||
UserDerefObjectCo(Wnd);
|
Wnd = UserGetWindowObject(hWnd);
|
||||||
Ret = TRUE;
|
if (!Wnd)
|
||||||
|
goto Exit; // Return FALSE
|
||||||
|
|
||||||
|
UserRefObjectCo(Wnd, &Ref);
|
||||||
|
if (!UserIsDesktopWindow(Wnd) && !UserIsMessageWindow(Wnd))
|
||||||
|
Ret = IntSetWindowPlacement(Wnd, &Safepl, Flags);
|
||||||
|
UserDerefObjectCo(Wnd);
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
TRACE("Leave NtUserSetWindowPlacement, ret=%i\n", Ret);
|
TRACE("Leave NtUserSetWindowPlacement, ret=%i\n", Ret);
|
||||||
|
|
Loading…
Reference in a new issue