mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 17:50:45 +00:00
Improved deobfuscation
This commit is contained in:
@@ -1483,6 +1483,30 @@ public class AVM2Code implements Serializable {
|
||||
code.add(pos, instruction);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<Object> prepareBranchLocalData(List<Object> localData) {
|
||||
List<Object> ret = new ArrayList<>();
|
||||
ret.add(localData.get(0)); //isStatic
|
||||
ret.add(localData.get(1)); //classIndex
|
||||
ret.add(new HashMap<Integer, GraphTargetItem>((HashMap<Integer, GraphTargetItem>) localData.get(2)));
|
||||
ret.add((Stack<GraphTargetItem>) ((Stack<GraphTargetItem>) localData.get(3)).clone());
|
||||
ret.add(localData.get(4)); //constants
|
||||
ret.add(localData.get(5)); //method_info
|
||||
ret.add(localData.get(6)); //body
|
||||
ret.add(localData.get(7)); //abc
|
||||
ret.add(localData.get(8)); //localgetNames
|
||||
ret.add(localData.get(9));
|
||||
ret.add(localData.get(10));
|
||||
ret.add(localData.get(11));
|
||||
ret.add(localData.get(12));
|
||||
ret.add(localData.get(13));
|
||||
ret.add(localData.get(14));
|
||||
ret.add(localData.get(15));
|
||||
ret.add(localData.get(16));
|
||||
ret.add(localData.get(17));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int removeTraps(ConstantPool constants, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) {
|
||||
removeDeadCode(constants, body);
|
||||
List<Object> localData = new ArrayList<>();
|
||||
@@ -2212,6 +2236,14 @@ public class AVM2Code implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
int curVisited;
|
||||
if (!visited.containsKey(ip)) {
|
||||
curVisited = 1;
|
||||
} else {
|
||||
curVisited = visited.get(ip) + 1;
|
||||
}
|
||||
visited.put(ip, curVisited);
|
||||
|
||||
List<Integer> r = refs.get(ip);
|
||||
/*if (r != null) {
|
||||
if (r.size() > 1) {
|
||||
@@ -2245,6 +2277,16 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
if (debugMode) {
|
||||
System.out.println((useVisited ? "useV " : "") + (secondPass ? "secondPass " : "") + "Visit " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString()));
|
||||
HashMap<Integer, GraphTargetItem> registers = (HashMap<Integer, GraphTargetItem>) localData.get(2);
|
||||
System.out.print("Registers:");
|
||||
for (int reg : registers.keySet()) {
|
||||
try {
|
||||
System.out.print(" r" + reg + ": " + registers.get(reg).getResult());
|
||||
} catch (NullPointerException npe) {
|
||||
System.out.print(" r" + reg + ": " + "null");
|
||||
}
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
if (secondPass) {
|
||||
/*if ((ins instanceof AVM2Instruction) && (((AVM2Instruction) ins).definition instanceof PopIns)) {
|
||||
@@ -2349,12 +2391,26 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
dec.jumpUsed = true;
|
||||
dec.skipUsed = true;
|
||||
|
||||
if (curVisited > 1) {
|
||||
for (int b : branches) {
|
||||
int visc = 0;
|
||||
if (visited.containsKey(b)) {
|
||||
visc = visited.get(b);
|
||||
}
|
||||
if (visc == 0) {//<curVisited){
|
||||
ip = b;
|
||||
continue iploop;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int b : branches) {
|
||||
Stack<GraphTargetItem> brStack = (Stack<GraphTargetItem>) stack.clone();
|
||||
if (b >= 0) {
|
||||
ret += removeTraps(refs, secondPass, useVisited || (!ins.isJump()), localData, brStack, output, code, b, visited, visitedStates, decisions, path);
|
||||
if (b >= 0) { //useVisited || (!ins.isJump())
|
||||
ret += removeTraps(refs, secondPass, false, prepareBranchLocalData(localData), brStack, output, code, b, visited, visitedStates, decisions, path);
|
||||
} else {
|
||||
if (debugMode) {
|
||||
System.out.println("Negative branch:" + b);
|
||||
@@ -2375,8 +2431,30 @@ public class AVM2Code implements Serializable {
|
||||
public static int removeTraps(ConstantPool constants, MethodBody body, List<Object> localData, AVM2GraphSource code, int addr, String path, HashMap<Integer, List<Integer>> refs) {
|
||||
HashMap<GraphSourceItem, AVM2Code.Decision> decisions = new HashMap<>();
|
||||
removeTraps(refs, false, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path);
|
||||
localData.set(2, new HashMap<Integer, GraphTargetItem>());
|
||||
int cnt = removeTraps(refs, true, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path);
|
||||
int cnt = 0;
|
||||
for (GraphSourceItem src : decisions.keySet()) {
|
||||
Decision dec = decisions.get(src);
|
||||
if (dec != null) {
|
||||
if ((src instanceof AVM2Instruction) && (((AVM2Instruction) src).definition instanceof LookupSwitchIns)) {
|
||||
if (dec.casesUsed.size() == 1) {
|
||||
for (int c : dec.casesUsed) {
|
||||
src.setFixBranch(c);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (dec.jumpUsed && !dec.skipUsed) {
|
||||
src.setFixBranch(0);
|
||||
cnt++;
|
||||
}
|
||||
if (!dec.jumpUsed && dec.skipUsed) {
|
||||
src.setFixBranch(1);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//int cnt = removeTraps(refs, true, false, localData, new Stack<GraphTargetItem>(), new ArrayList<GraphTargetItem>(), code, code.adr2pos(addr), new HashMap<Integer, Integer>(), new HashMap<Integer, HashMap<Integer, GraphTargetItem>>(), decisions, path);
|
||||
code.getCode().removeIgnored(constants, body);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
+9
-5
@@ -57,14 +57,18 @@ public class DecLocalIIns extends InstructionDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new DecLocalAVM2Item(ins, regIndex));
|
||||
if (localRegs.containsKey(regIndex)) {
|
||||
localRegs.put(regIndex, new NotCompileTimeAVM2Item(ins, new SubtractAVM2Item(ins, localRegs.get(regIndex), new IntegerValueAVM2Item(ins, Long.valueOf(1)))));
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regId = ins.operands[0];
|
||||
output.add(new DecLocalAVM2Item(ins, regId));
|
||||
if (localRegs.containsKey(regId)) {
|
||||
localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1))));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1))));
|
||||
}
|
||||
if (!regAssignCount.containsKey(regId)) {
|
||||
regAssignCount.put(regId, 0);
|
||||
}
|
||||
regAssignCount.put(regId, regAssignCount.get(regId) + 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -57,13 +57,17 @@ public class DecLocalIns extends InstructionDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new DecLocalAVM2Item(ins, regIndex));
|
||||
if (localRegs.containsKey(regIndex)) {
|
||||
localRegs.put(regIndex, new NotCompileTimeAVM2Item(ins, new SubtractAVM2Item(ins, localRegs.get(regIndex), new IntegerValueAVM2Item(ins, Long.valueOf(1)))));
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regId = ins.operands[0];
|
||||
output.add(new DecLocalAVM2Item(ins, regId));
|
||||
if (localRegs.containsKey(regId)) {
|
||||
localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1))));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1))));
|
||||
}
|
||||
if (!regAssignCount.containsKey(regId)) {
|
||||
regAssignCount.put(regId, 0);
|
||||
}
|
||||
regAssignCount.put(regId, regAssignCount.get(regId) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-7
@@ -37,17 +37,24 @@ public abstract class GetLocalTypeIns extends InstructionDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regId = getRegisterId(ins);
|
||||
GraphTargetItem computedValue = localRegs.get(regId);
|
||||
if (!isRegisterCompileTime(regId, ip, refs, code)) {
|
||||
int assignCount = 0;
|
||||
if (regAssignCount.containsKey(regId)) {
|
||||
assignCount = regAssignCount.get(regId);
|
||||
}
|
||||
if (assignCount > 5) { //Do not allow change register more than 5 - for deobfuscation
|
||||
computedValue = new NotCompileTimeAVM2Item(ins, computedValue);
|
||||
}
|
||||
if (computedValue == null) {
|
||||
if (!localRegNames.containsKey(regId)) {
|
||||
computedValue = new UndefinedAVM2Item(null); //In some obfuscated code there seems to be reading of undefined registers
|
||||
}
|
||||
}
|
||||
/*if (!isRegisterCompileTime(regId, ip, refs, code)) {
|
||||
computedValue = new NotCompileTimeAVM2Item(ins, computedValue);
|
||||
}
|
||||
if (computedValue == null) {
|
||||
if (!localRegNames.containsKey(regId)) {
|
||||
computedValue = new UndefinedAVM2Item(null); //In some obfuscated code there seems to be reading of undefined registers
|
||||
}
|
||||
}*/
|
||||
stack.push(new LocalRegAVM2Item(ins, regId, computedValue));
|
||||
}
|
||||
|
||||
|
||||
+9
-5
@@ -37,13 +37,17 @@ public class IncLocalIIns extends InstructionDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new IncLocalAVM2Item(ins, regIndex));
|
||||
if (localRegs.containsKey(regIndex)) {
|
||||
localRegs.put(regIndex, new NotCompileTimeAVM2Item(ins, new AddAVM2Item(ins, localRegs.get(regIndex), new IntegerValueAVM2Item(ins, Long.valueOf(1)))));
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regId = ins.operands[0];
|
||||
output.add(new IncLocalAVM2Item(ins, regId));
|
||||
if (localRegs.containsKey(regId)) {
|
||||
localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1))));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1))));
|
||||
}
|
||||
if (!regAssignCount.containsKey(regId)) {
|
||||
regAssignCount.put(regId, 0);
|
||||
}
|
||||
regAssignCount.put(regId, regAssignCount.get(regId) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -37,13 +37,17 @@ public class IncLocalIns extends InstructionDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new IncLocalAVM2Item(ins, regIndex));
|
||||
if (localRegs.containsKey(regIndex)) {
|
||||
localRegs.put(regIndex, new NotCompileTimeAVM2Item(ins, new AddAVM2Item(ins, localRegs.get(regIndex), new IntegerValueAVM2Item(ins, Long.valueOf(1)))));
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regId = ins.operands[0];
|
||||
output.add(new IncLocalAVM2Item(ins, regId));
|
||||
if (localRegs.containsKey(regId)) {
|
||||
localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1))));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1))));
|
||||
}
|
||||
if (!regAssignCount.containsKey(regId)) {
|
||||
regAssignCount.put(regId, 0);
|
||||
}
|
||||
regAssignCount.put(regId, regAssignCount.get(regId) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-10
@@ -47,15 +47,20 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> regAssignCount, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
|
||||
int regId = getRegisterId(ins);
|
||||
GraphTargetItem value = (GraphTargetItem) stack.pop();
|
||||
if (localRegs.containsKey(regId)) {
|
||||
localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value));
|
||||
} else {
|
||||
localRegs.put(regId, value);
|
||||
/*if (localRegs.containsKey(regId)) {
|
||||
localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value));
|
||||
} else {
|
||||
localRegs.put(regId, value);
|
||||
}*/
|
||||
localRegs.put(regId, value);
|
||||
if (!regAssignCount.containsKey(regId)) {
|
||||
regAssignCount.put(regId, 0);
|
||||
}
|
||||
localRegsAssignmentIps.put(regId, ip);
|
||||
regAssignCount.put(regId, regAssignCount.get(regId) + 1);
|
||||
//localRegsAssignmentIps.put(regId, ip);
|
||||
if (value instanceof NewActivationAVM2Item) {
|
||||
return;
|
||||
}
|
||||
@@ -63,7 +68,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
return;
|
||||
}
|
||||
if (value.getNotCoerced() instanceof IncrementAVM2Item) {
|
||||
GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).object.getNotCoerced().getThroughDuplicate();
|
||||
GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate();
|
||||
if (inside instanceof LocalRegAVM2Item) {
|
||||
if (((LocalRegAVM2Item) inside).regIndex == regId) {
|
||||
if (stack.size() > 0) {
|
||||
@@ -71,7 +76,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
if (top == inside) {
|
||||
stack.pop();
|
||||
stack.push(new PostIncrementAVM2Item(ins, inside));
|
||||
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).object == inside)) {
|
||||
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) {
|
||||
stack.pop();
|
||||
stack.push(new PreIncrementAVM2Item(ins, inside));
|
||||
} else {
|
||||
@@ -86,7 +91,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
}
|
||||
|
||||
if (value.getNotCoerced() instanceof DecrementAVM2Item) {
|
||||
GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).object.getNotCoerced().getThroughDuplicate();
|
||||
GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate();
|
||||
if (inside instanceof LocalRegAVM2Item) {
|
||||
if (((LocalRegAVM2Item) inside).regIndex == regId) {
|
||||
if (stack.size() > 0) {
|
||||
@@ -94,7 +99,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
|
||||
if (top == inside) {
|
||||
stack.pop();
|
||||
stack.push(new PostDecrementAVM2Item(ins, inside));
|
||||
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).object == inside)) {
|
||||
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) {
|
||||
stack.pop();
|
||||
stack.push(new PreDecrementAVM2Item(ins, inside));
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -52,7 +52,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
|
||||
FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
GraphTargetItem obj = (GraphTargetItem) stack.pop();
|
||||
if (value.getThroughDuplicate().getThroughRegister().getThroughDuplicate() instanceof IncrementAVM2Item) {
|
||||
GraphTargetItem inside = ((IncrementAVM2Item) value.getThroughDuplicate().getThroughRegister().getThroughDuplicate()).object.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
GraphTargetItem inside = ((IncrementAVM2Item) value.getThroughDuplicate().getThroughRegister().getThroughDuplicate()).value.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
if (inside instanceof GetPropertyAVM2Item) {
|
||||
GetPropertyAVM2Item insideProp = ((GetPropertyAVM2Item) inside);
|
||||
if (insideProp.propertyName.compareSame(multiname)) {
|
||||
@@ -68,7 +68,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
|
||||
if (top == insideProp) {
|
||||
stack.pop();
|
||||
stack.push(new PostIncrementAVM2Item(ins, insideProp));
|
||||
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).object == inside)) {
|
||||
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) {
|
||||
stack.pop();
|
||||
stack.push(new PreIncrementAVM2Item(ins, insideProp));
|
||||
} else {
|
||||
@@ -84,7 +84,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
|
||||
}
|
||||
|
||||
if (value.getThroughDuplicate().getThroughRegister().getThroughDuplicate() instanceof DecrementAVM2Item) {
|
||||
GraphTargetItem inside = ((DecrementAVM2Item) value.getThroughDuplicate().getThroughRegister().getThroughDuplicate()).object.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
GraphTargetItem inside = ((DecrementAVM2Item) value.getThroughDuplicate().getThroughRegister().getThroughDuplicate()).value.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
if (inside instanceof GetPropertyAVM2Item) {
|
||||
GetPropertyAVM2Item insideProp = ((GetPropertyAVM2Item) inside);
|
||||
if (insideProp.propertyName.compareSame(multiname)) {
|
||||
@@ -100,7 +100,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
|
||||
if (top == insideProp) {
|
||||
stack.pop();
|
||||
stack.push(new PostDecrementAVM2Item(ins, insideProp));
|
||||
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).object == inside)) {
|
||||
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) {
|
||||
stack.pop();
|
||||
stack.push(new PreDecrementAVM2Item(ins, insideProp));
|
||||
} else {
|
||||
|
||||
@@ -105,7 +105,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
}
|
||||
|
||||
if (value.getNotCoerced().getThroughDuplicate() instanceof IncrementAVM2Item) {
|
||||
GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).object.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
if (inside instanceof GetSlotAVM2Item) {
|
||||
GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside;
|
||||
if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister())
|
||||
@@ -115,7 +115,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
if (top == inside) {
|
||||
stack.pop();
|
||||
stack.push(new PostIncrementAVM2Item(ins, inside));
|
||||
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).object == inside)) {
|
||||
} else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) {
|
||||
stack.pop();
|
||||
stack.push(new PreIncrementAVM2Item(ins, inside));
|
||||
} else {
|
||||
@@ -130,7 +130,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
}
|
||||
|
||||
if (value.getNotCoerced().getThroughDuplicate() instanceof DecrementAVM2Item) {
|
||||
GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).object.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getThroughRegister().getNotCoerced().getThroughDuplicate();
|
||||
if (inside instanceof GetSlotAVM2Item) {
|
||||
GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside;
|
||||
if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister())
|
||||
@@ -140,7 +140,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
|
||||
if (top == inside) {
|
||||
stack.pop();
|
||||
stack.push(new PostDecrementAVM2Item(ins, inside));
|
||||
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).object == inside)) {
|
||||
} else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) {
|
||||
stack.pop();
|
||||
stack.push(new PreDecrementAVM2Item(ins, inside));
|
||||
} else {
|
||||
|
||||
@@ -18,21 +18,30 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class DecrementAVM2Item extends AVM2Item {
|
||||
|
||||
public GraphTargetItem object;
|
||||
|
||||
public DecrementAVM2Item(AVM2Instruction instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_ADDITIVE);
|
||||
this.object = object;
|
||||
this.value = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("-1");
|
||||
return value.toString(constants, localRegNames, fullyQualifiedNames) + hilight("-1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime() {
|
||||
return value.isCompileTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return EcmaScript.toNumber(value.getResult()) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,21 +18,30 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class IncrementAVM2Item extends AVM2Item {
|
||||
|
||||
public GraphTargetItem object;
|
||||
|
||||
public IncrementAVM2Item(AVM2Instruction instruction, GraphTargetItem object) {
|
||||
super(instruction, PRECEDENCE_ADDITIVE);
|
||||
this.object = object;
|
||||
this.value = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("+1");
|
||||
return value.toString(constants, localRegNames, fullyQualifiedNames) + hilight("+1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime() {
|
||||
return value.isCompileTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return EcmaScript.toNumber(value.getResult()) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,21 @@ public class LocalRegAVM2Item extends AVM2Item {
|
||||
|
||||
public int regIndex;
|
||||
public GraphTargetItem computedValue;
|
||||
private Object computedResult;
|
||||
private boolean isCT = false;
|
||||
|
||||
public LocalRegAVM2Item(AVM2Instruction instruction, int regIndex, GraphTargetItem computedValue) {
|
||||
super(instruction, PRECEDENCE_PRIMARY);
|
||||
this.regIndex = regIndex;
|
||||
if (computedValue == null) {
|
||||
//computedValue = new UndefinedAVM2Item(instruction);
|
||||
computedResult = null;
|
||||
} else {
|
||||
if (computedValue.isCompileTime()) {
|
||||
computedResult = computedValue.getResult();
|
||||
isCT = true;
|
||||
} else {
|
||||
computedResult = null;
|
||||
}
|
||||
}
|
||||
this.computedValue = computedValue;
|
||||
}
|
||||
@@ -57,18 +66,15 @@ public class LocalRegAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
if (computedValue == null) {
|
||||
if (computedResult == null) {
|
||||
return new Undefined();
|
||||
}
|
||||
return computedValue.getResult();
|
||||
return computedResult;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime() {
|
||||
if (computedValue == null) {
|
||||
return false;
|
||||
}
|
||||
return computedValue.isCompileTime();
|
||||
return isCT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class NotCompileTimeAVM2Item extends AVM2Item {
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getThroughNotCompilable() {
|
||||
if(object==null){
|
||||
if (object == null) {
|
||||
return object;
|
||||
}
|
||||
return object.getThroughNotCompilable();
|
||||
|
||||
@@ -125,8 +125,8 @@ public class MethodBody implements Cloneable, Serializable {
|
||||
if ((Boolean) Configuration.getConfig("autoDeobfuscate", true)) {
|
||||
try {
|
||||
deobfuscated.removeTraps(constants, b, abc, scriptIndex, classIndex, isStatic, path);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Error during remove traps", ex);
|
||||
} catch (Exception | StackOverflowError ex) {
|
||||
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Error during remove traps in " + path, ex);
|
||||
}
|
||||
}
|
||||
//deobfuscated.restoreControlFlow(constants, b);
|
||||
|
||||
Reference in New Issue
Block a user