invalid jump fix

This commit is contained in:
honfika@gmail.com
2015-07-04 20:47:07 +02:00
parent 9893296f1d
commit 6cafe970fb
7 changed files with 37 additions and 9 deletions

View File

@@ -61,6 +61,7 @@ public class ScriptPack extends AS3ClassTreeItem {
public final List<Integer> traitIndices;
private final ClassPath path;
public boolean isSimple = false;
@Override
@@ -190,7 +191,7 @@ public class ScriptPack extends AS3ClassTreeItem {
} catch (TimeoutException ex) {
writer.continueMeasure();
logger.log(Level.SEVERE, "Decompilation error", ex);
Helper.appendTimeoutComment(writer, timeout);
Helper.appendTimeoutCommentAs3(writer, timeout, 0);
return;
} catch (ExecutionException ex) {
writer.continueMeasure();

View File

@@ -1149,9 +1149,11 @@ public class AVM2Code implements Cloneable {
posCache = new ArrayList<>();
long a = 0;
for (int i = 0; i < code.size(); i++) {
posCache.add(a);
a += code.get(i).getBytesLength();
AVM2Instruction ins = code.get(i);
posCache.add(ins.offset);
a = ins.offset + ins.getBytesLength();
}
posCache.add(a);
cacheActual = true;
}
@@ -1830,6 +1832,9 @@ public class AVM2Code implements Cloneable {
if (targetAddress > endOffset) {
return (int) (offset - targetAddress + endOffset);
}
if (targetAddress < 0) {
return (int) (offset - targetAddress);
}
return offset;
}
@@ -2228,7 +2233,7 @@ public class AVM2Code implements Cloneable {
}
while (ip < code.size()) {
if (!refs.containsKey(ip)) {
refs.put(ip, new ArrayList<Integer>());
refs.put(ip, new ArrayList<>());
}
refs.get(ip).add(lastIp);
lastIp = ip;
@@ -2276,7 +2281,7 @@ public class AVM2Code implements Cloneable {
public HashMap<Integer, List<Integer>> visitCode(MethodBody body) throws InterruptedException {
HashMap<Integer, List<Integer>> refs = new HashMap<>();
for (int i = 0; i < code.size(); i++) {
refs.put(i, new ArrayList<Integer>());
refs.put(i, new ArrayList<>());
}
visitCode(0, 0, refs);
int pos = 0;

View File

@@ -316,7 +316,7 @@ public final class MethodBody implements Cloneable {
//writer.endMethod();
} else if (convertException instanceof TimeoutException) {
// exception was logged in convert method
Helper.appendTimeoutComment(writer, timeout);
Helper.appendTimeoutCommentAs3(writer, timeout, getCode().code.size());
} else {
// exception was logged in convert method
Helper.appendErrorComment(writer, convertException);

View File

@@ -775,7 +775,7 @@ public abstract class Action implements GraphSourceItem {
@Override
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;
List<GraphTargetItem> tree = actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, version, staticOperation, path);
List<GraphTargetItem> tree = actionsToTree(new HashMap<>(), new HashMap<>(), new HashMap<>(), actions, version, staticOperation, path);
Graph.graphToString(tree, new NulWriter(), new LocalData());
return tree;
}
@@ -802,7 +802,7 @@ public abstract class Action implements GraphSourceItem {
if (convertException == null) {
Graph.graphToString(tree, writer, new LocalData());
} else if (convertException instanceof TimeoutException) {
Helper.appendTimeoutComment(writer, timeout);
Helper.appendTimeoutCommentAs2(writer, timeout, actions.size());
} else {
Helper.appendErrorComment(writer, convertException);
}

View File

@@ -19,6 +19,8 @@ decompilationError.timeout.description = Not decompiled due to timeout
decompilationError.obfuscated = Code may be obfuscated
decompilationError.errorType = Error type
decompilationError.error.description = Not decompiled due to error
decompilationError.actionCount = Action count:
decompilationError.instructionCount = Instruction count:
decompilation.skipped = Decompilation skipped
decompilation.unsupported = Unsupported by decompiler

View File

@@ -19,6 +19,8 @@ decompilationError.timeout.description = Id\u0151t\u00fall\u00e9p\u00e9s miatt n
decompilationError.obfuscated = K\u00f3d tal\u00e1n obfuszk\u00e1lva van
decompilationError.errorType = Hiba t\u00edpus
decompilationError.error.description = Hiba miatt nem lett visszaford\u00edtva
decompilationError.actionCount = Action-\u00f6k sz\u00e1ma:
decompilationError.instructionCount = Utas\u00edt\u00e1sok sz\u00e1ma:
decompilation.skipped = Visszaford\u00edt\u00e1s mell\u0151zve
decompilation.unsupported = Visszaford\u00edt\u00e1s nem t\u00e1mogatott

View File

@@ -1048,10 +1048,28 @@ public class Helper {
return "// " + AppResources.translate("decompilation.skipped");
}
public static void appendTimeoutComment(GraphTextWriter writer, int timeout) {
public static void appendTimeoutCommentAs2(GraphTextWriter writer, int timeout, int actionCount) {
writer.appendNoHilight("/*").newLine();
writer.appendNoHilight(" * ").appendNoHilight(AppResources.translate("decompilationError")).newLine();
writer.appendNoHilight(" * ").appendNoHilight(MessageFormat.format(AppResources.translate("decompilationError.timeout"), Helper.formatTimeToText(timeout))).newLine();
if (actionCount > 0) {
writer.appendNoHilight(" * ").appendNoHilight(AppResources.translate("decompilationError.instructionCount") + " " + actionCount).newLine();
}
writer.appendNoHilight(" */").newLine();
writer.appendNoHilight("throw new Error(\"").
appendNoHilight(AppResources.translate("decompilationError.timeout.description")).
appendNoHilight("\");").newLine();
}
public static void appendTimeoutCommentAs3(GraphTextWriter writer, int timeout, int instructionCount) {
writer.appendNoHilight("/*").newLine();
writer.appendNoHilight(" * ").appendNoHilight(AppResources.translate("decompilationError")).newLine();
writer.appendNoHilight(" * ").appendNoHilight(MessageFormat.format(AppResources.translate("decompilationError.timeout"), Helper.formatTimeToText(timeout))).newLine();
if (instructionCount > 0) {
writer.appendNoHilight(" * ").appendNoHilight(AppResources.translate("decompilationError.actionCount") + " " + instructionCount).newLine();
}
writer.appendNoHilight(" */").newLine();
writer.appendNoHilight("throw new flash.errors.IllegalOperationError(\"").
appendNoHilight(AppResources.translate("decompilationError.timeout.description")).