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);
}
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;
ut8 *buf;
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;
}
}
eprintf ("dumped 0x%"PFMT64x" bytes\n", i);
r_cons_break_pop ();
fclose (fd);
free (buf);

View File

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