a8880e253ecb1f669901d504598901450a585a38
[reactos.git] / reactos / subsys / smss / init.c
1 /* $Id$
2 *
3 * init.c - Session Manager initialization
4 *
5 * ReactOS Operating System
6 *
7 * --------------------------------------------------------------------
8 *
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This software is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this software; see the file COPYING.LIB. If not, write
21 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
22 * MA 02139, USA.
23 *
24 * --------------------------------------------------------------------
25 */
26
27 #include "smss.h"
28 #include <rosrtl/string.h>
29
30 #define NDEBUG
31 #include <debug.h>
32
33
34 /* FUNCTIONS ****************************************************************/
35
36 static NTSTATUS
37 SmpSignalInitEvent(VOID)
38 {
39 NTSTATUS Status = STATUS_SUCCESS;
40 OBJECT_ATTRIBUTES ObjectAttributes = {0};
41 UNICODE_STRING EventName ={0};
42 HANDLE ReactOSInitEvent = (HANDLE) 0;
43
44 RtlInitUnicodeString (& EventName, L"\\ReactOSInitDone");
45 InitializeObjectAttributes(&ObjectAttributes,
46 & EventName,
47 EVENT_ALL_ACCESS,
48 0,
49 NULL);
50 Status = NtOpenEvent(&ReactOSInitEvent,
51 EVENT_ALL_ACCESS,
52 &ObjectAttributes);
53 if (NT_SUCCESS(Status))
54 {
55 LARGE_INTEGER Timeout;
56 /* This will cause the boot screen image to go away (if displayed) */
57 NtPulseEvent(ReactOSInitEvent, NULL);
58
59 /* Wait for the display mode to be changed (if in graphics mode) */
60 Timeout.QuadPart = -50000000LL; /* 5 second timeout */
61 NtWaitForSingleObject(ReactOSInitEvent, FALSE, &Timeout);
62
63 NtClose(ReactOSInitEvent);
64 }
65 else
66 {
67 /* We don't really care if this fails */
68 DPRINT1("SM: Failed to open ReactOS init notification event\n");
69 }
70 return Status;
71 }
72
73 typedef NTSTATUS (* SM_INIT_ROUTINE)(VOID);
74
75 struct {
76 BOOL Required;
77 SM_INIT_ROUTINE EntryPoint;
78 PCHAR ErrorMessage;
79 } InitRoutine [] = {
80 {TRUE, SmCreateHeap, "create private heap, aborting"},
81 {TRUE, SmCreateObjectDirectories, "create object directories"},
82 {TRUE, SmCreateApiPort, "create \\SmApiPort"},
83 {TRUE, SmCreateEnvironment, "create the system environment"},
84 {TRUE, SmSetEnvironmentVariables, "set system environment variables"},
85 {TRUE, SmInitDosDevices, "create dos device links"},
86 {TRUE, SmRunBootApplications, "run boot applications"},
87 {TRUE, SmProcessFileRenameList, "process the file rename list"},
88 {FALSE, SmLoadKnownDlls, "preload system DLLs"},
89 {TRUE, SmCreatePagingFiles, "create paging files"},
90 {TRUE, SmInitializeRegistry, "initialize the registry"},
91 {FALSE, SmUpdateEnvironment, "update environment variables"},
92 {TRUE, SmInitializeClientManagement, "initialize client management"},
93 {TRUE, SmLoadSubsystems, "load subsystems"},
94 {FALSE, SmpSignalInitEvent, "open ReactOS init notification event"},
95 };
96
97 NTSTATUS
98 InitSessionManager(VOID)
99 {
100 INT i = 0;
101 NTSTATUS Status = STATUS_SUCCESS;
102
103 for (i=0; i < (sizeof InitRoutine / sizeof InitRoutine[0]); i++)
104 {
105 Status = InitRoutine[i].EntryPoint();
106 if(!NT_SUCCESS(Status))
107 {
108 DPRINT1("SM: %s: failed to %s (Status=%lx)\n",
109 __FUNCTION__,
110 InitRoutine[i].ErrorMessage,
111 Status);
112 if (InitRoutine[i].Required)
113 {
114 return(Status);
115 }
116 }
117 }
118 return(STATUS_SUCCESS);
119 }
120
121 /* EOF */