1 /* radare - LGPL - Copyright 2015 - condret */
2
3 #include <r_anal.h>
4 #include <r_types.h>
5 #include <r_lib.h>
6
mal_anal(RAnal * anal,RAnalOp * op,ut64 addr,const ut8 * data,int len,RAnalOpMask mask)7 static int mal_anal(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len, RAnalOpMask mask) {
8 if (len) {
9 switch ((data[0] + addr) % 94) {
10 case 4:
11 op->type = R_ANAL_OP_TYPE_UJMP;
12 break;
13 case 5:
14 case 23:
15 op->type = R_ANAL_OP_TYPE_IO;
16 break;
17 case 39:
18 op->type = R_ANAL_OP_TYPE_ROR;
19 op->type2 = R_ANAL_OP_TYPE_LOAD;
20 break;
21 case 40:
22 op->type = R_ANAL_OP_TYPE_LOAD;
23 break;
24 case 62:
25 op->type = R_ANAL_OP_TYPE_XOR;
26 op->type2 = R_ANAL_OP_TYPE_LOAD;
27 break;
28 case 81:
29 op->type = R_ANAL_OP_TYPE_TRAP;
30 break;
31 default:
32 op->type = R_ANAL_OP_TYPE_NOP;
33 }
34 return op->size = 1;
35 }
36 return false;
37 }
38
39 RAnalPlugin r_anal_plugin_malbolge = {
40 .name = "malbolge",
41 .desc = "Malbolge analysis plugin",
42 .arch = "malbolge",
43 .license = "LGPL3",
44 .bits = 32,
45 .op = &mal_anal,
46 };
47
48 #ifndef R2_PLUGIN_INCORE
49 R_API RLibStruct radare_plugin = {
50 .type = R_LIB_TYPE_ANAL,
51 .data = &r_anal_plugin_malbolge,
52 .version = R2_VERSION
53 };
54 #endif
55