Example #1
0
 internal FileDefinition(MetadataHeader header, MetadataToken token, MetadataRow <uint, uint, uint> row)
     : base(header, token, row)
 {
     Attributes = (FileAttributes)row.Column1;
     _name      = new LazyValue <string>(() => header.GetStream <StringStream>().GetStringByOffset(row.Column2));
     _hashValue = new LazyValue <DataBlobSignature>(() =>
                                                    DataBlobSignature.FromReader(header.GetStream <BlobStream>().CreateBlobReader(row.Column3)));
 }
Example #2
0
        /// <inheritdoc />
        protected override DataBlobSignature GetValue()
        {
            var reader = _parentModule.DotNetDirectory.Metadata
                         .GetStream <BlobStream>()
                         .GetBlobReaderByIndex(_row.Value);

            return(reader is null
                ? null
                : DataBlobSignature.FromReader(reader));
        }
Example #3
0
        internal FileReference(MetadataImage image, MetadataRow <FileAttributes, uint, uint> row)
            : base(row.MetadataToken)
        {
            _image     = image;
            Attributes = row.Column1;

            _name = new LazyValue <string>(()
                                           => image.Header.GetStream <StringStream>().GetStringByOffset(row.Column2));

            _hashValue = new LazyValue <DataBlobSignature>(() =>
                                                           DataBlobSignature.FromReader(image.Header.GetStream <BlobStream>().CreateBlobReader(row.Column3)));

            CustomAttributes = new CustomAttributeCollection(this);
        }
Example #4
0
        internal Constant(MetadataHeader header, MetadataToken token, MetadataRow <byte, byte, uint, uint> row)
            : base(header, token, row)
        {
            ConstantType = (ElementType)row.Column1;

            _parent = new LazyValue <IHasConstant>(() =>
            {
                var tableStream      = header.GetStream <TableStream>();
                var hasConstantToken = tableStream.GetIndexEncoder(CodedIndex.HasConstant).DecodeIndex(row.Column3);
                return(hasConstantToken.Rid != 0 ? (IHasConstant)tableStream.ResolveMember(hasConstantToken) : null);
            });

            _value = new LazyValue <DataBlobSignature>(() =>
                                                       DataBlobSignature.FromReader(header.GetStream <BlobStream>().CreateBlobReader(row.Column4)));
        }
Example #5
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);
        }
Example #6
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);
        }
Example #7
0
        internal AssemblyDefinition(MetadataHeader header, MetadataToken token,
                                    MetadataRow <uint, ushort, ushort, ushort, ushort, uint, uint, uint, uint> row)
            : base(header, token, row)
        {
            var stringStream = header.GetStream <StringStream>();
            var blobStream   = header.GetStream <BlobStream>();

            HashAlgorithm = (AssemblyHashAlgorithm)row.Column1;
            Version       = new Version(row.Column2, row.Column3, row.Column4, row.Column5);
            Attributes    = (AssemblyAttributes)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));
        }