Add combined command for running both deobfuscators and the decompiler

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 70b35216c9
commit e18d751125
  1. 15
      .idea/runConfigurations/Deobfuscator.xml
  2. 4
      all/build.gradle.kts
  3. 8
      all/src/main/kotlin/org/openrs2/Command.kt
  4. 3
      decompiler/build.gradle.kts
  5. 4
      decompiler/src/main/kotlin/org/openrs2/decompiler/DecompileCommand.kt
  6. 6
      decompiler/src/main/kotlin/org/openrs2/decompiler/Decompiler.kt
  7. 3
      deob-ast/build.gradle.kts
  8. 2
      deob-ast/src/main/kotlin/org/openrs2/deob/ast/DeobfuscateAstCommand.kt
  9. 1
      deob-bytecode/build.gradle.kts
  10. 2
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/DeobfuscateBytecodeCommand.kt
  11. 34
      deob/build.gradle.kts
  12. 14
      deob/src/main/kotlin/org/openrs2/deob/DeobfuscateCommand.kt
  13. 35
      deob/src/main/kotlin/org/openrs2/deob/Deobfuscator.kt
  14. 12
      deob/src/main/kotlin/org/openrs2/deob/DeobfuscatorModule.kt
  15. 1
      settings.gradle.kts

@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Deobfuscator" type="JetRunConfigurationType">
<module name="openrs2.deob.main" />
<option name="VM_PARAMETERS" value="-Xmx3G" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" value="org.openrs2.deob.DeobfuscateCommandKt" />
<option name="WORKING_DIRECTORY" value="" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

@ -18,9 +18,7 @@ dependencies {
implementation(project(":archive")) implementation(project(":archive"))
implementation(project(":compress-cli")) implementation(project(":compress-cli"))
implementation(project(":crc32")) implementation(project(":crc32"))
implementation(project(":decompiler")) implementation(project(":deob"))
implementation(project(":deob-ast"))
implementation(project(":deob-bytecode"))
implementation(project(":game")) implementation(project(":game"))
implementation(project(":patcher")) implementation(project(":patcher"))
} }

@ -5,9 +5,7 @@ import com.github.ajalt.clikt.core.subcommands
import org.openrs2.archive.ArchiveCommand import org.openrs2.archive.ArchiveCommand
import org.openrs2.compress.cli.CompressCommand import org.openrs2.compress.cli.CompressCommand
import org.openrs2.crc32.Crc32Command import org.openrs2.crc32.Crc32Command
import org.openrs2.decompiler.DecompileCommand import org.openrs2.deob.DeobfuscateCommand
import org.openrs2.deob.ast.DeobfuscateAstCommand
import org.openrs2.deob.bytecode.DeobfuscateBytecodeCommand
import org.openrs2.game.GameCommand import org.openrs2.game.GameCommand
import org.openrs2.patcher.PatchCommand import org.openrs2.patcher.PatchCommand
@ -19,9 +17,7 @@ public class Command : NoOpCliktCommand(name = "openrs2") {
ArchiveCommand(), ArchiveCommand(),
CompressCommand(), CompressCommand(),
Crc32Command(), Crc32Command(),
DecompileCommand(), DeobfuscateCommand(),
DeobfuscateAstCommand(),
DeobfuscateBytecodeCommand(),
GameCommand(), GameCommand(),
PatchCommand() PatchCommand()
) )

@ -10,9 +10,10 @@ application {
} }
dependencies { dependencies {
api(project(":deob-util"))
api("com.github.ajalt.clikt:clikt:${Versions.clikt}") api("com.github.ajalt.clikt:clikt:${Versions.clikt}")
api("com.google.inject:guice:${Versions.guice}")
implementation(project(":deob-util"))
implementation(project(":util")) implementation(project(":util"))
implementation("org.openrs2:fernflower:${Versions.fernflower}") implementation("org.openrs2:fernflower:${Versions.fernflower}")
} }

@ -7,7 +7,7 @@ public fun main(args: Array<String>): Unit = DecompileCommand().main(args)
public class DecompileCommand : CliktCommand(name = "decompile") { public class DecompileCommand : CliktCommand(name = "decompile") {
override fun run() { override fun run() {
val decompiler = Decompiler(Module.ALL) val decompiler = Decompiler()
decompiler.run() decompiler.run(Module.ALL)
} }
} }

@ -3,9 +3,11 @@ package org.openrs2.decompiler
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
import org.openrs2.deob.util.Module import org.openrs2.deob.util.Module
import javax.inject.Singleton
public class Decompiler(private val modules: Set<Module>) { @Singleton
public fun run() { public class Decompiler {
public fun run(modules: Set<Module>) {
for (module in modules) { for (module in modules) {
DecompilerIo(module.sources).use { io -> DecompilerIo(module.sources).use { io ->
val fernflower = Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger) val fernflower = Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger)

@ -9,9 +9,10 @@ application {
} }
dependencies { dependencies {
api(project(":deob-util"))
api("com.github.ajalt.clikt:clikt:${Versions.clikt}") api("com.github.ajalt.clikt:clikt:${Versions.clikt}")
api("com.google.inject:guice:${Versions.guice}")
implementation(project(":deob-util"))
implementation(project(":util")) implementation(project(":util"))
implementation("com.github.javaparser:javaparser-symbol-solver-core:${Versions.javaParser}") implementation("com.github.javaparser:javaparser-symbol-solver-core:${Versions.javaParser}")
implementation("com.google.guava:guava:${Versions.guava}") implementation("com.google.guava:guava:${Versions.guava}")

@ -6,7 +6,7 @@ import org.openrs2.deob.util.Module
public fun main(args: Array<String>): Unit = DeobfuscateAstCommand().main(args) public fun main(args: Array<String>): Unit = DeobfuscateAstCommand().main(args)
public class DeobfuscateAstCommand : CliktCommand(name = "deob-ast") { public class DeobfuscateAstCommand : CliktCommand(name = "ast") {
override fun run() { override fun run() {
val injector = Guice.createInjector(AstDeobfuscatorModule) val injector = Guice.createInjector(AstDeobfuscatorModule)
val deobfuscator = injector.getInstance(AstDeobfuscator::class.java) val deobfuscator = injector.getInstance(AstDeobfuscator::class.java)

@ -10,6 +10,7 @@ application {
dependencies { dependencies {
api("com.github.ajalt.clikt:clikt:${Versions.clikt}") api("com.github.ajalt.clikt:clikt:${Versions.clikt}")
api("com.google.inject:guice:${Versions.guice}")
implementation(project(":deob-annotations")) implementation(project(":deob-annotations"))
implementation(project(":deob-util")) implementation(project(":deob-util"))

@ -6,7 +6,7 @@ import java.nio.file.Paths
public fun main(args: Array<String>): Unit = DeobfuscateBytecodeCommand().main(args) public fun main(args: Array<String>): Unit = DeobfuscateBytecodeCommand().main(args)
public class DeobfuscateBytecodeCommand : CliktCommand(name = "deob-bytecode") { public class DeobfuscateBytecodeCommand : CliktCommand(name = "bytecode") {
override fun run() { override fun run() {
val injector = Guice.createInjector(BytecodeDeobfuscatorModule) val injector = Guice.createInjector(BytecodeDeobfuscatorModule)
val deobfuscator = injector.getInstance(BytecodeDeobfuscator::class.java) val deobfuscator = injector.getInstance(BytecodeDeobfuscator::class.java)

@ -0,0 +1,34 @@
plugins {
`maven-publish`
application
kotlin("jvm")
}
application {
mainClass.set("org.openrs2.deob.DeobfuscateCommandKt")
applicationDefaultJvmArgs = listOf("-Xmx3G")
}
dependencies {
api("com.github.ajalt.clikt:clikt:${Versions.clikt}")
implementation(project(":decompiler"))
implementation(project(":deob-ast"))
implementation(project(":deob-bytecode"))
}
publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
pom {
packaging = "jar"
name.set("OpenRS2 Deobfuscator")
description.set(
"""
A tool for deobfuscating and decompiling the RuneScape client.
""".trimIndent()
)
}
}
}

@ -0,0 +1,14 @@
package org.openrs2.deob
import com.github.ajalt.clikt.core.CliktCommand
import com.google.inject.Guice
public fun main(args: Array<String>): Unit = DeobfuscateCommand().main(args)
public class DeobfuscateCommand : CliktCommand(name = "deob") {
override fun run() {
val injector = Guice.createInjector(DeobfuscatorModule)
val deobfuscator = injector.getInstance(Deobfuscator::class.java)
deobfuscator.run()
}
}

@ -0,0 +1,35 @@
package org.openrs2.deob
import com.github.michaelbull.logging.InlineLogger
import org.openrs2.decompiler.Decompiler
import org.openrs2.deob.ast.AstDeobfuscator
import org.openrs2.deob.bytecode.BytecodeDeobfuscator
import org.openrs2.deob.util.Module
import java.nio.file.Paths
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
public class Deobfuscator @Inject constructor(
private val bytecodeDeobfuscator: BytecodeDeobfuscator,
private val decompiler: Decompiler,
private val astDeobfuscator: AstDeobfuscator
) {
public fun run() {
logger.info { "Deobfuscating bytecode" }
bytecodeDeobfuscator.run(
input = Paths.get("nonfree/lib"),
output = Paths.get("nonfree/var/cache/deob")
)
logger.info { "Decompiling" }
decompiler.run(Module.ALL)
logger.info { "Deobfuscating AST" }
astDeobfuscator.run(Module.ALL)
}
private companion object {
private val logger = InlineLogger()
}
}

@ -0,0 +1,12 @@
package org.openrs2.deob
import com.google.inject.AbstractModule
import org.openrs2.deob.ast.AstDeobfuscatorModule
import org.openrs2.deob.bytecode.BytecodeDeobfuscatorModule
public object DeobfuscatorModule : AbstractModule() {
override fun configure() {
install(AstDeobfuscatorModule)
install(BytecodeDeobfuscatorModule)
}
}

@ -13,6 +13,7 @@ include(
"crypto", "crypto",
"db", "db",
"decompiler", "decompiler",
"deob",
"deob-annotations", "deob-annotations",
"deob-ast", "deob-ast",
"deob-bytecode", "deob-bytecode",

Loading…
Cancel
Save