capstr

package module
v0.0.0-...-1b6ae95 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2018 License: MIT Imports: 3 Imported by: 2

README

capstr

Capstone Go bindings facilitating highly optimized printing of disassembly.

Usage

import "github.com/lunixbochs/capstr"

engine, err := capstr.New(capstr.ARCH_X86, capstr.MODE_32)
insns, err := engine.Dis(code, addr, insCount)
for _, ins := range insns {
    fmt.Printf("%#x: %s %s\n", ins.Addr(), ins.Mnemonic(), ins.OpStr())
}

Benchmarks

BenchmarkX86-4            200000          5532 ns/op        1032 B/op         22 allocs/op
BenchmarkGapstone-4       200000          9900 ns/op        9704 B/op         54 allocs/op

Documentation

Index

Constants

View Source
const (
	ARCH_ARM   = C.CS_ARCH_ARM
	ARCH_ARM64 = C.CS_ARCH_ARM64
	ARCH_MIPS  = C.CS_ARCH_MIPS
	ARCH_X86   = C.CS_ARCH_X86
	ARCH_PPC   = C.CS_ARCH_PPC
	ARCH_SPARC = C.CS_ARCH_SPARC
	ARCH_SYSZ  = C.CS_ARCH_SYSZ
	ARCH_XCORE = C.CS_ARCH_XCORE
)
View Source
const (
	MODE_LITTLE_ENDIAN = C.CS_MODE_LITTLE_ENDIAN
	MODE_ARM           = C.CS_MODE_ARM
	MODE_16            = C.CS_MODE_16
	MODE_32            = C.CS_MODE_32
	MODE_64            = C.CS_MODE_64
	MODE_THUMB         = C.CS_MODE_THUMB
	MODE_MCLASS        = C.CS_MODE_MCLASS
	MODE_V8            = C.CS_MODE_V8
	MODE_MICRO         = C.CS_MODE_MICRO
	MODE_MIPS3         = C.CS_MODE_MIPS3
	MODE_MIPS32R6      = C.CS_MODE_MIPS32R6
	MODE_V9            = C.CS_MODE_V9
	MODE_BIG_ENDIAN    = C.CS_MODE_BIG_ENDIAN
	MODE_MIPS32        = C.CS_MODE_MIPS32
	MODE_MIPS64        = C.CS_MODE_MIPS64
)
View Source
const (
	OPT_TYPE_INVALID        = C.CS_OPT_INVALID
	OPT_TYPE_SYNTAX         = C.CS_OPT_SYNTAX
	OPT_TYPE_DETAIL         = C.CS_OPT_DETAIL
	OPT_TYPE_MODE           = C.CS_OPT_MODE
	OPT_TYPE_MEM            = C.CS_OPT_MEM
	OPT_TYPE_SKIPDATA       = C.CS_OPT_SKIPDATA
	OPT_TYPE_SKIPDATA_SETUP = C.CS_OPT_SKIPDATA_SETUP
)
View Source
const (
	OPT_OFF              = C.CS_OPT_OFF
	OPT_ON               = C.CS_OPT_ON
	OPT_SYNTAX_DEFAULT   = C.CS_OPT_SYNTAX_DEFAULT
	OPT_SYNTAX_INTEL     = C.CS_OPT_SYNTAX_INTEL
	OPT_SYNTAX_ATT       = C.CS_OPT_SYNTAX_ATT
	OPT_SYNTAX_NOREGNAME = C.CS_OPT_SYNTAX_NOREGNAME
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CsError

type CsError C.cs_err

func (CsError) Error

func (e CsError) Error() string

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New(arch, mode int) (*Engine, error)

func (*Engine) Close

func (e *Engine) Close() error

func (*Engine) Dis

func (e *Engine) Dis(code []byte, addr, count uint64) ([]Ins, error)

func (*Engine) Option

func (e *Engine) Option(opt_type C.cs_opt_type, value C.size_t) error

type Ins

type Ins struct {
	// contains filtered or unexported fields
}

conforms to usercorn/models.Ins interface

func (Ins) Addr

func (i Ins) Addr() uint64

func (Ins) Bytes

func (i Ins) Bytes() []byte

func (Ins) Mnemonic

func (i Ins) Mnemonic() string

func (Ins) OpStr

func (i Ins) OpStr() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL