From bb05341cdb5732a21b183b6eb3b0376fe15a1083 Mon Sep 17 00:00:00 2001 From: naijun0403 Date: Thu, 22 May 2025 14:40:29 +0900 Subject: [PATCH] feat(kakaotalk): refactor patch to simplify reply handling for feed messages --- .../kakaotalk/send/AllowReplyToFeedPatch.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/send/AllowReplyToFeedPatch.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/send/AllowReplyToFeedPatch.kt index 7d04db0f4..0292032d0 100644 --- a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/send/AllowReplyToFeedPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/send/AllowReplyToFeedPatch.kt @@ -4,9 +4,11 @@ import app.revanced.patcher.Fingerprint import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.instructions import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction +import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction import app.revanced.patches.kakaotalk.send.fingerprints.allowSwipeReplyToFeedFingerprint import app.revanced.patches.kakaotalk.send.fingerprints.realActionForReplyFingerprint import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction11n import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21t @Suppress("unused") @@ -17,11 +19,12 @@ val allowReplyToFeedPatch = app.revanced.patcher.patch.bytecodePatch( compatibleWith("com.kakao.talk"("25.4.2")) execute { - val patch: (Fingerprint, String, Boolean) -> Unit = { fp, register, bool -> + val patch: (Fingerprint) -> Unit = { fp -> val method = fp.method val insns = method.instructions val idxIfnez = insns.indexOfFirst { it is Instruction21t && it.opcode == Opcode.IF_NEZ } + val idxIfnezTarget = (insns[idxIfnez] as Instruction21t).registerA val idxInvoke = insns.subList(0, idxIfnez) .indexOfLast { it.opcode == Opcode.INVOKE_VIRTUAL } @@ -30,15 +33,17 @@ val allowReplyToFeedPatch = app.revanced.patcher.patch.bytecodePatch( .sortedDescending() .forEach { method.removeInstruction(it) } - method.addInstructions( + method.replaceInstruction( idxInvoke, - """ - const/4 $register, ${if (bool) "0x1" else "0x0"} - """.trimIndent() + BuilderInstruction11n( + Opcode.CONST_4, + idxIfnezTarget, + 0x0, + ) ) } - patch(realActionForReplyFingerprint, "v0", false) - patch(allowSwipeReplyToFeedFingerprint, "p2", false) + patch(realActionForReplyFingerprint) + patch(allowSwipeReplyToFeedFingerprint) } } \ No newline at end of file