capstone

Форк
0
/
cstool_mips.c 
46 строк · 1.1 Кб
1
/* Capstone Disassembler Engine */
2
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
3

4
#include <stdio.h>
5
#include <stdlib.h>
6

7
#include <capstone/capstone.h>
8
#include "cstool.h"
9

10
void print_insn_detail_mips(csh handle, cs_insn *ins)
11
{
12
	int i;
13
	cs_mips *mips;
14

15
	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
16
	if (ins->detail == NULL)
17
		return;
18

19
	mips = &(ins->detail->mips);
20
	if (mips->op_count)
21
		printf("\top_count: %u\n", mips->op_count);
22

23
	for (i = 0; i < mips->op_count; i++) {
24
		cs_mips_op *op = &(mips->operands[i]);
25
		switch((int)op->type) {
26
			default:
27
				break;
28
			case MIPS_OP_REG:
29
				printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
30
				break;
31
			case MIPS_OP_IMM:
32
				printf("\t\toperands[%u].type: IMM = 0x%" PRIx64 "\n", i, op->imm);
33
				break;
34
			case MIPS_OP_MEM:
35
				printf("\t\toperands[%u].type: MEM\n", i);
36
				if (op->mem.base != MIPS_REG_INVALID)
37
					printf("\t\t\toperands[%u].mem.base: REG = %s\n",
38
						   i, cs_reg_name(handle, op->mem.base));
39
				if (op->mem.disp != 0)
40
					printf("\t\t\toperands[%u].mem.disp: 0x%" PRIx64 "\n", i, op->mem.disp);
41

42
				break;
43
		}
44

45
	}
46
}
47

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.