dinput8/tests: Add valid wide string termination to actionName member. (v2)
Bernhard Übelacker
bernhardu at mailbox.org
Thu Aug 4 17:50:51 CDT 2016
https://bugs.winehq.org/show_bug.cgi?id=40384
https://www.winehq.org/pipermail/wine-devel/2016-July/114054.html
DirectX SDK offers the possibility to increase debug
output via "DirectX Control Panel".
This prints this error:
DINPUT8: ERROR IDirectInput8::EnumDevicesBySemantics: arg 2: invalid UNICODE string
It looks like ansi version of EnumDevicesBySemantics forwards the string to
the wide variant without conversation.
So the assumption is that with the old compiler version we got
enough valid wide string termination between the ansi string actionName
member and the next invalid memory page.
v1:
https://www.winehq.org/pipermail/wine-patches/2016-August/153002.html
https://www.winehq.org/pipermail/wine-devel/2016-August/114185.html
Changes since v1:
- Remove the ugly test with PAGE_NOACCESS and leave just the fix with a comment.
Signed-off-by: Bernhard Übelacker <bernhardu at mailbox.org>
---
dlls/dinput8/tests/device.c | 15 ++++++++++-----
dlls/dinput8/tests/dinput.c | 15 ++++++++++-----
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c
index fc415b7..6753b73 100644
--- a/dlls/dinput8/tests/device.c
+++ b/dlls/dinput8/tests/device.c
@@ -49,16 +49,21 @@ enum {
static DIACTIONA actionMapping[]=
{
/* axis */
- { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */ , 0, { "Steer" } },
+ { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */, 0, { "Steer.\0" } },
/* button */
- { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */ , 0, { "Upshift" } },
+ { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */, 0, { "Upshift.\0" } },
/* keyboard key */
- { 2, DIKEYBOARD_SPACE , 0, { "Missile" } },
+ { 2, DIKEYBOARD_SPACE, 0, { "Missile.\0" } },
/* mouse button */
- { 3, DIMOUSE_BUTTON0, 0, { "Select" } },
+ { 3, DIMOUSE_BUTTON0, 0, { "Select\0" } },
/* mouse axis */
- { 4, DIMOUSE_YAXIS, 0, { "Y Axis" } }
+ { 4, DIMOUSE_YAXIS, 0, { "Y Axis\0" } }
};
+/* By placing the memory pointed to by lptszActionName right before memory with PAGE_NOACCESS
+ * one can find out that the regular ansi string termination is not respected by EnumDevicesBySemantics.
+ * Adding a double termination, making it a valid wide string termination, made the test succeed.
+ * Therefore it looks like ansi version of EnumDevicesBySemantics forwards the string to
+ * the wide variant without conversation. */
static void flush_events(void)
{
diff --git a/dlls/dinput8/tests/dinput.c b/dlls/dinput8/tests/dinput.c
index 57f5505..c3f80c6 100644
--- a/dlls/dinput8/tests/dinput.c
+++ b/dlls/dinput8/tests/dinput.c
@@ -443,16 +443,21 @@ struct enum_semantics_test
static DIACTIONA actionMapping[]=
{
/* axis */
- { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */, 0, { "Steer" } },
+ { 0, 0x01008A01 /* DIAXIS_DRIVINGR_STEER */, 0, { "Steer.\0" } },
/* button */
- { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */, 0, { "Upshift" } },
+ { 1, 0x01000C01 /* DIBUTTON_DRIVINGR_SHIFTUP */, 0, { "Upshift.\0" } },
/* keyboard key */
- { 2, DIKEYBOARD_SPACE, 0, { "Missile" } },
+ { 2, DIKEYBOARD_SPACE, 0, { "Missile.\0" } },
/* mouse button */
- { 3, DIMOUSE_BUTTON0, 0, { "Select" } },
+ { 3, DIMOUSE_BUTTON0, 0, { "Select\0" } },
/* mouse axis */
- { 4, DIMOUSE_YAXIS, 0, { "Y Axis" } }
+ { 4, DIMOUSE_YAXIS, 0, { "Y Axis\0" } }
};
+/* By placing the memory pointed to by lptszActionName right before memory with PAGE_NOACCESS
+ * one can find out that the regular ansi string termination is not respected by EnumDevicesBySemantics.
+ * Adding a double termination, making it a valid wide string termination, made the test succeed.
+ * Therefore it looks like ansi version of EnumDevicesBySemantics forwards the string to
+ * the wide variant without conversation. */
static BOOL CALLBACK enum_semantics_callback(const DIDEVICEINSTANCEA *lpddi, IDirectInputDevice8A *lpdid, DWORD dwFlags, DWORD dwRemaining, void *context)
{
--
2.1.4
More information about the wine-patches
mailing list