Skip to content

Commit

Permalink
[NTOS:CM] Add some more configuration options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
HBelusca committed Dec 14, 2024
1 parent 81d00fe commit 98df0eb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
21 changes: 21 additions & 0 deletions ntoskrnl/config/cmdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,27 @@ DATA_SEG("INITDATA") CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
NULL,
NULL
},
{
L"Session Manager\\Configuration Manager",
L"RegistryLazyFlushInterval",
&CmpLazyFlushIntervalInSeconds,
NULL,
NULL
},
{
L"Session Manager\\Configuration Manager",
L"RegistryLazyFlushHiveCount",
&CmpLazyFlushHiveCount,
NULL,
NULL
},
{
L"Session Manager\\Configuration Manager",
L"DelayCloseSize",
&CmpDelayedCloseSize,
NULL,
NULL
},
{
L"Session Manager\\Configuration Manager",
L"VolatileBoot",
Expand Down
4 changes: 2 additions & 2 deletions ntoskrnl/config/cmlazy.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BOOLEAN CmpLazyFlushPending;
BOOLEAN CmpForceForceFlush;
BOOLEAN CmpHoldLazyFlush = TRUE;
ULONG CmpLazyFlushIntervalInSeconds = 5;
static ULONG CmpLazyFlushHiveCount = 7;
ULONG CmpLazyFlushHiveCount = 7;
ULONG CmpLazyFlushCount = 1;
LONG CmpFlushStarveWriters;

Expand Down Expand Up @@ -60,7 +60,7 @@ CmpDoFlushNextHive(_In_ BOOLEAN ForceFlush,
if (!(CmHive->Hive.HiveFlags & HIVE_NOLAZYFLUSH) &&
(CmHive->FlushCount != CmpLazyFlushCount))
{
/* Great sucess! */
/* Great success! */
Result = TRUE;

/* One less to flush */
Expand Down
4 changes: 3 additions & 1 deletion ntoskrnl/include/internal/cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1460,14 +1460,16 @@ extern HANDLE CmpRegistryRootHandle;
extern BOOLEAN ExpInTextModeSetup;
extern BOOLEAN InitIsWinPEMode;
extern ULONG CmpHashTableSize;
extern ULONG CmpDelayedCloseSize, CmpDelayedCloseIndex;
extern ULONG CmpDelayedCloseSize;
extern BOOLEAN CmpNoWrite;
extern BOOLEAN CmpForceForceFlush;
extern BOOLEAN CmpWasSetupBoot;
extern BOOLEAN CmpProfileLoaded;
extern PCMHIVE CmiVolatileHive;
extern LIST_ENTRY CmiKeyObjectListHead;
extern BOOLEAN CmpHoldLazyFlush;
extern ULONG CmpLazyFlushIntervalInSeconds;
extern ULONG CmpLazyFlushHiveCount;
extern BOOLEAN HvShutdownComplete;

//
Expand Down

0 comments on commit 98df0eb

Please sign in to comment.