From 8b65b1c1c8c40c27455a259fe421024571ba62c8 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 2 Oct 2015 01:20:46 +0200 Subject: [PATCH] Added patch to avoid waiting for hook thread startup in IDirectInput8::Initialize. --- README.md | 3 +- debian/changelog | 2 + ...it-for-hook-thread-startup-in-IDirec.patch | 82 +++++++++++++++++++ patches/dinput-Initialize/definition | 1 + patches/patchinstall.sh | 19 +++++ 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 patches/dinput-Initialize/0001-dinput-Do-not-wait-for-hook-thread-startup-in-IDirec.patch create mode 100644 patches/dinput-Initialize/definition diff --git a/README.md b/README.md index 50b455bb..92f33e46 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,13 @@ Wine. All those differences are also documented on the Included bug fixes and improvements ----------------------------------- -**Bug fixes and features included in the next upcoming release [11]:** +**Bug fixes and features included in the next upcoming release [12]:** * Add implementation for msidb commandline tool * Codepage conversion should fail when destination length is < 0 * Do not trust width/height passed to edit control in WM_SIZE message ([Wine Bug #37542](https://bugs.winehq.org/show_bug.cgi?id=37542)) * Do not use GdipAlloc and GdipFree in internal functions ([Wine Bug #32786](https://bugs.winehq.org/show_bug.cgi?id=32786)) +* Do not wait for hook thread startup in IDirectInput8::Initialize ([Wine Bug #21403](https://bugs.winehq.org/show_bug.cgi?id=21403)) * Fix calculation of listbox size when horizontal scrollbar is present ([Wine Bug #38142](https://bugs.winehq.org/show_bug.cgi?id=38142)) * Implement additional stub functions in authz.dll * Implement semi-stub for d3d8 swapchain effect D3DSWAPEFFECT_COPY_VSYNC ([Wine Bug #39281](https://bugs.winehq.org/show_bug.cgi?id=39281)) diff --git a/debian/changelog b/debian/changelog index 155efca6..c26614df 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ wine-staging (1.7.52) UNRELEASED; urgency=low * Added patch to avoid using GdipAlloc and GdipFree in internal gdiplus functions. * Added patch to implement additional stub functions in authz.dll. + * Added patch to avoid waiting for hook thread startup in + IDirectInput8::Initialize. * Removed patch to fix possible memory leak in netprofm init_networks (fixed upstream). * Removed patch for stub of dwmapi.DwmUpdateThumbnailProperties (accepted diff --git a/patches/dinput-Initialize/0001-dinput-Do-not-wait-for-hook-thread-startup-in-IDirec.patch b/patches/dinput-Initialize/0001-dinput-Do-not-wait-for-hook-thread-startup-in-IDirec.patch new file mode 100644 index 00000000..aa28c022 --- /dev/null +++ b/patches/dinput-Initialize/0001-dinput-Do-not-wait-for-hook-thread-startup-in-IDirec.patch @@ -0,0 +1,82 @@ +From 62a15b6751bab986915164ce9792c662820022b6 Mon Sep 17 00:00:00 2001 +From: Sebastian Lackner +Date: Fri, 2 Oct 2015 01:11:54 +0200 +Subject: dinput: Do not wait for hook thread startup in + IDirectInput8::Initialize. + +--- + dlls/dinput/dinput_main.c | 31 ++++++++++++++++++------------- + 1 file changed, 18 insertions(+), 13 deletions(-) + +diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c +index 18840b2..49ad447 100644 +--- a/dlls/dinput/dinput_main.c ++++ b/dlls/dinput/dinput_main.c +@@ -1483,7 +1483,7 @@ static DWORD WINAPI hook_thread_proc(void *param) + + /* Force creation of the message queue */ + PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ); +- SetEvent(*(LPHANDLE)param); ++ SetEvent(param); + + while (GetMessageW( &msg, 0, 0, 0 )) + { +@@ -1551,6 +1551,7 @@ static DWORD WINAPI hook_thread_proc(void *param) + } + + static DWORD hook_thread_id; ++static HANDLE hook_thread_event; + + static CRITICAL_SECTION_DEBUG dinput_critsect_debug = + { +@@ -1569,24 +1570,21 @@ static BOOL check_hook_thread(void) + TRACE("IDirectInputs left: %d\n", list_count(&direct_input_list)); + if (!list_empty(&direct_input_list) && !hook_thread) + { +- HANDLE event; +- +- event = CreateEventW(NULL, FALSE, FALSE, NULL); +- hook_thread = CreateThread(NULL, 0, hook_thread_proc, &event, 0, &hook_thread_id); +- if (event && hook_thread) +- { +- HANDLE handles[2]; +- handles[0] = event; +- handles[1] = hook_thread; +- WaitForMultipleObjects(2, handles, FALSE, INFINITE); +- } ++ hook_thread_event = CreateEventW(NULL, FALSE, FALSE, NULL); ++ hook_thread = CreateThread(NULL, 0, hook_thread_proc, hook_thread_event, 0, &hook_thread_id); + LeaveCriticalSection(&dinput_hook_crit); +- CloseHandle(event); + } + else if (list_empty(&direct_input_list) && hook_thread) + { + DWORD tid = hook_thread_id; + ++ if (hook_thread_event) /* if thread is not started yet */ ++ { ++ WaitForSingleObject(hook_thread_event, INFINITE); ++ CloseHandle(hook_thread_event); ++ hook_thread_event = NULL; ++ } ++ + hook_thread_id = 0; + PostThreadMessageW(tid, WM_USER+0x10, 0, 0); + LeaveCriticalSection(&dinput_hook_crit); +@@ -1627,6 +1625,13 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface) + callwndproc_hook = NULL; + } + ++ if (hook_thread_event) /* if thread is not started yet */ ++ { ++ WaitForSingleObject(hook_thread_event, INFINITE); ++ CloseHandle(hook_thread_event); ++ hook_thread_event = NULL; ++ } ++ + PostThreadMessageW( hook_thread_id, WM_USER+0x10, 1, 0 ); + + LeaveCriticalSection(&dinput_hook_crit); +-- +2.5.1 + diff --git a/patches/dinput-Initialize/definition b/patches/dinput-Initialize/definition new file mode 100644 index 00000000..d5b082ce --- /dev/null +++ b/patches/dinput-Initialize/definition @@ -0,0 +1 @@ +Fixes: [21403] Do not wait for hook thread startup in IDirectInput8::Initialize diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index e0808d45..528f4536 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -128,6 +128,7 @@ patch_enable_all () enable_ddraw_ZBufferBitDepths="$1" enable_ddraw_d3d_execute_buffer="$1" enable_dinput_Events="$1" + enable_dinput_Initialize="$1" enable_dsound_EAX="$1" enable_dsound_Fast_Mixer="$1" enable_dxdiagn_Enumerate_DirectSound="$1" @@ -483,6 +484,9 @@ patch_enable () dinput-Events) enable_dinput_Events="$2" ;; + dinput-Initialize) + enable_dinput_Initialize="$2" + ;; dsound-EAX) enable_dsound_EAX="$2" ;; @@ -2904,6 +2908,21 @@ if test "$enable_dinput_Events" -eq 1; then ) >> "$patchlist" fi +# Patchset dinput-Initialize +# | +# | This patchset fixes the following Wine bugs: +# | * [#21403] Do not wait for hook thread startup in IDirectInput8::Initialize +# | +# | Modified files: +# | * dlls/dinput/dinput_main.c +# | +if test "$enable_dinput_Initialize" -eq 1; then + patch_apply dinput-Initialize/0001-dinput-Do-not-wait-for-hook-thread-startup-in-IDirec.patch + ( + echo '+ { "Sebastian Lackner", "dinput: Do not wait for hook thread startup in IDirectInput8::Initialize.", 1 },'; + ) >> "$patchlist" +fi + # Patchset dsound-Fast_Mixer # | # | This patchset fixes the following Wine bugs: