Exemplo n.º 1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public Swf(SwfHeader header,BaseTag[] tagList) {
     
     this.Header = header;
     this.tagList = tagList;
     
     // count actions
     _actionCount = 0;
     foreach (BaseTag b in tagList) {
         _actionCount+=b.ActionRecCount;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public Swf(SwfHeader header, BaseTag[] tagList)
        {
            this.Header  = header;
            this.tagList = tagList;

            // count actions
            _actionCount = 0;
            foreach (BaseTag b in tagList)
            {
                _actionCount += b.ActionRecCount;
            }
        }
        private void ExploreSWF(Stream stream)
        {
            SwfExportTagReader reader = new SwfExportTagReader(stream);
            Swf swf = null;
            try
            {
                swf = reader.ReadSwf();
            }
            catch (Exception ex)
            {
                Errors.Add("Swf error: " + ex.Message);
            }
            if (swf == null) return;

            Header = swf.Header;

            // list tags
            currentFrame = 0;
            DeclEntry frame = new DeclEntry("Frame 0");
            Frames.Add(frame);

            foreach (BaseTag tag in swf)
            {
                if (tag is ExportTag)
                {
                    ExportTag exportTag = tag as ExportTag;
                    foreach (string name in exportTag.Names)
                    {
                        if (name.StartsWith("__Packages."))
                        {
                            string cname = name.Substring(11);
                            Classes.Add(new DeclEntry(cname));
                        }
                        else Symbols.Add(new DeclEntry(name));
                    }
                }
                else if (tag is DoActionTag)
                {
                    AbcSize += tag.Data.Length;
                }
                else if (tag is AbcTag)
                {
                    ExploreABC((tag as AbcTag).abc);
                    AbcSize += tag.Data.Length;
                }
                else if ((TagCodeEnum)tag.TagCode == TagCodeEnum.ShowFrame)
                {
                    currentFrame++;
                    frame = new DeclEntry("Frame " + currentFrame);
                    Frames.Add(frame);
                }
                else if (tag is FrameTag)
                {
                    frame.Name = (tag as FrameTag).name;
                }
                else if (tag is DefineFontTag)
                {
                    DefineFontTag ftag = tag as DefineFontTag;
                    string style = "";
                    if (ftag.IsBold) style += "Bold ";
                    if (ftag.IsItalics) style += "Italic ";
                    Fonts.Add(new DeclEntry(ftag.Name + " (" + style + ftag.GlyphCount + ")"));
                    FontsSize += tag.Size;
                }
                else if ((TagCodeEnum)tag.TagCode == TagCodeEnum.FileAttributes)
                {
                    ParseAttributes(tag);
                }
                else if ((TagCodeEnum)tag.TagCode == TagCodeEnum.SetBackgroundColor)
                {
                    FileAttributes.Background = (tag.Data[2] << 16 | tag.Data[3] << 8 | tag.Data[4]).ToString("X");
                    while (FileAttributes.Background.Length < 6) FileAttributes.Background = "0" + FileAttributes.Background;
                    FileAttributes.Background = "#" + FileAttributes.Background;
                }

                if (tag is DoActionTag || tag is AbcTag) frame.AbcSize += tag.Size;
                else if (tag is DefineFontTag) frame.FontSize += tag.Size;
                else frame.DataSize += tag.Size;
                TotalSize += tag.Size;
            }

            // empty frame at the end
            if (Frames.Count > 1 && frame.DataSize == 4) Frames.Remove(frame);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Reads and parses swf header information into an instance of <see cref="SwfOp.Data.SwfHeader">SwfHeader</see>
		/// </summary>
		protected SwfHeader ReadHeader() {
			
			SwfHeader h = new SwfHeader(			                     
				br.ReadChars(3),
				br.ReadByte(),
				br.ReadUInt32(),
				this.ReadRectData(),
				br.ReadUInt16(),
				br.ReadUInt16()
			);
			
			this.version = h.Version;
			
			return h;
		}