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 {
api("com.github.ajalt:clikt:${Versions.clikt}")
implementation(project(":deob-util"))
implementation(project(":util"))
implementation("dev.openrs2:fernflower:${Versions.fernflower}")
}

@ -1,55 +1,13 @@
package dev.openrs2.decompiler
import com.github.ajalt.clikt.core.CliktCommand
import java.nio.file.Path
import java.nio.file.Paths
import dev.openrs2.deob.util.Module
fun main(args: Array<String>) = DecompileCommand().main(args)
class DecompileCommand : CliktCommand(name = "decompile") {
override fun run() {
val deobOutput = Paths.get("nonfree/var/cache/deob")
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)
)
)
val decompiler = Decompiler(Module.all)
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
import dev.openrs2.deob.util.Module
import org.jetbrains.java.decompiler.main.Fernflower
import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences
class Decompiler(private vararg val libraries: Library) {
class Decompiler(private val modules: Set<Module>) {
fun run() {
for (library in libraries) {
DecompilerIo(library.destination).use { io ->
for (module in modules) {
DecompilerIo(module.sources).use { io ->
val fernflower = Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger)
for (dependency in library.dependencies) {
fernflower.addLibrary(dependency.toFile())
for (dependency in module.transitiveDependencies) {
fernflower.addLibrary(dependency.jar.toFile())
}
fernflower.addSource(library.source.toFile())
fernflower.addSource(module.jar.toFile())
fernflower.decompileContext()
}

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

Loading…
Cancel
Save