Exclude browser control class from static scrambling

I suspect it is excluded on Jagex's end so the client deals correctly
with any class loading failures caused by the absence of the
netscape.javascript.JSObject class.

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 5 years ago
parent 3db6b2c381
commit 57800cb03e
  1. 61
      deob/src/main/java/dev/openrs2/deob/filter/BrowserControlFilter.kt
  2. 2
      deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt
  3. 2
      deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt
  4. 8
      deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt

@ -0,0 +1,61 @@
package dev.openrs2.deob.filter
import com.github.michaelbull.logging.InlineLogger
import dev.openrs2.asm.classpath.ClassPath
import dev.openrs2.asm.filter.AnyMemberFilter
import dev.openrs2.asm.filter.MemberFilter
import dev.openrs2.asm.hasCode
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.MethodInsnNode
class BrowserControlFilter private constructor(private val clazz: String) : MemberFilter {
override fun matches(owner: String, name: String, desc: String): Boolean {
return clazz == owner
}
companion object {
private val logger = InlineLogger()
fun create(classPath: ClassPath): MemberFilter {
val browserControlClass = findBrowserControlClass(classPath)
return if (browserControlClass != null) {
logger.info { "Identified browser control class $browserControlClass" }
BrowserControlFilter(browserControlClass)
} else {
logger.warn { "Failed to identify browser control class" }
AnyMemberFilter
}
}
private fun findBrowserControlClass(classPath: ClassPath): String? {
for (library in classPath.libraries) {
for (clazz in library) {
if (isBrowserControlClass(clazz)) {
return clazz.name
}
}
}
return null
}
private fun isBrowserControlClass(clazz: ClassNode): Boolean {
for (method in clazz.methods) {
if (!method.hasCode) {
continue
}
for (insn in method.instructions) {
if (insn !is MethodInsnNode) {
continue
} else if (insn.owner == "netscape/javascript/JSObject") {
return true
}
}
}
return false
}
}
}

@ -32,8 +32,6 @@ class StaticFieldUnscrambler(
}
for (clazz in library) {
// TODO(gpe): exclude the JSObject class
val clinit = clazz.methods.find { it.name == "<clinit>" }
val (simpleInitializers, complexInitializers) = clinit?.extractInitializers(clazz.name)
?: Pair(emptyMap(), emptySet())

@ -26,8 +26,6 @@ class StaticMethodUnscrambler(
}
for (clazz in library) {
// TODO(gpe): exclude the JSObject class
for (method in clazz.methods) {
if (method.access and Opcodes.ACC_STATIC == 0) {
continue

@ -4,7 +4,9 @@ import com.github.michaelbull.logging.InlineLogger
import dev.openrs2.asm.MemberRef
import dev.openrs2.asm.classpath.ClassPath
import dev.openrs2.asm.classpath.ExtendedRemapper
import dev.openrs2.asm.filter.UnionMemberFilter
import dev.openrs2.deob.Profile
import dev.openrs2.deob.filter.BrowserControlFilter
import dev.openrs2.deob.map.NameMap
import dev.openrs2.util.collect.DisjointSet
import org.objectweb.asm.tree.AbstractInsnNode
@ -84,10 +86,12 @@ class TypedRemapper private constructor(
verifyMemberMapping(fields, profile.maxObfuscatedNameLen)
verifyMemberMapping(methods, profile.maxObfuscatedNameLen)
val browserControlFilter = BrowserControlFilter.create(classPath)
val staticClassNameGenerator = NameGenerator()
val staticFields = StaticFieldUnscrambler(
classPath,
profile.excludedFields,
UnionMemberFilter(profile.excludedFields, browserControlFilter),
profile.scrambledLibraries,
nameMap,
inheritedFieldSets,
@ -95,7 +99,7 @@ class TypedRemapper private constructor(
).unscramble()
val staticMethods = StaticMethodUnscrambler(
classPath,
profile.excludedMethods,
UnionMemberFilter(profile.excludedMethods, browserControlFilter),
profile.scrambledLibraries,
nameMap,
inheritedMethodSets,

Loading…
Cancel
Save