justjake / quickjs-emscripten

Safely execute untrusted Javascript in your Javascript, and execute synchronous code that uses async functions
https://www.npmjs.com/package/quickjs-emscripten
Other
1.27k stars 95 forks source link

How to access wasm module's Memory? #146

Closed ppedziwiatr closed 8 months ago

ppedziwiatr commented 8 months ago

Hey,

is it possible to access the wasm module's memory (i.e. the https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Memory) via the instance of the QuickJS, runtime or maybe context?

I would simply like to:

  1. 'dump' and store the memory after evaluating the script
  2. read the stored memory into the WASM module at the next evaluation
justjake commented 8 months ago

I looked into this a bit but didn't see a great way to do it in the Emscripten APIs. Access would be from the QuickJSEmscriptenModule class.

justjake commented 8 months ago

Actually, it seems possible.

ppedziwiatr commented 8 months ago

wow, that was quick ;-) thank you!