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
f8719181
Commit
f8719181
authored
Feb 15, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Fix GetKeyNameText returned length.
parent
73cdf653
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
14 deletions
+61
-14
input.c
dlls/user32/input.c
+4
-1
input.c
dlls/user32/tests/input.c
+41
-0
keyboard.c
dlls/winex11.drv/keyboard.c
+16
-13
No files found.
dlls/user32/input.c
View file @
f8719181
...
...
@@ -823,7 +823,7 @@ INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
WCHAR
buf
[
256
];
INT
ret
;
if
(
!
GetKeyNameTextW
(
lParam
,
buf
,
256
))
if
(
!
nSize
||
!
GetKeyNameTextW
(
lParam
,
buf
,
256
))
{
lpBuffer
[
0
]
=
0
;
return
0
;
...
...
@@ -834,6 +834,8 @@ INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
ret
=
nSize
-
1
;
lpBuffer
[
ret
]
=
0
;
}
else
ret
--
;
return
ret
;
}
...
...
@@ -842,6 +844,7 @@ INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
*/
INT
WINAPI
GetKeyNameTextW
(
LONG
lParam
,
LPWSTR
lpBuffer
,
INT
nSize
)
{
if
(
!
lpBuffer
||
!
nSize
)
return
0
;
return
USER_Driver
->
pGetKeyNameText
(
lParam
,
lpBuffer
,
nSize
);
}
...
...
dlls/user32/tests/input.c
View file @
f8719181
...
...
@@ -1603,6 +1603,46 @@ static void test_keyboard_layout_name(void)
ok
(
!
strcmp
(
klid
,
"00000409"
),
"expected 00000409, got %s
\n
"
,
klid
);
}
static
void
test_key_names
(
void
)
{
char
buffer
[
40
];
WCHAR
bufferW
[
40
];
int
ret
,
prev
;
LONG
lparam
=
0x1d
<<
16
;
memset
(
buffer
,
0xcc
,
sizeof
(
buffer
)
);
ret
=
GetKeyNameTextA
(
lparam
,
buffer
,
sizeof
(
buffer
)
);
ok
(
ret
>
0
,
"wrong len %u for '%s'
\n
"
,
ret
,
buffer
);
ok
(
ret
==
strlen
(
buffer
),
"wrong len %u for '%s'
\n
"
,
ret
,
buffer
);
memset
(
buffer
,
0xcc
,
sizeof
(
buffer
)
);
prev
=
ret
;
ret
=
GetKeyNameTextA
(
lparam
,
buffer
,
prev
);
ok
(
ret
==
prev
-
1
,
"wrong len %u for '%s'
\n
"
,
ret
,
buffer
);
ok
(
ret
==
strlen
(
buffer
),
"wrong len %u for '%s'
\n
"
,
ret
,
buffer
);
memset
(
buffer
,
0xcc
,
sizeof
(
buffer
)
);
ret
=
GetKeyNameTextA
(
lparam
,
buffer
,
0
);
ok
(
ret
==
0
,
"wrong len %u for '%s'
\n
"
,
ret
,
buffer
);
ok
(
buffer
[
0
]
==
0
,
"wrong string '%s'
\n
"
,
buffer
);
memset
(
bufferW
,
0xcc
,
sizeof
(
bufferW
)
);
ret
=
GetKeyNameTextW
(
lparam
,
bufferW
,
sizeof
(
bufferW
)
/
sizeof
(
WCHAR
)
);
ok
(
ret
>
0
,
"wrong len %u for %s
\n
"
,
ret
,
wine_dbgstr_w
(
bufferW
)
);
ok
(
ret
==
lstrlenW
(
bufferW
),
"wrong len %u for %s
\n
"
,
ret
,
wine_dbgstr_w
(
bufferW
)
);
memset
(
bufferW
,
0xcc
,
sizeof
(
bufferW
)
);
prev
=
ret
;
ret
=
GetKeyNameTextW
(
lparam
,
bufferW
,
prev
);
ok
(
ret
==
prev
-
1
,
"wrong len %u for %s
\n
"
,
ret
,
wine_dbgstr_w
(
bufferW
)
);
ok
(
ret
==
lstrlenW
(
bufferW
),
"wrong len %u for %s
\n
"
,
ret
,
wine_dbgstr_w
(
bufferW
)
);
memset
(
bufferW
,
0xcc
,
sizeof
(
bufferW
)
);
ret
=
GetKeyNameTextW
(
lparam
,
bufferW
,
0
);
ok
(
ret
==
0
,
"wrong len %u for %s
\n
"
,
ret
,
wine_dbgstr_w
(
bufferW
)
);
ok
(
bufferW
[
0
]
==
0xcccc
,
"wrong string %s
\n
"
,
wine_dbgstr_w
(
bufferW
)
);
}
START_TEST
(
input
)
{
init_function_pointers
();
...
...
@@ -1621,6 +1661,7 @@ START_TEST(input)
test_ToUnicode
();
test_get_async_key_state
();
test_keyboard_layout_name
();
test_key_names
();
if
(
pGetMouseMovePointsEx
)
test_GetMouseMovePointsEx
();
...
...
dlls/winex11.drv/keyboard.c
View file @
f8719181
...
...
@@ -2291,7 +2291,7 @@ INT CDECL X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize)
(
scanCode
!=
0x4a
)
&&
/* numpad - */
(
scanCode
!=
0x4e
)
)
/* numpad + */
{
if
(
(
nSize
>=
2
)
&&
lpBuffer
)
if
(
nSize
>=
2
)
{
*
lpBuffer
=
toupperW
((
WCHAR
)
ansi
);
*
(
lpBuffer
+
1
)
=
0
;
...
...
@@ -2318,6 +2318,8 @@ INT CDECL X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize)
break
;
if
(
keyi
<=
max_keycode
)
{
INT
rc
;
wine_tsx11_lock
();
keyc
=
(
KeyCode
)
keyi
;
keys
=
keycode_to_keysym
(
display
,
keyc
,
0
);
...
...
@@ -2329,29 +2331,30 @@ INT CDECL X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize)
char
*
idx
=
strrchr
(
name
,
'_'
);
if
(
idx
&&
(
strcasecmp
(
idx
,
"_r"
)
==
0
||
strcasecmp
(
idx
,
"_l"
)
==
0
))
{
INT
rc
=
0
;
TRACE
(
"found scan=%04x keyc=%u keysym=%lx modified_string=%s
\n
"
,
scanCode
,
keyc
,
keys
,
debugstr_an
(
name
,
idx
-
name
));
if
(
lpBuffer
&&
nSize
)
{
rc
=
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
name
,
idx
-
name
+
1
,
lpBuffer
,
nSize
);
if
(
rc
>
0
)
lpBuffer
[
rc
-
1
]
=
0
;
}
rc
=
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
name
,
idx
-
name
+
1
,
lpBuffer
,
nSize
);
if
(
!
rc
)
rc
=
nSize
;
lpBuffer
[
--
rc
]
=
0
;
return
rc
;
}
}
TRACE
(
"found scan=%04x keyc=%u keysym=%04x string=%s
\n
"
,
scanCode
,
keyc
,
(
int
)
keys
,
debugstr_a
(
name
));
if
(
lpBuffer
&&
nSize
&&
name
)
return
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
name
,
-
1
,
lpBuffer
,
nSize
);
if
(
name
)
{
TRACE
(
"found scan=%04x keyc=%u keysym=%04x vkey=%04x string=%s
\n
"
,
scanCode
,
keyc
,
(
int
)
keys
,
vkey
,
debugstr_a
(
name
));
rc
=
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
name
,
-
1
,
lpBuffer
,
nSize
);
if
(
!
rc
)
rc
=
nSize
;
lpBuffer
[
--
rc
]
=
0
;
return
rc
;
}
}
/* Finally issue WARN for unknown keys */
WARN
(
"(%08x,%p,%d): unsupported key, vkey=%04X, ansi=%04x
\n
"
,
lParam
,
lpBuffer
,
nSize
,
vkey
,
ansi
);
if
(
lpBuffer
&&
nSize
)
*
lpBuffer
=
0
;
*
lpBuffer
=
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