https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3dffe964a3f7b5af7e627…
commit 3dffe964a3f7b5af7e6277707ae97d78c8d755f2
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Fri Jun 9 16:37:53 2017 +0000
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed Oct 24 00:55:16 2018 +0200
[USETUP] Reshuffle a bit the main-function of USetup.
svn path=/branches/setup_improvements/; revision=74975
---
base/setup/usetup/usetup.c | 57 ++++++++++++++++++++++++++++++++++------------
1 file changed, 43 insertions(+), 14 deletions(-)
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index d83be76f24..9170b23225 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -4855,16 +4855,22 @@ PnpEventThread(IN LPVOID lpParameter);
/*
* The start routine and page management
*/
-VOID
+NTSTATUS
RunUSetup(VOID)
{
+ NTSTATUS Status;
INPUT_RECORD Ir;
PAGE_NUMBER Page;
- LARGE_INTEGER Time;
- NTSTATUS Status;
BOOLEAN Old;
- NtQuerySystemTime(&Time);
+ InfSetHeap(ProcessHeap);
+
+#if 0
+ /* Tell the Cm this is a setup boot, and it has to behave accordingly */
+ Status = NtInitializeRegistry(CM_BOOT_FLAG_SETUP);
+ if (!NT_SUCCESS(Status))
+ DPRINT1("NtInitializeRegistry() failed (Status 0x%08lx)\n", Status);
+#endif
/* Create the PnP thread in suspended state */
Status = RtlCreateUserThread(NtCurrentProcess(),
@@ -4886,9 +4892,8 @@ RunUSetup(VOID)
PrintString(MUIGetString(STRING_CONSOLEFAIL2));
PrintString(MUIGetString(STRING_CONSOLEFAIL3));
- /* Raise a hard error (crash the system/BSOD) */
- NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
- 0,0,0,0,0);
+ /* We failed to initialize the video, just quit the installer */
+ return STATUS_APP_INIT_FAILURE;
}
/* Initialize global unicode strings */
@@ -5065,26 +5070,50 @@ RunUSetup(VOID)
FreeConsole();
- /* Avoid bugcheck */
- Time.QuadPart += 50000000;
- NtDelayExecution(FALSE, &Time);
-
/* Reboot */
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, &Old);
NtShutdownSystem(ShutdownReboot);
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, Old, FALSE, &Old);
- NtTerminateProcess(NtCurrentProcess(), 0);
+
+ return STATUS_SUCCESS;
}
VOID NTAPI
NtProcessStartup(PPEB Peb)
{
+ NTSTATUS Status;
+ LARGE_INTEGER Time;
+
RtlNormalizeProcessParams(Peb->ProcessParameters);
ProcessHeap = Peb->ProcessHeap;
- InfSetHeap(ProcessHeap);
- RunUSetup();
+
+ NtQuerySystemTime(&Time);
+
+ Status = RunUSetup();
+
+ if (NT_SUCCESS(Status))
+ {
+ /*
+ * Avoid a bugcheck if RunUSetup() finishes too quickly by implementing
+ * a protective waiting.
+ * This wait is needed because, since we are started as SMSS.EXE,
+ * the NT kernel explicitly waits 5 seconds for the initial process
+ * SMSS.EXE to initialize (as a protective measure), and otherwise
+ * bugchecks with the code SESSION5_INITIALIZATION_FAILED.
+ */
+ Time.QuadPart += 50000000;
+ NtDelayExecution(FALSE, &Time);
+ }
+ else
+ {
+ /* The installer failed to start: raise a hard error (crash the system/BSOD) */
+ Status = NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
+ 0, 0, NULL, 0, NULL);
+ }
+
+ NtTerminateProcess(NtCurrentProcess(), Status);
}
/* EOF */