Make ClassNamePrefixer more similar to TypedRemapper

bzip2
Graham 5 years ago
parent 1319295d77
commit b97294457a
  1. 10
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.java
  2. 9
      deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.java

@ -11,7 +11,7 @@ import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer; import dev.openrs2.asm.transform.Transformer;
import dev.openrs2.bundler.transform.HostCheckTransformer; import dev.openrs2.bundler.transform.HostCheckTransformer;
import dev.openrs2.bundler.transform.RightClickTransformer; import dev.openrs2.bundler.transform.RightClickTransformer;
import dev.openrs2.deob.remap.ClassNamePrefixer; import dev.openrs2.deob.remap.PrefixRemapper;
import dev.openrs2.deob.remap.TypedRemapper; import dev.openrs2.deob.remap.TypedRemapper;
import dev.openrs2.deob.transform.BitShiftTransformer; import dev.openrs2.deob.transform.BitShiftTransformer;
import dev.openrs2.deob.transform.BitwiseOpTransformer; import dev.openrs2.deob.transform.BitwiseOpTransformer;
@ -101,10 +101,10 @@ public final class Deobfuscator {
/* prefix remaining loader/unpacker classes (to avoid conflicts when we rename in the same classpath as the client) */ /* prefix remaining loader/unpacker classes (to avoid conflicts when we rename in the same classpath as the client) */
logger.info("Prefixing loader and unpacker class names"); logger.info("Prefixing loader and unpacker class names");
ClassNamePrefixer.addPrefix(loader, "loader_"); loader.remap(PrefixRemapper.create(loader, "loader_"));
ClassNamePrefixer.addPrefix(glLoader, "loader_"); glLoader.remap(PrefixRemapper.create(glLoader, "loader_"));
ClassNamePrefixer.addPrefix(unpacker, "unpacker_"); unpacker.remap(PrefixRemapper.create(unpacker, "unpacker_"));
ClassNamePrefixer.addPrefix(glUnpacker, "unpacker_"); glUnpacker.remap(PrefixRemapper.create(glUnpacker, "unpacker_"));
/* bundle libraries together into a common classpath */ /* bundle libraries together into a common classpath */
var runtime = ClassLoader.getPlatformClassLoader(); var runtime = ClassLoader.getPlatformClassLoader();

@ -3,10 +3,11 @@ package dev.openrs2.deob.remap;
import java.util.HashMap; import java.util.HashMap;
import dev.openrs2.asm.classpath.Library; import dev.openrs2.asm.classpath.Library;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.commons.SimpleRemapper; import org.objectweb.asm.commons.SimpleRemapper;
public final class ClassNamePrefixer { public final class PrefixRemapper {
public static void addPrefix(Library library, String prefix) { public static Remapper create(Library library, String prefix) {
var mapping = new HashMap<String, String>(); var mapping = new HashMap<String, String>();
for (var clazz : library) { for (var clazz : library) {
if (TypedRemapper.EXCLUDED_CLASSES.contains(clazz.name)) { if (TypedRemapper.EXCLUDED_CLASSES.contains(clazz.name)) {
@ -16,10 +17,10 @@ public final class ClassNamePrefixer {
} }
} }
library.remap(new SimpleRemapper(mapping)); return new SimpleRemapper(mapping);
} }
private ClassNamePrefixer() { private PrefixRemapper() {
/* empty */ /* empty */
} }
} }
Loading…
Cancel
Save