Exemplo n.º 1
0
        internal AssemblyDefinition(MetadataImage image, MetadataRow <AssemblyHashAlgorithm, ushort, ushort, ushort, ushort, AssemblyAttributes, uint, uint, uint> row)
            : base(row.MetadataToken)
        {
            Image = image;
            var tableStream  = image.Header.GetStream <TableStream>();
            var stringStream = image.Header.GetStream <StringStream>();
            var blobStream   = image.Header.GetStream <BlobStream>();

            HashAlgorithm = row.Column1;
            Version       = new Version(row.Column2, row.Column3, row.Column4, row.Column5);
            Attributes    = row.Column6;

            _publicKey = new LazyValue <DataBlobSignature>(() =>
                                                           row.Column7 == 0 ? null : DataBlobSignature.FromReader(blobStream.CreateBlobReader(row.Column7)));

            _name = new LazyValue <string>(() =>
                                           stringStream.GetStringByOffset(row.Column8));

            _culture = new LazyValue <string>(() =>
                                              stringStream.GetStringByOffset(row.Column9));

            Modules = new TableMemberCollection <AssemblyDefinition, ModuleDefinition>(
                this, tableStream.GetTable(MetadataTokenType.Module), GetModuleOwner, SetModuleOwner);

            AssemblyReferences = new TableMemberCollection <AssemblyDefinition, AssemblyReference>(
                this, tableStream.GetTable(MetadataTokenType.AssemblyRef), GetReferenceOwner, SetReferenceOwner);

            ModuleReferences = new TableMemberCollection <AssemblyDefinition, ModuleReference>(
                this, tableStream.GetTable(MetadataTokenType.ModuleRef), GetReferenceOwner, SetReferenceOwner);

            Resources = new TableMemberCollection <AssemblyDefinition, ManifestResource>(
                this, tableStream.GetTable(MetadataTokenType.ManifestResource), GetResourceOwner, SetResourceOwner);

            Files = new TableMemberCollection <AssemblyDefinition, FileReference>(
                this, tableStream.GetTable(MetadataTokenType.File), GetFileOwner, SetFileOwner);

            CustomAttributes     = new CustomAttributeCollection(this);
            SecurityDeclarations = new SecurityDeclarationCollection(this);

            OperatingSystems = new TableMemberCollection <AssemblyDefinition, AssemblyOs>(
                this, tableStream.GetTable(MetadataTokenType.AssemblyOs), GetOsOwner, SetOsOwner);

            Processors = new TableMemberCollection <AssemblyDefinition, AssemblyProcessor>(
                this, tableStream.GetTable(MetadataTokenType.AssemblyProcessor), GetProcessorOwner, SetProcessorOwner);
        }
Exemplo n.º 2
0
        internal AssemblyReference(MetadataImage image, MetadataRow <ushort, ushort, ushort, ushort, AssemblyAttributes, uint, uint, uint, uint> row)
            : base(row.MetadataToken)
        {
            var stringStream = image.Header.GetStream <StringStream>();
            var blobStream   = image.Header.GetStream <BlobStream>();

            Version    = new Version(row.Column1, row.Column2, row.Column3, row.Column4);
            Attributes = row.Column5;
            _publicKey = new LazyValue <DataBlobSignature>(() => row.Column6 == 0 ? null : DataBlobSignature.FromReader(blobStream.CreateBlobReader(row.Column6)));
            _name      = new LazyValue <string>(() => stringStream.GetStringByOffset(row.Column7));
            _culture   = new LazyValue <string>(() => stringStream.GetStringByOffset(row.Column8));
            _hashValue = new LazyValue <DataBlobSignature>(() => row.Column9 == 0 ? null : DataBlobSignature.FromReader(blobStream.CreateBlobReader(row.Column9)));

            Referrer         = image.Assembly;
            CustomAttributes = new CustomAttributeCollection(this);
            OperatingSystems = new TableMemberCollection <AssemblyReference, AssemblyRefOs>(this, MetadataTokenType.AssemblyRefOs, GetOsOwner, SetOsOwner);
            Processors       = new TableMemberCollection <AssemblyReference, AssemblyRefProcessor>(this, MetadataTokenType.AssemblyRefProcessor, GetProcessorOwner, SetProcessorOwner);
        }