From 9db64efb7bd9ef0a66a91b2b694c83b3d6b028aa Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 7 Jun 2020 15:20:27 +0100 Subject: [PATCH] Add name field to Library Signed-off-by: Graham --- .../main/java/dev/openrs2/asm/classpath/Library.kt | 8 ++++---- bundler/src/main/java/dev/openrs2/bundler/Bundler.kt | 12 ++++++------ deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt b/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt index a0a9377245..d77c61e04a 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt @@ -9,10 +9,10 @@ import java.nio.file.Path import java.util.SortedMap import java.util.TreeMap -class Library() : Iterable { +class Library(val name: String) : Iterable { private var classes: SortedMap = TreeMap() - constructor(library: Library) : this() { + constructor(name: String, library: Library) : this(name) { for (clazz in library.classes.values) { val copy = ClassNode() clazz.accept(copy) @@ -55,14 +55,14 @@ class Library() : Iterable { companion object { private val logger = InlineLogger() - fun read(path: Path, reader: LibraryReader): Library { + fun read(name: String, path: Path, reader: LibraryReader): Library { logger.info { "Reading library $path" } val classes = Files.newInputStream(path).use { input -> reader.read(input) } - val library = Library() + val library = Library(name) for (clazz in classes) { library.add(clazz) } diff --git a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt index 30fa9ddb2d..dd170dc443 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt @@ -42,12 +42,12 @@ class Bundler @Inject constructor( fun run(input: Path, output: Path, keyStorePath: Path) { // read input jars/packs logger.info { "Reading input jars" } - val unpacker = Library.read(input.resolve("unpackclass.pack"), JarLibraryReader) - val loader = Library.read(input.resolve("loader.jar"), JarLibraryReader) - val glLoader = Library.read(input.resolve("loader_gl.jar"), JarLibraryReader) - val gl = Library.read(input.resolve("jaggl.pack200"), Pack200LibraryReader) - val client = Library.read(input.resolve("runescape.jar"), JarLibraryReader) - val glClient = Library.read(input.resolve("runescape_gl.pack200"), Pack200LibraryReader) + val unpacker = Library.read("unpackclass", input.resolve("unpackclass.pack"), JarLibraryReader) + val loader = Library.read("loader_sd", input.resolve("loader.jar"), JarLibraryReader) + val glLoader = Library.read("loader_hd", input.resolve("loader_gl.jar"), JarLibraryReader) + val gl = Library.read("gl", input.resolve("jaggl.pack200"), Pack200LibraryReader) + val client = Library.read("client_sd", input.resolve("runescape.jar"), JarLibraryReader) + val glClient = Library.read("client_hd", input.resolve("runescape_gl.pack200"), Pack200LibraryReader) // bundle libraries together into a common classpath val runtime = ClassLoader.getPlatformClassLoader() diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt index 84e0bf5ccf..f00f9a746e 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt @@ -21,19 +21,19 @@ class Deobfuscator @Inject constructor( fun run(input: Path, output: Path) { // read input jars/packs logger.info { "Reading input jars" } - val client = Library.read(input.resolve("runescape_gl.pack200"), Pack200LibraryReader) - val gl = Library.read(input.resolve("jaggl.pack200"), Pack200LibraryReader) - val loader = Library.read(input.resolve("loader_gl.jar"), JarLibraryReader) - val unpackClass = Library.read(input.resolve("unpackclass.pack"), JarLibraryReader) + val client = Library.read("client", input.resolve("runescape_gl.pack200"), Pack200LibraryReader) + val gl = Library.read("gl", input.resolve("jaggl.pack200"), Pack200LibraryReader) + val loader = Library.read("loader", input.resolve("loader_gl.jar"), JarLibraryReader) + val unpackClass = Library.read("unpackclass", input.resolve("unpackclass.pack"), JarLibraryReader) // overwrite client's classes with signed classes from the loader logger.info { "Moving signed classes from loader to signlink" } - val signlink = Library() + val signlink = Library("signlink") SignedClassUtils.move(loader, client, signlink) // 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" } - val unpack = Library() + val unpack = Library("unpack") unpack.add(loader.remove("unpack")!!) // prefix remaining loader/unpacker classes (to avoid conflicts when we rename in the same classpath as the client)