From faae08b50a7a60c45e64522187101967d8f70d7c Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 5 Apr 2008 18:05:11 +0000 Subject: [PATCH] BroadcastSystemMessage: - Implement User half only. - Introduce example use for NtUserMessageCall. - IntBroadcastSystemMessage is based on Wine LGPL implementation http://www.winehq.org/pipermail/wine-cvs/2008-April/042051.html . - Wine testing needed to be change by adding message range parameter check. The range was from 0 to -1 and check for resulting errors that conformed to XP. - Need to move BROADCASTPARM to include/X/X/ntuser.h or other after Dr. Timo finishes header realignment. svn path=/trunk/; revision=32874 --- reactos/dll/win32/user32/misc/stubs.c | 68 ----------- reactos/dll/win32/user32/windows/message.c | 133 +++++++++++++++++++++ 2 files changed, 133 insertions(+), 68 deletions(-) diff --git a/reactos/dll/win32/user32/misc/stubs.c b/reactos/dll/win32/user32/misc/stubs.c index 98ffb769640..249af40ab22 100644 --- a/reactos/dll/win32/user32/misc/stubs.c +++ b/reactos/dll/win32/user32/misc/stubs.c @@ -31,40 +31,6 @@ AttachThreadInput( } -/* - * @unimplemented - */ -long -STDCALL -BroadcastSystemMessageA( - DWORD dwFlags, - LPDWORD lpdwRecipients, - UINT uiMessage, - WPARAM wParam, - LPARAM lParam) -{ - UNIMPLEMENTED; - return 0; -} - - -/* - * @unimplemented - */ -long -STDCALL -BroadcastSystemMessageW( - DWORD dwFlags, - LPDWORD lpdwRecipients, - UINT uiMessage, - WPARAM wParam, - LPARAM lParam) -{ - UNIMPLEMENTED; - return 0; -} - - /* * @unimplemented */ @@ -352,23 +318,6 @@ GetRawInputDeviceInfoW( return FALSE; } -/* - * @unimplemented - */ -LONG -STDCALL -BroadcastSystemMessageExW( - DWORD dwflags, - LPDWORD lpdwRecipients, - UINT uiMessage, - WPARAM wParam, - LPARAM lParam, - PBSMINFO pBSMInfo) -{ - UNIMPLEMENTED; - return FALSE; -} - /* * @unimplemented */ @@ -401,23 +350,6 @@ GetRawInputDeviceInfoA( return FALSE; } -/* - * @unimplemented - */ -LONG -STDCALL -BroadcastSystemMessageExA( - DWORD dwflags, - LPDWORD lpdwRecipients, - UINT uiMessage, - WPARAM wParam, - LPARAM lParam, - PBSMINFO pBSMInfo) -{ - UNIMPLEMENTED; - return FALSE; -} - /* * @unimplemented */ diff --git a/reactos/dll/win32/user32/windows/message.c b/reactos/dll/win32/user32/windows/message.c index 4b0eea1c725..7a9bd7ada79 100644 --- a/reactos/dll/win32/user32/windows/message.c +++ b/reactos/dll/win32/user32/windows/message.c @@ -2559,3 +2559,136 @@ IsDialogMessageA( HWND hwndDlg, LPMSG pmsg ) msg.wParam = map_wparam_AtoW( msg.message, msg.wParam ); return IsDialogMessageW( hwndDlg, &msg ); } + +typedef struct _BROADCASTPARM +{ + DWORD flags; + LPDWORD recipients; +} BROADCASTPARM, *PBROADCASTPARM; + +LONG +STDCALL +IntBroadcastSystemMessage( + DWORD dwflags, + LPDWORD lpdwRecipients, + UINT uiMessage, + WPARAM wParam, + LPARAM lParam, + PBSMINFO pBSMInfo, + BOOL Ansi) +{ + BROADCASTPARM parm; + DWORD recips = BSM_ALLCOMPONENTS; + BOOL ret = TRUE; + static const DWORD all_flags = ( BSF_QUERY | BSF_IGNORECURRENTTASK | BSF_FLUSHDISK | BSF_NOHANG + | BSF_POSTMESSAGE | BSF_FORCEIFHUNG | BSF_NOTIMEOUTIFNOTHUNG + | BSF_ALLOWSFW | BSF_SENDNOTIFYMESSAGE | BSF_RETURNHDESK | BSF_LUID ); + + if (dwflags & ~all_flags) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + if(uiMessage >= WM_USER && uiMessage < 0xC000) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + if (!lpdwRecipients) + lpdwRecipients = &recips; + + if ( pBSMInfo && dwflags & BSF_QUERY ) + { + if (pBSMInfo->cbSize != sizeof(BSMINFO)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + FIXME("Not returning PBSMINFO information yet\n"); + } + + parm.flags = dwflags; + parm.recipients = lpdwRecipients; + + if (*lpdwRecipients & BSM_APPLICATIONS) + { + return NtUserMessageCall(GetDesktopWindow(), + uiMessage, + wParam, + lParam, + (ULONG_PTR)&parm, + NUMC_BROADCASTSYSTEMMESSAGE, + Ansi); + } + else + { + FIXME("Recipients %08x not supported!\n", *lpdwRecipients); + } + + return ret; +} + +/* + * @implemented + */ +LONG +STDCALL +BroadcastSystemMessageA( + DWORD dwFlags, + LPDWORD lpdwRecipients, + UINT uiMessage, + WPARAM wParam, + LPARAM lParam) +{ + return IntBroadcastSystemMessage( dwFlags, lpdwRecipients, uiMessage, wParam, lParam, NULL, TRUE ); +} + +/* + * @implemented + */ +LONG +STDCALL +BroadcastSystemMessageW( + DWORD dwFlags, + LPDWORD lpdwRecipients, + UINT uiMessage, + WPARAM wParam, + LPARAM lParam) +{ + return IntBroadcastSystemMessage( dwFlags, lpdwRecipients, uiMessage, wParam, lParam, NULL, FALSE ); +} + +/* + * @implemented + */ +LONG +STDCALL +BroadcastSystemMessageExA( + DWORD dwflags, + LPDWORD lpdwRecipients, + UINT uiMessage, + WPARAM wParam, + LPARAM lParam, + PBSMINFO pBSMInfo) +{ + return IntBroadcastSystemMessage( dwflags, lpdwRecipients, uiMessage, wParam, lParam , pBSMInfo, TRUE ); +} + +/* + * @implemented + */ +LONG +STDCALL +BroadcastSystemMessageExW( + DWORD dwflags, + LPDWORD lpdwRecipients, + UINT uiMessage, + WPARAM wParam, + LPARAM lParam, + PBSMINFO pBSMInfo) +{ + return IntBroadcastSystemMessage( dwflags, lpdwRecipients, uiMessage, wParam, lParam , pBSMInfo, FALSE ); +} +