diff --git a/reactos/ntoskrnl/cm/cm.h b/reactos/ntoskrnl/cm/cm.h index 83645854ce6..ffcd26cc284 100644 --- a/reactos/ntoskrnl/cm/cm.h +++ b/reactos/ntoskrnl/cm/cm.h @@ -531,4 +531,7 @@ CmiCopyPackedName(PWCHAR NameBuffer, PCHAR PackedNameBuffer, ULONG PackedNameSize); +VOID +CmiSyncHives(VOID); + #endif /*__INCLUDE_CM_H*/ diff --git a/reactos/ntoskrnl/cm/ntfunc.c b/reactos/ntoskrnl/cm/ntfunc.c index 7016c4e96f4..bb11ab4cb32 100644 --- a/reactos/ntoskrnl/cm/ntfunc.c +++ b/reactos/ntoskrnl/cm/ntfunc.c @@ -184,6 +184,8 @@ NtCreateKey(OUT PHANDLE KeyHandle, VERIFY_KEY_OBJECT(KeyObject); + CmiSyncHives(); + return Status; } @@ -229,6 +231,8 @@ NtDeleteKey(IN HANDLE KeyHandle) /* Release hive lock */ ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource); + CmiSyncHives(); + return STATUS_SUCCESS; } @@ -1487,6 +1491,8 @@ NtSetValueKey(IN HANDLE KeyHandle, ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource); ObDereferenceObject(KeyObject); + CmiSyncHives(); + DPRINT("Return Status 0x%X\n", Status); return(Status); @@ -1526,6 +1532,8 @@ NtDeleteValueKey(IN HANDLE KeyHandle, ObDereferenceObject(KeyObject); + CmiSyncHives(); + return Status; } diff --git a/reactos/ntoskrnl/cm/registry.c b/reactos/ntoskrnl/cm/registry.c index dbc039946c7..75901dbaca7 100644 --- a/reactos/ntoskrnl/cm/registry.c +++ b/reactos/ntoskrnl/cm/registry.c @@ -1,4 +1,4 @@ -/* $Id: registry.c,v 1.79 2002/11/30 14:46:27 ekohl Exp $ +/* $Id: registry.c,v 1.80 2002/12/02 18:52:44 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -37,6 +37,11 @@ KSPIN_LOCK CmiKeyListLock; LIST_ENTRY CmiHiveListHead; KSPIN_LOCK CmiHiveListLock; +volatile BOOLEAN CmiHiveSyncEnabled = FALSE; +volatile BOOLEAN CmiHiveSyncPending = FALSE; +KDPC CmiHiveSyncDpc; +KTIMER CmiHiveSyncTimer; + static PKEY_OBJECT CmiRootKey = NULL; static PKEY_OBJECT CmiMachineKey = NULL; static PKEY_OBJECT CmiUserKey = NULL; @@ -54,6 +59,12 @@ CmiCheckKey(BOOLEAN Verbose, static NTSTATUS CmiCreateCurrentControlSetLink(VOID); +static VOID STDCALL +CmiHiveSyncDpcRoutine(PKDPC Dpc, + PVOID DeferredContext, + PVOID SystemArgument1, + PVOID SystemArgument2); + /* FUNCTIONS ****************************************************************/ VOID @@ -901,7 +912,12 @@ CmiInitHives(BOOLEAN SetUpBoot) // CmiCheckRegistry(TRUE); - /* FIXME: Start automatic hive syncronization */ + /* Start automatic hive synchronization */ + KeInitializeDpc(&CmiHiveSyncDpc, + CmiHiveSyncDpcRoutine, + NULL); + KeInitializeTimer(&CmiHiveSyncTimer); + CmiHiveSyncEnabled = TRUE; DPRINT("CmiInitHives() done\n"); @@ -918,7 +934,8 @@ CmShutdownRegistry(VOID) DPRINT1("CmShutdownRegistry() called\n"); - /* FIXME: Stop automatic hive syncronization */ + /* Stop automatic hive synchronization */ + CmiHiveSyncEnabled = FALSE; KeAcquireSpinLock(&CmiHiveListLock,&oldlvl); Entry = CmiHiveListHead.Flink; @@ -928,11 +945,11 @@ CmShutdownRegistry(VOID) if (Hive->Flags & HIVE_VOLATILE) { - DPRINT1("Volatile hive\n"); + DPRINT("Volatile hive\n"); } else { - DPRINT1("Flush non-volatile hive '%wZ'\n", &Hive->Filename); + DPRINT("Flush non-volatile hive '%wZ'\n", &Hive->Filename); /* Flush non-volatile hive */ @@ -945,13 +962,41 @@ CmShutdownRegistry(VOID) } KeReleaseSpinLock(&CmiHiveListLock,oldlvl); -DPRINT1(" *** System stopped ***\n"); -for (;;); - /* Note: * Don't call UNIMPLEMENTED() here since this function is * called by NtShutdownSystem(). */ } + +static VOID STDCALL +CmiHiveSyncDpcRoutine(PKDPC Dpc, + PVOID DeferredContext, + PVOID SystemArgument1, + PVOID SystemArgument2) +{ + DPRINT("CmiHiveSyncDpcRoutine() called\n"); + + CmiHiveSyncPending = FALSE; +} + + +VOID +CmiSyncHives(VOID) +{ + LARGE_INTEGER Timeout; + + if (CmiHiveSyncEnabled == FALSE || + CmiHiveSyncPending == TRUE) + return; + + CmiHiveSyncPending = TRUE; + + + Timeout.QuadPart = -50000000LL; + KeSetTimer(&CmiHiveSyncTimer, + Timeout, + &CmiHiveSyncDpc); +} + /* EOF */