refactor(photomath): SpoofDeviceIdPatch

This commit is contained in:
Pun Butrach
2026-01-12 17:12:08 +07:00
parent 198cb93ef2
commit 530f81b436
2 changed files with 24 additions and 20 deletions

View File

@@ -1,21 +1,26 @@
package app.revanced.patches.photomath.detection.deviceid
import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patcher.parameterTypes
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import com.android.tools.smali.dexlib2.Opcode
import app.revanced.patcher.fingerprint
internal val getDeviceIdFingerprint = fingerprint {
returns("Ljava/lang/String;")
parameters()
opcodes(
Opcode.SGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IF_NEZ,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_VIRTUAL,
internal val BytecodePatchContext.getDeviceIdMethod by gettingFirstMutableMethodDeclaratively {
returnType("Ljava/lang/String;")
parameterTypes()
instructions(
Opcode.SGET_OBJECT(),
Opcode.IGET_OBJECT(),
Opcode.INVOKE_STATIC(),
Opcode.MOVE_RESULT_OBJECT(),
Opcode.IF_NEZ(),
Opcode.INVOKE_STATIC(),
Opcode.MOVE_RESULT_OBJECT(),
Opcode.INVOKE_VIRTUAL(),
Opcode.MOVE_RESULT_OBJECT(),
Opcode.INVOKE_VIRTUAL(),
)
}
}

View File

@@ -1,13 +1,12 @@
package app.revanced.patches.photomath.detection.deviceid
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.creatingBytecodePatch
import app.revanced.patches.photomath.detection.signature.signatureDetectionPatch
import app.revanced.util.returnEarly
import kotlin.random.Random
@Suppress("unused")
val getDeviceIdPatch = bytecodePatch(
name = "Spoof device ID",
val `Spoof device ID` by creatingBytecodePatch(
description = "Spoofs device ID to mitigate manual bans by developers.",
) {
dependsOn(signatureDetectionPatch)
@@ -15,6 +14,6 @@ val getDeviceIdPatch = bytecodePatch(
compatibleWith("com.microblink.photomath")
apply {
getDeviceIdFingerprint.method.returnEarly(Random.nextLong().toString(16))
getDeviceIdMethod.returnEarly(Random.nextLong().toString(16))
}
}