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 <gpe@openrs2.dev>
Graham 5 years ago
parent 9db64efb7b
commit fa2f9cd33d
  1. 1
      deob/src/main/java/dev/openrs2/deob/Profile.kt
  2. 4
      deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt
  3. 4
      deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt
  4. 2
      deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt
  5. 2
      share/deob/profile.yaml

@ -8,5 +8,6 @@ class Profile(
val excludedMethods: GlobMemberFilter, val excludedMethods: GlobMemberFilter,
val excludedFields: GlobMemberFilter, val excludedFields: GlobMemberFilter,
val entryPoints: GlobMemberFilter, val entryPoints: GlobMemberFilter,
val scrambledLibraries: Set<String>,
val maxObfuscatedNameLen: Int val maxObfuscatedNameLen: Int
) )

@ -16,6 +16,7 @@ import org.objectweb.asm.tree.MethodNode
class StaticFieldUnscrambler( class StaticFieldUnscrambler(
private val classPath: ClassPath, private val classPath: ClassPath,
private val excludedFields: MemberFilter, private val excludedFields: MemberFilter,
private val scrambledLibraries: Set<String>,
private val nameMap: NameMap, private val nameMap: NameMap,
private val inheritedFieldSets: DisjointSet<MemberRef>, private val inheritedFieldSets: DisjointSet<MemberRef>,
staticClassNameGenerator: NameGenerator staticClassNameGenerator: NameGenerator
@ -26,8 +27,7 @@ class StaticFieldUnscrambler(
val fields = mutableMapOf<DisjointSet.Partition<MemberRef>, StaticField>() val fields = mutableMapOf<DisjointSet.Partition<MemberRef>, StaticField>()
for (library in classPath.libraries) { for (library in classPath.libraries) {
if ("client" !in library) { if (library.name !in scrambledLibraries) {
// TODO(gpe): improve detection of the client library
continue continue
} }

@ -10,6 +10,7 @@ import org.objectweb.asm.Opcodes
class StaticMethodUnscrambler( class StaticMethodUnscrambler(
private val classPath: ClassPath, private val classPath: ClassPath,
private val excludedMethods: MemberFilter, private val excludedMethods: MemberFilter,
private val scrambledLibraries: Set<String>,
private val nameMap: NameMap, private val nameMap: NameMap,
private val inheritedMethodSets: DisjointSet<MemberRef>, private val inheritedMethodSets: DisjointSet<MemberRef>,
staticClassNameGenerator: NameGenerator staticClassNameGenerator: NameGenerator
@ -20,8 +21,7 @@ class StaticMethodUnscrambler(
val owners = mutableMapOf<DisjointSet.Partition<MemberRef>, String>() val owners = mutableMapOf<DisjointSet.Partition<MemberRef>, String>()
for (library in classPath.libraries) { for (library in classPath.libraries) {
if ("client" !in library) { if (library.name !in scrambledLibraries) {
// TODO(gpe): improve detection of the client library
continue continue
} }

@ -88,6 +88,7 @@ class TypedRemapper private constructor(
val staticFields = StaticFieldUnscrambler( val staticFields = StaticFieldUnscrambler(
classPath, classPath,
profile.excludedFields, profile.excludedFields,
profile.scrambledLibraries,
nameMap, nameMap,
inheritedFieldSets, inheritedFieldSets,
staticClassNameGenerator staticClassNameGenerator
@ -95,6 +96,7 @@ class TypedRemapper private constructor(
val staticMethods = StaticMethodUnscrambler( val staticMethods = StaticMethodUnscrambler(
classPath, classPath,
profile.excludedMethods, profile.excludedMethods,
profile.scrambledLibraries,
nameMap, nameMap,
inheritedMethodSets, inheritedMethodSets,
staticClassNameGenerator staticClassNameGenerator

@ -31,4 +31,6 @@ entry_points:
- "com/sun/opengl/impl/x11/DRIHack.end *" - "com/sun/opengl/impl/x11/DRIHack.end *"
- "loader.<init> *" - "loader.<init> *"
- "unpackclass.<init> *" - "unpackclass.<init> *"
scrambled_libraries:
- client
max_obfuscated_name_len: 2 max_obfuscated_name_len: 2

Loading…
Cancel
Save