/
ffi-interface.lisp
36 lines (28 loc) · 1005 Bytes
/
ffi-interface.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(in-package #:capstone)
;;;; FFI Library
;; Much of what we do below requires it be loaded during macroexpansion time.
(eval-when (:compile-toplevel :load-toplevel :execute)
(define-foreign-library capstone-library
(:darwin "libcapstone.3.dylib")
(:unix "libcapstone.so")
(:windows "libcapstone.dll")
(t (:default "libcapstone")))
(use-foreign-library capstone-library))
(defcfun ("cs_open" .cs-open) cs-err
(arch cs-arch) (mode cs-mode) (handle (:pointer csh))
)
(defcfun ("cs_close" .cs-close) cs-err
(handle (:pointer csh)))
(defcfun ("cs_option" .cs-option) cs-err
(ud csh) (type cs-opt-type) (value size-t)
)
(defcfun ("cs_disasm" .cs-disasm) size-t
(ud csh) (buffer (:pointer uint8-t)) (size size-t)
(offset uint64-t) (count size-t) (insn (:pointer (:pointer (:struct cs-insn))))
)
(defcfun ("cs_free" .cs-free) :void
(insn (:pointer (:struct cs-insn)))
(count size-t))
(defcfun ("cs_reg_name" .cs-reg-name) :string
(csh csh)
(reg :unsigned-int))