From fa2f9cd33dbe69cdcd3c931157f2a7633937a6e9 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 7 Jun 2020 15:23:58 +0100 Subject: [PATCH] Add scrambledLibraries set to the deobfuscator profile This allows us to improve the code used for detecting the client library in the static member scrambling code. Signed-off-by: Graham --- deob/src/main/java/dev/openrs2/deob/Profile.kt | 1 + .../java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt | 4 ++-- .../java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt | 4 ++-- deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt | 2 ++ share/deob/profile.yaml | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/deob/src/main/java/dev/openrs2/deob/Profile.kt b/deob/src/main/java/dev/openrs2/deob/Profile.kt index 4409ee0f3b..c0946f67b8 100644 --- a/deob/src/main/java/dev/openrs2/deob/Profile.kt +++ b/deob/src/main/java/dev/openrs2/deob/Profile.kt @@ -8,5 +8,6 @@ class Profile( val excludedMethods: GlobMemberFilter, val excludedFields: GlobMemberFilter, val entryPoints: GlobMemberFilter, + val scrambledLibraries: Set, val maxObfuscatedNameLen: Int ) diff --git a/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt b/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt index 2299629be9..9ef452f5cc 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt @@ -16,6 +16,7 @@ import org.objectweb.asm.tree.MethodNode class StaticFieldUnscrambler( private val classPath: ClassPath, private val excludedFields: MemberFilter, + private val scrambledLibraries: Set, private val nameMap: NameMap, private val inheritedFieldSets: DisjointSet, staticClassNameGenerator: NameGenerator @@ -26,8 +27,7 @@ class StaticFieldUnscrambler( val fields = mutableMapOf, StaticField>() for (library in classPath.libraries) { - if ("client" !in library) { - // TODO(gpe): improve detection of the client library + if (library.name !in scrambledLibraries) { continue } diff --git a/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt b/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt index 60a2225bdf..b8ff6e4dc2 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt @@ -10,6 +10,7 @@ import org.objectweb.asm.Opcodes class StaticMethodUnscrambler( private val classPath: ClassPath, private val excludedMethods: MemberFilter, + private val scrambledLibraries: Set, private val nameMap: NameMap, private val inheritedMethodSets: DisjointSet, staticClassNameGenerator: NameGenerator @@ -20,8 +21,7 @@ class StaticMethodUnscrambler( val owners = mutableMapOf, String>() for (library in classPath.libraries) { - if ("client" !in library) { - // TODO(gpe): improve detection of the client library + if (library.name !in scrambledLibraries) { continue } diff --git a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt index a5d883b0fc..3630a03f1f 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt @@ -88,6 +88,7 @@ class TypedRemapper private constructor( val staticFields = StaticFieldUnscrambler( classPath, profile.excludedFields, + profile.scrambledLibraries, nameMap, inheritedFieldSets, staticClassNameGenerator @@ -95,6 +96,7 @@ class TypedRemapper private constructor( val staticMethods = StaticMethodUnscrambler( classPath, profile.excludedMethods, + profile.scrambledLibraries, nameMap, inheritedMethodSets, staticClassNameGenerator diff --git a/share/deob/profile.yaml b/share/deob/profile.yaml index 619df28855..9304431ebe 100644 --- a/share/deob/profile.yaml +++ b/share/deob/profile.yaml @@ -31,4 +31,6 @@ entry_points: - "com/sun/opengl/impl/x11/DRIHack.end *" - "loader. *" - "unpackclass. *" +scrambled_libraries: + - client max_obfuscated_name_len: 2