- 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
This commit is contained in:
Alex Ionescu 2007-01-25 01:13:09 +00:00
parent 3f65c90a12
commit bdc7f65b2d
21 changed files with 255 additions and 111 deletions

View file

@ -305,12 +305,12 @@ CreateFreeLoaderIniForDos(PWCHAR IniPath,
L"SystemPath", L"SystemPath",
ArcPath); ArcPath);
/* Options=/DEBUGPORT=SCREEN /NOGUIBOOT */ /* Options=/DEBUGPORT=SCREEN /NOGUIBOOT /SOS*/
IniCacheInsertKey(IniSection, IniCacheInsertKey(IniSection,
NULL, NULL,
INSERT_LAST, INSERT_LAST,
L"Options", L"Options",
L"/DEBUGPORT=SCREEN /NOGUIBOOT"); L"/DEBUGPORT=SCREEN /NOGUIBOOT /SOS");
/* Create "DOS" section */ /* Create "DOS" section */
IniSection = IniCacheAppendSection(IniCache, IniSection = IniCacheAppendSection(IniCache,
@ -416,12 +416,12 @@ CreateFreeLoaderIniForReactos(PWCHAR IniPath,
L"SystemPath", L"SystemPath",
ArcPath); ArcPath);
/* Options=/DEBUGPORT=SCREEN /NOGUIBOOT */ /* Options=/DEBUGPORT=COM1 /NOGUIBOOT /SOS*/
IniCacheInsertKey(IniSection, IniCacheInsertKey(IniSection,
NULL, NULL,
INSERT_LAST, INSERT_LAST,
L"Options", L"Options",
L"/DEBUGPORT=COM1 /NOGUIBOOT"); L"/DEBUGPORT=COM1 /NOGUIBOOT /SOS");
/* Save the ini file */ /* Save the ini file */
IniCacheSave(IniCache, IniPath); IniCacheSave(IniCache, IniPath);

View file

@ -33,8 +33,7 @@ ULONG ExpInitializationPhase;
BOOLEAN ExpInTextModeSetup; BOOLEAN ExpInTextModeSetup;
BOOLEAN IoRemoteBootClient; BOOLEAN IoRemoteBootClient;
ULONG InitSafeBootMode; ULONG InitSafeBootMode;
BOOLEAN InitIsWinPEMode, InitWinPEModeType;
BOOLEAN NoGuiBoot = FALSE;
/* NT Boot Path */ /* NT Boot Path */
UNICODE_STRING NtSystemRoot; UNICODE_STRING NtSystemRoot;
@ -53,6 +52,9 @@ NLSTABLEINFO ExpNlsTableInfo;
ULONG ExpNlsTableSize; ULONG ExpNlsTableSize;
PVOID ExpNlsSectionPointer; PVOID ExpNlsSectionPointer;
/* CMOS Timer Sanity */
BOOLEAN ExCmosClockIsSane = TRUE;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
NTSTATUS NTSTATUS
@ -353,13 +355,11 @@ ExpDisplayNotice(VOID)
NTSTATUS NTSTATUS
NTAPI NTAPI
ExpLoadInitialProcess(IN PHANDLE ProcessHandle, ExpLoadInitialProcess(IN OUT PRTL_USER_PROCESS_INFORMATION ProcessInformation)
IN PHANDLE ThreadHandle)
{ {
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
NTSTATUS Status; NTSTATUS Status;
ULONG Size; ULONG Size;
RTL_USER_PROCESS_INFORMATION ProcessInformation;
PWSTR p; PWSTR p;
UNICODE_STRING NullString = RTL_CONSTANT_STRING(L""); UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
UNICODE_STRING SmssName, Environment, SystemDriveString; UNICODE_STRING SmssName, Environment, SystemDriveString;
@ -509,7 +509,7 @@ ExpLoadInitialProcess(IN PHANDLE ProcessHandle,
FALSE, FALSE,
NULL, NULL,
NULL, NULL,
&ProcessInformation); ProcessInformation);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Failed */ /* Failed */
@ -517,16 +517,14 @@ ExpLoadInitialProcess(IN PHANDLE ProcessHandle,
} }
/* Resume the thread */ /* Resume the thread */
Status = ZwResumeThread(ProcessInformation.ThreadHandle, NULL); Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Failed */ /* Failed */
KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0); KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0);
} }
/* Return Handles */ /* Return success */
*ProcessHandle = ProcessInformation.ProcessHandle;
*ThreadHandle = ProcessInformation.ThreadHandle;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -749,7 +747,9 @@ ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
RtlInitString(&SymbolString, NameBuffer); RtlInitString(&SymbolString, NameBuffer);
/* Load the symbols */ /* Load the symbols */
DbgLoadImageSymbols(&SymbolString, LdrEntry->DllBase, -1); DbgLoadImageSymbols(&SymbolString,
LdrEntry->DllBase,
0xFFFFFFFF);
} }
} }
@ -988,7 +988,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
if (!SeInit()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED); if (!SeInit()) KEBUGCHECK(SECURITY_INITIALIZATION_FAILED);
/* Initialize the Process Manager */ /* Initialize the Process Manager */
if (!PsInitSystem()) KEBUGCHECK(PROCESS_INITIALIZATION_FAILED); if (!PsInitSystem(LoaderBlock)) KEBUGCHECK(PROCESS_INITIALIZATION_FAILED);
/* Initialize the PnP Manager */ /* Initialize the PnP Manager */
if (!PpInitSystem()) KEBUGCHECK(PP0_INITIALIZATION_FAILED); if (!PpInitSystem()) KEBUGCHECK(PP0_INITIALIZATION_FAILED);
@ -1018,14 +1018,27 @@ ExpInitializeExecutive(IN ULONG Cpu,
VOID VOID
NTAPI NTAPI
ExPhase2Init(PVOID Context) Phase1InitializationDiscard(PVOID Context)
{ {
PLOADER_PARAMETER_BLOCK LoaderBlock = Context;
PCHAR CommandLine, Y2KHackRequired;
LARGE_INTEGER Timeout; LARGE_INTEGER Timeout;
HANDLE ProcessHandle;
HANDLE ThreadHandle;
NTSTATUS Status; NTSTATUS Status;
TIME_FIELDS TimeFields; TIME_FIELDS TimeFields;
LARGE_INTEGER SystemBootTime, UniversalBootTime; LARGE_INTEGER SystemBootTime, UniversalBootTime, OldTime;
PRTL_USER_PROCESS_INFORMATION ProcessInfo;
BOOLEAN SosEnabled, NoGuiBoot;
ULONG YearHack = 0;
/* Allocate initial process information */
ProcessInfo = ExAllocatePoolWithTag(NonPagedPool,
sizeof(RTL_USER_PROCESS_INFORMATION),
TAG('I', 'n', 'i', 't'));
if (!ProcessInfo)
{
/* Bugcheck */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 8, 0, 0);
}
/* Set to phase 1 */ /* Set to phase 1 */
ExpInitializationPhase = 1; ExpInitializationPhase = 1;
@ -1034,29 +1047,59 @@ ExPhase2Init(PVOID Context)
KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY); KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY);
/* Do Phase 1 HAL Initialization */ /* Do Phase 1 HAL Initialization */
HalInitSystem(1, KeLoaderBlock); if (!HalInitSystem(1, LoaderBlock)) KeBugCheck(HAL1_INITIALIZATION_FAILED);
/* Get the command line and upcase it */
CommandLine = _strupr(LoaderBlock->LoadOptions);
/* Check if GUI Boot is enabled */ /* Check if GUI Boot is enabled */
if (strstr(KeLoaderBlock->LoadOptions, "NOGUIBOOT")) NoGuiBoot = TRUE; NoGuiBoot = (strstr(CommandLine, "NOGUIBOOT")) ? TRUE: FALSE;
/* Display the boot screen image if not disabled */ /* Get the SOS setting */
SosEnabled = strstr(CommandLine, "SOS") ? TRUE: FALSE;
/* Setup the boot driver */
InbvDisplayInitialize(); InbvDisplayInitialize();
if (!ExpInTextModeSetup) InbvDisplayInitialize2(NoGuiBoot); if (!ExpInTextModeSetup) InbvDisplayInitialize2(NoGuiBoot);
if (!NoGuiBoot) InbvDisplayBootLogo();
/* Clear the screen to blue and display the boot notice and debug status */ /* Check if GUI boot is enabled */
if (NoGuiBoot) ExpDisplayNotice(); if (!NoGuiBoot)
KdInitSystem(2, KeLoaderBlock); {
/* It is, display the boot logo and enable printing strings */
InbvEnableDisplayString(SosEnabled);
InbvDisplayBootLogo(SosEnabled);
}
else
{
/* Release display ownership if not using GUI boot */
if (!SosEnabled) InbvNotifyDisplayOwnershipLost(NULL);
/* Set up Region Maps, Sections and the Paging File */ /* Don't allow boot-time strings */
MmInit2(); InbvEnableDisplayString(FALSE);
}
/* Check if this is LiveCD (WinPE) mode */
if (strstr(CommandLine, "MININT"))
{
/* Setup WinPE Settings */
InitIsWinPEMode = TRUE;
InitWinPEModeType |= (strstr(CommandLine, "INRAM")) ? 0x80000000 : 1;
}
/* Initialize Power Subsystem in Phase 0 */ /* Initialize Power Subsystem in Phase 0 */
PoInit(0, AcpiTableDetected); if (!PoInitSystem(0, AcpiTableDetected)) KeBugCheck(INTERNAL_POWER_ERROR);
/* Check for Y2K hack */
Y2KHackRequired = strstr(CommandLine, "YEAR");
if (Y2KHackRequired) Y2KHackRequired = strstr(Y2KHackRequired, "=");
if (Y2KHackRequired) YearHack = atol(Y2KHackRequired + 1);
/* Query the clock */ /* Query the clock */
if (HalQueryRealTimeClock(&TimeFields)) if ((ExCmosClockIsSane) && (HalQueryRealTimeClock(&TimeFields)))
{ {
/* Check if we're using the Y2K hack */
if (Y2KHackRequired) TimeFields.Year = (CSHORT)YearHack;
/* Convert to time fields */ /* Convert to time fields */
RtlTimeFieldsToTime(&TimeFields, &SystemBootTime); RtlTimeFieldsToTime(&TimeFields, &SystemBootTime);
UniversalBootTime = SystemBootTime; UniversalBootTime = SystemBootTime;
@ -1075,41 +1118,54 @@ ExPhase2Init(PVOID Context)
UniversalBootTime.QuadPart = SystemBootTime.QuadPart + UniversalBootTime.QuadPart = SystemBootTime.QuadPart +
ExpTimeZoneBias.QuadPart; ExpTimeZoneBias.QuadPart;
#endif #endif
KiSetSystemTime(&UniversalBootTime);
/* Update the system time */
KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL);
/* Remember this as the boot time */ /* Remember this as the boot time */
KeBootTime = UniversalBootTime; KeBootTime = UniversalBootTime;
KeBootTimeBias = 0;
} }
/* The clock is ready now (FIXME: HACK FOR OLD HAL) */ /* The clock is ready now (FIXME: HACK FOR OLD HAL) */
KiClockSetupComplete = TRUE; KiClockSetupComplete = TRUE;
/* Initialize all processors */ /* Initialize all processors */
HalAllProcessorsStarted(); if (!HalAllProcessorsStarted()) KeBugCheck(HAL1_INITIALIZATION_FAILED);
/* Call OB initialization again */ /* Call OB initialization again */
if (!ObInit()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED); if (!ObInit()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED);
/* Initialize Basic System Objects and Worker Threads */ /* Initialize Basic System Objects and Worker Threads */
if (!ExInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 1, 0, 0, 0); if (!ExInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 1, 0);
/* Initialize the later stages of the kernel */ /* Initialize the later stages of the kernel */
if (!KeInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 2, 0, 0, 0); if (!KeInitSystem()) KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 2, 0);
/* Call KD Providers at Phase 1 */ /* Call KD Providers at Phase 1 */
if (!KdInitSystem(ExpInitializationPhase, KeLoaderBlock)) if (!KdInitSystem(ExpInitializationPhase, KeLoaderBlock))
{ {
/* Failed, bugcheck */ /* Failed, bugcheck */
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 3, 0, 0, 0); KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, 0, 0, 3, 0);
} }
/* Initialize the SRM in Phase 1 */
if (!SeInit()) KEBUGCHECK(SECURITY1_INITIALIZATION_FAILED);
/* Update the progress bar */
InbvUpdateProgressBar(10);
/* Create SystemRoot Link */ /* Create SystemRoot Link */
Status = ExpCreateSystemRootLink(KeLoaderBlock); Status = ExpCreateSystemRootLink(LoaderBlock);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Failed to create the system root link */
KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 0, 0, 0); KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 0, 0, 0);
} }
/* Set up Region Maps, Sections and the Paging File */
MmInit2();
/* Create NLS section */ /* Create NLS section */
ExpInitNls(KeLoaderBlock); ExpInitNls(KeLoaderBlock);
@ -1148,17 +1204,17 @@ ExPhase2Init(PVOID Context)
KeI386VdmInitialize(); KeI386VdmInitialize();
/* Initialize Power Subsystem in Phase 1*/ /* Initialize Power Subsystem in Phase 1*/
PoInit(1, AcpiTableDetected); PoInitSystem(1, AcpiTableDetected);
/* Initialize the Process Manager at Phase 1 */ /* Initialize the Process Manager at Phase 1 */
if (!PsInitSystem()) KeBugCheck(PROCESS1_INITIALIZATION_FAILED); if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);
/* Launch initial process */ /* Launch initial process */
Status = ExpLoadInitialProcess(&ProcessHandle, &ThreadHandle); Status = ExpLoadInitialProcess(ProcessInfo);
/* Wait 5 seconds for it to initialize */ /* Wait 5 seconds for it to initialize */
Timeout.QuadPart = Int32x32To64(5, -10000000); Timeout.QuadPart = Int32x32To64(5, -10000000);
Status = ZwWaitForSingleObject(ProcessHandle, FALSE, &Timeout); Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout);
if (!NoGuiBoot) InbvFinalizeBootLogo(); if (!NoGuiBoot) InbvFinalizeBootLogo();
if (Status == STATUS_SUCCESS) if (Status == STATUS_SUCCESS)
{ {
@ -1167,15 +1223,26 @@ ExPhase2Init(PVOID Context)
} }
/* Close process handles */ /* Close process handles */
ZwClose(ThreadHandle); ZwClose(ProcessInfo->ThreadHandle);
ZwClose(ProcessHandle); ZwClose(ProcessInfo->ProcessHandle);
/* FIXME: We should free the initial process' memory!*/ /* FIXME: We should free the initial process' memory!*/
/* Increase init phase */ /* Increase init phase */
ExpInitializationPhase += 1; ExpInitializationPhase += 1;
/* Free the process information */
ExFreePool(ProcessInfo);
}
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 */ /* Jump into zero page thread */
MmZeroPageThreadMain(NULL); MmZeroPageThreadMain(NULL);
} }
/* EOF */

View file

@ -123,7 +123,7 @@ ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation)
ExLocalTimeToSystemTime(&LocalTime, &SystemTime); ExLocalTimeToSystemTime(&LocalTime, &SystemTime);
/* Set the new system time */ /* Set the new system time */
KiSetSystemTime(&SystemTime); KeSetSystemTime(&SystemTime, NULL, FALSE, NULL);
/* Return success */ /* Return success */
DPRINT("ExpSetTimeZoneInformation() done\n"); DPRINT("ExpSetTimeZoneInformation() done\n");
@ -193,7 +193,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime,
HalSetRealTimeClock(&TimeFields); HalSetRealTimeClock(&TimeFields);
/* Now set system time */ /* Now set system time */
KiSetSystemTime(&NewSystemTime); KeSetSystemTime(&NewSystemTime, NULL, FALSE, NULL);
/* Check if caller wanted previous time */ /* Check if caller wanted previous time */
if(PreviousTime) if(PreviousTime)

View file

@ -300,14 +300,14 @@ InbvDisplayInitialize2(BOOLEAN NoGuiBoot)
VOID NTAPI VOID NTAPI
InbvDisplayBootLogo(VOID) InbvDisplayBootLogo(IN BOOLEAN SosEnabled)
{ {
InbvEnableBootDriver(TRUE); InbvEnableBootDriver(TRUE);
if (BootVidDriverInstalled) if (BootVidDriverInstalled)
{ {
InbvResetDisplayParameters = BootVidResetDisplayParameters; InbvResetDisplayParameters = BootVidResetDisplayParameters;
BootVidDisplayBootLogo(BootVidBase); if (!SosEnabled) BootVidDisplayBootLogo(BootVidBase);
} }
} }

View file

@ -138,7 +138,7 @@ ExInit2(VOID);
VOID VOID
NTAPI NTAPI
ExPhase2Init( Phase1Initialization(
IN PVOID Context IN PVOID Context
); );

View file

@ -14,7 +14,7 @@ VOID NTAPI
InbvDisplayInitialize2(BOOLEAN NoGuiBoot); InbvDisplayInitialize2(BOOLEAN NoGuiBoot);
VOID NTAPI VOID NTAPI
InbvDisplayBootLogo(VOID); InbvDisplayBootLogo(IN BOOLEAN SosEnabled);
VOID NTAPI VOID NTAPI
InbvUpdateProgressBar(ULONG Progress); InbvUpdateProgressBar(ULONG Progress);

View file

@ -85,6 +85,7 @@ extern PVOID KeUserCallbackDispatcher;
extern PVOID KeUserExceptionDispatcher; extern PVOID KeUserExceptionDispatcher;
extern PVOID KeRaiseUserExceptionDispatcher; extern PVOID KeRaiseUserExceptionDispatcher;
extern LARGE_INTEGER KeBootTime; extern LARGE_INTEGER KeBootTime;
extern ULONG KeBootTimeBias;
extern ULONG KeI386NpxPresent; extern ULONG KeI386NpxPresent;
extern ULONG KeI386XMMIPresent; extern ULONG KeI386XMMIPresent;
extern ULONG KeI386FxsrPresent; extern ULONG KeI386FxsrPresent;
@ -781,7 +782,12 @@ KeRosDumpStackFrames(
VOID VOID
NTAPI NTAPI
KiSetSystemTime(PLARGE_INTEGER NewSystemTime); KeSetSystemTime(
IN PLARGE_INTEGER NewSystemTime,
OUT PLARGE_INTEGER OldSystemTime,
IN BOOLEAN FixInterruptTime,
IN PLARGE_INTEGER HalTime
);
ULONG ULONG
NTAPI NTAPI

View file

@ -35,9 +35,9 @@
// //
// Initialization routines // Initialization routines
// //
VOID BOOLEAN
NTAPI NTAPI
PoInit( PoInitSystem(
IN ULONG BootPhase, IN ULONG BootPhase,
IN BOOLEAN HaveAcpiTable IN BOOLEAN HaveAcpiTable
); );

View file

@ -82,7 +82,7 @@ PspShutdownProcessManager(
BOOLEAN BOOLEAN
NTAPI NTAPI
PsInitSystem( PsInitSystem(
VOID IN PLOADER_PARAMETER_BLOCK LoaderBlock
); );
// //

View file

@ -30,7 +30,6 @@ UNICODE_STRING IopHardwareDatabaseKey =
POBJECT_TYPE IoDriverObjectType = NULL; POBJECT_TYPE IoDriverObjectType = NULL;
extern BOOLEAN ExpInTextModeSetup; extern BOOLEAN ExpInTextModeSetup;
extern BOOLEAN NoGuiBoot;
/* DECLARATIONS ***************************************************************/ /* DECLARATIONS ***************************************************************/
@ -281,7 +280,7 @@ IopDisplayLoadingMessage(PVOID ServiceName,
BOOLEAN Unicode) BOOLEAN Unicode)
{ {
CHAR TextBuffer[256]; CHAR TextBuffer[256];
if (ExpInTextModeSetup || !NoGuiBoot) return; if (ExpInTextModeSetup) return;
if (Unicode) if (Unicode)
{ {
sprintf(TextBuffer, "Loading %S...\n", (PWCHAR)ServiceName); sprintf(TextBuffer, "Loading %S...\n", (PWCHAR)ServiceName);

View file

@ -3363,11 +3363,12 @@ PpInitializeDeviceReferenceTable(VOID)
{ {
/* Setup the guarded mutex and AVL table */ /* Setup the guarded mutex and AVL table */
KeInitializeGuardedMutex(&PpDeviceReferenceTableLock); KeInitializeGuardedMutex(&PpDeviceReferenceTableLock);
RtlInitializeGenericTableAvl(&PpDeviceReferenceTable, RtlInitializeGenericTableAvl(
PiCompareInstancePath, &PpDeviceReferenceTable,
PiAllocateGenericTableEntry, (PRTL_AVL_COMPARE_ROUTINE)PiCompareInstancePath,
PiFreeGenericTableEntry, (PRTL_AVL_ALLOCATE_ROUTINE)PiAllocateGenericTableEntry,
NULL); (PRTL_AVL_FREE_ROUTINE)PiFreeGenericTableEntry,
NULL);
} }
BOOLEAN BOOLEAN

View file

@ -26,7 +26,8 @@
/* GLOBALS ****************************************************************/ /* GLOBALS ****************************************************************/
LARGE_INTEGER KeBootTime, KeBootTimeBias; LARGE_INTEGER KeBootTime;
ULONG KeBootTimeBias;
KDPC KiTimerExpireDpc; KDPC KiTimerExpireDpc;
BOOLEAN KiClockSetupComplete = FALSE; BOOLEAN KiClockSetupComplete = FALSE;
ULONG KiTimeLimitIsrMicroseconds; ULONG KiTimeLimitIsrMicroseconds;
@ -59,7 +60,10 @@ ULONG KeTimeAdjustment = 100000;
VOID VOID
NTAPI NTAPI
KiSetSystemTime(PLARGE_INTEGER NewSystemTime) KeSetSystemTime(IN PLARGE_INTEGER NewSystemTime,
OUT PLARGE_INTEGER OldTime,
IN BOOLEAN FixInterruptTime,
IN PLARGE_INTEGER HalTime)
{ {
LARGE_INTEGER OldSystemTime; LARGE_INTEGER OldSystemTime;
LARGE_INTEGER DeltaTime; LARGE_INTEGER DeltaTime;

View file

@ -451,15 +451,21 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr,
MmInitializeMdlImplementation(); MmInitializeMdlImplementation();
} }
BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
VOID VOID
NTAPI NTAPI
INIT_FUNCTION INIT_FUNCTION
MmInit2(VOID) MmInit2(VOID)
{ {
MmInitializeRmapList(); MmInitializeRmapList();
RmapReady = TRUE;
MmInitializePageOp(); MmInitializePageOp();
PageOpReady = TRUE;
MmInitSectionImplementation(); MmInitSectionImplementation();
SectionsReady = TRUE;
MmInitPagingFile(); MmInitPagingFile();
PagingReady = TRUE;
} }
VOID VOID

View file

@ -318,6 +318,8 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page)
return(Status); return(Status);
} }
extern BOOLEAN PagingReady;
VOID VOID
INIT_FUNCTION INIT_FUNCTION
NTAPI NTAPI
@ -361,6 +363,7 @@ MmReserveSwapPages(ULONG Nr)
KIRQL oldIrql; KIRQL oldIrql;
ULONG MiAvailSwapPages; ULONG MiAvailSwapPages;
if (!PagingReady) KEBUGCHECK(0);
KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
MiAvailSwapPages = MiAvailSwapPages =
(MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE; (MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE;
@ -380,6 +383,7 @@ MmDereserveSwapPages(ULONG Nr)
{ {
KIRQL oldIrql; KIRQL oldIrql;
if (!PagingReady) KEBUGCHECK(0);
KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
MiReservedSwapPages = MiReservedSwapPages - Nr; MiReservedSwapPages = MiReservedSwapPages - Nr;
KeReleaseSpinLock(&PagingFileListLock, oldIrql); KeReleaseSpinLock(&PagingFileListLock, oldIrql);
@ -391,6 +395,7 @@ MiAllocPageFromPagingFile(PPAGINGFILE PagingFile)
KIRQL oldIrql; KIRQL oldIrql;
ULONG i, j; ULONG i, j;
if (!PagingReady) KEBUGCHECK(0);
KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql); KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
for (i = 0; i < PagingFile->AllocMapSize; i++) for (i = 0; i < PagingFile->AllocMapSize; i++)
@ -420,6 +425,7 @@ MmFreeSwapPage(SWAPENTRY Entry)
ULONG off; ULONG off;
KIRQL oldIrql; KIRQL oldIrql;
if (!PagingReady) KEBUGCHECK(0);
i = FILE_FROM_ENTRY(Entry); i = FILE_FROM_ENTRY(Entry);
off = OFFSET_FROM_ENTRY(Entry); off = OFFSET_FROM_ENTRY(Entry);
@ -464,6 +470,7 @@ MmAllocSwapPage(VOID)
ULONG off; ULONG off;
SWAPENTRY entry; SWAPENTRY entry;
if (!PagingReady) KEBUGCHECK(0);
KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
if (MiFreeSwapPages == 0) if (MiFreeSwapPages == 0)

View file

@ -133,6 +133,8 @@ MmCheckForPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
return(NULL); return(NULL);
} }
extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
PMM_PAGEOP PMM_PAGEOP
NTAPI NTAPI
MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address, MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
@ -147,6 +149,8 @@ MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address,
KIRQL oldIrql; KIRQL oldIrql;
PMM_PAGEOP PageOp; PMM_PAGEOP PageOp;
if (!PageOpReady) KEBUGCHECK(0);
/* /*
* Calcuate the hash value for pageop structure * Calcuate the hash value for pageop structure
*/ */

View file

@ -379,6 +379,8 @@ MmIsDirtyPageRmap(PFN_TYPE Page)
return(FALSE); return(FALSE);
} }
extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady;
VOID VOID
NTAPI NTAPI
MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
@ -388,6 +390,8 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process,
PMM_RMAP_ENTRY new_entry; PMM_RMAP_ENTRY new_entry;
ULONG PrevSize; ULONG PrevSize;
if (!RmapReady) KEBUGCHECK(0);
Address = (PVOID)PAGE_ROUND_DOWN(Address); Address = (PVOID)PAGE_ROUND_DOWN(Address);
new_entry = ExAllocateFromNPagedLookasideList(&RmapLookasideList); new_entry = ExAllocateFromNPagedLookasideList(&RmapLookasideList);

View file

@ -1105,6 +1105,14 @@ Language=English
INVALID_WORK_QUEUE_ITEM INVALID_WORK_QUEUE_ITEM
. .
MessageId=0xA0
Severity=Success
Facility=System
SymbolicName=INTERNAL_POWER_ERROR
Language=English
INTERNAL_POWER_ERROR
.
MessageId=0xA5 MessageId=0xA5
Severity=Success Severity=Success
Facility=System Facility=System

View file

@ -501,7 +501,7 @@ ParseFromRoot:
if (DeviceMap) if (DeviceMap)
{ {
/* Dereference it */ /* Dereference it */
ObfDereferenceDeviceMap(DeviceMap); //ObfDereferenceDeviceMap(DeviceMap);
DeviceMap = NULL; DeviceMap = NULL;
} }
@ -935,7 +935,7 @@ ReparseObject:
} }
/* Check if we have a device map and dereference it if so */ /* Check if we have a device map and dereference it if so */
if (DeviceMap) ObfDereferenceDeviceMap(DeviceMap); //if (DeviceMap) ObfDereferenceDeviceMap(DeviceMap);
/* Check if we have a referenced directory and dereference it if so */ /* Check if we have a referenced directory and dereference it if so */
if (ReferencedDirectory) ObDereferenceObject(ReferencedDirectory); if (ReferencedDirectory) ObDereferenceObject(ReferencedDirectory);

View file

@ -13,10 +13,6 @@
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, PoInit)
#endif
extern ULONG ExpInitialiationPhase; extern ULONG ExpInitialiationPhase;
typedef struct _REQUEST_POWER_ITEM typedef struct _REQUEST_POWER_ITEM
@ -304,11 +300,10 @@ PopSetSystemPowerState(
return Status; return Status;
} }
VOID BOOLEAN
INIT_FUNCTION
NTAPI NTAPI
PoInit(IN ULONG BootPhase, PoInitSystem(IN ULONG BootPhase,
IN BOOLEAN HaveAcpiTable) IN BOOLEAN HaveAcpiTable)
{ {
PVOID NotificationEntry; PVOID NotificationEntry;
PCHAR CommandLine; PCHAR CommandLine;
@ -326,7 +321,7 @@ PoInit(IN ULONG BootPhase,
PopAddRemoveSysCapsCallback, PopAddRemoveSysCapsCallback,
NULL, NULL,
&NotificationEntry); &NotificationEntry);
return; return TRUE;
} }
/* Get the Command Line */ /* Get the Command Line */
@ -348,6 +343,8 @@ PoInit(IN ULONG BootPhase,
/* Otherwise check the LoaderBlock's Flag */ /* Otherwise check the LoaderBlock's Flag */
PopAcpiPresent = HaveAcpiTable; PopAcpiPresent = HaveAcpiTable;
} }
return TRUE;
} }
VOID VOID

View file

@ -271,7 +271,7 @@ PspInitializeSystemDll(VOID)
BOOLEAN BOOLEAN
NTAPI NTAPI
PspInitPhase1(VOID) PspInitPhase1()
{ {
/* Initialize the System DLL and return status of operation */ /* Initialize the System DLL and return status of operation */
if (!NT_SUCCESS(PspInitializeSystemDll())) return FALSE; if (!NT_SUCCESS(PspInitializeSystemDll())) return FALSE;
@ -280,7 +280,7 @@ PspInitPhase1(VOID)
BOOLEAN BOOLEAN
NTAPI NTAPI
PspInitPhase0(VOID) PspInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
NTSTATUS Status; NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -478,8 +478,8 @@ PspInitPhase0(VOID)
&ObjectAttributes, &ObjectAttributes,
0, 0,
NULL, NULL,
ExPhase2Init, Phase1Initialization,
NULL); LoaderBlock);
if (!NT_SUCCESS(Status)) return FALSE; if (!NT_SUCCESS(Status)) return FALSE;
/* Create a handle to it */ /* Create a handle to it */
@ -497,7 +497,7 @@ PspInitPhase0(VOID)
BOOLEAN BOOLEAN
NTAPI NTAPI
PsInitSystem(VOID) PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{ {
/* Check the initialization phase */ /* Check the initialization phase */
switch (ExpInitializationPhase) switch (ExpInitializationPhase)
@ -505,7 +505,7 @@ PsInitSystem(VOID)
case 0: case 0:
/* Do Phase 0 */ /* Do Phase 0 */
return PspInitPhase0(); return PspInitPhase0(LoaderBlock);
case 1: case 1:
@ -515,7 +515,11 @@ PsInitSystem(VOID)
default: default:
/* Don't know any other phase! Bugcheck! */ /* Don't know any other phase! Bugcheck! */
KeBugCheck(UNEXPECTED_INITIALIZATION_CALL); KeBugCheckEx(UNEXPECTED_INITIALIZATION_CALL,
1,
ExpInitializationPhase,
0,
0);
return FALSE; return FALSE;
} }
} }

View file

@ -20,58 +20,95 @@ PSE_EXPORTS SeExports = NULL;
SE_EXPORTS SepExports; SE_EXPORTS SepExports;
static ERESOURCE SepSubjectContextLock; static ERESOURCE SepSubjectContextLock;
extern ULONG ExpInitializationPhase;
/* PROTOTYPES ***************************************************************/ /* PROTOTYPES ***************************************************************/
static BOOLEAN SepInitExports(VOID); static BOOLEAN SepInitExports(VOID);
#if defined (ALLOC_PRAGMA)
#pragma alloc_text(INIT, SeInit)
#pragma alloc_text(INIT, SepInitExports)
#endif
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
BOOLEAN BOOLEAN
INIT_FUNCTION
NTAPI NTAPI
SeInit(VOID) SepInitializationPhase0(VOID)
{ {
DPRINT1("FIXME: SeAccessCheck has been HACKED to always grant access!\n"); DPRINT1("FIXME: SeAccessCheck has been HACKED to always grant access!\n");
DPRINT1("FIXME: Please fix all the code that doesn't get proper rights!\n"); DPRINT1("FIXME: Please fix all the code that doesn't get proper rights!\n");
SepInitLuid(); SepInitLuid();
if (!SepInitSecurityIDs()) return FALSE;
if (!SepInitDACLs()) return FALSE;
if (!SepInitSDs()) return FALSE;
SepInitPrivileges();
if (!SepInitExports()) return FALSE;
if (!SepInitSecurityIDs()) /* Initialize the subject context lock */
return FALSE; ExInitializeResource(&SepSubjectContextLock);
if (!SepInitDACLs()) /* Initialize token objects */
return FALSE; SepInitializeTokenImplementation();
if (!SepInitSDs()) /* Clear impersonation info for the idle thread */
return FALSE; PsGetCurrentThread()->ImpersonationInfo = NULL;
PspClearCrossThreadFlag(PsGetCurrentThread(),
CT_ACTIVE_IMPERSONATION_INFO_BIT);
SepInitPrivileges(); /* Initialize the boot token */
ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL);
ObInitializeFastReference(&PsGetCurrentProcess()->Token,
SepCreateSystemProcessToken());
return TRUE;
}
if (!SepInitExports()) BOOLEAN
return FALSE; NTAPI
SepInitializationPhase1(VOID)
{
NTSTATUS Status;
PAGED_CODE();
/* Initialize the subject context lock */ /* Insert the system token into the tree */
ExInitializeResource(&SepSubjectContextLock); Status = ObInsertObject((PVOID)(PsGetCurrentProcess()->Token.Value &
~MAX_FAST_REFS),
NULL,
0,
0,
NULL,
NULL);
ASSERT(NT_SUCCESS(Status));
/* Initialize token objects */ /* FIXME: TODO \\ Security directory */
SepInitializeTokenImplementation(); return TRUE;
}
/* Clear impersonation info for the idle thread */ BOOLEAN
PsGetCurrentThread()->ImpersonationInfo = NULL; NTAPI
PspClearCrossThreadFlag(PsGetCurrentThread(), CT_ACTIVE_IMPERSONATION_INFO_BIT); SeInit(VOID)
{
/* Check the initialization phase */
switch (ExpInitializationPhase)
{
case 0:
/* Initailize the boot token */ /* Do Phase 0 */
ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL); return SepInitializationPhase0();
ObInitializeFastReference(&PsGetCurrentProcess()->Token,
SepCreateSystemProcessToken()); case 1:
return TRUE;
/* Do Phase 1 */
return SepInitializationPhase1();
default:
/* Don't know any other phase! Bugcheck! */
KeBugCheckEx(UNEXPECTED_INITIALIZATION_CALL,
0,
ExpInitializationPhase,
0,
0);
return FALSE;
}
} }
BOOLEAN BOOLEAN