Rizin
unix-like reverse engineering framework and cli tools
|
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <capstone/capstone.h>
#include "utils.h"
#include "MCRegisterInfo.h"
#include "arch/AArch64/AArch64Module.h"
#include "arch/ARM/ARMModule.h"
#include "arch/EVM/EVMModule.h"
#include "arch/M680X/M680XModule.h"
#include "arch/M68K/M68KModule.h"
#include "arch/Mips/MipsModule.h"
#include "arch/PowerPC/PPCModule.h"
#include "arch/Sparc/SparcModule.h"
#include "arch/SystemZ/SystemZModule.h"
#include "arch/TMS320C64x/TMS320C64xModule.h"
#include "arch/X86/X86Module.h"
#include "arch/XCore/XCoreModule.h"
Go to the source code of this file.
Macros | |
#define | INSN_CACHE_SIZE 32 |
#define | SKIPDATA_MNEM ".byte" |
Variables | |
static cs_err(* | cs_arch_init [MAX_ARCH])(cs_struct *) |
static cs_err(* | cs_arch_option [MAX_ARCH])(cs_struct *, cs_opt_type, size_t value) |
static cs_mode | cs_arch_disallowed_mode_mask [MAX_ARCH] |
static uint32_t | all_arch = 0 |
cs_malloc_t | cs_mem_malloc = NULL |
cs_calloc_t | cs_mem_calloc = NULL |
cs_realloc_t | cs_mem_realloc = NULL |
cs_free_t | cs_mem_free = NULL |
cs_vsnprintf_t | cs_vsnprintf = NULL |
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_close | ( | csh * | handle | ) |
Definition at line 501 of file cs.c.
References capstone::CS_ERR_CSH, capstone::CS_ERR_OK, cs_mem_free, handle, cs_struct::insn_cache, memset(), cs_struct::mnem_list, insn_mnem::next, cs_struct::printer_info, and autogen_x86imm::tmp.
Referenced by analop(), analysis_op(), arm_fini(), bs_close(), cs_driver_hello(), disassemble(), fini(), LLVMFuzzerTestOneInput(), main(), ocaml_close(), test(), test_invalids(), test_valids(), the_end(), tms320_fini(), and x86_fini().
CAPSTONE_EXPORT size_t CAPSTONE_API cs_disasm | ( | csh | ud, |
const uint8_t * | buffer, | ||
size_t | size, | ||
uint64_t | offset, | ||
size_t | count, | ||
cs_insn ** | insn | ||
) |
Definition at line 798 of file cs.c.
References MCInst::address, SStream::buffer, c, count, CS_ARCH_ARM, CS_ARCH_X86, capstone::CS_ERR_MEM, capstone::CS_ERR_OK, cs_mem_calloc, cs_mem_free, cs_mem_realloc, MCInst::csh, f, fill_insn(), MCInst::flat_insn, handle, i, cs_struct::insn_cache, INSN_CACHE_SIZE, int, MCInst_Init(), memcpy(), memset(), NULL, MCInst::Opcode, MCInst::popcode_adjust, r, skipdata_opstr(), SStream_Init(), and autogen_x86imm::tmp.
Referenced by _cs_disasm(), analop(), analysis_op(), bs_disasm(), cs_disasm_ex(), cs_driver_hello(), disassemble(), LLVMFuzzerTestOneInput(), main(), print_insn(), test(), test_invalids(), and test_valids().
CAPSTONE_EXPORT CAPSTONE_DEPRECATED size_t CAPSTONE_API cs_disasm_ex | ( | csh | ud, |
const uint8_t * | buffer, | ||
size_t | size, | ||
uint64_t | offset, | ||
size_t | count, | ||
cs_insn ** | insn | ||
) |
CAPSTONE_EXPORT bool CAPSTONE_API cs_disasm_iter | ( | csh | ud, |
const uint8_t ** | code, | ||
size_t * | size, | ||
uint64_t * | address, | ||
cs_insn * | insn | ||
) |
Definition at line 1058 of file cs.c.
References MCInst::address, SStream::buffer, CS_ARCH_X86, capstone::CS_ERR_OK, MCInst::csh, fill_insn(), MCInst::flat_insn, handle, MCInst_Init(), memcpy(), MCInst::Opcode, MCInst::popcode_adjust, r, skipdata_opstr(), and SStream_Init().
Referenced by bs_disasm_iter(), LLVMFuzzerTestOneInput(), and test().
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_errno | ( | csh | handle | ) |
Definition at line 402 of file cs.c.
References capstone::CS_ERR_CSH, cs_struct::errnum, and handle.
Referenced by bs_errno().
CAPSTONE_EXPORT void CAPSTONE_API cs_free | ( | cs_insn * | insn, |
size_t | count | ||
) |
Definition at line 1017 of file cs.c.
References count, cs_mem_free, and i.
Referenced by _cs_disasm(), analop(), analysis_op(), bs_free(), cs_driver_hello(), disassemble(), LLVMFuzzerTestOneInput(), main(), print_insn(), test(), test_invalids(), and test_valids().
CAPSTONE_EXPORT const char* CAPSTONE_API cs_group_name | ( | csh | ud, |
unsigned int | group | ||
) |
Definition at line 1178 of file cs.c.
Referenced by bcs_group_name(), check_features(), LLVMFuzzerTestOneInput(), main(), ocaml_group_name(), print_details(), print_insn_detail(), and test().
CAPSTONE_EXPORT bool CAPSTONE_API cs_insn_group | ( | csh | ud, |
const cs_insn * | insn, | ||
unsigned int | group_id | ||
) |
Definition at line 1190 of file cs.c.
References arr_exist8(), capstone::CS_ERR_DETAIL, capstone::CS_ERR_SKIPDATA, and handle.
Referenced by analop(), anop(), anop32(), anop64(), and bs_insn_group().
CAPSTONE_EXPORT const char* CAPSTONE_API cs_insn_name | ( | csh | ud, |
unsigned int | insn | ||
) |
Definition at line 1166 of file cs.c.
Referenced by bs_insn_name(), disassemble(), LLVMFuzzerTestOneInput(), main(), mnemonics(), ocaml_instruction_name(), print_details(), and test().
CAPSTONE_EXPORT cs_insn* CAPSTONE_API cs_malloc | ( | csh | ud | ) |
Definition at line 1030 of file cs.c.
References capstone::CS_ERR_MEM, cs_mem_free, cs_mem_malloc, handle, and NULL.
Referenced by bs_malloc(), LLVMFuzzerTestOneInput(), and test().
CAPSTONE_EXPORT int CAPSTONE_API cs_op_count | ( | csh | ud, |
const cs_insn * | insn, | ||
unsigned int | op_type | ||
) |
Definition at line 1271 of file cs.c.
References count, CS_ARCH_ARM, CS_ARCH_ARM64, CS_ARCH_EVM, CS_ARCH_M680X, CS_ARCH_M68K, CS_ARCH_MIPS, CS_ARCH_PPC, CS_ARCH_SPARC, CS_ARCH_SYSZ, CS_ARCH_TMS320C64X, CS_ARCH_X86, CS_ARCH_XCORE, capstone::CS_ERR_DETAIL, capstone::CS_ERR_HANDLE, capstone::CS_ERR_OK, capstone::CS_ERR_SKIPDATA, handle, and i.
Referenced by bs_op_count(), print_insn_detail(), and print_insn_detail_x86().
CAPSTONE_EXPORT int CAPSTONE_API cs_op_index | ( | csh | ud, |
const cs_insn * | insn, | ||
unsigned int | op_type, | ||
unsigned int | post | ||
) |
Definition at line 1369 of file cs.c.
References count, CS_ARCH_ARM, CS_ARCH_ARM64, CS_ARCH_EVM, CS_ARCH_M680X, CS_ARCH_M68K, CS_ARCH_MIPS, CS_ARCH_PPC, CS_ARCH_SPARC, CS_ARCH_SYSZ, CS_ARCH_TMS320C64X, CS_ARCH_X86, CS_ARCH_XCORE, capstone::CS_ERR_DETAIL, capstone::CS_ERR_HANDLE, capstone::CS_ERR_OK, capstone::CS_ERR_SKIPDATA, handle, i, and post().
Referenced by bs_op_index(), print_insn_detail(), and print_insn_detail_x86().
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_open | ( | cs_arch | arch, |
cs_mode | mode, | ||
csh * | handle | ||
) |
Definition at line 453 of file cs.c.
References cs_struct::arch, arch, cs_arch_disallowed_mode_mask, cs_arch_init, CS_ARCH_MAX, capstone::CS_ERR_ARCH, capstone::CS_ERR_MEM, capstone::CS_ERR_MEMSETUP, capstone::CS_ERR_MODE, capstone::CS_ERR_OK, cs_mem_calloc, cs_mem_free, cs_mem_malloc, cs_mem_realloc, CS_OPT_OFF, cs_vsnprintf, cs_struct::detail, err, cs_struct::errnum, handle, cs_struct::mode, SKIPDATA_MNEM, and cs_struct::skipdata_setup.
Referenced by analop(), analysis_op(), bs_open(), cs_driver_hello(), disassemble(), LLVMFuzzerTestOneInput(), main(), ocaml_cs_disasm(), ocaml_open(), test(), test_invalids(), and test_valids().
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_option | ( | csh | ud, |
cs_opt_type | type, | ||
size_t | value | ||
) |
Definition at line 646 of file cs.c.
References cs_arch_disallowed_mode_mask, cs_arch_option, capstone::CS_ERR_CSH, capstone::CS_ERR_OK, capstone::CS_ERR_OPTION, cs_mem_calloc, cs_mem_free, cs_mem_malloc, cs_mem_realloc, CS_OPT_DETAIL, CS_OPT_MEM, CS_OPT_MNEMONIC, CS_OPT_MODE, CS_OPT_ON, CS_OPT_SKIPDATA, CS_OPT_SKIPDATA_SETUP, CS_OPT_UNSIGNED, cs_vsnprintf, handle, cs_opt_mnem::id, mem, cs_opt_mnem::mnemonic, insn_mnem::next, skipdata_size(), autogen_x86imm::tmp, type, and value.
Referenced by analop(), analysis_op(), bs_option(), disassemble(), LLVMFuzzerTestOneInput(), main(), ocaml_option(), test(), test_invalids(), and test_valids().
CAPSTONE_EXPORT const char* CAPSTONE_API cs_reg_name | ( | csh | ud, |
unsigned int | reg | ||
) |
Definition at line 1154 of file cs.c.
References handle, NULL, and reg.
Referenced by anop(), anop32(), anop64(), anop_esil(), arg(), bs_reg_name(), cs_reg2reg(), getarg(), getarg2(), LLVMFuzzerTestOneInput(), main(), ocaml_register_name(), opex(), opex64(), parse_reg64_name(), parse_reg_name(), print_insn_detail(), print_insn_detail_arm(), print_insn_detail_arm64(), print_insn_detail_m680x(), print_insn_detail_m68k(), print_insn_detail_mips(), print_insn_detail_ppc(), print_insn_detail_sparc(), print_insn_detail_sysz(), print_insn_detail_tms320c64x(), print_insn_detail_x86(), print_insn_detail_xcore(), print_read_write_regs(), snprint_insn_detail(), and test().
CAPSTONE_EXPORT bool CAPSTONE_API cs_reg_read | ( | csh | ud, |
const cs_insn * | insn, | ||
unsigned int | reg_id | ||
) |
Definition at line 1217 of file cs.c.
References arr_exist(), capstone::CS_ERR_DETAIL, capstone::CS_ERR_SKIPDATA, and handle.
Referenced by bs_reg_read().
CAPSTONE_EXPORT bool CAPSTONE_API cs_reg_write | ( | csh | ud, |
const cs_insn * | insn, | ||
unsigned int | reg_id | ||
) |
Definition at line 1244 of file cs.c.
References arr_exist(), capstone::CS_ERR_DETAIL, capstone::CS_ERR_SKIPDATA, and handle.
Referenced by bs_reg_write().
CAPSTONE_EXPORT cs_err CAPSTONE_API cs_regs_access | ( | csh | ud, |
const cs_insn * | insn, | ||
cs_regs | regs_read, | ||
uint8_t * | regs_read_count, | ||
cs_regs | regs_write, | ||
uint8_t * | regs_write_count | ||
) |
Definition at line 1504 of file cs.c.
References capstone::CS_ERR_ARCH, capstone::CS_ERR_DETAIL, capstone::CS_ERR_DIET, capstone::CS_ERR_OK, capstone::CS_ERR_SKIPDATA, and handle.
Referenced by print_insn_detail(), print_insn_detail_arm(), print_insn_detail_arm64(), print_insn_detail_x86(), and set_access_info().
CAPSTONE_EXPORT const char* CAPSTONE_API cs_strerror | ( | cs_err | code | ) |
Definition at line 414 of file cs.c.
References capstone::CS_ERR_ARCH, capstone::CS_ERR_CSH, capstone::CS_ERR_DETAIL, capstone::CS_ERR_DIET, capstone::CS_ERR_HANDLE, capstone::CS_ERR_MEM, capstone::CS_ERR_MEMSETUP, capstone::CS_ERR_MODE, capstone::CS_ERR_OK, capstone::CS_ERR_OPTION, capstone::CS_ERR_SKIPDATA, capstone::CS_ERR_VERSION, capstone::CS_ERR_X86_ATT, capstone::CS_ERR_X86_INTEL, and capstone::CS_ERR_X86_MASM.
Referenced by bs_strerror().
CAPSTONE_EXPORT bool CAPSTONE_API cs_support | ( | int | query | ) |
Definition at line 368 of file cs.c.
References all_arch, CS_ARCH_ALL, CS_ARCH_ARM, CS_ARCH_ARM64, CS_ARCH_EVM, CS_ARCH_M680X, CS_ARCH_M68K, CS_ARCH_MAX, CS_ARCH_MIPS, CS_ARCH_PPC, CS_ARCH_SPARC, CS_ARCH_SYSZ, CS_ARCH_TMS320C64X, CS_ARCH_X86, CS_ARCH_XCORE, CS_SUPPORT_DIET, and CS_SUPPORT_X86_REDUCE.
Referenced by bs_support(), main(), and usage().
CAPSTONE_EXPORT unsigned int CAPSTONE_API cs_version | ( | int * | major, |
int * | minor | ||
) |
Definition at line 357 of file cs.c.
References CS_API_MAJOR, CS_API_MINOR, major, minor, and NULL.
Referenced by bs_version(), and ocaml_version().
|
static |
Definition at line 536 of file cs.c.
References handle, customized_mnem::id, insn_mnem::insn, MCInst_getOpcodePub(), memcpy(), MIN, mnem, customized_mnem::mnemonic, sp, and autogen_x86imm::tmp.
Referenced by cs_disasm(), and cs_disasm_iter().
Definition at line 765 of file cs.c.
References cs_snprintf(), i, len, NULL, opstr(), and p.
Referenced by cs_disasm(), and cs_disasm_iter().
Definition at line 601 of file cs.c.
References CS_ARCH_ARM, CS_ARCH_ARM64, CS_ARCH_EVM, CS_ARCH_M680X, CS_ARCH_M68K, CS_ARCH_MIPS, CS_ARCH_PPC, CS_ARCH_SPARC, CS_ARCH_SYSZ, CS_ARCH_TMS320C64X, CS_ARCH_X86, CS_ARCH_XCORE, CS_MODE_THUMB, and handle.
Referenced by cs_option().
|
static |
Definition at line 269 of file cs.c.
Referenced by cs_support().
Definition at line 198 of file cs.c.
Referenced by cs_open(), and cs_option().
|
static |
Definition at line 133 of file cs.c.
Referenced by cs_option().
cs_calloc_t cs_mem_calloc = NULL |
Definition at line 349 of file cs.c.
Referenced by cs_disasm(), cs_open(), cs_option(), and make_id2insn().
Definition at line 351 of file cs.c.
Referenced by cs_close(), cs_disasm(), cs_free(), cs_malloc(), cs_open(), and cs_option().
cs_malloc_t cs_mem_malloc = NULL |
Definition at line 348 of file cs.c.
Referenced by cs_malloc(), cs_open(), cs_option(), and cs_strdup().
cs_realloc_t cs_mem_realloc = NULL |
Definition at line 350 of file cs.c.
Referenced by cs_disasm(), cs_open(), and cs_option().
cs_vsnprintf_t cs_vsnprintf = NULL |
Definition at line 352 of file cs.c.
Referenced by cs_open(), cs_option(), cs_snprintf(), and SStream_concat().