2010-06-27 22:19:17 +00:00
|
|
|
/*
|
2002-10-20 14:54:34 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS user32.dll
|
|
|
|
* FILE: lib/user32/misc/exit.c
|
|
|
|
* PURPOSE: Shutdown related functions
|
2010-01-09 22:43:16 +00:00
|
|
|
* PROGRAMMER: Eric Kohl
|
2002-10-20 14:54:34 +00:00
|
|
|
*/
|
|
|
|
|
2005-06-19 18:06:53 +00:00
|
|
|
#include <user32.h>
|
2002-10-20 14:54:34 +00:00
|
|
|
|
2006-06-26 13:16:43 +00:00
|
|
|
#include <wine/debug.h>
|
|
|
|
|
2004-07-12 20:09:35 +00:00
|
|
|
/*
|
|
|
|
* Sequence of events:
|
|
|
|
*
|
|
|
|
* - App (usually explorer) calls ExitWindowsEx()
|
2005-12-01 22:29:57 +00:00
|
|
|
* - ExitWindowsEx() sends a message to CSRSS
|
2004-07-12 20:09:35 +00:00
|
|
|
* - CSRSS impersonates the caller and sends a message to a hidden WinLogon window
|
2005-12-01 22:29:57 +00:00
|
|
|
* - WinLogon checks if the caller has the required privileges
|
2004-07-12 20:09:35 +00:00
|
|
|
* - WinLogon enters pending log-out state
|
|
|
|
* - WinLogon impersonates the interactive user and calls ExitWindowsEx() again,
|
|
|
|
* passing some special internal flags
|
|
|
|
* - CSRSS loops over all processes of the interactive user (sorted by their
|
|
|
|
* SetProcessShutdownParameters() level), sending WM_QUERYENDSESSION and
|
|
|
|
* WM_ENDSESSION messages to its top-level windows. If the messages aren't
|
|
|
|
* processed within the timeout period (registry key HKCU\Control Panel\Desktop\HungAppTimeout)
|
|
|
|
* CSRSS will put up a dialog box asking if the process should be terminated.
|
|
|
|
* Using the registry key HKCU\Control Panel\Desktop\AutoEndTask you can
|
|
|
|
* specify that the dialog box shouldn't be shown and CSRSS should just
|
2005-12-01 22:29:57 +00:00
|
|
|
* terminate the thread. If the the WM_ENDSESSION message is processed
|
2004-07-12 20:09:35 +00:00
|
|
|
* but the thread doesn't terminate within the timeout specified by
|
|
|
|
* HKCU\Control Panel\Desktop\WaitToKillAppTimeout CSRSS will terminate
|
|
|
|
* the thread. When all the top-level windows have been destroyed CSRSS
|
|
|
|
* will terminate the process.
|
|
|
|
* If the process is a console process, CSRSS will send a CTRL_LOGOFF_EVENT
|
|
|
|
* to the console control handler on logoff. No event is sent on shutdown.
|
|
|
|
* If the handler doesn't respond in time the same activities as for GUI
|
|
|
|
* apps (i.e. display dialog box etc) take place. This also happens if
|
|
|
|
* the handler returns TRUE.
|
|
|
|
* - This ends the processing for the first ExitWindowsEx() call from WinLogon.
|
|
|
|
* Execution continues in WinLogon, which calls ExitWindowsEx() again to
|
|
|
|
* terminate COM processes in the interactive user's session.
|
|
|
|
* - WinLogon stops impersonating the interactive user (whos processes are
|
2005-05-09 01:42:07 +00:00
|
|
|
* all dead by now). and enters log-out state
|
2004-07-12 20:09:35 +00:00
|
|
|
* - If the ExitWindowsEx() request was for a logoff, WinLogon sends a SAS
|
|
|
|
* event (to display the "press ctrl+alt+del") to the GINA. WinLogon then
|
2005-05-09 01:42:07 +00:00
|
|
|
* waits for the GINA to send a SAS event to login.
|
2004-07-12 20:09:35 +00:00
|
|
|
* - If the ExitWindowsEx() request was for shutdown/restart, WinLogon calls
|
|
|
|
* ExitWindowsEx() again in the system process context.
|
|
|
|
* - CSRSS goes through the motions of sending WM_QUERYENDSESSION/WM_ENDSESSION
|
|
|
|
* to GUI processes running in the system process context but won't display
|
|
|
|
* dialog boxes or kill threads/processes. Same for console processes,
|
|
|
|
* using the CTRL_SHUTDOWN_EVENT. The Service Control Manager is one of
|
|
|
|
* these console processes and has a special timeout value WaitToKillServiceTimeout.
|
2005-12-01 22:29:57 +00:00
|
|
|
* - WinLogon issues a "InitiateSystemShutdown" request to the SM (SMSS API # 1)
|
2004-07-12 20:09:35 +00:00
|
|
|
* - the SM propagates the shutdown request to every environment subsystem it
|
|
|
|
* started since bootstrap time (still active ones, of course)
|
|
|
|
* - each environment subsystem, on shutdown request, releases every resource
|
|
|
|
* it aquired during its life (processes, memory etc), then dies
|
|
|
|
* - when every environment subsystem has gone to bed, the SM actually initiates
|
2005-12-01 22:29:57 +00:00
|
|
|
* the kernel and executive shutdown by calling NtShutdownSystem.
|
2004-07-12 20:09:35 +00:00
|
|
|
*/
|
2003-07-10 21:04:32 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2002-10-20 14:54:34 +00:00
|
|
|
ExitWindowsEx(UINT uFlags,
|
|
|
|
DWORD dwReserved)
|
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CSR_API_MESSAGE Request;
|
|
|
|
ULONG CsrRequest;
|
2002-10-20 14:54:34 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CsrRequest = MAKE_CSR_API(EXIT_REACTOS, CSR_GUI);
|
2002-10-20 14:54:34 +00:00
|
|
|
Request.Data.ExitReactosRequest.Flags = uFlags;
|
|
|
|
Request.Data.ExitReactosRequest.Reserved = dwReserved;
|
|
|
|
|
|
|
|
Status = CsrClientCallServer(&Request,
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
NULL,
|
|
|
|
CsrRequest,
|
|
|
|
sizeof(CSR_API_MESSAGE));
|
|
|
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
2002-10-20 14:54:34 +00:00
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2002-10-20 14:54:34 +00:00
|
|
|
RegisterServicesProcess(DWORD ServicesProcessId)
|
|
|
|
{
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CSR_API_MESSAGE Request;
|
|
|
|
ULONG CsrRequest;
|
2002-10-20 14:54:34 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CsrRequest = MAKE_CSR_API(REGISTER_SERVICES_PROCESS, CSR_GUI);
|
2010-06-27 22:19:17 +00:00
|
|
|
Request.Data.RegisterServicesProcessRequest.ProcessId = UlongToHandle(ServicesProcessId);
|
2002-10-20 14:54:34 +00:00
|
|
|
|
|
|
|
Status = CsrClientCallServer(&Request,
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
NULL,
|
|
|
|
CsrRequest,
|
|
|
|
sizeof(CSR_API_MESSAGE));
|
|
|
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
2002-10-20 14:54:34 +00:00
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|