diff --git a/reactos/base/system/winlogon/sas.c b/reactos/base/system/winlogon/sas.c index d4dbad881f6..d394439b191 100644 --- a/reactos/base/system/winlogon/sas.c +++ b/reactos/base/system/winlogon/sas.c @@ -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); diff --git a/reactos/base/system/winlogon/winlogon.c b/reactos/base/system/winlogon/winlogon.c index 3f977d0f9be..619ff4e7367 100644 --- a/reactos/base/system/winlogon/winlogon.c +++ b/reactos/base/system/winlogon/winlogon.c @@ -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); } diff --git a/reactos/base/system/winlogon/winlogon.h b/reactos/base/system/winlogon/winlogon.h index 45e73254428..d28e1502544 100644 --- a/reactos/base/system/winlogon/winlogon.h +++ b/reactos/base/system/winlogon/winlogon.h @@ -40,6 +40,7 @@ #include #include +#include #include #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, diff --git a/reactos/dll/win32/user32/misc/misc.c b/reactos/dll/win32/user32/misc/misc.c index e7b7672cfdc..3f1c4b6b367 100644 --- a/reactos/dll/win32/user32/misc/misc.c +++ b/reactos/dll/win32/user32/misc/misc.c @@ -72,7 +72,7 @@ SetLogonNotifyWindow (HWND Wnd, HWINSTA WinSta) return(FALSE); } - return(TRUE); + return NtUserSetLogonNotifyWindow(Wnd); } /* diff --git a/reactos/dll/win32/user32/windows/messagebox.c b/reactos/dll/win32/user32/windows/messagebox.c index 7ea0b9016e2..13b374af9d3 100644 --- a/reactos/dll/win32/user32/windows/messagebox.c +++ b/reactos/dll/win32/user32/windows/messagebox.c @@ -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); } diff --git a/reactos/include/reactos/undocuser.h b/reactos/include/reactos/undocuser.h index 22bd858ee3b..208c10b3686 100644 --- a/reactos/include/reactos/undocuser.h +++ b/reactos/include/reactos/undocuser.h @@ -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); diff --git a/reactos/include/reactos/winlogon.h b/reactos/include/reactos/winlogon.h index 42eaf620468..4c00b674e81 100644 --- a/reactos/include/reactos/winlogon.h +++ b/reactos/include/reactos/winlogon.h @@ -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 */ diff --git a/reactos/subsystems/win32/win32k/include/winsta.h b/reactos/subsystems/win32/win32k/include/winsta.h index a50a23ed6b7..c40d14bf419 100644 --- a/reactos/subsystems/win32/win32k/include/winsta.h +++ b/reactos/subsystems/win32/win32k/include/winsta.h @@ -61,6 +61,7 @@ typedef struct _WINSTATION_OBJECT extern WINSTATION_OBJECT *InputWindowStation; extern PPROCESSINFO LogonProcess; +extern HWND hwndSAS; INIT_FUNCTION NTSTATUS diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 5045718de8a..821d4d6ddf4 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -1272,17 +1272,6 @@ NtUserSetLayeredWindowAttributes(HWND hwnd, return FALSE; } -/* - * @unimplemented - */ -BOOL APIENTRY -NtUserSetLogonNotifyWindow(HWND hWnd) -{ - UNIMPLEMENTED - - return 0; -} - /* * @unimplemented */ diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index 941d31a4f63..f31b44296a1 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -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); diff --git a/reactos/subsystems/win32/win32k/ntuser/winsta.c b/reactos/subsystems/win32/win32k/ntuser/winsta.c index d6e5a0fe446..ff429a17524 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winsta.c +++ b/reactos/subsystems/win32/win32k/ntuser/winsta.c @@ -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 */