feat: update patches to latest version

Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
oSumAtrIX 2022-05-22 17:11:34 +02:00
parent c4c86b65fd
commit bad25dec1d
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
33 changed files with 64 additions and 207 deletions

View File

@ -29,10 +29,10 @@ class CodecsUnlockPatch : BytecodePatch(
val implementation = result.method.implementation!! val implementation = result.method.implementation!!
val instructionIndex = result.scanData.startIndex val instructionIndex = result.scanResult.startIndex
result = signatures.last().result!! result = signatures.last().result!!
val codecMethod = data.toMethodWalker(result.immutableMethod).walk(result.scanData.startIndex).getMethod() val codecMethod = data.toMethodWalker(result.immutableMethod).walk(result.scanResult.startIndex).getMethod()
implementation.replaceInstruction( implementation.replaceInstruction(
instructionIndex, instructionIndex,

View File

@ -28,7 +28,7 @@ class RemoveTasteBuilderPatch : BytecodePatch(
val result = signatures.first().result!! val result = signatures.first().result!!
val implementation = result.method.implementation!! val implementation = result.method.implementation!!
val insertIndex = result.scanData.endIndex - 8 val insertIndex = result.scanResult.endIndex - 8
val register = (implementation.instructions[insertIndex] as Instruction22c).registerA val register = (implementation.instructions[insertIndex] as Instruction22c).registerA

View File

@ -33,7 +33,7 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
val implementation = result.method.implementation!! val implementation = result.method.implementation!!
val pivotBarElementFieldRef = val pivotBarElementFieldRef =
(implementation.instructions[result.scanData.endIndex - 1] as Instruction22c).reference (implementation.instructions[result.scanResult.endIndex - 1] as Instruction22c).reference
val register = (implementation.instructions.first() as Instruction35c).registerC val register = (implementation.instructions.first() as Instruction35c).registerC
// first compile all the needed instructions // first compile all the needed instructions
@ -48,14 +48,14 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
// replace the instruction to retain the label at given index // replace the instruction to retain the label at given index
implementation.replaceInstruction( implementation.replaceInstruction(
result.scanData.endIndex - 1, instructionList[0] // invoke-interface result.scanResult.endIndex - 1, instructionList[0] // invoke-interface
) )
// do not forget to remove this instruction since we added it already // do not forget to remove this instruction since we added it already
instructionList.removeFirst() instructionList.removeFirst()
val exitInstruction = instructionList.last() // iput-object val exitInstruction = instructionList.last() // iput-object
implementation.addInstruction( implementation.addInstruction(
result.scanData.endIndex, exitInstruction result.scanResult.endIndex, exitInstruction
) )
// do not forget to remove this instruction since we added it already // do not forget to remove this instruction since we added it already
instructionList.removeLast() instructionList.removeLast()
@ -64,12 +64,12 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
instructionList.add( instructionList.add(
2, // if-le 2, // if-le
BuilderInstruction22t( BuilderInstruction22t(
Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(result.scanData.endIndex) Opcode.IF_LE, 1, 2, implementation.newLabelForIndex(result.scanResult.endIndex)
) )
) )
implementation.addInstructions( implementation.addInstructions(
result.scanData.endIndex, instructionList result.scanResult.endIndex, instructionList
) )
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.03.38", "17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.03.38", "17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -1697,7 +1697,7 @@ for (i in 0 until signatures.count()) {
val signature = signatures.elementAt(i) val signature = signatures.elementAt(i)
val result = signature.result!! val result = signature.result!!
val implementation = result.method.implementation!! val implementation = result.method.implementation!!
val index = result.scanData.startIndex val index = result.scanResult.startIndex
val instructions = implementation.instructions val instructions = implementation.instructions
val register = (instructions[index + (if (i < 2) -1 else 1)] as Instruction11x).registerA val register = (instructions[index + (if (i < 2) -1 else 1)] as Instruction11x).registerA

View File

@ -6,16 +6,16 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.signature.implementation.method.MethodSignature import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import app.revanced.patches.youtube.ad.home.annotation.PromotionsCompatibility
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
@Name("promoted-discovery-app-parent-signature") @Name("promoted-discovery-app-parent-signature")
@MatchingMethod( @MatchingMethod(
"Ljre;", "lP" "Ljqb;", "lG"
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility @PromotionsCompatibility
@Version("0.0.1") @Version("0.0.1")
object PromotedDiscoveryActionParentSignature : MethodSignature( object PromotedDiscoveryActionParentSignature : MethodSignature(
"V", "V",

View File

@ -6,17 +6,17 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.signature.implementation.method.MethodSignature import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import app.revanced.patches.youtube.ad.home.annotation.PromotionsCompatibility
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
@Name("promoted-discovery-action-parent-signature") @Name("promoted-discovery-action-parent-signature")
@MatchingMethod( @MatchingMethod(
"Ljqv;", "Ljqj;",
"lP" "lG"
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility @PromotionsCompatibility
@Version("0.0.1") @Version("0.0.1")
object PromotedDiscoveryAppParentSignature : MethodSignature( object PromotedDiscoveryAppParentSignature : MethodSignature(

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -6,17 +6,17 @@ import app.revanced.patcher.extensions.or
import app.revanced.patcher.signature.implementation.method.MethodSignature import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
@Name("show-video-ads-constructor-signature") @Name("show-video-ads-constructor-signature")
@MatchingMethod( @MatchingMethod(
"Laadb", "Laair",
"<init>", "<init>",
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility @VideoAdsCompatibility
@Version("0.0.1") @Version("0.0.1")
object ShowVideoAdsConstructorSignature : MethodSignature( object ShowVideoAdsConstructorSignature : MethodSignature(
"V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L"), listOf( "V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf("L", "L", "L"), listOf(

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.17.34") "com.google.android.youtube", arrayOf("17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -66,25 +66,25 @@ class EnableSeekbarTappingPatch : BytecodePatch(
val oMethod = tapSeekMethods["O"]!! val oMethod = tapSeekMethods["O"]!!
// get the required register // get the required register
val instruction = implementation.instructions[result.scanData.endIndex] val instruction = implementation.instructions[result.scanResult.endIndex]
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct register") if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC val register = (instruction as Instruction35c).registerC
// the instructions are written in reverse order. // the instructions are written in reverse order.
implementation.addInstructions( implementation.addInstructions(
result.scanData.endIndex + 1, """ result.scanResult.endIndex + 1, """
invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V
invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V
""".trimIndent().toInstructions() """.trimIndent().toInstructions()
) )
// if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label
val elseLabel = implementation.newLabelForIndex(result.scanData.endIndex + 1) val elseLabel = implementation.newLabelForIndex(result.scanResult.endIndex + 1)
implementation.addInstruction( implementation.addInstruction(
result.scanData.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) result.scanResult.endIndex + 1, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel)
) )
implementation.addInstructions( implementation.addInstructions(
result.scanData.endIndex + 1, """ result.scanResult.endIndex + 1, """
invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z
move-result v0 move-result v0
""".trimIndent().toInstructions() """.trimIndent().toInstructions()

View File

@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
@Name("enable-seekbar-tapping-parent") @Name("enable-seekbar-tapping-parent")
@MatchingMethod("Lzhj;", "J") @MatchingMethod("Lzmx;", "I")
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility @SeekbarTappingCompatibility
@Version("0.0.1") @Version("0.0.1")

View File

@ -11,7 +11,7 @@ import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
@Name("enable-seekbar-tapping-signature") @Name("enable-seekbar-tapping-signature")
@MatchingMethod("Lfao;", "onTouchEvent") @MatchingMethod("Lfbl;", "onTouchEvent")
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@SeekbarTappingCompatibility @SeekbarTappingCompatibility
@Version("0.0.1") @Version("0.0.1")

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -14,7 +14,7 @@ import java.io.File
@Patch @Patch
@Name("amoled") @Name("amoled")
@Description("Enables black theme (amoled mode)") @Description("Enables pure black theme.")
@AmoledCompatibility @AmoledCompatibility
@Version("0.0.1") @Version("0.0.1")
class AmoledPatch : ResourcePatch() { class AmoledPatch : ResourcePatch() {
@ -23,18 +23,13 @@ class AmoledPatch : ResourcePatch() {
val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element val resourcesNode = editor.file.getElementsByTagName("resources").item(0) as Element
for (i in 0 until resourcesNode.childNodes.length) { for (i in 0 until resourcesNode.childNodes.length) {
val node = resourcesNode.childNodes.item(i) as Element val node = resourcesNode.childNodes.item(i)
if (node !is Element) continue
node.nodeValue = when (node.getAttribute("name")) { val element = resourcesNode.childNodes.item(i) as Element
"yt_black1", element.textContent = when (element.getAttribute("name")) {
"yt_black1_opacity95", "yt_black1", "yt_black1_opacity95", "yt_black2", "yt_black3", "yt_black4", "yt_status_bar_background_dark" -> "@android:color/black"
"yt_black2", "yt_selected_nav_label_dark" -> "#ffdf0000"
"yt_black3",
"yt_black4",
"yt_status_bar_background_dark"
-> "@android:color/black"
"yt_selected_nav_label_dark"
-> "#ffdf0000"
else -> continue else -> continue
} }
} }

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -10,15 +10,15 @@ import app.revanced.patcher.patch.implementation.misc.PatchResult
import app.revanced.patcher.patch.implementation.misc.PatchResultError import app.revanced.patcher.patch.implementation.misc.PatchResultError
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
import app.revanced.patcher.util.smali.toInstruction import app.revanced.patcher.util.smali.toInstruction
import app.revanced.patches.youtube.layout.createbutton.annotations.CreateButtonCompatibility
import app.revanced.patches.youtube.layout.createbutton.signatures.CreateButtonSignature import app.revanced.patches.youtube.layout.createbutton.signatures.CreateButtonSignature
import app.revanced.patches.youtube.layout.minimizedplayback.annotations.MinimizedPlaybackCompatibility
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.formats.Instruction35c import org.jf.dexlib2.iface.instruction.formats.Instruction35c
@Patch @Patch
@Name("disable-create-button") @Name("disable-create-button")
@Description("Disable the create button.") @Description("Disable the create button.")
@MinimizedPlaybackCompatibility @CreateButtonCompatibility
@Version("0.0.1") @Version("0.0.1")
class CreateButtonRemoverPatch : BytecodePatch( class CreateButtonRemoverPatch : BytecodePatch(
listOf( listOf(
@ -30,14 +30,14 @@ class CreateButtonRemoverPatch : BytecodePatch(
// Get the required register which holds the view object we need to pass to the method hideCreateButton // Get the required register which holds the view object we need to pass to the method hideCreateButton
val implementation = result.method.implementation!! val implementation = result.method.implementation!!
val instruction = implementation.instructions[result.scanData.endIndex + 1] val instruction = implementation.instructions[result.scanResult.endIndex + 1]
if (instruction.opcode != Opcode.INVOKE_STATIC) if (instruction.opcode != Opcode.INVOKE_STATIC)
return PatchResultError("Could not find the correct register") return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC val register = (instruction as Instruction35c).registerC
// Hide the button view via proxy by passing it to the hideCreateButton method // Hide the button view via proxy by passing it to the hideCreateButton method
implementation.addInstruction( implementation.addInstruction(
result.scanData.endIndex + 1, result.scanResult.endIndex + 1,
"invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction() "invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction()
) )

View File

@ -12,7 +12,7 @@ import org.jf.dexlib2.Opcode
@Name("create-button-signature") @Name("create-button-signature")
@MatchingMethod( @MatchingMethod(
"Lkne", "z" "Lknw", "z"
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@CreateButtonCompatibility @CreateButtonCompatibility

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -12,7 +12,7 @@ import org.jf.dexlib2.Opcode
@Name("minimized-playback-manager-signature") @Name("minimized-playback-manager-signature")
@MatchingMethod( @MatchingMethod(
"Lype", "j" "Lyuf", "n"
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@MinimizedPlaybackCompatibility @MinimizedPlaybackCompatibility

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.17.34") "com.google.android.youtube", arrayOf("17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -51,7 +51,7 @@ class OldQualityLayoutPatch : BytecodePatch(
// if useOldStyleQualitySettings == true, jump over all instructions // if useOldStyleQualitySettings == true, jump over all instructions
val jmpInstruction = BuilderInstruction21t( val jmpInstruction = BuilderInstruction21t(
Opcode.IF_NEZ, 0, implementation.instructions[result.scanData.endIndex].location.labels.first() Opcode.IF_NEZ, 0, implementation.instructions[result.scanResult.endIndex].location.labels.first()
) )
implementation.addInstruction(5, jmpInstruction) implementation.addInstruction(5, jmpInstruction)
implementation.addInstructions( implementation.addInstructions(

View File

@ -4,7 +4,6 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.implementation.BytecodeData import app.revanced.patcher.data.implementation.BytecodeData
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.implementation.BytecodePatch import app.revanced.patcher.patch.implementation.BytecodePatch
import app.revanced.patcher.patch.implementation.misc.PatchResult import app.revanced.patcher.patch.implementation.misc.PatchResult
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
@ -12,7 +11,7 @@ import app.revanced.patcher.util.smali.toInstruction
import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility
import app.revanced.patches.youtube.layout.reels.signatures.HideReelsSignature import app.revanced.patches.youtube.layout.reels.signatures.HideReelsSignature
@Patch //@Patch TODO: converted to litho
@Name("hide-reels") @Name("hide-reels")
@Description("Hide reels on the page.") @Description("Hide reels on the page.")
@HideReelsCompatibility @HideReelsCompatibility
@ -29,7 +28,7 @@ class HideReelsPatch : BytecodePatch(
// HideReel will hide the reel view before it is being used, // HideReel will hide the reel view before it is being used,
// so we pass the view to the HideReel method // so we pass the view to the HideReel method
implementation.addInstruction( implementation.addInstruction(
result.scanData.endIndex, result.scanResult.endIndex,
"invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".toInstruction() "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".toInstruction()
) )

View File

@ -8,7 +8,6 @@ import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatt
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@Name("hide-reels-signature") @Name("hide-reels-signature")
@MatchingMethod( @MatchingMethod(
@ -18,41 +17,6 @@ import org.jf.dexlib2.Opcode
@HideReelsCompatibility @HideReelsCompatibility
@Version("0.0.1") @Version("0.0.1")
object HideReelsSignature : MethodSignature( object HideReelsSignature : MethodSignature(
"V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, listOf( null, AccessFlags.PROTECTED or AccessFlags.FINAL, listOf("L", "L"), null,
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "[B", "[B", "[B", "[B", "[B", "[B" listOf("multiReelDismissalCallback", "reelItemRenderers", "reelDismissalInfo")
), listOf(
Opcode.MOVE_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.INVOKE_DIRECT,
Opcode.MOVE_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT_FROM16,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT_FROM16,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IPUT_OBJECT,
Opcode.MOVE_OBJECT_FROM16,
Opcode.IPUT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CONST,
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IPUT_OBJECT
)
) )

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -27,24 +27,24 @@ class ShortsButtonRemoverPatch : BytecodePatch(
override fun execute(data: BytecodeData): PatchResult { override fun execute(data: BytecodeData): PatchResult {
val result1 = signatures.first().result!! val result1 = signatures.first().result!!
val implementation1 = result1.method.implementation!! val implementation1 = result1.method.implementation!!
val moveEnumInstruction = implementation1.instructions[result1.scanData.endIndex] val moveEnumInstruction = implementation1.instructions[result1.scanResult.endIndex]
val enumRegister = (moveEnumInstruction as Instruction11x).registerA val enumRegister = (moveEnumInstruction as Instruction11x).registerA
val result2 = signatures.last().result!! val result2 = signatures.last().result!!
val implementation2 = result2.method.implementation!! val implementation2 = result2.method.implementation!!
val moveViewInstruction = implementation2.instructions[result2.scanData.endIndex] val moveViewInstruction = implementation2.instructions[result2.scanResult.endIndex]
val viewRegister = (moveViewInstruction as Instruction11x).registerA val viewRegister = (moveViewInstruction as Instruction11x).registerA
// Save the tab enum in XGlobals to avoid smali/register workarounds // Save the tab enum in XGlobals to avoid smali/register workarounds
implementation1.addInstruction( implementation1.addInstruction(
result1.scanData.endIndex + 1, result1.scanResult.endIndex + 1,
"sput-object v$enumRegister, Lfi/razerman/youtube/XGlobals;->lastPivotTab:Ljava/lang/Enum;".toInstruction() "sput-object v$enumRegister, Lfi/razerman/youtube/XGlobals;->lastPivotTab:Ljava/lang/Enum;".toInstruction()
) )
// Hide the button view via proxy by passing it to the hideShortsButton method // Hide the button view via proxy by passing it to the hideShortsButton method
// It only hides it if the last tab name is "TAB_SHORTS" // It only hides it if the last tab name is "TAB_SHORTS"
implementation2.addInstruction( implementation2.addInstruction(
result2.scanData.endIndex + 2, result2.scanResult.endIndex + 2,
"invoke-static { v$viewRegister }, Lfi/razerman/youtube/XAdRemover;->hideShortsButton(Landroid/view/View;)V".toInstruction() "invoke-static { v$viewRegister }, Lfi/razerman/youtube/XAdRemover;->hideShortsButton(Landroid/view/View;)V".toInstruction()
) )

View File

@ -12,7 +12,7 @@ import org.jf.dexlib2.Opcode
@Name("pivotbar-buttons-tabenum-signature") @Name("pivotbar-buttons-tabenum-signature")
@MatchingMethod( @MatchingMethod(
"Lkne", "z" "Lknw", "z"
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@ShortsButtonCompatibility @ShortsButtonCompatibility

View File

@ -12,7 +12,7 @@ import org.jf.dexlib2.Opcode
@Name("pivotbar-buttons-view-signature") @Name("pivotbar-buttons-view-signature")
@MatchingMethod( @MatchingMethod(
"Lkne", "z" "Lknw", "z"
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value. @FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@ShortsButtonCompatibility @ShortsButtonCompatibility

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.03.38", "17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.03.38", "17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -35,7 +35,7 @@ class IntegrationsPatch : BytecodePatch(
val count = implementation.registerCount - 1 val count = implementation.registerCount - 1
implementation.addInstructions( implementation.addInstructions(
result.scanData.endIndex + 1, """ result.scanResult.endIndex + 1, """
invoke-static {v$count}, Lpl/jakubweg/StringRef;->setContext(Landroid/content/Context;)V invoke-static {v$count}, Lpl/jakubweg/StringRef;->setContext(Landroid/content/Context;)V
sput-object v$count, Lapp/revanced/integrations/Globals;->context:Landroid/content/Context; sput-object v$count, Lapp/revanced/integrations/Globals;->context:Landroid/content/Context;
""".trimIndent().toInstructions() """.trimIndent().toInstructions()

View File

@ -3,55 +3,16 @@ package app.revanced.patches.youtube.misc.integrations.signatures
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
import app.revanced.patcher.signature.implementation.method.MethodSignature import app.revanced.patcher.signature.implementation.method.MethodSignature
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility import app.revanced.patches.youtube.misc.integrations.annotations.IntegrationsCompatibility
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@Name("init-signature") @Name("init-signature")
@MatchingMethod( @MatchingMethod(
"Lacnx", "onCreate" "Lacuu", "onCreate"
) )
@FuzzyPatternScanMethod(2) // FIXME: Test this threshold and find the best value.
@IntegrationsCompatibility @IntegrationsCompatibility
@Version("0.0.1") @Version("0.0.1")
object InitSignature : MethodSignature( object InitSignature : MethodSignature(
"V", null, null, null, null,
AccessFlags.PUBLIC.value, listOf("Application creation")
listOf(),
listOf(
Opcode.SGET_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.IGET_OBJECT,
Opcode.CONST_STRING,
Opcode.IF_NEZ,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.CHECK_CAST,
Opcode.MOVE_OBJECT,
Opcode.CHECK_CAST,
Opcode.CONST_4,
Opcode.CONST_STRING,
Opcode.INVOKE_INTERFACE_RANGE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.SPUT_OBJECT,
Opcode.SGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.INVOKE_SUPER,
Opcode.INVOKE_VIRTUAL
)
) )

View File

@ -5,7 +5,7 @@ import app.revanced.patcher.annotation.Package
@Compatibility( @Compatibility(
[Package( [Package(
"com.google.android.youtube", arrayOf("17.14.35", "17.17.34") "com.google.android.youtube", arrayOf("17.14.35", "17.17.34", "17.19.36")
)] )]
) )
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)

View File

@ -1,62 +0,0 @@
package app.revanced.patches
import app.revanced.patcher.Patcher
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
import app.revanced.patcher.signature.implementation.method.annotation.PatternScanMethod
import org.jf.dexlib2.iface.Method
import org.junit.Test
import java.io.File
internal class SignatureChecker {
@Test
fun checkMethodSignatures() {
// FIXME: instead of having this as a test, it should be turned into a task which can be ran manually
val file = File("stock.apk")
if (!file.exists()) {
throw IllegalStateException("Missing $file! To run this test, please place stock.apk here: ${file.absolutePath}")
}
val patcher = Patcher(file, "signatureCheckerCache", false)
patcher.addPatches(Index.patches.map { it() })
val unresolved = mutableListOf<String>()
for (signature in patcher.resolveSignatures()) {
val signatureAnnotations = signature::class.annotations
val nameAnnotation = signatureAnnotations.find { it is Name } as Name
if (!signature.resolved) {
unresolved.add(nameAnnotation.name)
continue
}
val patternScanMethod =
signatureAnnotations.find { it::class.annotations.any { method -> method is PatternScanMethod } }
if (patternScanMethod is FuzzyPatternScanMethod) {
val warnings = signature.result!!.scanData.warnings!!
val method = signature.result!!.method
val methodFromMetadata =
signatureAnnotations.find { it is MatchingMethod } as MatchingMethod? ?: MatchingMethod()
println("Signature: ${nameAnnotation}.\nMethod: ${methodFromMetadata.definingClass}->${methodFromMetadata.name} (Signature matches: ${method.definingClass}->${method.toStr()})\nWarnings: ${warnings.count()}")
for (warning in warnings) {
println("${warning.instructionIndex} / ${warning.patternIndex}: ${warning.wrongOpcode} (expected: ${warning.correctOpcode})")
}
println("=".repeat(20))
}
}
if (unresolved.isNotEmpty()) {
val base = Exception("${unresolved.size} signatures were not resolved.")
for (name in unresolved) {
base.addSuppressed(Exception("Signature $name was not resolved!"))
}
throw base
}
}
private fun Method.toStr(): String {
return "${this.name}(${this.parameterTypes.joinToString("")})${this.returnType}"
}
}