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
ecd1c664
Commit
ecd1c664
authored
Nov 22, 2021
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Nov 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Add exception handler to GetWindowText.
Signed-off-by:
Dmitry Timoshkov
<
dmitry@baikal.ru
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4b9010d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
19 deletions
+67
-19
win.c
dlls/user32/tests/win.c
+24
-5
win.c
dlls/user32/win.c
+43
-14
No files found.
dlls/user32/tests/win.c
View file @
ecd1c664
...
...
@@ -7923,17 +7923,36 @@ static void test_gettext(void)
if
(
0
)
{
r
=
SendMessageA
(
hwnd
,
WM_GETTEXT
,
0x10
,
0x1000
);
ok
(
r
==
0
,
"
settext should return zero
\n
"
);
ok
(
r
==
0
,
"
WM_GETTEXT should return zero (%ld)
\n
"
,
r
);
r
=
SendMessageA
(
hwnd
,
WM_GETTEXT
,
0x10000
,
0
);
ok
(
r
==
0
,
"
settext should return zero (%ld)
\n
"
,
r
);
ok
(
r
==
0
,
"
WM_GETTEXT should return zero (%ld)
\n
"
,
r
);
r
=
SendMessageA
(
hwnd
,
WM_GETTEXT
,
0xff000000
,
0x1000
);
ok
(
r
==
0
,
"
settext should return zero (%ld)
\n
"
,
r
);
ok
(
r
==
0
,
"
WM_GETTEXT should return zero (%ld)
\n
"
,
r
);
r
=
SendMessageA
(
hwnd
,
WM_GETTEXT
,
0x1000
,
0xff000000
);
ok
(
r
==
0
,
"settext should return zero (%ld)
\n
"
,
r
);
}
ok
(
r
==
0
,
"WM_GETTEXT should return zero (%ld)
\n
"
,
r
);
}
/* GetWindowText doesn't crash */
r
=
GetWindowTextA
(
hwnd
,
(
LPSTR
)
0x10
,
0x1000
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
r
=
GetWindowTextA
(
hwnd
,
(
LPSTR
)
0x10000
,
0
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
r
=
GetWindowTextA
(
hwnd
,
(
LPSTR
)
0xff000000
,
0x1000
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
r
=
GetWindowTextA
(
hwnd
,
(
LPSTR
)
0x1000
,
0xff000000
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
r
=
GetWindowTextW
(
hwnd
,
(
LPWSTR
)
0x10
,
0x1000
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
r
=
GetWindowTextW
(
hwnd
,
(
LPWSTR
)
0x10000
,
0
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
r
=
GetWindowTextW
(
hwnd
,
(
LPWSTR
)
0xff000000
,
0x1000
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
r
=
GetWindowTextW
(
hwnd
,
(
LPWSTR
)
0x1000
,
0xff000000
);
ok
(
r
==
0
,
"GetWindowText should return zero (%ld)
\n
"
,
r
);
DestroyWindow
(
hwnd
);
}
...
...
dlls/user32/win.c
View file @
ecd1c664
...
...
@@ -31,6 +31,7 @@
#include "win.h"
#include "controls.h"
#include "winerror.h"
#include "wine/exception.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
win
);
...
...
@@ -2999,22 +3000,35 @@ LONG WINAPI DECLSPEC_HOTPATCH SetWindowLongW(
INT
WINAPI
GetWindowTextA
(
HWND
hwnd
,
LPSTR
lpString
,
INT
nMaxCount
)
{
WCHAR
*
buffer
;
int
ret
=
0
;
if
(
!
lpString
||
nMaxCount
<=
0
)
return
0
;
if
(
WIN_IsCurrentProcess
(
hwnd
))
__TRY
{
lpString
[
0
]
=
0
;
return
(
INT
)
SendMessageA
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
if
(
WIN_IsCurrentProcess
(
hwnd
))
{
ret
=
(
INT
)
SendMessageA
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
}
else
if
((
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nMaxCount
*
sizeof
(
WCHAR
)
)))
{
/* when window belongs to other process, don't send a message */
get_server_window_text
(
hwnd
,
buffer
,
nMaxCount
);
if
(
!
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
lpString
,
nMaxCount
,
NULL
,
NULL
))
lpString
[
nMaxCount
-
1
]
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
ret
=
strlen
(
lpString
);
}
}
__EXCEPT_PAGE_FAULT
{
ret
=
0
;
}
__ENDTRY
/* when window belongs to other process, don't send a message */
if
(
!
(
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
nMaxCount
*
sizeof
(
WCHAR
)
)))
return
0
;
get_server_window_text
(
hwnd
,
buffer
,
nMaxCount
);
if
(
!
WideCharToMultiByte
(
CP_ACP
,
0
,
buffer
,
-
1
,
lpString
,
nMaxCount
,
NULL
,
NULL
))
lpString
[
nMaxCount
-
1
]
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
return
strlen
(
lpString
);
return
ret
;
}
...
...
@@ -3047,17 +3061,32 @@ INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount )
*/
INT
WINAPI
GetWindowTextW
(
HWND
hwnd
,
LPWSTR
lpString
,
INT
nMaxCount
)
{
int
ret
;
if
(
!
lpString
||
nMaxCount
<=
0
)
return
0
;
if
(
WIN_IsCurrentProcess
(
hwnd
))
__TRY
{
lpString
[
0
]
=
0
;
return
(
INT
)
SendMessageW
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
if
(
WIN_IsCurrentProcess
(
hwnd
))
{
ret
=
(
INT
)
SendMessageW
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
}
else
{
/* when window belongs to other process, don't send a message */
get_server_window_text
(
hwnd
,
lpString
,
nMaxCount
);
ret
=
lstrlenW
(
lpString
);
}
}
__EXCEPT_PAGE_FAULT
{
ret
=
0
;
}
__ENDTRY
/* when window belongs to other process, don't send a message */
get_server_window_text
(
hwnd
,
lpString
,
nMaxCount
);
return
lstrlenW
(
lpString
);
return
ret
;
}
...
...
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