use of net.runelite.asm.ClassGroup in project runelite by runelite.
the class ClassFileVisitorTest method test.
@Test
public void test() throws Exception {
ClassGroup group = JarUtil.loadJar(new File(properties.getVanillaClient()));
JarUtil.saveJar(group, folder.newFile());
}
use of net.runelite.asm.ClassGroup in project runelite by runelite.
the class ParallelMappingExecutorTest method testTableswitch.
@Test
public void testTableswitch() throws IOException {
InputStream in = ParallelMappingExecutorTest.class.getResourceAsStream("tests/TableSwitch.class");
Assert.assertNotNull(in);
ClassGroup group = new ClassGroup();
ClassFile cf = ClassUtil.loadClass(in);
group.addClass(cf);
in = ParallelMappingExecutorTest.class.getResourceAsStream("tests/TableSwitch.class");
Assert.assertNotNull(in);
ClassGroup group2 = new ClassGroup();
ClassFile cf2 = ClassUtil.loadClass(in);
group2.addClass(cf2);
Method m1 = cf.findMethod("method");
Method m2 = cf2.findMethod("method");
ParallelExecutorMapping map = MappingExecutorUtil.map(m1, m2);
Assert.assertEquals(cf2.findField("field2"), map.get(cf.findField("field2")));
}
use of net.runelite.asm.ClassGroup in project runelite by runelite.
the class CastNullTest method testRun.
@Test
public void testRun() {
ClassGroup group = ClassGroupFactory.generateGroup();
Code code = group.findClass("test").findMethod("func").getCode();
Instructions ins = code.getInstructions();
code.setMaxStack(3);
CheckCast checkCast = new CheckCast(ins);
checkCast.setType(new Type("test"));
Instruction[] instructions = { new LDC(ins, 2), new AConstNull(ins), checkCast, new LDC(ins, 2), new IAdd(ins), new Return(ins, InstructionType.IRETURN) };
for (Instruction i : instructions) {
ins.addInstruction(i);
}
Assert.assertEquals(6, ins.getInstructions().size());
CastNull lvt = new CastNull();
lvt.run(group);
Assert.assertEquals(5, ins.getInstructions().size());
Optional<Instruction> o = ins.getInstructions().stream().filter(i -> i instanceof CheckCast).findAny();
Assert.assertFalse(o.isPresent());
}
use of net.runelite.asm.ClassGroup in project runelite by runelite.
the class SimpleModArithTest method test.
@Test
public void test() throws IOException {
InputStream in = this.getClass().getClassLoader().getResourceAsStream("net/runelite/deob/deobfuscators/arithmetic/TestClass.class");
Assert.assertNotNull(in);
ClassGroup group = new ClassGroup();
ClassFile cf = ClassUtil.loadClass(in);
group.addClass(cf);
ModArith d1 = new ModArith();
d1.run(group);
d1.runOnce();
Deobfuscator d2 = new MultiplicationDeobfuscator();
d2.run(group);
this.checkConstants(cf);
}
use of net.runelite.asm.ClassGroup in project runelite by runelite.
the class ExprArgOrderTest method test2.
@Test
public void test2() {
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);
}
Instruction[] body = { // 2
new ILoad(ins, 0), new LDC(ins, 3), new IAdd(ins), new Pop(ins), // 6
new LDC(ins, 3), new ILoad(ins, 0), new IAdd(ins), new SiPush(ins, (short) 512), new IAdd(ins), new Pop(ins), new VReturn(ins) };
for (Instruction i : body) {
ins.addInstruction(i);
}
ExprArgOrder exprArgOrder = new ExprArgOrder();
exprArgOrder.run(group);
List<Instruction> instructions = ins.getInstructions();
// ensure this stays the same
assertEquals(ILOAD, instructions.get(2).getType());
assertEquals(LDC, instructions.get(3).getType());
assertEquals(IADD, instructions.get(4).getType());
//
assertEquals(ILOAD, instructions.get(6).getType());
assertEquals(SIPUSH, instructions.get(7).getType());
assertEquals(IADD, instructions.get(8).getType());
assertEquals(LDC, instructions.get(9).getType());
assertEquals(IADD, instructions.get(10).getType());
}
Aggregations