Rizin
unix-like reverse engineering framework and cli tools
hint.c File Reference
#include <rz_analysis.h>

Go to the source code of this file.

Classes

struct  rz_analysis_ranged_hint_record_base_t
 
struct  rz_analysis_arch_hint_record_t
 
struct  rz_analysis_bits_hint_record_t
 
struct  DeleteRangeCtx
 
struct  AddrHintForeachCtx
 

Macros

#define SET_HINT(type, setcode)
 

Typedefs

typedef struct rz_analysis_ranged_hint_record_base_t RzAnalysisRangedHintRecordBase
 
typedef struct rz_analysis_arch_hint_record_t RzAnalysisArchHintRecord
 
typedef struct rz_analysis_bits_hint_record_t RzAnalysisBitsHintRecord
 

Functions

static int ranged_hint_record_cmp (const void *incoming, const RBNode *in_tree, void *user)
 
static void addr_hint_record_fini (void *element, void *user)
 
static void addr_hint_record_ht_free (HtUPKv *kv)
 
static void bits_hint_record_free_rb (RBNode *node, void *user)
 
static void arch_hint_record_free_rb (RBNode *node, void *user)
 
void rz_analysis_hint_storage_init (RzAnalysis *a)
 
void rz_analysis_hint_storage_fini (RzAnalysis *a)
 
RZ_API void rz_analysis_hint_clear (RzAnalysis *a)
 
static bool addr_hint_range_delete_cb (void *user, const ut64 key, const void *value)
 
RZ_API void rz_analysis_hint_del (RzAnalysis *a, ut64 addr, ut64 size)
 
static void unset_addr_hint_record (RzAnalysis *analysis, RzAnalysisAddrHintType type, ut64 addr)
 
static RzAnalysisAddrHintRecordensure_addr_hint_record (RzAnalysis *analysis, RzAnalysisAddrHintType type, ut64 addr)
 
static RzAnalysisRangedHintRecordBaseensure_ranged_hint_record (RBTree *tree, ut64 addr, size_t sz)
 
RZ_API void rz_analysis_hint_set_offset (RzAnalysis *a, ut64 addr, const char *typeoff)
 
RZ_API void rz_analysis_hint_set_nword (RzAnalysis *a, ut64 addr, int nword)
 
RZ_API void rz_analysis_hint_set_jump (RzAnalysis *a, ut64 addr, ut64 jump)
 
RZ_API void rz_analysis_hint_set_fail (RzAnalysis *a, ut64 addr, ut64 fail)
 
RZ_API void rz_analysis_hint_set_newbits (RzAnalysis *a, ut64 addr, int bits)
 
RZ_API void rz_analysis_hint_set_high (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_set_immbase (RzAnalysis *a, ut64 addr, int base)
 
RZ_API void rz_analysis_hint_set_pointer (RzAnalysis *a, ut64 addr, ut64 ptr)
 
RZ_API void rz_analysis_hint_set_ret (RzAnalysis *a, ut64 addr, ut64 val)
 
RZ_API void rz_analysis_hint_set_syntax (RzAnalysis *a, ut64 addr, const char *syn)
 
RZ_API void rz_analysis_hint_set_opcode (RzAnalysis *a, ut64 addr, const char *opcode)
 
RZ_API void rz_analysis_hint_set_esil (RzAnalysis *a, ut64 addr, const char *esil)
 
RZ_API void rz_analysis_hint_set_type (RzAnalysis *a, ut64 addr, int type)
 
RZ_API void rz_analysis_hint_set_size (RzAnalysis *a, ut64 addr, ut64 size)
 
RZ_API void rz_analysis_hint_set_stackframe (RzAnalysis *a, ut64 addr, ut64 size)
 
RZ_API void rz_analysis_hint_set_val (RzAnalysis *a, ut64 addr, ut64 v)
 
RZ_API void rz_analysis_hint_set_arch (RzAnalysis *a, ut64 addr, RZ_NULLABLE const char *arch)
 
RZ_API void rz_analysis_hint_set_bits (RzAnalysis *a, ut64 addr, int bits)
 
RZ_API void rz_analysis_hint_unset_size (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_esil (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_opcode (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_high (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_immbase (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_nword (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_syntax (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_pointer (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_ret (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_offset (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_jump (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_fail (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_newbits (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_val (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_type (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_stackframe (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_arch (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_unset_bits (RzAnalysis *a, ut64 addr)
 
RZ_API void rz_analysis_hint_free (RzAnalysisHint *h)
 
RZ_API RZ_NULLABLE RZ_BORROW const char * rz_analysis_hint_arch_at (RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr)
 
RZ_API int rz_analysis_hint_bits_at (RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr)
 
RZ_API RZ_NULLABLE const RzVectorrz_analysis_addr_hints_at (RzAnalysis *analysis, ut64 addr)
 
static bool addr_hint_foreach_cb (void *user, const ut64 key, const void *value)
 
RZ_API void rz_analysis_addr_hints_foreach (RzAnalysis *analysis, RzAnalysisAddrHintRecordsCb cb, void *user)
 
RZ_API void rz_analysis_arch_hints_foreach (RzAnalysis *analysis, RzAnalysisArchHintCb cb, void *user)
 
RZ_API void rz_analysis_bits_hints_foreach (RzAnalysis *analysis, RzAnalysisBitsHintCb cb, void *user)
 
static void hint_merge (RzAnalysisHint *hint, RzAnalysisAddrHintRecord *record)
 
RZ_API RzAnalysisHintrz_analysis_hint_get (RzAnalysis *a, ut64 addr)
 

Macro Definition Documentation

◆ SET_HINT

#define SET_HINT (   type,
  setcode 
)
Value:
do { \
RzAnalysisAddrHintRecord *r = ensure_addr_hint_record(a, type, addr); \
if (!r) { \
break; \
} \
setcode \
} while (0)
#define r
Definition: crypto_rc6.c:12
static RzAnalysisAddrHintRecord * ensure_addr_hint_record(RzAnalysis *analysis, RzAnalysisAddrHintType type, ut64 addr)
Definition: hint.c:157
int type
Definition: mipsasm.c:17
#define a(i)
Definition: sha256.c:41
static int addr
Definition: z80asm.c:58

Definition at line 179 of file hint.c.

Typedef Documentation

◆ RzAnalysisArchHintRecord

◆ RzAnalysisBitsHintRecord

◆ RzAnalysisRangedHintRecordBase

Function Documentation

◆ addr_hint_foreach_cb()

static bool addr_hint_foreach_cb ( void *  user,
const ut64  key,
const void *  value 
)
static

Definition at line 421 of file hint.c.

421  {
422  AddrHintForeachCtx *ctx = user;
423  return ctx->cb(key, value, ctx->user);
424 }
static int value
Definition: cmd_api.c:93
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 static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118

References key, and value.

Referenced by rz_analysis_addr_hints_foreach().

◆ addr_hint_range_delete_cb()

static bool addr_hint_range_delete_cb ( void *  user,
const ut64  key,
const void *  value 
)
static

Definition at line 96 of file hint.c.

96  {
97  DeleteRangeCtx *ctx = user;
98  if (key < ctx->addr || key >= ctx->addr + ctx->size) {
99  return true;
100  }
101  ht_up_delete(ctx->ht, key);
102  return true;
103 }

References addr, and key.

Referenced by rz_analysis_hint_del().

◆ addr_hint_record_fini()

static void addr_hint_record_fini ( void *  element,
void *  user 
)
static

Definition at line 36 of file hint.c.

36  {
37  (void)user;
39  switch (record->type) {
41  free(record->type_offset);
42  break;
44  free(record->syntax);
45  break;
47  free(record->opcode);
48  break;
50  free(record->esil);
51  break;
52  default:
53  break;
54  }
55 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
@ RZ_ANALYSIS_ADDR_HINT_TYPE_SYNTAX
Definition: rz_analysis.h:639
@ RZ_ANALYSIS_ADDR_HINT_TYPE_ESIL
Definition: rz_analysis.h:643
@ RZ_ANALYSIS_ADDR_HINT_TYPE_TYPE_OFFSET
Definition: rz_analysis.h:642
@ RZ_ANALYSIS_ADDR_HINT_TYPE_OPCODE
Definition: rz_analysis.h:641
Definition: tar.h:52

References free(), RZ_ANALYSIS_ADDR_HINT_TYPE_ESIL, RZ_ANALYSIS_ADDR_HINT_TYPE_OPCODE, RZ_ANALYSIS_ADDR_HINT_TYPE_SYNTAX, and RZ_ANALYSIS_ADDR_HINT_TYPE_TYPE_OFFSET.

Referenced by ensure_addr_hint_record(), and unset_addr_hint_record().

◆ addr_hint_record_ht_free()

static void addr_hint_record_ht_free ( HtUPKv *  kv)
static

Definition at line 57 of file hint.c.

57  {
58  rz_vector_free(kv->value);
59 }
RZ_API void rz_vector_free(RzVector *vec)
Definition: vector.c:75

References rz_vector_free().

Referenced by rz_analysis_hint_storage_init().

◆ arch_hint_record_free_rb()

static void arch_hint_record_free_rb ( RBNode node,
void *  user 
)
static

Definition at line 65 of file hint.c.

References container_of, and free().

Referenced by rz_analysis_hint_storage_fini(), and rz_analysis_hint_unset_arch().

◆ bits_hint_record_free_rb()

static void bits_hint_record_free_rb ( RBNode node,
void *  user 
)
static

Definition at line 61 of file hint.c.

61  {
63 }

References container_of, and free().

Referenced by rz_analysis_hint_storage_fini(), and rz_analysis_hint_unset_bits().

◆ ensure_addr_hint_record()

static RzAnalysisAddrHintRecord* ensure_addr_hint_record ( RzAnalysis analysis,
RzAnalysisAddrHintType  type,
ut64  addr 
)
static

Definition at line 157 of file hint.c.

157  {
158  RzVector *records = ht_up_find(analysis->addr_hints, addr, NULL);
159  if (!records) {
161  if (!records) {
162  return NULL;
163  }
164  ht_up_insert(analysis->addr_hints, addr, records);
165  }
166  void *pos;
167  rz_vector_foreach(records, pos) {
169  if (record->type == type) {
170  return record;
171  }
172  }
174  memset(record, 0, sizeof(*record));
175  record->type = type;
176  return record;
177 }
#define NULL
Definition: cris-opc.c:27
static void addr_hint_record_fini(void *element, void *user)
Definition: hint.c:36
return memset(p, 0, total)
RZ_API void * rz_vector_push(RzVector *vec, void *x)
Definition: vector.c:197
#define rz_vector_foreach(vec, it)
Definition: rz_vector.h:169
RZ_API RzVector * rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user)
Definition: vector.c:42
HtUP * addr_hints
Definition: rz_analysis.h:596
int pos
Definition: main.c:11

References addr, addr_hint_record_fini(), rz_analysis_t::addr_hints, memset(), NULL, pos, rz_vector_foreach, rz_vector_new(), rz_vector_push(), and type.

◆ ensure_ranged_hint_record()

static RzAnalysisRangedHintRecordBase* ensure_ranged_hint_record ( RBTree tree,
ut64  addr,
size_t  sz 
)
static

Definition at line 188 of file hint.c.

188  {
190  if (node) {
192  }
194  memset(record, 0, sz);
195  if (!record) {
196  return NULL;
197  }
198  record->addr = addr;
200  return record;
201 }
static int ranged_hint_record_cmp(const void *incoming, const RBNode *in_tree, void *user)
Definition: hint.c:25
void * malloc(size_t size)
Definition: malloc.c:123
RZ_API RBNode * rz_rbtree_find(RBNode *root, void *data, RBComparator cmp, void *user)
Definition: rbtree.c:267
RZ_API bool rz_rbtree_insert(RBNode **root, void *data, RBNode *node, RBComparator cmp, void *user)
Returns true if the node was inserted successfully.
Definition: rbtree.c:291

References addr, container_of, malloc(), memset(), NULL, ranged_hint_record_cmp(), rz_rbtree_find(), and rz_rbtree_insert().

Referenced by rz_analysis_hint_set_arch(), and rz_analysis_hint_set_bits().

◆ hint_merge()

static void hint_merge ( RzAnalysisHint hint,
RzAnalysisAddrHintRecord record 
)
static

Definition at line 453 of file hint.c.

453  {
454  switch (record->type) {
456  hint->immbase = record->immbase;
457  break;
459  hint->jump = record->jump;
460  break;
462  hint->fail = record->fail;
463  break;
465  hint->stackframe = record->stackframe;
466  break;
468  hint->ptr = record->ptr;
469  break;
471  hint->nword = record->nword;
472  break;
474  hint->ret = record->retval;
475  break;
477  hint->new_bits = record->newbits;
478  break;
480  hint->size = record->size;
481  break;
483  hint->syntax = record->syntax ? strdup(record->syntax) : NULL;
484  break;
486  hint->type = record->optype;
487  break;
489  hint->opcode = record->opcode ? strdup(record->opcode) : NULL;
490  break;
492  hint->offset = record->type_offset ? strdup(record->type_offset) : NULL;
493  break;
495  hint->esil = record->esil ? strdup(record->esil) : NULL;
496  break;
498  hint->high = true;
499  break;
501  hint->val = record->val;
502  break;
503  }
504 }
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")
@ RZ_ANALYSIS_ADDR_HINT_TYPE_PTR
Definition: rz_analysis.h:634
@ RZ_ANALYSIS_ADDR_HINT_TYPE_SIZE
Definition: rz_analysis.h:638
@ RZ_ANALYSIS_ADDR_HINT_TYPE_STACKFRAME
Definition: rz_analysis.h:633
@ RZ_ANALYSIS_ADDR_HINT_TYPE_HIGH
Definition: rz_analysis.h:644
@ RZ_ANALYSIS_ADDR_HINT_TYPE_NEW_BITS
Definition: rz_analysis.h:637
@ RZ_ANALYSIS_ADDR_HINT_TYPE_JUMP
Definition: rz_analysis.h:631
@ RZ_ANALYSIS_ADDR_HINT_TYPE_OPTYPE
Definition: rz_analysis.h:640
@ RZ_ANALYSIS_ADDR_HINT_TYPE_RET
Definition: rz_analysis.h:636
@ RZ_ANALYSIS_ADDR_HINT_TYPE_IMMBASE
Definition: rz_analysis.h:630
@ RZ_ANALYSIS_ADDR_HINT_TYPE_NWORD
Definition: rz_analysis.h:635
@ RZ_ANALYSIS_ADDR_HINT_TYPE_FAIL
Definition: rz_analysis.h:632
@ RZ_ANALYSIS_ADDR_HINT_TYPE_VAL
Definition: rz_analysis.h:645

References rz_analysis_hint_t::esil, rz_analysis_hint_t::fail, rz_analysis_hint_t::high, rz_analysis_hint_t::immbase, rz_analysis_hint_t::jump, rz_analysis_hint_t::new_bits, NULL, rz_analysis_hint_t::nword, rz_analysis_hint_t::offset, rz_analysis_hint_t::opcode, rz_analysis_hint_t::ptr, rz_analysis_hint_t::ret, RZ_ANALYSIS_ADDR_HINT_TYPE_ESIL, RZ_ANALYSIS_ADDR_HINT_TYPE_FAIL, RZ_ANALYSIS_ADDR_HINT_TYPE_HIGH, RZ_ANALYSIS_ADDR_HINT_TYPE_IMMBASE, RZ_ANALYSIS_ADDR_HINT_TYPE_JUMP, RZ_ANALYSIS_ADDR_HINT_TYPE_NEW_BITS, RZ_ANALYSIS_ADDR_HINT_TYPE_NWORD, RZ_ANALYSIS_ADDR_HINT_TYPE_OPCODE, RZ_ANALYSIS_ADDR_HINT_TYPE_OPTYPE, RZ_ANALYSIS_ADDR_HINT_TYPE_PTR, RZ_ANALYSIS_ADDR_HINT_TYPE_RET, RZ_ANALYSIS_ADDR_HINT_TYPE_SIZE, RZ_ANALYSIS_ADDR_HINT_TYPE_STACKFRAME, RZ_ANALYSIS_ADDR_HINT_TYPE_SYNTAX, RZ_ANALYSIS_ADDR_HINT_TYPE_TYPE_OFFSET, RZ_ANALYSIS_ADDR_HINT_TYPE_VAL, rz_analysis_hint_t::size, rz_analysis_hint_t::stackframe, strdup(), rz_analysis_hint_t::syntax, rz_analysis_hint_t::type, and rz_analysis_hint_t::val.

Referenced by rz_analysis_hint_get().

◆ ranged_hint_record_cmp()

static int ranged_hint_record_cmp ( const void *  incoming,
const RBNode in_tree,
void *  user 
)
static

Definition at line 25 of file hint.c.

25  {
26  ut64 addr = *(const ut64 *)incoming;
27  const RzAnalysisRangedHintRecordBase *in_tree_record = container_of(in_tree, const RzAnalysisRangedHintRecordBase, rb);
28  if (addr < in_tree_record->addr) {
29  return -1;
30  } else if (addr > in_tree_record->addr) {
31  return 1;
32  }
33  return 0;
34 }
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References rz_analysis_ranged_hint_record_base_t::addr, addr, container_of, and ut64().

Referenced by ensure_ranged_hint_record(), rz_analysis_hint_arch_at(), rz_analysis_hint_bits_at(), rz_analysis_hint_del(), rz_analysis_hint_unset_arch(), and rz_analysis_hint_unset_bits().

◆ rz_analysis_addr_hints_at()

RZ_API RZ_NULLABLE const RzVector* rz_analysis_addr_hints_at ( RzAnalysis analysis,
ut64  addr 
)

Definition at line 412 of file hint.c.

412  {
413  return ht_up_find(analysis->addr_hints, addr, NULL);
414 }

References addr, rz_analysis_t::addr_hints, and NULL.

Referenced by rz_analysis_hint_get(), and rz_core_analysis_hint_print().

◆ rz_analysis_addr_hints_foreach()

RZ_API void rz_analysis_addr_hints_foreach ( RzAnalysis analysis,
RzAnalysisAddrHintRecordsCb  cb,
void *  user 
)

Definition at line 426 of file hint.c.

426  {
427  AddrHintForeachCtx ctx = { cb, user };
428  ht_up_foreach(analysis->addr_hints, addr_hint_foreach_cb, &ctx);
429 }
static bool addr_hint_foreach_cb(void *user, const ut64 key, const void *value)
Definition: hint.c:421
static const char * cb[]
Definition: z80_tab.h:176

References addr_hint_foreach_cb(), rz_analysis_t::addr_hints, and cb.

Referenced by rz_core_analysis_hint_list_print(), and rz_serialize_analysis_hints_save().

◆ rz_analysis_arch_hints_foreach()

RZ_API void rz_analysis_arch_hints_foreach ( RzAnalysis analysis,
RzAnalysisArchHintCb  cb,
void *  user 
)

Definition at line 431 of file hint.c.

431  {
432  RBIter iter;
435  bool cont = cb(record->addr, ((RzAnalysisArchHintRecord *)record)->arch, user);
436  if (!cont) {
437  break;
438  }
439  }
440 }
#define rz_rbtree_foreach(root, it, data, struc, rb)
Definition: rz_rbtree.h:101
RBTree arch_hints
Definition: rz_analysis.h:597

References rz_analysis_t::arch_hints, cb, and rz_rbtree_foreach.

Referenced by rz_core_analysis_hint_list_print(), and rz_serialize_analysis_hints_save().

◆ rz_analysis_bits_hints_foreach()

RZ_API void rz_analysis_bits_hints_foreach ( RzAnalysis analysis,
RzAnalysisBitsHintCb  cb,
void *  user 
)

Definition at line 442 of file hint.c.

442  {
443  RBIter iter;
446  bool cont = cb(record->addr, ((RzAnalysisBitsHintRecord *)record)->bits, user);
447  if (!cont) {
448  break;
449  }
450  }
451 }
RBTree bits_hints
Definition: rz_analysis.h:598

References rz_analysis_t::bits_hints, cb, and rz_rbtree_foreach.

Referenced by rz_core_analysis_hint_list_print(), and rz_serialize_analysis_hints_save().

◆ rz_analysis_hint_arch_at()

RZ_API RZ_NULLABLE RZ_BORROW const char* rz_analysis_hint_arch_at ( RzAnalysis analysis,
ut64  addr,
RZ_NULLABLE ut64 hint_addr 
)

Definition at line 382 of file hint.c.

382  {
384  if (!node) {
385  if (hint_addr) {
386  *hint_addr = UT64_MAX;
387  }
388  return NULL;
389  }
391  if (hint_addr) {
392  *hint_addr = record->base.addr;
393  }
394  return record->arch;
395 }
RZ_API RBNode * rz_rbtree_upper_bound(RBNode *root, void *data, RBComparator cmp, void *user)
Definition: rbtree.c:313
#define UT64_MAX
Definition: rz_types_base.h:86

References addr, rz_analysis_t::arch_hints, container_of, NULL, ranged_hint_record_cmp(), rz_rbtree_upper_bound(), and UT64_MAX.

Referenced by rz_analysis_hint_get(), rz_core_analysis_hint_print(), and rz_core_arch_bits_at().

◆ rz_analysis_hint_bits_at()

RZ_API int rz_analysis_hint_bits_at ( RzAnalysis analysis,
ut64  addr,
RZ_NULLABLE ut64 hint_addr 
)

Definition at line 397 of file hint.c.

397  {
399  if (!node) {
400  if (hint_addr) {
401  *hint_addr = UT64_MAX;
402  }
403  return 0;
404  }
406  if (hint_addr) {
407  *hint_addr = record->base.addr;
408  }
409  return record->bits;
410 }

References addr, rz_analysis_t::bits_hints, container_of, NULL, ranged_hint_record_cmp(), rz_rbtree_upper_bound(), and UT64_MAX.

Referenced by rz_analysis_hint_get(), rz_core_analysis_hint_print(), and rz_core_arch_bits_at().

◆ rz_analysis_hint_clear()

RZ_API void rz_analysis_hint_clear ( RzAnalysis a)

Definition at line 85 of file hint.c.

85  {
88 }
void rz_analysis_hint_storage_fini(RzAnalysis *a)
Definition: hint.c:79
void rz_analysis_hint_storage_init(RzAnalysis *a)
Definition: hint.c:72

References a, rz_analysis_hint_storage_fini(), and rz_analysis_hint_storage_init().

Referenced by rz_analysis_hint_del_all_handler(), rz_analysis_purge(), and rz_core_bin_update_arch_bits().

◆ rz_analysis_hint_del()

RZ_API void rz_analysis_hint_del ( RzAnalysis a,
ut64  addr,
ut64  size 
)

Definition at line 105 of file hint.c.

105  {
106  if (size <= 1) {
107  // only single address
108  ht_up_delete(a->addr_hints, addr);
111  return;
112  }
113  // ranged delete
114  DeleteRangeCtx ctx = { a->addr_hints, addr, size };
115  ht_up_foreach(a->addr_hints, addr_hint_range_delete_cb, &ctx);
116  while (true) { // arch
118  if (!node) {
119  return;
120  }
122  if (base->addr >= addr + size) {
123  break;
124  }
126  }
127  while (true) { // bits
129  if (!node) {
130  return;
131  }
133  if (base->addr >= addr + size) {
134  break;
135  }
137  }
138 }
RZ_API void rz_analysis_hint_unset_arch(RzAnalysis *a, ut64 addr)
Definition: hint.c:363
RZ_API void rz_analysis_hint_unset_bits(RzAnalysis *a, ut64 addr)
Definition: hint.c:367
static bool addr_hint_range_delete_cb(void *user, const ut64 key, const void *value)
Definition: hint.c:96
voidpf void uLong size
Definition: ioapi.h:138
RZ_API RBNode * rz_rbtree_lower_bound(RBNode *root, void *data, RBComparator cmp, void *user)
Definition: rbtree.c:295

References a, rz_analysis_ranged_hint_record_base_t::addr, addr, addr_hint_range_delete_cb(), container_of, NULL, ranged_hint_record_cmp(), rz_analysis_hint_unset_arch(), rz_analysis_hint_unset_bits(), and rz_rbtree_lower_bound().

Referenced by rz_analysis_hint_del_handler(), and wasm_op().

◆ rz_analysis_hint_free()

◆ rz_analysis_hint_get()

RZ_API RzAnalysisHint* rz_analysis_hint_get ( RzAnalysis a,
ut64  addr 
)

Definition at line 506 of file hint.c.

506  {
508  if (!hint) {
509  return NULL;
510  }
511  hint->addr = addr;
512  hint->jump = UT64_MAX;
513  hint->fail = UT64_MAX;
514  hint->ret = UT64_MAX;
515  hint->val = UT64_MAX;
516  hint->stackframe = UT64_MAX;
517  const RzVector *records = rz_analysis_addr_hints_at(a, addr);
518  if (records) {
520  rz_vector_foreach(records, record) {
521  hint_merge(hint, record);
522  }
523  }
524  const char *arch = rz_analysis_hint_arch_at(a, addr, NULL);
525  hint->arch = arch ? strdup(arch) : NULL;
527  if ((!records || rz_vector_empty(records)) && !hint->arch && !hint->bits) {
528  // no hints found
529  free(hint);
530  return NULL;
531  }
532  return hint;
533 }
cs_arch arch
Definition: cstool.c:13
RZ_API RZ_NULLABLE const RzVector * rz_analysis_addr_hints_at(RzAnalysis *analysis, ut64 addr)
Definition: hint.c:412
static void hint_merge(RzAnalysisHint *hint, RzAnalysisAddrHintRecord *record)
Definition: hint.c:453
RZ_API int rz_analysis_hint_bits_at(RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr)
Definition: hint.c:397
RZ_API RZ_NULLABLE RZ_BORROW const char * rz_analysis_hint_arch_at(RzAnalysis *analysis, ut64 addr, RZ_NULLABLE ut64 *hint_addr)
Definition: hint.c:382
#define RZ_NEW0(x)
Definition: rz_types.h:284
static bool rz_vector_empty(const RzVector *vec)
Definition: rz_vector.h:74

References a, addr, rz_analysis_hint_t::addr, rz_analysis_hint_t::arch, arch, rz_analysis_hint_t::bits, rz_analysis_hint_t::fail, free(), hint_merge(), rz_analysis_hint_t::jump, NULL, rz_analysis_hint_t::ret, rz_analysis_addr_hints_at(), rz_analysis_hint_arch_at(), rz_analysis_hint_bits_at(), RZ_NEW0, rz_vector_empty(), rz_vector_foreach, rz_analysis_hint_t::stackframe, strdup(), UT64_MAX, and rz_analysis_hint_t::val.

Referenced by __core_analysis_fcn(), _analysis_calls(), analysis_mask(), do_asm_search(), do_ref_search(), ds_print_core_vmode_jump_hit(), rotateAsmBits(), rz_analysis_bind(), rz_analysis_get_jmptbl_info(), rz_analysis_op(), rz_analysis_xrefs_from_list_handler(), rz_core_analysis_bytes(), rz_core_disasm_instruction(), rz_core_disasm_pdi_with_buf(), rz_core_hint_begin(), set_retval(), and wasm_op().

◆ rz_analysis_hint_set_arch()

RZ_API void rz_analysis_hint_set_arch ( RzAnalysis a,
ut64  addr,
RZ_NULLABLE const char *  arch 
)

Definition at line 279 of file hint.c.

279  {
281  if (!record) {
282  return;
283  }
284  free(record->arch);
285  record->arch = arch ? strdup(arch) : NULL;
286 }
static RzAnalysisRangedHintRecordBase * ensure_ranged_hint_record(RBTree *tree, ut64 addr, size_t sz)
Definition: hint.c:188

References a, addr, arch, ensure_ranged_hint_record(), free(), NULL, and strdup().

Referenced by rz_analysis_hint_set_arch_handler().

◆ rz_analysis_hint_set_bits()

RZ_API void rz_analysis_hint_set_bits ( RzAnalysis a,
ut64  addr,
int  bits 
)

Definition at line 288 of file hint.c.

288  {
290  if (!record) {
291  return;
292  }
293  record->bits = bits;
294  if (a->hint_cbs.on_bits) {
295  a->hint_cbs.on_bits(a, addr, bits, true);
296  }
297 }
int bits(struct state *s, int need)
Definition: blast.c:72

References a, addr, bits(), and ensure_ranged_hint_record().

Referenced by esilbreak_reg_write(), handle_arm_hint(), handle_arm_special_symbol(), handleHints(), rotateAsmBits(), run_basic_block_analysis(), rz_analysis_function_setbits_handler(), and rz_analysis_hint_set_bits_handler().

◆ rz_analysis_hint_set_esil()

RZ_API void rz_analysis_hint_set_esil ( RzAnalysis a,
ut64  addr,
const char *  esil 
)

Definition at line 257 of file hint.c.

257  {
259  free(r->esil);
260  r->esil = strdup(esil););
261 }
#define SET_HINT(type, setcode)
Definition: hint.c:179

References free(), r, RZ_ANALYSIS_ADDR_HINT_TYPE_ESIL, SET_HINT, and strdup().

Referenced by hints_load_cb(), and rz_analysis_hint_set_esil_handler().

◆ rz_analysis_hint_set_fail()

RZ_API void rz_analysis_hint_set_fail ( RzAnalysis a,
ut64  addr,
ut64  fail 
)

Definition at line 217 of file hint.c.

217  {
219 }
#define fail(test)
Definition: tests.h:29

References fail, r, RZ_ANALYSIS_ADDR_HINT_TYPE_FAIL, and SET_HINT.

Referenced by hints_load_cb(), and rz_analysis_hint_set_fail_handler().

◆ rz_analysis_hint_set_high()

RZ_API void rz_analysis_hint_set_high ( RzAnalysis a,
ut64  addr 
)

Definition at line 225 of file hint.c.

225  {
227 }

References RZ_ANALYSIS_ADDR_HINT_TYPE_HIGH, and SET_HINT.

Referenced by hints_load_cb(), and rz_analysis_hint_set_high_handler().

◆ rz_analysis_hint_set_immbase()

RZ_API void rz_analysis_hint_set_immbase ( RzAnalysis a,
ut64  addr,
int  base 
)

Definition at line 229 of file hint.c.

229  {
230  if (base) {
231  SET_HINT(RZ_ANALYSIS_ADDR_HINT_TYPE_IMMBASE, r->immbase = base;);
232  } else {
234  }
235 }
static void unset_addr_hint_record(RzAnalysis *analysis, RzAnalysisAddrHintType type, ut64 addr)
Definition: hint.c:140

References a, addr, r, RZ_ANALYSIS_ADDR_HINT_TYPE_IMMBASE, SET_HINT, and unset_addr_hint_record().

Referenced by apply_case(), hints_load_cb(), rz_analysis_hint_set_immbase_handler(), rz_analysis_walkthrough_casetbl(), and rz_core_visual_define().

◆ rz_analysis_hint_set_jump()

RZ_API void rz_analysis_hint_set_jump ( RzAnalysis a,
ut64  addr,
ut64  jump 
)

Definition at line 213 of file hint.c.

213  {
215 }
int jump(int a, int b)
Definition: bcj_test.c:35

References jump(), r, RZ_ANALYSIS_ADDR_HINT_TYPE_JUMP, and SET_HINT.

Referenced by hints_load_cb(), rz_analysis_hint_set_jump_handler(), and wasm_op().

◆ rz_analysis_hint_set_newbits()

RZ_API void rz_analysis_hint_set_newbits ( RzAnalysis a,
ut64  addr,
int  bits 
)

Definition at line 221 of file hint.c.

221  {
223 }

References bits(), r, RZ_ANALYSIS_ADDR_HINT_TYPE_NEW_BITS, and SET_HINT.

Referenced by hints_load_cb().

◆ rz_analysis_hint_set_nword()

RZ_API void rz_analysis_hint_set_nword ( RzAnalysis a,
ut64  addr,
int  nword 
)

Definition at line 209 of file hint.c.

209  {
210  SET_HINT(RZ_ANALYSIS_ADDR_HINT_TYPE_NWORD, r->nword = nword;);
211 }

References r, RZ_ANALYSIS_ADDR_HINT_TYPE_NWORD, and SET_HINT.

Referenced by hints_load_cb(), and rz_analysis_hint_set_immbase_handler().

◆ rz_analysis_hint_set_offset()

RZ_API void rz_analysis_hint_set_offset ( RzAnalysis a,
ut64  addr,
const char *  typeoff 
)

Definition at line 203 of file hint.c.

203  {
205  free(r->type_offset);
206  r->type_offset = strdup(typeoff););
207 }

References free(), r, RZ_ANALYSIS_ADDR_HINT_TYPE_TYPE_OFFSET, SET_HINT, and strdup().

Referenced by hints_load_cb(), rz_core_analysis_hint_set_offset(), and set_offset_hint().

◆ rz_analysis_hint_set_opcode()

RZ_API void rz_analysis_hint_set_opcode ( RzAnalysis a,
ut64  addr,
const char *  opcode 
)

Definition at line 251 of file hint.c.

251  {
253  free(r->opcode);
254  r->opcode = strdup(opcode););
255 }

References free(), r, RZ_ANALYSIS_ADDR_HINT_TYPE_OPCODE, SET_HINT, and strdup().

Referenced by hints_load_cb(), rz_analysis_hint_set_opcode_handler(), and wasm_op().

◆ rz_analysis_hint_set_pointer()

RZ_API void rz_analysis_hint_set_pointer ( RzAnalysis a,
ut64  addr,
ut64  ptr 
)

Definition at line 237 of file hint.c.

237  {
239 }

References r, RZ_ANALYSIS_ADDR_HINT_TYPE_PTR, and SET_HINT.

Referenced by hints_load_cb(), and rz_analysis_hint_set_ptr_handler().

◆ rz_analysis_hint_set_ret()

RZ_API void rz_analysis_hint_set_ret ( RzAnalysis a,
ut64  addr,
ut64  val 
)

Definition at line 241 of file hint.c.

241  {
243 }
ut16 val
Definition: armass64_const.h:6

References r, RZ_ANALYSIS_ADDR_HINT_TYPE_RET, SET_HINT, and val.

Referenced by hints_load_cb(), and rz_analysis_hint_set_ret_handler().

◆ rz_analysis_hint_set_size()

RZ_API void rz_analysis_hint_set_size ( RzAnalysis a,
ut64  addr,
ut64  size 
)

Definition at line 267 of file hint.c.

267  {
269 }

References r, RZ_ANALYSIS_ADDR_HINT_TYPE_SIZE, and SET_HINT.

Referenced by hints_load_cb(), rz_analysis_hint_set_size_handler(), and set_bin_relocs().

◆ rz_analysis_hint_set_stackframe()

RZ_API void rz_analysis_hint_set_stackframe ( RzAnalysis a,
ut64  addr,
ut64  size 
)

Definition at line 271 of file hint.c.

271  {
273 }

References r, RZ_ANALYSIS_ADDR_HINT_TYPE_STACKFRAME, and SET_HINT.

Referenced by hints_load_cb(), and rz_analysis_hint_set_stackframe_handler().

◆ rz_analysis_hint_set_syntax()

RZ_API void rz_analysis_hint_set_syntax ( RzAnalysis a,
ut64  addr,
const char *  syn 
)

Definition at line 245 of file hint.c.

245  {
247  free(r->syntax);
248  r->syntax = strdup(syn););
249 }

References free(), r, RZ_ANALYSIS_ADDR_HINT_TYPE_SYNTAX, SET_HINT, and strdup().

Referenced by hints_load_cb(), and rz_analysis_hint_set_syntax_handler().

◆ rz_analysis_hint_set_type()

RZ_API void rz_analysis_hint_set_type ( RzAnalysis a,
ut64  addr,
int  type 
)

Definition at line 263 of file hint.c.

263  {
265 }

References r, RZ_ANALYSIS_ADDR_HINT_TYPE_OPTYPE, SET_HINT, and type.

Referenced by hints_load_cb(), and rz_analysis_hint_set_optype_handler().

◆ rz_analysis_hint_set_val()

RZ_API void rz_analysis_hint_set_val ( RzAnalysis a,
ut64  addr,
ut64  v 
)

Definition at line 275 of file hint.c.

275  {
277 }
const char * v
Definition: dsignal.c:12

References r, RZ_ANALYSIS_ADDR_HINT_TYPE_VAL, SET_HINT, and v.

Referenced by hints_load_cb(), and rz_analysis_hint_set_val_handler().

◆ rz_analysis_hint_storage_fini()

void rz_analysis_hint_storage_fini ( RzAnalysis a)

Definition at line 79 of file hint.c.

79  {
80  ht_up_free(a->addr_hints);
83 }
static void arch_hint_record_free_rb(RBNode *node, void *user)
Definition: hint.c:65
static void bits_hint_record_free_rb(RBNode *node, void *user)
Definition: hint.c:61
RZ_API void rz_rbtree_free(RZ_NULLABLE RBNode *root, RBNodeFree freefn, void *user)
Definition: rbtree.c:281

References a, arch_hint_record_free_rb(), bits_hint_record_free_rb(), NULL, and rz_rbtree_free().

Referenced by rz_analysis_free(), and rz_analysis_hint_clear().

◆ rz_analysis_hint_storage_init()

void rz_analysis_hint_storage_init ( RzAnalysis a)

Definition at line 72 of file hint.c.

72  {
73  a->addr_hints = ht_up_new(NULL, addr_hint_record_ht_free, NULL);
74  a->arch_hints = NULL;
75  a->bits_hints = NULL;
76 }
static void addr_hint_record_ht_free(HtUPKv *kv)
Definition: hint.c:57

References a, addr_hint_record_ht_free(), and NULL.

Referenced by rz_analysis_hint_clear(), and rz_analysis_new().

◆ rz_analysis_hint_unset_arch()

RZ_API void rz_analysis_hint_unset_arch ( RzAnalysis a,
ut64  addr 
)

Definition at line 363 of file hint.c.

363  {
365 }
RZ_API bool rz_rbtree_delete(RBNode **root, void *data, RBComparator cmp, void *cmp_user, RBNodeFree freefn, void *free_user)
Returns true if a node with an equal key is deleted.
Definition: rbtree.c:263

References a, addr, arch_hint_record_free_rb(), NULL, ranged_hint_record_cmp(), and rz_rbtree_delete().

Referenced by rz_analysis_hint_del(), and rz_analysis_hint_del_arch_handler().

◆ rz_analysis_hint_unset_bits()

RZ_API void rz_analysis_hint_unset_bits ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_esil()

RZ_API void rz_analysis_hint_unset_esil ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_fail()

RZ_API void rz_analysis_hint_unset_fail ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_high()

RZ_API void rz_analysis_hint_unset_high ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_immbase()

RZ_API void rz_analysis_hint_unset_immbase ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_jump()

RZ_API void rz_analysis_hint_unset_jump ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_newbits()

RZ_API void rz_analysis_hint_unset_newbits ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_nword()

RZ_API void rz_analysis_hint_unset_nword ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_offset()

RZ_API void rz_analysis_hint_unset_offset ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_opcode()

RZ_API void rz_analysis_hint_unset_opcode ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_pointer()

RZ_API void rz_analysis_hint_unset_pointer ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_ret()

RZ_API void rz_analysis_hint_unset_ret ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_size()

RZ_API void rz_analysis_hint_unset_size ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_stackframe()

RZ_API void rz_analysis_hint_unset_stackframe ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_syntax()

RZ_API void rz_analysis_hint_unset_syntax ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_type()

RZ_API void rz_analysis_hint_unset_type ( RzAnalysis a,
ut64  addr 
)

◆ rz_analysis_hint_unset_val()

RZ_API void rz_analysis_hint_unset_val ( RzAnalysis a,
ut64  addr 
)

◆ unset_addr_hint_record()

static void unset_addr_hint_record ( RzAnalysis analysis,
RzAnalysisAddrHintType  type,
ut64  addr 
)
static