Search in sources :

Example 11 with InvokeInstruction

use of net.runelite.asm.attributes.code.instruction.types.InvokeInstruction in project runelite by runelite.

the class RenameUniqueTest method checkCode.

private void checkCode(Code code) {
    if (code == null)
        return;
    for (Instruction i : code.getInstructions().getInstructions()) {
        if (!(i instanceof InvokeInstruction))
            continue;
        InvokeInstruction ii = (InvokeInstruction) i;
        Assert.assertTrue(ii.getMethod().getName().length() > Deob.OBFUSCATED_NAME_MAX_LEN || ii.getMethod().getClazz().getName().length() > Deob.OBFUSCATED_NAME_MAX_LEN);
    }
}
Also used : InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) Instruction(net.runelite.asm.attributes.code.Instruction)

Example 12 with InvokeInstruction

use of net.runelite.asm.attributes.code.instruction.types.InvokeInstruction in project runelite by runelite.

the class PacketWriteDeobfuscator method isEnd.

private boolean isEnd(InstructionContext ctx) {
    // conditions where packet write ends:
    // any invoke that isn't to the packet buffer
    // any variable assignment
    // any field assignment
    // any conditional jump
    // any return
    Instruction i = ctx.getInstruction();
    if (i instanceof InvokeInstruction) {
        InvokeInstruction ii = (InvokeInstruction) i;
        Method method = ii.getMethod();
        if (!method.getClazz().equals(rw.getSecretBuffer().getPoolClass()) && !method.getClazz().equals(rw.getBuffer().getPoolClass())) {
            return true;
        }
    }
    if (i instanceof LVTInstruction) {
        LVTInstruction lvt = (LVTInstruction) i;
        if (lvt.store()) {
            return true;
        }
    }
    if (i instanceof SetFieldInstruction) {
        return true;
    }
    if (i instanceof If || i instanceof If0) {
        return true;
    }
    if (i instanceof ReturnInstruction) {
        return true;
    }
    return false;
}
Also used : InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) ReturnInstruction(net.runelite.asm.attributes.code.instruction.types.ReturnInstruction) SetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction) If0(net.runelite.asm.attributes.code.instructions.If0) Method(net.runelite.asm.pool.Method) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) ReturnInstruction(net.runelite.asm.attributes.code.instruction.types.ReturnInstruction) SetFieldInstruction(net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction) Instruction(net.runelite.asm.attributes.code.Instruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) If(net.runelite.asm.attributes.code.instructions.If)

Example 13 with InvokeInstruction

use of net.runelite.asm.attributes.code.instruction.types.InvokeInstruction in project runelite by runelite.

the class ExprArgOrder method canRemove.

private boolean canRemove(MethodContext mctx, Instructions ins, Instruction i) {
    Set<InstructionContext> ctxs = new HashSet<>(mctx.getInstructonContexts(i));
    if (!alwaysPoppedBySameInstruction(ctxs, i) || !alwaysPopsFromSameInstructions(ctxs, i)) {
        return false;
    }
    if (i instanceof InvokeInstruction) {
        // func1() + func2() vs func2() + func1() is not the same thing
        return false;
    }
    int idx = ins.getInstructions().indexOf(i);
    if (idx == -1) {
        return false;
    }
    for (InstructionContext ictx : ctxs) {
        for (StackContext sctx : ictx.getPops()) {
            Instruction pushed = sctx.getPushed().getInstruction();
            int idx2 = ins.getInstructions().indexOf(pushed);
            if (idx2 == -1) {
                return false;
            }
            assert idx > idx2;
            // instructions, we can't move them
            for (int j = idx2; j <= idx; ++j) {
                Instruction i2 = ins.getInstructions().get(j);
                if (i2 instanceof LVTInstruction) {
                    if (((LVTInstruction) i2).store()) {
                        return false;
                    }
                }
                if (i2 instanceof IInc) {
                    return false;
                }
            }
            if (!canRemove(mctx, ins, pushed)) {
                return false;
            }
        }
    }
    return true;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) StackContext(net.runelite.asm.execution.StackContext) IInc(net.runelite.asm.attributes.code.instructions.IInc) PushConstantInstruction(net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) Instruction(net.runelite.asm.attributes.code.Instruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) HashSet(java.util.HashSet)

Example 14 with InvokeInstruction

use of net.runelite.asm.attributes.code.instruction.types.InvokeInstruction in project runelite by runelite.

the class UnusedParameters method visit.

private void visit(InstructionContext ictx) {
    Instruction i = ictx.getInstruction();
    if (!(i instanceof InvokeInstruction)) {
        return;
    }
    invokes.put(i, ictx);
}
Also used : InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) Instruction(net.runelite.asm.attributes.code.Instruction)

Example 15 with InvokeInstruction

use of net.runelite.asm.attributes.code.instruction.types.InvokeInstruction in project runelite by runelite.

the class MixinInjector method setOwnersToTargetClass.

private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method, Map<net.runelite.asm.pool.Field, Field> shadowFields, Map<net.runelite.asm.pool.Method, CopiedMethod> copiedMethods) throws InjectionException {
    ListIterator<Instruction> iterator = method.getCode().getInstructions().getInstructions().listIterator();
    while (iterator.hasNext()) {
        Instruction i = iterator.next();
        if (i instanceof InvokeInstruction) {
            InvokeInstruction ii = (InvokeInstruction) i;
            CopiedMethod copiedMethod = copiedMethods.get(ii.getMethod());
            if (copiedMethod != null) {
                ii.setMethod(copiedMethod.obMethod.getPoolMethod());
                // Pass through garbage value if the method has one
                if (copiedMethod.hasGarbageValue) {
                    int garbageIndex = copiedMethod.obMethod.isStatic() ? copiedMethod.obMethod.getDescriptor().size() - 1 : copiedMethod.obMethod.getDescriptor().size();
                    iterator.previous();
                    iterator.add(new ILoad(method.getCode().getInstructions(), garbageIndex));
                    iterator.next();
                }
            } else if (ii.getMethod().getClazz().getName().equals(mixinCf.getName())) {
                ii.setMethod(new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class(cf.getName()), ii.getMethod().getName(), ii.getMethod().getType()));
            }
        } else if (i instanceof FieldInstruction) {
            FieldInstruction fi = (FieldInstruction) i;
            Field shadowed = shadowFields.get(fi.getField());
            if (shadowed != null) {
                fi.setField(shadowed.getPoolField());
            } else if (fi.getField().getClazz().getName().equals(mixinCf.getName())) {
                fi.setField(new net.runelite.asm.pool.Field(new net.runelite.asm.pool.Class(cf.getName()), fi.getField().getName(), fi.getField().getType()));
            }
        } else if (i instanceof PushConstantInstruction) {
            PushConstantInstruction pi = (PushConstantInstruction) i;
            if (mixinCf.getPoolClass().equals(pi.getConstant())) {
                pi.setConstant(cf.getPoolClass());
            }
        }
        verify(mixinCf, i);
    }
}
Also used : PushConstantInstruction(net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction) ILoad(net.runelite.asm.attributes.code.instructions.ILoad) Method(net.runelite.asm.Method) FieldInstruction(net.runelite.asm.attributes.code.instruction.types.FieldInstruction) PushConstantInstruction(net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) ReturnInstruction(net.runelite.asm.attributes.code.instruction.types.ReturnInstruction) Instruction(net.runelite.asm.attributes.code.Instruction) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) GetField(net.runelite.asm.attributes.code.instructions.GetField) Field(net.runelite.asm.Field) PutField(net.runelite.asm.attributes.code.instructions.PutField) FieldInstruction(net.runelite.asm.attributes.code.instruction.types.FieldInstruction)

Aggregations

InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)15 Instruction (net.runelite.asm.attributes.code.Instruction)10 LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)8 ArrayList (java.util.ArrayList)5 Method (net.runelite.asm.Method)5 InstructionContext (net.runelite.asm.execution.InstructionContext)5 Signature (net.runelite.asm.signature.Signature)5 Code (net.runelite.asm.attributes.Code)4 List (java.util.List)3 ClassFile (net.runelite.asm.ClassFile)3 Field (net.runelite.asm.Field)3 Type (net.runelite.asm.Type)3 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)3 InvokeStatic (net.runelite.asm.attributes.code.instructions.InvokeStatic)3 StackContext (net.runelite.asm.execution.StackContext)3 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClassGroup (net.runelite.asm.ClassGroup)2 InstructionType (net.runelite.asm.attributes.code.InstructionType)2