WM_DEVICECHANGE's lParam can be either a pointer to a variant of DEV_BROADCAST_HDR or an immediate value (usually 0) depending on the wParam's value.
This fixes a crash when broadcasting WM_DEVICECHANGE with wParam = DBT_DEVNODES_CHANGED, lParam = 0.
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/user32/message.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/message.c b/dlls/user32/message.c index d8ebbfd32e3..f7ce262f90d 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -1023,7 +1023,7 @@ static size_t pack_message( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara case WM_DEVICECHANGE: { DEV_BROADCAST_HDR *header = (DEV_BROADCAST_HDR *)lparam; - push_data( data, header, header->dbch_size ); + if ((wparam & 0x8000) && header) push_data( data, header, header->dbch_size ); return 0; } case WM_WINE_KEYBOARD_LL_HOOK: @@ -1426,6 +1426,7 @@ static BOOL unpack_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lpa if (!get_buffer_space( buffer, sizeof(BOOL) )) return FALSE; break; case WM_DEVICECHANGE: + if (!(*wparam & 0x8000)) return TRUE; minsize = sizeof(DEV_BROADCAST_HDR); break; case WM_WINE_KEYBOARD_LL_HOOK:
Windows sends *a lot* of those messages whenever there's a device / drive / etc. appearing or disappearing.
This fixes controller hotplug in Doom (2016).
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- programs/plugplay/main.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/programs/plugplay/main.c b/programs/plugplay/main.c index 2c4054de3e4..19e02286312 100644 --- a/programs/plugplay/main.c +++ b/programs/plugplay/main.c @@ -19,6 +19,7 @@ #define WIN32_LEAN_AND_MEAN
#include <windows.h> +#include <dbt.h> #include "winsvc.h" #include "wine/debug.h" #include "wine/list.h" @@ -142,6 +143,7 @@ void __cdecl plugplay_send_event( DWORD code, const BYTE *data, unsigned int siz struct event *event;
BroadcastSystemMessageW( BSF_FORCEIFHUNG | BSF_QUERY, NULL, WM_DEVICECHANGE, code, (LPARAM)data ); + BroadcastSystemMessageW( BSF_FORCEIFHUNG | BSF_QUERY, NULL, WM_DEVICECHANGE, DBT_DEVNODES_CHANGED, 0 );
EnterCriticalSection( &plugplay_cs );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=82429
Your paranoid android.
=== debiant (32 bit report) ===
user32: monitor: Timeout win.c:10147: Test failed: GetActiveWindow() = 00000000 win.c:10147: Test failed: GetFocus() = 00000000 win.c:10149: Test failed: Expected foreground window 001B0140, got 00E10102 win.c:10152: Test failed: Received WM_ACTIVATEAPP(0), did not expect it. win.c:10159: Test failed: Expected foreground window 001B0140, got 00000000 win.c:10161: Test failed: GetActiveWindow() = 00000000 win.c:10161: Test failed: GetFocus() = 00000000 win.c:10169: Test failed: Received WM_ACTIVATEAPP(1), did not expect it.
=== debiant (32 bit WoW report) ===
user32: monitor: Timeout
=== debiant (64 bit WoW report) ===
user32: clipboard.c:760: Test failed: 2: gle 5 clipboard.c:765: Test failed: 2.0: got 0000 instead of 000d clipboard.c:805: Test failed: 2: gle 1418 clipboard.c:815: Test failed: 2: count 4 clipboard.c:818: Test failed: 2: gle 1418 clipboard.c:853: Test failed: 2.0: formats 00000000 have been rendered clipboard.c:858: Test failed: 2.0: formats 00000000 have been rendered clipboard.c:853: Test failed: 2.2: formats 00000000 have been rendered clipboard.c:858: Test failed: 2.2: formats 00000000 have been rendered clipboard.c:853: Test failed: 2.3: formats 00000000 have been rendered clipboard.c:858: Test failed: 2.3: formats 00000000 have been rendered monitor: Timeout
On Wed, Nov 25, 2020 at 09:42:37AM -0600, Marvin wrote:
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=82429
Your paranoid android.
=== debiant (32 bit report) ===
user32: monitor: Timeout win.c:10147: Test failed: GetActiveWindow() = 00000000 win.c:10147: Test failed: GetFocus() = 00000000 win.c:10149: Test failed: Expected foreground window 001B0140, got 00E10102 win.c:10152: Test failed: Received WM_ACTIVATEAPP(0), did not expect it. win.c:10159: Test failed: Expected foreground window 001B0140, got 00000000 win.c:10161: Test failed: GetActiveWindow() = 00000000 win.c:10161: Test failed: GetFocus() = 00000000 win.c:10169: Test failed: Received WM_ACTIVATEAPP(1), did not expect it.
=== debiant (32 bit WoW report) ===
user32: monitor: Timeout
=== debiant (64 bit WoW report) ===
user32: clipboard.c:760: Test failed: 2: gle 5 clipboard.c:765: Test failed: 2.0: got 0000 instead of 000d clipboard.c:805: Test failed: 2: gle 1418 clipboard.c:815: Test failed: 2: count 4 clipboard.c:818: Test failed: 2: gle 1418 clipboard.c:853: Test failed: 2.0: formats 00000000 have been rendered clipboard.c:858: Test failed: 2.0: formats 00000000 have been rendered clipboard.c:853: Test failed: 2.2: formats 00000000 have been rendered clipboard.c:858: Test failed: 2.2: formats 00000000 have been rendered clipboard.c:853: Test failed: 2.3: formats 00000000 have been rendered clipboard.c:858: Test failed: 2.3: formats 00000000 have been rendered monitor: Timeout
Just in case someone wonders - both those and 1/2 results are false negatives that are quite usual for user32 changes as far as I have noticed.
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=82428
Your paranoid android.
=== debiant (32 bit report) ===
user32: monitor: Timeout
=== debiant (32 bit WoW report) ===
user32: monitor: Timeout
=== debiant (64 bit WoW report) ===
user32: monitor: Timeout