mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 19:50:44 +00:00
AS3: Lookupswitch offsets deobfuscation fix
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user