Move signed classes in a single pass

master
Graham 5 years ago
parent 12293bb3b1
commit 0b6966c6f8
  1. 19
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.java
  2. 30
      deob/src/main/java/dev/openrs2/deob/SignedClassUtils.java

@ -60,11 +60,13 @@ public final class Deobfuscator {
var unsignedClient = new Library(client);
/* overwrite client's classes with signed classes from the loader */
logger.info("Moving signed classes from loader to runescape");
var signedClasses = SignedClassSet.create(loader, client);
logger.info("Moving signed classes from loader");
var signLink = new Library();
SignedClassUtils.move(loader, client, signLink);
logger.info("Moving signed classes from loader_gl to runescape_gl");
var glSignedClasses = SignedClassSet.create(glLoader, glClient);
logger.info("Moving signed classes from loader_gl");
var glSignLink = new Library();
SignedClassUtils.move(glLoader, glClient, glSignLink);
/* move unpack class out of the loader (so the unpacker and loader can both depend on it) */
logger.info("Moving unpack from loader to unpack");
@ -75,15 +77,6 @@ public final class Deobfuscator {
var glUnpack = new Library();
glUnpack.add(glLoader.remove("unpack"));
/* move signed classes out of the client (so the client and loader can both depend on them) */
logger.info("Moving signed classes from runescape to signlink");
var signLink = new Library();
signedClasses.move(client, signLink);
logger.info("Moving signed classes from runescape_gl to signlink_gl");
var glSignLink = new Library();
glSignedClasses.move(glClient, glSignLink);
/* 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_");

@ -16,12 +16,12 @@ import org.objectweb.asm.tree.MethodNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class SignedClassSet {
private static final Logger logger = LoggerFactory.getLogger(SignedClassSet.class);
public final class SignedClassUtils {
private static final Logger logger = LoggerFactory.getLogger(SignedClassUtils.class);
private static final InsnMatcher LOAD_SIGNED_CLASS_MATCHER = InsnMatcher.compile("LDC INVOKESTATIC ASTORE ALOAD GETFIELD ALOAD INVOKEVIRTUAL ALOAD INVOKEVIRTUAL POP");
public static SignedClassSet create(Library loader, Library client) {
public static void move(Library loader, Library client, Library signLink) {
/* find signed classes */
var signedClasses = findSignedClasses(loader);
logger.info("Identified signed classes {}", signedClasses);
@ -36,18 +36,20 @@ public final class SignedClassSet {
}
var remapper = new SimpleRemapper(mapping);
/* move signed classes to the client */
var remappedSignedClasses = new HashSet<String>();
/* delete original signed classes (these have no dependencies) */
for (var name : signedClasses) {
client.remove(name);
}
/* move loader signed classes to signlink */
for (var name : Sets.union(signedClasses, dependencies)) {
var in = loader.remove(name);
var out = new ClassNode();
in.accept(new ClassRemapper(out, remapper));
remappedSignedClasses.add(out.name);
client.add(out);
signLink.add(out);
}
return new SignedClassSet(remappedSignedClasses);
}
private static Set<String> findSignedClasses(Library loader) {
@ -100,15 +102,7 @@ public final class SignedClassSet {
return dependencies;
}
private final Set<String> signedClasses;
private SignedClassSet(Set<String> signedClasses) {
this.signedClasses = signedClasses;
}
public void move(Library client, Library signLink) {
for (var name : signedClasses) {
signLink.add(client.remove(name));
}
private SignedClassUtils() {
/* empty */
}
}
Loading…
Cancel
Save