Replace some ExFreePool by ExFreePoolWithTag
authorHervé Poussineau <hpoussin@reactos.org>
Sun, 31 Aug 2008 15:29:21 +0000 (15:29 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Sun, 31 Aug 2008 15:29:21 +0000 (15:29 +0000)
svn path=/trunk/; revision=35834

24 files changed:
reactos/ntoskrnl/config/cmalloc.c
reactos/ntoskrnl/config/cmconfig.c
reactos/ntoskrnl/config/cmse.c
reactos/ntoskrnl/config/cmsysini.c
reactos/ntoskrnl/config/i386/cmhardwr.c
reactos/ntoskrnl/ex/init.c
reactos/ntoskrnl/fstub/disksup.c
reactos/ntoskrnl/io/iomgr/arcname.c
reactos/ntoskrnl/io/iomgr/device.c
reactos/ntoskrnl/io/iomgr/driver.c
reactos/ntoskrnl/io/iomgr/drvrlist.c
reactos/ntoskrnl/io/iomgr/file.c
reactos/ntoskrnl/io/iomgr/iofunc.c
reactos/ntoskrnl/io/iomgr/iorsrce.c
reactos/ntoskrnl/io/iomgr/irp.c
reactos/ntoskrnl/mm/section.c
reactos/ntoskrnl/mm/sysldr.c
reactos/ntoskrnl/ob/obdir.c
reactos/ntoskrnl/ob/obhandle.c
reactos/ntoskrnl/ob/obname.c
reactos/ntoskrnl/ob/obsecure.c
reactos/ntoskrnl/ob/obwait.c
reactos/ntoskrnl/rtl/libsupp.c
reactos/ntoskrnl/se/sd.c

index 3c8cdbb..a0e6c0a 100644 (file)
@@ -62,7 +62,7 @@ CmpFreeKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
     if (!Kcb->PrivateAlloc)
     {
         /* Free it from the pool */
-        ExFreePool(Kcb);
+        ExFreePoolWithTag(Kcb, TAG_CM);
         return;
     }
     
@@ -99,7 +99,7 @@ CmpFreeKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
         }
         
         /* Free the page */
-        ExFreePool(AllocPage);
+        ExFreePoolWithTag(AllocPage, TAG_CM);
     }
     
     /* Release the lock */
@@ -296,7 +296,7 @@ CmpFreeDelayItem(PVOID Entry)
         }
         
         /* Now free the page */
-        ExFreePool(AllocPage);
+        ExFreePoolWithTag(AllocPage, TAG_CM);
     }
     
     /* Release the lock */
index e56a60c..7aae14d 100644 (file)
@@ -386,7 +386,7 @@ CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     }
 
     /* Close our handle, free the buffer and return status */
-    ExFreePool(CmpConfigurationData);
+    ExFreePoolWithTag(CmpConfigurationData, TAG_CM);
     NtClose(KeyHandle);
     return Status;
 }
index 16e9124..4ee2335 100644 (file)
@@ -129,8 +129,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++) ExFreePool(Sid[i]);
-    ExFreePool(Acl);
+    for (i = 0; i < 4; i++) ExFreePoolWithTag(Sid[i], TAG_CM);
+    ExFreePoolWithTag(Acl, TAG_CM);
 
     /* Return the security descriptor */
     return SecurityDescriptor;
index 59321b9..f95e6ed 100644 (file)
@@ -804,7 +804,7 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
                                  SecurityDescriptor);
 
     /* Free the security descriptor */
-    ExFreePool(SecurityDescriptor);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
     if (!NT_SUCCESS(Status)) return FALSE;
 
     /* Add the hive to the hive list */
@@ -944,7 +944,7 @@ CmpCreateRegistryRoot(VOID)
                             0,
                             0,
                             (PVOID*)&RootKey);
-    ExFreePool(SecurityDescriptor);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
     if (!NT_SUCCESS(Status)) return FALSE;
 
     /* Sanity check, and get the key cell */
@@ -1041,7 +1041,7 @@ CmpGetRegistryPath(IN PWCHAR ConfigPath)
         if (!NT_SUCCESS(Status))
         {
             /* Fail */
-            ExFreePool(ValueInfo);
+            ExFreePoolWithTag(ValueInfo, TAG_CM);
             return Status;
         }
 
@@ -1050,7 +1050,7 @@ CmpGetRegistryPath(IN PWCHAR ConfigPath)
                       ValueInfo->Data,
                       ValueInfo->DataLength);
         ConfigPath[ValueInfo->DataLength / sizeof(WCHAR)] = UNICODE_NULL;
-        ExFreePool(ValueInfo);
+        ExFreePoolWithTag(ValueInfo, TAG_CM);
     }
     else
     {
@@ -1356,7 +1356,7 @@ CmpInitializeHiveList(IN USHORT Flag)
     }
     
     /* Get rid of the SD */
-    ExFreePool(SecurityDescriptor);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
 
     /* FIXME: Link SECURITY to SAM */
     
@@ -1541,7 +1541,7 @@ CmInitSystem1(VOID)
     /* FIXME: Add to HiveList key */
     
     /* Free the security descriptor */
-    ExFreePool(SecurityDescriptor);
+    ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
 
     /* Fill out the Hardware key with the ARC Data from the Loader */
     Status = CmpInitializeHardwareConfiguration(KeLoaderBlock);
@@ -1568,7 +1568,7 @@ CmInitSystem1(VOID)
     }
 
     /* Free the load options */
-    ExFreePool(CmpLoadOptions.Buffer);
+    ExFreePoolWithTag(CmpLoadOptions.Buffer, TAG_CM);
 
     /* If we got here, all went well */
     return TRUE;
index 90b72c7..a3a04fe 100644 (file)
@@ -546,7 +546,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
         }
 
         /* Free the configuration data */
-        ExFreePool(CmpConfigurationData);
+        ExFreePoolWithTag(CmpConfigurationData, TAG_CM);
     }
 
     /* Open physical memory */
@@ -824,7 +824,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
     ZwClose(SectionHandle);
 
     /* Free the BIOS version string buffer */
-    if (BiosVersion) ExFreePool(BiosVersion);
+    if (BiosVersion) ExFreePoolWithTag(BiosVersion, TAG_CM);
 
 Quickie:
     /* Close the procesor handle */
index 4ce02eb..9e3c6f4 100644 (file)
@@ -324,7 +324,7 @@ ExpInitNls(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     RtlCopyMemory(SectionBase, ExpNlsTableBase, ExpNlsTableSize);
 
     /* Free the previously allocated buffer and set the new location */
-    ExFreePool(ExpNlsTableBase);
+    ExFreePoolWithTag(ExpNlsTableBase, TAG('R', 't', 'l', 'i'));
     ExpNlsTableBase = SectionBase;
 
     /* Initialize the NLS Tables */
index 462e522..725ac34 100644 (file)
@@ -948,7 +948,7 @@ HalpGetFullGeometry(IN PDEVICE_OBJECT DeviceObject,
     if (!Irp)
     {
         /* Fail, free the event */
-        ExFreePool(Event);
+        ExFreePoolWithTag(Event, TAG_FILE_SYSTEM);
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
@@ -977,7 +977,7 @@ HalpGetFullGeometry(IN PDEVICE_OBJECT DeviceObject,
         if (!Irp)
         {
             /* Fail, free the event */
-            ExFreePool(Event);
+            ExFreePoolWithTag(Event, TAG_FILE_SYSTEM);
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
@@ -1000,7 +1000,7 @@ HalpGetFullGeometry(IN PDEVICE_OBJECT DeviceObject,
     }
 
     /* Free the event and return the Status */
-    ExFreePool(Event);
+    ExFreePoolWithTag(Event, TAG_FILE_SYSTEM);
     return Status;
 }
 
@@ -1200,7 +1200,7 @@ xHalGetPartialGeometry(IN PDEVICE_OBJECT DeviceObject,
 
 Cleanup:
     /* Free all the pointers */
-    if (Event) ExFreePool(Event);
+    if (Event) ExFreePoolWithTag(Event, TAG_FILE_SYSTEM);
     if (IoStatusBlock) ExFreePool(IoStatusBlock);
     if (DiskGeometry) ExFreePool(DiskGeometry);
     return;
@@ -1251,7 +1251,7 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
     if (!Irp)
     {
         /* Failed */
-        ExFreePool(Buffer);
+        ExFreePoolWithTag(Buffer, TAG_FILE_SYSTEM);
         return;
     }
 
@@ -1275,7 +1275,7 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
         if (((PUSHORT)Buffer)[BOOT_SIGNATURE_OFFSET] != BOOT_RECORD_SIGNATURE)
         {
             /* Failed */
-            ExFreePool(Buffer);
+            ExFreePoolWithTag(Buffer, TAG_FILE_SYSTEM);
             return;
         }
 
@@ -1287,7 +1287,7 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
         if (PartitionDescriptor->PartitionType != MbrTypeIdentifier)
         {
             /* It's not, free our buffer */
-        ExFreePool(Buffer);
+            ExFreePoolWithTag(Buffer, TAG_FILE_SYSTEM);
         }
         else
         {
@@ -1367,7 +1367,7 @@ xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
     Status = HalpGetFullGeometry(DeviceObject, &DiskGeometry, &MaxOffset);
     if (!NT_SUCCESS(Status))
     {
-        ExFreePool(*PartitionBuffer);
+        ExFreePoolWithTag(*PartitionBuffer, TAG_FILE_SYSTEM);
         *PartitionBuffer = NULL;
         return Status;
     }
@@ -1383,7 +1383,8 @@ xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
     if (!Buffer)
     {
         /* Fail, free the input buffer */
-        ExFreePool(*PartitionBuffer);
+        ExFreePoolWithTag(*PartitionBuffer, TAG_FILE_SYSTEM);
+        *PartitionBuffer = NULL;
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
@@ -1549,7 +1550,7 @@ xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
                               BufferSize);
 
                 /* Free the old buffer and set this one as the new one */
-                ExFreePool(*PartitionBuffer);
+                ExFreePoolWithTag(*PartitionBuffer, TAG_FILE_SYSTEM);
                 *PartitionBuffer = DriveLayoutInfo;
 
                 /* Double the size */
@@ -1732,8 +1733,8 @@ xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
     if (!i) (*PartitionBuffer)->Signature = 0;
 
     /* Free the buffer and check for success */
-    if (Buffer) ExFreePool(Buffer);
-    if (!NT_SUCCESS(Status)) ExFreePool(*PartitionBuffer);
+    if (Buffer) ExFreePoolWithTag(Buffer, TAG_FILE_SYSTEM);
+    if (!NT_SUCCESS(Status)) ExFreePoolWithTag(*PartitionBuffer, TAG_FILE_SYSTEM);
 
     /* Return status */
     return Status;
@@ -2212,7 +2213,7 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
     }
 
     /* If we had a buffer, free it, then return status */
-    if (Buffer) ExFreePool(Buffer);
+    if (Buffer) ExFreePoolWithTag(Buffer, TAG_FILE_SYSTEM);
     return Status;
 }
 
index c18a31c..6560a3d 100644 (file)
@@ -242,8 +242,8 @@ IopGetDiskInformation(IN ULONG i,
     if (!NT_SUCCESS(Status))
     {
         /* Try again */
-        ExFreePool(PartitionBuffer);
-        ExFreePool(DriveLayout);
+        ExFreePoolWithTag(PartitionBuffer, TAG_IO);
+        ExFreePoolWithTag(DriveLayout, TAG_FILE_SYSTEM);
         return FALSE;
     }
 
@@ -257,8 +257,8 @@ IopGetDiskInformation(IN ULONG i,
     *PartitionCount = DriveLayout->PartitionCount;
 
     /* Free the buffer */
-    ExFreePool(PartitionBuffer);
-    ExFreePool(DriveLayout);
+    ExFreePoolWithTag(PartitionBuffer, TAG_IO);
+    ExFreePoolWithTag(DriveLayout, TAG_FILE_SYSTEM);
     return TRUE;
 }
 
@@ -574,7 +574,7 @@ IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
         }
 
         /* Free the buffer */
-        ExFreePool(PartitionBuffer);
+        ExFreePoolWithTag(PartitionBuffer, TAG_IO);
     }
 
     /* Return success */
index d010cb0..4d88d8c 100644 (file)
@@ -122,7 +122,7 @@ IoShutdownRegisteredDevices(VOID)
         }
 
         /* Free the shutdown entry and reset the event */
-        ExFreePool(ShutdownEntry);
+        ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
         KeClearEvent(&Event);
 
         /* Go to the next entry */
@@ -317,7 +317,7 @@ IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
         if (DeviceObject->SecurityDescriptor)
         {
             /* Free it */
-            ExFreePool(DeviceObject->SecurityDescriptor);
+            ExFreePoolWithTag(DeviceObject->SecurityDescriptor, TAG_SD);
         }
 
         /* Remove the device from the list */
@@ -1328,7 +1328,7 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
             NextEntry = NextEntry->Blink;
 
             /* Free the entry */
-            ExFreePool(ShutdownEntry);
+            ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
         }
 
         /* Go to the next entry */
@@ -1352,7 +1352,7 @@ IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
             NextEntry = NextEntry->Blink;
 
             /* Free the entry */
-            ExFreePool(ShutdownEntry);
+            ExFreePoolWithTag(ShutdownEntry, TAG_SHUTDOWN_ENTRY);
         }
 
         /* Go to the next entry */
index 90fddac..68aeeea 100644 (file)
@@ -29,6 +29,8 @@ UNICODE_STRING IopHardwareDatabaseKey =
 
 POBJECT_TYPE IoDriverObjectType = NULL;
 
+#define TAG_RTLREGISTRY TAG('R', 'q', 'r', 'v')
+
 extern BOOLEAN ExpInTextModeSetup;
 
 /* PRIVATE FUNCTIONS **********************************************************/
@@ -246,7 +248,7 @@ IopNormalizeImagePath(
       RtlAppendUnicodeStringToString(ImagePath, &InputImagePath);
 
       /* Free caller's string */
-      RtlFreeUnicodeString(&InputImagePath);
+      ExFreePoolWithTag(InputImagePath.Buffer, TAG_RTLREGISTRY);
    }
 
    return STATUS_SUCCESS;
index b1abfc1..e8f3a72 100644 (file)
@@ -37,6 +37,8 @@ typedef struct _SERVICE
 /*  BOOLEAN ServiceRunning;*/  // needed ??
 } SERVICE, *PSERVICE;
 
+#define TAG_RTLREGISTRY TAG('R', 'q', 'r', 'v')
+
 /* GLOBALS ********************************************************************/
 
 LIST_ENTRY GroupListHead = {NULL, NULL};
@@ -205,11 +207,11 @@ IopCreateServiceListEntry(PUNICODE_STRING ServiceName)
        */
       if (Service->ServiceGroup.Buffer)
         {
-          ExFreePool(Service->ServiceGroup.Buffer);
+          ExFreePoolWithTag(Service->ServiceGroup.Buffer, TAG_RTLREGISTRY);
         }
       if (Service->ImagePath.Buffer)
         {
-          ExFreePool(Service->ImagePath.Buffer);
+          ExFreePoolWithTag(Service->ImagePath.Buffer, TAG_RTLREGISTRY);
         }
       ExFreePool(Service);
       return(Status);
index fd92560..2efe9b0 100644 (file)
@@ -1031,7 +1031,7 @@ IopDeleteFile(IN PVOID ObjectBody)
         /* Clear the file name */
         if (FileObject->FileName.Buffer)
         {
-           ExFreePool(FileObject->FileName.Buffer);
+           ExFreePoolWithTag(FileObject->FileName.Buffer, TAG_IO_NAME);
            FileObject->FileName.Buffer = NULL;
         }
 
index bc4bc77..a6abaf8 100644 (file)
@@ -1890,7 +1890,7 @@ NtQueryInformationFile(IN HANDLE FileHandle,
         {
             /* Clear it in the IRP for completion */
             Irp->UserEvent = NULL;
-            ExFreePool(Event);
+            ExFreePoolWithTag(Event, TAG_IO);
         }
 
         /* Set the caller IOSB */
index 23828e9..6e0d2f3 100644 (file)
@@ -179,7 +179,7 @@ IopQueryDeviceDescription(
       if (!NT_SUCCESS(Status))
       {
          if (ControllerFullInformation != NULL)
-            ExFreePool(ControllerFullInformation);
+            ExFreePoolWithTag(ControllerFullInformation, TAG_IO_RESOURCE);
          return Status;
       }
 
@@ -188,7 +188,7 @@ IopQueryDeviceDescription(
       MaximumControllerNumber = ControllerFullInformation->SubKeys;
 
       /* Free Memory */
-      ExFreePool(ControllerFullInformation);
+      ExFreePoolWithTag(ControllerFullInformation, TAG_IO_RESOURCE);
       ControllerFullInformation = NULL;
    }
 
@@ -318,7 +318,7 @@ IopQueryDeviceDescription(
          MaximumPeripheralNumber = PeripheralFullInformation->SubKeys;
 
          /* Free Memory */
-         ExFreePool(PeripheralFullInformation);
+         ExFreePoolWithTag(PeripheralFullInformation, TAG_IO_RESOURCE);
          PeripheralFullInformation = NULL;
       }
 
@@ -400,7 +400,7 @@ IopQueryDeviceDescription(
             {
                if (PeripheralInformation[PeripheralLoop])
                {
-                  ExFreePool(PeripheralInformation[PeripheralLoop]);
+                  ExFreePoolWithTag(PeripheralInformation[PeripheralLoop], TAG_IO_RESOURCE);
                   PeripheralInformation[PeripheralLoop] = NULL;
                }
             }
@@ -416,7 +416,7 @@ EndLoop:
       {
          if (ControllerInformation[ControllerLoop])
          {
-            ExFreePool(ControllerInformation[ControllerLoop]);
+            ExFreePoolWithTag(ControllerInformation[ControllerLoop], TAG_IO_RESOURCE);
             ControllerInformation[ControllerLoop] = NULL;
          }
       }
@@ -498,7 +498,7 @@ IopQueryBusDescription(
    }
 
    /* Deallocate the old Buffer */
-   ExFreePool(FullInformation);
+   ExFreePoolWithTag(FullInformation, TAG_IO_RESOURCE);
 
    /* Try to find a Bus */
    for (BusLoop = 0; NT_SUCCESS(Status); BusLoop++)
@@ -619,7 +619,7 @@ IopQueryBusDescription(
          {
             if (BusInformation[SubBusLoop])
             {
-               ExFreePool(BusInformation[SubBusLoop]);
+               ExFreePoolWithTag(BusInformation[SubBusLoop], TAG_IO_RESOURCE);
                BusInformation[SubBusLoop] = NULL;
             }
          }
@@ -645,7 +645,7 @@ IopQueryBusDescription(
 
    /* Free the last remaining Allocated Memory */
    if (BasicInformation)
-      ExFreePool(BasicInformation);
+      ExFreePoolWithTag(BasicInformation, TAG_IO_RESOURCE);
 
    return Status;
 }
@@ -788,7 +788,7 @@ IoQueryDeviceDescription(PINTERFACE_TYPE BusType OPTIONAL,
    }
 
    /* Free Memory */
-   ExFreePool(RootRegKey.Buffer);
+   ExFreePoolWithTag(RootRegKey.Buffer, TAG_IO_RESOURCE);
 
    return Status;
 }
index 0a2b65a..0d445bb 100644 (file)
@@ -1499,7 +1499,7 @@ IoFreeIrp(IN PIRP Irp)
     if (!(Irp->AllocationFlags & IRP_ALLOCATED_FIXED_SIZE))
     {
         /* Free it */
-        ExFreePool(Irp);
+        ExFreePoolWithTag(Irp, TAG_IRP);
     }
     else
     {
@@ -1528,7 +1528,7 @@ IoFreeIrp(IN PIRP Irp)
             {
                 /* All lists failed, use the pool */
                 List->L.FreeMisses++;
-                ExFreePool(Irp);
+                ExFreePoolWithTag(Irp, TAG_IRP);
                 Irp = NULL;
             }
         }
index 00a1570..fd4ec51 100644 (file)
@@ -136,7 +136,7 @@ MmGetFileNameForSection(IN PROS_SECTION_OBJECT Section,
     if (!NT_SUCCESS(Status))
     {
         /* Failed, free memory */
-        ExFreePool(ObjectNameInfo);
+        ExFreePoolWithTag(ObjectNameInfo, TAG('M', 'm', ' ', ' '));
         return Status;
     }
 
@@ -2759,7 +2759,7 @@ ExeFmtpReadFile(IN PVOID File,
    }
    else
    {
-      ExFreePool(Buffer);
+      ExFreePoolWithTag(Buffer, TAG('M', 'm', 'X', 'r'));
    }
 
    return Status;
@@ -3168,7 +3168,7 @@ ExeFmtpCreateImageSection(HANDLE FileHandle,
          break;
    }
 
-   ExFreePool(FileHeaderBuffer);
+   ExFreePoolWithTag(FileHeaderBuffer, TAG('M', 'm', 'X', 'r'));
 
    /*
     * No loader handled the format
@@ -3963,7 +3963,7 @@ MmUnmapViewOfSegment(PMM_AVL_TABLE AddressSpace,
    {
       CurrentEntry = RemoveHeadList(RegionListHead);
       CurrentRegion = CONTAINING_RECORD(CurrentEntry, MM_REGION, RegionListEntry);
-      ExFreePool(CurrentRegion);
+      ExFreePoolWithTag(CurrentRegion, TAG_MM_REGION);
    }
 
    if (Section->AllocationAttributes & SEC_PHYSICALMEMORY)
index aacc93c..78eaf46 100644 (file)
@@ -660,7 +660,7 @@ MiSnapThunk(IN PVOID DllBase,
                                          &MissingForwarder);\r
 \r
                     /* Free the forwarder name and set the thunk */\r
-                    ExFreePool(ForwardName);\r
+                    ExFreePoolWithTag(ForwardName, TAG_LDR_WSTR);\r
                     Address->u1 = ForwardThunk.u1;\r
                     break;\r
                 }\r
@@ -876,7 +876,7 @@ MiResolveImageReferences(IN PVOID ImageBase,
         {\r
             /* Failed */\r
             MiDereferenceImports(LoadedImports);\r
-            if (LoadedImports) ExFreePool(LoadedImports);\r
+            if (LoadedImports) ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR);\r
             return Status;\r
         }\r
 \r
@@ -997,7 +997,7 @@ CheckDllState:
                 /* Cleanup and return */\r
                 RtlFreeUnicodeString(&NameString);\r
                 MiDereferenceImports(LoadedImports);\r
-                if (LoadedImports) ExFreePool(LoadedImports);\r
+                if (LoadedImports) ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR);\r
                 return Status;\r
             }\r
 \r
@@ -1030,7 +1030,7 @@ CheckDllState:
         {\r
             /* Cleanup and return */\r
             MiDereferenceImports(LoadedImports);\r
-            if (LoadedImports) ExFreePool(LoadedImports);\r
+            if (LoadedImports) ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR);\r
             return STATUS_DRIVER_ENTRYPOINT_NOT_FOUND;\r
         }\r
 \r
@@ -1059,7 +1059,7 @@ CheckDllState:
                 {\r
                     /* Cleanup and return */\r
                     MiDereferenceImports(LoadedImports);\r
-                    if (LoadedImports) ExFreePool(LoadedImports);\r
+                    if (LoadedImports) ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR);\r
                     return Status;\r
                 }\r
 \r
@@ -1091,13 +1091,13 @@ CheckDllState:
         if (!ImportCount)\r
         {\r
             /* Free the list and set it to no imports */\r
-            ExFreePool(LoadedImports);\r
+            ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR);\r
             LoadedImports = (PVOID)-2;\r
         }\r
         else if (ImportCount == 1)\r
         {\r
             /* Just one entry, we can free the table and only use our entry */\r
-            ExFreePool(LoadedImports);\r
+            ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR);\r
             LoadedImports = (PLOAD_IMPORTS)ImportEntry;\r
         }\r
         else if (ImportCount != LoadedImports->Count)\r
@@ -1125,7 +1125,7 @@ CheckDllState:
                 }\r
 \r
                 /* Free the old copy */\r
-                ExFreePool(LoadedImports);\r
+                ExFreePoolWithTag(LoadedImports, TAG_LDR_WSTR);\r
                 LoadedImports = NewImports;\r
             }\r
         }\r
@@ -1834,7 +1834,7 @@ LoaderScan:
         }\r
 \r
         /* Free the entry itself */\r
-        ExFreePool(LdrEntry);\r
+        ExFreePoolWithTag(LdrEntry, TAG_MODULE_OBJECT);\r
         LdrEntry = NULL;\r
         goto Quickie;\r
     }\r
@@ -1924,7 +1924,7 @@ Quickie:
     if (NamePrefix) ExFreePool(PrefixName.Buffer);\r
 \r
     /* Free the name buffer and return status */\r
-    ExFreePool(Buffer);\r
+    ExFreePoolWithTag(Buffer, TAG_LDR_WSTR);\r
     return Status;\r
 }\r
 \r
index 7fc6c1a..0bccc12 100644 (file)
@@ -326,7 +326,7 @@ ObpDeleteEntryDirectory(POBP_LOOKUP_CONTEXT Context)
     CurrentEntry->ChainLink = NULL;
 
     /* Free it */
-    ExFreePool(CurrentEntry);
+    ExFreePoolWithTag(CurrentEntry, OB_DIR_TAG);
 
     /* Return */
     return TRUE;
@@ -529,7 +529,7 @@ NtQueryDirectoryObject(IN HANDLE DirectoryHandle,
     if (!NT_SUCCESS(Status))
     {
         /* Free the buffer and fail */
-        ExFreePool(LocalBuffer);
+        ExFreePoolWithTag(LocalBuffer, OB_NAME_TAG);
         return Status;
     }
 
@@ -701,7 +701,7 @@ Quickie:
 
     /* Dereference the directory and free our buffer */
     ObDereferenceObject(Directory);
-    ExFreePool(LocalBuffer);
+    ExFreePoolWithTag(LocalBuffer, OB_NAME_TAG);
 
     /* Return status to caller */
     return Status;
index 9ec6266..5916040 100644 (file)
@@ -289,7 +289,7 @@ ObpInsertHandleCount(IN POBJECT_HEADER ObjectHeader)
     else
     {
         /* Otherwise we had a DB, free it */
-        ExFreePool(OldHandleDatabase);
+        ExFreePoolWithTag(OldHandleDatabase, TAG_OB_HANDLE);
     }
 
     /* Find the end of the copy and zero out the new data */
@@ -2425,7 +2425,7 @@ ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes,
     if (!NT_SUCCESS(Status))
     {
         /* Fail */
-        ExFreePool(TempBuffer);
+        ExFreePoolWithTag(TempBuffer, TAG_OB_TEMP_STORAGE);
         return Status;
     }
 
@@ -2533,7 +2533,7 @@ Quickie:
     /* Release the object attributes and temporary buffer */
     ObpReleaseObjectCreateInformation(&TempBuffer->ObjectCreateInfo);
     if (ObjectName.Buffer) ObpFreeObjectNameBuffer(&ObjectName);
-    ExFreePool(TempBuffer);
+    ExFreePoolWithTag(TempBuffer, TAG_OB_TEMP_STORAGE);
 
     /* Return status */
     OBTRACE(OB_HANDLE_DEBUG,
index a23a2df..7980031 100644 (file)
@@ -720,7 +720,7 @@ ParseFromRoot:
                 if (ObjectNameInfo->Name.Buffer)
                 {
                     /* Free it */
-                    ExFreePool(ObjectNameInfo->Name.Buffer);
+                    ExFreePoolWithTag(ObjectNameInfo->Name.Buffer, OB_NAME_TAG );
                 }
 
                 /* Write new one */
index 6d46538..493f3a4 100644 (file)
@@ -40,7 +40,7 @@ ObAssignObjectSecurityDescriptor(IN PVOID Object,
     if (NT_SUCCESS(Status))
     {
         /* Free the old copy */
-        ExFreePool(SecurityDescriptor);
+        ExFreePoolWithTag(SecurityDescriptor, TAG_SD);
 
         /* Set the new pointer */
         ASSERT(NewSd);
@@ -633,7 +633,7 @@ ObGetObjectSecurity(IN PVOID Object,
     if (!NT_SUCCESS(Status))
     {
         /* Free the descriptor and tell the caller we failed */
-        ExFreePool(*SecurityDescriptor);
+        ExFreePoolWithTag(*SecurityDescriptor, TAG_SEC_QUERY);
         *MemoryAllocated = FALSE;
     }
 
index e644af6..eddb17d 100644 (file)
@@ -279,7 +279,7 @@ Quickie:
     }
 
     /* Free wait block array */
-    if (WaitBlockArray) ExFreePool(WaitBlockArray);
+    if (WaitBlockArray) ExFreePoolWithTag(WaitBlockArray, TAG_WAIT);
 
     /* Re-enable APCs if needed */
     if (LockInUse) KeLeaveCriticalRegion();
index e7a5072..52f388e 100644 (file)
@@ -13,6 +13,8 @@
 #define NDEBUG
 #include <debug.h>
 
+#define TAG_ATMT TAG('A', 't', 'o', 'T') /* Atom table */
+
 extern ULONG NtGlobalFlag;
 
 typedef struct _RTL_RANGE_ENTRY
@@ -482,21 +484,21 @@ RtlpFreeAtomTable(PRTL_ATOM_TABLE AtomTable)
 PRTL_ATOM_TABLE_ENTRY
 RtlpAllocAtomTableEntry(ULONG Size)
 {
-   PRTL_ATOM_TABLE_ENTRY Entry = ExAllocatePool(NonPagedPool,
-                                                Size);
-   if (Entry != NULL)
-   {
-      RtlZeroMemory(Entry,
-                    Size);
-   }
+    PRTL_ATOM_TABLE_ENTRY Entry;
 
-   return Entry;
+    Entry = ExAllocatePoolWithTag(NonPagedPool, Size, TAG_ATMT);
+    if (Entry != NULL)
+    {
+        RtlZeroMemory(Entry, Size);
+    }
+
+    return Entry;
 }
 
 VOID
 RtlpFreeAtomTableEntry(PRTL_ATOM_TABLE_ENTRY Entry)
 {
-   ExFreePool(Entry);
+    ExFreePoolWithTag(Entry, TAG_ATMT);
 }
 
 VOID
index 2c58e39..a489143 100644 (file)
@@ -619,8 +619,9 @@ DescriptorCopy.AclType = NULL;                                           \
         
         /* allocate enough memory to store a complete copy of a self-relative
          security descriptor */
-        NewDescriptor = ExAllocatePool(PoolType,
-                                       DescriptorSize);
+        NewDescriptor = ExAllocatePoolWithTag(PoolType,
+                                              DescriptorSize,
+                                              TAG_SD);
         if(NewDescriptor != NULL)
         {
             ULONG_PTR Offset = sizeof(SECURITY_DESCRIPTOR);
@@ -872,7 +873,7 @@ SeReleaseSecurityDescriptor(IN PSECURITY_DESCRIPTOR CapturedSecurityDescriptor,
         (CurrentMode == KernelMode && CaptureIfKernelMode)))
     {
         /* only delete the descriptor when SeCaptureSecurityDescriptor() allocated one! */
-        ExFreePool(CapturedSecurityDescriptor);
+        ExFreePoolWithTag(CapturedSecurityDescriptor, TAG_SD);
     }
     
     return STATUS_SUCCESS;
@@ -1450,8 +1451,9 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR _ParentDescriptor OPTIONAL,
            DaclLength,
            SaclLength);
     
-    Descriptor = ExAllocatePool(PagedPool,
-                                Length);
+    Descriptor = ExAllocatePoolWithTag(PagedPool,
+                                       Length,
+                                       TAG_SD);
     if (Descriptor == NULL)
     {
         DPRINT1("ExAlloctePool() failed\n");