Search in sources :

Example 1 with Field

use of net.runelite.asm.pool.Field in project runelite by runelite.

the class CodeVisitor method visitFieldInsn.

@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
    FieldInstruction i = (FieldInstruction) createInstructionFromOpcode(opcode);
    Field field = new Field(new net.runelite.asm.pool.Class(owner), name, new Type(desc));
    i.setField(field);
}
Also used : Field(net.runelite.asm.pool.Field) InstructionType(net.runelite.asm.attributes.code.InstructionType) Type(net.runelite.asm.Type) FieldInstruction(net.runelite.asm.attributes.code.instruction.types.FieldInstruction)

Example 2 with Field

use of net.runelite.asm.pool.Field in project runelite by runelite.

the class DupDeobfuscatorTest method test2.

// 035   aload_0               // this
// 036   dup                   // this this
// 037   getfield              class153/field2097 I // this I
// 038   ldc                   830083863
// 039   imul                                      // this I
// 040   ldc                   830083863
// 041   iadd                                      // this I
// 042   dup_x1                                    // I this I
@Test
public void test2() {
    ClassGroup group = ClassGroupFactory.generateGroup();
    Code code = group.findClass("test").findMethod("func").getCode();
    Instructions ins = code.getInstructions();
    code.setMaxStack(3);
    Instruction[] body = { // this
    new AConstNull(ins), // this this
    new Dup(ins), new GetField(ins, new Field(new Class("test"), "field", Type.INT)), // this this I I
    new LDC(ins, 830083863), // this this I
    new IMul(ins), new LDC(ins, 830083863), new IAdd(ins), new Dup_X1(ins), new LDC(ins, 636900519), // pops dup
    new IMul(ins), new VReturn(ins) };
    for (Instruction i : body) {
        ins.addInstruction(i);
    }
    Execution e = new Execution(group);
    e.populateInitialMethods();
    e.run();
    Deobfuscator d = new DupDeobfuscator();
    d.run(group);
    // assert the dup wasn't duplicated
    long dupCount = ins.getInstructions().stream().filter(i -> i instanceof Dup).count();
    Assert.assertEquals(1, dupCount);
    // assert the dup_x1 was removed
    dupCount = ins.getInstructions().stream().filter(i -> i instanceof Dup_X1).count();
    Assert.assertEquals(0, dupCount);
}
Also used : Pop2(net.runelite.asm.attributes.code.instructions.Pop2) AConstNull(net.runelite.asm.attributes.code.instructions.AConstNull) GetField(net.runelite.asm.attributes.code.instructions.GetField) IMul(net.runelite.asm.attributes.code.instructions.IMul) Dup(net.runelite.asm.attributes.code.instructions.Dup) Code(net.runelite.asm.attributes.Code) Test(org.junit.Test) Type(net.runelite.asm.Type) Deobfuscator(net.runelite.deob.Deobfuscator) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) Class(net.runelite.asm.pool.Class) ClassGroupFactory(net.runelite.deob.ClassGroupFactory) ILoad(net.runelite.asm.attributes.code.instructions.ILoad) LDC(net.runelite.asm.attributes.code.instructions.LDC) IStore(net.runelite.asm.attributes.code.instructions.IStore) VReturn(net.runelite.asm.attributes.code.instructions.VReturn) Instructions(net.runelite.asm.attributes.code.Instructions) Field(net.runelite.asm.pool.Field) IAdd(net.runelite.asm.attributes.code.instructions.IAdd) Instruction(net.runelite.asm.attributes.code.Instruction) Assert(org.junit.Assert) Dup_X1(net.runelite.asm.attributes.code.instructions.Dup_X1) GetField(net.runelite.asm.attributes.code.instructions.GetField) Instructions(net.runelite.asm.attributes.code.Instructions) AConstNull(net.runelite.asm.attributes.code.instructions.AConstNull) LDC(net.runelite.asm.attributes.code.instructions.LDC) 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) GetField(net.runelite.asm.attributes.code.instructions.GetField) Field(net.runelite.asm.pool.Field) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) Dup_X1(net.runelite.asm.attributes.code.instructions.Dup_X1) IMul(net.runelite.asm.attributes.code.instructions.IMul) Class(net.runelite.asm.pool.Class) IAdd(net.runelite.asm.attributes.code.instructions.IAdd) Dup(net.runelite.asm.attributes.code.instructions.Dup) Test(org.junit.Test)

Aggregations

Type (net.runelite.asm.Type)2 Field (net.runelite.asm.pool.Field)2 ClassGroup (net.runelite.asm.ClassGroup)1 Code (net.runelite.asm.attributes.Code)1 Instruction (net.runelite.asm.attributes.code.Instruction)1 InstructionType (net.runelite.asm.attributes.code.InstructionType)1 Instructions (net.runelite.asm.attributes.code.Instructions)1 FieldInstruction (net.runelite.asm.attributes.code.instruction.types.FieldInstruction)1 AConstNull (net.runelite.asm.attributes.code.instructions.AConstNull)1 Dup (net.runelite.asm.attributes.code.instructions.Dup)1 Dup_X1 (net.runelite.asm.attributes.code.instructions.Dup_X1)1 GetField (net.runelite.asm.attributes.code.instructions.GetField)1 IAdd (net.runelite.asm.attributes.code.instructions.IAdd)1 ILoad (net.runelite.asm.attributes.code.instructions.ILoad)1 IMul (net.runelite.asm.attributes.code.instructions.IMul)1 IStore (net.runelite.asm.attributes.code.instructions.IStore)1 LDC (net.runelite.asm.attributes.code.instructions.LDC)1 Pop2 (net.runelite.asm.attributes.code.instructions.Pop2)1 VReturn (net.runelite.asm.attributes.code.instructions.VReturn)1 Execution (net.runelite.asm.execution.Execution)1