feat(kakaotalk): refactor patch to simplify reply handling for feed messages

This commit is contained in:
2025-05-22 14:40:29 +09:00
parent 46a97d9e14
commit bb05341cdb

View File

@ -4,9 +4,11 @@ import app.revanced.patcher.Fingerprint
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.instructions import app.revanced.patcher.extensions.InstructionExtensions.instructions
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction 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.allowSwipeReplyToFeedFingerprint
import app.revanced.patches.kakaotalk.send.fingerprints.realActionForReplyFingerprint import app.revanced.patches.kakaotalk.send.fingerprints.realActionForReplyFingerprint
import com.android.tools.smali.dexlib2.Opcode 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 import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction21t
@Suppress("unused") @Suppress("unused")
@ -17,11 +19,12 @@ val allowReplyToFeedPatch = app.revanced.patcher.patch.bytecodePatch(
compatibleWith("com.kakao.talk"("25.4.2")) compatibleWith("com.kakao.talk"("25.4.2"))
execute { execute {
val patch: (Fingerprint, String, Boolean) -> Unit = { fp, register, bool -> val patch: (Fingerprint) -> Unit = { fp ->
val method = fp.method val method = fp.method
val insns = method.instructions val insns = method.instructions
val idxIfnez = insns.indexOfFirst { it is Instruction21t && it.opcode == Opcode.IF_NEZ } 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) val idxInvoke = insns.subList(0, idxIfnez)
.indexOfLast { it.opcode == Opcode.INVOKE_VIRTUAL } .indexOfLast { it.opcode == Opcode.INVOKE_VIRTUAL }
@ -30,15 +33,17 @@ val allowReplyToFeedPatch = app.revanced.patcher.patch.bytecodePatch(
.sortedDescending() .sortedDescending()
.forEach { method.removeInstruction(it) } .forEach { method.removeInstruction(it) }
method.addInstructions( method.replaceInstruction(
idxInvoke, idxInvoke,
""" BuilderInstruction11n(
const/4 $register, ${if (bool) "0x1" else "0x0"} Opcode.CONST_4,
""".trimIndent() idxIfnezTarget,
0x0,
)
) )
} }
patch(realActionForReplyFingerprint, "v0", false) patch(realActionForReplyFingerprint)
patch(allowSwipeReplyToFeedFingerprint, "p2", false) patch(allowSwipeReplyToFeedFingerprint)
} }
} }