fix(Sync): Fix patches by not throwing unnecessarily

This commit is contained in:
oSumAtrIX 2024-11-11 02:37:44 +01:00
parent 0c75929a83
commit 2ee13160d5
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 10 additions and 11 deletions

View File

@ -10,6 +10,6 @@ val disablePiracyDetectionPatch = bytecodePatch(
execute { execute {
// Do not throw an error if the fingerprint is not resolved. // 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. // This is fine because new versions of the target app do not need this patch.
piracyDetectionFingerprint.method.addInstruction(0, "return-void") piracyDetectionFingerprint.methodOrNull?.addInstruction(0, "return-void")
} }
} }

View File

@ -1,9 +1,11 @@
package app.revanced.patches.reddit.customclients.sync.detection.piracy package app.revanced.patches.reddit.customclients.sync.detection.piracy
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction import app.revanced.patcher.extensions.InstructionExtensions.instructions
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import app.revanced.patcher.fingerprint import app.revanced.patcher.fingerprint
import app.revanced.util.getReference
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 piracyDetectionFingerprint = fingerprint {
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL) accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
@ -16,12 +18,9 @@ internal val piracyDetectionFingerprint = fingerprint {
Opcode.INVOKE_VIRTUAL, Opcode.INVOKE_VIRTUAL,
) )
custom { method, _ -> custom { method, _ ->
method.implementation?.instructions?.any { method.implementation ?: return@custom false
if (it.opcode != Opcode.NEW_INSTANCE) return@any false method.instructions.any {
it.getReference<Reference>()?.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;"
val reference = (it as ReferenceInstruction).reference }
reference.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;"
} == true
} }
} }