From 0702259c88d1bf7c9c1f485710e5c80c5c91c487 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sat, 2 May 2015 22:09:28 +0200 Subject: [PATCH] resolve as2 constants button --- .../decompiler/flash/SWFInputStream.java | 8 +++--- .../flash/action/ActionListReader.java | 15 +++--------- .../flash/action/parser/pcode/ASMParser.java | 3 ++- .../flash/action/swf3/ActionWaitForFrame.java | 3 +-- .../action/swf4/ActionWaitForFrame2.java | 3 +-- .../flash/action/swf4/ConstantIndex.java | 2 ++ .../flash/tags/DefineButtonTag.java | 1 + .../decompiler/flash/tags/DoActionTag.java | 1 + .../flash/tags/DoInitActionTag.java | 1 + .../flash/types/BUTTONCONDACTION.java | 1 + .../flash/types/CLIPACTIONRECORD.java | 1 + .../flash/gui/action/ActionPanel.java | 23 ++++++++++++++++++ .../flash/gui/graphics/constantpool16.png | Bin 0 -> 621 bytes .../flash/gui/locales/MainFrame.properties | 1 + .../flash/gui/locales/MainFrame_hu.properties | 1 + 15 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/constantpool16.png diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index 89c61d4c2..dd4f0c853 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ConstantPool; import com.jpexs.decompiler.flash.action.special.ActionEnd; import com.jpexs.decompiler.flash.action.special.ActionNop; import com.jpexs.decompiler.flash.action.swf3.ActionGetURL; @@ -1565,11 +1564,10 @@ public class SWFInputStream implements AutoCloseable { /** * Reads one Action from the stream * - * @param cpool * @return Action or null when ActionEndFlag or end of the stream * @throws IOException */ - public Action readAction(ConstantPool cpool) throws IOException { + public Action readAction() throws IOException { int actionCode = -1; try { @@ -1603,7 +1601,7 @@ public class SWFInputStream implements AutoCloseable { case 0x09: return new ActionStopSounds(); case 0x8A: - return new ActionWaitForFrame(actionLength, this, cpool); + return new ActionWaitForFrame(actionLength, this); case 0x8B: return new ActionSetTarget(actionLength, this, swf.version); case 0x8C: @@ -1684,7 +1682,7 @@ public class SWFInputStream implements AutoCloseable { case 0x28: return new ActionEndDrag(); case 0x8D: - return new ActionWaitForFrame2(actionLength, this, cpool); + return new ActionWaitForFrame2(actionLength, this); case 0x26: return new ActionTrace(); case 0x34: diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java index ef9290aac..6c2f8852d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -131,13 +131,11 @@ public class ActionListReader { * @throws java.lang.InterruptedException */ public static ActionList readActionList(List listeners, SWFInputStream sis, int version, int ip, int endIp, String path, int deobfuscationMode) throws IOException, InterruptedException { - ConstantPool cpool = new ConstantPool(); - // Map of the actions. Use TreeMap to sort the keys in ascending order // actionMap and nextOffsets should contain exaclty the same keys Map actionMap = new TreeMap<>(); Map nextOffsets = new HashMap<>(); - Action entryAction = readActionListAtPos(listeners, cpool, + Action entryAction = readActionListAtPos(listeners, null, sis, actionMap, nextOffsets, ip, 0, endIp, path, false, new ArrayList()); @@ -238,12 +236,10 @@ public class ActionListReader { } public static List getOriginalActions(SWFInputStream sis, int startIp, int endIp) throws IOException, InterruptedException { - ConstantPool cpool = new ConstantPool(); - // Map of the actions. Use TreeMap to sort the keys in ascending order Map actionMap = new TreeMap<>(); Map nextOffsets = new HashMap<>(); - readActionListAtPos(new ArrayList(), cpool, + readActionListAtPos(new ArrayList(), null, sis, actionMap, nextOffsets, startIp, startIp, endIp + 1, "", false, new ArrayList()); @@ -690,7 +686,7 @@ public class ActionListReader { sis.seek((int) ip); Action a; - if ((a = sis.readAction(cpool)) == null) { + if ((a = sis.readAction()) == null) { break; } @@ -729,10 +725,7 @@ public class ActionListReader { if (a instanceof ActionPush && cpool != null) { ((ActionPush) a).constantPool = cpool.constants; } else if (a instanceof ActionConstantPool) { - if (cpool == null) { - cpool = new ConstantPool(); - } - cpool.setNew(((ActionConstantPool) a).constantPool); + cpool = new ConstantPool(((ActionConstantPool) a).constantPool); } else if (a instanceof ActionIf) { ActionIf aIf = (ActionIf) a; long nIp = ip + actionLengthWithHeader + aIf.getJumpOffset(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java index 6beabfc79..2c1485919 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.parser.pcode; import com.jpexs.decompiler.flash.action.Action; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java index 542945eea..3723c34cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java @@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraph; import com.jpexs.decompiler.flash.action.ActionList; -import com.jpexs.decompiler.flash.action.model.ConstantPool; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; import com.jpexs.decompiler.flash.action.parser.ActionParseException; @@ -46,7 +45,7 @@ public class ActionWaitForFrame extends Action implements ActionStore { public List skipped; - public ActionWaitForFrame(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException { + public ActionWaitForFrame(int actionLength, SWFInputStream sis) throws IOException { super(0x8A, actionLength); frame = sis.readUI16("frame"); skipCount = sis.readUI8("skipCount"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index c7b4359b6..59569ca52 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraph; import com.jpexs.decompiler.flash.action.ActionList; -import com.jpexs.decompiler.flash.action.model.ConstantPool; import com.jpexs.decompiler.flash.action.model.clauses.IfFrameLoadedActionItem; import com.jpexs.decompiler.flash.action.parser.ActionParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; @@ -60,7 +59,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore { skipCount = store.size(); } - public ActionWaitForFrame2(int actionLength, SWFInputStream sis, ConstantPool cpool) throws IOException { + public ActionWaitForFrame2(int actionLength, SWFInputStream sis) throws IOException { super(0x8D, actionLength); skipCount = sis.readUI8("skipCount"); skipped = new ArrayList<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java index 8a7a678d0..d617946f7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java @@ -46,6 +46,7 @@ public class ConstantIndex implements Serializable { } } } + return "constant" + index; } @@ -58,6 +59,7 @@ public class ConstantIndex implements Serializable { } } } + return "constant" + index; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 715f6afc2..8e25da103 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -196,6 +196,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { if (prevLength != 0) { rri.seek(prevLength); } + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index c9f89900d..a1ba2ec7c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -131,6 +131,7 @@ public class DoActionTag extends Tag implements ASMSource { if (prevLength != 0) { rri.seek(prevLength); } + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 66f1ff68b..937289a07 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -138,6 +138,7 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource { if (prevLength != 0) { rri.seek(prevLength); } + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, getVersion(), prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index f3c872ead..9ffe01748 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -205,6 +205,7 @@ public class BUTTONCONDACTION implements ASMSource, Serializable { if (prevLength != 0) { rri.seek(prevLength); } + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index fb333c17c..f3554c3fe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -199,6 +199,7 @@ public class CLIPACTIONRECORD implements ASMSource, Serializable { if (prevLength != 0) { rri.seek(prevLength); } + ActionList list = ActionListReader.readActionListTimeout(listeners, rri, swf.version, prevLength, prevLength + actionBytes.getLength(), toString()/*FIXME?*/); return list; } catch (InterruptedException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 2cdf2247b..f45d447e5 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -51,6 +51,7 @@ import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.Insets; @@ -68,6 +69,7 @@ import java.util.concurrent.CancellationException; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; +import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JLabel; @@ -114,6 +116,8 @@ public class ActionPanel extends JPanel implements SearchListeneraCvr zCoGlxItPScgVsZm4WUNJ-yxdRK#r0?f>NlV1<&>(?bdqtFYsWG>B;Qw?9TY!B(qvX zp$~?6Z|1%4eeb;)Ycv`yk|f!bQo^z<018TBt>X`y_0<{QWipxTUaxl-!{Hmn5(GjC zk*F{fq(@qhV@Yy?%)=7Z=!hxPwloi?-K*ZQFRT zy$#RnU^00N|LhDx2z)v{1v6%`*F2GR9DJA`V$=Fðx~UoS6_&*ur;$NR%0 z%-$V>Q*!nj0KV_z4h5c{`*3p`I{V(!I__<4X;9;AQMgQ`34?8#MNL7y{+M-u>9l?>Lt248Uo5Uw5JuX6Fc_?+uqJ>P-RE2n3dJJPPc&tA zc(V5l-Ti%3Div*WY0YLcEx|F$csyP`o3#_~hUSFsI1l&2jQuZwR;xvImUS?_Otjl= zor%xb_B>D9MPkUlsjO?cwekaZcke1+00000NkvXX Hu0mjfawHzd literal 0 HcmV?d00001 diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 3bfa3e4d3..d83cf9aab 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -583,3 +583,4 @@ preview.loop = Loop menu.file.import.script = Import script contextmenu.copyTagWithDependencies = Copy tag with dependencies to button.replaceWithTag = Replace with other character tag +button.resolveConstants = Resolve constants diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index cf9157f80..de1e70705 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -582,3 +582,4 @@ preview.loop = Ism\u00e9tl\u00e9s menu.file.import.script = Szkript import\u00e1l\u00e1sa contextmenu.copyTagWithDependencies = M\u00e1sol\u00e1s ide f\u00fcgg\u0151s\u00e9gekkel button.replaceWithTag = Csere m\u00e1sik karakter tagre +button.resolveConstants = Konstansok felold\u00e1sa