Example #1
0
 /// <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;
 }
Example #2
0
 /// <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);
 }
Example #3
0
 /// <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;
     }
 }
Example #4
0
 /// <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;
 }
Example #5
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public DotNetStream()
 {
     this.imageStream  = MemoryImageStream.CreateEmpty();
     this.streamHeader = null;
 }
Example #6
0
 /// <inheritdoc/>
 protected HeapStream(IImageStream imageStream, StreamHeader streamHeader)
     : base(imageStream, streamHeader)
 {
 }
Example #7
0
 /// <inheritdoc/>
 public GuidStream(IImageStream imageStream, StreamHeader streamHeader)
     : base(imageStream, streamHeader)
 {
 }
Example #8
0
        /// <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);
            }
        }
Example #9
0
 /// <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)
 {
 }
Example #10
0
 /// <inheritdoc/>
 public BlobStream(IImageStream imageStream, StreamHeader streamHeader)
     : base(imageStream, streamHeader)
 {
 }
Example #11
0
 /// <inheritdoc/>
 public StringsStream(IImageStream imageStream, StreamHeader streamHeader)
     : base(imageStream, streamHeader)
 {
 }
Example #12
0
 /// <inheritdoc/>
 public TablesStream(IImageStream imageStream, StreamHeader streamHeader)
     : base(imageStream, streamHeader)
 {
 }