mirror of
https://github.com/revanced/revanced-patches
synced 2024-08-22 23:30:39 +02:00
fix(Tiktok - Settings): get instruction registers dynamically (#2676)
This commit is contained in:
parent
c9f7831f1b
commit
b34e45b6da
@ -18,7 +18,8 @@ import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
|
|||||||
import app.revanced.patches.tiktok.misc.settings.annotations.SettingsCompatibility
|
import app.revanced.patches.tiktok.misc.settings.annotations.SettingsCompatibility
|
||||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.*
|
import app.revanced.patches.tiktok.misc.settings.fingerprints.*
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||||
|
|
||||||
@Patch
|
@Patch
|
||||||
@DependsOn([IntegrationsPatch::class])
|
@DependsOn([IntegrationsPatch::class])
|
||||||
@ -45,7 +46,9 @@ class SettingsPatch : BytecodePatch(
|
|||||||
AddSettingsEntryFingerprint.result?.apply {
|
AddSettingsEntryFingerprint.result?.apply {
|
||||||
scanResult.patternScanResult?.startIndex?.let {
|
scanResult.patternScanResult?.startIndex?.let {
|
||||||
val settingsEntries = mutableMethod.getInstruction(it + 3)
|
val settingsEntries = mutableMethod.getInstruction(it + 3)
|
||||||
val addEntry = mutableMethod.getInstruction(it + 5)
|
val addEntry = mutableMethod.getInstruction<BuilderInstruction35c>(it + 5)
|
||||||
|
val register1 = addEntry.registerC
|
||||||
|
val register2 = addEntry.registerD
|
||||||
// Add the settings entry created to the settings fragment
|
// Add the settings entry created to the settings fragment
|
||||||
mutableMethod.addInstructions(
|
mutableMethod.addInstructions(
|
||||||
it + 6,
|
it + 6,
|
||||||
@ -58,10 +61,10 @@ class SettingsPatch : BytecodePatch(
|
|||||||
mutableMethod.addInstructions(
|
mutableMethod.addInstructions(
|
||||||
it + 6,
|
it + 6,
|
||||||
"""
|
"""
|
||||||
const-string v1, "$settingsButtonClass"
|
const-string v$register1, "$settingsButtonClass"
|
||||||
const-string v2, "$settingsButtonInfoClass"
|
const-string v$register2, "$settingsButtonInfoClass"
|
||||||
invoke-static {v1, v2}, $CREATE_SETTINGS_ENTRY_METHOD_DESCRIPTOR
|
invoke-static {v$register1, v$register2}, $CREATE_SETTINGS_ENTRY_METHOD_DESCRIPTOR
|
||||||
move-result-object v1
|
move-result-object v$register2
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -73,14 +76,15 @@ class SettingsPatch : BytecodePatch(
|
|||||||
it.opcode == Opcode.INVOKE_SUPER
|
it.opcode == Opcode.INVOKE_SUPER
|
||||||
} + 1
|
} + 1
|
||||||
|
|
||||||
val thisRegister = getInstruction<FiveRegisterInstruction>(initializeSettingsIndex - 1).registerC
|
val thisRegister = getInstruction<Instruction35c>(initializeSettingsIndex - 1).registerC
|
||||||
|
val usableRegister = implementation!!.registerCount - parameters.size - 2
|
||||||
|
|
||||||
addInstructionsWithLabels(
|
addInstructionsWithLabels(
|
||||||
initializeSettingsIndex,
|
initializeSettingsIndex,
|
||||||
"""
|
"""
|
||||||
invoke-static {v$thisRegister}, $INITIALIZE_SETTINGS_METHOD_DESCRIPTOR
|
invoke-static {v$thisRegister}, $INITIALIZE_SETTINGS_METHOD_DESCRIPTOR
|
||||||
move-result v0
|
move-result v$usableRegister
|
||||||
if-eqz v0, :notrevanced
|
if-eqz v$usableRegister, :notrevanced
|
||||||
return-void
|
return-void
|
||||||
""",
|
""",
|
||||||
ExternalLabel("notrevanced", getInstruction(initializeSettingsIndex))
|
ExternalLabel("notrevanced", getInstruction(initializeSettingsIndex))
|
||||||
|
Loading…
Reference in New Issue
Block a user