wargio / r2dec-js

radare2 plugin - converts asm to pseudo-C code.
508 stars 48 forks source link

esm and qjs rewrite #293

Closed trufae closed 8 months ago

trufae commented 1 year ago

Some months ago i rewrote r2dec to use ESM and few other basic es6 features. The plan was to make r2dec run on top of quickjs instead of duktape. and also be loaded as a native javascript plugin for radare2, now that we ship qjs by default.

The result is 2-3 faster execution, cleaner code and it does not depend on a C compiler anymore and also works in the webassembly builds (duktape depends on globals and setjmp which is bad). But the amount of changes in the import/require statements makes it not possible to work side by side (some stuff is not ported because that was just a PoC), so a fork is required because duktape will never support es6 or esm. And that's a language change not an API one. I just have the WIP rewrite in a branch of my fork just in case someone wants to try:

But i'm opening this issue here just to discuss about options and plans for the main r2dec in order to move to this new paradigm before doing more work. I have been rebasing it without much difficulty, but supporting both engines is imho not an option.

Thoughs?

wargio commented 1 year ago

could be a good transition. i would just use es6 tho.

trufae commented 1 year ago

So how would you like to proceed?

wargio commented 1 year ago

probably i need to integrate quickjs in r2dec and remove the dukjs dependency code.

trufae commented 12 months ago

If r2dec is only suposed to run in r2 you can just relay on r2's qjs and theres no need to port the c logic to use qjs instead of duktape.

Check my pr, the js code is compiled with frida-compile (or r2frida-compile) into a single .js file that can be loaded by r2 as a plugin directly.

wargio commented 12 months ago

i haven't had chance yet to do anything, but i will

trufae commented 8 months ago

i think we can close this ticket now