示例#1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        /// <param name="code"></param>
        public void Verify(AbcFile abc, AVM2Code code)
        {
            if (!abc.VerifyMultinameIndex(_ExceptionType))
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid Exception type: " + _ExceptionType.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }

            if (!abc.VerifyMultinameIndex(_VariableName))
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid exception variable name: " + _VariableName.ToString("d")); ;
                Log.Error(this, ave);
                throw ave;
            }

            try
            {
                uint dummy = code.Address2Index(_From) + code.Address2Index(_To) + code.Address2Index(_Target);
                dummy++;
            }
            catch (ArgumentOutOfRangeException aoor)
            {
                AbcVerifierException ave = new AbcVerifierException("Exception to/from/target not on a instruction", aoor);
                Log.Error(this, ave);
                throw ave;
            }
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        /// <param name="method"></param>
        /// <param name="argument"></param>
        public AVM2Argument( AbcFile abc, UInt32 method, UInt32 argument )
        {
            _ArgumentType = abc.ConstantPool.Multinames[ ( int )abc.Methods[ ( int )method ].ParamType[ ( int )argument ] ].ToString( abc );

            if ( abc.Methods[ ( int )method ].FlagHasParamNames )
            {
                _ArgumentName = abc.ConstantPool.Strings[ ( int )abc.Methods[ ( int )method ].ParamNames[ ( int )argument ] ];
            }
            else
            {
                _ArgumentName = "(no param name)";
            }

            if ( ( abc.Methods[ ( int )method ].FlagHasOptional ) && ( argument < abc.Methods[ ( int )method ].Option.Count ) )
            {
                _IsOptional = true;
                _OptionalType = abc.Methods[ ( int )method ].Option[ ( int )argument ].OptionType;
                _OptionalTypeName = abc.Methods[ ( int )method ].Option[ ( int )argument ].OptionTypeName;
                _OptionalValue = abc.Methods[ ( int )method ].Option[ ( int )argument ].GetValue( abc );
            }
            else
            {
                _IsOptional = false;
                _OptionalType = OptionType.TotallyInvalid;
                _OptionalValue = null;
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abc"></param>
 public void Verify( AbcFile abc )
 {
     if ( ( !abc.VerifyNameIndex( _Key ) ) || ( !abc.VerifyNameIndex( _Value ) ) )
     {
         AbcVerifierException ave = new AbcVerifierException( "Invalid Key/Value pair: " + _Key.ToString( "d" ) + "/" + _Value.ToString( "d" ) );
        Log.Error(this,  ave );
         throw ave;
     }
 }
示例#4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <param name="abc"></param>
        public AVM2Method( UInt32 index, AbcFile abc )
        {
            if ( abc.Methods.Count <= index )
            {
                ArgumentException ae = new ArgumentException( "Method " + index.ToString( "d" ) + " not in ABC file" );
                Log.Error(this,  ae );
                throw ae;
            }

            _Abc = abc;
            _MethodID = index;
        }
示例#5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify( AbcFile abc )
        {
            if ( Cinit >= abc.Methods.Count )
            {
                AbcVerifierException ave = new AbcVerifierException( "Invalid Cinit: " + Cinit.ToString( "d" ) );
                Log.Error(this,  ave );
                throw ave;
            }

            foreach ( Traits_info t in Traits )
            {
                t.Verify( abc );
            }
        }
示例#6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify(AbcFile abc)
        {
            if (!abc.VerifyNameIndex(_Name))
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid Name entry " + _Name.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }

            foreach (Metadata_item_info i in _ItemInfo)
            {
                i.Verify(abc);
            }
        }
示例#7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abc"></param>
 public void Verify( AbcFile abc )
 {
     for ( int i = 0; i < _Ns.Count; i++ )
     {
         if ( 0 == _Ns[ i ] )
         {
             AbcVerifierException ave = new AbcVerifierException( "Ns_set entry " + i.ToString( "d" ) + " is 0, which is not allowed" );
            Log.Error(this,  ave );
             throw ave;
         }
         if ( _Ns[ i ] >= abc.ConstantPool.Namespaces.Count )
         {
             AbcVerifierException ave = new AbcVerifierException( "Ns_set entry " + i.ToString( "d" ) + " index outside Namespace array" );
            Log.Error(this,  ave );
             throw ave;
         }
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abc"></param>
 public void Verify( AbcFile abc )
 {
     try
     {
         if ( this.HasNsSet )
         {
             for ( int i = 0; i < abc.ConstantPool.NsSets[ ( int )this.NsSet ].Entries.Count; i++ )
             {
                 int ldummy = abc.ConstantPool.Strings[ ( int )abc.ConstantPool.NsSets[ ( int )this.NsSet ].Entries[ i ] ].Length;
                 ldummy++;
             }
         }
         if ( this.HasNamespace )
         {
             int ldummy = abc.ConstantPool.Strings[ ( int )abc.ConstantPool.Namespaces[ ( int )this.Namespace ].NameIndex ].Length;
             ldummy++;
         }
         if ( this.HasNameIndex )
         {
             int ldummy = abc.ConstantPool.Strings[ ( int )this.NameIndex ].Length;
             ldummy++;
         }
     }
     catch ( Exception e )
     {
         AbcVerifierException ave = new AbcVerifierException( "Multiname entry has invalid indices", e );
         Log.Error(this,  ave );
         throw ave;
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        /// <returns></returns>
        public string ToString( AbcFile abc )
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat( "[{0}]", Enum.GetName( typeof( MultinameType ), _Type ) );

            if ( this.HasNsSet )
            {
                sb.Append( "{" );
                for ( int i = 0; i < abc.ConstantPool.NsSets[ (int)this.NsSet ].Entries.Count; i++ )
                {
                    string ns = abc.ConstantPool.Strings[ ( int )abc.ConstantPool.NsSets[ ( int )this.NsSet  ].Entries[ i ] ];
                    sb.Append( ns );
                    if ( ( i + 1 ) != abc.ConstantPool.NsSets[ ( int )this.NsSet ].Entries.Count )
                    {
                        sb.Append( "|" );
                    }
                }
                sb.Append( "}." );
            }

            if ( this.HasNamespace )
            {
                if ( abc.ConstantPool.EmptyString == abc.ConstantPool.Namespaces[ ( int )this.Namespace ].NameIndex )
                {
                    sb.Append( "*:" );
                }
                else
                {
                    sb.Append( abc.ConstantPool.Strings[ ( int )abc.ConstantPool.Namespaces[ ( int )this.Namespace ].NameIndex ] );
                    sb.Append( ":" );
                }
            }

            if ( this.HasNameIndex )
            {
                if ( abc.ConstantPool.EmptyString == this.NameIndex )
                {
                    sb.Append( "(unnamed)" );
                }
                else
                {
                    sb.Append( abc.ConstantPool.Strings[ ( int )this.NameIndex ] );
                }
            }

            return sb.ToString();
        }
示例#10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify(AbcFile abc)
        {
            if (Method >= abc.Methods.Count)
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid Method: " + Method.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }

            Code.Verify(abc);

            foreach (Exception_info ex in Exceptions)
            {
                ex.Verify(abc, Code);
            }

            foreach (Traits_info t in Traits)
            {
                t.Verify(abc);
            }
        }
示例#11
0
 /// <summary>
 /// Verifies this object and its components for documentation compliance.
 /// </summary>
 /// <param name="abc">The abc file to verify</param>
 public void Verify(AbcFile abc)
 {
     for (int i = 0; i < Multinames.Count; i++)
     {
         Multinames[i].Verify(abc);
     }
     for (int i = 0; i < NsSets.Count; i++)
     {
         NsSets[i].Verify(abc);
     }
     for (int i = 0; i < Namespaces.Count; i++)
     {
         Namespaces[i].Verify(abc);
     }
 }
示例#12
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abcfile"></param>
 /// <returns></returns>
 public string ToString(AbcFile abcfile)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append(this.GetType().Name);
     sb.Append(" ");
     sb.Append(Environment.NewLine);
     for (int i = 0; i < Integers.Count; i++)
     {
         sb.AppendFormat(" Integer[#{0:d}] : {1:d} ", i, Integers[i]);
         sb.Append(Environment.NewLine);
     }
     sb.Append(Environment.NewLine);
     for (int i = 0; i < UIntegers.Count; i++)
     {
         sb.AppendFormat(" Unsigned Integer[#{0:d}] t: {1:d} ", i, UIntegers[i]);
         sb.Append(Environment.NewLine);
     }
     sb.Append(Environment.NewLine);
     for (int i = 0; i < Doubles.Count; i++)
     {
         sb.AppendFormat(" Double[#{0:d}] : {1:g} ", i, Doubles[i]);
         sb.Append(Environment.NewLine);
     }
     sb.Append(Environment.NewLine);
     for (int i = 0; i < Strings.Count; i++)
     {
         sb.AppendFormat(" String[#{0:d}] : '{1}' ", i, Strings[i]);
         sb.Append(Environment.NewLine);
     }
     sb.Append(Environment.NewLine);
     for (int i = 0; i < Namespaces.Count; i++)
     {
         sb.AppendFormat(" Namespace[#{0:d}] : {1} ", i, Namespaces[i].ToString(abcfile));
         sb.Append(Environment.NewLine);
     }
     sb.Append(Environment.NewLine);
     for (int i = 0; i < NsSets.Count; i++)
     {
         sb.AppendFormat(" Namespace Set[#{0:d}] : {1} ", i, NsSets[i].ToString());
         sb.Append(Environment.NewLine);
     }
     sb.Append(Environment.NewLine);
     for (int i = 0; i < Multinames.Count; i++)
     {
         sb.AppendFormat(" Multiname[#{0:d}] : {1} ", i, Multinames[i].ToString(abcfile));
         sb.Append(Environment.NewLine);
     }
     sb.Append(Environment.NewLine);
     return sb.ToString();
 }
示例#13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify(AbcFile abc)
        {
            if (!abc.VerifyMultinameIndex(TypeName))
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid TypeName: " + TypeName.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }

            if (0 == Vindex)
            {
                return;
            }
            else
            {
                if ((!Enum.IsDefined(typeof(OptionType), Vkind)) || (Vkind == OptionType.TotallyInvalid))
                {
                    AbcVerifierException ave = new AbcVerifierException("Invalid Vkind: " + Vkind.ToString("d"));
                    Log.Error(this, ave);
                    throw ave;
                }

                bool valid = false;
                switch (Vkind)
                {
                    case OptionType.Option_Int:
                        valid = (Vindex < abc.ConstantPool.Integers.Count);
                        break;
                    case OptionType.Option_UInt:
                        valid = (Vindex < abc.ConstantPool.UIntegers.Count);
                        break;
                    case OptionType.Option_Double:
                        valid = (Vindex < abc.ConstantPool.Doubles.Count);
                        break;
                    case OptionType.Option_Utf8:
                        valid = (Vindex < abc.ConstantPool.Strings.Count);
                        break;
                    case OptionType.Option_True:
                    case OptionType.Option_False:
                    case OptionType.Option_Null:
                    case OptionType.Option_Undefined:
                        valid = true;
                        break;
                    case OptionType.Option_Namespace:
                    case OptionType.Option_PackageNamespace:
                    case OptionType.Option_PackageInternalNs:
                    case OptionType.Option_ProtectedNamespace:
                    case OptionType.Option_ExplicitNamespace:
                    case OptionType.Option_StaticProtectedNs:
                    case OptionType.Option_PrivateNs:
                        valid = (Vindex < abc.ConstantPool.Namespaces.Count);
                        break;
                    default:
                        valid = false;
                        break;
                }

                if (!valid)
                {
                    AbcVerifierException ave = new AbcVerifierException("Invalid Vindex " + Vindex.ToString("d") + " for vkind " + Vkind.ToString("d"));
                    Log.Error(this, ave);
                    throw ave;
                }
            }
        }
示例#14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abc"></param>
 /// <returns></returns>
 public string ToString(AbcFile abc)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append("[");
     sb.Append(Enum.GetName(typeof(NamespaceKind), _Kind));
     sb.Append("]");
     if (0 == _Name)
     {
         sb.Append("*");
     }
     else
     {
         sb.Append(abc.ConstantPool.Strings[(int)_Name]);
     }
     return sb.ToString();
 }
示例#15
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify(AbcFile abc)
        {
            string name = null;

            if (!Enum.IsDefined(typeof(NamespaceKind), _Kind))
            {
                AbcVerifierException ave = new AbcVerifierException("Namespace with invalid kind type " + _Kind.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }

            try
            {
                name = abc.ConstantPool.Strings[(int)_Name];
            }
            catch (Exception e)
            {
                AbcVerifierException ave = new AbcVerifierException("Namespace with invalid name index " + _Name.ToString("d"), e);
                Log.Error(this, ave);
                throw ave;
            }

            if (!IsValidNamespace(name))
            {
                AbcVerifierException ave = new AbcVerifierException("Namespace name is invalid: >>>" + name + "<<<");
                Log.Error(this, ave);
                throw ave;
            }
        }
示例#16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abc"></param>
 public void Verify(AbcFile abc)
 {
     try
     {
         object test = this.GetValue(abc);
     }
     catch (IndexOutOfRangeException ioor)
     {
         AbcVerifierException ave = new AbcVerifierException("Option_info out of range value", ioor);
         Log.Error(this, ave);
         throw ave;
     }
 }
示例#17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        /// <returns></returns>
        public object GetValue(AbcFile abc)
        {
            object ret;

            switch (_Type)
            {
                case OptionType.Option_Int:
                    Int32 v = abc.ConstantPool.Integers[(int)_Value];
                    ret = v;
                    break;

                case OptionType.Option_UInt:
                    UInt32 u = abc.ConstantPool.UIntegers[(int)_Value];
                    ret = u;
                    break;

                case OptionType.Option_Double:
                    Double d = abc.ConstantPool.Doubles[(int)_Value];
                    ret = d;
                    break;

                case OptionType.Option_Utf8:
                    string ut = abc.ConstantPool.Strings[(int)_Value];
                    ret = ut;
                    break;

                case OptionType.Option_True:
                    bool bt = true;
                    ret = bt;
                    break;

                case OptionType.Option_False:
                    bool bf = false;
                    ret = bf;
                    break;

                case OptionType.Option_Null:
                    string sn = "NULL";
                    ret = sn;
                    break;

                case OptionType.Option_Undefined:
                    string su = "UNDEFINED";
                    ret = su;
                    break;

                case OptionType.Option_Namespace:
                case OptionType.Option_PackageNamespace:
                case OptionType.Option_PackageInternalNs:
                case OptionType.Option_ProtectedNamespace:
                case OptionType.Option_ExplicitNamespace:
                case OptionType.Option_StaticProtectedNs:
                case OptionType.Option_PrivateNs:
                    string ns = abc.ConstantPool.Namespaces[(int)_Value].ToString(abc);
                    ret = ns;
                    break;

                default:
                    Exception e = new Exception("Invalid option type value 0x" + _Type.ToString("X02"));
                    Log.Error(this, e);
                    throw e;
            }

            return ret;
        }
示例#18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abc"></param>
 public void Verify(AbcFile abc)
 {
     if (ClassI >= abc.Classes.Count)
     {
         AbcVerifierException ave = new AbcVerifierException("Invalid Classi: " + ClassI.ToString("d"));
         Log.Error(this, ave);
         throw ave;
     }
 }
示例#19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify(AbcFile abc)
        {
            if (!abc.VerifyMultinameIndex(Name))
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid name: " + Name.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }
            if (abc.ConstantPool.Multinames[(int)Name].Type != MultinameType.QName)
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid name type");
                Log.Error(this, ave);
                throw ave;
            }

            if (AttribMetadata)
            {
                foreach (UInt32 ind in _Metadata)
                {
                    if (ind >= abc.Metadata.Count)
                    {
                        AbcVerifierException ave = new AbcVerifierException("Invalid metadata index: " + ind.ToString("d"));
                        Log.Error(this, ave);
                        throw ave;
                    }
                }
            }

            switch (Type)
            {
                case TraitType.Trait_Const:
                case TraitType.Trait_Slot:
                    _Data_Slot.Verify(abc);
                    break;

                case TraitType.Trait_Class:
                    _Data_Class.Verify(abc);
                    break;

                case TraitType.Trait_Function:
                    _Data_Function.Verify(abc);
                    break;

                case TraitType.Trait_Method:
                case TraitType.Trait_Getter:
                case TraitType.Trait_Setter:
                    _Data_Method.Verify(abc);
                    break;
            }
        }
示例#20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify( AbcFile abc )
        {
            //
            // _Name must be a multiname of type QName
            // _Supername must be a multiname
            // _ProtectedNs if _FlagClassProtectedNs must point to namespace
            // _Interface is multiname index
            // _Iinit is index into method array
            //

            if ( !abc.VerifyMultinameIndex( _Name ) )
            {
                AbcVerifierException ave = new AbcVerifierException( "Invalid Name: " + _Name.ToString( "d" ) );
               Log.Error(this,  ave );
                throw ave;
            }

            if ( abc.ConstantPool.Multinames[ (int)_Name ].Type != MultinameType.QName )
            {
                AbcVerifierException ave = new AbcVerifierException( "Name: " + _Name.ToString( "d" ) + " is not of type QName" );
               Log.Error(this,  ave );
                throw ave;
            }

            if ( _FlagClassProtectedNs )
            {
                if ( !abc.VerifyMultinameIndex( _ProtectedNs ) )
                {
                    AbcVerifierException ave = new AbcVerifierException( "Invalid ProtectedNs: " + _ProtectedNs.ToString( "d" ) );
                   Log.Error(this,  ave );
                    throw ave;
                }
            }

            if ( !abc.VerifyMultinameIndex( _Supername ) )
            {
                AbcVerifierException ave = new AbcVerifierException( "Invalid SuperName: " + _Supername.ToString( "d" ) );
               Log.Error(this,  ave );
                throw ave;
            }

            for ( int i = 0; i < _Interface.Count; i++ )
            {
                if ( !abc.VerifyMultinameIndex( _Interface[i] ) )
                {
                    AbcVerifierException ave = new AbcVerifierException( "Invalid interface: " + _Interface[i].ToString( "d" ) );
                   Log.Error(this,  ave );
                    throw ave;
                }
                if ( 0 == _Interface[ i ] )
                {
                    AbcVerifierException ave = new AbcVerifierException( "Invalid interface, being 0" );
                   Log.Error(this,  ave );
                    throw ave;
                }
            }

            if ( _Iinit >= abc.Methods.Count )
            {
                AbcVerifierException ave = new AbcVerifierException( "Iinit does not point into method array: " + _Iinit.ToString( "d" ) );
               Log.Error(this,  ave );
                throw ave;
            }

            foreach ( Traits_info ti in _Trait )
            {
                ti.Verify( abc );
            }
        }
示例#21
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="abc"></param>
        public void Verify(AbcFile abc)
        {
            for (int i = 0; i < ParamType.Count; i++)
            {
                if (!abc.VerifyMultinameIndex(ParamType[i]))
                {
                    AbcVerifierException ave = new AbcVerifierException("Invalid param type in method_info: " + ParamType[i].ToString("d"));
                    Log.Error(this, ave);
                    throw ave;
                }
            }

            if (!abc.VerifyNameIndex(Name))
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid method name : " + Name.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }

            if (!abc.VerifyMultinameIndex(ReturnType))
            {
                AbcVerifierException ave = new AbcVerifierException("Invalid return type: " + ReturnType.ToString("d"));
                Log.Error(this, ave);
                throw ave;
            }

            if (FlagHasOptional)
            {
                for (int i = 0; i < Option.Count; i++)
                {
                    Option[i].Verify(abc);
                }
            }

            if (FlagHasParamNames)
            {
                for (int i = 0; i < ParamNames.Count; i++)
                {
                    if (!abc.VerifyNameIndex(ParamNames[i]))
                    {
                        AbcVerifierException ave = new AbcVerifierException("Invalid param name: " + ParamNames[i].ToString("d"));
                        Log.Error(this, ave);
                        throw ave;
                    }
                }
            }
        }
示例#22
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="abc"></param>
 public void Verify(AbcFile abc)
 {
     if (Method >= abc.Methods.Count)
     {
         AbcVerifierException ave = new AbcVerifierException("Invalid Method: " + Method.ToString("d"));
         Log.Error(this, ave);
         throw ave;
     }
 }