diff --git a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/chatlog/ShowDeletedOrHiddenMessagePatch.kt b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/chatlog/ShowDeletedOrHiddenMessagePatch.kt index ee3a2c038..96292d2a5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/kakaotalk/chatlog/ShowDeletedOrHiddenMessagePatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/kakaotalk/chatlog/ShowDeletedOrHiddenMessagePatch.kt @@ -1,11 +1,13 @@ package app.revanced.patches.kakaotalk.chatlog -import app.revanced.patcher.extensions.InstructionExtensions.addInstructions +import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.instructions import app.revanced.patcher.patch.bytecodePatch +import app.revanced.patches.kakaotalk.chatlog.fingerprints.chatLogFingerprint import app.revanced.patches.kakaotalk.chatlog.fingerprints.createChatLogViewHolderFromRealFingerprint import app.revanced.util.getReference import com.android.tools.smali.dexlib2.Opcode +import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c import com.android.tools.smali.dexlib2.iface.reference.MethodReference @@ -21,31 +23,49 @@ val showDeletedOrHiddenMessagePatch = bytecodePatch( val method = createChatLogViewHolderFromRealFingerprint.method val insns = method.instructions - val modifyInst = insns + val chatLogClass = chatLogFingerprint.classDef + + println("ChatLog class: ${chatLogClass.type}") + + val dateInst = insns .filterIsInstance() .filter { it.opcode == Opcode.INVOKE_VIRTUAL } .find { - it.getReference()?.name == "setModify" + it.getReference()?.name == "setDate" } - val modifyIndex = insns.indexOf(modifyInst ?: return@execute) + val dateIndex = insns.indexOf(dateInst ?: return@execute) - println("Modify index: $modifyIndex") + val chatLogRegister = insns + .filterIsInstance() + .filter { it.opcode == Opcode.CHECK_CAST } + .find { + it.reference == chatLogClass + }?.registerA ?: error("ChatLog class ${chatLogClass.type} not found") - method.addInstructions( - modifyIndex, + println(chatLogRegister) + + println("Date index: $dateIndex") + + method.addInstructionsWithLabels( + dateIndex + 1, """ + invoke-virtual/range {p0 .. p0}, LOe/f2;->u0()LKe/S; + move-result-object v12 + instance-of v13, v12, ${chatLogClass.type} + if-eqz v13, :is_not_chat_log + check-cast v12, ${chatLogClass.type} + goto :fuck + :is_not_chat_log const/4 v12, 0x0 - if-eqz v14, :skip_get_deleted_flag - iget-boolean v12, v14, LXo/c;->isRealDeleted:Z - :skip_get_deleted_flag - invoke-virtual {v4, v12}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setDeleted(Z)V + :fuck + nop - const/4 v12, 0x0 - if-eqz v14, :skip_get_hidden_flag - iget-boolean v12, v14, LXo/c;->isHidden:Z - :skip_get_hidden_flag - invoke-virtual {v4, v12}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setHidden(Z)V - """.trimIndent() + iget-boolean v10, v12, ${chatLogClass.type}->isRealDeleted:Z + invoke-virtual {v4, v10}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setDeleted(Z)V + + iget-boolean v10, v12, ${chatLogClass.type}->isHidden:Z + invoke-virtual {v4, v10}, Lcom/kakao/talk/widget/chatlog/ChatInfoView;->setHidden(Z)V + """.trimIndent(), ) } } \ No newline at end of file