Author: fireball
Date: Sun Dec 2 21:40:33 2007
New Revision: 30966
URL:
http://svn.reactos.org/svn/reactos?rev=30966&view=rev
Log:
- Implement NtInitalizeRegistry with proper boot flags instead of TRUE/FALSE (our winlogon
doesn't yet call the function with the CM_BOOT_FLAG_ACCEPTED_X flag-- this is needed
to support setting the last known good boot/current control set).
- Always set last mode to kernel-mode when calling this function.
Modified:
trunk/reactos/base/setup/usetup/interface/usetup.c
trunk/reactos/base/system/smss/initreg.c
trunk/reactos/include/ndk/cmtypes.h
trunk/reactos/ntoskrnl/cm/ntfunc.c
trunk/reactos/ntoskrnl/config/cm.h
trunk/reactos/ntoskrnl/config/ntapi.c
Modified: trunk/reactos/base/setup/usetup/interface/usetup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interfac…
==============================================================================
--- trunk/reactos/base/setup/usetup/interface/usetup.c (original)
+++ trunk/reactos/base/setup/usetup/interface/usetup.c Sun Dec 2 21:40:33 2007
@@ -3197,7 +3197,7 @@
/* Create the default hives */
#ifdef __REACTOS__
- Status = NtInitializeRegistry(TRUE);
+ Status = NtInitializeRegistry(CM_BOOT_FLAG_SETUP);
if (!NT_SUCCESS(Status))
{
DPRINT("NtInitializeRegistry() failed (Status %lx)\n", Status);
Modified: trunk/reactos/base/system/smss/initreg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/smss/initreg.c…
==============================================================================
--- trunk/reactos/base/system/smss/initreg.c (original)
+++ trunk/reactos/base/system/smss/initreg.c Sun Dec 2 21:40:33 2007
@@ -35,7 +35,7 @@
DPRINT("SM: %s: initializing registry\n", __FUNCTION__);
/* Load remaining registry hives */
- return NtInitializeRegistry(FALSE);
+ return NtInitializeRegistry(CM_BOOT_FLAG_SMSS);
}
/* EOF */
Modified: trunk/reactos/include/ndk/cmtypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/cmtypes.h?rev=…
==============================================================================
--- trunk/reactos/include/ndk/cmtypes.h (original)
+++ trunk/reactos/include/ndk/cmtypes.h Sun Dec 2 21:40:33 2007
@@ -110,6 +110,14 @@
#define CM_RESOURCE_DMA_TYPE_B 0x0020
#define CM_RESOURCE_DMA_TYPE_F 0x0040
+//
+// NtInitializeRegistry Flags
+//
+#define CM_BOOT_FLAG_SMSS 0x0000
+#define CM_BOOT_FLAG_SETUP 0x0001
+#define CM_BOOT_FLAG_ACCEPTED 0x0002
+#define CM_BOOT_FLAG_MAX 0x03E9
+
#ifdef NTOS_MODE_USER
//
@@ -510,3 +518,4 @@
#endif // _CMTYPES_H
+
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/cm/ntfunc.c (original)
+++ trunk/reactos/ntoskrnl/cm/ntfunc.c Sun Dec 2 21:40:33 2007
@@ -29,8 +29,6 @@
ACCESS_MASK GrantedAccess,
ULONG HandleAttributes,
PHANDLE HandleReturn);
-
-static BOOLEAN CmiRegistryInitialized = FALSE;
/* FUNCTIONS ****************************************************************/
@@ -284,22 +282,4 @@
return Status;
}
-NTSTATUS
-NTAPI
-NtInitializeRegistry (IN USHORT Flag)
-{
- PAGED_CODE();
-
- if (CmiRegistryInitialized == TRUE)
- return STATUS_ACCESS_DENIED;
-
- /* Save boot log file */
- IopSaveBootLogToFile();
-
- CmpCmdInit(Flag);
- CmiRegistryInitialized = TRUE;
-
- return STATUS_SUCCESS;
-}
-
/* EOF */
Modified: trunk/reactos/ntoskrnl/config/cm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cm.h?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/config/cm.h (original)
+++ trunk/reactos/ntoskrnl/config/cm.h Sun Dec 2 21:40:33 2007
@@ -1353,6 +1353,15 @@
IN PULONG ResultLength
);
+NTSTATUS
+NTAPI
+CmLoadKey(
+ IN POBJECT_ATTRIBUTES TargetKey,
+ IN POBJECT_ATTRIBUTES SourceFile,
+ IN ULONG Flags,
+ IN PKEY_OBJECT KeyBody
+);
+
//
// Startup and Shutdown
//
@@ -1406,6 +1415,7 @@
extern BOOLEAN CmpWasSetupBoot;
extern PCMHIVE CmiVolatileHive;
extern LIST_ENTRY CmiKeyObjectListHead;
+extern BOOLEAN CmpHoldLazyFlush;
//
// Inlined functions
Modified: trunk/reactos/ntoskrnl/config/ntapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/ntapi.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/config/ntapi.c (original)
+++ trunk/reactos/ntoskrnl/config/ntapi.c Sun Dec 2 21:40:33 2007
@@ -12,6 +12,9 @@
#include "cm.h"
#define NDEBUG
#include "debug.h"
+
+BOOLEAN CmBootAcceptFirstTime = TRUE;
+BOOLEAN CmFirstTime = TRUE;
/* FUNCTIONS *****************************************************************/
@@ -503,13 +506,6 @@
NTSTATUS
NTAPI
-CmLoadKey(IN POBJECT_ATTRIBUTES TargetKey,
- IN POBJECT_ATTRIBUTES SourceFile,
- IN ULONG Flags,
- IN PKEY_OBJECT KeyBody);
-
-NTSTATUS
-NTAPI
NtLoadKeyEx(IN POBJECT_ATTRIBUTES TargetKey,
IN POBJECT_ATTRIBUTES SourceFile,
IN ULONG Flags,
@@ -557,6 +553,68 @@
/* Return status */
return Status;
+}
+
+NTSTATUS
+NTAPI
+NtInitializeRegistry(IN USHORT Flag)
+{
+ BOOLEAN SetupBoot;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PAGED_CODE();
+
+ /* Always do this as kernel mode */
+ if (KeGetPreviousMode() == UserMode) return ZwInitializeRegistry(Flag);
+
+ /* Validate flag */
+ if (Flag > CM_BOOT_FLAG_MAX) return STATUS_INVALID_PARAMETER;
+
+ /* Check if boot was accepted */
+ if ((Flag >= CM_BOOT_FLAG_ACCEPTED) && (Flag <= CM_BOOT_FLAG_MAX))
+ {
+ /* Only allow once */
+ if (!CmBootAcceptFirstTime) return STATUS_ACCESS_DENIED;
+ CmBootAcceptFirstTime = FALSE;
+
+ /* Get the control set accepted */
+ Flag -= CM_BOOT_FLAG_ACCEPTED;
+ if (Flag)
+ {
+ /* FIXME: Save the last known good boot */
+ //Status = CmpSaveBootControlSet(Flag);
+
+ /* Notify HAL */
+ HalEndOfBoot();
+
+ /* Enable lazy flush */
+ CmpHoldLazyFlush = FALSE;
+ CmpLazyFlush();
+ return Status;
+ }
+
+ /* Otherwise, invalid boot */
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Check if this was a setup boot */
+ SetupBoot = (Flag == CM_BOOT_FLAG_SETUP ? TRUE : FALSE);
+
+ /* Make sure we're only called once */
+ if (!CmFirstTime) return STATUS_ACCESS_DENIED;
+ CmFirstTime = FALSE;
+
+ /* Acquire registry lock */
+ //CmpLockRegistryExclusive();
+
+ /* Initialize the hives and lazy flusher */
+ CmpCmdInit(SetupBoot);
+
+ /* FIXME: Save version data */
+ //CmpSetVersionData();
+
+ /* Release the registry lock */
+ //CmpUnlockRegistry();
+ return STATUS_SUCCESS;
}
NTSTATUS