Change ExFreePool to ExFreePoolWithTag
authorHervé Poussineau <hpoussin@reactos.org>
Thu, 5 May 2005 17:20:10 +0000 (17:20 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Thu, 5 May 2005 17:20:10 +0000 (17:20 +0000)
Don't call RtlFreeUnicodeString if the string wasn't created by RtlAnsiStringToUnicodeString or RtlUpcaseUnicodeString
Implement ExRosQueryNonPagedPoolTag
Add BAD_POOL_CALLER code

svn path=/trunk/; revision=15008

reactos/ntoskrnl/cm/regobj.c
reactos/ntoskrnl/io/device.c
reactos/ntoskrnl/io/irp.c
reactos/ntoskrnl/io/mdl.c
reactos/ntoskrnl/mm/marea.c
reactos/ntoskrnl/mm/mdl.c
reactos/ntoskrnl/mm/npool.c
reactos/ntoskrnl/ntoskrnl.mc
reactos/ntoskrnl/ob/object.c

index 4a5ffa8..79d5016 100644 (file)
@@ -91,7 +91,7 @@ CmiObjectParse(PVOID ParsedObject,
   {
      ExReleaseResourceLite(&CmiRegistryLock);
      KeLeaveCriticalRegion();
-     RtlFreeUnicodeString(&KeyName);
+     ExFreePool(KeyName.Buffer);
      return Status;
   }
   if (FoundObject == NULL)
@@ -107,7 +107,7 @@ CmiObjectParse(PVOID ParsedObject,
        {
           ExReleaseResourceLite(&CmiRegistryLock);
           KeLeaveCriticalRegion();
-         RtlFreeUnicodeString(&KeyName);
+         ExFreePool(KeyName.Buffer);
          return(STATUS_UNSUCCESSFUL);
        }
 
@@ -140,7 +140,7 @@ CmiObjectParse(PVOID ParsedObject,
                  wcscat(TargetPath.Buffer, EndPtr);
                }
 
-             RtlFreeUnicodeString(FullPath);
+             ExFreePool(FullPath->Buffer);
              RtlFreeUnicodeString(&LinkPath);
              FullPath->Length = TargetPath.Length;
              FullPath->MaximumLength = TargetPath.MaximumLength;
@@ -153,7 +153,7 @@ CmiObjectParse(PVOID ParsedObject,
 
              *NextObject = NULL;
 
-             RtlFreeUnicodeString(&KeyName);
+             ExFreePool(KeyName.Buffer);
              return(STATUS_REPARSE);
            }
        }
@@ -173,7 +173,7 @@ CmiObjectParse(PVOID ParsedObject,
        {
           ExReleaseResourceLite(&CmiRegistryLock);
           KeLeaveCriticalRegion();
-         RtlFreeUnicodeString(&KeyName);
+         ExFreePool(KeyName.Buffer);
          return(Status);
        }
       /* Add the keep-alive reference */
@@ -224,8 +224,8 @@ CmiObjectParse(PVOID ParsedObject,
                  wcscat(TargetPath.Buffer, EndPtr);
                }
 
-             RtlFreeUnicodeString(FullPath);
-             RtlFreeUnicodeString(&LinkPath);
+             ExFreePool(FullPath->Buffer);
+             ExFreePool(LinkPath.Buffer);
              FullPath->Length = TargetPath.Length;
              FullPath->MaximumLength = TargetPath.MaximumLength;
              FullPath->Buffer = TargetPath.Buffer;
@@ -237,7 +237,7 @@ CmiObjectParse(PVOID ParsedObject,
 
              *NextObject = NULL;
 
-             RtlFreeUnicodeString(&KeyName);
+             ExFreePool(KeyName.Buffer);
              return(STATUS_REPARSE);
            }
        }
@@ -258,7 +258,7 @@ CmiObjectParse(PVOID ParsedObject,
 
   *NextObject = FoundObject;
 
-  RtlFreeUnicodeString(&KeyName);
+  ExFreePool(KeyName.Buffer);
 
   return(STATUS_SUCCESS);
 }
index 91fff63..17554f2 100644 (file)
@@ -18,6 +18,7 @@
 
 #define TAG_DEVICE_EXTENSION   TAG('D', 'E', 'X', 'T')
 #define TAG_SHUTDOWN_ENTRY    TAG('S', 'H', 'U', 'T')
+#define TAG_IO_TIMER      TAG('I', 'O', 'T', 'M')
 
 static ULONG IopDeviceObjectNumber = 0;
 
@@ -589,7 +590,7 @@ IoDeleteDevice(PDEVICE_OBJECT DeviceObject)
    if (DeviceObject->Timer)
    {
       IopRemoveTimerFromTimerList(DeviceObject->Timer);
-      ExFreePool(DeviceObject->Timer);
+      ExFreePoolWithTag(DeviceObject->Timer, TAG_IO_TIMER);
    }
 
    /* Remove device from driver device list */
index 644eefa..91813e6 100644 (file)
@@ -871,7 +871,7 @@ STDCALL
 IoFreeIrp(PIRP Irp)
 {
     /* Free the pool memory associated with it */
-    ExFreePool(Irp);
+    ExFreePoolWithTag(Irp, TAG_IRP);
 }
 
 /*
@@ -1253,7 +1253,7 @@ IoSecondStageCompletion(PKAPC Apc,
         /* Also check if we should de-allocate it */
         if (Irp->Flags & IRP_DEALLOCATE_BUFFER)
         {
-            ExFreePool(Irp->AssociatedIrp.SystemBuffer);
+            ExFreePoolWithTag(Irp->AssociatedIrp.SystemBuffer, TAG_SYS_BUF);
         }
     }
     
index b4b423f..b5319ab 100644 (file)
@@ -132,7 +132,7 @@ IoFreeMdl(PMDL Mdl)
 
    MmPrepareMdlForReuse(Mdl);
 
-   ExFreePool(Mdl);
+   ExFreePoolWithTag(Mdl, TAG_MDL);
 }
 
 
index c56f487..282dfd7 100644 (file)
@@ -812,7 +812,7 @@ MmFreeMemoryArea(
       }
    }
 
-   ExFreePool(MemoryArea);
+   ExFreePoolWithTag(MemoryArea, TAG_MAREA);
 
    DPRINT("MmFreeMemoryAreaByNode() succeeded\n");
 
index 7f24286..e51234f 100644 (file)
@@ -16,7 +16,7 @@
 
 /* GLOBALS *******************************************************************/
 
-#define TAG_MDL    TAG('M', 'M', 'D', 'L')
+#define TAG_MDL    TAG('M', 'D', 'L', ' ')
 
 #define MI_MDL_MAPPING_REGION_SIZE       (256*1024*1024)
 
index fc92e77..cf60a88 100644 (file)
@@ -1458,6 +1458,28 @@ static BLOCK_HDR* get_block(unsigned int size, unsigned long alignment)
 
 #endif /* not WHOLE_PAGE_ALLOCATIONS */
 
+ULONG STDCALL
+ExRosQueryNonPagedPoolTag ( PVOID Addr )
+{
+#ifdef WHOLE_PAGE_ALLOCATIONS /* WHOLE_PAGE_ALLOCATIONS */
+
+   UNIMPLEMENTED;
+   return 0;
+   
+#else /* not WHOLE_PAGE_ALLOCATIONS */
+
+   BLOCK_HDR* blk=address_to_block(Addr);
+   
+   if (blk->Magic != BLOCK_HDR_USED_MAGIC)
+      KEBUGCHECK(0);
+   if (blk->Magic == BLOCK_HDR_FREE_MAGIC)
+      KEBUGCHECK(0);
+   
+   return blk->Used.Tag;
+
+#endif /* WHOLE_PAGE_ALLOCATIONS */
+}
+
 VOID STDCALL ExFreeNonPagedPool (PVOID block)
 /*
  * FUNCTION: Releases previously allocated memory
index 4fcbae9..dbc250f 100644 (file)
@@ -987,6 +987,14 @@ Language=English
 INVALID_WORK_QUEUE_ITEM
 .
 
+MessageId=0xC2
+Severity=Success
+Facility=System
+SymbolicName=BAD_POOL_CALLER
+Language=English
+BAD_POOL_CALLER
+.
+
 MessageId=0xE1
 Severity=Success
 Facility=System
index 99a6d5d..dfc455f 100644 (file)
@@ -507,7 +507,7 @@ ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
 
   if (current)
      RtlpCreateUnicodeString (RemainingPath, current, NonPagedPool);
-  RtlFreeUnicodeString (&PathString);
+  ExFreePool(PathString.Buffer);
   *ReturnedObject = CurrentObject;
 
   return STATUS_SUCCESS;
@@ -806,7 +806,7 @@ ObCreateObject (IN KPROCESSOR_MODE ObjectAttributesAccessMode OPTIONAL,
            }
          RtlFreeUnicodeString(&Header->Name);
          RtlFreeUnicodeString(&RemainingPath);
-         ExFreePool(Header);
+         ExFreePoolWithTag(Header, Header->ObjectType->Tag);
          DPRINT("Create Failed\n");
          return Status;
        }
@@ -1000,7 +1000,7 @@ ObpDeleteObject(POBJECT_HEADER Header)
     }
 
   DPRINT("ObPerformRetentionChecks() = Freeing object\n");
-  ExFreePool(Header);
+  ExFreePoolWithTag(Header, Header->ObjectType->Tag);
 
   return(STATUS_SUCCESS);
 }
@@ -1010,16 +1010,14 @@ VOID STDCALL
 ObpDeleteObjectWorkRoutine (IN PVOID Parameter)
 {
   PRETENTION_CHECK_PARAMS Params = (PRETENTION_CHECK_PARAMS)Parameter;
-  /* ULONG Tag; */ /* See below */
+  ULONG Tag;
 
   ASSERT(Params);
   ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); /* We need PAGED_CODE somewhere... */
 
-  /* Turn this on when we have ExFreePoolWithTag
-  Tag = Params->ObjectHeader->ObjectType->Tag; */
+  Tag = Params->ObjectHeader->ObjectType->Tag;
   ObpDeleteObject(Params->ObjectHeader);
-  ExFreePool(Params);
-  /* ExFreePoolWithTag(Params, Tag); */
+  ExFreePoolWithTag(Params, Tag); 
 }