Commit 2784c1ca authored by Alexandre Julliard's avatar Alexandre Julliard

win32u: Fix Get/SetWindowWord behavior on 32-bit.

parent 7ab46c4f
......@@ -248,7 +248,7 @@ static LRESULT call_window_proc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPA
memset(&context, 0, sizeof(context));
context.SegDs = context.SegEs = CURRENT_SS;
if (!(context.Eax = GetWindowWord( HWND_32(hwnd), GWLP_HINSTANCE ))) context.Eax = context.SegDs;
if (!(context.Eax = (WORD)GetWindowLongA( HWND_32(hwnd), GWLP_HINSTANCE ))) context.Eax = context.SegDs;
context.SegCs = SELECTOROF(func);
context.Eip = OFFSETOF(func);
context.Ebp = CURRENT_SP + FIELD_OFFSET(STACK16FRAME, bp);
......
......@@ -838,7 +838,15 @@ LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
*/
WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
{
return GetWindowWord( WIN_Handle32(hwnd), offset );
switch(offset)
{
case GWLP_ID:
case GWLP_HINSTANCE:
case GWLP_HWNDPARENT:
return GetWindowLongA( WIN_Handle32(hwnd), offset );
default:
return GetWindowWord( WIN_Handle32(hwnd), offset );
}
}
......@@ -847,7 +855,15 @@ WORD WINAPI GetWindowWord16( HWND16 hwnd, INT16 offset )
*/
WORD WINAPI SetWindowWord16( HWND16 hwnd, INT16 offset, WORD newval )
{
return SetWindowWord( WIN_Handle32(hwnd), offset, newval );
switch(offset)
{
case GWLP_ID:
case GWLP_HINSTANCE:
case GWLP_HWNDPARENT:
return SetWindowLongA( WIN_Handle32(hwnd), offset, newval );
default:
return SetWindowWord( WIN_Handle32(hwnd), offset, newval );
}
}
......
......@@ -7090,33 +7090,25 @@ static void test_set_window_long_size(void)
retval = GetWindowLongPtrA(hwnd, GWLP_USERDATA);
ok(retval > 123, "Unexpected user data.\n");
ret = GetWindowWord(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == 123, "Unexpected user data %#lx.\n", ret);
ret = SetWindowWord(hwnd, GWLP_USERDATA, 124);
todo_wine
ok(ret == 123, "Unexpected user data %#lx.\n", ret);
ret = GetWindowLongA(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == 124, "Unexpected user data %#lx.\n", ret);
retval = GetWindowLongPtrA(hwnd, GWLP_USERDATA);
todo_wine
ok(retval == 124, "Unexpected user data.\n");
SetWindowLongA(hwnd, GWLP_USERDATA, (1 << 16) | 123);
ret = GetWindowLongA(hwnd, GWLP_USERDATA);
ok(ret == ((1 << 16) | 123), "Unexpected user data %#lx.\n", ret);
ret = GetWindowWord(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == 123, "Unexpected user data %#lx.\n", ret);
ret = SetWindowWord(hwnd, GWLP_USERDATA, 124);
todo_wine
ok(ret == 123, "Unexpected user data %#lx.\n", ret);
ret = GetWindowLongA(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == ((1 << 16) | 124), "Unexpected user data %#lx.\n", ret);
ret = GetWindowWord(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == 124, "Unexpected user data %#lx.\n", ret);
/* GWLP_ID */
......@@ -7138,7 +7130,6 @@ static void test_set_window_long_size(void)
ok(retval > 123, "Unexpected id.\n");
SetLastError(0xdeadbeef);
ret = GetWindowWord(hwnd, GWLP_ID);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected id %#lx.\n", ret);
/* GWLP_HINSTANCE */
......@@ -7155,7 +7146,6 @@ static void test_set_window_long_size(void)
SetLastError(0xdeadbeef);
ret = GetWindowWord(hwnd, GWLP_HINSTANCE);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
SetLastError(0xdeadbeef);
......@@ -7181,7 +7171,6 @@ static void test_set_window_long_size(void)
SetLastError(0xdeadbeef);
ret = GetWindowWord(hwnd, GWLP_HWNDPARENT);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#lx.\n", ret);
DestroyWindow(hwnd);
......@@ -7221,16 +7210,12 @@ static void test_set_window_word_size(void)
ret = GetWindowLongA(hwnd, GWLP_USERDATA);
ok(ret > 123, "Unexpected user data %#lx.\n", ret);
ret = GetWindowWord(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == 123, "Unexpected user data %#lx.\n", ret);
ret = SetWindowWord(hwnd, GWLP_USERDATA, 124);
todo_wine
ok(ret == 123, "Unexpected user data %#lx.\n", ret);
ret = GetWindowWord(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == 124, "Unexpected user data %#lx.\n", ret);
ret = GetWindowLongA(hwnd, GWLP_USERDATA);
todo_wine
ok(ret == ((1 << 16) | 124), "Unexpected user data %#lx.\n", ret);
/* GWLP_ID */
......@@ -7241,11 +7226,9 @@ static void test_set_window_word_size(void)
SetLastError(0xdeadbeef);
ret = GetWindowWord(hwnd, GWLP_ID);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected id %#lx.\n", ret);
SetLastError(0xdeadbeef);
ret = SetWindowWord(hwnd, GWLP_ID, 2);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected id %#lx.\n", ret);
/* GWLP_HINSTANCE */
......@@ -7254,12 +7237,10 @@ static void test_set_window_word_size(void)
SetLastError(0xdeadbeef);
ret = GetWindowWord(hwnd, GWLP_HINSTANCE);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
SetLastError(0xdeadbeef);
ret = SetWindowWord(hwnd, GWLP_HINSTANCE, 0xdead);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
/* GWLP_HWNDPARENT */
......@@ -7268,7 +7249,6 @@ static void test_set_window_word_size(void)
SetLastError(0xdeadbeef);
ret = GetWindowWord(hwnd, GWLP_HWNDPARENT);
todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#lx.\n", ret);
DestroyWindow(hwnd);
......
......@@ -1101,20 +1101,10 @@ ULONG_PTR get_window_long_ptr( HWND hwnd, INT offset, BOOL ansi )
/* see GetWindowWord */
static WORD get_window_word( HWND hwnd, INT offset )
{
switch(offset)
if (offset < 0 && offset != GWLP_USERDATA)
{
case GWLP_ID:
case GWLP_HINSTANCE:
case GWLP_HWNDPARENT:
break;
default:
if (offset < 0)
{
WARN("Invalid offset %d\n", offset );
RtlSetLastWin32Error( ERROR_INVALID_INDEX );
return 0;
}
break;
RtlSetLastWin32Error( ERROR_INVALID_INDEX );
return 0;
}
return get_window_long_size( hwnd, offset, sizeof(WORD), TRUE );
}
......@@ -1354,6 +1344,7 @@ LONG_PTR set_window_long( HWND hwnd, INT offset, UINT size, LONG_PTR newval, BOO
req->is_unicode = (win->flags & WIN_ISUNICODE) != 0;
break;
case GWLP_USERDATA:
if (size == sizeof(WORD)) newval = MAKELONG( newval, win->userdata >> 16 );
req->flags = SET_WIN_USERDATA;
req->user_data = newval;
break;
......@@ -1426,20 +1417,10 @@ LONG_PTR set_window_long( HWND hwnd, INT offset, UINT size, LONG_PTR newval, BOO
*/
WORD WINAPI NtUserSetWindowWord( HWND hwnd, INT offset, WORD newval )
{
switch(offset)
if (offset < 0 && offset != GWLP_USERDATA)
{
case GWLP_ID:
case GWLP_HINSTANCE:
case GWLP_HWNDPARENT:
break;
default:
if (offset < 0)
{
WARN("Invalid offset %d\n", offset );
RtlSetLastWin32Error( ERROR_INVALID_INDEX );
return 0;
}
break;
RtlSetLastWin32Error( ERROR_INVALID_INDEX );
return 0;
}
return set_window_long( hwnd, offset, sizeof(WORD), newval, TRUE );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment