Skip to content

Commit

Permalink
fix(Sync): Fix patches by not throwing unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 11, 2024
1 parent 0c75929 commit 2ee1316
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ val disablePiracyDetectionPatch = bytecodePatch(
execute {
// 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.method.addInstruction(0, "return-void")
piracyDetectionFingerprint.methodOrNull?.addInstruction(0, "return-void")
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package app.revanced.patches.reddit.customclients.sync.detection.piracy

import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.AccessFlags
import app.revanced.patcher.extensions.InstructionExtensions.instructions
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 {
accessFlags(AccessFlags.PRIVATE, AccessFlags.FINAL)
Expand All @@ -16,12 +18,9 @@ internal val piracyDetectionFingerprint = fingerprint {
Opcode.INVOKE_VIRTUAL,
)
custom { method, _ ->
method.implementation?.instructions?.any {
if (it.opcode != Opcode.NEW_INSTANCE) return@any false

val reference = (it as ReferenceInstruction).reference

reference.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;"
} == true
method.implementation ?: return@custom false
method.instructions.any {
it.getReference<Reference>()?.toString() == "Lcom/github/javiersantos/piracychecker/PiracyChecker;"
}
}
}

0 comments on commit 2ee1316

Please sign in to comment.