From 2b61d8dd9797406519e19c8cbcb49dd30d0db4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Fri, 8 Oct 2021 15:36:00 +0200 Subject: [PATCH] dinput: Hold the HID joystick CS when updating the device state. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The read buffer is only used by the reading thread but the device state is not, we should only update it while holding the CS. Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/dinput/joystick_hid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 4449c11256c..6f9e9987e6e 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1603,6 +1603,7 @@ static HRESULT hid_joystick_read_state( IDirectInputDevice8W *iface ) } } + EnterCriticalSection( &impl->base.crit ); do { count = impl->usages_count; @@ -1638,6 +1639,7 @@ static HRESULT hid_joystick_read_state( IDirectInputDevice8W *iface ) memset( &impl->read_ovl, 0, sizeof(impl->read_ovl) ); impl->read_ovl.hEvent = impl->base.read_event; } while (ReadFile( impl->device, report_buf, report_len, &count, &impl->read_ovl )); + LeaveCriticalSection( &impl->base.crit ); return DI_OK; }