2005-03-12 21:08:29 +00:00
|
|
|
/*
|
2007-01-22 06:47:44 +00:00
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: ntoskrnl/ex/init.c
|
|
|
|
* PURPOSE: Executive Initialization Code
|
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
2010-01-09 22:43:16 +00:00
|
|
|
* Eric Kohl
|
2007-01-22 06:47:44 +00:00
|
|
|
*/
|
2006-10-08 22:50:26 +00:00
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
1999-08-11 23:29:26 +00:00
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
2011-07-27 13:07:32 +00:00
|
|
|
#include <reactos/buildno.h>
|
2022-02-13 19:57:12 +00:00
|
|
|
#include "inbv/logo.h"
|
|
|
|
|
2001-06-12 17:51:51 +00:00
|
|
|
#define NDEBUG
|
2007-02-15 17:44:04 +00:00
|
|
|
#include <debug.h>
|
2007-05-09 00:44:45 +00:00
|
|
|
|
2014-11-04 20:47:18 +00:00
|
|
|
/* This is the size that we can expect from the win 2003 loader */
|
|
|
|
#define LOADER_PARAMETER_EXTENSION_MIN_SIZE \
|
|
|
|
RTL_SIZEOF_THROUGH_FIELD(LOADER_PARAMETER_EXTENSION, AcpiTableSize)
|
|
|
|
|
2010-10-18 23:07:09 +00:00
|
|
|
/* Temporary hack */
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-10-18 23:07:09 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
MmArmInitSystem(
|
|
|
|
IN ULONG Phase,
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
|
|
|
);
|
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
typedef struct _INIT_BUFFER
|
|
|
|
{
|
|
|
|
WCHAR DebugBuffer[256];
|
|
|
|
CHAR VersionBuffer[256];
|
|
|
|
CHAR BootlogHeader[256];
|
|
|
|
CHAR VersionNumber[24];
|
|
|
|
RTL_USER_PROCESS_INFORMATION ProcessInfo;
|
|
|
|
WCHAR RegistryBuffer[256];
|
|
|
|
} INIT_BUFFER, *PINIT_BUFFER;
|
2000-05-09 16:16:07 +00:00
|
|
|
|
2001-06-12 17:51:51 +00:00
|
|
|
/* DATA **********************************************************************/
|
2000-05-09 16:16:07 +00:00
|
|
|
|
2006-09-03 21:06:30 +00:00
|
|
|
/* NT Version Info */
|
2007-02-19 22:28:50 +00:00
|
|
|
ULONG NtMajorVersion = VER_PRODUCTMAJORVERSION;
|
|
|
|
ULONG NtMinorVersion = VER_PRODUCTMINORVERSION;
|
2015-03-16 03:14:16 +00:00
|
|
|
#if DBG /* Checked Build */
|
2007-02-19 22:28:50 +00:00
|
|
|
ULONG NtBuildNumber = VER_PRODUCTBUILD | 0xC0000000;
|
2015-03-16 03:14:16 +00:00
|
|
|
#else /* Free Build */
|
2007-02-19 22:28:50 +00:00
|
|
|
ULONG NtBuildNumber = VER_PRODUCTBUILD;
|
|
|
|
#endif
|
2007-02-19 18:52:23 +00:00
|
|
|
|
|
|
|
/* NT System Info */
|
2011-03-25 21:42:48 +00:00
|
|
|
ULONG NtGlobalFlag = 0;
|
2006-10-02 13:23:03 +00:00
|
|
|
ULONG ExSuiteMask;
|
2006-09-03 21:06:30 +00:00
|
|
|
|
2007-02-19 18:52:23 +00:00
|
|
|
/* Cm Version Info */
|
|
|
|
ULONG CmNtSpBuildNumber;
|
|
|
|
ULONG CmNtCSDVersion;
|
|
|
|
ULONG CmNtCSDReleaseType;
|
|
|
|
UNICODE_STRING CmVersionString;
|
|
|
|
UNICODE_STRING CmCSDVersionString;
|
2016-07-01 19:45:39 +00:00
|
|
|
|
|
|
|
CHAR NtBuildLab[] = KERNEL_VERSION_BUILD_STR "."
|
|
|
|
REACTOS_COMPILER_NAME "_" REACTOS_COMPILER_VERSION;
|
2007-02-19 18:52:23 +00:00
|
|
|
|
2006-10-01 19:27:10 +00:00
|
|
|
/* Init flags and settings */
|
2006-10-01 18:01:38 +00:00
|
|
|
ULONG ExpInitializationPhase;
|
2006-10-01 18:27:59 +00:00
|
|
|
BOOLEAN ExpInTextModeSetup;
|
|
|
|
BOOLEAN IoRemoteBootClient;
|
2006-10-01 19:43:18 +00:00
|
|
|
ULONG InitSafeBootMode;
|
2007-01-25 01:13:09 +00:00
|
|
|
BOOLEAN InitIsWinPEMode, InitWinPEModeType;
|
2024-02-07 11:34:23 +00:00
|
|
|
BOOLEAN SosEnabled; // Used by driver.c!IopDisplayLoadingMessage()
|
2006-10-05 02:02:27 +00:00
|
|
|
|
2006-10-02 13:23:03 +00:00
|
|
|
/* NT Boot Path */
|
|
|
|
UNICODE_STRING NtSystemRoot;
|
|
|
|
|
2007-01-18 06:23:14 +00:00
|
|
|
/* NT Initial User Application */
|
2012-02-14 06:06:39 +00:00
|
|
|
WCHAR NtInitialUserProcessBuffer[128] = L"\\SystemRoot\\System32\\smss.exe";
|
2007-01-18 06:23:14 +00:00
|
|
|
ULONG NtInitialUserProcessBufferLength = sizeof(NtInitialUserProcessBuffer) -
|
|
|
|
sizeof(WCHAR);
|
|
|
|
ULONG NtInitialUserProcessBufferType = REG_SZ;
|
|
|
|
|
2006-10-01 19:27:10 +00:00
|
|
|
/* Boot NLS information */
|
|
|
|
PVOID ExpNlsTableBase;
|
|
|
|
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
|
|
|
|
ULONG ExpUnicodeCaseTableDataOffset;
|
|
|
|
NLSTABLEINFO ExpNlsTableInfo;
|
2010-01-13 22:35:43 +00:00
|
|
|
SIZE_T ExpNlsTableSize;
|
2006-10-05 01:44:54 +00:00
|
|
|
PVOID ExpNlsSectionPointer;
|
2006-10-01 19:27:10 +00:00
|
|
|
|
2007-01-25 01:13:09 +00:00
|
|
|
/* CMOS Timer Sanity */
|
|
|
|
BOOLEAN ExCmosClockIsSane = TRUE;
|
2007-05-09 00:44:45 +00:00
|
|
|
BOOLEAN ExpRealTimeIsUniversal;
|
2007-01-25 01:13:09 +00:00
|
|
|
|
1999-08-11 23:29:26 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-10-08 07:53:37 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
ExpCreateSystemRootLink(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|
|
|
{
|
|
|
|
UNICODE_STRING LinkName;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE LinkHandle;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ANSI_STRING AnsiName;
|
|
|
|
CHAR Buffer[256];
|
|
|
|
ANSI_STRING TargetString;
|
|
|
|
UNICODE_STRING TargetName;
|
|
|
|
|
|
|
|
/* Initialize the ArcName tree */
|
|
|
|
RtlInitUnicodeString(&LinkName, L"\\ArcName");
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&LinkName,
|
|
|
|
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
|
|
|
|
NULL,
|
2007-01-18 06:23:14 +00:00
|
|
|
SePublicDefaultUnrestrictedSd);
|
2006-10-08 07:53:37 +00:00
|
|
|
|
|
|
|
/* Create it */
|
|
|
|
Status = NtCreateDirectoryObject(&LinkHandle,
|
|
|
|
DIRECTORY_ALL_ACCESS,
|
|
|
|
&ObjectAttributes);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Failed */
|
2006-10-08 07:53:37 +00:00
|
|
|
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 1, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the LinkHandle */
|
|
|
|
NtClose(LinkHandle);
|
|
|
|
|
|
|
|
/* Initialize the Device tree */
|
|
|
|
RtlInitUnicodeString(&LinkName, L"\\Device");
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&LinkName,
|
|
|
|
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
|
|
|
|
NULL,
|
2007-01-18 06:23:14 +00:00
|
|
|
SePublicDefaultUnrestrictedSd);
|
2006-10-08 07:53:37 +00:00
|
|
|
|
|
|
|
/* Create it */
|
|
|
|
Status = NtCreateDirectoryObject(&LinkHandle,
|
|
|
|
DIRECTORY_ALL_ACCESS,
|
|
|
|
&ObjectAttributes);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Failed */
|
2006-10-08 07:53:37 +00:00
|
|
|
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 2, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the LinkHandle */
|
|
|
|
ObCloseHandle(LinkHandle, KernelMode);
|
|
|
|
|
|
|
|
/* Create the system root symlink name */
|
|
|
|
RtlInitAnsiString(&AnsiName, "\\SystemRoot");
|
|
|
|
Status = RtlAnsiStringToUnicodeString(&LinkName, &AnsiName, TRUE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Failed */
|
2006-10-08 07:53:37 +00:00
|
|
|
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 3, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the attributes for the link */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&LinkName,
|
|
|
|
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
|
|
|
|
NULL,
|
2007-01-18 06:23:14 +00:00
|
|
|
SePublicDefaultUnrestrictedSd);
|
2006-10-08 07:53:37 +00:00
|
|
|
|
|
|
|
/* Build the ARC name */
|
|
|
|
sprintf(Buffer,
|
|
|
|
"\\ArcName\\%s%s",
|
|
|
|
LoaderBlock->ArcBootDeviceName,
|
|
|
|
LoaderBlock->NtBootPathName);
|
|
|
|
Buffer[strlen(Buffer) - 1] = ANSI_NULL;
|
|
|
|
|
|
|
|
/* Convert it to Unicode */
|
|
|
|
RtlInitString(&TargetString, Buffer);
|
|
|
|
Status = RtlAnsiStringToUnicodeString(&TargetName,
|
|
|
|
&TargetString,
|
|
|
|
TRUE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* We failed, bugcheck */
|
|
|
|
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 4, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create it */
|
|
|
|
Status = NtCreateSymbolicLinkObject(&LinkHandle,
|
|
|
|
SYMBOLIC_LINK_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&TargetName);
|
|
|
|
|
|
|
|
/* Free the strings */
|
|
|
|
RtlFreeUnicodeString(&LinkName);
|
|
|
|
RtlFreeUnicodeString(&TargetName);
|
|
|
|
|
|
|
|
/* Check if creating the link failed */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Failed */
|
2006-10-08 07:53:37 +00:00
|
|
|
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 5, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the handle and return success */
|
|
|
|
ObCloseHandle(LinkHandle, KernelMode);
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-10-05 01:44:54 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2006-10-05 16:38:58 +00:00
|
|
|
ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
2006-10-05 01:44:54 +00:00
|
|
|
{
|
|
|
|
LARGE_INTEGER SectionSize;
|
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE NlsSection;
|
|
|
|
PVOID SectionBase = NULL;
|
2010-01-13 22:35:43 +00:00
|
|
|
SIZE_T ViewSize = 0;
|
2008-12-03 17:28:59 +00:00
|
|
|
LARGE_INTEGER SectionOffset = {{0, 0}};
|
2006-10-05 16:38:58 +00:00
|
|
|
PLIST_ENTRY ListHead, NextEntry;
|
|
|
|
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
|
2007-03-21 14:31:57 +00:00
|
|
|
ULONG NlsTablesEncountered = 0;
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
SIZE_T NlsTableSizes[3] = {0, 0, 0}; /* 3 NLS tables */
|
2006-10-05 16:38:58 +00:00
|
|
|
|
|
|
|
/* Check if this is boot-time phase 0 initialization */
|
|
|
|
if (!ExpInitializationPhase)
|
|
|
|
{
|
|
|
|
/* Loop the memory descriptors */
|
|
|
|
ListHead = &LoaderBlock->MemoryDescriptorListHead;
|
|
|
|
NextEntry = ListHead->Flink;
|
|
|
|
while (NextEntry != ListHead)
|
|
|
|
{
|
|
|
|
/* Get the current block */
|
|
|
|
MdBlock = CONTAINING_RECORD(NextEntry,
|
|
|
|
MEMORY_ALLOCATION_DESCRIPTOR,
|
|
|
|
ListEntry);
|
|
|
|
|
|
|
|
/* Check if this is an NLS block */
|
|
|
|
if (MdBlock->MemoryType == LoaderNlsData)
|
|
|
|
{
|
|
|
|
/* Increase the table size */
|
|
|
|
ExpNlsTableSize += MdBlock->PageCount * PAGE_SIZE;
|
2007-03-21 14:31:57 +00:00
|
|
|
|
|
|
|
/* FreeLdr-specific */
|
|
|
|
NlsTableSizes[NlsTablesEncountered] = MdBlock->PageCount * PAGE_SIZE;
|
|
|
|
NlsTablesEncountered++;
|
|
|
|
ASSERT(NlsTablesEncountered < 4);
|
2006-10-05 16:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Go to the next block */
|
|
|
|
NextEntry = MdBlock->ListEntry.Flink;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate the a new buffer since loader memory will be freed */
|
|
|
|
ExpNlsTableBase = ExAllocatePoolWithTag(NonPagedPool,
|
|
|
|
ExpNlsTableSize,
|
2011-06-01 13:39:36 +00:00
|
|
|
TAG_RTLI);
|
2006-10-05 16:38:58 +00:00
|
|
|
if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
|
|
|
|
|
|
|
|
/* Copy the codepage data in its new location. */
|
2008-02-24 17:06:10 +00:00
|
|
|
if (NlsTablesEncountered == 1)
|
|
|
|
{
|
|
|
|
/* Ntldr-way boot process */
|
|
|
|
RtlCopyMemory(ExpNlsTableBase,
|
|
|
|
LoaderBlock->NlsData->AnsiCodePageData,
|
|
|
|
ExpNlsTableSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* In NT, the memory blocks are contiguous, but in ReactOS they aren't,
|
|
|
|
* so unless someone fixes FreeLdr, we'll have to use this icky hack.
|
|
|
|
*/
|
|
|
|
RtlCopyMemory(ExpNlsTableBase,
|
|
|
|
LoaderBlock->NlsData->AnsiCodePageData,
|
|
|
|
NlsTableSizes[0]);
|
|
|
|
|
|
|
|
RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0]),
|
|
|
|
LoaderBlock->NlsData->OemCodePageData,
|
|
|
|
NlsTableSizes[1]);
|
|
|
|
|
|
|
|
RtlCopyMemory((PVOID)((ULONG_PTR)ExpNlsTableBase + NlsTableSizes[0] +
|
|
|
|
NlsTableSizes[1]),
|
|
|
|
LoaderBlock->NlsData->UnicodeCodePageData,
|
|
|
|
NlsTableSizes[2]);
|
|
|
|
/* End of Hack */
|
|
|
|
}
|
2006-10-05 16:38:58 +00:00
|
|
|
|
|
|
|
/* Initialize and reset the NLS TAbles */
|
|
|
|
RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpAnsiCodePageDataOffset),
|
|
|
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpOemCodePageDataOffset),
|
|
|
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpUnicodeCaseTableDataOffset),
|
|
|
|
&ExpNlsTableInfo);
|
|
|
|
RtlResetRtlTranslations(&ExpNlsTableInfo);
|
|
|
|
return;
|
|
|
|
}
|
2006-10-05 01:44:54 +00:00
|
|
|
|
|
|
|
/* Set the section size */
|
|
|
|
SectionSize.QuadPart = ExpNlsTableSize;
|
|
|
|
|
|
|
|
/* Create the NLS Section */
|
|
|
|
Status = ZwCreateSection(&NlsSection,
|
|
|
|
SECTION_ALL_ACCESS,
|
|
|
|
NULL,
|
|
|
|
&SectionSize,
|
|
|
|
PAGE_READWRITE,
|
2012-03-05 17:10:51 +00:00
|
|
|
SEC_COMMIT | 0x1,
|
2006-10-05 01:44:54 +00:00
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Failed */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 1, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get a pointer to the section */
|
|
|
|
Status = ObReferenceObjectByHandle(NlsSection,
|
|
|
|
SECTION_ALL_ACCESS,
|
|
|
|
MmSectionObjectType,
|
|
|
|
KernelMode,
|
|
|
|
&ExpNlsSectionPointer,
|
|
|
|
NULL);
|
2010-01-23 21:27:26 +00:00
|
|
|
ObCloseHandle(NlsSection, KernelMode);
|
2006-10-05 01:44:54 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Failed */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 2, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Map the NLS Section in system space */
|
2010-10-19 20:23:37 +00:00
|
|
|
Status = MmMapViewInSystemSpace(ExpNlsSectionPointer,
|
2006-10-05 01:44:54 +00:00
|
|
|
&SectionBase,
|
|
|
|
&ExpNlsTableSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Failed */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 3, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the codepage data in its new location. */
|
2012-02-03 20:59:35 +00:00
|
|
|
ASSERT(SectionBase >= MmSystemRangeStart);
|
2006-10-22 09:06:58 +00:00
|
|
|
RtlCopyMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize);
|
2006-10-05 01:44:54 +00:00
|
|
|
|
|
|
|
/* Free the previously allocated buffer and set the new location */
|
2011-06-01 13:39:36 +00:00
|
|
|
ExFreePoolWithTag(ExpNlsTableBase, TAG_RTLI);
|
2006-10-05 01:44:54 +00:00
|
|
|
ExpNlsTableBase = SectionBase;
|
|
|
|
|
|
|
|
/* Initialize the NLS Tables */
|
|
|
|
RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpAnsiCodePageDataOffset),
|
|
|
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpOemCodePageDataOffset),
|
|
|
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpUnicodeCaseTableDataOffset),
|
|
|
|
&ExpNlsTableInfo);
|
|
|
|
RtlResetRtlTranslations(&ExpNlsTableInfo);
|
|
|
|
|
|
|
|
/* Reset the base to 0 */
|
|
|
|
SectionBase = NULL;
|
|
|
|
|
|
|
|
/* Map the section in the system process */
|
2010-10-19 20:23:37 +00:00
|
|
|
Status = MmMapViewOfSection(ExpNlsSectionPointer,
|
2006-10-05 01:44:54 +00:00
|
|
|
PsGetCurrentProcess(),
|
|
|
|
&SectionBase,
|
|
|
|
0L,
|
|
|
|
0L,
|
|
|
|
&SectionOffset,
|
|
|
|
&ViewSize,
|
|
|
|
ViewShare,
|
|
|
|
0L,
|
|
|
|
PAGE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Failed */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 5, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the table into the system process and set this as the base */
|
2006-10-22 09:06:58 +00:00
|
|
|
RtlCopyMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize);
|
2006-10-05 01:44:54 +00:00
|
|
|
ExpNlsTableBase = SectionBase;
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2007-05-09 00:44:45 +00:00
|
|
|
VOID
|
2006-10-05 15:13:59 +00:00
|
|
|
NTAPI
|
2007-05-09 00:44:45 +00:00
|
|
|
ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
|
|
|
|
OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
|
|
|
|
OUT PCHAR *ProcessEnvironment)
|
2005-08-05 03:44:24 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2010-01-13 22:35:43 +00:00
|
|
|
SIZE_T Size;
|
2006-10-05 14:49:20 +00:00
|
|
|
PWSTR p;
|
|
|
|
UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
|
2007-05-09 00:44:45 +00:00
|
|
|
UNICODE_STRING SmssName, Environment, SystemDriveString, DebugString;
|
2007-01-18 06:23:14 +00:00
|
|
|
PVOID EnvironmentPtr = NULL;
|
2007-05-09 00:44:45 +00:00
|
|
|
PRTL_USER_PROCESS_INFORMATION ProcessInformation;
|
|
|
|
PRTL_USER_PROCESS_PARAMETERS ProcessParams = NULL;
|
|
|
|
|
2007-06-03 19:57:41 +00:00
|
|
|
NullString.Length = sizeof(WCHAR);
|
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Use the initial buffer, after the strings */
|
|
|
|
ProcessInformation = &InitBuffer->ProcessInfo;
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Allocate memory for the process parameters */
|
2019-03-31 07:18:16 +00:00
|
|
|
Size = sizeof(*ProcessParams) + ((MAX_WIN32_PATH * 6) * sizeof(WCHAR));
|
2006-10-05 14:49:20 +00:00
|
|
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
2007-05-09 00:44:45 +00:00
|
|
|
(PVOID*)&ProcessParams,
|
2006-10-05 14:49:20 +00:00
|
|
|
0,
|
|
|
|
&Size,
|
2012-02-16 17:24:01 +00:00
|
|
|
MEM_RESERVE | MEM_COMMIT,
|
2006-10-05 14:49:20 +00:00
|
|
|
PAGE_READWRITE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2005-08-05 03:44:24 +00:00
|
|
|
{
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Failed, display error */
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
_snwprintf(InitBuffer->DebugBuffer,
|
|
|
|
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
|
2007-05-09 00:44:45 +00:00
|
|
|
L"INIT: Unable to allocate Process Parameters. 0x%lx",
|
|
|
|
Status);
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
|
2007-05-09 00:44:45 +00:00
|
|
|
ZwDisplayString(&DebugString);
|
|
|
|
|
|
|
|
/* Bugcheck the system */
|
2006-10-05 14:49:20 +00:00
|
|
|
KeBugCheckEx(SESSION1_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup the basic header, and give the process the low 1MB to itself */
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
ProcessParams->Length = (ULONG)Size;
|
|
|
|
ProcessParams->MaximumLength = (ULONG)Size;
|
2007-05-09 00:44:45 +00:00
|
|
|
ProcessParams->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED |
|
|
|
|
RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Allocate a page for the environment */
|
|
|
|
Size = PAGE_SIZE;
|
|
|
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
2007-01-18 06:23:14 +00:00
|
|
|
&EnvironmentPtr,
|
2006-10-05 14:49:20 +00:00
|
|
|
0,
|
|
|
|
&Size,
|
2012-02-16 17:24:01 +00:00
|
|
|
MEM_RESERVE | MEM_COMMIT,
|
2006-10-07 22:23:35 +00:00
|
|
|
PAGE_READWRITE);
|
2006-10-05 14:49:20 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Failed, display error */
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
_snwprintf(InitBuffer->DebugBuffer,
|
|
|
|
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
|
2007-05-09 00:44:45 +00:00
|
|
|
L"INIT: Unable to allocate Process Environment. 0x%lx",
|
|
|
|
Status);
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
|
2007-05-09 00:44:45 +00:00
|
|
|
ZwDisplayString(&DebugString);
|
|
|
|
|
|
|
|
/* Bugcheck the system */
|
2006-10-05 14:49:20 +00:00
|
|
|
KeBugCheckEx(SESSION2_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
2005-08-05 03:44:24 +00:00
|
|
|
}
|
|
|
|
|
2007-01-18 06:23:14 +00:00
|
|
|
/* Write the pointer */
|
2007-05-09 00:44:45 +00:00
|
|
|
ProcessParams->Environment = EnvironmentPtr;
|
2007-01-18 06:23:14 +00:00
|
|
|
|
2006-10-05 14:49:20 +00:00
|
|
|
/* Make a buffer for the DOS path */
|
2007-05-09 00:44:45 +00:00
|
|
|
p = (PWSTR)(ProcessParams + 1);
|
|
|
|
ProcessParams->CurrentDirectory.DosPath.Buffer = p;
|
2019-03-31 07:18:16 +00:00
|
|
|
ProcessParams->CurrentDirectory.DosPath.MaximumLength = MAX_WIN32_PATH *
|
2007-05-09 00:44:45 +00:00
|
|
|
sizeof(WCHAR);
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Copy the DOS path */
|
2007-05-09 00:44:45 +00:00
|
|
|
RtlCopyUnicodeString(&ProcessParams->CurrentDirectory.DosPath,
|
2006-10-05 14:49:20 +00:00
|
|
|
&NtSystemRoot);
|
|
|
|
|
|
|
|
/* Make a buffer for the DLL Path */
|
2007-05-09 00:44:45 +00:00
|
|
|
p = (PWSTR)((PCHAR)ProcessParams->CurrentDirectory.DosPath.Buffer +
|
|
|
|
ProcessParams->CurrentDirectory.DosPath.MaximumLength);
|
|
|
|
ProcessParams->DllPath.Buffer = p;
|
2019-03-31 07:18:16 +00:00
|
|
|
ProcessParams->DllPath.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Copy the DLL path and append the system32 directory */
|
2007-05-09 00:44:45 +00:00
|
|
|
RtlCopyUnicodeString(&ProcessParams->DllPath,
|
|
|
|
&ProcessParams->CurrentDirectory.DosPath);
|
|
|
|
RtlAppendUnicodeToString(&ProcessParams->DllPath, L"\\System32");
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Make a buffer for the image name */
|
2007-05-09 00:44:45 +00:00
|
|
|
p = (PWSTR)((PCHAR)ProcessParams->DllPath.Buffer +
|
|
|
|
ProcessParams->DllPath.MaximumLength);
|
|
|
|
ProcessParams->ImagePathName.Buffer = p;
|
2019-03-31 07:18:16 +00:00
|
|
|
ProcessParams->ImagePathName.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
|
2006-10-05 14:49:20 +00:00
|
|
|
|
2007-01-18 06:23:14 +00:00
|
|
|
/* Make sure the buffer is a valid string which within the given length */
|
|
|
|
if ((NtInitialUserProcessBufferType != REG_SZ) ||
|
2009-09-27 20:07:43 +00:00
|
|
|
((NtInitialUserProcessBufferLength != MAXULONG) &&
|
2007-01-18 06:23:14 +00:00
|
|
|
((NtInitialUserProcessBufferLength < sizeof(WCHAR)) ||
|
|
|
|
(NtInitialUserProcessBufferLength >
|
|
|
|
sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
|
|
|
|
{
|
|
|
|
/* Invalid initial process string, bugcheck */
|
|
|
|
KeBugCheckEx(SESSION2_INITIALIZATION_FAILED,
|
2007-05-09 00:44:45 +00:00
|
|
|
STATUS_INVALID_PARAMETER,
|
2007-01-18 06:23:14 +00:00
|
|
|
NtInitialUserProcessBufferType,
|
|
|
|
NtInitialUserProcessBufferLength,
|
|
|
|
sizeof(NtInitialUserProcessBuffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cut out anything after a space */
|
|
|
|
p = NtInitialUserProcessBuffer;
|
2007-05-09 00:44:45 +00:00
|
|
|
while ((*p) && (*p != L' ')) p++;
|
2007-01-18 06:23:14 +00:00
|
|
|
|
|
|
|
/* Set the image path length */
|
2007-05-09 00:44:45 +00:00
|
|
|
ProcessParams->ImagePathName.Length =
|
2007-01-18 06:23:14 +00:00
|
|
|
(USHORT)((PCHAR)p - (PCHAR)NtInitialUserProcessBuffer);
|
|
|
|
|
|
|
|
/* Copy the actual buffer */
|
2007-05-09 00:44:45 +00:00
|
|
|
RtlCopyMemory(ProcessParams->ImagePathName.Buffer,
|
2007-01-18 06:23:14 +00:00
|
|
|
NtInitialUserProcessBuffer,
|
2007-05-09 00:44:45 +00:00
|
|
|
ProcessParams->ImagePathName.Length);
|
2007-01-18 06:23:14 +00:00
|
|
|
|
|
|
|
/* Null-terminate it */
|
2007-05-09 00:44:45 +00:00
|
|
|
ProcessParams->ImagePathName.Buffer[ProcessParams->ImagePathName.Length /
|
|
|
|
sizeof(WCHAR)] = UNICODE_NULL;
|
2007-01-18 06:23:14 +00:00
|
|
|
|
|
|
|
/* Make a buffer for the command line */
|
2007-05-09 00:44:45 +00:00
|
|
|
p = (PWSTR)((PCHAR)ProcessParams->ImagePathName.Buffer +
|
|
|
|
ProcessParams->ImagePathName.MaximumLength);
|
|
|
|
ProcessParams->CommandLine.Buffer = p;
|
2019-03-31 07:18:16 +00:00
|
|
|
ProcessParams->CommandLine.MaximumLength = MAX_WIN32_PATH * sizeof(WCHAR);
|
2007-01-18 06:23:14 +00:00
|
|
|
|
|
|
|
/* Add the image name to the command line */
|
2007-05-09 00:44:45 +00:00
|
|
|
RtlAppendUnicodeToString(&ProcessParams->CommandLine,
|
2007-01-18 06:23:14 +00:00
|
|
|
NtInitialUserProcessBuffer);
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Create the environment string */
|
|
|
|
RtlInitEmptyUnicodeString(&Environment,
|
2007-05-09 00:44:45 +00:00
|
|
|
ProcessParams->Environment,
|
- Set OBJ_OPENLINK invalid for core object types.
- Initialize symbolic link in-line with other core object types.
- Use the SePublicDefaultUnrestrictedSd directly instead of building another SD.
- Create core directory objects with Nt* functions instead of Ob*, to insure full accounting and error-handling.
- Create core objects with OBJ_CASE_INSENSITIVE.
- Fix the huge ObInit hack which was manually inserting Directory and Type object types in the type directory, and now loop the type list. Now we don't skip the Process, Token, Thread, Job, Section types anymore.
- Support Quota Information during object allocation and deallocation isntead of ignoring it.
- Use interlocked decrement when touching the object type (since it's a shared structure. We don't use the lock yet, but we won't for this anyways, since it's a simple lockable operation).
- Use the right object key when freeing the object.
- Modify the allocation function for a more optimized way of allocating objects instead of having to keep track of two sets of variables.
- Add various accounting variables.
- Make sure to properly handle allocations without object create info (ie, for object types). Now they get creator info and name info (which allowed us to cleanp the hack in ObInit).
- Add checks to see if Quota informatio is needed.
- Clear CreatorBackTraceIndex during allocation.
- Remove CreatorUniqueProcess hack from back when the idle thread was NULL.
- Do not zero out the header during allocation anymore, since this slows down the routine (instead, simply zero out the 2 fields that are NULL).
- Locate and clearly display that the fact we zero objects on creation is a HACK that needs to be fixed. (The Token code makes this assumption).
- Update HighWaterNumberOfObjects when needed.
- If caller didn't give pool charges, use the one from the object type.
- Clear the Total/HighWater* values for newly created object types instead of using random values.
- Properly typecast the WCHAR tag as CHAR.
- Insert each new object type in the ObTypeObjectType Type List.
- Set the Index member of each new object type and insert each new object type in the ObpObjectTypes array. This is crucial for object type enumeration when implemented.
- Fixup the way we insert new object types into the tree. Allow failure and don't return a type if we couldn't insert it, and only reference the type directory object if it actually exists.
- Move DOS Devices\"??" initialization in its own routine and fix it:
- Use Nt APIs for all operations instead of raw I/O.
- Create GLOBALROOT link to \
- Create \??\Global link to \??
svn path=/trunk/; revision=24568
2006-10-19 02:20:32 +00:00
|
|
|
(USHORT)Size);
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Append the DLL path to it */
|
2015-02-21 01:25:47 +00:00
|
|
|
RtlAppendUnicodeToString(&Environment, L"Path=");
|
2007-05-09 00:44:45 +00:00
|
|
|
RtlAppendUnicodeStringToString(&Environment, &ProcessParams->DllPath);
|
|
|
|
RtlAppendUnicodeStringToString(&Environment, &NullString);
|
2006-10-05 14:49:20 +00:00
|
|
|
|
|
|
|
/* Create the system drive string */
|
|
|
|
SystemDriveString = NtSystemRoot;
|
|
|
|
SystemDriveString.Length = 2 * sizeof(WCHAR);
|
|
|
|
|
|
|
|
/* Append it to the environment */
|
|
|
|
RtlAppendUnicodeToString(&Environment, L"SystemDrive=");
|
|
|
|
RtlAppendUnicodeStringToString(&Environment, &SystemDriveString);
|
|
|
|
RtlAppendUnicodeStringToString(&Environment, &NullString);
|
|
|
|
|
|
|
|
/* Append the system root to the environment */
|
|
|
|
RtlAppendUnicodeToString(&Environment, L"SystemRoot=");
|
|
|
|
RtlAppendUnicodeStringToString(&Environment, &NtSystemRoot);
|
|
|
|
RtlAppendUnicodeStringToString(&Environment, &NullString);
|
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Prepare the prefetcher */
|
|
|
|
//CcPfBeginBootPhase(150);
|
|
|
|
|
2006-10-05 14:49:20 +00:00
|
|
|
/* Create SMSS process */
|
2007-05-09 00:44:45 +00:00
|
|
|
SmssName = ProcessParams->ImagePathName;
|
2006-10-05 14:49:20 +00:00
|
|
|
Status = RtlCreateUserProcess(&SmssName,
|
2005-08-05 03:44:24 +00:00
|
|
|
OBJ_CASE_INSENSITIVE,
|
2007-05-09 00:44:45 +00:00
|
|
|
RtlDeNormalizeProcessParams(ProcessParams),
|
2005-08-05 03:44:24 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2006-06-07 01:47:33 +00:00
|
|
|
NULL,
|
2005-08-05 03:44:24 +00:00
|
|
|
FALSE,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2007-01-25 01:13:09 +00:00
|
|
|
ProcessInformation);
|
2005-08-05 03:44:24 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Failed, display error */
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
_snwprintf(InitBuffer->DebugBuffer,
|
|
|
|
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
|
2007-05-09 00:44:45 +00:00
|
|
|
L"INIT: Unable to create Session Manager. 0x%lx",
|
|
|
|
Status);
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
|
2007-05-09 00:44:45 +00:00
|
|
|
ZwDisplayString(&DebugString);
|
|
|
|
|
|
|
|
/* Bugcheck the system */
|
2006-10-05 14:49:20 +00:00
|
|
|
KeBugCheckEx(SESSION3_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
2005-08-05 03:44:24 +00:00
|
|
|
}
|
|
|
|
|
2006-10-05 14:49:20 +00:00
|
|
|
/* Resume the thread */
|
2007-01-25 01:13:09 +00:00
|
|
|
Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL);
|
2006-10-05 14:49:20 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Failed, display error */
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
_snwprintf(InitBuffer->DebugBuffer,
|
|
|
|
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
|
2007-05-09 00:44:45 +00:00
|
|
|
L"INIT: Unable to resume Session Manager. 0x%lx",
|
|
|
|
Status);
|
[NTOSKRNL]
Coverity code defects fixes :
- Cache: CID 701441
- Config: CIDs 716570, 716669, 716760
- Dbgk: Kdbg: CIDs 716571, 515128/9, 500432
- Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669
- Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber
- Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713
- Ke: CIDs 515125, 716592
- Ps: CIDs 716603/4, 701422
- Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2
All the details are given in the different bug reports.
CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close
svn path=/trunk/; revision=57400
2012-09-27 17:16:31 +00:00
|
|
|
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
|
2007-05-09 00:44:45 +00:00
|
|
|
ZwDisplayString(&DebugString);
|
|
|
|
|
|
|
|
/* Bugcheck the system */
|
2006-10-05 14:49:20 +00:00
|
|
|
KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
2005-08-05 03:44:24 +00:00
|
|
|
|
2007-01-25 01:13:09 +00:00
|
|
|
/* Return success */
|
2007-05-09 00:44:45 +00:00
|
|
|
*ProcessParameters = ProcessParams;
|
|
|
|
*ProcessEnvironment = EnvironmentPtr;
|
2005-08-05 03:44:24 +00:00
|
|
|
}
|
2006-01-05 16:24:32 +00:00
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-10-02 15:52:58 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
ExComputeTickCountMultiplier(IN ULONG ClockIncrement)
|
|
|
|
{
|
|
|
|
ULONG MsRemainder = 0, MsIncrement;
|
|
|
|
ULONG IncrementRemainder;
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
/* Count the number of milliseconds for each clock interrupt */
|
|
|
|
MsIncrement = ClockIncrement / (10 * 1000);
|
|
|
|
|
|
|
|
/* Count the remainder from the division above, with 24-bit precision */
|
|
|
|
IncrementRemainder = ClockIncrement - (MsIncrement * (10 * 1000));
|
|
|
|
for (i= 0; i < 24; i++)
|
|
|
|
{
|
|
|
|
/* Shift the remainders */
|
|
|
|
MsRemainder <<= 1;
|
|
|
|
IncrementRemainder <<= 1;
|
|
|
|
|
|
|
|
/* Check if we've went past 1 ms */
|
|
|
|
if (IncrementRemainder >= (10 * 1000))
|
|
|
|
{
|
|
|
|
/* Increase the remainder by one, and substract from increment */
|
|
|
|
IncrementRemainder -= (10 * 1000);
|
|
|
|
MsRemainder |= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the increment */
|
|
|
|
return (MsIncrement << 24) | MsRemainder;
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-10-02 13:23:03 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
ExpInitSystemPhase0(VOID)
|
|
|
|
{
|
|
|
|
/* Initialize EXRESOURCE Support */
|
|
|
|
ExpResourceInitialization();
|
|
|
|
|
|
|
|
/* Initialize the environment lock */
|
|
|
|
ExInitializeFastMutex(&ExpEnvironmentLock);
|
|
|
|
|
|
|
|
/* Initialize the lookaside lists and locks */
|
|
|
|
ExpInitLookasideLists();
|
|
|
|
|
|
|
|
/* Initialize the Firmware Table resource and listhead */
|
|
|
|
InitializeListHead(&ExpFirmwareTableProviderListHead);
|
|
|
|
ExInitializeResourceLite(&ExpFirmwareTableResource);
|
2022-08-09 13:48:48 +00:00
|
|
|
ExInitializeResourceLite(&ExpTimeRefreshLock);
|
2006-10-02 13:23:03 +00:00
|
|
|
|
|
|
|
/* Set the suite mask to maximum and return */
|
|
|
|
ExSuiteMask = 0xFFFFFFFF;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-10-02 13:23:03 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
ExpInitSystemPhase1(VOID)
|
|
|
|
{
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Initialize worker threads */
|
|
|
|
ExpInitializeWorkerThreads();
|
|
|
|
|
|
|
|
/* Initialize pushlocks */
|
|
|
|
ExpInitializePushLocks();
|
|
|
|
|
|
|
|
/* Initialize events and event pairs */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpInitializeEventImplementation() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Event initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (ExpInitializeEventPairImplementation() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Event Pair initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Initialize mutants */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpInitializeMutantImplementation() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Mutant initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2012-09-02 22:06:42 +00:00
|
|
|
/* Initialize callbacks */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpInitializeCallbacks() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Callback initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Initialize semaphores */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpInitializeSemaphoreImplementation() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Semaphore initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Initialize timers */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpInitializeTimerImplementation() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Timer initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Initialize profiling */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpInitializeProfileImplementation() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Profile initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Initialize UUIDs */
|
2019-02-27 20:12:32 +00:00
|
|
|
if (ExpUuidInitialization() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Uuid initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2012-09-02 22:06:42 +00:00
|
|
|
/* Initialize keyed events */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpInitializeKeyedEventImplementation() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Keyed event initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-11-02 11:30:14 +00:00
|
|
|
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Initialize Win32K */
|
2012-09-03 01:12:58 +00:00
|
|
|
if (ExpWin32kInit() == FALSE)
|
|
|
|
{
|
|
|
|
DPRINT1("Executive: Win32 initialization failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-10-05 15:13:59 +00:00
|
|
|
return TRUE;
|
2006-10-02 13:23:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-10-02 13:23:03 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
ExInitSystem(VOID)
|
|
|
|
{
|
|
|
|
/* Check the initialization phase */
|
|
|
|
switch (ExpInitializationPhase)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
|
|
|
|
/* Do Phase 0 */
|
|
|
|
return ExpInitSystemPhase0();
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
/* Do Phase 1 */
|
|
|
|
return ExpInitSystemPhase1();
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
/* Don't know any other phase! Bugcheck! */
|
|
|
|
KeBugCheck(UNEXPECTED_INITIALIZATION_CALL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-10-01 18:01:38 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
|
|
|
{
|
|
|
|
PLOADER_PARAMETER_EXTENSION Extension;
|
|
|
|
|
|
|
|
/* Get the loader extension */
|
|
|
|
Extension = LoaderBlock->Extension;
|
|
|
|
|
2014-11-04 20:47:18 +00:00
|
|
|
/* Validate the size (Windows 2003 loader doesn't provide more) */
|
|
|
|
if (Extension->Size < LOADER_PARAMETER_EXTENSION_MIN_SIZE) return FALSE;
|
2006-10-01 18:01:38 +00:00
|
|
|
|
|
|
|
/* Don't validate upper versions */
|
2007-05-09 00:44:45 +00:00
|
|
|
if (Extension->MajorVersion > VER_PRODUCTMAJORVERSION) return TRUE;
|
2006-10-01 18:01:38 +00:00
|
|
|
|
|
|
|
/* Fail if this is NT 4 */
|
2007-05-09 00:44:45 +00:00
|
|
|
if (Extension->MajorVersion < VER_PRODUCTMAJORVERSION) return FALSE;
|
2006-10-01 18:01:38 +00:00
|
|
|
|
|
|
|
/* Fail if this is XP */
|
2007-05-09 00:44:45 +00:00
|
|
|
if (Extension->MinorVersion < VER_PRODUCTMINORVERSION) return FALSE;
|
2006-10-01 18:01:38 +00:00
|
|
|
|
2006-10-08 22:50:26 +00:00
|
|
|
/* This is 2003 or newer, approve it */
|
2006-10-01 18:01:38 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2024-11-28 19:18:32 +00:00
|
|
|
static CODE_SEG("INIT")
|
2007-01-24 19:48:34 +00:00
|
|
|
VOID
|
2024-11-28 19:18:32 +00:00
|
|
|
ExpLoadBootSymbols(
|
|
|
|
_In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
2007-01-24 19:48:34 +00:00
|
|
|
{
|
|
|
|
PLIST_ENTRY NextEntry;
|
2024-11-28 19:18:32 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY LdrEntry;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG i;
|
2007-01-24 19:48:34 +00:00
|
|
|
ULONG Count, Length;
|
|
|
|
PWCHAR Name;
|
2024-11-28 19:18:32 +00:00
|
|
|
STRING ImageName;
|
2007-01-24 19:48:34 +00:00
|
|
|
CHAR NameBuffer[256];
|
|
|
|
|
2024-11-28 19:18:32 +00:00
|
|
|
/* Loop over the boot modules list */
|
|
|
|
for (NextEntry = LoaderBlock->LoadOrderListHead.Flink, i = 0;
|
|
|
|
NextEntry != &LoaderBlock->LoadOrderListHead;
|
|
|
|
NextEntry = NextEntry->Flink, ++i)
|
2007-01-24 19:48:34 +00:00
|
|
|
{
|
2024-11-28 19:18:32 +00:00
|
|
|
/* Skip the first two images: HAL and kernel */
|
|
|
|
if (i < 2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Get the entry */
|
|
|
|
LdrEntry = CONTAINING_RECORD(NextEntry,
|
|
|
|
LDR_DATA_TABLE_ENTRY,
|
|
|
|
InLoadOrderLinks);
|
|
|
|
if (LdrEntry->FullDllName.Buffer[0] == L'\\')
|
2007-01-24 19:48:34 +00:00
|
|
|
{
|
2024-11-28 19:18:32 +00:00
|
|
|
/* We have a name, read its data */
|
|
|
|
Name = LdrEntry->FullDllName.Buffer;
|
|
|
|
Length = LdrEntry->FullDllName.Length / sizeof(WCHAR);
|
2007-01-24 19:48:34 +00:00
|
|
|
|
2024-11-28 19:18:32 +00:00
|
|
|
/* Check if our buffer can hold it */
|
|
|
|
if (sizeof(NameBuffer) < Length + sizeof(ANSI_NULL))
|
2007-01-24 19:48:34 +00:00
|
|
|
{
|
2024-11-28 19:18:32 +00:00
|
|
|
/* It's too long */
|
|
|
|
Status = STATUS_BUFFER_OVERFLOW;
|
2007-01-24 19:48:34 +00:00
|
|
|
}
|
2024-11-28 19:18:32 +00:00
|
|
|
else
|
2007-01-24 19:48:34 +00:00
|
|
|
{
|
2024-11-28 19:18:32 +00:00
|
|
|
/* Copy the name */
|
|
|
|
Count = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Do cheap Unicode to ANSI conversion */
|
|
|
|
NameBuffer[Count++] = (CHAR)*Name++;
|
|
|
|
} while (Count < Length);
|
2007-01-24 19:48:34 +00:00
|
|
|
|
2024-11-28 19:18:32 +00:00
|
|
|
/* Null-terminate */
|
|
|
|
NameBuffer[Count] = ANSI_NULL;
|
|
|
|
Status = STATUS_SUCCESS;
|
2007-01-24 19:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
2024-11-28 19:18:32 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Safely print the string into our buffer */
|
|
|
|
Status = RtlStringCbPrintfA(NameBuffer,
|
|
|
|
sizeof(NameBuffer),
|
|
|
|
"%S\\System32\\Drivers\\%wZ",
|
|
|
|
&SharedUserData->NtSystemRoot[2],
|
|
|
|
&LdrEntry->BaseDllName);
|
|
|
|
}
|
2007-01-24 19:48:34 +00:00
|
|
|
|
2024-11-28 19:18:32 +00:00
|
|
|
/* Check if the buffer is OK */
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Load the symbols */
|
|
|
|
RtlInitString(&ImageName, NameBuffer);
|
|
|
|
DbgLoadImageSymbols(&ImageName,
|
|
|
|
LdrEntry->DllBase,
|
|
|
|
(ULONG_PTR)PsGetCurrentProcessId());
|
|
|
|
}
|
2007-01-24 19:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2010-08-19 08:50:23 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
IN ULONG_PTR PagesToDestroy,
|
2010-08-19 08:50:23 +00:00
|
|
|
IN TYPE_OF_MEMORY MemoryType)
|
|
|
|
{
|
|
|
|
PLIST_ENTRY ListEntry;
|
|
|
|
PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor;
|
|
|
|
|
2013-08-31 16:02:13 +00:00
|
|
|
DPRINT1("Burn RAM amount: %lu pages\n", PagesToDestroy);
|
2010-08-19 08:50:23 +00:00
|
|
|
|
|
|
|
/* Loop the memory descriptors, beginning at the end */
|
|
|
|
for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Blink;
|
|
|
|
ListEntry != &LoaderBlock->MemoryDescriptorListHead;
|
|
|
|
ListEntry = ListEntry->Blink)
|
|
|
|
{
|
|
|
|
/* Get the memory descriptor structure */
|
|
|
|
MemDescriptor = CONTAINING_RECORD(ListEntry,
|
|
|
|
MEMORY_ALLOCATION_DESCRIPTOR,
|
|
|
|
ListEntry);
|
|
|
|
|
|
|
|
/* Is memory free there or is it temporary? */
|
|
|
|
if (MemDescriptor->MemoryType == LoaderFree ||
|
|
|
|
MemDescriptor->MemoryType == LoaderFirmwareTemporary)
|
|
|
|
{
|
|
|
|
/* Check if the descriptor has more pages than we want */
|
|
|
|
if (MemDescriptor->PageCount > PagesToDestroy)
|
|
|
|
{
|
|
|
|
/* Change block's page count, ntoskrnl doesn't care much */
|
|
|
|
MemDescriptor->PageCount -= PagesToDestroy;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Change block type */
|
|
|
|
MemDescriptor->MemoryType = MemoryType;
|
|
|
|
PagesToDestroy -= MemDescriptor->PageCount;
|
|
|
|
|
|
|
|
/* Check if we are done */
|
|
|
|
if (PagesToDestroy == 0) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-09-16 20:37:49 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2006-10-01 18:01:38 +00:00
|
|
|
ExpInitializeExecutive(IN ULONG Cpu,
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
2006-09-16 20:37:49 +00:00
|
|
|
{
|
2006-10-01 19:27:10 +00:00
|
|
|
PNLS_DATA_BLOCK NlsData;
|
2006-10-02 13:23:03 +00:00
|
|
|
CHAR Buffer[256];
|
|
|
|
ANSI_STRING AnsiPath;
|
|
|
|
NTSTATUS Status;
|
2007-01-24 19:48:34 +00:00
|
|
|
PCHAR CommandLine, PerfMem;
|
|
|
|
ULONG PerfMemUsed;
|
2007-05-09 00:44:45 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY NtosEntry;
|
2010-06-27 20:38:12 +00:00
|
|
|
PMESSAGE_RESOURCE_ENTRY MsgEntry;
|
2015-03-16 03:14:16 +00:00
|
|
|
ANSI_STRING CSDString;
|
2011-03-25 21:42:48 +00:00
|
|
|
size_t Remaining = 0;
|
2007-05-09 00:44:45 +00:00
|
|
|
PCHAR RcEnd = NULL;
|
2015-03-16 03:14:16 +00:00
|
|
|
CHAR VersionBuffer[65];
|
2006-10-01 19:27:10 +00:00
|
|
|
|
2006-10-01 18:01:38 +00:00
|
|
|
/* Validate Loader */
|
|
|
|
if (!ExpIsLoaderValid(LoaderBlock))
|
|
|
|
{
|
|
|
|
/* Invalid loader version */
|
|
|
|
KeBugCheckEx(MISMATCHED_HAL,
|
|
|
|
3,
|
|
|
|
LoaderBlock->Extension->Size,
|
|
|
|
LoaderBlock->Extension->MajorVersion,
|
|
|
|
LoaderBlock->Extension->MinorVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize PRCB pool lookaside pointers */
|
|
|
|
ExInitPoolLookasidePointers();
|
|
|
|
|
|
|
|
/* Check if this is an application CPU */
|
|
|
|
if (Cpu)
|
|
|
|
{
|
|
|
|
/* Then simply initialize it with HAL */
|
|
|
|
if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
|
|
|
|
{
|
|
|
|
/* Initialization failed */
|
2006-10-09 01:16:28 +00:00
|
|
|
KeBugCheck(HAL_INITIALIZATION_FAILED);
|
2006-10-01 18:01:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We're done */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-01 18:27:59 +00:00
|
|
|
/* Assume no text-mode or remote boot */
|
|
|
|
ExpInTextModeSetup = FALSE;
|
|
|
|
IoRemoteBootClient = FALSE;
|
|
|
|
|
|
|
|
/* Check if we have a setup loader block */
|
|
|
|
if (LoaderBlock->SetupLdrBlock)
|
|
|
|
{
|
|
|
|
/* Check if this is text-mode setup */
|
2017-06-02 15:47:52 +00:00
|
|
|
if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
|
|
|
|
ExpInTextModeSetup = TRUE;
|
2006-10-01 18:27:59 +00:00
|
|
|
|
|
|
|
/* Check if this is network boot */
|
2008-08-01 16:47:17 +00:00
|
|
|
if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
|
2006-10-01 18:27:59 +00:00
|
|
|
{
|
|
|
|
/* Set variable */
|
|
|
|
IoRemoteBootClient = TRUE;
|
|
|
|
|
|
|
|
/* Make sure we're actually booting off the network */
|
|
|
|
ASSERT(!_memicmp(LoaderBlock->ArcBootDeviceName, "net(0)", 6));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set phase to 0 */
|
|
|
|
ExpInitializationPhase = 0;
|
|
|
|
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Get boot command line */
|
|
|
|
CommandLine = LoaderBlock->LoadOptions;
|
|
|
|
if (CommandLine)
|
|
|
|
{
|
|
|
|
/* Upcase it for comparison and check if we're in performance mode */
|
|
|
|
_strupr(CommandLine);
|
|
|
|
PerfMem = strstr(CommandLine, "PERFMEM");
|
|
|
|
if (PerfMem)
|
|
|
|
{
|
|
|
|
/* Check if the user gave a number of bytes to use */
|
|
|
|
PerfMem = strstr(PerfMem, "=");
|
|
|
|
if (PerfMem)
|
|
|
|
{
|
|
|
|
/* Read the number of pages we'll use */
|
|
|
|
PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
|
2020-05-24 17:37:16 +00:00
|
|
|
if (PerfMemUsed)
|
2007-01-24 19:48:34 +00:00
|
|
|
{
|
|
|
|
/* FIXME: TODO */
|
|
|
|
DPRINT1("BBT performance mode not yet supported."
|
|
|
|
"/PERFMEM option ignored.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we're burning memory */
|
|
|
|
PerfMem = strstr(CommandLine, "BURNMEMORY");
|
|
|
|
if (PerfMem)
|
|
|
|
{
|
|
|
|
/* Check if the user gave a number of bytes to use */
|
|
|
|
PerfMem = strstr(PerfMem, "=");
|
|
|
|
if (PerfMem)
|
|
|
|
{
|
|
|
|
/* Read the number of pages we'll use */
|
|
|
|
PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE);
|
2010-08-19 08:50:23 +00:00
|
|
|
if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
|
2007-01-24 19:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-01 19:27:10 +00:00
|
|
|
/* Setup NLS Base and offsets */
|
|
|
|
NlsData = LoaderBlock->NlsData;
|
|
|
|
ExpNlsTableBase = NlsData->AnsiCodePageData;
|
|
|
|
ExpAnsiCodePageDataOffset = 0;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
ExpOemCodePageDataOffset = (ULONG)((ULONG_PTR)NlsData->OemCodePageData -
|
|
|
|
(ULONG_PTR)NlsData->AnsiCodePageData);
|
|
|
|
ExpUnicodeCaseTableDataOffset = (ULONG)((ULONG_PTR)NlsData->UnicodeCodePageData -
|
|
|
|
(ULONG_PTR)NlsData->AnsiCodePageData);
|
2006-10-01 19:27:10 +00:00
|
|
|
|
|
|
|
/* Initialize the NLS Tables */
|
|
|
|
RtlInitNlsTables((PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpAnsiCodePageDataOffset),
|
|
|
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpOemCodePageDataOffset),
|
|
|
|
(PVOID)((ULONG_PTR)ExpNlsTableBase +
|
|
|
|
ExpUnicodeCaseTableDataOffset),
|
|
|
|
&ExpNlsTableInfo);
|
|
|
|
RtlResetRtlTranslations(&ExpNlsTableInfo);
|
|
|
|
|
|
|
|
/* Now initialize the HAL */
|
|
|
|
if (!HalInitSystem(ExpInitializationPhase, LoaderBlock))
|
|
|
|
{
|
|
|
|
/* HAL failed to initialize, bugcheck */
|
|
|
|
KeBugCheck(HAL_INITIALIZATION_FAILED);
|
|
|
|
}
|
2006-09-02 04:40:09 +00:00
|
|
|
|
2006-10-01 19:27:10 +00:00
|
|
|
/* Make sure interrupts are active now */
|
|
|
|
_enable();
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-10-02 13:23:03 +00:00
|
|
|
/* Clear the crypto exponent */
|
|
|
|
SharedUserData->CryptoExponent = 0;
|
|
|
|
|
|
|
|
/* Set global flags for the checked build */
|
|
|
|
#if DBG
|
|
|
|
NtGlobalFlag |= FLG_ENABLE_CLOSE_EXCEPTIONS |
|
|
|
|
FLG_ENABLE_KDEBUG_SYMBOL_LOAD;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Setup NT System Root Path */
|
|
|
|
sprintf(Buffer, "C:%s", LoaderBlock->NtBootPathName);
|
|
|
|
|
|
|
|
/* Convert to ANSI_STRING and null-terminate it */
|
2007-05-09 00:44:45 +00:00
|
|
|
RtlInitString(&AnsiPath, Buffer);
|
2006-10-09 01:16:28 +00:00
|
|
|
Buffer[--AnsiPath.Length] = ANSI_NULL;
|
2006-10-02 13:23:03 +00:00
|
|
|
|
|
|
|
/* Get the string from KUSER_SHARED_DATA's buffer */
|
2007-01-18 06:23:14 +00:00
|
|
|
RtlInitEmptyUnicodeString(&NtSystemRoot,
|
|
|
|
SharedUserData->NtSystemRoot,
|
|
|
|
sizeof(SharedUserData->NtSystemRoot));
|
2006-10-02 13:23:03 +00:00
|
|
|
|
|
|
|
/* Now fill it in */
|
|
|
|
Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &AnsiPath, FALSE);
|
2008-08-24 15:48:05 +00:00
|
|
|
if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
|
2006-10-02 13:23:03 +00:00
|
|
|
|
2006-09-02 05:10:16 +00:00
|
|
|
/* Setup bugcheck messages */
|
|
|
|
KiInitializeBugCheck();
|
|
|
|
|
2008-08-16 17:53:28 +00:00
|
|
|
/* Setup initial system settings */
|
2007-02-15 17:44:04 +00:00
|
|
|
CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
|
2007-01-24 19:48:34 +00:00
|
|
|
|
2015-03-16 03:14:16 +00:00
|
|
|
/* Set the Service Pack Number and add it to the CSD Version number if needed */
|
2012-09-20 19:53:14 +00:00
|
|
|
CmNtSpBuildNumber = VER_PRODUCTBUILD_QFE;
|
2015-03-16 03:14:16 +00:00
|
|
|
if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
|
2007-05-09 00:44:45 +00:00
|
|
|
{
|
2015-03-16 03:14:16 +00:00
|
|
|
CmNtCSDVersion |= (VER_PRODUCTBUILD_QFE << 16);
|
2007-05-09 00:44:45 +00:00
|
|
|
}
|
|
|
|
|
2011-02-09 21:22:47 +00:00
|
|
|
/* Add loaded CmNtGlobalFlag value */
|
|
|
|
NtGlobalFlag |= CmNtGlobalFlag;
|
|
|
|
|
2006-10-02 13:23:03 +00:00
|
|
|
/* Initialize the executive at phase 0 */
|
2008-08-24 15:48:05 +00:00
|
|
|
if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
|
2006-01-05 16:24:32 +00:00
|
|
|
|
2007-02-22 18:02:53 +00:00
|
|
|
/* Initialize the memory manager at phase 0 */
|
2010-10-18 23:07:09 +00:00
|
|
|
if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
|
2007-02-22 18:02:53 +00:00
|
|
|
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Load boot symbols */
|
|
|
|
ExpLoadBootSymbols(LoaderBlock);
|
2006-10-02 15:52:58 +00:00
|
|
|
|
2007-03-05 02:29:46 +00:00
|
|
|
/* Check if we should break after symbol load */
|
2024-11-28 19:18:32 +00:00
|
|
|
if (KdBreakAfterSymbolLoad)
|
|
|
|
DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
|
2007-03-05 02:29:46 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Check if this loader is compatible with NT 5.2 */
|
|
|
|
if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
|
|
|
|
{
|
|
|
|
/* Setup headless terminal settings */
|
|
|
|
HeadlessInit(LoaderBlock);
|
|
|
|
}
|
|
|
|
|
2006-10-02 15:05:03 +00:00
|
|
|
/* Set system ranges */
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
#ifdef _M_AMD64
|
|
|
|
SharedUserData->Reserved1 = MM_HIGHEST_USER_ADDRESS_WOW64;
|
|
|
|
SharedUserData->Reserved3 = MM_SYSTEM_RANGE_START_WOW64;
|
|
|
|
#else
|
2006-10-02 15:05:03 +00:00
|
|
|
SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
|
|
|
|
SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
|
[HAL/NDK]
- Make Vector parameter in HalEnableSystemInterrupt, HalDisableSystemInterrupt and HalBeginSystemInterrupt an ULONG, not an UCHAR
[NDK]
- 64bit fixes for HANDLE_TABLE, KPROCESS, SECTION_IMAGE_INFORMATION, MMADDRESS_LIST, MMVAD_FLAGS, MMVAD, MMVAD_LONG, MMVAD_SHORT, MEMORY_DESCRIPTOR, MEMORY_ALLOCATION_DESCRIPTOR, LdrVerifyMappedImageMatchesChecksum
- KDPC_DATA::DpcQueueDepth is signed on amd64, unsigned on x86
[NTOSKRNL]
- Fix hundreds of MSVC and amd64 warnings
- add a pragma message to FstubFixupEfiPartition, since it looks broken
- Move portable Ke constants from <arch>/cpu.c to krnlinit.c
- Fixed a bug in amd64 KiGeneralProtectionFaultHandler
svn path=/trunk/; revision=53734
2011-09-18 13:11:45 +00:00
|
|
|
#endif
|
2006-10-02 15:05:03 +00:00
|
|
|
|
2006-10-05 16:38:58 +00:00
|
|
|
/* Make a copy of the NLS Tables */
|
|
|
|
ExpInitNls(LoaderBlock);
|
2005-03-12 21:08:29 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Get the kernel's load entry */
|
|
|
|
NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
|
|
|
|
LDR_DATA_TABLE_ENTRY,
|
|
|
|
InLoadOrderLinks);
|
|
|
|
|
|
|
|
/* Check if this is a service pack */
|
|
|
|
if (CmNtCSDVersion & 0xFFFF)
|
|
|
|
{
|
|
|
|
/* Get the service pack string */
|
|
|
|
Status = RtlFindMessage(NtosEntry->DllBase,
|
|
|
|
11,
|
|
|
|
0,
|
|
|
|
WINDOWS_NT_CSD_STRING,
|
|
|
|
&MsgEntry);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Setup the string */
|
2015-03-16 03:14:16 +00:00
|
|
|
RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
|
2007-05-13 20:26:08 +00:00
|
|
|
|
|
|
|
/* Remove trailing newline */
|
2015-03-16 03:14:16 +00:00
|
|
|
while ((CSDString.Length > 0) &&
|
|
|
|
((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
|
|
|
|
(CSDString.Buffer[CSDString.Length - 1] == '\n')))
|
2007-05-13 20:26:08 +00:00
|
|
|
{
|
|
|
|
/* Skip the trailing character */
|
2015-03-16 03:14:16 +00:00
|
|
|
CSDString.Length--;
|
2007-05-13 20:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill the buffer with version information */
|
2007-05-09 00:44:45 +00:00
|
|
|
Status = RtlStringCbPrintfA(Buffer,
|
|
|
|
sizeof(Buffer),
|
|
|
|
"%Z %u%c",
|
2015-03-16 03:14:16 +00:00
|
|
|
&CSDString,
|
2007-05-09 00:44:45 +00:00
|
|
|
(CmNtCSDVersion & 0xFF00) >> 8,
|
|
|
|
(CmNtCSDVersion & 0xFF) ?
|
|
|
|
'A' + (CmNtCSDVersion & 0xFF) - 1 :
|
|
|
|
ANSI_NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Build default string */
|
|
|
|
Status = RtlStringCbPrintfA(Buffer,
|
|
|
|
sizeof(Buffer),
|
|
|
|
"CSD %04x",
|
|
|
|
CmNtCSDVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for success */
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Then this is a beta */
|
|
|
|
Status = RtlStringCbCopyExA(Buffer,
|
|
|
|
sizeof(Buffer),
|
|
|
|
VER_PRODUCTBETA_STR,
|
|
|
|
NULL,
|
|
|
|
&Remaining,
|
|
|
|
0);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update length */
|
2007-08-05 11:27:39 +00:00
|
|
|
CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
|
2007-05-09 00:44:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we have an RC number */
|
2015-03-16 03:14:16 +00:00
|
|
|
if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
|
2007-05-09 00:44:45 +00:00
|
|
|
{
|
|
|
|
/* Check if we have no version data yet */
|
|
|
|
if (!(*Buffer))
|
|
|
|
{
|
|
|
|
/* Set defaults */
|
|
|
|
Remaining = sizeof(Buffer);
|
|
|
|
RcEnd = Buffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Add comma and space */
|
|
|
|
Status = RtlStringCbCatExA(Buffer,
|
|
|
|
sizeof(Buffer),
|
|
|
|
", ",
|
|
|
|
&RcEnd,
|
|
|
|
&Remaining,
|
|
|
|
0);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the version format string */
|
|
|
|
Status = RtlStringCbPrintfA(RcEnd,
|
|
|
|
Remaining,
|
2015-03-17 03:04:20 +00:00
|
|
|
"v.%u",
|
|
|
|
(CmNtCSDVersion & 0xFFFF0000) >> 16);
|
2007-05-09 00:44:45 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now setup the final string */
|
2015-03-16 03:14:16 +00:00
|
|
|
RtlInitAnsiString(&CSDString, Buffer);
|
2007-05-09 00:44:45 +00:00
|
|
|
Status = RtlAnsiStringToUnicodeString(&CmCSDVersionString,
|
2015-03-16 03:14:16 +00:00
|
|
|
&CSDString,
|
2007-05-09 00:44:45 +00:00
|
|
|
TRUE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add our version */
|
|
|
|
Status = RtlStringCbPrintfA(VersionBuffer,
|
|
|
|
sizeof(VersionBuffer),
|
|
|
|
"%u.%u",
|
|
|
|
VER_PRODUCTMAJORVERSION,
|
|
|
|
VER_PRODUCTMINORVERSION);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Fail */
|
|
|
|
KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Build the final version string */
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(&CmVersionString, VersionBuffer);
|
|
|
|
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Check if the user wants a kernel stack trace database */
|
|
|
|
if (NtGlobalFlag & FLG_KERNEL_STACK_TRACE_DB)
|
|
|
|
{
|
|
|
|
/* FIXME: TODO */
|
|
|
|
DPRINT1("Kernel-mode stack trace support not yet present."
|
|
|
|
"FLG_KERNEL_STACK_TRACE_DB flag ignored.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if he wanted exception logging */
|
|
|
|
if (NtGlobalFlag & FLG_ENABLE_EXCEPTION_LOGGING)
|
|
|
|
{
|
|
|
|
/* FIXME: TODO */
|
|
|
|
DPRINT1("Kernel-mode exception logging support not yet present."
|
|
|
|
"FLG_ENABLE_EXCEPTION_LOGGING flag ignored.\n");
|
|
|
|
}
|
|
|
|
|
2006-10-02 13:23:03 +00:00
|
|
|
/* Initialize the Handle Table */
|
|
|
|
ExpInitializeHandleTables();
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-10-02 15:05:03 +00:00
|
|
|
#if DBG
|
|
|
|
/* On checked builds, allocate the system call count table */
|
|
|
|
KeServiceDescriptorTable[0].Count =
|
|
|
|
ExAllocatePoolWithTag(NonPagedPool,
|
|
|
|
KiServiceLimit * sizeof(ULONG),
|
2009-08-24 18:19:53 +00:00
|
|
|
'llaC');
|
2006-10-02 15:05:03 +00:00
|
|
|
|
|
|
|
/* Use it for the shadow table too */
|
|
|
|
KeServiceDescriptorTableShadow[0].Count = KeServiceDescriptorTable[0].Count;
|
|
|
|
|
|
|
|
/* Make sure allocation succeeded */
|
|
|
|
if (KeServiceDescriptorTable[0].Count)
|
|
|
|
{
|
|
|
|
/* Zero the call counts to 0 */
|
|
|
|
RtlZeroMemory(KeServiceDescriptorTable[0].Count,
|
|
|
|
KiServiceLimit * sizeof(ULONG));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-05-29 03:32:43 +00:00
|
|
|
/* Create the Basic Object Manager Types to allow new Object Types */
|
2008-08-24 15:48:05 +00:00
|
|
|
if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
|
2006-10-02 15:05:03 +00:00
|
|
|
|
|
|
|
/* Load basic Security for other Managers */
|
2008-08-24 15:48:05 +00:00
|
|
|
if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
|
2006-05-29 03:32:43 +00:00
|
|
|
|
2006-10-02 15:05:03 +00:00
|
|
|
/* Initialize the Process Manager */
|
2008-08-24 15:48:05 +00:00
|
|
|
if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
|
2006-10-02 15:52:58 +00:00
|
|
|
|
2007-01-24 19:48:34 +00:00
|
|
|
/* Initialize the PnP Manager */
|
2008-08-24 15:48:05 +00:00
|
|
|
if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
|
2007-01-24 19:48:34 +00:00
|
|
|
|
2006-11-30 04:16:35 +00:00
|
|
|
/* Initialize the User-Mode Debugging Subsystem */
|
|
|
|
DbgkInitialize();
|
|
|
|
|
2006-10-02 15:52:58 +00:00
|
|
|
/* Calculate the tick count multiplier */
|
|
|
|
ExpTickCountMultiplier = ExComputeTickCountMultiplier(KeMaximumIncrement);
|
|
|
|
SharedUserData->TickCountMultiplier = ExpTickCountMultiplier;
|
|
|
|
|
|
|
|
/* Set the OS Version */
|
|
|
|
SharedUserData->NtMajorVersion = NtMajorVersion;
|
|
|
|
SharedUserData->NtMinorVersion = NtMinorVersion;
|
|
|
|
|
|
|
|
/* Set the machine type */
|
2010-12-22 16:14:58 +00:00
|
|
|
SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
|
|
|
|
SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
|
2024-11-18 08:44:51 +00:00
|
|
|
|
|
|
|
/* ReactOS magic */
|
|
|
|
*(PULONG)(KI_USER_SHARED_DATA + PAGE_SIZE - sizeof(ULONG)) = 0x8eac705;
|
2006-09-16 20:37:49 +00:00
|
|
|
}
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2012-02-17 07:23:27 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
MmFreeLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
|
|
|
|
|
2020-10-06 19:44:01 +00:00
|
|
|
CODE_SEG("INIT")
|
2006-09-16 20:37:49 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2007-05-09 00:44:45 +00:00
|
|
|
Phase1InitializationDiscard(IN PVOID Context)
|
2006-09-16 20:37:49 +00:00
|
|
|
{
|
2007-01-25 01:13:09 +00:00
|
|
|
PLOADER_PARAMETER_BLOCK LoaderBlock = Context;
|
2007-05-09 00:44:45 +00:00
|
|
|
NTSTATUS Status, MsgStatus;
|
2006-10-08 04:05:27 +00:00
|
|
|
TIME_FIELDS TimeFields;
|
2007-05-09 00:44:45 +00:00
|
|
|
LARGE_INTEGER SystemBootTime, UniversalBootTime, OldTime, Timeout;
|
2024-02-07 11:34:23 +00:00
|
|
|
BOOLEAN NoGuiBoot, ResetBias = FALSE, AlternateShell = FALSE;
|
2007-05-09 00:44:45 +00:00
|
|
|
PLDR_DATA_TABLE_ENTRY NtosEntry;
|
2010-06-27 20:38:12 +00:00
|
|
|
PMESSAGE_RESOURCE_ENTRY MsgEntry;
|
2007-05-09 00:44:45 +00:00
|
|
|
PCHAR CommandLine, Y2KHackRequired, SafeBoot, Environment;
|
|
|
|
PCHAR StringBuffer, EndBuffer, BeginBuffer, MpString = "";
|
|
|
|
PINIT_BUFFER InitBuffer;
|
|
|
|
ANSI_STRING TempString;
|
2010-01-13 22:35:43 +00:00
|
|
|
ULONG LastTzBias, Length, YearHack = 0, Disposition, MessageCode = 0;
|
|
|
|
SIZE_T Size;
|
2011-03-25 21:42:48 +00:00
|
|
|
size_t Remaining;
|
2007-01-25 01:13:09 +00:00
|
|
|
PRTL_USER_PROCESS_INFORMATION ProcessInfo;
|
2007-05-09 00:44:45 +00:00
|
|
|
KEY_VALUE_PARTIAL_INFORMATION KeyPartialInfo;
|
2011-06-15 12:53:32 +00:00
|
|
|
UNICODE_STRING KeyName;
|
2007-05-09 00:44:45 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
HANDLE KeyHandle, OptionHandle;
|
|
|
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
|
|
|
|
|
|
|
|
/* Allocate the initialization buffer */
|
|
|
|
InitBuffer = ExAllocatePoolWithTag(NonPagedPool,
|
|
|
|
sizeof(INIT_BUFFER),
|
2011-06-01 13:39:36 +00:00
|
|
|
TAG_INIT);
|
2007-05-09 00:44:45 +00:00
|
|
|
if (!InitBuffer)
|
2007-01-25 01:13:09 +00:00
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 8, 0, 0);
|
|
|
|
}
|
2006-09-16 20:37:49 +00:00
|
|
|
|
2006-10-05 15:13:59 +00:00
|
|
|
/* Set to phase 1 */
|
|
|
|
ExpInitializationPhase = 1;
|
|
|
|
|
2006-09-16 20:37:49 +00:00
|
|
|
/* Set us at maximum priority */
|
|
|
|
KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-10-05 16:38:58 +00:00
|
|
|
/* Do Phase 1 HAL Initialization */
|
2007-01-25 01:13:09 +00:00
|
|
|
if (!HalInitSystem(1, LoaderBlock)) KeBugCheck(HAL1_INITIALIZATION_FAILED);
|
|
|
|
|
|
|
|
/* Get the command line and upcase it */
|
2015-02-27 01:39:49 +00:00
|
|
|
CommandLine = (LoaderBlock->LoadOptions ? _strupr(LoaderBlock->LoadOptions) : NULL);
|
2006-10-05 16:38:58 +00:00
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Check if GUI Boot is enabled */
|
2015-02-27 01:39:49 +00:00
|
|
|
NoGuiBoot = (CommandLine && strstr(CommandLine, "NOGUIBOOT") != NULL);
|
2007-01-25 01:13:09 +00:00
|
|
|
|
|
|
|
/* Get the SOS setting */
|
2015-02-27 01:39:49 +00:00
|
|
|
SosEnabled = (CommandLine && strstr(CommandLine, "SOS") != NULL);
|
2006-10-08 04:05:27 +00:00
|
|
|
|
2022-05-02 00:48:46 +00:00
|
|
|
/* Setup the boot video driver */
|
2007-02-03 20:30:32 +00:00
|
|
|
InbvEnableBootDriver(!NoGuiBoot);
|
2022-05-02 00:48:46 +00:00
|
|
|
InbvDriverInitialize(LoaderBlock, IDB_MAX_RESOURCES);
|
2006-10-09 04:00:34 +00:00
|
|
|
|
2007-01-25 01:13:09 +00:00
|
|
|
/* Check if GUI boot is enabled */
|
|
|
|
if (!NoGuiBoot)
|
|
|
|
{
|
|
|
|
/* It is, display the boot logo and enable printing strings */
|
|
|
|
InbvEnableDisplayString(SosEnabled);
|
2007-02-08 00:50:23 +00:00
|
|
|
DisplayBootBitmap(SosEnabled);
|
2007-01-25 01:13:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Release display ownership if not using GUI boot */
|
2007-02-03 20:30:32 +00:00
|
|
|
InbvNotifyDisplayOwnershipLost(NULL);
|
2006-10-08 04:47:26 +00:00
|
|
|
|
2007-01-25 01:13:09 +00:00
|
|
|
/* Don't allow boot-time strings */
|
|
|
|
InbvEnableDisplayString(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if this is LiveCD (WinPE) mode */
|
2015-02-27 01:39:49 +00:00
|
|
|
if (CommandLine && strstr(CommandLine, "MININT") != NULL)
|
2007-01-25 01:13:09 +00:00
|
|
|
{
|
|
|
|
/* Setup WinPE Settings */
|
|
|
|
InitIsWinPEMode = TRUE;
|
2015-02-27 01:39:49 +00:00
|
|
|
InitWinPEModeType |= (strstr(CommandLine, "INRAM") != NULL) ? 0x80000000 : 0x00000001;
|
2007-01-25 01:13:09 +00:00
|
|
|
}
|
2007-01-24 19:48:34 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Get the kernel's load entry */
|
|
|
|
NtosEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
|
|
|
|
LDR_DATA_TABLE_ENTRY,
|
|
|
|
InLoadOrderLinks);
|
|
|
|
|
|
|
|
/* Find the banner message */
|
|
|
|
MsgStatus = RtlFindMessage(NtosEntry->DllBase,
|
|
|
|
11,
|
|
|
|
0,
|
|
|
|
WINDOWS_NT_BANNER,
|
|
|
|
&MsgEntry);
|
|
|
|
|
|
|
|
/* Setup defaults and check if we have a version string */
|
|
|
|
StringBuffer = InitBuffer->VersionBuffer;
|
|
|
|
BeginBuffer = StringBuffer;
|
|
|
|
EndBuffer = StringBuffer;
|
2011-03-25 21:42:48 +00:00
|
|
|
Remaining = sizeof(InitBuffer->VersionBuffer);
|
2007-05-09 00:44:45 +00:00
|
|
|
if (CmCSDVersionString.Length)
|
|
|
|
{
|
|
|
|
/* Print the version string */
|
|
|
|
Status = RtlStringCbPrintfExA(StringBuffer,
|
2011-03-25 21:42:48 +00:00
|
|
|
Remaining,
|
2007-05-09 00:44:45 +00:00
|
|
|
&EndBuffer,
|
2011-03-25 21:42:48 +00:00
|
|
|
&Remaining,
|
2007-05-09 00:44:45 +00:00
|
|
|
0,
|
|
|
|
": %wZ",
|
|
|
|
&CmCSDVersionString);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* No version */
|
2011-03-26 21:41:49 +00:00
|
|
|
*EndBuffer = ANSI_NULL; /* Null-terminate the string */
|
2007-05-09 00:44:45 +00:00
|
|
|
}
|
|
|
|
|
2011-03-26 21:41:49 +00:00
|
|
|
/* Skip over the null-terminator to start a new string */
|
|
|
|
++EndBuffer;
|
|
|
|
--Remaining;
|
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Build the version number */
|
|
|
|
StringBuffer = InitBuffer->VersionNumber;
|
|
|
|
Status = RtlStringCbPrintfA(StringBuffer,
|
2011-03-25 21:42:48 +00:00
|
|
|
sizeof(InitBuffer->VersionNumber),
|
2007-05-09 00:44:45 +00:00
|
|
|
"%u.%u",
|
|
|
|
VER_PRODUCTMAJORVERSION,
|
|
|
|
VER_PRODUCTMINORVERSION);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if we had found a banner message */
|
|
|
|
if (NT_SUCCESS(MsgStatus))
|
|
|
|
{
|
|
|
|
/* Create the banner message */
|
2017-10-03 10:55:38 +00:00
|
|
|
/* ReactOS specific: Report ReactOS version, NtBuildLab information and reported NT kernel version */
|
2007-05-09 00:44:45 +00:00
|
|
|
Status = RtlStringCbPrintfA(EndBuffer,
|
2011-03-25 21:42:48 +00:00
|
|
|
Remaining,
|
2010-06-27 20:45:15 +00:00
|
|
|
(PCHAR)MsgEntry->Text,
|
2017-10-03 10:55:38 +00:00
|
|
|
KERNEL_VERSION_STR,
|
|
|
|
NtBuildLab,
|
2007-05-09 00:44:45 +00:00
|
|
|
StringBuffer,
|
|
|
|
NtBuildNumber & 0xFFFF,
|
|
|
|
BeginBuffer);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Use hard-coded banner message */
|
2013-10-13 23:04:13 +00:00
|
|
|
Status = RtlStringCbCopyA(EndBuffer, Remaining, "REACTOS (R)\r\n");
|
2007-05-09 00:44:45 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Display the version string on-screen */
|
|
|
|
InbvDisplayString(EndBuffer);
|
2007-01-25 17:51:45 +00:00
|
|
|
|
2006-10-08 04:47:26 +00:00
|
|
|
/* Initialize Power Subsystem in Phase 0 */
|
2009-11-08 01:13:49 +00:00
|
|
|
if (!PoInitSystem(0)) KeBugCheck(INTERNAL_POWER_ERROR);
|
2007-01-25 01:13:09 +00:00
|
|
|
|
|
|
|
/* Check for Y2K hack */
|
2018-01-20 12:42:39 +00:00
|
|
|
Y2KHackRequired = CommandLine ? strstr(CommandLine, "YEAR") : NULL;
|
2007-01-25 01:13:09 +00:00
|
|
|
if (Y2KHackRequired) Y2KHackRequired = strstr(Y2KHackRequired, "=");
|
|
|
|
if (Y2KHackRequired) YearHack = atol(Y2KHackRequired + 1);
|
2006-10-08 04:47:26 +00:00
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Query the clock */
|
2007-01-25 01:13:09 +00:00
|
|
|
if ((ExCmosClockIsSane) && (HalQueryRealTimeClock(&TimeFields)))
|
2006-10-08 04:05:27 +00:00
|
|
|
{
|
2007-01-25 01:13:09 +00:00
|
|
|
/* Check if we're using the Y2K hack */
|
|
|
|
if (Y2KHackRequired) TimeFields.Year = (CSHORT)YearHack;
|
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Convert to time fields */
|
|
|
|
RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
|
|
|
|
UniversalBootTime = SystemBootTime;
|
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Check if real time is GMT */
|
|
|
|
if (!ExpRealTimeIsUniversal)
|
|
|
|
{
|
|
|
|
/* Check if we don't have a valid bias */
|
2009-09-27 20:07:43 +00:00
|
|
|
if (ExpLastTimeZoneBias == MAXULONG)
|
2007-05-09 00:44:45 +00:00
|
|
|
{
|
|
|
|
/* Reset */
|
|
|
|
ResetBias = TRUE;
|
|
|
|
ExpLastTimeZoneBias = ExpAltTimeZoneBias;
|
|
|
|
}
|
2006-10-08 04:05:27 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Calculate the bias in seconds */
|
|
|
|
ExpTimeZoneBias.QuadPart = Int32x32To64(ExpLastTimeZoneBias * 60,
|
|
|
|
10000000);
|
2006-10-08 04:05:27 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Set the boot time-zone bias */
|
|
|
|
SharedUserData->TimeZoneBias.High2Time = ExpTimeZoneBias.HighPart;
|
|
|
|
SharedUserData->TimeZoneBias.LowPart = ExpTimeZoneBias.LowPart;
|
|
|
|
SharedUserData->TimeZoneBias.High1Time = ExpTimeZoneBias.HighPart;
|
|
|
|
|
|
|
|
/* Convert the boot time to local time, and set it */
|
|
|
|
UniversalBootTime.QuadPart = SystemBootTime.QuadPart +
|
|
|
|
ExpTimeZoneBias.QuadPart;
|
|
|
|
}
|
2007-01-25 01:13:09 +00:00
|
|
|
|
2023-09-03 14:44:12 +00:00
|
|
|
/* Update the system time and notify the system */
|
2007-01-25 01:13:09 +00:00
|
|
|
KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
|
2007-05-09 00:44:45 +00:00
|
|
|
PoNotifySystemTimeSet();
|
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Remember this as the boot time */
|
|
|
|
KeBootTime = UniversalBootTime;
|
2007-01-25 01:13:09 +00:00
|
|
|
KeBootTimeBias = 0;
|
2006-10-08 04:05:27 +00:00
|
|
|
}
|
|
|
|
|
2023-11-19 23:51:33 +00:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Start Application Processors */
|
|
|
|
KeStartAllProcessors();
|
|
|
|
#endif
|
|
|
|
|
2006-10-02 15:52:58 +00:00
|
|
|
/* Initialize all processors */
|
2007-01-25 01:13:09 +00:00
|
|
|
if (!HalAllProcessorsStarted()) KeBugCheck(HAL1_INITIALIZATION_FAILED);
|
2006-10-02 15:52:58 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* HACK: We should use RtlFindMessage and not only fallback to this */
|
|
|
|
MpString = "MultiProcessor Kernel\r\n";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Setup the "MP" String */
|
|
|
|
RtlInitAnsiString(&TempString, MpString);
|
|
|
|
|
|
|
|
/* Make sure to remove the \r\n if we actually have a string */
|
2007-05-13 20:26:08 +00:00
|
|
|
while ((TempString.Length > 0) &&
|
2007-05-13 22:44:36 +00:00
|
|
|
((TempString.Buffer[TempString.Length - 1] == '\r') ||
|
|
|
|
(TempString.Buffer[TempString.Length - 1] == '\n')))
|
2007-05-13 20:26:08 +00:00
|
|
|
{
|
|
|
|
/* Skip the trailing character */
|
|
|
|
TempString.Length--;
|
|
|
|
}
|
2007-05-09 00:44:45 +00:00
|
|
|
|
|
|
|
/* Get the information string from our resource file */
|
|
|
|
MsgStatus = RtlFindMessage(NtosEntry->DllBase,
|
|
|
|
11,
|
|
|
|
0,
|
|
|
|
KeNumberProcessors > 1 ?
|
|
|
|
WINDOWS_NT_INFO_STRING_PLURAL :
|
|
|
|
WINDOWS_NT_INFO_STRING,
|
|
|
|
&MsgEntry);
|
|
|
|
|
2018-02-02 23:19:18 +00:00
|
|
|
/* Get total RAM size, in MiB */
|
|
|
|
/* Round size up. Assumed to better match actual physical RAM size */
|
|
|
|
Size = ALIGN_UP_BY(MmNumberOfPhysicalPages * PAGE_SIZE, 1024 * 1024) / (1024 * 1024);
|
2007-05-09 00:44:45 +00:00
|
|
|
|
|
|
|
/* Create the string */
|
|
|
|
StringBuffer = InitBuffer->VersionBuffer;
|
|
|
|
Status = RtlStringCbPrintfA(StringBuffer,
|
2011-03-25 21:42:48 +00:00
|
|
|
sizeof(InitBuffer->VersionBuffer),
|
2007-05-09 00:44:45 +00:00
|
|
|
NT_SUCCESS(MsgStatus) ?
|
2010-06-27 20:45:15 +00:00
|
|
|
(PCHAR)MsgEntry->Text :
|
2018-01-29 19:31:07 +00:00
|
|
|
"%u System Processor [%Iu MB Memory] %Z\r\n",
|
2007-05-09 00:44:45 +00:00
|
|
|
KeNumberProcessors,
|
|
|
|
Size,
|
|
|
|
&TempString);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 4, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Display RAM and CPU count */
|
|
|
|
InbvDisplayString(StringBuffer);
|
2007-01-25 17:51:45 +00:00
|
|
|
|
|
|
|
/* Update the progress bar */
|
|
|
|
InbvUpdateProgressBar(5);
|
|
|
|
|
2006-10-05 16:38:58 +00:00
|
|
|
/* Call OB initialization again */
|
2008-08-14 19:30:32 +00:00
|
|
|
if (!ObInitSystem()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED);
|
2006-10-02 15:52:58 +00:00
|
|
|
|
2006-09-16 20:37:49 +00:00
|
|
|
/* Initialize Basic System Objects and Worker Threads */
|
2007-01-25 01:13:09 +00:00
|
|
|
if (!ExInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 1, 0);
|
2006-10-05 16:38:58 +00:00
|
|
|
|
|
|
|
/* Initialize the later stages of the kernel */
|
2007-01-25 01:13:09 +00:00
|
|
|
if (!KeInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 2, 0);
|
2006-10-08 04:05:27 +00:00
|
|
|
|
|
|
|
/* Call KD Providers at Phase 1 */
|
|
|
|
if (!KdInitSystem(ExpInitializationPhase, KeLoaderBlock))
|
|
|
|
{
|
|
|
|
/* Failed, bugcheck */
|
2007-01-25 01:13:09 +00:00
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 3, 0);
|
2006-10-08 04:05:27 +00:00
|
|
|
}
|
2006-10-05 16:38:58 +00:00
|
|
|
|
2007-01-25 01:13:09 +00:00
|
|
|
/* Initialize the SRM in Phase 1 */
|
2008-08-24 15:48:05 +00:00
|
|
|
if (!SeInitSystem()) KeBugCheck(SECURITY1_INITIALIZATION_FAILED);
|
2007-01-25 01:13:09 +00:00
|
|
|
|
|
|
|
/* Update the progress bar */
|
|
|
|
InbvUpdateProgressBar(10);
|
|
|
|
|
2006-10-08 04:47:26 +00:00
|
|
|
/* Create SystemRoot Link */
|
2007-01-25 01:13:09 +00:00
|
|
|
Status = ExpCreateSystemRootLink(LoaderBlock);
|
2006-10-08 07:53:37 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2007-01-25 01:13:09 +00:00
|
|
|
/* Failed to create the system root link */
|
2006-10-08 07:53:37 +00:00
|
|
|
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 0, 0, 0);
|
|
|
|
}
|
2006-10-08 04:47:26 +00:00
|
|
|
|
2007-01-25 01:13:09 +00:00
|
|
|
/* Set up Region Maps, Sections and the Paging File */
|
2007-01-25 17:51:45 +00:00
|
|
|
if (!MmInitSystem(1, LoaderBlock)) KeBugCheck(MEMORY1_INITIALIZATION_FAILED);
|
2007-01-25 01:13:09 +00:00
|
|
|
|
2006-10-05 16:38:58 +00:00
|
|
|
/* Create NLS section */
|
2010-10-18 23:07:09 +00:00
|
|
|
ExpInitNls(LoaderBlock);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Initialize Cache Views */
|
2007-01-25 17:51:45 +00:00
|
|
|
if (!CcInitializeCacheManager()) KeBugCheck(CACHE_INITIALIZATION_FAILED);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2006-10-09 01:16:28 +00:00
|
|
|
/* Initialize the Registry */
|
|
|
|
if (!CmInitSystem1()) KeBugCheck(CONFIG_INITIALIZATION_FAILED);
|
2006-10-08 04:05:27 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Initialize Prefetcher */
|
|
|
|
CcPfInitializePrefetcher();
|
|
|
|
|
2007-01-25 17:51:45 +00:00
|
|
|
/* Update progress bar */
|
|
|
|
InbvUpdateProgressBar(15);
|
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Update timezone information */
|
2007-05-09 00:44:45 +00:00
|
|
|
LastTzBias = ExpLastTimeZoneBias;
|
2006-10-08 04:05:27 +00:00
|
|
|
ExRefreshTimeZoneInformation(&SystemBootTime);
|
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Check if we're resetting timezone data */
|
|
|
|
if (ResetBias)
|
|
|
|
{
|
|
|
|
/* Convert the local time to system time */
|
|
|
|
ExLocalTimeToSystemTime(&SystemBootTime, &UniversalBootTime);
|
|
|
|
KeBootTime = UniversalBootTime;
|
|
|
|
KeBootTimeBias = 0;
|
|
|
|
|
|
|
|
/* Set the new time */
|
|
|
|
KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Check if the timezone switched and update the time */
|
2023-09-03 14:44:12 +00:00
|
|
|
if (LastTzBias != ExpLastTimeZoneBias)
|
|
|
|
ZwSetSystemTime(NULL, NULL);
|
2007-05-09 00:44:45 +00:00
|
|
|
}
|
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Initialize the File System Runtime Library */
|
2007-01-25 17:51:45 +00:00
|
|
|
if (!FsRtlInitSystem()) KeBugCheck(FILE_INITIALIZATION_FAILED);
|
2005-03-12 21:08:29 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Initialize range lists */
|
|
|
|
RtlInitializeRangeListPackage();
|
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Report all resources used by HAL */
|
2005-05-09 01:38:29 +00:00
|
|
|
HalReportResourceUsage();
|
2005-10-09 00:45:33 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Call the debugger DLL */
|
2007-03-04 19:20:03 +00:00
|
|
|
KdDebuggerInitialize1(LoaderBlock);
|
2007-01-25 17:51:45 +00:00
|
|
|
|
|
|
|
/* Setup PnP Manager in phase 1 */
|
|
|
|
if (!PpInitSystem()) KeBugCheck(PP1_INITIALIZATION_FAILED);
|
|
|
|
|
|
|
|
/* Update progress bar */
|
|
|
|
InbvUpdateProgressBar(20);
|
2006-10-05 15:13:59 +00:00
|
|
|
|
2007-01-25 17:51:45 +00:00
|
|
|
/* Initialize LPC */
|
|
|
|
if (!LpcInitSystem()) KeBugCheck(LPC_INITIALIZATION_FAILED);
|
2005-03-12 21:08:29 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Make sure we have a command line */
|
|
|
|
if (CommandLine)
|
|
|
|
{
|
|
|
|
/* Check if this is a safe mode boot */
|
|
|
|
SafeBoot = strstr(CommandLine, "SAFEBOOT:");
|
|
|
|
if (SafeBoot)
|
|
|
|
{
|
|
|
|
/* Check what kind of boot this is */
|
|
|
|
SafeBoot += 9;
|
|
|
|
if (!strncmp(SafeBoot, "MINIMAL", 7))
|
|
|
|
{
|
|
|
|
/* Minimal mode */
|
|
|
|
InitSafeBootMode = 1;
|
|
|
|
SafeBoot += 7;
|
|
|
|
MessageCode = BOOTING_IN_SAFEMODE_MINIMAL;
|
|
|
|
}
|
|
|
|
else if (!strncmp(SafeBoot, "NETWORK", 7))
|
|
|
|
{
|
|
|
|
/* With Networking */
|
2010-05-11 00:36:56 +00:00
|
|
|
InitSafeBootMode = 2;
|
2007-05-09 00:44:45 +00:00
|
|
|
SafeBoot += 7;
|
|
|
|
MessageCode = BOOTING_IN_SAFEMODE_NETWORK;
|
|
|
|
}
|
|
|
|
else if (!strncmp(SafeBoot, "DSREPAIR", 8))
|
|
|
|
{
|
|
|
|
/* Domain Server Repair */
|
|
|
|
InitSafeBootMode = 3;
|
|
|
|
SafeBoot += 8;
|
|
|
|
MessageCode = BOOTING_IN_SAFEMODE_DSREPAIR;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Invalid */
|
|
|
|
InitSafeBootMode = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if there's any settings left */
|
|
|
|
if (*SafeBoot)
|
|
|
|
{
|
|
|
|
/* Check if an alternate shell was requested */
|
|
|
|
if (!strncmp(SafeBoot, "(ALTERNATESHELL)", 16))
|
|
|
|
{
|
|
|
|
/* Remember this for later */
|
|
|
|
AlternateShell = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the message to print out */
|
|
|
|
Status = RtlFindMessage(NtosEntry->DllBase,
|
|
|
|
11,
|
|
|
|
0,
|
|
|
|
MessageCode,
|
|
|
|
&MsgEntry);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Display it */
|
2010-06-27 20:45:15 +00:00
|
|
|
InbvDisplayString((PCHAR)MsgEntry->Text);
|
2007-05-09 00:44:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure we have a command line */
|
|
|
|
if (CommandLine)
|
|
|
|
{
|
|
|
|
/* Check if bootlogging is enabled */
|
|
|
|
if (strstr(CommandLine, "BOOTLOG"))
|
|
|
|
{
|
|
|
|
/* Find the message to print out */
|
|
|
|
Status = RtlFindMessage(NtosEntry->DllBase,
|
|
|
|
11,
|
|
|
|
0,
|
|
|
|
BOOTLOG_ENABLED,
|
|
|
|
&MsgEntry);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Display it */
|
2010-06-27 20:45:15 +00:00
|
|
|
InbvDisplayString((PCHAR)MsgEntry->Text);
|
2007-05-09 00:44:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup boot logging */
|
|
|
|
//IopInitializeBootLogging(LoaderBlock, InitBuffer->BootlogHeader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup the Executive in Phase 2 */
|
|
|
|
//ExInitSystemPhase2();
|
|
|
|
|
|
|
|
/* Update progress bar */
|
|
|
|
InbvUpdateProgressBar(25);
|
|
|
|
|
|
|
|
/* No KD Time Slip is pending */
|
|
|
|
KdpTimeSlipPending = 0;
|
|
|
|
|
|
|
|
/* Initialize in-place execution support */
|
|
|
|
XIPInit(LoaderBlock);
|
|
|
|
|
|
|
|
/* Set maximum update to 75% */
|
|
|
|
InbvSetProgressBarSubset(25, 75);
|
|
|
|
|
2006-10-08 23:46:26 +00:00
|
|
|
/* Initialize the I/O Subsystem */
|
2007-05-09 00:44:45 +00:00
|
|
|
if (!IoInitSystem(LoaderBlock)) KeBugCheck(IO1_INITIALIZATION_FAILED);
|
|
|
|
|
|
|
|
/* Set maximum update to 100% */
|
|
|
|
InbvSetProgressBarSubset(0, 100);
|
|
|
|
|
|
|
|
/* Are we in safe mode? */
|
|
|
|
if (InitSafeBootMode)
|
|
|
|
{
|
|
|
|
/* Open the safe boot key */
|
|
|
|
RtlInitUnicodeString(&KeyName,
|
|
|
|
L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"
|
|
|
|
L"\\CONTROL\\SAFEBOOT");
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&KeyName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = ZwOpenKey(&KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* First check if we have an alternate shell */
|
|
|
|
if (AlternateShell)
|
|
|
|
{
|
|
|
|
/* Make sure that the registry has one setup */
|
|
|
|
RtlInitUnicodeString(&KeyName, L"AlternateShell");
|
|
|
|
Status = NtQueryValueKey(KeyHandle,
|
|
|
|
&KeyName,
|
|
|
|
KeyValuePartialInformation,
|
|
|
|
&KeyPartialInfo,
|
|
|
|
sizeof(KeyPartialInfo),
|
|
|
|
&Length);
|
2011-06-07 16:42:43 +00:00
|
|
|
if (!(NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW))
|
|
|
|
{
|
|
|
|
AlternateShell = FALSE;
|
|
|
|
}
|
2007-05-09 00:44:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the option key */
|
|
|
|
RtlInitUnicodeString(&KeyName, L"Option");
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&KeyName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
KeyHandle,
|
|
|
|
NULL);
|
|
|
|
Status = ZwCreateKey(&OptionHandle,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_VOLATILE,
|
|
|
|
&Disposition);
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
|
|
|
|
/* Check if the key create worked */
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Write the safe boot type */
|
|
|
|
RtlInitUnicodeString(&KeyName, L"OptionValue");
|
2014-07-10 09:05:37 +00:00
|
|
|
NtSetValueKey(OptionHandle,
|
2007-05-09 00:44:45 +00:00
|
|
|
&KeyName,
|
|
|
|
0,
|
|
|
|
REG_DWORD,
|
|
|
|
&InitSafeBootMode,
|
|
|
|
sizeof(InitSafeBootMode));
|
|
|
|
|
|
|
|
/* Check if we have to use an alternate shell */
|
|
|
|
if (AlternateShell)
|
|
|
|
{
|
|
|
|
/* Remember this for later */
|
|
|
|
Disposition = TRUE;
|
|
|
|
RtlInitUnicodeString(&KeyName, L"UseAlternateShell");
|
2014-07-10 09:05:37 +00:00
|
|
|
NtSetValueKey(OptionHandle,
|
2007-05-09 00:44:45 +00:00
|
|
|
&KeyName,
|
|
|
|
0,
|
|
|
|
REG_DWORD,
|
|
|
|
&Disposition,
|
|
|
|
sizeof(Disposition));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the options key handle */
|
|
|
|
NtClose(OptionHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Are we in Win PE mode? */
|
|
|
|
if (InitIsWinPEMode)
|
|
|
|
{
|
|
|
|
/* Open the safe control key */
|
|
|
|
RtlInitUnicodeString(&KeyName,
|
|
|
|
L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"
|
|
|
|
L"\\CONTROL");
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&KeyName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = ZwOpenKey(&KeyHandle, KEY_ALL_ACCESS, &ObjectAttributes);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 6, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the MiniNT key */
|
|
|
|
RtlInitUnicodeString(&KeyName, L"MiniNT");
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&KeyName,
|
|
|
|
OBJ_CASE_INSENSITIVE,
|
|
|
|
KeyHandle,
|
|
|
|
NULL);
|
|
|
|
Status = ZwCreateKey(&OptionHandle,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
REG_OPTION_VOLATILE,
|
|
|
|
&Disposition);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Bugcheck */
|
|
|
|
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 6, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the handles */
|
|
|
|
NtClose(KeyHandle);
|
|
|
|
NtClose(OptionHandle);
|
|
|
|
}
|
2005-03-12 21:08:29 +00:00
|
|
|
|
2010-10-18 23:07:09 +00:00
|
|
|
/* FIXME: This doesn't do anything for now */
|
|
|
|
MmArmInitSystem(2, LoaderBlock);
|
2007-01-25 17:51:45 +00:00
|
|
|
|
|
|
|
/* Update progress bar */
|
|
|
|
InbvUpdateProgressBar(80);
|
2006-10-09 01:16:28 +00:00
|
|
|
|
2006-10-08 04:47:26 +00:00
|
|
|
/* Initialize VDM support */
|
2009-10-24 20:44:43 +00:00
|
|
|
#if defined(_M_IX86)
|
2006-10-08 04:47:26 +00:00
|
|
|
KeI386VdmInitialize();
|
2008-03-12 18:17:55 +00:00
|
|
|
#endif
|
2006-10-08 04:47:26 +00:00
|
|
|
|
|
|
|
/* Initialize Power Subsystem in Phase 1*/
|
2009-11-08 01:13:49 +00:00
|
|
|
if (!PoInitSystem(1)) KeBugCheck(INTERNAL_POWER_ERROR);
|
2006-10-08 04:47:26 +00:00
|
|
|
|
2011-06-21 15:53:02 +00:00
|
|
|
/* Update progress bar */
|
|
|
|
InbvUpdateProgressBar(90);
|
|
|
|
|
2006-10-08 04:05:27 +00:00
|
|
|
/* Initialize the Process Manager at Phase 1 */
|
2007-01-25 01:13:09 +00:00
|
|
|
if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
|
2006-10-08 02:10:34 +00:00
|
|
|
|
2007-01-25 17:51:45 +00:00
|
|
|
/* Make sure nobody touches the loader block again */
|
2007-02-05 23:58:06 +00:00
|
|
|
if (LoaderBlock == KeLoaderBlock) KeLoaderBlock = NULL;
|
2012-02-17 07:23:27 +00:00
|
|
|
MmFreeLoaderBlock(LoaderBlock);
|
2007-01-25 17:51:45 +00:00
|
|
|
LoaderBlock = Context = NULL;
|
|
|
|
|
2015-10-25 14:33:27 +00:00
|
|
|
/* Initialize the SRM in phase 1 */
|
|
|
|
if (!SeRmInitPhase1()) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
|
|
|
|
|
2007-01-25 17:51:45 +00:00
|
|
|
/* Update progress bar */
|
2011-06-21 15:53:02 +00:00
|
|
|
InbvUpdateProgressBar(100);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2015-02-21 01:25:47 +00:00
|
|
|
/* Clear the screen */
|
|
|
|
if (InbvBootDriverInstalled) FinalizeBootLogo();
|
|
|
|
|
2011-06-15 19:28:22 +00:00
|
|
|
/* Allow strings to be displayed */
|
|
|
|
InbvEnableDisplayString(TRUE);
|
2011-06-15 12:53:32 +00:00
|
|
|
|
2011-06-21 15:53:02 +00:00
|
|
|
/* Launch initial process */
|
|
|
|
ProcessInfo = &InitBuffer->ProcessInfo;
|
|
|
|
ExpLoadInitialProcess(InitBuffer, &ProcessParameters, &Environment);
|
|
|
|
|
2011-06-15 12:53:32 +00:00
|
|
|
/* Wait 5 seconds for initial process to initialize */
|
2006-10-05 16:14:28 +00:00
|
|
|
Timeout.QuadPart = Int32x32To64(5, -10000000);
|
2007-01-25 01:13:09 +00:00
|
|
|
Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout);
|
2006-10-05 16:14:28 +00:00
|
|
|
if (Status == STATUS_SUCCESS)
|
|
|
|
{
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Failed, display error */
|
2011-06-15 12:53:32 +00:00
|
|
|
DPRINT1("INIT: Session Manager terminated.\n");
|
2007-05-09 00:44:45 +00:00
|
|
|
|
2006-10-05 16:14:28 +00:00
|
|
|
/* Bugcheck the system if SMSS couldn't initialize */
|
|
|
|
KeBugCheck(SESSION5_INITIALIZATION_FAILED);
|
2005-03-12 21:08:29 +00:00
|
|
|
}
|
|
|
|
|
2007-01-18 06:23:14 +00:00
|
|
|
/* Close process handles */
|
2007-01-25 01:13:09 +00:00
|
|
|
ZwClose(ProcessInfo->ThreadHandle);
|
|
|
|
ZwClose(ProcessInfo->ProcessHandle);
|
2005-05-09 01:38:29 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Free the initial process environment */
|
|
|
|
Size = 0;
|
|
|
|
ZwFreeVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID*)&Environment,
|
|
|
|
&Size,
|
|
|
|
MEM_RELEASE);
|
|
|
|
|
|
|
|
/* Free the initial process parameters */
|
|
|
|
Size = 0;
|
|
|
|
ZwFreeVirtualMemory(NtCurrentProcess(),
|
|
|
|
(PVOID*)&ProcessParameters,
|
|
|
|
&Size,
|
|
|
|
MEM_RELEASE);
|
2006-09-16 20:37:49 +00:00
|
|
|
|
2007-01-18 06:23:14 +00:00
|
|
|
/* Increase init phase */
|
2007-05-09 00:44:45 +00:00
|
|
|
ExpInitializationPhase++;
|
2007-01-18 06:23:14 +00:00
|
|
|
|
2007-05-09 00:44:45 +00:00
|
|
|
/* Free the boot buffer */
|
2011-06-01 13:39:36 +00:00
|
|
|
ExFreePoolWithTag(InitBuffer, TAG_INIT);
|
2007-01-25 01:13:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
Phase1Initialization(IN PVOID Context)
|
|
|
|
{
|
|
|
|
/* Do the .INIT part of Phase 1 which we can free later */
|
|
|
|
Phase1InitializationDiscard(Context);
|
|
|
|
|
2007-01-18 06:23:14 +00:00
|
|
|
/* Jump into zero page thread */
|
2010-09-28 16:47:25 +00:00
|
|
|
MmZeroPageThread();
|
2000-07-04 01:30:18 +00:00
|
|
|
}
|