Skip to content

Commit fe30abb

Browse files
oSumAtrIXindrastorms
authored andcommitted
fix(nova): Update patch
1 parent 2669f26 commit fe30abb

2 files changed

Lines changed: 20 additions & 31 deletions

File tree

src/main/kotlin/dropped/patches/nova/prime/fingerprints/UnlockPrimeFingerprint.kt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ package app.revanced.patches.nova.prime.fingerprints
33
import app.revanced.patcher.fingerprint.MethodFingerprint
44
import com.android.tools.smali.dexlib2.Opcode
55

6-
object UnlockPrimeFingerprint : MethodFingerprint(
7-
"V",
8-
opcodes = listOf(
9-
Opcode.IPUT_OBJECT,
10-
Opcode.CONST_STRING,
11-
Opcode.CONST_4,
12-
Opcode.INVOKE_INTERFACE,
13-
Opcode.MOVE_RESULT
14-
),
15-
strings = listOf("1")
6+
object UpdatePrimeStatusFingerprint : MethodFingerprint(
7+
opcodes = listOf(Opcode.CONST_4), // Modify this to change the prime status.
8+
strings = listOf("widget_reset_ids")
169
)

src/main/kotlin/dropped/patches/nova/prime/patch/UnlockPrimePatch.kt

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,35 @@ package app.revanced.patches.nova.prime.patch
22

33
import app.revanced.util.exception
44
import app.revanced.patcher.data.BytecodeContext
5-
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
5+
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
6+
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
67
import app.revanced.patcher.patch.BytecodePatch
7-
import app.revanced.patcher.patch.PatchResult
88
import app.revanced.patcher.patch.annotation.Patch
99
import app.revanced.patcher.patch.annotation.CompatiblePackage
10-
import app.revanced.patches.nova.prime.fingerprints.UnlockPrimeFingerprint
11-
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction11x
10+
import app.revanced.patches.nova.prime.fingerprints.UpdatePrimeStatusFingerprint
11+
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
1212

1313
@Patch(
1414
name = "Unlock prime",
1515
description = "Unlocks Nova Prime and all functions of the app.",
1616
compatiblePackages = [CompatiblePackage("com.teslacoilsw.launcher")]
1717
)
18+
@Suppress("unused")
1819
object UnlockPrimePatch : BytecodePatch(
19-
setOf(UnlockPrimeFingerprint)
20+
setOf(UpdatePrimeStatusFingerprint)
2021
) {
21-
override fun execute(context: BytecodeContext) {
22-
UnlockPrimeFingerprint.result?.apply {
23-
// Any value except 0 unlocks prime, but 512 is needed for a protection mechanism
24-
// which would reset the preferences if the value on disk had changed after a restart.
25-
val PRIME_STATUS: Int = 512
26-
val insertIndex = scanResult.patternScanResult!!.endIndex + 1
22+
// Any value except 0 unlocks Nova Prime, but 512 is needed for a protection mechanism
23+
// otherwise the preferences will be reset if the status on disk changes after a restart.
24+
private const val PRIME_STATUS = 512
2725

28-
val primeStatusRegister =
29-
(mutableMethod.implementation!!.instructions[insertIndex - 1] as BuilderInstruction11x).registerA
26+
override fun execute(context: BytecodeContext) = UpdatePrimeStatusFingerprint.result?.let {
27+
val setStatusIndex = it.scanResult.patternScanResult!!.startIndex
3028

31-
mutableMethod.addInstruction(
32-
insertIndex,
33-
"""
34-
const/16 v$primeStatusRegister, $PRIME_STATUS
35-
"""
36-
)
37-
} ?: throw UnlockPrimeFingerprint.exception
29+
it.mutableMethod.apply {
30+
val statusRegister = getInstruction<OneRegisterInstruction>(setStatusIndex).registerA
31+
replaceInstruction(setStatusIndex, "const/16 v$statusRegister, $PRIME_STATUS")
32+
}
3833

39-
}
34+
return@let
35+
} ?: throw UpdatePrimeStatusFingerprint.exception
4036
}

0 commit comments

Comments
 (0)