use of net.runelite.asm.ClassFile in project runelite by runelite.
the class UnusedClass method run.
@Override
public void run(ClassGroup group) {
int count = 0;
for (ClassFile cf : new ArrayList<>(group.getClasses())) {
if (!cf.getFields().isEmpty()) {
continue;
}
if (!cf.getMethods().isEmpty()) {
continue;
}
if (isImplemented(group, cf)) {
continue;
}
group.removeClass(cf);
++count;
}
logger.info("Removed {} classes", count);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class UnusedMethods method run.
@Override
public void run(ClassGroup group) {
for (ClassFile cf : group.getClasses()) {
for (Method method : cf.getMethods()) {
run(method);
}
}
int count = 0;
for (ClassFile cf : group.getClasses()) {
boolean extendsApplet = extendsApplet(cf);
for (Method method : new ArrayList<>(cf.getMethods())) {
// constructors can't be renamed, but are obfuscated
if (!Deob.isObfuscated(method.getName()) && !method.getName().equals("<init>")) {
continue;
}
if (extendsApplet && method.getName().equals("<init>")) {
continue;
}
if (!methods.contains(method)) {
logger.debug("Removing unused method {}", method);
cf.removeMethod(method);
++count;
}
}
}
logger.info("Removed {} methods", count);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class Renamer method run.
@Override
public void run(ClassGroup group) {
group.buildClassGraph();
group.lookup();
int classes = 0, fields = 0, methods = 0;
// rename fields
for (ClassFile cf : group.getClasses()) {
for (Field field : cf.getFields()) {
String newName = mappings.get(field.getPoolField());
if (newName == null) {
continue;
}
if (field.getAnnotations().find(DeobAnnotations.OBFUSCATED_NAME) == null) {
field.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_NAME, "value", field.getName());
}
field.setName(newName);
++fields;
}
}
// rename methods
for (ClassFile cf : group.getClasses()) {
for (Method method : cf.getMethods()) {
String newName = mappings.get(method.getPoolMethod());
// rename on obfuscated signature
Annotation an = method.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (an != null) {
Signature obfuscatedSig = new Signature(an.getElement().getString());
Signature updatedSig = renameSignature(obfuscatedSig);
an.getElement().setValue(updatedSig.toString());
}
if (newName == null) {
continue;
}
List<Method> virtualMethods = VirtualMethods.getVirtualMethods(method);
assert !virtualMethods.isEmpty();
for (Method m : virtualMethods) {
if (m.getAnnotations().find(DeobAnnotations.OBFUSCATED_NAME) == null) {
m.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_NAME, "value", m.getName());
}
m.setName(newName);
}
methods += virtualMethods.size();
}
}
for (ClassFile cf : group.getClasses()) {
String newName = mappings.get(cf.getPoolClass());
if (newName == null) {
continue;
}
renameClass(group, cf, newName);
++classes;
}
this.regeneratePool(group);
logger.info("Renamed {} classes, {} fields, and {} methods", classes, fields, methods);
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class PutStatic method getMyField.
@Override
public net.runelite.asm.Field getMyField() {
Class clazz = field.getClazz();
ClassGroup group = this.getInstructions().getCode().getMethod().getClassFile().getGroup();
ClassFile cf = group.findClass(clazz.getName());
if (cf == null) {
return null;
}
net.runelite.asm.Field f2 = cf.findFieldDeep(field.getName(), field.getType());
return f2;
}
use of net.runelite.asm.ClassFile in project runelite by runelite.
the class RWOpcodeFinder method find.
public void find() {
IsaacCipherFinder ic = new IsaacCipherFinder(group);
ic.find();
for (ClassFile cf : group.getClasses()) {
for (Method m : cf.getMethods()) {
Code code = m.getCode();
find(ic, m, code);
}
}
logger.debug("Found readOpcode {}, writeOpcode {}", readOpcode, writeOpcode);
}
Aggregations