forked from openrs2/openrs2
Some static members are not scrambled in the client. Maintaining a one-to-one mapping between instanced and static classes makes refactoring easier in these cases. The browser control filter is removed as we now get the same functionality for free. Signed-off-by: Graham <gpe@openrs2.org>
parent
e08f355e6f
commit
ac9b132937
@ -1,61 +0,0 @@ |
|||||||
package org.openrs2.deob.filter |
|
||||||
|
|
||||||
import com.github.michaelbull.logging.InlineLogger |
|
||||||
import org.objectweb.asm.tree.ClassNode |
|
||||||
import org.objectweb.asm.tree.MethodInsnNode |
|
||||||
import org.openrs2.asm.classpath.ClassPath |
|
||||||
import org.openrs2.asm.filter.AnyMemberFilter |
|
||||||
import org.openrs2.asm.filter.MemberFilter |
|
||||||
import org.openrs2.asm.hasCode |
|
||||||
|
|
||||||
public class BrowserControlFilter private constructor(private val clazz: String) : MemberFilter { |
|
||||||
override fun matches(owner: String, name: String, desc: String): Boolean { |
|
||||||
return clazz == owner |
|
||||||
} |
|
||||||
|
|
||||||
public companion object { |
|
||||||
private val logger = InlineLogger() |
|
||||||
|
|
||||||
public 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 |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,20 +0,0 @@ |
|||||||
package org.openrs2.deob.remap |
|
||||||
|
|
||||||
public class StaticClassGenerator(private val generator: NameGenerator, private val maxMembers: Int) { |
|
||||||
private var lastClass: String? = null |
|
||||||
private var members = 0 |
|
||||||
|
|
||||||
public fun generate(): String { |
|
||||||
var clazz = lastClass |
|
||||||
|
|
||||||
if (clazz == null || members >= maxMembers) { |
|
||||||
clazz = generator.generate("Static") |
|
||||||
lastClass = clazz |
|
||||||
members = 1 |
|
||||||
} else { |
|
||||||
members++ |
|
||||||
} |
|
||||||
|
|
||||||
return clazz |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,10 @@ |
|||||||
|
package org.openrs2.deob.remap |
||||||
|
|
||||||
|
public class StaticClassMapping { |
||||||
|
private val nameGenerator = NameGenerator() |
||||||
|
private val mapping = mutableMapOf<String, String>() |
||||||
|
|
||||||
|
public operator fun get(name: String): String { |
||||||
|
return mapping.computeIfAbsent(name) { nameGenerator.generate("Static") } |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue