[Win32SS] Fix Send and Post Parameters for WM_DEVICECHANGE

For CORE-16492. See CORE-7447.

See 43197e6641
This commit is contained in:
James Tabor 2020-04-19 18:40:59 -05:00
parent 435d2b5652
commit b9d6c5869d
2 changed files with 32 additions and 16 deletions

View file

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

View file

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