diff --git a/trunk/src/com/jpexs/decompiler/flash/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/Configuration.java index b8846dc72..0c38d7f16 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/Configuration.java @@ -45,10 +45,6 @@ public class Configuration { * Turn off resolving constants in ActionScript 2 */ public static final boolean RESOLVE_CONSTANTS = true; - /** - * Turn off decompiling if needed - */ - public static final boolean DO_DECOMPILE = true; /** * Find latest constant pool in the code */ diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java index bb0be69fc..b3fc080a9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java @@ -461,7 +461,17 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { public void hilightScript(String name) { ClassesListTreeModel clModel = (ClassesListTreeModel) classTree.getModel(); - ScriptPack pack = clModel.getList().get(name); + HashMap list = clModel.getList(); + ClassPath path = null; + for (ClassPath p : list.keySet()) { + if (p.toString().equals(name)) { + path = p; + } + } + if (path == null) { + return; + } + ScriptPack pack = clModel.getList().get(path); if (pack != null) { hilightScript(pack); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 43b8f735e..be3d83223 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -103,8 +103,8 @@ public class MethodBody implements Cloneable, Serializable { public String toString(String path, boolean pcode, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack scopeStack, boolean isStaticInitializer, boolean hilight, List fullyQualifiedNames, Traits initTraits) { String s = ""; - if (!Configuration.DO_DECOMPILE) { - s = "//NOT DECOMPILED"; + if (!(Boolean) Configuration.getConfig("decompile", Boolean.TRUE)) { + s = "//Decompilation skipped"; if (hilight) { s = Highlighting.hilighMethod(s, this.method_info); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index f4f9ddcaa..4cd5b3ff9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -443,11 +443,9 @@ public class TraitClass extends Trait implements TraitWithSlot { String bodyStr = ""; bodyIndex = abc.findBodyIndex(abc.class_info[class_info].cinit_index); if (bodyIndex != -1) { - if (Configuration.DO_DECOMPILE) { - bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits); - if (!highlight) { - bodyStr = Highlighting.stripHilights(bodyStr); - } + bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits); + if (!highlight) { + bodyStr = Highlighting.stripHilights(bodyStr); } } if (Highlighting.stripHilights(bodyStr).equals("")) { @@ -482,11 +480,9 @@ public class TraitClass extends Trait implements TraitWithSlot { bodyStr = ""; bodyIndex = abc.findBodyIndex(abc.instance_info[class_info].iinit_index); if (bodyIndex != -1) { - if (Configuration.DO_DECOMPILE) { - bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3); - if (!highlight) { - bodyStr = Highlighting.stripHilights(bodyStr); - } + bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3); + if (!highlight) { + bodyStr = Highlighting.stripHilights(bodyStr); } constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, abc.bodies[bodyIndex], abc, fullyQualifiedNames); } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 32e9e620a..26ce951e0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -52,9 +52,6 @@ public class TraitFunction extends Trait implements TraitWithSlot { @Override public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List fullyQualifiedNames, boolean paralel) { - if (!Configuration.DO_DECOMPILE) { - return ""; - } String header = convertHeader(path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlight, fullyQualifiedNames, paralel); String bodyStr = ""; int bodyIndex = abc.findBodyIndex(method_info); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java index bfccc2fad..e106182b7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java @@ -114,6 +114,10 @@ public class ActionPanel extends JPanel implements ActionListener { private boolean searchRegexp; private Cache cache = new Cache(true); + public void clearCache() { + cache.clear(); + } + public String getStringUnderCursor() { int pos = decompiledEditor.getCaretPosition(); for (Highlighting h : decompiledHilights) { @@ -258,7 +262,7 @@ public class ActionPanel extends JPanel implements ActionListener { @Override public void run() { editor.setText("; Disassembling..."); - if (Configuration.DO_DECOMPILE) { + if ((Boolean) Configuration.getConfig("decompile", Boolean.TRUE)) { decompiledEditor.setText("//Waiting for dissasembly..."); } DisassemblyListener listener = new DisassemblyListener() { @@ -286,7 +290,7 @@ public class ActionPanel extends JPanel implements ActionListener { srcNoHex = Helper.stripComments(lastDisasm); editor.setText("; Disassembling - setting"); setHex(hexButton.isSelected()); - if (Configuration.DO_DECOMPILE) { + if ((Boolean) Configuration.getConfig("decompile", Boolean.TRUE)) { decompiledEditor.setText("//Decompiling..."); String stripped = ""; if (!useCache) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 606a61b6c..13cad1b54 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -221,6 +221,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi private JCheckBoxMenuItem miInternalViewer; private JCheckBoxMenuItem miParallelSpeedUp; private JCheckBoxMenuItem miAssociate; + private JCheckBoxMenuItem miDecompile; public void setPercent(int percent) { progressBar.setValue(percent); @@ -448,10 +449,16 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi miGotoDocumentClass.addActionListener(this); menuBar.add(menuTools); + miDecompile = new JCheckBoxMenuItem("Disable decompilation (Disassemble only)"); + miDecompile.setSelected(!(Boolean) Configuration.getConfig("decompile", Boolean.TRUE)); + miDecompile.setActionCommand("DISABLEDECOMPILATION"); + miDecompile.addActionListener(this); + JMenu menuSettings = new JMenu("Settings"); menuSettings.add(autoDeobfuscateMenuItem); menuSettings.add(miInternalViewer); menuSettings.add(miParallelSpeedUp); + menuSettings.add(miDecompile); miAssociate = new JCheckBoxMenuItem("Add FFDec to SWF files context menu"); @@ -1494,9 +1501,26 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi return ret; } + private void clearCache() { + if (abcPanel != null) { + abcPanel.decompiledTextArea.clearScriptCache(); + } + if (actionPanel != null) { + actionPanel.clearCache(); + } + } + @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { + case "DISABLEDECOMPILATION": + Configuration.setConfig("decompile", !miDecompile.isSelected()); + clearCache(); + if (abcPanel != null) { + abcPanel.reload(); + } + reload(true); + break; case "ASSOCIATE": if (miAssociate.getState() == Main.isAssociated()) { return; @@ -1688,6 +1712,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi case "AUTODEOBFUSCATE": if (JOptionPane.showConfirmDialog(this, "Automatic deobfuscation is a way to decompile obfuscated code.\r\nDeobfuscation leads to slower decompilation and some of the dead code may be eliminated.\r\nIf the code is not obfuscated, it's better to turn autodeobfuscation off.\r\nDo you really want to " + (autoDeobfuscateMenuItem.getState() ? "turn ON" : "turn OFF") + " automatic debfuscation?", "Confirm", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { Configuration.setConfig("autoDeobfuscate", autoDeobfuscateMenuItem.getState()); + clearCache(); } else { autoDeobfuscateMenuItem.setState(!autoDeobfuscateMenuItem.getState()); } @@ -1970,6 +1995,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi cnt = swf.deobfuscateIdentifiers(renameType); Main.stopWork(); JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt); + clearCache(); if (abcPanel != null) { abcPanel.reload(); } @@ -2027,6 +2053,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi } Main.stopWork(); JOptionPane.showMessageDialog(null, "Deobfuscation complete"); + clearCache(); abcPanel.reload(); return true; }