diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index cbf214f70..85d62cf4c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -50,6 +50,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionIf; import com.jpexs.decompiler.flash.action.swf4.ActionNot; import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; +import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool; import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; @@ -412,6 +413,10 @@ public abstract class Action implements GraphSourceItem { * @return GraphTextWriter */ public static GraphTextWriter actionsToString(List listeners, long address, ActionList list, int version, ScriptExportMode exportMode, GraphTextWriter writer) { + if (exportMode == ScriptExportMode.CONSTANTS) { + return constantPoolActionsToString(listeners, address, list, version, exportMode, writer); + } + long offset; Set importantOffsets = getActionsAllRefs(list); /*List cps = SWFInputStream.getConstantPool(new ArrayList(), new ActionGraphSource(list, version, new HashMap(), new HashMap(), new HashMap()), 0, version, path); @@ -423,14 +428,13 @@ public abstract class Action implements GraphSourceItem { offset = address; int pos = 0; boolean lastPush = false; - for (GraphSourceItem s : list) { + for (Action a : list) { if (pos % INFORM_LISTENER_RESOLUTION == 0) { for (DisassemblyListener listener : listeners) { listener.progressToString(pos + 1, list.size()); } } - Action a = (Action) s; if (exportMode == ScriptExportMode.PCODE_HEX) { if (lastPush) { writer.newLine(); @@ -585,6 +589,30 @@ public abstract class Action implements GraphSourceItem { return writer; } + public static GraphTextWriter constantPoolActionsToString(List listeners, long address, ActionList list, int version, ScriptExportMode exportMode, GraphTextWriter writer) { + int poolIdx = 0; + writer.appendNoHilight(Helper.constants).newLine(); + for (Action a : list) { + if (a instanceof ActionConstantPool) { + ActionConstantPool cPool = (ActionConstantPool) a; + int constIdx = 0; + for (String c : cPool.constantPool) { + writer.appendNoHilight(poolIdx); + writer.appendNoHilight("|"); + writer.appendNoHilight(constIdx); + writer.appendNoHilight("|"); + writer.appendNoHilight(c); + writer.newLine(); + constIdx++; + } + + poolIdx++; + } + } + + return writer; + } + /** * Convert action to ASM source * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java index 1238448dc..e9cc885db 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/modes/ScriptExportMode.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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.exporters.modes; /** @@ -21,5 +22,5 @@ package com.jpexs.decompiler.flash.exporters.modes; */ public enum ScriptExportMode { - AS, PCODE, PCODE_HEX, HEX; + AS, PCODE, PCODE_HEX, HEX, CONSTANTS; } 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 a1ba2ec7c..9e333d6ac 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 @@ -110,6 +110,7 @@ public class DoActionTag extends Tag implements ASMSource { if (actions == null) { actions = getActions(); } + return Action.actionsToString(listeners, 0, actions, swf.version, exportMode, writer); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index 091351b8b..5e7b1677e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -66,6 +66,10 @@ public class Helper { public static String newLine = System.getProperty("line.separator"); + public static String hexData = "#hexdata"; + + public static String constants = "#constants"; + public static String decompilationErrorAdd = null; private static final Map shapeCache = new HashMap<>(); diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index b90f9e974..1d51bb642 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -1566,7 +1566,7 @@ public class CommandLineArgumentParser { private static void replaceAS2PCode(String text, ASMSource src) throws IOException, InterruptedException { System.out.println("Replace AS1/2 PCode"); - if (text.trim().startsWith("#hexdata")) { + if (text.trim().startsWith(Helper.hexData)) { src.setActionBytes(Helper.getBytesFromHexaText(text)); } else { try { @@ -1597,7 +1597,7 @@ public class CommandLineArgumentParser { private static void replaceAS3PCode(String text, ABC abc, int bodyIndex, Trait trait) throws IOException, InterruptedException { System.out.println("Replace AS3 PCode"); - if (text.trim().startsWith("#hexdata")) { + if (text.trim().startsWith(Helper.hexData)) { byte[] data = Helper.getBytesFromHexaText(text); MethodBody mb = abc.bodies.get(bodyIndex); mb.setCodeBytes(data); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 83f0ec70f..9a59b547d 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -205,7 +205,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi public boolean save() { try { String text = getText(); - if (text.trim().startsWith("#hexdata")) { + if (text.trim().startsWith(Helper.hexData)) { byte[] data = Helper.getBytesFromHexaText(text); MethodBody mb = abc.bodies.get(bodyIndex); mb.setCodeBytes(data); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java b/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java index 3a4f48a4f..a35a7db9d 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.gui.controls.NoneSelectedButtonGroup; import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType; import java.awt.BorderLayout; import java.awt.Font; @@ -117,6 +118,10 @@ public class MethodCodePanel extends JPanel { hexOnlyButton.setToolTipText(AppStrings.translate("button.viewhex")); hexOnlyButton.setMargin(new Insets(3, 3, 3, 3)); + NoneSelectedButtonGroup exportModeButtonGroup = new NoneSelectedButtonGroup(); + exportModeButtonGroup.add(hexButton); + exportModeButtonGroup.add(hexOnlyButton); + buttonsPanel.add(graphButton); buttonsPanel.add(hexButton); buttonsPanel.add(hexOnlyButton); @@ -140,7 +145,6 @@ public class MethodCodePanel extends JPanel { return; } - hexOnlyButton.setSelected(false); sourceTextArea.setHex(getExportMode(), false); } @@ -149,7 +153,6 @@ public class MethodCodePanel extends JPanel { return; } - hexButton.setSelected(false); sourceTextArea.setHex(getExportMode(), false); } diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 419f5edae..7c4e12520 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -43,6 +43,7 @@ import com.jpexs.decompiler.flash.gui.SearchResultsDialog; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane; +import com.jpexs.decompiler.flash.gui.controls.NoneSelectedButtonGroup; import com.jpexs.decompiler.flash.gui.tagtree.TagTreeModel; import com.jpexs.decompiler.flash.helpers.HighlightedText; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; @@ -115,6 +116,8 @@ public class ActionPanel extends JPanel implements SearchListener. + */ +package com.jpexs.decompiler.flash.gui.controls; + +import javax.swing.ButtonGroup; +import javax.swing.ButtonModel; + +/** + * + * @author JPEXS + */ +public class NoneSelectedButtonGroup extends ButtonGroup { + + @Override + public void setSelected(ButtonModel model, boolean selected) { + if (selected) { + super.setSelected(model, selected); + } else { + clearSelection(); + } + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index d83cf9aab..118b2189d 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -584,3 +584,4 @@ menu.file.import.script = Import script contextmenu.copyTagWithDependencies = Copy tag with dependencies to button.replaceWithTag = Replace with other character tag button.resolveConstants = Resolve constants +button.viewConstants = View 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 de1e70705..36b2ae690 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -583,3 +583,4 @@ 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 +button.viewConstants = Konstansok mutat\u00e1sa \ No newline at end of file