[user32/win32k]

- Implement MessageBeep and SetLogonNotifyWindow

[winlogon]
- Implement receiving notifications from win32k to play sounds of MessageBeep

svn path=/trunk/; revision=50813
This commit is contained in:
Giannis Adamopoulos 2011-02-18 20:16:43 +00:00
parent bc92849c38
commit c7b9d6f0df
11 changed files with 133 additions and 67 deletions

View file

@ -25,8 +25,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(winlogon);
#define HK_CTRL_ALT_DEL 0
#define HK_CTRL_SHIFT_ESC 1
extern BOOL WINAPI SetLogonNotifyWindow(HWND Wnd, HWINSTA WinSta);
/* FUNCTIONS ****************************************************************/
static BOOL
@ -843,6 +841,40 @@ CheckForShutdownPrivilege(
return STATUS_SUCCESS;
}
BOOL
WINAPI
HandleMessageBeep(UINT uType)
{
LPWSTR EventName;
switch(uType)
{
case 0xFFFFFFFF:
EventName = NULL;
break;
case MB_OK:
EventName = L"SystemDefault";
break;
case MB_ICONASTERISK:
EventName = L"SystemAsterisk";
break;
case MB_ICONEXCLAMATION:
EventName = L"SystemExclamation";
break;
case MB_ICONHAND:
EventName = L"SystemHand";
break;
case MB_ICONQUESTION:
EventName = L"SystemQuestion";
break;
default:
WARN("Unhandled type %d\n", uType);
EventName = L"SystemDefault";
}
return PlaySoundRoutine(EventName, FALSE, SND_ALIAS | SND_NOWAIT | SND_NOSTOP | SND_ASYNC);
}
static LRESULT CALLBACK
SASWindowProc(
IN HWND hwndDlg,
@ -902,6 +934,21 @@ SASWindowProc(
}
return TRUE;
}
case WM_LOGONNOTIFY:
{
switch(wParam)
{
case LN_MESSAGE_BEEP:
{
return HandleMessageBeep(lParam);
}
default:
{
ERR("WM_LOGONNOTIFY case %d is unimplemented\n", wParam);
}
}
return 0;
}
case WLX_WM_SAS:
{
DispatchSAS(Session, (DWORD)wParam);

View file

@ -23,6 +23,49 @@ PWLSESSION WLSession = NULL;
/* FUNCTIONS *****************************************************************/
BOOL
PlaySoundRoutine(
IN LPCWSTR FileName,
IN UINT bLogon,
IN UINT Flags)
{
typedef BOOL (WINAPI *PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
typedef UINT (WINAPI *WAVEOUTGETNUMDEVS)(VOID);
PLAYSOUNDW Play;
WAVEOUTGETNUMDEVS waveOutGetNumDevs;
UINT NumDevs;
HMODULE hLibrary;
BOOL Ret = FALSE;
hLibrary = LoadLibraryW(L"winmm.dll");
if (hLibrary)
{
waveOutGetNumDevs = (WAVEOUTGETNUMDEVS)GetProcAddress(hLibrary, "waveOutGetNumDevs");
if (waveOutGetNumDevs)
{
NumDevs = waveOutGetNumDevs();
if (!NumDevs)
{
if (!bLogon)
{
Beep(500, 500);
}
FreeLibrary(hLibrary);
return FALSE;
}
}
Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
if (Play)
{
Ret = Play(FileName, NULL, Flags);
}
FreeLibrary(hLibrary);
}
return Ret;
}
DWORD
WINAPI
PlayLogonSoundThread(
@ -32,10 +75,8 @@ PlayLogonSoundThread(
WCHAR szBuffer[MAX_PATH] = {0};
WCHAR szDest[MAX_PATH];
DWORD dwSize = sizeof(szBuffer);
HMODULE hLibrary;
SERVICE_STATUS_PROCESS Info;
typedef BOOL (WINAPI *PLAYSOUNDW)(LPCWSTR,HMODULE,DWORD);
PLAYSOUNDW Play;
ULONG Index = 0;
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"AppEvents\\Schemes\\Apps\\.Default\\WindowsLogon\\.Current", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
@ -94,17 +135,7 @@ PlayLogonSoundThread(
if (Info.dwCurrentState != SERVICE_RUNNING)
ExitThread(0);
hLibrary = LoadLibraryW(L"winmm.dll");
if (hLibrary)
{
Play = (PLAYSOUNDW)GetProcAddress(hLibrary, "PlaySoundW");
if (Play)
{
Play(szDest, NULL, SND_FILENAME);
}
FreeLibrary(hLibrary);
}
PlaySoundRoutine(szDest, TRUE, SND_FILENAME);
}
ExitThread(0);
}

View file

@ -40,6 +40,7 @@
#include <accctrl.h>
#include <aclapi.h>
#include <reactos/undocuser.h>
#include <reactos/winlogon.h>
#include "setup.h"
@ -203,6 +204,13 @@ StartScreenSaver(
IN PWLSESSION Session);
/* winlogon.c */
BOOL
PlaySoundRoutine(
IN LPCWSTR FileName,
IN UINT Logon,
IN UINT Flags);
BOOL
DisplayStatusMessage(
IN PWLSESSION Session,

View file

@ -72,7 +72,7 @@ SetLogonNotifyWindow (HWND Wnd, HWINSTA WinSta)
return(FALSE);
}
return(TRUE);
return NtUserSetLogonNotifyWindow(Wnd);
}
/*

View file

@ -890,36 +890,7 @@ BOOL
WINAPI
MessageBeep(UINT uType)
{
#if 0
LPWSTR EventName;
switch(uType)
{
case 0xFFFFFFFF:
if(waveOutGetNumDevs() == 0)
return Beep(500, 100); // Beep through speaker
/* fall through */
case MB_OK:
EventName = L"SystemDefault";
break;
case MB_ICONASTERISK:
EventName = L"SystemAsterisk";
break;
case MB_ICONEXCLAMATION:
EventName = L"SystemExclamation";
break;
case MB_ICONHAND:
EventName = L"SystemHand";
break;
case MB_ICONQUESTION:
EventName = L"SystemQuestion";
break;
}
return PlaySoundW((LPCWSTR)EventName, NULL, SND_ALIAS | SND_NOWAIT | SND_NOSTOP | SND_ASYNC);
#else
return Beep(500, 100); // Beep through speaker
#endif
return (BOOL)NtUserCallOneParam(ONEPARAM_ROUTINE_MESSAGEBEEP, uType);
}

View file

@ -92,7 +92,7 @@
#define SBRG_PAGEDOWNLEFT 4 /* the page down or page left region */
#define SBRG_BOTTOMLEFTBTN 5 /* the bottom or left button */
BOOL WINAPI SetLogonNotifyWindow(HWND Wnd, HWINSTA WinSta);
BOOL WINAPI KillSystemTimer(HWND,UINT_PTR);
UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC);
DWORD_PTR WINAPI SetSysColorsTemp(const COLORREF *, const HBRUSH *, DWORD_PTR);

View file

@ -17,14 +17,6 @@
#define EWX_INTERNAL_KILL_ALL_APPS (EWX_INTERNAL_FLAG | 0x200)
#define EWX_INTERNAL_FLAG_LOGOFF 0x1000
#define WM_LOGONNOTIFY 0x0000004c
/* WPARAM values for WM_LOGONNOTIFY */
#define LN_START_TASK_MANAGER 0x4
#define LN_LOCK_WORKSTATION 0x5
#define LN_UNLOCK_WORKSTATION 0x6
#define LN_MESSAGE_BEEP 0x9
#endif /* REACTOS_WINLOGON_H_INCLUDED */
/* EOF */

View file

@ -61,6 +61,7 @@ typedef struct _WINSTATION_OBJECT
extern WINSTATION_OBJECT *InputWindowStation;
extern PPROCESSINFO LogonProcess;
extern HWND hwndSAS;
INIT_FUNCTION
NTSTATUS

View file

@ -1272,17 +1272,6 @@ NtUserSetLayeredWindowAttributes(HWND hwnd,
return FALSE;
}
/*
* @unimplemented
*/
BOOL APIENTRY
NtUserSetLogonNotifyWindow(HWND hWnd)
{
UNIMPLEMENTED
return 0;
}
/*
* @unimplemented
*/

View file

@ -341,6 +341,9 @@ NtUserCallOneParam(
}
case ONEPARAM_ROUTINE_REPLYMESSAGE:
RETURN (co_MsqReplyMessage((LRESULT) Param));
case ONEPARAM_ROUTINE_MESSAGEBEEP:
RETURN ( UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, Param) );
/* TODO: Implement sound sentry */
}
DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n",
Routine, Param);

View file

@ -43,6 +43,9 @@
/* Currently active window station */
PWINSTATION_OBJECT InputWindowStation = NULL;
/* Winlogon sas window*/
HWND hwndSAS = NULL;
/* INITALIZATION FUNCTIONS ****************************************************/
static GENERIC_MAPPING IntWindowStationMapping =
@ -1455,4 +1458,25 @@ NtUserBuildNameList(
BuildDesktopNameList(hWindowStation, dwSize, lpBuffer, pRequiredSize);
}
/*
* @implemented
*/
BOOL APIENTRY
NtUserSetLogonNotifyWindow(HWND hWnd)
{
if(LogonProcess != PsGetCurrentProcessWin32Process())
{
return FALSE;
}
if(!IntIsWindow(hWnd))
{
return FALSE;
}
hwndSAS = hWnd;
return TRUE;
}
/* EOF */