コード例 #1
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(ref DataReader reader, bool verify)
 {
     SetStartOffset(ref reader);
     signature = reader.ReadUInt32();
     if (verify && signature != 0x424A5342)
     {
         throw new BadImageFormatException("Invalid metadata header signature");
     }
     majorVersion  = reader.ReadUInt16();
     minorVersion  = reader.ReadUInt16();
     reserved1     = reader.ReadUInt32();
     stringLength  = reader.ReadUInt32();
     versionString = ReadString(ref reader, stringLength);
     offset2ndPart = (FileOffset)reader.CurrentOffset;
     flags         = (StorageFlags)reader.ReadByte();
     reserved2     = reader.ReadByte();
     streams       = reader.ReadUInt16();
     streamHeaders = new StreamHeader[streams];
     for (int i = 0; i < streamHeaders.Count; i++)
     {
         // Mono doesn't verify all of these so we can't either
         var sh = new StreamHeader(ref reader, throwOnError: false, verify, out bool failedVerification);
         if (failedVerification || (ulong)sh.Offset + sh.StreamSize > reader.EndOffset)
         {
             sh = new StreamHeader(0, 0, "<invalid>");
         }
         streamHeaders[i] = sh;
     }
     SetEndoffset(ref reader);
 }
コード例 #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="mdReaderFactory">Data reader factory</param>
 /// <param name="metadataBaseOffset">Offset of metadata</param>
 /// <param name="streamHeader">The stream header</param>
 protected DotNetStream(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader)
 {
     this.mdReaderFactory = mdReaderFactory;
     mdReaderFactory.DataReaderInvalidated += DataReaderFactory_DataReaderInvalidated;
     this.mdReaderFactory    = mdReaderFactory;
     this.metadataBaseOffset = metadataBaseOffset;
     this.streamHeader       = streamHeader;
     RecreateReader(mdReaderFactory, metadataBaseOffset, streamHeader, notifyThisClass: false);
 }
コード例 #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 mdReaderFactory = this.mdReaderFactory;
         if (mdReaderFactory != null)
         {
             mdReaderFactory.DataReaderInvalidated -= DataReaderFactory_DataReaderInvalidated;
         }
         streamHeader         = null;
         this.mdReaderFactory = null;
     }
 }
コード例 #4
0
        /// <inheritdoc/>
        public PdbStream(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader)
            : base(mdReaderFactory, metadataBaseOffset, streamHeader)
        {
            var reader = CreateReader();

            Id         = reader.ReadBytes(20);
            EntryPoint = new MDToken(reader.ReadUInt32());
            var tables = reader.ReadUInt64();

            ReferencedTypeSystemTables = tables;
            var rows = new uint[64];

            for (int i = 0; i < rows.Length; i++, tables >>= 1)
            {
                if (((uint)tables & 1) != 0)
                {
                    rows[i] = reader.ReadUInt32();
                }
            }
            TypeSystemTableRows = rows;
        }
コード例 #5
0
 void RecreateReader(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader, bool notifyThisClass)
 {
     if (mdReaderFactory == null || streamHeader == null)
     {
         dataReader = default;
     }
     else
     {
         dataReader = mdReaderFactory.CreateReader(metadataBaseOffset + streamHeader.Offset, streamHeader.StreamSize);
     }
     if (notifyThisClass)
     {
         OnReaderRecreated();
     }
 }
コード例 #6
0
 /// <summary>
 /// Default constructor
 /// </summary>
 protected DotNetStream()
 {
     streamHeader = null;
     dataReader   = default;
 }
コード例 #7
0
 /// <inheritdoc/>
 protected HeapStream(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader)
     : base(mdReaderFactory, metadataBaseOffset, streamHeader)
 {
 }
コード例 #8
0
 /// <inheritdoc/>
 public StringsStream(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader)
     : base(mdReaderFactory, metadataBaseOffset, streamHeader)
 {
 }
コード例 #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="mdReaderFactory">Data reader factory</param>
 /// <param name="metadataBaseOffset">Offset of metadata</param>
 /// <param name="streamHeader">The stream header</param>
 public CustomDotNetStream(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader)
     : base(mdReaderFactory, metadataBaseOffset, streamHeader)
 {
 }