/// <summary> /// Reads from stream. /// </summary> /// <param name="stream">The stream.</param> /// <exception cref="System.IO.InvalidDataException">Version of object is not supported!</exception> private void ReadFromStream(System.IO.BinaryReader stream) { int version = stream.ReadInt32(); if (version <= 0 || version > StreamVersion) { throw new System.IO.InvalidDataException("Version of object is not supported!"); } this.FileVersion = new int[4]; for (int i = 0; i < 4; i++) { this.FileVersion[i] = stream.ReadInt32(); } { int count = stream.ReadInt32(); for (int i = 0; i < count; i++) { DebugTypeInfo dt = new DebugTypeInfo(); dt.ReadFromStream(stream); this.Types[dt.VTable] = dt; } } { int count = stream.ReadInt32(); for (int i = 0; i < count; i++) { var fi = new DebugFunctionInfo(); fi.ReadFromStream(stream); this.Functions.Add(fi); } } }
/// <summary> /// Adds the type information. /// </summary> /// <param name="vtable">The vtable.</param> /// <param name="name">The name.</param> internal void AddTypeInfo(ulong vtable, string name) { DebugTypeInfo dt = new DebugTypeInfo(); dt.Name = name; dt.VTable = vtable; this.Types[dt.VTable] = dt; }
/// <summary> /// Gets the type from vtable address. /// </summary> /// <param name="vtable">The vtable address.</param> /// <param name="withBaseOffset">Does the address include base offset of module?</param> /// <returns></returns> public DebugTypeInfo GetTypeInfo(IntPtr vtable, bool withBaseOffset) { ulong v = Main.Is64Bit ? vtable.ToUInt64() : vtable.ToUInt32(); if (withBaseOffset) { v = unchecked (v - this.BaseOffset); } DebugTypeInfo result = null; if (this.Types.TryGetValue(v, out result)) { return(result); } return(null); }