Recaf icon indicating copy to clipboard operation
Recaf copied to clipboard

Improvements to missing class generation

Open Col-E opened this issue 2 years ago • 0 comments

Problem: JPhantom works for basic cases, consistently fails on large inputs & obfuscated code

Alternatives: Reconstruct - though not yet feature complete

Requirements for viable alternatives:

  • Generate missing @annotation when a @annotation(foo="bar") and such are seen annotating classes/fields/methods
  • Generate missing classes when getfield references are seen
    • Interfaces can only have constants, so if you see a getfield or putfield you know it must be a class/enum/record
  • Ensure type hierarchies must be regenerated to the best of their ability
    • The accuracy is limited to what is available in the known code being analyzed
  • Should prefer creating class over interface types when possible
    • If some type does not have enough known about it to be sure one way or another, default to class instead of interface
    • Must consider use in type hierarchies, due to single inheritance of classes you will need interfaces at times

Bonus points:

  • Allow a lazy model which can be updated over time
    • Rather than run analysis on the entire input at launch, only analyze one class at a time (such as what is open in the Recaf UI) and then update the generated model over time.
    • Saves a lot of CPU on startup, reduces over-all workload assuming a user will not be opening every single class in an input workspace
  • Allow manual tweaking of the model
    • It may be useful to allow users to provide the ability to "correct" the model. If there is some missing data that prevents the generation of some fields/methods in a phantom class, the user could tell the model these items exist, allowing the recompile feature to utilize their changes
    • The model changes sent by users must be validated such that they cannot "break" the model into making invalid classes.

Col-E avatar Apr 05 '23 00:04 Col-E