Ejemplo n.º 1
0
        protected override void Load(SwfStream stream, ushort length)
        {
            List<ActionVar> values = new List<ActionVar>();
            long end = length + stream.TagPosition;

            while (stream.TagPosition < end)
            {
                ActionVar value;
                switch (stream.ReadByte())
                {
                    case 0: value = stream.ReadString(); break;
                    case 1: value = stream.ReadSingle(); break;
                    case 2: value = new ActionVar((string)null); break;
                    case 3: value = new ActionVar(); break;
                    case 4: value = stream.ReadByte(); break;
                    case 5: value = stream.ReadByte() != 0; break;
                    case 6: value = stream.ReadDouble(); break;
                    case 7: value = stream.ReadUInt(); break;
                    case 8: value = new ActionVar.IndexActionVar(stream.ReadByte()); break;
                    case 9: value = new ActionVar.IndexActionVar(stream.ReadUShort()); break;
                    default:
                        throw new SwfCorruptedException("Invalid push action value type!");
                }
                values.Add(value);
            }

            Values = values.ToArray();
        }
Ejemplo n.º 2
0
        protected override void Load(SwfStream stream, ushort length)
        {
            byte flags = stream.ReadByte();
            ushort trySize = stream.ReadUShort();
            ushort catchSize = stream.ReadUShort();
            ushort finallySize = stream.ReadUShort();

            if ((flags & 0x04) != 0)
            {
                CatchRegister = stream.ReadByte();
                CatchVariable = null;
            }
            else
            {
                CatchRegister = null;
                CatchVariable = stream.ReadString();
            }

            Try = ActionRecord.ReadActions(stream, trySize);

            if (catchSize > 0 && (flags & 0x01) != 0)
                Catch = ActionRecord.ReadActions(stream, trySize);

            if (finallySize > 0 && (flags & 0x02) != 0)
                Finally = ActionRecord.ReadActions(stream, finallySize);
        }
Ejemplo n.º 3
0
        protected override void Load(SwfStream stream, ushort length)
        {
            Name = stream.ReadString();
            Params = new ActionFunc.RegisterParam[stream.ReadUShort()];
            NumRegisters = stream.ReadByte();
            Flags = (FuncFlags)stream.ReadUShort();

            for (int i = 0; i < Params.Length; i++)
                Params[i] = new ActionFunc.RegisterParam(stream);

            Actions = ActionRecord.ReadActions(stream, stream.ReadUShort());
        }
Ejemplo n.º 4
0
        public static ActionRecord Read(SwfStream stream)
        {
            byte code = stream.ReadByte();

            if (code == 0)
                return new ActionRecord { Action = ActionCode.End };

            if (!Enum.IsDefined(typeof(ActionCode), code))
                throw new SwfCorruptedException("Unknown action code has been found!");

            if (code < 0x80)
                return new ActionRecord { Action = (ActionCode)code };

            ActionRecord r = null;
            switch ((ActionCode)code)
            {
                // SWF 3
                case ActionCode.GoToFrame: r = new FrameAction(); break;
                case ActionCode.GetURL: r = new GetURLAction(); break;
                case ActionCode.WaitForFrame: r = new WaitForFrameAction(); break;
                case ActionCode.SetTarget: r = new SetTargetAction(); break;
                case ActionCode.GoToLabel: r = new GoToLabelAction(); break;

                // SWF 4
                case ActionCode.Push: r = new PushAction(); break;
                case ActionCode.If:
                case ActionCode.Jump: r = new BranchAction(); break;
                case ActionCode.Call: r = new ActionRecord(); break;
                case ActionCode.GetURL2: r = new GetURL2Action(); break;
                case ActionCode.GoToFrame2: r = new GoToFrame2Action(); break;
                case ActionCode.WaitForFrame2: r = new WaitForFrame2Action(); break;

                // SWF 5
                case ActionCode.ConstantPool: r = new ConstantPoolAction(); break;
                case ActionCode.DefineFunction: r = new DefineFunctionAction(); break;
                case ActionCode.With: r = new WithAction(); break;
                case ActionCode.StoreRegister: r = new StoreRegisterAction(); break;

                // SWF 6
                case ActionCode.DefineFunction2: r = new DefineFunction2Action(); break;

                // SWF 7
                case ActionCode.Try: r = new TryAction(); break;
            }

            ushort len = stream.ReadUShort();
            r.Load(stream, len);
            r.Action = (ActionCode)code;
            return r;
        }
Ejemplo n.º 5
0
 protected override void Load(SwfStream stream, ushort length)
 {
     byte flags = stream.ReadByte();
     SceneBias = ((flags & 0x02) != 0) ? stream.ReadUShort() : (ushort)0;
     Play = (flags & 0x01) != 0;
 }
Ejemplo n.º 6
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Flags = (GetURLFlags)stream.ReadByte();
 }
Ejemplo n.º 7
0
 internal RegisterParam(SwfStream stream)
 {
     Register = stream.ReadByte();
     Name = stream.ReadString();
 }
Ejemplo n.º 8
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Frame = stream.ReadUShort();
     SkipCount = stream.ReadByte();
 }
Ejemplo n.º 9
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Register = stream.ReadByte();
 }