This change has been in Proton to fix a bug in the DayZ launcher.
The launcher is a .NET application that, best I can tell, contains marshaling code that calls SetWindowPlacement incorrectly. This results in undefined memory being passed in and broken values returned by GetWindowPlacement. I think the value passed in must be broken on Windows, but as the tests show, Windows rejects SetWindowPlacement calls that don't have length set correctly (but not GetWindowPlacement, as zeroing the structure to give it an invalid length in `other_process_proc` shows).
-- v2: win32u: Reject invalid length in SetWindowPlacement. user32: Test Get/SetWindowPlacement with invalid length.
From: Esme Povirk esme@codeweavers.com
--- dlls/user32/tests/win.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index b86a9b05e61..d70f8a0cafd 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -12498,6 +12498,17 @@ static void test_window_placement(void) GetWindowRect(hwnd, &rect); ok(EqualRect(&rect, &orig), "got window rect %s\n", wine_dbgstr_rect(&rect));
+ ret = SetWindowPlacement(hwnd, &wp); + ok(ret, "failed to set window placement, error %lu\n", GetLastError()); + + wp.length = 0; + SetLastError(0xdeadbeef); + ret = SetWindowPlacement(hwnd, &wp); +todo_wine { + ok(!ret, "SetWindowPlacement should have failed\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError()); +} + DestroyWindow(hwnd); }
@@ -12657,7 +12668,7 @@ static void test_arrange_iconic_windows(void) static void other_process_proc(HWND hwnd) { HANDLE window_ready_event, test_done_event; - WINDOWPLACEMENT wp; + WINDOWPLACEMENT wp = {0}; DWORD ret;
window_ready_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_opw_window");
From: Esme Povirk esme@codeweavers.com
--- dlls/user32/tests/win.c | 2 -- dlls/win32u/window.c | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index d70f8a0cafd..d9b1d9c2665 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -12504,10 +12504,8 @@ static void test_window_placement(void) wp.length = 0; SetLastError(0xdeadbeef); ret = SetWindowPlacement(hwnd, &wp); -todo_wine { ok(!ret, "SetWindowPlacement should have failed\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError()); -}
DestroyWindow(hwnd); } diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index d7263875b17..5b87dcdf465 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2567,6 +2567,11 @@ BOOL WINAPI NtUserSetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl ) { UINT flags = PLACE_MAX | PLACE_RECT; if (!wpl) return FALSE; + if (wpl->length != sizeof(*wpl)) + { + RtlSetLastWin32Error( ERROR_INVALID_PARAMETER ); + return FALSE; + } if (wpl->flags & WPF_SETMINPOSITION) flags |= PLACE_MIN; return set_window_placement( hwnd, wpl, flags ); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125313
Your paranoid android.
=== w1064_adm (64 bit report) ===
user32: win.c:2688: Test failed: style 0x200000: expected !100 win.c:2688: Test failed: style 0x300000: expected !100
=== w10pro64_ja (64 bit report) ===
user32: win.c:4388: Test failed: message 0200 available
=== debian11 (build log) ===
Task: Could not create the win32 wineprefix: Failed to disable the crash dialogs: Task: WineTest did not produce the win32 report