use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class MultiplyOneDeobfuscatorTest method testDir.
@Test
public void testDir() {
ClassGroup group = ClassGroupFactory.generateGroup();
Code code = group.findClass("test").findMethod("func").getCode();
Instructions ins = code.getInstructions();
code.setMaxStack(2);
// vars[0] = 3
Instruction[] prepareVariables = { new LDC(ins, 3), new IStore(ins, 0) };
for (Instruction i : prepareVariables) ins.addInstruction(i);
Label label = new Label(ins), label2 = new Label(ins);
LDC one = new LDC(ins, 1);
Instruction[] body = { new SiPush(ins, (short) 256), new ILoad(ins, 0), new IfEq(ins, label), new LDC(ins, 2), new Goto(ins, label2), label, one, label2, 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();
Deobfuscator d = new MultiplyOneDeobfuscator(false);
d.run(group);
Assert.assertTrue(one.getInstructions() != null);
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class PacketWriteDeobfuscator method run.
@Override
public void run(ClassGroup group) {
rw = new RWOpcodeFinder(group);
rw.find();
Execution e = new Execution(group);
e.addExecutionVisitor(this::visit);
e.populateInitialMethods();
e.run();
end();
opcodeReplacer.run(group, writes.values());
int count = 0;
int writesCount = 0;
for (PacketWrite write : writes.values()) {
if (write.writes.isEmpty()) {
continue;
}
insert(group, write);
++count;
writesCount += write.writes.size();
}
logger.info("Converted buffer write methods for {} opcodes ({} writes)", count, writesCount);
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class PacketFlushFinder method find.
private void find(Method method) {
Code code = method.getCode();
Set<Instruction> checked = new HashSet<>();
Execution e = new Execution(group);
e.addMethod(method);
e.noInvoke = true;
e.noExceptions = true;
e.addExecutionVisitor(ic -> {
Instruction i = ic.getInstruction();
if (checked.contains(i)) {
return;
}
checked.add(i);
if (i.getType() != INVOKEVIRTUAL) {
return;
}
InvokeVirtual iv = (InvokeVirtual) i;
// queueForWrite
if (!iv.getMethod().getType().equals(new Signature("([BII)V"))) {
return;
}
InstructionContext lengthCtx = ic.getPops().get(0).getPushed();
if (lengthCtx.getInstruction().getType() != GETFIELD) {
return;
}
queueForWrite.add(ic);
});
e.run();
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class MultiplicationDeobfuscator method runOnce.
private int runOnce() {
group.buildClassGraph();
count = 0;
Execution e = new Execution(group);
e.addMethodContextVisitor(m -> visit(m));
e.populateInitialMethods();
e.run();
return count;
}
use of net.runelite.asm.execution.Execution in project runelite by runelite.
the class MultiplyZeroDeobfuscator method run.
@Override
public void run(ClassGroup group) {
Execution e = new Execution(group);
e.addMethodContextVisitor(i -> visit(i));
e.populateInitialMethods();
e.run();
logger.info("Removed " + count + " 0 multiplications");
}
Aggregations