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

Virtual mappings #671

Open
Col-E opened this issue Jan 12, 2023 · 1 comment
Open

Virtual mappings #671

Col-E opened this issue Jan 12, 2023 · 1 comment

Comments

@Col-E
Copy link
Owner

Col-E commented Jan 12, 2023

Mostly for brainstorming, the feature is complex and not likely to actually be implemented unless a REALLY good solution is put forward

UI components:

  • Workspace tree
  • Class tab tiles
  • Class views & all associated components

Logical components:

  • Decompilers
    • Need to target the virtual mappings, NOT the real existing code
      • Pre-processors can handle that
  • Assembler / Disassembler
    • Need to target the virtual mappings, NOT the real existing code
      • This one is a bit of a doozy...
  • Inheritance graph
    • Need to target the virtual mappings, NOT the real existing code
      • Need to make getSuperClass() yield the virtual mapped name, or handle it explicitly here.
      • More API changes for solution work mentioned below.
  • Call graph
    • Need to target the virtual mappings, NOT the real existing code
      • Should be operating off virtually mapped bytecode, shouldn't be too hard to manage.
      • Lookups by name need to resolve as virtual mapped names.
  • Mapping
    • Need to target the virtual mappings, NOT the real existing code
      Example: If XYZ is virtually Dog what should be done in the given circumstances?
      • Map XYZ to ABC: Nothing since XYZ virtually does not exist.
      • Map Dog to ABC: Apply the mapping.

Potential solutions:

  • Currently we have getBytecode() for JVM classes.
    • Instead offer getOriginalBytecode() and getVirtualMappedBytecode() (Names not final, but to drive the point across)
    • The VirtualMappedBytecode is mutable data, which is dynamically updated across the workspace whenever virtual mapping are modified. They are thus always kept up-to-date.
      • Would be useful to optimize the update process so unaffected classes per a change are easily determined, so the mapping process only applies to relevent classes.
    • The usage of getOriginalBytecode() is very limited, and instead most calls are to getVirtualMappedBytecode().
    • The remaining issue is maintaining access by virtual name.
      • Can potentially change the Workspace#findClass(String) to assume the input is the virtual mapped name?
        • Would need to ensure all ClassInfo lookups use the find operations, and not directly from the ClassMap.
@Col-E Col-E transferred this issue from Col-E/recaf-3x-issues Aug 30, 2023
@Col-E Col-E mentioned this issue Sep 13, 2023
@Janmm14
Copy link
Contributor

Janmm14 commented Sep 23, 2023

Using a bijective function for identifier renaming and renaming all identifiers makes virtual mapped bytecode not experience more mutations than regular bytecode..
The target identifier could add prefix for field/class/method differenciation, every char not allowed in identifiers and underscores are replaced by _ + unicode hex of the char + same for desc

Every feature except mappings would use the virtual mapped bytecode and "only" for displaying to the user or exporting identifiers would be mapped back.
Maybe there'd be no need to even keep non-mapped bytecode in memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants