Rémi Bernon : xinput1_3: Wait for CancelIoEx completion when disabling controllers.

Alexandre Julliard julliard at winehq.org
Fri Oct 8 14:12:26 CDT 2021


Module: wine
Branch: master
Commit: 54db76104085b4edba11f0f1f255547005f9667a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=54db76104085b4edba11f0f1f255547005f9667a

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Oct  8 13:02:22 2021 +0200

xinput1_3: Wait for CancelIoEx completion when disabling controllers.

Otherwise we may later write the cancelled status to invalid memory.

Also use a manual-reset event, as it should be for overlapped I/O, so
all waiters are waken up on cancel.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/xinput1_3/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dlls/xinput1_3/main.c b/dlls/xinput1_3/main.c
index 81d11e5d38f..1f9d4881751 100644
--- a/dlls/xinput1_3/main.c
+++ b/dlls/xinput1_3/main.c
@@ -354,6 +354,7 @@ static void controller_disable(struct xinput_controller *controller)
     controller->enabled = FALSE;
 
     CancelIoEx(controller->device, &controller->hid.read_ovl);
+    WaitForSingleObject(controller->hid.read_ovl.hEvent, INFINITE);
     SetEvent(update_event);
 }
 
@@ -365,7 +366,7 @@ static BOOL controller_init(struct xinput_controller *controller, PHIDP_PREPARSE
     controller->hid.caps = *caps;
     if (!(controller->hid.feature_report_buf = calloc(1, controller->hid.caps.FeatureReportByteLength))) goto failed;
     if (!controller_check_caps(controller, device, preparsed)) goto failed;
-    if (!(event = CreateEventA(NULL, FALSE, FALSE, NULL))) goto failed;
+    if (!(event = CreateEventW(NULL, TRUE, FALSE, NULL))) goto failed;
 
     TRACE("Found gamepad %s\n", debugstr_w(device_path));
 




More information about the wine-cvs mailing list