Add Original{Class,Name} annotations even if the name was unchanged

I think they will still be useful, as we might refactor the names in the
deobfuscated code in the future.
bzip2
Graham 5 years ago
parent f26695a0c1
commit 6fde1a4bca
  1. 4
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.java
  2. 17
      deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.java

@ -140,17 +140,15 @@ public final class Deobfuscator {
/* add @OriginalName annotations */ /* add @OriginalName annotations */
logger.info("Annotating classes and members with original names"); logger.info("Annotating classes and members with original names");
transformer = new OriginalNameTransformer(remapper); transformer = new OriginalNameTransformer();
for (var library : libraries) { for (var library : libraries) {
transformer.transform(library); transformer.transform(library);
} }
transformer = new OriginalNameTransformer(glRemapper);
for (var library : glLibraries) { for (var library : glLibraries) {
transformer.transform(library); transformer.transform(library);
} }
transformer = new OriginalNameTransformer(unsignedRemapper);
transformer.transform(unsignedClient); transformer.transform(unsignedClient);
/* write output jars */ /* write output jars */

@ -7,7 +7,6 @@ import dev.openrs2.asm.Transformer;
import dev.openrs2.deob.annotation.OriginalClass; import dev.openrs2.deob.annotation.OriginalClass;
import dev.openrs2.deob.annotation.OriginalMember; import dev.openrs2.deob.annotation.OriginalMember;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode; import org.objectweb.asm.tree.FieldNode;
@ -30,18 +29,8 @@ public final class OriginalNameTransformer extends Transformer {
return annotation; return annotation;
} }
private final Remapper remapper;
public OriginalNameTransformer(Remapper remapper) {
this.remapper = remapper;
}
@Override @Override
public void transformClass(ClassNode clazz) { public void transformClass(ClassNode clazz) {
if (clazz.name.equals(remapper.map(clazz.name))) {
return;
}
if (clazz.invisibleAnnotations == null) { if (clazz.invisibleAnnotations == null) {
clazz.invisibleAnnotations = new ArrayList<>(); clazz.invisibleAnnotations = new ArrayList<>();
} }
@ -50,10 +39,6 @@ public final class OriginalNameTransformer extends Transformer {
@Override @Override
public void transformField(ClassNode clazz, FieldNode field) { public void transformField(ClassNode clazz, FieldNode field) {
if (field.name.equals(remapper.mapFieldName(clazz.name, field.name, field.desc))) {
return;
}
if (field.invisibleAnnotations == null) { if (field.invisibleAnnotations == null) {
field.invisibleAnnotations = new ArrayList<>(); field.invisibleAnnotations = new ArrayList<>();
} }
@ -62,7 +47,7 @@ public final class OriginalNameTransformer extends Transformer {
@Override @Override
public void transformMethod(ClassNode clazz, MethodNode method) { public void transformMethod(ClassNode clazz, MethodNode method) {
if (method.name.equals(remapper.mapMethodName(clazz.name, method.name, method.desc))) { if (method.name.equals("<init>") || method.name.equals("<clinit>")) {
return; return;
} }

Loading…
Cancel
Save