Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Match fingerprints by instruction filters #329

Open
wants to merge 59 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
31f6122
feat: Match fingerprints by instruction filters
LisoUseInAIKyrios Jan 1, 2025
1965e84
refactor
LisoUseInAIKyrios Jan 2, 2025
d02aad0
refactor: Use 'by' semantic to capture fingerprint name
LisoUseInAIKyrios Jan 3, 2025
a160101
Allow using a fingerprint result inside another fingerprint
LisoUseInAIKyrios Jan 3, 2025
7547319
fix 'by' syntax causing multiple resolves. Add debug resolving perfor…
LisoUseInAIKyrios Jan 3, 2025
14335e8
Add helper method
LisoUseInAIKyrios Jan 3, 2025
3386fd9
make match result fields consistent with fingerprint accessor methods
LisoUseInAIKyrios Jan 3, 2025
e2707e1
fix: Retain existing null opcode behavior
LisoUseInAIKyrios Jan 3, 2025
9779e50
refactor: Change `ByteCodePatchContext` to a singleton object, remove…
LisoUseInAIKyrios Jan 3, 2025
4d38837
feat: Add 'classFingerprint' (parent fingerprint)
LisoUseInAIKyrios Jan 3, 2025
a3852a6
fix: Temporarily turn off failing tests
LisoUseInAIKyrios Jan 4, 2025
2b6e437
add `NewInstanceFilter`, add JVM method string parsing, add basic uni…
LisoUseInAIKyrios Jan 4, 2025
319a8a7
code documentation
LisoUseInAIKyrios Jan 4, 2025
1199e21
refactor
LisoUseInAIKyrios Jan 5, 2025
111d6ca
comments
LisoUseInAIKyrios Jan 5, 2025
3dad1b0
refactor
LisoUseInAIKyrios Jan 5, 2025
6c80a20
refactor: remove performance logging
LisoUseInAIKyrios Jan 5, 2025
cfb873a
Revert "refactor: Change `ByteCodePatchContext` to a singleton object…
LisoUseInAIKyrios Jan 5, 2025
c37ecb8
fix: delete test that is now too clunky since a context must be passed
LisoUseInAIKyrios Jan 5, 2025
231378e
refactor: Rename to `MethodCallFilter` and `FieldCallFilter`
LisoUseInAIKyrios Jan 5, 2025
502ea98
Revert "feat: Add 'classFingerprint' (parent fingerprint)"
LisoUseInAIKyrios Jan 5, 2025
f5a1b26
perf: Copy strings only if strings are found
LisoUseInAIKyrios Jan 5, 2025
1166096
Restore instruction filter test
LisoUseInAIKyrios Jan 5, 2025
cdb986d
Comments. Will update .md examples after DSL is figured out.
LisoUseInAIKyrios Jan 5, 2025
0e85451
refactor: Rename FieldCallFilter -> FieldAccessFilter
LisoUseInAIKyrios Jan 6, 2025
b3b77ac
docs: Update fingerprinting examples
LisoUseInAIKyrios Jan 6, 2025
47e8086
refactor: Use DSL style constructor functions
LisoUseInAIKyrios Jan 7, 2025
0ca165d
refactor
LisoUseInAIKyrios Jan 7, 2025
f54efb1
add String literal instruction filter
LisoUseInAIKyrios Jan 7, 2025
a572771
docs: Cleanup examples
LisoUseInAIKyrios Jan 8, 2025
2faba7f
Comments
LisoUseInAIKyrios Jan 9, 2025
b74d51b
refactor: Comments, consistency
LisoUseInAIKyrios Jan 9, 2025
df7bc88
refactor: Allow partial matches of string literals
LisoUseInAIKyrios Jan 9, 2025
2c91090
refactor
LisoUseInAIKyrios Jan 9, 2025
a0a0306
perf: Skip return type check if access flags include constructor
LisoUseInAIKyrios Jan 9, 2025
329dfbd
add 'checkCast' instruction filter
LisoUseInAIKyrios Jan 10, 2025
b117dba
Add field access smali parsing for consistency
LisoUseInAIKyrios Jan 10, 2025
bb06381
fix: Improve smali regex filter
LisoUseInAIKyrios Jan 10, 2025
e1930ea
refactor: Match class types using endsWith
LisoUseInAIKyrios Jan 10, 2025
f981d1c
refactor: Throw exception on bad new instance type
LisoUseInAIKyrios Jan 10, 2025
20b4900
Add more details to example
LisoUseInAIKyrios Jan 12, 2025
132fa00
refactor: Add sub version to show files in correct order
LisoUseInAIKyrios Jan 12, 2025
f93f870
refactor: Deprecate pure opcode declarations
LisoUseInAIKyrios Jan 15, 2025
955ceb6
Move instruction filters to fingerprint.kt file
LisoUseInAIKyrios Jan 15, 2025
c74c1b8
rename parameter to be more clear
LisoUseInAIKyrios Jan 15, 2025
5885984
Revert "refactor: Deprecate pure opcode declarations" It's still use…
LisoUseInAIKyrios Jan 21, 2025
57d8087
add debugging code
LisoUseInAIKyrios Jan 27, 2025
1dacd3d
Revert "add debugging code"
LisoUseInAIKyrios Jan 27, 2025
b08ef19
Work in progress fix for wrong fingerprint indexes found when multipl…
LisoUseInAIKyrios Jan 27, 2025
0f198c4
fix: Replace original classdef with proxy class immediately
LisoUseInAIKyrios Jan 28, 2025
142aa71
refactor: Remove ClassProxy wrapper that's no longer needed. All exi…
LisoUseInAIKyrios Jan 28, 2025
8951990
refactor: Change ProxyList to a map, remove now redundant class looku…
LisoUseInAIKyrios Jan 28, 2025
772c0e6
Update documentation
LisoUseInAIKyrios Jan 28, 2025
8f7911e
Refactor: Simplify
LisoUseInAIKyrios Jan 28, 2025
567feef
refactor: Add `mutableClassByOrNull()`
LisoUseInAIKyrios Jan 28, 2025
d7974ef
refactor: Pre-size the class map
LisoUseInAIKyrios Jan 28, 2025
d0e0a80
Update examples
LisoUseInAIKyrios Jan 28, 2025
44a1424
refactor
LisoUseInAIKyrios Jan 30, 2025
fc319f4
refactor, remove `lastInstruction()` filter
LisoUseInAIKyrios Feb 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 105 additions & 4 deletions api/revanced-patcher.api
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
public final class app/revanced/patcher/AnyFilter : app/revanced/patcher/InstructionFilter {
public fun <init> (Ljava/util/List;I)V
public synthetic fun <init> (Ljava/util/List;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getMaxInstructionsBefore ()I
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
}

public final class app/revanced/patcher/FieldFilter : app/revanced/patcher/OpcodesFilter {
public fun <init> ()V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;I)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDefiningClass ()Ljava/lang/String;
public fun getMaxInstructionsBefore ()I
public final fun getName ()Ljava/lang/String;
public final fun getType ()Ljava/lang/String;
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
}

public final class app/revanced/patcher/Fingerprint {
public final fun getClassDef (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
public final fun getClassDefOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
public final fun getFilterMatch (Lapp/revanced/patcher/patch/BytecodePatchContext;)Ljava/util/List;
public final fun getFilterMatchOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Ljava/util/List;
public final fun getMethod (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun getMethodOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun getOriginalClassDef (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/ClassDef;
public final fun getOriginalClassDefOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/ClassDef;
public final fun getOriginalMethod (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/Method;
public final fun getOriginalMethodOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lcom/android/tools/smali/dexlib2/iface/Method;
public final fun getPatternMatch (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/Match$PatternMatch;
public final fun getPatternMatchOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Lapp/revanced/patcher/Match$PatternMatch;
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
public final fun getStringMatches (Lapp/revanced/patcher/patch/BytecodePatchContext;)Ljava/util/List;
public final fun getStringMatchesOrNull (Lapp/revanced/patcher/patch/BytecodePatchContext;)Ljava/util/List;
public final fun match (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/ClassDef;)Lapp/revanced/patcher/Match;
Expand All @@ -20,10 +39,10 @@ public final class app/revanced/patcher/Fingerprint {
}

public final class app/revanced/patcher/FingerprintBuilder {
public fun <init> ()V
public final fun accessFlags (I)V
public final fun accessFlags ([Lcom/android/tools/smali/dexlib2/AccessFlags;)V
public final fun custom (Lkotlin/jvm/functions/Function2;)V
public final fun instructions ([Lapp/revanced/patcher/InstructionFilter;)V
public final fun opcodes (Ljava/lang/String;)V
public final fun opcodes ([Lcom/android/tools/smali/dexlib2/Opcode;)V
public final fun parameters ([Ljava/lang/String;)V
Expand All @@ -32,22 +51,60 @@ public final class app/revanced/patcher/FingerprintBuilder {
}

public final class app/revanced/patcher/FingerprintKt {
public static final fun fingerprint (ILkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/Fingerprint;
public static synthetic fun fingerprint$default (ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/Fingerprint;
public static final fun fingerprint (Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/Fingerprint;
}

public abstract interface class app/revanced/patcher/InstructionFilter {
public static final field Companion Lapp/revanced/patcher/InstructionFilter$Companion;
public static final field METHOD_MAX_INSTRUCTIONS I
public abstract fun getMaxInstructionsBefore ()I
public abstract fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
}

public final class app/revanced/patcher/InstructionFilter$Companion {
public static final field METHOD_MAX_INSTRUCTIONS I
}

public abstract interface annotation class app/revanced/patcher/InternalApi : java/lang/annotation/Annotation {
}

public final class app/revanced/patcher/LastInstructionFilter : app/revanced/patcher/InstructionFilter {
public fun <init> (Lapp/revanced/patcher/InstructionFilter;I)V
public synthetic fun <init> (Lapp/revanced/patcher/InstructionFilter;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getFilter ()Lapp/revanced/patcher/InstructionFilter;
public fun getMaxInstructionsBefore ()I
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public final fun setFilter (Lapp/revanced/patcher/InstructionFilter;)V
}

public final class app/revanced/patcher/LiteralFilter : app/revanced/patcher/OpcodesFilter {
public fun <init> (DILjava/util/List;)V
public synthetic fun <init> (DILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (JILjava/util/List;)V
public synthetic fun <init> (JILjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getLiteral ()J
public fun getMaxInstructionsBefore ()I
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public final fun setLiteral (J)V
}

public final class app/revanced/patcher/Match {
public final fun getClassDef ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableClass;
public final fun getFilterMatches ()Ljava/util/List;
public final fun getMethod ()Lapp/revanced/patcher/util/proxy/mutableTypes/MutableMethod;
public final fun getOriginalClassDef ()Lcom/android/tools/smali/dexlib2/iface/ClassDef;
public final fun getOriginalMethod ()Lcom/android/tools/smali/dexlib2/iface/Method;
public final fun getPatternMatch ()Lapp/revanced/patcher/Match$PatternMatch;
public final fun getStringMatches ()Ljava/util/List;
}

public final class app/revanced/patcher/Match$FilterMatch {
public fun <init> (Lapp/revanced/patcher/InstructionFilter;ILcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)V
public final fun getFilter ()Lapp/revanced/patcher/InstructionFilter;
public final fun getIndex ()I
public final fun getInstruction ()Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;
}

public final class app/revanced/patcher/Match$PatternMatch {
public final fun getEndIndex ()I
public final fun getStartIndex ()I
Expand All @@ -58,6 +115,47 @@ public final class app/revanced/patcher/Match$StringMatch {
public final fun getString ()Ljava/lang/String;
}

public final class app/revanced/patcher/MethodFilter : app/revanced/patcher/OpcodesFilter {
public fun <init> ()V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/util/List;I)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/util/List;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDefiningClass ()Ljava/lang/String;
public final fun getMethodName ()Ljava/lang/String;
public final fun getParameters ()Ljava/util/List;
public final fun getReturnType ()Ljava/lang/String;
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
}

public final class app/revanced/patcher/MethodFingerprintFilter : app/revanced/patcher/InstructionFilter {
public fun <init> (Lapp/revanced/patcher/Fingerprint;I)V
public synthetic fun <init> (Lapp/revanced/patcher/Fingerprint;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getMaxInstructionsBefore ()I
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
}

public final class app/revanced/patcher/OpcodeFilter : app/revanced/patcher/InstructionFilter {
public static final field Companion Lapp/revanced/patcher/OpcodeFilter$Companion;
public fun <init> (Lcom/android/tools/smali/dexlib2/Opcode;I)V
public synthetic fun <init> (Lcom/android/tools/smali/dexlib2/Opcode;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getMaxInstructionsBefore ()I
public final fun getOpcode ()Lcom/android/tools/smali/dexlib2/Opcode;
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
}

public final class app/revanced/patcher/OpcodeFilter$Companion {
public final fun listOfOpcodes (Ljava/util/Collection;)Ljava/util/List;
}

public class app/revanced/patcher/OpcodesFilter : app/revanced/patcher/InstructionFilter {
public fun <init> (Ljava/util/EnumSet;I)V
public synthetic fun <init> (Ljava/util/EnumSet;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/util/List;I)V
public synthetic fun <init> (Ljava/util/List;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getMaxInstructionsBefore ()I
public final fun getOpcodes ()Ljava/util/EnumSet;
public fun matches (Lcom/android/tools/smali/dexlib2/iface/ClassDef;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
}

public final class app/revanced/patcher/PackageMetadata {
public final fun getPackageName ()Ljava/lang/String;
public final fun getPackageVersion ()Ljava/lang/String;
Expand Down Expand Up @@ -171,9 +269,12 @@ public final class app/revanced/patcher/patch/BytecodePatchContext : app/revance
public final class app/revanced/patcher/patch/Option {
public fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;)V
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;ZLkotlin/reflect/KType;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDefault ()Ljava/lang/Object;
public final fun getDescription ()Ljava/lang/String;
public final fun getKey ()Ljava/lang/String;
public final fun getName ()Ljava/lang/String;
public final fun getRequired ()Z
public final fun getTitle ()Ljava/lang/String;
public final fun getType ()Lkotlin/reflect/KType;
Expand Down
Loading
Loading