diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 8f070d918..c28b780b2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -414,6 +414,23 @@ public final class SWF implements TreeItem { } tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly); if (!checkOnly) { + Map tagMap = new HashMap<>(); + for (Tag tag : tags) { + tagMap.put(tag.getPos(), tag); + } + + for (Tag tag : tags) { + if (tag instanceof ShowFrameTag) { + ShowFrameTag showFrameTag = (ShowFrameTag) tag; + List tagPositions = sis.tagPositionsInFrames.get(tag.getPos()); + List innerTags = new ArrayList<>(); + for (long tagPos : tagPositions) { + innerTags.add(tagMap.get(tagPos)); + } + showFrameTag.innerTags = innerTags; + } + } + assignExportNamesToSymbols(); assignClassesToSymbols(); findFileAttributes(); @@ -839,7 +856,8 @@ public final class SWF implements TreeItem { } TreeNode addNode = null; if (t instanceof ShowFrameTag) { - FrameNode tti = new FrameNode(new FrameNodeItem(t.getSwf(), frame, parent, false)); + // do not add PlaceObjects (+etc) to script nodes + FrameNode tti = new FrameNode(new FrameNodeItem(t.getSwf(), frame, parent, false), null); for (int r = ret.size() - 1; r >= 0; r--) { if (!(ret.get(r).getItem() instanceof DefineSpriteTag)) { diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 55a78e147..18f8b2f3f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -63,8 +63,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.Stack; +import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -82,7 +83,6 @@ import java.util.zip.InflaterInputStream; public class SWFInputStream extends InputStream { private InputStream is; - private final Stack margedPos = new Stack<>(); private long pos; private int version; private static final Logger logger = Logger.getLogger(SWFInputStream.class.getName()); @@ -90,7 +90,17 @@ public class SWFInputStream extends InputStream { private long percentMax; private final List buffered = new ArrayList<>(); private ByteArrayOutputStream buffer; - private static boolean DEOBFUSCATION_ALL_CODE_IN_PREVIOUS_TAG = Configuration.deobfuscateUsePrevTagOnly.get(); + private List tagPositionsInFrame = new ArrayList<>(); + public Map> tagPositionsInFrames = new HashMap<>(); + private List frameTagTypeIds = new ArrayList() {{ + add(PlaceObjectTag.ID); + add(PlaceObject2Tag.ID); + add(PlaceObject3Tag.ID); + add(PlaceObject4Tag.ID); + add(RemoveObjectTag.ID); + add(RemoveObject2Tag.ID); + add(FrameLabelTag.ID); + }}; public int getVersion() { return version; @@ -616,35 +626,6 @@ public class SWFInputStream extends InputStream { } } - /** - * Reads list of tags from the stream. Reading ends with End tag(=0) or end - * of the stream. - * - * @param swf - * @param level - * @param parallel - * @return List of tags - * @throws IOException - */ - public List readTagList(SWF swf, int level, boolean parallel) throws IOException, InterruptedException { - return readTagList(swf, level, parallel, false); - } - - /** - * Reads list of tags from the stream. Reading ends with End tag(=0) or end - * of the stream. Optionally can skip AS1/2 tags when file is AS3 - * - * @param swf - * @param level - * @param parallel - * @param skipUnusualTags - * @return List of tags - * @throws IOException - */ - public List readTagList(SWF swf, int level, boolean parallel, boolean skipUnusualTags) throws IOException, InterruptedException { - return readTagList(swf, level, parallel, skipUnusualTags, true); - } - /** * Reads list of tags from the stream. Reading ends with End tag(=0) or end * of the stream. Optionally can skip AS1/2 tags when file is AS3 @@ -686,6 +667,15 @@ public class SWFInputStream extends InputStream { } tag.previousTag = previousTag; previousTag = tag; + + if (frameTagTypeIds.contains(tag.getId())) { + tagPositionsInFrame.add(pos); + } + else if (tag.getId() == ShowFrameTag.ID) { + tagPositionsInFrames.put(pos, tagPositionsInFrame); + tagPositionsInFrame = new ArrayList<>(); + } + boolean doParse; if (!skipUnusualTags) { doParse = true; diff --git a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 985df6f7e..b660dafd3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -75,7 +75,7 @@ public class Configuration { public static final ConfigurationItem offeredAssociation = null; @ConfigurationDefaultBoolean(true) public static final ConfigurationItem removeNops = null; - @ConfigurationDefaultBoolean(false) + @ConfigurationDefaultBoolean(true) public static final ConfigurationItem showHexOnlyButton = null; @ConfigurationDefaultBoolean(false) public static final ConfigurationItem decimalAddress = null; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 280401793..08d0eb865 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.tags.PlaceObject4Tag; import com.jpexs.decompiler.flash.tags.PlaceObjectTag; import com.jpexs.decompiler.flash.tags.RemoveObject2Tag; import com.jpexs.decompiler.flash.tags.RemoveObjectTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag; @@ -113,7 +114,10 @@ public class TagTreeModel implements TreeModel { for (Tag t : list) { TreeNodeType ttype = TagTree.getTreeNodeType(t); switch (ttype) { - case SHOW_FRAME: frames.add(new FrameNode(new FrameNodeItem(t.getSwf(), ++frameCnt, parent, true))); break; + case SHOW_FRAME: + ShowFrameTag showFrameTag = (ShowFrameTag) t; + frames.add(new FrameNode(new FrameNodeItem(t.getSwf(), ++frameCnt, parent, true), showFrameTag.innerTags)); + break; case SHAPE: shapes.add(new TagNode(t)); break; case MORPH_SHAPE: morphShapes.add(new TagNode(t)); break; case SPRITE: sprites.add(new TagNode(t)); break; @@ -125,16 +129,8 @@ public class TagTreeModel implements TreeModel { case SOUND: sounds.add(new TagNode(t)); break; case BINARY_DATA: binaryData.add(new TagNode(t)); break; default: - if (!actionScriptTags.contains(t)) { - if (!(t instanceof PlaceObjectTag - || t instanceof PlaceObject2Tag - || t instanceof PlaceObject3Tag - || t instanceof PlaceObject4Tag - || t instanceof RemoveObjectTag - || t instanceof RemoveObject2Tag - || t instanceof FrameLabelTag)) { - others.add(new TagNode(t)); - } + if (!actionScriptTags.contains(t) && !isFrameInnerTag(t)) { + others.add(new TagNode(t)); } break; } @@ -254,9 +250,12 @@ public class TagTreeModel implements TreeModel { for (Tag t : list) { TreeNodeType ttype = TagTree.getTreeNodeType(t); switch (ttype) { - case SHOW_FRAME: frames.add(new FrameNode(new FrameNodeItem(t.getSwf(), ++frameCnt, parent, true))); break; + case SHOW_FRAME: + ShowFrameTag showFrameTag = (ShowFrameTag) t; + frames.add(new FrameNode(new FrameNodeItem(t.getSwf(), ++frameCnt, parent, true), showFrameTag.innerTags)); + break; default: - if (!actionScriptTags.contains(t)) { + if (!actionScriptTags.contains(t) && !isFrameInnerTag(t)) { others.add(new TagNode(t)); } break; @@ -274,6 +273,16 @@ public class TagTreeModel implements TreeModel { return ret; } + private boolean isFrameInnerTag(Tag t) { + return t instanceof PlaceObjectTag + || t instanceof PlaceObject2Tag + || t instanceof PlaceObject3Tag + || t instanceof PlaceObject4Tag + || t instanceof RemoveObjectTag + || t instanceof RemoveObject2Tag + || t instanceof FrameLabelTag; + } + private List searchTag(TreeItem obj, TreeNode parent, List path) { List ret = null; int cnt = getChildCount(parent); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java index 5e0fc938d..73171715a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java @@ -107,7 +107,7 @@ public class MethodCodePanel extends JPanel implements ActionListener { graphButton.setToolTipText(AppStrings.translate("button.viewgraph")); graphButton.setMargin(new Insets(3, 3, 3, 3)); - hexButton = new JToggleButton(View.getIcon("hex16")); + hexButton = new JToggleButton(View.getIcon("hexas16")); hexButton.setActionCommand(ACTION_HEX); hexButton.addActionListener(this); hexButton.setToolTipText(AppStrings.translate("button.viewhex")); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 2c7e6b870..0021b97fd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -450,7 +450,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene graphButton.setToolTipText(AppStrings.translate("button.viewgraph")); graphButton.setMargin(new Insets(3, 3, 3, 3)); - hexButton = new JToggleButton(View.getIcon("hex16")); + hexButton = new JToggleButton(View.getIcon("hexas16")); hexButton.setActionCommand(ACTION_HEX); hexButton.addActionListener(this); hexButton.setToolTipText(AppStrings.translate("button.viewhex")); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/graphics/hexas16.png b/trunk/src/com/jpexs/decompiler/flash/gui/graphics/hexas16.png new file mode 100644 index 000000000..a5385bf0c Binary files /dev/null and b/trunk/src/com/jpexs/decompiler/flash/gui/graphics/hexas16.png differ diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 5441d138a..1273b5d22 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -198,7 +198,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(data), version, pos); spriteId = sis.readUI16(); frameCount = sis.readUI16(); - subTags = sis.readTagList(swf, level + 1, parallel, skipUnusualTags); + subTags = sis.readTagList(swf, level + 1, parallel, skipUnusualTags, true); } static int c = 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.java index 3c60ebd91..a112d5421 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; +import java.util.List; /** * Instructs Flash Player to display the contents of the display list @@ -26,6 +27,8 @@ import com.jpexs.decompiler.flash.SWF; public class ShowFrameTag extends Tag { public static final int ID = 1; + + public List innerTags; /** * Constructor diff --git a/trunk/src/com/jpexs/decompiler/flash/treenodes/FrameNode.java b/trunk/src/com/jpexs/decompiler/flash/treenodes/FrameNode.java index 4abda8f96..94fdb0ce6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/treenodes/FrameNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/treenodes/FrameNode.java @@ -16,7 +16,9 @@ */ package com.jpexs.decompiler.flash.treenodes; +import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; +import java.util.List; /** * @@ -24,8 +26,13 @@ import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; */ public class FrameNode extends TreeNode { - public FrameNode(FrameNodeItem item) { + public FrameNode(FrameNodeItem item, List innerTags) { super(item); + if (innerTags != null) { + for (Tag tag : innerTags) { + subNodes.add(new TagNode(tag)); + } + } } @Override