youtube patches work now

This commit is contained in:
oSumAtrIX 2026-01-30 16:14:35 +01:00
parent acac6e960c
commit 2ea26b02ea
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
28 changed files with 181 additions and 184 deletions

View file

@ -5,6 +5,7 @@ import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.instructions import app.revanced.patcher.instructions
import app.revanced.patcher.invoke import app.revanced.patcher.invoke
import app.revanced.patcher.name import app.revanced.patcher.name
import app.revanced.patcher.opcodes
import app.revanced.patches.shared.misc.extension.extensionHook import app.revanced.patches.shared.misc.extension.extensionHook
import app.revanced.util.getReference import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionOrThrow
@ -29,16 +30,16 @@ internal val startActivityInitHook = extensionHook(
) { ) {
name("onCreate") name("onCreate")
definingClass { endsWith("/StartActivity;") } definingClass { endsWith("/StartActivity;") }
instructions( opcodes(
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT(), Opcode.MOVE_RESULT,
Opcode.CONST_4(), Opcode.CONST_4,
Opcode.IF_EQZ(), Opcode.IF_EQZ,
Opcode.CONST(), Opcode.CONST,
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
Opcode.IPUT_OBJECT(), Opcode.IPUT_OBJECT,
Opcode.IPUT_BOOLEAN(), Opcode.IPUT_BOOLEAN,
Opcode.INVOKE_VIRTUAL(), // Calls startActivity.getApplicationContext(). Opcode.INVOKE_VIRTUAL, // Calls startActivity.getApplicationContext().
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
) )
} }

View file

@ -5,6 +5,7 @@ import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.instructions import app.revanced.patcher.instructions
import app.revanced.patcher.invoke import app.revanced.patcher.invoke
import app.revanced.patcher.name import app.revanced.patcher.name
import app.revanced.patcher.opcodes
import app.revanced.patches.shared.misc.extension.extensionHook import app.revanced.patches.shared.misc.extension.extensionHook
import app.revanced.util.getReference import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionOrThrow
@ -29,12 +30,12 @@ internal val homeActivityInitHook = extensionHook(
) { ) {
name("onCreate") name("onCreate")
definingClass { endsWith("/HomeActivity;") } definingClass { endsWith("/HomeActivity;") }
instructions( opcodes(
Opcode.CONST_STRING(), Opcode.CONST_STRING,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.IF_NEZ(), Opcode.IF_NEZ,
Opcode.INVOKE_VIRTUAL(), // Calls getApplicationContext(). Opcode.INVOKE_VIRTUAL, // Calls getApplicationContext().
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
) )
} }

View file

@ -20,24 +20,22 @@ internal val BytecodePatchContext.screenMapperMethodMatch by composingFirstMetho
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returnType("Lnl/nu/android/bff/domain/models/screen/ScreenEntity;") returnType("Lnl/nu/android/bff/domain/models/screen/ScreenEntity;")
parameterTypes("Lnl/nu/performance/api/client/objects/Screen;") parameterTypes("Lnl/nu/performance/api/client/objects/Screen;")
instructions( opcodes(
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.IF_EQZ(), Opcode.IF_EQZ,
Opcode.CHECK_CAST(), Opcode.CHECK_CAST,
) )
} }
internal val BytecodePatchContext.nextPageRepositoryImplMethodMatch by composingFirstMethod { internal val BytecodePatchContext.nextPageRepositoryImplMethodMatch by composingFirstMethod {
definingClass("Lnl/nu/android/bff/data/repositories/NextPageRepositoryImpl;")
name("mapToPage")
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
returnType("Lnl/nu/android/bff/domain/models/Page;") returnType("Lnl/nu/android/bff/domain/models/Page;")
parameterTypes("Lnl/nu/performance/api/client/PacResponse;", "Ljava/lang/String;") parameterTypes("Lnl/nu/performance/api/client/PacResponse;", "Ljava/lang/String;")
opcodes(
definingClass("Lnl/nu/android/bff/data/repositories/NextPageRepositoryImpl;") Opcode.MOVE_RESULT_OBJECT,
name("mapToPage") Opcode.IF_EQZ,
Opcode.CHECK_CAST,
instructions(
Opcode.MOVE_RESULT_OBJECT(),
Opcode.IF_EQZ(),
Opcode.CHECK_CAST(),
) )
} }

View file

@ -3,6 +3,7 @@ package app.revanced.patches.photomath.detection.deviceid
import app.revanced.patcher.gettingFirstMutableMethodDeclaratively import app.revanced.patcher.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.instructions import app.revanced.patcher.instructions
import app.revanced.patcher.invoke import app.revanced.patcher.invoke
import app.revanced.patcher.opcodes
import app.revanced.patcher.parameterTypes import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType import app.revanced.patcher.returnType
@ -11,16 +12,16 @@ import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.getDeviceIdMethod by gettingFirstMutableMethodDeclaratively { internal val BytecodePatchContext.getDeviceIdMethod by gettingFirstMutableMethodDeclaratively {
returnType("Ljava/lang/String;") returnType("Ljava/lang/String;")
parameterTypes() parameterTypes()
instructions( opcodes(
Opcode.SGET_OBJECT(), Opcode.SGET_OBJECT,
Opcode.IGET_OBJECT(), Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.IF_NEZ(), Opcode.IF_NEZ,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
) )
} }

View file

@ -3,18 +3,19 @@ package app.revanced.patches.photomath.detection.signature
import app.revanced.patcher.composingFirstMethod import app.revanced.patcher.composingFirstMethod
import app.revanced.patcher.instructions import app.revanced.patcher.instructions
import app.revanced.patcher.invoke import app.revanced.patcher.invoke
import app.revanced.patcher.opcodes
import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.patch.BytecodePatchContext
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.checkSignatureMethodMatch by composingFirstMethod("SHA") { internal val BytecodePatchContext.checkSignatureMethodMatch by composingFirstMethod("SHA") {
instructions( opcodes(
Opcode.CONST_STRING(), Opcode.CONST_STRING,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT(), Opcode.MOVE_RESULT,
) )
} }

View file

@ -10,11 +10,11 @@ internal val BytecodePatchContext.hideUpdatePopupMethod by gettingFirstMutableMe
definingClass("Lcom/microblink/photomath/main/activity/MainActivity;") definingClass("Lcom/microblink/photomath/main/activity/MainActivity;")
accessFlags(AccessFlags.FINAL, AccessFlags.PUBLIC) accessFlags(AccessFlags.FINAL, AccessFlags.PUBLIC)
returnType("V") returnType("V")
instructions( opcodes(
Opcode.CONST_HIGH16(), Opcode.CONST_HIGH16,
Opcode.INVOKE_VIRTUAL(), // ViewPropertyAnimator.alpha(1.0f) Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.alpha(1.0f)
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST_WIDE_16(), Opcode.CONST_WIDE_16,
Opcode.INVOKE_VIRTUAL(), // ViewPropertyAnimator.setDuration(1000L) Opcode.INVOKE_VIRTUAL, // ViewPropertyAnimator.setDuration(1000L)
) )
} }

View file

@ -12,11 +12,11 @@ internal val BytecodePatchContext.enterServerInsertedAdBreakStateMethod by getti
accessFlags(AccessFlags.PUBLIC) accessFlags(AccessFlags.PUBLIC)
parameterTypes("Lcom/amazon/avod/fsm/Trigger;") parameterTypes("Lcom/amazon/avod/fsm/Trigger;")
returnType("V") returnType("V")
instructions( opcodes(
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST_4(), Opcode.CONST_4,
Opcode.CONST_4() Opcode.CONST_4,
) )
} }
@ -25,9 +25,9 @@ internal val BytecodePatchContext.doTriggerMethod by gettingFirstMutableMethodDe
definingClass("Lcom/amazon/avod/fsm/StateBase;") definingClass("Lcom/amazon/avod/fsm/StateBase;")
accessFlags(AccessFlags.PROTECTED) accessFlags(AccessFlags.PROTECTED)
returnType("V") returnType("V")
instructions( opcodes(
Opcode.IGET_OBJECT(), Opcode.IGET_OBJECT,
Opcode.INVOKE_INTERFACE(), Opcode.INVOKE_INTERFACE,
Opcode.RETURN_VOID() Opcode.RETURN_VOID,
) )
} }

View file

@ -8,15 +8,15 @@ import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.createOkHttpClientMethod by gettingFirstMutableMethodDeclaratively { internal val BytecodePatchContext.createOkHttpClientMethod by gettingFirstMutableMethodDeclaratively {
accessFlags(AccessFlags.PRIVATE) accessFlags(AccessFlags.PRIVATE)
instructions( opcodes(
Opcode.NEW_INSTANCE(), Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT(), Opcode.INVOKE_DIRECT,
Opcode.NEW_INSTANCE(), Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT(), Opcode.INVOKE_DIRECT,
Opcode.NEW_INSTANCE(), Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT(), Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT() Opcode.MOVE_RESULT_OBJECT,
) )
custom { immutableClassDef.sourceFile == "RedGifsAPIv2.java" } custom { immutableClassDef.sourceFile == "RedGifsAPIv2.java" }
} }

View file

@ -9,18 +9,18 @@ import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.authUtilityUserAgentMethod by gettingFirstMutableMethodDeclaratively { internal val BytecodePatchContext.authUtilityUserAgentMethod by gettingFirstMutableMethodDeclaratively {
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
returnType("Ljava/lang/String;") returnType("Ljava/lang/String;")
instructions(Opcode.APUT_OBJECT()) opcodes(Opcode.APUT_OBJECT)
custom { immutableClassDef.sourceFile == "AuthUtility.java" } custom { immutableClassDef.sourceFile == "AuthUtility.java" }
} }
internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively { internal val BytecodePatchContext.getClientIdMethod by gettingFirstMutableMethodDeclaratively {
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
returnType("L") returnType("L")
instructions( opcodes(
Opcode.CONST(), Opcode.CONST,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.RETURN_OBJECT(), Opcode.RETURN_OBJECT,
) )
custom { immutableClassDef.sourceFile == "AuthUtility.java" } custom { immutableClassDef.sourceFile == "AuthUtility.java" }
} }

View file

@ -5,6 +5,7 @@ import app.revanced.patcher.definingClass
import app.revanced.patcher.gettingFirstMutableMethodDeclaratively import app.revanced.patcher.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.instructions import app.revanced.patcher.instructions
import app.revanced.patcher.invoke import app.revanced.patcher.invoke
import app.revanced.patcher.opcodes
import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType import app.revanced.patcher.returnType
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
@ -13,13 +14,13 @@ import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.detectPiracyMethod by gettingFirstMutableMethodDeclaratively { internal val BytecodePatchContext.detectPiracyMethod by gettingFirstMutableMethodDeclaratively {
accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC) accessFlags(AccessFlags.PRIVATE, AccessFlags.STATIC)
returnType("V") returnType("V")
instructions( opcodes(
Opcode.NEW_INSTANCE(), Opcode.NEW_INSTANCE,
Opcode.CONST_16(), Opcode.CONST_16,
Opcode.CONST_WIDE_16(), Opcode.CONST_WIDE_16,
Opcode.INVOKE_DIRECT(), Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
Opcode.RETURN_VOID(), Opcode.RETURN_VOID,
) )
definingClass { endsWith("ProcessLifeCyleListener;") } definingClass { endsWith("ProcessLifeCyleListener;") }
} }

View file

@ -24,12 +24,12 @@ internal val BytecodePatchContext.getUserAgentMethod by gettingFirstMutableMetho
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC) accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
returnType("Ljava/lang/String;") returnType("Ljava/lang/String;")
parameterTypes() parameterTypes()
instructions( opcodes(
Opcode.NEW_ARRAY(), Opcode.NEW_ARRAY,
Opcode.CONST_4(), Opcode.CONST_4,
Opcode.INVOKE_STATIC(), Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.APUT_OBJECT(), Opcode.APUT_OBJECT,
Opcode.CONST(), Opcode.CONST,
) )
} }

View file

@ -1,33 +1,30 @@
package app.revanced.patches.reddit.customclients.sync.detection.piracy package app.revanced.patches.reddit.customclients.sync.detection.piracy
import app.revanced.patcher.gettingFirstMutableMethodDeclarativelyOrNull
import app.revanced.patcher.invoke
import app.revanced.patcher.accessFlags import app.revanced.patcher.accessFlags
import app.revanced.patcher.custom import app.revanced.patcher.custom
import app.revanced.patcher.extensions.instructions import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.extensions.reference import app.revanced.patcher.extensions.reference
import app.revanced.patcher.gettingFirstMutableMethodDeclarativelyOrNull
import app.revanced.patcher.instructions import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patcher.opcodes
import app.revanced.patcher.patch.BytecodePatchContext import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType import app.revanced.patcher.returnType
import app.revanced.patcher.type
import com.android.tools.smali.dexlib2.AccessFlags import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.Opcode
internal val BytecodePatchContext.detectPiracyMethodOrNull by gettingFirstMutableMethodDeclarativelyOrNull( internal val BytecodePatchContext.detectPiracyMethodOrNull by gettingFirstMutableMethodDeclarativelyOrNull(
"Lcom/github/javiersantos/piracychecker/PiracyChecker;" "Lcom/github/javiersantos/piracychecker/PiracyChecker;",
) { ) {
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
returnType("V") returnType("V")
instructions( opcodes(
Opcode.NEW_INSTANCE(), Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT(), Opcode.INVOKE_DIRECT,
Opcode.NEW_INSTANCE(), Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT(), Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL,
) )
// TODO: Convert to instructions() extension. instructions(type("Lcom/github/javiersantos/piracychecker/PiracyChecker;"))
custom { }
instructions.any {
it.reference.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;"
}
}
}

View file

@ -30,7 +30,7 @@ internal val BytecodePatchContext.lithoOnBoundsChangeMethodMatch by composingFir
5, 5,
allOf( allOf(
Opcode.IGET_OBJECT(), Opcode.IGET_OBJECT(),
field { type == "Landroid/graphics/Path;" && definingClass == methodDefiningClass }, field { type == "Landroid/graphics/Paint;" && definingClass == methodDefiningClass },
), ),
), ),
after( after(

View file

@ -9,10 +9,10 @@ internal val BytecodePatchContext.youTubeCopyTextMethodMatch by composingFirstMe
parameterTypes("L", "Ljava/util/Map;") parameterTypes("L", "Ljava/util/Map;")
instructions( instructions(
Opcode.IGET_OBJECT(), Opcode.IGET_OBJECT(),
after(0..2, "text/plain"()), afterAtMost(2, "text/plain"()),
after(0..2, method("newPlainText")), afterAtMost(2, method("newPlainText")),
after(0..2, Opcode.MOVE_RESULT_OBJECT()), afterAtMost(2, Opcode.MOVE_RESULT_OBJECT()),
after(0..2, method("setPrimaryClip")), afterAtMost(2, method("setPrimaryClip")),
) )
} }
@ -21,9 +21,9 @@ internal val BytecodePatchContext.youTubeSystemShareSheetMethodMatch by composin
parameterTypes("L", "Ljava/util/Map;") parameterTypes("L", "Ljava/util/Map;")
instructions( instructions(
method("setClassName"), method("setClassName"),
after(0..4, method("iterator")), afterAtMost(4, method("iterator")),
after(0..15, allOf(Opcode.IGET_OBJECT(), type("Ljava/lang/String;"))), afterAtMost(15, allOf(Opcode.IGET_OBJECT(), field { type == "Ljava/lang/String;" })),
after(0..15, method("putExtra")), afterAtMost(15, method("putExtra")),
) )
} }

View file

@ -1,5 +1,6 @@
package app.revanced.patches.shared.misc.privacy package app.revanced.patches.shared.misc.privacy
import app.revanced.com.android.tools.smali.dexlib2.mutable.MutableMethod
import app.revanced.patcher.Match import app.revanced.patcher.Match
import app.revanced.patcher.extensions.addInstructions import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.getInstruction
@ -15,6 +16,7 @@ import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.util.addInstructionsAtControlFlowLabel import app.revanced.util.addInstructionsAtControlFlowLabel
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction 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.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
private const val EXTENSION_CLASS_DESCRIPTOR = private const val EXTENSION_CLASS_DESCRIPTOR =
"Lapp/revanced/extension/shared/patches/SanitizeSharingLinksPatch;" "Lapp/revanced/extension/shared/patches/SanitizeSharingLinksPatch;"
@ -58,40 +60,34 @@ internal fun sanitizeSharingLinksPatch(
}, },
) )
fun Match.hookUrlString(matchIndex: Int) { fun Match.hook(
val index = get(matchIndex) getInsertIndex: List<Int>.() -> Int,
getUrlRegister: MutableMethod.(insertIndex: Int) -> Int,
val urlRegister = method.getInstruction<OneRegisterInstruction>(index).registerA ) {
val insertIndex = indices[0].getInsertIndex()
val urlRegister = method.getUrlRegister(insertIndex)
method.addInstructions( method.addInstructions(
index + 1, insertIndex,
""" """
invoke-static { v$urlRegister }, $EXTENSION_CLASS_DESCRIPTOR->sanitize(Ljava/lang/String;)Ljava/lang/String; invoke-static {v$urlRegister}, $EXTENSION_CLASS_DESCRIPTOR->sanitize(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$urlRegister move-result-object v$urlRegister
""", """,
) )
} }
fun Match.hookIntentPutExtra(matchIndex: Int) { // YouTube share sheet.\
val index = get(matchIndex) youTubeShareSheetMethodMatch.hook(getInsertIndex = { first() + 1 }) { insertIndex ->
val urlRegister = method.getInstruction<FiveRegisterInstruction>(index).registerE getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
method.addInstructionsAtControlFlowLabel(
index,
"""
invoke-static { v$urlRegister }, $EXTENSION_CLASS_DESCRIPTOR->sanitize(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$urlRegister
""",
)
} }
// YouTube share sheet copy link.
youTubeCopyTextMethodMatch.hookUrlString(0)
// YouTube share sheet other apps.
youTubeShareSheetMethodMatch.hookIntentPutExtra(3)
// Native system share sheet. // Native system share sheet.
youTubeSystemShareSheetMethodMatch.hookIntentPutExtra(3) youTubeSystemShareSheetMethodMatch.hook(getInsertIndex = { last() }) { insertIndex ->
getInstruction<OneRegisterInstruction>(insertIndex - 1).registerA
}
youTubeCopyTextMethodMatch.hook(getInsertIndex = { first() + 2 }) { insertIndex ->
getInstruction<TwoRegisterInstruction>(insertIndex - 2).registerA
}
} }
} }

View file

@ -1,6 +1,7 @@
package app.revanced.patches.shared.misc.spoof package app.revanced.patches.shared.misc.spoof
import app.revanced.patcher.accessFlags import app.revanced.patcher.accessFlags
import app.revanced.patcher.anyField
import app.revanced.patcher.composingFirstMethod import app.revanced.patcher.composingFirstMethod
import app.revanced.patcher.custom import app.revanced.patcher.custom
import app.revanced.patcher.definingClass import app.revanced.patcher.definingClass
@ -23,21 +24,21 @@ import com.android.tools.smali.dexlib2.iface.Method
internal val BytecodePatchContext.buildInitPlaybackRequestMethodMatch by composingFirstMethod("Content-Type", "Range") { internal val BytecodePatchContext.buildInitPlaybackRequestMethodMatch by composingFirstMethod("Content-Type", "Range") {
returnType($$"Lorg/chromium/net/UrlRequest$Builder;") returnType($$"Lorg/chromium/net/UrlRequest$Builder;")
instructions( opcodes(
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT(), // Moves the request URI string to a register to build the request with. Opcode.IGET_OBJECT, // Moves the request URI string to a register to build the request with.
) )
} }
internal val BytecodePatchContext.buildPlayerRequestURIMethodMatch by composingFirstMethod("key", "asig") { internal val BytecodePatchContext.buildPlayerRequestURIMethodMatch by composingFirstMethod("key", "asig") {
returnType("Ljava/lang/String;") returnType("Ljava/lang/String;")
instructions( opcodes(
Opcode.INVOKE_VIRTUAL(), // Register holds player request URI. Opcode.INVOKE_VIRTUAL, // Register holds player request URI.
Opcode.MOVE_RESULT_OBJECT(), Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT(), Opcode.IPUT_OBJECT,
Opcode.IGET_OBJECT(), Opcode.IGET_OBJECT,
Opcode.MONITOR_EXIT(), Opcode.MONITOR_EXIT,
Opcode.RETURN_OBJECT(), Opcode.RETURN_OBJECT,
) )
} }
@ -101,17 +102,15 @@ internal val BytecodePatchContext.protobufClassParseByteBufferMethod by gettingF
internal val BytecodePatchContext.createStreamingDataMethodMatch by composingFirstMethod { internal val BytecodePatchContext.createStreamingDataMethodMatch by composingFirstMethod {
accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR) accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR)
parameterTypes("L") parameterTypes("L")
instructions( opcodes(
Opcode.IPUT_OBJECT(), Opcode.IPUT_OBJECT,
Opcode.IGET_OBJECT(), Opcode.IGET_OBJECT,
Opcode.IF_NEZ(), Opcode.IF_NEZ,
Opcode.SGET_OBJECT(), Opcode.SGET_OBJECT,
Opcode.IPUT_OBJECT(), Opcode.IPUT_OBJECT,
) )
custom { custom {
immutableClassDef.fields.any { field -> immutableClassDef.anyField { name == "a" && type.endsWith($$"/StreamingDataOuterClass$StreamingData;") }
field.name == "a" && field.type.endsWith($$"/StreamingDataOuterClass$StreamingData;")
}
} }
} }

View file

@ -290,7 +290,7 @@ internal fun spoofVideoStreamsPatch(
Opcode.SGET_OBJECT, Opcode.SGET_OBJECT,
Opcode.RETURN_OBJECT, Opcode.RETURN_OBJECT,
) )
custom { parameterTypes.isEmpty() } custom { !parameterTypes.isEmpty() }
} }
sabrMethod.addInstructionsWithLabels( sabrMethod.addInstructionsWithLabels(
0, 0,

View file

@ -11,10 +11,10 @@ import kotlin.properties.ReadOnlyProperty
internal val BytecodePatchContext.jsonHookPatchMethodMatch by ReadOnlyProperty { context, _ -> internal val BytecodePatchContext.jsonHookPatchMethodMatch by ReadOnlyProperty { context, _ ->
context.firstClassDef(JSON_HOOK_PATCH_CLASS_DESCRIPTOR).firstMethodComposite { context.firstClassDef(JSON_HOOK_PATCH_CLASS_DESCRIPTOR).firstMethodComposite {
name("<clinit>") name("<clinit>")
instructions( opcodes(
Opcode.INVOKE_INTERFACE(), // Add dummy hook to hooks list. Opcode.INVOKE_INTERFACE, // Add dummy hook to hooks list.
// Add hooks to the hooks list. // Add hooks to the hooks list.
Opcode.INVOKE_STATIC(), // Call buildList. Opcode.INVOKE_STATIC, // Call buildList.
) )
} }
} }

View file

@ -130,8 +130,8 @@ internal val BytecodePatchContext.showFloatingMicrophoneButtonMethodMatch by com
parameterTypes() parameterTypes()
instructions( instructions(
ResourceType.ID("fab"), ResourceType.ID("fab"),
afterAtMost(10, allOf(Opcode.CHECK_CAST(), "/FloatingActionButton;"())), afterAtMost(10, allOf(Opcode.CHECK_CAST(), type { endsWith("/FloatingActionButton;") })),
afterAtMost(15, Opcode.IGET_BOOLEAN()), afterAtMost(10, Opcode.IGET_BOOLEAN()),
) )
} }

View file

@ -66,7 +66,7 @@ internal val ClassDef.miniplayerModernCloseButtonMethodMatch by ClassDefComposin
parameterTypes() parameterTypes()
instructions( instructions(
ResourceType.ID("modern_miniplayer_close"), ResourceType.ID("modern_miniplayer_close"),
allOf(Opcode.CHECK_CAST(), "Landroid/widget/ImageView;"()), allOf(Opcode.CHECK_CAST(), type("Landroid/widget/ImageView;")),
) )
} }
@ -79,7 +79,7 @@ internal val ClassDef.miniplayerModernExpandButtonMethodMatch by ClassDefComposi
parameterTypes() parameterTypes()
instructions( instructions(
ResourceType.ID("modern_miniplayer_expand"), ResourceType.ID("modern_miniplayer_expand"),
allOf(Opcode.CHECK_CAST(), "Landroid/widget/ImageView;"()), allOf(Opcode.CHECK_CAST(), type("Landroid/widget/ImageView;")),
) )
} }

View file

@ -80,11 +80,11 @@ internal val BytecodePatchContext.rollingNumberTextViewMethod by gettingFirstMut
parameterTypes("L", "F", "F") parameterTypes("L", "F", "F")
instructions( instructions(
Opcode.IPUT(), Opcode.IPUT(),
anyOf(Opcode.INVOKE_DIRECT(), Opcode.INVOKE_VIRTUAL()), after(anyOf(Opcode.INVOKE_DIRECT(), Opcode.INVOKE_VIRTUAL())),
Opcode.IPUT_OBJECT(), after(Opcode.IPUT_OBJECT()),
Opcode.IGET_OBJECT(), after(Opcode.IGET_OBJECT()),
Opcode.INVOKE_VIRTUAL(), after(Opcode.INVOKE_VIRTUAL()),
Opcode.RETURN_VOID(), after(Opcode.RETURN_VOID()),
) )
custom { custom {
immutableClassDef.superclass == "Landroid/support/v7/widget/AppCompatTextView;" || immutableClassDef.superclass == immutableClassDef.superclass == "Landroid/support/v7/widget/AppCompatTextView;" || immutableClassDef.superclass ==

View file

@ -4,6 +4,7 @@ import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.extensions.fieldReference import app.revanced.patcher.extensions.fieldReference
import app.revanced.patcher.extensions.getInstruction import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.methodReference import app.revanced.patcher.extensions.methodReference
import app.revanced.patcher.extensions.typeReference
import app.revanced.patcher.immutableClassDef import app.revanced.patcher.immutableClassDef
import app.revanced.patcher.patch.PatchException import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.bytecodePatch
@ -153,7 +154,7 @@ val returnYouTubeDislikePatch = bytecodePatch(
} else { } else {
insertIndex = indexOfFirstInstructionOrThrow { insertIndex = indexOfFirstInstructionOrThrow {
opcode == Opcode.NEW_INSTANCE && opcode == Opcode.NEW_INSTANCE &&
fieldReference?.type == textDataClassType typeReference?.type == textDataClassType
} }
val charSequenceIndex = indexOfFirstInstructionOrThrow(insertIndex) { val charSequenceIndex = indexOfFirstInstructionOrThrow(insertIndex) {

View file

@ -54,7 +54,7 @@ internal val BytecodePatchContext.reelPlaybackMethodMatch by composingFirstMetho
5, 5,
allOf( allOf(
Opcode.INVOKE_VIRTUAL(), Opcode.INVOKE_VIRTUAL(),
method { returnType == "I" && parameterTypes.count() == 1 && parameterTypes.first() == "L" }, method { returnType == "I" && parameterTypes.count() == 1 && parameterTypes.first().startsWith("L") },
), ),
), ),
) )

View file

@ -11,7 +11,7 @@ internal val BytecodePatchContext.toolBarButtonMethodMatch by composingFirstMeth
returnType("V") returnType("V")
instructions( instructions(
ResourceType.ID("menu_item_view"), ResourceType.ID("menu_item_view"),
allOf(Opcode.INVOKE_VIRTUAL(), method { returnType == "I" }), allOf(Opcode.INVOKE_INTERFACE(), method { returnType == "I" }),
after(Opcode.MOVE_RESULT()), after(Opcode.MOVE_RESULT()),
afterAtMost(6, allOf(Opcode.IGET_OBJECT(), field { type == "Landroid/widget/ImageView;" })), afterAtMost(6, allOf(Opcode.IGET_OBJECT(), field { type == "Landroid/widget/ImageView;" })),
afterAtMost(8, method { name == "getDrawable" && definingClass == "Landroid/content/res/Resources;" }), afterAtMost(8, method { name == "getDrawable" && definingClass == "Landroid/content/res/Resources;" }),

View file

@ -32,6 +32,7 @@ val cronetImageUrlHookPatch = bytecodePatch(
dependsOn(sharedExtensionPatch) dependsOn(sharedExtensionPatch)
apply { apply {
loadImageUrlMethod = messageDigestImageUrlParentMethod.immutableClassDef.getMessageDigestImageUrlMethod() loadImageUrlMethod = messageDigestImageUrlParentMethod.immutableClassDef.getMessageDigestImageUrlMethod()
loadImageSuccessCallbackMethod = onResponseStartedMethod.immutableClassDef.getOnSucceededMethod() loadImageSuccessCallbackMethod = onResponseStartedMethod.immutableClassDef.getOnSucceededMethod()
loadImageErrorCallbackMethod = onResponseStartedMethod.immutableClassDef.getOnFailureMethod() loadImageErrorCallbackMethod = onResponseStartedMethod.immutableClassDef.getOnFailureMethod()

View file

@ -57,8 +57,8 @@ internal val BytecodePatchContext.messageDigestImageUrlParentMethod by gettingFi
parameterTypes() parameterTypes()
instructions( instructions(
anyOf( anyOf(
"@#&=*+-_.,:!?()/~'%;$"(), string { equals("@#&=*+-_.,:!?()/~'%;$") },
"@#&=*+-_.,:!?()/~'%;$[]"(), // 20.38+ string { equals("@#&=*+-_.,:!?()/~'%;$[]") }, // 20.38+
), ),
) )
} }

View file

@ -96,15 +96,15 @@ val videoInformationPatch = bytecodePatch(
// Find the location of the first invoke-direct call // Find the location of the first invoke-direct call
// and extract the register storing the 'this' object reference. // and extract the register storing the 'this' object reference.
val initThisIndex = indexOfFirstInstructionOrThrow { val initThisIndex = playerInitMethod.indexOfFirstInstructionOrThrow {
opcode == Opcode.INVOKE_DIRECT && getReference<MethodReference>()?.name == "<init>" opcode == Opcode.INVOKE_DIRECT && getReference<MethodReference>()?.name == "<init>"
} }
playerInitInsertRegister = getInstruction<FiveRegisterInstruction>(initThisIndex).registerC playerInitInsertRegister = playerInitMethod.getInstruction<FiveRegisterInstruction>(initThisIndex).registerC
playerInitInsertIndex = initThisIndex + 1 playerInitInsertIndex = initThisIndex + 1
// Create extension interface methods. // Create extension interface methods.
addSeekInterfaceMethods( addSeekInterfaceMethods(
playVideoCheckVideoStreamingDataResponseMethod.classDef, playerInitMethod.classDef,
classDef.getSeekMethod(), classDef.getSeekMethod(),
classDef.getSeekRelativeMethod(), classDef.getSeekRelativeMethod(),
) )
@ -133,7 +133,7 @@ val videoInformationPatch = bytecodePatch(
val videoLengthMethodMatch = immutableClassDef.videoLengthMethodMatch val videoLengthMethodMatch = immutableClassDef.videoLengthMethodMatch
videoLengthMethodMatch.method.apply { videoLengthMethodMatch.method.apply {
val videoLengthRegisterIndex = videoLengthMethodMatch[-1] val videoLengthRegisterIndex = videoLengthMethodMatch[-1] - 2
val videoLengthRegister = getInstruction<OneRegisterInstruction>(videoLengthRegisterIndex).registerA val videoLengthRegister = getInstruction<OneRegisterInstruction>(videoLengthRegisterIndex).registerA
val dummyRegisterForLong = videoLengthRegister + 1 // required for long values since they are wide val dummyRegisterForLong = videoLengthRegister + 1 // required for long values since they are wide

View file

@ -42,7 +42,7 @@ internal val BytecodePatchContext.speedArrayGeneratorMethodMatch by composingFir
"0.0#"(), "0.0#"(),
7L(), 7L(),
Opcode.NEW_ARRAY(), Opcode.NEW_ARRAY(),
field { definingClass == "/PlayerConfigModel;" && type == "[F" }, field { definingClass.endsWith("/PlayerConfigModel;") && type == "[F" },
) )
} }