Mini-merge from my local changes. Rewrite of Process Creation. Notable improvements:
[reactos.git] / reactos / ntoskrnl / ex / init.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/ex/init.c
5 * PURPOSE: Executive initalization
6 *
7 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Added ExpInitializeExecutive
8 * and optimized/cleaned it.
9 * Eric Kohl (ekohl@abo.rhein-zeitung.de)
10 */
11
12 #include <ntoskrnl.h>
13 #include <ntos/bootvid.h>
14 #include "../dbg/kdb.h"
15 #define NDEBUG
16 #include <internal/debug.h>
17
18 /* DATA **********************************************************************/
19
20 extern ULONG MmCoreDumpType;
21 extern CHAR KiTimerSystemAuditing;
22 extern PVOID Ki386InitialStackArray[MAXIMUM_PROCESSORS];
23 extern ADDRESS_RANGE KeMemoryMap[64];
24 extern ULONG KeMemoryMapRangeCount;
25 extern ULONG_PTR FirstKrnlPhysAddr;
26 extern ULONG_PTR LastKrnlPhysAddr;
27 extern ULONG_PTR LastKernelAddress;
28 extern LOADER_MODULE KeLoaderModules[64];
29 extern PRTL_MESSAGE_RESOURCE_DATA KiBugCodeMessages;
30 extern LIST_ENTRY KiProfileListHead;
31 extern LIST_ENTRY KiProfileSourceListHead;
32 extern KSPIN_LOCK KiProfileLock;
33
34 VOID PspPostInitSystemProcess(VOID);
35
36 /* FUNCTIONS ****************************************************************/
37
38 static
39 VOID
40 INIT_FUNCTION
41 InitSystemSharedUserPage (PCSZ ParameterLine)
42 {
43 UNICODE_STRING ArcDeviceName;
44 UNICODE_STRING ArcName;
45 UNICODE_STRING BootPath;
46 UNICODE_STRING DriveDeviceName;
47 UNICODE_STRING DriveName;
48 WCHAR DriveNameBuffer[20];
49 PCHAR ParamBuffer;
50 PWCHAR ArcNameBuffer;
51 PCHAR p;
52 NTSTATUS Status;
53 ULONG Length;
54 OBJECT_ATTRIBUTES ObjectAttributes;
55 HANDLE Handle;
56 ULONG i;
57 BOOLEAN BootDriveFound = FALSE;
58
59 /*
60 * NOTE:
61 * The shared user page has been zeroed-out right after creation.
62 * There is NO need to do this again.
63 */
64 Ki386SetProcessorFeatures();
65
66 /* Set the Version Data */
67 SharedUserData->NtProductType = NtProductWinNt;
68 SharedUserData->ProductTypeIsValid = TRUE;
69 SharedUserData->NtMajorVersion = 5;
70 SharedUserData->NtMinorVersion = 0;
71
72 /*
73 * Retrieve the current dos system path
74 * (e.g.: C:\reactos) from the given arc path
75 * (e.g.: multi(0)disk(0)rdisk(0)partititon(1)\reactos)
76 * Format: "<arc_name>\<path> [options...]"
77 */
78
79 /* Create local parameter line copy */
80 ParamBuffer = ExAllocatePool(PagedPool, 256);
81 strcpy (ParamBuffer, (char *)ParameterLine);
82 DPRINT("%s\n", ParamBuffer);
83
84 /* Cut options off */
85 p = strchr (ParamBuffer, ' ');
86 if (p) *p = 0;
87 DPRINT("%s\n", ParamBuffer);
88
89 /* Extract path */
90 p = strchr (ParamBuffer, '\\');
91 if (p) {
92
93 DPRINT("Boot path: %s\n", p);
94 RtlCreateUnicodeStringFromAsciiz (&BootPath, p);
95 *p = 0;
96
97 } else {
98
99 DPRINT("Boot path: %s\n", "\\");
100 RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
101 }
102 DPRINT("Arc name: %s\n", ParamBuffer);
103
104 /* Only ARC Name left - Build full ARC Name */
105 ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
106 swprintf (ArcNameBuffer, L"\\ArcName\\%S", ParamBuffer);
107 RtlInitUnicodeString (&ArcName, ArcNameBuffer);
108 DPRINT("Arc name: %wZ\n", &ArcName);
109
110 /* Free ParamBuffer */
111 ExFreePool (ParamBuffer);
112
113 /* Allocate ARC Device Name string */
114 ArcDeviceName.Length = 0;
115 ArcDeviceName.MaximumLength = 256 * sizeof(WCHAR);
116 ArcDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
117
118 /* Open the Symbolic Link */
119 InitializeObjectAttributes(&ObjectAttributes,
120 &ArcName,
121 OBJ_OPENLINK,
122 NULL,
123 NULL);
124 Status = NtOpenSymbolicLinkObject(&Handle,
125 SYMBOLIC_LINK_ALL_ACCESS,
126 &ObjectAttributes);
127
128 /* Free the String */
129 RtlFreeUnicodeString(&ArcName);
130
131 /* Check for Success */
132 if (!NT_SUCCESS(Status)) {
133
134 /* Free the Strings */
135 RtlFreeUnicodeString(&BootPath);
136 RtlFreeUnicodeString(&ArcDeviceName);
137 CPRINT("NtOpenSymbolicLinkObject() failed (Status %x)\n", Status);
138 KEBUGCHECK(0);
139 }
140
141 /* Query the Link */
142 Status = NtQuerySymbolicLinkObject(Handle,
143 &ArcDeviceName,
144 &Length);
145 NtClose (Handle);
146
147 /* Check for Success */
148 if (!NT_SUCCESS(Status)) {
149
150 /* Free the Strings */
151 RtlFreeUnicodeString(&BootPath);
152 RtlFreeUnicodeString(&ArcDeviceName);
153 CPRINT("NtQuerySymbolicLinkObject() failed (Status %x)\n", Status);
154 KEBUGCHECK(0);
155 }
156 DPRINT("Length: %lu ArcDeviceName: %wZ\n", Length, &ArcDeviceName);
157
158 /* Allocate Device Name string */
159 DriveDeviceName.Length = 0;
160 DriveDeviceName.MaximumLength = 256 * sizeof(WCHAR);
161 DriveDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
162
163 /* Loop Drives */
164 for (i = 0; i < 26; i++) {
165
166 /* Setup the String */
167 swprintf (DriveNameBuffer, L"\\??\\%C:", 'A' + i);
168 RtlInitUnicodeString(&DriveName,
169 DriveNameBuffer);
170
171 /* Open the Symbolic Link */
172 InitializeObjectAttributes(&ObjectAttributes,
173 &DriveName,
174 OBJ_OPENLINK,
175 NULL,
176 NULL);
177 Status = NtOpenSymbolicLinkObject(&Handle,
178 SYMBOLIC_LINK_ALL_ACCESS,
179 &ObjectAttributes);
180
181 /* If it failed, skip to the next drive */
182 if (!NT_SUCCESS(Status)) {
183 DPRINT("Failed to open link %wZ\n", &DriveName);
184 continue;
185 }
186
187 /* Query it */
188 Status = NtQuerySymbolicLinkObject(Handle,
189 &DriveDeviceName,
190 &Length);
191
192 /* If it failed, skip to the next drive */
193 if (!NT_SUCCESS(Status)) {
194 DPRINT("Failed to query link %wZ\n", &DriveName);
195 continue;
196 }
197 DPRINT("Opened link: %wZ ==> %wZ\n", &DriveName, &DriveDeviceName);
198
199 /* See if we've found the boot drive */
200 if (!RtlCompareUnicodeString (&ArcDeviceName, &DriveDeviceName, FALSE)) {
201
202 DPRINT("DOS Boot path: %c:%wZ\n", 'A' + i, &BootPath);
203 swprintf(SharedUserData->NtSystemRoot, L"%C:%wZ", 'A' + i, &BootPath);
204 BootDriveFound = TRUE;
205 }
206
207 /* Close this Link */
208 NtClose (Handle);
209 }
210
211 /* Free all the Strings we have in memory */
212 RtlFreeUnicodeString (&BootPath);
213 RtlFreeUnicodeString (&DriveDeviceName);
214 RtlFreeUnicodeString (&ArcDeviceName);
215
216 /* Make sure we found the Boot Drive */
217 if (BootDriveFound == FALSE) {
218
219 DbgPrint("No system drive found!\n");
220 KEBUGCHECK (NO_BOOT_DEVICE);
221 }
222 }
223
224 inline
225 VOID
226 STDCALL
227 ExecuteRuntimeAsserts(VOID)
228 {
229 /*
230 * Fail at runtime if someone has changed various structures without
231 * updating the offsets used for the assembler code.
232 */
233 ASSERT(FIELD_OFFSET(KTHREAD, InitialStack) == KTHREAD_INITIAL_STACK);
234 ASSERT(FIELD_OFFSET(KTHREAD, Teb) == KTHREAD_TEB);
235 ASSERT(FIELD_OFFSET(KTHREAD, KernelStack) == KTHREAD_KERNEL_STACK);
236 ASSERT(FIELD_OFFSET(KTHREAD, NpxState) == KTHREAD_NPX_STATE);
237 ASSERT(FIELD_OFFSET(KTHREAD, ServiceTable) == KTHREAD_SERVICE_TABLE);
238 ASSERT(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE);
239 ASSERT(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME);
240 ASSERT(FIELD_OFFSET(KTHREAD, CallbackStack) == KTHREAD_CALLBACK_STACK);
241 ASSERT(FIELD_OFFSET(KTHREAD, ApcState.Process) == KTHREAD_APCSTATE_PROCESS);
242 ASSERT(FIELD_OFFSET(KPROCESS, DirectoryTableBase) == KPROCESS_DIRECTORY_TABLE_BASE);
243 ASSERT(FIELD_OFFSET(KPROCESS, IopmOffset) == KPROCESS_IOPM_OFFSET);
244 ASSERT(FIELD_OFFSET(KPROCESS, LdtDescriptor) == KPROCESS_LDT_DESCRIPTOR0);
245 ASSERT(FIELD_OFFSET(KTRAP_FRAME, Reserved9) == KTRAP_FRAME_RESERVED9);
246 ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, SavedExceptionStack) == TF_SAVED_EXCEPTION_STACK);
247 ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, regs) == TF_REGS);
248 ASSERT(FIELD_OFFSET(KV86M_TRAP_FRAME, orig_ebp) == TF_ORIG_EBP);
249 ASSERT(FIELD_OFFSET(KPCR, Tib.ExceptionList) == KPCR_EXCEPTION_LIST);
250 ASSERT(FIELD_OFFSET(KPCR, Self) == KPCR_SELF);
251 ASSERT(FIELD_OFFSET(KPCR, PrcbData) + FIELD_OFFSET(KPRCB, CurrentThread) == KPCR_CURRENT_THREAD);
252 ASSERT(FIELD_OFFSET(KPCR, PrcbData) + FIELD_OFFSET(KPRCB, NpxThread) == KPCR_NPX_THREAD);
253 ASSERT(FIELD_OFFSET(KTSS, Esp0) == KTSS_ESP0);
254 ASSERT(FIELD_OFFSET(KTSS, Eflags) == KTSS_EFLAGS);
255 ASSERT(FIELD_OFFSET(KTSS, IoMapBase) == KTSS_IOMAPBASE);
256 ASSERT(sizeof(FX_SAVE_AREA) == SIZEOF_FX_SAVE_AREA);
257 }
258
259 inline
260 VOID
261 STDCALL
262 ParseAndCacheLoadedModules(PBOOLEAN SetupBoot)
263 {
264 ULONG i;
265 PCHAR Name;
266
267 /* Loop the Module List and get the modules we want */
268 for (i = 1; i < KeLoaderBlock.ModsCount; i++) {
269
270 /* Get the Name of this Module */
271 if (!(Name = strrchr((PCHAR)KeLoaderModules[i].String, '\\'))) {
272
273 /* Save the name */
274 Name = (PCHAR)KeLoaderModules[i].String;
275
276 } else {
277
278 /* No name, skip */
279 Name++;
280 }
281
282 /* Now check for any of the modules we will need later */
283 if (!_stricmp(Name, "ansi.nls")) {
284
285 CachedModules[AnsiCodepage] = &KeLoaderModules[i];
286
287 } else if (!_stricmp(Name, "oem.nls")) {
288
289 CachedModules[OemCodepage] = &KeLoaderModules[i];
290
291 } else if (!_stricmp(Name, "casemap.nls")) {
292
293 CachedModules[UnicodeCasemap] = &KeLoaderModules[i];
294
295 } else if (!_stricmp(Name, "system") || !_stricmp(Name, "system.hiv")) {
296
297 CachedModules[SystemRegistry] = &KeLoaderModules[i];
298 *SetupBoot = FALSE;
299
300 } else if (!_stricmp(Name, "hardware") || !_stricmp(Name, "hardware.hiv")) {
301
302 CachedModules[HardwareRegistry] = &KeLoaderModules[i];
303 }
304 }
305 }
306
307 inline
308 VOID
309 STDCALL
310 ParseCommandLine(PULONG MaxMem,
311 PBOOLEAN NoGuiBoot,
312 PBOOLEAN BootLog,
313 PBOOLEAN ForceAcpiDisable)
314 {
315 PCHAR p1, p2;
316
317 p1 = (PCHAR)KeLoaderBlock.CommandLine;
318 while(*p1 && (p2 = strchr(p1, '/'))) {
319
320 p2++;
321 if (!_strnicmp(p2, "MAXMEM", 6)) {
322
323 p2 += 6;
324 while (isspace(*p2)) p2++;
325
326 if (*p2 == '=') {
327
328 p2++;
329
330 while(isspace(*p2)) p2++;
331
332 if (isdigit(*p2)) {
333 while (isdigit(*p2)) {
334 *MaxMem = *MaxMem * 10 + *p2 - '0';
335 p2++;
336 }
337 break;
338 }
339 }
340 } else if (!_strnicmp(p2, "NOGUIBOOT", 9)) {
341
342 p2 += 9;
343 *NoGuiBoot = TRUE;
344
345 } else if (!_strnicmp(p2, "CRASHDUMP", 9)) {
346
347 p2 += 9;
348 if (*p2 == ':') {
349
350 p2++;
351 if (!_strnicmp(p2, "FULL", 4)) {
352
353 MmCoreDumpType = MM_CORE_DUMP_TYPE_FULL;
354
355 } else {
356
357 MmCoreDumpType = MM_CORE_DUMP_TYPE_NONE;
358 }
359 }
360 } else if (!_strnicmp(p2, "BOOTLOG", 7)) {
361
362 p2 += 7;
363 *BootLog = TRUE;
364 } else if (!_strnicmp(p2, "NOACPI", 6)) {
365
366 p2 += 6;
367 *ForceAcpiDisable = TRUE;
368 }
369
370 p1 = p2;
371 }
372 }
373
374 VOID
375 INIT_FUNCTION
376 STDCALL
377 ExpInitializeExecutive(VOID)
378 {
379 CHAR str[50];
380 UNICODE_STRING EventName;
381 HANDLE InitDoneEventHandle;
382 OBJECT_ATTRIBUTES ObjectAttributes;
383 BOOLEAN NoGuiBoot = FALSE;
384 BOOLEAN BootLog = FALSE;
385 ULONG MaxMem = 0;
386 BOOLEAN SetupBoot = TRUE;
387 BOOLEAN ForceAcpiDisable = FALSE;
388 LARGE_INTEGER Timeout;
389 HANDLE ProcessHandle;
390 HANDLE ThreadHandle;
391 NTSTATUS Status;
392
393 /* Check if the structures match the ASM offset constants */
394 ExecuteRuntimeAsserts();
395
396 /* Sets up the Text Sections of the Kernel and HAL for debugging */
397 LdrInit1();
398
399 /* Lower the IRQL to Dispatch Level */
400 KeLowerIrql(DISPATCH_LEVEL);
401
402 /* Sets up the VDM Data */
403 NtEarlyInitVdm();
404
405 /* Parse Command Line Settings */
406 ParseCommandLine(&MaxMem, &NoGuiBoot, &BootLog, &ForceAcpiDisable);
407
408 /* Initialize Kernel Memory Address Space */
409 MmInit1(FirstKrnlPhysAddr,
410 LastKrnlPhysAddr,
411 LastKernelAddress,
412 (PADDRESS_RANGE)&KeMemoryMap,
413 KeMemoryMapRangeCount,
414 MaxMem > 8 ? MaxMem : 4096);
415
416 /* Parse the Loaded Modules (by FreeLoader) and cache the ones we'll need */
417 ParseAndCacheLoadedModules(&SetupBoot);
418
419 /* Initialize the kernel debugger */
420 KdInitSystem (1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
421
422 /* Initialize the Dispatcher, Clock and Bug Check Mechanisms. */
423 KeInit2();
424
425 /* Bring back the IRQL to Passive */
426 KeLowerIrql(PASSIVE_LEVEL);
427
428 /* Initialize Profiling */
429 InitializeListHead(&KiProfileListHead);
430 InitializeListHead(&KiProfileSourceListHead);
431 KeInitializeSpinLock(&KiProfileLock);
432
433 /* Load basic Security for other Managers */
434 if (!SeInit1()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
435
436 /* Create the Basic Object Manager Types to allow new Object Types */
437 ObInit();
438
439 /* Initialize Lookaside Lists */
440 ExInit2();
441
442 /* Set up Region Maps, Sections and the Paging File */
443 MmInit2();
444
445 /* Initialize Tokens now that the Object Manager is ready */
446 if (!SeInit2()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
447
448 /* Set 1 CPU for now, we'll increment this later */
449 KeNumberProcessors = 1;
450
451 /* Initalize the Process Manager */
452 PiInitProcessManager();
453
454 /* Break into the Debugger if requested */
455 if (KdPollBreakIn()) DbgBreakPointWithStatus (DBG_STATUS_CONTROL_C);
456
457 /* Initialize all processors */
458 while (!HalAllProcessorsStarted()) {
459
460 PVOID ProcessorStack;
461
462 /* Set up the Kernel and Process Manager for this CPU */
463 KePrepareForApplicationProcessorInit(KeNumberProcessors);
464 PsPrepareForApplicationProcessorInit(KeNumberProcessors);
465
466 /* Allocate a stack for use when booting the processor */
467 ProcessorStack = Ki386InitialStackArray[((int)KeNumberProcessors)] + MM_STACK_SIZE;
468
469 /* Tell HAL a new CPU is being started */
470 HalStartNextProcessor(0, (ULONG)ProcessorStack - 2*sizeof(FX_SAVE_AREA));
471 KeNumberProcessors++;
472 }
473
474 /* Do Phase 1 HAL Initalization */
475 HalInitSystem(1, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
476
477 /* Initialize Basic System Objects and Worker Threads */
478 ExInit3();
479
480 /* Create the system handle table, assign it to the system process, create
481 the client id table and assign a PID for the system process. This needs
482 to be done before the worker threads are initialized so the system
483 process gets the first PID (4) */
484 PspPostInitSystemProcess();
485
486 /* initialize the worker threads */
487 ExpInitializeWorkerThreads();
488
489 /* initialize callbacks */
490 ExpInitializeCallbacks();
491
492 /* Initialize the GDB Stub and break */
493 KdInit1();
494
495 /* Initialize I/O Objects, Filesystems, Error Logging and Shutdown */
496 IoInit();
497
498 /* TBD */
499 PoInit((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock, ForceAcpiDisable);
500
501 /* Initialize the Registry (Hives are NOT yet loaded!) */
502 CmInitializeRegistry();
503
504 /* Unmap Low memory, initialize the Page Zeroing and the Balancer Thread */
505 MmInit3();
506
507 /* Initialize Cache Views */
508 CcInit();
509
510 /* Hook System Interrupt for the Debugger */
511 KdInit2();
512
513 /* Initialize File Locking */
514 FsRtlpInitFileLockingImplementation();
515
516 /* Report all resources used by hal */
517 HalReportResourceUsage();
518
519 /* Clear the screen to blue */
520 HalInitSystem(2, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
521
522 /* Display version number and copyright/warranty message */
523 HalDisplayString("Starting ReactOS "KERNEL_VERSION_STR" (Build "
524 KERNEL_VERSION_BUILD_STR")\n");
525 HalDisplayString(RES_STR_LEGAL_COPYRIGHT);
526 HalDisplayString("\n\nReactOS is free software, covered by the GNU General "
527 "Public License, and you\n");
528 HalDisplayString("are welcome to change it and/or distribute copies of it "
529 "under certain\n");
530 HalDisplayString("conditions. There is absolutely no warranty for "
531 "ReactOS.\n\n");
532
533 /* Display number of Processors */
534 sprintf(str,
535 "Found %d system processor(s). [%lu MB Memory]\n",
536 KeNumberProcessors,
537 (KeLoaderBlock.MemHigher + 1088)/ 1024);
538 HalDisplayString(str);
539
540 /* Print which Debugger is being used */
541 KdInit3();
542
543 /* Import and create NLS Data and Sections */
544 RtlpInitNls();
545
546 /* Import and Load Registry Hives */
547 CmInitHives(SetupBoot);
548
549 /* Initialize the time zone information from the registry */
550 ExpInitTimeZoneInfo();
551
552 /* Enter the kernel debugger before starting up the boot drivers */
553 #ifdef KDBG
554 KdbEnter();
555 #endif /* KDBG */
556
557 /* Setup Drivers and Root Device Node */
558 IoInit2(BootLog);
559
560 /* Display the boot screen image if not disabled */
561 if (!NoGuiBoot) InbvEnableBootDriver(TRUE);
562
563 /* Create ARC Names, SystemRoot SymLink, Load Drivers and Assign Letters */
564 IoInit3();
565
566 /* Load the System DLL and its Entrypoints */
567 LdrpInitializeSystemDll();
568
569 /* Initialize the Default Locale */
570 PiInitDefaultLocale();
571
572 /* Initialize shared user page. Set dos system path, dos device map, etc. */
573 InitSystemSharedUserPage ((PCHAR)KeLoaderBlock.CommandLine);
574
575 /* Create 'ReactOSInitDone' event */
576 RtlInitUnicodeString(&EventName, L"\\ReactOSInitDone");
577 InitializeObjectAttributes(&ObjectAttributes,
578 &EventName,
579 0,
580 NULL,
581 NULL);
582 Status = ZwCreateEvent(&InitDoneEventHandle,
583 EVENT_ALL_ACCESS,
584 &ObjectAttributes,
585 SynchronizationEvent,
586 FALSE);
587
588 /* Check for Success */
589 if (!NT_SUCCESS(Status)) {
590
591 DPRINT1("Failed to create 'ReactOSInitDone' event (Status 0x%x)\n", Status);
592 InitDoneEventHandle = INVALID_HANDLE_VALUE;
593 }
594
595 /* Launch initial process */
596 Status = LdrLoadInitialProcess(&ProcessHandle,
597 &ThreadHandle);
598
599 /* Check for success, Bugcheck if we failed */
600 if (!NT_SUCCESS(Status)) {
601
602 KEBUGCHECKEX(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
603 }
604
605 /* Wait on the Completion Event */
606 if (InitDoneEventHandle != INVALID_HANDLE_VALUE) {
607
608 HANDLE Handles[2]; /* Init event, Initial process */
609
610 /* Setup the Handles to wait on */
611 Handles[0] = InitDoneEventHandle;
612 Handles[1] = ProcessHandle;
613
614 /* Wait for the system to be initialized */
615 Timeout.QuadPart = (LONGLONG)-1200000000; /* 120 second timeout */
616 Status = ZwWaitForMultipleObjects(2,
617 Handles,
618 WaitAny,
619 FALSE,
620 &Timeout);
621 if (!NT_SUCCESS(Status)) {
622
623 DPRINT1("NtWaitForMultipleObjects failed with status 0x%x!\n", Status);
624
625 } else if (Status == STATUS_TIMEOUT) {
626
627 DPRINT1("WARNING: System not initialized after 120 seconds.\n");
628
629 } else if (Status == STATUS_WAIT_0 + 1) {
630
631 /* Crash the system if the initial process was terminated. */
632 KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 0, 0, 0);
633 }
634
635 /* Disable the Boot Logo */
636 if (!NoGuiBoot) InbvEnableBootDriver(FALSE);
637
638 /* Signal the Event and close the handle */
639 ZwSetEvent(InitDoneEventHandle, NULL);
640 ZwClose(InitDoneEventHandle);
641
642 } else {
643
644 /* On failure to create 'ReactOSInitDone' event, go to text mode ASAP */
645 if (!NoGuiBoot) InbvEnableBootDriver(FALSE);
646
647 /* Crash the system if the initial process terminates within 5 seconds. */
648 Timeout.QuadPart = (LONGLONG)-50000000; /* 5 second timeout */
649 Status = ZwWaitForSingleObject(ProcessHandle,
650 FALSE,
651 &Timeout);
652
653 /* Check for timeout, crash if the initial process didn't initalize */
654 if (Status != STATUS_TIMEOUT) KEBUGCHECKEX(SESSION5_INITIALIZATION_FAILED, Status, 1, 0, 0);
655 }
656
657 /* Enable the Clock, close remaining handles */
658 KiTimerSystemAuditing = 1;
659 ZwClose(ThreadHandle);
660 ZwClose(ProcessHandle);
661 }
662
663 VOID INIT_FUNCTION
664 ExInit2(VOID)
665 {
666 ExpInitLookasideLists();
667 }
668
669 VOID INIT_FUNCTION
670 ExInit3 (VOID)
671 {
672 ExpInitializeEventImplementation();
673 ExpInitializeEventPairImplementation();
674 ExpInitializeMutantImplementation();
675 ExpInitializeSemaphoreImplementation();
676 ExpInitializeTimerImplementation();
677 LpcpInitSystem();
678 ExpInitializeProfileImplementation();
679 ExpWin32kInit();
680 ExpInitUuids();
681 ExpInitializeHandleTables();
682 }
683
684 /* EOF */