public override uint GetElementByteCount()
 {
     return(sizeof(ushort) +
            (uint)TableStream.GetIndexEncoder(CodedIndex.MemberForwarded).IndexSize +
            (uint)TableStream.StringIndexSize +
            (uint)TableStream.GetTable <ModuleReference>().IndexSize);
 }
Beispiel #2
0
        public override uint GetElementByteCount()
        {
            var definitionTable = TableStream.GetTable <TypeDefinition>();

            return((uint)definitionTable.IndexSize +
                   (uint)definitionTable.IndexSize);
        }
Beispiel #3
0
        protected override void UpdateMember(NetBuildingContext context, FieldMarshal member)
        {
            var row = member.MetadataRow;

            row.Column1 = TableStream.GetIndexEncoder(CodedIndex.HasFieldMarshal).EncodeToken(member.Parent.MetadataToken);
            row.Column2 = context.GetStreamBuffer <BlobStreamBuffer>().GetBlobOffset(member.MarshalDescriptor);
        }
Beispiel #4
0
 public TsProgram(ushort programNumber, TableStream programMapStream)
 {
     ProgramNumber    = programNumber;
     ProgramMapStream = programMapStream;
     ProgramMapStream.UnitReceived += ProgramMapTableReceived;
     Streams = new List <TsStream>();
 }
Beispiel #5
0
 public override uint GetElementByteCount()
 {
     return(sizeof(ushort) +
            sizeof(ushort) +
            (uint)TableStream.GetIndexEncoder(CodedIndex.TypeOrMethodDef).IndexSize +
            (uint)TableStream.StringIndexSize);
 }
Beispiel #6
0
 public override uint GetElementByteCount()
 {
     return(sizeof(uint) +
            sizeof(uint) +
            (uint)TableStream.StringIndexSize +
            (uint)TableStream.GetIndexEncoder(CodedIndex.Implementation).IndexSize);
 }
Beispiel #7
0
        protected override void WriteRow(WritingContext context, MetadataRow <uint, uint> row)
        {
            var writer = context.Writer;

            writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.HasFieldMarshal).IndexSize, row.Column1);
            writer.WriteIndex(TableStream.BlobIndexSize, row.Column2);
        }
        protected override void WriteRow(WritingContext context, MetadataRow <uint, uint> row)
        {
            var writer = context.Writer;

            writer.WriteIndex(TableStream.GetTable(MetadataTokenType.Method).IndexSize, row.Column1);
            writer.WriteIndex(TableStream.BlobIndexSize, row.Column2);
        }
Beispiel #9
0
 protected override PropertyPtr ReadMember(MetadataToken token, ReadingContext context)
 {
     return(new PropertyPtr(Header, token, new MetadataRow <uint>()
     {
         Column1 = context.Reader.ReadIndex(TableStream.GetTable <PropertyDefinition>().IndexSize)
     }));
 }
Beispiel #10
0
 public TsProgram(ushort programNumber, TableStream programMapStream)
 {
     ProgramNumber = programNumber;
     ProgramMapStream = programMapStream;
     ProgramMapStream.UnitReceived += ProgramMapTableReceived;
     Streams = Portability.CreateList<TsStream>();
 }
Beispiel #11
0
        protected override void UpdateMember(NetBuildingContext context, MethodSpecification member)
        {
            var row = member.MetadataRow;

            row.Column1 = TableStream.GetIndexEncoder(CodedIndex.MethodDefOrRef).EncodeToken(member.Method.MetadataToken);
            row.Column2 = context.GetStreamBuffer <BlobStreamBuffer>().GetBlobOffset(member.Signature);
        }
Beispiel #12
0
 public override uint GetElementByteCount()
 {
     return(sizeof(byte) +
            sizeof(byte) +
            (uint)TableStream.GetIndexEncoder(CodedIndex.HasConstant).IndexSize +
            (uint)TableStream.BlobIndexSize);
 }
Beispiel #13
0
 public override uint GetElementByteCount()
 {
     return(sizeof(uint) +
            sizeof(uint) +
            sizeof(uint) +
            (uint)TableStream.GetTable <AssemblyReference>().IndexSize);
 }
        protected override void WriteRow(WritingContext context, MetadataRow <uint, uint> row)
        {
            var writer = context.Writer;

            writer.WriteIndex(TableStream.GetTable(MetadataTokenType.TypeDef).IndexSize, row.Column1);
            writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.TypeDefOrRef).IndexSize, row.Column2);
        }
Beispiel #15
0
 protected override MetadataRow <uint> ReadRow(ReadingContext context, MetadataToken token)
 {
     return(new MetadataRow <uint>(token)
     {
         Column1 = context.Reader.ReadIndex(TableStream.GetTable(MetadataTokenType.Field).IndexSize)
     });
 }
Beispiel #16
0
        protected override void WriteRow(WritingContext context, MetadataRow <DataSegment, uint> row)
        {
            var writer = context.Writer;

            writer.WriteUInt32((uint)row.Column1.GetRva(context.Assembly));
            writer.WriteIndex(TableStream.GetTable(MetadataTokenType.Field).IndexSize, row.Column2);
        }
Beispiel #17
0
 protected override void WriteRow(WritingContext context, MetadataRow<EventAttributes, uint, uint> row)
 {
     var writer = context.Writer;
     writer.WriteUInt16((ushort) row.Column1);
     writer.WriteIndex(TableStream.StringIndexSize, row.Column2);
     writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.TypeDefOrRef).IndexSize, row.Column3);
 }
        protected override void WriteMember(WritingContext context, InterfaceImplementation member)
        {
            var writer = context.Writer;
            var row    = member.MetadataRow;

            writer.WriteIndex(TableStream.GetTable <TypeDefinition>().IndexSize, row.Column1);
            writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.TypeDefOrRef).IndexSize, row.Column2);
        }
Beispiel #19
0
        protected override void UpdateMember(NetBuildingContext context, Constant member)
        {
            var row = member.MetadataRow;

            row.Column1 = (byte)member.ConstantType;
            row.Column3 = TableStream.GetIndexEncoder(CodedIndex.HasConstant).EncodeToken(member.Parent.MetadataToken);
            row.Column4 = context.GetStreamBuffer <BlobStreamBuffer>().GetBlobOffset(member.Value);
        }
Beispiel #20
0
        protected override void WriteRow(WritingContext context, MetadataRow <ushort, uint, uint> row)
        {
            var writer = context.Writer;

            writer.WriteUInt16(row.Column1);
            writer.WriteUInt32(row.Column2);
            writer.WriteIndex(TableStream.GetTable(MetadataTokenType.TypeDef).IndexSize, row.Column3);
        }
Beispiel #21
0
        protected override void WriteMember(WritingContext context, AssemblyRefProcessor member)
        {
            var writer = context.Writer;
            var row    = member.MetadataRow;

            writer.WriteUInt32(row.Column1);
            writer.WriteIndex(TableStream.GetTable <AssemblyReference>().IndexSize, row.Column2);
        }
Beispiel #22
0
        protected override void WriteMember(WritingContext context, MethodSpecification member)
        {
            var writer = context.Writer;
            var row    = member.MetadataRow;

            writer.WriteIndex(TableStream.GetTable <MethodDefinition>().IndexSize, row.Column1);
            writer.WriteIndex(TableStream.BlobIndexSize, row.Column2);
        }
Beispiel #23
0
 public ReferenceImporter(TableStream tableStreamBuffer, SignatureComparer signatureComparer)
 {
     if (tableStreamBuffer == null)
         throw new ArgumentNullException("tableStreamBuffer");
     _tableStreamBuffer = tableStreamBuffer;
     _signatureComparer = signatureComparer;
     _typeSystem = tableStreamBuffer.StreamHeader.MetadataHeader.TypeSystem;
 }
Beispiel #24
0
        protected override void WriteRow(WritingContext context, MetadataRow <uint, uint> row)
        {
            var writer          = context.Writer;
            var definitionTable = TableStream.GetTable(MetadataTokenType.TypeDef);

            writer.WriteIndex(definitionTable.IndexSize, row.Column1);
            writer.WriteIndex(definitionTable.IndexSize, row.Column2);
        }
        protected override void UpdateMember(NetBuildingContext context, InterfaceImplementation member)
        {
            var row = member.MetadataRow;

            row.Column1 = member.Class.MetadataToken.Rid;
            row.Column2 = TableStream.GetIndexEncoder(CodedIndex.TypeDefOrRef)
                          .EncodeToken(member.Interface.MetadataToken);
        }
Beispiel #26
0
        protected override void WriteMember(WritingContext context, FieldRva member)
        {
            var writer = context.Writer;
            var row    = member.MetadataRow;

            writer.WriteUInt32(row.Column1);
            writer.WriteIndex(TableStream.GetTable <FieldDefinition>().IndexSize, row.Column2);
        }
Beispiel #27
0
        protected override void WriteMember(WritingContext context, PropertyMap member)
        {
            var writer = context.Writer;
            var row    = member.MetadataRow;

            writer.WriteIndex(TableStream.GetTable <TypeDefinition>().IndexSize, row.Column1);
            writer.WriteIndex(TableStream.GetTable <PropertyDefinition>().IndexSize, row.Column2);
        }
Beispiel #28
0
        protected override void WriteRow(WritingContext context, MetadataRow <uint, uint, uint> row)
        {
            var writer = context.Writer;

            writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.MemberRefParent).IndexSize, row.Column1);
            writer.WriteIndex(TableStream.StringIndexSize, row.Column2);
            writer.WriteIndex(TableStream.BlobIndexSize, row.Column3);
        }
Beispiel #29
0
        protected override void WriteMember(WritingContext context, FieldMarshal member)
        {
            var writer = context.Writer;
            var row    = member.MetadataRow;

            writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.HasFieldMarshal).IndexSize, row.Column1);
            writer.WriteIndex(TableStream.BlobIndexSize, row.Column2);
        }
Beispiel #30
0
        protected override void WriteMember(WritingContext context, GenericParameterConstraint member)
        {
            var writer = context.Writer;
            var row    = member.MetadataRow;

            writer.WriteIndex(TableStream.GetTable <GenericParameter>().IndexSize, row.Column1);
            writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.TypeDefOrRef).IndexSize, row.Column2);
        }
Beispiel #31
0
        protected override void UpdateMember(NetBuildingContext context, GenericParameterConstraint member)
        {
            var row = member.MetadataRow;

            row.Column1 = member.Owner.MetadataToken.Rid;
            row.Column2 = TableStream.GetIndexEncoder(CodedIndex.TypeDefOrRef)
                          .EncodeToken(member.Constraint.MetadataToken);
        }
        protected override void WriteRow(WritingContext context, MetadataRow <SecurityAction, uint, uint> row)
        {
            var writer = context.Writer;

            writer.WriteUInt16((ushort)row.Column1);
            writer.WriteIndex(TableStream.GetIndexEncoder(CodedIndex.HasDeclSecurity).IndexSize, row.Column2);
            writer.WriteIndex(TableStream.BlobIndexSize, row.Column3);
        }
Beispiel #33
0
        public IndexEncoder(TableStream tableStream, params MetadataTokenType[] tables)
        {
            if (tableStream == null)
                throw new ArgumentNullException("tableStream");
            if (tables == null)
                throw new ArgumentNullException("tables");
            _tableStream = tableStream;
            _tables = tables;

            _tableIndexBitCount = (int)Math.Ceiling(Math.Log(tables.Length, 2));
            _tableIndexBitMask = (int)(Math.Pow(2, _tableIndexBitCount) - 1);
            _maxSmallTableMemberCount = ushort.MaxValue >> _tableIndexBitCount;
        }
Beispiel #34
0
        public TsDemuxer()
        {
            Programs = Portability.CreateList<TsProgram>();

            var programAssociationStream = new TableStream()
                                               {PacketIdentifier = (ushort) PacketIdentifier.ProgramAssociationTable};
            programAssociationStream.UnitReceived += ProgramAssociationTableReceived;
            _streams.Add((ushort) PacketIdentifier.ProgramAssociationTable, programAssociationStream);

            var descriptionStream = new TableStream() {PacketIdentifier = (ushort) PacketIdentifier.TsDescriptionTable};
            descriptionStream.UnitReceived += DescriptionTableReceived;
            _streams.Add((ushort) PacketIdentifier.TsDescriptionTable, descriptionStream);
        }
        private static void InitializeMetadata(MetadataHeader header)
        {
            header.Signature = 0x424A5342;
            header.MajorVersion = 1;
            header.MinorVersion = 1;
            header.VersionLength = 0xC;
            header.VersionString = "v4.0.30319";
            header.Flags = 0;

            var tableStream = new TableStream
            {
                SortedBitVector = 0x000016003325FA00,
                MajorVersion = 2,
                Reserved2 = 1
            };

            header.StreamHeaders.Add(new MetadataStreamHeader("#~", tableStream));
            header.StreamHeaders.Add(new MetadataStreamHeader("#Strings", new StringStream()));
            header.StreamHeaders.Add(new MetadataStreamHeader("#US", new UserStringStream()));
            header.StreamHeaders.Add(new MetadataStreamHeader("#GUID", new GuidStream()));
            header.StreamHeaders.Add(new MetadataStreamHeader("#Blob", new BlobStream()));
        }
Beispiel #36
0
 public ReferenceImporter(TableStream tableStreamBuffer)
     : this(tableStreamBuffer, new SignatureComparer())
 {
 }