parent
1bdb23a76d
commit
34d49d935b
7 changed files with 232 additions and 163 deletions
@ -0,0 +1,21 @@ |
||||
#ifndef __ARCH_H__ |
||||
#define __ARCH_H__ |
||||
|
||||
#define MAX_ARCH 32 |
||||
|
||||
void (*init_arch[MAX_ARCH]) (cs_struct *); |
||||
|
||||
#ifdef CS_SUPPORT_X86 |
||||
#include "arch/X86/include.h" |
||||
#endif |
||||
#ifdef CS_SUPPORT_ARM |
||||
#include "arch/ARM/include.h" |
||||
#endif |
||||
#ifdef CS_SUPPORT_AARCH64 |
||||
#include "arch/AArch64/include.h" |
||||
#endif |
||||
#ifdef CS_SUPPORT_MIPS |
||||
#include "arch/Mips/include.h" |
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,26 @@ |
||||
#ifndef __ARM64_INCLUDE_H__ |
||||
#define __ARM64_INCLUDE_H__ |
||||
|
||||
#include "AArch64Disassembler.h" |
||||
#include "AArch64InstPrinter.h" |
||||
#include "mapping.h" |
||||
|
||||
void init_arm64(cs_struct *ud) { |
||||
MCRegisterInfo *mri = malloc(sizeof(*mri)); |
||||
|
||||
AArch64_init(mri); |
||||
ud->printer = AArch64_printInst; |
||||
ud->printer_info = mri; |
||||
ud->getinsn_info = mri; |
||||
ud->disasm = AArch64_getInstruction; |
||||
ud->reg_name = AArch64_reg_name; |
||||
ud->insn_id = AArch64_get_insn_id; |
||||
ud->insn_name = AArch64_insn_name; |
||||
ud->post_printer = AArch64_post_printer; |
||||
} |
||||
|
||||
void __attribute__ ((constructor)) __init_arm64__() { |
||||
init_arch[CS_ARCH_ARM64] = init_arm64; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,30 @@ |
||||
#ifndef __ARM_INCLUDE_H__ |
||||
#define __ARM_INCLUDE_H__ |
||||
|
||||
#include "ARMDisassembler.h" |
||||
#include "ARMInstPrinter.h" |
||||
#include "mapping.h" |
||||
|
||||
void init_arm(cs_struct *ud) { |
||||
MCRegisterInfo *mri = malloc(sizeof(*mri)); |
||||
|
||||
ARM_init(mri); |
||||
|
||||
ud->printer = ARM_printInst; |
||||
ud->printer_info = mri; |
||||
ud->reg_name = ARM_reg_name; |
||||
ud->insn_id = ARM_get_insn_id; |
||||
ud->insn_name = ARM_insn_name; |
||||
ud->post_printer = ARM_post_printer; |
||||
|
||||
if (ud->mode & CS_MODE_THUMB) |
||||
ud->disasm = Thumb_getInstruction; |
||||
else |
||||
ud->disasm = ARM_getInstruction; |
||||
} |
||||
|
||||
void __attribute__ ((constructor)) __init_arm__() { |
||||
init_arch[CS_ARCH_ARM] = init_arm; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,29 @@ |
||||
#ifndef __MIPS_INCLUDE_H__ |
||||
#define __MIPS_INCLUDE_H__ |
||||
|
||||
#include "MipsDisassembler.h" |
||||
#include "MipsInstPrinter.h" |
||||
#include "mapping.h" |
||||
|
||||
void init_mips(cs_struct *ud) { |
||||
MCRegisterInfo *mri = malloc(sizeof(*mri)); |
||||
|
||||
Mips_init(mri); |
||||
ud->printer = Mips_printInst; |
||||
ud->printer_info = mri; |
||||
ud->getinsn_info = mri; |
||||
ud->reg_name = Mips_reg_name; |
||||
ud->insn_id = Mips_get_insn_id; |
||||
ud->insn_name = Mips_insn_name; |
||||
|
||||
if (ud->mode & CS_MODE_32) |
||||
ud->disasm = Mips_getInstruction; |
||||
else |
||||
ud->disasm = Mips64_getInstruction; |
||||
} |
||||
|
||||
void __attribute__ ((constructor)) __init_mips__() { |
||||
init_arch[CS_ARCH_MIPS] = init_mips; |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,23 @@ |
||||
#ifndef __X86_INCLUDE_H__ |
||||
#define __X86_INCLUDE_H__ |
||||
|
||||
#include "X86Disassembler.h" |
||||
#include "X86InstPrinter.h" |
||||
#include "mapping.h" |
||||
|
||||
void init_x86(cs_struct *ud) { |
||||
// by default, we use Intel syntax
|
||||
ud->printer = X86_Intel_printInst; |
||||
ud->printer_info = NULL; |
||||
ud->disasm = X86_getInstruction; |
||||
ud->reg_name = X86_reg_name; |
||||
ud->insn_id = X86_get_insn_id; |
||||
ud->insn_name = X86_insn_name; |
||||
ud->post_printer = X86_post_printer; |
||||
} |
||||
|
||||
void __attribute__ ((constructor)) __init_x86__() { |
||||
init_arch[CS_ARCH_X86] = init_x86; |
||||
} |
||||
|
||||
#endif |
Loading…
Reference in new issue