CapstoneEngine

Main Capstone disassembly engine.

This is the primary interface for disassembling machine code. Use the build factory method to create instances with configuration.

The engine must be closed after use to release resources. Use the use extension function for automatic resource management:

CapstoneEngine.build(Architecture.ARM64, Mode.LITTLE_ENDIAN) {
detail = true
syntax = Syntax.DEFAULT
}.use { engine ->
val result = engine.disassemble(bytes, address = 0x1000)
result.onSuccess { instructions ->
instructions.forEach { println(it) }
}
}

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Target architecture being disassembled

Link copied to clipboard

Disassembly mode flags

Functions

Link copied to clipboard
open override fun close()

Close the engine and release resources.

Link copied to clipboard
fun disassemble(code: ByteArray, address: Long = 0, count: Int = 0): CapstoneResult<List<Instruction>>

Disassemble binary code.

Link copied to clipboard

Disassemble single instruction at current position.

Link copied to clipboard
fun groupName(groupId: Int): String?

Get the friendly name of an instruction group.

Link copied to clipboard
fun instructionName(insnId: Int): String?

Get the friendly name of an instruction.

Link copied to clipboard
fun iterate(code: ByteArray, address: Long = 0): DisassemblyIterator

Create an iterator for memory-efficient disassembly.

Link copied to clipboard

Get the last error code from the engine.

Link copied to clipboard
fun registerName(regId: Int): String?

Get the friendly name of a register.

Link copied to clipboard

Set a runtime option.