Skip to content

Commit

Permalink
Merge pull request #20 from Swakshan/dev
Browse files Browse the repository at this point in the history
fix(Twitter): Download patch
  • Loading branch information
crimera authored Mar 8, 2024
2 parents 0f86e00 + f87dee7 commit 1e60ba0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import crimera.patches.twitter.interaction.downloads.unlockdownloads.fingerprints.DownloadPatchFingerprint
import crimera.patches.twitter.interaction.downloads.unlockdownloads.fingerprints.FIleDownloaderFingerprint
import crimera.patches.twitter.interaction.downloads.unlockdownloads.fingerprints.MediaEntityFingerprint

// Credits to @iKirby
@Patch(
Expand All @@ -26,7 +27,7 @@ import crimera.patches.twitter.interaction.downloads.unlockdownloads.fingerprint
)
@Suppress("unused")
object DownloadPatch : BytecodePatch(
setOf(DownloadPatchFingerprint, FIleDownloaderFingerprint)
setOf(DownloadPatchFingerprint,FIleDownloaderFingerprint,MediaEntityFingerprint)
) {
override fun execute(context: BytecodeContext) {
val result = DownloadPatchFingerprint.result
Expand All @@ -40,7 +41,7 @@ object DownloadPatch : BytecodePatch(
val r1 = reg.registerA
val r2 = reg.registerB

//add support for gif
////add support for gif
method.addInstructionsWithLabels(
first_if_loc + 1,
"""
Expand All @@ -50,13 +51,13 @@ object DownloadPatch : BytecodePatch(
""",
ExternalLabel("cond_1212", method.getInstructions().first { it.opcode == Opcode.NEW_INSTANCE })
)

//enable download for all media
instructions.first { it.opcode == Opcode.IGET_BOOLEAN }.location.index.apply {
method.removeInstruction(this)
method.removeInstruction(this)
}

val f2Result = FIleDownloaderFingerprint.result
?: throw PatchException("FIleDownloaderFingerprint not found")

Expand All @@ -65,10 +66,31 @@ object DownloadPatch : BytecodePatch(
val instructions2 = method2.getInstructions()
val first_if2_loc = instructions2.first { it.opcode == Opcode.IF_EQZ }.location.index
val r3 = method2.getInstruction<OneRegisterInstruction>(first_if2_loc).registerA

//remove premium restriction
method2.addInstructions(first_if2_loc,"""
const v$r3, true
""".trimIndent())


//force video downloadable
val f3Result = MediaEntityFingerprint.result
?: throw PatchException("MediaEntityFingerprint not found")

val method3 = f3Result.mutableMethod
val instructions3 = method3.getInstructions()
val loc = instructions3.last { it.opcode == Opcode.IGET_BOOLEAN }.location.index
val r4 = method3.getInstruction<TwoRegisterInstruction>(loc).registerA

method3.addInstructions(loc+1,"""
const v$r4, true
""".trimIndent())




//end
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package crimera.patches.twitter.interaction.downloads.unlockdownloads.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.Opcode


object MediaEntityFingerprint:MethodFingerprint(
opcodes = listOf(
Opcode.IGET_BOOLEAN,
),

customFingerprint = { it, _ ->
it.definingClass == "Lcom/twitter/model/json/core/JsonMediaEntity;"
}

)

0 comments on commit 1e60ba0

Please sign in to comment.