diff --git a/reactos/base/setup/usetup/bootsup.c b/reactos/base/setup/usetup/bootsup.c index 2d962a4e1ad..17684789ba3 100644 --- a/reactos/base/setup/usetup/bootsup.c +++ b/reactos/base/setup/usetup/bootsup.c @@ -305,12 +305,12 @@ CreateFreeLoaderIniForDos(PWCHAR IniPath, L"SystemPath", ArcPath); - /* Options=/DEBUGPORT=SCREEN /NOGUIBOOT */ + /* Options=/DEBUGPORT=SCREEN /NOGUIBOOT /SOS*/ IniCacheInsertKey(IniSection, NULL, INSERT_LAST, L"Options", - L"/DEBUGPORT=SCREEN /NOGUIBOOT"); + L"/DEBUGPORT=SCREEN /NOGUIBOOT /SOS"); /* Create "DOS" section */ IniSection = IniCacheAppendSection(IniCache, @@ -416,12 +416,12 @@ CreateFreeLoaderIniForReactos(PWCHAR IniPath, L"SystemPath", ArcPath); - /* Options=/DEBUGPORT=SCREEN /NOGUIBOOT */ + /* Options=/DEBUGPORT=COM1 /NOGUIBOOT /SOS*/ IniCacheInsertKey(IniSection, NULL, INSERT_LAST, L"Options", - L"/DEBUGPORT=COM1 /NOGUIBOOT"); + L"/DEBUGPORT=COM1 /NOGUIBOOT /SOS"); /* Save the ini file */ IniCacheSave(IniCache, IniPath); diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index c95e5ee6d32..52e38c48692 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -33,8 +33,7 @@ ULONG ExpInitializationPhase; BOOLEAN ExpInTextModeSetup; BOOLEAN IoRemoteBootClient; ULONG InitSafeBootMode; - -BOOLEAN NoGuiBoot = FALSE; +BOOLEAN InitIsWinPEMode, InitWinPEModeType; /* NT Boot Path */ UNICODE_STRING NtSystemRoot; @@ -53,6 +52,9 @@ NLSTABLEINFO ExpNlsTableInfo; ULONG ExpNlsTableSize; PVOID ExpNlsSectionPointer; +/* CMOS Timer Sanity */ +BOOLEAN ExCmosClockIsSane = TRUE; + /* FUNCTIONS ****************************************************************/ NTSTATUS @@ -353,13 +355,11 @@ ExpDisplayNotice(VOID) NTSTATUS NTAPI -ExpLoadInitialProcess(IN PHANDLE ProcessHandle, - IN PHANDLE ThreadHandle) +ExpLoadInitialProcess(IN OUT PRTL_USER_PROCESS_INFORMATION ProcessInformation) { PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; NTSTATUS Status; ULONG Size; - RTL_USER_PROCESS_INFORMATION ProcessInformation; PWSTR p; UNICODE_STRING NullString = RTL_CONSTANT_STRING(L""); UNICODE_STRING SmssName, Environment, SystemDriveString; @@ -509,7 +509,7 @@ ExpLoadInitialProcess(IN PHANDLE ProcessHandle, FALSE, NULL, NULL, - &ProcessInformation); + ProcessInformation); if (!NT_SUCCESS(Status)) { /* Failed */ @@ -517,16 +517,14 @@ ExpLoadInitialProcess(IN PHANDLE ProcessHandle, } /* Resume the thread */ - Status = ZwResumeThread(ProcessInformation.ThreadHandle, NULL); + Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL); if (!NT_SUCCESS(Status)) { /* Failed */ KeBugCheckEx(SESSION4_INITIALIZATION_FAILED, Status, 0, 0, 0); } - /* Return Handles */ - *ProcessHandle = ProcessInformation.ProcessHandle; - *ThreadHandle = ProcessInformation.ThreadHandle; + /* Return success */ return STATUS_SUCCESS; } @@ -749,7 +747,9 @@ ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock) RtlInitString(&SymbolString, NameBuffer); /* 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); /* Initialize the Process Manager */ - if (!PsInitSystem()) KEBUGCHECK(PROCESS_INITIALIZATION_FAILED); + if (!PsInitSystem(LoaderBlock)) KEBUGCHECK(PROCESS_INITIALIZATION_FAILED); /* Initialize the PnP Manager */ if (!PpInitSystem()) KEBUGCHECK(PP0_INITIALIZATION_FAILED); @@ -1018,14 +1018,27 @@ ExpInitializeExecutive(IN ULONG Cpu, VOID NTAPI -ExPhase2Init(PVOID Context) +Phase1InitializationDiscard(PVOID Context) { + PLOADER_PARAMETER_BLOCK LoaderBlock = Context; + PCHAR CommandLine, Y2KHackRequired; LARGE_INTEGER Timeout; - HANDLE ProcessHandle; - HANDLE ThreadHandle; NTSTATUS Status; 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 */ ExpInitializationPhase = 1; @@ -1034,29 +1047,59 @@ ExPhase2Init(PVOID Context) KeSetPriorityThread(KeGetCurrentThread(), HIGH_PRIORITY); /* 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 */ - 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(); if (!ExpInTextModeSetup) InbvDisplayInitialize2(NoGuiBoot); - if (!NoGuiBoot) InbvDisplayBootLogo(); - /* Clear the screen to blue and display the boot notice and debug status */ - if (NoGuiBoot) ExpDisplayNotice(); - KdInitSystem(2, KeLoaderBlock); + /* Check if GUI boot is enabled */ + if (!NoGuiBoot) + { + /* 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 */ - MmInit2(); + /* Don't allow boot-time strings */ + 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 */ - 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 */ - 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 */ RtlTimeFieldsToTime(&TimeFields, &SystemBootTime); UniversalBootTime = SystemBootTime; @@ -1075,41 +1118,54 @@ ExPhase2Init(PVOID Context) UniversalBootTime.QuadPart = SystemBootTime.QuadPart + ExpTimeZoneBias.QuadPart; #endif - KiSetSystemTime(&UniversalBootTime); + + /* Update the system time */ + KeSetSystemTime(&UniversalBootTime, &OldTime, FALSE, NULL); /* Remember this as the boot time */ KeBootTime = UniversalBootTime; + KeBootTimeBias = 0; } /* The clock is ready now (FIXME: HACK FOR OLD HAL) */ KiClockSetupComplete = TRUE; /* Initialize all processors */ - HalAllProcessorsStarted(); + if (!HalAllProcessorsStarted()) KeBugCheck(HAL1_INITIALIZATION_FAILED); /* Call OB initialization again */ if (!ObInit()) KeBugCheck(OBJECT1_INITIALIZATION_FAILED); /* 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 */ - 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 */ if (!KdInitSystem(ExpInitializationPhase, KeLoaderBlock)) { /* 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 */ - Status = ExpCreateSystemRootLink(KeLoaderBlock); + Status = ExpCreateSystemRootLink(LoaderBlock); if (!NT_SUCCESS(Status)) { + /* Failed to create the system root link */ KeBugCheckEx(SYMBOLIC_INITIALIZATION_FAILED, Status, 0, 0, 0); } + /* Set up Region Maps, Sections and the Paging File */ + MmInit2(); + /* Create NLS section */ ExpInitNls(KeLoaderBlock); @@ -1148,17 +1204,17 @@ ExPhase2Init(PVOID Context) KeI386VdmInitialize(); /* Initialize Power Subsystem in Phase 1*/ - PoInit(1, AcpiTableDetected); + PoInitSystem(1, AcpiTableDetected); /* Initialize the Process Manager at Phase 1 */ - if (!PsInitSystem()) KeBugCheck(PROCESS1_INITIALIZATION_FAILED); + if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS1_INITIALIZATION_FAILED); /* Launch initial process */ - Status = ExpLoadInitialProcess(&ProcessHandle, &ThreadHandle); + Status = ExpLoadInitialProcess(ProcessInfo); /* Wait 5 seconds for it to initialize */ Timeout.QuadPart = Int32x32To64(5, -10000000); - Status = ZwWaitForSingleObject(ProcessHandle, FALSE, &Timeout); + Status = ZwWaitForSingleObject(ProcessInfo->ProcessHandle, FALSE, &Timeout); if (!NoGuiBoot) InbvFinalizeBootLogo(); if (Status == STATUS_SUCCESS) { @@ -1167,15 +1223,26 @@ ExPhase2Init(PVOID Context) } /* Close process handles */ - ZwClose(ThreadHandle); - ZwClose(ProcessHandle); + ZwClose(ProcessInfo->ThreadHandle); + ZwClose(ProcessInfo->ProcessHandle); /* FIXME: We should free the initial process' memory!*/ /* Increase init phase */ 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 */ MmZeroPageThreadMain(NULL); } -/* EOF */ + diff --git a/reactos/ntoskrnl/ex/time.c b/reactos/ntoskrnl/ex/time.c index cb35557030a..9acd4b18eaa 100644 --- a/reactos/ntoskrnl/ex/time.c +++ b/reactos/ntoskrnl/ex/time.c @@ -123,7 +123,7 @@ ExpSetTimeZoneInformation(PTIME_ZONE_INFORMATION TimeZoneInformation) ExLocalTimeToSystemTime(&LocalTime, &SystemTime); /* Set the new system time */ - KiSetSystemTime(&SystemTime); + KeSetSystemTime(&SystemTime, NULL, FALSE, NULL); /* Return success */ DPRINT("ExpSetTimeZoneInformation() done\n"); @@ -193,7 +193,7 @@ NtSetSystemTime(IN PLARGE_INTEGER SystemTime, HalSetRealTimeClock(&TimeFields); /* Now set system time */ - KiSetSystemTime(&NewSystemTime); + KeSetSystemTime(&NewSystemTime, NULL, FALSE, NULL); /* Check if caller wanted previous time */ if(PreviousTime) diff --git a/reactos/ntoskrnl/inbv/inbv.c b/reactos/ntoskrnl/inbv/inbv.c index b652ef8d6fa..4a704d7973b 100644 --- a/reactos/ntoskrnl/inbv/inbv.c +++ b/reactos/ntoskrnl/inbv/inbv.c @@ -300,14 +300,14 @@ InbvDisplayInitialize2(BOOLEAN NoGuiBoot) VOID NTAPI -InbvDisplayBootLogo(VOID) +InbvDisplayBootLogo(IN BOOLEAN SosEnabled) { InbvEnableBootDriver(TRUE); if (BootVidDriverInstalled) { InbvResetDisplayParameters = BootVidResetDisplayParameters; - BootVidDisplayBootLogo(BootVidBase); + if (!SosEnabled) BootVidDisplayBootLogo(BootVidBase); } } diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index f19a6161afd..b5e0934ad48 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -138,7 +138,7 @@ ExInit2(VOID); VOID NTAPI -ExPhase2Init( +Phase1Initialization( IN PVOID Context ); diff --git a/reactos/ntoskrnl/include/internal/inbv.h b/reactos/ntoskrnl/include/internal/inbv.h index 26a65e49ea5..9e6b34e3ad2 100644 --- a/reactos/ntoskrnl/include/internal/inbv.h +++ b/reactos/ntoskrnl/include/internal/inbv.h @@ -14,7 +14,7 @@ VOID NTAPI InbvDisplayInitialize2(BOOLEAN NoGuiBoot); VOID NTAPI -InbvDisplayBootLogo(VOID); +InbvDisplayBootLogo(IN BOOLEAN SosEnabled); VOID NTAPI InbvUpdateProgressBar(ULONG Progress); diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index 3d079faa3ea..40ba45824ea 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -85,6 +85,7 @@ extern PVOID KeUserCallbackDispatcher; extern PVOID KeUserExceptionDispatcher; extern PVOID KeRaiseUserExceptionDispatcher; extern LARGE_INTEGER KeBootTime; +extern ULONG KeBootTimeBias; extern ULONG KeI386NpxPresent; extern ULONG KeI386XMMIPresent; extern ULONG KeI386FxsrPresent; @@ -781,7 +782,12 @@ KeRosDumpStackFrames( VOID NTAPI -KiSetSystemTime(PLARGE_INTEGER NewSystemTime); +KeSetSystemTime( + IN PLARGE_INTEGER NewSystemTime, + OUT PLARGE_INTEGER OldSystemTime, + IN BOOLEAN FixInterruptTime, + IN PLARGE_INTEGER HalTime +); ULONG NTAPI diff --git a/reactos/ntoskrnl/include/internal/po.h b/reactos/ntoskrnl/include/internal/po.h index 7db0f128f60..c627dfbd4d7 100644 --- a/reactos/ntoskrnl/include/internal/po.h +++ b/reactos/ntoskrnl/include/internal/po.h @@ -35,9 +35,9 @@ // // Initialization routines // -VOID +BOOLEAN NTAPI -PoInit( +PoInitSystem( IN ULONG BootPhase, IN BOOLEAN HaveAcpiTable ); diff --git a/reactos/ntoskrnl/include/internal/ps.h b/reactos/ntoskrnl/include/internal/ps.h index d167814a82f..79c7f7a9936 100644 --- a/reactos/ntoskrnl/include/internal/ps.h +++ b/reactos/ntoskrnl/include/internal/ps.h @@ -82,7 +82,7 @@ PspShutdownProcessManager( BOOLEAN NTAPI PsInitSystem( - VOID + IN PLOADER_PARAMETER_BLOCK LoaderBlock ); // diff --git a/reactos/ntoskrnl/io/iomgr/driver.c b/reactos/ntoskrnl/io/iomgr/driver.c index cb169efd037..dfa34bf62fb 100644 --- a/reactos/ntoskrnl/io/iomgr/driver.c +++ b/reactos/ntoskrnl/io/iomgr/driver.c @@ -30,7 +30,6 @@ UNICODE_STRING IopHardwareDatabaseKey = POBJECT_TYPE IoDriverObjectType = NULL; extern BOOLEAN ExpInTextModeSetup; -extern BOOLEAN NoGuiBoot; /* DECLARATIONS ***************************************************************/ @@ -281,7 +280,7 @@ IopDisplayLoadingMessage(PVOID ServiceName, BOOLEAN Unicode) { CHAR TextBuffer[256]; - if (ExpInTextModeSetup || !NoGuiBoot) return; + if (ExpInTextModeSetup) return; if (Unicode) { sprintf(TextBuffer, "Loading %S...\n", (PWCHAR)ServiceName); diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 62cd61034af..2cd18320a18 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -3363,11 +3363,12 @@ PpInitializeDeviceReferenceTable(VOID) { /* Setup the guarded mutex and AVL table */ KeInitializeGuardedMutex(&PpDeviceReferenceTableLock); - RtlInitializeGenericTableAvl(&PpDeviceReferenceTable, - PiCompareInstancePath, - PiAllocateGenericTableEntry, - PiFreeGenericTableEntry, - NULL); + RtlInitializeGenericTableAvl( + &PpDeviceReferenceTable, + (PRTL_AVL_COMPARE_ROUTINE)PiCompareInstancePath, + (PRTL_AVL_ALLOCATE_ROUTINE)PiAllocateGenericTableEntry, + (PRTL_AVL_FREE_ROUTINE)PiFreeGenericTableEntry, + NULL); } BOOLEAN diff --git a/reactos/ntoskrnl/ke/clock.c b/reactos/ntoskrnl/ke/clock.c index 5df7bcc1f8e..cee80f92f6f 100644 --- a/reactos/ntoskrnl/ke/clock.c +++ b/reactos/ntoskrnl/ke/clock.c @@ -26,7 +26,8 @@ /* GLOBALS ****************************************************************/ -LARGE_INTEGER KeBootTime, KeBootTimeBias; +LARGE_INTEGER KeBootTime; +ULONG KeBootTimeBias; KDPC KiTimerExpireDpc; BOOLEAN KiClockSetupComplete = FALSE; ULONG KiTimeLimitIsrMicroseconds; @@ -59,7 +60,10 @@ ULONG KeTimeAdjustment = 100000; VOID 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 DeltaTime; diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index b12bb875874..6ceae129e4c 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -451,15 +451,21 @@ MmInit1(ULONG_PTR FirstKrnlPhysAddr, MmInitializeMdlImplementation(); } +BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady; + VOID NTAPI INIT_FUNCTION MmInit2(VOID) { MmInitializeRmapList(); + RmapReady = TRUE; MmInitializePageOp(); + PageOpReady = TRUE; MmInitSectionImplementation(); + SectionsReady = TRUE; MmInitPagingFile(); + PagingReady = TRUE; } VOID diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 5ce6407a4c7..e9e14bb056b 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -318,6 +318,8 @@ MmReadFromSwapPage(SWAPENTRY SwapEntry, PFN_TYPE Page) return(Status); } +extern BOOLEAN PagingReady; + VOID INIT_FUNCTION NTAPI @@ -361,6 +363,7 @@ MmReserveSwapPages(ULONG Nr) KIRQL oldIrql; ULONG MiAvailSwapPages; + if (!PagingReady) KEBUGCHECK(0); KeAcquireSpinLock(&PagingFileListLock, &oldIrql); MiAvailSwapPages = (MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE; @@ -380,6 +383,7 @@ MmDereserveSwapPages(ULONG Nr) { KIRQL oldIrql; + if (!PagingReady) KEBUGCHECK(0); KeAcquireSpinLock(&PagingFileListLock, &oldIrql); MiReservedSwapPages = MiReservedSwapPages - Nr; KeReleaseSpinLock(&PagingFileListLock, oldIrql); @@ -391,6 +395,7 @@ MiAllocPageFromPagingFile(PPAGINGFILE PagingFile) KIRQL oldIrql; ULONG i, j; + if (!PagingReady) KEBUGCHECK(0); KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql); for (i = 0; i < PagingFile->AllocMapSize; i++) @@ -420,6 +425,7 @@ MmFreeSwapPage(SWAPENTRY Entry) ULONG off; KIRQL oldIrql; + if (!PagingReady) KEBUGCHECK(0); i = FILE_FROM_ENTRY(Entry); off = OFFSET_FROM_ENTRY(Entry); @@ -464,6 +470,7 @@ MmAllocSwapPage(VOID) ULONG off; SWAPENTRY entry; + if (!PagingReady) KEBUGCHECK(0); KeAcquireSpinLock(&PagingFileListLock, &oldIrql); if (MiFreeSwapPages == 0) diff --git a/reactos/ntoskrnl/mm/pageop.c b/reactos/ntoskrnl/mm/pageop.c index 2ab70ddebed..4f33d07f0a7 100644 --- a/reactos/ntoskrnl/mm/pageop.c +++ b/reactos/ntoskrnl/mm/pageop.c @@ -133,6 +133,8 @@ MmCheckForPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address, return(NULL); } +extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady; + PMM_PAGEOP NTAPI MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address, @@ -147,6 +149,8 @@ MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address, KIRQL oldIrql; PMM_PAGEOP PageOp; + if (!PageOpReady) KEBUGCHECK(0); + /* * Calcuate the hash value for pageop structure */ diff --git a/reactos/ntoskrnl/mm/rmap.c b/reactos/ntoskrnl/mm/rmap.c index e76b80934d9..cbd879ae642 100644 --- a/reactos/ntoskrnl/mm/rmap.c +++ b/reactos/ntoskrnl/mm/rmap.c @@ -379,6 +379,8 @@ MmIsDirtyPageRmap(PFN_TYPE Page) return(FALSE); } +extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady; + VOID NTAPI MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, @@ -388,6 +390,8 @@ MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, PMM_RMAP_ENTRY new_entry; ULONG PrevSize; + if (!RmapReady) KEBUGCHECK(0); + Address = (PVOID)PAGE_ROUND_DOWN(Address); new_entry = ExAllocateFromNPagedLookasideList(&RmapLookasideList); diff --git a/reactos/ntoskrnl/ntoskrnl.mc b/reactos/ntoskrnl/ntoskrnl.mc index fb1b9943a4f..57b72a99004 100644 --- a/reactos/ntoskrnl/ntoskrnl.mc +++ b/reactos/ntoskrnl/ntoskrnl.mc @@ -1105,6 +1105,14 @@ Language=English INVALID_WORK_QUEUE_ITEM . +MessageId=0xA0 +Severity=Success +Facility=System +SymbolicName=INTERNAL_POWER_ERROR +Language=English +INTERNAL_POWER_ERROR +. + MessageId=0xA5 Severity=Success Facility=System diff --git a/reactos/ntoskrnl/ob/obname.c b/reactos/ntoskrnl/ob/obname.c index 05872bbffa0..27846d40b0b 100644 --- a/reactos/ntoskrnl/ob/obname.c +++ b/reactos/ntoskrnl/ob/obname.c @@ -501,7 +501,7 @@ ParseFromRoot: if (DeviceMap) { /* Dereference it */ - ObfDereferenceDeviceMap(DeviceMap); + //ObfDereferenceDeviceMap(DeviceMap); DeviceMap = NULL; } @@ -935,7 +935,7 @@ ReparseObject: } /* 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 */ if (ReferencedDirectory) ObDereferenceObject(ReferencedDirectory); diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index 8eb01c5bcf4..0d3978e5ab5 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -13,10 +13,6 @@ #define NDEBUG #include -#if defined (ALLOC_PRAGMA) -#pragma alloc_text(INIT, PoInit) -#endif - extern ULONG ExpInitialiationPhase; typedef struct _REQUEST_POWER_ITEM @@ -304,11 +300,10 @@ PopSetSystemPowerState( return Status; } -VOID -INIT_FUNCTION +BOOLEAN NTAPI -PoInit(IN ULONG BootPhase, - IN BOOLEAN HaveAcpiTable) +PoInitSystem(IN ULONG BootPhase, + IN BOOLEAN HaveAcpiTable) { PVOID NotificationEntry; PCHAR CommandLine; @@ -326,7 +321,7 @@ PoInit(IN ULONG BootPhase, PopAddRemoveSysCapsCallback, NULL, &NotificationEntry); - return; + return TRUE; } /* Get the Command Line */ @@ -348,6 +343,8 @@ PoInit(IN ULONG BootPhase, /* Otherwise check the LoaderBlock's Flag */ PopAcpiPresent = HaveAcpiTable; } + + return TRUE; } VOID diff --git a/reactos/ntoskrnl/ps/psmgr.c b/reactos/ntoskrnl/ps/psmgr.c index 3b19a60f671..7567844784a 100644 --- a/reactos/ntoskrnl/ps/psmgr.c +++ b/reactos/ntoskrnl/ps/psmgr.c @@ -271,7 +271,7 @@ PspInitializeSystemDll(VOID) BOOLEAN NTAPI -PspInitPhase1(VOID) +PspInitPhase1() { /* Initialize the System DLL and return status of operation */ if (!NT_SUCCESS(PspInitializeSystemDll())) return FALSE; @@ -280,7 +280,7 @@ PspInitPhase1(VOID) BOOLEAN NTAPI -PspInitPhase0(VOID) +PspInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { NTSTATUS Status; OBJECT_ATTRIBUTES ObjectAttributes; @@ -478,8 +478,8 @@ PspInitPhase0(VOID) &ObjectAttributes, 0, NULL, - ExPhase2Init, - NULL); + Phase1Initialization, + LoaderBlock); if (!NT_SUCCESS(Status)) return FALSE; /* Create a handle to it */ @@ -497,7 +497,7 @@ PspInitPhase0(VOID) BOOLEAN NTAPI -PsInitSystem(VOID) +PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { /* Check the initialization phase */ switch (ExpInitializationPhase) @@ -505,7 +505,7 @@ PsInitSystem(VOID) case 0: /* Do Phase 0 */ - return PspInitPhase0(); + return PspInitPhase0(LoaderBlock); case 1: @@ -515,7 +515,11 @@ PsInitSystem(VOID) default: /* Don't know any other phase! Bugcheck! */ - KeBugCheck(UNEXPECTED_INITIALIZATION_CALL); + KeBugCheckEx(UNEXPECTED_INITIALIZATION_CALL, + 1, + ExpInitializationPhase, + 0, + 0); return FALSE; } } diff --git a/reactos/ntoskrnl/se/semgr.c b/reactos/ntoskrnl/se/semgr.c index fcbb210db36..0e8267a7b39 100644 --- a/reactos/ntoskrnl/se/semgr.c +++ b/reactos/ntoskrnl/se/semgr.c @@ -20,58 +20,95 @@ PSE_EXPORTS SeExports = NULL; SE_EXPORTS SepExports; static ERESOURCE SepSubjectContextLock; +extern ULONG ExpInitializationPhase; /* PROTOTYPES ***************************************************************/ static BOOLEAN SepInitExports(VOID); -#if defined (ALLOC_PRAGMA) -#pragma alloc_text(INIT, SeInit) -#pragma alloc_text(INIT, SepInitExports) -#endif - /* FUNCTIONS ****************************************************************/ -BOOLEAN -INIT_FUNCTION +BOOLEAN NTAPI -SeInit(VOID) +SepInitializationPhase0(VOID) { 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"); - SepInitLuid(); + SepInitLuid(); + if (!SepInitSecurityIDs()) return FALSE; + if (!SepInitDACLs()) return FALSE; + if (!SepInitSDs()) return FALSE; + SepInitPrivileges(); + if (!SepInitExports()) return FALSE; - if (!SepInitSecurityIDs()) - return FALSE; + /* Initialize the subject context lock */ + ExInitializeResource(&SepSubjectContextLock); - if (!SepInitDACLs()) - return FALSE; + /* Initialize token objects */ + SepInitializeTokenImplementation(); - if (!SepInitSDs()) - return FALSE; + /* Clear impersonation info for the idle thread */ + 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()) - return FALSE; +BOOLEAN +NTAPI +SepInitializationPhase1(VOID) +{ + NTSTATUS Status; + PAGED_CODE(); - /* Initialize the subject context lock */ - ExInitializeResource(&SepSubjectContextLock); + /* Insert the system token into the tree */ + Status = ObInsertObject((PVOID)(PsGetCurrentProcess()->Token.Value & + ~MAX_FAST_REFS), + NULL, + 0, + 0, + NULL, + NULL); + ASSERT(NT_SUCCESS(Status)); - /* Initialize token objects */ - SepInitializeTokenImplementation(); + /* FIXME: TODO \\ Security directory */ + return TRUE; +} - /* Clear impersonation info for the idle thread */ - PsGetCurrentThread()->ImpersonationInfo = NULL; - PspClearCrossThreadFlag(PsGetCurrentThread(), CT_ACTIVE_IMPERSONATION_INFO_BIT); +BOOLEAN +NTAPI +SeInit(VOID) +{ + /* Check the initialization phase */ + switch (ExpInitializationPhase) + { + case 0: - /* Initailize the boot token */ - ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL); - ObInitializeFastReference(&PsGetCurrentProcess()->Token, - SepCreateSystemProcessToken()); - return TRUE; + /* Do Phase 0 */ + return SepInitializationPhase0(); + + case 1: + + /* Do Phase 1 */ + return SepInitializationPhase1(); + + default: + + /* Don't know any other phase! Bugcheck! */ + KeBugCheckEx(UNEXPECTED_INITIALIZATION_CALL, + 0, + ExpInitializationPhase, + 0, + 0); + return FALSE; + } } BOOLEAN