[USETUP] Reshuffle a bit the main-function of USetup.

svn path=/branches/setup_improvements/; revision=74975
This commit is contained in:
Hermès Bélusca-Maïto 2017-06-09 16:37:53 +00:00
parent 3fd27d34a5
commit 3dffe964a3
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -4855,16 +4855,22 @@ PnpEventThread(IN LPVOID lpParameter);
/* /*
* The start routine and page management * The start routine and page management
*/ */
VOID NTSTATUS
RunUSetup(VOID) RunUSetup(VOID)
{ {
NTSTATUS Status;
INPUT_RECORD Ir; INPUT_RECORD Ir;
PAGE_NUMBER Page; PAGE_NUMBER Page;
LARGE_INTEGER Time;
NTSTATUS Status;
BOOLEAN Old; 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 */ /* Create the PnP thread in suspended state */
Status = RtlCreateUserThread(NtCurrentProcess(), Status = RtlCreateUserThread(NtCurrentProcess(),
@ -4886,9 +4892,8 @@ RunUSetup(VOID)
PrintString(MUIGetString(STRING_CONSOLEFAIL2)); PrintString(MUIGetString(STRING_CONSOLEFAIL2));
PrintString(MUIGetString(STRING_CONSOLEFAIL3)); PrintString(MUIGetString(STRING_CONSOLEFAIL3));
/* Raise a hard error (crash the system/BSOD) */ /* We failed to initialize the video, just quit the installer */
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, return STATUS_APP_INIT_FAILURE;
0,0,0,0,0);
} }
/* Initialize global unicode strings */ /* Initialize global unicode strings */
@ -5065,26 +5070,50 @@ RunUSetup(VOID)
FreeConsole(); FreeConsole();
/* Avoid bugcheck */
Time.QuadPart += 50000000;
NtDelayExecution(FALSE, &Time);
/* Reboot */ /* Reboot */
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, &Old); RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, &Old);
NtShutdownSystem(ShutdownReboot); NtShutdownSystem(ShutdownReboot);
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, Old, FALSE, &Old); RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, Old, FALSE, &Old);
NtTerminateProcess(NtCurrentProcess(), 0);
return STATUS_SUCCESS;
} }
VOID NTAPI VOID NTAPI
NtProcessStartup(PPEB Peb) NtProcessStartup(PPEB Peb)
{ {
NTSTATUS Status;
LARGE_INTEGER Time;
RtlNormalizeProcessParams(Peb->ProcessParameters); RtlNormalizeProcessParams(Peb->ProcessParameters);
ProcessHeap = Peb->ProcessHeap; 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 */ /* EOF */