go/

directory
v0.0.0-...-fb8211e Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: GPL-2.0

README

keystone

Go bindings for the keystone engine.

Sample

package main

import (
	"fmt"
	"os"

	"github.com/keystone-engine/keystone/bindings/go/keystone"
)

func main() {
	assembly := os.Args[1]

	ks, err := keystone.New(keystone.ARCH_X86, keystone.MODE_32)
	if err != nil {
		panic(err)
	}
	defer ks.Close()

	if err := ks.Option(keystone.OPT_SYNTAX, keystone.OPT_SYNTAX_INTEL); err != nil {
		panic(fmt.Errorf("Could not set syntax option to intel"))
	}

	if insn, _, ok := ks.Assemble(assembly, 0); !ok {
		panic(fmt.Errorf("Could not assemble instruction"))
	} else {
		fmt.Printf("%s: [%x]", assembly, insn)
	}
}

Testing

go test

Contributors

  • Remco Verhoef (@remco_verhoef)

Directories

Path Synopsis
+build darwin,linux,cgo
+build darwin,linux,cgo

Jump to

Keyboard shortcuts

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