Haka: modules/misc/asm/asm.h Source File

Haka

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

asm.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef ASM_H_
6 #define ASM_H_
7
8 #include <haka/types.h>
9 #include <haka/vbuffer_stream.h>
10 #include <capstone.h>
11
12 #define INSTRUCTION_BYTES 16
13 #define INSTRUCTION_OPERANDS 160
14 #define INSTRUCTION_MNEMONIC 32
15
16 /* The maximum size of an instruction depends
17 * on the architecture. Instruction size does
18 * not exceed 15 (on x86).
19 */
20 #define INSTRUCTION_MAX_LEN 15
21
22 struct asm_instruction_pending {
23 uint8_t code[INSTRUCTION_MAX_LEN];
24 uint16_t size;
25 size_t advance;
26 };
27
28 struct asm_handle {
29 csh handle;
30 int arch;
31 int mode;
32 struct asm_instruction_pending pending;
33 };
34
35 struct asm_instruction {
36 uint64_t addr;
37 cs_insn inst;
38 cs_detail detail;
39 };
40
41 void instruction_release(struct asm_instruction *inst);
42 uint32 instruction_get_id(struct asm_instruction *inst);
43 uintptr_t instruction_get_address(struct asm_instruction *inst);
44 uint16 instruction_get_size(struct asm_instruction *inst);
45 const uint8 *instruction_get_bytes(struct asm_instruction *inst);
46 const char *instruction_get_mnemonic(struct asm_instruction *inst);
47 const char *instruction_get_operands(struct asm_instruction *inst);
48 void instruction_print(struct asm_instruction *inst);
49
50 struct asm_handle *asm_initialize(cs_arch arch, cs_mode mode);
51 void asm_destroy(struct asm_handle *asm_handle);
52 void asm_set_disassembly_flavor(struct asm_handle *asm_handle, int syntax);
53 int asm_get_arch(struct asm_handle *asm_handle);
54 int asm_get_mode(struct asm_handle *asm_handle);
55 bool asm_vbdisas(struct asm_handle *asm_handle, struct vbuffer_iterator *pos,
56 struct asm_instruction *_inst);
57
58 #endif
types.h
vbuffer_iterator
Definition: vbuffer.h:77
uint16
unsigned HAKA_16BIT_TYPE uint16
Definition: types.h:28
uint32
unsigned HAKA_32BIT_TYPE uint32
Definition: types.h:29
vbuffer_stream.h
uint8
unsigned char uint8
Definition: types.h:27