コード例 #1
0
 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;
 }
コード例 #2
0
        /// <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;
                }
            }
        }