mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 00:54:32 +02:00
36 lines
1.5 KiB
Kotlin
36 lines
1.5 KiB
Kotlin
package app.revanced.patches.shared.spoofappversion
|
|
|
|
import app.revanced.patcher.data.BytecodeContext
|
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
|
import app.revanced.patcher.patch.BytecodePatch
|
|
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint
|
|
import app.revanced.patches.shared.fingerprints.CreatePlayerRequestBodyWithModelFingerprint.indexOfReleaseInstruction
|
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
|
import app.revanced.util.resultOrThrow
|
|
import com.android.tools.smali.dexlib2.Opcode
|
|
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
|
|
|
abstract class BaseSpoofAppVersionPatch(
|
|
private val descriptor: String
|
|
) : BytecodePatch(
|
|
setOf(CreatePlayerRequestBodyWithModelFingerprint)
|
|
) {
|
|
override fun execute(context: BytecodeContext) {
|
|
|
|
CreatePlayerRequestBodyWithModelFingerprint.resultOrThrow().mutableMethod.apply {
|
|
val versionIndex = indexOfReleaseInstruction(this) + 1
|
|
val insertIndex =
|
|
indexOfFirstInstructionReversedOrThrow(versionIndex, Opcode.IPUT_OBJECT)
|
|
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
|
|
|
addInstructions(
|
|
insertIndex, """
|
|
invoke-static {v$insertRegister}, $descriptor
|
|
move-result-object v$insertRegister
|
|
"""
|
|
)
|
|
}
|
|
|
|
}
|
|
} |