Example #1
0
 protected MetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(mdTable.Span)
 {
     this.buffer          = buffer;
     TablesStream         = tablesStream;
     this.stringsHeapSpan = stringsHeapSpan;
     this.guidHeapSpan    = guidHeapSpan;
     Rows       = mdTable.Rows;
     TableInfo  = CreateTableInfo(mdTable.TableInfo);
     Collection = new VirtualizedList <MetaDataTableRecordVM>((int)Rows, CreateItem);
 }
Example #2
0
        public PEStructureProviderImpl(HexBufferFile file, PeHeaders peHeaders)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }
            if (peHeaders == null)
            {
                throw new ArgumentNullException(nameof(peHeaders));
            }
            if (peHeaders != file.GetHeaders <PeHeaders>())
            {
                throw new ArgumentException();
            }
            this.file      = file;
            this.peHeaders = peHeaders;
            var buffer = file.Buffer;

            imageDosHeader  = new ImageDosHeaderVM(buffer, peHeaders.DosHeader);
            imageFileHeader = new ImageFileHeaderVM(buffer, peHeaders.FileHeader);
            if (peHeaders.OptionalHeader.Is32Bit)
            {
                imageOptionalHeader = new ImageOptionalHeader32VM(buffer, (PeOptionalHeader32Data)peHeaders.OptionalHeader);
            }
            else
            {
                imageOptionalHeader = new ImageOptionalHeader64VM(buffer, (PeOptionalHeader64Data)peHeaders.OptionalHeader);
            }
            sections = new ImageSectionHeaderVM[peHeaders.Sections.FieldCount];
            for (int i = 0; i < sections.Length; i++)
            {
                sections[i] = new ImageSectionHeaderVM(buffer, peHeaders.Sections[i].Data);
            }
            var dnHeaders = file.GetHeaders <DotNetHeaders>();

            storageStreams = Array.Empty <StorageStreamVM>();
            if (dnHeaders != null)
            {
                imageCor20Header = new ImageCor20HeaderVM(buffer, dnHeaders.Cor20);
                var mdHeaders = dnHeaders.MetadataHeaders;
                if (mdHeaders != null)
                {
                    storageSignature = new StorageSignatureVM(buffer, mdHeaders.MetadataHeader);
                    storageHeader    = new StorageHeaderVM(buffer, mdHeaders.MetadataHeader);
                    storageStreams   = new StorageStreamVM[mdHeaders.Streams.Count];
                    for (int i = 0; i < storageStreams.Length; i++)
                    {
                        var ssh  = mdHeaders.MetadataHeader.StreamHeaders.Data[i].Data;
                        var heap = mdHeaders.Streams[i];
                        storageStreams[i] = new StorageStreamVM(buffer, heap, ssh, i);
                    }

                    var metaDataTables = new MetaDataTableVM[0x40];
                    if (mdHeaders.TablesStream != null)
                    {
                        tablesStream = new TablesStreamVM(buffer, mdHeaders.TablesStream, metaDataTables);
                        var stringsHeapSpan = GetSpan(mdHeaders.StringsStream);
                        var guidHeapSpan    = GetSpan(mdHeaders.GUIDStream);
                        foreach (var mdTable in mdHeaders.TablesStream.MDTables)
                        {
                            if (mdTable.Rows != 0)
                            {
                                metaDataTables[(int)mdTable.Table] = MetaDataTableVM.Create(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan);
                            }
                        }
                    }
                }
            }
        }
Example #3
0
 public CustomDebugInformationMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #4
0
 public StateMachineMethodMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #5
0
 public ImportScopeMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #6
0
 public GenericParamConstraintMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #7
0
 public LocalConstantMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #8
0
 public ManifestResourceMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #9
0
 public NestedClassMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #10
0
 public MethodSemanticsMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #11
0
 public AssemblyRefOSMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #12
0
 public StandAloneSigMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #13
0
 public DeclSecurityMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #14
0
 public FieldMarshalMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #15
0
 public CustomAttributeMetaDataTableVM(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
     : base(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan)
 {
 }
Example #16
0
        public static MetaDataTableVM Create(HexBuffer buffer, TablesStreamVM tablesStream, MDTable mdTable, HexSpan stringsHeapSpan, HexSpan guidHeapSpan)
        {
            switch (mdTable.Table)
            {
            case Table.Module:                                      return(new ModuleMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.TypeRef:                                     return(new TypeRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.TypeDef:                                     return(new TypeDefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.FieldPtr:                            return(new FieldPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Field:                                       return(new FieldMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.MethodPtr:                           return(new MethodPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Method:                                      return(new MethodMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ParamPtr:                            return(new ParamPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Param:                                       return(new ParamMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.InterfaceImpl:                       return(new InterfaceImplMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.MemberRef:                           return(new MemberRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Constant:                            return(new ConstantMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.CustomAttribute:                     return(new CustomAttributeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.FieldMarshal:                        return(new FieldMarshalMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.DeclSecurity:                        return(new DeclSecurityMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ClassLayout:                         return(new ClassLayoutMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.FieldLayout:                         return(new FieldLayoutMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.StandAloneSig:                       return(new StandAloneSigMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.EventMap:                            return(new EventMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.EventPtr:                            return(new EventPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Event:                                       return(new EventMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.PropertyMap:                         return(new PropertyMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.PropertyPtr:                         return(new PropertyPtrMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Property:                            return(new PropertyMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.MethodSemantics:                     return(new MethodSemanticsMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.MethodImpl:                          return(new MethodImplMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ModuleRef:                           return(new ModuleRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.TypeSpec:                            return(new TypeSpecMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ImplMap:                                     return(new ImplMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.FieldRVA:                            return(new FieldRVAMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ENCLog:                                      return(new ENCLogMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ENCMap:                                      return(new ENCMapMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Assembly:                            return(new AssemblyMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.AssemblyProcessor:           return(new AssemblyProcessorMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.AssemblyOS:                          return(new AssemblyOSMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.AssemblyRef:                         return(new AssemblyRefMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.AssemblyRefProcessor:        return(new AssemblyRefProcessorMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.AssemblyRefOS:                       return(new AssemblyRefOSMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.File:                                        return(new FileMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ExportedType:                        return(new ExportedTypeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ManifestResource:            return(new ManifestResourceMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.NestedClass:                         return(new NestedClassMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.GenericParam:                        return(mdTable.Columns.Count == 5 ? (MetaDataTableVM) new GenericParamMetaDataTableV11VM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan) : new GenericParamMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.MethodSpec:                          return(new MethodSpecMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.GenericParamConstraint:      return(new GenericParamConstraintMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.Document:                            return(new DocumentMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.MethodDebugInformation:      return(new MethodDebugInformationMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.LocalScope:                          return(new LocalScopeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.LocalVariable:                       return(new LocalVariableMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.LocalConstant:                       return(new LocalConstantMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.ImportScope:                         return(new ImportScopeMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.StateMachineMethod:          return(new StateMachineMethodMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            case Table.CustomDebugInformation:      return(new CustomDebugInformationMetaDataTableVM(buffer, tablesStream, mdTable, stringsHeapSpan, guidHeapSpan));

            default:                                                        throw new InvalidOperationException();
            }
        }