mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 18:34:45 +00:00
AS1/2 ActionTry fix
AS1/2 Infinity
This commit is contained in:
@@ -19,11 +19,9 @@ package com.jpexs.decompiler.flash;
|
||||
import SevenZip.Compression.LZMA.Encoder;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionGraphSource;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItemContainer;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionIf;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable;
|
||||
import com.jpexs.decompiler.flash.action.swf4.Null;
|
||||
@@ -46,12 +44,11 @@ import com.jpexs.decompiler.flash.flv.FLVOutputStream;
|
||||
import com.jpexs.decompiler.flash.flv.FLVTAG;
|
||||
import com.jpexs.decompiler.flash.flv.VIDEODATA;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItemContainer;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.flash.gui.FrameNode;
|
||||
import com.jpexs.decompiler.flash.gui.TagNode;
|
||||
import com.jpexs.decompiler.flash.helpers.Helper;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag;
|
||||
@@ -240,7 +237,7 @@ public class SWF {
|
||||
* @param is Stream to read SWF from
|
||||
* @throws IOException
|
||||
*/
|
||||
public SWF(InputStream is, PercentListener listener) throws IOException {
|
||||
public SWF(InputStream is, PercentListener listener) throws IOException {
|
||||
byte hdr[] = new byte[3];
|
||||
is.read(hdr);
|
||||
String shdr = new String(hdr);
|
||||
@@ -287,7 +284,7 @@ public class SWF {
|
||||
int tmpFirstByetOfFrameRate = sis.readUI8();
|
||||
frameRate = sis.readUI8();
|
||||
frameCount = sis.readUI16();
|
||||
tags = sis.readTagList(0);
|
||||
tags = sis.readTagList(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -949,6 +946,7 @@ public class SWF {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void getVariables(ConstantPool constantPool, List localData, Stack<GraphTargetItem> stack, List<GraphTargetItem> output, ActionGraphSource code, int ip, int lastIp, HashMap<DirectValueTreeItem, ConstantPool> variables, List<GraphSourceItem> functions, List<Integer> visited) {
|
||||
boolean debugMode = false;
|
||||
while ((ip > -1) && ip < code.size()) {
|
||||
@@ -958,11 +956,11 @@ public class SWF {
|
||||
|
||||
lastIp = ip;
|
||||
GraphSourceItem ins = code.get(ip);
|
||||
|
||||
|
||||
if (debugMode) {
|
||||
System.err.println("Visit " + ip + ": ofs" +Helper.formatAddress(((Action)ins).getAddress())+":" + ((Action)ins).getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), code.version,false) + " stack:" + Helper.stackToString(stack, Helper.toList(new ConstantPool())));
|
||||
System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), code.version, false) + " stack:" + Helper.stackToString(stack, Helper.toList(new ConstantPool())));
|
||||
}
|
||||
if(ins.isIgnored()){
|
||||
if (ins.isIgnored()) {
|
||||
ip++;
|
||||
continue;
|
||||
}
|
||||
@@ -984,11 +982,20 @@ public class SWF {
|
||||
}
|
||||
|
||||
if (ins instanceof GraphSourceItemContainer) {
|
||||
long endAddr=((GraphSourceItemContainer)ins).getEndAddress();
|
||||
int endIp=code.adr2pos(endAddr);
|
||||
getVariables(variables, functions, new ActionGraphSource(code.getActions().subList(ip+1, endIp), code.version, new HashMap<Integer, String>(),new HashMap<String, GraphTargetItem>(),new HashMap<String, GraphTargetItem>()),0);
|
||||
((GraphSourceItemContainer)ins).translateContainer(new ArrayList<GraphTargetItem>(), stack, output, new HashMap<Integer, String>(),new HashMap<String, GraphTargetItem>(),new HashMap<String, GraphTargetItem>());
|
||||
ip=endIp;
|
||||
GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins;
|
||||
List<Long> cntSizes = cnt.getContainerSizes();
|
||||
long addr = code.pos2adr(ip + 1);
|
||||
for (Long size : cntSizes) {
|
||||
if (size == 0) {
|
||||
continue;
|
||||
}
|
||||
ip = code.adr2pos(addr);
|
||||
addr += size;
|
||||
int nextip = code.adr2pos(addr);
|
||||
getVariables(variables, functions, new ActionGraphSource(code.getActions().subList(ip, nextip), code.version, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>()), 0);
|
||||
ip = nextip;
|
||||
}
|
||||
((GraphSourceItemContainer) ins).translateContainer(new ArrayList<List<GraphTargetItem>>(), stack, output, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1017,7 +1024,7 @@ public class SWF {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ins.isBranch() || ins.isJump()) {
|
||||
if (ins.isBranch() || ins.isJump()) {
|
||||
if (ins instanceof ActionIf) {
|
||||
stack.pop();
|
||||
}
|
||||
@@ -1033,7 +1040,7 @@ public class SWF {
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
break;
|
||||
}
|
||||
ip++;
|
||||
@@ -1052,29 +1059,29 @@ public class SWF {
|
||||
private HashMap<DirectValueTreeItem, ConstantPool> getVariables(HashMap<DirectValueTreeItem, ConstantPool> variables, List<GraphSourceItem> functions, ASMSource src) {
|
||||
HashMap<DirectValueTreeItem, ConstantPool> ret = new HashMap<DirectValueTreeItem, ConstantPool>();
|
||||
List<Action> actions = src.getActions(version);
|
||||
/* int ip=0;
|
||||
for(Action a:actions){
|
||||
System.out.println("ip "+ip+" "+a.getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), version, false));
|
||||
ip++;
|
||||
}
|
||||
if(true)
|
||||
return ret;*/
|
||||
/* int ip=0;
|
||||
for(Action a:actions){
|
||||
System.out.println("ip "+ip+" "+a.getASMSource(new ArrayList<GraphSourceItem>(), new ArrayList<Long>(), new ArrayList<String>(), version, false));
|
||||
ip++;
|
||||
}
|
||||
if(true)
|
||||
return ret;*/
|
||||
actionsMap.put(src, actions);
|
||||
List<GraphSourceItem> ss=new ArrayList<GraphSourceItem>();
|
||||
List<GraphSourceItem> ss = new ArrayList<GraphSourceItem>();
|
||||
ss.addAll(actions);
|
||||
getVariables(variables, functions, new ActionGraphSource(ss, version, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>()), 0);
|
||||
return ret;
|
||||
}
|
||||
private HashMap<ASMSource, List<Action>> actionsMap = new HashMap<ASMSource, List<Action>>();
|
||||
|
||||
private void getVariables(List<Object> objs,String path) {
|
||||
private void getVariables(List<Object> objs, String path) {
|
||||
for (Object o : objs) {
|
||||
if (o instanceof ASMSource) {
|
||||
informListeners("getVariables", path+"/"+o.toString());
|
||||
informListeners("getVariables", path + "/" + o.toString());
|
||||
getVariables(allVariableNames, allFunctions, (ASMSource) o);
|
||||
}
|
||||
if (o instanceof Container) {
|
||||
getVariables(((Container) o).getSubItems(),path+"/"+o.toString());
|
||||
getVariables(((Container) o).getSubItems(), path + "/" + o.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1086,7 +1093,7 @@ public class SWF {
|
||||
List<Object> objs = new ArrayList<Object>();
|
||||
int ret = 0;
|
||||
objs.addAll(tags);
|
||||
getVariables(objs,"");
|
||||
getVariables(objs, "");
|
||||
for (GraphSourceItem fun : allFunctions) {
|
||||
if (fun instanceof ActionDefineFunction) {
|
||||
ActionDefineFunction f = (ActionDefineFunction) fun;
|
||||
|
||||
Reference in New Issue
Block a user