forked from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(songpal): make patches more resilient (ReVanced#2386)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
Showing
2 changed files
with
42 additions
and
41 deletions.
There are no files selected for viewing
37 changes: 16 additions & 21 deletions
37
src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/CreateTabsFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,26 @@ | ||
package app.revanced.patches.songpal.badge.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.songpal.badge.patch.BadgeTabPatch | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction | ||
import org.jf.dexlib2.iface.reference.MethodReference | ||
|
||
// Located @ ub.i0.h#p (9.5.0) | ||
@FuzzyPatternScanMethod(2) | ||
object CreateTabsFingerprint : MethodFingerprint( | ||
"L", | ||
"Ljava/util/List", | ||
accessFlags = AccessFlags.PRIVATE.value, | ||
opcodes = listOf( | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.SGET_OBJECT, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.SGET_OBJECT, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.CHECK_CAST, | ||
Opcode.RETURN_OBJECT | ||
) | ||
customFingerprint = { methodDef, _ -> | ||
methodDef.implementation?.instructions?.any { instruction -> | ||
if (instruction.opcode != Opcode.INVOKE_STATIC) return@any false | ||
|
||
val reference = (instruction as ReferenceInstruction).reference as MethodReference | ||
|
||
if (reference.parameterTypes.isNotEmpty()) return@any false | ||
if (reference.definingClass != BadgeTabPatch.ACTIVITY_TAB_DESCRIPTOR) return@any false | ||
if (reference.returnType != "[${BadgeTabPatch.ACTIVITY_TAB_DESCRIPTOR}") return@any false | ||
true | ||
} ?: false | ||
} | ||
) |
46 changes: 26 additions & 20 deletions
46
...ain/kotlin/app/revanced/patches/songpal/badge/fingerprints/ShowNotificationFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
package app.revanced.patches.songpal.badge.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.songpal.badge.fingerprints.ShowNotificationFingerprint.expectedReference | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction | ||
import org.jf.dexlib2.iface.reference.MethodReference | ||
import org.jf.dexlib2.immutable.reference.ImmutableMethodReference | ||
|
||
// Located @ com.sony.songpal.mdr.vim.activity.MdrRemoteBaseActivity.e#run (9.5.0) | ||
@FuzzyPatternScanMethod(2) | ||
object ShowNotificationFingerprint : MethodFingerprint( | ||
"V", | ||
accessFlags = AccessFlags.PUBLIC.value, | ||
opcodes = listOf( | ||
Opcode.IGET_OBJECT, | ||
Opcode.IGET, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.IGET_OBJECT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.CONST, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.IGET_BOOLEAN, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.CONST, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.RETURN_VOID | ||
customFingerprint = custom@{ methodDef, _ -> | ||
methodDef.implementation?.instructions?.any { instruction -> | ||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) return@any false | ||
|
||
with(expectedReference) { | ||
val currentReference = (instruction as ReferenceInstruction).reference as MethodReference | ||
currentReference.let { | ||
if (it.definingClass != definingClass) return@any false | ||
if (it.parameterTypes != parameterTypes) return@any false | ||
if (it.returnType != returnType) return@any false | ||
} | ||
} | ||
true | ||
} ?: false | ||
} | ||
) { | ||
val expectedReference = ImmutableMethodReference( | ||
"Lcom/google/android/material/bottomnavigation/BottomNavigationView;", | ||
"getOrCreateBadge", // Non-obfuscated placeholder method name. | ||
listOf("I"), | ||
"Lcom/google/android/material/badge/BadgeDrawable;", | ||
) | ||
) | ||
} |