Skip to content

Commit

Permalink
refactor, remove lastInstruction() filter
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Feb 2, 2025
1 parent 44a1424 commit fc319f4
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 154 deletions.
29 changes: 11 additions & 18 deletions api/revanced-patcher.api
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
public final class app/revanced/patcher/AnyInstruction : app/revanced/patcher/InstructionFilter {
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
}

public final class app/revanced/patcher/CheckCastFilter : app/revanced/patcher/OpcodeFilter {
public final fun getType ()Lkotlin/jvm/functions/Function1;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
public final fun setType (Lkotlin/jvm/functions/Function1;)V
}

public final class app/revanced/patcher/FieldAccessFilter : app/revanced/patcher/OpcodesFilter {
public final fun getDefiningClass ()Lkotlin/jvm/functions/Function1;
public final fun getName ()Lkotlin/jvm/functions/Function1;
public final fun getType ()Lkotlin/jvm/functions/Function1;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
}

public final class app/revanced/patcher/Fingerprint {
Expand Down Expand Up @@ -80,7 +80,6 @@ public final class app/revanced/patcher/FingerprintKt {
public static synthetic fun fieldAccess$default (Ljava/lang/String;Ljava/util/List;IILjava/lang/Object;)Lapp/revanced/patcher/FieldAccessFilter;
public static synthetic fun fieldAccess$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Ljava/util/List;IILjava/lang/Object;)Lapp/revanced/patcher/FieldAccessFilter;
public static final fun fingerprint (Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/FingerprintDelegate;
public static final fun lastInstruction (Lapp/revanced/patcher/InstructionFilter;)Lapp/revanced/patcher/LastInstructionFilter;
public static final fun literal (DLjava/util/List;I)Lapp/revanced/patcher/LiteralFilter;
public static final fun literal (JLjava/util/List;I)Lapp/revanced/patcher/LiteralFilter;
public static final fun literal (Lkotlin/jvm/functions/Function1;Ljava/util/List;I)Lapp/revanced/patcher/LiteralFilter;
Expand Down Expand Up @@ -115,8 +114,8 @@ public abstract class app/revanced/patcher/InstructionFilter {
public fun <init> ()V
public fun <init> (I)V
public synthetic fun <init> (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getMaxBefore ()I
public abstract fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public final fun getMaxAfter ()I
public abstract fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
}

public final class app/revanced/patcher/InstructionFilter$Companion {
Expand All @@ -125,15 +124,9 @@ public final class app/revanced/patcher/InstructionFilter$Companion {
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 final fun getFilter ()Lapp/revanced/patcher/InstructionFilter;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;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 final fun getLiteral ()Lkotlin/jvm/functions/Function1;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
public final fun setLiteral (Lkotlin/jvm/functions/Function1;)V
}

Expand Down Expand Up @@ -172,30 +165,30 @@ public final class app/revanced/patcher/MethodCallFilter : app/revanced/patcher/
public final fun getName ()Lkotlin/jvm/functions/Function1;
public final fun getParameters ()Lkotlin/jvm/functions/Function1;
public final fun getReturnType ()Lkotlin/jvm/functions/Function1;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
}

public final class app/revanced/patcher/MethodCallFilter$Companion {
}

public final class app/revanced/patcher/NewInstanceFilter : app/revanced/patcher/OpcodesFilter {
public final fun getType ()Lkotlin/jvm/functions/Function1;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
public final fun setType (Lkotlin/jvm/functions/Function1;)V
}

public class app/revanced/patcher/OpcodeFilter : app/revanced/patcher/InstructionFilter {
public fun <init> (Lcom/android/tools/smali/dexlib2/Opcode;I)V
public final fun getOpcode ()Lcom/android/tools/smali/dexlib2/Opcode;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
}

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

public final class app/revanced/patcher/OpcodesFilter$Companion {
Expand Down Expand Up @@ -247,7 +240,7 @@ public final class app/revanced/patcher/PatcherResult$PatchedResources {
public final class app/revanced/patcher/StringFilter : app/revanced/patcher/OpcodesFilter {
public final fun getPartialMatch ()Z
public final fun getString ()Lkotlin/jvm/functions/Function1;
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;I)Z
public fun matches (Lapp/revanced/patcher/patch/BytecodePatchContext;Lcom/android/tools/smali/dexlib2/iface/Method;Lcom/android/tools/smali/dexlib2/iface/instruction/Instruction;)Z
public final fun setPartialMatch (Z)V
public final fun setString (Lkotlin/jvm/functions/Function1;)V
}
Expand Down
9 changes: 4 additions & 5 deletions docs/2_2_1_fingerprinting.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ val hideAdsFingerprint by fingerprint {
),

// Filter 4
// maxBefore = 0 means this must match immediately after the last filter.
opcode(Opcode.MOVE_RESULT, maxBefore = 0),
// maxAfter = 0 means this must match immediately after the last filter.
opcode(Opcode.MOVE_RESULT, maxAfter = 0),

// Filter 5
literal(1337),
Expand All @@ -197,10 +197,9 @@ val hideAdsFingerprint by fingerprint {
must be declared in the same order as the instructions appear in the target method.

If the distance between each instruction declaration can be approximated,
then the `maxBefore` parameter can be used to restrict the instruction match to
then the `maxAfter` parameter can be used to restrict the instruction match to
a maximum distance from the last instruction. A value of 0 for the first instruction filter
means the filter must be the first instruction of the target method. To restrict an instruction
filter to only match the last instruction of a method, use the `lastInstruction()` filter wrapper.
means the filter must be the first instruction of the target method.

If a single instruction varies slightly between different app targets but otherwise the fingerprint
is still the same, the `anyInstruction()` wrapper can be used to specify variations of the
Expand Down
Loading

0 comments on commit fc319f4

Please sign in to comment.