This is the capstone Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 03:47:04 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
capstone
Common Lisp CLOS interface to the Capstone disassembler
GrammaTech
MIT
gt
(system).
cffi
(system).
static-vectors
(system).
capstone/raw
(system).
capstone.lisp
(file).
capstone/raw
Raw Common Lisp FFI interface to the Capstone disassembler
GrammaTech
MIT
cffi-grovel
(system).
gt
(system).
cffi
(system).
static-vectors
(system).
package.lisp
(file).
grovel.lisp
(file).
raw.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
capstone/capstone.asd
capstone/capstone.lisp
capstone/raw/package.lisp
capstone/raw/grovel.lisp
capstone/raw/raw.lisp
capstone/capstone.lisp
capstone
(system).
address
(reader method).
architecture
(reader method).
bytes
(reader method).
bytes
(reader method).
capstone
(condition).
capstone-engine
(class).
capstone-instruction
(class).
capstone-instruction/arm
(class).
capstone-instruction/arm-a32
(class).
capstone-instruction/arm-t32
(class).
capstone-instruction/ppc
(class).
capstone-instruction/ppc-32
(class).
capstone-instruction/ppc-64
(class).
capstone-instruction/x86
(class).
capstone-instruction/x86-32
(class).
capstone-instruction/x86-64
(class).
disasm
(generic function).
disasm-iter
(macro).
disassembly
(condition).
id
(reader method).
initialize-instance
(method).
mnemonic
(reader method).
mode
(reader method).
op-str
(reader method).
operands
(generic function).
print-object
(method).
print-object
(method).
size
(reader method).
version
(function).
capstone-insn-to-string
(generic function).
capstone-instruction-class
(generic function).
capstone-instruction/arm-a64
(class).
code
(reader method).
make-instruction
(function).
opstring-to-tokens
(generic function).
parse-operand
(generic function).
parse-operands-list
(generic function).
strerr
(reader method).
capstone/raw/raw.lisp
capstone/raw
(system).
cs-close
(function).
cs-disasm
(function).
cs-disasm-iter
(function).
cs-errno
(function).
cs-free
(function).
cs-group-name
(function).
cs-insn-name
(function).
cs-malloc
(function).
cs-op-count
(function).
cs-op-index
(function).
cs-open
(function).
cs-reg-name
(function).
cs-reg-read
(function).
cs-strerror
(function).
cs-support
(function).
cs-version
(function).
cs-insn-group
(function).
cs-insn-tclass
(class).
cs-option
(function).
cs-reg-write
(function).
Packages are listed by definition order.
capstone
capstone/raw
.
cffi
.
cl-ppcre
.
gt
.
static-vectors
.
architecture
(generic reader).
capstone
(condition).
capstone-engine
(class).
capstone-instruction
(class).
capstone-instruction/arm
(class).
capstone-instruction/arm-a32
(class).
capstone-instruction/arm-t32
(class).
capstone-instruction/ppc
(class).
capstone-instruction/ppc-32
(class).
capstone-instruction/ppc-64
(class).
capstone-instruction/x86
(class).
capstone-instruction/x86-32
(class).
capstone-instruction/x86-64
(class).
disasm
(generic function).
disasm-iter
(macro).
disassembly
(condition).
mode
(generic reader).
operands
(generic function).
version
(function).
capstone-insn-to-string
(generic function).
capstone-instruction-class
(generic function).
capstone-instruction/arm-a64
(class).
code
(generic reader).
make-instruction
(function).
opstring-to-tokens
(generic function).
parse-operand
(generic function).
parse-operands-list
(generic function).
strerr
(generic reader).
capstone/raw
cffi
.
common-lisp
.
address
(slot).
address
(generic reader).
bytes
(slot).
bytes
(slot).
bytes
(generic reader).
cs-close
(function).
cs-disasm
(function).
cs-disasm-iter
(function).
cs-errno
(function).
cs-free
(function).
cs-group-name
(function).
cs-insn-name
(function).
cs-malloc
(function).
cs-op-count
(function).
cs-op-index
(function).
cs-open
(function).
cs-reg-name
(function).
cs-reg-read
(function).
cs-strerror
(function).
cs-support
(function).
cs-version
(function).
id
(slot).
id
(generic reader).
mnemonic
(slot).
mnemonic
(generic reader).
op-str
(slot).
op-str
(generic reader).
cs-insn-group
(function).
cs-insn-tclass
(class).
cs-option
(function).
cs-reg-write
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Use ENGINE to disassemble BYTES one instructions at a time.
Bind each instruction to VAR when executing BODY. Optional argument
ADDRESS may be used to set the starting ADDRESS during disassembly.
Close CS handle: MUST do to release the handle when it is not used anymore.
NOTE: this must be only called when there is no longer usage of Capstone,
not even access to cs_insn array. The reason is the this API releases some
cached memory, thus access to any Capstone API after cs_close() might crash
your application.
In fact,this API invalidate @handle by ZERO out its value (i.e *handle = 0).
@handle: pointer to a handle returned by cs_open()
@return CS_ERR_OK on success, or other value on failure (refer to cs_err enum for detailed error).
Disassemble binary code, given the code buffer, size, address
and number of instructions to be decoded.
This API dynamically allocate memory to contain disassembled
instruction. Resulting instructions will be put into @*insn
NOTE 1: this API will automatically determine memory needed to
contain output disassembled instructions in @insn.
NOTE 2: caller must free the allocated memory itself to avoid
memory leaking.
NOTE 3: for system with scarce memory to be dynamically
allocated such as OS kernel or firmware, the API
cs_disasm_iter() might be a better choice than cs_disasm(). The
reason is that with cs_disasm(), based on limited available
memory, we have to calculate in advance how many instructions
to be disassembled, which complicates things. This is
especially troublesome for the case @count=0, when cs_disasm()
runs uncontrollably (until either end of input buffer, or when
it encounters an invalid instruction).
@handle: handle returned by cs_open()
@code: buffer containing raw binary code to be disassembled.
@code_size: size of the above code buffer.
@address: address of the first instruction in given raw code
buffer.
@insn: array of instructions filled in by this API.
NOTE: @insn will be allocated by this function, and
should be freed with cs_free() API.
@count: number of instructions to be disassembled, or 0 to get
all of them
@return: the number of successfully disassembled instructions,
or 0 if this function failed to disassemble the given code
On failure, call cs_errno() for error code.
Fast API to disassemble binary code, given the code buffer, size, address
and number of instructions to be decoded.
This API puts the resulting instruction into a given cache in @insn.
See tests/test_iter.c for sample code demonstrating this API.
NOTE 1: this API will update @code, @size & @address to point to the next
instruction in the input buffer. Therefore, it is convenient to use
cs_disasm_iter() inside a loop to quickly iterate all the instructions.
While decoding one instruction at a time can also be achieved with
cs_disasm(count=1), some benchmarks shown that cs_disasm_iter() can be 30%
faster on random input.
NOTE 2: the cache in @insn can be created with cs_malloc() API.
NOTE 3: for system with scarce memory to be dynamically allocated such as
OS kernel or firmware, this API is recommended over cs_disasm(), which
allocates memory based on the number of instructions to be disassembled.
The reason is that with cs_disasm(), based on limited available memory,
we have to calculate in advance how many instructions to be disassembled,
which complicates things. This is especially troublesome for the case
@count=0, when cs_disasm() runs uncontrollably (until either end of input
buffer, or when it encounters an invalid instruction).
@handle: handle returned by cs_open()
@code: buffer containing raw binary code to be disassembled
@size: size of above code
@address: address of the first insn in given raw code buffer
@insn: pointer to instruction to be filled in by this API.
@return: true if this API successfully decode 1 instruction,
or false otherwise.
On failure, call cs_errno() for error code.
Report the last error number when some API function fail.
Like glibc’s errno, cs_errno might not retain its old value once accessed.
@handle: handle returned by cs_open()
@return: error code of cs_err enum type (CS_ERR_*, see above)
Free memory allocated by cs_malloc() or cs_disasm() (argument @insn)
@insn: pointer returned by @insn argument in cs_disasm() or cs_malloc() @count: number of cs_insn structures returned by cs_disasm(), or 1 to free memory allocated by cs_malloc().
Return friendly name of a group id (that an instruction can belong to)
Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
WARN: when in ’diet’ mode, this API is irrelevant because the engine does not
store group name.
@handle: handle returned by cs_open()
@group_id: group id
@return: string name of the group, or NULL if @group_id is invalid.
Return friendly name of an instruction in a string.
Find the instruction id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
WARN: when in ’diet’ mode, this API is irrelevant because the engine does not
store instruction name.
@handle: handle returned by cs_open()
@insn_id: instruction id
@return: string name of the instruction, or NULL if @insn_id is invalid.
Allocate memory for 1 instruction to be used by cs_disasm_iter().
@handle: handle returned by cs_open()
NOTE: when no longer in use, you can reclaim the memory allocated for this instruction with cs_free(insn, 1)
Count the number of operands of a given type.
Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
NOTE: this API is only valid when detail option is ON (which is OFF by default)
@handle: handle returned by cs_open()
@insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
@op_type: Operand type to be found.
@return: number of operands of given type @op_type in instruction @insn,
or -1 on failure.
Retrieve the position of operand of given type in <arch>.operands[] array.
Later, the operand can be accessed using the returned position.
Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
NOTE: this API is only valid when detail option is ON (which is OFF by default)
@handle: handle returned by cs_open()
@insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
@op_type: Operand type to be found.
@position: position of the operand to be found. This must be in the range
[1, cs_op_count(handle, insn, op_type)]
@return: index of operand of given type @op_type in <arch>.operands[] array
in instruction @insn, or -1 on failure.
Initialize CS handle: this must be done before any usage of CS.
@arch: architecture type (CS_ARCH_*)
@mode: hardware mode. This is combined of CS_MODE_*
@handle: pointer to handle, which will be updated at return time
@return CS_ERR_OK on success, or other value on failure (refer to cs_err enum for detailed error).
Return friendly name of register in a string.
Find the instruction id from header file of corresponding architecture (arm.h for ARM,
x86.h for X86, ...)
WARN: when in ’diet’ mode, this API is irrelevant because engine does not
store register name.
@handle: handle returned by cs_open()
@reg_id: register id
@return: string name of the register, or NULL if @reg_id is invalid.
Check if a disassembled instruction IMPLICITLY used a particular register.
Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
Internally, this simply verifies if @reg_id matches any member of insn->regs_read array.
NOTE: this API is only valid when detail option is ON (which is OFF by default)
WARN: when in ’diet’ mode, this API is irrelevant because the engine does not
update @regs_read array.
@insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
@reg_id: register that you want to check if this instruction used it.
@return: true if this instruction indeed implicitly used the given register, or false otherwise.
Return a string describing given error code.
@code: error code (see CS_ERR_* above)
@return: returns a pointer to a string that describes the error code passed in the argument @code
This API can be used to either ask for archs supported by this library,
or check to see if the library was compile with ’diet’ option (or called
in ’diet’ mode).
To check if a particular arch is supported by this library, set @query to
arch mode (CS_ARCH_* value).
To verify if this library supports all the archs, use CS_ARCH_ALL.
To check if this library is in ’diet’ mode, set @query to CS_SUPPORT_DIET.
@return True if this library supports the given arch, or in ’diet’ mode.
Return combined API version & major and minor version numbers.
@major: major number of API version
@minor: minor number of API version
@return hexical number as (major << 8 | minor), which encodes both
major & minor versions.
NOTE: This returned value can be compared with version number made
with macro CS_MAKE_VERSION
For example, second API version would return 1 in @major, and 1 in @minor
The return value would be 0x0101
NOTE: if you only care about returned value, but not major and minor values, set both @major & @minor arguments to NULL.
Return the CAPSTONE version as two values MAJOR and MINOR.
capstone-instruction
)) ¶automatically generated reader method
capstone-engine
)) ¶automatically generated reader method
capstone-instruction
)) ¶automatically generated reader method
disassembly
)) ¶Disassemble BYTES with ENGINE using starting address ADDRESS. Optional argument COUNT may be supplied to limit the number of instructions disassembled.
capstone-engine
) (bytes vector
) &key address count) ¶capstone-instruction
)) ¶automatically generated reader method
id
.
capstone-instruction
)) ¶automatically generated reader method
capstone-engine
)) ¶automatically generated reader method
mode
.
capstone-instruction
)) ¶automatically generated reader method
Method for extracting the operands information from a CAPSTONE-INSTRUCTION. May vary with architecture.
capstone-instruction
)) ¶capstone-engine
) &key) ¶capstone-instruction
) stream) ¶capstone-engine
) stream) ¶capstone-instruction
)) ¶automatically generated reader method
fset
.
size
.
Capstone error.
error
.
Capstone disassembly error.
(quote nil)
:bytes
This slot is read-only.
keyword
(alexandria:required-argument :architecture)
:architecture
This slot is read-only.
(or keyword list)
(alexandria:required-argument :mode)
:mode
mode
.
This slot is read-only.
capstone::unsigned-integer
:address
This slot is read-only.
(quote (simple-array (unsigned-byte 8)))
:bytes
This slot is read-only.
string
:op-str
This slot is read-only.
:keyword
:mnemonic
This slot is read-only.
Check if a disassembled instruction belong to a particular group.
Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
Internally, this simply verifies if @group_id matches any member of insn->groups array.
NOTE: this API is only valid when detail option is ON (which is OFF by default).
WARN: when in ’diet’ mode, this API is irrelevant because the engine does not
update @groups array.
@handle: handle returned by cs_open()
@insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
@group_id: group that you want to check if this instruction belong to.
@return: true if this instruction indeed belongs to the given group, or false otherwise.
Set option for disassembling engine at runtime
@handle: handle returned by cs_open()
@type: type of option to be set
@value: option value corresponding with @type
@return: CS_ERR_OK on success, or other value on failure.
Refer to cs_err enum for detailed error.
NOTE: in the case of CS_OPT_MEM, handle’s value can be anything, so that cs_option(handle, CS_OPT_MEM, value) can (i.e must) be called even before cs_open()
Check if a disassembled instruction IMPLICITLY modified a particular register.
Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...)
Internally, this simply verifies if @reg_id matches any member of insn->regs_write array.
NOTE: this API is only valid when detail option is ON (which is OFF by default)
WARN: when in ’diet’ mode, this API is irrelevant because the engine does not
update @regs_write array.
@insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter()
@reg_id: register that you want to check if this instruction modified it.
@return: true if this instruction indeed implicitly modified the given register, or false otherwise.
Create an object of class INSN-CLASS for the instruction INSN
Convert a capstone instruction object to a string that is suitable for use by keystone.
capstone-instruction
)) ¶The name of the subclass of CAPSTONE-INSTRUCTION for the particular architecture, or CAPSTONE-INSTRUCTION if there is such proper subclass.
capstone-engine
)) ¶Method for parsing operand string to list of tokens, with distinct methods per architecture.
capstone-instruction/x86
) string) ¶capstone-instruction/arm
) string) ¶Method to convert single token from string format to token, specialized for the architecture. This may include, for example, converting numeric values in various bases, recognizing known register names, etc.
capstone-instruction/arm
) tok) ¶capstone-instruction/x86
) tok) ¶Method for parsing operand list, with distinct methods per architecture.
capstone-instruction/arm
) oplist) ¶capstone-instruction/x86
) oplist) ¶capstone-instruction
) oplist) ¶Jump to: | A B C D F G I M O P S V |
---|
Jump to: | A B C D F G I M O P S V |
---|
Jump to: | A B C H I M O S |
---|
Jump to: | A B C H I M O S |
---|
Jump to: | C D F G P R S |
---|
Jump to: | C D F G P R S |
---|