private bool GetMethodTables(ulong obj, out ulong mt, out ulong cmt) { mt = 0; cmt = 0; byte[] data = new byte[IntPtr.Size * 3]; // TODO assumes bitness same as dump if (!_runtime.ReadMemory(obj, data, data.Length, out int read) || read != data.Length) { return(false); } if (IntPtr.Size == 4) { mt = BitConverter.ToUInt32(data, 0); } else { mt = BitConverter.ToUInt64(data, 0); } if (mt == _runtime.ArrayMethodTable) { if (IntPtr.Size == 4) { cmt = BitConverter.ToUInt32(data, 2 * IntPtr.Size); } else { cmt = BitConverter.ToUInt64(data, 2 * IntPtr.Size); } } return(true); }
private GCDesc FillGCDesc() { DesktopRuntimeBase runtime = DesktopHeap.DesktopRuntime; Debug.Assert(_constructedMT != 0, "Attempted to fill GC desc with a constructed (not real) type."); if (!runtime.ReadDword(_constructedMT - (ulong)IntPtr.Size, out int entries)) { return(null); } // Get entries in map if (entries < 0) { entries = -entries; } int slots = 1 + entries * 2; byte[] buffer = new byte[slots * IntPtr.Size]; if (!runtime.ReadMemory(_constructedMT - (ulong)(slots * IntPtr.Size), buffer, buffer.Length, out int read) || read != buffer.Length) { return(null); } // Construct the gc desc return(new GCDesc(buffer)); }