diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 5ea056a53..6df43e5c5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -22,9 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.CodeStats; import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode; -import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorJumps; -import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorRegisters; -import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorSimple; +import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.DeobfuscationLevel; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.Traits; @@ -177,6 +175,17 @@ public final class MethodBody implements Cloneable { return getCode().removeTraps(constants, trait, abc.method_info.get(method_info), this, abc, scriptIndex, classIndex, isStatic, path); } + public void deobfuscate(DeobfuscationLevel level, Trait trait, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException { + if (level == DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE) { + removeDeadCode(abc.constants, trait, abc.method_info.get(method_info)); + } else if (level == DeobfuscationLevel.LEVEL_REMOVE_TRAPS) { + removeTraps(abc.constants, abc, trait, scriptIndex, classIndex, isStatic, path); + } else if (level == DeobfuscationLevel.LEVEL_RESTORE_CONTROL_FLOW) { + removeTraps(abc.constants, abc, trait, scriptIndex, classIndex, isStatic, path); + restoreControlFlow(abc.constants, trait, abc.method_info.get(method_info)); + } + } + public void removeInstruction(int pos) { getCode().removeInstruction(pos, this); } @@ -291,9 +300,9 @@ public final class MethodBody implements Cloneable { throw ex; } catch (Exception | OutOfMemoryError | StackOverflowError ex) { if (ex instanceof TimeoutException) { - logger.log(Level.SEVERE, "Decompilation timeout in " + path, ex); + logger.log(Level.SEVERE, "Decompilation timeout in: " + path, ex); } else { - logger.log(Level.SEVERE, "Decompilation error in " + path, ex); + logger.log(Level.SEVERE, "Decompilation error in: " + path, ex); } convertException = ex; Throwable cause = ex.getCause(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java index 7348d04e0..fefc02662 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS2ScriptExporter.java @@ -144,7 +144,7 @@ public class AS2ScriptExporter { } else { List as = asm.getActions(); Action.setActionsAddresses(as, 0); - Action.actionsToSource(asm, as, ""/*FIXME*/, writer2); + Action.actionsToSource(asm, as, asm.toString()/*FIXME?*/, writer2); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index a5d9b682e..2eb4a2d50 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -1156,7 +1156,7 @@ public class XFLConverter { private static String convertActionScript(ASMSource as) { HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); try { - Action.actionsToSource(as, as.getActions(), as.toString(), writer); + Action.actionsToSource(as, as.getActions(), as.toString()/*FIXME?*/, writer); } catch (InterruptedException ex) { logger.log(Level.SEVERE, null, ex); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 5b4f39b51..d07ec135b 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2311,14 +2311,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se Trait t = abcPanel.decompiledTextArea.getCurrentTrait(); ABC abc = abcPanel.abc; if (bi != -1) { - if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE.getLevel()) { - abc.bodies.get(bi).removeDeadCode(abc.constants, t, abc.method_info.get(abc.bodies.get(bi).method_info)); - } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationLevel.LEVEL_REMOVE_TRAPS.getLevel()) { - abc.bodies.get(bi).removeTraps(abc.constants, abc, t, decompiledTextArea.getScriptLeaf().scriptIndex, decompiledTextArea.getClassIndex(), decompiledTextArea.getIsStatic(), ""/*FIXME*/); - } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationLevel.LEVEL_RESTORE_CONTROL_FLOW.getLevel()) { - abc.bodies.get(bi).removeTraps(abc.constants, abc, t, decompiledTextArea.getScriptLeaf().scriptIndex, decompiledTextArea.getClassIndex(), decompiledTextArea.getIsStatic(), ""/*FIXME*/); - abc.bodies.get(bi).restoreControlFlow(abc.constants, t, abc.method_info.get(abc.bodies.get(bi).method_info)); - } + int scriptIndex = decompiledTextArea.getScriptLeaf().scriptIndex; + int classIndex = decompiledTextArea.getClassIndex(); + boolean isStatic = decompiledTextArea.getIsStatic(); + abc.bodies.get(bi).deobfuscate(level, t, scriptIndex, classIndex, isStatic, ""/*FIXME*/); } abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc, t, abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getScriptIndex());