use of net.runelite.asm.ClassFile in project runelite by runelite.
the class HookImporter method importHooks.
@Test
@Ignore
public void importHooks() {
int classes = 0, fields = 0, methods = 0;
NameMappings mappings = new NameMappings();
for (HookClass hc : hooks) {
ClassFile cf = findClassWithObfuscatedName(hc.name);
assert cf != null;
String implementsName = getAnnotation(cf.getAnnotations(), IMPLEMENTS);
if (implementsName.isEmpty()) {
String deobfuscatedClassName = hc.clazz;
cf.getAnnotations().addAnnotation(IMPLEMENTS, "value", deobfuscatedClassName);
mappings.map(cf.getPoolClass(), deobfuscatedClassName);
++classes;
}
for (HookField fh : hc.fields) {
ClassFile cf2 = findClassWithObfuscatedName(fh.owner);
assert cf2 != null;
Field f = findFieldWithObfuscatedName(cf2, fh.name);
if (f == null) {
// inlined constant maybe?
logger.warn("Missing field {}", fh);
continue;
}
String exportedName = getAnnotation(f.getAnnotations(), EXPORT);
if (exportedName.isEmpty()) {
String deobfuscatedFieldName = fh.field;
Field other = cf2.findField(deobfuscatedFieldName);
if (other != null) {
logger.warn("Name collision for field {}", deobfuscatedFieldName);
continue;
}
f.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedFieldName);
mappings.map(f.getPoolField(), deobfuscatedFieldName);
++fields;
}
}
outer: for (HookMethod hm : hc.methods) {
ClassFile cf2 = findClassWithObfuscatedName(hm.owner);
assert cf2 != null;
Method m = findMethodWithObfuscatedName(cf2, hm.name, hm.descriptor);
assert m != null;
// maybe only the base class method is exported
List<Method> virtualMethods = VirtualMethods.getVirtualMethods(m);
for (Method method : virtualMethods) {
String exportedName = getAnnotation(method.getAnnotations(), EXPORT);
if (!exportedName.isEmpty()) {
continue outer;
}
}
String deobfuscatedMethodName = hm.method;
m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName);
mappings.map(m.getPoolMethod(), deobfuscatedMethodName);
++methods;
}
}
Renamer renamer = new Renamer(mappings);
renamer.run(group);
logger.info("Imported {} classes, {} fields, {} methods", classes, fields, methods);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class UpdateMappingsTest method summary.
public static void summary(ParallelExecutorMapping finalm, ClassGroup in) {
int fields = 0, staticMethod = 0, method = 0, total = 0, classes = 0;
for (Map.Entry<Object, Object> e : finalm.getMap().entrySet()) {
Object o = e.getKey();
if (o instanceof Field) {
++fields;
Field f = (Field) o;
assert f.getClassFile().getGroup() == in;
} else if (o instanceof Method) {
Method m = (Method) o;
assert m.getClassFile().getGroup() == in;
if (m.isStatic()) {
++staticMethod;
} else {
++method;
}
} else if (o instanceof ClassFile) {
++classes;
}
++total;
}
logger.info("Total mapped: {}. {} fields, {} static methods, {} member methods, {} classes", total, fields, staticMethod, method, classes);
}
use of net.runelite.asm.ClassFile 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.ClassFile 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.ClassFile in project runelite by runelite.
the class ModArith method annotateEncryption.
public void annotateEncryption() {
for (ClassFile cf : group.getClasses()) {
for (Field f : cf.getFields()) {
Pair pair = encryption.getField(f.getPoolField());
if (pair == null) {
continue;
}
if (pair.getter.longValue() == 1L) {
continue;
}
String ename = pair.getType() == Long.class ? "longValue" : "intValue";
f.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_GETTER, ename, pair.getter);
}
}
}
Aggregations