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

[feature] Allow plugins to edit BlockNodes #2335

Closed
eybisi opened this issue Nov 2, 2024 · 3 comments · Fixed by #2336
Closed

[feature] Allow plugins to edit BlockNodes #2335

eybisi opened this issue Nov 2, 2024 · 3 comments · Fixed by #2336

Comments

@eybisi
Copy link
Contributor

eybisi commented Nov 2, 2024

Allow plugins to edit BlockNodes

Plugins can't edit block nodes after BlockProcessor run, since blocks are locked. I mention specifically BlockProcessor because it adds very useful data to MethodNode (loops, dominators etc). These information can used to edit control flows For example I've used loops information from method node to find switch cases and manipulated control flow to recover it from obfuscator link

We can move mth.finishBasicBlocks(); out of BlockProcessor to another visitor lets say BlockFinisher. Then plugins can attach into .before('BlockFinisher') to manipulate blocks. I have a PR ready for this if its okay.

Also writing document to give general information about visitors for deobfuscation (or general) plugins will be very useful. For example if a deobfuscator plugin does MBA simplification to deobfuscate instructions when it should run? Which visitor gives best information ? I think generic cases for deobfuscation would be instruction editing, control flow editing, string deobfuscation

@skylot
Copy link
Owner

skylot commented Nov 2, 2024

We can move mth.finishBasicBlocks(); out of BlockProcessor to another visitor lets say BlockFinisher.

Sure, that's a good start.
Also, we need to add some method to "recalculate everything" so custom pass can call it after changing block tree overwise next plugin will get outdated info.

Also writing document to give general information about visitors

Yeah, I should add some docs on passes, but I am awful at writing, I started many times and still not finished it 🤣

@eybisi
Copy link
Contributor Author

eybisi commented Nov 2, 2024

Also, we need to add some method to "recalculate everything" so custom pass can call it after changing block tree overwise next plugin will get outdated info.

Yes good idea! I'm manually removing unused blocks and calling BlockProcessor again to reassing attributes.

@skylot
Copy link
Owner

skylot commented Nov 2, 2024

@eybisi I have added method to update blocks data:

BlockProcessor.updateBlocksData(mth);

Also, jadx libs snapshot updated, hope it works fine 🙂

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

Successfully merging a pull request may close this issue.

2 participants