diff --git a/reactos/lib/cmlib/hiveinit.c b/reactos/lib/cmlib/hiveinit.c index 7aed3d6fda2..9463d6d2725 100644 --- a/reactos/lib/cmlib/hiveinit.c +++ b/reactos/lib/cmlib/hiveinit.c @@ -529,6 +529,7 @@ HvInitialize( * @name HvFree * * Free all stroage and handles associated with hive descriptor. + * But do not free the hive descriptor itself. */ VOID CMAPI @@ -544,9 +545,14 @@ HvFree( } HvpFreeHiveBins(RegistryHive); - } - RegistryHive->Free(RegistryHive, 0); + /* Free the BaseBlock */ + if (RegistryHive->BaseBlock) + { + RegistryHive->Free(RegistryHive->BaseBlock, 0); + RegistryHive->BaseBlock = NULL; + } + } } /* EOF */ diff --git a/reactos/ntoskrnl/config/cmapi.c b/reactos/ntoskrnl/config/cmapi.c index e862b1da525..869a6768ec6 100644 --- a/reactos/ntoskrnl/config/cmapi.c +++ b/reactos/ntoskrnl/config/cmapi.c @@ -2241,7 +2241,20 @@ CmUnloadKey(IN PCM_KEY_CONTROL_BLOCK Kcb, /* Remove the hive from the hive file list */ CmpRemoveFromHiveFileList(CmHive); - /* FIXME: Destroy the hive */ + /* FIXME: More cleanup */ + + /* Free the hive storage */ + HvFree(Hive); + + /* Delete the flusher lock */ + ExDeleteResourceLite(CmHive->FlusherLock); + ExFreePoolWithTag(CmHive->FlusherLock, TAG_CM); + + /* Delete the view lock */ + ExFreePoolWithTag(CmHive->ViewLock, TAG_CM); + + /* Free the hive */ + CmpFree(CmHive, TAG_CM); return STATUS_SUCCESS; } diff --git a/reactos/ntoskrnl/config/cminit.c b/reactos/ntoskrnl/config/cminit.c index bf23d20750a..7b542c1b338 100644 --- a/reactos/ntoskrnl/config/cminit.c +++ b/reactos/ntoskrnl/config/cminit.c @@ -257,9 +257,12 @@ CmpDestroyHive(IN PCMHIVE CmHive) /* Delete the view lock */ ExFreePoolWithTag(CmHive->ViewLock, TAG_CM); - /* Free the hive */ + /* Free the hive storage */ HvFree(&CmHive->Hive); + /* Free the hive */ + CmpFree(CmHive, TAG_CM); + return STATUS_SUCCESS; }