This commit is contained in:
Fangrui Song 2017-09-01 10:34:09 -07:00 committed by radare
parent b496b8804c
commit 800fed2e31
3 changed files with 17 additions and 13 deletions

View File

@ -60,7 +60,7 @@ R_API int r_core_seek_base (RCore *core, const char *hex) {
return r_core_seek (core, addr, 1); return r_core_seek (core, addr, 1);
} }
R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int append) { R_API bool r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int append) {
ut64 i; ut64 i;
ut8 *buf; ut8 *buf;
int bs = core->blocksize; int bs = core->blocksize;
@ -98,7 +98,6 @@ R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int a
break; break;
} }
} }
eprintf ("dumped 0x%"PFMT64x" bytes\n", i);
r_cons_break_pop (); r_cons_break_pop ();
fclose (fd); fclose (fd);
free (buf); free (buf);

View File

@ -1161,26 +1161,31 @@ static int cmd_write(void *data, const char *input) {
if ((st64)sz < 1) { if ((st64)sz < 1) {
// wtf? // wtf?
sz = 0; sz = 0;
} else { } else if (!r_core_dump (core, filename, poff, (ut64)sz, append)) {
r_core_dump (core, filename, poff, (ut64)sz, append); sz = -1;
} }
} else { } else {
if (toend) { if (toend) {
sz = r_io_fd_size (core->io, core->file->fd); sz = r_io_fd_size (core->io, core->file->fd);
if (sz <= core->offset) { if (sz != -1 && core->offset <= sz) {
sz -= core->offset; sz -= core->offset;
r_core_dump (core, filename, core->offset, (ut64)sz, append); if (!r_core_dump (core, filename, core->offset, (ut64)sz, append)) {
sz = -1;
}
} else {
sz = -1;
} }
} else { } else {
if (!r_file_dump (filename, core->block, core->blocksize, append)) { sz = core->blocksize;
sz = 0; if (!r_file_dump (filename, core->block, sz, append)) {
} else { sz = -1;
sz = core->blocksize;
} }
} }
} }
eprintf ("Dumped %"PFMT64d" bytes from 0x%08"PFMT64x" into %s\n", if (sz >= 0) {
sz, poff, filename); eprintf ("Dumped %"PFMT64d" bytes from 0x%08"PFMT64x" into %s\n",
sz, poff, filename);
}
} }
break; break;
case 'f': case 'f':

View File

@ -548,7 +548,7 @@ R_API int r_core_patch (RCore *core, const char *patch);
R_API void r_core_hack_help(const RCore *core); R_API void r_core_hack_help(const RCore *core);
R_API int r_core_hack(RCore *core, const char *op); R_API int r_core_hack(RCore *core, const char *op);
R_API int r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int append); R_API bool r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int append);
R_API void r_core_diff_show(RCore *core, RCore *core2); R_API void r_core_diff_show(RCore *core, RCore *core2);
R_API void r_core_clippy(const char *msg); R_API void r_core_clippy(const char *msg);