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 ); }