Skip to content

Instantly share code, notes, and snippets.

@Altanis
Created July 15, 2022 14:10
Show Gist options
  • Save Altanis/ba79da9f330192d562931e8d9f51edc2 to your computer and use it in GitHub Desktop.
Save Altanis/ba79da9f330192d562931e8d9f51edc2 to your computer and use it in GitHub Desktop.
Memory hook for Diep.io
WebAssembly.instantiateStreaming = (r, i) => r.arrayBuffer().then(b => WebAssembly.instantiate(b, i));
const _initWasm = WebAssembly.instantiate;
WebAssembly.instantiate = (wasm, imports) => {
const loader = {raw: new Uint8Array(new Uint8Array(wasm)), buffer: new Uint8Array(wasm), imports};
_initWasm(loader.buffer, loader.imports).then(results => {
console.log(results);
const memory = Object.values(results.instance.exports).find(e => e instanceof WebAssembly.Memory);
window.HEAPF32 = new Float32Array(memory.buffer);
});
return _initWasm(wasm, imports);
};
// Made by ABCxFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment