feat: migrate to dalvik patches
This commit is contained in:
@ -4,27 +4,16 @@ import app.revanced.patcher.cache.Cache
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.writer.ASMWriter.insertAt
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.tree.MethodInsnNode
|
||||
import org.objectweb.asm.tree.VarInsnNode
|
||||
import app.revanced.patcher.smali.asInstruction
|
||||
|
||||
class CreateButtonRemover : Patch("create-button-remover") {
|
||||
override fun execute(cache: Cache): PatchResult {
|
||||
val patchData = cache.methods["create-button-patch"]
|
||||
val map = cache.methodMap["create-button-patch"]
|
||||
|
||||
patchData.method.instructions.insertAt(
|
||||
patchData.scanData.endIndex - 1,
|
||||
VarInsnNode(
|
||||
Opcodes.ALOAD,
|
||||
6
|
||||
),
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"fi/razerman/youtube/XAdRemover",
|
||||
"hideCreateButton",
|
||||
"(Landroid/view/View;)V"
|
||||
)
|
||||
// Hide the button view via proxy by passing it to the hideCreateButton method
|
||||
map.resolveAndGetMethod().implementation!!.addInstruction(
|
||||
map.scanData.endIndex,
|
||||
"invoke-static { v6 }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".asInstruction()
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
|
@ -4,24 +4,17 @@ import app.revanced.patcher.cache.Cache
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.writer.ASMWriter.insertAt
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.tree.MethodInsnNode
|
||||
import org.objectweb.asm.tree.VarInsnNode
|
||||
import app.revanced.patcher.smali.asInstruction
|
||||
|
||||
class HideReels : Patch("hide-reels") {
|
||||
override fun execute(cache: Cache): PatchResult {
|
||||
val patchData = cache.methods["hide-reel-patch"]
|
||||
val implementation = cache.methodMap["hide-reel-patch"].resolveAndGetMethod().implementation!!
|
||||
|
||||
patchData.method.instructions.insertAt(
|
||||
patchData.scanData.endIndex + 1,
|
||||
VarInsnNode(Opcodes.ALOAD, 18),
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"fi/razerman/youtube/XAdRemover",
|
||||
"HideReels",
|
||||
"(Landroid/view/View;)V"
|
||||
)
|
||||
// HideReel will hide the reel view before it is being used,
|
||||
// so we pass the view to the HideReel method
|
||||
implementation.addInstruction(
|
||||
22,
|
||||
"invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".asInstruction()
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
|
@ -1,52 +1,47 @@
|
||||
package app.revanced.patches.layout
|
||||
|
||||
import app.revanced.patcher.cache.Cache
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.signature.Signature
|
||||
import app.revanced.patcher.writer.ASMWriter.insertAt
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.Type
|
||||
import org.objectweb.asm.tree.MethodInsnNode
|
||||
import org.objectweb.asm.tree.VarInsnNode
|
||||
import app.revanced.patcher.signature.MethodSignature
|
||||
import app.revanced.patcher.smali.asInstructions
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
class HideSuggestions : Patch("hide-suggestions") {
|
||||
override fun execute(cache: Cache): PatchResult {
|
||||
val method = cache.methods["hide-suggestions-patch"].findParentMethod(
|
||||
Signature(
|
||||
val map = cache.methodMap["hide-suggestions-patch"].findParentMethod(
|
||||
MethodSignature(
|
||||
"hide-suggestions-method",
|
||||
Type.VOID_TYPE,
|
||||
Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL,
|
||||
arrayOf(Type.BOOLEAN_TYPE),
|
||||
"V",
|
||||
AccessFlags.PUBLIC or AccessFlags.PUBLIC,
|
||||
setOf("Z"),
|
||||
arrayOf(
|
||||
Opcodes.ALOAD,
|
||||
Opcodes.ILOAD,
|
||||
Opcodes.PUTFIELD,
|
||||
Opcodes.ALOAD,
|
||||
Opcodes.GETFIELD
|
||||
Opcode.IPUT_BOOLEAN,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.IPUT_BOOLEAN,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.RETURN_VOID
|
||||
)
|
||||
)
|
||||
) ?: return PatchResultError("Parent method hide-suggestions-method has not been found")
|
||||
|
||||
method.method.instructions.insertAt(
|
||||
// Proxy the first parameter by passing it to the RemoveSuggestions method
|
||||
map.resolveAndGetMethod().implementation!!.addInstructions(
|
||||
0,
|
||||
VarInsnNode(Opcodes.ILOAD, 1),
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"java/lang/Boolean",
|
||||
"valueOf",
|
||||
"(Z)Ljava/lang/Boolean"
|
||||
),
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"fi/razerman/youtube/XAdRemover",
|
||||
"HideReels",
|
||||
"(Landroid/view/View;)V"
|
||||
)
|
||||
"""
|
||||
invoke-static { p1 }, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
||||
move-result-object v0
|
||||
invoke-static { v0 }, Lfi/razerman/youtube/XAdRemover;->RemoveSuggestions(Ljava/lang/Boolean;)Ljava/lang/Boolean;
|
||||
move-result-object v0
|
||||
invoke-virtual { v0 }, Ljava/lang/Boolean;->booleanValue()Z
|
||||
move-result v0
|
||||
""".trimIndent().asInstructions()
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -4,10 +4,20 @@ import app.revanced.patcher.cache.Cache
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction10x
|
||||
|
||||
class MinimizedPlayback : Patch("minimized-playback") {
|
||||
override fun execute(cache: Cache): PatchResult {
|
||||
cache.methods["minimized-playback-manager"].method.instructions.clear()
|
||||
// Instead of removing all instructions like Vanced,
|
||||
// we return the method at the beginning instead
|
||||
cache.methodMap["minimized-playback-manager"]
|
||||
.resolveAndGetMethod()
|
||||
.implementation!!
|
||||
.addInstruction(
|
||||
0,
|
||||
BuilderInstruction10x(Opcode.RETURN_VOID)
|
||||
)
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -1,50 +1,47 @@
|
||||
package app.revanced.patches.layout
|
||||
|
||||
import app.revanced.patcher.cache.Cache
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.signature.Signature
|
||||
import app.revanced.patcher.util.ExtraTypes
|
||||
import app.revanced.patcher.writer.ASMWriter.insertAt
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.tree.JumpInsnNode
|
||||
import org.objectweb.asm.tree.MethodInsnNode
|
||||
import org.objectweb.asm.tree.VarInsnNode
|
||||
import app.revanced.patcher.signature.MethodSignature
|
||||
import app.revanced.patcher.smali.asInstruction
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
|
||||
|
||||
class OldQualityLayout : Patch("old-quality-restore") {
|
||||
override fun execute(cache: Cache): PatchResult {
|
||||
val method = cache.methods["old-quality-patch"].findParentMethod(
|
||||
Signature(
|
||||
val map = cache.methodMap["old-quality-patch"].findParentMethod(
|
||||
MethodSignature(
|
||||
"old-quality-patch-method",
|
||||
ExtraTypes.Any,
|
||||
Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL,
|
||||
arrayOf(),
|
||||
"L",
|
||||
AccessFlags.FINAL or AccessFlags.PUBLIC,
|
||||
emptySet(),
|
||||
arrayOf(
|
||||
Opcodes.ALOAD,
|
||||
Opcodes.GETFIELD,
|
||||
Opcodes.ISTORE,
|
||||
Opcodes.ICONST_3,
|
||||
Opcodes.ISTORE
|
||||
Opcode.IF_NEZ,
|
||||
Opcode.IGET,
|
||||
Opcode.CONST_4,
|
||||
Opcode.IF_NE
|
||||
)
|
||||
)
|
||||
) ?: return PatchResultError("Parent method old-quality-patch-method has not been found")
|
||||
|
||||
method.method.instructions.insertAt(
|
||||
|
||||
val implementation = map.resolveAndGetMethod().implementation!!
|
||||
|
||||
// if useOldStyleQualitySettings == true, jump over all instructions and return the field at the end
|
||||
val jmpInstruction =
|
||||
BuilderInstruction21t(Opcode.IF_NEZ, 0, implementation.instructions[5].location.labels.first())
|
||||
implementation.addInstruction(0, jmpInstruction)
|
||||
implementation.addInstruction(
|
||||
0,
|
||||
MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"fi/razerman/youtube/XGlobals",
|
||||
"useOldStyleQualitySettings",
|
||||
"()Z"
|
||||
),
|
||||
VarInsnNode(Opcodes.ISTORE, 1),
|
||||
VarInsnNode(Opcodes.ILOAD, 1),
|
||||
JumpInsnNode(
|
||||
Opcodes.IFNE,
|
||||
(method.method.instructions[method.scanData.endIndex + 3] as JumpInsnNode).label
|
||||
),
|
||||
"""
|
||||
invoke-static { }, Lfi/razerman/youtube/XGlobals;->useOldStyleQualitySettings()Z
|
||||
move-result v0
|
||||
""".trimIndent().asInstruction()
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
|
Reference in New Issue
Block a user