コード例 #1
0
ファイル: AbcClass.cs プロジェクト: BiasHacker/SwfDec
        public TraitsInfo GetTraitByName(TraitKind kind, string name)
        {
            foreach (TraitsInfo t in ClassInfo.TraitsArray.GetTraitsByKind(kind).Where(t => t.Name.MKQName.Name == name))
            {
                return(t);
            }

            return(InstanceInfo.TraitsArray.GetTraitsByKind(kind).FirstOrDefault(t => t.Name.MKQName.Name == name));
        }
コード例 #2
0
ファイル: FlashABC.cs プロジェクト: TheCrazyT/FlashABCRead
        public void getTraits(BinaryReader br, bool addproperties, out List <cProp> properties)
        {
            properties = new List <cProp>();
            ulong type = 0;
            ulong cnt2 = getU30(br.BaseStream);

            for (ulong m = 0; m < cnt2; m++)
            {
                ulong     name = getU32(br.BaseStream);
                byte      tag  = br.ReadByte();
                TraitKind kind = (TraitKind)(tag & 0xF);
                switch (kind)
                {
                case TraitKind.Slot:
                    skipU32(br.BaseStream);
                    type = getU32(br.BaseStream);
                    ulong v1 = getU32(br.BaseStream);
                    byte  v2 = 0;
                    if (v1 > 0)
                    {
                        v2 = br.ReadByte();
                    }
                    if (addproperties)
                    {
                        cProp p = new cProp();
                        p.name = getLabel(name);
                        p.type = getLabel(type);
                        p.v1   = v1;
                        p.v2   = v2;
                        ulong nsidx = getNameSpaceByMultinameIdx(name);
                        p.nskind = 0;
                        if (nsidx > 0)
                        {
                            p.nskind = getNameSpaceKind(nsidx);
                        }
                        Debug.Print("var {0} {1} {2} {3} {4}", p.name, p.type, v1, v2, p.nskind);
                        properties.Add(p);
                    }
                    break;

                case TraitKind.Const:
                    type = getU32(br.BaseStream);
                    skipU32(br.BaseStream);
                    v1 = getU32(br.BaseStream);
                    v2 = 0;
                    if (v1 > 0)
                    {
                        v2 = br.ReadByte();
                    }
                    if (addproperties)
                    {
                        cProp p = new cProp();
                        p.name = getLabel(name);
                        p.type = "const_" + getLabel(type);
                        p.v1   = v1;
                        p.v2   = v2;
                        properties.Add(p);
                        ulong nsidx = getNameSpaceByMultinameIdx(name);
                        p.nskind = 0;
                        if (nsidx > 0)
                        {
                            p.nskind = getNameSpaceKind(nsidx);
                        }
                        Debug.Print("const {0} {1} {2} {3} {4}", p.name, p.type, v1, v2, p.nskind);
                    }
                    break;

                case TraitKind.Class:
                case TraitKind.Function:
                case TraitKind.Method:
                case TraitKind.Getter:
                case TraitKind.Setter:
                    skipU32(br.BaseStream);
                    skipU32(br.BaseStream);
                    break;

                /*experimental kinds
                 * case 11:
                 * case 8:
                 * case 14:
                 * case 9:
                 * case 12:
                 * case 15:
                 * case 7:
                 * case 13:
                 * case 10:
                 *  //Debugger.Break();
                 *
                 *  skipU32(br.BaseStream);
                 *  skipU32(br.BaseStream);
                 *  skipU32(br.BaseStream);
                 *  //return;
                 *  break;*/
                default:
                    //skipU32(br.BaseStream);
                    //skipU32(br.BaseStream);
                    Debugger.Break();
                    break;
                }
                if ((tag & (0x04 << 4)) != 0)
                {
                    ulong cnt3 = getU30(br.BaseStream);
                    for (ulong m2 = 0; m2 < cnt3; m2++)
                    {
                        skipU32(br.BaseStream);
                    }
                }
                //Debug.Print("{0:x} {1:x}", br.BaseStream.Position,br.BaseStream.Length);
            }
        }
コード例 #3
0
ファイル: AbcClass.cs プロジェクト: BiasHacker/SwfDec
 public TraitsInfo[] GetClassTraitsByKind(TraitKind kind)
 {
     return(ClassInfo.TraitsArray.GetTraitsByKind(kind));
 }
コード例 #4
0
ファイル: AbcClass.cs プロジェクト: BiasHacker/SwfDec
 public IEnumerable <TraitsInfo> GetInstanceTraitsByKind(TraitKind kind)
 {
     return(InstanceInfo.TraitsArray.GetTraitsByKind(kind));
 }
コード例 #5
0
ファイル: TraitsArray.cs プロジェクト: BiasHacker/SwfDec
 public TraitsInfo[] GetTraitsByKind(TraitKind traitKind)
 {
     return(_traitsDictionary[traitKind].ToArray());
 }
コード例 #6
0
ファイル: AbcReader.cs プロジェクト: mkbiltek2019/Swiffotron
        /// <summary>
        /// Read in a trait, which are like object properties.
        /// </summary>
        /// <returns>A trait.</returns>
        private Trait ReadTrait()
        {
            Trait     t         = null;
            Multiname traitName = this.code.GetMultiname((int)this.abcdtr.ReadU30());
            int       traitCode = this.abcdtr.ReadUI8();
            TraitKind kind      = (TraitKind)(traitCode & 0xF);

            switch (kind)
            {
            case TraitKind.Slot:
            case TraitKind.Const:
                SlotTrait st = new SlotTrait();
                st.Name = traitName;
                st.Kind = kind;

                st.SlotID   = this.abcdtr.ReadU30();
                st.TypeName = this.code.GetMultiname((int)this.abcdtr.ReadU30());

                uint vindex = this.abcdtr.ReadU30();

                if (vindex != 0)
                {
                    st.ValKind = (ConstantKind)this.abcdtr.ReadUI8();
                    switch (st.ValKind)
                    {
                    case ConstantKind.ConInt:
                        st.Val = this.code.IntConsts[vindex];
                        break;

                    case ConstantKind.ConUInt:
                        st.Val = this.code.UIntConsts[vindex];
                        break;

                    case ConstantKind.ConDouble:
                        st.Val = this.code.DoubleConsts[vindex];
                        break;

                    case ConstantKind.ConUtf8:
                        st.Val = this.code.StringConsts[vindex];
                        break;

                    case ConstantKind.ConTrue:
                    case ConstantKind.ConFalse:
                    case ConstantKind.ConNull:
                    case ConstantKind.ConUndefined:
                        break;

                    case ConstantKind.ConNamespace:
                    case ConstantKind.ConPackageNamespace:
                    case ConstantKind.ConPackageInternalNs:
                    case ConstantKind.ConProtectedNamespace:
                    case ConstantKind.ConExplicitNamespace:
                    case ConstantKind.ConStaticProtectedNs:
                    case ConstantKind.ConPrivateNs:
                        st.Val = this.code.GetNamespace((int)vindex);
                        break;

                    default:
                        throw new SWFModellerException(
                                  SWFModellerError.Internal,
                                  "Unsupported constant kind: " + st.ValKind.ToString());
                    }
                }

                t = st;
                break;

            case TraitKind.Class:
                ClassTrait ct = new ClassTrait();
                ct.Name = traitName;
                ct.Kind = kind;

                ct.SlotID = this.abcdtr.ReadU30();
                this.LateResolutions.Add(ct, (int)this.abcdtr.ReadU30());     /* We'll resolve the class ref later. */

                t = ct;
                break;

            case TraitKind.Function:
                FunctionTrait ft = new FunctionTrait();
                ft.Name = traitName;
                ft.Kind = kind;

                ft.SlotID = this.abcdtr.ReadU30();
                ft.Fn     = this.code.GetMethod((int)this.abcdtr.ReadU30());

                t = ft;
                break;

            case TraitKind.Method:
            case TraitKind.Getter:
            case TraitKind.Setter:
            default:
                MethodTrait mt = new MethodTrait();
                mt.Name = traitName;
                mt.Kind = kind;

                uint dispID = this.abcdtr.ReadU30();
                if (dispID != 0)
                {
                    mt.OverriddenMethod = this.code.GetMethod((int)dispID);
                }

                mt.Fn = this.code.GetMethod((int)this.abcdtr.ReadU30());

                t = mt;
                break;
            }

            return(t);
        }
コード例 #7
0
ファイル: TraitDescription.cs プロジェクト: BiasHacker/SwfDec
 public TraitDescription(TraitKind kind, string typeName)
 {
     Kind     = kind;
     TypeName = typeName;
 }