Example #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();
        }
Example #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);
        }
Example #3
0
 protected override void Load(SwfStream stream, ushort length)
 {
     var array = new string[stream.ReadUShort()];
     for (int i = 0; i < array.Length; i++)
         array[i] = stream.ReadString();
     Pool = new ConstantPool(array);
 }
Example #4
0
 public FlashDocument(string name, SwfStream stream, ISystemServices services)
     : base(stream.ProcessFile(), 0, stream.FrameCount, services)
 {
     Name = name;
     Version = stream.Version;
     Width = stream.Rectangle.Width;
     Height = stream.Rectangle.Height;
     FrameDelay = 1000.0 / (double)stream.FrameRate;
 }
Example #5
0
        protected override void Load(SwfStream stream, ushort length)
        {
            Name = stream.ReadString();

            Params = new string[stream.ReadUShort()];
            for (int i = 0; i < Params.Length; i++)
                Params[i] = stream.ReadString();

            Actions = ActionRecord.ReadActions(stream, stream.ReadUShort());
        }
Example #6
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());
        }
Example #7
0
        public static ISwfTag LoadTag(SwfStream stream, ushort id, uint length, byte version, ref string name)
        {
            if (sDictionary == null)
                Initialize();

            KeyValuePair<string, Type> info;
            if (!sDictionary.TryGetValue(id, out info))
                return null;

            name = info.Key;
            var tag = (ISwfTag)Activator.CreateInstance(info.Value);
            tag.Load(stream, length, version);
            return tag;
        }
Example #8
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;
        }
Example #9
0
        internal static ActionBlock ReadActions(SwfStream stream, uint? length)
        {
            int start = stream.TagPosition;
            long end = start + length ?? 0;
            int position = start;
            ActionRecord rec;

            List<ActionRecord> actions = new List<ActionRecord>(256);
            while(!length.HasValue || position < end)
            {
                rec = Read(stream);

                rec.Address = position - start;
                actions.Add(rec);

                position = stream.TagPosition;
                if (rec.Action == ActionCode.End)
                    break;
            }

            return new ActionBlock(actions.ToArray());
        }
Example #10
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Flags = (GetURLFlags)stream.ReadByte();
 }
Example #11
0
 protected override void Load(SwfStream stream, ushort length)
 {
     BranchOffset = stream.ReadShort();
 }
Example #12
0
 internal RegisterParam(SwfStream stream)
 {
     Register = stream.ReadByte();
     Name = stream.ReadString();
 }
Example #13
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Frame = stream.ReadUShort();
     SkipCount = stream.ReadByte();
 }
Example #14
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Register = stream.ReadByte();
 }
Example #15
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Label = stream.ReadString();
 }
Example #16
0
 protected virtual void Load(SwfStream stream, ushort length)
 {
 }
Example #17
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Url = stream.ReadString();
     Target = stream.ReadString();
 }
Example #18
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;
 }
Example #19
0
 protected override void Load(SwfStream stream, ushort length)
 {
     Actions = ActionRecord.ReadActions(stream, stream.ReadUShort());
 }