use of net.runelite.asm.attributes.code.instructions.SiPush in project runelite by runelite.
the class MultiplyOneDeobfuscatorTest method test.
@Test
public void test() {
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);
IMul mul = new IMul(ins);
Instruction[] body = { new SiPush(ins, (short) 256), new ILoad(ins, 0), new IfEq(ins, label), label, one, label2, mul, 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);
Assert.assertTrue(mul.getInstructions() == null);
}
use of net.runelite.asm.attributes.code.instructions.SiPush 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);
}
Aggregations