Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- uint8_t buff[10][100];
- uint64_t addr(int buffer_index){
- return (uint64_t)&buff[buffer_index];
- }
- emcc project.c -Os -s WASM=1 -s SIDE_MODULE=1 -o project.wasm
- <script>
- var importObject = {
- env: {
- memoryBase: 0,
- tableBase: 0,
- setTempRet0:(x)=>{},
- memory: new WebAssembly.Memory({ initial:256 }),
- table: new WebAssembly.Table({ initial:0, element:'anyfunc' })
- }
- };
- fetch('http://localhost:9000/assets/wasm/project.wasm').then(
- response => response.arrayBuffer()
- ).then(
- bytes => WebAssembly.instantiate(bytes, importObject)
- ).then(
- results => {
- let module=results.instance
- let exports=module.exports
- let addr=exports._addr
- console.log(addr(0))
- console.log(addr(1))
- console.log(addr(2))
- }
- )
- </script>
- project.html:21 5242880
- project.html:22 5242980
- project.html:23 5243080
Add Comment
Please, Sign In to add comment