Implement #956 (rabin2 -k - prompt) and fix r_bin_load()

This commit is contained in:
pancake 2014-05-22 00:12:30 +02:00
parent e87c1745bb
commit ff939fd048
2 changed files with 26 additions and 7 deletions

View File

@ -84,6 +84,22 @@ static int rabin_show_help(int v) {
return 1;
}
static char *stdin_gets() {
static char buf[96096];
fgets (buf, sizeof (buf)-1, stdin);
if (feof (stdin)) return NULL;
buf[strlen (buf)-1] = 0;
return strdup (buf);
}
static void __sdb_prompt(Sdb *sdb) {
char *line;
for (;(line = stdin_gets ());) {
sdb_query (sdb, line);
free (line);
}
}
static int extract_binobj (RBinFile *bf, RBinObject *o, int idx ) {
ut64 boffset = o ? o->boffset : 0;
ut64 bin_size = o ? o->obj_size : 0;
@ -516,7 +532,9 @@ int main(int argc, char **argv) {
}
if (query) {
sdb_query (bin->cur->sdb, query);
if (!strcmp (query, "-")) {
__sdb_prompt (bin->cur->sdb);
} else sdb_query (bin->cur->sdb, query);
return 0;
}

View File

@ -527,12 +527,13 @@ R_API int r_bin_load_io_at_offset_as(RBin *bin, RIODesc *desc, ut64 baseaddr, ut
// adding file_sz to help reduce the performance impact on the system
// in this case the number of bytes read will be limited to 2MB (MIN_LOAD_SIZE)
// if it fails, the whole file is loaded.
ut64 MIN_LOAD_SIZE = 2 * (1 << 10 << 10);
int res = r_bin_load_io_at_offset_as_sz (bin, desc, baseaddr, loadaddr, xtr_idx, offset, name, MIN_LOAD_SIZE);
if (!res) {
return r_bin_load_io_at_offset_as_sz (bin, desc, baseaddr, loadaddr, xtr_idx, offset, name, UT64_MAX);
}
const ut64 MIN_LOAD_SIZE = 2 * (1 << 10 << 10);
int res = r_bin_load_io_at_offset_as_sz (bin, desc, baseaddr,
loadaddr, xtr_idx, offset, name, MIN_LOAD_SIZE);
if (res)
return res;
return r_bin_load_io_at_offset_as_sz (bin, desc, baseaddr,
loadaddr, xtr_idx, offset, name, UT64_MAX);
}
#if 0