diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 2b816e015..01416c5df 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1297,6 +1297,16 @@ public class AVM2Code implements Cloneable { return ret; } + public AVM2Instruction adr2ins(long address) throws ConvertException { + int pos = adr2pos(address, false); + if (pos == code.size()) { + // end + return null; + } + + return code.get(pos); + } + public int adr2pos(long address) throws ConvertException { return adr2pos(address, false); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegistersOld.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegistersOld.java index ed8747779..173b93b09 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegistersOld.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegistersOld.java @@ -146,7 +146,6 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld { originalBody.exceptions = body.exceptions; originalBody.setCode(body.getCode()); - } private int getFirstRegisterSetter(Reference assignment, int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, Set ignoredRegisters, Set ignoredGets) throws InterruptedException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index 7f2177a88..667714a6a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -383,6 +383,10 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { return offset + 4 /*getBytesLength()*/ + operands[0]; } + public void setTargetOffset(int offset) { + operands[0] = offset; + } + @Override public List getBranches(GraphSource code) { List ret = new ArrayList<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 1a9e633eb..2250d8e53 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -1793,22 +1793,27 @@ public class Graph { hasExpr = true; } } - } + first = true; pos = 0; //This is tied to AS3 switch implementation which has nextparts switched from index 1. TODO: Make more universal GraphPart defaultPart = hasExpr ? part.nextParts.get(1 + defaultBranch) : part.nextParts.get(0); - for (GraphPart p : part.nextParts) { - if (p != defaultPart) { + for (int i = 1; i < part.nextParts.size(); i++) { + if (hasExpr && i == 1 + defaultBranch) { + continue; + } + + if (part.nextParts.get(i) != defaultPart) { if (caseExpressions.containsKey(pos)) { caseValues.add(caseExpressions.get(pos)); } else { caseValues.add(new IntegerValueItem(null, localData.lineStartInstruction, pos)); } - pos++; } + + pos++; } first = true;