Пример #1
0
		static void ExploreSWF(string swfname)
		{
			Stream stream = File.OpenRead(swfname);
			SwfExportTagReader reader = new SwfExportTagReader(new BufferedStream(stream)); 
			Swf swf = reader.ReadSwf(); 
			
			Hashtable tagsSeen = new Hashtable();

			// list tags
			ExportTag export;
			foreach(BaseTag tag in swf)
			{
				export = tag as ExportTag;
				if (export != null)
				{
					foreach(string name in export.Names)
					{
						if (!tagsSeen.Contains(name))
						{
							Console.WriteLine(name);
							tagsSeen.Add(name,true);
						}
					}
				}
			}
		}
        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);
        }
Пример #3
0
        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;
			
			// list tags
            int currentFrame = 1;
            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);
                            if (!Classes.Contains(cname)) Classes.Add(cname + frameInfo);
                        }
                        else if (!Symbols.Contains(name)) Symbols.Add(name + frameInfo);
                    }
                }
                else if (tag is AbcTag)
                {
                    AbcTag abcTag = tag as AbcTag;
                    ExploreABC(abcTag.abc);
                }
                else if ((TagCodeEnum)tag.TagCode == TagCodeEnum.ShowFrame)
                {
                    currentFrame++;
                    frameInfo = " @Frame " + currentFrame;
                }
                else if (tag  is FrameTag)
                {
                    frameInfo = " @Frame " + currentFrame + ": " + (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(ftag.Name + " (" + style + ftag.GlyphCount + ")" + frameInfo);
                }
            }
        }