diff --git a/src/main/kotlin/crimera/patches/twitter/interaction/downloads/changedirectory/ChangeDownloadDirPatch.kt b/src/main/kotlin/crimera/patches/twitter/interaction/downloads/changedirectory/ChangeDownloadDirPatch.kt index b61ecac8..0a3b175c 100644 --- a/src/main/kotlin/crimera/patches/twitter/interaction/downloads/changedirectory/ChangeDownloadDirPatch.kt +++ b/src/main/kotlin/crimera/patches/twitter/interaction/downloads/changedirectory/ChangeDownloadDirPatch.kt @@ -10,7 +10,7 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.Patch import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction -import crimera.patches.twitter.interaction.downloads.changedirectory.fingerprints.SetDownloadDestinationFingerprint +import crimera.patches.twitter.interaction.downloads.copyMediaLink.DownloadCallFingerprint import crimera.patches.twitter.misc.settings.SettingsPatch import crimera.patches.twitter.misc.settings.SettingsPatch.PREF_DESCRIPTOR import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint @@ -22,8 +22,8 @@ import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFing compatiblePackages = [CompatiblePackage("com.twitter.android")] ) @Suppress("unused") -object ChangeDownloadDirPatch: BytecodePatch( - setOf(SetDownloadDestinationFingerprint, SettingsStatusLoadFingerprint) +object ChangeDownloadDirPatch : BytecodePatch( + setOf(DownloadCallFingerprint, SettingsStatusLoadFingerprint) ) { private const val GETFOLDER_DESCRIPTOR = "invoke-static {p1}, $PREF_DESCRIPTOR;->getVideoFolder(Ljava/lang/String;)Ljava/lang/String;" @@ -31,22 +31,24 @@ object ChangeDownloadDirPatch: BytecodePatch( "invoke-static {}, $PREF_DESCRIPTOR;->getPublicFolder()Ljava/lang/String;" override fun execute(context: BytecodeContext) { - val result = SetDownloadDestinationFingerprint.result - ?: throw PatchException("Could not find fingerprint") + val result = DownloadCallFingerprint.result ?: throw PatchException("Could not find fingerprint") - val method = result.mutableMethod + val method = result.mutableClass.methods.findLast { method -> + method.implementation?.instructions?.map { it.opcode }?.contains(Opcode.NEW_INSTANCE) == true + } ?: throw PatchException("Error") - val insertAt = method.getInstructions() - .first { it.opcode == Opcode.INVOKE_VIRTUAL }.location.index + val insertAt = method.getInstructions().first { it.opcode == Opcode.INVOKE_VIRTUAL }.location.index - val publicFolderRegister = method.getInstruction(insertAt-1).registerA - method.addInstructions(insertAt, """ + val publicFolderRegister = method.getInstruction(insertAt - 1).registerA + method.addInstructions( + insertAt, """ $PUBLICFOLDER_DESCRIPTOR move-result-object v$publicFolderRegister $GETFOLDER_DESCRIPTOR move-result-object p1 - """.trimIndent()) + """.trimIndent() + ) SettingsStatusLoadFingerprint.enableSettings("enableDownloadFolder") } diff --git a/src/main/kotlin/crimera/patches/twitter/interaction/downloads/changedirectory/fingerprints/SetDownloadDestinationFingerprint.kt b/src/main/kotlin/crimera/patches/twitter/interaction/downloads/changedirectory/fingerprints/SetDownloadDestinationFingerprint.kt deleted file mode 100644 index 2242bc18..00000000 --- a/src/main/kotlin/crimera/patches/twitter/interaction/downloads/changedirectory/fingerprints/SetDownloadDestinationFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package crimera.patches.twitter.interaction.downloads.changedirectory.fingerprints - -import app.revanced.patcher.fingerprint.MethodFingerprint - -object SetDownloadDestinationFingerprint: MethodFingerprint( - returnType = "V", - strings = listOf( - "guessFileName(...)" - ) -)