https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2ed65d15557489e8e9ee7ca0cfd8901cdf5f8efd

commit 2ed65d15557489e8e9ee7ca0cfd8901cdf5f8efd
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Fri Jun 2 15:47:52 2017 +0000
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Thu Oct 25 00:40:02 2018 +0200

    [NTOS] Configuration Manager fixes.
    
    - Rework CmpSetSystemValues() and remove its 1st-stage text-mode setup 
hack, since a real registry hive will be used for 1st-stage either.
    - Lock, then unlock the registry in NtInitializeRegistry when initializing 
the hives & flusher.
    - Call CmpInitializeHiveList() (i.e., initialize the other hives like 
\Software, \User, \.Default) only when we are not in setup-mode.
    
    svn path=/branches/setup_improvements/; revision=74747
---
 ntoskrnl/config/cmlazy.c       |  5 +++--
 ntoskrnl/config/cmsysini.c     | 27 ++++++++++++++-------------
 ntoskrnl/config/ntapi.c        |  9 +++++----
 ntoskrnl/ex/init.c             |  3 ++-
 ntoskrnl/include/internal/cm.h |  2 +-
 5 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/ntoskrnl/config/cmlazy.c b/ntoskrnl/config/cmlazy.c
index 0b19924216..8093c61bd5 100644
--- a/ntoskrnl/config/cmlazy.c
+++ b/ntoskrnl/config/cmlazy.c
@@ -262,8 +262,9 @@ CmpCmdInit(IN BOOLEAN SetupBoot)
     /* Testing: Force Lazy Flushing */
     CmpHoldLazyFlush = FALSE;
 
-    /* Setup the hive list */
-    CmpInitializeHiveList(SetupBoot);
+    /* Setup the hive list if this is not a Setup boot */
+    if (!SetupBoot)
+        CmpInitializeHiveList();
 }
 
 NTSTATUS
diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c
index ca198833a4..f49c07acd1 100644
--- a/ntoskrnl/config/cmsysini.c
+++ b/ntoskrnl/config/cmsysini.c
@@ -396,10 +396,11 @@ NTAPI
 INIT_FUNCTION
 CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
+    NTSTATUS Status;
     OBJECT_ATTRIBUTES ObjectAttributes;
+    HANDLE KeyHandle;
     UNICODE_STRING KeyName, ValueName = { 0, 0, NULL };
-    HANDLE KeyHandle = NULL;
-    NTSTATUS Status;
+
     ASSERT(LoaderBlock != NULL);
 
     /* Setup attributes for loader options */
@@ -412,9 +413,10 @@ CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
                                NULL,
                                NULL);
     Status = NtOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes);
-    if (!NT_SUCCESS(Status)) goto Quickie;
+    if (!NT_SUCCESS(Status))
+        return Status;
 
-    /* Key opened, now write to the key */
+    /* Setup the value for the system start options */
     RtlInitUnicodeString(&KeyName, L"SystemStartOptions");
     Status = NtSetValueKey(KeyHandle,
                            &KeyName,
@@ -422,9 +424,10 @@ CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
                            REG_SZ,
                            CmpLoadOptions.Buffer,
                            CmpLoadOptions.Length);
-    if (!NT_SUCCESS(Status)) goto Quickie;
+    if (!NT_SUCCESS(Status))
+        goto Quit;
 
-    /* Setup value name for system boot device in ARC format */
+    /* Setup the value for the system boot device in ARC format */
     RtlInitUnicodeString(&KeyName, L"SystemBootDevice");
     RtlCreateUnicodeStringFromAsciiz(&ValueName, 
LoaderBlock->ArcBootDeviceName);
     Status = NtSetValueKey(KeyHandle,
@@ -434,15 +437,13 @@ CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
                            ValueName.Buffer,
                            ValueName.Length);
 
-Quickie:
-    /* Free the buffers */
+    /* Free the temporary string */
     RtlFreeUnicodeString(&ValueName);
 
+Quit:
     /* Close the key and return */
-    if (KeyHandle) NtClose(KeyHandle);
-
-    /* Return the status */
-    return (ExpInTextModeSetup ? STATUS_SUCCESS : Status);
+    NtClose(KeyHandle);
+    return Status;
 }
 
 static
@@ -1409,7 +1410,7 @@ CmpLoadHiveThread(IN PVOID StartContext)
 
 VOID
 NTAPI
-CmpInitializeHiveList(IN USHORT Flag)
+CmpInitializeHiveList(VOID)
 {
     WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH];
     UNICODE_STRING TempName, FileName, RegName;
diff --git a/ntoskrnl/config/ntapi.c b/ntoskrnl/config/ntapi.c
index 5be3a279d8..f3137ce861 100644
--- a/ntoskrnl/config/ntapi.c
+++ b/ntoskrnl/config/ntapi.c
@@ -1302,7 +1302,8 @@ NtInitializeRegistry(IN USHORT Flag)
     PAGED_CODE();
 
     /* Always do this as kernel mode */
-    if (KeGetPreviousMode() == UserMode) return ZwInitializeRegistry(Flag);
+    if (KeGetPreviousMode() == UserMode)
+        return ZwInitializeRegistry(Flag);
 
     /* Enough of the system has booted by now */
     Ki386PerfEnd();
@@ -1344,8 +1345,8 @@ NtInitializeRegistry(IN USHORT Flag)
     if (!CmFirstTime) return STATUS_ACCESS_DENIED;
     CmFirstTime = FALSE;
 
-    /* Acquire registry lock */
-    //CmpLockRegistryExclusive();
+    /* Lock the registry exclusively */
+    CmpLockRegistryExclusive();
 
     /* Initialize the hives and lazy flusher */
     CmpCmdInit(SetupBoot);
@@ -1354,7 +1355,7 @@ NtInitializeRegistry(IN USHORT Flag)
     CmpSetVersionData();
 
     /* Release the registry lock */
-    //CmpUnlockRegistry();
+    CmpUnlockRegistry();
     return STATUS_SUCCESS;
 }
 
diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c
index 1e9a9c07f8..66819c56c8 100644
--- a/ntoskrnl/ex/init.c
+++ b/ntoskrnl/ex/init.c
@@ -963,7 +963,8 @@ ExpInitializeExecutive(IN ULONG Cpu,
     if (LoaderBlock->SetupLdrBlock)
     {
         /* Check if this is text-mode setup */
-        if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE) 
ExpInTextModeSetup = TRUE;
+        if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_TEXT_MODE)
+            ExpInTextModeSetup = TRUE;
 
         /* Check if this is network boot */
         if (LoaderBlock->SetupLdrBlock->Flags & SETUPLDR_REMOTE_BOOT)
diff --git a/ntoskrnl/include/internal/cm.h b/ntoskrnl/include/internal/cm.h
index 12ccb1c8bb..c2900b2314 100644
--- a/ntoskrnl/include/internal/cm.h
+++ b/ntoskrnl/include/internal/cm.h
@@ -859,7 +859,7 @@ CmpInitHiveFromFile(
 VOID
 NTAPI
 CmpInitializeHiveList(
-    IN USHORT Flag
+    VOID
 );
 
 //

Reply via email to