Author: fireball
Date: Mon Dec 14 12:10:40 2015
New Revision: 70345
URL:
http://svn.reactos.org/svn/reactos?rev=70345&view=rev
Log:
[ARWINSS]
- Implement logon process registration in win32k and its shutdown notification.
- Add a hack into server/queue.c which allows to send message to a thread without the
desktop. Once the dektop issue is properly solved, this hack should go away.
- Arwinss boots to the desktop now.
- Remove redundant csr_shared.h, and use trunk's ntuser.h instead.
Removed:
branches/arwinss/arwinss/include/csr_shared.h
Modified:
branches/arwinss/arwinss/client/user32/csr.c
branches/arwinss/arwinss/include/wine/rosuser.h
branches/arwinss/arwinss/server/main/misc.c
branches/arwinss/arwinss/server/main/shutdown.c
branches/arwinss/arwinss/server/w32ksvc.db
branches/arwinss/arwinss/server/w32ksvc.h
branches/arwinss/arwinss/server/wine/queue.c
Modified: branches/arwinss/arwinss/client/user32/csr.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/client/user32/c…
==============================================================================
--- branches/arwinss/arwinss/client/user32/csr.c [iso-8859-1] (original)
+++ branches/arwinss/arwinss/client/user32/csr.c [iso-8859-1] Mon Dec 14 12:10:40 2015
@@ -28,13 +28,18 @@
/* CSRSS Headers */
#include <subsys/csr/csr.h>
-#include <csr_shared.h>
+#include <ntuser.h>
#include <subsys/win/winmsg.h>
+
+#include "wine/rosuser.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(usercsr);
+/* GLOBALS ********************************************************************/
+
+BOOLEAN gfLogonProcess = FALSE;
/* FUNCTIONS ******************************************************************/
@@ -89,31 +94,42 @@
return TRUE;
}
+EXTINLINE BOOL NtUserxRegisterLogonProcess(DWORD dwProcessId, BOOL bRegister)
+{
+ return (BOOL)NtUserCallTwoParam((DWORD_PTR)dwProcessId, (DWORD_PTR)bRegister,
TWOPARAM_ROUTINE_REGISTERLOGONPROCESS);
+}
+
/***********************************************************************
* RegisterLogonProcess (USER32.@)
*/
-BOOL WINAPI RegisterLogonProcess(DWORD dwProcessId, BOOL bRegister)
+BOOL
+WINAPI
+RegisterLogonProcess(DWORD dwProcessId,
+ BOOL bRegister)
{
- NTSTATUS Status;
+ gfLogonProcess = NtUserxRegisterLogonProcess(dwProcessId, bRegister);
+
+ if (gfLogonProcess)
+ {
USER_API_MESSAGE ApiMessage;
+ PUSER_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest =
&ApiMessage.Data.RegisterLogonProcessRequest;
- ApiMessage.Data.RegisterLogonProcessRequest.ProcessId = dwProcessId;
- ApiMessage.Data.RegisterLogonProcessRequest.Register = bRegister;
+ RegisterLogonProcessRequest->ProcessId = dwProcessId;
+ RegisterLogonProcessRequest->Register = bRegister;
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(USERSRV_SERVERDLL_INDEX,
UserpRegisterLogonProcess),
- sizeof(USER_REGISTER_LOGON_PROCESS));
- if (!NT_SUCCESS(Status))
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(USERSRV_SERVERDLL_INDEX,
UserpRegisterLogonProcess),
+ sizeof(*RegisterLogonProcessRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
{
ERR("Failed to register logon process with CSRSS\n");
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
+ SetLastError(RtlNtStatusToDosError(ApiMessage.Status));
}
+ }
- return TRUE;
+ return gfLogonProcess;
}
-
/***********************************************************************
* SetLogonNotifyWindow (USER32.@)
@@ -122,30 +138,7 @@
WINAPI
SetLogonNotifyWindow (HWND Wnd)
{
-#if 0
- /* Maybe we should call NtUserSetLogonNotifyWindow and let that one inform CSRSS???
*/
- CSR_API_MESSAGE Request;
- ULONG CsrRequest;
- NTSTATUS Status;
-
- CsrRequest = MAKE_CSR_API(SET_LOGON_NOTIFY_WINDOW, CSR_GUI);
- Request.Data.SetLogonNotifyWindowRequest.LogonNotifyWindow = Wnd;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CsrRequest,
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
-
- return TRUE;
-#else
- ERR("SetLogonNotifyWindow is not yet implemented in Arwinss\n");
- return TRUE;
-#endif
+ return NtUserSetLogonNotifyWindow(Wnd);
}
/* EOF */
Removed: branches/arwinss/arwinss/include/csr_shared.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/include/csr_sha…
==============================================================================
--- branches/arwinss/arwinss/include/csr_shared.h [iso-8859-1] (original)
+++ branches/arwinss/arwinss/include/csr_shared.h (removed)
@@ -1,72 +0,0 @@
-#pragma once
-
-/* FNID's for NtUserSetWindowFNID, NtUserMessageCall */
-#define FNID_FIRST 0x029A
-#define FNID_SCROLLBAR 0x029A
-#define FNID_ICONTITLE 0x029B
-#define FNID_MENU 0x029C
-#define FNID_DESKTOP 0x029D
-#define FNID_DEFWINDOWPROC 0x029E
-#define FNID_MESSAGEWND 0x029F
-#define FNID_SWITCH 0x02A0
-#define FNID_BUTTON 0x02A1
-#define FNID_COMBOBOX 0x02A2
-#define FNID_COMBOLBOX 0x02A3
-#define FNID_DIALOG 0x02A4
-#define FNID_EDIT 0x02A5
-#define FNID_LISTBOX 0x02A6
-#define FNID_MDICLIENT 0x02A7
-#define FNID_STATIC 0x02A8
-#define FNID_IME 0x02A9
-#define FNID_GHOST 0x02AA
-#define FNID_CALLWNDPROC 0x02AB
-#define FNID_CALLWNDPROCRET 0x02AC
-#define FNID_HKINLPCWPEXSTRUCT 0x02AD
-#define FNID_HKINLPCWPRETEXSTRUCT 0x02AE
-#define FNID_MB_DLGPROC 0x02AF
-#define FNID_MDIACTIVATEDLGPROC 0x02B0
-#define FNID_SENDMESSAGE 0x02B1
-#define FNID_SENDMESSAGEFF 0x02B2
-/* Kernel has option to use TimeOut or normal msg send, based on type of msg. */
-#define FNID_SENDMESSAGEWTOOPTION 0x02B3
-#define FNID_SENDMESSAGECALLPROC 0x02B4
-#define FNID_BROADCASTSYSTEMMESSAGE 0x02B5
-#define FNID_TOOLTIPS 0x02B6
-#define FNID_SENDNOTIFYMESSAGE 0x02B7
-#define FNID_SENDMESSAGECALLBACK 0x02B8
-#define FNID_LAST 0x02B9
-
-typedef struct _WNDMSG
-{
- DWORD maxMsgs;
- PINT abMsgs;
-} WNDMSG, *PWNDMSG;
-
-typedef PVOID PSERVERINFO;
-
-typedef struct _SHAREDINFO
-{
- PSERVERINFO psi; /* global Server Info */
- PVOID aheList; /* Handle Entry List */
- PVOID pDispInfo; /* global PDISPLAYINFO pointer */
- ULONG_PTR ulSharedDelta; /* Heap delta */
- WNDMSG awmControl[FNID_LAST - FNID_FIRST];
- WNDMSG DefWindowMsgs;
- WNDMSG DefWindowSpecMsgs;
-} SHAREDINFO, *PSHAREDINFO;
-
-/* See also the USERSRV_API_CONNECTINFO #define in include/reactos/subsys/win/winmsg.h
*/
-typedef struct _USERCONNECT
-{
- ULONG ulVersion;
- ULONG ulCurrentVersion;
- DWORD dwDispatchCount;
- SHAREDINFO siClient;
-} USERCONNECT, *PUSERCONNECT;
-
-/* WinNT 5.0 compatible user32 / win32k */
-#define USER_VERSION MAKELONG(0x0000, 0x0005)
-
-#if defined(_M_IX86)
-C_ASSERT(sizeof(USERCONNECT) == 0x124);
-#endif
Modified: branches/arwinss/arwinss/include/wine/rosuser.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/include/wine/ro…
==============================================================================
--- branches/arwinss/arwinss/include/wine/rosuser.h [iso-8859-1] (original)
+++ branches/arwinss/arwinss/include/wine/rosuser.h [iso-8859-1] Mon Dec 14 12:10:40 2015
@@ -10,6 +10,14 @@
#ifndef __WIN32K_ROSUSER_H
#define __WIN32K_ROSUSER_H
+
+#if defined(__GNUC__)
+#define EXTINLINE extern inline __attribute__((always_inline))
+#elif defined(_MSC_VER)
+#define EXTINLINE extern __forceinline
+#else
+#error
+#endif
/* DEFINES *******************************************************************/
@@ -181,6 +189,12 @@
BOOL NTAPI
RosUserBuildShellHookHwndList(HWND *list, UINT *cbSize);
+DWORD_PTR NTAPI
+NtUserCallTwoParam(DWORD_PTR Param1, DWORD_PTR Param2, DWORD Routine);
+
+BOOL NTAPI
+NtUserSetLogonNotifyWindow(HWND hWnd);
+
SWM_WINDOW_ID NTAPI
SwmNewWindow(SWM_WINDOW_ID parent, RECT *WindowRect, HWND hWnd, DWORD ex_style);
Modified: branches/arwinss/arwinss/server/main/misc.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/server/main/mis…
==============================================================================
--- branches/arwinss/arwinss/server/main/misc.c [iso-8859-1] (original)
+++ branches/arwinss/arwinss/server/main/misc.c [iso-8859-1] Mon Dec 14 12:10:40 2015
@@ -10,7 +10,7 @@
#include <win32k.h>
-//#define NDEBUG
+#define NDEBUG
#include <debug.h>
#include <ntstatus.h>
@@ -18,6 +18,25 @@
#include <csr.h>
extern PEPROCESS CsrProcess;
+extern HWND hwndSAS;
+
+/* Registered logon process ID */
+HANDLE gpidLogon = 0;
+
+BOOL
+APIENTRY
+NtUserSetLogonNotifyWindow(HWND hWnd)
+{
+ if (gpidLogon != PsGetCurrentProcessId())
+ return FALSE;
+
+ DPRINT("Logon hwnd %x\n", hWnd);
+
+ hwndSAS = hWnd;
+
+ return TRUE;
+}
+
NTSTATUS
APIENTRY
@@ -163,3 +182,64 @@
UserLeave();
return Status;
}
+
+BOOL
+UserRegisterLogonProcess(HANDLE ProcessId, BOOL Register)
+{
+ NTSTATUS Status;
+ PEPROCESS Process;
+
+ Status = PsLookupProcessByProcessId(ProcessId, &Process);
+ if (!NT_SUCCESS(Status))
+ {
+ EngSetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+
+ ProcessId = Process->UniqueProcessId;
+ ObDereferenceObject(Process);
+
+ if (Register)
+ {
+ /* Register the logon process */
+ if (gpidLogon != 0) return FALSE;
+ gpidLogon = ProcessId;
+ }
+ else
+ {
+ /* Deregister the logon process */
+ if (gpidLogon != ProcessId) return FALSE;
+ gpidLogon = 0;
+ }
+
+ return TRUE;
+}
+
+DWORD_PTR
+APIENTRY
+NtUserCallTwoParam(
+ DWORD_PTR Param1,
+ DWORD_PTR Param2,
+ DWORD Routine)
+{
+ DWORD_PTR ReturnValue;
+
+ DPRINT("Enter NtUserCallTwoParam\n");
+ UserEnterExclusive();
+
+ switch(Routine)
+ {
+ case TWOPARAM_ROUTINE_REGISTERLOGONPROCESS:
+ ReturnValue = (DWORD_PTR)UserRegisterLogonProcess((HANDLE)Param1,
(BOOL)Param2);
+ break;
+
+ default:
+ DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(),
Param1=0x%x Parm2=0x%x\n",
+ Routine, Param1, Param2);
+ EngSetLastError(ERROR_INVALID_PARAMETER);
+ }
+
+ DPRINT("Leave NtUserCallTwoParam, ret=%p\n", ReturnValue);
+ UserLeave();
+ return ReturnValue;
+}
Modified: branches/arwinss/arwinss/server/main/shutdown.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/server/main/shu…
==============================================================================
--- branches/arwinss/arwinss/server/main/shutdown.c [iso-8859-1] (original)
+++ branches/arwinss/arwinss/server/main/shutdown.c [iso-8859-1] Mon Dec 14 12:10:40 2015
@@ -9,16 +9,54 @@
/* INCLUDES ******************************************************************/
#include <win32k.h>
-
-//#define NDEBUG
+#include <ntstatus.h>
+
+#include "object.h"
+#include "request.h"
+#include "user.h"
+
+#define NDEBUG
#include <debug.h>
-
-#include <ntstatus.h>
/* Our local copy of shutdown flags */
static ULONG gdwShutdownFlags = 0;
+/* Registered logon window */
HWND hwndSAS = NULL;
+
+extern HANDLE gpidLogon;
+
+VOID
+UserPostMessage(HWND hWnd,
+ UINT Msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ PTHREADINFO thread;
+ struct send_message_request req;
+ struct send_message_reply reply;
+
+ // Get that window's thread
+ thread = get_window_thread((user_handle_t)hWnd);
+ if (!thread) return;
+
+ req.id = (ULONG)thread->peThread->Cid.UniqueThread;
+ req.type = MSG_NOTIFY; // Or MSG_OTHER_PROCESS ?
+ req.flags = 0;
+ req.win = (user_handle_t)hWnd;
+ req.msg = Msg;
+ req.wparam = wParam;
+ req.lparam = lParam;
+ req.timeout = TIMEOUT_INFINITE;
+
+ // No strings attached
+ req.__header.request_size = 0;
+
+ // Zero reply's memory area
+ memset( &reply, 0, sizeof(reply) );
+
+ req_send_message(&req, &reply);
+}
NTSTATUS
GetProcessLuid(IN PETHREAD Thread OPTIONAL,
@@ -89,8 +127,7 @@
if (hwndSAS)
{
DPRINT("\tSending %s, Param 0x%x message to Winlogon\n", Notif ==
LN_LOGOFF ? "LN_LOGOFF" : "LN_LOGOFF_CANCELED", Param);
- //UserPostMessage(hwndSAS, WM_LOGONNOTIFY, Notif, (LPARAM)Param);
- UNIMPLEMENTED;
+ UserPostMessage(hwndSAS, WM_LOGONNOTIFY, Notif, (LPARAM)Param);
return TRUE;
}
else
@@ -110,12 +147,6 @@
ULONG Flags = *pFlags;
LUID CallerLuid;
LUID SystemLuid = SYSTEM_LUID;
- /*static PRIVILEGE_SET ShutdownPrivilege =
- {
- 1, PRIVILEGE_SET_ALL_NECESSARY,
- { {{SE_SHUTDOWN_PRIVILEGE, 0}, 0} }
- };*/
-
PPROCESSINFO ppi;
DPRINT("UserInitiateShutdown\n");
@@ -145,8 +176,7 @@
if (ppi == NULL)
return STATUS_INVALID_HANDLE;
-#if 0
- /* If the caller is not Winlogon, do some security checks */
+ /* If the caller is not Winlogon, do some security checks and notify it to perform
the real shutdown */
if (PsGetThreadProcessId(Thread) != gpidLogon)
{
/*
@@ -157,47 +187,16 @@
*pFlags = Flags;
- /* Check whether the current process is attached to a window station */
- if (ppi->prpwinsta == NULL)
- return STATUS_INVALID_HANDLE;
-
- /* Check whether the window station of the current process can send exit requests
*/
- if (!RtlAreAllAccessesGranted(ppi->amwinsta, WINSTA_EXITWINDOWS))
- return STATUS_ACCESS_DENIED;
-
- /*
- * NOTE: USERSRV automatically adds the shutdown flag when we poweroff or
reboot.
- *
- * If the caller wants to shutdown / reboot / power-off...
- */
- if (Flags & EWX_SHUTDOWN)
- {
- /* ... check whether it has shutdown privilege */
- if (!HasPrivilege(&ShutdownPrivilege))
- return STATUS_PRIVILEGE_NOT_HELD;
- }
- else
- {
- /*
- * ... but if it just wants to log-off, in case its
- * window station is a non-IO one, fail the call.
- */
- if (ppi->prpwinsta->Flags & WSS_NOIO)
- return STATUS_INVALID_DEVICE_REQUEST;
- }
- }
-
- /* If the caller is not Winlogon, possibly notify it to perform the real shutdown */
- if (PsGetThreadProcessId(Thread) != gpidLogon)
- {
// FIXME: HACK!! Do more checks!!
- ERR("UserInitiateShutdown -- Notify Winlogon for shutdown\n");
+
+ /* NOTE: USERSRV automatically adds the shutdown flag when we poweroff or reboot.
*/
+ DPRINT("UserInitiateShutdown -- Notify Winlogon for shutdown\n");
NotifyLogon(hwndSAS, &CallerLuid, Flags, STATUS_SUCCESS);
return STATUS_PENDING;
}
// If we reach this point, that means it's Winlogon that triggered the shutdown.
- ERR("UserInitiateShutdown -- Winlogon is doing a shutdown\n");
+ DPRINT("UserInitiateShutdown -- Winlogon is doing a shutdown\n");
/*
* Update and save the shutdown flags globally for renotifying
@@ -208,9 +207,7 @@
/* Save the shutdown flags now */
gdwShutdownFlags = Flags;
-#else
- UNIMPLEMENTED;
-#endif
+
return STATUS_SUCCESS;
}
@@ -252,11 +249,7 @@
DPRINT("UserEndShutdown -- Notify Winlogon for end of shutdown\n");
-#if 0
NotifyLogon(hwndSAS, &CallerLuid, Flags, ShutdownStatus);
-#else
- UNIMPLEMENTED
-#endif
/* Always return success */
return STATUS_SUCCESS;
Modified: branches/arwinss/arwinss/server/w32ksvc.db
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/server/w32ksvc.…
==============================================================================
--- branches/arwinss/arwinss/server/w32ksvc.db [iso-8859-1] (original)
+++ branches/arwinss/arwinss/server/w32ksvc.db [iso-8859-1] Mon Dec 14 12:10:40 2015
@@ -92,5 +92,7 @@
SwmPosChanged 5
SwmGetWindowFromPoint 2
SwmShowWindow 3
+NtUserCallTwoParam 3
NtUserInitialize 3
-NtUserSetInformationThread 4
+NtUserSetInformationThread 4
+NtUserSetLogonNotifyWindow 1
Modified: branches/arwinss/arwinss/server/w32ksvc.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/server/w32ksvc.…
==============================================================================
--- branches/arwinss/arwinss/server/w32ksvc.h [iso-8859-1] (original)
+++ branches/arwinss/arwinss/server/w32ksvc.h [iso-8859-1] Mon Dec 14 12:10:40 2015
@@ -95,5 +95,7 @@
SVC_(SwmPosChanged, 5)
SVC_(SwmGetWindowFromPoint, 2)
SVC_(SwmShowWindow, 3)
+SVC_(NtUserCallTwoParam, 3)
SVC_(NtUserInitialize, 3)
-SVC_(NtUserSetInformationThread, 4)
+SVC_(NtUserSetInformationThread, 4)
+SVC_(NtUserSetLogonNotifyWindow, 1)
Modified: branches/arwinss/arwinss/server/wine/queue.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/arwinss/server/wine/que…
==============================================================================
--- branches/arwinss/arwinss/server/wine/queue.c [iso-8859-1] (original)
+++ branches/arwinss/arwinss/server/wine/queue.c [iso-8859-1] Mon Dec 14 12:10:40 2015
@@ -236,9 +236,9 @@
if (!(input->desktop = get_thread_desktop( thread, 0 /* FIXME: access rights
*/ )))
{
- DPRINT1("error getting thread desktop\n");
- release_object( input );
- return NULL;
+ DPRINT1("error getting thread desktop, SHOULD FAIL! BIG BUG\n");
+ //release_object( input );
+ //return NULL;
}
}
return input;