From ff4308e96154a8c6eceefed24b8baeb98cfc0108 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sat, 9 Aug 2025 11:13:35 -0400 Subject: [PATCH] refactor(YouTube Music - Hide category bar): Fix possible crash when patching certain app targets --- .../patches/music/layout/compactheader/HideCategoryBar.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt b/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt index b0021b966..2128722e7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt +++ b/patches/src/main/kotlin/app/revanced/patches/music/layout/compactheader/HideCategoryBar.kt @@ -3,6 +3,7 @@ package app.revanced.patches.music.layout.compactheader import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.findFreeRegister import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction @Suppress("unused") @@ -17,13 +18,14 @@ val hideCategoryBar = bytecodePatch( constructCategoryBarFingerprint.method.apply { val insertIndex = constructCategoryBarFingerprint.patternMatch!!.startIndex val register = getInstruction(insertIndex - 1).registerA + val freeRegister = findFreeRegister(insertIndex, register) addInstructions( insertIndex, """ - const/16 v2, 0x8 - invoke-virtual {v$register, v2}, Landroid/view/View;->setVisibility(I)V - """, + const/16 v$freeRegister, 0x8 + invoke-virtual { v$register, v$freeRegister }, Landroid/view/View;->setVisibility(I)V + """ ) } }