From fb173e18afd5566a4ccdbb613810fa9646da9334 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 12 Nov 2023 16:23:57 +0100 Subject: [PATCH] fix(YouTube - Hide layout components): Reduce false positives when hiding mix playlists Implementation references taken from github.com/inotia00/revanced-integrations/commit/cfaf3d6356f316623ad32b10719b1b5ef0ba25b9 --- .../layout/hide/general/HideLayoutComponentsPatch.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt index a71aed1eb..4dc8868c8 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/layout/hide/general/HideLayoutComponentsPatch.kt @@ -23,6 +23,7 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch import app.revanced.patches.youtube.misc.settings.SettingsPatch.PreferenceScreen import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction +import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction @Patch( name = "Hide layout components", @@ -327,12 +328,15 @@ object HideLayoutComponentsPatch : BytecodePatch( result.mutableMethod.apply { val consumeByteBufferIndex = result.scanResult.patternScanResult!!.startIndex - val byteBufferRegister = getInstruction(consumeByteBufferIndex).registerD + val conversionContextRegister = + getInstruction(consumeByteBufferIndex - 2).registerA + val byteBufferRegister = + getInstruction(consumeByteBufferIndex).registerD addInstructionsWithLabels( - result.scanResult.patternScanResult!!.startIndex, + consumeByteBufferIndex, """ - invoke-static {v$byteBufferRegister}, $FILTER_CLASS_DESCRIPTOR->filterMixPlaylists([B)Z + invoke-static {v$conversionContextRegister, v$byteBufferRegister}, $FILTER_CLASS_DESCRIPTOR->filterMixPlaylists(Ljava/lang/Object;[B)Z move-result v0 # Conveniently same register happens to be free. if-nez v0, :return_empty_component """,