コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reader">PE file reader pointing to the start of this section</param>
 /// <param name="runtime">Runtime reader kind</param>
 /// <param name="verify">Verify section</param>
 /// <exception cref="BadImageFormatException">Thrown if verification fails</exception>
 public MetadataHeader(ref DataReader reader, CLRRuntimeReaderKind runtime, 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, runtime);
     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, runtime, 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
        /// <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;
        }
コード例 #4
0
 /// <inheritdoc/>
 public GuidStream(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader)
     : base(mdReaderFactory, metadataBaseOffset, streamHeader)
 {
 }
コード例 #5
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)
 {
 }
コード例 #6
0
 void RecreateReader(DataReaderFactory mdReaderFactory, uint metadataBaseOffset, StreamHeader streamHeader, bool notifyThisClass)
 {
     if (mdReaderFactory is null || streamHeader is null)
     {
         dataReader = default;
     }
コード例 #7
0
 /// <summary>
 /// Default constructor
 /// </summary>
 protected DotNetStream()
 {
     streamHeader = null;
     dataReader   = default;
 }