feat(kakaotalk): refactor patch to simplify reply handling for feed messages
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user