Make enabled transformers and their order configurable in profile

Signed-off-by: Graham <gpe@openrs2.org>
Graham 10 months ago
parent d38ca044ec
commit e6f7a40f6e
  1. 2
      asm/src/main/kotlin/org/openrs2/asm/transform/Transformer.kt
  2. 10
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/BytecodeDeobfuscator.kt
  3. 46
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/BytecodeDeobfuscatorModule.kt
  4. 3
      deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/Profile.kt
  5. 34
      share/deob/profile.yaml

@ -8,6 +8,8 @@ import org.openrs2.asm.classpath.Library
import org.openrs2.asm.hasCode
public abstract class Transformer {
public val name: String = javaClass.simpleName.removeSuffix("Transformer")
public open fun transform(classPath: ClassPath) {
preTransform(classPath)

@ -16,9 +16,17 @@ import java.nio.file.Path
@Singleton
public class BytecodeDeobfuscator @Inject constructor(
@DeobfuscatorQualifier private val transformers: Set<Transformer>
@DeobfuscatorQualifier private val allTransformers: Set<Transformer>,
private val profile: Profile,
) {
private val allTransformersByName = allTransformers.associateBy(Transformer::name)
public fun run(input: Path, output: Path) {
// read list of enabled transformers and their order from the profile
val transformers = profile.transformers.map { name ->
allTransformersByName[name] ?: throw IllegalArgumentException("Unknown transformer $name")
}
// read input jars/packs
logger.info { "Reading input jars" }
val client = Library.read("client", input.resolve("runescape_gl.pack200"), Pack200LibraryReader)

@ -50,38 +50,38 @@ public object BytecodeDeobfuscatorModule : AbstractModule() {
.`in`(Scopes.SINGLETON)
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(ClassLiteralTransformer::class.java)
binder.addBinding().to(InvokeSpecialTransformer::class.java)
binder.addBinding().to(MultipleAssignmentTransformer::class.java)
binder.addBinding().to(RemapTransformer::class.java)
binder.addBinding().to(PatcherTransformer::class.java)
binder.addBinding().to(ResourceTransformer::class.java)
binder.addBinding().to(OpaquePredicateTransformer::class.java)
binder.addBinding().to(ExceptionObfuscationTransformer::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(CanvasTransformer::class.java)
binder.addBinding().to(ClassLiteralTransformer::class.java)
binder.addBinding().to(ConstantArgTransformer::class.java)
binder.addBinding().to(CopyPropagationTransformer::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(EmptyClassTransformer::class.java)
binder.addBinding().to(MethodOrderTransformer::class.java)
binder.addBinding().to(VisibilityTransformer::class.java)
binder.addBinding().to(ExceptionObfuscationTransformer::class.java)
binder.addBinding().to(ExceptionTracingTransformer::class.java)
binder.addBinding().to(FernflowerExceptionTransformer::class.java)
binder.addBinding().to(FieldOrderTransformer::class.java)
binder.addBinding().to(FinalClassTransformer::class.java)
binder.addBinding().to(FinalMethodTransformer::class.java)
binder.addBinding().to(FinalFieldTransformer::class.java)
binder.addBinding().to(FinalMethodTransformer::class.java)
binder.addBinding().to(InvokeSpecialTransformer::class.java)
binder.addBinding().to(MethodOrderTransformer::class.java)
binder.addBinding().to(MonitorTransformer::class.java)
binder.addBinding().to(MultipleAssignmentTransformer::class.java)
binder.addBinding().to(OpaquePredicateTransformer::class.java)
binder.addBinding().to(OriginalNameTransformer::class.java)
binder.addBinding().to(OriginalPcRestoreTransformer::class.java)
binder.addBinding().to(OriginalPcSaveTransformer::class.java)
binder.addBinding().to(OverrideTransformer::class.java)
binder.addBinding().to(PatcherTransformer::class.java)
binder.addBinding().to(RedundantGotoTransformer::class.java)
binder.addBinding().to(OriginalPcRestoreTransformer::class.java)
binder.addBinding().to(FernflowerExceptionTransformer::class.java)
binder.addBinding().to(RemapTransformer::class.java)
binder.addBinding().to(ResetTransformer::class.java)
binder.addBinding().to(ResourceTransformer::class.java)
binder.addBinding().to(UnusedArgTransformer::class.java)
binder.addBinding().to(UnusedLocalTransformer::class.java)
binder.addBinding().to(UnusedMethodTransformer::class.java)
binder.addBinding().to(VisibilityTransformer::class.java)
}
}

@ -9,5 +9,6 @@ public class Profile(
public val excludedFields: GlobMemberFilter,
public val entryPoints: GlobMemberFilter,
public val scrambledLibraries: Set<String>,
public val maxObfuscatedNameLen: Int
public val maxObfuscatedNameLen: Int,
public val transformers: List<String>
)

@ -35,3 +35,37 @@ entry_points:
scrambled_libraries:
- client
max_obfuscated_name_len: 2
transformers:
- OriginalPcSave
- OriginalName
- ClassLiteral
- InvokeSpecial
- MultipleAssignment
- Remap
- Patcher
- Resource
- OpaquePredicate
- ExceptionObfuscation
- ExceptionTracing
- Monitor
- BitShift
- Canvas
- FieldOrder
- BitwiseOp
- ConstantArg
- CopyPropagation
- UnusedLocal
- UnusedMethod
- UnusedArg
- Counter
- Reset
- EmptyClass
- MethodOrder
- Visibility
- FinalClass
- FinalMethod
- FinalField
- Override
- RedundantGoto
- OriginalPcRestore
- FernflowerException

Loading…
Cancel
Save