user32: Fix WM_DEVICECHANGE handling.

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>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Arkadiusz Hiler 2020-11-25 17:04:14 +02:00 committed by Alexandre Julliard
parent 44e2a14af1
commit b4abe3889f
1 changed files with 2 additions and 1 deletions

View File

@ -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: