Port of the Keystone assembler framework for JavaScript. Powered by Emscripten.
Notes: Keystone is a lightweight multi-architecture assembler framework originally developed by Nguyen Anh Quynh et al. and released under a dual license GPLv2 and the possibility of its commercial usage. More information about contributors and license terms can be found in the files AUTHORS.TXT
, CREDITS.TXT
and the files mentioned by the License section in README.md
inside the keystone submodule in this repository.
To add Keystone.js to your web application, include it with:
<script src="keystone.min.js"></script>
or install it with the Bower command:
bower install keystonejs
// Input: Assembly
var assembly = `
inc rax;
call 0x10040;
mov rax, qword ptr[rdx + 4];
sub esp, 0x100;
pop rbx;
`;
// Initialize the encoder
var a = new ks.Keystone(ks.ARCH_X86, ks.MODE_64);
// Choose preferred syntax
a.option(ks.OPT_SYNTAX, ks.OPT_SYNTAX_INTEL);
// Assemble instructions
var result = a.asm(assembly);
/* result.failed = false; */
/* result.count = 5; */
/* result.mc = new Uint8Array([0x48, 0xFF, 0xC0, 0xE8, ...]); */
// Close encoder
a.close();
To build the Keystone.js library, clone the master branch of this repository, and do the following:
-
Initialize the original Keystone submodule:
git submodule update --init
. -
Install the latest Python 2.x (64-bit), CMake and the Emscripten SDK. Follow the respective instructions and make sure all environment variables are configured correctly. Under Windows MinGW (specifically mingw32-make) is required.
-
Install the development dependencies with:
npm install
. -
Finally, build the source with:
grunt build
.