@cheatron/keystone
v1.0.1
Published
TypeScript/FFI bindings for the Keystone assembler engine with full OOP support
Downloads
225
Maintainers
Readme
@cheatron/keystone
TypeScript/FFI bindings for the Keystone assembler engine with full OOP support.
Features
- Full Keystone API —
ks_open,ks_asm,ks_close,ks_optionand more - OOP Wrapper —
Keystonebase class andKeystoneX86for x86/x64 - Type-safe Enums — Auto-generated from
keystone.h(ks_arch,ks_mode,ks_err,ks_opt_type, etc.) - Auto Cleanup —
FinalizationRegistry+ explicitclose()for deterministic resource management - Dynamic DLL Resolution —
keystone.dllbundled indeps/, resolved viaimport.meta.url
Install
bun add @cheatron/keystoneUsage
import { KeystoneX86 } from '@cheatron/keystone';
const ks = new KeystoneX86(); // defaults to 64-bit mode
const bytes = ks.asm('MOV RAX, RBX');
console.log(bytes); // [0x48, 0x89, 0xD8]
// Multi-line assembly
const prologue = ks.asm('push rbp; mov rbp, rsp; sub rsp, 0x20');
console.log(prologue);
// With base address
const code = ks.asm('jmp 0x1000', 0xff0n);
ks.close();License
MIT
