internal HeapInformation(RtlHeapInformation heapInfo) { this.Address = heapInfo.BaseAddress; this.BytesAllocated = heapInfo.BytesAllocated.ToInt64(); this.BytesCommitted = heapInfo.BytesCommitted.ToInt64(); this.TagCount = heapInfo.NumberOfTags; this.EntryCount = heapInfo.NumberOfEntries; this.PseudoTagCount = heapInfo.NumberOfPseudoTags; }
/// <summary> /// Enumerates heap information. /// </summary> /// <param name="callback">The callback for the enumeration.</param> public void EnumHeaps(DebugEnumHeapsDelegate callback) { RtlDebugInformation debugInfo = this.GetDebugInformation(); if (debugInfo.Heaps == IntPtr.Zero) { throw new InvalidOperationException("Heap information does not exist."); } MemoryRegion heapInfo = new MemoryRegion(debugInfo.Heaps); var heaps = heapInfo.ReadStruct <RtlProcessHeaps>(); for (int i = 0; i < heaps.NumberOfHeaps; i++) { RtlHeapInformation heap = heapInfo.ReadStruct <RtlHeapInformation>(RtlProcessHeaps.HeapsOffset, RtlHeapInformation.SizeOf, i); if (!callback(new HeapInformation(heap))) { break; } } }