diff --git a/build.gradle.kts b/build.gradle.kts index 0aecbd1f1..970fda0d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,7 +24,7 @@ repositories { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.10") - implementation("app.revanced:revanced-patcher:1.+") // use latest version. + implementation(files("P:\\Andere Dateien\\STUFF\\Coding\\Java\\revanced\\revanced-patcher\\build\\libs\\revanced-patcher-1.0.0-dev.8.jar")) // use latest version. implementation("org.smali:dexlib2:2.5.2") } diff --git a/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt b/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt index 84c1997c9..f425dc692 100644 --- a/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt +++ b/src/main/kotlin/app/revanced/patches/ad/VideoAds.kt @@ -18,17 +18,17 @@ class VideoAds : Patch("VideoAds") { "show-video-ads-method", "V", AccessFlags.PUBLIC or AccessFlags.FINAL, - setOf("Z"), + arrayOf("Z"), null ) ) ?: return PatchResultError("Could not find required method to patch") // Override the parameter by calling shouldShowAds and setting the parameter to the result - map.resolveAndGetMethod().implementation!!.addInstructions( + map.method.implementation!!.addInstructions( 0, """ invoke-static { }, Lfi/vanced/libraries/youtube/whitelisting/Whitelist;->shouldShowAds()Z - move-result v0 + move-result v1 """.trimIndent().asInstructions() ) diff --git a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt index bdc775315..9b1df3d60 100644 --- a/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt +++ b/src/main/kotlin/app/revanced/patches/interaction/EnableSeekbarTapping.kt @@ -7,10 +7,10 @@ import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.smali.asInstructions import org.jf.dexlib2.Opcode -import org.jf.dexlib2.builder.instruction.BuilderInstruction11n import org.jf.dexlib2.builder.instruction.BuilderInstruction21t import org.jf.dexlib2.builder.instruction.BuilderInstruction35c import org.jf.dexlib2.iface.Method +import org.jf.dexlib2.iface.instruction.formats.Instruction11n import org.jf.dexlib2.immutable.reference.ImmutableMethodReference class EnableSeekbarTapping : Patch("enable-seekbar-tapping") { @@ -20,23 +20,26 @@ class EnableSeekbarTapping : Patch("enable-seekbar-tapping") { val tapSeekMethods = mutableMapOf() // find the methods which tap the seekbar - map.definingClassProxy.immutableClass.methods.forEach { + for (it in map.definingClassProxy.immutableClass.methods) { + if (it.implementation == null) continue + val instructions = it.implementation!!.instructions // here we make sure we actually find the method because it has more then 7 instructions - if (instructions.count() < 7) return@forEach + if (instructions.count() < 7) continue // we know that the 7th instruction has the opcode CONST_4 val instruction = instructions.elementAt(6) - if (instruction.opcode != Opcode.CONST_4) return@forEach + if (instruction.opcode != Opcode.CONST_4) continue // the literal for this instruction has to be either 1 or 2 - val literal = (instruction as BuilderInstruction11n).narrowLiteral + val literal = (instruction as Instruction11n).narrowLiteral // method founds if (literal == 1) tapSeekMethods["P"] = it if (literal == 2) tapSeekMethods["O"] = it } - val implementation = cache.methodMap["enable-seekbar-tapping"].resolveAndGetMethod().implementation!! + + val implementation = cache.methodMap["enable-seekbar-tapping"].method.implementation!! // if tap-seeking is enabled, do not invoke the two methods below val pMethod = tapSeekMethods["P"]!! @@ -78,7 +81,7 @@ class EnableSeekbarTapping : Patch("enable-seekbar-tapping") { ) // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label - val elseLabel = implementation.instructions[7].location.labels.first() + val elseLabel = implementation.newLabelForIndex(map.scanData.endIndex) implementation.addInstruction( map.scanData.endIndex, BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) diff --git a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt index 51f6f0128..dea467dd5 100644 --- a/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt +++ b/src/main/kotlin/app/revanced/patches/layout/CreateButtonRemover.kt @@ -11,7 +11,7 @@ class CreateButtonRemover : Patch("create-button-remover") { val map = cache.methodMap["create-button-patch"] // Hide the button view via proxy by passing it to the hideCreateButton method - map.resolveAndGetMethod().implementation!!.addInstruction( + map.method.implementation!!.addInstruction( map.scanData.endIndex, "invoke-static { v6 }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".asInstruction() ) diff --git a/src/main/kotlin/app/revanced/patches/layout/HideReels.kt b/src/main/kotlin/app/revanced/patches/layout/HideReels.kt index d331f381e..3d524a74f 100644 --- a/src/main/kotlin/app/revanced/patches/layout/HideReels.kt +++ b/src/main/kotlin/app/revanced/patches/layout/HideReels.kt @@ -8,7 +8,7 @@ import app.revanced.patcher.smali.asInstruction class HideReels : Patch("hide-reels") { override fun execute(cache: Cache): PatchResult { - val implementation = cache.methodMap["hide-reel-patch"].resolveAndGetMethod().implementation!! + val implementation = cache.methodMap["hide-reel-patch"].method.implementation!! // HideReel will hide the reel view before it is being used, // so we pass the view to the HideReel method diff --git a/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt b/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt index 95dea7d46..d3c9a3944 100644 --- a/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt +++ b/src/main/kotlin/app/revanced/patches/layout/HideSuggestions.kt @@ -18,12 +18,12 @@ class HideSuggestions : Patch("hide-suggestions") { MethodSignature( "hide-suggestions-method", "V", - AccessFlags.PUBLIC or AccessFlags.PUBLIC, - setOf("Z"), + AccessFlags.PUBLIC or AccessFlags.FINAL, + arrayOf("Z"), arrayOf( Opcode.IPUT_BOOLEAN, Opcode.IGET_OBJECT, - Opcode.IPUT_BOOLEAN, + Opcode.IGET_BOOLEAN, Opcode.INVOKE_VIRTUAL, Opcode.RETURN_VOID ) @@ -31,7 +31,7 @@ class HideSuggestions : Patch("hide-suggestions") { ) ?: return PatchResultError("Parent method hide-suggestions-method has not been found") // Proxy the first parameter by passing it to the RemoveSuggestions method - map.resolveAndGetMethod().implementation!!.addInstructions( + map.method.implementation!!.addInstructions( 0, """ invoke-static { p1 }, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean; diff --git a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt index f898b98ef..ce30d4c8b 100644 --- a/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt +++ b/src/main/kotlin/app/revanced/patches/layout/MinimizedPlayback.kt @@ -12,7 +12,7 @@ class MinimizedPlayback : Patch("minimized-playback") { // Instead of removing all instructions like Vanced, // we return the method at the beginning instead cache.methodMap["minimized-playback-manager"] - .resolveAndGetMethod() + .method .implementation!! .addInstruction( 0, diff --git a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt index edaeb3245..0715e5df8 100644 --- a/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt +++ b/src/main/kotlin/app/revanced/patches/layout/OldQualityLayout.kt @@ -19,18 +19,20 @@ class OldQualityLayout : Patch("old-quality-restore") { "old-quality-patch-method", "L", AccessFlags.FINAL or AccessFlags.PUBLIC, - emptySet(), + emptyArray(), arrayOf( - Opcode.IF_NEZ, Opcode.IGET, Opcode.CONST_4, - Opcode.IF_NE + Opcode.IF_NE, + Opcode.IGET_OBJECT, + Opcode.GOTO, + Opcode.IGET_OBJECT, + Opcode.RETURN_OBJECT ) ) ) ?: return PatchResultError("Parent method old-quality-patch-method has not been found") - - val implementation = map.resolveAndGetMethod().implementation!! + val implementation = map.method.implementation!! // if useOldStyleQualitySettings == true, jump over all instructions and return the field at the end val jmpInstruction =