Search in sources :

Example 16 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class MultiplyOneDeobfuscatorTest method test2.

// iconst_1
// iconst_m1
// iload                 5
// if_icmpeq             LABEL0x56d1
// iload                 5
// iconst_1
// if_icmpne             LABEL0x56e8
// goto                  LABEL0x56d1
// LABEL0x56d1:
// getstatic             class139/field2130 I
// ldc_w                 -1440517609
// imul
// goto                  LABEL0x5708
// LABEL0x56e8:
// getstatic             class139/field2130 I
// ldc_w                 -1440517609
// imul
// getstatic             client/field377 I
// iadd
// iconst_2
// idiv
// LABEL0x5708:
// imul
// putstatic             client/field377 I
// 
// client.field377 = 1 * (-1 != var5 && var5 != 1?(class139.field2130 + client.field377) / 2:class139.field2130);
@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), new LDC(ins, 2), new IStore(ins, 1) };
    for (Instruction i : prepareVariables) ins.addInstruction(i);
    Label label = new Label(ins), label2 = new Label(ins), label3 = new Label(ins);
    LDC one = new LDC(ins, 1);
    IMul mul = new IMul(ins);
    Instruction[] body = { one, new LDC(ins, -1), new ILoad(ins, 0), new IfICmpEq(ins, label), new Goto(ins, label2), label, new ILoad(ins, 1), new LDC(ins, -1440517609), new IDiv(ins), new Goto(ins, label3), label2, new ILoad(ins, 1), new LDC(ins, -1440517609), new IDiv(ins), label3, 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);
}
Also used : IfICmpEq(net.runelite.asm.attributes.code.instructions.IfICmpEq) IStore(net.runelite.asm.attributes.code.instructions.IStore) Goto(net.runelite.asm.attributes.code.instructions.Goto) ILoad(net.runelite.asm.attributes.code.instructions.ILoad) Label(net.runelite.asm.attributes.code.Label) Instructions(net.runelite.asm.attributes.code.Instructions) LDC(net.runelite.asm.attributes.code.instructions.LDC) IDiv(net.runelite.asm.attributes.code.instructions.IDiv) Instruction(net.runelite.asm.attributes.code.Instruction) Code(net.runelite.asm.attributes.Code) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Deobfuscator(net.runelite.deob.Deobfuscator) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) IMul(net.runelite.asm.attributes.code.instructions.IMul) Test(org.junit.Test)

Example 17 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class InvokeVirtual method lookupMethod.

private net.runelite.asm.Method lookupMethod() {
    ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
    ClassFile otherClass = group.findClass(method.getClazz().getName());
    if (otherClass == null) {
        // not our class
        return null;
    }
    net.runelite.asm.Method m = otherClass.findMethodDeep(method.getName(), method.getType());
    return m;
}
Also used : ClassFile(net.runelite.asm.ClassFile) ClassGroup(net.runelite.asm.ClassGroup)

Example 18 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class InvokeSpecial method lookup.

@Override
public void lookup() {
    myMethod = null;
    ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
    ClassFile otherClass = group.findClass(method.getClazz().getName());
    if (otherClass == null) {
        // not our class
        return;
    }
    net.runelite.asm.Method other = otherClass.findMethod(method.getName(), method.getType());
    if (other == null) {
        return;
    }
    myMethod = other;
}
Also used : ClassFile(net.runelite.asm.ClassFile) ClassGroup(net.runelite.asm.ClassGroup)

Example 19 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class InvokeStatic method lookupMethod.

private net.runelite.asm.Method lookupMethod() {
    ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
    ClassFile otherClass = group.findClass(method.getClazz().getName());
    if (otherClass == null) {
        // not our class
        return null;
    }
    net.runelite.asm.Method other = otherClass.findMethodDeepStatic(method.getName(), method.getType());
    if (other == null) {
        // when regenerating the pool after renaming the method this can be null.
        return null;
    }
    return other;
}
Also used : ClassFile(net.runelite.asm.ClassFile) ClassGroup(net.runelite.asm.ClassGroup)

Example 20 with ClassGroup

use of net.runelite.asm.ClassGroup in project runelite by runelite.

the class UpdateMappingsTest method testRun.

@Test
public void testRun() throws IOException {
    File client = new File(properties.getRsClient());
    ClassGroup group1 = JarUtil.loadJar(client);
    ClassGroup group2 = JarUtil.loadJar(client);
    // Remove existing annotations
    unannotate(group2);
    // Map the client against itself
    map(group1, group2);
    check(group1, group2);
}
Also used : ClassGroup(net.runelite.asm.ClassGroup) File(java.io.File) ClassFile(net.runelite.asm.ClassFile) Test(org.junit.Test)

Aggregations

ClassGroup (net.runelite.asm.ClassGroup)66 Test (org.junit.Test)41 Code (net.runelite.asm.attributes.Code)29 ClassFile (net.runelite.asm.ClassFile)28 Instruction (net.runelite.asm.attributes.code.Instruction)28 Instructions (net.runelite.asm.attributes.code.Instructions)28 LDC (net.runelite.asm.attributes.code.instructions.LDC)28 VReturn (net.runelite.asm.attributes.code.instructions.VReturn)26 IStore (net.runelite.asm.attributes.code.instructions.IStore)23 Deobfuscator (net.runelite.deob.Deobfuscator)22 ILoad (net.runelite.asm.attributes.code.instructions.ILoad)21 Execution (net.runelite.asm.execution.Execution)21 IMul (net.runelite.asm.attributes.code.instructions.IMul)18 Method (net.runelite.asm.Method)12 IAdd (net.runelite.asm.attributes.code.instructions.IAdd)11 Pop (net.runelite.asm.attributes.code.instructions.Pop)11 File (java.io.File)9 Label (net.runelite.asm.attributes.code.Label)9 Type (net.runelite.asm.Type)8 Signature (net.runelite.asm.signature.Signature)8