Compare commits

..

No commits in common. "v6.1.1-dev.3" and "main" have entirely different histories.

84 changed files with 265 additions and 182 deletions

View file

@ -1,25 +1,3 @@
## [6.1.1-dev.3](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.2...v6.1.1-dev.3) (2026-03-20)
### Bug Fixes
* **GmsCore support:** Correct option name ([6cbef5a](https://github.com/ReVanced/revanced-patches/commit/6cbef5a48a83e4a74de578e7d20f7d71a8b1de8e))
* **GmsCore support:** Correct package name for custom vendor group id ([292728a](https://github.com/ReVanced/revanced-patches/commit/292728a8baddbca87993590db4a8bab60b564432))
## [6.1.1-dev.2](https://github.com/ReVanced/revanced-patches/compare/v6.1.1-dev.1...v6.1.1-dev.2) (2026-03-20)
### Bug Fixes
* **Twitter:** Correct extension path to fix crashes ([f4b2545](https://github.com/ReVanced/revanced-patches/commit/f4b2545742e0501ab252c70654993a4e4414319e))
## [6.1.1-dev.1](https://github.com/ReVanced/revanced-patches/compare/v6.1.0...v6.1.1-dev.1) (2026-03-19)
### Bug Fixes
* **YouTube - Spoof video streams:** Set `ANDROID_REEL` client as default ([#6878](https://github.com/ReVanced/revanced-patches/issues/6878)) ([a9aeb32](https://github.com/ReVanced/revanced-patches/commit/a9aeb325de1160262c4db9b4b60c6c5e39730620))
# [6.1.0](https://github.com/ReVanced/revanced-patches/compare/v6.0.1...v6.1.0) (2026-03-18)

View file

@ -81,7 +81,7 @@ Some of the features the patches provide are:
export activities, etc.
* ✨ **And much more!**
For a complete list of all available patches, see [this](https://github.com/ReVanced/revanced-documentation/blob/main/docs/revanced-resources/questions.md#5-which-patches-are-available).
For a complete list of all available patches, visit [revanced.app/patches](https://revanced.app/patches).
## 🚀 How to get started

View file

@ -105,7 +105,7 @@ public class GmsCoreSupport {
return null;
}
}),
UNKNOWN(getGmsCoreVendorGroupId(), getGmsCoreVendorGroupId() + ".android.gms", () -> null);
UNKNOWN(getGmsCoreVendorGroupId(), getGmsCoreVendorGroupId() + "android.gms", () -> null);
private static final String DONT_KILL_MY_APP_URL
= "https://dontkillmyapp.com/";

View file

@ -1,4 +1,4 @@
package app.revanced.extension.twitter.patches.links;
package app.revanced.twitter.patches.links;
@SuppressWarnings("unused")
public final class ChangeLinkSharingDomainPatch {

View file

@ -0,0 +1,22 @@
package app.revanced.twitter.patches.links;
import android.content.Context;
import android.content.Intent;
import app.revanced.extension.shared.Logger;
@SuppressWarnings("unused")
@Deprecated(forRemoval = true)
public final class OpenLinksWithAppChooserPatch {
/**
* Injection point.
*/
public static void openWithChooser(final Context context, final Intent intent) {
Logger.printInfo(() -> "Opening intent with chooser: " + intent);
intent.setAction("android.intent.action.VIEW");
context.startActivity(Intent.createChooser(intent, null));
}
}

View file

@ -391,7 +391,7 @@ public class Settings extends YouTubeAndMusicSettings {
public static final BooleanSetting EXTERNAL_BROWSER = new BooleanSetting("revanced_external_browser", TRUE, true);
public static final BooleanSetting SPOOF_DEVICE_DIMENSIONS = new BooleanSetting("revanced_spoof_device_dimensions", FALSE, true,
"revanced_spoof_device_dimensions_user_dialog_message");
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_REEL, true, parent(SPOOF_VIDEO_STREAMS));
public static final EnumSetting<ClientType> SPOOF_VIDEO_STREAMS_CLIENT_TYPE = new EnumSetting<>("revanced_spoof_video_streams_client_type", ClientType.ANDROID_VR_1_43_32, true, parent(SPOOF_VIDEO_STREAMS));
public static final BooleanSetting SPOOF_VIDEO_STREAMS_AV1 = new BooleanSetting("revanced_spoof_video_streams_av1", FALSE, true,
"revanced_spoof_video_streams_av1_user_dialog_message", new SpoofClientAv1Availability());

View file

@ -4,4 +4,4 @@ org.gradle.parallel = true
android.useAndroidX = true
android.uniquePackageNames = false
kotlin.code.style = official
version = 6.1.1-dev.3
version = 6.1.0

View file

@ -1,11 +1,12 @@
package app.revanced.patches.all.misc.adb
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
import com.android.tools.smali.dexlib2.util.MethodUtil
@ -43,7 +44,7 @@ val hideADBStatusPatch = bytecodePatch(
filterMap = filterMap@{ classDef, method, instruction, instructionIndex ->
val reference = instruction
.takeIf { it.opcode == Opcode.INVOKE_STATIC }
?.methodReference
?.getReference<MethodReference>()
?.takeIf { reference ->
getIntMethodReferences.any { MethodUtil.methodSignaturesMatch(it, reference) }
}

View file

@ -1,11 +1,12 @@
package app.revanced.patches.all.misc.build
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
private const val BUILD_CLASS_DESCRIPTOR = "Landroid/os/Build;"
@ -74,7 +75,7 @@ fun baseSpoofBuildInfoPatch(buildInfoSupplier: () -> BuildInfo) = bytecodePatch
dependsOn(
transformInstructionsPatch(
filterMap = filterMap@{ _, _, instruction, instructionIndex ->
val reference = instruction.fieldReference ?: return@filterMap null
val reference = instruction.getReference<FieldReference>() ?: return@filterMap null
if (reference.definingClass != BUILD_CLASS_DESCRIPTOR) return@filterMap null
return@filterMap replacements[reference.name]?.let { instructionIndex to it }

View file

@ -1,12 +1,13 @@
package app.revanced.patches.all.misc.connectivity.location.hide
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.transformation.IMethodCall
import app.revanced.patches.all.misc.transformation.fromMethodReference
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
val hideMockLocationPatch = bytecodePatch(
@ -17,7 +18,7 @@ val hideMockLocationPatch = bytecodePatch(
dependsOn(
transformInstructionsPatch(
filterMap = filter@{ _, _, instruction, instructionIndex ->
val reference = instruction.methodReference ?: return@filter null
val reference = instruction.getReference<MethodReference>() ?: return@filter null
if (fromMethodReference<MethodCall>(reference) == null) return@filter null
instruction to instructionIndex

View file

@ -1,10 +1,11 @@
package app.revanced.patches.all.misc.play
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
import com.android.tools.smali.dexlib2.util.MethodUtil
@ -29,7 +30,7 @@ val disablePlayIntegrityPatch = bytecodePatch(
transformInstructionsPatch(
filterMap = filterMap@{ classDef, method, instruction, instructionIndex ->
val reference = instruction
.methodReference
.getReference<MethodReference>()
?.takeIf {
MethodUtil.methodSignaturesMatch(CONTEXT_BIND_SERVICE_METHOD_REFERENCE, it)
}

View file

@ -2,12 +2,14 @@ package app.revanced.patches.all.misc.play
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.removeInstructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.intOption
import app.revanced.patcher.patch.option
import app.revanced.util.forEachInstructionAsSequence
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
@ -44,7 +46,7 @@ val spoofPlayAgeSignalsPatch = bytecodePatch(
if (classDef.type.startsWith("Lcom/google/android/play/agesignals/")) return@forEachInstructionAsSequence null
// Keep method calls only.
val reference = instruction.methodReference
val reference = instruction.getReference<MethodReference>()
?: return@forEachInstructionAsSequence null
val match = MethodCall.entries.firstOrNull {

View file

@ -1,10 +1,11 @@
package app.revanced.patches.all.misc.screenshot
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
import com.android.tools.smali.dexlib2.util.MethodUtil
@ -38,7 +39,7 @@ val preventScreenshotDetectionPatch = bytecodePatch(
filterMap = { _, _, instruction, instructionIndex ->
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@transformInstructionsPatch null
val reference = instruction.methodReference ?: return@transformInstructionsPatch null
val reference = instruction.getReference<MethodReference>() ?: return@transformInstructionsPatch null
instructionIndex.takeIf {
MethodUtil.methodSignaturesMatch(reference, registerScreenCaptureCallbackMethodReference) ||

View file

@ -1,14 +1,15 @@
package app.revanced.patches.cricbuzz.ads
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.cricbuzz.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/cricbuzz/ads/HideAdsPatch;"
@ -26,7 +27,7 @@ val hideAdsPatch = bytecodePatch("Hide ads") {
cb11ConstructorMethod.addInstruction(0, "const/4 p7, 0x0")
getBottomBarMethod.apply {
val getIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.IGET_OBJECT && fieldReference?.name == "bottomBar"
opcode == Opcode.IGET_OBJECT && getReference<FieldReference>()?.name == "bottomBar"
}
val getRegister = getInstruction<TwoRegisterInstruction>(getIndex).registerA

View file

@ -1,15 +1,16 @@
package app.revanced.patches.crunchyroll.ads
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.removeFlags
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Suppress("unused")
val hideAdsPatch = bytecodePatch("Hide ads") {
@ -21,7 +22,7 @@ val hideAdsPatch = bytecodePatch("Hide ads") {
val stringIndex = videoUrlReadyToStringMethodMatch[-1]
val fieldIndex = it.indexOfFirstInstruction(stringIndex, Opcode.IGET_BOOLEAN)
it.getInstruction<ReferenceInstruction>(fieldIndex).fieldReference!!
it.getInstruction<ReferenceInstruction>(fieldIndex).getReference<FieldReference>()!!
}
// Remove final access flag on field.

View file

@ -2,20 +2,23 @@ package app.revanced.patches.googlenews.misc.extension.hooks
import app.revanced.patcher.definingClass
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patcher.name
import app.revanced.patcher.opcodes
import app.revanced.patches.shared.misc.extension.extensionHook
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private var getApplicationContextIndex = -1
internal val startActivityInitHook = extensionHook(
getInsertIndex = {
getApplicationContextIndex = indexOfFirstInstructionOrThrow {
methodReference?.name == "getApplicationContext"
getReference<MethodReference>()?.name == "getApplicationContext"
}
getApplicationContextIndex + 2 // Below the move-result-object instruction.

View file

@ -2,20 +2,23 @@ package app.revanced.patches.googlephotos.misc.extension
import app.revanced.patcher.definingClass
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patcher.name
import app.revanced.patcher.opcodes
import app.revanced.patches.shared.misc.extension.extensionHook
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private var getApplicationContextIndex = -1
internal val homeActivityInitHook = extensionHook(
getInsertIndex = {
getApplicationContextIndex = indexOfFirstInstructionOrThrow {
methodReference?.name == "getApplicationContext"
getReference<MethodReference>()?.name == "getApplicationContext"
}
getApplicationContextIndex + 2 // Below the move-result-object instruction.

View file

@ -2,11 +2,12 @@ package app.revanced.patches.googlephotos.misc.features
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.extensions.stringReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.stringsOption
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference
@Suppress("unused")
val spoofFeaturesPatch = bytecodePatch(
@ -61,7 +62,7 @@ val spoofFeaturesPatch = bytecodePatch(
initializeFeaturesEnumMethod.apply {
instructions.filter { it.opcode == Opcode.CONST_STRING }.forEach {
val feature = it.stringReference!!.string
val feature = it.getReference<StringReference>()!!.string
val spoofedFeature = when (feature) {
in featuresToEnable -> "android.hardware.wifi"

View file

@ -7,6 +7,10 @@ import app.revanced.patches.googlephotos.misc.extension.extensionPatch
import app.revanced.patches.googlephotos.misc.gms.Constants.PHOTOS_PACKAGE_NAME
import app.revanced.patches.googlephotos.misc.gms.Constants.REVANCED_PHOTOS_PACKAGE_NAME
import app.revanced.patches.shared.misc.gms.gmsCoreSupportPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
@Suppress("unused")

View file

@ -9,8 +9,10 @@ import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.name
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/instagram/feed/LimitFeedToFollowedProfiles;"
@ -38,7 +40,7 @@ val limitFeedToFollowedProfilesPatch = bytecodePatch(
reference?.type == "Ljava/util/Map;" &&
reference.definingClass == mainFeedRequestClassMethod.classDef.type
}.let { instructionIndex ->
getInstruction(instructionIndex).fieldReference!!.name
getInstruction(instructionIndex).getReference<FieldReference>()!!.name
}
}
@ -47,7 +49,7 @@ val limitFeedToFollowedProfilesPatch = bytecodePatch(
}.apply {
// Finds the instruction where the map is being initialized in the constructor
val getHeaderIndex = indexOfFirstInstructionOrThrow {
fieldReference.let {
getReference<FieldReference>().let {
it?.name == mainFeedRequestHeaderFieldName
}
}

View file

@ -1,6 +1,5 @@
package app.revanced.patches.instagram.hide.navigation
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.firstMethodDeclaratively
import app.revanced.patcher.immutableClassDef
@ -10,10 +9,12 @@ import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.instagram.misc.extension.sharedExtensionPatch
import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.findFreeRegister
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import java.util.logging.Logger
private const val EXTENSION_CLASS_DESCRIPTOR =
@ -81,7 +82,7 @@ val hideNavigationButtonsPatch = bytecodePatch(
opcode == Opcode.IPUT_OBJECT &&
(this as TwoRegisterInstruction).registerA == 2 // p2 register.
}.let {
method.getInstruction(it).fieldReference!!.name
method.getInstruction(it).getReference<FieldReference>()!!.name
}
}

View file

@ -2,7 +2,6 @@ package app.revanced.patches.music.layout.branding
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.typeReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
import app.revanced.patches.music.misc.gms.Constants.MUSIC_MAIN_ACTIVITY_NAME
@ -13,10 +12,12 @@ import app.revanced.patches.shared.layout.branding.EXTENSION_CLASS_DESCRIPTOR
import app.revanced.patches.shared.layout.branding.baseCustomBrandingPatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
private val disableSplashAnimationPatch = bytecodePatch {
@ -36,7 +37,7 @@ private val disableSplashAnimationPatch = bytecodePatch {
)
val checkCastIndex = indexOfFirstInstructionOrThrow(literalIndex) {
opcode == Opcode.CHECK_CAST &&
typeReference?.type == "Lcom/airbnb/lottie/LottieAnimationView;"
getReference<TypeReference>()?.type == "Lcom/airbnb/lottie/LottieAnimationView;"
}
val register = getInstruction<OneRegisterInstruction>(checkCastIndex).registerA

View file

@ -4,7 +4,6 @@ package app.revanced.patches.music.layout.miniplayercolor
import app.revanced.patcher.accessFlags
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.firstMethodDeclaratively
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.bytecodePatch
@ -21,6 +20,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/music/patches/ChangeMiniplayerColorPatch;"
@ -72,7 +72,7 @@ val changeMiniplayerColorPatch = bytecodePatch(
val colorGreyIndex =
miniPlayerConstructorMethodMatch.immutableMethod.indexOfFirstInstructionReversedOrThrow {
methodReference?.name == "getColor"
getReference<MethodReference>()?.name == "getColor"
}
val iPutIndex =
miniPlayerConstructorMethodMatch.immutableMethod.indexOfFirstInstructionOrThrow(

View file

@ -1,14 +1,15 @@
package app.revanced.patches.openinghours.misc.fix.crash
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.newLabel
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21t
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
val fixCrashPatch = bytecodePatch(
@ -77,7 +78,7 @@ val fixCrashPatch = bytecodePatch(
}
private fun isInvokeInstruction(instruction: Instruction, className: String, methodName: String): Boolean {
val methodRef = instruction.methodReference ?: return false
val methodRef = instruction.getReference<MethodReference>() ?: return false
return methodRef.definingClass == className && methodRef.name == methodName
}

View file

@ -3,10 +3,11 @@ package app.revanced.patches.piccomafr.tracking
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.extensions.stringReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference
@Suppress("unused")
val disableTrackingPatch = bytecodePatch(
@ -47,7 +48,7 @@ val disableTrackingPatch = bytecodePatch(
firebaseInstallMethod.instructions.filter {
it.opcode == Opcode.CONST_STRING
}.filter {
it.stringReference?.string == "firebaseinstallations.googleapis.com"
it.getReference<StringReference>()?.string == "firebaseinstallations.googleapis.com"
}.forEach { instruction ->
instruction as OneRegisterInstruction

View file

@ -2,13 +2,14 @@ package app.revanced.patches.primevideo.ads
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.primevideo.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
val skipAdsPatch = bytecodePatch(
@ -31,7 +32,7 @@ val skipAdsPatch = bytecodePatch(
// move-result-object { playerRegister }
val getPlayerIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_VIRTUAL &&
methodReference?.name == "getPrimaryPlayer"
getReference<MethodReference>()?.name == "getPrimaryPlayer"
}
val playerRegister = getInstruction<OneRegisterInstruction>(getPlayerIndex + 1).registerA

View file

@ -1,13 +1,14 @@
package app.revanced.patches.primevideo.video.speed
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.primevideo.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/primevideo/videoplayer/PlaybackSpeedPatch;"
@ -29,7 +30,7 @@ val playbackSpeedPatch = bytecodePatch(
playbackUserControlsInitializeMethod.apply {
val getIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.IPUT_OBJECT &&
fieldReference?.name == "mUserControls"
getReference<FieldReference>()?.name == "mUserControls"
}
val getRegister = getInstruction<OneRegisterInstruction>(getIndex).registerA

View file

@ -1,12 +1,13 @@
package app.revanced.patches.protonvpn.splittunneling
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
val unlockSplitTunnelingPatch = bytecodePatch("Unlock split tunneling") {
@ -21,7 +22,7 @@ val unlockSplitTunnelingPatch = bytecodePatch("Unlock split tunneling") {
initializeSplitTunnelingSettingsUIMethod.apply {
val initSettingsIndex = indexOfFirstInstructionOrThrow {
methodReference?.name == "getSplitTunneling"
getReference<MethodReference>()?.name == "getSplitTunneling"
}
removeInstruction(initSettingsIndex - 1)
}

View file

@ -1,16 +1,17 @@
package app.revanced.patches.reddit.ad.general
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.reddit.ad.comments.hideCommentAdsPatch
import app.revanced.patches.reddit.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction22c
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
val hideAdsPatch = bytecodePatch("Hide ads") {
@ -56,7 +57,7 @@ val hideAdsPatch = bytecodePatch("Hide ads") {
// By removing the appending instruction no ad posts gets appended to the feed.
val index = newAdPostMethod.indexOfFirstInstruction {
val reference = methodReference ?: return@indexOfFirstInstruction false
val reference = getReference<MethodReference>() ?: return@indexOfFirstInstruction false
reference.name == "add" && reference.definingClass == "Ljava/util/ArrayList;"
}

View file

@ -1,16 +1,17 @@
package app.revanced.patches.reddit.customclients.baconreader.fix.redgifs
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.removeInstructions
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.extensions.typeReference
import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD
import app.revanced.patches.reddit.customclients.baconreader.misc.extension.sharedExtensionPatch
import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/baconreader/FixRedgifsApiPatch;"
@ -33,7 +34,7 @@ val fixRedgifsApi = fixRedgifsApiPatch(
getOkHttpClientMethod.removeInstructions(originalInterceptorInstallIndex, 5)
val index = getOkHttpClientMethod.indexOfFirstInstructionOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.name == "build" && reference.definingClass == $$"Lokhttp3/OkHttpClient$Builder;"
}
val register = getOkHttpClientMethod.getInstruction<FiveRegisterInstruction>(index).registerC

View file

@ -2,12 +2,13 @@ package app.revanced.patches.reddit.customclients.boostforreddit.api
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.extensions.stringReference
import app.revanced.patches.reddit.customclients.spoofClientPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference
@Suppress("unused")
val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com") { clientIdOption ->
@ -29,7 +30,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "http://rubenmayayo.com")
val userAgent = "$randomName:app.revanced.$randomName:v1.0.0 (by /u/revanced)"
val userAgentTemplateIndex = buildUserAgentMethod.indexOfFirstInstructionOrThrow {
opcode == Opcode.CONST_STRING && stringReference?.string == "%s:%s:%s (by /u/%s)"
opcode == Opcode.CONST_STRING && getReference<StringReference>()?.string == "%s:%s:%s (by /u/%s)"
}
val register = buildUserAgentMethod.getInstruction<OneRegisterInstruction>(userAgentTemplateIndex).registerA

View file

@ -3,11 +3,12 @@ package app.revanced.patches.reddit.customclients.redditisfun.api
import app.revanced.patcher.CompositeMatch
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.extensions.stringReference
import app.revanced.patches.reddit.customclients.spoofClientPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference
@Suppress("unused")
val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { clientIdOption ->
@ -63,7 +64,7 @@ val spoofClientPatch = spoofClientPatch(redirectUri = "redditisfun://auth") { cl
// Replace old.reddit.com with www.reddit.com to fix this.
buildAuthorizationStringMethodMatch.method.apply {
val index = indexOfFirstInstructionOrThrow {
stringReference?.contains("old.reddit.com") == true
getReference<StringReference>()?.contains("old.reddit.com") == true
}
val targetRegister = getInstruction<OneRegisterInstruction>(index).registerA

View file

@ -2,13 +2,14 @@ package app.revanced.patches.reddit.customclients.sync.syncforreddit.fix.redgifs
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patches.reddit.customclients.INSTALL_NEW_CLIENT_METHOD
import app.revanced.patches.reddit.customclients.fixRedgifsApiPatch
import app.revanced.patches.reddit.customclients.sync.syncforreddit.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/syncforreddit/FixRedgifsApiPatch;"
@ -26,7 +27,7 @@ val fixRedgifsApi = fixRedgifsApiPatch(
// region Patch Redgifs OkHttp3 client.
val index = createOkHttpClientMethod.indexOfFirstInstructionOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.name == "build" && reference.definingClass == $$"Lokhttp3/OkHttpClient$Builder;"
}
val register = createOkHttpClientMethod.getInstruction<FiveRegisterInstruction>(index).registerC

View file

@ -2,11 +2,12 @@ package app.revanced.patches.samsung.radio.restrictions.device
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.removeInstructions
import app.revanced.patcher.extensions.stringReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.util.findFreeRegister
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.reference.StringReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/samsung/radio/restrictions/device/BypassDeviceChecksPatch;"
@ -24,7 +25,7 @@ val bypassDeviceChecksPatch = bytecodePatch(
// Find the first string that start with "SM-", that's the list of incompatible devices.
val firstStringIndex = checkDeviceMethod.indexOfFirstInstructionOrThrow {
opcode == Opcode.CONST_STRING &&
stringReference?.string?.startsWith("SM-") == true
getReference<StringReference>()?.string?.startsWith("SM-") == true
}
// Find the following filled-new-array (or filled-new-array/range) instruction.

View file

@ -2,9 +2,7 @@ package app.revanced.patches.shared.layout.branding
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.typeReference
import app.revanced.patcher.patch.*
import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName
import app.revanced.patches.all.misc.resources.addResources
@ -16,6 +14,8 @@ import app.revanced.util.*
import app.revanced.util.Utils.trimIndentMultiline
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
import org.w3c.dom.Element
import org.w3c.dom.NodeList
import java.io.File
@ -125,22 +125,22 @@ internal fun baseCustomBrandingPatch(
val getBuilderIndex = if (isYouTubeMusic) {
// YT Music the field is not a plain object type.
indexOfFirstInstructionOrThrow {
fieldReference?.type == $$"Landroid/app/Notification$Builder;"
getReference<FieldReference>()?.type == $$"Landroid/app/Notification$Builder;"
}
} else {
// Find the field name of the notification builder. Field is an Object type.
val builderCastIndex = indexOfFirstInstructionOrThrow {
val reference = typeReference
val reference = getReference<TypeReference>()
opcode == Opcode.CHECK_CAST &&
reference?.type == $$"Landroid/app/Notification$Builder;"
}
indexOfFirstInstructionReversedOrThrow(builderCastIndex) {
fieldReference?.type == "Ljava/lang/Object;"
getReference<FieldReference>()?.type == "Ljava/lang/Object;"
}
}
val builderFieldName = getInstruction<ReferenceInstruction>(getBuilderIndex)
.fieldReference
.getReference<FieldReference>()
findInstructionIndicesReversedOrThrow(
Opcode.RETURN_VOID,

View file

@ -65,9 +65,10 @@ fun gmsCoreSupportPatch(
"using a GmsCore instead of Google Play Services.",
) {
val gmsCoreVendorGroupIdOption = stringOption(
name = "GmsCore vendor group ID",
key = "gmsCoreVendorGroupId",
default = "app.revanced",
values = mapOf("ReVanced" to "app.revanced"),
title = "GmsCore vendor group ID",
description = "The vendor's group ID for GmsCore.",
required = true,
) { it!!.matches(Regex(PACKAGE_NAME_REGEX_PATTERN)) }

View file

@ -20,6 +20,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
@ -122,7 +123,7 @@ internal fun spoofVideoStreamsPatch(
val resultMethodType = createStreamingDataMethodMatch.classDef.type
val videoDetailsIndex = createStreamingDataMethodMatch[-1]
val videoDetailsRegister = getInstruction<TwoRegisterInstruction>(videoDetailsIndex).registerA
val videoDetailsClass = getInstruction(videoDetailsIndex).fieldReference!!.type
val videoDetailsClass = getInstruction(videoDetailsIndex).getReference<FieldReference>()!!.type
addInstruction(
videoDetailsIndex + 1,
@ -134,15 +135,15 @@ internal fun spoofVideoStreamsPatch(
val setStreamingDataIndex = createStreamingDataMethodMatch[0]
val playerProtoClass = getInstruction(setStreamingDataIndex + 1)
.fieldReference!!.definingClass
.getReference<FieldReference>()!!.definingClass
val setStreamingDataField = getInstruction(setStreamingDataIndex).fieldReference
val setStreamingDataField = getInstruction(setStreamingDataIndex).getReference<FieldReference>()
val getStreamingDataField = getInstruction(
indexOfFirstInstructionOrThrow {
opcode == Opcode.IGET_OBJECT && fieldReference?.definingClass == playerProtoClass
opcode == Opcode.IGET_OBJECT && getReference<FieldReference>()?.definingClass == playerProtoClass
},
).fieldReference
).getReference<FieldReference>()
// Use a helper method to avoid the need of picking out multiple free registers from the hooked code.
createStreamingDataMethodMatch.classDef.methods.add(
@ -274,7 +275,7 @@ internal fun spoofVideoStreamsPatch(
val mediaFetchEnumClass = definingClass
val sabrFieldIndex = indexOfFirstInstructionOrThrow(disabledBySABRStreamingUrlString) {
opcode == Opcode.SPUT_OBJECT &&
fieldReference?.type == mediaFetchEnumClass
getReference<FieldReference>()?.type == mediaFetchEnumClass
}
Pair(

View file

@ -1,15 +1,16 @@
package app.revanced.patches.shared.misc.spoof
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.extensions.stringReference
import app.revanced.patches.all.misc.transformation.IMethodCall
import app.revanced.patches.all.misc.transformation.filterMapInstruction35c
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.iface.reference.StringReference
private const val USER_AGENT_STRING_BUILDER_APPEND_METHOD_REFERENCE =
"Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;"
@ -36,7 +37,7 @@ fun userAgentClientSpoofPatch(originalPackageName: String) = transformInstructio
// IndexOutOfBoundsException is technically possible here,
// but no such occurrences are present in the app.
val referee = getInstruction(instructionIndex + 2).methodReference?.toString()
val referee = getInstruction(instructionIndex + 2).getReference<MethodReference>()?.toString()
// Only replace string builder usage.
if (referee != USER_AGENT_STRING_BUILDER_APPEND_METHOD_REFERENCE) {
@ -47,7 +48,7 @@ fun userAgentClientSpoofPatch(originalPackageName: String) = transformInstructio
// Changing these package names will result in playback limitations,
// particularly Android VR background audio only playback.
val resourceOrGmsStringInstructionIndex = indexOfFirstInstruction {
val reference = stringReference
val reference = getReference<StringReference>()
opcode == Opcode.CONST_STRING &&
(reference?.string == "android.resource://" || reference?.string == "gcore_")
}

View file

@ -1,11 +1,12 @@
package app.revanced.patches.shared.misc.string
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.extensions.stringReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.transformation.transformInstructionsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.ReferenceType
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.StringReference
import kotlin.text.contains
fun replaceStringPatch(
@ -19,7 +20,7 @@ fun replaceStringPatch(
filterMap = filterMap@{ _, _, instruction, instructionIndex ->
if (instruction.opcode.referenceType != ReferenceType.STRING) return@filterMap null
val stringReference = instruction.stringReference!!.string
val stringReference = instruction.getReference<StringReference>()!!.string
if (from !in stringReference) return@filterMap null
Triple(instructionIndex, instruction as OneRegisterInstruction, stringReference)

View file

@ -3,8 +3,10 @@ package app.revanced.patches.soundcloud.offlinesync
import app.revanced.patcher.extensions.*
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.soundcloud.shared.featureConstructorMethod
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Suppress("unused")
val enableOfflineSyncPatch = bytecodePatch("Enable offline sync") {
@ -38,7 +40,7 @@ val enableOfflineSyncPatch = bytecodePatch("Enable offline sync") {
val getEndpointsEnumFieldInstruction = getInstruction<OneRegisterInstruction>(getEndpointsEnumFieldIndex)
val targetRegister = getEndpointsEnumFieldInstruction.registerA
val endpointsType = getEndpointsEnumFieldInstruction.fieldReference!!.type
val endpointsType = getEndpointsEnumFieldInstruction.getReference<FieldReference>()!!.type
replaceInstruction(
getEndpointsEnumFieldIndex,

View file

@ -2,15 +2,16 @@ package app.revanced.patches.spotify.layout.theme
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.patch.booleanOption
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.patch.stringOption
import app.revanced.patches.spotify.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import org.w3c.dom.Element
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/spotify/layout/theme/CustomThemePatch;"
@ -38,7 +39,7 @@ private val customThemeBytecodePatch = bytecodePatch {
// including the solid color of it.
parseLottieJsonMethod.apply {
val invokeParseColorIndex = indexOfFirstInstructionOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == "Landroid/graphics/Color;" &&
reference.name == "parseColor"
}
@ -59,7 +60,7 @@ private val customThemeBytecodePatch = bytecodePatch {
// Lottie animated color parser.
parseAnimatedColorMethod.apply {
val invokeArgbIndex = indexOfFirstInstructionOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == "Landroid/graphics/Color;" &&
reference.name == "argb"
}

View file

@ -1,14 +1,15 @@
package app.revanced.patches.spotify.misc.extension
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.string
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patches.shared.misc.extension.activityOnCreateExtensionHook
import app.revanced.patches.shared.misc.extension.extensionHook
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
internal val mainActivityOnCreateHook = activityOnCreateExtensionHook(
"Lcom/spotify/music/SpotifyMainActivity;"
@ -24,7 +25,7 @@ internal val loadOrbitLibraryHook = extensionHook(
},
getContextRegister = {
contextReferenceIndex = indexOfFirstInstruction {
fieldReference?.type == "Landroid/content/Context;"
getReference<FieldReference>()?.type == "Landroid/content/Context;"
}
val contextRegister =
getInstruction<TwoRegisterInstruction>(contextReferenceIndex).registerA

View file

@ -4,7 +4,6 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.firstMethodDeclaratively
import app.revanced.patcher.instructions
@ -13,10 +12,13 @@ import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.stringOption
import app.revanced.patcher.returnType
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.reference.ImmutableMethodReference
import java.net.InetAddress
import java.net.URI
@ -68,10 +70,10 @@ val changeLyricsProviderPatch = bytecodePatch(
val patchedHttpClientBuilderMethod = with(httpClientBuilderMethod) {
val invokeBuildUrlIndex = indexOfFirstInstructionOrThrow {
methodReference?.returnType == "Lokhttp3/HttpUrl;"
getReference<MethodReference>()?.returnType == "Lokhttp3/HttpUrl;"
}
val setUrlBuilderHostIndex = indexOfFirstInstructionReversedOrThrow(invokeBuildUrlIndex) {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == "Lokhttp3/HttpUrl${"$"}Builder;" &&
reference.parameterTypes.firstOrNull() == "Ljava/lang/String;"
}
@ -101,7 +103,7 @@ val changeLyricsProviderPatch = bytecodePatch(
getLyricsHttpClientMethod.apply {
val getLyricsHttpClientIndex = indexOfFirstInstructionOrThrow {
methodReference == httpClientBuilderMethod
getReference<MethodReference>() == httpClientBuilderMethod
}
val getLyricsHttpClientInstruction = getInstruction<BuilderInstruction35c>(getLyricsHttpClientIndex)

View file

@ -1,7 +1,12 @@
package app.revanced.patches.spotify.misc.lyrics
import app.revanced.patcher.gettingFirstImmutableMethod
import app.revanced.patcher.gettingFirstImmutableMethodDeclaratively
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
internal val BytecodePatchContext.httpClientBuilderMethod by gettingFirstImmutableMethod("client == null", "scheduler == null")

View file

@ -4,12 +4,12 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.typeReference
import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
import app.revanced.util.childElementsSequence
import app.revanced.util.findElementByAttributeValueOrThrow
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.AccessFlags.*
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
@ -18,6 +18,7 @@ import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction21c
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction31i
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction35c
import com.android.tools.smali.dexlib2.iface.instruction.NarrowLiteralInstruction
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
import com.android.tools.smali.dexlib2.immutable.ImmutableClassDef
import com.android.tools.smali.dexlib2.immutable.ImmutableField
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
@ -114,7 +115,7 @@ val addGiveGroupKudosButtonToGroupActivityPatch = bytecodePatch(
val checkCastButtonInstruction =
getInstruction<BuilderInstruction21c>(constLeaveIdInstruction.location.index + 3)
val buttonClassName = checkCastButtonInstruction.typeReference!!.type
val buttonClassName = checkCastButtonInstruction.getReference<TypeReference>()!!.type
addInstructions(
constLeaveIdInstruction.location.index,

View file

@ -4,18 +4,19 @@ import app.revanced.patcher.extensions.ExternalLabel
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.typeReference
import app.revanced.patcher.firstImmutableClassDef
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.misc.mapping.ResourceType
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.strava.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import app.revanced.util.writeRegister
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction22c
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.TypeReference
private const val ACTION_CLASS_DESCRIPTOR = "Lcom/strava/bottomsheet/Action;"
private const val MEDIA_CLASS_DESCRIPTOR = "Lcom/strava/photos/data/Media;"
@ -44,7 +45,7 @@ val addMediaDownloadPatch = bytecodePatch(
}
val actionRegistrarRegister = getInstruction<BuilderInstruction22c>(setTrueIndex).registerB
val actionRegister = instructions.first { instruction ->
instruction.typeReference?.type == ACTION_CLASS_DESCRIPTOR
instruction.getReference<TypeReference>()?.type == ACTION_CLASS_DESCRIPTOR
}.writeRegister!!
fun addMenuItem(actionId: String, string: String, color: String, drawable: String) = addInstructions(
@ -73,7 +74,7 @@ val addMediaDownloadPatch = bytecodePatch(
// Move media to last parameter of `Action` constructor.
val getMediaInstruction = instructions.first { instruction ->
instruction.fieldReference?.type == MEDIA_CLASS_DESCRIPTOR
instruction.getReference<FieldReference>()?.type == MEDIA_CLASS_DESCRIPTOR
}
addInstruction(
getMediaInstruction.location.index + 1,

View file

@ -6,9 +6,11 @@ import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch
import app.revanced.patches.tiktok.misc.settings.settingsPatch
import app.revanced.patches.tiktok.misc.settings.settingsStatusLoadMethod
import app.revanced.util.findInstructionIndicesReversedOrThrow
import app.revanced.util.getReference
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/tiktok/download/DownloadsPatch;"
@ -48,7 +50,7 @@ val downloadsPatch = bytecodePatch(
// Change the download path patch.
downloadUriMethod.apply {
findInstructionIndicesReversedOrThrow {
fieldReference.let {
getReference<FieldReference>().let {
it?.definingClass == "Landroid/os/Environment;" && it.name.startsWith("DIRECTORY_")
}
}.forEach { fieldIndex ->

View file

@ -4,13 +4,15 @@ import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.firstClassDef
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.tiktok.shared.getEnterFromMethod
import app.revanced.patches.tiktok.shared.onRenderFirstFrameMethod
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.returnEarly
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction11x
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@Suppress("unused")
val playbackSpeedPatch = bytecodePatch(
@ -26,7 +28,7 @@ val playbackSpeedPatch = bytecodePatch(
apply {
getSpeedMethod.apply {
val injectIndex =
indexOfFirstInstructionOrThrow { methodReference?.returnType == "F" } + 2
indexOfFirstInstructionOrThrow { getReference<MethodReference>()?.returnType == "F" } + 2
val register = getInstruction<Instruction11x>(injectIndex - 1).registerA
addInstruction(

View file

@ -2,10 +2,10 @@ package app.revanced.patches.tiktok.misc.share
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.tiktok.misc.extension.sharedExtensionPatch
import app.revanced.util.findFreeRegister
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -30,7 +30,7 @@ val sanitizeSharingLinksPatch = bytecodePatch(
apply {
urlShorteningMethod.apply {
val invokeIndex = indexOfFirstInstructionOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.name == "LIZ" && reference.definingClass.startsWith("LX/")
}
@ -43,7 +43,7 @@ val sanitizeSharingLinksPatch = bytecodePatch(
.reference.toString()
val observableFactoryIndex = indexOfFirstInstructionOrThrow {
val ref = methodReference
val ref = getReference<MethodReference>()
ref?.name == "LJ" && ref.definingClass.startsWith("LX/")
}
val observableFactoryRef = getInstruction<ReferenceInstruction>(observableFactoryIndex)

View file

@ -14,7 +14,7 @@ import java.net.InetAddress
import java.net.UnknownHostException
import java.util.logging.Logger
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/twitter/patches/links/ChangeLinkSharingDomainPatch;"
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/links/ChangeLinkSharingDomainPatch;"
internal val domainNameOption = stringOption(
default = "fxtwitter.com",

View file

@ -14,8 +14,10 @@ import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.findInstructionIndicesReversed
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/SlideToSeekPatch;"
@ -43,7 +45,7 @@ val enableSlideToSeekPatch = bytecodePatch(
val checkIndex = slideToSeekMethodMatch[0]
val checkReference = slideToSeekMethodMatch.method.getInstruction(checkIndex)
.methodReference!!
.getReference<MethodReference>()!!
val extensionMethodDescriptor = "$EXTENSION_CLASS_DESCRIPTOR->isSlideToSeekDisabled(Z)Z"

View file

@ -3,7 +3,6 @@ package app.revanced.patches.youtube.interaction.seekbar
import app.revanced.patcher.extensions.ExternalLabel
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
@ -13,6 +12,8 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.findFreeRegister
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/TapToSeekPatch;"
@ -34,7 +35,8 @@ val enableTapToSeekPatch = bytecodePatch(
// Find the required methods to tap the seekbar.
val tapToSeekMethods = onTouchEventHandlerMethodMatch.let {
fun getReference(index: Int) = it.method.getInstruction(index).methodReference!!
fun getReference(index: Int) = it.method.getInstruction<ReferenceInstruction>(index)
.reference as MethodReference
listOf(
getReference(it[0]),

View file

@ -26,11 +26,13 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.findInstructionIndicesReversedOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.insertLiteralOverride
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import kotlin.collections.plusAssign
private const val EXTENSION_CLASS_DESCRIPTOR =
@ -233,7 +235,7 @@ val navigationBarPatch = bytecodePatch(
// Fix missing left padding when using wide searchbar.
wideSearchbarLayoutMethod.apply {
findInstructionIndicesReversedOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == "Landroid/view/LayoutInflater;" && reference.name == "inflate"
}.forEach { inflateIndex ->
val register =

View file

@ -17,11 +17,12 @@ import app.revanced.util.*
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/HidePlayerOverlayButtonsPatch;"
@Suppress("unused")
@Suppress("ObjectPropertyName")
val hidePlayerOverlayButtonsPatch = bytecodePatch(
name = "Hide player overlay buttons",
description = "Adds options to hide the player Cast, Autoplay, Captions, Previous & Next buttons, and the player " +
@ -120,7 +121,7 @@ val hidePlayerOverlayButtonsPatch = bytecodePatch(
// Add a conditional branch around the code that inflates and adds the auto-repeat button.
val gotoIndex = indexOfFirstInstructionOrThrow(constIndex) {
val parameterTypes = methodReference?.parameterTypes
val parameterTypes = getReference<MethodReference>()?.parameterTypes
opcode == Opcode.INVOKE_VIRTUAL &&
parameterTypes?.size == 2 &&
parameterTypes.first() == "Landroid/view/ViewStub;"

View file

@ -2,7 +2,6 @@ package app.revanced.patches.youtube.layout.hide.fullscreenambientmode
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
@ -10,8 +9,10 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/DisableFullscreenAmbientModePatch;"
@ -50,7 +51,7 @@ val disableFullscreenAmbientModePatch = bytecodePatch(
setFullScreenBackgroundColorMethod.apply {
val insertIndex = indexOfFirstInstructionReversedOrThrow {
methodReference?.name == "setBackgroundColor"
getReference<MethodReference>()?.name == "setBackgroundColor"
}
val register = getInstruction<FiveRegisterInstruction>(insertIndex).registerD

View file

@ -21,6 +21,7 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.findFreeRegister
import app.revanced.util.findInstructionIndicesReversedOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
@ -30,6 +31,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
@ -487,7 +489,7 @@ val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
yoodlesImageViewMethod.apply {
findInstructionIndicesReversedOrThrow {
methodReference?.name == "setImageDrawable"
getReference<MethodReference>()?.name == "setImageDrawable"
}.forEach { insertIndex ->
val drawableRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
val imageViewRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerC
@ -510,7 +512,7 @@ val hideLayoutComponentsPatch = hideLayoutComponentsPatch(
// Find the instruction where the text dimension is retrieved.
val applyDimensionIndex = indexOfFirstInstructionReversedOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_STATIC &&
reference?.definingClass == "Landroid/util/TypedValue;" &&
reference.returnType == "F" &&

View file

@ -7,9 +7,7 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.patch.bytecodePatch
@ -31,6 +29,8 @@ import com.android.tools.smali.dexlib2.iface.ClassDef
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
@ -269,7 +269,7 @@ val miniplayerPatch = bytecodePatch(
it.apply {
if (AccessFlags.CONSTRUCTOR.isSet(accessFlags)) {
val iPutIndex = indexOfFirstInstructionOrThrow {
this.opcode == Opcode.IPUT && this.fieldReference?.type == "I"
this.opcode == Opcode.IPUT && this.getReference<FieldReference>()?.type == "I"
}
insertModernMiniplayerTypeOverride(iPutIndex)
@ -394,7 +394,7 @@ val miniplayerPatch = bytecodePatch(
if (is_20_31_or_greater) {
miniplayerSetIconsMethod.apply {
findInstructionIndicesReversedOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_INTERFACE &&
reference?.returnType == "Z" && reference.parameterTypes.isEmpty()
}.forEach { index ->

View file

@ -5,7 +5,6 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan
import app.revanced.patcher.*
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.layout.theme.lithoColorHookPatch
@ -19,12 +18,14 @@ import app.revanced.patches.youtube.misc.playservice.is_21_02_or_greater
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
import app.revanced.patches.youtube.shared.mainActivityOnCreateMethod
import app.revanced.util.findInstructionIndicesReversedOrThrow
import app.revanced.util.getReference
import app.revanced.util.insertLiteralOverride
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
@ -157,7 +158,7 @@ val seekbarColorPatch = bytecodePatch(
val setAnimationIntMethodName = lottieAnimationViewSetAnimationIntMethod.name
findInstructionIndicesReversedOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == LOTTIE_ANIMATION_VIEW_CLASS_TYPE &&
reference.name == setAnimationIntMethodName
}.forEach { index ->

View file

@ -5,7 +5,6 @@ import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.immutableClassDef
@ -21,19 +20,22 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.patches.youtube.shared.mainActivityOnCreateMethod
import app.revanced.util.findInstructionIndicesReversedOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodParameter
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/ShortsAutoplayPatch;"
@Suppress("unused")
@Suppress("ObjectPropertyName")
val shortsAutoplayPatch = bytecodePatch(
name = "Shorts autoplay",
description = "Adds options to automatically play the next Short.",
@ -97,7 +99,7 @@ val shortsAutoplayPatch = bytecodePatch(
reelPlaybackRepeatMethod.apply {
// The behavior enums are looked up from an ordinal value to an enum type.
findInstructionIndicesReversedOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == reelEnumClass &&
reference.parameterTypes.firstOrNull() == "I" &&
reference.returnType == reelEnumClass
@ -127,12 +129,12 @@ val shortsAutoplayPatch = bytecodePatch(
// Find the first call modified by extension code above.
val extensionReturnResultIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_STATIC &&
methodReference?.definingClass == EXTENSION_CLASS_DESCRIPTOR
getReference<MethodReference>()?.definingClass == EXTENSION_CLASS_DESCRIPTOR
} + 1
val enumRegister =
getInstruction<OneRegisterInstruction>(extensionReturnResultIndex).registerA
val getReelSequenceControllerIndex = indexOfFirstInstructionOrThrow {
val reference = fieldReference
val reference = getReference<FieldReference>()
opcode == Opcode.IGET_OBJECT &&
reference?.definingClass == definingClass &&
reference.type == reelSequenceControllerMethodReference.definingClass

View file

@ -24,11 +24,13 @@ import app.revanced.patches.youtube.shared.mainActivityOnCreateMethod
import app.revanced.patches.youtube.video.information.playbackStartDescriptorToStringMethodMatch
import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.findInstructionIndicesReversedOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/OpenShortsInRegularPlayerPatch;"
@ -147,14 +149,14 @@ val openShortsInRegularPlayerPatch = bytecodePatch(
// Method call for Activity.finish()
val finishIndexFirst = indexOfFirstInstructionOrThrow {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.name == "finish"
}
// Second Activity.finish() call. Has been present since 19.x but started
// to interfere with back to exit fullscreen around 20.47.
val finishIndexSecond = indexOfFirstInstruction(finishIndexFirst + 1) {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.name == "finish"
}
val getBooleanFieldIndex = indexOfFirstInstructionReversedOrThrow(finishIndexSecond) {

View file

@ -2,9 +2,7 @@ package app.revanced.patches.youtube.layout.sponsorblock
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
@ -35,6 +33,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private val sponsorBlockResourcePatch = resourcePatch {
dependsOn(
@ -158,7 +157,7 @@ val sponsorBlockPatch = bytecodePatch(
val rectangleIndex = indexOfFirstInstructionReversedOrThrow(
it[0],
) {
fieldReference?.type == "Landroid/graphics/Rect;"
getReference<FieldReference>()?.type == "Landroid/graphics/Rect;"
}
rectangleFieldName =
getInstruction<ReferenceInstruction>(rectangleIndex).reference as FieldReference
@ -183,7 +182,7 @@ val sponsorBlockPatch = bytecodePatch(
// Find the drawCircle call and draw the segment before it.
val drawCircleIndex = indexOfFirstInstructionReversedOrThrow {
methodReference?.name == "drawCircle"
getReference<MethodReference>()?.name == "drawCircle"
}
val drawCircleInstruction = getInstruction<FiveRegisterInstruction>(drawCircleIndex)
val canvasInstanceRegister = drawCircleInstruction.registerC

View file

@ -2,7 +2,6 @@ package app.revanced.patches.youtube.layout.startupshortsreset
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
@ -15,9 +14,11 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.findFreeRegister
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/DisableResumingStartupShortsPlayerPatch;"
@ -77,8 +78,8 @@ val disableResumingShortsOnStartupPatch = bytecodePatch(
userWasInShortsLegacyMethod.apply {
val listenableInstructionIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_INTERFACE &&
methodReference?.definingClass == "Lcom/google/common/util/concurrent/ListenableFuture;" &&
methodReference?.name == "isDone"
getReference<MethodReference>()?.definingClass == "Lcom/google/common/util/concurrent/ListenableFuture;" &&
getReference<MethodReference>()?.name == "isDone"
}
val freeRegister = findFreeRegister(listenableInstructionIndex)

View file

@ -3,13 +3,13 @@ package app.revanced.patches.youtube.layout.toolbar
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.removeInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.shared.getToolBarButtonMethodMatch
import app.revanced.util.findFreeRegister
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
@ -17,6 +17,7 @@ import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
internal const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/ToolbarPatch;"
@ -32,14 +33,14 @@ val toolbarHookPatch = bytecodePatch {
fun indexOfGetDrawableInstruction(method: Method) =
method.indexOfFirstInstruction {
opcode == Opcode.INVOKE_VIRTUAL &&
methodReference?.toString() == "Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;"
getReference<MethodReference>()?.toString() == "Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;"
}
getToolBarButtonMethodMatch().method.apply {
val getDrawableIndex = indexOfGetDrawableInstruction(this)
val enumOrdinalIndex = indexOfFirstInstructionReversedOrThrow(getDrawableIndex) {
opcode == Opcode.INVOKE_INTERFACE &&
methodReference?.returnType == "I"
getReference<MethodReference>()?.returnType == "I"
}
val replaceReference = getInstruction<ReferenceInstruction>(enumOrdinalIndex).reference
val replaceRegister = getInstruction<FiveRegisterInstruction>(enumOrdinalIndex).registerC

View file

@ -2,7 +2,6 @@ package app.revanced.patches.youtube.misc.backgroundplayback
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
@ -21,6 +20,7 @@ import app.revanced.patches.youtube.video.information.videoInformationPatch
import app.revanced.util.*
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
internal var prefBackgroundAndOfflineCategoryId = -1L
private set
@ -86,7 +86,7 @@ val removeBackgroundPlaybackRestrictionsPatch = bytecodePatch(
// Enable background playback option in YouTube settings
backgroundPlaybackSettingsMethod.apply {
val booleanCalls = instructions.withIndex().filter {
it.value.methodReference?.returnType == "Z"
it.value.getReference<MethodReference>()?.returnType == "Z"
}
val settingsBooleanIndex = booleanCalls.elementAt(1).index

View file

@ -9,7 +9,9 @@ import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.shared.getEngagementPanelControllerMethodMatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import kotlin.properties.Delegates
private const val EXTENSION_CLASS_DESCRIPTOR =

View file

@ -1,12 +1,13 @@
package app.revanced.patches.youtube.misc.fix.backtoexitgesture
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.youtube.shared.mainActivityOnBackPressedMethod
import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/youtube/patches/FixBackToExitGesturePatch;"
@ -25,7 +26,7 @@ internal val fixBackToExitGesturePatch = bytecodePatch(
with(scrollPositionMethodMatch) {
navigate(immutableMethod).to(scrollPositionMethodMatch[0] + 1).stop().apply {
val index = indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_VIRTUAL && methodReference?.definingClass ==
opcode == Opcode.INVOKE_VIRTUAL && getReference<MethodReference>()?.definingClass ==
"Landroid/support/v7/widget/RecyclerView;"
}

View file

@ -2,16 +2,18 @@ package app.revanced.patches.youtube.misc.fix.playbackspeed
import app.revanced.patcher.accessFlags
import app.revanced.patcher.custom
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.gettingFirstImmutableMethodDeclaratively
import app.revanced.patcher.gettingFirstMethodDeclaratively
import app.revanced.patcher.opcodes
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversed
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
/**
* This method is usually used to set the initial speed (1.0x) when playback starts from the feed.
@ -38,5 +40,5 @@ internal val BytecodePatchContext.playbackSpeedInFeedsMethod by gettingFirstMeth
internal fun indexOfGetPlaybackSpeedInstruction(method: Method) = method.indexOfFirstInstructionReversed {
opcode == Opcode.IGET &&
fieldReference?.type == "F"
getReference<FieldReference>()?.type == "F"
}

View file

@ -5,11 +5,11 @@ import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod.Compan
import app.revanced.patcher.classDef
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
@ -40,7 +40,7 @@ val cronetImageURLHookPatch = bytecodePatch(
// The URL is required for the failure callback hook, but the URL field is obfuscated.
// Add a helper get method that returns the URL field.
val urlFieldInstruction = requestMethod.instructions.first {
val reference = it.fieldReference
val reference = it.getReference<FieldReference>()
it.opcode == Opcode.IPUT_OBJECT && reference?.type == "Ljava/lang/String;"
} as ReferenceInstruction

View file

@ -7,7 +7,6 @@ import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.reference
import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.patch.PatchException
@ -21,14 +20,19 @@ import app.revanced.patches.youtube.shared.mainActivityOnBackPressedMethod
import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
import app.revanced.util.findFreeRegister
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction31i
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
import com.android.tools.smali.dexlib2.util.MethodUtil
import java.util.logging.Logger
internal const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/shared/NavigationBar;"
@ -80,14 +84,14 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
val navigationEnumClassName = navigationEnumMethod.classDef.type
addHook(NavigationHook.SET_LAST_APP_NAVIGATION_ENUM) {
opcode == Opcode.INVOKE_STATIC &&
methodReference?.definingClass == navigationEnumClassName
getReference<MethodReference>()?.definingClass == navigationEnumClassName
}
// Hook the creation of navigation tab views.
val drawableTabMethod = pivotBarButtonsCreateDrawableViewMethod
addHook(NavigationHook.NAVIGATION_TAB_LOADED) predicate@{
MethodUtil.methodSignaturesMatch(
methodReference ?: return@predicate false,
getReference<MethodReference>() ?: return@predicate false,
drawableTabMethod,
)
}
@ -95,7 +99,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
if (is_20_21_or_greater && !is_20_28_or_greater) {
addHook(NavigationHook.NAVIGATION_TAB_LOADED) predicate@{
MethodUtil.methodSignaturesMatch(
methodReference ?: return@predicate false,
getReference<MethodReference>() ?: return@predicate false,
pivotBarButtonsCreateResourceIntViewMethod,
)
}
@ -103,7 +107,7 @@ val navigationBarHookPatch = bytecodePatch(description = "Hooks the active navig
addHook(NavigationHook.NAVIGATION_IMAGE_RESOURCE_TAB_LOADED) predicate@{
MethodUtil.methodSignaturesMatch(
methodReference ?: return@predicate false,
getReference<MethodReference>() ?: return@predicate false,
pivotBarButtonsCreateResourceStyledViewMethod,
)
}

View file

@ -1,7 +1,6 @@
package app.revanced.patches.youtube.video.codecs
import app.revanced.patcher.extensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.resources.addResources
@ -11,7 +10,9 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
import app.revanced.patches.youtube.misc.settings.settingsPatch
import app.revanced.util.getReference
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/youtube/patches/DisableVideoCodecsPatch;"
@ -34,7 +35,7 @@ val disableVideoCodecsPatch = bytecodePatch(
return@filterMap null
}
val reference = instruction.methodReference
val reference = instruction.getReference<MethodReference>()
if (reference?.definingClass == "Landroid/view/Display\$HdrCapabilities;" && reference.name == "getSupportedHdrTypes") {
return@filterMap instruction to instructionIndex
}

View file

@ -23,6 +23,7 @@ import app.revanced.patches.youtube.video.videoid.hookVideoId
import app.revanced.patches.youtube.video.videoid.videoIdPatch
import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.addStaticFieldToExtension
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.patcher.patch.PatchException
import com.android.tools.smali.dexlib2.AccessFlags
@ -104,7 +105,7 @@ val videoInformationPatch = bytecodePatch(
// Find the location of the first invoke-direct call
// and extract the register storing the 'this' object reference.
val initThisIndex = playerInitMethod.indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_DIRECT && methodReference?.name == "<init>"
opcode == Opcode.INVOKE_DIRECT && getReference<MethodReference>()?.name == "<init>"
}
playerInitInsertRegister =
playerInitMethod.getInstruction<FiveRegisterInstruction>(initThisIndex).registerC
@ -122,7 +123,7 @@ val videoInformationPatch = bytecodePatch(
mdxInitMethod = classDef.methods.first { MethodUtil.isConstructor(it) }
val initThisIndex = mdxInitMethod.indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_DIRECT && methodReference?.name == "<init>"
opcode == Opcode.INVOKE_DIRECT && getReference<MethodReference>()?.name == "<init>"
}
mdxInitInsertRegister =
mdxInitMethod.getInstruction<FiveRegisterInstruction>(initThisIndex).registerC
@ -200,7 +201,7 @@ val videoInformationPatch = bytecodePatch(
setPlaybackSpeedMethodReference = getInstruction<ReferenceInstruction>(
indexOfFirstInstructionOrThrow(speedSelectionValueInstructionIndex) {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.parameterTypes?.size == 1 && reference.parameterTypes.first() == "F"
}
).reference as MethodReference
@ -230,7 +231,7 @@ val videoInformationPatch = bytecodePatch(
setPlaybackSpeedClassFieldReference = getInstruction<ReferenceInstruction>(
indexOfFirstInstructionOrThrow(speedSelectionValueInstructionIndex) {
fieldReference?.type?.startsWith("L") == true
getReference<FieldReference>()?.type?.startsWith("L") == true
}
).reference as FieldReference
@ -397,6 +398,7 @@ val videoInformationPatch = bytecodePatch(
// Detect video quality changes and override the current quality.
videoQualitySetterMethod.immutableClassDef.getSetVideoQualityMethod().let {
it
// This instruction refers to the field with the type that contains the setQuality method.
val onItemClickListenerClassReference =
it.getInstruction<ReferenceInstruction>(0).reference

View file

@ -21,7 +21,9 @@ import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.MethodParameter
import com.android.tools.smali.dexlib2.iface.instruction.*
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
import com.android.tools.smali.dexlib2.iface.reference.Reference
import com.android.tools.smali.dexlib2.iface.reference.StringReference
import com.android.tools.smali.dexlib2.iface.value.*
import com.android.tools.smali.dexlib2.immutable.ImmutableField
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod
@ -38,7 +40,7 @@ import kotlin.collections.remove
*/
private fun Method.findInstructionIndexFromToString(fieldName: String): Int {
val stringIndex = indexOfFirstInstruction {
val reference = stringReference
val reference = getReference<StringReference>()
reference?.string?.contains(fieldName) == true
}
if (stringIndex < 0) {
@ -48,7 +50,7 @@ private fun Method.findInstructionIndexFromToString(fieldName: String): Int {
// Find use of the string with a StringBuilder.
val stringUsageIndex = indexOfFirstInstruction(stringIndex) {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == "Ljava/lang/StringBuilder;" &&
(this as? FiveRegisterInstruction)?.registerD == stringRegister
}
@ -58,7 +60,7 @@ private fun Method.findInstructionIndexFromToString(fieldName: String): Int {
// Find the next usage of StringBuilder, which should be the desired field.
val fieldUsageIndex = indexOfFirstInstruction(stringUsageIndex + 1) {
val reference = methodReference
val reference = getReference<MethodReference>()
reference?.definingClass == "Ljava/lang/StringBuilder;" && reference.name == "append"
}
if (fieldUsageIndex < 0) {
@ -102,7 +104,7 @@ internal fun Method.findMethodFromToString(fieldName: String): MutableMethod {
*/
internal fun Method.findFieldFromToString(fieldName: String): FieldReference {
val methodUsageIndex = findInstructionIndexFromToString(fieldName)
return getInstruction<ReferenceInstruction>(methodUsageIndex).fieldReference!!
return getInstruction<ReferenceInstruction>(methodUsageIndex).getReference<FieldReference>()!!
}
/**
@ -378,8 +380,6 @@ fun BytecodePatchContext.traverseClassHierarchy(targetClass: MutableClassDef, ca
* if the [Instruction] is not a [ReferenceInstruction] or the [Reference] is not of type [T].
* @see ReferenceInstruction
*/
@Deprecated("Instead use `methodReference`, `fieldReference`, `typeReference` or `stringReference`")
@Suppress("unused")
inline fun <reified T : Reference> Instruction.getReference() = (this as? ReferenceInstruction)?.reference as? T
/**

View file

@ -2,7 +2,6 @@ package app.revanced.util
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.reference
import app.revanced.util.FreeRegisterProvider.Companion.conditionalBranchOpcodes
import app.revanced.util.FreeRegisterProvider.Companion.logFreeRegisterSearch
import app.revanced.util.FreeRegisterProvider.Companion.returnOpcodes
@ -346,7 +345,7 @@ private fun Method.findFreeRegistersInternal(
// If it appears more than once, it's also read.
if (occurrences <= 1) {
if (logFreeRegisterSearch) println("Found free register at $i: $writeRegister " +
"opcode: " + instruction.opcode + " reference: " + (instruction.reference))
"opcode: " + instruction.opcode + " reference: " + (instruction.getReference()))
freeRegisters.add(writeRegister)
// If the requested number of free registers is found and this is not a branch,
// then no additional searching is needed.