Open eternaleclipse opened 2 years ago
Likely you are using an incompatible (newer?) Emscripten version.
Emscripten has changed a lot over the years which means quite some maintenance burden for me, so I'm not going to update the build scripts unless we have a significant reason to do so (PRs are welcome though!).
Try to use whichever Emcripten version was latest as of the date of the latest release: 2027-02-01
Using Python 3.8.10 and latest Emscripten (3.1.9).
Looks like there are no changes needed. the output JS is good, only usage is a bit different.
There were probably some changes to Emscripten usage for MODULARIZE=1
option - module usage is documented here.
cs.MCapstone.then(instance => {
MCapstone = instance;
// Continue normally from here
const capstone = new cs.Capstone(cs.ARCH_X86, cs.MODE_64);
const code = new Uint8Array([0x55, 0x31, 0xD2, 0x89, 0xE5, 0x8B, 0x45, 0x08]);
const instructions = capstone.disasm(code, 0);
console.log(instructions);
})
This works 🙂 I suggest updating the example in the Readme accordingly.
After manually building the library with Grunt and Emscripten, using both
capstone.min.js
andcapstone-x86.min.js
, without adding any extra JS code: