Inheritance: FileSegment
Exemplo n.º 1
0
        public static VTableHeader FromReadingContext(ReadingContext readingContext)
        {
            var tableHeader = new VTableHeader();
            tableHeader.Rva = readingContext.Reader.ReadUInt32();
            ushort size = readingContext.Reader.ReadUInt16();
            tableHeader.Attributes = (VTableAttributes) readingContext.Reader.ReadUInt16();

            long fileOffset = readingContext.Assembly.RvaToFileOffset(tableHeader.Rva);
            var tokensReader = readingContext.Reader.CreateSubReader(fileOffset, size * (tableHeader.Is32Bit ? sizeof (int) : sizeof (long)));

            for (int i = 0; i < size; i++)
            {
                var token = new MetadataToken(tokensReader.ReadUInt32());
                MetadataMember member;
                if (readingContext.Assembly.NetDirectory.MetadataHeader.GetStream<TableStream>()
                    .TryResolveMember(token, out member))
                {
                    tableHeader.Table.Add(member);
                }

                if (tableHeader.Is64Bit)
                    tokensReader.ReadUInt32();
            }

            return tableHeader;
        }
Exemplo n.º 2
0
        public static VTableHeader FromReadingContext(ReadingContext readingContext)
        {
            var tableHeader = new VTableHeader();

            tableHeader.Rva = readingContext.Reader.ReadUInt32();
            ushort size = readingContext.Reader.ReadUInt16();

            tableHeader.Attributes = (VTableAttributes)readingContext.Reader.ReadUInt16();

            long fileOffset   = readingContext.Assembly.RvaToFileOffset(tableHeader.Rva);
            var  tokensReader = readingContext.Reader.CreateSubReader(fileOffset, size * (tableHeader.Is32Bit ? sizeof(int) : sizeof(long)));

            for (int i = 0; i < size; i++)
            {
                var            token = new MetadataToken(tokensReader.ReadUInt32());
                MetadataMember member;
                if (readingContext.Assembly.NetDirectory.MetadataHeader.GetStream <TableStream>()
                    .TryResolveMember(token, out member))
                {
                    tableHeader.Table.Add(member);
                }

                if (tableHeader.Is64Bit)
                {
                    tokensReader.ReadUInt32();
                }
            }

            return(tableHeader);
        }