fix: incorrect endIndex (fixed in Patcher)

This commit is contained in:
Lucaskyy 2022-04-16 21:42:02 +02:00
parent 5f6a6d2b7d
commit 424788edd7
No known key found for this signature in database
GPG key ID: 1530BFF96D1EEB89
5 changed files with 10 additions and 10 deletions

View file

@ -154,14 +154,14 @@ class EnableSeekbarTappingPatch : Patch(
val oMethod = tapSeekMethods["O"]!! val oMethod = tapSeekMethods["O"]!!
// get the required register // get the required register
val instruction = implementation.instructions[result.scanData.endIndex - 1] val instruction = implementation.instructions[result.scanData.endIndex]
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) if (instruction.opcode != Opcode.INVOKE_VIRTUAL)
return PatchResultError("Could not find the correct register") return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC val register = (instruction as Instruction35c).registerC
// the instructions are written in reverse order. // the instructions are written in reverse order.
implementation.addInstructions( implementation.addInstructions(
result.scanData.endIndex, result.scanData.endIndex + 1,
""" """
invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V invoke-virtual { v$register, v2 }, ${oMethod.definingClass}->${oMethod.name}(I)V
invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V invoke-virtual { v$register, v2 }, ${pMethod.definingClass}->${pMethod.name}(I)V
@ -169,13 +169,13 @@ class EnableSeekbarTappingPatch : Patch(
) )
// if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label // if tap-seeking is disabled, do not invoke the two methods above by jumping to the else label
val elseLabel = implementation.newLabelForIndex(result.scanData.endIndex) val elseLabel = implementation.newLabelForIndex(result.scanData.endIndex + 1)
implementation.addInstruction( implementation.addInstruction(
result.scanData.endIndex, result.scanData.endIndex + 1,
BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel) BuilderInstruction21t(Opcode.IF_EQZ, 0, elseLabel)
) )
implementation.addInstructions( implementation.addInstructions(
result.scanData.endIndex, result.scanData.endIndex + 1,
""" """
invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z
move-result v0 move-result v0

View file

@ -76,14 +76,14 @@ class CreateButtonRemoverPatch : Patch(
// Get the required register which holds the view object we need to pass to the method hideCreateButton // Get the required register which holds the view object we need to pass to the method hideCreateButton
val implementation = result.method.implementation!! val implementation = result.method.implementation!!
val instruction = implementation.instructions[result.scanData.endIndex] val instruction = implementation.instructions[result.scanData.endIndex + 1]
if (instruction.opcode != Opcode.INVOKE_STATIC) if (instruction.opcode != Opcode.INVOKE_STATIC)
return PatchResultError("Could not find the correct register") return PatchResultError("Could not find the correct register")
val register = (instruction as Instruction35c).registerC val register = (instruction as Instruction35c).registerC
// Hide the button view via proxy by passing it to the hideCreateButton method // Hide the button view via proxy by passing it to the hideCreateButton method
implementation.addInstruction( implementation.addInstruction(
result.scanData.endIndex, result.scanData.endIndex + 1,
"invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction() "invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V".toInstruction()
) )

View file

@ -101,7 +101,7 @@ class HideReelsPatch : Patch(
// HideReel will hide the reel view before it is being used, // HideReel will hide the reel view before it is being used,
// so we pass the view to the HideReel method // so we pass the view to the HideReel method
implementation.addInstruction( implementation.addInstruction(
result.scanData.endIndex - 1, result.scanData.endIndex,
"invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".toInstruction() "invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V".toInstruction()
) )

View file

@ -98,7 +98,7 @@ class OldQualityLayoutPatch : Patch(
// if useOldStyleQualitySettings == true, jump over all instructions // if useOldStyleQualitySettings == true, jump over all instructions
val jmpInstruction = val jmpInstruction =
BuilderInstruction21t(Opcode.IF_NEZ, 0, implementation.instructions[result.scanData.endIndex - 1].location.labels.first()) BuilderInstruction21t(Opcode.IF_NEZ, 0, implementation.instructions[result.scanData.endIndex].location.labels.first())
implementation.addInstruction(5, jmpInstruction) implementation.addInstruction(5, jmpInstruction)
implementation.addInstructions( implementation.addInstructions(
0, 0,

View file

@ -85,7 +85,7 @@ class IntegrationsPatch : Patch(
val count = implementation.registerCount - 1 val count = implementation.registerCount - 1
implementation.addInstructions( implementation.addInstructions(
result.scanData.endIndex, result.scanData.endIndex + 1,
""" """
invoke-static {v$count}, Lpl/jakubweg/StringRef;->setContext(Landroid/content/Context;)V invoke-static {v$count}, Lpl/jakubweg/StringRef;->setContext(Landroid/content/Context;)V
sput-object v$count, Lapp/revanced/integrations/Globals;->context:Landroid/content/Context; sput-object v$count, Lapp/revanced/integrations/Globals;->context:Landroid/content/Context;