mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-30 12:41:34 +00:00
Issue #942 AS3 timeout optimisation, improved register obfuscator
This commit is contained in:
@@ -2092,7 +2092,7 @@ public class AVM2Code implements Cloneable {
|
||||
* @param body Method body (used for try handling)
|
||||
*/
|
||||
public void insertInstruction(int pos, AVM2Instruction instruction, boolean mapOffsetsAfterIns, MethodBody body) {
|
||||
checkValidOffsets(body);
|
||||
//checkValidOffsets(body);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
@@ -2130,7 +2130,7 @@ public class AVM2Code implements Cloneable {
|
||||
}, body);
|
||||
code.add(pos, instruction);
|
||||
invalidateCache();
|
||||
checkValidOffsets(body);
|
||||
//checkValidOffsets(body);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -72,7 +72,6 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody abody) throws InterruptedException {
|
||||
|
||||
MethodBody body = abody.clone();
|
||||
System.err.println("A");
|
||||
removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
|
||||
|
||||
Map<Integer, GraphTargetItem> outFirstAssigned = new HashMap<>();
|
||||
@@ -84,27 +83,21 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
|
||||
List<AVM2Instruction> ignored = new ArrayList<>();
|
||||
Map<Integer, GraphTargetItem> registers = new HashMap<>();
|
||||
System.err.println("B");
|
||||
getFirstRegistersUsage(outAssignCount1, outFirstAssigned, outFirstAssignments, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body, ignored, registers);
|
||||
ignored.addAll(outFirstAssignments.values());
|
||||
registers.putAll(outFirstAssigned);
|
||||
|
||||
System.err.println("C");
|
||||
replaceSingleUseRegisters(registers, ignored, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
|
||||
|
||||
System.err.println("C1");
|
||||
super.deobfuscate(path, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
|
||||
System.err.println("C2");
|
||||
removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
|
||||
|
||||
System.err.println("D");
|
||||
//second pass - ignore all first assignments
|
||||
registers.clear();
|
||||
ignored.clear();
|
||||
outFirstAssignments.clear();
|
||||
getFirstRegistersUsage(outAssignCount2, new HashMap<>(), outFirstAssignments, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body, ignored, registers);
|
||||
|
||||
System.err.println("E");
|
||||
for (int regId : outAssignCount1.keySet()) {
|
||||
int ac = outAssignCount2.containsKey(regId) ? outAssignCount2.get(regId) : 0;
|
||||
if (ac == 0) {
|
||||
@@ -114,19 +107,14 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
|
||||
|
||||
body = abody;
|
||||
replaceSingleUseRegisters(singleRegisters, null, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
|
||||
System.err.println("F");
|
||||
super.deobfuscate(path, classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
|
||||
System.err.println("G");
|
||||
removeUnreachableActions(body.getCode(), cpool, trait, minfo, body);
|
||||
System.err.println("H");
|
||||
|
||||
}
|
||||
|
||||
private void replaceSingleUseRegisters(Map<Integer, GraphTargetItem> singleRegisters, List<AVM2Instruction> setInss, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) {
|
||||
AVM2Code code = body.getCode();
|
||||
|
||||
for (int i = 0; i < code.code.size(); i++) {
|
||||
System.err.println("replacesingle: " + i + "/" + code.code.size());
|
||||
AVM2Instruction ins = code.code.get(i);
|
||||
if (((setInss == null) || setInss.contains(ins)) && (ins.definition instanceof SetLocalTypeIns)) {
|
||||
SetLocalTypeIns slt = (SetLocalTypeIns) ins.definition;
|
||||
|
||||
@@ -398,13 +398,9 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
|
||||
|
||||
public void deobfuscate(String path, int classIndex, boolean isStatic, int scriptIndex, ABC abc, AVM2ConstantPool cpool, Trait trait, MethodInfo minfo, MethodBody body) throws InterruptedException {
|
||||
AVM2Code code = body.getCode();
|
||||
System.err.println("1");
|
||||
code.fixJumps(body);
|
||||
System.err.println("2");
|
||||
removeUnreachableActions(code, cpool, trait, minfo, body);
|
||||
System.err.println("3");
|
||||
removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, cpool, trait, minfo, body);
|
||||
System.err.println("4");
|
||||
removeZeroJumps(code, body);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user