reactos/ntoskrnl/ex/init.c

2024 lines
67 KiB
C
Raw Normal View History

/*
* 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)
* Eric Kohl
*/
/* INCLUDES ******************************************************************/
#include <ntoskrnl.h>
#include <reactos/buildno.h>
#define NDEBUG
#include <debug.h>
/* 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)
/* Temporary hack */
BOOLEAN
NTAPI
MmArmInitSystem(
IN ULONG Phase,
IN PLOADER_PARAMETER_BLOCK LoaderBlock
);
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;
/* DATA **********************************************************************/
/* NT Version Info */
ULONG NtMajorVersion = VER_PRODUCTMAJORVERSION;
ULONG NtMinorVersion = VER_PRODUCTMINORVERSION;
#if DBG /* Checked Build */
ULONG NtBuildNumber = VER_PRODUCTBUILD | 0xC0000000;
#else /* Free Build */
ULONG NtBuildNumber = VER_PRODUCTBUILD;
#endif
/* NT System Info */
ULONG NtGlobalFlag = 0;
ULONG ExSuiteMask;
/* Cm Version Info */
ULONG CmNtSpBuildNumber;
ULONG CmNtCSDVersion;
ULONG CmNtCSDReleaseType;
UNICODE_STRING CmVersionString;
UNICODE_STRING CmCSDVersionString;
CHAR NtBuildLab[] = KERNEL_VERSION_BUILD_STR "."
REACTOS_COMPILER_NAME "_" REACTOS_COMPILER_VERSION;
/* Init flags and settings */
ULONG ExpInitializationPhase;
BOOLEAN ExpInTextModeSetup;
BOOLEAN IoRemoteBootClient;
ULONG InitSafeBootMode;
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
BOOLEAN InitIsWinPEMode, InitWinPEModeType;
/* NT Boot Path */
UNICODE_STRING NtSystemRoot;
/* NT Initial User Application */
WCHAR NtInitialUserProcessBuffer[128] = L"\\SystemRoot\\System32\\smss.exe";
ULONG NtInitialUserProcessBufferLength = sizeof(NtInitialUserProcessBuffer) -
sizeof(WCHAR);
ULONG NtInitialUserProcessBufferType = REG_SZ;
/* Boot NLS information */
PVOID ExpNlsTableBase;
ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
ULONG ExpUnicodeCaseTableDataOffset;
NLSTABLEINFO ExpNlsTableInfo;
SIZE_T ExpNlsTableSize;
PVOID ExpNlsSectionPointer;
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* CMOS Timer Sanity */
BOOLEAN ExCmosClockIsSane = TRUE;
BOOLEAN ExpRealTimeIsUniversal;
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* FUNCTIONS ****************************************************************/
INIT_FUNCTION
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,
SePublicDefaultUnrestrictedSd);
/* Create it */
Status = NtCreateDirectoryObject(&LinkHandle,
DIRECTORY_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
/* Failed */
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,
SePublicDefaultUnrestrictedSd);
/* Create it */
Status = NtCreateDirectoryObject(&LinkHandle,
DIRECTORY_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
/* Failed */
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))
{
/* Failed */
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 3, 0, 0);
}
/* Initialize the attributes for the link */
InitializeObjectAttributes(&ObjectAttributes,
&LinkName,
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT,
NULL,
SePublicDefaultUnrestrictedSd);
/* 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))
{
/* Failed */
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 5, 0, 0);
}
/* Close the handle and return success */
ObCloseHandle(LinkHandle, KernelMode);
return STATUS_SUCCESS;
}
INIT_FUNCTION
VOID
NTAPI
ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
LARGE_INTEGER SectionSize;
NTSTATUS Status;
HANDLE NlsSection;
PVOID SectionBase = NULL;
SIZE_T ViewSize = 0;
LARGE_INTEGER SectionOffset = {{0, 0}};
PLIST_ENTRY ListHead, NextEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MdBlock;
ULONG NlsTablesEncountered = 0;
SIZE_T NlsTableSizes[3] = {0, 0, 0}; /* 3 NLS tables */
/* 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;
/* FreeLdr-specific */
NlsTableSizes[NlsTablesEncountered] = MdBlock->PageCount * PAGE_SIZE;
NlsTablesEncountered++;
ASSERT(NlsTablesEncountered < 4);
}
/* Go to the next block */
NextEntry = MdBlock->ListEntry.Flink;
}
/* Allocate the a new buffer since loader memory will be freed */
ExpNlsTableBase = ExAllocatePoolWithTag(NonPagedPool,
ExpNlsTableSize,
TAG_RTLI);
if (!ExpNlsTableBase) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
/* Copy the codepage data in its new location. */
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 */
}
/* 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;
}
/* Set the section size */
SectionSize.QuadPart = ExpNlsTableSize;
/* Create the NLS Section */
Status = ZwCreateSection(&NlsSection,
SECTION_ALL_ACCESS,
NULL,
&SectionSize,
PAGE_READWRITE,
SEC_COMMIT | 0x1,
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);
ObCloseHandle(NlsSection, KernelMode);
if (!NT_SUCCESS(Status))
{
/* Failed */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 2, 0, 0);
}
/* Map the NLS Section in system space */
Status = MmMapViewInSystemSpace(ExpNlsSectionPointer,
&SectionBase,
&ExpNlsTableSize);
if (!NT_SUCCESS(Status))
{
/* Failed */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 3, 0, 0);
}
/* Copy the codepage data in its new location. */
ASSERT(SectionBase >= MmSystemRangeStart);
RtlCopyMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize);
/* Free the previously allocated buffer and set the new location */
ExFreePoolWithTag(ExpNlsTableBase, TAG_RTLI);
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 */
Status = MmMapViewOfSection(ExpNlsSectionPointer,
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 */
RtlCopyMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize);
ExpNlsTableBase = SectionBase;
}
INIT_FUNCTION
VOID
NTAPI
ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
OUT PCHAR *ProcessEnvironment)
{
NTSTATUS Status;
SIZE_T Size;
PWSTR p;
UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
UNICODE_STRING SmssName, Environment, SystemDriveString, DebugString;
PVOID EnvironmentPtr = NULL;
PRTL_USER_PROCESS_INFORMATION ProcessInformation;
PRTL_USER_PROCESS_PARAMETERS ProcessParams = NULL;
NullString.Length = sizeof(WCHAR);
/* Use the initial buffer, after the strings */
ProcessInformation = &InitBuffer->ProcessInfo;
/* Allocate memory for the process parameters */
Size = sizeof(*ProcessParams) + ((MAX_PATH * 6) * sizeof(WCHAR));
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
(PVOID*)&ProcessParams,
0,
&Size,
MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
/* Failed, display error */
_snwprintf(InitBuffer->DebugBuffer,
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
L"INIT: Unable to allocate Process Parameters. 0x%lx",
Status);
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
ZwDisplayString(&DebugString);
/* Bugcheck the system */
KeBugCheckEx(SESSION1_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
/* Setup the basic header, and give the process the low 1MB to itself */
ProcessParams->Length = (ULONG)Size;
ProcessParams->MaximumLength = (ULONG)Size;
ProcessParams->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED |
RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
/* Allocate a page for the environment */
Size = PAGE_SIZE;
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
&EnvironmentPtr,
0,
&Size,
MEM_RESERVE | MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
/* Failed, display error */
_snwprintf(InitBuffer->DebugBuffer,
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
L"INIT: Unable to allocate Process Environment. 0x%lx",
Status);
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
ZwDisplayString(&DebugString);
/* Bugcheck the system */
KeBugCheckEx(SESSION2_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
/* Write the pointer */
ProcessParams->Environment = EnvironmentPtr;
/* Make a buffer for the DOS path */
p = (PWSTR)(ProcessParams + 1);
ProcessParams->CurrentDirectory.DosPath.Buffer = p;
ProcessParams->CurrentDirectory.DosPath.MaximumLength = MAX_PATH *
sizeof(WCHAR);
/* Copy the DOS path */
RtlCopyUnicodeString(&ProcessParams->CurrentDirectory.DosPath,
&NtSystemRoot);
/* Make a buffer for the DLL Path */
p = (PWSTR)((PCHAR)ProcessParams->CurrentDirectory.DosPath.Buffer +
ProcessParams->CurrentDirectory.DosPath.MaximumLength);
ProcessParams->DllPath.Buffer = p;
ProcessParams->DllPath.MaximumLength = MAX_PATH * sizeof(WCHAR);
/* Copy the DLL path and append the system32 directory */
RtlCopyUnicodeString(&ProcessParams->DllPath,
&ProcessParams->CurrentDirectory.DosPath);
RtlAppendUnicodeToString(&ProcessParams->DllPath, L"\\System32");
/* Make a buffer for the image name */
p = (PWSTR)((PCHAR)ProcessParams->DllPath.Buffer +
ProcessParams->DllPath.MaximumLength);
ProcessParams->ImagePathName.Buffer = p;
ProcessParams->ImagePathName.MaximumLength = MAX_PATH * sizeof(WCHAR);
/* Make sure the buffer is a valid string which within the given length */
if ((NtInitialUserProcessBufferType != REG_SZ) ||
((NtInitialUserProcessBufferLength != MAXULONG) &&
((NtInitialUserProcessBufferLength < sizeof(WCHAR)) ||
(NtInitialUserProcessBufferLength >
sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
{
/* Invalid initial process string, bugcheck */
KeBugCheckEx(SESSION2_INITIALIZATION_FAILED,
STATUS_INVALID_PARAMETER,
NtInitialUserProcessBufferType,
NtInitialUserProcessBufferLength,
sizeof(NtInitialUserProcessBuffer));
}
/* Cut out anything after a space */
p = NtInitialUserProcessBuffer;
while ((*p) && (*p != L' ')) p++;
/* Set the image path length */
ProcessParams->ImagePathName.Length =
(USHORT)((PCHAR)p - (PCHAR)NtInitialUserProcessBuffer);
/* Copy the actual buffer */
RtlCopyMemory(ProcessParams->ImagePathName.Buffer,
NtInitialUserProcessBuffer,
ProcessParams->ImagePathName.Length);
/* Null-terminate it */
ProcessParams->ImagePathName.Buffer[ProcessParams->ImagePathName.Length /
sizeof(WCHAR)] = UNICODE_NULL;
/* Make a buffer for the command line */
p = (PWSTR)((PCHAR)ProcessParams->ImagePathName.Buffer +
ProcessParams->ImagePathName.MaximumLength);
ProcessParams->CommandLine.Buffer = p;
ProcessParams->CommandLine.MaximumLength = MAX_PATH * sizeof(WCHAR);
/* Add the image name to the command line */
RtlAppendUnicodeToString(&ProcessParams->CommandLine,
NtInitialUserProcessBuffer);
/* Create the environment string */
RtlInitEmptyUnicodeString(&Environment,
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);
/* Append the DLL path to it */
RtlAppendUnicodeToString(&Environment, L"Path=");
RtlAppendUnicodeStringToString(&Environment, &ProcessParams->DllPath);
RtlAppendUnicodeStringToString(&Environment, &NullString);
/* 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);
/* Prepare the prefetcher */
//CcPfBeginBootPhase(150);
/* Create SMSS process */
SmssName = ProcessParams->ImagePathName;
Status = RtlCreateUserProcess(&SmssName,
OBJ_CASE_INSENSITIVE,
RtlDeNormalizeProcessParams(ProcessParams),
NULL,
NULL,
NULL,
FALSE,
NULL,
NULL,
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
ProcessInformation);
if (!NT_SUCCESS(Status))
{
/* Failed, display error */
_snwprintf(InitBuffer->DebugBuffer,
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
L"INIT: Unable to create Session Manager. 0x%lx",
Status);
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
ZwDisplayString(&DebugString);
/* Bugcheck the system */
KeBugCheckEx(SESSION3_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
/* Resume the thread */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL);
if (!NT_SUCCESS(Status))
{
/* Failed, display error */
_snwprintf(InitBuffer->DebugBuffer,
sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR),
L"INIT: Unable to resume Session Manager. 0x%lx",
Status);
RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer);
ZwDisplayString(&DebugString);
/* Bugcheck the system */
KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Return success */
*ProcessParameters = ProcessParams;
*ProcessEnvironment = EnvironmentPtr;
}
INIT_FUNCTION
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;
}
INIT_FUNCTION
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);
/* Set the suite mask to maximum and return */
ExSuiteMask = 0xFFFFFFFF;
return TRUE;
}
INIT_FUNCTION
BOOLEAN
NTAPI
ExpInitSystemPhase1(VOID)
{
/* Initialize worker threads */
ExpInitializeWorkerThreads();
/* Initialize pushlocks */
ExpInitializePushLocks();
/* Initialize events and event pairs */
if (ExpInitializeEventImplementation() == FALSE)
{
DPRINT1("Executive: Event initialization failed\n");
return FALSE;
}
if (ExpInitializeEventPairImplementation() == FALSE)
{
DPRINT1("Executive: Event Pair initialization failed\n");
return FALSE;
}
/* Initialize mutants */
if (ExpInitializeMutantImplementation() == FALSE)
{
DPRINT1("Executive: Mutant initialization failed\n");
return FALSE;
}
/* Initialize callbacks */
if (ExpInitializeCallbacks() == FALSE)
{
DPRINT1("Executive: Callback initialization failed\n");
return FALSE;
}
/* Initialize semaphores */
if (ExpInitializeSemaphoreImplementation() == FALSE)
{
DPRINT1("Executive: Semaphore initialization failed\n");
return FALSE;
}
/* Initialize timers */
if (ExpInitializeTimerImplementation() == FALSE)
{
DPRINT1("Executive: Timer initialization failed\n");
return FALSE;
}
/* Initialize profiling */
if (ExpInitializeProfileImplementation() == FALSE)
{
DPRINT1("Executive: Profile initialization failed\n");
return FALSE;
}
/* Initialize UUIDs */
if (ExpUuidInitialization() == FALSE)
{
DPRINT1("Executive: Uuid initialization failed\n");
return FALSE;
}
/* Initialize keyed events */
if (ExpInitializeKeyedEventImplementation() == FALSE)
{
DPRINT1("Executive: Keyed event initialization failed\n");
return FALSE;
}
/* Initialize Win32K */
if (ExpWin32kInit() == FALSE)
{
DPRINT1("Executive: Win32 initialization failed\n");
return FALSE;
}
return TRUE;
}
INIT_FUNCTION
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;
}
}
INIT_FUNCTION
BOOLEAN
NTAPI
ExpIsLoaderValid(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
PLOADER_PARAMETER_EXTENSION Extension;
/* Get the loader extension */
Extension = LoaderBlock->Extension;
/* Validate the size (Windows 2003 loader doesn't provide more) */
if (Extension->Size < LOADER_PARAMETER_EXTENSION_MIN_SIZE) return FALSE;
/* Don't validate upper versions */
if (Extension->MajorVersion > VER_PRODUCTMAJORVERSION) return TRUE;
/* Fail if this is NT 4 */
if (Extension->MajorVersion < VER_PRODUCTMAJORVERSION) return FALSE;
/* Fail if this is XP */
if (Extension->MinorVersion < VER_PRODUCTMINORVERSION) return FALSE;
/* This is 2003 or newer, approve it */
return TRUE;
}
INIT_FUNCTION
VOID
NTAPI
ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
ULONG i = 0;
PLIST_ENTRY NextEntry;
ULONG Count, Length;
PWCHAR Name;
PLDR_DATA_TABLE_ENTRY LdrEntry;
CHAR NameBuffer[256];
- DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Protocol 6 uses the DBGKD_ANY_WAIT_STATE_CHANGE structure which is sized according to the largest control-report structure (AMD64_DBGKD_CONTROL_REPORT currently), and is larger than DBGKD_WAIT_STATE_CHANGE64 on x86. This worked because our DBGKD_WAIT_STATE_CHANGE32/64 structures contained incorrect DBGKD_CONTROL_REPORT (used) and CONTEXT (unused) members that sized up the wait-state structure to pass WinDbg's length verification! It actually becomes larger than DBGKD_ANY_WAIT_STATE_CHANGE, but WinDbg only seems bail out only if the structure is too small. Remove the incorrect members from the protocol 5 structures and change to DBGKD_ANY_WAIT_STATE_CHANGE everywhere. - Correct the value of SIZE_OF_FX_REGISTERS -- it was 4 times too low which resulted in KeContextToTrapFrame not properly clearing out the XMM register area. Correct the define and move it out from ke.h to x86's ketypes.h and use it in the FXSAVE format structure. Also remove the IOPM definitions from ke.h as they have been in the NDK for a while. - KD uses STRINGs, not ANSI_STRINGs -- they are the same thing, but let's be consistent. - ExceptionRecord32To64 should be available for both 32 and 64 bit builds (and it shouldn't be a forceinline). Get rid of CopyExceptionRecord and determine if we need to convert or can just copy it directly instead. - Use _WIN64 instead of _M_AMD64 when determining if we need to set the DBGKD_VERS_FLAG_PTR64 flag. - Don't check Nt/DbgQueryDebugFilterState for zero or nonzero -- it actually returns TRUE, FALSE or STATUS_INVALID_PARAMETER_1! Check for != TRUE in preparation for proper implementation of NtSet/QueryDebugFilterState. - Fix Format parameter of DbgPrintReturnControlC -- it is const like the other DbgPrint* routines. - Be consistent with the types used in debug.c and don't set local variables to zero if we are going to return to caller -- this doesn't seem to be required anymore. - Fix DebugService and DebugService2: DebugService should take a ULONG followed by 4 pointers and DebugService2 doesn't return anything. - Use ZwCurrentProcess() instead of -1 or 0xFFFFFFFF (which is incorrect for 64-bit) for the ProcessId parameter of DbgLoad/UnloadImageSymbols to clarify what is being passed. Don't use ZwCurrentProcess() in KeBugCheckWithTf for the pointer parameter of DbgUnLoadImageSymbols either. Use MAXULONG_PTR casted to PVOID instead. - Use better named and sized variables in KdpTrap for setting the "return register" in the caller's CONTEXT. - Correct and clarify the comment documenting under what conditions we pass user mode exceptions to the kernel debugger. svn path=/trunk/; revision=43741
2009-10-25 15:56:38 +00:00
STRING SymbolString;
NTSTATUS Status;
/* Loop the driver list */
NextEntry = LoaderBlock->LoadOrderListHead.Flink;
while (NextEntry != &LoaderBlock->LoadOrderListHead)
{
/* Skip the first two images */
if (i >= 2)
{
/* Get the entry */
LdrEntry = CONTAINING_RECORD(NextEntry,
LDR_DATA_TABLE_ENTRY,
InLoadOrderLinks);
if (LdrEntry->FullDllName.Buffer[0] == L'\\')
{
/* We have a name, read its data */
Name = LdrEntry->FullDllName.Buffer;
Length = LdrEntry->FullDllName.Length / sizeof(WCHAR);
/* Check if our buffer can hold it */
if (sizeof(NameBuffer) < Length + sizeof(ANSI_NULL))
{
/* It's too long */
Status = STATUS_BUFFER_OVERFLOW;
}
else
{
/* Copy the name */
Count = 0;
do
{
/* Copy the character */
NameBuffer[Count++] = (CHAR)*Name++;
} while (Count < Length);
/* Null-terminate */
NameBuffer[Count] = ANSI_NULL;
Status = STATUS_SUCCESS;
}
}
else
{
/* Safely print the string into our buffer */
Status = RtlStringCbPrintfA(NameBuffer,
sizeof(NameBuffer),
"%S\\System32\\Drivers\\%wZ",
&SharedUserData->NtSystemRoot[2],
&LdrEntry->BaseDllName);
}
/* Check if the buffer was ok */
if (NT_SUCCESS(Status))
{
- DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Protocol 6 uses the DBGKD_ANY_WAIT_STATE_CHANGE structure which is sized according to the largest control-report structure (AMD64_DBGKD_CONTROL_REPORT currently), and is larger than DBGKD_WAIT_STATE_CHANGE64 on x86. This worked because our DBGKD_WAIT_STATE_CHANGE32/64 structures contained incorrect DBGKD_CONTROL_REPORT (used) and CONTEXT (unused) members that sized up the wait-state structure to pass WinDbg's length verification! It actually becomes larger than DBGKD_ANY_WAIT_STATE_CHANGE, but WinDbg only seems bail out only if the structure is too small. Remove the incorrect members from the protocol 5 structures and change to DBGKD_ANY_WAIT_STATE_CHANGE everywhere. - Correct the value of SIZE_OF_FX_REGISTERS -- it was 4 times too low which resulted in KeContextToTrapFrame not properly clearing out the XMM register area. Correct the define and move it out from ke.h to x86's ketypes.h and use it in the FXSAVE format structure. Also remove the IOPM definitions from ke.h as they have been in the NDK for a while. - KD uses STRINGs, not ANSI_STRINGs -- they are the same thing, but let's be consistent. - ExceptionRecord32To64 should be available for both 32 and 64 bit builds (and it shouldn't be a forceinline). Get rid of CopyExceptionRecord and determine if we need to convert or can just copy it directly instead. - Use _WIN64 instead of _M_AMD64 when determining if we need to set the DBGKD_VERS_FLAG_PTR64 flag. - Don't check Nt/DbgQueryDebugFilterState for zero or nonzero -- it actually returns TRUE, FALSE or STATUS_INVALID_PARAMETER_1! Check for != TRUE in preparation for proper implementation of NtSet/QueryDebugFilterState. - Fix Format parameter of DbgPrintReturnControlC -- it is const like the other DbgPrint* routines. - Be consistent with the types used in debug.c and don't set local variables to zero if we are going to return to caller -- this doesn't seem to be required anymore. - Fix DebugService and DebugService2: DebugService should take a ULONG followed by 4 pointers and DebugService2 doesn't return anything. - Use ZwCurrentProcess() instead of -1 or 0xFFFFFFFF (which is incorrect for 64-bit) for the ProcessId parameter of DbgLoad/UnloadImageSymbols to clarify what is being passed. Don't use ZwCurrentProcess() in KeBugCheckWithTf for the pointer parameter of DbgUnLoadImageSymbols either. Use MAXULONG_PTR casted to PVOID instead. - Use better named and sized variables in KdpTrap for setting the "return register" in the caller's CONTEXT. - Correct and clarify the comment documenting under what conditions we pass user mode exceptions to the kernel debugger. svn path=/trunk/; revision=43741
2009-10-25 15:56:38 +00:00
/* Initialize the STRING for the debugger */
RtlInitString(&SymbolString, NameBuffer);
/* Load the symbols */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
DbgLoadImageSymbols(&SymbolString,
LdrEntry->DllBase,
(ULONG_PTR)PsGetCurrentProcessId());
}
}
/* Go to the next entry */
i++;
NextEntry = NextEntry->Flink;
}
}
INIT_FUNCTION
VOID
NTAPI
ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN ULONG_PTR PagesToDestroy,
IN TYPE_OF_MEMORY MemoryType)
{
PLIST_ENTRY ListEntry;
PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor;
DPRINT1("Burn RAM amount: %lu pages\n", PagesToDestroy);
/* 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;
}
}
}
}
INIT_FUNCTION
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
VOID
NTAPI
ExpInitializeExecutive(IN ULONG Cpu,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
{
PNLS_DATA_BLOCK NlsData;
CHAR Buffer[256];
ANSI_STRING AnsiPath;
NTSTATUS Status;
PCHAR CommandLine, PerfMem;
ULONG PerfMemUsed;
PLDR_DATA_TABLE_ENTRY NtosEntry;
PMESSAGE_RESOURCE_ENTRY MsgEntry;
ANSI_STRING CSDString;
size_t Remaining = 0;
PCHAR RcEnd = NULL;
CHAR VersionBuffer[65];
/* 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 */
KeBugCheck(HAL_INITIALIZATION_FAILED);
}
/* We're done */
return;
}
/* 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 */
if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
ExpInTextModeSetup = TRUE;
/* Check if this is network boot */
if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
{
/* 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;
/* 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);
if (PerfMem)
{
/* 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);
if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad);
}
}
}
/* Setup NLS Base and offsets */
NlsData = LoaderBlock->NlsData;
ExpNlsTableBase = NlsData->AnsiCodePageData;
ExpAnsiCodePageDataOffset = 0;
ExpOemCodePageDataOffset = (ULONG)((ULONG_PTR)NlsData->OemCodePageData -
(ULONG_PTR)NlsData->AnsiCodePageData);
ExpUnicodeCaseTableDataOffset = (ULONG)((ULONG_PTR)NlsData->UnicodeCodePageData -
(ULONG_PTR)NlsData->AnsiCodePageData);
/* 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);
}
/* Make sure interrupts are active now */
_enable();
/* 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 */
RtlInitString(&AnsiPath, Buffer);
Buffer[--AnsiPath.Length] = ANSI_NULL;
/* Get the string from KUSER_SHARED_DATA's buffer */
RtlInitEmptyUnicodeString(&NtSystemRoot,
SharedUserData->NtSystemRoot,
sizeof(SharedUserData->NtSystemRoot));
/* Now fill it in */
Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &AnsiPath, FALSE);
if (!NT_SUCCESS(Status)) KeBugCheck(SESSION3_INITIALIZATION_FAILED);
/* Setup bugcheck messages */
KiInitializeBugCheck();
/* Setup initial system settings */
CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
/* Set the Service Pack Number and add it to the CSD Version number if needed */
CmNtSpBuildNumber = VER_PRODUCTBUILD_QFE;
if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
{
CmNtCSDVersion |= (VER_PRODUCTBUILD_QFE << 16);
}
/* Add loaded CmNtGlobalFlag value */
NtGlobalFlag |= CmNtGlobalFlag;
/* Initialize the executive at phase 0 */
if (!ExInitSystem()) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
/* Initialize the memory manager at phase 0 */
if (!MmArmInitSystem(0, LoaderBlock)) KeBugCheck(PHASE0_INITIALIZATION_FAILED);
/* Load boot symbols */
ExpLoadBootSymbols(LoaderBlock);
/* Check if we should break after symbol load */
if (KdBreakAfterSymbolLoad) DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
/* Check if this loader is compatible with NT 5.2 */
if (LoaderBlock->Extension->Size >= sizeof(LOADER_PARAMETER_EXTENSION))
{
/* Setup headless terminal settings */
HeadlessInit(LoaderBlock);
}
/* Set system ranges */
#ifdef _M_AMD64
SharedUserData->Reserved1 = MM_HIGHEST_USER_ADDRESS_WOW64;
SharedUserData->Reserved3 = MM_SYSTEM_RANGE_START_WOW64;
#else
SharedUserData->Reserved1 = (ULONG_PTR)MmHighestUserAddress;
SharedUserData->Reserved3 = (ULONG_PTR)MmSystemRangeStart;
#endif
/* Make a copy of the NLS Tables */
ExpInitNls(LoaderBlock);
/* 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 */
RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
/* Remove trailing newline */
while ((CSDString.Length > 0) &&
((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
(CSDString.Buffer[CSDString.Length - 1] == '\n')))
{
/* Skip the trailing character */
CSDString.Length--;
}
/* Fill the buffer with version information */
Status = RtlStringCbPrintfA(Buffer,
sizeof(Buffer),
"%Z %u%c",
&CSDString,
(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 */
CmCSDVersionString.MaximumLength = sizeof(Buffer) - (USHORT)Remaining;
}
/* Check if we have an RC number */
if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
{
/* 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,
"v.%u",
(CmNtCSDVersion & 0xFFFF0000) >> 16);
if (!NT_SUCCESS(Status))
{
/* Fail */
KeBugCheckEx(PHASE0_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
}
/* Now setup the final string */
RtlInitAnsiString(&CSDString, Buffer);
Status = RtlAnsiStringToUnicodeString(&CmCSDVersionString,
&CSDString,
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);
/* 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");
}
/* Initialize the Handle Table */
ExpInitializeHandleTables();
#if DBG
/* On checked builds, allocate the system call count table */
KeServiceDescriptorTable[0].Count =
ExAllocatePoolWithTag(NonPagedPool,
KiServiceLimit * sizeof(ULONG),
'llaC');
/* 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
/* Create the Basic Object Manager Types to allow new Object Types */
if (!ObInitSystem()) KeBugCheck(OBJECT_INITIALIZATION_FAILED);
/* Load basic Security for other Managers */
if (!SeInitSystem()) KeBugCheck(SECURITY_INITIALIZATION_FAILED);
/* Initialize the Process Manager */
if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS_INITIALIZATION_FAILED);
/* Initialize the PnP Manager */
if (!PpInitSystem()) KeBugCheck(PP0_INITIALIZATION_FAILED);
/* Initialize the User-Mode Debugging Subsystem */
DbgkInitialize();
/* 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 */
SharedUserData->ImageNumberLow = IMAGE_FILE_MACHINE_NATIVE;
SharedUserData->ImageNumberHigh = IMAGE_FILE_MACHINE_NATIVE;
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
}
VOID
NTAPI
MmFreeLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
INIT_FUNCTION
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
VOID
NTAPI
Phase1InitializationDiscard(IN PVOID Context)
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
{
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
PLOADER_PARAMETER_BLOCK LoaderBlock = Context;
NTSTATUS Status, MsgStatus;
TIME_FIELDS TimeFields;
LARGE_INTEGER SystemBootTime, UniversalBootTime, OldTime, Timeout;
BOOLEAN SosEnabled, NoGuiBoot, ResetBias = FALSE, AlternateShell = FALSE;
PLDR_DATA_TABLE_ENTRY NtosEntry;
PMESSAGE_RESOURCE_ENTRY MsgEntry;
PCHAR CommandLine, Y2KHackRequired, SafeBoot, Environment;
PCHAR StringBuffer, EndBuffer, BeginBuffer, MpString = "";
PINIT_BUFFER InitBuffer;
ANSI_STRING TempString;
ULONG LastTzBias, Length, YearHack = 0, Disposition, MessageCode = 0;
SIZE_T Size;
size_t Remaining;
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
PRTL_USER_PROCESS_INFORMATION ProcessInfo;
KEY_VALUE_PARTIAL_INFORMATION KeyPartialInfo;
UNICODE_STRING KeyName;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE KeyHandle, OptionHandle;
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
/* Allocate the initialization buffer */
InitBuffer = ExAllocatePoolWithTag(NonPagedPool,
sizeof(INIT_BUFFER),
TAG_INIT);
if (!InitBuffer)
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
{
/* Bugcheck */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 8, 0, 0);
}
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
/* Set to phase 1 */
ExpInitializationPhase = 1;
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
/* Set us at maximum priority */
KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY);
/* Do Phase 1 HAL Initialization */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
if (!HalInitSystem(1, LoaderBlock)) KeBugCheck(HAL1_INITIALIZATION_FAILED);
/* Get the command line and upcase it */
CommandLine = (LoaderBlock->LoadOptions ? _strupr(LoaderBlock->LoadOptions) : NULL);
/* Check if GUI Boot is enabled */
NoGuiBoot = (CommandLine && strstr(CommandLine, "NOGUIBOOT") != NULL);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Get the SOS setting */
SosEnabled = (CommandLine && strstr(CommandLine, "SOS") != NULL);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Setup the boot driver */
InbvEnableBootDriver(!NoGuiBoot);
InbvDriverInitialize(LoaderBlock, IDB_MAX_RESOURCE);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
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);
DisplayBootBitmap(SosEnabled);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
}
else
{
/* Release display ownership if not using GUI boot */
InbvNotifyDisplayOwnershipLost(NULL);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Don't allow boot-time strings */
InbvEnableDisplayString(FALSE);
}
/* Check if this is LiveCD (WinPE) mode */
if (CommandLine && strstr(CommandLine, "MININT") != NULL)
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
{
/* Setup WinPE Settings */
InitIsWinPEMode = TRUE;
InitWinPEModeType |= (strstr(CommandLine, "INRAM") != NULL) ? 0x80000000 : 0x00000001;
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +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;
Remaining = sizeof(InitBuffer->VersionBuffer);
if (CmCSDVersionString.Length)
{
/* Print the version string */
Status = RtlStringCbPrintfExA(StringBuffer,
Remaining,
&EndBuffer,
&Remaining,
0,
": %wZ",
&CmCSDVersionString);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
}
}
else
{
/* No version */
*EndBuffer = ANSI_NULL; /* Null-terminate the string */
}
/* Skip over the null-terminator to start a new string */
++EndBuffer;
--Remaining;
/* Build the version number */
StringBuffer = InitBuffer->VersionNumber;
Status = RtlStringCbPrintfA(StringBuffer,
sizeof(InitBuffer->VersionNumber),
"%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 */
/* ReactOS specific: Report ReactOS version, NtBuildLab information and reported NT kernel version */
Status = RtlStringCbPrintfA(EndBuffer,
Remaining,
(PCHAR)MsgEntry->Text,
KERNEL_VERSION_STR,
NtBuildLab,
StringBuffer,
NtBuildNumber & 0xFFFF,
BeginBuffer);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
}
}
else
{
/* Use hard-coded banner message */
Status = RtlStringCbCopyA(EndBuffer, Remaining, "REACTOS (R)\r\n");
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 7, 0, 0);
}
}
/* Display the version string on-screen */
InbvDisplayString(EndBuffer);
/* Initialize Power Subsystem in Phase 0 */
- Disable the MiCacheImageSymbols call in MmLoadSystemImage for KD too as this hack is required for rossym rather than KDBG. Fixes detection of non-boot driver images by WinDbg. - Add another hack to freeldr.c to make sure that HAL is the second entry in the Load Order list -- detect if it isn't and insert it as the second entry manually if it isn't. - KdbInitialize can now assume that the 2nd entry in the Load Order list is HAL, just like ExpLoadBootSymbols and KD does, so get the Loader Entry directly instead of searching for it. - Move KiBootTss and KiBootGdt to freeldr.c as this is where they belong -- they are not required for NTLDR/WINLDR boot style and are only used directly in freeldr.c. - Get rid of the AcpiTableDetected variable from freeldr.c. Instead, set the AcpiTable entry to something and make PoInitSystem check for that instead to preserve the old behavior. - Implement KdpGetFirstParameter and KdpGetSecondParameter for ARM too -- just retrieve R3/R4 here. Also rename those macros to clarify what parameters we are retrieving. - Add MmIsSessionAddress stub and use it from KD handle session space properly in the Memory Query API, and ASSERT that we are not trying to do a copy to/from session space in MmDbgCopyMemory as we don't handle it properly. Put this in mmdbg.c for now as we don't implement session space, and it is only called from KD right now. - Rename the 3 kdsup.c files to kdx86.c, kdx64.c and kdarm.c to differ them from each other. - Implement KdpAllowDisable -- just check if any processor breakpoints are set on any processor in the system and disallow the disable if so. The routine is now architecture dependant, so move it to the appropriate files. - Get rid of the MmFreeLdr* variables too. These have been deprecated for some time now. - The ModuleObject and ImageBaseAddress parameters of MmLoadSystemImage are not optional so don't treat them as such, and don't zero initialize them as callers shouldn't rely on this. - Set LDRP_ENTRY_NATIVE instead of LDRP_COMPAT_DATABASE_PROCESSED to mark the image as a native image. Also fix the value of LDRP_ENTRY_NATIVE. - Fix definition of LDR_DATA_TABLE_ENTRY -- the Checksum member should be in the union too. - Remove some unnecessary externs for stuff we now define globally in the kernel headers. - Rename some variables in KD to better match the logic. - Move some x86 only stuff from global ke.h and ke_x.h to the x86 dependent ke.h. Remove DR_ACTIVE_MASK as it has been deprecated/unused for a while now. svn path=/trunk/; revision=44023
2009-11-08 01:13:49 +00:00
if (!PoInitSystem(0)) KeBugCheck(INTERNAL_POWER_ERROR);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Check for Y2K hack */
Y2KHackRequired = CommandLine ? strstr(CommandLine, "YEAR") : NULL;
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
if (Y2KHackRequired) Y2KHackRequired = strstr(Y2KHackRequired, "=");
if (Y2KHackRequired) YearHack = atol(Y2KHackRequired + 1);
/* Query the clock */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
if ((ExCmosClockIsSane) && (HalQueryRealTimeClock(&TimeFields)))
{
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Check if we're using the Y2K hack */
if (Y2KHackRequired) TimeFields.Year = (CSHORT)YearHack;
/* Convert to time fields */
RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
UniversalBootTime = SystemBootTime;
/* Check if real time is GMT */
if (!ExpRealTimeIsUniversal)
{
/* Check if we don't have a valid bias */
if (ExpLastTimeZoneBias == MAXULONG)
{
/* Reset */
ResetBias = TRUE;
ExpLastTimeZoneBias = ExpAltTimeZoneBias;
}
/* Calculate the bias in seconds */
ExpTimeZoneBias.QuadPart = Int32x32To64(ExpLastTimeZoneBias * 60,
10000000);
/* 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;
}
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Update the system time */
KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
/* Do system callback */
PoNotifySystemTimeSet();
/* Remember this as the boot time */
KeBootTime = UniversalBootTime;
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
KeBootTimeBias = 0;
}
/* Initialize all processors */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
if (!HalAllProcessorsStarted()) KeBugCheck(HAL1_INITIALIZATION_FAILED);
#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 */
while ((TempString.Length > 0) &&
((TempString.Buffer[TempString.Length - 1] == '\r') ||
(TempString.Buffer[TempString.Length - 1] == '\n')))
{
/* Skip the trailing character */
TempString.Length--;
}
/* 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);
/* 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);
/* Create the string */
StringBuffer = InitBuffer->VersionBuffer;
Status = RtlStringCbPrintfA(StringBuffer,
sizeof(InitBuffer->VersionBuffer),
NT_SUCCESS(MsgStatus) ?
(PCHAR)MsgEntry->Text :
2018-01-29 19:31:07 +00:00
"%u System Processor [%Iu MB Memory] %Z\r\n",
KeNumberProcessors,
Size,
&TempString);
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 4, 0, 0);
}
/* Display RAM and CPU count */
InbvDisplayString(StringBuffer);
/* Update the progress bar */
InbvUpdateProgressBar(5);
/* Call OB initialization again */
if (!ObInitSystem()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED);
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
/* Initialize Basic System Objects and Worker Threads */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
if (!ExInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 1, 0);
/* Initialize the later stages of the kernel */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
if (!KeInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 2, 0);
/* Call KD Providers at Phase 1 */
if (!KdInitSystem(ExpInitializationPhase, KeLoaderBlock))
{
/* Failed, bugcheck */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 3, 0);
}
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Initialize the SRM in Phase 1 */
if (!SeInitSystem()) KeBugCheck(SECURITY1_INITIALIZATION_FAILED);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Update the progress bar */
InbvUpdateProgressBar(10);
/* Create SystemRoot Link */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
Status = ExpCreateSystemRootLink(LoaderBlock);
if (!NT_SUCCESS(Status))
{
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Failed to create the system root link */
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Set up Region Maps, Sections and the Paging File */
if (!MmInitSystem(1, LoaderBlock)) KeBugCheck(MEMORY1_INITIALIZATION_FAILED);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
/* Create NLS section */
ExpInitNls(LoaderBlock);
/* Initialize Cache Views */
if (!CcInitializeCacheManager()) KeBugCheck(CACHE_INITIALIZATION_FAILED);
/* Initialize the Registry */
if (!CmInitSystem1()) KeBugCheck(CONFIG_INITIALIZATION_FAILED);
/* Initialize Prefetcher */
CcPfInitializePrefetcher();
/* Update progress bar */
InbvUpdateProgressBar(15);
/* Update timezone information */
LastTzBias = ExpLastTimeZoneBias;
ExRefreshTimeZoneInformation(&SystemBootTime);
/* 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 */
if (LastTzBias != ExpLastTimeZoneBias) ZwSetSystemTime(NULL, NULL);
}
/* Initialize the File System Runtime Library */
if (!FsRtlInitSystem()) KeBugCheck(FILE_INITIALIZATION_FAILED);
/* Initialize range lists */
RtlInitializeRangeListPackage();
/* Report all resources used by HAL */
HalReportResourceUsage();
/* Call the debugger DLL */
KdDebuggerInitialize1(LoaderBlock);
/* Setup PnP Manager in phase 1 */
if (!PpInitSystem()) KeBugCheck(PP1_INITIALIZATION_FAILED);
/* Update progress bar */
InbvUpdateProgressBar(20);
/* Initialize LPC */
if (!LpcInitSystem()) KeBugCheck(LPC_INITIALIZATION_FAILED);
/* 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 */
InitSafeBootMode = 2;
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 */
InbvDisplayString((PCHAR)MsgEntry->Text);
}
}
}
/* 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 */
InbvDisplayString((PCHAR)MsgEntry->Text);
}
/* 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);
/* Initialize the I/O Subsystem */
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);
if (!(NT_SUCCESS(Status) || Status == STATUS_BUFFER_OVERFLOW))
{
AlternateShell = FALSE;
}
}
/* 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");
NtSetValueKey(OptionHandle,
&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");
NtSetValueKey(OptionHandle,
&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);
}
/* FIXME: This doesn't do anything for now */
MmArmInitSystem(2, LoaderBlock);
/* Update progress bar */
InbvUpdateProgressBar(80);
/* Initialize VDM support */
#if defined(_M_IX86)
KeI386VdmInitialize();
#endif
/* Initialize Power Subsystem in Phase 1*/
- Disable the MiCacheImageSymbols call in MmLoadSystemImage for KD too as this hack is required for rossym rather than KDBG. Fixes detection of non-boot driver images by WinDbg. - Add another hack to freeldr.c to make sure that HAL is the second entry in the Load Order list -- detect if it isn't and insert it as the second entry manually if it isn't. - KdbInitialize can now assume that the 2nd entry in the Load Order list is HAL, just like ExpLoadBootSymbols and KD does, so get the Loader Entry directly instead of searching for it. - Move KiBootTss and KiBootGdt to freeldr.c as this is where they belong -- they are not required for NTLDR/WINLDR boot style and are only used directly in freeldr.c. - Get rid of the AcpiTableDetected variable from freeldr.c. Instead, set the AcpiTable entry to something and make PoInitSystem check for that instead to preserve the old behavior. - Implement KdpGetFirstParameter and KdpGetSecondParameter for ARM too -- just retrieve R3/R4 here. Also rename those macros to clarify what parameters we are retrieving. - Add MmIsSessionAddress stub and use it from KD handle session space properly in the Memory Query API, and ASSERT that we are not trying to do a copy to/from session space in MmDbgCopyMemory as we don't handle it properly. Put this in mmdbg.c for now as we don't implement session space, and it is only called from KD right now. - Rename the 3 kdsup.c files to kdx86.c, kdx64.c and kdarm.c to differ them from each other. - Implement KdpAllowDisable -- just check if any processor breakpoints are set on any processor in the system and disallow the disable if so. The routine is now architecture dependant, so move it to the appropriate files. - Get rid of the MmFreeLdr* variables too. These have been deprecated for some time now. - The ModuleObject and ImageBaseAddress parameters of MmLoadSystemImage are not optional so don't treat them as such, and don't zero initialize them as callers shouldn't rely on this. - Set LDRP_ENTRY_NATIVE instead of LDRP_COMPAT_DATABASE_PROCESSED to mark the image as a native image. Also fix the value of LDRP_ENTRY_NATIVE. - Fix definition of LDR_DATA_TABLE_ENTRY -- the Checksum member should be in the union too. - Remove some unnecessary externs for stuff we now define globally in the kernel headers. - Rename some variables in KD to better match the logic. - Move some x86 only stuff from global ke.h and ke_x.h to the x86 dependent ke.h. Remove DR_ACTIVE_MASK as it has been deprecated/unused for a while now. svn path=/trunk/; revision=44023
2009-11-08 01:13:49 +00:00
if (!PoInitSystem(1)) KeBugCheck(INTERNAL_POWER_ERROR);
/* Update progress bar */
InbvUpdateProgressBar(90);
/* Initialize the Process Manager at Phase 1 */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
/* Make sure nobody touches the loader block again */
if (LoaderBlock == KeLoaderBlock) KeLoaderBlock = NULL;
MmFreeLoaderBlock(LoaderBlock);
LoaderBlock = Context = NULL;
/* Initialize the SRM in phase 1 */
if (!SeRmInitPhase1()) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
/* Update progress bar */
InbvUpdateProgressBar(100);
/* Clear the screen */
if (InbvBootDriverInstalled) FinalizeBootLogo();
/* Allow strings to be displayed */
InbvEnableDisplayString(TRUE);
/* Launch initial process */
DPRINT("Free non-cache pages: %lx\n", MmAvailablePages + MiMemoryConsumers[MC_CACHE].PagesUsed);
ProcessInfo = &InitBuffer->ProcessInfo;
ExpLoadInitialProcess(InitBuffer, &ProcessParameters, &Environment);
/* Wait 5 seconds for initial process to initialize */
Timeout.QuadPart = Int32x32To64(5, -10000000);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout);
if (Status == STATUS_SUCCESS)
{
/* Failed, display error */
DPRINT1("INIT: Session Manager terminated.\n");
/* Bugcheck the system if SMSS couldn't initialize */
KeBugCheck(SESSION5_INITIALIZATION_FAILED);
}
/* Close process handles */
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
2007-01-25 01:13:09 +00:00
ZwClose(ProcessInfo->ThreadHandle);
ZwClose(ProcessInfo->ProcessHandle);
/* 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);
- Fix one of the oldest hacks in ReactOS: KeGetCurrentThread() and PsGetcurrentProcess used to be NULL during early boot stage. We also didn't have an official idle therad/process. Also system intialization was not in its sepearte thread. Changes: - Implemented SeAssignPrimaryToken. - Setup Boot/System Token for Idle Process in SeInit2. - Remove ROS hack in SeCaptureSubjectContextEx. - Call SeAssignPrimaryToken in PspInitializeProcessSecurty when called for the Initial Process creation. - Implement PsInitiailizeQuotaSystem and set PspDefauptQuotaBlock for the idle process so that it can be used for the initial process. - Rewrite Process Manager Phase 0 initialization from scratch, to create a new initial system process and thread which will be used for Phase 1 (in ROS, phase 2) initialization of the executive. - Fix a bug in PspCreateProcess which was using an uninitialized value of SectionObject in some cases, instead of NULL. - Call PsInitailizeQuotaSystem from ObInit, and also create the system handle table inside the idle process, and make it the ObpKernelHandleTable. - Do Executive Phase 0 Initialization at APC_LEVEL. - Start idle thread at HIGH_PRIORITY then lower it to 0 once the Initial Thread is setup, so that it can run, then keep priority to 0 at DISPATCH_LEVEL and jump into idle loop code. - Add NtYieldExecution to idle loop code since it's now being used. - Fix IoGetCurrentProcess which was previously hacked. - Remove some checks for Thread == NULL in ke_x.h, since this is now impossible. - Split Phase 0/1 initialization in ex\init.c, since one runs in a separate thread now. Also don't lower IRQL to PASSIVE_LEVEL anymore (run at APC_LEVEL). svn path=/trunk/; revision=24148
2006-09-16 20:37:49 +00:00
/* Increase init phase */
ExpInitializationPhase++;
/* Free the boot buffer */
ExFreePoolWithTag(InitBuffer, TAG_INIT);
DPRINT("Free non-cache pages: %lx\n", MmAvailablePages + MiMemoryConsumers[MC_CACHE].PagesUsed);
- Rename KiSetSystemTime to KeSetSystemTime and enhance prototype for later use. - Create Phase 1 initialization for the SRM (SeInitSystem). Right now it inserts the system boot token into object manager, which is something we forgot to do before. - Renamed ExPhase2Init to Phase1Initialization, since it's not Phase 2. - Updated Phase 1 PS Initialization to get the KeLoaderBlock pointer and use it as a context parameter when calling Phase1Initialization. - Split off Phase1Initialization into Phase1InitializationDiscard, which is the bulk of the phase 1 code (99% of it) and can be put in an .INIT section to be freed after boot. - Modify parts of the Inbv setup code. Also implement support for /SOS, and try to mimic its behaviour on NT (not fully achieved). You will need /SOS to see boot messages on the screen! FreeLDR now adds this by default to the "Debug "configuration. - Temporarily disable ReactOS Banner during boot. We will get this data from the .mc/.res file in a later patch instead of hard-coding it. - Optimize calling and usage of ExpLoadInitialProcess. - Add support for Y2K bug fix documented for Windows NT (/YEAR). - Add support to detect WinPE/MiniNT/ReactOS Live CD. - Add temporary debugging code to MmInit2 and some Mm functions to detect if these functions are being used too early, which could result in catastrophic to subtle bugs. - Add more bugchecks when failures occur, and enhance others. Also add more codes to ntoskrnl.mc. - Disable calls to ObfDereferenceDeviceMap since it's not yet implemented. svn path=/trunk/; revision=25624
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);
/* Jump into zero page thread */
MmZeroPageThread();
}