mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-24 03:01:03 +00:00
refactor(photomath): SignatureDetectionPatch
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user