ReactOS 0.4.15-dev-7942-gd23573b
shutdown.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/consrv/shutdown.c
5 * PURPOSE: Processes Shutdown
6 * PROGRAMMERS: Alex Ionescu
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "consrv.h"
12#include <psapi.h>
13
14#define NDEBUG
15#include <debug.h>
16
17/* FUNCTIONS ******************************************************************/
18
19static void
21 IN PCONSOLE_PROCESS_DATA ProcessData,
23{
24 DPRINT1("ConsoleClientShutdown(0x%p, 0x%x) - Console process [0x%x, 0x%x]\n",
25 CsrProcess, Flags, CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);
26
27 /* Send a log-off event. In reality this should be way more complex */
30}
31
32static BOOL
35{
36 /* FIXME: Implement the generic process shutdown handler */
38
39 return TRUE;
40}
41
46{
48 {
49 /* Terminate this process */
50#if DBG
53 {
54 DPRINT1("Terminating process %x\n", Process->ClientId.UniqueProcess);
55 }
56 else
57 {
58 DPRINT1("Terminating process %x (%S)\n", Process->ClientId.UniqueProcess, buffer);
59 }
60#endif
61 NtTerminateProcess(Process->ProcessHandle, 0);
63 }
64
67}
68
69// NOTE: See http://blogs.msdn.com/b/ntdebugging/archive/2007/06/09/how-windows-shuts-down.aspx
74 IN BOOLEAN FirstPhase)
75{
77
78 /* Do not kill system processes when a user is logging off */
79 if ((Flags & EWX_SHUTDOWN) == EWX_LOGOFF &&
80 (CsrProcess->ShutdownFlags & (CsrShutdownSystem | CsrShutdownOther)))
81 {
82 DPRINT("Do not kill a system process in a logoff request!\n");
84 }
85
86 /* Is it a console process? */
87 if ( ProcessData->ConsoleHandle != NULL ||
88 ProcessData->HandleTable != NULL )
89 {
91
92 /* We are done with the process itself */
95 }
96 else
97 {
98 DPRINT("ConsoleClientShutdown(0x%p, 0x%x, %s) - Non-console process [0x%x, 0x%x]\n",
99 CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
100 CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);
101
102 /* On first pass, let the gui server terminate all the processes that it owns */
103 if (FirstPhase) return CsrShutdownNonCsrProcess;
104
105 /* Use the generic handler since this isn't a gui process */
107 }
108
110}
111
112/* EOF */
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
@ CsrShutdownOther
Definition: csrsrv.h:120
@ CsrShutdownSystem
Definition: csrsrv.h:119
@ CsrShutdownNonCsrProcess
Definition: csrsrv.h:113
@ CsrShutdownCsrProcess
Definition: csrsrv.h:112
VOID NTAPI CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:691
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetProcessImageFileNameW(HANDLE hProcess, LPWSTR lpImageFileName, DWORD nSize)
Definition: psapi.c:1163
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
GLuint buffer
Definition: glext.h:5915
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
#define DPRINT
Definition: sndvol32.h:71
HANDLE ConsoleHandle
Definition: consrv.h:45
struct _CONSOLE_IO_HANDLE * HandleTable
Definition: consrv.h:50
ULONG WaitToKillAppTimeout
Definition: winsrv.h:52
ULONG ProcessTerminateTimeout
Definition: winsrv.h:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define UNIMPLEMENTED_ONCE
Definition: typedefs.h:30
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
PKPROCESS CsrProcess
Definition: videoprt.c:39
NTSTATUS ConSrvConsoleCtrlEventTimeout(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Timeout)
Definition: console.c:1305
static void NotifyConsoleProcessForShutdown(IN PCSR_PROCESS CsrProcess, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Flags)
Definition: shutdown.c:20
ULONG NTAPI NonConsoleProcessShutdown(IN PCSR_PROCESS Process, IN ULONG Flags)
Definition: shutdown.c:44
ULONG NTAPI ConsoleClientShutdown(IN PCSR_PROCESS CsrProcess, IN ULONG Flags, IN BOOLEAN FirstPhase)
Definition: shutdown.c:72
static BOOL NotifyGenericProcessForShutdown(IN PCSR_PROCESS CsrProcess, IN ULONG Flags)
Definition: shutdown.c:33
SHUTDOWN_SETTINGS ShutdownSettings
Definition: init.c:24
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:72
#define EWX_SHUTDOWN
Definition: winuser.h:639
#define EWX_LOGOFF
Definition: winuser.h:636
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180