mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-28 20:44:55 +00:00
Putting in old AVM2 deobfuscator
Issue #1033 and other: Fix inclocal/declocal deobfuscation
This commit is contained in:
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorGetSet;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorJumps;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorRegisters;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorRegistersOld;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorSimple;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2ExecutionException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
@@ -349,8 +350,7 @@ public class AVM2Code implements Cloneable {
|
||||
|
||||
public static final int DAT_DEBUG_TYPE = OPT_U8 + 0x05;
|
||||
|
||||
public static final int DAT_REGISTER_INDEX = OPT_U8 + 0x06;
|
||||
|
||||
//public static final int DAT_REGISTER_INDEX = OPT_U8 + 0x06;
|
||||
public static final int DAT_LINENUM = OPT_U30 + 0x07;
|
||||
|
||||
public static final int DAT_LOCAL_REG_INDEX = OPT_U30 + 0x08;
|
||||
@@ -2335,7 +2335,7 @@ public class AVM2Code implements Cloneable {
|
||||
new AVM2DeobfuscatorSimple().avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body);
|
||||
}
|
||||
try (Statistics s = new Statistics("AVM2DeobfuscatorRegisters")) {
|
||||
new AVM2DeobfuscatorRegisters().avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body);
|
||||
new AVM2DeobfuscatorRegistersOld().avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body);
|
||||
}
|
||||
try (Statistics s = new Statistics("AVM2DeobfuscatorJumps")) {
|
||||
new AVM2DeobfuscatorJumps().avm2CodeRemoveTraps(path, classIndex, isStatic, scriptIndex, abc, trait, methodInfo, body);
|
||||
@@ -2399,7 +2399,7 @@ public class AVM2Code implements Cloneable {
|
||||
} else {
|
||||
for (int i = 0; i < ins.definition.operands.length; i++) {
|
||||
int op = ins.definition.operands[i];
|
||||
if (op == DAT_REGISTER_INDEX/* || op == DAT_LOCAL_REG_INDEX ???*/) {
|
||||
if (op == DAT_LOCAL_REG_INDEX) {
|
||||
handleRegister(stats, ins.operands[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2ExecutionException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.debug.DebugIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns;
|
||||
@@ -74,7 +76,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
} else {
|
||||
for (int p = 0; p < ins.definition.operands.length; p++) {
|
||||
int op = ins.definition.operands[p];
|
||||
if (op == AVM2Code.DAT_REGISTER_INDEX || op == AVM2Code.DAT_LOCAL_REG_INDEX) {
|
||||
if (op == AVM2Code.DAT_LOCAL_REG_INDEX) {
|
||||
int regId = ins.operands[p];
|
||||
regs.add(regId);
|
||||
}
|
||||
@@ -233,7 +235,6 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
Logger.getLogger(AVM2DeobfuscatorRegisters.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
//if (!(def instanceof KillIns))
|
||||
if (def instanceof SetLocalTypeIns) {
|
||||
int regId = ((SetLocalTypeIns) def).getRegisterId(ins);
|
||||
if (!ignored.contains(regId)) {
|
||||
@@ -246,10 +247,10 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
assignment.setVal(ins);
|
||||
return regId;
|
||||
}
|
||||
} else {
|
||||
} else if (!(def instanceof KillIns) && !(def instanceof DebugIns)) {
|
||||
for (int p = 0; p < ins.definition.operands.length; p++) {
|
||||
int op = ins.definition.operands[p];
|
||||
if (op == AVM2Code.DAT_REGISTER_INDEX/* || op == AVM2Code.DAT_LOCAL_REG_INDEX ???*/) {
|
||||
if (op == AVM2Code.DAT_LOCAL_REG_INDEX) {
|
||||
int regId = ins.operands[p];
|
||||
if (!ignored.contains(regId)) {
|
||||
assignment.setVal(ins);
|
||||
|
||||
@@ -24,8 +24,10 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.debug.DebugIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocalTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.KillIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns;
|
||||
@@ -72,7 +74,7 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
} else {
|
||||
for (int p = 0; p < ins.definition.operands.length; p++) {
|
||||
int op = ins.definition.operands[p];
|
||||
if (op == AVM2Code.DAT_REGISTER_INDEX || op == AVM2Code.DAT_LOCAL_REG_INDEX) {
|
||||
if (op == AVM2Code.DAT_LOCAL_REG_INDEX) {
|
||||
int regId = ins.operands[p];
|
||||
regs.add(regId);
|
||||
}
|
||||
@@ -217,7 +219,7 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
|
||||
AVM2Instruction ins = code.code.get(idx);
|
||||
InstructionDefinition def = ins.definition;
|
||||
//System.err.println("" + idx + ": " + ins + " stack:" + stack.size());
|
||||
System.err.println("" + idx + ": " + ins + " stack:" + stack.size());
|
||||
|
||||
// do not throw EmptyStackException, much faster
|
||||
int requiredStackSize = ins.getStackPopCount(localData);
|
||||
@@ -226,8 +228,6 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
}
|
||||
|
||||
ins.translate(localData, stack, output, Graph.SOP_USE_STATIC, "");
|
||||
|
||||
//if (!(def instanceof KillIns))
|
||||
if (def instanceof SetLocalTypeIns) {
|
||||
int regId = ((SetLocalTypeIns) def).getRegisterId(ins);
|
||||
if (!ignored.contains(regId)) {
|
||||
@@ -240,10 +240,11 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
|
||||
assignment.setVal(ins);
|
||||
return regId;
|
||||
}
|
||||
} else {
|
||||
} else if (!(def instanceof KillIns) && !(def instanceof DebugIns)) {
|
||||
//can be inclocal, declocal, hasnext...
|
||||
for (int p = 0; p < ins.definition.operands.length; p++) {
|
||||
int op = ins.definition.operands[p];
|
||||
if (op == AVM2Code.DAT_REGISTER_INDEX/* || op == AVM2Code.DAT_LOCAL_REG_INDEX ???*/) {
|
||||
if (op == AVM2Code.DAT_LOCAL_REG_INDEX) {
|
||||
int regId = ins.operands[p];
|
||||
if (!ignored.contains(regId)) {
|
||||
assignment.setVal(ins);
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
public class DebugIns extends InstructionDefinition {
|
||||
|
||||
public DebugIns() {
|
||||
super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_REGISTER_INDEX, AVM2Code.OPT_U30}, false);
|
||||
super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_LOCAL_REG_INDEX, AVM2Code.OPT_U30}, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
public class DecLocalPIns extends InstructionDefinition {
|
||||
|
||||
public DecLocalPIns() {
|
||||
super(0x9F, "declocal_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS, AVM2Code.DAT_REGISTER_INDEX}, false /*?*/);
|
||||
super(0x9F, "declocal_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS, AVM2Code.DAT_LOCAL_REG_INDEX}, false /*?*/);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
public class IncLocalPIns extends InstructionDefinition {
|
||||
|
||||
public IncLocalPIns() {
|
||||
super(0x9D, "inclocal_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS, AVM2Code.DAT_REGISTER_INDEX}, true /*?*/);
|
||||
super(0x9D, "inclocal_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS, AVM2Code.DAT_LOCAL_REG_INDEX}, true /*?*/);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user