https://github.com/for-acgn/go-keystone
WASM based bindings for the Keystone assembler
https://github.com/for-acgn/go-keystone
assembler keystone
Last synced: about 1 month ago
JSON representation
WASM based bindings for the Keystone assembler
- Host: GitHub
- URL: https://github.com/for-acgn/go-keystone
- Owner: For-ACGN
- License: gpl-3.0
- Created: 2024-11-03T04:54:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-09T12:28:18.000Z (3 months ago)
- Last Synced: 2026-03-09T17:17:33.187Z (3 months ago)
- Topics: assembler, keystone
- Language: Go
- Homepage:
- Size: 2.16 MB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-keystone
WASM based bindings for the [Keystone](https://github.com/For-ACGN/keystone) assembler.
## Features
Since Keystone is compiled into a wasm module and a pure go-implemented wasm runtime [wazero](https://github.com/tetratelabs/wazero) is used, calling the C program is implemented while retaining cross-compilation.
## Usage
```bash
keystone -arch x86 -mode 32 -src hello.asm -out hello.bin
```
## Development
```go
package main
import (
"fmt"
"os"
"github.com/For-ACGN/go-keystone"
)
func main() {
engine, err := keystone.NewEngine(keystone.ARCH_X86, keystone.MODE_64)
checkError(err)
defer func() { _ = engine.Close() }()
err = engine.Option(keystone.OPT_SYNTAX, keystone.OPT_SYNTAX_INTEL)
checkError(err)
src := ".code64\n"
src += "xor rax, rax\n"
src += "ret\n"
inst, err := engine.Assemble(src, 0)
checkError(err)
// [0x48, 0x31, 0xC0, 0xC3]
fmt.Println(inst)
}
func checkError(err error) {
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
```