Skip to content

Commit a184242

Browse files
committed
[NTOS:CM] Add some more configuration options.
Add support for configuring the CM lazy-flush and delay-close variables: `CmpLazyFlushIntervalInSeconds`, `CmpLazyFlushHiveCount`, and `CmpDelayedCloseSize`, using REG_DWORD values named respectively: `RegistryLazyFlushInterval`, `RegistryLazyFlushHiveCount`, and `DelayCloseSize`, in the registry key `HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Configuration Manager` . Extra observations: - While delay-close support exists in Windows 2003, configuring the delay-close size is possible only in Windows Vista and later. - The possibility of configuring the lazy-flush hive count has been removed in Windows 8+. See the comparison tables at: https://redplait.blogspot.com/2011/07/cmcontrolvector.html https://redplait.blogspot.com/2012/06/cmcontrolvector-for-w8.html https://redplait.blogspot.com/2016/03/cmcontrolvector-from-windows-10-build.html In addition: Remove `CmpDelayedCloseIndex` from cm.h as it is not used anymore in our code.
1 parent d44ed03 commit a184242

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

ntoskrnl/config/cmdata.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,27 @@ DATA_SEG("INITDATA") CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
675675
NULL,
676676
NULL
677677
},
678+
{
679+
L"Session Manager\\Configuration Manager",
680+
L"RegistryLazyFlushInterval",
681+
&CmpLazyFlushIntervalInSeconds,
682+
NULL,
683+
NULL
684+
},
685+
{
686+
L"Session Manager\\Configuration Manager",
687+
L"RegistryLazyFlushHiveCount",
688+
&CmpLazyFlushHiveCount,
689+
NULL,
690+
NULL
691+
},
692+
{
693+
L"Session Manager\\Configuration Manager",
694+
L"DelayCloseSize",
695+
&CmpDelayedCloseSize,
696+
NULL,
697+
NULL
698+
},
678699
{
679700
L"Session Manager\\Configuration Manager",
680701
L"VolatileBoot",

ntoskrnl/config/cmlazy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ BOOLEAN CmpLazyFlushPending;
2222
BOOLEAN CmpForceForceFlush;
2323
BOOLEAN CmpHoldLazyFlush = TRUE;
2424
ULONG CmpLazyFlushIntervalInSeconds = 5;
25-
static ULONG CmpLazyFlushHiveCount = 7;
25+
ULONG CmpLazyFlushHiveCount = 7;
2626
ULONG CmpLazyFlushCount = 1;
2727
LONG CmpFlushStarveWriters;
2828

@@ -60,7 +60,7 @@ CmpDoFlushNextHive(_In_ BOOLEAN ForceFlush,
6060
if (!(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH) &&
6161
(CmHive->FlushCount != CmpLazyFlushCount))
6262
{
63-
/* Great sucess! */
63+
/* Great success! */
6464
Result = TRUE;
6565

6666
/* One less to flush */
@@ -80,7 +80,7 @@ CmpDoFlushNextHive(_In_ BOOLEAN ForceFlush,
8080
DPRINT("Flushing: %wZ\n", &CmHive->FileFullPath);
8181
DPRINT("Handle: %p\n", CmHive->FileHandles[HFILE_TYPE_PRIMARY]);
8282
Status = HvSyncHive(&CmHive->Hive);
83-
if(!NT_SUCCESS(Status))
83+
if (!NT_SUCCESS(Status))
8484
{
8585
/* Let them know we failed */
8686
DPRINT1("Failed to flush %wZ on handle %p (status 0x%08lx)\n",

ntoskrnl/include/internal/cm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,14 +1460,16 @@ extern HANDLE CmpRegistryRootHandle;
14601460
extern BOOLEAN ExpInTextModeSetup;
14611461
extern BOOLEAN InitIsWinPEMode;
14621462
extern ULONG CmpHashTableSize;
1463-
extern ULONG CmpDelayedCloseSize, CmpDelayedCloseIndex;
1463+
extern ULONG CmpDelayedCloseSize;
14641464
extern BOOLEAN CmpNoWrite;
14651465
extern BOOLEAN CmpForceForceFlush;
14661466
extern BOOLEAN CmpWasSetupBoot;
14671467
extern BOOLEAN CmpProfileLoaded;
14681468
extern PCMHIVE CmiVolatileHive;
14691469
extern LIST_ENTRY CmiKeyObjectListHead;
14701470
extern BOOLEAN CmpHoldLazyFlush;
1471+
extern ULONG CmpLazyFlushIntervalInSeconds;
1472+
extern ULONG CmpLazyFlushHiveCount;
14711473
extern BOOLEAN HvShutdownComplete;
14721474

14731475
//

0 commit comments

Comments
 (0)