mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-09 11:04:36 +02:00
chore: lint code
This commit is contained in:
parent
9f0e512283
commit
49727dfb3a
@ -14,12 +14,9 @@ import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
|||||||
import app.revanced.patches.music.utils.settings.CategoryType
|
import app.revanced.patches.music.utils.settings.CategoryType
|
||||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Hide handle",
|
name = "Hide handle",
|
||||||
@ -61,19 +58,12 @@ object HideHandlePatch : BytecodePatch(
|
|||||||
AccountSwitcherAccessibilityLabelFingerprint.result?.let { result ->
|
AccountSwitcherAccessibilityLabelFingerprint.result?.let { result ->
|
||||||
result.mutableMethod.apply {
|
result.mutableMethod.apply {
|
||||||
|
|
||||||
val textColorIndex = indexOfFirstInstruction {
|
val textColorIndex = getTargetIndexWithMethodReferenceName("setTextColor")
|
||||||
getReference<MethodReference>()?.name == "setTextColor"
|
val setVisibilityIndex = getTargetIndexWithMethodReferenceName(textColorIndex, "setVisibility")
|
||||||
}
|
val textViewInstruction = getInstruction<FiveRegisterInstruction>(setVisibilityIndex)
|
||||||
val setTextIndex = implementation!!.instructions.let {
|
|
||||||
textColorIndex + it.subList(textColorIndex, textColorIndex + 10).indexOfFirst { instruction ->
|
|
||||||
instruction.opcode == Opcode.INVOKE_VIRTUAL
|
|
||||||
&& instruction.getReference<MethodReference>()?.name == "setVisibility"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val textViewInstruction = getInstruction<Instruction35c>(setTextIndex)
|
|
||||||
|
|
||||||
replaceInstruction(
|
replaceInstruction(
|
||||||
setTextIndex,
|
setVisibilityIndex,
|
||||||
"invoke-static {v${textViewInstruction.registerC}, v${textViewInstruction.registerD}}, $ACCOUNT->hideHandle(Landroid/widget/TextView;I)V"
|
"invoke-static {v${textViewInstruction.registerC}, v${textViewInstruction.registerD}}, $ACCOUNT->hideHandle(Landroid/widget/TextView;I)V"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package app.revanced.patches.music.general.floatingbutton.fingerprints
|
package app.revanced.patches.music.general.floatingbutton.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
|
||||||
object FloatingButtonFingerprint : MethodFingerprint(
|
object FloatingButtonFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL,
|
|
||||||
parameters = listOf("L"),
|
parameters = listOf("L"),
|
||||||
opcodes = listOf(Opcode.AND_INT_LIT16)
|
opcodes = listOf(Opcode.AND_INT_LIT16)
|
||||||
)
|
)
|
||||||
|
@ -16,7 +16,7 @@ object HistoryMenuItemOfflineTabFingerprint : MethodFingerprint(
|
|||||||
Opcode.INVOKE_INTERFACE,
|
Opcode.INVOKE_INTERFACE,
|
||||||
Opcode.RETURN_VOID
|
Opcode.RETURN_VOID
|
||||||
),
|
),
|
||||||
customFingerprint = { methodDef, classDef ->
|
customFingerprint = { methodDef, _ ->
|
||||||
methodDef.containsWideLiteralInstructionIndex(HistoryMenuItem)
|
methodDef.containsWideLiteralInstructionIndex(HistoryMenuItem)
|
||||||
&& methodDef.containsWideLiteralInstructionIndex(OfflineSettingsMenuItem)
|
&& methodDef.containsWideLiteralInstructionIndex(OfflineSettingsMenuItem)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage
|
|||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patches.music.general.startpage.fingerprints.ColdStartUpFingerprint
|
import app.revanced.patches.music.general.startpage.fingerprints.ColdStartUpFingerprint
|
||||||
import app.revanced.patches.music.utils.integrations.Constants.GENERAL
|
import app.revanced.patches.music.utils.integrations.Constants.GENERAL
|
||||||
import app.revanced.patches.music.utils.intenthook.IntentHookPatch
|
|
||||||
import app.revanced.patches.music.utils.settings.CategoryType
|
import app.revanced.patches.music.utils.settings.CategoryType
|
||||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||||
import app.revanced.patches.music.utils.settings.SettingsPatch.contexts
|
import app.revanced.patches.music.utils.settings.SettingsPatch.contexts
|
||||||
@ -20,10 +19,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@Patch(
|
@Patch(
|
||||||
name = "Change start page",
|
name = "Change start page",
|
||||||
description = "Adds an option to set which page the app opens in instead of the homepage.",
|
description = "Adds an option to set which page the app opens in instead of the homepage.",
|
||||||
dependencies = [
|
dependencies = [SettingsPatch::class],
|
||||||
IntentHookPatch::class,
|
|
||||||
SettingsPatch::class
|
|
||||||
],
|
|
||||||
compatiblePackages = [
|
compatiblePackages = [
|
||||||
CompatiblePackage(
|
CompatiblePackage(
|
||||||
"com.google.android.apps.youtube.music",
|
"com.google.android.apps.youtube.music",
|
||||||
|
@ -10,7 +10,7 @@ import app.revanced.patcher.patch.annotation.Patch
|
|||||||
import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint
|
import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint
|
||||||
import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderSyntheticFingerprint
|
import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderSyntheticFingerprint
|
||||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTastebuilderShelf
|
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTasteBuilderShelf
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
import app.revanced.util.getTargetIndex
|
import app.revanced.util.getTargetIndex
|
||||||
import app.revanced.util.getWideLiteralInstructionIndex
|
import app.revanced.util.getWideLiteralInstructionIndex
|
||||||
@ -49,7 +49,7 @@ object TasteBuilderPatch : BytecodePatch(
|
|||||||
|
|
||||||
parentResult.mutableMethod.apply {
|
parentResult.mutableMethod.apply {
|
||||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||||
val constIndex = getWideLiteralInstructionIndex(MusicTastebuilderShelf)
|
val constIndex = getWideLiteralInstructionIndex(MusicTasteBuilderShelf)
|
||||||
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
val targetIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
||||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package app.revanced.patches.music.misc.tastebuilder.fingerprints
|
package app.revanced.patches.music.misc.tastebuilder.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTastebuilderShelf
|
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTasteBuilderShelf
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
object TasteBuilderConstructorFingerprint : LiteralValueFingerprint(
|
object TasteBuilderConstructorFingerprint : LiteralValueFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
literalSupplier = { MusicTastebuilderShelf }
|
literalSupplier = { MusicTasteBuilderShelf }
|
||||||
)
|
)
|
@ -32,7 +32,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var MiniPlayerPlayPauseReplayButton: Long = -1
|
var MiniPlayerPlayPauseReplayButton: Long = -1
|
||||||
var MusicMenuLikeButtons: Long = -1
|
var MusicMenuLikeButtons: Long = -1
|
||||||
var MusicNotifierShelf: Long = -1
|
var MusicNotifierShelf: Long = -1
|
||||||
var MusicTastebuilderShelf: Long = -1
|
var MusicTasteBuilderShelf: Long = -1
|
||||||
var NamesInactiveAccountThumbnailSize: Long = -1
|
var NamesInactiveAccountThumbnailSize: Long = -1
|
||||||
var OfflineSettingsMenuItem: Long = -1
|
var OfflineSettingsMenuItem: Long = -1
|
||||||
var PlayerCastMediaRouteButton: Long = -1
|
var PlayerCastMediaRouteButton: Long = -1
|
||||||
|
@ -11,9 +11,14 @@ import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
|||||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
|
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
|
||||||
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
|
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccountSwitcherAccessibility
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import app.revanced.util.getTargetIndex
|
||||||
|
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||||
|
import app.revanced.util.getWideLiteralInstructionIndex
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Hide handle",
|
name = "Hide handle",
|
||||||
@ -66,13 +71,15 @@ object HideHandlePatch : BytecodePatch(
|
|||||||
|
|
||||||
AccountSwitcherAccessibilityLabelFingerprint.result?.let {
|
AccountSwitcherAccessibilityLabelFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex - 2
|
val constIndex = getWideLiteralInstructionIndex(AccountSwitcherAccessibility)
|
||||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
val insertIndex = getTargetIndex(constIndex, Opcode.IF_EQZ)
|
||||||
|
val setVisibilityIndex = getTargetIndexWithMethodReferenceName(insertIndex, "setVisibility")
|
||||||
|
val visibilityRegister = getInstruction<FiveRegisterInstruction>(setVisibilityIndex).registerD
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
targetIndex + 2, """
|
insertIndex, """
|
||||||
invoke-static {v$targetRegister}, $GENERAL->hideHandle(I)I
|
invoke-static {v$visibilityRegister}, $GENERAL->hideHandle(I)I
|
||||||
move-result v$targetRegister
|
move-result v$visibilityRegister
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,9 @@ package app.revanced.patches.youtube.general.handle.fingerprints
|
|||||||
|
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccountSwitcherAccessibility
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccountSwitcherAccessibility
|
||||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
object AccountSwitcherAccessibilityLabelFingerprint : LiteralValueFingerprint(
|
object AccountSwitcherAccessibilityLabelFingerprint : LiteralValueFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
parameters = listOf("L", "Ljava/lang/Object;"),
|
parameters = listOf("L", "Ljava/lang/Object;"),
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.INVOKE_VIRTUAL,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.IGET_OBJECT,
|
|
||||||
Opcode.NEW_ARRAY,
|
|
||||||
Opcode.CONST_4,
|
|
||||||
Opcode.APUT_OBJECT,
|
|
||||||
Opcode.CONST
|
|
||||||
),
|
|
||||||
literalSupplier = { AccountSwitcherAccessibility }
|
literalSupplier = { AccountSwitcherAccessibility }
|
||||||
)
|
)
|
@ -11,17 +11,11 @@ import app.revanced.patches.youtube.utils.integrations.Constants.SEEKBAR
|
|||||||
import app.revanced.patches.youtube.utils.overridequality.OverrideQualityHookPatch
|
import app.revanced.patches.youtube.utils.overridequality.OverrideQualityHookPatch
|
||||||
import app.revanced.patches.youtube.utils.overridespeed.OverrideSpeedHookPatch
|
import app.revanced.patches.youtube.utils.overridespeed.OverrideSpeedHookPatch
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.TotalTime
|
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.exception
|
import app.revanced.util.exception
|
||||||
import app.revanced.util.getReference
|
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||||
import app.revanced.util.getTargetIndex
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import app.revanced.util.getWideLiteralInstructionIndex
|
|
||||||
import app.revanced.util.indexOfFirstInstruction
|
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
|
||||||
|
|
||||||
@Patch(
|
@Patch(
|
||||||
name = "Append time stamps information",
|
name = "Append time stamps information",
|
||||||
@ -71,14 +65,11 @@ object AppendTimeStampInformationPatch : BytecodePatch(
|
|||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
TotalTimeFingerprint.result?.let {
|
TotalTimeFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val constIndex = getWideLiteralInstructionIndex(TotalTime)
|
val charSequenceIndex = getTargetIndexWithMethodReferenceName("getString") + 1
|
||||||
val charSequenceIndex = getTargetIndex(constIndex, Opcode.MOVE_RESULT_OBJECT)
|
|
||||||
val charSequenceRegister = getInstruction<OneRegisterInstruction>(charSequenceIndex).registerA
|
val charSequenceRegister = getInstruction<OneRegisterInstruction>(charSequenceIndex).registerA
|
||||||
val textViewIndex = indexOfFirstInstruction {
|
val textViewIndex = getTargetIndexWithMethodReferenceName("getText")
|
||||||
getReference<MethodReference>()?.name == "getText"
|
|
||||||
}
|
|
||||||
val textViewRegister =
|
val textViewRegister =
|
||||||
getInstruction<Instruction35c>(textViewIndex).registerC
|
getInstruction<FiveRegisterInstruction>(textViewIndex).registerC
|
||||||
|
|
||||||
addInstructions(
|
addInstructions(
|
||||||
textViewIndex, """
|
textViewIndex, """
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package app.revanced.util
|
package app.revanced.util
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
@ -15,6 +17,8 @@ import com.android.tools.smali.dexlib2.iface.Method
|
|||||||
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
import com.android.tools.smali.dexlib2.iface.reference.Reference
|
||||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||||
|
|
||||||
@ -109,6 +113,9 @@ fun Method.getStringInstructionIndex(value: String) = implementation?.let {
|
|||||||
fun Method.containsWideLiteralInstructionIndex(literal: Long) =
|
fun Method.containsWideLiteralInstructionIndex(literal: Long) =
|
||||||
getWideLiteralInstructionIndex(literal) >= 0
|
getWideLiteralInstructionIndex(literal) >= 0
|
||||||
|
|
||||||
|
fun Method.containsMethodReferenceNameInstructionIndex(methodName: String) =
|
||||||
|
getTargetIndexWithMethodReferenceName(methodName) >= 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverse the class hierarchy starting from the given root class.
|
* Traverse the class hierarchy starting from the given root class.
|
||||||
*
|
*
|
||||||
@ -136,14 +143,10 @@ fun BytecodeContext.traverseClassHierarchy(
|
|||||||
inline fun <reified T : Reference> Instruction.getReference() =
|
inline fun <reified T : Reference> Instruction.getReference() =
|
||||||
(this as? ReferenceInstruction)?.reference as? T
|
(this as? ReferenceInstruction)?.reference as? T
|
||||||
|
|
||||||
/**
|
fun MutableMethod.getTargetIndex(opcode: Opcode) = getTargetIndex(0, opcode)
|
||||||
* Get the index of the first [Instruction] that matches the predicate.
|
|
||||||
*
|
fun MutableMethod.getTargetIndexReversed(opcode: Opcode) =
|
||||||
* @param predicate The predicate to match.
|
getTargetIndex(implementation!!.instructions.size - 1, opcode)
|
||||||
* @return The index of the first [Instruction] that matches the predicate.
|
|
||||||
*/
|
|
||||||
fun Method.indexOfFirstInstruction(predicate: Instruction.() -> Boolean) =
|
|
||||||
this.implementation!!.instructions.indexOfFirst(predicate)
|
|
||||||
|
|
||||||
fun MutableMethod.getTargetIndex(startIndex: Int, opcode: Opcode) =
|
fun MutableMethod.getTargetIndex(startIndex: Int, opcode: Opcode) =
|
||||||
implementation!!.instructions.let {
|
implementation!!.instructions.let {
|
||||||
@ -159,7 +162,80 @@ fun MutableMethod.getTargetIndexReversed(startIndex: Int, opcode: Opcode): Int {
|
|||||||
|
|
||||||
return index
|
return index
|
||||||
}
|
}
|
||||||
throw PatchException("Failed to find target index")
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Method.getTargetIndexWithFieldReferenceType(returnType: String) = implementation?.let {
|
||||||
|
it.instructions.indexOfFirst { instruction ->
|
||||||
|
instruction.getReference<FieldReference>()?.type == returnType
|
||||||
|
}
|
||||||
|
} ?: -1
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithFieldReferenceTypeReversed(returnType: String)
|
||||||
|
= getTargetIndexWithFieldReferenceTypeReversed(implementation!!.instructions.size - 1, returnType)
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithFieldReferenceType(startIndex: Int, returnType: String) =
|
||||||
|
implementation!!.instructions.let {
|
||||||
|
startIndex + it.subList(startIndex, it.size - 1).indexOfFirst { instruction ->
|
||||||
|
instruction.getReference<FieldReference>()?.type == returnType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithFieldReferenceTypeReversed(startIndex: Int, returnType: String): Int {
|
||||||
|
for (index in startIndex downTo 0) {
|
||||||
|
val instruction = getInstruction(index)
|
||||||
|
if (instruction.getReference<FieldReference>()?.type != returnType)
|
||||||
|
continue
|
||||||
|
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Method.getTargetIndexWithMethodReferenceName(methodName: String) = implementation?.let {
|
||||||
|
it.instructions.indexOfFirst { instruction ->
|
||||||
|
instruction.getReference<MethodReference>()?.name == methodName
|
||||||
|
}
|
||||||
|
} ?: -1
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithMethodReferenceNameReversed(methodName: String)
|
||||||
|
= getTargetIndexWithMethodReferenceNameReversed(implementation!!.instructions.size - 1, methodName)
|
||||||
|
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithMethodReferenceName(startIndex: Int, methodName: String) =
|
||||||
|
implementation!!.instructions.let {
|
||||||
|
startIndex + it.subList(startIndex, it.size - 1).indexOfFirst { instruction ->
|
||||||
|
instruction.getReference<MethodReference>()?.name == methodName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithMethodReferenceNameReversed(startIndex: Int, methodName: String): Int {
|
||||||
|
for (index in startIndex downTo 0) {
|
||||||
|
val instruction = getInstruction(index)
|
||||||
|
if (instruction.getReference<MethodReference>()?.name != methodName)
|
||||||
|
continue
|
||||||
|
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithReference(startIndex: Int, reference: String) =
|
||||||
|
implementation!!.instructions.let {
|
||||||
|
startIndex + it.subList(startIndex, it.size - 1).indexOfFirst { instruction ->
|
||||||
|
(instruction as? ReferenceInstruction)?.reference.toString().contains(reference)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MutableMethod.getTargetIndexWithReferenceReversed(startIndex: Int, reference: String): Int {
|
||||||
|
for (index in startIndex downTo 0) {
|
||||||
|
val instruction = getInstruction(index)
|
||||||
|
if (!(instruction as? ReferenceInstruction)?.reference.toString().contains(reference))
|
||||||
|
continue
|
||||||
|
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BytecodeContext.updatePatchStatus(
|
fun BytecodeContext.updatePatchStatus(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user