Enhancement for wt dumper

This commit is contained in:
pancake 2015-08-19 01:58:27 +02:00
parent 4a22a56c12
commit 869ab6000e
2 changed files with 13 additions and 6 deletions

View File

@ -697,7 +697,7 @@ static int cmd_write(void *data, const char *input) {
} }
} else if (*str != ' ') { } else if (*str != ' ') {
const char* prefix = r_config_get (core->config, "cfg.prefixdump"); const char* prefix = r_config_get (core->config, "cfg.prefixdump");
snprintf(_fn, sizeof(_fn), "%s.0x%08"PFMT64x, prefix, core->offset); snprintf (_fn, sizeof(_fn), "%s.0x%08"PFMT64x, prefix, core->offset);
filename = _fn; filename = _fn;
} else filename = str+1; } else filename = str+1;
tmp = strchr (str+1, ' '); tmp = strchr (str+1, ' ');

View File

@ -83,15 +83,22 @@ R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int a
eprintf ("Cannot open '%s' for writing\n", file); eprintf ("Cannot open '%s' for writing\n", file);
return R_FALSE; return R_FALSE;
} }
/* some io backends seems to be buggy in those cases */
if (bs > 4096)
bs = 4096;
buf = malloc (bs); buf = malloc (bs);
if (!buf) {
eprintf ("Cannot alloc %d bytes\n", bs);
return R_FALSE;
}
r_cons_break (NULL, NULL); r_cons_break (NULL, NULL);
for (i=0; i<size; i+=bs) { for (i = 0; i<size; i += bs) {
if (r_cons_singleton ()->breaked) if (r_cons_singleton ()->breaked)
break; break;
if ((i+bs)>size) if ((i + bs) > size)
bs = size-i; bs = size - i;
r_io_read_at (core->io, addr+i, buf, bs); r_io_read_at (core->io, addr + i, buf, bs);
if (fwrite (buf, bs, 1, fd) <1) { if (fwrite (buf, bs, 1, fd) < 1) {
eprintf ("write error\n"); eprintf ("write error\n");
break; break;
} }