From 3e714d22fbdc2e65a4dd1156e5e5265c8a431b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 7 Feb 2015 01:18:40 +0000 Subject: [PATCH] [WINLOGON][WIN32K]: Tend towards Win2k3-compatible winlogon logoff/shutdown messaging. Something that needs to be fixed is that it is not winlogon that checks whether the app requesting the shutdown has the correct rights, but it is win32k. I temporarily disable this check in winlogon (it's not as if we introduced a security breach in ReactOS ^^) svn path=/trunk/; revision=66186 --- reactos/base/system/winlogon/sas.c | 63 ++++++++++++---------- reactos/include/reactos/undocuser.h | 68 ++++++++++++------------ reactos/include/reactos/winlogon.h | 2 - reactos/win32ss/user/ntuser/simplecall.c | 7 ++- 4 files changed, 75 insertions(+), 65 deletions(-) diff --git a/reactos/base/system/winlogon/sas.c b/reactos/base/system/winlogon/sas.c index 21b66051d12..e152f82c3b6 100644 --- a/reactos/base/system/winlogon/sas.c +++ b/reactos/base/system/winlogon/sas.c @@ -1148,6 +1148,7 @@ UnregisterHotKeys( return TRUE; } +#if 0 static NTSTATUS CheckForShutdownPrivilege( @@ -1206,6 +1207,7 @@ CheckForShutdownPrivilege( } return STATUS_SUCCESS; } +#endif BOOL WINAPI @@ -1329,6 +1331,38 @@ SASWindowProc( DoGenericAction(Session, WLX_SAS_ACTION_LOCK_WKSTA); break; } + case LN_LOGOFF: + { + UINT Flags = (UINT)lParam; + UINT Action = Flags & EWX_ACTION_MASK; + DWORD wlxAction; + + /* Check parameters */ + switch (Action) + { + case EWX_LOGOFF: wlxAction = WLX_SAS_ACTION_LOGOFF; break; + case EWX_SHUTDOWN: wlxAction = WLX_SAS_ACTION_SHUTDOWN; break; + case EWX_REBOOT: wlxAction = WLX_SAS_ACTION_SHUTDOWN_REBOOT; break; + case EWX_POWEROFF: wlxAction = WLX_SAS_ACTION_SHUTDOWN_POWER_OFF; break; + default: + { + ERR("Invalid ExitWindows action 0x%x\n", Action); + return STATUS_INVALID_PARAMETER; + } + } + +#if 0 + // FIXME: This check must be done by Win32k, not by us! + if (WLX_SHUTTINGDOWN(wlxAction)) + { + NTSTATUS Status = CheckForShutdownPrivilege(wParam); + if (!NT_SUCCESS(Status)) + return Status; + } +#endif + DoGenericAction(Session, wlxAction); + return 1; + } default: { ERR("WM_LOGONNOTIFY case %d is unimplemented\n", wParam); @@ -1350,35 +1384,6 @@ SASWindowProc( DispatchSAS(Session, (DWORD)wParam); return TRUE; } - case PM_WINLOGON_EXITWINDOWS: - { - UINT Flags = (UINT)lParam; - UINT Action = Flags & EWX_ACTION_MASK; - DWORD wlxAction; - - /* Check parameters */ - switch (Action) - { - case EWX_LOGOFF: wlxAction = WLX_SAS_ACTION_LOGOFF; break; - case EWX_SHUTDOWN: wlxAction = WLX_SAS_ACTION_SHUTDOWN; break; - case EWX_REBOOT: wlxAction = WLX_SAS_ACTION_SHUTDOWN_REBOOT; break; - case EWX_POWEROFF: wlxAction = WLX_SAS_ACTION_SHUTDOWN_POWER_OFF; break; - default: - { - ERR("Invalid ExitWindows action 0x%x\n", Action); - return STATUS_INVALID_PARAMETER; - } - } - - if (WLX_SHUTTINGDOWN(wlxAction)) - { - NTSTATUS Status = CheckForShutdownPrivilege((DWORD)wParam); - if (!NT_SUCCESS(Status)) - return Status; - } - DoGenericAction(Session, wlxAction); - return 1; - } } return DefWindowProc(hwndDlg, uMsg, wParam, lParam); diff --git a/reactos/include/reactos/undocuser.h b/reactos/include/reactos/undocuser.h index 1d47195e339..270f64e2f2e 100644 --- a/reactos/include/reactos/undocuser.h +++ b/reactos/include/reactos/undocuser.h @@ -100,12 +100,14 @@ extern "C" { // // Definitions used by WM_LOGONNOTIFY // +#define LN_LOGOFF 0x0 #define LN_SHELL_EXITED 0x2 #define LN_START_TASK_MANAGER 0x4 #define LN_LOCK_WORKSTATION 0x5 #define LN_UNLOCK_WORKSTATION 0x6 #define LN_MESSAGE_BEEP 0x9 #define LN_START_SCREENSAVE 0xA +#define LN_LOGOFF_CANCELED 0xB // From WinCE 6.0 Imm.h SDK // Returns for ImmProcessHotKey @@ -174,8 +176,8 @@ typedef int (WINAPI *SETWINDOWRGN)(HWND hWnd, HRGN hRgn, BOOL bRedraw); typedef struct _UAHOWP { - BYTE* MsgBitArray; - DWORD Size; + BYTE* MsgBitArray; + DWORD Size; } UAHOWP, *PUAHOWP; #define UAH_HOOK_MESSAGE(uahowp, msg) uahowp.MsgBitArray[msg/8] |= (1 << (msg % 8)); @@ -184,47 +186,47 @@ typedef struct _UAHOWP typedef struct tagUSERAPIHOOK { - DWORD size; - WNDPROC DefWindowProcA; - WNDPROC DefWindowProcW; - UAHOWP DefWndProcArray; - FARPROC GetScrollInfo; - FARPROC SetScrollInfo; - FARPROC EnableScrollBar; - FARPROC AdjustWindowRectEx; - SETWINDOWRGN SetWindowRgn; - WNDPROC_OWP PreWndProc; - WNDPROC_OWP PostWndProc; - UAHOWP WndProcArray; - WNDPROC_OWP PreDefDlgProc; - WNDPROC_OWP PostDefDlgProc; - UAHOWP DlgProcArray; - FARPROC GetSystemMetrics; - FARPROC SystemParametersInfoA; - FARPROC SystemParametersInfoW; - FARPROC ForceResetUserApiHook; - FARPROC DrawFrameControl; - FARPROC DrawCaption; - FARPROC MDIRedrawFrame; - FARPROC GetRealWindowOwner; + DWORD size; + WNDPROC DefWindowProcA; + WNDPROC DefWindowProcW; + UAHOWP DefWndProcArray; + FARPROC GetScrollInfo; + FARPROC SetScrollInfo; + FARPROC EnableScrollBar; + FARPROC AdjustWindowRectEx; + SETWINDOWRGN SetWindowRgn; + WNDPROC_OWP PreWndProc; + WNDPROC_OWP PostWndProc; + UAHOWP WndProcArray; + WNDPROC_OWP PreDefDlgProc; + WNDPROC_OWP PostDefDlgProc; + UAHOWP DlgProcArray; + FARPROC GetSystemMetrics; + FARPROC SystemParametersInfoA; + FARPROC SystemParametersInfoW; + FARPROC ForceResetUserApiHook; + FARPROC DrawFrameControl; + FARPROC DrawCaption; + FARPROC MDIRedrawFrame; + FARPROC GetRealWindowOwner; } USERAPIHOOK, *PUSERAPIHOOK; typedef enum _UAPIHK { - uahLoadInit, - uahStop, - uahShutdown + uahLoadInit, + uahStop, + uahShutdown } UAPIHK, *PUAPIHK; typedef BOOL(CALLBACK *USERAPIHOOKPROC)(UAPIHK State, PUSERAPIHOOK puah); typedef struct _USERAPIHOOKINFO { - DWORD m_size; - LPCWSTR m_dllname1; - LPCWSTR m_funname1; - LPCWSTR m_dllname2; - LPCWSTR m_funname2; + DWORD m_size; + LPCWSTR m_dllname1; + LPCWSTR m_funname1; + LPCWSTR m_dllname2; + LPCWSTR m_funname2; } USERAPIHOOKINFO,*PUSERAPIHOOKINFO; #if (WINVER == _WIN32_WINNT_WINXP) diff --git a/reactos/include/reactos/winlogon.h b/reactos/include/reactos/winlogon.h index b8571da7bbc..06c31957afb 100644 --- a/reactos/include/reactos/winlogon.h +++ b/reactos/include/reactos/winlogon.h @@ -9,8 +9,6 @@ #ifndef REACTOS_WINLOGON_H_INCLUDED #define REACTOS_WINLOGON_H_INCLUDED -#define PM_WINLOGON_EXITWINDOWS WM_APP - #define EWX_INTERNAL_FLAG 0x10000 #define EWX_INTERNAL_KILL_USER_APPS (EWX_INTERNAL_FLAG | 0x100) #define EWX_INTERNAL_KILL_ALL_APPS (EWX_INTERNAL_FLAG | 0x200) diff --git a/reactos/win32ss/user/ntuser/simplecall.c b/reactos/win32ss/user/ntuser/simplecall.c index 3cbcff5e95a..7d034cd37dd 100644 --- a/reactos/win32ss/user/ntuser/simplecall.c +++ b/reactos/win32ss/user/ntuser/simplecall.c @@ -449,13 +449,18 @@ NtUserCallTwoParam( case TWOPARAM_ROUTINE_UNHOOKWINDOWSHOOK: RETURN( IntUnhookWindowsHook((int)Param1, (HOOKPROC)Param2)); + case TWOPARAM_ROUTINE_EXITREACTOS: + { + UNREFERENCED_PARAMETER(Param1 /* ProcessId */); + if(hwndSAS == NULL) { ASSERT(hwndSAS); RETURN(STATUS_NOT_FOUND); } - RETURN( co_IntSendMessage (hwndSAS, PM_WINLOGON_EXITWINDOWS, (WPARAM) Param1, (LPARAM)Param2)); + RETURN(co_IntSendMessage(hwndSAS, WM_LOGONNOTIFY, LN_LOGOFF, Param2 /* Flags */)); + } } ERR("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n", Routine, Param1, Param2);