[v2 PATCH 2/2] user32: Make GetWindowLong() fail for some values on 64-bit.
Nikolay Sivov
nsivov at codeweavers.com
Thu Feb 28 15:53:43 CST 2019
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/user32/tests/win.c | 4 ----
dlls/user32/win.c | 28 ++++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index d9a8e85d7b..639eef4c42 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -6346,7 +6346,6 @@ static void test_set_window_long_size(void)
/* GWLP_WNDPROC */
SetLastError(0xdeadbeef);
wnd_proc = (WNDPROC)(LONG_PTR)GetWindowLongA(hwnd, GWLP_WNDPROC);
-todo_wine
ok(!wnd_proc && GetLastError() == ERROR_INVALID_INDEX, "Unexpected window proc.\n");
wnd_proc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
@@ -6427,12 +6426,10 @@ todo_wine
SetLastError(0xdeadbeef);
ret = GetWindowLongA(hwnd, GWLP_HINSTANCE);
-todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#x.\n", ret);
SetLastError(0xdeadbeef);
ret = GetWindowLongW(hwnd, GWLP_HINSTANCE);
-todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#x.\n", ret);
SetLastError(0xdeadbeef);
@@ -6451,7 +6448,6 @@ todo_wine
/* GWLP_HWNDPARENT */
SetLastError(0xdeadbeef);
ret = GetWindowLongA(hwnd, GWLP_HWNDPARENT);
-todo_wine
ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#x.\n", ret);
SetLastError(0xdeadbeef);
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index f5ac867d2b..0bb9fd9cba 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -2690,7 +2690,19 @@ WORD WINAPI GetWindowWord( HWND hwnd, INT offset )
*/
LONG WINAPI GetWindowLongA( HWND hwnd, INT offset )
{
- return WIN_GetWindowLong( hwnd, offset, sizeof(LONG), FALSE );
+ switch (offset)
+ {
+#ifdef _WIN64
+ case GWLP_WNDPROC:
+ case GWLP_HINSTANCE:
+ case GWLP_HWNDPARENT:
+ WARN( "Invalid offset %d\n", offset );
+ SetLastError( ERROR_INVALID_INDEX );
+ return 0;
+#endif
+ default:
+ return WIN_GetWindowLong( hwnd, offset, sizeof(LONG), FALSE );
+ }
}
@@ -2699,7 +2711,19 @@ LONG WINAPI GetWindowLongA( HWND hwnd, INT offset )
*/
LONG WINAPI GetWindowLongW( HWND hwnd, INT offset )
{
- return WIN_GetWindowLong( hwnd, offset, sizeof(LONG), TRUE );
+ switch (offset)
+ {
+#ifdef _WIN64
+ case GWLP_WNDPROC:
+ case GWLP_HINSTANCE:
+ case GWLP_HWNDPARENT:
+ WARN( "Invalid offset %d\n", offset );
+ SetLastError( ERROR_INVALID_INDEX );
+ return 0;
+#endif
+ default:
+ return WIN_GetWindowLong( hwnd, offset, sizeof(LONG), TRUE );
+ }
}
--
2.20.1
More information about the wine-devel
mailing list