Rizin
unix-like reverse engineering framework and cli tools
MipsModule.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_MIPS
5 
6 #include "../../utils.h"
7 #include "../../MCRegisterInfo.h"
8 #include "MipsDisassembler.h"
9 #include "MipsInstPrinter.h"
10 #include "MipsMapping.h"
11 #include "MipsModule.h"
12 
13 // Returns mode value with implied bits set
14 static cs_mode updated_mode(cs_mode mode)
15 {
16  if (mode & CS_MODE_MIPS32R6) {
17  mode |= CS_MODE_32;
18  }
19 
20  return mode;
21 }
22 
23 cs_err Mips_global_init(cs_struct *ud)
24 {
25  MCRegisterInfo *mri;
26  mri = cs_mem_malloc(sizeof(*mri));
27 
28  Mips_init(mri);
29  ud->printer = Mips_printInst;
30  ud->printer_info = mri;
31  ud->getinsn_info = mri;
32  ud->reg_name = Mips_reg_name;
36 
38 
39  return CS_ERR_OK;
40 }
41 
43 {
44  if (type == CS_OPT_MODE) {
45  handle->mode = updated_mode(value);
46  return CS_ERR_OK;
47  }
48 
49  return CS_ERR_OPTION;
50 }
51 
52 #endif
bool Mips_getInstruction(csh handle, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
void Mips_init(MCRegisterInfo *MRI)
void Mips_printInst(MCInst *MI, SStream *O, void *info)
const char * Mips_group_name(csh handle, unsigned int id)
const char * Mips_reg_name(csh handle, unsigned int reg)
const char * Mips_insn_name(csh handle, unsigned int id)
void Mips_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
cs_err Mips_global_init(cs_struct *ud)
cs_err Mips_option(cs_struct *handle, cs_opt_type type, size_t value)
static mcore_handle handle
Definition: asm_mcore.c:8
cs_mode
Mode type.
Definition: capstone.h:102
@ CS_MODE_32
32-bit mode (X86)
Definition: capstone.h:106
@ CS_MODE_MIPS32R6
Mips32r6 ISA.
Definition: capstone.h:113
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
static int value
Definition: cmd_api.c:93
cs_malloc_t cs_mem_malloc
Definition: cs.c:348
const char int mode
Definition: ioapi.h:137
int type
Definition: mipsasm.c:17
int CS_ERR_OPTION
Definition: __init__.py:241
int CS_ERR_OK
Definition: __init__.py:235
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
Disasm_t disasm
Definition: cs_priv.h:59
void * getinsn_info
Definition: cs_priv.h:60