コード例 #1
0
        public MetadataEditor(RawModuleBytes moduleData, Metadata metadata)
        {
            this.moduleData = moduleData ?? throw new ArgumentNullException(nameof(moduleData));
            this.metadata   = metadata ?? throw new ArgumentNullException(nameof(metadata));

            heaps = new List <MDHeap>(metadata.AllStreams.Count);
            foreach (var stream in metadata.AllStreams)
            {
                switch (stream)
                {
                case BlobStream blobStream:
                    heaps.Add(BlobHeap = new BlobMDHeap(this, blobStream));
                    break;

                case GuidStream guidStream:
                    heaps.Add(GuidHeap = new GuidMDHeap(this, guidStream));
                    break;

                case StringsStream stringsStream:
                    heaps.Add(StringsHeap = new StringsMDHeap(this, stringsStream));
                    break;

                case USStream usStream:
                    heaps.Add(USHeap = new USMDHeap(this, usStream));
                    break;

                case TablesStream tablesStream:
                    heaps.Add(TablesHeap = new TablesMDHeap(this, tablesStream));
                    break;

                default:
                    heaps.Add(new UnknownMDHeap(this, stream));
                    break;
                }
            }
            if (BlobHeap == null)
            {
                heaps.Add(BlobHeap = new BlobMDHeap(this, metadata.BlobStream));
            }
            if (GuidHeap == null)
            {
                heaps.Add(GuidHeap = new GuidMDHeap(this, metadata.GuidStream));
            }
            if (StringsHeap == null)
            {
                heaps.Add(StringsHeap = new StringsMDHeap(this, metadata.StringsStream));
            }
            if (USHeap == null)
            {
                heaps.Add(USHeap = new USMDHeap(this, metadata.USStream));
            }
            if (TablesHeap == null)
            {
                throw new InvalidOperationException();
            }
        }
コード例 #2
0
 public TablesHeapWriter(TablesMDHeap tablesHeap, StringsMDHeap stringsHeap, GuidMDHeap guidHeap, BlobMDHeap blobHeap)
 {
     this.tablesHeap  = tablesHeap;
     this.stringsHeap = stringsHeap;
     this.guidHeap    = guidHeap;
     this.blobHeap    = blobHeap;
     if (stringsHeap.IsBig)
     {
         mdStreamFlags |= MDStreamFlags.BigStrings;
     }
     if (guidHeap.IsBig)
     {
         mdStreamFlags |= MDStreamFlags.BigGUID;
     }
     if (blobHeap.IsBig)
     {
         mdStreamFlags |= MDStreamFlags.BigBlob;
     }
 }