* Sync up to trunk head (r65481).
[reactos.git] / win32ss / user / winsrv / consrv / shutdown.c
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
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS ******************************************************************/
17
18 // NOTE: See http://blogs.msdn.com/b/ntdebugging/archive/2007/06/09/how-windows-shuts-down.aspx
19 ULONG
20 NTAPI
21 ConsoleClientShutdown(IN PCSR_PROCESS CsrProcess,
22 IN ULONG Flags,
23 IN BOOLEAN FirstPhase)
24 {
25 PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
26
27 if ( ProcessData->ConsoleHandle != NULL ||
28 ProcessData->HandleTable != NULL )
29 {
30 DPRINT1("ConsoleClientShutdown(0x%p, 0x%x, %s) - Console process [0x%x, 0x%x]\n",
31 CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
32 CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);
33
34 /* We are done with the process itself */
35 CsrDereferenceProcess(CsrProcess);
36 return CsrShutdownCsrProcess;
37 }
38 else
39 {
40 DPRINT1("ConsoleClientShutdown(0x%p, 0x%x, %s) - Non-console process [0x%x, 0x%x]\n",
41 CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
42 CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);
43
44 /* On first pass, ignore the process since the GUI server should take it... */
45 if (FirstPhase) return CsrShutdownNonCsrProcess;
46
47 /* ... otherwise, call the generic handler */
48 // FIXME: Should call a generic shutdown handler!!
49 CsrDereferenceProcess(CsrProcess);
50 return CsrShutdownCsrProcess;
51 }
52
53 return CsrShutdownNonCsrProcess;
54 }
55
56 /* EOF */