This fixes SetWindowLongPtr on WoW64. On 32-bit, we have
``` #define SetWindowLongPtrA SetWindowLongA #define SetWindowLongPtrW SetWindowLongW ```
meaning that on WoW64, all pointers passed would be padded with `0xffffffff` (because they are treated as LONG), and this is the cause of many of the failing WoW64 tests. This fixes that behavior. I'm not sure if this is the right place to fix it though.
-- v4: wow64win: Always use NtUserSetWindowLongPtr() for GWLP_HINSTANCE and GWLP_WNDPROC.
From: Sven Baars sbaars@codeweavers.com
--- dlls/user32/tests/win.c | 23 ++++++++++++++++++++++- dlls/wow64win/user.c | 7 +++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 31d14480861..a275127e303 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -7257,8 +7257,9 @@ static void test_set_window_word_size(void)
static void test_SetWindowLong(void) { - LONG_PTR retval; + HWND hwnd, parentA, parentW; WNDPROC old_window_procW; + LONG_PTR retval;
SetLastError(0xdeadbeef); retval = SetWindowLongPtrA(NULL, GWLP_WNDPROC, 0); @@ -7293,6 +7294,26 @@ static void test_SetWindowLong(void) "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%Ix\n", retval); ok(IsWindowUnicode(hwndMain), "hwndMain should now be Unicode\n");
+ /* Make sure nothing changes if we set the same proc */ + retval = SetWindowLongPtrW(hwndMain, GWLP_WNDPROC, old_window_procW); + ok((WNDPROC)retval == old_window_procW, "unexpected proc 0x%Ix\n", retval); + retval = GetWindowLongPtrW(hwndMain, GWLP_WNDPROC); + ok((WNDPROC)retval == old_window_procW, "unexpected proc 0x%Ix\n", retval); + retval = GetWindowLongPtrA(hwndMain, GWLP_WNDPROC); + ok((WNDPROC)retval == main_window_procA, "unexpected proc 0x%Ix\n", retval); + + /* Check that we can set negative HWND, HWND_MESSAGE = -3 */ + hwnd = create_tool_window( WS_CHILD, hwndMain ); + parentW = GetWindowLongPtrW(hwnd, GWLP_HWNDPARENT); + parentA = GetWindowLongPtrA(hwnd, GWLP_HWNDPARENT); + retval = SetWindowLongW(hwnd, GWLP_HWNDPARENT, HWND_MESSAGE); + ok((HWND)retval == parentW, "unexpected parent 0x%Ix\n", retval); + retval = GetWindowLongPtrW(hwnd, GWLP_HWNDPARENT); + ok((HWND)retval != parentW, "unexpected parent 0x%Ix\n", retval); + retval = GetWindowLongPtrA(hwnd, GWLP_HWNDPARENT); + ok((HWND)retval != parentA, "unexpected parent 0x%Ix\n", retval); + DestroyWindow(hwnd); + /* set it back to ANSI */ SetWindowLongPtrA(hwndMain, GWLP_WNDPROC, 0); } diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 8065a05f44a..602ccfa79b9 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -3832,6 +3832,13 @@ NTSTATUS WINAPI wow64_NtUserSetWindowLong( UINT *args ) LONG newval = get_ulong( &args ); BOOL ansi = get_ulong( &args );
+ switch (offset) + { + case GWLP_HINSTANCE: + case GWLP_WNDPROC: + return NtUserSetWindowLongPtr( hwnd, offset, (ULONG)newval, ansi ); + } + return NtUserSetWindowLong( hwnd, offset, newval, ansi ); }
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 tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=134747
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x10126 win.c:7314: Test failed: unexpected parent 0x10126
=== w7u_adm (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x10138 win.c:7314: Test failed: unexpected parent 0x10138
=== w7u_el (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x4014a win.c:7314: Test failed: unexpected parent 0x4014a
=== w8 (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x1019c win.c:7314: Test failed: unexpected parent 0x1019c
=== w8adm (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x30132 win.c:7314: Test failed: unexpected parent 0x30132
=== w864 (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x60046 win.c:7314: Test failed: unexpected parent 0x60046
=== w1064v1507 (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x500a2 win.c:7314: Test failed: unexpected parent 0x500a2
=== w1064v1809 (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0xf0032 win.c:7314: Test failed: unexpected parent 0xf0032
=== w1064_tsign (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x20058 win.c:7314: Test failed: unexpected parent 0x20058
=== w10pro64 (32 bit report) ===
user32: win.c:3817: Test failed: GetForegroundWindow returned 00040198 win.c:3749: Test failed: SetForegroundWindow failed, error 0 win.c:3752: Test failed: GetForegroundWindow returned 00040198 win.c:3789: Test failed: GetForegroundWindow returned 00040198 win.c:3874: Test failed: GetActiveWindow() = 0002021C win.c:3878: Test failed: GetFocus() = 00000000 win.c:3881: Test failed: GetFocus() = 00000000 win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x2021c win.c:7314: Test failed: unexpected parent 0x2021c
=== w11pro64 (32 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x553dc0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x40030 win.c:7314: Test failed: unexpected parent 0x40030
=== w7pro64 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x7013a win.c:7314: Test failed: unexpected parent 0x7013a
=== w864 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x3001e win.c:7314: Test failed: unexpected parent 0x3001e
=== w1064v1507 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x30166 win.c:7314: Test failed: unexpected parent 0x30166
=== w1064v1809 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x201f0 win.c:7314: Test failed: unexpected parent 0x201f0
=== w1064_2qxl (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x301b2 win.c:7314: Test failed: unexpected parent 0x301b2
=== w1064_adm (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x30074 win.c:7314: Test failed: unexpected parent 0x30074
=== w1064_tsign (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x801fa win.c:7314: Test failed: unexpected parent 0x801fa
=== w10pro64 (64 bit report) ===
user32: win.c:3817: Test failed: GetForegroundWindow returned 00000000000202CA win.c:3749: Test failed: SetForegroundWindow failed, error 0 win.c:3752: Test failed: GetForegroundWindow returned 00000000000202CA win.c:3789: Test failed: GetForegroundWindow returned 00000000000202CA win.c:3874: Test failed: GetActiveWindow() = 000000000002021C win.c:3878: Test failed: GetFocus() = 0000000000000000 win.c:3881: Test failed: GetFocus() = 0000000000000000 win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x2021c win.c:7314: Test failed: unexpected parent 0x2021c
=== w10pro64_en_AE_u8 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x602ee win.c:7314: Test failed: unexpected parent 0x602ee
=== w10pro64_ar (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0xa02b8 win.c:7314: Test failed: unexpected parent 0xa02b8
=== w10pro64_ja (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0xb023a win.c:7314: Test failed: unexpected parent 0xb023a
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x170350 win.c:7314: Test failed: unexpected parent 0x170350
=== w11pro64_amd (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524eb0 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x30242 win.c:7314: Test failed: unexpected parent 0x30242
=== debian11b (64 bit WoW report) ===
user32: win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x20050 win.c:7314: Test failed: unexpected parent 0x20050
On Wed Jul 12 07:34:05 2023 +0000, Jacek Caban wrote:
We should probably also do this for `GWLP_HINSTANCE`.
I pushed this and added some tests for the aforementioned cases as well. I'm not really sure how to test this for GWLP_HINSTANCE.