Rizin
unix-like reverse engineering framework and cli tools
analysis_propeller.c File Reference
#include <string.h>
#include <rz_types.h>
#include <rz_lib.h>
#include <rz_asm.h>
#include <rz_analysis.h>
#include <rz_util.h>
#include <propeller_disas.h>

Go to the source code of this file.

Functions

static int propeller_op (RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
 

Variables

RzAnalysisPlugin rz_analysis_plugin_propeller
 

Function Documentation

◆ propeller_op()

static int propeller_op ( RzAnalysis analysis,
RzAnalysisOp op,
ut64  addr,
const ut8 buf,
int  len,
RzAnalysisOpMask  mask 
)
static

Definition at line 14 of file analysis_propeller.c.

14  {
15  rz_return_val_if_fail(analysis && op && buf, -1);
16  if (len < 4) {
17  RZ_LOG_WARN("Couldn't disassemble instruction at 0x%x. Less than 4 bytes were provided.\n", (ut32)addr);
18  return -1;
19  }
20  int ret;
21  struct propeller_cmd cmd;
22 
23  memset(&cmd, 0, sizeof(cmd));
24 
25  ret = op->size = propeller_decode_command(buf, &cmd);
26 
27  if (ret < 0) {
28  return ret;
29  }
30 
31  op->addr = addr;
32 
33  switch (cmd.opcode) {
34  case PROP_TEST:
35  case PROP_TESTN:
36  case PROP_TJNZ:
37  case PROP_TJZ:
38  case PROP_CMPS:
39  case PROP_CMPSUB:
41  break;
42  case PROP_ADD:
43  case PROP_ADDX:
44  case PROP_ADDABS:
46  break;
47  case PROP_OR:
48  op->type = RZ_ANALYSIS_OP_TYPE_OR;
49  break;
50  case PROP_RCL:
51  case PROP_ROL:
52  case PROP_SHL:
54  break;
55  case PROP_RCR:
56  case PROP_ROR:
57  case PROP_SHR:
59  break;
60  case PROP_NEG:
62  break;
63  case PROP_XOR:
65  break;
66  case PROP_ABS:
67  case PROP_MINS:
68  case PROP_MIN:
69  case PROP_MAX:
70  case PROP_MAXS:
71  case PROP_RDBYTE:
72  case PROP_RDLONG:
73  case PROP_RDWORD:
74  case PROP_MOV:
75  case PROP_MOVD:
76  case PROP_MOVI:
77  case PROP_MOVS:
78  case PROP_WAITVID:
79  case PROP_MUXC:
80  if (cmd.opcode == PROP_MOV && cmd.dst == 0x44 && cmd.src == 0x3c) {
82  } else {
84  }
85  break;
86  case PROP_SUB:
88  break;
89  case PROP_JMP:
90  case PROP_DJNZ:
91  if (cmd.immed == 0) {
93  op->jump = 0x20 + cmd.src;
94  op->fail = addr + 2;
95  } else {
97  op->fail = addr + 2;
98  }
99  break;
100  default:
101  op->type = RZ_ANALYSIS_OP_TYPE_UNK;
102  break;
103  }
104 
105  return ret;
106 }
size_t len
Definition: 6502dis.c:15
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
uint32_t ut32
voidpf void * buf
Definition: ioapi.h:138
return memset(p, 0, total)
int propeller_decode_command(const ut8 *instr, struct propeller_cmd *cmd)
@ PROP_MOVS
@ PROP_MOVD
@ PROP_MIN
@ PROP_RDWORD
@ PROP_CMPSUB
@ PROP_RCR
@ PROP_ADDX
@ PROP_XOR
@ PROP_NEG
@ PROP_MOVI
@ PROP_SHL
@ PROP_RDBYTE
@ PROP_TJZ
@ PROP_TJNZ
@ PROP_SHR
@ PROP_RCL
@ PROP_MUXC
@ PROP_ROR
@ PROP_TEST
@ PROP_MAXS
@ PROP_MINS
@ PROP_RDLONG
@ PROP_ADDABS
@ PROP_MOV
@ PROP_WAITVID
@ PROP_TESTN
@ PROP_ADD
@ PROP_ROL
@ PROP_OR
@ PROP_MAX
@ PROP_JMP
@ PROP_DJNZ
@ PROP_CMPS
@ PROP_SUB
@ PROP_ABS
@ RZ_ANALYSIS_OP_TYPE_CMP
Definition: rz_analysis.h:399
@ RZ_ANALYSIS_OP_TYPE_SUB
Definition: rz_analysis.h:402
@ RZ_ANALYSIS_OP_TYPE_UNK
Definition: rz_analysis.h:388
@ RZ_ANALYSIS_OP_TYPE_ROL
Definition: rz_analysis.h:420
@ RZ_ANALYSIS_OP_TYPE_AND
Definition: rz_analysis.h:411
@ RZ_ANALYSIS_OP_TYPE_UJMP
Definition: rz_analysis.h:369
@ RZ_ANALYSIS_OP_TYPE_ROR
Definition: rz_analysis.h:419
@ RZ_ANALYSIS_OP_TYPE_ADD
Definition: rz_analysis.h:401
@ RZ_ANALYSIS_OP_TYPE_OR
Definition: rz_analysis.h:410
@ RZ_ANALYSIS_OP_TYPE_CJMP
Definition: rz_analysis.h:373
@ RZ_ANALYSIS_OP_TYPE_MOV
Definition: rz_analysis.h:390
@ RZ_ANALYSIS_OP_TYPE_RET
Definition: rz_analysis.h:385
@ RZ_ANALYSIS_OP_TYPE_XOR
Definition: rz_analysis.h:412
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
Definition: dis.c:32
static int addr
Definition: z80asm.c:58

References addr, cmd, len, memset(), PROP_ABS, PROP_ADD, PROP_ADDABS, PROP_ADDX, PROP_CMPS, PROP_CMPSUB, PROP_DJNZ, PROP_JMP, PROP_MAX, PROP_MAXS, PROP_MIN, PROP_MINS, PROP_MOV, PROP_MOVD, PROP_MOVI, PROP_MOVS, PROP_MUXC, PROP_NEG, PROP_OR, PROP_RCL, PROP_RCR, PROP_RDBYTE, PROP_RDLONG, PROP_RDWORD, PROP_ROL, PROP_ROR, PROP_SHL, PROP_SHR, PROP_SUB, PROP_TEST, PROP_TESTN, PROP_TJNZ, PROP_TJZ, PROP_WAITVID, PROP_XOR, propeller_decode_command(), RZ_ANALYSIS_OP_TYPE_ADD, RZ_ANALYSIS_OP_TYPE_AND, RZ_ANALYSIS_OP_TYPE_CJMP, RZ_ANALYSIS_OP_TYPE_CMP, RZ_ANALYSIS_OP_TYPE_MOV, RZ_ANALYSIS_OP_TYPE_OR, RZ_ANALYSIS_OP_TYPE_RET, RZ_ANALYSIS_OP_TYPE_ROL, RZ_ANALYSIS_OP_TYPE_ROR, RZ_ANALYSIS_OP_TYPE_SUB, RZ_ANALYSIS_OP_TYPE_UJMP, RZ_ANALYSIS_OP_TYPE_UNK, RZ_ANALYSIS_OP_TYPE_XOR, RZ_LOG_WARN, and rz_return_val_if_fail.

Variable Documentation

◆ rz_analysis_plugin_propeller

RzAnalysisPlugin rz_analysis_plugin_propeller
Initial value:
= {
.name = "propeller",
.desc = "Parallax propeller code analysis plugin",
.license = "LGPL3",
.arch = "propeller",
.bits = 32,
.op = propeller_op,
}
static int propeller_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)

Definition at line 108 of file analysis_propeller.c.