Rizin
unix-like reverse engineering framework and cli tools
ARMModule.c
Go to the documentation of this file.
1 /* Capstone Disassembly Engine */
2 /* By Dang Hoang Vu <danghvu@gmail.com> 2013 */
3 
4 #ifdef CAPSTONE_HAS_ARM
5 
6 #include "../../cs_priv.h"
7 #include "../../MCRegisterInfo.h"
8 #include "ARMDisassembler.h"
9 #include "ARMInstPrinter.h"
10 #include "ARMMapping.h"
11 #include "ARMModule.h"
12 
13 cs_err ARM_global_init(cs_struct *ud)
14 {
15  MCRegisterInfo *mri;
16  mri = cs_mem_malloc(sizeof(*mri));
17 
18  ARM_init(mri);
19  ARM_getRegName(ud, 0); // use default get_regname
20 
21  ud->printer = ARM_printInst;
22  ud->printer_info = mri;
23  ud->reg_name = ARM_reg_name;
28 #ifndef CAPSTONE_DIET
30 #endif
31 
32  if (ud->mode & CS_MODE_THUMB)
34  else
36 
37  return CS_ERR_OK;
38 }
39 
41 {
42  switch(type) {
43  case CS_OPT_MODE:
44  if (value & CS_MODE_THUMB)
45  handle->disasm = Thumb_getInstruction;
46  else
47  handle->disasm = ARM_getInstruction;
48 
49  handle->mode = (cs_mode)value;
50 
51  break;
52  case CS_OPT_SYNTAX:
54  handle->syntax = (int)value;
55  break;
56  default:
57  break;
58  }
59 
60  return CS_ERR_OK;
61 }
62 
63 #endif
bool Thumb_getInstruction(csh handle, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
void ARM_init(MCRegisterInfo *MRI)
bool ARM_getInstruction(csh handle, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
void ARM_post_printer(csh handle, cs_insn *pub_insn, char *mnem, MCInst *mci)
void ARM_printInst(MCInst *MI, SStream *O, void *Info)
void ARM_getRegName(cs_struct *handle, int value)
const char * ARM_insn_name(csh handle, unsigned int id)
void ARM_reg_access(const cs_insn *insn, cs_regs regs_read, uint8_t *regs_read_count, cs_regs regs_write, uint8_t *regs_write_count)
const char * ARM_reg_name(csh handle, unsigned int reg)
void ARM_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
const char * ARM_group_name(csh handle, unsigned int id)
cs_err ARM_option(cs_struct *handle, cs_opt_type type, size_t value)
cs_err ARM_global_init(cs_struct *ud)
static mcore_handle handle
Definition: asm_mcore.c:8
cs_mode
Mode type.
Definition: capstone.h:102
@ CS_MODE_THUMB
ARM's Thumb mode, including Thumb-2.
Definition: capstone.h:108
cs_opt_type
Runtime option for the disassembled engine.
Definition: capstone.h:168
@ CS_OPT_MODE
Change engine's mode at run-time.
Definition: capstone.h:172
@ CS_OPT_SYNTAX
Assembly output syntax.
Definition: capstone.h:170
static int value
Definition: cmd_api.c:93
cs_malloc_t cs_mem_malloc
Definition: cs.c:348
int type
Definition: mipsasm.c:17
int CS_ERR_OK
Definition: __init__.py:235
static int
Definition: sfsocketcall.h:114
GetName_t insn_name
Definition: cs_priv.h:62
GetName_t reg_name
Definition: cs_priv.h:61
void * printer_info
Definition: cs_priv.h:58
Printer_t printer
Definition: cs_priv.h:57
GetID_t insn_id
Definition: cs_priv.h:64
GetName_t group_name
Definition: cs_priv.h:63
GetRegisterAccess_t reg_access
Definition: cs_priv.h:77
Disasm_t disasm
Definition: cs_priv.h:59
cs_mode mode
Definition: cs_priv.h:56
PostPrinter_t post_printer
Definition: cs_priv.h:65