sbcl.sbcl/contrib/sb-capstone
Douglas Katzman e47ab64eb9 Cease using ASDF to build contribs
Our contrib build graph was already expressed in contrib/Makefile,
so ASDF wasn't doing anything to determine an execution schedule.
The new make-contrib.lisp script can parse '.asd' files more-or-less as-is,
removing ASDF from the critical path. With blocklist=sb-simd, this change
decreased the time in parallelized make-target-contrib to under 5 seconds
for me (down from >10) when run on as many cores as there are contrib dirs.
All defsystems are treated as if containing ":serial t", and there are
two invented keywords to bind/assign special variables around compilation.

We still install '.asd' files in $SBCL_HOME/contrib, and build uiop and asdf
so there should be no observable difference to users.
2022-09-30 11:54:53 -04:00
..
capstone.lisp Fix sb-capstone for 32-bit platforms. 2022-03-01 01:34:59 +03:00
Makefile Add contrib module for calling Capstone disassembler 2018-06-12 18:16:46 -04:00
README.md Fix typo. 2020-05-06 02:28:14 +03:00
sb-capstone.asd Cease using ASDF to build contribs 2022-09-30 11:54:53 -04:00
tests.lisp Disable sb-capstone tests 2022-08-17 16:16:12 -04:00

SB-CAPSTONE

Capstone integration for SBCL

Capstone [1] is a lightweight multi-platform, multi-architecture disassembly framework. Capstone is based off the LLVM project, and can target a variety of architectures, including but not limiting to PowerPC, x86 and ARM. Capstone is implemented in C [2], and has several bindings into other languages. A binding into Common Lisp was not previously available.

Binding

We exported constants and routines from Capstone main header file [3] using the sb-alien SBCL package.

Requirements

SB-CAPSTONE requires having the Capstone library installed, as a shared object. See the Capstone file COMPLILE.TXT for instructions, and then install file "libcapstone.so" where the load-shared-object function can find it. You can set up the LD_LIBRARY_PATH environment variable if necessary.

Examples

An example on using the bindings can be found on the tests. We rely on sb-alien heavily for passing system addresses to Capstone (where pointers were used in the C analog)

Example: using Capstone's cs_open to create a handle

(require :sb-capstone)

(defun get-handle ()
  (multiple-value-bind (return-code handle) (sb-capstone:cs-open-for-target '(:x86-64 :little-endian))
    handle))

[1] http://www.capstone-engine.org [2] https://github.com/aquynh/capstone [3] https://github.com/aquynh/capstone/blob/master/include/capstone.h