Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d00ed8e7
Commit
d00ed8e7
authored
Mar 01, 2019
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Do not touch some of the values on 64-bit with SetWindowLong().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9d0ba368
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
258 additions
and
3 deletions
+258
-3
win.c
dlls/user32/tests/win.c
+230
-0
win.c
dlls/user32/win.c
+28
-3
No files found.
dlls/user32/tests/win.c
View file @
d00ed8e7
...
...
@@ -6330,6 +6330,233 @@ static int check_error(DWORD actual, DWORD expected)
return
(
!
sets_last_error
&&
(
actual
==
0xdeadbeef
))
||
(
actual
==
expected
);
}
static
void
test_set_window_long_size
(
void
)
{
#ifdef _WIN64
WNDPROC
wnd_proc
,
wnd_proc_2
;
LONG_PTR
retval
;
HWND
hwnd
;
LONG
ret
;
/* It's not allowed to set or get 64-bit pointer values using 32-bit functions. */
hwnd
=
CreateWindowExA
(
0
,
"MainWindowClass"
,
"Child window"
,
WS_CAPTION
|
WS_SYSMENU
|
WS_MINIMIZEBOX
|
WS_CHILD
|
WS_MAXIMIZEBOX
|
WS_VISIBLE
,
100
,
100
,
200
,
200
,
hwndMain
,
0
,
GetModuleHandleA
(
NULL
),
NULL
);
ok
(
hwnd
!=
NULL
,
"Failed to create test window.
\n
"
);
/* 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
);
ok
(
!!
wnd_proc
,
"Unexpected window proc.
\n
"
);
SetLastError
(
0xdeadbeef
);
wnd_proc_2
=
(
WNDPROC
)(
LONG_PTR
)
SetWindowLongA
(
hwnd
,
GWLP_WNDPROC
,
0xdeadbeef
);
ok
(
!
wnd_proc_2
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected window proc.
\n
"
);
wnd_proc_2
=
(
WNDPROC
)
GetWindowLongPtrA
(
hwnd
,
GWLP_WNDPROC
);
ok
(
wnd_proc_2
==
wnd_proc
,
"Unexpected window proc.
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_WNDPROC
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected return value.
\n
"
);
/* GWLP_USERDATA */
SetWindowLongPtrA
(
hwnd
,
GWLP_USERDATA
,
((
LONG_PTR
)
1
<<
32
)
|
123
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_USERDATA
);
ok
(
ret
==
123
,
"Unexpected user data %#x.
\n
"
,
ret
);
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 %#x.
\n
"
,
ret
);
ret
=
SetWindowWord
(
hwnd
,
GWLP_USERDATA
,
124
);
todo_wine
ok
(
ret
==
123
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_USERDATA
);
todo_wine
ok
(
ret
==
124
,
"Unexpected user data %#x.
\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 %#x.
\n
"
,
ret
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_USERDATA
);
todo_wine
ok
(
ret
==
123
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
SetWindowWord
(
hwnd
,
GWLP_USERDATA
,
124
);
todo_wine
ok
(
ret
==
123
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_USERDATA
);
todo_wine
ok
(
ret
==
((
1
<<
16
)
|
124
),
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_USERDATA
);
todo_wine
ok
(
ret
==
124
,
"Unexpected user data %#x.
\n
"
,
ret
);
/* GWLP_ID */
ret
=
SetWindowLongA
(
hwnd
,
GWLP_ID
,
1
);
ok
(
!
ret
,
"Unexpected id %#x.
\n
"
,
ret
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_ID
);
ok
(
ret
==
1
,
"Unexpected id %#x.
\n
"
,
ret
);
ret
=
GetWindowLongW
(
hwnd
,
GWLP_ID
);
ok
(
ret
==
1
,
"Unexpected id %#x.
\n
"
,
ret
);
SetWindowLongPtrA
(
hwnd
,
GWLP_ID
,
((
LONG_PTR
)
1
<<
32
)
|
123
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_ID
);
ok
(
ret
==
123
,
"Unexpected id %#x.
\n
"
,
ret
);
ret
=
GetWindowLongW
(
hwnd
,
GWLP_ID
);
ok
(
ret
==
123
,
"Unexpected id %#x.
\n
"
,
ret
);
retval
=
GetWindowLongPtrA
(
hwnd
,
GWLP_ID
);
ok
(
retval
>
123
,
"Unexpected id.
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_ID
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected id %#x.
\n
"
,
ret
);
/* GWLP_HINSTANCE */
retval
=
GetWindowLongPtrA
(
hwnd
,
GWLP_HINSTANCE
);
ok
(
retval
==
(
LONG_PTR
)
GetModuleHandleA
(
NULL
),
"Unexpected instance %#lx.
\n
"
,
retval
);
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
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_HINSTANCE
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected instance %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
SetWindowLongA
(
hwnd
,
GWLP_HINSTANCE
,
1
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected instance %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
SetWindowLongW
(
hwnd
,
GWLP_HINSTANCE
,
1
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected instance %#x.
\n
"
,
ret
);
/* 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
);
ret
=
SetWindowLongA
(
hwnd
,
GWLP_HWNDPARENT
,
0
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected parent window %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
SetWindowLongW
(
hwnd
,
GWLP_HWNDPARENT
,
0
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected parent window %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_HWNDPARENT
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected parent window %#x.
\n
"
,
ret
);
DestroyWindow
(
hwnd
);
#endif
}
static
void
test_set_window_word_size
(
void
)
{
WNDPROC
wnd_proc
,
wnd_proc_2
;
LONG_PTR
retval
;
HWND
hwnd
;
LONG
ret
;
/* It's not allowed to set or get 64-bit pointer values using 32-bit functions. */
hwnd
=
CreateWindowExA
(
0
,
"MainWindowClass"
,
"Child window"
,
WS_CAPTION
|
WS_SYSMENU
|
WS_MINIMIZEBOX
|
WS_CHILD
|
WS_MAXIMIZEBOX
|
WS_VISIBLE
,
100
,
100
,
200
,
200
,
hwndMain
,
0
,
GetModuleHandleA
(
NULL
),
NULL
);
ok
(
hwnd
!=
NULL
,
"Failed to create test window.
\n
"
);
/* GWLP_WNDPROC */
wnd_proc
=
(
WNDPROC
)
GetWindowLongPtrA
(
hwnd
,
GWLP_WNDPROC
);
ok
(
!!
wnd_proc
,
"Unexpected window proc.
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_WNDPROC
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected window proc.
\n
"
);
SetLastError
(
0xdeadbeef
);
ret
=
SetWindowWord
(
hwnd
,
GWLP_WNDPROC
,
0xbeef
);
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected window proc.
\n
"
);
wnd_proc_2
=
(
WNDPROC
)
GetWindowLongPtrA
(
hwnd
,
GWLP_WNDPROC
);
ok
(
wnd_proc_2
==
wnd_proc
,
"Unexpected window proc.
\n
"
);
/* GWLP_USERDATA */
ret
=
SetWindowLongA
(
hwnd
,
GWLP_USERDATA
,
(
1
<<
16
)
|
123
);
ok
(
!
ret
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_USERDATA
);
ok
(
ret
>
123
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_USERDATA
);
todo_wine
ok
(
ret
==
123
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
SetWindowWord
(
hwnd
,
GWLP_USERDATA
,
124
);
todo_wine
ok
(
ret
==
123
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_USERDATA
);
todo_wine
ok
(
ret
==
124
,
"Unexpected user data %#x.
\n
"
,
ret
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_USERDATA
);
todo_wine
ok
(
ret
==
((
1
<<
16
)
|
124
),
"Unexpected user data %#x.
\n
"
,
ret
);
/* GWLP_ID */
ret
=
SetWindowLongA
(
hwnd
,
GWLP_ID
,
1
);
ok
(
!
ret
,
"Unexpected id %#x.
\n
"
,
ret
);
ret
=
GetWindowLongA
(
hwnd
,
GWLP_ID
);
ok
(
ret
==
1
,
"Unexpected id %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_ID
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected id %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
SetWindowWord
(
hwnd
,
GWLP_ID
,
2
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected id %#x.
\n
"
,
ret
);
/* GWLP_HINSTANCE */
retval
=
GetWindowLongPtrA
(
hwnd
,
GWLP_HINSTANCE
);
ok
(
retval
==
(
LONG_PTR
)
GetModuleHandleA
(
NULL
),
"Unexpected instance %#lx.
\n
"
,
retval
);
SetLastError
(
0xdeadbeef
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_HINSTANCE
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected instance %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
SetWindowWord
(
hwnd
,
GWLP_HINSTANCE
,
0xdead
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected instance %#x.
\n
"
,
ret
);
/* GWLP_HWNDPARENT */
retval
=
GetWindowLongPtrA
(
hwnd
,
GWLP_HWNDPARENT
);
ok
(
!!
retval
,
"Unexpected parent window %#x.
\n
"
,
ret
);
SetLastError
(
0xdeadbeef
);
ret
=
GetWindowWord
(
hwnd
,
GWLP_HWNDPARENT
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_INDEX
,
"Unexpected parent window %#x.
\n
"
,
ret
);
DestroyWindow
(
hwnd
);
}
static
void
test_SetWindowLong
(
void
)
{
LONG_PTR
retval
;
...
...
@@ -6371,6 +6598,9 @@ static void test_SetWindowLong(void)
/* set it back to ANSI */
SetWindowLongPtrA
(
hwndMain
,
GWLP_WNDPROC
,
0
);
}
test_set_window_long_size
();
test_set_window_word_size
();
}
static
LRESULT
WINAPI
check_style_wnd_proc
(
HWND
hwnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
...
...
dlls/user32/win.c
View file @
d00ed8e7
...
...
@@ -2734,7 +2734,19 @@ WORD WINAPI SetWindowWord( HWND hwnd, INT offset, WORD newval )
*/
LONG
WINAPI
DECLSPEC_HOTPATCH
SetWindowLongA
(
HWND
hwnd
,
INT
offset
,
LONG
newval
)
{
return
WIN_SetWindowLong
(
hwnd
,
offset
,
sizeof
(
LONG
),
newval
,
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_SetWindowLong
(
hwnd
,
offset
,
sizeof
(
LONG
),
newval
,
FALSE
);
}
}
...
...
@@ -2808,8 +2820,21 @@ LONG WINAPI DECLSPEC_HOTPATCH SetWindowLongW(
HWND
hwnd
,
/* [in] window to alter */
INT
offset
,
/* [in] offset, in bytes, of location to alter */
LONG
newval
/* [in] new value of location */
)
{
return
WIN_SetWindowLong
(
hwnd
,
offset
,
sizeof
(
LONG
),
newval
,
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_SetWindowLong
(
hwnd
,
offset
,
sizeof
(
LONG
),
newval
,
TRUE
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment