Signed-off-by: Graham <gpe@openrs2.dev>
@ -13,7 +13,7 @@ class GlobMemberFilter(@Suppress("CanBeParameter") private val patterns: List<Me
return compiledPatterns.any { it.owner.matches(owner) && it.name.matches(name) && it.desc.matches(desc) }
}
companion object {
private companion object {
private fun compile(member: MemberRef): CompiledPattern {
return CompiledPattern(
Glob.compileClass(member.owner),
@ -146,7 +146,7 @@ class Bundler @Inject constructor(
glLoader.write(output.resolve("loader_gl.jar"), SignedJarLibraryWriter(signedManifest, keyStore), glClassPath)
private val logger = InlineLogger()
private val APPLICATION_NAME = Attributes.Name("Application-Name")
@ -58,7 +58,7 @@ class BufferSizeTransformer : Transformer() {
logger.info { "Resized $buffersResized buffers to 65536 bytes" }
private val GPP1_POS_MATCHER = InsnMatcher.compile("LDC (INVOKESPECIAL | INVOKEVIRTUAL) GETSTATIC")
private val NEW_BUFFER_MATCHER = InsnMatcher.compile("NEW DUP (SIPUSH | LDC) INVOKESPECIAL PUTSTATIC")
@ -50,7 +50,7 @@ class CachePathTransformer @Inject constructor(
logger.info { "Updated $paths cache paths" }
@ -45,7 +45,7 @@ class DomainTransformer @Inject constructor(
logger.info { "Replaced $domains domains" }
@ -62,7 +62,7 @@ class HostCheckTransformer : Transformer() {
logger.info { "Removed $hostChecks host checks" }
private val GET_HOST_MATCHER = InsnMatcher.compile("INVOKEVIRTUAL INVOKEVIRTUAL INVOKEVIRTUAL")
@ -41,7 +41,7 @@ class LoadLibraryTransformer : Transformer() {
logger.info { "Replaced $jnilibs jnilibs with dylibs and removed $amd64Checks amd64 jagmisc checks" }
private val AMD64_CHECK_MATCHER =
InsnMatcher.compile("GETSTATIC LDC INVOKEVIRTUAL IFNE GETSTATIC LDC INVOKEVIRTUAL IFNE")
@ -68,7 +68,7 @@ class MacResizeTransformer : Transformer() {
logger.info { "Removed $branchesRemoved branches to macOS-specific resize logic" }
private val DETECT_MAC_MATCHER = InsnMatcher.compile("GETSTATIC LDC INVOKEVIRTUAL (IFEQ | IFNE)")
@ -56,7 +56,7 @@ class MemoryAllocationTransformer : Transformer() {
logger.info { "Zeroed $usedMemoryExprsZeroed used memory expressions" }
private val USED_MEMORY_MATCHER = InsnMatcher.compile("ALOAD INVOKEVIRTUAL ALOAD INVOKEVIRTUAL LSUB")
@ -46,7 +46,7 @@ class NameTransformer @Inject constructor(
logger.info { "Replaced $names operator and game names" }
@ -151,7 +151,7 @@ class PlatformDetectionTransformer : Transformer() {
logger.info { "Replaced $glBlocks jaggl and $miscBlocks jagmisc platform detection blocks" }
private val GL_PLATFORM_DETECTION_MATCHER = InsnMatcher.compile(
"""
@ -46,7 +46,7 @@ class PublicKeyTransformer @Inject constructor(private val key: RSAPrivateCrtKey
logger.info { "Replaced $exponents exponents and $moduli moduli" }
private const val JAGEX_EXPONENT =
"58778699976184461502525193738213253649000149147835990136706041084440742975821"
@ -182,7 +182,7 @@ class ResourceTransformer(
logger.info { "Replaced $glBlocks jaggl and $miscBlocks jagmisc resource constructor blocks" }
private const val RESOURCE_CONSTRUCTOR = """
@ -53,7 +53,7 @@ class RightClickTransformer : Transformer() {
logger.info { "Replaced $metaDownCalls isMetaDown calls with getModifiersEx" }
@ -36,7 +36,7 @@ class TypoTransformer : Transformer() {
logger.info { "Fixed $errorsFixed typographical errors" }
@ -13,7 +13,7 @@ data class Config(
internalOperator = operator.toInternalName()
private val INTERNAL_NAME_REGEX = Regex("(?i)[^a-z0-9]+")
private fun String.toInternalName(): String {
@ -17,7 +17,7 @@ class ConfigProvider @Inject constructor(private val mapper: ObjectMapper) : Pro
private val CONFIG_PATH = Paths.get("etc/config.yaml")
private val EXAMPLE_CONFIG_PATH = Paths.get("etc/config.example.yaml")
@ -16,7 +16,7 @@ class RsaKeyProvider : Provider<RSAPrivateCrtKeyParameters> {
private val PATH = Paths.get("etc/game.key")
@ -31,7 +31,7 @@ class DecompileCommand : CliktCommand(name = "decompile") {
return Paths.get("nonfree").resolve(dir).resolve("src/main/java")
private val JAR_SUFFIX_REGEX = Regex("(?:_gl)?[.]jar$")
@ -23,7 +23,7 @@ class Decompiler(
io.close()
private val OPTIONS = mapOf(
IFernflowerPreferences.INDENT_STRING to "\t",
IFernflowerPreferences.SYNTHETIC_NOT_SET to "1"
@ -75,7 +75,7 @@ class AstDeobfuscator(private val modules: List<Path>) {
private val TRANSFORMERS = listOf(
@ -59,7 +59,7 @@ class BitMaskTransformer : Transformer() {
private val SHIFT_OPS = setOf(
BinaryExpr.Operator.SIGNED_RIGHT_SHIFT,
BinaryExpr.Operator.UNSIGNED_RIGHT_SHIFT
@ -31,7 +31,7 @@ class ComplementTransformer : Transformer() {
private fun Expression.isComplement(): Boolean {
return isUnaryExpr && asUnaryExpr().operator == UnaryExpr.Operator.BITWISE_COMPLEMENT
@ -124,7 +124,7 @@ class EncloseTransformer : Transformer() {
private fun encloseLeft(parent: Expression, child: Expression) {
val parentOp = Op.from(parent) ?: throw IllegalArgumentException()
val childOp = Op.from(child) ?: return
@ -306,7 +306,7 @@ class GlTransformer(private val registry: GlRegistry = GlRegistry.parse()) : Tra
private const val GL_METHOD_PREFIX = "gl"
private const val GL_CLASS_UNQUALIFIED = "GL"
@ -22,7 +22,7 @@ class NewInstanceTransformer : Transformer() {
private val CONSTRUCTOR_METHODS = setOf("getConstructor", "getDeclaredConstructor")
@ -25,7 +25,7 @@ class NameMapProvider @Inject constructor(private val mapper: ObjectMapper) : Pr
return Files.isRegularFile(path) && path.fileName.toString().endsWith(YAML_SUFFIX)
private val PATH = Paths.get("share/deob/map")
private const val YAML_SUFFIX = ".yaml"
@ -120,7 +120,7 @@ class Deobfuscator @Inject constructor(
unsignedClient.write(output.resolve("runescape_unsigned.jar"), JarLibraryWriter, unsignedClassPath)
@ -145,7 +145,7 @@ class IntInterpreter(private val args: Array<IntValueSet>) : Interpreter<IntValu
private const val MAX_TRACKED_VALUES = 1
@ -47,7 +47,7 @@ class BitShiftTransformer : Transformer() {
logger.info { "Simplified $simplified bit shifts" }
private val CONST_SHIFT_MATCHER =
InsnMatcher.compile("(ICONST | BIPUSH | SIPUSH | LDC) (ISHL | ISHR | IUSHR | LSHL | LSHR | LUSHR)")
@ -81,7 +81,7 @@ class BitwiseOpTransformer : Transformer() {
logger.info { "Inlined $inlinedOps bitwise ops and removed ${methodOps.size} redundant methods" }
private val BITWISE_OP_MATCHER = InsnMatcher.compile("^ILOAD ILOAD (IXOR | IAND | IOR) IRETURN$")
private const val BITWISE_OP_DESC = "(II)I"
@ -18,7 +18,7 @@ class BundlerTransformer @Inject constructor(
@ -110,7 +110,7 @@ class ClassLiteralTransformer : Transformer() {
logger.info { "Updated $classLiterals class literals to Java 5 style" }
private val CLASS_FOR_NAME_MATCHER = InsnMatcher.compile(
@ -307,7 +307,7 @@ class ConstantArgTransformer @Inject constructor(private val profile: Profile) :
logger.info { "Simplified $branchesSimplified branches and inlined $constantsInlined constants" }
@ -113,7 +113,7 @@ class CounterTransformer : Transformer() {
logger.info { "Removed ${counters.size} counters" }
private val RESET_PATTERN = InsnMatcher.compile("ICONST_0 PUTSTATIC")
private val INCREMENT_PATTERN = InsnMatcher.compile("GETSTATIC ICONST_1 IADD PUTSTATIC")
@ -102,7 +102,7 @@ class EmptyClassTransformer : Transformer() {
logger.info { "Removed $removedClasses unused classes" }
@ -59,7 +59,7 @@ class ExceptionTracingTransformer : Transformer() {
logger.info { "Removed $tracingTryCatches tracing try/catch blocks" }
private val CATCH_MATCHER = InsnMatcher.compile(
@ -18,7 +18,7 @@ class FieldOrderTransformer : Transformer() {
return false
private const val CONSTRUCTOR = "<init>"
private const val STATIC_CONSTRUCTOR = "<clinit>"
private val STATIC_COMPARATOR = Comparator<FieldNode> { a, b ->
@ -113,7 +113,7 @@ class FinalTransformer : Transformer() {
logger.info { "Updated final modifier on $classesChanged classes and $methodsChanged methods" }
@ -86,7 +86,7 @@ class InvokeSpecialTransformer : Transformer() {
logger.info { "Replaced $invokeSpecialsReplaced INVOKESPECIALs with INVOKEVIRTUAL" }
@ -15,7 +15,7 @@ class MethodOrderTransformer : Transformer() {
private val STATIC_COMPARATOR = Comparator<MethodNode> { a, b ->
val aStatic = a.access and Opcodes.ACC_STATIC != 0
val bStatic = b.access and Opcodes.ACC_STATIC != 0
@ -131,7 +131,7 @@ class MonitorTransformer : Transformer() {
logger.info { "Replaced $loadsReplaced ASTORE ALOAD sequences with DUP ASTORE" }
// these regexes rely on JSRInlinerAdapter running first
@ -115,7 +115,7 @@ class OpaquePredicateTransformer : Transformer() {
logger.info { "Removed $opaquePredicates opaque predicates and $stores redundant stores" }
private val FLOW_OBSTRUCTOR_INITIALIZER_MATCHER = InsnMatcher.compile(
@ -67,7 +67,7 @@ class OriginalNameTransformer : Transformer() {
private fun createOriginalClassAnnotation(name: String): AnnotationNode {
val annotation = AnnotationNode(Type.getDescriptor(OriginalClass::class.java))
annotation.values = listOf("value", name)
@ -51,7 +51,7 @@ class OriginalPcRestoreTransformer : Transformer() {
logger.info { "Restored $originalPcsRestored original instruction indexes" }
@ -22,7 +22,7 @@ class OriginalPcSaveTransformer : Transformer() {
logger.info { "Saved ${classPath.originalPcs.size} original instruction indexes" }
@ -51,7 +51,7 @@ class OverrideTransformer : Transformer() {
logger.info { "Added $overrides override annotations" }
private val OVERRIDE_DESC: String = Type.getDescriptor(Override::class.java)
@ -59,7 +59,7 @@ class ResetTransformer : Transformer() {
logger.info { "Removed ${resetMethods.size} reset methods" }
private fun findMasterReset(method: MethodNode): MemberRef? {
@ -213,7 +213,7 @@ class StaticScramblingTransformer @Inject constructor(private val profile: Profi
logger.info { "Moved ${fieldClasses.size} fields and ${methodClasses.size} methods" }
private const val MAX_FIELDS = 500
private const val MAX_METHODS = 50
@ -171,7 +171,7 @@ class UnusedArgTransformer @Inject constructor(private val profile: Profile) : T
logger.info { "Removed $deletedArgs unused arguments" }
private val INT_SORTS = setOf(
Type.BOOLEAN,
@ -54,7 +54,7 @@ class UnusedLocalTransformer : Transformer() {
logger.info { "Removed $localsRemoved unused local variables" }
@ -154,7 +154,7 @@ class VisibilityTransformer @Inject constructor(private val profile: Profile) :
private const val VISIBILITY_FLAGS = Opcodes.ACC_PUBLIC or Opcodes.ACC_PROTECTED or Opcodes.ACC_PRIVATE
@ -22,7 +22,7 @@ class DeterministicJarOutputStream : JarOutputStream {
super.putNextEntry(ze)
private val UNIX_EPOCH = FileTime.fromMillis(0)