From 3a7d34ee38cd292c3589b6fab9b369518235567b Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 29 Jun 2015 18:26:56 +0000 Subject: [PATCH] [NTOSKRNL] Add CmpDestroySecurityCache() and CmpDestroyHiveViewList() stubs and call them in CmpDestroyHive and CmUnloadKey(). CORE-6492 #resolve #comment Thank you Hermes! This is exactly what I needed! svn path=/trunk/; revision=68313 --- reactos/ntoskrnl/config/cmapi.c | 6 ++- reactos/ntoskrnl/config/cminit.c | 6 +++ reactos/ntoskrnl/config/cmmapvw.c | 51 ++++++++++++++++++++++++++ reactos/ntoskrnl/config/cmsecach.c | 15 ++++++++ reactos/ntoskrnl/include/internal/cm.h | 12 ++++++ 5 files changed, 89 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/config/cmapi.c b/reactos/ntoskrnl/config/cmapi.c index 869a6768ec6..e2e1f6a9a40 100644 --- a/reactos/ntoskrnl/config/cmapi.c +++ b/reactos/ntoskrnl/config/cmapi.c @@ -2241,7 +2241,11 @@ CmUnloadKey(IN PCM_KEY_CONTROL_BLOCK Kcb, /* Remove the hive from the hive file list */ CmpRemoveFromHiveFileList(CmHive); - /* FIXME: More cleanup */ + /* Destroy the security descriptor cache */ + CmpDestroySecurityCache(CmHive); + + /* Destroy the view list */ + CmpDestroyHiveViewList(CmHive); /* Free the hive storage */ HvFree(Hive); diff --git a/reactos/ntoskrnl/config/cminit.c b/reactos/ntoskrnl/config/cminit.c index 7b542c1b338..dea23111ef8 100644 --- a/reactos/ntoskrnl/config/cminit.c +++ b/reactos/ntoskrnl/config/cminit.c @@ -257,6 +257,12 @@ CmpDestroyHive(IN PCMHIVE CmHive) /* Delete the view lock */ ExFreePoolWithTag(CmHive->ViewLock, TAG_CM); + /* Destroy the security descriptor cache */ + CmpDestroySecurityCache(CmHive); + + /* Destroy the view list */ + CmpDestroyHiveViewList(CmHive); + /* Free the hive storage */ HvFree(&CmHive->Hive); diff --git a/reactos/ntoskrnl/config/cmmapvw.c b/reactos/ntoskrnl/config/cmmapvw.c index 7314eaed817..d223d2fd08c 100644 --- a/reactos/ntoskrnl/config/cmmapvw.c +++ b/reactos/ntoskrnl/config/cmmapvw.c @@ -29,3 +29,54 @@ CmpInitHiveViewList(IN PCMHIVE Hive) Hive->PinnedViews = 0; Hive->UseCount = 0; } + +VOID +NTAPI +CmpDestroyHiveViewList(IN PCMHIVE Hive) +{ + PCM_VIEW_OF_FILE CmView; + PLIST_ENTRY EntryList; + + /* Do NOT destroy the views of read-only hives */ + ASSERT(Hive->Hive.ReadOnly == FALSE); + + /* Free all the views inside the Pinned View List */ + EntryList = RemoveHeadList(&Hive->PinViewListHead); + while (EntryList != &Hive->PinViewListHead) + { + CmView = CONTAINING_RECORD(EntryList, CM_VIEW_OF_FILE, PinViewList); + + /* FIXME: Unmap the view if it is mapped */ + + ExFreePool(CmView); + + Hive->PinnedViews--; + + EntryList = RemoveHeadList(&Hive->PinViewListHead); + } + + /* The Pinned View List should be empty */ + ASSERT(IsListEmpty(&Hive->PinViewListHead) == TRUE); + ASSERT(Hive->PinnedViews == 0); + + /* Now, free all the views inside the LRU View List */ + EntryList = RemoveHeadList(&Hive->LRUViewListHead); + while (EntryList != &Hive->LRUViewListHead) + { + CmView = CONTAINING_RECORD(EntryList, CM_VIEW_OF_FILE, LRUViewList); + + /* FIXME: Unmap the view if it is mapped */ + + ExFreePool(CmView); + + Hive->MappedViews--; + + EntryList = RemoveHeadList(&Hive->LRUViewListHead); + } + + /* The LRU View List should be empty */ + ASSERT(IsListEmpty(&Hive->LRUViewListHead) == TRUE); + ASSERT(Hive->MappedViews == 0); +} + +/* EOF */ diff --git a/reactos/ntoskrnl/config/cmsecach.c b/reactos/ntoskrnl/config/cmsecach.c index 872ede571c6..69236c09886 100644 --- a/reactos/ntoskrnl/config/cmsecach.c +++ b/reactos/ntoskrnl/config/cmsecach.c @@ -35,3 +35,18 @@ CmpInitSecurityCache(IN PCMHIVE Hive) InitializeListHead(&Hive->SecurityHash[i]); } } + +VOID +NTAPI +CmpDestroySecurityCache(IN PCMHIVE Hive) +{ + /* FIXME: clean Hive->SecurityHash and/or Hive->SecurityCache */ + + /* Reset data */ + Hive->SecurityCount = 0; + Hive->SecurityCacheSize = 0; + Hive->SecurityHitHint = -1; + Hive->SecurityCache = NULL; +} + +/* EOF */ diff --git a/reactos/ntoskrnl/include/internal/cm.h b/reactos/ntoskrnl/include/internal/cm.h index d991869bdb7..0647c5959c4 100644 --- a/reactos/ntoskrnl/include/internal/cm.h +++ b/reactos/ntoskrnl/include/internal/cm.h @@ -552,6 +552,12 @@ CmpInitHiveViewList( IN PCMHIVE Hive ); +VOID +NTAPI +CmpDestroyHiveViewList( + IN PCMHIVE Hive +); + // // Security Cache Functions // @@ -561,6 +567,12 @@ CmpInitSecurityCache( IN PCMHIVE Hive ); +VOID +NTAPI +CmpDestroySecurityCache( + IN PCMHIVE Hive +); + // // Value Cache Functions // -- 2.17.1