diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java index ed50e54d9..81c929bf5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/LocalDataArea.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action; import com.jpexs.decompiler.flash.ecma.EcmaScript; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Stack; @@ -35,6 +36,15 @@ public class LocalDataArea { public String executionException; + public LocalDataArea() { + } + + public LocalDataArea(boolean preserveVariableOrder) { + if (preserveVariableOrder) { + localVariables = new LinkedHashMap<>(); + } + } + public void clear() { constantPool = null; stack.clear(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java index 7ba8c3e7a..c54925330 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java @@ -197,7 +197,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { actions.removeZeroJumps(); ActionConstantPool cPool = getConstantPool(actions); - LocalDataArea localData = new LocalDataArea(); + LocalDataArea localData = new LocalDataArea(true); localData.stack = new FixItemCounterStack(); ExecutionResult result = new ExecutionResult(); FastActionListIterator iterator = actions.iterator(); @@ -451,8 +451,9 @@ public class ActionDeobfuscator implements SWFDecompilerListener { int skippedInstructions = 0; ActionConstantPool lastConstantPool = null; - boolean jumpFound = false; + boolean skippedInstructionsUnknown = false; boolean jumpedHere = true; + boolean jumpFound = false; while (true) { if (item.isExcluded()) { break; @@ -601,7 +602,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { } instructionsProcessed++; - if (!jumpFound) { + if (!skippedInstructionsUnknown) { boolean isJumpTarget = prevItem.isJumpTarget() || prevItem.prev.isContainerLastAction(); if (isJumpTarget) { if (prevJumpedHere && prevItem.jumpsHereSize() == 1) { @@ -610,25 +611,25 @@ public class ActionDeobfuscator implements SWFDecompilerListener { } if (isJumpTarget) { - jumpFound = true; + skippedInstructionsUnknown = true; } else { skippedInstructions++; if (action instanceof ActionIf) { - jumpFound = true; + skippedInstructionsUnknown = true; } } if (jumpedHere) { - jumpFound = true; + skippedInstructionsUnknown = true; } } } - if (isEnd || (stack.allItemsFixed() && !(action instanceof ActionPush))) { + if (isEnd || (stack.allItemsFixed() && (action instanceof ActionIf || (jumpFound && action instanceof ActionJump) || action instanceof ActionSetVariable))) { result.item = item; result.instructionsProcessed = instructionsProcessed; result.minSkippedInstructions = skippedInstructions; - result.maxSkippedInstructions = jumpFound ? Integer.MAX_VALUE : skippedInstructions; + result.maxSkippedInstructions = skippedInstructionsUnknown ? Integer.MAX_VALUE : skippedInstructions; result.constantPool = lastConstantPool; result.variables.clear(); for (String variableName : localData.localVariables.keySet()) { @@ -647,6 +648,10 @@ public class ActionDeobfuscator implements SWFDecompilerListener { result.resultValue = localData.returnValue; break; } + + if (action instanceof ActionJump) { + jumpFound = true; + } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/stat/Statistics.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/stat/Statistics.java index 80198450c..752946303 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/stat/Statistics.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/stat/Statistics.java @@ -33,7 +33,7 @@ public class Statistics implements AutoCloseable { private final Stopwatch sw; - public static synchronized void addTime(String name, long duration) { + private static synchronized void addTime(String name, long duration) { StatisticData s = map.get(name); if (s == null) { s = new StatisticData();