From 05a03d5bdcec8f19c76a03650f5b1611b29045d8 Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 30 Apr 2020 20:48:38 +0100 Subject: [PATCH] Inject transformers in the bundler and deobfuscator Signed-off-by: Graham --- .../dev/openrs2/asm/transform/Transformer.kt | 2 +- bundler/build.gradle.kts | 1 + .../main/java/dev/openrs2/bundler/Bundler.kt | 26 +------ .../java/dev/openrs2/bundler/BundlerModule.kt | 22 ++++++ .../dev/openrs2/bundler/BundlerQualifier.kt | 8 ++ .../transform/BufferSizeTransformer.kt | 2 + .../bundler/transform/CachePathTransformer.kt | 2 + .../bundler/transform/HostCheckTransformer.kt | 2 + .../transform/LoadLibraryTransformer.kt | 2 + .../bundler/transform/MacResizeTransformer.kt | 2 + .../transform/PlatformDetectionTransformer.kt | 2 + .../transform/RightClickTransformer.kt | 2 + .../bundler/transform/TypoTransformer.kt | 2 + .../dev/openrs2/deob/DeobfuscateCommand.kt | 6 +- .../java/dev/openrs2/deob/Deobfuscator.kt | 78 +++---------------- .../dev/openrs2/deob/DeobfuscatorModule.kt | 72 +++++++++++++++++ .../dev/openrs2/deob/DeobfuscatorQualifier.kt | 8 ++ .../deob/transform/BitShiftTransformer.kt | 2 + .../deob/transform/BitwiseOpTransformer.kt | 2 + .../deob/transform/BundlerTransformer.kt | 24 ++++++ .../deob/transform/CanvasTransformer.kt | 2 + .../deob/transform/ClassLiteralTransformer.kt | 2 + .../deob/transform/ConstantArgTransformer.kt | 2 + .../deob/transform/CounterTransformer.kt | 2 + .../deob/transform/EmptyClassTransformer.kt | 2 + .../transform/ExceptionTracingTransformer.kt | 2 + .../FernflowerExceptionTransformer.kt | 2 + .../deob/transform/FieldOrderTransformer.kt | 2 + .../deob/transform/FinalTransformer.kt | 2 + .../transform/InvokeSpecialTransformer.kt | 2 + .../deob/transform/MethodOrderTransformer.kt | 2 + .../deob/transform/MonitorTransformer.kt | 2 + .../transform/OpaquePredicateTransformer.kt | 2 + .../deob/transform/OriginalNameTransformer.kt | 2 + .../transform/OriginalPcRestoreTransformer.kt | 2 + .../transform/OriginalPcSaveTransformer.kt | 2 + .../deob/transform/OverrideTransformer.kt | 2 + .../transform/RedundantGotoTransformer.kt | 2 + .../deob/transform/RemapTransformer.kt | 2 + .../deob/transform/ResetTransformer.kt | 2 + .../transform/StaticScramblingTransformer.kt | 2 + .../deob/transform/UnusedArgTransformer.kt | 2 + .../deob/transform/UnusedLocalTransformer.kt | 2 + .../deob/transform/UnusedMethodTransformer.kt | 2 + .../deob/transform/VisibilityTransformer.kt | 2 + 45 files changed, 226 insertions(+), 91 deletions(-) create mode 100644 bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt create mode 100644 deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt create mode 100644 deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt create mode 100644 deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt diff --git a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt index 68466113..ebb1fc17 100644 --- a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt +++ b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt @@ -8,7 +8,7 @@ import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.MethodNode abstract class Transformer { - fun transform(classPath: ClassPath) { + open fun transform(classPath: ClassPath) { preTransform(classPath) var changed: Boolean diff --git a/bundler/build.gradle.kts b/bundler/build.gradle.kts index 27afd876..6ef55af3 100644 --- a/bundler/build.gradle.kts +++ b/bundler/build.gradle.kts @@ -11,6 +11,7 @@ application { dependencies { api(project(":asm")) api("com.github.ajalt:clikt:${Versions.clikt}") + api("com.google.inject:guice:${Versions.guice}") implementation(project(":crypto")) implementation("dev.openrs2:openrs2-natives-all:${Versions.openrs2Natives}") diff --git a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt index 7a664f15..febb5a62 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt @@ -3,16 +3,8 @@ package dev.openrs2.bundler import com.github.michaelbull.logging.InlineLogger import dev.openrs2.asm.classpath.ClassPath import dev.openrs2.asm.classpath.Library -import dev.openrs2.bundler.transform.BufferSizeTransformer -import dev.openrs2.bundler.transform.CachePathTransformer -import dev.openrs2.bundler.transform.HostCheckTransformer -import dev.openrs2.bundler.transform.LoadLibraryTransformer -import dev.openrs2.bundler.transform.MacResizeTransformer -import dev.openrs2.bundler.transform.PlatformDetectionTransformer -import dev.openrs2.bundler.transform.PublicKeyTransformer +import dev.openrs2.asm.transform.Transformer import dev.openrs2.bundler.transform.ResourceTransformer -import dev.openrs2.bundler.transform.RightClickTransformer -import dev.openrs2.bundler.transform.TypoTransformer import dev.openrs2.crypto.Pkcs12KeyStore import java.nio.file.Path import java.util.jar.Attributes @@ -22,9 +14,9 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class Bundler @Inject constructor(publicKeyTransformer: PublicKeyTransformer) { - private val transformers = TRANSFORMERS + publicKeyTransformer - +class Bundler @Inject constructor( + @BundlerQualifier private val transformers: Set<@JvmSuppressWildcards Transformer> +) { fun run(input: Path, output: Path, keyStorePath: Path) { // read input jars/packs logger.info { "Reading input jars" } @@ -118,16 +110,6 @@ class Bundler @Inject constructor(publicKeyTransformer: PublicKeyTransformer) { companion object { private val logger = InlineLogger() - val TRANSFORMERS = listOf( - BufferSizeTransformer(), - CachePathTransformer(), - HostCheckTransformer(), - MacResizeTransformer(), - RightClickTransformer(), - LoadLibraryTransformer(), - PlatformDetectionTransformer(), - TypoTransformer() - ) private val unsignedManifest = Manifest() private val signedManifest: Manifest diff --git a/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt b/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt index ceee5b6f..479a417b 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt @@ -1,10 +1,32 @@ package dev.openrs2.bundler import com.google.inject.AbstractModule +import com.google.inject.multibindings.Multibinder +import dev.openrs2.asm.transform.Transformer +import dev.openrs2.bundler.transform.BufferSizeTransformer +import dev.openrs2.bundler.transform.CachePathTransformer +import dev.openrs2.bundler.transform.HostCheckTransformer +import dev.openrs2.bundler.transform.LoadLibraryTransformer +import dev.openrs2.bundler.transform.MacResizeTransformer +import dev.openrs2.bundler.transform.PlatformDetectionTransformer +import dev.openrs2.bundler.transform.PublicKeyTransformer +import dev.openrs2.bundler.transform.RightClickTransformer +import dev.openrs2.bundler.transform.TypoTransformer import dev.openrs2.crypto.CryptoModule object BundlerModule : AbstractModule() { override fun configure() { install(CryptoModule) + + val binder = Multibinder.newSetBinder(binder(), Transformer::class.java, BundlerQualifier::class.java) + binder.addBinding().to(BufferSizeTransformer::class.java) + binder.addBinding().to(CachePathTransformer::class.java) + binder.addBinding().to(HostCheckTransformer::class.java) + binder.addBinding().to(LoadLibraryTransformer::class.java) + binder.addBinding().to(MacResizeTransformer::class.java) + binder.addBinding().to(PlatformDetectionTransformer::class.java) + binder.addBinding().to(PublicKeyTransformer::class.java) + binder.addBinding().to(RightClickTransformer::class.java) + binder.addBinding().to(TypoTransformer::class.java) } } diff --git a/bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt b/bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt new file mode 100644 index 00000000..21baf80d --- /dev/null +++ b/bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt @@ -0,0 +1,8 @@ +package dev.openrs2.bundler + +import javax.inject.Qualifier + +@Qualifier +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) +annotation class BundlerQualifier diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt index 334e86bd..0b3cab7d 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt @@ -12,7 +12,9 @@ import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class BufferSizeTransformer : Transformer() { private var buffer: MemberRef? = null private var buffersResized = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt index d5c81747..42b3e194 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt @@ -7,7 +7,9 @@ import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class CachePathTransformer : Transformer() { private var paths = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt index 3f222595..cec919c3 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt @@ -11,7 +11,9 @@ import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.InsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class HostCheckTransformer : Transformer() { private var hostChecks = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt index 2dc1fa15..bc8d060d 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt @@ -8,7 +8,9 @@ import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class LoadLibraryTransformer : Transformer() { private var jnilibs = 0 private var amd64Checks = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt index 5aa3186b..3f3b089a 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt @@ -12,7 +12,9 @@ import org.objectweb.asm.tree.JumpInsnNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class MacResizeTransformer : Transformer() { private var branchesRemoved = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt index c2ceb5f6..3686eb0a 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt @@ -19,7 +19,9 @@ import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode +import javax.inject.Singleton +@Singleton class PlatformDetectionTransformer : Transformer() { private var glBlocks = 0 private var miscBlocks = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt index 43c993a5..63d82a26 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt @@ -11,7 +11,9 @@ import org.objectweb.asm.tree.InsnList import org.objectweb.asm.tree.InsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class RightClickTransformer : Transformer() { private var metaDownCalls = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt index 7fd2e74b..53d86d29 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt @@ -7,7 +7,9 @@ import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class TypoTransformer : Transformer() { private var errorsFixed = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt b/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt index e8e38c0d..ccae4f3c 100644 --- a/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt +++ b/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt @@ -1,13 +1,15 @@ package dev.openrs2.deob import com.github.ajalt.clikt.core.CliktCommand +import com.google.inject.Guice import java.nio.file.Paths fun main(args: Array) = DeobfuscateCommand().main(args) class DeobfuscateCommand : CliktCommand(name = "deob") { override fun run() { - val deobfuscator = Deobfuscator(Paths.get("nonfree/lib"), Paths.get("nonfree/var/cache/deob")) - deobfuscator.run() + val injector = Guice.createInjector(DeobfuscatorModule) + val deobfuscator = injector.getInstance(Deobfuscator::class.java) + deobfuscator.run(Paths.get("nonfree/lib"), Paths.get("nonfree/var/cache/deob")) } } diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt index 338793bd..50469d96 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt @@ -5,42 +5,19 @@ import dev.openrs2.asm.classpath.ClassPath import dev.openrs2.asm.classpath.Library import dev.openrs2.asm.classpath.Library.Companion.readJar import dev.openrs2.asm.classpath.Library.Companion.readPack -import dev.openrs2.bundler.Bundler -import dev.openrs2.bundler.transform.ResourceTransformer +import dev.openrs2.asm.transform.Transformer import dev.openrs2.deob.SignedClassUtils.move import dev.openrs2.deob.remap.PrefixRemapper.create -import dev.openrs2.deob.transform.BitShiftTransformer -import dev.openrs2.deob.transform.BitwiseOpTransformer -import dev.openrs2.deob.transform.CanvasTransformer -import dev.openrs2.deob.transform.ClassLiteralTransformer -import dev.openrs2.deob.transform.ConstantArgTransformer -import dev.openrs2.deob.transform.CounterTransformer -import dev.openrs2.deob.transform.EmptyClassTransformer -import dev.openrs2.deob.transform.ExceptionTracingTransformer -import dev.openrs2.deob.transform.FernflowerExceptionTransformer -import dev.openrs2.deob.transform.FieldOrderTransformer -import dev.openrs2.deob.transform.FinalTransformer -import dev.openrs2.deob.transform.InvokeSpecialTransformer -import dev.openrs2.deob.transform.MethodOrderTransformer -import dev.openrs2.deob.transform.MonitorTransformer -import dev.openrs2.deob.transform.OpaquePredicateTransformer -import dev.openrs2.deob.transform.OriginalNameTransformer -import dev.openrs2.deob.transform.OriginalPcRestoreTransformer -import dev.openrs2.deob.transform.OriginalPcSaveTransformer -import dev.openrs2.deob.transform.OverrideTransformer -import dev.openrs2.deob.transform.RedundantGotoTransformer -import dev.openrs2.deob.transform.RemapTransformer -import dev.openrs2.deob.transform.ResetTransformer -import dev.openrs2.deob.transform.StaticScramblingTransformer -import dev.openrs2.deob.transform.UnusedArgTransformer -import dev.openrs2.deob.transform.UnusedLocalTransformer -import dev.openrs2.deob.transform.UnusedMethodTransformer -import dev.openrs2.deob.transform.VisibilityTransformer import java.nio.file.Files import java.nio.file.Path - -class Deobfuscator(private val input: Path, private val output: Path) { - fun run() { +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class Deobfuscator @Inject constructor( + @DeobfuscatorQualifier private val transformers: Set<@JvmSuppressWildcards Transformer> +) { + fun run(input: Path, output: Path) { // read input jars/packs logger.info { "Reading input jars" } val unpackClass = readJar(input.resolve("unpackclass.pack")) @@ -102,19 +79,19 @@ class Deobfuscator(private val input: Path, private val output: Path) { // deobfuscate logger.info { "Transforming client" } - for (transformer in TRANSFORMERS) { + for (transformer in transformers) { logger.info { "Running transformer ${transformer.javaClass.simpleName} " } transformer.transform(classPath) } logger.info { "Transforming client_gl" } - for (transformer in TRANSFORMERS) { + for (transformer in transformers) { logger.info { "Running transformer ${transformer.javaClass.simpleName} " } transformer.transform(glClassPath) } logger.info { "Transforming client_unsigned" } - for (transformer in TRANSFORMERS) { + for (transformer in transformers) { logger.info { "Running transformer ${transformer.javaClass.simpleName} " } transformer.transform(unsignedClassPath) } @@ -142,36 +119,5 @@ class Deobfuscator(private val input: Path, private val output: Path) { companion object { private val logger = InlineLogger() - private val TRANSFORMERS = listOf( - OriginalPcSaveTransformer(), - OriginalNameTransformer(), - *Bundler.TRANSFORMERS.toTypedArray(), - ResourceTransformer(), - OpaquePredicateTransformer(), - ExceptionTracingTransformer(), - MonitorTransformer(), - BitShiftTransformer(), - CanvasTransformer(), - FieldOrderTransformer(), - BitwiseOpTransformer(), - RemapTransformer(), - ConstantArgTransformer(), - UnusedLocalTransformer(), - UnusedMethodTransformer(), - UnusedArgTransformer(), - CounterTransformer(), - ResetTransformer(), - ClassLiteralTransformer(), - InvokeSpecialTransformer(), - StaticScramblingTransformer(), - EmptyClassTransformer(), - MethodOrderTransformer(), - VisibilityTransformer(), - FinalTransformer(), - OverrideTransformer(), - RedundantGotoTransformer(), - OriginalPcRestoreTransformer(), - FernflowerExceptionTransformer() - ) } } diff --git a/deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt new file mode 100644 index 00000000..47888190 --- /dev/null +++ b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt @@ -0,0 +1,72 @@ +package dev.openrs2.deob + +import com.google.inject.AbstractModule +import com.google.inject.multibindings.Multibinder +import dev.openrs2.asm.transform.Transformer +import dev.openrs2.bundler.BundlerModule +import dev.openrs2.bundler.transform.ResourceTransformer +import dev.openrs2.deob.transform.BitShiftTransformer +import dev.openrs2.deob.transform.BitwiseOpTransformer +import dev.openrs2.deob.transform.BundlerTransformer +import dev.openrs2.deob.transform.CanvasTransformer +import dev.openrs2.deob.transform.ClassLiteralTransformer +import dev.openrs2.deob.transform.ConstantArgTransformer +import dev.openrs2.deob.transform.CounterTransformer +import dev.openrs2.deob.transform.EmptyClassTransformer +import dev.openrs2.deob.transform.ExceptionTracingTransformer +import dev.openrs2.deob.transform.FernflowerExceptionTransformer +import dev.openrs2.deob.transform.FieldOrderTransformer +import dev.openrs2.deob.transform.FinalTransformer +import dev.openrs2.deob.transform.InvokeSpecialTransformer +import dev.openrs2.deob.transform.MethodOrderTransformer +import dev.openrs2.deob.transform.MonitorTransformer +import dev.openrs2.deob.transform.OpaquePredicateTransformer +import dev.openrs2.deob.transform.OriginalNameTransformer +import dev.openrs2.deob.transform.OriginalPcRestoreTransformer +import dev.openrs2.deob.transform.OriginalPcSaveTransformer +import dev.openrs2.deob.transform.OverrideTransformer +import dev.openrs2.deob.transform.RedundantGotoTransformer +import dev.openrs2.deob.transform.RemapTransformer +import dev.openrs2.deob.transform.ResetTransformer +import dev.openrs2.deob.transform.StaticScramblingTransformer +import dev.openrs2.deob.transform.UnusedArgTransformer +import dev.openrs2.deob.transform.UnusedLocalTransformer +import dev.openrs2.deob.transform.UnusedMethodTransformer +import dev.openrs2.deob.transform.VisibilityTransformer + +object DeobfuscatorModule : AbstractModule() { + override fun configure() { + install(BundlerModule) + + val binder = Multibinder.newSetBinder(binder(), Transformer::class.java, DeobfuscatorQualifier::class.java) + binder.addBinding().to(OriginalPcSaveTransformer::class.java) + binder.addBinding().to(OriginalNameTransformer::class.java) + binder.addBinding().to(BundlerTransformer::class.java) + binder.addBinding().to(ResourceTransformer::class.java) + binder.addBinding().to(OpaquePredicateTransformer::class.java) + binder.addBinding().to(ExceptionTracingTransformer::class.java) + binder.addBinding().to(MonitorTransformer::class.java) + binder.addBinding().to(BitShiftTransformer::class.java) + binder.addBinding().to(CanvasTransformer::class.java) + binder.addBinding().to(FieldOrderTransformer::class.java) + binder.addBinding().to(BitwiseOpTransformer::class.java) + binder.addBinding().to(RemapTransformer::class.java) + binder.addBinding().to(ConstantArgTransformer::class.java) + binder.addBinding().to(UnusedLocalTransformer::class.java) + binder.addBinding().to(UnusedMethodTransformer::class.java) + binder.addBinding().to(UnusedArgTransformer::class.java) + binder.addBinding().to(CounterTransformer::class.java) + binder.addBinding().to(ResetTransformer::class.java) + binder.addBinding().to(ClassLiteralTransformer::class.java) + binder.addBinding().to(InvokeSpecialTransformer::class.java) + binder.addBinding().to(StaticScramblingTransformer::class.java) + binder.addBinding().to(EmptyClassTransformer::class.java) + binder.addBinding().to(MethodOrderTransformer::class.java) + binder.addBinding().to(VisibilityTransformer::class.java) + binder.addBinding().to(FinalTransformer::class.java) + binder.addBinding().to(OverrideTransformer::class.java) + binder.addBinding().to(RedundantGotoTransformer::class.java) + binder.addBinding().to(OriginalPcRestoreTransformer::class.java) + binder.addBinding().to(FernflowerExceptionTransformer::class.java) + } +} diff --git a/deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt new file mode 100644 index 00000000..3823cfe2 --- /dev/null +++ b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt @@ -0,0 +1,8 @@ +package dev.openrs2.deob + +import javax.inject.Qualifier + +@Qualifier +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) +annotation class DeobfuscatorQualifier diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt index 4ff0e26c..6b0b8e87 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt @@ -10,7 +10,9 @@ import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class BitShiftTransformer : Transformer() { private var simplified = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt index ddcbd178..50d6361c 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt @@ -13,7 +13,9 @@ import org.objectweb.asm.tree.InsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode +import javax.inject.Singleton +@Singleton class BitwiseOpTransformer : Transformer() { private val methodOps = mutableMapOf() private var inlinedOps = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt new file mode 100644 index 00000000..4f0a9922 --- /dev/null +++ b/deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt @@ -0,0 +1,24 @@ +package dev.openrs2.deob.transform + +import com.github.michaelbull.logging.InlineLogger +import dev.openrs2.asm.classpath.ClassPath +import dev.openrs2.asm.transform.Transformer +import dev.openrs2.bundler.BundlerQualifier +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class BundlerTransformer @Inject constructor( + @BundlerQualifier private val transformers: Set<@JvmSuppressWildcards Transformer> +) : Transformer() { + override fun transform(classPath: ClassPath) { + for (transformer in transformers) { + logger.info { "Running transformer ${transformer.javaClass.simpleName}" } + transformer.transform(classPath) + } + } + + companion object { + private val logger = InlineLogger() + } +} diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt index f47c6c68..f9685f05 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt @@ -5,7 +5,9 @@ import dev.openrs2.asm.classpath.Library import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode +import javax.inject.Singleton +@Singleton class CanvasTransformer : Transformer() { override fun transformClass( classPath: ClassPath, diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt index b398be6c..1f6b4cf7 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt @@ -15,7 +15,9 @@ import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class ClassLiteralTransformer : Transformer() { private val classForNameMethods = mutableListOf() private var classLiterals = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt index 4c44489d..60f4d061 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt @@ -43,7 +43,9 @@ import org.objectweb.asm.tree.JumpInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.analysis.Analyzer +import javax.inject.Singleton +@Singleton class ConstantArgTransformer : Transformer() { private val pendingMethods = LinkedHashSet() private val arglessMethods = mutableSetOf>() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt index 948834af..b406e620 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt @@ -10,7 +10,9 @@ import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class CounterTransformer : Transformer() { private val counters = mutableSetOf() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt index c8e2cca4..3f1b90f2 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt @@ -11,7 +11,9 @@ import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.TypeInsnNode +import javax.inject.Singleton +@Singleton class EmptyClassTransformer : Transformer() { private var removedClasses = 0 private val emptyClasses = mutableSetOf() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt index d1dd15d6..1a3cd295 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt @@ -8,6 +8,7 @@ import dev.openrs2.asm.nextReal import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton /** * A [Transformer] responsible for removing two kinds of redundant exception @@ -27,6 +28,7 @@ import org.objectweb.asm.tree.MethodNode * and not obfuscation, it is clearly automatically-generated and thus we * remove these exception handlers too. */ +@Singleton class ExceptionTracingTransformer : Transformer() { private var tracingTryCatches = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt index ba09cc26..0dedac23 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt @@ -9,7 +9,9 @@ import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.InsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class FernflowerExceptionTransformer : Transformer() { private var nopsInserted = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt index d7e0d113..56ea8150 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt @@ -8,7 +8,9 @@ import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.FieldNode +import javax.inject.Singleton +@Singleton class FieldOrderTransformer : Transformer() { override fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { sortFields(clazz, CONSTRUCTOR, Opcodes.PUTFIELD) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt index da264f78..b1662aa9 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt @@ -9,7 +9,9 @@ import dev.openrs2.util.collect.DisjointSet import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class FinalTransformer : Transformer() { private val superClasses = mutableListOf() private lateinit var inheritedMethodSets: DisjointSet diff --git a/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt index 194bae90..734cc543 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt @@ -8,6 +8,7 @@ import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton /** * A [Transformer] that replaces `INVOKESPECIAL` instructions in static methods @@ -47,6 +48,7 @@ import org.objectweb.asm.tree.MethodNode * instructions where possible, allowing the [StaticScramblingTransformer] to * produce verifiable output. */ +@Singleton class InvokeSpecialTransformer : Transformer() { private var invokeSpecialsReplaced = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt index d47464b1..23057a9f 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt @@ -6,7 +6,9 @@ import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class MethodOrderTransformer : Transformer() { override fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { clazz.methods.sortWith(STATIC_COMPARATOR.then(INIT_COMPARATOR)) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt index bbe3dfa5..b1d9aac6 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt @@ -15,6 +15,7 @@ import org.objectweb.asm.tree.InsnNode import org.objectweb.asm.tree.JumpInsnNode import org.objectweb.asm.tree.LabelNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton /** * A [Transformer] that rewrites `synchronized` blocks produced by older @@ -41,6 +42,7 @@ import org.objectweb.asm.tree.MethodNode * handler pointing to the same `MONITOREXIT` sequence. Adding this isn't * necessary for Fernflower compatibility. */ +@Singleton class MonitorTransformer : Transformer() { private var subroutinesInlined = 0 private var tryRangesExtended = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt index 38be3c6a..5e64065e 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt @@ -14,7 +14,9 @@ import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.JumpInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode +import javax.inject.Singleton +@Singleton class OpaquePredicateTransformer : Transformer() { private val flowObstructors = mutableSetOf() private var opaquePredicates = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt index 1198b3bd..d5142008 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt @@ -11,7 +11,9 @@ import org.objectweb.asm.tree.AnnotationNode import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class OriginalNameTransformer : Transformer() { override fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { if (clazz.invisibleAnnotations == null) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt index 1ad235fa..7d55f3c1 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt @@ -9,7 +9,9 @@ import dev.openrs2.deob.OriginalPcTable import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.LabelNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class OriginalPcRestoreTransformer : Transformer() { private var originalPcsRestored = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt index a0cb58f9..a7077a3c 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt @@ -6,7 +6,9 @@ import dev.openrs2.asm.classpath.Library import dev.openrs2.asm.transform.Transformer import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class OriginalPcSaveTransformer : Transformer() { override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean { for ((pc, insn) in method.instructions.filter { it.opcode != -1 }.withIndex()) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt index 8780341e..282c2975 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt @@ -10,7 +10,9 @@ import org.objectweb.asm.Type import org.objectweb.asm.tree.AnnotationNode import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class OverrideTransformer : Transformer() { private var overrides = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt index ad104ad7..443215ab 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt @@ -10,7 +10,9 @@ import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.JumpInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class RedundantGotoTransformer : Transformer() { private var removed = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt index 13b82275..8af2b09c 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt @@ -3,7 +3,9 @@ package dev.openrs2.deob.transform import dev.openrs2.asm.classpath.ClassPath import dev.openrs2.asm.transform.Transformer import dev.openrs2.deob.remap.TypedRemapper +import javax.inject.Singleton +@Singleton class RemapTransformer : Transformer() { override fun preTransform(classPath: ClassPath) { classPath.remap(TypedRemapper.create(classPath)) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt index 06c68d84..6cd901d4 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt @@ -16,7 +16,9 @@ import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode +import javax.inject.Singleton +@Singleton class ResetTransformer : Transformer() { private val resetMethods = mutableSetOf() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt index 0e6b5ed8..f1cc073b 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt @@ -18,8 +18,10 @@ import org.objectweb.asm.tree.JumpInsnNode import org.objectweb.asm.tree.LabelNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton import kotlin.math.max +@Singleton class StaticScramblingTransformer : Transformer() { private class FieldSet(val owner: ClassNode, val fields: List, val clinit: MethodNode?) { val dependencies = clinit?.instructions diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt index b25b4762..91ed1637 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt @@ -20,7 +20,9 @@ import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode import org.objectweb.asm.tree.analysis.Analyzer +import javax.inject.Singleton +@Singleton class UnusedArgTransformer : Transformer() { private val retainedArgs = mutableSetOf() private lateinit var inheritedMethodSets: DisjointSet diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt index 897a18e0..eabc92b9 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt @@ -12,7 +12,9 @@ import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode +import javax.inject.Singleton +@Singleton class UnusedLocalTransformer : Transformer() { private var localsRemoved = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt index 098d9d83..20a038d1 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt @@ -14,7 +14,9 @@ import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class UnusedMethodTransformer : Transformer() { private lateinit var inheritedMethodSets: DisjointSet private val methodReferences = HashMultimap.create, MemberRef>() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt index 78debb93..cb6fbb7b 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt @@ -16,7 +16,9 @@ import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode +import javax.inject.Singleton +@Singleton class VisibilityTransformer : Transformer() { private lateinit var inheritedFieldSets: DisjointSet private lateinit var inheritedMethodSets: DisjointSet