Implement @@iS RBin.Section foreach operator

This commit is contained in:
pancake 2018-02-27 23:10:28 +01:00
parent 964cc83a17
commit 6cdd273d5c
3 changed files with 24 additions and 2 deletions

View File

@ -2894,7 +2894,23 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
}
break;
case 'i': // "@@i" - function instructions
{
if (each[1] == 'S') {
RListIter *it;
RBinSection *sec;
RBinObject *obj = r_bin_cur_object (core->bin);
int cbsz = core->blocksize;
r_list_foreach (obj->sections, it, sec){
ut64 addr = sec->vaddr;
ut64 size = sec->vsize;
// TODO:
//if (R_BIN_SCN_EXECUTABLE & sec->srwx) {
// continue;
//}
r_core_seek_size (core, addr, size);
r_core_cmd (core, cmd, 0);
}
r_core_block_size (core, cbsz);
} else {
RListIter *iter;
RAnalBlock *bb;
int i;

View File

@ -2139,7 +2139,7 @@ R_API int r_core_prompt_exec(RCore *r) {
return ret;
}
R_API int r_core_block_size(RCore *core, int bsize) {
R_API int r_core_seek_size(RCore *core, ut64 addr, int bsize) {
ut8 *bump;
int ret = false;
if (bsize < 0) {
@ -2159,6 +2159,7 @@ R_API int r_core_block_size(RCore *core, int bsize) {
eprintf ("Block size %d is too big\n", bsize);
return false;
}
core->offset = addr;
if (bsize < 1) {
bsize = 1;
} else if (core->blocksize_max && bsize>core->blocksize_max) {
@ -2180,6 +2181,10 @@ R_API int r_core_block_size(RCore *core, int bsize) {
return ret;
}
R_API int r_core_block_size(RCore *core, int bsize) {
return r_core_seek_size (core, core->offset, bsize);
}
R_API int r_core_seek_align(RCore *core, ut64 align, int times) {
int diff, inc = (times >= 0)? 1: -1;
ut64 seek = core->offset;

View File

@ -248,6 +248,7 @@ R_API int r_core_seek_align(RCore *core, ut64 align, int count);
R_API void r_core_seek_archbits (RCore *core, ut64 addr);
R_API int r_core_block_read(RCore *core);
R_API int r_core_block_size(RCore *core, int bsize);
R_API int r_core_seek_size(RCore *core, ut64 addr, int bsize);
R_API bool r_core_read_at(RCore *core, ut64 addr, ut8 *buf, int size);
R_API int r_core_is_valid_offset (RCore *core, ut64 offset);
R_API int r_core_shift_block(RCore *core, ut64 addr, ut64 b_size, st64 dist);