From ac5532a65c353b1964d9b7d990341fc7362e510d Mon Sep 17 00:00:00 2001 From: badawoll <129878899+badawoll@users.noreply.github.com> Date: Mon, 8 May 2023 00:08:27 +0000 Subject: [PATCH] feat(messenger): add `disable-switching-emoji-to-sticker-in-message-input-field` patch (#2099) Co-authored-by: oSumAtrIX --- ...itchMessangeInputEmojiButtonFingerprint.kt | 18 +++++++++ ...tchingEmojiToStickerInMessageInputField.kt | 37 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/messenger/inputfield/fingerprints/SwitchMessangeInputEmojiButtonFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/fingerprints/SwitchMessangeInputEmojiButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/fingerprints/SwitchMessangeInputEmojiButtonFingerprint.kt new file mode 100644 index 00000000..ef01e1a5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/fingerprints/SwitchMessangeInputEmojiButtonFingerprint.kt @@ -0,0 +1,18 @@ +package app.revanced.patches.messenger.inputfield.fingerprints + +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import org.jf.dexlib2.Opcode + +object SwitchMessangeInputEmojiButtonFingerprint : MethodFingerprint( + returnType = "V", + parameters = listOf("L", "Z"), + strings = listOf("afterTextChanged", "expression_search"), + opcodes = listOf( + Opcode.IGET_OBJECT, + Opcode.IF_EQZ, + Opcode.CONST_STRING, + Opcode.GOTO, + Opcode.CONST_STRING, + Opcode.GOTO + ) +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt new file mode 100644 index 00000000..3d577a33 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/messenger/inputfield/patch/DisableSwitchingEmojiToStickerInMessageInputField.kt @@ -0,0 +1,37 @@ +package app.revanced.patches.messenger.inputfield.patch + +import app.revanced.extensions.toErrorResult +import app.revanced.patcher.annotation.* +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.instruction +import app.revanced.patcher.extensions.replaceInstruction +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.messenger.inputfield.fingerprints.SwitchMessangeInputEmojiButtonFingerprint +import org.jf.dexlib2.iface.instruction.OneRegisterInstruction + +@Patch +@Name("disable-switching-emoji-to-sticker-in-message-input-field") +@Description("Disables switching from emoji to sticker search mode in message input field") +@Compatibility([Package("com.facebook.orca")]) +@Version("0.0.1") +class DisableSwitchingEmojiToStickerInMessageInputField : BytecodePatch(listOf(SwitchMessangeInputEmojiButtonFingerprint)) { + override fun execute(context: BytecodeContext): PatchResult { + SwitchMessangeInputEmojiButtonFingerprint.result?.let { + val setStringIndex = it.scanResult.patternScanResult!!.startIndex + 2 + + it.mutableMethod.apply { + val targetRegister = instruction(setStringIndex).registerA + + replaceInstruction( + setStringIndex, + "const-string v$targetRegister, \"expression\"" + ) + } + } ?: throw SwitchMessangeInputEmojiButtonFingerprint.toErrorResult() + + return PatchResultSuccess() + } +}