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