use of net.runelite.asm.Method in project runelite by runelite.
the class BufferFinder method find.
public void find() {
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code code = m.getCode();
if (findModPow(code)) {
buffer = cf;
// packetBuffer extends this
packetBuffer = group.getClasses().stream().filter(cl -> cl.getParent() == cf).findAny().get();
logger.info("Identified buffer {}, packetBuffer {}", buffer, packetBuffer);
}
}
}
}
use of net.runelite.asm.Method 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.Method in project runelite by runelite.
the class BufferMethodInjector method inject.
public void inject() throws IOException {
Field buffer = bp.getBuffer();
Field offset = bp.getOffset();
assert buffer.getClassFile() == offset.getClassFile();
InputStream in = getClass().getResourceAsStream("RuneliteBuffer.class");
assert in != null : "no RuneliteBuffer";
ClassFile runeliteBuffer = loadClass(in);
ClassFile bufferClass = buffer.getClassFile();
for (Field f : runeliteBuffer.getFields()) {
if (!f.getName().startsWith("runelite")) {
continue;
}
inject(bufferClass, f);
}
for (Method m : runeliteBuffer.getMethods()) {
if (!m.getName().startsWith("runelite")) {
continue;
}
inject(bufferClass, m);
}
}
use of net.runelite.asm.Method in project runelite by runelite.
the class ConstantParameter method getCMPFor.
private ConstantMethodParameter getCMPFor(List<Method> methods, int paramIndex, int lvtIndex) {
ConstantMethodParameter cmp = new ConstantMethodParameter();
cmp.methods = methods;
cmp.paramIndex = paramIndex;
cmp.lvtIndex = lvtIndex;
ConstantMethodParameter exists = parameters.get(cmp);
if (exists != null) {
// due to invokespecial on virtual methods.
return exists;
}
parameters.put(cmp, cmp);
for (Method m : methods) {
mparams.put(m, cmp);
}
return cmp;
}
use of net.runelite.asm.Method in project runelite by runelite.
the class ConstantParameter method annotateObfuscatedSignature.
private void annotateObfuscatedSignature(ConstantMethodParameter parameter) {
for (Method m : parameter.methods) {
Object value = parameter.values.get(0);
Annotations annotations = m.getAnnotations();
Annotation obfuscatedSignature = annotations.find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfuscatedSignature != null && obfuscatedSignature.getElements().size() == 2) {
// already annotated
continue;
}
if (obfuscatedSignature == null) {
obfuscatedSignature = annotations.addAnnotation(DeobAnnotations.OBFUSCATED_SIGNATURE, "signature", m.getDescriptor().toString());
}
// Add garbage value
Element element = new Element(obfuscatedSignature);
element.setName("garbageValue");
element.setValue(value.toString());
obfuscatedSignature.addElement(element);
}
}
Aggregations