diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/common/fingerprints/KotlinUnitInstanceFingerprint.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/common/fingerprints/KotlinUnitInstanceFingerprint.kt new file mode 100644 index 000000000..f1c381942 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/common/fingerprints/KotlinUnitInstanceFingerprint.kt @@ -0,0 +1,19 @@ +package app.revanced.patches.kakaotalk.common.fingerprints + +import app.revanced.patcher.fingerprint +import com.android.tools.smali.dexlib2.AccessFlags +import com.android.tools.smali.dexlib2.Opcode + +internal val kotlinUnitInstanceFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + parameters() + returns("Ljava/lang/String;") + strings("kotlin.Unit") + opcodes( + Opcode.CONST_STRING, + Opcode.RETURN_OBJECT + ) + custom { method, classDef -> + method.name == "toString" + } +} \ No newline at end of file diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/ghost/GhostModePatch.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/ghost/GhostModePatch.kt index 4edad69f2..a8ee5793a 100644 --- a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/ghost/GhostModePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/ghost/GhostModePatch.kt @@ -2,6 +2,7 @@ package app.revanced.patches.kakaotalk.ghost import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.kakaotalk.common.fingerprints.kotlinUnitInstanceFingerprint import app.revanced.patches.kakaotalk.ghost.fingerprints.ghostModeFingerprint @Suppress("unused") @@ -12,12 +13,17 @@ val ghostMode = bytecodePatch( compatibleWith("com.kakao.talk"("25.4.0")) execute { + val findUnit = kotlinUnitInstanceFingerprint.method + val unitClass = findUnit.definingClass + val method = ghostModeFingerprint.method + // I tried to find the field name, but it's pretty obvious to me, so I hardcode it. + // If it changes, we need to fix it method.addInstructions( 0, """ - sget-object v0, Lnk0/C;->a:Lnk0/C; + sget-object v0, $unitClass->a:$unitClass; return-object v0 """.trimIndent() )