https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0d776beac91f215a324d069477090cb9708dfcd7

commit 0d776beac91f215a324d069477090cb9708dfcd7
Author:     George Bișoc <[email protected]>
AuthorDate: Wed Oct 26 18:51:09 2022 +0200
Commit:     George Bișoc <[email protected]>
CommitDate: Sun Nov 19 20:44:26 2023 +0100

    [NTOS:CM] Ignore syncing/flushing requests after registry shutdown
    
    When shutting down the registry of the system we don't want that the 
registry in question gets poked again, such as flushing the hives or syncing 
the hives and respective logs for example. The reasoning behind this is very 
simple, during a complete shutdown the system does final check-ups and stuff 
until the computer
    shuts down.
    
    Any writing operations done to the registry can lead to erratic behaviors. 
CmShutdownSystem call already invokes a final flushing of all the hives on the 
backing storage which is more than enough to ensure consistency of the last 
session configuration. So after that final flushing, mark HvShutdownComplete as 
TRUE indicating
    that any eventual flushing or syncying (in the case where HvSyncHive gets 
called) request is outright ignored.
---
 ntoskrnl/config/cmsysini.c     | 10 +++++++++-
 ntoskrnl/include/internal/cm.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c
index 32450c366a6..0e3a647de66 100644
--- a/ntoskrnl/config/cmsysini.c
+++ b/ntoskrnl/config/cmsysini.c
@@ -21,7 +21,6 @@ LIST_ENTRY CmpSelfHealQueueListHead;
 KEVENT CmpLoadWorkerEvent;
 LONG CmpLoadWorkerIncrement;
 PEPROCESS CmpSystemProcess;
-BOOLEAN HvShutdownComplete;
 PVOID CmpRegistryLockCallerCaller, CmpRegistryLockCaller;
 BOOLEAN CmpFlushOnLockRelease;
 BOOLEAN CmpSpecialBootCondition;
@@ -30,6 +29,7 @@ BOOLEAN CmpWasSetupBoot;
 BOOLEAN CmpProfileLoaded;
 BOOLEAN CmpNoVolatileCreates;
 ULONG CmpTraceLevel = 0;
+BOOLEAN HvShutdownComplete = FALSE;
 
 extern LONG CmpFlushStarveWriters;
 extern BOOLEAN CmFirstTime;
@@ -2049,6 +2049,14 @@ CmShutdownSystem(VOID)
         ListEntry = ListEntry->Flink;
     }
 
+    /*
+     * As we flushed all the hives on the disk,
+     * tell the system we do not want any further
+     * registry flushing or syncing at this point
+     * since we are shutting down the registry anyway.
+     */
+    HvShutdownComplete = TRUE;
+
     CmpUnlockRegistry();
 }
 
diff --git a/ntoskrnl/include/internal/cm.h b/ntoskrnl/include/internal/cm.h
index db702bd8b28..e8fee77faf4 100644
--- a/ntoskrnl/include/internal/cm.h
+++ b/ntoskrnl/include/internal/cm.h
@@ -1473,6 +1473,7 @@ extern BOOLEAN CmpProfileLoaded;
 extern PCMHIVE CmiVolatileHive;
 extern LIST_ENTRY CmiKeyObjectListHead;
 extern BOOLEAN CmpHoldLazyFlush;
+extern BOOLEAN HvShutdownComplete;
 
 //
 // Inlined functions

Reply via email to