ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

exit.c
Go to the documentation of this file.
00001 /* 
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS user32.dll
00004  * FILE:            lib/user32/misc/exit.c
00005  * PURPOSE:         Shutdown related functions
00006  * PROGRAMMER:      Eric Kohl
00007  */
00008 
00009 #include <user32.h>
00010 
00011 #include <wine/debug.h>
00012 
00013 /*
00014  * Sequence of events:
00015  *
00016  * - App (usually explorer) calls ExitWindowsEx()
00017  * - ExitWindowsEx() sends a message to CSRSS
00018  * - CSRSS impersonates the caller and sends a message to a hidden WinLogon window
00019  * - WinLogon checks if the caller has the required privileges
00020  * - WinLogon enters pending log-out state
00021  * - WinLogon impersonates the interactive user and calls ExitWindowsEx() again,
00022  *   passing some special internal flags
00023  * - CSRSS loops over all processes of the interactive user (sorted by their
00024  *   SetProcessShutdownParameters() level), sending WM_QUERYENDSESSION and
00025  *   WM_ENDSESSION messages to its top-level windows. If the messages aren't
00026  *   processed within the timeout period (registry key HKCU\Control Panel\Desktop\HungAppTimeout)
00027  *   CSRSS will put up a dialog box asking if the process should be terminated.
00028  *   Using the registry key HKCU\Control Panel\Desktop\AutoEndTask you can
00029  *   specify that the dialog box shouldn't be shown and CSRSS should just
00030  *   terminate the thread. If the the WM_ENDSESSION message is processed
00031  *   but the thread doesn't terminate within the timeout specified by
00032  *   HKCU\Control Panel\Desktop\WaitToKillAppTimeout CSRSS will terminate
00033  *   the thread. When all the top-level windows have been destroyed CSRSS
00034  *   will terminate the process.
00035  *   If the process is a console process, CSRSS will send a CTRL_LOGOFF_EVENT
00036  *   to the console control handler on logoff. No event is sent on shutdown.
00037  *   If the handler doesn't respond in time the same activities as for GUI
00038  *   apps (i.e. display dialog box etc) take place. This also happens if
00039  *   the handler returns TRUE.
00040  * - This ends the processing for the first ExitWindowsEx() call from WinLogon.
00041  *   Execution continues in WinLogon, which calls ExitWindowsEx() again to
00042  *   terminate COM processes in the interactive user's session.
00043  * - WinLogon stops impersonating the interactive user (whos processes are
00044  *   all dead by now). and enters log-out state
00045  * - If the ExitWindowsEx() request was for a logoff, WinLogon sends a SAS
00046  *   event (to display the "press ctrl+alt+del") to the GINA. WinLogon then
00047  *   waits for the GINA to send a SAS event to login.
00048  * - If the ExitWindowsEx() request was for shutdown/restart, WinLogon calls
00049  *   ExitWindowsEx() again in the system process context.
00050  * - CSRSS goes through the motions of sending WM_QUERYENDSESSION/WM_ENDSESSION
00051  *   to GUI processes running in the system process context but won't display
00052  *   dialog boxes or kill threads/processes. Same for console processes,
00053  *   using the CTRL_SHUTDOWN_EVENT. The Service Control Manager is one of
00054  *   these console processes and has a special timeout value WaitToKillServiceTimeout.
00055  * - WinLogon issues a "InitiateSystemShutdown" request to the SM (SMSS API # 1)
00056  * - the SM propagates the shutdown request to every environment subsystem it
00057  *   started since bootstrap time (still active ones, of course)
00058  * - each environment subsystem, on shutdown request, releases every resource
00059  *   it aquired during its life (processes, memory etc), then dies
00060  * - when every environment subsystem has gone to bed, the SM actually initiates
00061  *   the kernel and executive shutdown by calling NtShutdownSystem.
00062  */
00063 /*
00064  * @implemented
00065  */
00066 BOOL WINAPI
00067 ExitWindowsEx(UINT uFlags,
00068           DWORD dwReserved)
00069 {
00070   CSR_API_MESSAGE Request;
00071   ULONG CsrRequest;
00072   NTSTATUS Status;
00073 
00074   CsrRequest = MAKE_CSR_API(EXIT_REACTOS, CSR_GUI);
00075   Request.Data.ExitReactosRequest.Flags = uFlags;
00076   Request.Data.ExitReactosRequest.Reserved = dwReserved;
00077 
00078   Status = CsrClientCallServer(&Request,
00079                    NULL,
00080                    CsrRequest,
00081                    sizeof(CSR_API_MESSAGE));
00082   if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
00083     {
00084       SetLastError(RtlNtStatusToDosError(Status));
00085       return(FALSE);
00086     }
00087 
00088   return(TRUE);
00089 }
00090 
00091 
00092 /*
00093  * @implemented
00094  */
00095 BOOL WINAPI
00096 RegisterServicesProcess(DWORD ServicesProcessId)
00097 {
00098   CSR_API_MESSAGE Request;
00099   ULONG CsrRequest;
00100   NTSTATUS Status;
00101 
00102   CsrRequest = MAKE_CSR_API(REGISTER_SERVICES_PROCESS, CSR_GUI);
00103   Request.Data.RegisterServicesProcessRequest.ProcessId = UlongToHandle(ServicesProcessId);
00104 
00105   Status = CsrClientCallServer(&Request,
00106                    NULL,
00107                    CsrRequest,
00108                    sizeof(CSR_API_MESSAGE));
00109   if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
00110     {
00111       SetLastError(RtlNtStatusToDosError(Status));
00112       return(FALSE);
00113     }
00114 
00115   return(TRUE);
00116 }
00117 
00118 /* EOF */

Generated on Fri May 25 2012 04:37:09 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.