Rizin
unix-like reverse engineering framework and cli tools
op.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2010-2020 pancake <pancake@nopcode.org>
2 // SPDX-FileCopyrightText: 2010-2020 nibble <nibble.ds@gmail.com>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include <rz_analysis.h>
6 #include <rz_util.h>
7 #include <rz_list.h>
8 
12  return op;
13 }
14 
15 RZ_API RzList /*<RzAnalysisOp *>*/ *rz_analysis_op_list_new(void) {
16  RzList *list = rz_list_new();
17  if (list) {
18  list->free = &rz_analysis_op_free;
19  }
20  return list;
21 }
22 
24  if (op) {
25  memset(op, 0, sizeof(*op));
26  op->addr = UT64_MAX;
27  op->jump = UT64_MAX;
28  op->fail = UT64_MAX;
29  op->ptr = UT64_MAX;
30  op->refptr = 0;
31  op->val = UT64_MAX;
32  op->disp = UT64_MAX;
33  op->mmio_address = UT64_MAX;
34  }
35 }
36 
38  if (!op) {
39  return false;
40  }
41  rz_analysis_value_free(op->src[0]);
42  rz_analysis_value_free(op->src[1]);
43  rz_analysis_value_free(op->src[2]);
44  op->src[0] = NULL;
45  op->src[1] = NULL;
46  op->src[2] = NULL;
48  op->dst = NULL;
49  rz_list_free(op->access);
50  op->access = NULL;
51  rz_strbuf_fini(&op->opex);
52  rz_strbuf_fini(&op->esil);
53  rz_analysis_switch_op_free(op->switch_op);
54  op->switch_op = NULL;
55  RZ_FREE(op->mnemonic);
56  rz_il_op_effect_free(op->il_op);
57  op->il_op = NULL;
58  return true;
59 }
60 
62  if (!op) {
63  return;
64  }
66  memset(op, 0, sizeof(RzAnalysisOp));
67  free(op);
68 }
69 
71  switch (op->type) {
76  return 2;
80  return 1;
83  return 4;
85  return 4;
90  return 4;
91  default:
92  return 1;
93  }
94 }
95 
98  rz_return_val_if_fail(analysis && op && len > 0, -1);
99 
100  int ret = RZ_MIN(2, len);
101  if (len > 0 && analysis->cur && analysis->cur->op) {
102  // use core binding to set asm.bits correctly based on the addr
103  // this is because of the hassle of arm/thumb
104  if (analysis && analysis->coreb.archbits) {
105  analysis->coreb.archbits(analysis->coreb.core, addr);
106  }
107  if (analysis->pcalign && addr % analysis->pcalign) {
108  op->type = RZ_ANALYSIS_OP_TYPE_ILL;
109  op->addr = addr;
110  // RZ_LOG_DEBUG("Unaligned instruction for %d bits at 0x%"PFMT64x"\n", analysis->bits, addr);
111  op->size = 1;
112  return -1;
113  }
114  ret = analysis->cur->op(analysis, op, addr, data, len, mask);
115  if (ret < 1) {
116  op->type = RZ_ANALYSIS_OP_TYPE_ILL;
117  }
118  op->addr = addr;
119  /* consider at least 1 byte to be part of the opcode */
120  if (op->nopcode < 1) {
121  op->nopcode = 1;
122  }
123  } else if (!memcmp(data, "\xff\xff\xff\xff", RZ_MIN(4, len))) {
124  op->type = RZ_ANALYSIS_OP_TYPE_ILL;
125  } else {
126  op->type = RZ_ANALYSIS_OP_TYPE_MOV;
127  if (op->cycles == 0) {
128  op->cycles = defaultCycles(op);
129  }
130  }
131  if (!op->mnemonic && (mask & RZ_ANALYSIS_OP_MASK_DISASM)) {
132  RZ_LOG_DEBUG("Warning: unhandled RZ_ANALYSIS_OP_MASK_DISASM in rz_analysis_op\n");
133  }
135  RzAnalysisHint *hint = rz_analysis_hint_get(analysis, addr);
136  if (hint) {
137  rz_analysis_op_hint(op, hint);
138  rz_analysis_hint_free(hint);
139  }
140  }
141  return ret;
142 }
143 
146  if (!nop) {
147  return NULL;
148  }
149  *nop = *op;
150  if (op->mnemonic) {
151  nop->mnemonic = strdup(op->mnemonic);
152  if (!nop->mnemonic) {
153  free(nop);
154  return NULL;
155  }
156  } else {
157  nop->mnemonic = NULL;
158  }
159  nop->src[0] = rz_analysis_value_copy(op->src[0]);
160  nop->src[1] = rz_analysis_value_copy(op->src[1]);
161  nop->src[2] = rz_analysis_value_copy(op->src[2]);
162  nop->dst = rz_analysis_value_copy(op->dst);
163  if (op->access) {
164  RzListIter *it;
167  rz_list_foreach (op->access, it, val) {
169  }
170  nop->access = naccess;
171  }
172  rz_strbuf_init(&nop->esil);
173  rz_strbuf_copy(&nop->esil, &op->esil);
174  return nop;
175 }
176 
179  switch (t) {
180  // call
187  // jmp
196  // trap| ill| unk
202  return true;
203  default:
204  return false;
205  }
206 }
207 
210  switch (t) {
216  return true;
217  default:
218  return false;
219  }
220 }
221 
222 static struct optype {
223  int type;
224  const char *name;
225 } optypes[] = {
226  { RZ_ANALYSIS_OP_TYPE_IO, "io" },
227  { RZ_ANALYSIS_OP_TYPE_ACMP, "acmp" },
228  { RZ_ANALYSIS_OP_TYPE_ADD, "add" },
229  { RZ_ANALYSIS_OP_TYPE_SYNC, "sync" },
230  { RZ_ANALYSIS_OP_TYPE_AND, "and" },
231  { RZ_ANALYSIS_OP_TYPE_CALL, "call" },
232  { RZ_ANALYSIS_OP_TYPE_CCALL, "ccall" },
233  { RZ_ANALYSIS_OP_TYPE_CJMP, "cjmp" },
234  { RZ_ANALYSIS_OP_TYPE_MJMP, "mjmp" },
235  { RZ_ANALYSIS_OP_TYPE_CMP, "cmp" },
236  { RZ_ANALYSIS_OP_TYPE_CRET, "cret" },
237  { RZ_ANALYSIS_OP_TYPE_ILL, "ill" },
238  { RZ_ANALYSIS_OP_TYPE_JMP, "jmp" },
239  { RZ_ANALYSIS_OP_TYPE_LEA, "lea" },
240  { RZ_ANALYSIS_OP_TYPE_LEAVE, "leave" },
241  { RZ_ANALYSIS_OP_TYPE_LOAD, "load" },
242  { RZ_ANALYSIS_OP_TYPE_NEW, "new" },
243  { RZ_ANALYSIS_OP_TYPE_MOD, "mod" },
244  { RZ_ANALYSIS_OP_TYPE_CMOV, "cmov" },
245  { RZ_ANALYSIS_OP_TYPE_MOV, "mov" },
246  { RZ_ANALYSIS_OP_TYPE_CAST, "cast" },
247  { RZ_ANALYSIS_OP_TYPE_MUL, "mul" },
248  { RZ_ANALYSIS_OP_TYPE_DIV, "div" },
249  { RZ_ANALYSIS_OP_TYPE_NOP, "nop" },
250  { RZ_ANALYSIS_OP_TYPE_NOT, "not" },
251  { RZ_ANALYSIS_OP_TYPE_NULL, "null" },
252  { RZ_ANALYSIS_OP_TYPE_OR, "or" },
253  { RZ_ANALYSIS_OP_TYPE_POP, "pop" },
254  { RZ_ANALYSIS_OP_TYPE_PUSH, "push" },
255  { RZ_ANALYSIS_OP_TYPE_REP, "rep" },
256  { RZ_ANALYSIS_OP_TYPE_RET, "ret" },
257  { RZ_ANALYSIS_OP_TYPE_ROL, "rol" },
258  { RZ_ANALYSIS_OP_TYPE_ROR, "ror" },
259  { RZ_ANALYSIS_OP_TYPE_SAL, "sal" },
260  { RZ_ANALYSIS_OP_TYPE_SAR, "sar" },
261  { RZ_ANALYSIS_OP_TYPE_SHL, "shl" },
262  { RZ_ANALYSIS_OP_TYPE_SHR, "shr" },
263  { RZ_ANALYSIS_OP_TYPE_STORE, "store" },
264  { RZ_ANALYSIS_OP_TYPE_SUB, "sub" },
265  { RZ_ANALYSIS_OP_TYPE_SWI, "swi" },
266  { RZ_ANALYSIS_OP_TYPE_CSWI, "cswi" },
267  { RZ_ANALYSIS_OP_TYPE_SWITCH, "switch" },
268  { RZ_ANALYSIS_OP_TYPE_TRAP, "trap" },
269  { RZ_ANALYSIS_OP_TYPE_UCALL, "ucall" },
270  { RZ_ANALYSIS_OP_TYPE_RCALL, "rcall" },
271  { RZ_ANALYSIS_OP_TYPE_ICALL, "icall" },
272  { RZ_ANALYSIS_OP_TYPE_IRCALL, "ircall" },
273  { RZ_ANALYSIS_OP_TYPE_UCCALL, "uccall" },
274  { RZ_ANALYSIS_OP_TYPE_UCJMP, "ucjmp" },
275  { RZ_ANALYSIS_OP_TYPE_UJMP, "ujmp" },
276  { RZ_ANALYSIS_OP_TYPE_RJMP, "rjmp" },
277  { RZ_ANALYSIS_OP_TYPE_IJMP, "ijmp" },
278  { RZ_ANALYSIS_OP_TYPE_IRJMP, "irjmp" },
279  { RZ_ANALYSIS_OP_TYPE_UNK, "unk" },
280  { RZ_ANALYSIS_OP_TYPE_UPUSH, "upush" },
281  { RZ_ANALYSIS_OP_TYPE_RPUSH, "rpush" },
282  { RZ_ANALYSIS_OP_TYPE_XCHG, "xchg" },
283  { RZ_ANALYSIS_OP_TYPE_XOR, "xor" },
284  { RZ_ANALYSIS_OP_TYPE_CASE, "case" },
285  { RZ_ANALYSIS_OP_TYPE_CPL, "cpl" },
286  { RZ_ANALYSIS_OP_TYPE_CRYPTO, "crypto" }
287 };
288 
296  int i;
297  for (i = 0; RZ_ARRAY_SIZE(optypes); i++) {
298  if (!strcmp(optypes[i].name, name)) {
299  return optypes[i].type;
300  }
301  }
302  return -1;
303 }
304 
311  int i;
312 
313  for (i = 0; i < RZ_ARRAY_SIZE(optypes); i++) {
314  if (optypes[i].type == type) {
315  return optypes[i].name;
316  }
317  }
318 
320 
321  for (i = 0; i < RZ_ARRAY_SIZE(optypes); i++) {
322  if (optypes[i].type == type) {
323  return optypes[i].name;
324  }
325  }
326  return "undefined";
327 }
328 
330  return rz_strbuf_get(&op->esil);
331 }
332 
333 // TODO: use esil here?
335  RzAnalysisBlock *bb;
337  char *cstr, ret[128];
338  char *r0 = rz_analysis_value_to_string(op->dst);
339  char *a0 = rz_analysis_value_to_string(op->src[0]);
340  char *a1 = rz_analysis_value_to_string(op->src[1]);
341  if (!r0) {
342  r0 = strdup("?");
343  }
344  if (!a0) {
345  a0 = strdup("?");
346  }
347  if (!a1) {
348  a1 = strdup("?");
349  }
350 
351  switch (op->type) {
353  snprintf(ret, sizeof(ret), "%s = %s", r0, a0);
354  break;
356  if ((bb = rz_analysis_find_most_relevant_block_in(analysis, op->addr))) {
357  cstr = rz_analysis_cond_to_string(bb->cond);
358  snprintf(ret, sizeof(ret), "if (%s) goto 0x%" PFMT64x, cstr, op->jump);
359  free(cstr);
360  } else {
361  snprintf(ret, sizeof(ret), "if (%s) goto 0x%" PFMT64x, "?", op->jump);
362  }
363  break;
365  snprintf(ret, sizeof(ret), "goto 0x%" PFMT64x, op->jump);
366  break;
371  snprintf(ret, sizeof(ret), "goto %s", r0);
372  break;
376  snprintf(ret, sizeof(ret), "push %s", a0);
377  break;
379  snprintf(ret, sizeof(ret), "pop %s", r0);
380  break;
385  snprintf(ret, sizeof(ret), "%s()", r0);
386  break;
389  if (f) {
390  snprintf(ret, sizeof(ret), "%s()", f->name);
391  } else {
392  snprintf(ret, sizeof(ret), "0x%" PFMT64x "()", op->jump);
393  }
394  break;
397  if ((bb = rz_analysis_find_most_relevant_block_in(analysis, op->addr))) {
398  cstr = rz_analysis_cond_to_string(bb->cond);
399  if (f) {
400  snprintf(ret, sizeof(ret), "if (%s) %s()", cstr, f->name);
401  } else {
402  snprintf(ret, sizeof(ret), "if (%s) 0x%" PFMT64x "()", cstr, op->jump);
403  }
404  free(cstr);
405  } else {
406  if (f) {
407  snprintf(ret, sizeof(ret), "if (unk) %s()", f->name);
408  } else {
409  snprintf(ret, sizeof(ret), "if (unk) 0x%" PFMT64x "()", op->jump);
410  }
411  }
412  break;
414  if (!a1 || !strcmp(a0, a1)) {
415  snprintf(ret, sizeof(ret), "%s += %s", r0, a0);
416  } else {
417  snprintf(ret, sizeof(ret), "%s = %s + %s", r0, a0, a1);
418  }
419  break;
421  if (!a1 || !strcmp(a0, a1)) {
422  snprintf(ret, sizeof(ret), "%s -= %s", r0, a0);
423  } else {
424  snprintf(ret, sizeof(ret), "%s = %s - %s", r0, a0, a1);
425  }
426  break;
428  if (!a1 || !strcmp(a0, a1)) {
429  snprintf(ret, sizeof(ret), "%s *= %s", r0, a0);
430  } else {
431  snprintf(ret, sizeof(ret), "%s = %s * %s", r0, a0, a1);
432  }
433  break;
435  if (!a1 || !strcmp(a0, a1)) {
436  snprintf(ret, sizeof(ret), "%s /= %s", r0, a0);
437  } else {
438  snprintf(ret, sizeof(ret), "%s = %s / %s", r0, a0, a1);
439  }
440  break;
442  if (!a1 || !strcmp(a0, a1)) {
443  snprintf(ret, sizeof(ret), "%s &= %s", r0, a0);
444  } else {
445  snprintf(ret, sizeof(ret), "%s = %s & %s", r0, a0, a1);
446  }
447  break;
449  if (!a1 || !strcmp(a0, a1)) {
450  snprintf(ret, sizeof(ret), "%s |= %s", r0, a0);
451  } else {
452  snprintf(ret, sizeof(ret), "%s = %s | %s", r0, a0, a1);
453  }
454  break;
456  if (!a1 || !strcmp(a0, a1)) {
457  snprintf(ret, sizeof(ret), "%s ^= %s", r0, a0);
458  } else {
459  snprintf(ret, sizeof(ret), "%s = %s ^ %s", r0, a0, a1);
460  }
461  break;
463  snprintf(ret, sizeof(ret), "%s -> %s", r0, a0);
464  break;
466  memcpy(ret, ";", 2);
467  break;
469  memcpy(ret, "nop", 4);
470  break;
472  memcpy(ret, "ret", 4);
473  break;
475  if ((bb = rz_analysis_find_most_relevant_block_in(analysis, op->addr))) {
476  cstr = rz_analysis_cond_to_string(bb->cond);
477  snprintf(ret, sizeof(ret), "if (%s) ret", cstr);
478  free(cstr);
479  } else {
480  strcpy(ret, "if (unk) ret");
481  }
482  break;
484  memcpy(ret, "leave", 6);
485  break;
487  if (!a1 || !strcmp(a0, a1)) {
488  snprintf(ret, sizeof(ret), "%s %%= %s", r0, a0);
489  } else {
490  snprintf(ret, sizeof(ret), "%s = %s %% %s", r0, a0, a1);
491  }
492  break;
494  if (!a1 || !strcmp(a0, a1)) {
495  snprintf(ret, sizeof(ret), "tmp = %s; %s = %s; %s = tmp", r0, r0, a0, a0);
496  } else {
497  snprintf(ret, sizeof(ret), "%s = %s ^ %s", r0, a0, a1);
498  }
499  break;
504  RZ_LOG_DEBUG("Command not implemented.\n");
505  free(r0);
506  free(a0);
507  free(a1);
508  return NULL;
509  default:
510  free(r0);
511  free(a0);
512  free(a1);
513  return NULL;
514  }
515  free(r0);
516  free(a0);
517  free(a1);
518  return strdup(ret);
519 }
520 
522  switch (s) {
524  return "null";
526  return "nop";
528  return "inc";
530  return "get";
532  return "set";
534  return "reset";
535  }
536  return "unk";
537 }
538 
539 static const struct {
540  int id;
541  const char *name;
542 } op_families[] = {
543  { RZ_ANALYSIS_OP_FAMILY_CPU, "cpu" },
544  { RZ_ANALYSIS_OP_FAMILY_FPU, "fpu" },
545  { RZ_ANALYSIS_OP_FAMILY_MMX, "mmx" },
546  { RZ_ANALYSIS_OP_FAMILY_SSE, "sse" },
547  { RZ_ANALYSIS_OP_FAMILY_PRIV, "priv" },
548  { RZ_ANALYSIS_OP_FAMILY_VIRT, "virt" },
549  { RZ_ANALYSIS_OP_FAMILY_CRYPTO, "crpt" },
550  { RZ_ANALYSIS_OP_FAMILY_IO, "io" },
552  { RZ_ANALYSIS_OP_FAMILY_THREAD, "thread" },
553 };
554 
561  int i;
562 
563  for (i = 0; i < RZ_ARRAY_SIZE(op_families); i++) {
564  if (op_families[i].id == id) {
565  return op_families[i].name;
566  }
567  }
568  return NULL;
569 }
570 
577  int i;
579  for (i = 0; i < RZ_ARRAY_SIZE(op_families); i++) {
580  if (!strcmp(name, op_families[i].name)) {
581  return op_families[i].id;
582  }
583  }
585 }
586 
587 /* apply hint to op, return the number of hints applied */
589  int changes = 0;
590  if (hint) {
591  if (hint->val != UT64_MAX) {
592  op->val = hint->val;
593  changes++;
594  }
595  if (hint->type > 0) {
596  op->type = hint->type;
597  changes++;
598  }
599  if (hint->jump != UT64_MAX) {
600  op->jump = hint->jump;
601  changes++;
602  }
603  if (hint->fail != UT64_MAX) {
604  op->fail = hint->fail;
605  changes++;
606  }
607  if (hint->opcode) {
608  /* XXX: this is not correct */
609  free(op->mnemonic);
610  op->mnemonic = strdup(hint->opcode);
611  changes++;
612  }
613  if (hint->esil) {
614  rz_strbuf_set(&op->esil, hint->esil);
615  changes++;
616  }
617  if (hint->size) {
618  op->size = hint->size;
619  changes++;
620  }
621  }
622  return changes;
623 }
624 
625 // returns the '33' in 'rax + 33'
626 // returns value for the given register name in specific address / range
627 RZ_API int rz_analysis_op_reg_delta(RzAnalysis *analysis, ut64 addr, const char *name) {
628  int delta = 0;
629  ut8 buf[32];
630  analysis->iob.read_at(analysis->iob.io, addr, buf, sizeof(buf));
633  if (rz_analysis_op(analysis, &op, addr, buf, sizeof(buf), RZ_ANALYSIS_OP_MASK_ALL) > 0) {
634  if (op.dst && op.dst->reg && op.dst->reg->name && (!name || !strcmp(op.dst->reg->name, name))) {
635  if (op.src[0]) {
636  delta = op.src[0]->delta;
637  }
638  }
639  }
641  return delta;
642 }
size_t len
Definition: 6502dis.c:15
ut8 op
Definition: 6502dis.c:13
RZ_API char * rz_analysis_value_to_string(RzAnalysisValue *value)
Definition: value.c:83
RZ_API void rz_analysis_value_free(RzAnalysisValue *value)
Definition: value.c:29
RZ_API RzAnalysisValue * rz_analysis_value_copy(RzAnalysisValue *ov)
Definition: value.c:15
#define mask()
lzma_index ** i
Definition: index.h:629
ut16 val
Definition: armass64_const.h:6
RZ_API RzAnalysisBlock * rz_analysis_find_most_relevant_block_in(RzAnalysis *analysis, ut64 off)
Definition: block.c:997
RZ_API char * rz_analysis_cond_to_string(RzAnalysisCond *cond)
Definition: cond.c:63
#define RZ_API
#define NULL
Definition: cris-opc.c:27
RZ_DEPRECATE RZ_API RzAnalysisFunction * rz_analysis_get_fcn_in(RzAnalysis *analysis, ut64 addr, int type)
Definition: fcn.c:1687
RZ_API RzAnalysisHint * rz_analysis_hint_get(RzAnalysis *a, ut64 addr)
Definition: hint.c:506
RZ_API void rz_analysis_hint_free(RzAnalysisHint *h)
Definition: hint.c:371
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API void rz_il_op_effect_free(RZ_NULLABLE RzILOpEffect *op)
Definition: il_opcodes.c:1036
a0
Definition: insn-good.s.cs:704
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
int type
Definition: mipsasm.c:17
RZ_API int rz_analysis_op_reg_delta(RzAnalysis *analysis, ut64 addr, const char *name)
Definition: op.c:627
const char * name
Definition: op.c:541
RZ_API RzAnalysisOp * rz_analysis_op_copy(RzAnalysisOp *op)
Definition: op.c:144
RZ_API void rz_analysis_op_free(void *op)
Definition: op.c:61
RZ_API bool rz_analysis_op_fini(RzAnalysisOp *op)
Definition: op.c:37
RZ_API char * rz_analysis_op_to_string(RzAnalysis *analysis, RzAnalysisOp *op)
Definition: op.c:334
RZ_API int rz_analysis_op_hint(RzAnalysisOp *op, RzAnalysisHint *hint)
Definition: op.c:588
RZ_API const char * rz_analysis_optype_to_string(int type)
Definition: op.c:310
static int defaultCycles(RzAnalysisOp *op)
Definition: op.c:70
int id
Definition: op.c:540
RZ_API bool rz_analysis_op_nonlinear(int t)
Definition: op.c:177
static const struct @7 op_families[]
RZ_API int rz_analysis_optype_from_string(RZ_NONNULL const char *name)
Definition: op.c:294
RZ_API const char * rz_analysis_op_to_esil_string(RzAnalysis *analysis, RzAnalysisOp *op)
Definition: op.c:329
RZ_API RzAnalysisOp * rz_analysis_op_new(void)
Definition: op.c:9
RZ_API void rz_analysis_op_init(RzAnalysisOp *op)
Definition: op.c:23
RZ_API int rz_analysis_op_family_from_string(RZ_NONNULL const char *name)
Definition: op.c:576
RZ_API const char * rz_analysis_stackop_tostring(int s)
Definition: op.c:521
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
Definition: op.c:96
RZ_API const char * rz_analysis_op_family_to_string(int id)
Definition: op.c:560
static struct optype optypes[]
RZ_API bool rz_analysis_op_ismemref(int t)
Definition: op.c:208
RZ_API RzList * rz_analysis_op_list_new(void)
Definition: op.c:15
static RzSocket * s
Definition: rtr.c:28
@ RZ_ANALYSIS_FCN_TYPE_NULL
Definition: rz_analysis.h:192
@ RZ_ANALYSIS_STACK_RESET
Definition: rz_analysis.h:460
@ RZ_ANALYSIS_STACK_SET
Definition: rz_analysis.h:459
@ RZ_ANALYSIS_STACK_GET
Definition: rz_analysis.h:458
@ RZ_ANALYSIS_STACK_NULL
Definition: rz_analysis.h:455
@ RZ_ANALYSIS_STACK_INC
Definition: rz_analysis.h:457
@ RZ_ANALYSIS_STACK_NOP
Definition: rz_analysis.h:456
@ RZ_ANALYSIS_OP_FAMILY_FPU
Definition: rz_analysis.h:313
@ RZ_ANALYSIS_OP_FAMILY_THREAD
Definition: rz_analysis.h:318
@ RZ_ANALYSIS_OP_FAMILY_CRYPTO
Definition: rz_analysis.h:317
@ RZ_ANALYSIS_OP_FAMILY_SSE
Definition: rz_analysis.h:315
@ RZ_ANALYSIS_OP_FAMILY_UNKNOWN
Definition: rz_analysis.h:311
@ RZ_ANALYSIS_OP_FAMILY_PRIV
Definition: rz_analysis.h:316
@ RZ_ANALYSIS_OP_FAMILY_CPU
Definition: rz_analysis.h:312
@ RZ_ANALYSIS_OP_FAMILY_MMX
Definition: rz_analysis.h:314
@ RZ_ANALYSIS_OP_FAMILY_VIRT
Definition: rz_analysis.h:319
@ RZ_ANALYSIS_OP_FAMILY_IO
Definition: rz_analysis.h:321
@ RZ_ANALYSIS_OP_FAMILY_SECURITY
Definition: rz_analysis.h:320
RzAnalysisOpMask
Definition: rz_analysis.h:439
@ RZ_ANALYSIS_OP_MASK_DISASM
Definition: rz_analysis.h:445
@ RZ_ANALYSIS_OP_MASK_ALL
Definition: rz_analysis.h:447
@ RZ_ANALYSIS_OP_MASK_HINT
Definition: rz_analysis.h:443
#define RZ_ANALYSIS_OP_TYPE_MASK
Definition: rz_analysis.h:358
@ RZ_ANALYSIS_OP_TYPE_CMP
Definition: rz_analysis.h:399
@ RZ_ANALYSIS_OP_TYPE_SUB
Definition: rz_analysis.h:402
@ RZ_ANALYSIS_OP_TYPE_ICALL
Definition: rz_analysis.h:381
@ RZ_ANALYSIS_OP_TYPE_LOAD
Definition: rz_analysis.h:416
@ RZ_ANALYSIS_OP_TYPE_CRYPTO
Definition: rz_analysis.h:430
@ RZ_ANALYSIS_OP_TYPE_UNK
Definition: rz_analysis.h:388
@ RZ_ANALYSIS_OP_TYPE_MUL
Definition: rz_analysis.h:404
@ RZ_ANALYSIS_OP_TYPE_ROL
Definition: rz_analysis.h:420
@ RZ_ANALYSIS_OP_TYPE_CASE
Definition: rz_analysis.h:424
@ RZ_ANALYSIS_OP_TYPE_JMP
Definition: rz_analysis.h:368
@ RZ_ANALYSIS_OP_TYPE_REP
Definition: rz_analysis.h:363
@ RZ_ANALYSIS_OP_TYPE_AND
Definition: rz_analysis.h:411
@ RZ_ANALYSIS_OP_TYPE_SAL
Definition: rz_analysis.h:408
@ RZ_ANALYSIS_OP_TYPE_SYNC
Definition: rz_analysis.h:431
@ RZ_ANALYSIS_OP_TYPE_MOD
Definition: rz_analysis.h:422
@ RZ_ANALYSIS_OP_TYPE_UPUSH
Definition: rz_analysis.h:395
@ RZ_ANALYSIS_OP_TYPE_RPUSH
Definition: rz_analysis.h:396
@ RZ_ANALYSIS_OP_TYPE_UJMP
Definition: rz_analysis.h:369
@ RZ_ANALYSIS_OP_TYPE_IJMP
Definition: rz_analysis.h:371
@ RZ_ANALYSIS_OP_TYPE_IO
Definition: rz_analysis.h:403
@ RZ_ANALYSIS_OP_TYPE_UCCALL
Definition: rz_analysis.h:384
@ RZ_ANALYSIS_OP_TYPE_MJMP
Definition: rz_analysis.h:375
@ RZ_ANALYSIS_OP_TYPE_ROR
Definition: rz_analysis.h:419
@ RZ_ANALYSIS_OP_TYPE_SWI
Definition: rz_analysis.h:393
@ RZ_ANALYSIS_OP_TYPE_SAR
Definition: rz_analysis.h:409
@ RZ_ANALYSIS_OP_TYPE_NULL
Definition: rz_analysis.h:367
@ RZ_ANALYSIS_OP_TYPE_CMOV
Definition: rz_analysis.h:391
@ RZ_ANALYSIS_OP_TYPE_LEAVE
Definition: rz_analysis.h:418
@ RZ_ANALYSIS_OP_TYPE_TRAP
Definition: rz_analysis.h:392
@ RZ_ANALYSIS_OP_TYPE_XCHG
Definition: rz_analysis.h:421
@ RZ_ANALYSIS_OP_TYPE_CCALL
Definition: rz_analysis.h:383
@ RZ_ANALYSIS_OP_TYPE_CALL
Definition: rz_analysis.h:378
@ RZ_ANALYSIS_OP_TYPE_ADD
Definition: rz_analysis.h:401
@ RZ_ANALYSIS_OP_TYPE_SWITCH
Definition: rz_analysis.h:423
@ RZ_ANALYSIS_OP_TYPE_OR
Definition: rz_analysis.h:410
@ RZ_ANALYSIS_OP_TYPE_STORE
Definition: rz_analysis.h:415
@ RZ_ANALYSIS_OP_TYPE_CPL
Definition: rz_analysis.h:429
@ RZ_ANALYSIS_OP_TYPE_CRET
Definition: rz_analysis.h:386
@ RZ_ANALYSIS_OP_TYPE_PUSH
Definition: rz_analysis.h:397
@ RZ_ANALYSIS_OP_TYPE_SHR
Definition: rz_analysis.h:406
@ RZ_ANALYSIS_OP_TYPE_IRJMP
Definition: rz_analysis.h:372
@ RZ_ANALYSIS_OP_TYPE_POP
Definition: rz_analysis.h:398
@ RZ_ANALYSIS_OP_TYPE_RJMP
Definition: rz_analysis.h:370
@ RZ_ANALYSIS_OP_TYPE_CJMP
Definition: rz_analysis.h:373
@ RZ_ANALYSIS_OP_TYPE_DIV
Definition: rz_analysis.h:405
@ RZ_ANALYSIS_OP_TYPE_CSWI
Definition: rz_analysis.h:394
@ RZ_ANALYSIS_OP_TYPE_CAST
Definition: rz_analysis.h:426
@ RZ_ANALYSIS_OP_TYPE_UCJMP
Definition: rz_analysis.h:377
@ RZ_ANALYSIS_OP_TYPE_MOV
Definition: rz_analysis.h:390
@ RZ_ANALYSIS_OP_TYPE_SHL
Definition: rz_analysis.h:407
@ RZ_ANALYSIS_OP_TYPE_ILL
Definition: rz_analysis.h:387
@ RZ_ANALYSIS_OP_TYPE_UCALL
Definition: rz_analysis.h:379
@ RZ_ANALYSIS_OP_TYPE_NOT
Definition: rz_analysis.h:414
@ RZ_ANALYSIS_OP_TYPE_RET
Definition: rz_analysis.h:385
@ RZ_ANALYSIS_OP_TYPE_NOP
Definition: rz_analysis.h:389
@ RZ_ANALYSIS_OP_TYPE_ACMP
Definition: rz_analysis.h:400
@ RZ_ANALYSIS_OP_TYPE_LEA
Definition: rz_analysis.h:417
@ RZ_ANALYSIS_OP_TYPE_RCALL
Definition: rz_analysis.h:380
@ RZ_ANALYSIS_OP_TYPE_XOR
Definition: rz_analysis.h:412
@ RZ_ANALYSIS_OP_TYPE_NEW
Definition: rz_analysis.h:427
@ RZ_ANALYSIS_OP_TYPE_IRCALL
Definition: rz_analysis.h:382
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_LOG_DEBUG(fmtstr,...)
Definition: rz_log.h:49
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
Definition: strbuf.c:153
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
Definition: strbuf.c:321
RZ_API bool rz_strbuf_copy(RzStrBuf *dst, RzStrBuf *src)
Definition: strbuf.c:48
RZ_API void rz_strbuf_fini(RzStrBuf *sb)
Definition: strbuf.c:365
RZ_API void rz_strbuf_init(RzStrBuf *sb)
Definition: strbuf.c:33
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_NEW(x)
Definition: rz_types.h:285
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define RZ_FREE(x)
Definition: rz_types.h:369
#define PFMT64x
Definition: rz_types.h:393
#define RZ_MIN(x, y)
#define UT64_MAX
Definition: rz_types_base.h:86
#define f(i)
Definition: sha256.c:46
Definition: z80asm.h:102
Definition: op.c:222
const char * name
Definition: op.c:224
int type
Definition: op.c:223
RzAnalysisCond * cond
Definition: rz_analysis.h:873
RzAnalysisValue * dst
Definition: rz_analysis.h:840
RzAnalysisValue * src[3]
Definition: rz_analysis.h:839
RzAnalysisOpCallback op
Definition: rz_analysis.h:1257
struct rz_analysis_plugin_t * cur
Definition: rz_analysis.h:586
RzIOBind iob
Definition: rz_analysis.h:574
RzCoreBind coreb
Definition: rz_analysis.h:580
void * core
Definition: rz_bind.h:31
RzCoreSeekArchBits archbits
Definition: rz_bind.h:42
RzIOReadAt read_at
Definition: rz_io.h:240
RzIO * io
Definition: rz_io.h:232
RZ_API void rz_analysis_switch_op_free(RzAnalysisSwitchOp *swop)
Definition: switch.c:42
Definition: dis.c:32
static st64 delta
Definition: vmenus.c:2425
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58