Need to compare this to master.
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.HashSet;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import net.runelite.asm.ClassFile;
|
import net.runelite.asm.ClassFile;
|
||||||
import net.runelite.asm.ClassGroup;
|
import net.runelite.asm.ClassGroup;
|
||||||
import net.runelite.deob.Deob;
|
import net.runelite.deob.Deob;
|
||||||
@@ -136,9 +137,19 @@ public class Execution
|
|||||||
|
|
||||||
if (frames.isEmpty())
|
if (frames.isEmpty())
|
||||||
{
|
{
|
||||||
|
assert frame.getMethod() == frame.getMethodCtx().getMethod();
|
||||||
|
|
||||||
accept(frame.getMethodCtx());
|
accept(frame.getMethodCtx());
|
||||||
frames.addAll(framesOther);
|
|
||||||
framesOther.clear();
|
if (framesOther.isEmpty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
Frame begin = framesOther.remove(0);
|
||||||
|
frames.add(begin);
|
||||||
|
|
||||||
|
List<Frame> toMove = framesOther.stream().filter(f -> f.getMethod() == begin.getMethod()).collect(Collectors.toList());
|
||||||
|
frames.addAll(toMove);
|
||||||
|
framesOther.removeAll(toMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class Frame
|
|||||||
|
|
||||||
stack = new Stack(code.getMaxStack());
|
stack = new Stack(code.getMaxStack());
|
||||||
variables = new Variables(code.getMaxLocals());
|
variables = new Variables(code.getMaxLocals());
|
||||||
ctx = new MethodContext(execution);
|
ctx = new MethodContext(execution, method);
|
||||||
nonStatic = method;
|
nonStatic = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class Frame
|
|||||||
stack = new Stack(code.getMaxStack());
|
stack = new Stack(code.getMaxStack());
|
||||||
variables = new Variables(code.getMaxLocals());
|
variables = new Variables(code.getMaxLocals());
|
||||||
|
|
||||||
ctx = new MethodContext(execution);
|
ctx = new MethodContext(execution, method);
|
||||||
nonStatic = method;
|
nonStatic = method;
|
||||||
|
|
||||||
cur = i;
|
cur = i;
|
||||||
|
|||||||
@@ -1,18 +1,31 @@
|
|||||||
package net.runelite.asm.execution;
|
package net.runelite.asm.execution;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import net.runelite.asm.Method;
|
||||||
import net.runelite.asm.attributes.code.Instruction;
|
import net.runelite.asm.attributes.code.Instruction;
|
||||||
import org.apache.commons.collections4.map.MultiValueMap;
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
public class MethodContext
|
public class MethodContext
|
||||||
{
|
{
|
||||||
private Execution execution;
|
private Execution execution;
|
||||||
|
private Method method;
|
||||||
private MultiValueMap<InstructionContext, Instruction> visited = new MultiValueMap<>();
|
private MultiValueMap<InstructionContext, Instruction> visited = new MultiValueMap<>();
|
||||||
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>(); // XXX this should move to method ctx probably
|
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>(); // XXX this should move to method ctx probably
|
||||||
|
|
||||||
public MethodContext(Execution execution)
|
public MethodContext(Execution execution, Method method)
|
||||||
{
|
{
|
||||||
this.execution = execution;
|
this.execution = execution;
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Execution getExecution()
|
||||||
|
{
|
||||||
|
return execution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Method getMethod()
|
||||||
|
{
|
||||||
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasJumped(InstructionContext from, Instruction to)
|
protected boolean hasJumped(InstructionContext from, Instruction to)
|
||||||
|
|||||||
@@ -472,8 +472,6 @@ public class MultiplicationDeobfuscatorTest
|
|||||||
{
|
{
|
||||||
ClassGroup group = ClassGroupFactory.generateGroup();
|
ClassGroup group = ClassGroupFactory.generateGroup();
|
||||||
Code code = group.findClass("test").findMethod("func").getCode();
|
Code code = group.findClass("test").findMethod("func").getCode();
|
||||||
Code code2 = group.findClass("test").findMethod("func2").getCode();
|
|
||||||
Field field = group.findClass("test").findField("field");
|
|
||||||
Instructions ins = code.getInstructions();
|
Instructions ins = code.getInstructions();
|
||||||
|
|
||||||
code.setMaxStack(2);
|
code.setMaxStack(2);
|
||||||
@@ -607,4 +605,51 @@ public class MultiplicationDeobfuscatorTest
|
|||||||
Assert.assertEquals(1L, constant2.getConstantAsLong());
|
Assert.assertEquals(1L, constant2.getConstantAsLong());
|
||||||
Assert.assertEquals(1L, constant3.getConstantAsLong());
|
Assert.assertEquals(1L, constant3.getConstantAsLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test10()
|
||||||
|
{
|
||||||
|
ClassGroup group = ClassGroupFactory.generateGroup();
|
||||||
|
Code code = group.findClass("test").findMethod("func").getCode();
|
||||||
|
Instructions ins = code.getInstructions();
|
||||||
|
|
||||||
|
code.setMaxStack(5);
|
||||||
|
|
||||||
|
// vars[0] = 3
|
||||||
|
Instruction[] prepareVariables = {
|
||||||
|
new IConst_3(ins),
|
||||||
|
new IStore_0(ins)
|
||||||
|
};
|
||||||
|
|
||||||
|
for (Instruction i : prepareVariables)
|
||||||
|
ins.addInstruction(i);
|
||||||
|
|
||||||
|
LDC_W constant1 = new LDC_W(ins, -1729723287),
|
||||||
|
constant2 = new LDC_W(ins, -143176743);
|
||||||
|
|
||||||
|
Instruction body[] = {
|
||||||
|
new ILoad(ins, 0),
|
||||||
|
constant1,
|
||||||
|
new IMul(ins),
|
||||||
|
constant2,
|
||||||
|
new IMul(ins),
|
||||||
|
new VReturn(ins)
|
||||||
|
};
|
||||||
|
|
||||||
|
for (Instruction i : body)
|
||||||
|
ins.addInstruction(i);
|
||||||
|
|
||||||
|
// check execution runs ok
|
||||||
|
Execution e = new Execution(group);
|
||||||
|
e.populateInitialMethods();
|
||||||
|
e.run();
|
||||||
|
|
||||||
|
assert constant1.getConstantAsInt() * constant2.getConstantAsInt() == 1;
|
||||||
|
|
||||||
|
Deobfuscator d = new MultiplicationDeobfuscator();
|
||||||
|
d.run(group);
|
||||||
|
|
||||||
|
Assert.assertEquals(1, constant1.getConstantAsInt());
|
||||||
|
Assert.assertEquals(1, constant2.getConstantAsInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user