public HeapInfo(ProcessInfo info) { HeapProcess = info; HEAPLIST32 firstHeapList = new HEAPLIST32(); firstHeapList.dwSize = (IntPtr)Marshal.SizeOf(typeof(HEAPLIST32)); IntPtr Handle = ErcCore.CreateToolhelp32Snapshot(SnapshotFlags.HeapList, (uint)info.ProcessID); if ((int)Handle == -1) { throw new ERCException("CreateToolhelp32Snapshot returned an invalid handle value (-1)"); } if (ErcCore.Heap32ListFirst(Handle, ref firstHeapList)) { HeapLists.Add(firstHeapList); bool moreHeaps = false; do { HEAPLIST32 currentHeap = new HEAPLIST32(); currentHeap.dwSize = (IntPtr)Marshal.SizeOf(typeof(HEAPLIST32)); moreHeaps = ErcCore.Heap32ListNext(Handle, ref currentHeap); if (HeapEntries.Count == 0) { currentHeap = firstHeapList; } if (moreHeaps) { HeapLists.Add(currentHeap); HEAPENTRY32 heapentry32 = new HEAPENTRY32(); heapentry32.dwSize = (IntPtr)Marshal.SizeOf(typeof(HEAPENTRY32)); if (ErcCore.Heap32First(ref heapentry32, (uint)HeapProcess.ProcessID, currentHeap.th32HeapID)) { bool moreheapblocks = false; do { HeapEntries.Add(heapentry32); moreheapblocks = ErcCore.Heap32Next(ref heapentry32); }while (moreheapblocks); } } }while (moreHeaps); } else { throw new ERCException("Heap32ListFirst returned an invalid response. Error: " + Utilities.Win32Errors.GetLastWin32Error()); } }