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.
-- v5: 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..1d6dac34d1f 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, (LONG_PTR)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 = (HWND)GetWindowLongPtrW(hwnd, GWLP_HWNDPARENT); + parentA = (HWND)GetWindowLongPtrA(hwnd, GWLP_HWNDPARENT); + retval = SetWindowLongPtrW(hwnd, GWLP_HWNDPARENT, (LONG_PTR)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=134749
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 0x10124 win.c:7314: Test failed: unexpected parent 0x10124
=== 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 0x1014c win.c:7314: Test failed: unexpected parent 0x1014c
=== 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 0x8019a win.c:7314: Test failed: unexpected parent 0x8019a
=== 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 0x2001c win.c:7314: Test failed: unexpected parent 0x2001c
=== 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 0x4003e win.c:7314: Test failed: unexpected parent 0x4003e
=== 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 0x30156 win.c:7314: Test failed: unexpected parent 0x30156
=== 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 0x201f0 win.c:7314: Test failed: unexpected parent 0x201f0
=== 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 0x301e0 win.c:7314: Test failed: unexpected parent 0x301e0
=== w10pro64 (32 bit report) ===
user32: win.c:3817: Test failed: GetForegroundWindow returned 000202C4 win.c:3749: Test failed: SetForegroundWindow failed, error 0 win.c:3752: Test failed: GetForegroundWindow returned 000202C4 win.c:3789: Test failed: GetForegroundWindow returned 000202C4 win.c:3874: Test failed: GetActiveWindow() = 000301D6 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 0x301d6 win.c:7314: Test failed: unexpected parent 0x301d6
=== 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 0x524e70 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 0x524e70 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 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x401a2 win.c:7314: Test failed: unexpected parent 0x401a2
=== w1064v1809 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 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 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x20224 win.c:7314: Test failed: unexpected parent 0x20224
=== w1064_adm (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x301a0 win.c:7314: Test failed: unexpected parent 0x301a0
=== w1064_tsign (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x40092 win.c:7314: Test failed: unexpected parent 0x40092
=== w10pro64 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x200f6 win.c:7314: Test failed: unexpected parent 0x200f6
=== w10pro64_en_AE_u8 (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x602de win.c:7314: Test failed: unexpected parent 0x602de
=== w10pro64_ar (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x701b0 win.c:7314: Test failed: unexpected parent 0x701b0
=== w10pro64_ja (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x10388 win.c:7314: Test failed: unexpected parent 0x10388
=== w10pro64_zh_CN (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x4038a win.c:7314: Test failed: unexpected parent 0x4038a
=== w11pro64_amd (64 bit report) ===
user32: win.c:7299: Test failed: unexpected proc 0x524e70 win.c:7310: Test failed: unexpected parent 0x0 win.c:7312: Test failed: unexpected parent 0x2024a win.c:7314: Test failed: unexpected parent 0x2024a