diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index ae4c3ddd8..79e543b27 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -79,7 +79,6 @@ public class SWFInputStream extends InputStream { private List buffered = new ArrayList(); private ByteArrayOutputStream buffer; private static boolean DEOBFUSCATION_ALL_CODE_IN_PREVIOUS_TAG = (Boolean) Configuration.getConfig("deobfuscateUsePrevTagOnly", true); - private static boolean AUTO_DEOBFUSCATE = (Boolean) Configuration.getConfig("autoDeobfuscate", true); public int getBufferLength() { return buffer.size(); @@ -587,7 +586,7 @@ public class SWFInputStream extends InputStream { if (ins.isBranch() || ins.isJump()) { - if (AUTO_DEOBFUSCATE && (ins instanceof ActionIf) && !stack.isEmpty() && (stack.peek().isCompileTime() && (!stack.peek().hasSideEffect()))) { + if ((Boolean) Configuration.getConfig("autoDeobfuscate", false) && (ins instanceof ActionIf) && !stack.isEmpty() && (stack.peek().isCompileTime() && (!stack.peek().hasSideEffect()))) { ActionIf aif = (ActionIf) ins; if (aif.ignoreUsed && (!aif.jumpUsed)) { ins.setIgnored(true); @@ -874,7 +873,7 @@ public class SWFInputStream extends InputStream { } else if (next.equals("c")) { goaif = true; } - } else if (AUTO_DEOBFUSCATE && top.isCompileTime() && (!top.hasSideEffect()) && ((!top.isVariableComputed()) || (top.isVariableComputed() && enableVariables && (!notCompileTime)))) { + } else if ((Boolean) Configuration.getConfig("autoDeobfuscate", false) && top.isCompileTime() && (!top.hasSideEffect()) && ((!top.isVariableComputed()) || (top.isVariableComputed() && enableVariables && (!notCompileTime)))) { //if(top.isCompileTime()) { //if(false){ if (enableVariables) { 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 7fdf48898..a3e49363f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -43,7 +43,6 @@ public class MethodBody implements Cloneable, Serializable { public AVM2Code code; public ABCException exceptions[] = new ABCException[0]; public Traits traits = new Traits(); - private static boolean AUTO_DEOBFUSCATE = (Boolean) Configuration.getConfig("autoDeobfuscate", true); public List getExceptionEntries() { List ret = new ArrayList(); @@ -117,7 +116,7 @@ public class MethodBody implements Cloneable, Serializable { MethodBody b = (MethodBody) Helper.deepCopy(this); deobfuscated = b.code; deobfuscated.markMappedOffsets(); - if (AUTO_DEOBFUSCATE) { + if ((Boolean) Configuration.getConfig("autoDeobfuscate", true)) { deobfuscated.removeTraps(constants, b, abc); } //deobfuscated.restoreControlFlow(constants, b); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 14a2a1c5b..0e67de670 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -163,6 +163,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi private JPanel detailPanel; private JTextField filterField = new JTextField(""); private JPanel searchPanel; + private JCheckBoxMenuItem autoDeobfuscateMenuItem; public void setPercent(int percent) { progressBar.setValue(percent); @@ -268,6 +269,12 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi miDeobfuscation.setActionCommand("DEOBFUSCATE"); miDeobfuscation.addActionListener(this); + autoDeobfuscateMenuItem = new JCheckBoxMenuItem("Automatic deobfuscation"); + autoDeobfuscateMenuItem.setState((Boolean) Configuration.getConfig("autoDeobfuscate", true)); + autoDeobfuscateMenuItem.addActionListener(this); + autoDeobfuscateMenuItem.setActionCommand("AUTODEOBFUSCATE"); + + menuDeobfuscation.add(autoDeobfuscateMenuItem); JCheckBoxMenuItem miSubLimiter = new JCheckBoxMenuItem("Enable sub limiter"); miSubLimiter.setActionCommand("SUBLIMITER"); miSubLimiter.addActionListener(this); @@ -954,6 +961,13 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi @Override public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("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()); + } else { + autoDeobfuscateMenuItem.setState(!autoDeobfuscateMenuItem.getState()); + } + } if (e.getActionCommand().equals("EXIT")) { setVisible(false); if (Main.proxyFrame != null) {