Rizin
unix-like reverse engineering framework and cli tools
asm_malbolge.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014-2018 condret <condr3t@protonmail.com>
2 // SPDX-FileCopyrightText: 2014-2018 pancake <pancake@nopcode.org>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include <rz_asm.h>
6 #include <rz_types.h>
7 #include <rz_lib.h>
8 #include <string.h>
9 
10 static const char *mal_dis(ut64 c, const ut8 *buf, ut64 len) {
11  if (len) {
12  switch ((buf[0] + c) % 94) {
13  case 4: return "jmp [d]";
14  case 5: return "out a";
15  case 23: return "in a";
16  case 39: return "rotr [d], mov a, [d]";
17  case 40: return "mov d, [d]";
18  case 62: return "crz [d], a, mov a, [d]";
19  case 81: return "end";
20  default: return "nop";
21  }
22  }
23  return NULL;
24 }
25 
26 static int __disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
27  const char *opstr = mal_dis(a->pc, buf, len);
28  return op->size = opstr ? 1 : 0;
29 }
30 
32  .name = "malbolge",
33  .desc = "Malbolge Ternary VM",
34  .arch = "malbolge",
35  .author = "condret",
36  .license = "LGPL3",
37  .bits = 32,
38  .endian = RZ_SYS_ENDIAN_NONE,
39  .disassemble = &__disassemble
40 };
41 
42 #ifndef RZ_PLUGIN_INCORE
45  .data = &rz_asm_plugin_malbolge,
47 };
48 #endif
size_t len
Definition: 6502dis.c:15
static const char * mal_dis(ut64 c, const ut8 *buf, ut64 len)
Definition: asm_malbolge.c:10
RZ_API RzLibStruct rizin_plugin
Definition: asm_malbolge.c:43
static int __disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_malbolge.c:26
RzAsmPlugin rz_asm_plugin_malbolge
Definition: asm_malbolge.c:31
static int opstr(RzAsm *a, ut8 *data, const Opcode *op)
Definition: asm_x86_nz.c:4054
#define RZ_API
#define NULL
Definition: cris-opc.c:27
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_SYS_ENDIAN_NONE
Definition: rz_types.h:525
#define RZ_VERSION
Definition: rz_version.h:8
#define c(i)
Definition: sha256.c:43
#define a(i)
Definition: sha256.c:41
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()