fix: migrate to breaking changes from patcher

This commit is contained in:
oSumAtrIX 2022-06-20 21:29:19 +02:00
parent 8e86d9e6cb
commit 2c0a4196fe
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
18 changed files with 46 additions and 39 deletions

View file

@ -18,7 +18,7 @@ repositories {
dependencies {
implementation(kotlin("stdlib"))
implementation("app.revanced:revanced-patcher:1.2.8")
implementation("app.revanced:revanced-patcher:1.3.0")
}
tasks {

View file

@ -25,13 +25,13 @@ class CodecsUnlockPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
var result = signatures.first().result!!
var result = CodecsLockSignature.result!!
val implementation = result.method.implementation!!
val instructionIndex = result.scanResult.startIndex
result = signatures.last().result!!
result = AllCodecsReferenceSignature.result!!
val codecMethod =
data.toMethodWalker(result.immutableMethod).nextMethod(result.scanResult.startIndex).getMethod()

View file

@ -30,7 +30,7 @@ class ExclusiveAudioPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
val result = signatures.first().result!!.findParentMethod(@Name("audio-only-enabler-method") @MatchingMethod(
val result = ExclusiveAudioSignature.result!!.findParentMethod(@Name("audio-only-enabler-method") @MatchingMethod(
"Lgmd;",
"d"
) @DirectPatternScanMethod @ExclusiveAudioCompatibility @Version(

View file

@ -25,20 +25,18 @@ class RemoveTasteBuilderPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
val result = signatures.first().result!!
val result = TasteBuilderConstructorSignature.result!!
val implementation = result.method.implementation!!
val insertIndex = result.scanResult.endIndex - 8
val register = (implementation.instructions[insertIndex] as Instruction22c).registerA
val instructionList = """
result.method.addInstructions(
insertIndex, """
const/16 v1, 0x8
invoke-virtual {v${register}, v1}, Landroid/view/View;->setVisibility(I)V
""".trimIndent().toInstructions().toMutableList()
implementation.addInstructions(
insertIndex, instructionList
"""
)
return PatchResultSuccess()

View file

@ -29,7 +29,7 @@ class RemoveUpgradeButtonPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
val result = signatures.first().result!!
val result = PivotBarConstructorSignature.result!!
val implementation = result.method.implementation!!
val pivotBarElementFieldRef =

View file

@ -24,7 +24,7 @@ class BackgroundPlayPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
signatures.first().result!!.method.implementation!!.addInstructions(
BackgroundPlaybackDisableSignature.result!!.method.implementation!!.addInstructions(
0,
"""
const/4 v0, 0x1

View file

@ -242,25 +242,23 @@ class GeneralBytecodeAdsPatch : BytecodePatch(
BuilderInstruction21t(Opcode.IF_EQZ, 1, lithoRemoveLabel)
// create blocks
val parameters = lithoMethod.parameterTypes.joinToString("") { it }
val registers = lithoMethodImplementation.registerCount
val block1 = """
invoke-static/range {p3}, $thisType->getTemplateName($templateNameParameterType)Ljava/lang/String;
move-result-object v0
""".trimIndent().toInstructions(parameters, registers, false)
""".trimIndent().toInstructions(lithoMethod)
val block2 = """
move-object/from16 v1, p3
iget-object v2, v1, $templateNameParameterType->b:Ljava/nio/ByteBuffer;
invoke-static {v0, v2}, Lfi/razerman/youtube/litho/LithoAdRemoval;->containsAd(Ljava/lang/String;Ljava/nio/ByteBuffer;)Z
move-result v1
""".trimIndent().toInstructions(parameters, registers, false)
""".trimIndent().toInstructions(lithoMethod)
val block3 = """
move-object/from16 v2, p1
invoke-static {v2}, $descriptor1
move-result-object v0
iget-object v0, v0, $descriptor2
return-object v0
""".trimIndent().toInstructions(parameters, registers, false)
""".trimIndent().toInstructions(lithoMethod)
// insert blocks and branch instructions
lithoMethodImplementation.insertBlocks(

View file

@ -34,7 +34,7 @@ class VideoAdsPatch : BytecodePatch(
) {
override fun execute(data: BytecodeData): PatchResult {
val result =
signatures.first().result!!.findParentMethod(@Name("show-video-ads-method-signature") @MatchingMethod(
ShowVideoAdsConstructorSignature.result!!.findParentMethod(@Name("show-video-ads-method-signature") @MatchingMethod(
definingClass = "zai"
) @DirectPatternScanMethod @VideoAdsCompatibility @Version("0.0.1") object : MethodSignature(
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), null

View file

@ -34,7 +34,7 @@ class EnableSeekbarTappingPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
var result = signatures.first().result!!
var result = SeekbarTappingParentSignature.result!!
val tapSeekMethods = mutableMapOf<String, Method>()
@ -59,7 +59,7 @@ class EnableSeekbarTappingPatch : BytecodePatch(
}
// replace map because we dont need the upper one anymore
result = signatures.last().result!!
result = SeekbarTappingSignature.result!!
val implementation = result.method.implementation!!

View file

@ -11,7 +11,6 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.implementation.BytecodePatch
import app.revanced.patcher.patch.implementation.misc.PatchResult
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
import app.revanced.patcher.util.smali.toInstructions
import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
@ -26,14 +25,14 @@ class HideCastButtonPatch : BytecodePatch(listOf()) {
data.classes.forEach { classDef ->
classDef.methods.forEach { method ->
if (classDef.type.endsWith("MediaRouteButton;") && method.name == "setVisibility") {
val implementation =
data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" }.implementation!!
val setVisibilityMethod =
data.proxy(classDef).resolve().methods.first { it.name == "setVisibility" }
implementation.addInstructions(
setVisibilityMethod.addInstructions(
0, """
invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I
move-result p1
""".trimIndent().toInstructions("I", 2, false)
invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I
move-result p1
"""
)
}
}

View file

@ -29,7 +29,7 @@ class CreateButtonRemoverPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
val result = signatures.first().result!!
val result = CreateButtonSignature.result!!
// Get the required register which holds the view object we need to pass to the method hideCreateButton
val implementation = result.method.implementation!!

View file

@ -27,7 +27,7 @@ class MinimizedPlaybackPatch : BytecodePatch(
override fun execute(data: BytecodeData): PatchResult {
// Instead of removing all instructions like Vanced,
// we return the method at the beginning instead
signatures.first().result!!.method.implementation!!.addInstructions(
MinimizedPlaybackManagerSignature.result!!.method.implementation!!.addInstructions(
0, """
const/4 v0, 0x1
return v0

View file

@ -35,7 +35,7 @@ class OldQualityLayoutPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
val result = signatures.first().result!!.findParentMethod(@Name("old-quality-signature") @MatchingMethod(
val result = OldQualityParentSignature.result!!.findParentMethod(@Name("old-quality-signature") @MatchingMethod(
definingClass = "Libh"
) @FuzzyPatternScanMethod(2) @OldQualityLayoutCompatibility @Version("0.0.1") object : MethodSignature(
"L", AccessFlags.FINAL or AccessFlags.PRIVATE, listOf("Z"), listOf(

View file

@ -22,7 +22,7 @@ class HideReelsPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
val result = signatures.first().result!!
val result = HideReelsSignature.result!!
val implementation = result.method.implementation!!
// HideReel will hide the reel view before it is being used,

View file

@ -28,12 +28,12 @@ class ShortsButtonRemoverPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
val result1 = signatures.first().result!!
val result1 = PivotBarButtonTabenumSignature.result!!
val implementation1 = result1.method.implementation!!
val moveEnumInstruction = implementation1.instructions[result1.scanResult.endIndex]
val enumRegister = (moveEnumInstruction as Instruction11x).registerA
val result2 = signatures.last().result!!
val result2 = PivotBarButtonsViewSignature.result!!
val implementation2 = result2.method.implementation!!
val moveViewInstruction = implementation2.instructions[result2.scanResult.endIndex]
val viewRegister = (moveViewInstruction as Instruction11x).registerA

View file

@ -31,7 +31,7 @@ class IntegrationsPatch : BytecodePatch(
if (data.findClass("Lapp/revanced/integrations/Globals") == null)
return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.")
val result = signatures.first().result!!
val result = InitSignature.result!!
val implementation = result.method.implementation!!
val count = implementation.registerCount - 1

View file

@ -16,6 +16,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
import app.revanced.patcher.util.smali.toInstruction
import app.revanced.patcher.util.smali.toInstructions
import app.revanced.patches.youtube.layout.castbutton.patch.HideCastButtonPatch
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
import app.revanced.patches.youtube.misc.microg.patch.resource.MicroGResourcePatch
import app.revanced.patches.youtube.misc.microg.patch.resource.enum.StringReplaceMode
@ -31,7 +32,11 @@ import org.jf.dexlib2.immutable.reference.ImmutableStringReference
@Patch(include = false)
@Dependencies(
dependencies = [MicroGResourcePatch::class, HideCastButtonPatch::class]
dependencies = [
MicroGResourcePatch::class,
HideCastButtonPatch::class,
FixLocaleConfigErrorPatch::class
]
)
@Name("microg-support")
@Description("Patch to allow YouTube ReVanced to run without root and under a different package name.")
@ -115,13 +120,19 @@ class MicroGBytecodePatch : BytecodePatch(
}
}
signatures.last()
return PatchResultSuccess()
}
private fun disablePlayServiceChecksAndFixCastIssues() {
for (i in 0 until signatures.count() - 1) {
val result = signatures.elementAt(i).result!!
listOf(
IntegrityCheckSignature,
ServiceCheckSignature,
GooglePlayUtilitySignature,
CastDynamiteModuleSignature,
CastDynamiteModuleV2Signature,
CastContextFetchSignature
).forEach { signature ->
val result = signature.result!!
val stringInstructions = when (result.immutableMethod.returnType.first()) {
'L' -> """
const/4 v0, 0x0
@ -141,7 +152,7 @@ class MicroGBytecodePatch : BytecodePatch(
)
}
val implementation = signatures.last().result!!.method.implementation!!
val implementation = PrimeSignature.result!!.method.implementation!!
var register = 2
val index = implementation.instructions.indexOfFirst {

View file

@ -4,6 +4,7 @@ import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.implementation.ResourceData
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.implementation.ResourcePatch
import app.revanced.patcher.patch.implementation.misc.PatchResult
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess