This commit is contained in:
Adam
2015-11-20 11:54:09 -05:00
parent 0da5258c17
commit 050fa333fa
4 changed files with 30 additions and 15 deletions

View File

@@ -10,7 +10,15 @@ public class Encryption
public void addPair(Pair pair) public void addPair(Pair pair)
{ {
fields.put(pair.field, pair); Pair existing = fields.get(pair.field);
if (existing != null)
{
fields.put(pair.field, new Pair(pair, existing));
}
else
{
fields.put(pair.field, pair);
}
} }
public Pair getField(Field field) public Pair getField(Field field)

View File

@@ -37,6 +37,7 @@ public class ModArith implements Deobfuscator
private MultiValueMap<Field, Number> constantGetters = new MultiValueMap<>(), private MultiValueMap<Field, Number> constantGetters = new MultiValueMap<>(),
constantSetters = new MultiValueMap<>(); constantSetters = new MultiValueMap<>();
private List<Pair> pairs = new ArrayList<>(); private List<Pair> pairs = new ArrayList<>();
private Encryption encryption = new Encryption();
private List<InstructionContext> getInsInExpr(InstructionContext ctx, Set<Instruction> set) private List<InstructionContext> getInsInExpr(InstructionContext ctx, Set<Instruction> set)
{ {
@@ -637,7 +638,7 @@ public class ModArith implements Deobfuscator
group.buildClassGraph(); group.buildClassGraph();
pairs.clear(); pairs.clear();
constantGetters.clear();; constantGetters.clear();
constantSetters.clear(); constantSetters.clear();
constants.clear(); constants.clear();
@@ -658,6 +659,7 @@ public class ModArith implements Deobfuscator
Encryption encr = new Encryption(); Encryption encr = new Encryption();
encr.addPair(pair); encr.addPair(pair);
encryption.addPair(pair); // sum total
insertGetterSetterMuls(encr); insertGetterSetterMuls(encr);
@@ -669,4 +671,8 @@ public class ModArith implements Deobfuscator
return i; return i;
} }
public Encryption getEncryption()
{
return encryption;
}
} }

View File

@@ -7,6 +7,19 @@ public class Pair
public Field field; public Field field;
public Number getter, setter; public Number getter, setter;
public Pair()
{
}
public Pair(Pair one, Pair two)
{
assert one.getType() == two.getType();
assert one.field == two.field;
getter = DMath.multiply(one.getter, two.getter);
setter = DMath.multiply(one.setter, two.setter);
}
public Class getType() public Class getType()
{ {
assert getter.getClass() == setter.getClass(); assert getter.getClass() == setter.getClass();

View File

@@ -18,7 +18,6 @@ import net.runelite.deob.attributes.code.instruction.types.FieldInstruction;
import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction; import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction;
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction; import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
import net.runelite.deob.attributes.code.instructions.InvokeStatic; import net.runelite.deob.attributes.code.instructions.InvokeStatic;
import net.runelite.deob.deobfuscators.arithmetic.Encryption;
import net.runelite.deob.deobfuscators.rename.graph.EdgeType; import net.runelite.deob.deobfuscators.rename.graph.EdgeType;
import net.runelite.deob.deobfuscators.rename.graph.Graph; import net.runelite.deob.deobfuscators.rename.graph.Graph;
import org.apache.commons.collections4.map.MultiValueMap; import org.apache.commons.collections4.map.MultiValueMap;
@@ -31,7 +30,6 @@ public class Execution
public Set<Method> methods = new HashSet<>(); // all methods public Set<Method> methods = new HashSet<>(); // all methods
public Set<Instruction> executed = new HashSet<>(); // executed instructions public Set<Instruction> executed = new HashSet<>(); // executed instructions
private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>(); private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>();
private Encryption encryption;
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>(); public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>();
private Map<Method, MethodContext> methodContexts = new HashMap<>(); private Map<Method, MethodContext> methodContexts = new HashMap<>();
private boolean buildGraph; // if true the frame graph is built and execution hasJumped also compares previous instructions private boolean buildGraph; // if true the frame graph is built and execution hasJumped also compares previous instructions
@@ -42,16 +40,6 @@ public class Execution
this.group = group; this.group = group;
} }
public Encryption getEncryption()
{
return encryption;
}
public void setEncryption(Encryption encryption)
{
this.encryption = encryption;
}
public List<Method> getInitialMethods() public List<Method> getInitialMethods()
{ {
List<Method> methods = new ArrayList<>(); List<Method> methods = new ArrayList<>();