Rizin
unix-like reverse engineering framework and cli tools
bin.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2020 pancake <pancake@nopcode.org>
2 // SPDX-FileCopyrightText: 2009-2020 nibble <nibble.ds@gmail.com>
3 // SPDX-FileCopyrightText: 2009-2020 dso <dso@rice.edu>
4 // SPDX-License-Identifier: LGPL-3.0-only
5 
6 #include <rz_bin.h>
7 #include <rz_demangler.h>
8 #include <rz_util.h>
9 #include <rz_lib.h>
10 #include <rz_io.h>
11 #include <config.h>
12 #include "i/private.h"
13 
15 
16 #define DB a->sdb;
17 #define RBINLISTFREE(x) \
18  if (x) { \
19  rz_list_free(x); \
20  (x) = NULL; \
21  }
22 
23 #define ARCHS_KEY "archs"
24 
27 
28 static ut64 __getoffset(RzBin *bin, int type, int idx) {
31  if (plugin && plugin->get_offset) {
32  return plugin->get_offset(a, type, idx);
33  }
34  return UT64_MAX;
35 }
36 
37 static char *__getname(RzBin *bin, int type, int idx) {
40  if (plugin && plugin->get_name) {
41  return plugin->get_name(a, type, idx);
42  }
43  return NULL;
44 }
45 
46 // TODO: move these two function do a different file
49  if (data) {
50  data->offset = offset;
51  data->size = size;
52  data->file_count = file_count;
53  data->metadata = metadata;
54  data->loaded = 0;
55  // don't slice twice TODO. review this
56  data->buf = rz_buf_ref(buf); // rz_buf_new_slice (buf, offset, size);
57  }
58  return data;
59 }
60 
61 RZ_API void rz_bin_xtrdata_free(void /*RzBinXtrData*/ *data_) {
62  RzBinXtrData *data = data_;
63  rz_return_if_fail(data);
64  if (data->metadata) {
65  free(data->metadata->libname);
66  free(data->metadata->arch);
67  free(data->metadata->machine);
68  free(data->metadata);
69  }
70  free(data->file);
71  rz_buf_free(data->buf);
72  free(data);
73 }
74 
75 RZ_API void rz_bin_options_init(RzBinOptions *opt, int fd, ut64 baseaddr, ut64 loadaddr, bool patch_relocs) {
76  memset(opt, 0, sizeof(*opt));
77  opt->obj_opts.baseaddr = baseaddr;
78  opt->obj_opts.loadaddr = loadaddr;
79  opt->obj_opts.patch_relocs = patch_relocs;
80  opt->obj_opts.elf_load_sections = true;
81  opt->fd = fd;
82 }
83 
85  opt->arch = arch ? arch : RZ_SYS_ARCH;
86  opt->bits = bits ? bits : RZ_SYS_BITS;
87 }
88 
90  if (fhash) {
91  RZ_FREE(fhash->type);
92  RZ_FREE(fhash->hex);
93  free(fhash);
94  }
95 }
96 
98  if (!rb) {
99  return;
100  }
101 
103  free(rb->intrp);
104  free(rb->file);
105  free(rb->type);
106  free(rb->bclass);
107  free(rb->rclass);
108  free(rb->arch);
109  free(rb->cpu);
110  free(rb->machine);
111  free(rb->os);
112  free(rb->features);
113  free(rb->subsystem);
114  free(rb->default_cc);
115  free(rb->rpath);
116  free(rb->guid);
117  free(rb->debug_file_name);
118  free(rb->actual_checksum);
119  free(rb->claimed_checksum);
120  free(rb->compiler);
121  free(rb->head_flag);
122  free(rb);
123 }
124 
127 
128  RzBinImport *res = rz_mem_dup(o, sizeof(*o));
129  if (res) {
130  res->name = RZ_STR_DUP(o->name);
131  res->classname = RZ_STR_DUP(o->classname);
132  res->descriptor = RZ_STR_DUP(o->descriptor);
133  }
134  return res;
135 }
136 
138  if (imp) {
139  RZ_FREE(imp->name);
140  RZ_FREE(imp->libname);
141  RZ_FREE(imp->classname);
142  RZ_FREE(imp->descriptor);
143  free(imp);
144  }
145 }
146 
148  if (!res) {
149  return;
150  }
151  RZ_FREE(res->name);
152  RZ_FREE(res->time);
153  RZ_FREE(res->type);
154  RZ_FREE(res->language);
155  free(res);
156 }
157 
159  if (s->dup_count) {
160  return sdb_fmt("%s_%d", s->name, s->dup_count);
161  }
162  return s->name;
163 }
164 
165 RZ_API RzBinSymbol *rz_bin_symbol_new(const char *name, ut64 paddr, ut64 vaddr) {
167  if (sym) {
168  sym->name = name ? strdup(name) : NULL;
169  sym->paddr = paddr;
170  sym->vaddr = vaddr;
171  }
172  return sym;
173 }
174 
176  if (!sym) {
177  return;
178  }
179 
180  free(sym->name);
181  free(sym->dname);
182  free(sym->libname);
183  free(sym->classname);
184  free(sym->visibility_str);
185  free(sym);
186 }
187 
189  free(reloc);
190 }
191 
192 RZ_API void rz_bin_string_free(void *_str) {
193  RzBinString *str = (RzBinString *)_str;
194  if (str) {
195  free(str->string);
196  free(str);
197  }
198 }
199 
200 RZ_API RzBinFile *rz_bin_open(RzBin *bin, const char *file, RzBinOptions *opt) {
201  rz_return_val_if_fail(bin && bin->iob.io && opt, NULL);
202 
203  RzIOBind *iob = &(bin->iob);
204  if (!iob->desc_get(iob->io, opt->fd)) {
205  opt->fd = iob->fd_open(iob->io, file, RZ_PERM_R, 0644);
206  }
207  if (opt->fd < 0) {
208  RZ_LOG_ERROR("Couldn't open bin for file '%s'\n", file);
209  return NULL;
210  }
211  opt->sz = 0;
212  opt->pluginname = NULL;
213  return rz_bin_open_io(bin, opt);
214 }
215 
218 
219  bool big_endian = bf->o ? bf->o->opts.big_endian : false;
220  bool patch_relocs = bf->o ? bf->o->opts.patch_relocs : false;
221  bool elf_load_sections = bf->o ? bf->o->opts.elf_load_sections : false;
222  bool elf_checks_sections = bf->o ? bf->o->opts.elf_checks_sections : false;
223  bool elf_checks_segments = bf->o ? bf->o->opts.elf_checks_segments : false;
224 
225  RzBinOptions opt;
227  opt.obj_opts.elf_load_sections = elf_load_sections;
228  opt.obj_opts.elf_checks_sections = elf_checks_sections;
229  opt.obj_opts.elf_checks_segments = elf_checks_segments;
230  opt.obj_opts.big_endian = big_endian;
231  opt.filename = bf->file;
232  rz_buf_seek(bf->buf, 0, RZ_BUF_SET);
233  RzBinFile *nbf = rz_bin_open_buf(bin, bf->buf, &opt);
234  rz_bin_file_delete(bin, bf);
235  return nbf;
236 }
237 
239  rz_return_val_if_fail(bin && opt, NULL);
240 
241  RzListIter *it;
242  RzBinXtrPlugin *xtr;
243 
244  bin->file = opt->filename;
245  if (opt->obj_opts.loadaddr == UT64_MAX) {
246  opt->obj_opts.loadaddr = 0;
247  }
248 
249  RzBinFile *bf = NULL;
250  if (bin->use_xtr && !opt->pluginname) {
251  // XXX - for the time being this is fine, but we may want to
252  // change the name to something like
253  // <xtr_name>:<bin_type_name>
254  rz_list_foreach (bin->binxtrs, it, xtr) {
255  if (!xtr->check_buffer) {
256  RZ_LOG_ERROR("Missing check_buffer callback for '%s'\n", xtr->name);
257  continue;
258  }
259  if (xtr->check_buffer(buf)) {
260  if (xtr->extract_from_buffer || xtr->extractall_from_buffer ||
263  bin->file, buf, &opt->obj_opts,
264  opt->xtr_idx, opt->fd);
265  }
266  }
267  }
268  }
269  if (!bf) {
270  // Uncomment for this speedup: 20s vs 22s
271  // RzBuffer *buf = rz_buf_new_slurp (bin->file);
272  bf = rz_bin_file_new_from_buffer(bin, bin->file, buf,
273  &opt->obj_opts, opt->fd, opt->pluginname);
274  if (!bf) {
275  return NULL;
276  }
277  }
279  rz_id_storage_set(bin->ids, bin->cur, bf->id);
280  return bf;
281 }
282 
283 RZ_API RzBinFile *rz_bin_open_io(RzBin *bin, RzBinOptions *opt) {
284  rz_return_val_if_fail(bin && opt && bin->iob.io, NULL);
285  rz_return_val_if_fail(opt->fd >= 0 && (st64)opt->sz >= 0, NULL);
286 
287  RzIOBind *iob = &(bin->iob);
288  RzIO *io = iob ? iob->io : NULL;
289 
290  bool is_debugger = iob->fd_is_dbg(io, opt->fd);
291  const char *fname = iob->fd_get_name(io, opt->fd);
292  if (opt->obj_opts.loadaddr == UT64_MAX) {
293  opt->obj_opts.loadaddr = 0;
294  }
295 
296  // Create RzBuffer from the opened file
297  // When debugging something, we want to open the backed file because
298  // not all binary info are mapped in the virtual space. If that is not
299  // possible (e.g. remote file) just try to load bin info from the
300  // debugee process.
301  RzBuffer *buf = NULL;
302  if (is_debugger) {
304  is_debugger = false;
305  }
306  if (!buf) {
307  buf = rz_buf_new_with_io_fd(&bin->iob, opt->fd);
308  }
309  if (!buf) {
310  return NULL;
311  }
312 
313  if (!opt->sz) {
314  opt->sz = rz_buf_size(buf);
315  }
316 
317  // Slice buffer if necessary
318  RzBuffer *slice = buf;
319  if (!is_debugger && (opt->obj_opts.loadaddr != 0 || opt->sz != rz_buf_size(buf))) {
320  slice = rz_buf_new_slice(buf, opt->obj_opts.loadaddr, opt->sz);
321  } else if (is_debugger && opt->obj_opts.baseaddr != UT64_MAX && opt->obj_opts.baseaddr != 0) {
322  slice = rz_buf_new_slice(buf, opt->obj_opts.baseaddr, opt->sz);
323  }
324  if (slice != buf) {
325  rz_buf_free(buf);
326  buf = slice;
327  }
328 
329  opt->filename = fname;
330  RzBinFile *bf = rz_bin_open_buf(bin, buf, opt);
331  rz_buf_free(buf);
332  return bf;
333 }
334 
336  RzBinPlugin *plugin;
337  RzListIter *it;
338 
340 
341  rz_list_foreach (bin->plugins, it, plugin) {
342  if (!strcmp(plugin->name, name)) {
343  return plugin;
344  }
345  }
346  return NULL;
347 }
348 
350  RzBinPlugin *plugin;
351  RzListIter *it;
352 
354 
355  rz_list_foreach (bin->plugins, it, plugin) {
356  if (plugin->check_buffer) {
357  if (plugin->check_buffer(buf)) {
358  return plugin;
359  }
360  }
361  }
362  return NULL;
363 }
364 
366  RzBinPlugin *plugin;
367  RzListIter *it;
368 
370 
371  const char *filename = strrchr(bin->file, RZ_SYS_DIR[0]);
372  filename = filename ? filename + 1 : bin->file;
373  rz_list_foreach (bin->plugins, it, plugin) {
374  if (plugin->check_filename) {
375  if (plugin->check_filename(filename)) {
376  return plugin;
377  }
378  }
379  }
380  return NULL;
381 }
382 
384  RzBinXtrPlugin *xtr;
385  RzListIter *it;
386 
388 
389  // TODO: use a hashtable here
390  rz_list_foreach (bin->binxtrs, it, xtr) {
391  if (!strcmp(xtr->name, name)) {
392  return xtr;
393  }
394  // must be set to null
395  xtr = NULL;
396  }
397  return NULL;
398 }
399 
401  RZ_FREE(p);
402 }
403 
405  RzListIter *it;
406  RzBinPlugin *plugin;
407 
408  rz_return_val_if_fail(bin && foo, false);
409 
410  rz_list_foreach (bin->plugins, it, plugin) {
411  if (!strcmp(plugin->name, foo->name)) {
412  return false;
413  }
414  }
415  plugin = RZ_NEW0(RzBinPlugin);
416  memcpy(plugin, foo, sizeof(RzBinPlugin));
417  rz_list_append(bin->plugins, plugin);
418  return true;
419 }
420 
422  RzListIter *it;
423  RzBinXtrPlugin *xtr;
424 
425  rz_return_val_if_fail(bin && foo, false);
426 
427  if (foo->init) {
428  foo->init(bin->user);
429  }
430  // avoid duplicates
431  rz_list_foreach (bin->binxtrs, it, xtr) {
432  if (!strcmp(xtr->name, foo->name)) {
433  return false;
434  }
435  }
436  rz_list_append(bin->binxtrs, foo);
437  return true;
438 }
439 
441  if (!bin) {
442  return;
443  }
444  bin->file = NULL;
445  free(bin->force);
446  free(bin->srcdir);
447  free(bin->strenc);
448  // rz_bin_free_bin_files (bin);
449  rz_list_free(bin->binfiles);
450  rz_list_free(bin->binxtrs);
451  rz_list_free(bin->plugins);
452  sdb_free(bin->sdb);
453  rz_id_storage_free(bin->ids);
454  rz_hash_free(bin->hash);
455  rz_event_free(bin->event);
456  rz_str_constpool_fini(&bin->constpool);
457  rz_demangler_free(bin->demangler);
458  free(bin);
459 }
460 
461 static bool rz_bin_print_plugin_details(RzBin *bin, RzBinPlugin *bp, PJ *pj, int json) {
462  if (json == 'q') {
463  bin->cb_printf("%s\n", bp->name);
464  } else if (json) {
465  pj_o(pj);
466  pj_ks(pj, "name", bp->name);
467  pj_ks(pj, "description", bp->desc);
468  pj_ks(pj, "license", bp->license ? bp->license : "???");
469  pj_end(pj);
470  } else {
471  bin->cb_printf("Name: %s\n", bp->name);
472  bin->cb_printf("Description: %s\n", bp->desc);
473  if (bp->license) {
474  bin->cb_printf("License: %s\n", bp->license);
475  }
476  if (bp->version) {
477  bin->cb_printf("Version: %s\n", bp->version);
478  }
479  if (bp->author) {
480  bin->cb_printf("Author: %s\n", bp->author);
481  }
482  }
483  return true;
484 }
485 
486 static void __printXtrPluginDetails(RzBin *bin, RzBinXtrPlugin *bx, int json) {
487  if (json == 'q') {
488  bin->cb_printf("%s\n", bx->name);
489  } else if (json) {
490  PJ *pj = pj_new();
491  if (!pj) {
492  return;
493  }
494  pj_o(pj);
495  pj_ks(pj, "name", bx->name);
496  pj_ks(pj, "description", bx->desc);
497  pj_ks(pj, "license", bx->license ? bx->license : "???");
498  pj_end(pj);
499  bin->cb_printf("%s\n", pj_string(pj));
500  pj_free(pj);
501  } else {
502  bin->cb_printf("Name: %s\n", bx->name);
503  bin->cb_printf("Description: %s\n", bx->desc);
504  if (bx->license) {
505  bin->cb_printf("License: %s\n", bx->license);
506  }
507  }
508 }
509 
510 RZ_API bool rz_bin_list_plugin(RzBin *bin, const char *name, PJ *pj, int json) {
511  RzListIter *it;
512  RzBinPlugin *bp;
513  RzBinXtrPlugin *bx;
514 
515  rz_return_val_if_fail(bin && name, false);
516 
517  rz_list_foreach (bin->plugins, it, bp) {
518  if (rz_str_cmp(name, bp->name, strlen(name))) {
519  continue;
520  }
521  return rz_bin_print_plugin_details(bin, bp, pj, json);
522  }
523  rz_list_foreach (bin->binxtrs, it, bx) {
524  if (rz_str_cmp(name, bx->name, strlen(name))) {
525  continue;
526  }
527  __printXtrPluginDetails(bin, bx, json);
528  return true;
529  }
530 
531  RZ_LOG_ERROR("Cannot find plugin %s\n", name);
532  return false;
533 }
534 
535 /* returns the base address of bin or UT64_MAX in case of errors */
538  return rz_bin_file_get_baddr(bin->cur);
539 }
540 
541 /* returns the load address of bin or UT64_MAX in case of errors */
545  return o ? o->opts.loadaddr : UT64_MAX;
546 }
547 
548 // TODO: should be RzBinFile specific imho
551  RzBinFile *bf = rz_bin_cur(bin);
553  if (!o || !o->plugin || !o->plugin->baddr) {
554  return;
555  }
556  ut64 file_baddr = o->plugin->baddr(bf);
557  if (baddr == UT64_MAX) {
558  o->opts.baseaddr = file_baddr;
559  o->baddr_shift = 0; // o->baddr; // - file_baddr;
560  } else if (file_baddr != UT64_MAX) {
561  o->opts.baseaddr = baddr;
562  o->baddr_shift = baddr - file_baddr;
563  }
564 }
565 
566 // XXX: those accessors are redundant
570  return o ? (RzList *)rz_bin_object_get_entries(o) : NULL;
571 }
572 
576  return o ? (RzList *)rz_bin_object_get_fields(o) : NULL;
577 }
578 
582  return o ? (RzList *)rz_bin_object_get_imports(o) : NULL;
583 }
584 
588  return o ? (RzBinInfo *)rz_bin_object_get_info(o) : NULL;
589 }
590 
594  return o ? (RzList *)rz_bin_object_get_libs(o) : NULL;
595 }
596 
600  return o ? (RzList *)rz_bin_object_get_sections_all(o) : NULL;
601 }
602 
613  RzListIter *iter;
614  ut64 from, to;
615 
617  // TODO: must be O(1) .. use sdb here
618  rz_list_foreach (o->sections, iter, section) {
619  if (section->is_segment) {
620  continue;
621  }
622  from = va ? rz_bin_object_addr_with_base(o, section->vaddr) : section->paddr;
623  to = from + (va ? section->vsize : section->size);
624  if (off >= from && off < to) {
625  return section;
626  }
627  }
628  return NULL;
629 }
630 
645 
646  RzBinMap *map;
647  RzListIter *iter;
648  ut64 from, to;
649 
650  rz_list_foreach_prev(o->maps, iter, map) {
651  from = va ? rz_bin_object_addr_with_base(o, map->vaddr) : map->paddr;
652  to = from + (va ? map->vsize : map->psize);
653  if (off >= from && off < to) {
654  return map;
655  }
656  }
657  return NULL;
658 }
659 
670 
671  RzBinMap *map;
672  RzListIter *iter;
673  ut64 from, to;
674 
675  RzPVector *res = rz_pvector_new(NULL);
676  if (!res) {
677  return NULL;
678  }
679 
680  rz_list_foreach (o->maps, iter, map) {
681  from = va ? rz_bin_object_addr_with_base(o, map->vaddr) : map->paddr;
682  to = from + (va ? map->vsize : map->psize);
683  if (off >= from && off < to) {
684  rz_pvector_push(res, map);
685  }
686  }
687  return res;
688 }
689 
693  return o ? (RzList *)rz_bin_object_get_strings(o) : NULL;
694 }
695 
699  return o ? (RzList *)rz_bin_object_get_symbols(o) : NULL;
700 }
701 
705  return o ? (RzList *)rz_bin_object_get_mem(o) : NULL;
706 }
707 
709  rz_return_val_if_fail(bin, false);
711  return o ? rz_bin_object_is_static(o) : false;
712 }
713 
714 RZ_IPI void rz_bin_file_free(void /*RzBinFile*/ *_bf);
715 
717  int i;
718  RzBinXtrPlugin *static_xtr_plugin;
719  RzBin *bin = RZ_NEW0(RzBin);
720  if (!bin) {
721  return NULL;
722  }
723  /* demanglers */
724  bin->demangler = rz_demangler_new();
725  if (!bin->demangler) {
726  goto trashbin;
727  }
728  if (!rz_str_constpool_init(&bin->constpool)) {
729  goto trashbin_demangler;
730  }
731  bin->event = rz_event_new(bin);
732  if (!bin->event) {
733  goto trashbin_constpool;
734  }
735  bin->force = NULL;
736  bin->filter_rules = UT64_MAX;
737  bin->sdb = sdb_new0();
738  bin->cb_printf = (PrintfCallback)printf;
740  bin->minstrlen = 0;
741  bin->strpurge = NULL;
742  bin->strenc = NULL;
743  bin->want_dbginfo = true;
744  bin->cur = NULL;
745  bin->hash = rz_hash_new();
746  if (!bin->hash) {
747  goto trashbin_event;
748  }
749 
750  bin->ids = rz_id_storage_new(0, ST32_MAX);
751 
752  /* bin parsers */
754  for (i = 0; i < RZ_ARRAY_SIZE(bin_static_plugins); i++) {
756  }
757  /* extractors */
758  bin->binxtrs = rz_list_new();
759  bin->binxtrs->free = free;
760  for (i = 0; i < RZ_ARRAY_SIZE(bin_xtr_static_plugins); i++) {
761  static_xtr_plugin = RZ_NEW0(RzBinXtrPlugin);
762  if (!static_xtr_plugin) {
763  goto trashbin_binxtrs;
764  }
765  *static_xtr_plugin = *bin_xtr_static_plugins[i];
766  if (!rz_bin_xtr_add(bin, static_xtr_plugin)) {
767  free(static_xtr_plugin);
768  }
769  }
770  return bin;
771 
772 trashbin_binxtrs:
773  rz_list_free(bin->binxtrs);
774  rz_list_free(bin->binfiles);
775  rz_id_storage_free(bin->ids);
776 trashbin_event:
777  rz_event_free(bin->event);
778 trashbin_constpool:
779  rz_str_constpool_fini(&bin->constpool);
780 trashbin_demangler:
781  rz_demangler_free(bin->demangler);
782 trashbin:
783  free(bin);
784  return NULL;
785 }
786 
787 RZ_API bool rz_bin_use_arch(RzBin *bin, const char *arch, int bits, const char *name) {
788  rz_return_val_if_fail(bin && arch, false);
789 
791  if (!binfile) {
792  RZ_LOG_WARN("Cannot find binfile with arch/bits %s/%d\n", arch, bits);
793  return false;
794  }
795 
797  if (!obj && binfile->xtr_data) {
798  RzBinXtrData *xtr_data = rz_list_get_n(binfile->xtr_data, 0);
799  if (xtr_data && !xtr_data->loaded) {
800  RzBinObjectLoadOptions obj_opts = {
801  .baseaddr = UT64_MAX,
802  .loadaddr = rz_bin_get_laddr(bin)
803  };
804  if (!rz_bin_file_object_new_from_xtr_data(bin, binfile, &obj_opts, xtr_data)) {
805  return false;
806  }
807  }
808  obj = binfile->o;
809  }
810  return rz_bin_file_set_obj(bin, binfile, obj);
811 }
812 
813 RZ_API bool rz_bin_select(RzBin *bin, const char *arch, int bits, const char *name) {
814  rz_return_val_if_fail(bin, false);
815 
816  RzBinFile *cur = rz_bin_cur(bin);
817  RzBinObject *obj = NULL;
818  name = !name && cur ? cur->file : name;
820  if (binfile && name) {
821  obj = rz_bin_object_find_by_arch_bits(binfile, arch, bits, name);
822  }
823  return rz_bin_file_set_obj(bin, binfile, obj);
824 }
825 
826 RZ_API int rz_bin_select_object(RzBinFile *binfile, const char *arch, int bits, const char *name) {
827  rz_return_val_if_fail(binfile, false);
829  return rz_bin_file_set_obj(binfile->rbin, binfile, obj);
830 }
831 
832 // NOTE: this functiona works as expected, but we need to merge bfid and boid
834  rz_return_val_if_fail(bin, false);
835  RzBinFile *bf = rz_bin_file_find_by_id(bin, bf_id);
836  return bf ? rz_bin_file_set_obj(bin, bf, NULL) : false;
837 }
838 
839 RZ_API void rz_bin_set_user_ptr(RzBin *bin, void *user) {
840  bin->user = user;
841 }
842 
845  if (!bin->cur) {
846  return NULL;
847  }
848  return rz_bin_get_section_at(bin->cur->o, vaddr, true);
849 }
850 
852  if (b) {
853  b->bin = bin;
854  b->get_offset = __getoffset;
855  b->get_name = __getname;
856  b->get_sections = rz_bin_get_sections;
857  b->get_vsect_at = __get_vsection_at;
858  b->demangle = rz_bin_demangle;
859  }
860 }
861 
863  const ut8 *code, int codelen,
864  const ut8 *data, int datalen,
865  RzBinArchOptions *opt) {
866 
867  rz_return_val_if_fail(bin && p && opt, NULL);
868 
870  if (!plugin) {
871  RZ_LOG_WARN("Cannot find RzBin plugin named '%s'.\n", p);
872  return NULL;
873  }
874  if (!plugin->create) {
875  RZ_LOG_WARN("RzBin plugin '%s' does not implement \"create\" method.\n", p);
876  return NULL;
877  }
878  codelen = RZ_MAX(codelen, 0);
879  datalen = RZ_MAX(datalen, 0);
880  return plugin->create(bin, code, codelen, data, datalen, opt);
881 }
882 
886  return o ? o->classes : NULL;
887 }
888 
892  return o ? o->size : 0;
893 }
894 
897  return bin->cur;
898 }
899 
902  RzBinFile *binfile = rz_bin_cur(bin);
903  return binfile ? binfile->o : NULL;
904 }
905 
906 RZ_API void rz_bin_force_plugin(RzBin *bin, const char *name) {
908  free(bin->force);
909  bin->force = (name && *name) ? strdup(name) : NULL;
910 }
911 
912 RZ_API const char *rz_bin_entry_type_string(int etype) {
913  switch (etype) {
915  return "program";
917  return "main";
919  return "init";
921  return "fini";
923  return "tls";
925  return "preinit";
926  }
927  return NULL;
928 }
929 
931  bin->filter_rules = rules;
932 }
933 
934 /* RzBinField */
935 RZ_API RzBinField *rz_bin_field_new(ut64 paddr, ut64 vaddr, int size, const char *name, const char *comment, const char *format, bool format_named) {
936  RzBinField *ptr = RZ_NEW0(RzBinField);
937  if (ptr) {
938  ptr->name = strdup(name);
939  ptr->comment = (comment && *comment) ? strdup(comment) : NULL;
940  ptr->format = (format && *format) ? strdup(format) : NULL;
941  ptr->format_named = format_named;
942  ptr->paddr = paddr;
943  ptr->size = size;
944  // ptr->visibility = any default visibility?
945  ptr->vaddr = vaddr;
946  }
947  return ptr;
948 }
949 
951  if (field) {
952  free(field->name);
953  free(field->visibility_str);
954  free(field->type);
955  free(field->comment);
956  free(field->format);
957  free(field);
958  }
959 }
960 
961 RZ_API const char *rz_bin_get_meth_flag_string(ut64 flag, bool compact) {
962  switch (flag) {
963  case RZ_BIN_METH_CLASS:
964  return compact ? "c" : "class";
965  case RZ_BIN_METH_STATIC:
966  return compact ? "s" : "static";
967  case RZ_BIN_METH_PUBLIC:
968  return compact ? "p" : "public";
969  case RZ_BIN_METH_PRIVATE:
970  return compact ? "P" : "private";
972  return compact ? "r" : "protected";
974  return compact ? "i" : "internal";
975  case RZ_BIN_METH_OPEN:
976  return compact ? "o" : "open";
978  return compact ? "e" : "fileprivate";
979  case RZ_BIN_METH_FINAL:
980  return compact ? "f" : "final";
981  case RZ_BIN_METH_VIRTUAL:
982  return compact ? "v" : "virtual";
983  case RZ_BIN_METH_CONST:
984  return compact ? "k" : "const";
986  return compact ? "m" : "mutating";
988  return compact ? "a" : "abstract";
990  return compact ? "y" : "synchronized";
991  case RZ_BIN_METH_NATIVE:
992  return compact ? "n" : "native";
993  case RZ_BIN_METH_BRIDGE:
994  return compact ? "b" : "bridge";
995  case RZ_BIN_METH_VARARGS:
996  return compact ? "g" : "varargs";
998  return compact ? "h" : "synthetic";
999  case RZ_BIN_METH_STRICT:
1000  return compact ? "t" : "strict";
1001  case RZ_BIN_METH_MIRANDA:
1002  return compact ? "A" : "miranda";
1004  return compact ? "C" : "constructor";
1006  return compact ? "Y" : "declared_synchronized";
1007  default:
1008  return NULL;
1009  }
1010 }
1011 
1013  if (!vfile) {
1014  return;
1015  }
1016  if (vfile->buf_owned) {
1017  rz_buf_free(vfile->buf);
1018  }
1019  free(vfile->name);
1020  free(vfile);
1021 }
1022 
1024  if (!map) {
1025  return;
1026  }
1027  free(map->vfile_name);
1028  free(map->name);
1029  free(map);
1030 }
1031 
1041  rz_return_val_if_fail(binfile, NULL);
1042  if (!binfile->o || !binfile->o->plugin || !binfile->o->plugin->sections) {
1043  return NULL;
1044  }
1045  RzList *sections = binfile->o->plugin->sections(binfile);
1046  if (!sections) {
1047  return NULL;
1048  }
1050  if (!r) {
1051  goto hcf;
1052  }
1053  RzBinSection *sec;
1054  RzListIter *it;
1055  rz_list_foreach (sections, it, sec) {
1057  if (!map) {
1058  goto hcf;
1059  }
1060  map->name = sec->name ? strdup(sec->name) : NULL;
1061  map->paddr = sec->paddr;
1062  map->psize = sec->size;
1063  map->vaddr = sec->vaddr;
1064  map->vsize = sec->vsize;
1065  map->perm = sec->perm;
1066  rz_list_push(r, map);
1067  }
1068 hcf:
1070  return r;
1071 }
1072 
1084 RZ_API RzList /*<RzBinSection *>*/ *rz_bin_sections_of_maps(RzList /*<RzBinMap *>*/ *maps) {
1087  if (!ret) {
1088  return NULL;
1089  }
1090  RzListIter *it;
1091  RzBinMap *map;
1092  rz_list_foreach (maps, it, map) {
1094  if (!sec) {
1095  break;
1096  }
1097  sec->name = map->name ? strdup(map->name) : NULL;
1098  sec->paddr = map->paddr;
1099  sec->size = map->psize;
1100  sec->vaddr = map->vaddr;
1101  sec->vsize = map->vsize;
1102  sec->perm = map->perm;
1103  rz_list_append(ret, sec);
1104  }
1105  return ret;
1106 }
1107 
1110  if (s) {
1111  s->name = name ? strdup(name) : NULL;
1112  }
1113  return s;
1114 }
1115 
1117  if (bs) {
1118  free(bs->name);
1119  free(bs->format);
1120  free(bs);
1121  }
1122 }
1123 
1134  RzBinFile *a = rz_bin_cur(bin);
1136  if (plugin && plugin->section_type_to_string) {
1137  return plugin->section_type_to_string(type);
1138  }
1139  return NULL;
1140 }
1141 
1152  RzBinFile *a = rz_bin_cur(bin);
1154  if (plugin && plugin->section_flag_to_rzlist) {
1155  return plugin->section_flag_to_rzlist(flag);
1156  }
1157  return NULL;
1158 }
1159 
1161  RzListIter *it;
1162  RzBinFile *bf;
1163  rz_list_foreach (bin->binfiles, it, bf) {
1164  if (!bf->o) {
1165  continue;
1166  }
1167  RzBinMap *map = rz_bin_object_get_map_at(bf->o, at, true);
1168  if (map) {
1169  return bf;
1170  }
1171  if (at >= bf->o->opts.baseaddr && at < (bf->o->opts.baseaddr + bf->size)) {
1172  return bf;
1173  }
1174  }
1175  return NULL;
1176 }
1177 
1180  if (tc) {
1181  tc->source = source;
1182  tc->from = from;
1183  tc->to = to;
1184  tc->handler = handler;
1185  tc->filter = filter;
1186  }
1187  return tc;
1188 }
1189 
1191  free(tc);
1192 }
1193 
1199 
1200  RzListIter *iter;
1201  RzBinPlugin *bp;
1202 
1203  rz_list_foreach (bin->plugins, iter, bp) {
1204  if (!strcmp(bp->name, name)) {
1205  return bp;
1206  }
1207  }
1208  return NULL;
1209 }
1210 
1216 
1217  RzListIter *iter;
1218  RzBinXtrPlugin *bp;
1219 
1220  rz_list_foreach (bin->binxtrs, iter, bp) {
1221  if (!strcmp(bp->name, name)) {
1222  return bp;
1223  }
1224  }
1225  return NULL;
1226 }
1227 
1228 #if WITH_GPL
1229 static char *bin_demangle_cxx(RzBinFile *bf, const char *symbol, ut64 vaddr) {
1230  char *out = rz_demangler_cxx(symbol);
1231  if (!out || !bf) {
1232  return out;
1233  }
1234  char *sign = (char *)strchr(out, '(');
1235  if (!sign) {
1236  return out;
1237  }
1238 
1239  char *str = out;
1240  char *ptr = NULL;
1241  char *method_name = NULL;
1242  for (;;) {
1243  ptr = strstr(str, "::");
1244  if (!ptr || ptr > sign) {
1245  break;
1246  }
1247  method_name = ptr;
1248  str = ptr + 1;
1249  }
1250 
1251  if (RZ_STR_ISEMPTY(method_name)) {
1252  return out;
1253  }
1254 
1255  *method_name = 0;
1256  RzBinSymbol *sym = rz_bin_file_add_method(bf, out, method_name + 2, 0);
1257  if (sym) {
1258  if (sym->vaddr != 0 && sym->vaddr != vaddr) {
1259  RZ_LOG_INFO("Duplicated method found: %s\n", sym->name);
1260  }
1261  if (sym->vaddr == 0) {
1262  sym->vaddr = vaddr;
1263  }
1264  }
1265  *method_name = ':';
1266  return out;
1267 }
1268 
1269 static char *bin_demangle_rust(RzBinFile *binfile, const char *symbol, ut64 vaddr) {
1270  char *str = NULL;
1271  if (!(str = bin_demangle_cxx(binfile, symbol, vaddr))) {
1272  return str;
1273  }
1274  free(str);
1275  return rz_demangler_rust(symbol);
1276 }
1277 #endif
1278 
1295 RZ_API RZ_OWN char *rz_bin_demangle(RZ_NULLABLE RzBinFile *bf, RZ_NULLABLE const char *language, RZ_NULLABLE const char *symbol, ut64 vaddr, bool libs) {
1296  if (RZ_STR_ISEMPTY(symbol)) {
1297  return NULL;
1298  }
1299 
1301  RzBin *bin = bf ? bf->rbin : NULL;
1302  RzBinObject *o = bf ? bf->o : NULL;
1303 
1304  if (!language && o && o->info && o->info->lang) {
1305  language = o->info->lang;
1306  }
1307 
1308  RzListIter *iter;
1309  const char *lib = NULL;
1310  if (!strncmp(symbol, "reloc.", 6)) {
1311  symbol += 6;
1312  }
1313  if (!strncmp(symbol, "sym.", 4)) {
1314  symbol += 4;
1315  }
1316  if (!strncmp(symbol, "imp.", 4)) {
1317  symbol += 4;
1318  }
1319  if (!strncmp(symbol, "target.", 7)) {
1320  symbol += 7;
1321  }
1322  if (o) {
1323  bool found = false;
1324  rz_list_foreach (o->libs, iter, lib) {
1325  size_t len = strlen(lib);
1326  if (!rz_str_ncasecmp(symbol, lib, len)) {
1327  symbol += len;
1328  if (*symbol == '_') {
1329  symbol++;
1330  }
1331  found = true;
1332  break;
1333  }
1334  }
1335  if (!found) {
1336  lib = NULL;
1337  }
1338  size_t len = strlen(bin->file);
1339  if (!rz_str_ncasecmp(symbol, bin->file, len)) {
1340  lib = bin->file;
1341  symbol += len;
1342  if (*symbol == '_') {
1343  symbol++;
1344  }
1345  }
1346  }
1347 
1348  if (RZ_STR_ISEMPTY(symbol)) {
1349  return NULL;
1350  }
1351 
1352  if (!strncmp(symbol, "__", 2)) {
1353  if (symbol[2] == 'T') {
1355  } else {
1357  }
1358  }
1359 
1360  if (type == RZ_BIN_LANGUAGE_UNKNOWN) {
1361  type = rz_bin_language_to_id(language);
1362  // ignore "with blocks"
1364  language = rz_bin_language_to_string(type);
1365  }
1366  if (!language) {
1367  return NULL;
1368  }
1369  char *demangled = NULL;
1370  switch (type) {
1371  case RZ_BIN_LANGUAGE_UNKNOWN: return NULL;
1373  /* fall-thru */
1375  /* fall-thru */
1376  case RZ_BIN_LANGUAGE_DART:
1377  /* fall-thru */
1378  case RZ_BIN_LANGUAGE_JAVA: demangled = rz_demangler_java(symbol); break;
1379  case RZ_BIN_LANGUAGE_OBJC: demangled = rz_demangler_objc(symbol); break;
1380  case RZ_BIN_LANGUAGE_MSVC: demangled = rz_demangler_msvc(symbol); break;
1381 #if WITH_GPL
1382  case RZ_BIN_LANGUAGE_RUST: demangled = bin_demangle_rust(bf, symbol, vaddr); break;
1383  case RZ_BIN_LANGUAGE_CXX: demangled = bin_demangle_cxx(bf, symbol, vaddr); break;
1384 #else
1385  case RZ_BIN_LANGUAGE_RUST: demangled = NULL; break;
1386  case RZ_BIN_LANGUAGE_CXX: demangled = NULL; break;
1387 #endif
1388  default: rz_demangler_resolve(bin->demangler, symbol, language, &demangled);
1389  }
1390  if (libs && demangled && lib) {
1391  char *d = rz_str_newf("%s_%s", lib, demangled);
1392  free(demangled);
1393  demangled = d;
1394  }
1395  return demangled;
1396 }
size_t len
Definition: 6502dis.c:15
#define RZ_IPI
Definition: analysis_wasm.c:11
lzma_index ** i
Definition: index.h:629
RZ_API bool rz_bin_file_set_cur_binfile(RzBin *bin, RzBinFile *bf)
Definition: bfile.c:288
RZ_API RzBinSymbol * rz_bin_file_add_method(RzBinFile *bf, const char *klass, const char *method, int nargs)
Definition: bfile.c:543
RZ_IPI RzBinFile * rz_bin_file_new_from_buffer(RzBin *bin, const char *file, RzBuffer *buf, RzBinObjectLoadOptions *opts, int fd, const char *pluginname)
Definition: bfile.c:139
RZ_IPI bool rz_bin_file_set_obj(RzBin *bin, RzBinFile *bf, RzBinObject *obj)
Definition: bfile.c:263
RZ_API RzBinFile * rz_bin_file_find_by_id(RzBin *bin, ut32 bf_id)
Definition: bfile.c:188
RZ_API bool rz_bin_file_delete(RzBin *bin, RzBinFile *bf)
Definition: bfile.c:213
RZ_API RzBinFile * rz_bin_file_find_by_arch_bits(RzBin *bin, const char *arch, int bits)
Definition: bfile.c:163
RZ_API RzBinPlugin * rz_bin_file_cur_plugin(RzBinFile *bf)
Definition: bfile.c:348
RZ_API bool rz_bin_file_object_new_from_xtr_data(RzBin *bin, RzBinFile *bf, RzBinObjectLoadOptions *opts, RzBinXtrData *data)
Definition: bfile.c:94
RZ_IPI RzBinFile * rz_bin_file_xtr_load_buffer(RzBin *bin, RzBinXtrPlugin *xtr, const char *filename, RzBuffer *buf, RzBinObjectLoadOptions *obj_opts, int idx, int fd)
Definition: bfile.c:299
RZ_API ut64 rz_bin_file_get_baddr(RzBinFile *bf)
Definition: bfile.c:352
RZ_API void rz_bin_info_free(RzBinInfo *rb)
Definition: bin.c:97
RZ_API const char * rz_bin_entry_type_string(int etype)
Definition: bin.c:912
RZ_DEPRECATE RZ_API RZ_BORROW RzBinInfo * rz_bin_get_info(RzBin *bin)
Definition: bin.c:585
RZ_API RzBinImport * rz_bin_import_clone(RzBinImport *o)
Definition: bin.c:125
RZ_API RzBin * rz_bin_new(void)
Definition: bin.c:716
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_entries(RZ_NONNULL RzBin *bin)
Definition: bin.c:567
RZ_API ut64 rz_bin_get_laddr(RzBin *bin)
Definition: bin.c:542
RZ_API RzBinObject * rz_bin_cur_object(RzBin *bin)
Definition: bin.c:900
RZ_API bool rz_bin_plugin_add(RzBin *bin, RzBinPlugin *foo)
Definition: bin.c:404
static void __printXtrPluginDetails(RzBin *bin, RzBinXtrPlugin *bx, int json)
Definition: bin.c:486
RZ_API void rz_bin_xtrdata_free(void *data_)
Definition: bin.c:61
RZ_API RzBinSymbol * rz_bin_symbol_new(const char *name, ut64 paddr, ut64 vaddr)
Definition: bin.c:165
RZ_API ut64 rz_bin_get_size(RzBin *bin)
Definition: bin.c:889
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_imports(RZ_NONNULL RzBin *bin)
Definition: bin.c:579
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_mem(RZ_NONNULL RzBin *bin)
Definition: bin.c:702
RZ_API void rz_bin_load_filter(RzBin *bin, ut64 rules)
Definition: bin.c:930
RZ_API RzBinSection * rz_bin_section_new(const char *name)
Definition: bin.c:1108
RZ_API void rz_bin_file_hash_free(RzBinFileHash *fhash)
Definition: bin.c:89
RZ_API RZ_OWN RzList * rz_bin_section_flag_to_list(RzBin *bin, ut64 flag)
Converts the RzBinSection flags to a list of string representations.
Definition: bin.c:1151
RZ_API void rz_bin_bind(RzBin *bin, RzBinBind *b)
Definition: bin.c:851
RZ_API RzBinPlugin * rz_bin_get_binplugin_by_buffer(RzBin *bin, RzBuffer *buf)
Definition: bin.c:349
RZ_API void rz_bin_set_user_ptr(RzBin *bin, void *user)
Definition: bin.c:839
RZ_API RzBinFile * rz_bin_open_buf(RzBin *bin, RzBuffer *buf, RzBinOptions *opt)
Definition: bin.c:238
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
Definition: bin.c:175
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_classes(RZ_NONNULL RzBin *bin)
Definition: bin.c:883
RZ_API RzBinFile * rz_bin_file_at(RzBin *bin, ut64 at)
Definition: bin.c:1160
RZ_API const char * rz_bin_symbol_name(RzBinSymbol *s)
Definition: bin.c:158
RZ_API bool rz_bin_list_plugin(RzBin *bin, const char *name, PJ *pj, int json)
Definition: bin.c:510
RZ_LIB_VERSION(rz_bin)
static bool rz_bin_print_plugin_details(RzBin *bin, RzBinPlugin *bp, PJ *pj, int json)
Definition: bin.c:461
RZ_API void rz_bin_map_free(RzBinMap *map)
Definition: bin.c:1023
RZ_API void rz_bin_string_free(void *_str)
Definition: bin.c:192
RZ_API void rz_bin_field_free(RzBinField *field)
Definition: bin.c:950
RZ_IPI RzBinPlugin * rz_bin_get_binplugin_by_name(RzBin *bin, const char *name)
Definition: bin.c:335
RZ_IPI RzBinPlugin * rz_bin_get_binplugin_by_filename(RzBin *bin)
Definition: bin.c:365
RZ_API const RzBinPlugin * rz_bin_plugin_get(RZ_NONNULL RzBin *bin, RZ_NONNULL const char *name)
Get a RzBinPlugin by name.
Definition: bin.c:1197
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_libs(RZ_NONNULL RzBin *bin)
Definition: bin.c:591
RZ_API RzBinFile * rz_bin_open_io(RzBin *bin, RzBinOptions *opt)
Definition: bin.c:283
RZ_DEPRECATE RZ_API int rz_bin_is_static(RZ_NONNULL RzBin *bin)
Definition: bin.c:708
RZ_API RZ_BORROW RzBinMap * rz_bin_object_get_map_at(RZ_NONNULL RzBinObject *o, ut64 off, bool va)
Find the last binary map at offset off .
Definition: bin.c:643
RZ_API void rz_bin_import_free(RzBinImport *imp)
Definition: bin.c:137
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_symbols(RZ_NONNULL RzBin *bin)
Definition: bin.c:696
RZ_API void rz_bin_resource_free(RzBinResource *res)
Definition: bin.c:147
RZ_API void rz_bin_arch_options_init(RzBinArchOptions *opt, const char *arch, int bits)
Definition: bin.c:84
static RzBinXtrPlugin * bin_xtr_static_plugins[]
Definition: bin.c:26
RZ_API const RzBinXtrPlugin * rz_bin_xtrplugin_get(RZ_NONNULL RzBin *bin, RZ_NONNULL const char *name)
Get a RzBinXtrPlugin by name.
Definition: bin.c:1214
static RzBinPlugin * bin_static_plugins[]
Definition: bin.c:25
RZ_API RzList * rz_bin_sections_of_maps(RzList *maps)
Create a list of RzBinSection from RzBinMaps.
Definition: bin.c:1084
RZ_API bool rz_bin_select_bfid(RzBin *bin, ut32 bf_id)
Definition: bin.c:833
RZ_API ut64 rz_bin_get_baddr(RzBin *bin)
Definition: bin.c:536
RZ_API RZ_OWN RzPVector * rz_bin_object_get_maps_at(RzBinObject *o, ut64 off, bool va)
Find all binary maps at offset off .
Definition: bin.c:668
RZ_API void rz_bin_section_free(RzBinSection *bs)
Definition: bin.c:1116
RZ_API void rz_bin_force_plugin(RzBin *bin, const char *name)
Definition: bin.c:906
RZ_API RZ_BORROW RzBinSection * rz_bin_get_section_at(RzBinObject *o, ut64 off, int va)
Find the binary section at offset off.
Definition: bin.c:611
RZ_API RzBuffer * rz_bin_create(RzBin *bin, const char *p, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt)
Definition: bin.c:862
RZ_API RzBinXtrData * rz_bin_xtrdata_new(RzBuffer *buf, ut64 offset, ut64 size, ut32 file_count, RzBinXtrMetadata *metadata)
Definition: bin.c:47
RZ_API bool rz_bin_xtr_add(RzBin *bin, RzBinXtrPlugin *foo)
Definition: bin.c:421
RZ_API RZ_OWN char * rz_bin_demangle(RZ_NULLABLE RzBinFile *bf, RZ_NULLABLE const char *language, RZ_NULLABLE const char *symbol, ut64 vaddr, bool libs)
Demangles a symbol based on the language or the RzBinFile data.
Definition: bin.c:1295
static RzBinSection * __get_vsection_at(RzBin *bin, ut64 vaddr)
Definition: bin.c:843
RZ_API RZ_OWN RzList * rz_bin_maps_of_file_sections(RZ_NONNULL RzBinFile *binfile)
Create a list of RzBinMap from RzBinSections queried from the given file.
Definition: bin.c:1040
RZ_API RzBinFile * rz_bin_reload(RzBin *bin, RzBinFile *bf, ut64 baseaddr)
Definition: bin.c:216
static char * __getname(RzBin *bin, int type, int idx)
Definition: bin.c:37
RZ_API RzBinTrycatch * rz_bin_trycatch_new(ut64 source, ut64 from, ut64 to, ut64 handler, ut64 filter)
Definition: bin.c:1178
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_strings(RZ_NONNULL RzBin *bin)
Definition: bin.c:690
RZ_API void rz_bin_options_init(RzBinOptions *opt, int fd, ut64 baseaddr, ut64 loadaddr, bool patch_relocs)
Definition: bin.c:75
static void rz_bin_plugin_free(RzBinPlugin *p)
Definition: bin.c:400
RZ_API RzBinField * rz_bin_field_new(ut64 paddr, ut64 vaddr, int size, const char *name, const char *comment, const char *format, bool format_named)
Definition: bin.c:935
RZ_IPI void rz_bin_file_free(void *_bf)
Definition: bfile.c:44
RZ_API RzBinFile * rz_bin_open(RzBin *bin, const char *file, RzBinOptions *opt)
Definition: bin.c:200
RZ_API RzBinFile * rz_bin_cur(RzBin *bin)
Definition: bin.c:895
RZ_API void rz_bin_virtual_file_free(RzBinVirtualFile *vfile)
Definition: bin.c:1012
RZ_API const char * rz_bin_get_meth_flag_string(ut64 flag, bool compact)
Definition: bin.c:961
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_sections(RZ_NONNULL RzBin *bin)
Definition: bin.c:597
RZ_API int rz_bin_select_object(RzBinFile *binfile, const char *arch, int bits, const char *name)
Definition: bin.c:826
RZ_API bool rz_bin_select(RzBin *bin, const char *arch, int bits, const char *name)
Definition: bin.c:813
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_fields(RZ_NONNULL RzBin *bin)
Definition: bin.c:573
RZ_API void rz_bin_free(RzBin *bin)
Definition: bin.c:440
RZ_API bool rz_bin_use_arch(RzBin *bin, const char *arch, int bits, const char *name)
Definition: bin.c:787
RZ_API void rz_bin_set_baddr(RzBin *bin, ut64 baddr)
Definition: bin.c:549
RZ_API RZ_OWN char * rz_bin_section_type_to_string(RzBin *bin, int type)
Converts the RzBinSection type to the string representation.
Definition: bin.c:1133
RZ_API void rz_bin_reloc_free(RzBinReloc *reloc)
Definition: bin.c:188
RZ_IPI RzBinXtrPlugin * rz_bin_get_xtrplugin_by_name(RzBin *bin, const char *name)
Definition: bin.c:383
static ut64 __getoffset(RzBin *bin, int type, int idx)
Definition: bin.c:28
RZ_API void rz_bin_trycatch_free(RzBinTrycatch *tc)
Definition: bin.c:1190
static ut64 baddr(RzBinFile *bf)
Definition: bin_any.c:58
static RzList * maps(RzBinFile *bf)
Definition: bin_bf.c:116
static RzList * libs(RzBinFile *bf)
Definition: bin_coff.c:379
RZ_API RzBinLanguage rz_bin_language_to_id(const char *language)
returns the language identifier based on the given lang name
Definition: bin_language.c:193
RZ_API const char * rz_bin_language_to_string(RzBinLanguage language)
returns the language name based on the given language identifier
Definition: bin_language.c:229
RzList * sections(RzBinFile *bf)
Definition: bin_ne.c:110
int bits(struct state *s, int need)
Definition: blast.c:72
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
RZ_API const RzBinInfo * rz_bin_object_get_info(RZ_NONNULL RzBinObject *obj)
Get the RzBinInfo of the binary object.
Definition: bobj.c:734
RZ_API const RzList * rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj)
Get list of RzBinAddr representing the entry points of the binary object.
Definition: bobj.c:710
RZ_API const RzList * rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj)
Get list of RzBinImport representing the imports of the binary object.
Definition: bobj.c:726
RZ_API const RzList * rz_bin_object_get_fields(RZ_NONNULL RzBinObject *obj)
Get list of RzBinField representing the fields of the binary object.
Definition: bobj.c:718
RZ_API const RzList * rz_bin_object_get_libs(RZ_NONNULL RzBinObject *obj)
Get list of char* representing the libraries used by the binary object.
Definition: bobj.c:742
RZ_API const RzList * rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj)
Get list of RzBinSection representing both the sections and the segments of the binary object.
Definition: bobj.c:750
RZ_API ut64 rz_bin_object_addr_with_base(RzBinObject *o, ut64 addr)
Put the given address on top of o's base address.
Definition: bobj.c:661
RZ_API const RzList * rz_bin_object_get_strings(RZ_NONNULL RzBinObject *obj)
Get list of RzBinString representing the strings identified in the binary object.
Definition: bobj.c:798
RZ_API const RzList * rz_bin_object_get_mem(RZ_NONNULL RzBinObject *obj)
Get list of RzBinMem representing the memory regions identified in the binary object.
Definition: bobj.c:809
RZ_API const RzList * rz_bin_object_get_symbols(RZ_NONNULL RzBinObject *obj)
Get list of RzBinSymbol representing the symbols in the binary object.
Definition: bobj.c:817
RZ_IPI RzBinObject * rz_bin_object_find_by_arch_bits(RzBinFile *bf, const char *arch, int bits, const char *name)
Definition: bobj.c:644
RZ_API bool rz_bin_object_is_static(RZ_NONNULL RzBinObject *obj)
Return true if the binary object obj is detected as statically compiled.
Definition: bobj.c:883
#define RZ_BIN_STATIC_PLUGINS
Definition: config.h:16
#define RZ_BIN_XTR_STATIC_PLUGINS
Definition: config.h:17
#define RZ_API
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
cs_arch arch
Definition: cstool.c:13
uint32_t ut32
size_t map(int syms, int left, int len)
Definition: enough.c:237
RZ_API char * sdb_fmt(const char *fmt,...)
Definition: fmt.c:26
RZ_API void rz_hash_free(RzHash *rh)
Definition: hash.c:597
RZ_API RzHash * rz_hash_new(void)
Definition: hash.c:585
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API const KEY_TYPE bool * found
Definition: ht_inc.h:130
voidpf void uLong size
Definition: ioapi.h:138
const char * filename
Definition: ioapi.h:137
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
void * p
Definition: libc.cpp:67
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API RZ_OWN char * rz_demangler_cxx(RZ_NONNULL const char *symbol)
Demangles c++ symbols.
Definition: demangler.c:45
RZ_API RZ_OWN char * rz_demangler_objc(RZ_NONNULL const char *symbol)
Demangles objc symbols.
Definition: demangler.c:56
RZ_API RZ_OWN RzDemangler * rz_demangler_new(void)
Initializes the plugin list and returns a RzDemangler struct.
Definition: demangler.c:81
RZ_API RZ_OWN char * rz_demangler_msvc(RZ_NONNULL const char *symbol)
Demangles microsft vc symbols.
Definition: demangler.c:74
RZ_API RZ_OWN char * rz_demangler_java(RZ_NULLABLE const char *symbol)
Demangles java symbols.
Definition: demangler.c:38
RZ_API RZ_OWN char * rz_demangler_rust(RZ_NONNULL const char *symbol)
Demangles rust symbols.
Definition: demangler.c:63
RZ_API void rz_demangler_free(RZ_NULLABLE RzDemangler *dem)
Frees the RzDemangler struct.
Definition: demangler.c:112
RZ_API bool rz_demangler_resolve(RZ_NONNULL RzDemangler *dem, RZ_NULLABLE const char *symbol, RZ_NONNULL const char *language, RZ_NONNULL RZ_OWN char **output)
Resolves a symbol based on its language and return an output that needs to be freed.
Definition: demangler.c:187
static RzMain foo[]
Definition: main.c:11
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 void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
Definition: list.c:574
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
Definition: list.c:60
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")
const char * source
Definition: lz4.h:699
RZ_API void MACH0_() patch_relocs(RzBinFile *bf, struct MACH0_(obj_t) *obj)
Patching of external relocs in a sparse overlay buffer.
Definition: mach0_relocs.c:614
int type
Definition: mipsasm.c:17
int idx
Definition: setup.py:197
const char * name
Definition: op.c:541
int off
Definition: pal.c:13
static bool filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian)
Definition: filter.c:185
static RzSocket * s
Definition: rtr.c:28
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_BIN_METH_INTERNAL
Definition: rz_bin.h:88
RzBinLanguage
Definition: rz_bin.h:145
@ RZ_BIN_LANGUAGE_UNKNOWN
Definition: rz_bin.h:146
@ RZ_BIN_LANGUAGE_GROOVY
Definition: rz_bin.h:157
@ RZ_BIN_LANGUAGE_OBJC
Definition: rz_bin.h:151
@ RZ_BIN_LANGUAGE_KOTLIN
Definition: rz_bin.h:156
@ RZ_BIN_LANGUAGE_RUST
Definition: rz_bin.h:155
@ RZ_BIN_LANGUAGE_JAVA
Definition: rz_bin.h:147
@ RZ_BIN_LANGUAGE_DART
Definition: rz_bin.h:158
@ RZ_BIN_LANGUAGE_CXX
Definition: rz_bin.h:150
@ RZ_BIN_LANGUAGE_SWIFT
Definition: rz_bin.h:152
@ RZ_BIN_LANGUAGE_MSVC
Definition: rz_bin.h:154
#define RZ_BIN_METH_VIRTUAL
Definition: rz_bin.h:92
#define RZ_BIN_METH_CLASS
Definition: rz_bin.h:83
#define RZ_BIN_ENTRY_TYPE_PREINIT
Definition: rz_bin.h:38
#define RZ_BIN_METH_CONSTRUCTOR
Definition: rz_bin.h:103
#define RZ_BIN_METH_FILEPRIVATE
Definition: rz_bin.h:90
#define RZ_BIN_METH_SYNCHRONIZED
Definition: rz_bin.h:96
#define RZ_BIN_LANGUAGE_MASK(x)
Definition: rz_bin.h:162
#define RZ_BIN_ENTRY_TYPE_TLS
Definition: rz_bin.h:37
#define RZ_BIN_METH_PUBLIC
Definition: rz_bin.h:85
#define RZ_BIN_METH_VARARGS
Definition: rz_bin.h:99
#define RZ_BIN_METH_SYNTHETIC
Definition: rz_bin.h:100
#define RZ_BIN_METH_STRICT
Definition: rz_bin.h:101
#define RZ_BIN_ENTRY_TYPE_FINI
Definition: rz_bin.h:36
#define RZ_BIN_METH_ABSTRACT
Definition: rz_bin.h:95
#define RZ_BIN_ENTRY_TYPE_INIT
Definition: rz_bin.h:35
#define RZ_BIN_METH_DECLARED_SYNCHRONIZED
Definition: rz_bin.h:104
#define RZ_BIN_METH_MUTATING
Definition: rz_bin.h:94
#define RZ_BIN_METH_FINAL
Definition: rz_bin.h:91
#define RZ_BIN_METH_MIRANDA
Definition: rz_bin.h:102
#define RZ_BIN_METH_OPEN
Definition: rz_bin.h:89
#define RZ_BIN_ENTRY_TYPE_PROGRAM
Definition: rz_bin.h:33
#define RZ_BIN_METH_CONST
Definition: rz_bin.h:93
#define RZ_BIN_METH_BRIDGE
Definition: rz_bin.h:98
#define RZ_BIN_METH_STATIC
Definition: rz_bin.h:84
#define RZ_BIN_METH_PRIVATE
Definition: rz_bin.h:86
#define RZ_BIN_METH_PROTECTED
Definition: rz_bin.h:87
#define RZ_BIN_METH_NATIVE
Definition: rz_bin.h:97
#define RZ_BIN_ENTRY_TYPE_MAIN
Definition: rz_bin.h:34
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
Definition: buf.c:1166
RZ_API RzBuffer * rz_buf_ref(RzBuffer *b)
Increment the reference count of the buffer.
Definition: buf.c:668
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_io_fd(RZ_NONNULL void *iob, int fd)
Creates a new buffer wrapping a file descriptor accessed through RzIOBind.
Definition: buf.c:490
#define RZ_BUF_SET
Definition: rz_buf.h:14
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
Definition: buf.c:1253
RZ_API RZ_OWN RzBuffer * rz_buf_new_slice(RzBuffer *b, ut64 offset, ut64 size)
Creates a new buffer from a slice of another buffer.
Definition: buf.c:364
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
Definition: buf.c:1225
RZ_API RZ_OWN RzBuffer * rz_buf_new_file(const char *file, int perm, int mode)
Creates a new buffer from a file.
Definition: buf.c:317
RZ_API void rz_event_free(RzEvent *ev)
Definition: event.c:37
RZ_API RzEvent * rz_event_new(void *user)
Definition: event.c:17
RZ_API bool rz_id_storage_set(RzIDStorage *storage, void *data, ut32 id)
Definition: idpool.c:131
RZ_API RzIDStorage * rz_id_storage_new(ut32 start_id, ut32 last_id)
Definition: idpool.c:80
RZ_API void rz_id_storage_free(RzIDStorage *storage)
Definition: idpool.c:270
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API void * rz_mem_dup(const void *s, int l)
Definition: mem.c:319
RZ_API PJ * pj_new(void)
Definition: pj.c:25
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API const char * pj_string(PJ *pj)
Definition: pj.c:57
RZ_API void pj_free(PJ *j)
Definition: pj.c:34
RZ_API PJ * pj_o(PJ *j)
Definition: pj.c:75
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
Definition: pj.c:170
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
#define RZ_STR_DUP(x)
Definition: rz_str.h:69
RZ_API int rz_str_cmp(const char *dst, const char *orig, int len)
Definition: str.c:974
RZ_API int rz_str_ncasecmp(const char *dst, const char *orig, size_t n)
Definition: str.c:129
RZ_API void rz_str_constpool_fini(RzStrConstPool *pool)
Definition: str_constpool.c:15
RZ_API bool rz_str_constpool_init(RzStrConstPool *pool)
Definition: str_constpool.c:10
#define RZ_SYS_DIR
Definition: rz_types.h:218
#define RZ_PERM_R
Definition: rz_types.h:93
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_SYS_BITS
Definition: rz_types.h:520
#define RZ_NONNULL
Definition: rz_types.h:64
int(* PrintfCallback)(const char *str,...) RZ_PRINTF_CHECK(1
Definition: rz_types.h:233
#define RZ_SYS_ARCH
Definition: rz_types.h:519
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define RZ_FREE(x)
Definition: rz_types.h:369
#define RZ_BORROW
Definition: rz_types.h:63
#define RZ_DEPRECATE
Definition: rz_types.h:66
#define st64
Definition: rz_types_base.h:10
#define ST32_MAX
Definition: rz_types_base.h:97
#define RZ_MAX(x, y)
#define UT64_MAX
Definition: rz_types_base.h:86
RZ_API RzPVector * rz_pvector_new(RzPVectorFree free)
Definition: vector.c:302
static void ** rz_pvector_push(RzPVector *vec, void *x)
Definition: rz_vector.h:300
RZ_API Sdb * sdb_new0(void)
Definition: sdb.c:43
RZ_API bool sdb_free(Sdb *s)
Definition: sdb.c:206
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
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
#define O_RDONLY
Definition: sftypes.h:486
#define d(i)
Definition: sha256.c:44
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41
Definition: malloc.c:26
int fd
Definition: gzjoin.c:80
Definition: inftree9.h:24
Definition: gzappend.c:170
Definition: z80asm.h:102
Definition: rz_pj.h:12
const char * arch
Definition: rz_bin.h:414
char * comment
Definition: rz_bin.h:770
ut64 vaddr
Definition: rz_bin.h:762
char * format
Definition: rz_bin.h:771
char * name
Definition: rz_bin.h:767
char * type
Definition: rz_bin.h:768
char * visibility_str
Definition: rz_bin.h:769
ut64 paddr
Definition: rz_bin.h:763
bool format_named
Definition: rz_bin.h:772
const char * type
Definition: rz_bin.h:205
const char * hex
Definition: rz_bin.h:206
bool elf_checks_sections
ELF specific, checks or not ELF sections.
Definition: rz_bin.h:253
bool patch_relocs
ask the bin plugin to fill relocs with valid contents for analysis
Definition: rz_bin.h:250
ut64 loadaddr
starting physical address to read from the target file
Definition: rz_bin.h:249
bool elf_load_sections
ELF specific, load or not ELF sections.
Definition: rz_bin.h:252
bool elf_checks_segments
ELF specific, checks or not ELF sections.
Definition: rz_bin.h:254
ut64 baseaddr
where the linker maps the binary in memory
Definition: rz_bin.h:248
bool big_endian
only used for binary formats that do not specify the endian in the file, but need it to load,...
Definition: rz_bin.h:251
XX curplugin == o->plugin.
Definition: rz_bin.h:298
ut64 loadaddr
Definition: rz_bin.h:307
RzBinObject * o
Definition: rz_bin.h:305
struct rz_bin_t * rbin
Definition: rz_bin.h:316
int fd
when used in combination with RzIO, this refers to the io fd.
Definition: rz_bin.h:300
char * file
Definition: rz_bin.h:299
RzBuffer * buf
Definition: rz_bin.h:303
RzList * xtr_data
Definition: rz_bin.h:314
char * libname
Definition: rz_bin.h:702
char * descriptor
Definition: rz_bin.h:706
char * name
Definition: rz_bin.h:701
char * classname
Definition: rz_bin.h:705
char * claimed_checksum
Definition: rz_bin.h:237
char * type
Definition: rz_bin.h:211
RzList * file_hashes
Definition: rz_bin.h:226
char * intrp
Definition: rz_bin.h:243
char * default_cc
Definition: rz_bin.h:225
char * os
Definition: rz_bin.h:219
char * head_flag
Definition: rz_bin.h:217
char * subsystem
Definition: rz_bin.h:220
char * machine
Definition: rz_bin.h:216
const char * lang
Definition: rz_bin.h:224
char * bclass
Definition: rz_bin.h:212
char * guid
Definition: rz_bin.h:222
char * file
Definition: rz_bin.h:210
char * debug_file_name
Definition: rz_bin.h:223
char * features
Definition: rz_bin.h:218
char * rpath
Definition: rz_bin.h:221
char * cpu
Definition: rz_bin.h:215
char * actual_checksum
Definition: rz_bin.h:236
char * rclass
Definition: rz_bin.h:213
char * arch
Definition: rz_bin.h:214
char * compiler
Definition: rz_bin.h:244
Description of a single memory mapping into virtual memory from a binary.
Definition: rz_bin.h:602
RzList * classes
Definition: rz_bin.h:281
RzBinObjectLoadOptions opts
Definition: rz_bin.h:260
RzList * maps
Definition: rz_bin.h:266
struct rz_bin_plugin_t * plugin
Definition: rz_bin.h:289
RzBinInfo * info
Definition: rz_bin.h:287
RzList * libs
Definition: rz_bin.h:278
RzList * sections
Definition: rz_bin.h:267
st64 baddr_shift
Definition: rz_bin.h:261
bool(* check_buffer)(RzBuffer *buf)
Definition: rz_bin.h:519
ut64(* baddr)(RzBinFile *bf)
Definition: rz_bin.h:521
char * desc
Definition: rz_bin.h:510
char *(* get_name)(RzBinFile *bf, int type, int idx)
Definition: rz_bin.h:547
RzList *(* section_flag_to_rzlist)(ut64 flag)
Definition: rz_bin.h:550
char *(* section_type_to_string)(ut64 type)
Definition: rz_bin.h:549
RzBuffer *(* create)(RzBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt)
Definition: rz_bin.h:551
char * name
Definition: rz_bin.h:509
char * license
Definition: rz_bin.h:513
char * version
Definition: rz_bin.h:512
ut64(* get_offset)(RzBinFile *bf, int type, int idx)
Definition: rz_bin.h:546
char * author
Definition: rz_bin.h:511
bool(* check_filename)(const char *filename)
Definition: rz_bin.h:520
char * language
Definition: rz_bin.h:794
char * format
Definition: rz_bin.h:630
char * name
Definition: rz_bin.h:619
char * visibility_str
Definition: rz_bin.h:686
char * name
Definition: rz_bin.h:675
char * classname
Definition: rz_bin.h:678
char * dname
Definition: rz_bin.h:676
char * libname
Definition: rz_bin.h:677
RZ_NONNULL RzBuffer * buf
Definition: rz_bin.h:597
bool buf_owned
whether buf is owned and freed by this RzBinVirtualFile
Definition: rz_bin.h:598
RZ_OWN RZ_NONNULL char * name
Definition: rz_bin.h:596
RzBuffer * buf
Definition: rz_bin.h:380
RzBinXtrMetadata * metadata
Definition: rz_bin.h:386
bool(* check_buffer)(RzBuffer *b)
Definition: rz_bin.h:398
RzBinXtrData *(* extract_from_bytes)(RzBin *bin, const ut8 *buf, ut64 size, int idx)
Definition: rz_bin.h:400
RzList *(* extractall_from_bytes)(RzBin *bin, const ut8 *buf, ut64 size)
Definition: rz_bin.h:402
RzList *(* extractall_from_buffer)(RzBin *bin, RzBuffer *buf)
Definition: rz_bin.h:403
RzBinXtrData *(* extract_from_buffer)(RzBin *bin, RzBuffer *buf, int idx)
Definition: rz_bin.h:401
RzIOFdOpen fd_open
Definition: rz_io.h:243
RzIO * io
Definition: rz_io.h:232
RzIOFdIsDbg fd_is_dbg
Definition: rz_io.h:252
RzIOFdGetName fd_get_name
Definition: rz_io.h:253
RzIODescGet desc_get
Definition: rz_io.h:235
Definition: rz_io.h:59
const char * name
Definition: rz_main.h:17
uint32_t size
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
Definition: z80_tab.h:997
static int baseaddr
Definition: z80asm.c:79