public MetaDataHeader(AssemblyBuffer buffer, CLRHeader clrHeader, SectionsHeaders sectionsHeaders)
        {
            buffer.SetIndexPointer(clrHeader.MetaData.RVA - 0x1E00);
            this.Signature       = buffer.ReadDWord();
            this.MajorVersion    = buffer.ReadWord();
            this.MinorVersion    = buffer.ReadWord();
            this.Reserved        = buffer.ReadDWord();
            this.VersionLength   = buffer.ReadDWord();
            this.VersionString   = buffer.ReadStringOfLength(this.VersionLength);
            this.Flags           = buffer.ReadWord();
            this.NumberOfStreams = buffer.ReadWord();

            this.Streams = new StreamHeader[this.NumberOfStreams];

            this.Streams[(uint)MetaDataStreamType.DEFS_AND_REFS] = new DefsAndRefsStream(buffer, clrHeader, this);
            this.Streams[(uint)MetaDataStreamType.STRINGS]       = new StringStream(buffer, clrHeader);
            // These are boiler plate.
            this.Streams[(uint)MetaDataStreamType.US]   = new StringStream(buffer, clrHeader);
            this.Streams[(uint)MetaDataStreamType.GUID] = new StringStream(buffer, clrHeader);
            this.Streams[(uint)MetaDataStreamType.BLOB] = new BlobStream(buffer, clrHeader);

            // There is a specific load order for each stream. Therefore I'm not going to iterate over them.

            this.Streams[(uint)MetaDataStreamType.STRINGS].CacheBuffer(buffer);
            this.Streams[(uint)MetaDataStreamType.STRINGS].ProcessTables(buffer);

            this.Streams[(uint)MetaDataStreamType.BLOB].CacheBuffer(buffer);
            this.Streams[(uint)MetaDataStreamType.BLOB].ProcessTables(buffer);

            this.Streams[(uint)MetaDataStreamType.DEFS_AND_REFS].CacheBuffer(buffer);
            this.Streams[(uint)MetaDataStreamType.DEFS_AND_REFS].ProcessTables(buffer);
        }
Example #2
0
 public Section(AssemblyBuffer buffer)
 {
     this.Name                = buffer.ReadStringOfLength(8);
     this.VirtualSize         = buffer.ReadDWord();
     this.VirtualAddress      = buffer.ReadDWord();
     this.SizeOfRawData       = buffer.ReadDWord();
     this.PointerToRawData    = buffer.ReadDWord();
     this.RelocationAddress   = buffer.ReadDWord();
     this.LineNumbersAddress  = buffer.ReadDWord();
     this.NumberOfRelocations = buffer.ReadWord();
     this.NumberOfLineNumbers = buffer.ReadWord();
     this.Characteristics     = buffer.ReadDWord();
 }