Rizin
unix-like reverse engineering framework and cli tools
zones.c File Reference
#include <rz_flag.h>
#include <rz_util.h>

Go to the source code of this file.

Functions

static RzFlagZoneItemrz_flag_zone_get (RzFlag *f, const char *name)
 
static RzFlagZoneItemrz_flag_zone_get_inrange (RzFlag *f, ut64 from, ut64 to)
 
RZ_API bool rz_flag_zone_add (RzFlag *f, const char *name, ut64 addr)
 
RZ_API bool rz_flag_zone_reset (RzFlag *f)
 
RZ_API bool rz_flag_zone_del (RzFlag *f, const char *name)
 
RZ_API void rz_flag_zone_item_free (void *a)
 
RZ_API bool rz_flag_zone_around (RzFlag *f, ut64 addr, const char **prev, const char **next)
 
RZ_API RzListrz_flag_zone_barlist (RzFlag *f, ut64 from, ut64 bsize, int rows)
 

Function Documentation

◆ rz_flag_zone_add()

RZ_API bool rz_flag_zone_add ( RzFlag f,
const char *  name,
ut64  addr 
)

Definition at line 29 of file zones.c.

29  {
30  rz_return_val_if_fail(f && name && *name, false);
32  if (zi) {
33  if (addr < zi->from) {
34  zi->from = addr;
35  }
36  if (addr > zi->to) {
37  zi->to = addr;
38  }
39  } else {
40  if (!f->zones) {
42  }
43  zi = RZ_NEW0(RzFlagZoneItem);
44  zi->name = strdup(name);
45  zi->from = zi->to = addr;
46  rz_list_append(f->zones, zi);
47  }
48  return true;
49 }
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
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")
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_NEW0(x)
Definition: rz_types.h:284
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
#define f(i)
Definition: sha256.c:46
Definition: z80asm.h:102
static int addr
Definition: z80asm.c:58
RZ_API bool rz_flag_zone_reset(RzFlag *f)
Definition: zones.c:51
static RzFlagZoneItem * rz_flag_zone_get(RzFlag *f, const char *name)
Definition: zones.c:7

References addr, f, rz_flag_zone_item_t::from, from, rz_flag_zone_item_t::name, rz_flag_zone_get(), rz_flag_zone_reset(), rz_list_append(), RZ_NEW0, rz_return_val_if_fail, strdup(), and rz_flag_zone_item_t::to.

Referenced by rz_flag_zone_add_handler().

◆ rz_flag_zone_around()

RZ_API bool rz_flag_zone_around ( RzFlag f,
ut64  addr,
const char **  prev,
const char **  next 
)

Definition at line 75 of file zones.c.

75  {
77  RzFlagZoneItem *zi;
78  *prev = *next = NULL;
79  ut64 h = UT64_MAX, l = 0LL;
80 
81  rz_list_foreach (f->zones, iter, zi) {
82  if (zi->from > addr) {
83  if (h == UT64_MAX) {
84  h = zi->from;
85  *next = zi->name;
86  } else {
87  if (zi->from < h) {
88  h = zi->from;
89  *next = zi->name;
90  }
91  }
92  }
93  if (zi->from < addr) {
94  if (l == UT64_MAX) {
95  l = zi->from;
96  *prev = zi->name;
97  } else {
98  if (zi->from >= l) {
99  l = zi->from;
100  *prev = zi->name;
101  }
102  }
103  }
104  if (zi->to <= addr) {
105  if (l == UT64_MAX) {
106  l = zi->to;
107  *prev = zi->name;
108  } else {
109  if (zi->to >= l) {
110  l = zi->to;
111  *prev = zi->name;
112  }
113  }
114  }
115  if (zi->to > addr) {
116  if (h == UT64_MAX) {
117  h = zi->to;
118  *next = zi->name;
119  } else {
120  if (zi->to < h) {
121  h = zi->to;
122  *next = zi->name;
123  }
124  }
125  }
126  }
127  return true;
128 }
#define NULL
Definition: cris-opc.c:27
#define UT64_MAX
Definition: rz_types_base.h:86
#define h(i)
Definition: sha256.c:48
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References addr, f, rz_flag_zone_item_t::from, h, rz_flag_zone_item_t::name, NULL, rz_flag_zone_item_t::to, ut64(), and UT64_MAX.

Referenced by rz_flag_zone_around_handler(), and visual_flagzone().

◆ rz_flag_zone_barlist()

RZ_API RzList* rz_flag_zone_barlist ( RzFlag f,
ut64  from,
ut64  bsize,
int  rows 
)

Definition at line 130 of file zones.c.

130  {
132  int i;
133  for (i = 0; i < rows; i++) {
135  if (zi) {
136  rz_list_append(list, zi->name);
137  } else {
138  rz_list_append(list, "");
139  }
140  from += bsize;
141  }
142  return list;
143 }
lzma_index ** i
Definition: index.h:629
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
static RzFlagZoneItem * rz_flag_zone_get_inrange(RzFlag *f, ut64 from, ut64 to)
Definition: zones.c:18

References f, from, i, list(), rz_flag_zone_item_t::name, NULL, rz_flag_zone_get_inrange(), rz_list_append(), and rz_list_newf().

Referenced by rz_core_print_scrollbar(), and rz_core_print_scrollbar_bottom().

◆ rz_flag_zone_del()

RZ_API bool rz_flag_zone_del ( RzFlag f,
const char *  name 
)

Definition at line 57 of file zones.c.

57  {
59  RzFlagZoneItem *zi;
60  rz_list_foreach (f->zones, iter, zi) {
61  if (!strcmp(name, zi->name)) {
62  rz_list_delete(f->zones, iter);
63  return true;
64  }
65  }
66  return false;
67 }
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
Definition: list.c:162

References f, rz_flag_zone_item_t::name, and rz_list_delete().

Referenced by rz_flag_zone_remove_handler().

◆ rz_flag_zone_get()

static RzFlagZoneItem* rz_flag_zone_get ( RzFlag f,
const char *  name 
)
static

Definition at line 7 of file zones.c.

7  {
9  RzFlagZoneItem *zi;
10  rz_list_foreach (f->zones, iter, zi) {
11  if (!strcmp(name, zi->name)) {
12  return zi;
13  }
14  }
15  return NULL;
16 }

References f, rz_flag_zone_item_t::name, and NULL.

Referenced by rz_flag_zone_add().

◆ rz_flag_zone_get_inrange()

static RzFlagZoneItem* rz_flag_zone_get_inrange ( RzFlag f,
ut64  from,
ut64  to 
)
static

Definition at line 18 of file zones.c.

18  {
20  RzFlagZoneItem *zi;
21  rz_list_foreach (f->zones, iter, zi) {
22  if (RZ_BETWEEN(from, zi->from, to)) {
23  return zi;
24  }
25  }
26  return NULL;
27 }
#define RZ_BETWEEN(x, y, z)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125

References f, rz_flag_zone_item_t::from, from, NULL, RZ_BETWEEN, and to.

Referenced by rz_flag_zone_barlist().

◆ rz_flag_zone_item_free()

RZ_API void rz_flag_zone_item_free ( void *  a)

Definition at line 69 of file zones.c.

69  {
70  RzFlagZoneItem *zi = a;
71  free(zi->name);
72  free(zi);
73 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
#define a(i)
Definition: sha256.c:41

References a, free(), and rz_flag_zone_item_t::name.

Referenced by rz_flag_zone_reset().

◆ rz_flag_zone_reset()

RZ_API bool rz_flag_zone_reset ( RzFlag f)

Definition at line 51 of file zones.c.

51  {
52  rz_list_free(f->zones);
54  return true;
55 }
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
RZ_API void rz_flag_zone_item_free(void *a)
Definition: zones.c:69

References f, rz_flag_zone_item_free(), rz_list_free(), and rz_list_newf().

Referenced by rz_flag_zone_add(), rz_flag_zone_remove_all_handler(), and rz_serialize_flag_load().