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 6b1bacd0b..81324e6c7 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 @@ -1872,30 +1872,68 @@ public class AVM2Code implements Cloneable { { for (int i = 0; i < pos; i++) { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (code.get(i).definition instanceof LookupSwitchIns) { + long target = code.get(i).offset + code.get(i).operands[0]; + if (target > instruction.offset) { + code.get(i).operands[0] += byteCount; + } + if (target == instruction.offset && !preRefsToThis) { + code.get(i).operands[0] += byteCount; + } + for (int k = 2; k < code.get(i).operands.length; k++) { + target = code.get(i).offset + code.get(i).operands[k]; if (target > instruction.offset) { - code.get(i).operands[j] += byteCount; + code.get(i).operands[k] += byteCount; } if (target == instruction.offset && !preRefsToThis) { - code.get(i).operands[j] += byteCount; + code.get(i).operands[k] += byteCount; } + } + } else { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target > instruction.offset) { + code.get(i).operands[j] += byteCount; + } + if (target == instruction.offset && !preRefsToThis) { + code.get(i).operands[j] += byteCount; + } + } } } } } { for (int i = pos; i < code.size(); i++) { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (code.get(i).definition instanceof LookupSwitchIns) { + long target = code.get(i).offset + code.get(i).operands[0]; + if (target < instruction.offset) { + code.get(i).operands[0] -= byteCount; + } + if (target == instruction.offset && postRefsToThis) { + code.get(i).operands[0] -= byteCount; + } + for (int k = 2; k < code.get(i).operands.length; k++) { + target = code.get(i).offset + code.get(i).operands[k]; if (target < instruction.offset) { - code.get(i).operands[j] -= byteCount; + code.get(i).operands[k] -= byteCount; } if (target == instruction.offset && postRefsToThis) { - code.get(i).operands[j] -= byteCount; + code.get(i).operands[k] -= byteCount; + } + } + } else { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target < instruction.offset) { + code.get(i).operands[j] -= byteCount; + } + if (target == instruction.offset && postRefsToThis) { + code.get(i).operands[j] -= byteCount; + } } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index c29e13c1c..eff50d8c5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -528,7 +528,7 @@ public class AVM2Graph extends Graph { GraphTargetItem nt = sstack.peek(); if (!(nt instanceof IntegerValueAVM2Item)) { - throw new RuntimeException("Invalid integer value in Switch"); + throw new RuntimeException("Invalid integer value in Switch:" + nt); } IntegerValueAVM2Item iv = (IntegerValueAVM2Item) nt; caseValuesMap.put((int) (long) iv.value, tar); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java index ce7c35d1a..8c75a60ad 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java @@ -49,7 +49,7 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item { @Override public Object getResult() { - return (Double) (double) (long) value; + return value;//(Double) (double) (long) value; } @Override