refactor(sync): DisablePiracyDetectionPatch

This commit is contained in:
Pun Butrach
2026-01-12 16:46:43 +07:00
parent f4f43660da
commit 5477e8edbe
2 changed files with 19 additions and 21 deletions

View File

@@ -1,15 +1,15 @@
package app.revanced.patches.reddit.customclients.sync.detection.piracy
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.creatingBytecodePatch
val disablePiracyDetectionPatch = bytecodePatch(
val `Disable privacy detection` = creatingBytecodePatch(
description = "Disables detection of modified versions.",
) {
apply {
// Do not throw an error if the fingerprint is not resolved.
// This is fine because new versions of the target app do not need this patch.
piracyDetectionFingerprint.methodOrNull?.addInstruction(0, "return-void")
piracyDetectionMethod.addInstruction(0, "return-void")
}
}

View File

@@ -1,26 +1,24 @@
package app.revanced.patches.reddit.customclients.sync.detection.piracy
import app.revanced.patcher.extensions.instructions
import app.revanced.patcher.fingerprint
import app.revanced.util.getReference
import app.revanced.patcher.BytecodePatchContextMethodMatching.gettingFirstMutableMethodDeclaratively
import app.revanced.patcher.accessFlags
import app.revanced.patcher.instructions
import app.revanced.patcher.invoke
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.returnType
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.reference.Reference
internal val piracyDetectionFingerprint = fingerprint {
internal val BytecodePatchContext.piracyDetectionMethod by gettingFirstMutableMethodDeclaratively(
"Lcom/github/javiersantos/piracychecker/PiracyChecker;"
) {
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
returns("V")
opcodes(
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.INVOKE_VIRTUAL,
returnType("V")
instructions(
Opcode.NEW_INSTANCE(),
Opcode.INVOKE_DIRECT(),
Opcode.NEW_INSTANCE(),
Opcode.INVOKE_DIRECT(),
Opcode.INVOKE_VIRTUAL(),
)
custom { method, _ ->
method.implementation ?: return@custom false
method.instructions.any {
it.getReference<Reference>()?.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;"
}
}
}