use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class Code method getMaxLocalsFromSig.
private int getMaxLocalsFromSig() {
Method m = getMethod();
int num = m.isStatic() ? 0 : 1;
Signature sig = m.getDescriptor();
for (int i = 0; i < sig.size(); ++i) num += sig.getTypeOfArg(i).getSize();
return num;
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class PacketWriteDeobfuscator method translate.
private Instruction translate(Instruction i) {
if (!(i instanceof InvokeVirtual)) {
return i;
}
InvokeVirtual ii = (InvokeVirtual) i;
Method invoked = ii.getMethod();
assert invoked.getType().size() == 1;
Type argumentType = invoked.getType().getTypeOfArg(0);
Method invokeMethod;
if (argumentType.equals(Type.BYTE)) {
invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteByte", new Signature("(B)V"));
} else if (argumentType.equals(Type.SHORT)) {
invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteShort", new Signature("(S)V"));
} else if (argumentType.equals(Type.INT)) {
invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteInt", new Signature("(I)V"));
} else if (argumentType.equals(Type.LONG)) {
invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteLong", new Signature("(J)V"));
} else if (argumentType.equals(Type.STRING)) {
invokeMethod = new Method(ii.getMethod().getClazz(), "runeliteWriteString", new Signature("(Ljava/lang/String;)V"));
} else {
throw new IllegalStateException("Unknown type " + argumentType);
}
return new InvokeVirtual(i.getInstructions(), invokeMethod);
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class OpcodesTransformer method transform.
@Override
public void transform(ClassGroup group) {
ClassFile runeliteOpcodes = group.findClass(RUNELITE_OPCODES);
if (runeliteOpcodes == null) {
runeliteOpcodes = new ClassFile(group);
runeliteOpcodes.setName(RUNELITE_OPCODES);
runeliteOpcodes.setSuperName(Type.OBJECT.getInternalName());
runeliteOpcodes.setAccess(Opcodes.ACC_PUBLIC);
group.addClass(runeliteOpcodes);
} else {
runeliteOpcodes.getFields().clear();
}
Method clinit = runeliteOpcodes.findMethod("<clinit>");
if (clinit == null) {
clinit = new Method(runeliteOpcodes, "<clinit>", new Signature("()V"));
clinit.setStatic();
Code code = new Code(clinit);
code.setMaxStack(1);
clinit.setCode(code);
runeliteOpcodes.addMethod(clinit);
Instructions instructions = code.getInstructions();
instructions.addInstruction(new VReturn(instructions));
}
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class ClientErrorTransformer method transform.
private void transform(Method m) {
if (!m.isStatic() || m.getDescriptor().size() != 2 || !m.getDescriptor().getTypeOfArg(0).equals(Type.STRING) || !m.getDescriptor().getTypeOfArg(1).equals(Type.THROWABLE))
return;
Code code = m.getCode();
Instructions ins = code.getInstructions();
/*
Makes it so the old code in this method is logically dead,
letting the mapper map it but making it so it's never executed.
*/
// load throwable
Instruction aload0 = new ALoad(ins, 1);
IfNull ifNull = new IfNull(ins, InstructionType.IFNULL);
ifNull.setTo(ins.createLabelFor(ins.getInstructions().get(0)));
// load throwable
Instruction aload1 = new ALoad(ins, 1);
InvokeVirtual printStackTrace = new InvokeVirtual(ins, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("java/lang/Throwable"), "printStackTrace", new Signature("()V")));
Instruction ret = new VReturn(ins);
ins.addInstruction(0, aload0);
ins.addInstruction(1, ifNull);
ins.addInstruction(2, aload1);
ins.addInstruction(3, printStackTrace);
ins.addInstruction(4, ret);
done = true;
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class MaxMemoryTransformer method insert.
private void insert(Instructions ins, int idx) {
Class randomClass = new net.runelite.asm.pool.Class("java/util/Random");
ins.getInstructions().remove(idx);
// pop runtime
ins.getInstructions().add(idx++, new Pop(ins));
ins.getInstructions().add(idx++, new New(ins, randomClass));
ins.getInstructions().add(idx++, new Dup(ins));
// new Random
ins.getInstructions().add(idx++, new InvokeSpecial(ins, new net.runelite.asm.pool.Method(randomClass, "<init>", new Signature("()V"))));
ins.getInstructions().add(idx++, new LDC(ins, 31457280));
// nextInt(31457280)
ins.getInstructions().add(idx++, new InvokeVirtual(ins, new net.runelite.asm.pool.Method(randomClass, "nextInt", new Signature("(I)I"))));
ins.getInstructions().add(idx++, new LDC(ins, 230686720));
// 230686720 + nextInt(31457280)
ins.getInstructions().add(idx++, new IAdd(ins));
ins.getInstructions().add(idx++, new I2L(ins));
}
Aggregations