diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef47edaf..7c02f9e69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Added - Display object depth in flash panel - Show imported files on script import, able to cancel import +- [#270] AS3 show progress on deofuscating p-code ### Fixed - [#1761] AS3 - try..finally inside another structure like if @@ -2330,6 +2331,7 @@ All notable changes to this project will be documented in this file. [alpha 9]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha8...alpha9 [alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8 [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 +[#270]: https://www.free-decompiler.com/flash/issues/270 [#1761]: https://www.free-decompiler.com/flash/issues/1761 [#1762]: https://www.free-decompiler.com/flash/issues/1762 [#1763]: https://www.free-decompiler.com/flash/issues/1763 @@ -2365,7 +2367,6 @@ All notable changes to this project will be documented in this file. [#1488]: https://www.free-decompiler.com/flash/issues/1488 [#1584]: https://www.free-decompiler.com/flash/issues/1584 [#1572]: https://www.free-decompiler.com/flash/issues/1572 -[#270]: https://www.free-decompiler.com/flash/issues/270 [#1645]: https://www.free-decompiler.com/flash/issues/1645 [#1639]: https://www.free-decompiler.com/flash/issues/1639 [#1371]: https://www.free-decompiler.com/flash/issues/1371 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/DeobfuscationListener.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/DeobfuscationListener.java new file mode 100644 index 000000000..3abed2bc1 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/DeobfuscationListener.java @@ -0,0 +1,9 @@ +package com.jpexs.decompiler.flash; + +/** + * + * @author JPEXS + */ +public interface DeobfuscationListener { + public void itemDeobfuscated(); +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 5b678d2fb..2236c6e5f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -168,6 +168,7 @@ import com.jpexs.helpers.Helper; import com.jpexs.helpers.ImmediateFuture; import com.jpexs.helpers.NulStream; import com.jpexs.helpers.ProgressListener; +import com.jpexs.helpers.Reference; import com.jpexs.helpers.SerializableImage; import com.jpexs.helpers.utf8.Utf8Helper; import java.awt.AlphaComposite; @@ -3353,13 +3354,24 @@ public final class SWF implements SWFContainerItem, Timelined { public void deobfuscate(DeobfuscationLevel level) throws InterruptedException { List atags = getAbcList(); + int apos = 0; for (ABCContainerTag tag : atags) { + apos++; + final int fpos = apos; + Reference numDeoScripts = new Reference<>(0); + DeobfuscationListener deoListener = new DeobfuscationListener() { + @Override + public void itemDeobfuscated() { + numDeoScripts.setVal(numDeoScripts.getVal() + 1); + informListeners("deobfuscate_pcode", "abc " + fpos + "/" + atags.size() + " script " + numDeoScripts.getVal() + "/" + tag.getABC().script_info.size()); + } + }; if (level == DeobfuscationLevel.LEVEL_REMOVE_DEAD_CODE) { - tag.getABC().removeDeadCode(); + tag.getABC().removeDeadCode(deoListener); } else if (level == DeobfuscationLevel.LEVEL_REMOVE_TRAPS) { - tag.getABC().removeTraps(); + tag.getABC().removeTraps(deoListener); } else if (level == DeobfuscationLevel.LEVEL_RESTORE_CONTROL_FLOW) { - tag.getABC().removeTraps(); + tag.getABC().removeTraps(deoListener); } ((Tag) tag).setModified(true); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 93fe40a57..e6b9b9f4e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc; +import com.jpexs.decompiler.flash.DeobfuscationListener; import com.jpexs.decompiler.flash.EndOfStreamException; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.SWF; @@ -232,14 +233,24 @@ public class ABC { } public int removeTraps() throws InterruptedException { + return removeTraps(null); + } + public int removeTraps(DeobfuscationListener listener) throws InterruptedException { int rem = 0; for (int s = 0; s < script_info.size(); s++) { rem += script_info.get(s).removeTraps(s, this, ""); + if (listener != null) { + listener.itemDeobfuscated(); + } } return rem; } public int removeDeadCode() throws InterruptedException { + return removeDeadCode(null); + } + + public int removeDeadCode(DeobfuscationListener listener) throws InterruptedException { int rem = 0; for (MethodBody body : bodies) { rem += body.removeDeadCode(constants, null/*FIXME*/, method_info.get(body.method_info)); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 19a604dbb..5c183e717 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -197,6 +197,7 @@ public class Main { public static SearchResultsStorage searchResultsStorage = new SearchResultsStorage(); public static CancellableWorker importWorker = null; + public static CancellableWorker deobfuscatePCodeWorker = null; //This method makes file watcher to shut up during our own file saving public static void startSaving(File savedFile) { @@ -1045,6 +1046,9 @@ public class Main { if (event.equals("deobfuscate")) { startWork(AppStrings.translate("work.deobfuscating") + "..." + (String) data, null); } + if (event.equals("deobfuscate_pcode")) { + startWork(AppStrings.translate("work.deobfuscating_pcode") + "..." + (String) data, deobfuscatePCodeWorker); + } if (event.equals("rename")) { startWork(AppStrings.translate("work.renaming") + "..." + (String) data, null); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 227357916..c6038ae9a 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2804,11 +2804,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se @Override protected void onStart() { + Main.deobfuscatePCodeWorker = this; Main.startWork(translate("work.deobfuscating") + "...", this); } @Override protected void done() { + Main.deobfuscatePCodeWorker = null; View.execInEventDispatch(() -> { Main.stopWork(); ViewMessages.showMessageDialog(MainPanel.this, translate("work.deobfuscating.complete")); diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 81fd076b8..fc83cbfea 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -851,4 +851,5 @@ tagInfo.dependentFrames = Dependent Frames imagePanel.depth = depth: work.importing_as = Importing script -importing_as.finishedin = Imported in %time% \ No newline at end of file +importing_as.finishedin = Imported in %time% +work.deobfuscating_pcode = Deobfuscating pcode \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties index eff01504e..0c8e86050 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties @@ -827,4 +827,5 @@ tagInfo.dependentFrames = Z\u00e1visl\u00e9 sn\u00edmky imagePanel.depth = hloubka: work.importing_as = Importuji skript -importing_as.finishedin = Importov\u00e1no za %time% \ No newline at end of file +importing_as.finishedin = Importov\u00e1no za %time% +work.deobfuscating_pcode = Deobfuskov\u00e1n\u00ed p-k\u00f3du \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 3a2807b95..c5c31be45 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -1241,7 +1241,7 @@ public class TagTreeContextMenu extends JPopupMenu { try { List actions = parser.actionsFromString("class " + dc.toPrintableString(false) + "{}"); doInit.setActions(actions); - } catch (ActionParseException | IOException | CompilationException ex) { + } catch (ActionParseException | IOException | CompilationException | InterruptedException ex) { //ignore }