Skip to content

Commit

Permalink
feat(nova): pro unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX authored and indrastorms committed Feb 11, 2024
1 parent d57ec49 commit e5d28e5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package app.revanced.patches.nova.prime.fingerprints

import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.Opcode

object UnlockPrimeFingerprint : MethodFingerprint(
"V",
opcodes = listOf(
Opcode.IPUT_OBJECT,
Opcode.CONST_STRING,
Opcode.CONST_4,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT
),
strings = listOf("1")
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package app.revanced.patches.nova.prime.patch

import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patches.nova.prime.fingerprints.UnlockPrimeFingerprint
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction11x

@Patch(
name = "Unlock prime",
description = "Unlocks Nova Prime and all functions of the app.",
compatiblePackages = [CompatiblePackage("com.teslacoilsw.launcher")]
)
object UnlockPrimePatch : BytecodePatch(
setOf(UnlockPrimeFingerprint)
) {
override fun execute(context: BytecodeContext) {
UnlockPrimeFingerprint.result?.apply {
// Any value except 0 unlocks prime, but 512 is needed for a protection mechanism
// which would reset the preferences if the value on disk had changed after a restart.
val PRIME_STATUS: Int = 512
val insertIndex = scanResult.patternScanResult!!.endIndex + 1

val primeStatusRegister =
(mutableMethod.implementation!!.instructions[insertIndex - 1] as BuilderInstruction11x).registerA

mutableMethod.addInstruction(
insertIndex,
"""
const/16 v$primeStatusRegister, $PRIME_STATUS
"""
)
} ?: throw UnlockPrimeFingerprint.exception

}
}

0 comments on commit e5d28e5

Please sign in to comment.