mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 22:30:45 +00:00
Experimental execution of AS1/2 in FFDec Flash viewer (very basic, needs testing and many improvements)
This commit is contained in:
@@ -794,12 +794,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
ret[0] = 'Z';
|
||||
} else if (compression == SWFCompression.ZLIB) {
|
||||
ret[0] = 'C';
|
||||
} else if (gfx) {
|
||||
ret[0] = 'G';
|
||||
} else {
|
||||
if (gfx) {
|
||||
ret[0] = 'G';
|
||||
} else {
|
||||
ret[0] = 'F';
|
||||
}
|
||||
ret[0] = 'F';
|
||||
}
|
||||
|
||||
if (gfx) {
|
||||
@@ -1480,10 +1478,8 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
if (as3) {
|
||||
ret.addAll(new AS3ScriptExporter().exportActionScript3(this, handler, outdir, as3scripts, exportSettings, parallel, evl));
|
||||
}
|
||||
} else {
|
||||
if (as2) {
|
||||
ret.addAll(new AS2ScriptExporter().exportAS2Scripts(handler, outdir, getASMs(true), exportSettings, parallel, evl));
|
||||
}
|
||||
} else if (as2) {
|
||||
ret.addAll(new AS2ScriptExporter().exportAS2Scripts(handler, outdir, getASMs(true), exportSettings, parallel, evl));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1902,10 +1898,8 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
TranslateStack brStack = (TranslateStack) stack.clone();
|
||||
if (b >= 0) {
|
||||
getVariables(constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path);
|
||||
} else {
|
||||
if (debugMode) {
|
||||
System.out.println("Negative branch:" + b);
|
||||
}
|
||||
} else if (debugMode) {
|
||||
System.out.println("Negative branch:" + b);
|
||||
}
|
||||
}
|
||||
// }
|
||||
@@ -2020,12 +2014,10 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
cnt += deobfuscateAS2Identifiers(renameType);
|
||||
cnt += deobfuscateAS3Identifiers(renameType);
|
||||
return cnt;
|
||||
} else if (fileAttributes.actionScript3) {
|
||||
return deobfuscateAS3Identifiers(renameType);
|
||||
} else {
|
||||
if (fileAttributes.actionScript3) {
|
||||
return deobfuscateAS3Identifiers(renameType);
|
||||
} else {
|
||||
return deobfuscateAS2Identifiers(renameType);
|
||||
}
|
||||
return deobfuscateAS2Identifiers(renameType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3060,16 +3052,14 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
timelined.removeTag(tag);
|
||||
timelined.setModified(true);
|
||||
timelined.resetTimeline();
|
||||
} else // timeline should be always the swf here
|
||||
if (removeDependencies) {
|
||||
removeTagWithDependenciesFromTimeline(tag, timelined.getTimeline());
|
||||
timelined.setModified(true);
|
||||
} else {
|
||||
// timeline should be always the swf here
|
||||
if (removeDependencies) {
|
||||
removeTagWithDependenciesFromTimeline(tag, timelined.getTimeline());
|
||||
boolean modified = removeTagFromTimeline(tag, timelined.getTimeline());
|
||||
if (modified) {
|
||||
timelined.setModified(true);
|
||||
} else {
|
||||
boolean modified = removeTagFromTimeline(tag, timelined.getTimeline());
|
||||
if (modified) {
|
||||
timelined.setModified(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3121,14 +3111,11 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tag to the SWF
|
||||
* If targetTreeItem is:
|
||||
* - Frame: adds the tag to the Frame. Frame can be a frame of the main
|
||||
* timeline or a DefineSprite frame
|
||||
* - DefineSprite: adds the tag to the end of the DefineSprite's tag list
|
||||
* - Any other tag in the SWF: adds the new tag exactly before the specified
|
||||
* tag
|
||||
* - Other: adds the tag to the end of the SWF's tag list
|
||||
* Adds a tag to the SWF If targetTreeItem is: - Frame: adds the tag to the
|
||||
* Frame. Frame can be a frame of the main timeline or a DefineSprite frame
|
||||
* - DefineSprite: adds the tag to the end of the DefineSprite's tag list -
|
||||
* Any other tag in the SWF: adds the new tag exactly before the specified
|
||||
* tag - Other: adds the tag to the end of the SWF's tag list
|
||||
*
|
||||
* @param tag
|
||||
* @param targetTreeItem
|
||||
|
||||
@@ -15,6 +15,14 @@ public class ActionScriptFunction extends ActionScriptObject {
|
||||
protected List<String> paramNames;
|
||||
protected Map<Integer, String> funcRegNames;
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
public Map<Integer, String> getFuncRegNames() {
|
||||
return funcRegNames;
|
||||
}
|
||||
|
||||
public ActionScriptFunction(long functionOffset, long functionLength, String functionName, List<String> paramNames, Map<Integer, String> funcRegNames) {
|
||||
this.functionOffset = functionOffset;
|
||||
this.functionLength = functionLength;
|
||||
@@ -23,11 +31,6 @@ public class ActionScriptFunction extends ActionScriptObject {
|
||||
this.funcRegNames = funcRegNames;
|
||||
}
|
||||
|
||||
public Object execute(Object thisObj, List<Object> args) {
|
||||
//TODO!!!
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getFunctionLength() {
|
||||
return functionLength;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -54,6 +56,11 @@ public class DisplayObject extends ActionScriptObject {
|
||||
paused = false;
|
||||
}
|
||||
|
||||
public Object callFunction(long functionAddress, long functionLength, List<Object> args, Map<Integer, String> regNames, Object thisObj) {
|
||||
//TODO
|
||||
return Undefined.INSTANCE;
|
||||
}
|
||||
|
||||
public void callFrame(int frame) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class LocalDataArea {
|
||||
|
||||
public Stack<Object> stack = new Stack<>();
|
||||
|
||||
public List<Object> functions = new ArrayList<>();
|
||||
public List<ActionScriptFunction> functions = new ArrayList<>();
|
||||
|
||||
public Map<String, Object> localVariables = new HashMap<>();
|
||||
|
||||
@@ -70,6 +70,9 @@ public class LocalDataArea {
|
||||
constantPool = null;
|
||||
stack.clear();
|
||||
localVariables.clear();
|
||||
localRegisters.clear();
|
||||
withs.clear();
|
||||
functions.clear();
|
||||
jump = null;
|
||||
returnValue = null;
|
||||
executionException = null;
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.special;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
@@ -47,6 +48,7 @@ public class ActionEnd extends Action {
|
||||
|
||||
@Override
|
||||
public boolean execute(LocalDataArea lda) {
|
||||
lda.returnValue = Undefined.INSTANCE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,11 @@ package com.jpexs.decompiler.flash.action.swf5;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionScriptFunction;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.model.CallFunctionActionItem;
|
||||
import com.jpexs.decompiler.flash.ecma.Null;
|
||||
import com.jpexs.decompiler.flash.ecma.Undefined;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -47,6 +50,19 @@ public class ActionCallFunction extends Action {
|
||||
|
||||
@Override
|
||||
public boolean execute(LocalDataArea lda) {
|
||||
|
||||
String functionName = lda.popAsString();
|
||||
int numArgs = (int) (double) lda.popAsNumber();
|
||||
List<Object> args = new ArrayList<>();
|
||||
for (int i = 0; i < numArgs; i++) {
|
||||
args.add(lda.pop());
|
||||
}
|
||||
for (ActionScriptFunction f : lda.functions) {
|
||||
if (functionName.equals(f.getFunctionName())) {
|
||||
lda.stack.push(lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), Undefined.INSTANCE /*?*/));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ public class ActionCallMethod extends Action {
|
||||
args.add(lda.pop());
|
||||
}
|
||||
|
||||
lda.stack.push(((ActionScriptFunction) obj.getMember(methodName)).execute(obj, args));
|
||||
ActionScriptFunction f = (ActionScriptFunction) obj.getMember(methodName);
|
||||
|
||||
lda.stack.push(lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), obj));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ public class ActionNewMethod extends Action {
|
||||
args.add(lda.pop());
|
||||
}
|
||||
ActionScriptObject nobj = new ActionScriptObject();
|
||||
|
||||
((ActionScriptFunction) obj.getMember(methodName)).execute(nobj, args);
|
||||
ActionScriptFunction f = (ActionScriptFunction) obj.getMember(methodName);
|
||||
lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), nobj);
|
||||
lda.stack.push(nobj);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ActionNewObject extends Action {
|
||||
ActionScriptObject obj = new ActionScriptObject();
|
||||
//TODO:check type
|
||||
ActionScriptFunction constructor = (ActionScriptFunction) lda.stage.getMember(objectName);
|
||||
constructor.execute(obj, args);
|
||||
lda.stage.callFunction(constructor.getFunctionOffset(), constructor.getFunctionLength(), args, constructor.getFuncRegNames(), obj);
|
||||
lda.stack.push(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -543,6 +543,11 @@ public class Configuration {
|
||||
@ConfigurationCategory("import")
|
||||
public static final ConfigurationItem<Boolean> shapeImportUseNonSmoothedFill = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("display")
|
||||
@ConfigurationName("internalFlashViewer.execute.as12")
|
||||
public static final ConfigurationItem<Boolean> internalFlashViewerExecuteAs12 = null;
|
||||
|
||||
private enum OSId {
|
||||
|
||||
WINDOWS, OSX, UNIX
|
||||
|
||||
Reference in New Issue
Block a user