1 /* radare2 - LGPL - Copyright 2009-2019 - pancake, nibble */
2
3 #include <r_types.h>
4 #include <r_util.h>
5 #include <r_bin.h>
6
7 /* XXX Implement r__bin_wr_scn_{ set, del } instead */
r_bin_wr_scn_resize(RBin * bin,const char * name,ut64 size)8 R_API ut64 r_bin_wr_scn_resize(RBin *bin, const char *name, ut64 size) {
9 RBinFile *bf = r_bin_cur (bin);
10 RBinPlugin *plugin = r_bin_file_cur_plugin (bf);
11 if (plugin && plugin->write && plugin->write->scn_resize) {
12 return plugin->write->scn_resize (bf, name, size);
13 }
14 return false;
15 }
16
r_bin_wr_scn_perms(RBin * bin,const char * name,int perms)17 R_API bool r_bin_wr_scn_perms(RBin *bin, const char *name, int perms) {
18 RBinFile *bf = r_bin_cur (bin);
19 RBinPlugin *plugin = r_bin_file_cur_plugin (bf);
20 if (plugin && plugin->write && plugin->write->scn_perms) {
21 return plugin->write->scn_perms (bf, name, perms);
22 }
23 return false;
24 }
25
r_bin_wr_rpath_del(RBin * bin)26 R_API bool r_bin_wr_rpath_del(RBin *bin) {
27 RBinFile *bf = r_bin_cur (bin);
28 RBinPlugin *plugin = r_bin_file_cur_plugin (bf);
29 if (plugin && plugin->write && plugin->write->rpath_del) {
30 return plugin->write->rpath_del (bf);
31 }
32 return false;
33 }
34
r_bin_wr_output(RBin * bin,const char * filename)35 R_API bool r_bin_wr_output(RBin *bin, const char *filename) {
36 r_return_val_if_fail (bin && filename, false);
37 RBinFile *bf = r_bin_cur (bin);
38 if (!bf || !bf->buf) {
39 return false;
40 }
41 ut64 tmpsz;
42 const ut8 *tmp = r_buf_data (bf->buf, &tmpsz);
43 return r_file_dump (filename, tmp, tmpsz, 0);
44 }
45
r_bin_wr_entry(RBin * bin,ut64 addr)46 R_API bool r_bin_wr_entry(RBin *bin, ut64 addr) {
47 RBinFile *bf = r_bin_cur (bin);
48 RBinPlugin *plugin = r_bin_file_cur_plugin (bf);
49 if (plugin && plugin->write && plugin->write->entry) {
50 return plugin->write->entry (bf, addr);
51 }
52 return false;
53 }
54
r_bin_wr_addlib(RBin * bin,const char * lib)55 R_API bool r_bin_wr_addlib(RBin *bin, const char *lib) {
56 RBinFile *bf = r_bin_cur (bin);
57 RBinPlugin *plugin = r_bin_file_cur_plugin (bf);
58 if (plugin && plugin->write && plugin->write->addlib) {
59 return plugin->write->addlib (bin->cur, lib);
60 }
61 return false;
62 }
63