mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-09 20:49:31 +01:00
fix: migrate patches to latest patcher api changes
This commit is contained in:
parent
603680f10f
commit
8a0ee03a71
@ -25,7 +25,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
||||||
|
|
||||||
implementation("app.revanced:revanced-patcher:1.0.0-dev.16")
|
implementation("app.revanced:revanced-patcher:1.0.0-dev.17")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.21")
|
implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.21")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ class CodecsUnlockPatch : BytecodePatch(
|
|||||||
val instructionIndex = result.scanResult.startIndex
|
val instructionIndex = result.scanResult.startIndex
|
||||||
|
|
||||||
result = signatures.last().result!!
|
result = signatures.last().result!!
|
||||||
val codecMethod = data.toMethodWalker(result.immutableMethod).walk(result.scanResult.startIndex).getMethod()
|
val codecMethod =
|
||||||
|
data.toMethodWalker(result.immutableMethod).nextMethod(result.scanResult.startIndex).getMethod()
|
||||||
|
|
||||||
implementation.replaceInstruction(
|
implementation.replaceInstruction(
|
||||||
instructionIndex,
|
instructionIndex,
|
||||||
|
@ -6,8 +6,8 @@ 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.data.implementation.toMethodWalker
|
import app.revanced.patcher.data.implementation.toMethodWalker
|
||||||
|
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
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.PatchResultError
|
import app.revanced.patcher.patch.implementation.misc.PatchResultError
|
||||||
@ -23,7 +23,7 @@ import org.jf.dexlib2.AccessFlags
|
|||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
||||||
|
|
||||||
@Patch
|
//@Patch(dependencies = [IntegrationsPatch::class])
|
||||||
@Name("home-promo-ads")
|
@Name("home-promo-ads")
|
||||||
@Description("Patch to remove promoted ads in YouTube.")
|
@Description("Patch to remove promoted ads in YouTube.")
|
||||||
@PromotionsCompatibility
|
@PromotionsCompatibility
|
||||||
@ -47,14 +47,14 @@ class PromotionsPatch : BytecodePatch(
|
|||||||
val toBePatchedInvokeOffset =
|
val toBePatchedInvokeOffset =
|
||||||
requiredMethod.immutableMethod.implementation!!.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_DIRECT }
|
requiredMethod.immutableMethod.implementation!!.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_DIRECT }
|
||||||
val toBePatchedMethod =
|
val toBePatchedMethod =
|
||||||
data.toMethodWalker(requiredMethod.immutableMethod).walk(toBePatchedInvokeOffset, true)
|
data.toMethodWalker(requiredMethod.immutableMethod).nextMethod(toBePatchedInvokeOffset, true)
|
||||||
.getMethod() as MutableMethod
|
.getMethod() as MutableMethod
|
||||||
|
|
||||||
val implementation = toBePatchedMethod.implementation!!
|
val implementation = toBePatchedMethod.implementation!!
|
||||||
val invokeVirtualOffset = implementation.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_VIRTUAL }
|
val invokeVirtualOffset = implementation.instructions.indexOfFirst { it.opcode == Opcode.INVOKE_VIRTUAL }
|
||||||
|
|
||||||
val moveResultInstruction = implementation.instructions[invokeVirtualOffset + 1]
|
val moveResultInstruction = implementation.instructions[invokeVirtualOffset + 1]
|
||||||
if (moveResultInstruction.opcode != Opcode.MOVE_RESULT_OBJECT) return PatchResultError("The toBePatchedInvokeOffset offset was wrong in ${(this::class.annotations.find { it is Name } as Name).name}")
|
if (moveResultInstruction.opcode != Opcode.MOVE_RESULT_OBJECT) return PatchResultError("The toBePatchedInvokeOffset offset was wrong in ${this.javaClass.patchName}")
|
||||||
|
|
||||||
val register = (moveResultInstruction as Instruction11x).registerA
|
val register = (moveResultInstruction as Instruction11x).registerA
|
||||||
implementation.injectHideCall(invokeVirtualOffset + 2, register)
|
implementation.injectHideCall(invokeVirtualOffset + 2, register)
|
||||||
|
@ -17,9 +17,10 @@ import app.revanced.patcher.signature.implementation.method.annotation.MatchingM
|
|||||||
import app.revanced.patcher.util.smali.toInstructions
|
import app.revanced.patcher.util.smali.toInstructions
|
||||||
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
import app.revanced.patches.youtube.ad.video.annotations.VideoAdsCompatibility
|
||||||
import app.revanced.patches.youtube.ad.video.signatures.ShowVideoAdsConstructorSignature
|
import app.revanced.patches.youtube.ad.video.signatures.ShowVideoAdsConstructorSignature
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
|
||||||
@Patch
|
@Patch(dependencies = [IntegrationsPatch::class])
|
||||||
@Name("video-ads")
|
@Name("video-ads")
|
||||||
@Description("Patch to remove ads in the YouTube video player.")
|
@Description("Patch to remove ads in the YouTube video player.")
|
||||||
@VideoAdsCompatibility
|
@VideoAdsCompatibility
|
||||||
@ -37,7 +38,6 @@ class VideoAdsPatch : BytecodePatch(
|
|||||||
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), null
|
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("Z"), null
|
||||||
) {}) ?: return PatchResultError("Required parent method could not be found.")
|
) {}) ?: return PatchResultError("Required parent method could not be found.")
|
||||||
|
|
||||||
|
|
||||||
// Override the parameter by calling shouldShowAds and setting the parameter to the result
|
// Override the parameter by calling shouldShowAds and setting the parameter to the result
|
||||||
result.method.implementation!!.addInstructions(
|
result.method.implementation!!.addInstructions(
|
||||||
0, """
|
0, """
|
||||||
|
@ -14,6 +14,7 @@ import app.revanced.patcher.util.smali.toInstructions
|
|||||||
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
|
import app.revanced.patches.youtube.interaction.seekbar.annotation.SeekbarTappingCompatibility
|
||||||
import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingParentSignature
|
import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingParentSignature
|
||||||
import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingSignature
|
import app.revanced.patches.youtube.interaction.seekbar.signatures.SeekbarTappingSignature
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
||||||
import org.jf.dexlib2.iface.Method
|
import org.jf.dexlib2.iface.Method
|
||||||
@ -21,7 +22,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction11n
|
|||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
|
|
||||||
|
|
||||||
@Patch
|
@Patch(dependencies = [IntegrationsPatch::class])
|
||||||
@Name("seekbar-tapping")
|
@Name("seekbar-tapping")
|
||||||
@Description("Enable tapping on the seekbar of the YouTube player.")
|
@Description("Enable tapping on the seekbar of the YouTube player.")
|
||||||
@SeekbarTappingCompatibility
|
@SeekbarTappingCompatibility
|
||||||
|
@ -9,10 +9,15 @@ import app.revanced.patcher.patch.implementation.ResourcePatch
|
|||||||
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
|
||||||
import app.revanced.patches.youtube.layout.amoled.annotations.AmoledCompatibility
|
import app.revanced.patches.youtube.layout.amoled.annotations.AmoledCompatibility
|
||||||
|
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@Patch
|
@Patch(
|
||||||
|
dependencies = [
|
||||||
|
FixLocaleConfigErrorPatch::class
|
||||||
|
]
|
||||||
|
)
|
||||||
@Name("amoled")
|
@Name("amoled")
|
||||||
@Description("Enables pure black theme.")
|
@Description("Enables pure black theme.")
|
||||||
@AmoledCompatibility
|
@AmoledCompatibility
|
||||||
|
@ -12,10 +12,11 @@ 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.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.misc.integrations.patch.IntegrationsPatch
|
||||||
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(dependencies = [IntegrationsPatch::class])
|
||||||
@Name("disable-create-button")
|
@Name("disable-create-button")
|
||||||
@Description("Disable the create button.")
|
@Description("Disable the create button.")
|
||||||
@CreateButtonCompatibility
|
@CreateButtonCompatibility
|
||||||
|
@ -19,7 +19,6 @@ import app.revanced.patches.youtube.layout.minimizedplayback.signatures.Minimize
|
|||||||
@Description("Enable minimized and background playback.")
|
@Description("Enable minimized and background playback.")
|
||||||
@MinimizedPlaybackCompatibility
|
@MinimizedPlaybackCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
|
|
||||||
class MinimizedPlaybackPatch : BytecodePatch(
|
class MinimizedPlaybackPatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
MinimizedPlaybackManagerSignature
|
MinimizedPlaybackManagerSignature
|
||||||
|
@ -17,11 +17,12 @@ import app.revanced.patcher.signature.implementation.method.annotation.MatchingM
|
|||||||
import app.revanced.patcher.util.smali.toInstructions
|
import app.revanced.patcher.util.smali.toInstructions
|
||||||
import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility
|
import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQualityLayoutCompatibility
|
||||||
import app.revanced.patches.youtube.layout.oldqualitylayout.signatures.OldQualityParentSignature
|
import app.revanced.patches.youtube.layout.oldqualitylayout.signatures.OldQualityParentSignature
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
||||||
|
|
||||||
@Patch
|
@Patch(dependencies = [IntegrationsPatch::class])
|
||||||
@Name("old-quality-layout")
|
@Name("old-quality-layout")
|
||||||
@Description("Enable the original quality flyout menu.")
|
@Description("Enable the original quality flyout menu.")
|
||||||
@OldQualityLayoutCompatibility
|
@OldQualityLayoutCompatibility
|
||||||
|
@ -12,9 +12,10 @@ import app.revanced.patcher.util.smali.toInstruction
|
|||||||
import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility
|
import app.revanced.patches.youtube.layout.shorts.button.annotations.ShortsButtonCompatibility
|
||||||
import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonTabenumSignature
|
import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonTabenumSignature
|
||||||
import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonsViewSignature
|
import app.revanced.patches.youtube.layout.shorts.button.signatures.PivotBarButtonsViewSignature
|
||||||
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
||||||
|
|
||||||
@Patch
|
@Patch(dependencies = [IntegrationsPatch::class])
|
||||||
@Name("shorts-button")
|
@Name("shorts-button")
|
||||||
@Description("Hide the shorts button.")
|
@Description("Hide the shorts button.")
|
||||||
@ShortsButtonCompatibility
|
@ShortsButtonCompatibility
|
||||||
|
@ -6,9 +6,9 @@ import app.revanced.patcher.annotation.Version
|
|||||||
import app.revanced.patcher.data.implementation.BytecodeData
|
import app.revanced.patcher.data.implementation.BytecodeData
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
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.PatchResultError
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import app.revanced.patcher.util.smali.toInstructions
|
import app.revanced.patcher.util.smali.toInstructions
|
||||||
@ -18,7 +18,6 @@ import org.jf.dexlib2.AccessFlags
|
|||||||
import org.jf.dexlib2.immutable.ImmutableMethod
|
import org.jf.dexlib2.immutable.ImmutableMethod
|
||||||
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
||||||
|
|
||||||
@Patch
|
|
||||||
@Name("integrations")
|
@Name("integrations")
|
||||||
@Description("Applies mandatory patches to implement the ReVanced integrations into the application.")
|
@Description("Applies mandatory patches to implement the ReVanced integrations into the application.")
|
||||||
@IntegrationsCompatibility
|
@IntegrationsCompatibility
|
||||||
@ -29,6 +28,9 @@ class IntegrationsPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(data: BytecodeData): PatchResult {
|
override fun execute(data: BytecodeData): PatchResult {
|
||||||
|
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 = signatures.first().result!!
|
||||||
|
|
||||||
val implementation = result.method.implementation!!
|
val implementation = result.method.implementation!!
|
||||||
|
@ -4,14 +4,12 @@ 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.ResourceData
|
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.ResourcePatch
|
||||||
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
|
||||||
import app.revanced.patches.youtube.misc.manifest.annotations.FixLocaleConfigErrorCompatibility
|
import app.revanced.patches.youtube.misc.manifest.annotations.FixLocaleConfigErrorCompatibility
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
@Patch
|
|
||||||
@Name("locale-config-fix")
|
@Name("locale-config-fix")
|
||||||
@Description("Fix an error when building the resources by patching the manifest file.")
|
@Description("Fix an error when building the resources by patching the manifest file.")
|
||||||
@FixLocaleConfigErrorCompatibility
|
@FixLocaleConfigErrorCompatibility
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package app.revanced.patches.youtube.misc.mapping.patch
|
||||||
|
|
||||||
|
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.implementation.ResourcePatch
|
||||||
|
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||||
|
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||||
|
import app.revanced.patches.youtube.ad.general.resource.util.Extensions.doRecursively
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
|
@Name("resource-id-mapping-provider-resource-patch-dependency")
|
||||||
|
@Description("This patch works as a acts as a provider for resources mapped to their ids.")
|
||||||
|
@Version("0.0.1")
|
||||||
|
class ResourceIdMappingProviderResourcePatch : ResourcePatch() {
|
||||||
|
companion object {
|
||||||
|
internal lateinit var resourceMappings: Map<String, Long>
|
||||||
|
private set
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun execute(data: ResourceData): PatchResult {
|
||||||
|
data.getXmlEditor("res/values/public.xml").use { editor ->
|
||||||
|
resourceMappings = buildMap {
|
||||||
|
editor.file.documentElement.doRecursively { node ->
|
||||||
|
if (node !is Element) return@doRecursively
|
||||||
|
val nameAttribute = node.getAttribute("name")
|
||||||
|
if (node.nodeName != "public" || nameAttribute.startsWith("APKTOOL")) return@doRecursively
|
||||||
|
this[nameAttribute] = node.getAttribute("id").substring(2).toLong(16)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
}
|
@ -135,11 +135,13 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||||||
const/4 v0, 0x0
|
const/4 v0, 0x0
|
||||||
return-object v0
|
return-object v0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
'V' -> "return-void"
|
'V' -> "return-void"
|
||||||
'I' -> """
|
'I' -> """
|
||||||
const/4 v0, 0x0
|
const/4 v0, 0x0
|
||||||
return v0
|
return v0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
else -> throw Exception("This case should never happen.")
|
else -> throw Exception("This case should never happen.")
|
||||||
}
|
}
|
||||||
result.method.implementation!!.addInstructions(
|
result.method.implementation!!.addInstructions(
|
||||||
|
Loading…
Reference in New Issue
Block a user