mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 21:18:09 +00:00
Fixed AS2 - Do not detect classes inside functions
This commit is contained in:
@@ -2370,7 +2370,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
|
||||
List<GraphTargetItem> dec;
|
||||
try {
|
||||
dec = Action.actionsToTree(true /*Yes, inside doInitAction*/, dia.getActions(), version, staticOperation, ""/*FIXME*/);
|
||||
dec = Action.actionsToTree(true /*Yes, inside doInitAction*/, false, dia.getActions(), version, staticOperation, ""/*FIXME*/);
|
||||
} catch (EmptyStackException ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -830,8 +830,8 @@ public abstract class Action implements GraphSourceItem {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, List<Action> actions, int version, int staticOperation, String path) throws InterruptedException {
|
||||
return actionsToTree(insideDoInitAction, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
|
||||
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, boolean insideFunction, List<Action> actions, int version, int staticOperation, String path) throws InterruptedException {
|
||||
return actionsToTree(insideDoInitAction, insideFunction, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -857,7 +857,7 @@ public abstract class Action implements GraphSourceItem {
|
||||
public List<GraphTargetItem> call() throws Exception {
|
||||
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
|
||||
boolean insideDoInitAction = (asm instanceof DoInitActionTag);
|
||||
List<GraphTargetItem> tree = actionsToTree(insideDoInitAction, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
|
||||
List<GraphTargetItem> tree = actionsToTree(insideDoInitAction, false, new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
|
||||
SWFDecompilerPlugin.fireActionTreeCreated(tree, swf);
|
||||
if (Configuration.autoDeobfuscate.get()) {
|
||||
new ActionDeobfuscator().actionTreeCreated(tree, swf);
|
||||
@@ -916,8 +916,9 @@ public abstract class Action implements GraphSourceItem {
|
||||
* @return List of treeItems
|
||||
* @throws java.lang.InterruptedException
|
||||
*/
|
||||
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> actions, int version, int staticOperation, String path) throws InterruptedException {
|
||||
return ActionGraph.translateViaGraph(insideDoInitAction, regNames, variables, functions, actions, version, staticOperation, path);
|
||||
public static List<GraphTargetItem> actionsToTree(boolean insideDoInitAction, boolean insideFunction, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> actions, int version, int staticOperation, String path) throws InterruptedException {
|
||||
return ActionGraph.translateViaGraph(insideDoInitAction, insideFunction, regNames, variables, functions, actions, version, staticOperation, path
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1039,7 +1040,7 @@ public abstract class Action implements GraphSourceItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
out = ActionGraph.translateViaGraph(insideDoInitAction, regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName));
|
||||
out = ActionGraph.translateViaGraph(insideDoInitAction, true, regNames, variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName));
|
||||
} catch (OutOfMemoryError | TranslateException | StackOverflowError ex) {
|
||||
logger.log(Level.SEVERE, "Decompilation error in: " + path, ex);
|
||||
if (ex instanceof OutOfMemoryError) {
|
||||
|
||||
@@ -83,9 +83,12 @@ public class ActionGraph extends Graph {
|
||||
|
||||
private boolean insideDoInitAction;
|
||||
|
||||
public ActionGraph(String path, boolean insideDoInitAction, List<Action> code, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int version) {
|
||||
private boolean insideFunction;
|
||||
|
||||
public ActionGraph(String path, boolean insideDoInitAction, boolean insideFunction, List<Action> code, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int version) {
|
||||
super(new ActionGraphSource(path, insideDoInitAction, code, version, registerNames, variables, functions), new ArrayList<>());
|
||||
this.insideDoInitAction = insideDoInitAction;
|
||||
this.insideFunction = insideFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +113,7 @@ public class ActionGraph extends Graph {
|
||||
|
||||
for (ActionList al : outs) {
|
||||
subgraphs.put("loc" + Helper.formatAddress(code.pos2adr(ip)) + ": function " + functionName,
|
||||
new ActionGraph("", false, al, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION)
|
||||
new ActionGraph("", false, false, al, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -128,8 +131,8 @@ public class ActionGraph extends Graph {
|
||||
|
||||
}
|
||||
|
||||
public static List<GraphTargetItem> translateViaGraph(boolean insideDoInitAction, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> code, int version, int staticOperation, String path) throws InterruptedException {
|
||||
ActionGraph g = new ActionGraph(path, insideDoInitAction, code, registerNames, variables, functions, version);
|
||||
public static List<GraphTargetItem> translateViaGraph(boolean insideDoInitAction, boolean insideFunction, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, List<Action> code, int version, int staticOperation, String path) throws InterruptedException {
|
||||
ActionGraph g = new ActionGraph(path, insideDoInitAction, insideFunction, code, registerNames, variables, functions, version);
|
||||
ActionLocalData localData = new ActionLocalData(insideDoInitAction, registerNames);
|
||||
g.init(localData);
|
||||
return g.translate(localData, staticOperation, path);
|
||||
@@ -186,11 +189,6 @@ public class ActionGraph extends Graph {
|
||||
list.addAll(0, removed);
|
||||
}
|
||||
|
||||
if (insideDoInitAction) {
|
||||
ActionScript2ClassDetector detector = new ActionScript2ClassDetector();
|
||||
detector.checkClass(list, path);
|
||||
}
|
||||
|
||||
int targetStart;
|
||||
int targetEnd;
|
||||
|
||||
@@ -316,9 +314,14 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalProcessAfter(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) {
|
||||
super.finalProcessAfter(list, level, localData, path);
|
||||
makeDefineRegistersUp(list);
|
||||
public List<GraphTargetItem> translate(BaseLocalData localData, int staticOperation, String path) throws InterruptedException {
|
||||
List<GraphTargetItem> ret = super.translate(localData, staticOperation, path);
|
||||
if (insideDoInitAction && !insideFunction) {
|
||||
ActionScript2ClassDetector detector = new ActionScript2ClassDetector();
|
||||
detector.checkClass(ret, path);
|
||||
}
|
||||
makeDefineRegistersUp(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.swf3;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -101,7 +102,7 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
@Override
|
||||
public void translate(boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) throws InterruptedException {
|
||||
GraphTargetItem frameTi = new DirectValueActionItem(null, null, 0, (Long)((long)frame), new ArrayList<>());
|
||||
GraphTargetItem frameTi = new DirectValueActionItem(null, null, 0, (Long)((long)frame), new ArrayList<>());
|
||||
List<GraphTargetItem> body = ActionGraph.translateViaGraph(insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
|
||||
output.add(new IfFrameLoadedActionItem(frameTi, body, this, lineStartAction));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.swf4;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
@@ -147,7 +148,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore {
|
||||
@Override
|
||||
public void translate(boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) throws InterruptedException {
|
||||
GraphTargetItem frame = stack.pop();
|
||||
GraphTargetItem frame = stack.pop();
|
||||
List<GraphTargetItem> body = ActionGraph.translateViaGraph(insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path);
|
||||
output.add(new IfFrameLoadedActionItem(frame, body, this, lineStartAction));
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class PcodeGraphVizExporter {
|
||||
|
||||
public void exportAs12(ASMSource src, GraphTextWriter writer) throws InterruptedException {
|
||||
ActionList alist = src.getActions();
|
||||
ActionGraph gr = new ActionGraph("", false, alist, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION);
|
||||
ActionGraph gr = new ActionGraph("", false, false, alist, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION);
|
||||
export(gr, writer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user