use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class ReflectionTransformer method transformSetInt.
// invokevirtual java/lang/reflect/Field/setInt(Ljava/lang/Object;I)V
private void transformSetInt(Instructions instructions, Instruction i) {
if (!(i instanceof InvokeVirtual)) {
return;
}
InvokeVirtual iv = (InvokeVirtual) i;
if (iv.getMethod().getClazz().getName().equals("java/lang/reflect/Field") && iv.getMethod().getName().equals("setInt")) {
InvokeStatic is = new InvokeStatic(instructions, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("net/runelite/rs/Reflection"), "setInt", new Signature("(Ljava/lang/reflect/Field;Ljava/lang/Object;I)V")));
instructions.replace(iv, is);
logger.info("Transformed Field.setInt call");
}
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class ReflectionTransformer method transformGetParameterTypes.
// invokevirtual java/lang/reflect/Method/getParameterTypes()[Ljava/lang/Class;
// to
// invokestatic net/runelite/rs/Reflection/getParameterTypes(Ljava/lang/reflect/Method;)[Ljava/lang/Class;
private void transformGetParameterTypes(Instructions instructions, Instruction i) {
if (!(i instanceof InvokeVirtual)) {
return;
}
InvokeVirtual iv = (InvokeVirtual) i;
if (iv.getMethod().getClazz().getName().equals("java/lang/reflect/Method") && iv.getMethod().getName().equals("getParameterTypes")) {
InvokeStatic is = new InvokeStatic(instructions, new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class("net/runelite/rs/Reflection"), "getParameterTypes", new Signature("(Ljava/lang/reflect/Method;)[Ljava/lang/Class;")));
instructions.replace(iv, is);
logger.info("Transformed Method.getParameterTypes call");
}
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class RuneliteBufferTransformer method injectPacketFinish.
private void injectPacketFinish(ClassGroup group) {
PacketFlushFinder pff = new PacketFlushFinder(group);
pff.find();
for (InstructionContext queueForWriteCtx : pff.getQueueForWrite()) {
Instruction before = // socket
queueForWriteCtx.getPops().get(3).getPushed().getInstruction();
GetStatic getBuffer;
try {
getBuffer = (GetStatic) // buffer
queueForWriteCtx.getPops().get(2).getPushed().getPops().get(// getstatic
0).getPushed().getInstruction();
} catch (ClassCastException ex) {
continue;
}
Instructions instructions = before.getInstructions();
int idx = instructions.getInstructions().indexOf(before);
assert idx != -1;
instructions.addInstruction(idx++, getBuffer.clone());
net.runelite.asm.pool.Method method = new net.runelite.asm.pool.Method(new net.runelite.asm.pool.Class(getBuffer.getField().getType().getInternalName()), RUNELITE_FINISH_PACKET, new Signature("()V"));
instructions.addInstruction(idx++, new InvokeVirtual(instructions, method));
}
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class PacketFlushFinder method find.
private void find(Method method) {
Code code = method.getCode();
Set<Instruction> checked = new HashSet<>();
Execution e = new Execution(group);
e.addMethod(method);
e.noInvoke = true;
e.noExceptions = true;
e.addExecutionVisitor(ic -> {
Instruction i = ic.getInstruction();
if (checked.contains(i)) {
return;
}
checked.add(i);
if (i.getType() != INVOKEVIRTUAL) {
return;
}
InvokeVirtual iv = (InvokeVirtual) i;
// queueForWrite
if (!iv.getMethod().getType().equals(new Signature("([BII)V"))) {
return;
}
InstructionContext lengthCtx = ic.getPops().get(0).getPushed();
if (lengthCtx.getInstruction().getType() != GETFIELD) {
return;
}
queueForWrite.add(ic);
});
e.run();
}
use of net.runelite.asm.signature.Signature in project runelite by runelite.
the class ConstructorMapper method mapConstructors.
/**
* Map constructors based on the class mappings of the given mapping
*/
public void mapConstructors() {
for (ClassFile cf : source.getClasses()) {
ClassFile other = (ClassFile) mapping.get(cf);
if (other == null) {
continue;
}
for (Method m : cf.getMethods()) {
if (!m.getName().equals("<init>")) {
continue;
}
Signature otherSig = toOtherSignature(m.getDescriptor());
if (otherSig == null) {
continue;
}
logger.debug("Converted signature {} -> {}", m.getDescriptor(), otherSig);
Method m2 = other.findMethod(m.getName(), otherSig);
if (m2 == null) {
logger.warn("Unable to find other constructor for {}, looking for signature {} on class {}", m, otherSig, other);
continue;
}
ParallelExecutorMapping p = MappingExecutorUtil.map(m, m2);
p.map(null, m, m2);
mapping.merge(p);
}
}
}
Aggregations