Esempio n. 1
0
 public override void Parse(CLRMetaDataParser parser)
 {
     Parent = parser.ReadHasCustomAttribute();
     Constructor = parser.ReadCustomAttributeType();
     m_rawValue = parser.ReadBlob();
     m_tables = parser.Tables;
 }
Esempio n. 2
0
 public CLRSignatureParser(ArraySegment<byte> seg, CLRMetaDataTables tables)
 {
     byte[] hack = new byte[seg.Count];
     for (int i = 0; i < seg.Count; i++)
         hack[i] = seg.Array[seg.Offset + i];
     //m_memoryStream = new MemoryStream(seg.Array, seg.Offset, seg.Count, false);
     m_memoryStream = new MemoryStream(hack, 0, seg.Count, false);
     m_tables = tables;
     m_reader = new BinaryReader(m_memoryStream);
 }
Esempio n. 3
0
        public CLRMetaData(StreamParser parser, CLRAssembly assembly)
        {
            Assembly = assembly;

            long metaRootPosition = parser.Position;
            uint magic = parser.ReadU32();
            if (magic != 0x424a5342)
                throw new ParseFailedException("Bad metadata magic");
            MajorVersion = parser.ReadU16();
            MinorVersion = parser.ReadU16();
            parser.Skip(4);     // Reserved
            uint versionLength = parser.ReadU32();
            if (versionLength > 255)
                throw new ParseFailedException("Oversized section length");
            uint paddedLength = versionLength + 3;
            paddedLength -= paddedLength % 4;
            Version = parser.ReadUTF8String((int)versionLength);
            parser.Skip(paddedLength - versionLength);
            Flags = parser.ReadU16();

            ushort nStreams = parser.ReadU16();
            StreamHeaders = new CLRStreamHeader[nStreams];
            Dictionary<string, CLRStreamHeader> streamHeadersByName = new Dictionary<string, CLRStreamHeader>();
            for (int i = 0; i < nStreams; i++)
            {
                CLRStreamHeader sh = new CLRStreamHeader(parser);
                if (streamHeadersByName.ContainsKey(sh.Name))
                    throw new ParseFailedException("Duplicate metadata stream");
                streamHeadersByName[sh.Name] = sh;
            }

            // Strings US GUID Blob
            CLRMetaStreamBinaryData binData = new CLRMetaStreamBinaryData(parser, metaRootPosition, streamHeadersByName);

            // Parse metadata tables
            parser.Seek(streamHeadersByName["#~"].Offset + metaRootPosition);
            MetaDataTables = new CLRMetaDataTables(parser, this, binData);
        }
Esempio n. 4
0
 public ICLRTable GetTable(CLRMetaDataTables.TableIndex tableIndex)
 {
     return GetTable((int)tableIndex);
 }
Esempio n. 5
0
 private void ResolveTable(CLRMetaDataTables.TableIndex tableIndex, CLRAssemblyCollection assemblies, ref bool resolvedAny, ref bool resolvedAll)
 {
     CLRMetaDataTables tables = MetaData.MetaDataTables;
     ICLRTable typeRefTable = tables.GetTable(tableIndex);
     uint numRows = typeRefTable.NumRows;
     for (uint i = 0; i < numRows; i++)
     {
         ICLRResolvable typeRef = (ICLRResolvable)typeRefTable.GetRow(i);
         if (!typeRef.IsResolved)
         {
             typeRef.Resolve(assemblies);
             if (typeRef.IsResolved)
                 resolvedAny = true;
             else
                 resolvedAll = false;
         }
     }
 }
Esempio n. 6
0
            public CLRTableRow Parse(CLRMetaDataParser parser, CLRMetaDataTables tables)
            {
                uint code = parser.ReadU16();

                uint tag = (code & m_tagMask);
                if (tag > m_maxTag)
                    throw new ParseFailedException("Invalid coded tag");
                ICLRTable table = tables.GetTable((int)m_tableIndexes[tag]);
                if (table.NumRows > m_maxCompactRows)
                {
                    uint highCode = parser.ReadU16();
                    code |= (highCode << 16);
                }
                uint row = code >> (int)m_tagBits;
                if (row == 0)
                    return null;
                return table.GetRow(row - 1);
            }
Esempio n. 7
0
 public MixedTagDecoder(CLRMetaDataTables.TableIndex[] tableIndexes)
 {
     m_maxTag = (uint)tableIndexes.Length - 1;
     m_tagMask = 0;
     m_tagBits = 0;
     while (m_tagMask < m_maxTag)
     {
         m_tagBits++;
         m_tagMask = (m_tagMask << 1) + 1;
     }
     m_tableIndexes = tableIndexes;
     m_maxCompactRows = ((uint)1 << (int)(16 - m_tagBits)) - 1;
 }
Esempio n. 8
0
 public uint ReadTableRawRow(CLRMetaDataTables.TableIndex tableIndex)
 {
     ICLRTable table = m_tables.GetTable((int)tableIndex);
     if (table.NumRows >= 65536)
         return m_parser.ReadU32();
     else
         return m_parser.ReadU16();
 }
Esempio n. 9
0
 public CLRTableRow ReadTable(CLRMetaDataTables.TableIndex tableIndex)
 {
     return GetTableRawRow(tableIndex, ReadTableRawRow(tableIndex));
 }
Esempio n. 10
0
 public CLRTableRow GetTableRow(CLRMetaDataTables.TableIndex tableIndex, uint row)
 {
     return m_tables.GetTable((int)tableIndex).GetRow(row);
 }
Esempio n. 11
0
 public CLRTableRow GetTableRawRow(CLRMetaDataTables.TableIndex tableIndex, uint row)
 {
     if (row == 0)
         return null;
     return m_tables.GetTable((int)tableIndex).GetRow(row - 1);
 }
Esempio n. 12
0
 public uint GetTableNumRows(CLRMetaDataTables.TableIndex tableIndex)
 {
     return m_tables.GetTable((int)tableIndex).NumRows;
 }
Esempio n. 13
0
 public CLRMetaDataParser(StreamParser parser, CLRMetaStreamBinaryData binData, CLRMetaDataTables tables, bool largeStrings, bool largeGuids, bool largeBlobs)
 {
     m_parser = parser;
     m_binData = binData;
     m_tables = tables;
     m_largeStrings = largeStrings;
     m_largeGuids = largeGuids;
     m_largeBlobs = largeBlobs;
 }
Esempio n. 14
0
 public void Resolve()
 {
     CustomAttribute = new CLRSigCustomAttribute(new CLRSignatureParser(m_rawValue, m_tables), Constructor);
     m_rawValue = new ArraySegment<byte>();
     m_tables = null;
 }