/// <summary> /// Constructor /// </summary> /// <param name="imageStream">Heap stream</param> /// <param name="streamHeader">Stream header info</param> /// <param name="fullStream">Stream for the full PE file</param> /// <param name="baseOffset">Offset in <paramref name="fullStream"/> where the data starts</param> protected HotStream(IImageStream imageStream, StreamHeader streamHeader, IImageStream fullStream, FileOffset baseOffset) : base(imageStream, streamHeader) { this.fullStream = fullStream; this.baseOffset = (long)baseOffset; this.endOffset = (long)baseOffset + imageStream.Length; }
/// <summary> /// Constructor /// </summary> /// <param name="reader">PE file reader pointing to the start of this section</param> /// <param name="verify">Verify section</param> /// <exception cref="BadImageFormatException">Thrown if verification fails</exception> public MetaDataHeader(IImageStream reader, bool verify) { SetStartOffset(reader); this.signature = reader.ReadUInt32(); if (verify && this.signature != 0x424A5342) { throw new BadImageFormatException("Invalid MetaData header signature"); } this.majorVersion = reader.ReadUInt16(); this.minorVersion = reader.ReadUInt16(); if (verify && !((majorVersion == 1 && minorVersion == 1) || (majorVersion == 0 && minorVersion >= 19))) { throw new BadImageFormatException(string.Format("Unknown MetaData header version: {0}.{1}", majorVersion, minorVersion)); } this.reserved1 = reader.ReadUInt32(); this.stringLength = reader.ReadUInt32(); this.versionString = ReadString(reader, stringLength); this.offset2ndPart = reader.FileOffset + reader.Position; this.flags = (StorageFlags)reader.ReadByte(); this.reserved2 = reader.ReadByte(); this.streams = reader.ReadUInt16(); this.streamHeaders = new StreamHeader[streams]; for (int i = 0; i < streamHeaders.Count; i++) { streamHeaders[i] = new StreamHeader(reader, verify); } SetEndoffset(reader); }
/// <summary> /// Dispose method /// </summary> /// <param name="disposing"><c>true</c> if called by <see cref="Dispose()"/></param> protected virtual void Dispose(bool disposing) { if (disposing) { var ims = imageStream; if (ims != null) { ims.Dispose(); } imageStream = null; streamHeader = null; } }
/// <summary> /// Constructor /// </summary> /// <param name="imageStream">Stream data</param> /// <param name="streamHeader">The stream header</param> public DotNetStream(IImageStream imageStream, StreamHeader streamHeader) { this.imageStream = imageStream; this.streamHeader = streamHeader; }
/// <summary> /// Default constructor /// </summary> public DotNetStream() { this.imageStream = MemoryImageStream.CreateEmpty(); this.streamHeader = null; }
/// <inheritdoc/> protected HeapStream(IImageStream imageStream, StreamHeader streamHeader) : base(imageStream, streamHeader) { }
/// <inheritdoc/> public GuidStream(IImageStream imageStream, StreamHeader streamHeader) : base(imageStream, streamHeader) { }
/// <summary> /// Creates a <see cref="HotStream"/> instance /// </summary> /// <param name="version">Hot heap version</param> /// <param name="imageStream">Heap stream</param> /// <param name="streamHeader">Stream header info</param> /// <param name="fullStream">Stream for the full PE file</param> /// <param name="baseOffset">Offset in <paramref name="fullStream"/> where the data starts</param> /// <returns>A <see cref="HotStream"/> instance or <c>null</c> if <paramref name="version"/> /// is invalid</returns> public static HotStream Create(HotHeapVersion version, IImageStream imageStream, StreamHeader streamHeader, IImageStream fullStream, FileOffset baseOffset) { switch (version) { case HotHeapVersion.CLR20: return(new HotStreamCLR20(imageStream, streamHeader, fullStream, baseOffset)); case HotHeapVersion.CLR40: return(new HotStreamCLR40(imageStream, streamHeader, fullStream, baseOffset)); default: return(null); } }
/// <summary> /// Constructor /// </summary> /// <param name="imageStream">Heap stream</param> /// <param name="streamHeader">Stream header info</param> /// <param name="fullStream">Stream for the full PE file</param> /// <param name="baseOffset">Offset in <paramref name="fullStream"/> where the data starts</param> public HotStreamCLR40(IImageStream imageStream, StreamHeader streamHeader, IImageStream fullStream, FileOffset baseOffset) : base(imageStream, streamHeader, fullStream, baseOffset) { }
/// <inheritdoc/> public BlobStream(IImageStream imageStream, StreamHeader streamHeader) : base(imageStream, streamHeader) { }
/// <inheritdoc/> public StringsStream(IImageStream imageStream, StreamHeader streamHeader) : base(imageStream, streamHeader) { }
/// <inheritdoc/> public TablesStream(IImageStream imageStream, StreamHeader streamHeader) : base(imageStream, streamHeader) { }