Search code examples
v8shared-objectsfrida

Load *.dylib or *.so into the V8 Javascript runtime?


While not specifically related to Frida's use of V8, I was reading this Frida release page and noticed it made the following reference:

Short of writing the whole agent in C, one could go ahead and build a native library, and load it using Module.load(). This works but means it has to be compiled for every single architecture, deployed to the target, etc.

The comment by Ole alludes to this being possible, though I can't find any references other than the NodeJS C++ Addons features that are, of course, specific to NodeJS (though NodeJS does use V8).


tl;dr How does one load a generic object such that all of its exported functions are callable from Javascript? Is this possible?


Solution

  • I was misinterpreting the context of the comment in the original link, it seems. I was under the impression that Module.load was a v8-ism, while it in fact appears to be a Frida-API.

    https://frida.re/docs/javascript-api/#module

    I figured this out about the time I was writing code to use Module.getExportByName to just pass the addresses of dlopen and dlsym to the entry of my CModule code.