use of net.runelite.asm.Type 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.Type in project runelite by runelite.
the class SignatureTest method test.
@Test
public void test() {
Signature signature = new Signature("f(Ljava/lang/String;II[Lch;[ILce;IIB)V");
Type type = signature.getTypeOfArg(3);
Assert.assertTrue(type.isArray());
}
use of net.runelite.asm.Type in project runelite by runelite.
the class CastNullTest method testRun.
@Test
public void testRun() {
ClassGroup group = ClassGroupFactory.generateGroup();
Code code = group.findClass("test").findMethod("func").getCode();
Instructions ins = code.getInstructions();
code.setMaxStack(3);
CheckCast checkCast = new CheckCast(ins);
checkCast.setType(new Type("test"));
Instruction[] instructions = { new LDC(ins, 2), new AConstNull(ins), checkCast, new LDC(ins, 2), new IAdd(ins), new Return(ins, InstructionType.IRETURN) };
for (Instruction i : instructions) {
ins.addInstruction(i);
}
Assert.assertEquals(6, ins.getInstructions().size());
CastNull lvt = new CastNull();
lvt.run(group);
Assert.assertEquals(5, ins.getInstructions().size());
Optional<Instruction> o = ins.getInstructions().stream().filter(i -> i instanceof CheckCast).findAny();
Assert.assertFalse(o.isPresent());
}
use of net.runelite.asm.Type in project runelite by runelite.
the class Inject method getFieldType.
public Type getFieldType(Field f) {
Type type = f.getType();
Annotation obfSignature = f.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfSignature != null) {
// Annotation exists. Type was updated by us during deobfuscation
type = DeobAnnotations.getObfuscatedType(f);
}
return type;
}
use of net.runelite.asm.Type in project runelite by runelite.
the class Inject method toObField.
Field toObField(Field field) {
String obfuscatedClassName = DeobAnnotations.getObfuscatedName(field.getClassFile().getAnnotations());
// obfuscated name of field
String obfuscatedFieldName = DeobAnnotations.getObfuscatedName(field.getAnnotations());
Type type = getFieldType(field);
ClassFile obfuscatedClass = vanilla.findClass(obfuscatedClassName);
assert obfuscatedClass != null;
Field obfuscatedField = obfuscatedClass.findFieldDeep(obfuscatedFieldName, type);
assert obfuscatedField != null;
return obfuscatedField;
}
Aggregations