ReactOS  0.4.14-dev-52-g6116262
shutdown.c File Reference
#include "consrv.h"
#include <psapi.h>
#include <debug.h>
Include dependency graph for shutdown.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static void NotifyConsoleProcessForShutdown (IN PCSR_PROCESS CsrProcess, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Flags)
 
static BOOL NotifyGenericProcessForShutdown (IN PCSR_PROCESS CsrProcess, IN ULONG Flags)
 
ULONG NTAPI NonConsoleProcessShutdown (IN PCSR_PROCESS Process, IN ULONG Flags)
 
ULONG NTAPI ConsoleClientShutdown (IN PCSR_PROCESS CsrProcess, IN ULONG Flags, IN BOOLEAN FirstPhase)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file shutdown.c.

Function Documentation

◆ ConsoleClientShutdown()

ULONG NTAPI ConsoleClientShutdown ( IN PCSR_PROCESS  CsrProcess,
IN ULONG  Flags,
IN BOOLEAN  FirstPhase 
)

Definition at line 73 of file shutdown.c.

76 {
77  PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
78 
79  /* Do not kill system processes when a user is logging off */
80  if ((Flags & EWX_SHUTDOWN) == EWX_LOGOFF &&
81  (CsrProcess->ShutdownFlags & (CsrShutdownSystem | CsrShutdownOther)))
82  {
83  DPRINT("Do not kill a system process in a logoff request!\n");
85  }
86 
87  /* Is it a console process? */
88  if ( ProcessData->ConsoleHandle != NULL ||
89  ProcessData->HandleTable != NULL )
90  {
91  NotifyConsoleProcessForShutdown(CsrProcess, ProcessData, Flags);
92 
93  /* We are done with the process itself */
94  CsrDereferenceProcess(CsrProcess);
95  return CsrShutdownCsrProcess;
96  }
97  else
98  {
99  DPRINT("ConsoleClientShutdown(0x%p, 0x%x, %s) - Non-console process [0x%x, 0x%x]\n",
100  CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
101  CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);
102 
103  /* On first pass, let the gui server terminate all the processes that it owns */
104  if (FirstPhase) return CsrShutdownNonCsrProcess;
105 
106  /* Use the generic handler since this isn't a gui process */
107  return NonConsoleProcessShutdown(CsrProcess, Flags);
108  }
109 
111 }
HANDLE ConsoleHandle
Definition: consrv.h:45
VOID NTAPI CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:690
#define EWX_LOGOFF
Definition: winuser.h:631
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define EWX_SHUTDOWN
Definition: winuser.h:634
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static void NotifyConsoleProcessForShutdown(IN PCSR_PROCESS CsrProcess, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Flags)
Definition: shutdown.c:20
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
ULONG NTAPI NonConsoleProcessShutdown(IN PCSR_PROCESS Process, IN ULONG Flags)
Definition: shutdown.c:44
struct _CONSOLE_IO_HANDLE * HandleTable
Definition: consrv.h:50

Referenced by CSR_SERVER_DLL_INIT().

◆ NonConsoleProcessShutdown()

ULONG NTAPI NonConsoleProcessShutdown ( IN PCSR_PROCESS  Process,
IN ULONG  Flags 
)

Definition at line 44 of file shutdown.c.

46 {
48  {
49  /* Terminate this process */
50 #if DBG
52  if (!GetProcessImageFileNameW(Process->ProcessHandle, buffer, MAX_PATH))
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 
62  NtTerminateProcess(Process->ProcessHandle, 0);
64  }
65 
67  return CsrShutdownCsrProcess;
68 }
GLuint buffer
Definition: glext.h:5915
VOID NTAPI CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:690
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG ProcessTerminateTimeout
Definition: winsrv.h:52
static BOOL NotifyGenericProcessForShutdown(IN PCSR_PROCESS CsrProcess, IN ULONG Flags)
Definition: shutdown.c:33
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
SHUTDOWN_SETTINGS ShutdownSettings
Definition: init.c:24
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
DWORD WINAPI GetProcessImageFileNameW(HANDLE hProcess, LPWSTR lpImageFileName, DWORD nSize)
Definition: psapi.c:1179
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)

Referenced by ConsoleClientShutdown().

◆ NotifyConsoleProcessForShutdown()

static void NotifyConsoleProcessForShutdown ( IN PCSR_PROCESS  CsrProcess,
IN PCONSOLE_PROCESS_DATA  ProcessData,
IN ULONG  Flags 
)
static

Definition at line 20 of file shutdown.c.

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 }
NTSTATUS ConSrvConsoleCtrlEventTimeout(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Timeout)
Definition: console.c:809
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define CTRL_LOGOFF_EVENT
Definition: wincon.h:69
ULONG WaitToKillAppTimeout
Definition: winsrv.h:50
SHUTDOWN_SETTINGS ShutdownSettings
Definition: init.c:24
#define DPRINT1
Definition: precomp.h:8

Referenced by ConsoleClientShutdown().

◆ NotifyGenericProcessForShutdown()

static BOOL NotifyGenericProcessForShutdown ( IN PCSR_PROCESS  CsrProcess,
IN ULONG  Flags 
)
static

Definition at line 33 of file shutdown.c.

35 {
36  /* FIXME: Implement the generic process shutdown handler */
38 
39  return TRUE;
40 }
#define UNIMPLEMENTED_ONCE
Definition: debug.h:138
#define TRUE
Definition: types.h:120

Referenced by NonConsoleProcessShutdown().