diff --git a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/UnlockDuolingoSuperPatch.kt b/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/UnlockDuolingoSuperPatch.kt deleted file mode 100644 index 532f3902..00000000 --- a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/UnlockDuolingoSuperPatch.kt +++ /dev/null @@ -1,62 +0,0 @@ -package app.revanced.patches.duolingo.unlocksuper - -import app.revanced.extensions.exception -import app.revanced.patcher.data.BytecodeContext -import app.revanced.patcher.extensions.InstructionExtensions.getInstructions -import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.PatchException -import app.revanced.patcher.patch.annotation.CompatiblePackage -import app.revanced.patcher.patch.annotation.Patch -import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod -import app.revanced.patches.duolingo.unlocksuper.fingerprints.IsUserSuperMethodFingerprint -import app.revanced.patches.duolingo.unlocksuper.fingerprints.UserSerializationMethodFingerprint -import com.android.tools.smali.dexlib2.Opcode -import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction22c -import com.android.tools.smali.dexlib2.iface.reference.Reference - -@Patch( - name = "Unlock Duolingo Super", - compatiblePackages = [CompatiblePackage("com.duolingo")] -) -@Suppress("unused") -object UnlockDuolingoSuperPatch : BytecodePatch( - setOf( - UserSerializationMethodFingerprint, - IsUserSuperMethodFingerprint - ) -) { - /* First find the reference to the isUserSuper field, then patch the instruction that assigns it to false. - * This strategy is used because the method that sets the isUserSuper field is difficult to fingerprint reliably. - */ - override fun execute(context: BytecodeContext) { - // Find the reference to the isUserSuper field. - val isUserSuperReference = IsUserSuperMethodFingerprint - .result - ?.mutableMethod - ?.getInstructions() - ?.filterIsInstance() - ?.firstOrNull { it.opcode == Opcode.IGET_BOOLEAN } - ?.reference - ?: throw IsUserSuperMethodFingerprint.exception - - // Patch the instruction that assigns isUserSuper to true. - UserSerializationMethodFingerprint - .result - ?.mutableMethod - ?.apply { - replaceInstructions( - indexOfReference(isUserSuperReference) - 1, - "const/4 v2, 0x1" - ) - } - ?: throw UserSerializationMethodFingerprint.exception - } - - private fun MutableMethod.indexOfReference(reference: Reference) = getInstructions() - .indexOfFirst { it is BuilderInstruction22c && it.opcode == Opcode.IPUT_BOOLEAN && it.reference == reference } - .let { - if (it == -1) throw PatchException("Could not find index of instruction with supplied reference.") - else it - } -} \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/fingerprints/IsUserSuperMethodFingerprint.kt b/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/fingerprints/IsUserSuperMethodFingerprint.kt deleted file mode 100644 index 8ee88fdc..00000000 --- a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/fingerprints/IsUserSuperMethodFingerprint.kt +++ /dev/null @@ -1,14 +0,0 @@ -package app.revanced.patches.duolingo.unlocksuper.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode - -object IsUserSuperMethodFingerprint : MethodFingerprint( - returnType = "Ljava/lang/Object", - parameters = listOf("Ljava/lang/Object"), - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - strings = listOf("user"), - opcodes = listOf(Opcode.IGET_BOOLEAN), -) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/fingerprints/UserSerializationMethodFingerprint.kt b/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/fingerprints/UserSerializationMethodFingerprint.kt deleted file mode 100644 index 2d8bcdda..00000000 --- a/src/main/kotlin/app/revanced/patches/duolingo/unlocksuper/fingerprints/UserSerializationMethodFingerprint.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.revanced.patches.duolingo.unlocksuper.fingerprints - -import app.revanced.patcher.extensions.or -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import com.android.tools.smali.dexlib2.AccessFlags -import com.android.tools.smali.dexlib2.Opcode - -object UserSerializationMethodFingerprint : MethodFingerprint( - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, - strings = listOf( - "betaStatus", - "coachOutfit", - "globalAmbassadorStatus", - ), - opcodes = listOf( - Opcode.MOVE_FROM16, - Opcode.IPUT_BOOLEAN, - ), -) \ No newline at end of file