refactor(photomath): SignatureDetectionPatch

This commit is contained in:
Pun Butrach
2026-01-12 17:16:28 +07:00
parent 530f81b436
commit 1ee89fe0e6
2 changed files with 23 additions and 19 deletions

View File

@@ -1,18 +1,20 @@
package app.revanced.patches.photomath.detection.signature
import app.revanced.patcher.allOf
import app.revanced.patcher.firstMethodComposite
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import com.android.tools.smali.dexlib2.Opcode
import app.revanced.patcher.fingerprint
internal val checkSignatureFingerprint = fingerprint {
opcodes(
Opcode.CONST_STRING,
Opcode.INVOKE_STATIC,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT,
internal val checkSignatureMethodMatch = firstMethodComposite("SHA") {
instructions(
allOf(Opcode.CONST_STRING(), "SHA"()),
Opcode.INVOKE_STATIC(),
Opcode.INVOKE_STATIC(),
Opcode.MOVE_RESULT_OBJECT(),
Opcode.INVOKE_VIRTUAL(),
Opcode.MOVE_RESULT_OBJECT(),
Opcode.INVOKE_STATIC(),
Opcode.MOVE_RESULT(),
)
strings("SHA")
}

View File

@@ -2,17 +2,19 @@ package app.revanced.patches.photomath.detection.signature
import app.revanced.patcher.extensions.getInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.creatingBytecodePatch
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
val signatureDetectionPatch = bytecodePatch(
@Suppress("unused", "ObjectPropertyName")
val `Signature detection` by creatingBytecodePatch(
description = "Disables detection of incorrect signature.",
) {
apply {
val replacementIndex = checkSignatureFingerprint.instructionMatches.last().index
val checkRegister =
checkSignatureFingerprint.method.getInstruction<OneRegisterInstruction>(replacementIndex).registerA
checkSignatureFingerprint.method.replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1")
val replacementIndex = checkSignatureMethodMatch.indices.last()
checkSignatureMethodMatch.method.apply {
val checkRegister = getInstruction<OneRegisterInstruction>(replacementIndex).registerA
replaceInstruction(replacementIndex, "const/4 v$checkRegister, 0x1")
}
}
}