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: use class fingerprint instead of method fingerprint #164

Open
3 tasks done
Aunali321 opened this issue Apr 14, 2023 · 3 comments
Open
3 tasks done

feat: use class fingerprint instead of method fingerprint #164

Aunali321 opened this issue Apr 14, 2023 · 3 comments
Labels
Feature request Requesting a new feature that's not implemented yet

Comments

@Aunali321
Copy link
Member

Type

Functionality

Issue

Class fingerprints are helpful to find methods that have same method signature.

Feature

object MyClassFingerprint : ClassFingerprint(
    "com/example/package/MyClass",  // Name of the class
    listOf( // list of method signatures present in the class
        MethodFingerprint("V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L", "L", "L"), listOf(
            // Opcode list for method 1
        )),

        MethodFingerprint(strings = listOf("force_overlay", "Media#updateFields", "live_reels_metadata"))

        MethodFingerprint(customFingerprint = { methodDef ->
            methodDef.definingClass.endsWith("ClipsEditMetadataController;")
    }),


        // Add more method fingerprints as needed
    ),
    // Number of methods in the class
    3
)

ClassFingerprint: This is a class that extends the Fingerprint class and is used to define the fingerprint of the target class. The ClassFingerprint includes a set of characteristics that uniquely identify the target class, such as the class name, method signatures, and number of methods in the class.

Other details are self-explanatory.

Motivation

  1. Class structure is more stable
  2. More precise matching
  3. Less prone to false positives

Additional context

No response

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.
@Aunali321 Aunali321 added the Feature request Requesting a new feature that's not implemented yet label Apr 14, 2023
@oSumAtrIX
Copy link
Member

Also fields and other metadata like access flags

@badawoll
Copy link
Contributor

badawoll commented May 10, 2023

This feature came up in a discussion here.

Not sure what the best way to implement this would be (I don't have much Kotlin development experience), I came up with two viable solutions (they both expose ClassDef to `customFingerprint):

  • change customFingerprint signature to (Method, ClassDef) -> Bool. It's clean (nice API), but breaks pretty much all patches that depend on a custom fingerprint.
  • create a MethodProxy class that implements Method, but also accepts a ClassDef as a constructor argument, and makes it publicly accessible. Doesn't break API, but feels more hacky.

Maybe there exists even a cleaner way? I looked at extensions, but I couldn't find a nice way to pass a local variable into an extension function/field.

MethodFingerprint could also be reworked to perform matching on the ClassDef.

@oSumAtrIX
Copy link
Member

oSumAtrIX commented May 10, 2023

The first way is not an issue. The commit will be marked as a breaking change, if patches update to it, they will have to adjust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Requesting a new feature that's not implemented yet
Projects
None yet
Development

No branches or pull requests

3 participants