Author: ion Date: Thu Jan 25 04:13:09 2007 New Revision: 25624
URL: http://svn.reactos.org/svn/reactos?rev=25624&view=rev Log: - 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.
Modified: trunk/reactos/base/setup/usetup/bootsup.c trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/ex/time.c trunk/reactos/ntoskrnl/inbv/inbv.c trunk/reactos/ntoskrnl/include/internal/ex.h trunk/reactos/ntoskrnl/include/internal/inbv.h trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/include/internal/po.h trunk/reactos/ntoskrnl/include/internal/ps.h trunk/reactos/ntoskrnl/io/iomgr/driver.c trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c trunk/reactos/ntoskrnl/ke/clock.c trunk/reactos/ntoskrnl/mm/mminit.c trunk/reactos/ntoskrnl/mm/pagefile.c trunk/reactos/ntoskrnl/mm/pageop.c trunk/reactos/ntoskrnl/mm/rmap.c trunk/reactos/ntoskrnl/ntoskrnl.mc trunk/reactos/ntoskrnl/ob/obname.c trunk/reactos/ntoskrnl/po/power.c trunk/reactos/ntoskrnl/ps/psmgr.c trunk/reactos/ntoskrnl/se/semgr.c
Modified: trunk/reactos/base/setup/usetup/bootsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/bootsup.c... ============================================================================== --- trunk/reactos/base/setup/usetup/bootsup.c (original) +++ trunk/reactos/base/setup/usetup/bootsup.c Thu Jan 25 04:13:09 2007 @@ -305,12 +305,12 @@ 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 @@ 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);
Modified: trunk/reactos/ntoskrnl/ex/init.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=2562... ============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c (original) +++ trunk/reactos/ntoskrnl/ex/init.c Thu Jan 25 04:13:09 2007 @@ -33,8 +33,7 @@ BOOLEAN ExpInTextModeSetup; BOOLEAN IoRemoteBootClient; ULONG InitSafeBootMode; - -BOOLEAN NoGuiBoot = FALSE; +BOOLEAN InitIsWinPEMode, InitWinPEModeType;
/* NT Boot Path */ UNICODE_STRING NtSystemRoot; @@ -52,6 +51,9 @@ NLSTABLEINFO ExpNlsTableInfo; ULONG ExpNlsTableSize; PVOID ExpNlsSectionPointer; + +/* CMOS Timer Sanity */ +BOOLEAN ExCmosClockIsSane = TRUE;
/* FUNCTIONS ****************************************************************/
@@ -353,13 +355,11 @@
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 @@ FALSE, NULL, NULL, - &ProcessInformation); + ProcessInformation); if (!NT_SUCCESS(Status)) { /* Failed */ @@ -517,16 +517,14 @@ }
/* 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 @@ RtlInitString(&SymbolString, NameBuffer);
/* Load the symbols */ - DbgLoadImageSymbols(&SymbolString, LdrEntry->DllBase, -1); + DbgLoadImageSymbols(&SymbolString, + LdrEntry->DllBase, + 0xFFFFFFFF); } }
@@ -988,7 +988,7 @@ 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 @@
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 @@ 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; - - /* Display the boot screen image if not disabled */ + NoGuiBoot = (strstr(CommandLine, "NOGUIBOOT")) ? TRUE: FALSE; + + /* 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); - - /* Set up Region Maps, Sections and the Paging File */ - MmInit2(); + + /* 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); + + /* 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,40 +1118,53 @@ 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); - if (!NT_SUCCESS(Status)) - { + 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 @@ 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 @@ }
/* 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 */ +
Modified: trunk/reactos/ntoskrnl/ex/time.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/time.c?rev=2562... ============================================================================== --- trunk/reactos/ntoskrnl/ex/time.c (original) +++ trunk/reactos/ntoskrnl/ex/time.c Thu Jan 25 04:13:09 2007 @@ -123,7 +123,7 @@ 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 @@ HalSetRealTimeClock(&TimeFields);
/* Now set system time */ - KiSetSystemTime(&NewSystemTime); + KeSetSystemTime(&NewSystemTime, NULL, FALSE, NULL);
/* Check if caller wanted previous time */ if(PreviousTime)
Modified: trunk/reactos/ntoskrnl/inbv/inbv.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/inbv/inbv.c?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/inbv/inbv.c (original) +++ trunk/reactos/ntoskrnl/inbv/inbv.c Thu Jan 25 04:13:09 2007 @@ -300,14 +300,14 @@
VOID NTAPI -InbvDisplayBootLogo(VOID) +InbvDisplayBootLogo(IN BOOLEAN SosEnabled) { InbvEnableBootDriver(TRUE);
if (BootVidDriverInstalled) { InbvResetDisplayParameters = BootVidResetDisplayParameters; - BootVidDisplayBootLogo(BootVidBase); + if (!SosEnabled) BootVidDisplayBootLogo(BootVidBase); } }
Modified: trunk/reactos/ntoskrnl/include/internal/ex.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/e... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ex.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ex.h Thu Jan 25 04:13:09 2007 @@ -138,7 +138,7 @@
VOID NTAPI -ExPhase2Init( +Phase1Initialization( IN PVOID Context );
Modified: trunk/reactos/ntoskrnl/include/internal/inbv.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/inbv.h (original) +++ trunk/reactos/ntoskrnl/include/internal/inbv.h Thu Jan 25 04:13:09 2007 @@ -14,7 +14,7 @@ InbvDisplayInitialize2(BOOLEAN NoGuiBoot);
VOID NTAPI -InbvDisplayBootLogo(VOID); +InbvDisplayBootLogo(IN BOOLEAN SosEnabled);
VOID NTAPI InbvUpdateProgressBar(ULONG Progress);
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/k... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h Thu Jan 25 04:13:09 2007 @@ -85,6 +85,7 @@ 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 @@
VOID NTAPI -KiSetSystemTime(PLARGE_INTEGER NewSystemTime); +KeSetSystemTime( + IN PLARGE_INTEGER NewSystemTime, + OUT PLARGE_INTEGER OldSystemTime, + IN BOOLEAN FixInterruptTime, + IN PLARGE_INTEGER HalTime +);
ULONG NTAPI
Modified: trunk/reactos/ntoskrnl/include/internal/po.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/p... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/po.h (original) +++ trunk/reactos/ntoskrnl/include/internal/po.h Thu Jan 25 04:13:09 2007 @@ -35,9 +35,9 @@ // // Initialization routines // -VOID +BOOLEAN NTAPI -PoInit( +PoInitSystem( IN ULONG BootPhase, IN BOOLEAN HaveAcpiTable );
Modified: trunk/reactos/ntoskrnl/include/internal/ps.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/p... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ps.h (original) +++ trunk/reactos/ntoskrnl/include/internal/ps.h Thu Jan 25 04:13:09 2007 @@ -82,7 +82,7 @@ BOOLEAN NTAPI PsInitSystem( - VOID + IN PLOADER_PARAMETER_BLOCK LoaderBlock );
//
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c?... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/driver.c (original) +++ trunk/reactos/ntoskrnl/io/iomgr/driver.c Thu Jan 25 04:13:09 2007 @@ -30,7 +30,6 @@ POBJECT_TYPE IoDriverObjectType = NULL;
extern BOOLEAN ExpInTextModeSetup; -extern BOOLEAN NoGuiBoot;
/* DECLARATIONS ***************************************************************/
@@ -281,7 +280,7 @@ BOOLEAN Unicode) { CHAR TextBuffer[256]; - if (ExpInTextModeSetup || !NoGuiBoot) return; + if (ExpInTextModeSetup) return; if (Unicode) { sprintf(TextBuffer, "Loading %S...\n", (PWCHAR)ServiceName);
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c Thu Jan 25 04:13:09 2007 @@ -3363,11 +3363,12 @@ { /* 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
Modified: trunk/reactos/ntoskrnl/ke/clock.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/clock.c?rev=256... ============================================================================== --- trunk/reactos/ntoskrnl/ke/clock.c (original) +++ trunk/reactos/ntoskrnl/ke/clock.c Thu Jan 25 04:13:09 2007 @@ -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 @@
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;
Modified: trunk/reactos/ntoskrnl/mm/mminit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/mm/mminit.c (original) +++ trunk/reactos/ntoskrnl/mm/mminit.c Thu Jan 25 04:13:09 2007 @@ -451,15 +451,21 @@ 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
Modified: trunk/reactos/ntoskrnl/mm/pagefile.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/pagefile.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/mm/pagefile.c (original) +++ trunk/reactos/ntoskrnl/mm/pagefile.c Thu Jan 25 04:13:09 2007 @@ -318,6 +318,8 @@ return(Status); }
+extern BOOLEAN PagingReady; + VOID INIT_FUNCTION NTAPI @@ -361,6 +363,7 @@ 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 @@ { KIRQL oldIrql;
+ if (!PagingReady) KEBUGCHECK(0); KeAcquireSpinLock(&PagingFileListLock, &oldIrql); MiReservedSwapPages = MiReservedSwapPages - Nr; KeReleaseSpinLock(&PagingFileListLock, oldIrql); @@ -391,6 +395,7 @@ KIRQL oldIrql; ULONG i, j;
+ if (!PagingReady) KEBUGCHECK(0); KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql);
for (i = 0; i < PagingFile->AllocMapSize; i++) @@ -420,6 +425,7 @@ ULONG off; KIRQL oldIrql;
+ if (!PagingReady) KEBUGCHECK(0); i = FILE_FROM_ENTRY(Entry); off = OFFSET_FROM_ENTRY(Entry);
@@ -464,6 +470,7 @@ ULONG off; SWAPENTRY entry;
+ if (!PagingReady) KEBUGCHECK(0); KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
if (MiFreeSwapPages == 0)
Modified: trunk/reactos/ntoskrnl/mm/pageop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/pageop.c?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/mm/pageop.c (original) +++ trunk/reactos/ntoskrnl/mm/pageop.c Thu Jan 25 04:13:09 2007 @@ -133,6 +133,8 @@ return(NULL); }
+extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady; + PMM_PAGEOP NTAPI MmGetPageOp(PMEMORY_AREA MArea, HANDLE Pid, PVOID Address, @@ -146,6 +148,8 @@ ULONG_PTR Hash; KIRQL oldIrql; PMM_PAGEOP PageOp; + + if (!PageOpReady) KEBUGCHECK(0);
/* * Calcuate the hash value for pageop structure
Modified: trunk/reactos/ntoskrnl/mm/rmap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/rmap.c?rev=2562... ============================================================================== --- trunk/reactos/ntoskrnl/mm/rmap.c (original) +++ trunk/reactos/ntoskrnl/mm/rmap.c Thu Jan 25 04:13:09 2007 @@ -379,6 +379,8 @@ return(FALSE); }
+extern BOOLEAN RmapReady, PageOpReady, SectionsReady, PagingReady; + VOID NTAPI MmInsertRmap(PFN_TYPE Page, PEPROCESS Process, @@ -387,6 +389,8 @@ PMM_RMAP_ENTRY current_entry; PMM_RMAP_ENTRY new_entry; ULONG PrevSize; + + if (!RmapReady) KEBUGCHECK(0);
Address = (PVOID)PAGE_ROUND_DOWN(Address);
Modified: trunk/reactos/ntoskrnl/ntoskrnl.mc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.mc?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl.mc (original) +++ trunk/reactos/ntoskrnl/ntoskrnl.mc Thu Jan 25 04:13:09 2007 @@ -1105,6 +1105,14 @@ 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
Modified: trunk/reactos/ntoskrnl/ob/obname.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=25... ============================================================================== --- trunk/reactos/ntoskrnl/ob/obname.c (original) +++ trunk/reactos/ntoskrnl/ob/obname.c Thu Jan 25 04:13:09 2007 @@ -501,7 +501,7 @@ if (DeviceMap) { /* Dereference it */ - ObfDereferenceDeviceMap(DeviceMap); + //ObfDereferenceDeviceMap(DeviceMap); DeviceMap = NULL; }
@@ -935,7 +935,7 @@ }
/* 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);
Modified: trunk/reactos/ntoskrnl/po/power.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/po/power.c?rev=256... ============================================================================== --- trunk/reactos/ntoskrnl/po/power.c (original) +++ trunk/reactos/ntoskrnl/po/power.c Thu Jan 25 04:13:09 2007 @@ -12,10 +12,6 @@ #include <ntoskrnl.h> #define NDEBUG #include <internal/debug.h> - -#if defined (ALLOC_PRAGMA) -#pragma alloc_text(INIT, PoInit) -#endif
extern ULONG ExpInitialiationPhase;
@@ -304,11 +300,10 @@ return Status; }
-VOID -INIT_FUNCTION -NTAPI -PoInit(IN ULONG BootPhase, - IN BOOLEAN HaveAcpiTable) +BOOLEAN +NTAPI +PoInitSystem(IN ULONG BootPhase, + IN BOOLEAN HaveAcpiTable) { PVOID NotificationEntry; PCHAR CommandLine; @@ -326,7 +321,7 @@ PopAddRemoveSysCapsCallback, NULL, &NotificationEntry); - return; + return TRUE; }
/* Get the Command Line */ @@ -348,6 +343,8 @@ /* Otherwise check the LoaderBlock's Flag */ PopAcpiPresent = HaveAcpiTable; } + + return TRUE; }
VOID
Modified: trunk/reactos/ntoskrnl/ps/psmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/psmgr.c?rev=256... ============================================================================== --- trunk/reactos/ntoskrnl/ps/psmgr.c (original) +++ trunk/reactos/ntoskrnl/ps/psmgr.c Thu Jan 25 04:13:09 2007 @@ -271,7 +271,7 @@
BOOLEAN NTAPI -PspInitPhase1(VOID) +PspInitPhase1() { /* Initialize the System DLL and return status of operation */ if (!NT_SUCCESS(PspInitializeSystemDll())) return FALSE; @@ -280,7 +280,7 @@
BOOLEAN NTAPI -PspInitPhase0(VOID) +PspInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { NTSTATUS Status; OBJECT_ATTRIBUTES ObjectAttributes; @@ -478,8 +478,8 @@ &ObjectAttributes, 0, NULL, - ExPhase2Init, - NULL); + Phase1Initialization, + LoaderBlock); if (!NT_SUCCESS(Status)) return FALSE;
/* Create a handle to it */ @@ -497,7 +497,7 @@
BOOLEAN NTAPI -PsInitSystem(VOID) +PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { /* Check the initialization phase */ switch (ExpInitializationPhase) @@ -505,7 +505,7 @@ case 0:
/* Do Phase 0 */ - return PspInitPhase0(); + return PspInitPhase0(LoaderBlock);
case 1:
@@ -515,7 +515,11 @@ default:
/* Don't know any other phase! Bugcheck! */ - KeBugCheck(UNEXPECTED_INITIALIZATION_CALL); + KeBugCheckEx(UNEXPECTED_INITIALIZATION_CALL, + 1, + ExpInitializationPhase, + 0, + 0); return FALSE; } }
Modified: trunk/reactos/ntoskrnl/se/semgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/semgr.c?rev=256... ============================================================================== --- trunk/reactos/ntoskrnl/se/semgr.c (original) +++ trunk/reactos/ntoskrnl/se/semgr.c Thu Jan 25 04:13:09 2007 @@ -20,58 +20,95 @@ 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 +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(); + if (!SepInitSecurityIDs()) return FALSE; + if (!SepInitDACLs()) return FALSE; + if (!SepInitSDs()) return FALSE; + SepInitPrivileges(); + if (!SepInitExports()) return FALSE; + + /* Initialize the subject context lock */ + ExInitializeResource(&SepSubjectContextLock); + + /* Initialize token objects */ + SepInitializeTokenImplementation(); + + /* Clear impersonation info for the idle thread */ + PsGetCurrentThread()->ImpersonationInfo = NULL; + PspClearCrossThreadFlag(PsGetCurrentThread(), + CT_ACTIVE_IMPERSONATION_INFO_BIT); + + /* Initialize the boot token */ + ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL); + ObInitializeFastReference(&PsGetCurrentProcess()->Token, + SepCreateSystemProcessToken()); + return TRUE; +} + +BOOLEAN +NTAPI +SepInitializationPhase1(VOID) +{ + NTSTATUS Status; + PAGED_CODE(); + + /* 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)); + + /* FIXME: TODO \ Security directory */ + return TRUE; +} + +BOOLEAN NTAPI SeInit(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(); - - if (!SepInitSecurityIDs()) - return FALSE; - - if (!SepInitDACLs()) - return FALSE; - - if (!SepInitSDs()) - return FALSE; - - SepInitPrivileges(); - - if (!SepInitExports()) - return FALSE; - - /* Initialize the subject context lock */ - ExInitializeResource(&SepSubjectContextLock); - - /* Initialize token objects */ - SepInitializeTokenImplementation(); - - /* Clear impersonation info for the idle thread */ - PsGetCurrentThread()->ImpersonationInfo = NULL; - PspClearCrossThreadFlag(PsGetCurrentThread(), CT_ACTIVE_IMPERSONATION_INFO_BIT); - - /* Initailize the boot token */ - ObInitializeFastReference(&PsGetCurrentProcess()->Token, NULL); - ObInitializeFastReference(&PsGetCurrentProcess()->Token, - SepCreateSystemProcessToken()); - return TRUE; + /* Check the initialization phase */ + switch (ExpInitializationPhase) + { + case 0: + + /* 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