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
ee72b0fd
Commit
ee72b0fd
authored
Jul 23, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Initialize buffer before sending WM_GETTEXT.
parent
ccc34703
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
1 deletion
+130
-1
win.c
dlls/user32/tests/win.c
+122
-1
win.c
dlls/user32/win.c
+8
-0
No files found.
dlls/user32/tests/win.c
View file @
ee72b0fd
...
...
@@ -717,6 +717,14 @@ static void test_enum_thread_windows(void)
CloseHandle
(
handle
);
}
static
struct
wm_gettext_override_data
{
BOOL
enabled
;
/* when 1 bypasses default procedure */
char
*
buff
;
/* expected text buffer pointer */
WCHAR
*
buffW
;
/* same, for W test */
int
len
;
}
g_wm_gettext_override
;
static
LRESULT
WINAPI
main_window_procA
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
{
switch
(
msg
)
...
...
@@ -798,6 +806,14 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
break
;
case
WM_GETTEXT
:
num_gettext_msgs
++
;
if
(
g_wm_gettext_override
.
enabled
)
{
char
*
text
=
(
char
*
)
lparam
;
ok
(
g_wm_gettext_override
.
buff
==
text
,
"expected buffer %p, got %p
\n
"
,
g_wm_gettext_override
.
buff
,
text
);
if
(
g_wm_gettext_override
.
len
)
ok
(
*
text
==
0
,
"expected empty string buffer %x
\n
"
,
*
text
);
return
0
;
}
break
;
case
WM_SETTEXT
:
num_settext_msgs
++
;
...
...
@@ -807,6 +823,26 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
return
DefWindowProcA
(
hwnd
,
msg
,
wparam
,
lparam
);
}
static
LRESULT
WINAPI
main_window_procW
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
{
switch
(
msg
)
{
case
WM_GETTEXT
:
num_gettext_msgs
++
;
if
(
g_wm_gettext_override
.
enabled
)
{
WCHAR
*
text
=
(
WCHAR
*
)
lparam
;
ok
(
g_wm_gettext_override
.
buffW
==
text
,
"expected buffer %p, got %p
\n
"
,
g_wm_gettext_override
.
buffW
,
text
);
if
(
g_wm_gettext_override
.
len
)
ok
(
*
text
==
0
,
"expected empty string buffer %x
\n
"
,
*
text
);
return
0
;
}
break
;
}
return
DefWindowProcA
(
hwnd
,
msg
,
wparam
,
lparam
);
}
static
LRESULT
WINAPI
tool_window_procA
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wparam
,
LPARAM
lparam
)
{
switch
(
msg
)
...
...
@@ -832,8 +868,11 @@ static LRESULT WINAPI tool_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
return
DefWindowProcA
(
hwnd
,
msg
,
wparam
,
lparam
);
}
static
const
WCHAR
mainclassW
[]
=
{
'M'
,
'a'
,
'i'
,
'n'
,
'W'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
'C'
,
'l'
,
'a'
,
's'
,
's'
,
'W'
,
0
};
static
BOOL
RegisterWindowClasses
(
void
)
{
WNDCLASSW
clsW
;
WNDCLASSA
cls
;
cls
.
style
=
CS_DBLCLKS
;
...
...
@@ -849,6 +888,19 @@ static BOOL RegisterWindowClasses(void)
if
(
!
RegisterClassA
(
&
cls
))
return
FALSE
;
clsW
.
style
=
CS_DBLCLKS
;
clsW
.
lpfnWndProc
=
main_window_procW
;
clsW
.
cbClsExtra
=
0
;
clsW
.
cbWndExtra
=
0
;
clsW
.
hInstance
=
GetModuleHandleA
(
0
);
clsW
.
hIcon
=
0
;
clsW
.
hCursor
=
LoadCursorA
(
0
,
(
LPCSTR
)
IDC_ARROW
);
clsW
.
hbrBackground
=
GetStockObject
(
WHITE_BRUSH
);
clsW
.
lpszMenuName
=
NULL
;
clsW
.
lpszClassName
=
mainclassW
;
if
(
!
RegisterClassW
(
&
clsW
))
return
FALSE
;
cls
.
style
=
0
;
cls
.
lpfnWndProc
=
tool_window_procA
;
cls
.
cbClsExtra
=
0
;
...
...
@@ -5726,11 +5778,12 @@ static DWORD CALLBACK settext_msg_thread( LPVOID arg )
static
void
test_gettext
(
void
)
{
DWORD
tid
,
num_msgs
;
WCHAR
bufW
[
32
];
HANDLE
thread
;
BOOL
success
;
char
buf
[
32
];
INT
buf_len
;
HWND
hwnd
;
HWND
hwnd
,
hwnd2
;
LRESULT
r
;
MSG
msg
;
...
...
@@ -5745,6 +5798,74 @@ static void test_gettext(void)
ok
(
!
strcmp
(
buf
,
"caption"
),
"got wrong window text '%s'
\n
"
,
buf
);
ok
(
num_gettext_msgs
==
1
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
/* other process window */
strcpy
(
buf
,
"a"
);
buf_len
=
GetWindowTextA
(
GetDesktopWindow
(),
buf
,
sizeof
(
buf
)
);
ok
(
buf_len
==
0
,
"expected a nonempty window text
\n
"
);
ok
(
*
buf
==
0
,
"got wrong window text '%s'
\n
"
,
buf
);
strcpy
(
buf
,
"blah"
);
buf_len
=
GetWindowTextA
(
GetDesktopWindow
(),
buf
,
0
);
ok
(
buf_len
==
0
,
"expected a nonempty window text
\n
"
);
ok
(
!
strcmp
(
buf
,
"blah"
),
"got wrong window text '%s'
\n
"
,
buf
);
bufW
[
0
]
=
0xcc
;
buf_len
=
GetWindowTextW
(
GetDesktopWindow
(),
bufW
,
0
);
ok
(
buf_len
==
0
,
"expected a nonempty window text
\n
"
);
ok
(
bufW
[
0
]
==
0xcc
,
"got %x
\n
"
,
bufW
[
0
]
);
g_wm_gettext_override
.
enabled
=
TRUE
;
num_gettext_msgs
=
0
;
memset
(
buf
,
0xcc
,
sizeof
(
buf
)
);
g_wm_gettext_override
.
buff
=
buf
;
g_wm_gettext_override
.
len
=
sizeof
(
buf
);
buf_len
=
GetWindowTextA
(
hwnd
,
buf
,
sizeof
(
buf
)
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
*
buf
==
0
,
"got %x
\n
"
,
*
buf
);
ok
(
num_gettext_msgs
==
1
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
num_gettext_msgs
=
0
;
strcpy
(
buf
,
"blah"
);
g_wm_gettext_override
.
buff
=
buf
;
g_wm_gettext_override
.
len
=
0
;
buf_len
=
GetWindowTextA
(
hwnd
,
buf
,
0
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
!
strcmp
(
buf
,
"blah"
),
"got %s
\n
"
,
buf
);
todo_wine
ok
(
num_gettext_msgs
==
0
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
g_wm_gettext_override
.
enabled
=
FALSE
;
/* same for W window */
hwnd2
=
CreateWindowExW
(
0
,
mainclassW
,
NULL
,
WS_POPUP
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
NULL
);
ok
(
hwnd2
!=
0
,
"CreateWindowExA error %d
\n
"
,
GetLastError
()
);
g_wm_gettext_override
.
enabled
=
TRUE
;
num_gettext_msgs
=
0
;
memset
(
bufW
,
0xcc
,
sizeof
(
bufW
)
);
g_wm_gettext_override
.
buffW
=
bufW
;
g_wm_gettext_override
.
len
=
sizeof
(
bufW
)
/
sizeof
(
WCHAR
);
buf_len
=
GetWindowTextW
(
hwnd2
,
bufW
,
sizeof
(
bufW
)
/
sizeof
(
WCHAR
)
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
*
bufW
==
0
,
"got %x
\n
"
,
*
bufW
);
ok
(
num_gettext_msgs
==
1
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
num_gettext_msgs
=
0
;
memset
(
bufW
,
0xcc
,
sizeof
(
bufW
)
);
g_wm_gettext_override
.
buffW
=
bufW
;
g_wm_gettext_override
.
len
=
0
;
buf_len
=
GetWindowTextW
(
hwnd2
,
bufW
,
0
);
ok
(
buf_len
==
0
,
"got %d
\n
"
,
buf_len
);
ok
(
*
bufW
==
0xcccc
,
"got %x
\n
"
,
*
bufW
);
todo_wine
ok
(
num_gettext_msgs
==
0
,
"got %u WM_GETTEXT messages
\n
"
,
num_gettext_msgs
);
g_wm_gettext_override
.
enabled
=
FALSE
;
DestroyWindow
(
hwnd2
);
/* test WM_GETTEXT */
num_gettext_msgs
=
0
;
memset
(
buf
,
0
,
sizeof
(
buf
)
);
...
...
dlls/user32/win.c
View file @
ee72b0fd
...
...
@@ -2679,7 +2679,11 @@ INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount )
if
(
!
lpString
)
return
0
;
if
(
WIN_IsCurrentProcess
(
hwnd
))
{
if
(
nMaxCount
>
0
)
lpString
[
0
]
=
0
;
return
(
INT
)
SendMessageA
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
}
/* when window belongs to other process, don't send a message */
if
(
nMaxCount
<=
0
)
return
0
;
...
...
@@ -2724,7 +2728,11 @@ INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount )
if
(
!
lpString
)
return
0
;
if
(
WIN_IsCurrentProcess
(
hwnd
))
{
if
(
nMaxCount
>
0
)
lpString
[
0
]
=
0
;
return
(
INT
)
SendMessageW
(
hwnd
,
WM_GETTEXT
,
nMaxCount
,
(
LPARAM
)
lpString
);
}
/* when window belongs to other process, don't send a message */
if
(
nMaxCount
<=
0
)
return
0
;
...
...
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