From b9d6c5869d3a0cf4f0db3c0e0c1928cee6c5fdaf Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sun, 19 Apr 2020 18:40:59 -0500 Subject: [PATCH] [Win32SS] Fix Send and Post Parameters for WM_DEVICECHANGE For CORE-16492. See CORE-7447. See https://source.winehq.org/git/wine.git/commitdiff/43197e6641591c4b2955f086df7e880fbdb2d7ae --- win32ss/user/ntuser/message.c | 31 ++++++++++++++++++++------- win32ss/user/user32/windows/message.c | 17 ++++++++------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/win32ss/user/ntuser/message.c b/win32ss/user/ntuser/message.c index 5c6a3fc66a4..79d68a184ea 100644 --- a/win32ss/user/ntuser/message.c +++ b/win32ss/user/ntuser/message.c @@ -96,10 +96,11 @@ static const unsigned int message_pointer_flags[] = }; /* check whether a given message type includes pointers */ -static inline int is_pointer_message( UINT message ) +static inline int is_pointer_message( UINT message, WPARAM wparam ) { if (message >= 8*sizeof(message_pointer_flags)) return FALSE; - return (message_pointer_flags[message / 32] & SET(message)) != 0; + if (message == WM_DEVICECHANGE && !(wparam & 0x8000)) return FALSE; + return (message_pointer_flags[message / 32] & SET(message)) != 0; } #undef SET @@ -139,6 +140,7 @@ static MSGMEMORY g_MsgMemory[] = { WM_DRAWITEM, sizeof(DRAWITEMSTRUCT), MMS_FLAG_READWRITE }, { WM_HELP, sizeof(HELPINFO), MMS_FLAG_READWRITE }, { WM_NEXTMENU, sizeof(MDINEXTMENU), MMS_FLAG_READWRITE }, + { WM_DEVICECHANGE, MMS_SIZE_SPECIAL, MMS_FLAG_READ }, }; static PMSGMEMORY FASTCALL @@ -220,6 +222,16 @@ MsgMemorySize(PMSGMEMORY MsgMemoryEntry, WPARAM wParam, LPARAM lParam) } break; + case WM_DEVICECHANGE: + { + if ( lParam && (wParam & 0x8000) ) + { + DEV_BROADCAST_HDR *header = (DEV_BROADCAST_HDR *)lParam; + Size = header->dbch_size; + } + } + break; + default: ASSERT(FALSE); Size = 0; @@ -1219,8 +1231,11 @@ co_IntGetPeekMessage( PMSG pMsg, bGMSG ); if (Present) { - /* GetMessage or PostMessage must never get messages that contain pointers */ - ASSERT(FindMsgMemory(pMsg->message) == NULL); + if ( pMsg->message != WM_DEVICECHANGE || (pMsg->wParam & 0x8000) ) + { + /* GetMessage or PostMessage must never get messages that contain pointers */ + ASSERT(FindMsgMemory(pMsg->message) == NULL); + } if ( pMsg->message >= WM_DDE_FIRST && pMsg->message <= WM_DDE_LAST ) { @@ -1298,7 +1313,7 @@ UserPostThreadMessage( PTHREADINFO pti, { MSG Message; - if (is_pointer_message(Msg)) + if (is_pointer_message(Msg, wParam)) { EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -1344,7 +1359,7 @@ UserPostMessage( HWND Wnd, Message.pt = gpsi->ptCursor; Message.time = EngGetTickCount32(); - if (is_pointer_message(Message.message)) + if (is_pointer_message(Message.message, Message.wParam)) { EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -2026,7 +2041,7 @@ UserSendNotifyMessage( HWND hWnd, { BOOL Ret = TRUE; - if (is_pointer_message(Msg)) + if (is_pointer_message(Msg, wParam)) { EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -2860,7 +2875,7 @@ NtUserMessageCall( HWND hWnd, } _SEH2_END; - if (is_pointer_message(Msg)) + if (is_pointer_message(Msg, wParam)) { EngSetLastError(ERROR_MESSAGE_SYNC_ONLY ); break; diff --git a/win32ss/user/user32/windows/message.c b/win32ss/user/user32/windows/message.c index 2f94caa5f2c..607ae7dda9b 100644 --- a/win32ss/user/user32/windows/message.c +++ b/win32ss/user/user32/windows/message.c @@ -95,10 +95,11 @@ static const unsigned int message_pointer_flags[] = }; /* check whether a given message type includes pointers */ -static inline int is_pointer_message( UINT message ) +static inline int is_pointer_message( UINT message, WPARAM wparam ) { if (message >= 8*sizeof(message_pointer_flags)) return FALSE; - return (message_pointer_flags[message / 32] & SET(message)) != 0; + if (message == WM_DEVICECHANGE && !(wparam & 0x8000)) return FALSE; + return (message_pointer_flags[message / 32] & SET(message)) != 0; } #undef SET @@ -1917,7 +1918,7 @@ DispatchMessageA(CONST MSG *lpmsg) else Wnd = NULL; - if (is_pointer_message(lpmsg->message)) + if (is_pointer_message(lpmsg->message, lpmsg->wParam)) { SetLastError( ERROR_MESSAGE_SYNC_ONLY ); return 0; @@ -2006,7 +2007,7 @@ DispatchMessageW(CONST MSG *lpmsg) else Wnd = NULL; - if (is_pointer_message(lpmsg->message)) + if (is_pointer_message(lpmsg->message, lpmsg->wParam)) { SetLastError( ERROR_MESSAGE_SYNC_ONLY ); return 0; @@ -2529,7 +2530,7 @@ SendMessageCallbackA( MSG AnsiMsg, UcMsg; CALL_BACK_INFO CallBackInfo; - if (is_pointer_message(Msg)) + if (is_pointer_message(Msg, wParam)) { SetLastError( ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -2579,7 +2580,7 @@ SendMessageCallbackW( { CALL_BACK_INFO CallBackInfo; - if (is_pointer_message(Msg)) + if (is_pointer_message(Msg, wParam)) { SetLastError( ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -2742,7 +2743,7 @@ SendNotifyMessageA( BOOL Ret; MSG AnsiMsg, UcMsg; - if (is_pointer_message(Msg)) + if (is_pointer_message(Msg, wParam)) { SetLastError( ERROR_MESSAGE_SYNC_ONLY ); return FALSE; @@ -2779,7 +2780,7 @@ SendNotifyMessageW( { LRESULT Result; - if (is_pointer_message(Msg)) + if (is_pointer_message(Msg, wParam)) { SetLastError( ERROR_MESSAGE_SYNC_ONLY ); return FALSE;