Skip to content

Commit

Permalink
fix: wrong opcode pattern for create-button-method
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Apr 15, 2022
1 parent a112b22 commit f4d8a85
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ package app.revanced.patches.layout

import app.revanced.patcher.PatcherData
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchMetadata
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.*
import app.revanced.patcher.signature.MethodMetadata
import app.revanced.patcher.signature.MethodSignature
import app.revanced.patcher.signature.MethodSignatureMetadata
import app.revanced.patcher.signature.PatternScanMethod
import app.revanced.patcher.smali.toInstruction
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.formats.Instruction35c

private val compatiblePackages = listOf("com.google.android.youtube")

Expand Down Expand Up @@ -69,19 +67,24 @@ class CreateButtonRemoverPatch : Patch(
Opcode.CONST_4,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT
)
)
)
) {
override fun execute(patcherData: PatcherData): PatchResult {
val result = signatures.first().result!!

// Get the required register which holds the view object we need to pass to the method hideCreateButton
val implementation = result.method.implementation!!
val instruction = implementation.instructions[result.scanData.endIndex]
if (instruction.opcode != Opcode.INVOKE_STATIC)
return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC

// Hide the button view via proxy by passing it to the hideCreateButton method
result.method.implementation!!.addInstruction(
implementation.addInstruction(
result.scanData.endIndex,
"invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction()
"invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction()
)

return PatchResultSuccess()
Expand Down

0 comments on commit f4d8a85

Please sign in to comment.