void ReadSecurityDeclarations()
        {
            if (!m_tHeap.HasTable(DeclSecurityTable.RId))
            {
                return;
            }

            DeclSecurityTable dsTable = m_tableReader.GetDeclSecurityTable();

            for (int i = 0; i < dsTable.Rows.Count; i++)
            {
                DeclSecurityRow     dsRow = dsTable [i];
                SecurityDeclaration dec   = BuildSecurityDeclaration(dsRow);

                IHasSecurity owner = null;
                switch (dsRow.Parent.TokenType)
                {
                case TokenType.Assembly:
                    owner = this.Module.Assembly;
                    break;

                case TokenType.TypeDef:
                    owner = GetTypeDefAt(dsRow.Parent.RID);
                    break;

                case TokenType.Method:
                    owner = GetMethodDefAt(dsRow.Parent.RID);
                    break;
                }

                owner.SecurityDeclarations.Add(dec);
            }
        }
Esempio n. 2
0
            public int Compare(object x, object y)
            {
                DeclSecurityRow a = x as DeclSecurityRow;
                DeclSecurityRow b = y as DeclSecurityRow;

                return(Comparer.Default.Compare(
                           Utilities.CompressMetadataToken(CodedIndex.HasDeclSecurity, a.Parent),
                           Utilities.CompressMetadataToken(CodedIndex.HasDeclSecurity, b.Parent)));
            }
Esempio n. 3
0
 public override void FromRawData(byte [] buff, int offs, int numRows)
 {
     for (int i = numRows; --i >= 0;)
     {
         Row row = new DeclSecurityRow(this);
         row.FromRawData(buff, offs);
         Add(row);
         offs += DeclSecurityRow.LogicalSize;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="result">The result.</param>
        public void Read(TokenTypes token, out DeclSecurityRow result)
        {
            if ((token & TokenTypes.TableMask) != TokenTypes.DeclSecurity)
            {
                throw new ArgumentException("Invalid token type for DeclSecurityRow.", "token");
            }

            using (BinaryReader reader = CreateReaderForToken(token))
            {
                result = new DeclSecurityRow((System.Security.Permissions.SecurityAction)reader.ReadUInt16(), ReadIndexValue(reader, IndexType.HasDeclSecurity), ReadIndexValue(reader, IndexType.BlobHeap));
            }
        }
 public virtual void VisitDeclSecurityRow(DeclSecurityRow row)
 {
 }
 protected SecurityDeclaration BuildSecurityDeclaration(DeclSecurityRow dsRow)
 {
     return(BuildSecurityDeclaration(dsRow.Action, m_root.Streams.BlobHeap.Read(dsRow.PermissionSet)));
 }
Esempio n. 7
0
        void IMetadataProvider.Read(TokenTypes token, out DeclSecurityRow result)
        {
            TableHeap theap = (TableHeap)_streams[(int)HeapType.Tables];

            theap.Read(token, out result);
        }
 public virtual void VisitDeclSecurityRow(DeclSecurityRow row)
 {
 }