[user32/win32k]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Fri, 18 Feb 2011 20:16:43 +0000 (20:16 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Fri, 18 Feb 2011 20:16:43 +0000 (20:16 +0000)
- Implement MessageBeep and SetLogonNotifyWindow

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

svn path=/trunk/; revision=50813

reactos/base/system/winlogon/sas.c
reactos/base/system/winlogon/winlogon.c
reactos/base/system/winlogon/winlogon.h
reactos/dll/win32/user32/misc/misc.c
reactos/dll/win32/user32/windows/messagebox.c
reactos/include/reactos/undocuser.h
reactos/include/reactos/winlogon.h
reactos/subsystems/win32/win32k/include/winsta.h
reactos/subsystems/win32/win32k/ntuser/ntstubs.c
reactos/subsystems/win32/win32k/ntuser/simplecall.c
reactos/subsystems/win32/win32k/ntuser/winsta.c

index d4dbad8..d394439 100644 (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);
index 3f977d0..619ff4e 100644 (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);
 }
index 45e7325..d28e150 100644 (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,
index e7b7672..3f1c4b6 100644 (file)
@@ -72,7 +72,7 @@ SetLogonNotifyWindow (HWND Wnd, HWINSTA WinSta)
       return(FALSE);
     }
 
-  return(TRUE);
+  return NtUserSetLogonNotifyWindow(Wnd);
 }
 
 /*
index 7ea0b90..13b374a 100644 (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);
 }
 
 
index 22bd858..208c10b 100644 (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);
index 42eaf62..4c00b67 100644 (file)
 #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 */
index a50a23e..c40d14b 100644 (file)
@@ -61,6 +61,7 @@ typedef struct _WINSTATION_OBJECT
 
 extern WINSTATION_OBJECT *InputWindowStation;
 extern PPROCESSINFO LogonProcess;
+extern HWND hwndSAS;
 
 INIT_FUNCTION
 NTSTATUS
index 5045718..821d4d6 100644 (file)
@@ -1272,17 +1272,6 @@ NtUserSetLayeredWindowAttributes(HWND hwnd,
   return FALSE;
 }
 
-/*
- * @unimplemented
- */
-BOOL APIENTRY
-NtUserSetLogonNotifyWindow(HWND hWnd)
-{
-   UNIMPLEMENTED
-
-   return 0;
-}
-
 /*
  * @unimplemented
  */
index 941d31a..f31b442 100644 (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);
index d6e5a0f..ff429a1 100644 (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 */