[NTOS:CM]
authorThomas Faber <thomas.faber@reactos.org>
Fri, 18 Sep 2015 09:25:58 +0000 (09:25 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Fri, 18 Sep 2015 09:25:58 +0000 (09:25 +0000)
- Improve pool tagging

svn path=/trunk/; revision=69262

reactos/lib/cmlib/cmlib.h
reactos/ntoskrnl/config/cmalloc.c
reactos/ntoskrnl/config/cmapi.c
reactos/ntoskrnl/config/cminit.c
reactos/ntoskrnl/config/cmse.c
reactos/ntoskrnl/config/cmsysini.c

index ec784b7..c6b1c46 100644 (file)
 #endif
 #endif
 
-#define TAG_CM 'CM25'
+#define TAG_CM     '  MC'
+#define TAG_KCB    'bkMC'
+#define TAG_CMHIVE 'vHMC'
+#define TAG_CMSD   'DSMC'
 
 #define CMAPI NTAPI
 
index 6502883..e32712c 100644 (file)
@@ -64,7 +64,7 @@ CmpFreeKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
     if (!Kcb->PrivateAlloc)
     {
         /* Free it from the pool */
-        CmpFree(Kcb, 0);
+        CmpFree(Kcb, TAG_KCB);
         return;
     }
     
@@ -99,7 +99,7 @@ CmpFreeKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
         }
         
         /* Free the page */
-        CmpFree(AllocPage, 0);
+        CmpFree(AllocPage, TAG_KCB);
     }
     
     /* Release the lock */
@@ -152,7 +152,7 @@ SearchKcbList:
         }
         
         /* Allocate an allocation page */
-        AllocPage = CmpAllocate(PAGE_SIZE, TRUE, TAG_CM);
+        AllocPage = CmpAllocate(PAGE_SIZE, TRUE, TAG_KCB);
         if (AllocPage)
         {
             /* Set default entries */
@@ -179,7 +179,7 @@ SearchKcbList:
     }
 
     /* Allocate a KCB only */
-    CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK), TRUE, TAG_CM);
+    CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK), TRUE, TAG_KCB);
     if (CurrentKcb)
     {
         /* Set it up */
index efbd220..aa162d1 100644 (file)
@@ -2252,10 +2252,10 @@ CmUnloadKey(IN PCM_KEY_CONTROL_BLOCK Kcb,
 
     /* Delete the flusher lock */
     ExDeleteResourceLite(CmHive->FlusherLock);
-    ExFreePoolWithTag(CmHive->FlusherLock, TAG_CM);
+    ExFreePoolWithTag(CmHive->FlusherLock, TAG_CMHIVE);
 
     /* Delete the view lock */
-    ExFreePoolWithTag(CmHive->ViewLock, TAG_CM);
+    ExFreePoolWithTag(CmHive->ViewLock, TAG_CMHIVE);
 
     /* Free the hive */
     CmpFree(CmHive, TAG_CM);
index dea2311..d74429b 100644 (file)
@@ -84,7 +84,7 @@ CmpInitializeHive(OUT PCMHIVE *RegistryHive,
     }
 
     /* Allocate the hive */
-    Hive = ExAllocatePoolWithTag(NonPagedPool, sizeof(CMHIVE), TAG_CM);
+    Hive = ExAllocatePoolWithTag(NonPagedPool, sizeof(CMHIVE), TAG_CMHIVE);
     if (!Hive) return STATUS_INSUFFICIENT_RESOURCES;
 
     /* Setup null fields */
@@ -115,23 +115,23 @@ CmpInitializeHive(OUT PCMHIVE *RegistryHive,
     /* Allocate the view log */
     Hive->ViewLock = ExAllocatePoolWithTag(NonPagedPool,
                                            sizeof(KGUARDED_MUTEX),
-                                           TAG_CM);
+                                           TAG_CMHIVE);
     if (!Hive->ViewLock)
     {
         /* Cleanup allocation and fail */
-        ExFreePoolWithTag(Hive, TAG_CM);
+        ExFreePoolWithTag(Hive, TAG_CMHIVE);
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
     /* Allocate the flush lock */
     Hive->FlusherLock = ExAllocatePoolWithTag(NonPagedPool,
                                               sizeof(ERESOURCE),
-                                              TAG_CM);
+                                              TAG_CMHIVE);
     if (!Hive->FlusherLock)
     {
         /* Cleanup allocations and fail */
-        ExFreePoolWithTag(Hive->ViewLock, TAG_CM);
-        ExFreePoolWithTag(Hive, TAG_CM);
+        ExFreePoolWithTag(Hive->ViewLock, TAG_CMHIVE);
+        ExFreePoolWithTag(Hive, TAG_CMHIVE);
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
@@ -202,9 +202,9 @@ CmpInitializeHive(OUT PCMHIVE *RegistryHive,
     {
         /* Cleanup allocations and fail */
         ExDeleteResourceLite(Hive->FlusherLock);
-        ExFreePoolWithTag(Hive->FlusherLock, TAG_CM);
-        ExFreePoolWithTag(Hive->ViewLock, TAG_CM);
-        ExFreePoolWithTag(Hive, TAG_CM);
+        ExFreePoolWithTag(Hive->FlusherLock, TAG_CMHIVE);
+        ExFreePoolWithTag(Hive->ViewLock, TAG_CMHIVE);
+        ExFreePoolWithTag(Hive, TAG_CMHIVE);
         return Status;
     }
 
@@ -220,9 +220,9 @@ CmpInitializeHive(OUT PCMHIVE *RegistryHive,
         {
             /* Cleanup allocations and fail */
             ExDeleteResourceLite(Hive->FlusherLock);
-            ExFreePoolWithTag(Hive->FlusherLock, TAG_CM);
-            ExFreePoolWithTag(Hive->ViewLock, TAG_CM);
-            ExFreePoolWithTag(Hive, TAG_CM);
+            ExFreePoolWithTag(Hive->FlusherLock, TAG_CMHIVE);
+            ExFreePoolWithTag(Hive->ViewLock, TAG_CMHIVE);
+            ExFreePoolWithTag(Hive, TAG_CMHIVE);
             return STATUS_REGISTRY_CORRUPT;
         }
     }
@@ -252,10 +252,10 @@ CmpDestroyHive(IN PCMHIVE CmHive)
 
     /* Delete the flusher lock */
     ExDeleteResourceLite(CmHive->FlusherLock);
-    ExFreePoolWithTag(CmHive->FlusherLock, TAG_CM);
+    ExFreePoolWithTag(CmHive->FlusherLock, TAG_CMHIVE);
 
     /* Delete the view lock */
-    ExFreePoolWithTag(CmHive->ViewLock, TAG_CM);
+    ExFreePoolWithTag(CmHive->ViewLock, TAG_CMHIVE);
 
     /* Destroy the security descriptor cache */
     CmpDestroySecurityCache(CmHive);
index 7c026f9..384c2ea 100644 (file)
@@ -34,11 +34,11 @@ CmpHiveRootSecurityDescriptor(VOID)
 
     /* Phase 1: Allocate SIDs */
     SidLength = RtlLengthRequiredSid(1);
-    Sid[0] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
-    Sid[1] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
-    Sid[2] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
+    Sid[0] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CMSD);
+    Sid[1] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CMSD);
+    Sid[2] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CMSD);
     SidLength = RtlLengthRequiredSid(2);
-    Sid[3] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CM);
+    Sid[3] = ExAllocatePoolWithTag(PagedPool, SidLength, TAG_CMSD);
 
     /* Make sure all SIDs were allocated */
     if (!(Sid[0]) || !(Sid[1]) || !(Sid[2]) || !(Sid[3]))
@@ -78,7 +78,7 @@ CmpHiveRootSecurityDescriptor(VOID)
     }
 
     /* Phase 3: Allocate the ACL */
-    Acl = ExAllocatePoolWithTag(PagedPool, AclLength, TAG_CM);
+    Acl = ExAllocatePoolWithTag(PagedPool, AclLength, TAG_CMSD);
     if (!Acl) KeBugCheckEx(REGISTRY_ERROR, 11, 3, 0, 0);
 
     /* Phase 4: Create the ACL */
@@ -110,7 +110,7 @@ CmpHiveRootSecurityDescriptor(VOID)
     SecurityDescriptor = ExAllocatePoolWithTag(PagedPool,
                                                sizeof(SECURITY_DESCRIPTOR) +
                                                AclLength,
-                                               TAG_CM);
+                                               TAG_CMSD);
     if (!SecurityDescriptor) KeBugCheckEx(REGISTRY_ERROR, 11, 6, 0, 0);
 
     /* Phase 6: Make a copy of the ACL */
@@ -130,8 +130,8 @@ CmpHiveRootSecurityDescriptor(VOID)
     if (!NT_SUCCESS(Status)) KeBugCheckEx(REGISTRY_ERROR, 11, 8, Status, 0);
 
     /* Free the SIDs and original ACL */
-    for (i = 0; i < 4; i++) ExFreePoolWithTag(Sid[i], TAG_CM);
-    ExFreePoolWithTag(Acl, TAG_CM);
+    for (i = 0; i < 4; i++) ExFreePoolWithTag(Sid[i], TAG_CMSD);
+    ExFreePoolWithTag(Acl, TAG_CMSD);
 
     /* Return the security descriptor */
     return SecurityDescriptor;
index 90df1b8..41120d9 100644 (file)
@@ -980,7 +980,7 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
                                  SecurityDescriptor);
 
     /* Free the security descriptor */
-    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
     if (!NT_SUCCESS(Status)) return FALSE;
 
     /* Add the hive to the hive list */
@@ -1124,7 +1124,7 @@ CmpCreateRegistryRoot(VOID)
                             0,
                             0,
                             (PVOID*)&RootKey);
-    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
     if (!NT_SUCCESS(Status)) return FALSE;
 
     /* Sanity check, and get the key cell */
@@ -1551,7 +1551,7 @@ CmpInitializeHiveList(IN USHORT Flag)
     }
 
     /* Get rid of the SD */
-    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
 
     /* Link SECURITY to SAM */
     CmpLinkKeyToHive(L"\\Registry\\Machine\\Security\\SAM",
@@ -1747,7 +1747,7 @@ CmInitSystem1(VOID)
     CmpAddToHiveFileList(HardwareHive);
 
     /* Free the security descriptor */
-    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
 
     /* Fill out the Hardware key with the ARC Data from the Loader */
     Status = CmpInitializeHardwareConfiguration(KeLoaderBlock);