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);
}
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations