- 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.

svn path=/trunk/; revision=30966
This commit is contained in:
Aleksey Bragin 2007-12-02 18:40:33 +00:00
parent 2d7e275751
commit cff82f4686
6 changed files with 86 additions and 29 deletions

View file

@ -3197,7 +3197,7 @@ RegistryPage(PINPUT_RECORD Ir)
/* 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);

View file

@ -35,7 +35,7 @@ SmInitializeRegistry(VOID)
DPRINT("SM: %s: initializing registry\n", __FUNCTION__);
/* Load remaining registry hives */
return NtInitializeRegistry(FALSE);
return NtInitializeRegistry(CM_BOOT_FLAG_SMSS);
}
/* EOF */

View file

@ -110,6 +110,14 @@ typedef enum _CM_SHARE_DISPOSITION
#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 @@ typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA
#endif // _CMTYPES_H

View file

@ -30,8 +30,6 @@ CmpCreateHandle(PVOID ObjectBody,
ULONG HandleAttributes,
PHANDLE HandleReturn);
static BOOLEAN CmiRegistryInitialized = FALSE;
/* FUNCTIONS ****************************************************************/
NTSTATUS
@ -284,22 +282,4 @@ openkey_cleanup:
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 */

View file

@ -1353,6 +1353,15 @@ CmQueryValueKey(
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 CmpForceForceFlush;
extern BOOLEAN CmpWasSetupBoot;
extern PCMHIVE CmiVolatileHive;
extern LIST_ENTRY CmiKeyObjectListHead;
extern BOOLEAN CmpHoldLazyFlush;
//
// Inlined functions

View file

@ -13,6 +13,9 @@
#define NDEBUG
#include "debug.h"
BOOLEAN CmBootAcceptFirstTime = TRUE;
BOOLEAN CmFirstTime = TRUE;
/* FUNCTIONS *****************************************************************/
NTSTATUS
@ -501,13 +504,6 @@ NtLoadKey2(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
return NtLoadKeyEx(KeyObjectAttributes, FileObjectAttributes, Flags, NULL);
}
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,
@ -559,6 +555,68 @@ NtLoadKeyEx(IN POBJECT_ATTRIBUTES TargetKey,
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
NTAPI
NtLockProductActivationKeys(IN PULONG pPrivateVer,