Use Module class in the decompiler

This commit also changes the names of the deobfuscator output jars to
match up with the module names.

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 4 years ago
parent b5cbe3ea70
commit f9021f7fe6
  1. 1
      decompiler/build.gradle.kts
  2. 46
      decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt
  3. 13
      decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt
  4. 12
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt

@ -12,6 +12,7 @@ application {
dependencies { dependencies {
api("com.github.ajalt:clikt:${Versions.clikt}") api("com.github.ajalt:clikt:${Versions.clikt}")
implementation(project(":deob-util"))
implementation(project(":util")) implementation(project(":util"))
implementation("dev.openrs2:fernflower:${Versions.fernflower}") implementation("dev.openrs2:fernflower:${Versions.fernflower}")
} }

@ -1,55 +1,13 @@
package dev.openrs2.decompiler package dev.openrs2.decompiler
import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktCommand
import java.nio.file.Path import dev.openrs2.deob.util.Module
import java.nio.file.Paths
fun main(args: Array<String>) = DecompileCommand().main(args) fun main(args: Array<String>) = DecompileCommand().main(args)
class DecompileCommand : CliktCommand(name = "decompile") { class DecompileCommand : CliktCommand(name = "decompile") {
override fun run() { override fun run() {
val deobOutput = Paths.get("nonfree/var/cache/deob") val decompiler = Decompiler(Module.all)
val client = deobOutput.resolve("runescape_gl.jar")
val gl = deobOutput.resolve("jaggl.jar")
val loader = deobOutput.resolve("loader_gl.jar")
val signlink = deobOutput.resolve("signlink_gl.jar")
val unpack = deobOutput.resolve("unpack_gl.jar")
val unpackClass = deobOutput.resolve("unpackclass_gl.jar")
val decompiler = Decompiler(
Library(
source = client,
destination = getDestination("client"),
dependencies = listOf(gl, signlink)
),
Library(
source = gl,
destination = getDestination("gl")
),
Library(
source = loader,
destination = getDestination("loader"),
dependencies = listOf(signlink, unpack)
),
Library(
source = signlink,
destination = getDestination("signlink")
),
Library(
source = unpack,
destination = getDestination("unpack")
),
Library(
source = unpackClass,
destination = getDestination("unpackclass"),
dependencies = listOf(unpack)
)
)
decompiler.run() decompiler.run()
} }
private fun getDestination(dir: String): Path {
return Paths.get("nonfree").resolve(dir).resolve("src/main/java")
}
} }

@ -1,18 +1,19 @@
package dev.openrs2.decompiler package dev.openrs2.decompiler
import dev.openrs2.deob.util.Module
import org.jetbrains.java.decompiler.main.Fernflower import org.jetbrains.java.decompiler.main.Fernflower
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences
class Decompiler(private vararg val libraries: Library) { class Decompiler(private val modules: Set<Module>) {
fun run() { fun run() {
for (library in libraries) { for (module in modules) {
DecompilerIo(library.destination).use { io -> DecompilerIo(module.sources).use { io ->
val fernflower = Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger) val fernflower = Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger)
for (dependency in library.dependencies) { for (dependency in module.transitiveDependencies) {
fernflower.addLibrary(dependency.toFile()) fernflower.addLibrary(dependency.jar.toFile())
} }
fernflower.addSource(library.source.toFile()) fernflower.addSource(module.jar.toFile())
fernflower.decompileContext() fernflower.decompileContext()
} }

@ -106,12 +106,12 @@ class Deobfuscator @Inject constructor(
Files.createDirectories(output) Files.createDirectories(output)
client.write(output.resolve("runescape_gl.jar"), JarLibraryWriter, classPath) client.write(output.resolve("client.jar"), JarLibraryWriter, classPath)
gl.write(output.resolve("jaggl.jar"), JarLibraryWriter, classPath) gl.write(output.resolve("gl.jar"), JarLibraryWriter, classPath)
loader.write(output.resolve("loader_gl.jar"), JarLibraryWriter, classPath) loader.write(output.resolve("loader.jar"), JarLibraryWriter, classPath)
signlink.write(output.resolve("signlink_gl.jar"), JarLibraryWriter, classPath) signlink.write(output.resolve("signlink.jar"), JarLibraryWriter, classPath)
unpack.write(output.resolve("unpack_gl.jar"), JarLibraryWriter, classPath) unpack.write(output.resolve("unpack.jar"), JarLibraryWriter, classPath)
unpackClass.write(output.resolve("unpackclass_gl.jar"), JarLibraryWriter, classPath) unpackClass.write(output.resolve("unpackclass.jar"), JarLibraryWriter, classPath)
} }
private companion object { private companion object {

Loading…
Cancel
Save