static void ExploreSWF(Stream stream) { if (stream == null) { return; } SwfReader reader = new SwfReader(stream); //SwfExportTagReader reader = new SwfExportTagReader(stream); Swf swf = null; try { swf = reader.ReadSwf(); foreach (BaseTag tag in swf) { if (tag is ExportTag) { ExportTag etag = (ExportTag)tag; for (int i = 0; i < etag.Ids.Count; i++) { BaseTag ftag = FindObject(swf, (ushort)etag.Ids[i]); if (ftag is DefineSpriteTag) { DefineSpriteTag stag = (DefineSpriteTag)ftag; Console.WriteLine("Symbol '" + etag.Names[i] + "' - " + stag.Size); } else if (ftag is DefineSoundTag) { DefineSoundTag stag = (DefineSoundTag)ftag; Console.WriteLine("Sound '" + etag.Names[i] + "' - " + stag.MediaData.Length); } else if (ftag is DefineBitsTag) { DefineBitsTag btag = (DefineBitsTag)ftag; Console.WriteLine("Image '" + etag.Names[i] + "' - " + btag.MediaData.Length); } } } else if (tag is DefineFontTag) { DefineFontTag ftag = (DefineFontTag)tag; Console.WriteLine("Font '" + ftag.Name + "' - " + ftag.Data.Length); } } } catch (Exception ex) { Console.WriteLine("-- Swf error: " + ex.Message); } }
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); } } }
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); } }