Use jaggl instead of jogl in the deobfuscator

master
Graham 5 years ago
parent fe3e02550b
commit 1bf39200c5
  1. 18
      decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.java
  2. 23
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.java
  3. 6
      deob/src/main/java/dev/openrs2/deob/classpath/AsmClassMetadata.java
  4. 24
      deob/src/main/java/dev/openrs2/deob/classpath/ClassPath.java

@ -19,46 +19,42 @@ public final class Decompiler implements Closeable {
); );
private static Path getDestination(String archive) { private static Path getDestination(String archive) {
archive = archive.replaceAll("_gl[.]jar$", ""); archive = archive.replaceAll("(?:_gl)?[.]jar$", "");
if (archive.equals("runescape")) { if (archive.equals("runescape")) {
archive = "client"; archive = "client";
} else if (archive.equals("jaggl")) {
archive = "gl";
} }
return Paths.get("nonfree").resolve(archive).resolve("src/main/java"); return Paths.get("nonfree").resolve(archive).resolve("src/main/java");
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
var libraries = List.of(Paths.get("nonfree/code/jogl.jar"));
var deobOutput = Paths.get("nonfree/code/deob"); var deobOutput = Paths.get("nonfree/code/deob");
var sources = List.of( var sources = List.of(
deobOutput.resolve("runescape_gl.jar"), deobOutput.resolve("runescape_gl.jar"),
deobOutput.resolve("jaggl.jar"),
deobOutput.resolve("loader_gl.jar"), deobOutput.resolve("loader_gl.jar"),
deobOutput.resolve("signlink_gl.jar"), deobOutput.resolve("signlink_gl.jar"),
deobOutput.resolve("unpack_gl.jar"), deobOutput.resolve("unpack_gl.jar"),
deobOutput.resolve("unpacker_gl.jar") deobOutput.resolve("unpacker_gl.jar")
); );
try (var decompiler = new Decompiler(libraries, sources, Decompiler::getDestination)) { try (var decompiler = new Decompiler(sources, Decompiler::getDestination)) {
decompiler.run(); decompiler.run();
} }
} }
private final DecompilerIo io; private final DecompilerIo io;
private final Fernflower fernflower; private final Fernflower fernflower;
private final List<Path> libraries, sources; private final List<Path> sources;
public Decompiler(List<Path> libraries, List<Path> sources, Function<String, Path> destination) { public Decompiler(List<Path> sources, Function<String, Path> destination) {
this.io = new DecompilerIo(destination); this.io = new DecompilerIo(destination);
this.fernflower = new Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger.INSTANCE); this.fernflower = new Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger.INSTANCE);
this.libraries = libraries;
this.sources = sources; this.sources = sources;
} }
public void run() { public void run() {
for (var library : libraries) {
fernflower.addLibrary(library.toFile());
}
for (var source : sources) { for (var source : sources) {
fernflower.addSource(source.toFile()); fernflower.addSource(source.toFile());
} }

@ -1,8 +1,6 @@
package dev.openrs2.deob; package dev.openrs2.deob;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -51,16 +49,11 @@ public final class Deobfuscator {
var glUnpacker = new Library(unpacker); var glUnpacker = new Library(unpacker);
var loader = Library.readJar(input.resolve("loader.jar")); var loader = Library.readJar(input.resolve("loader.jar"));
var glLoader = Library.readJar(input.resolve("loader_gl.jar")); var glLoader = Library.readJar(input.resolve("loader_gl.jar"));
var gl = Library.readPack(input.resolve("jaggl.pack200"));
var client = Library.readJar(input.resolve("runescape.jar")); var client = Library.readJar(input.resolve("runescape.jar"));
var glClient = Library.readPack(input.resolve("runescape_gl.pack200")); var glClient = Library.readPack(input.resolve("runescape_gl.pack200"));
var unsignedClient = new Library(client); var unsignedClient = new Library(client);
/* read dependencies */
var runtime = ClassLoader.getPlatformClassLoader();
var jogl = new URLClassLoader(new URL[] {
input.resolve("jogl.jar").toUri().toURL()
}, runtime);
/* overwrite client's classes with signed classes from the loader */ /* overwrite client's classes with signed classes from the loader */
logger.info("Moving signed classes from loader to runescape"); logger.info("Moving signed classes from loader to runescape");
var signedClasses = SignedClassSet.create(loader, client); var signedClasses = SignedClassSet.create(loader, client);
@ -74,6 +67,7 @@ public final class Deobfuscator {
"unpacker_gl", glUnpacker, "unpacker_gl", glUnpacker,
"loader", loader, "loader", loader,
"loader_gl", glLoader, "loader_gl", glLoader,
"jaggl", gl,
"runescape", client, "runescape", client,
"runescape_gl", glClient, "runescape_gl", glClient,
"runescape_unsigned", unsignedClient "runescape_unsigned", unsignedClient
@ -115,13 +109,15 @@ public final class Deobfuscator {
/* remap all class, method and field names */ /* remap all class, method and field names */
logger.info("Creating remappers"); logger.info("Creating remappers");
var libraries = new Library[] { client, loader, signLink, unpack, unpacker }; var runtime = ClassLoader.getPlatformClassLoader();
var remapper = TypedRemapper.create(new ClassPath(runtime, libraries));
var libraries = List.of(client, loader, signLink, unpack, unpacker);
var remapper = TypedRemapper.create(new ClassPath(runtime, List.of(), libraries));
var glLibraries = new Library[] { glClient, glLoader, glSignLink, glUnpack, glUnpacker }; var glLibraries = List.of(glClient, glLoader, glSignLink, glUnpack, glUnpacker);
var glRemapper = TypedRemapper.create(new ClassPath(jogl, glLibraries)); var glRemapper = TypedRemapper.create(new ClassPath(runtime, List.of(gl), glLibraries));
var unsignedRemapper = TypedRemapper.create(new ClassPath(runtime, unsignedClient)); var unsignedRemapper = TypedRemapper.create(new ClassPath(runtime, List.of(), List.of(unsignedClient)));
/* transform Class.forName() calls */ /* transform Class.forName() calls */
logger.info("Transforming Class.forName() calls"); logger.info("Transforming Class.forName() calls");
@ -162,6 +158,7 @@ public final class Deobfuscator {
unpack.writeJar(output.resolve("unpack.jar"), remapper); unpack.writeJar(output.resolve("unpack.jar"), remapper);
unpacker.writeJar(output.resolve("unpacker.jar"), remapper); unpacker.writeJar(output.resolve("unpacker.jar"), remapper);
gl.writeJar(output.resolve("jaggl.jar"), glRemapper);
glClient.writeJar(output.resolve("runescape_gl.jar"), glRemapper); glClient.writeJar(output.resolve("runescape_gl.jar"), glRemapper);
glLoader.writeJar(output.resolve("loader_gl.jar"), glRemapper); glLoader.writeJar(output.resolve("loader_gl.jar"), glRemapper);
glSignLink.writeJar(output.resolve("signlink_gl.jar"), glRemapper); glSignLink.writeJar(output.resolve("signlink_gl.jar"), glRemapper);

@ -10,10 +10,12 @@ import org.objectweb.asm.tree.ClassNode;
public final class AsmClassMetadata extends ClassMetadata { public final class AsmClassMetadata extends ClassMetadata {
private final ClassPath classPath; private final ClassPath classPath;
private final ClassNode clazz; private final ClassNode clazz;
private final boolean dependency;
public AsmClassMetadata(ClassPath classPath, ClassNode clazz) { public AsmClassMetadata(ClassPath classPath, ClassNode clazz, boolean dependency) {
this.classPath = classPath; this.classPath = classPath;
this.clazz = clazz; this.clazz = clazz;
this.dependency = dependency;
} }
@Override @Override
@ -23,7 +25,7 @@ public final class AsmClassMetadata extends ClassMetadata {
@Override @Override
public boolean isDependency() { public boolean isDependency() {
return false; return dependency;
} }
@Override @Override

@ -9,13 +9,14 @@ import java.util.Map;
import dev.openrs2.asm.Library; import dev.openrs2.asm.Library;
public final class ClassPath { public final class ClassPath {
private final ClassLoader dependencyLoader; private final ClassLoader runtime;
private final List<Library> libraries; private final List<Library> dependencies, libraries;
private final Map<String, ClassMetadata> cache = new HashMap<>(); private final Map<String, ClassMetadata> cache = new HashMap<>();
public ClassPath(ClassLoader dependencyLoader, Library... libraries) { public ClassPath(ClassLoader runtime, List<Library> dependencies, List<Library> libraries) {
this.dependencyLoader = dependencyLoader; this.runtime = runtime;
this.libraries = List.of(libraries); this.dependencies = dependencies;
this.libraries = libraries;
} }
public List<ClassMetadata> getLibraryClasses() { public List<ClassMetadata> getLibraryClasses() {
@ -39,7 +40,16 @@ public final class ClassPath {
for (var library : libraries) { for (var library : libraries) {
var clazz = library.get(name); var clazz = library.get(name);
if (clazz != null) { if (clazz != null) {
metadata = new AsmClassMetadata(this, clazz); metadata = new AsmClassMetadata(this, clazz, false);
cache.put(name, metadata);
return metadata;
}
}
for (var library : dependencies) {
var clazz = library.get(name);
if (clazz != null) {
metadata = new AsmClassMetadata(this, clazz, true);
cache.put(name, metadata); cache.put(name, metadata);
return metadata; return metadata;
} }
@ -49,7 +59,7 @@ public final class ClassPath {
Class<?> clazz; Class<?> clazz;
try { try {
clazz = dependencyLoader.loadClass(reflectionName); clazz = runtime.loadClass(reflectionName);
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
throw new IllegalArgumentException("Unknown class " + name); throw new IllegalArgumentException("Unknown class " + name);
} }

Loading…
Cancel
Save