Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
447721e8
Commit
447721e8
authored
Jul 31, 2006
by
Robert Shearman
Committed by
Alexandre Julliard
Jul 31, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user: Ignore setting NULL window procs inside SetWindowLong.
Add tests for SetWindowLong error cases.
parent
bc194793
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
win.c
dlls/user/tests/win.c
+49
-0
win.c
dlls/user/win.c
+5
-3
No files found.
dlls/user/tests/win.c
View file @
447721e8
...
...
@@ -3818,6 +3818,54 @@ static void test_CreateWindow(void)
#undef expect_ex_style
}
/* function that remembers whether the system the test is running on sets the
* last error for user32 functions to make the tests stricter */
static
int
check_error
(
DWORD
actual
,
DWORD
expected
)
{
static
int
sets_last_error
=
-
1
;
if
(
sets_last_error
==
-
1
)
sets_last_error
=
(
actual
!=
0xdeadbeef
);
return
(
!
sets_last_error
&&
(
actual
==
0xdeadbeef
))
||
(
actual
==
expected
);
}
static
void
test_SetWindowLong
(
void
)
{
LONG_PTR
retval
;
SetLastError
(
0xdeadbeef
);
retval
=
SetWindowLongPtr
(
NULL
,
GWLP_WNDPROC
,
0
);
ok
(
!
retval
,
"SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%x
\n
"
,
retval
);
ok
(
check_error
(
GetLastError
(),
ERROR_INVALID_WINDOW_HANDLE
),
"SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instad of %ld
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
retval
=
SetWindowLongPtr
(
hwndMain
,
0xdeadbeef
,
0
);
ok
(
!
retval
,
"SetWindowLongPtr on invalid index should have returned 0 instead of 0x%x
\n
"
,
retval
);
ok
(
check_error
(
GetLastError
(),
ERROR_INVALID_INDEX
),
"SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instad of %ld
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
retval
=
SetWindowLongPtr
(
hwndMain
,
GWLP_WNDPROC
,
0
);
ok
((
WNDPROC
)
retval
==
main_window_procA
,
"SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%x
\n
"
,
retval
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"SetWindowLongPtr shouldn't have set the last error, instead of setting it to %ld
\n
"
,
GetLastError
());
retval
=
GetWindowLongPtr
(
hwndMain
,
GWLP_WNDPROC
);
ok
((
WNDPROC
)
retval
==
main_window_procA
,
"SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%x
\n
"
,
retval
);
ok
(
!
IsWindowUnicode
(
hwndMain
),
"hwndMain shouldn't be Unicode
\n
"
);
SetLastError
(
0xdeadbeef
);
retval
=
SetWindowLongPtrW
(
hwndMain
,
GWLP_WNDPROC
,
0
);
if
(
GetLastError
()
!=
ERROR_CALL_NOT_IMPLEMENTED
)
{
ok
(
GetLastError
()
==
0xdeadbeef
,
"SetWindowLongPtr shouldn't have set the last error, instead of setting it to %ld
\n
"
,
GetLastError
());
ok
(
IsWindowUnicode
(
hwndMain
),
"hwndMain should now be Unicode
\n
"
);
/* set it back to ANSI */
SetWindowLongPtr
(
hwndMain
,
GWLP_WNDPROC
,
0
);
}
}
START_TEST
(
win
)
{
pGetAncestor
=
(
void
*
)
GetProcAddress
(
GetModuleHandleA
(
"user32.dll"
),
"GetAncestor"
);
...
...
@@ -3893,6 +3941,7 @@ START_TEST(win)
test_window_styles
();
test_redrawnow
();
test_csparentdc
();
test_SetWindowLong
();
/* add the tests above this line */
UnhookWindowsHookEx
(
hhook
);
...
...
dlls/user/win.c
View file @
447721e8
...
...
@@ -1981,11 +1981,13 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval, BOOL
}
case
GWLP_WNDPROC
:
{
WNDPROC
proc
;
UINT
old_flags
=
wndPtr
->
flags
;
retval
=
(
ULONG_PTR
)
WINPROC_GetProc
(
wndPtr
->
winproc
,
unicode
);
if
(
unicode
)
wndPtr
->
winproc
=
WINPROC_AllocProc
(
NULL
,
(
WNDPROC
)
newval
);
else
wndPtr
->
winproc
=
WINPROC_AllocProc
(
(
WNDPROC
)
newval
,
NULL
);
if
(
WINPROC_IsUnicode
(
wndPtr
->
winproc
,
unicode
))
wndPtr
->
flags
|=
WIN_ISUNICODE
;
if
(
unicode
)
proc
=
WINPROC_AllocProc
(
NULL
,
(
WNDPROC
)
newval
);
else
proc
=
WINPROC_AllocProc
(
(
WNDPROC
)
newval
,
NULL
);
if
(
proc
)
wndPtr
->
winproc
=
proc
;
if
(
WINPROC_IsUnicode
(
proc
,
unicode
))
wndPtr
->
flags
|=
WIN_ISUNICODE
;
else
wndPtr
->
flags
&=
~
WIN_ISUNICODE
;
if
(
!
((
old_flags
^
wndPtr
->
flags
)
&
WIN_ISUNICODE
))
{
...
...
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