From b97294457a82e2b99e4162a02684d05d28c087d8 Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 27 Aug 2019 21:15:30 +0100 Subject: [PATCH] Make ClassNamePrefixer more similar to TypedRemapper --- deob/src/main/java/dev/openrs2/deob/Deobfuscator.java | 10 +++++----- .../{ClassNamePrefixer.java => PrefixRemapper.java} | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) rename deob/src/main/java/dev/openrs2/deob/remap/{ClassNamePrefixer.java => PrefixRemapper.java} (67%) diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java index 7c18814466..2fd85e9e59 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.java @@ -11,7 +11,7 @@ import dev.openrs2.asm.classpath.Library; import dev.openrs2.asm.transform.Transformer; import dev.openrs2.bundler.transform.HostCheckTransformer; 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.transform.BitShiftTransformer; 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) */ logger.info("Prefixing loader and unpacker class names"); - ClassNamePrefixer.addPrefix(loader, "loader_"); - ClassNamePrefixer.addPrefix(glLoader, "loader_"); - ClassNamePrefixer.addPrefix(unpacker, "unpacker_"); - ClassNamePrefixer.addPrefix(glUnpacker, "unpacker_"); + loader.remap(PrefixRemapper.create(loader, "loader_")); + glLoader.remap(PrefixRemapper.create(glLoader, "loader_")); + unpacker.remap(PrefixRemapper.create(unpacker, "unpacker_")); + glUnpacker.remap(PrefixRemapper.create(glUnpacker, "unpacker_")); /* bundle libraries together into a common classpath */ var runtime = ClassLoader.getPlatformClassLoader(); diff --git a/deob/src/main/java/dev/openrs2/deob/remap/ClassNamePrefixer.java b/deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.java similarity index 67% rename from deob/src/main/java/dev/openrs2/deob/remap/ClassNamePrefixer.java rename to deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.java index dee2e5e96b..40bde6610a 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/ClassNamePrefixer.java +++ b/deob/src/main/java/dev/openrs2/deob/remap/PrefixRemapper.java @@ -3,10 +3,11 @@ package dev.openrs2.deob.remap; import java.util.HashMap; import dev.openrs2.asm.classpath.Library; +import org.objectweb.asm.commons.Remapper; import org.objectweb.asm.commons.SimpleRemapper; -public final class ClassNamePrefixer { - public static void addPrefix(Library library, String prefix) { +public final class PrefixRemapper { + public static Remapper create(Library library, String prefix) { var mapping = new HashMap(); for (var clazz : library) { 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 */ } }