Skip to content

Cheatron/cheatron-capstone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@cheatron/capstone

TypeScript/FFI bindings for the Capstone disassembly engine with full OOP support.

Features

  • Full Capstone APIcs_open, cs_disasm, cs_close, cs_option and more
  • OOP WrapperCapstone base class and CapstoneX86 for x86/x64
  • Type-safe Enums — Auto-generated from capstone.h (cs_arch, cs_mode, cs_err, x86_insn, x86_reg, etc.)
  • Instruction Class — Rich Instruction with helpers: isCall, isJump, isRet, isNop, isMov, isBranch and more
  • Auto CleanupFinalizationRegistry + explicit close() for deterministic resource management
  • Dynamic DLL Resolutioncapstone.dll bundled in deps/, resolved via import.meta.url

Install

bun add @cheatron/capstone

Usage

import { CapstoneX86, x86_insn } from '@cheatron/capstone';

const cs = new CapstoneX86(true); // true = 64-bit mode

const code = Buffer.from([0x55, 0x48, 0x89, 0xe5, 0x90, 0xc3]);
const insns = cs.disasm(code, 0x1000n);

for (const insn of insns) {
  console.log(`${insn.address.toString(16)}: ${insn}`);
  // 1000: push rbp
  // 1001: mov rbp, rsp
  // 1004: nop
  // 1005: ret

  if (insn.isRet) console.log('Found return!');
  if (insn.id === x86_insn.NOP) console.log('NOP sled');
}

cs.close();

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors