mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-01 18:57:20 +00:00
Added 'oob', 'oon' and 'oo?'. Close RBinObjects with RCoreFiles
This commit is contained in:
parent
da866539ee
commit
1c583a4b39
@ -1533,7 +1533,7 @@ static int cmd_debug(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
r_core_file_reopen (core, input[1]? input+2: NULL, 0);
|
||||
r_core_file_reopen (core, input[1]? input+2: NULL, 0, 1);
|
||||
break;
|
||||
case 'w':
|
||||
r_cons_break (static_debug_stop, core->dbg);
|
||||
|
@ -261,8 +261,33 @@ static int cmd_open(void *data, const char *input) {
|
||||
r_core_block_read (core, 0);
|
||||
break;
|
||||
case 'o':
|
||||
r_core_file_reopen (core, input+2,
|
||||
(input[1]=='+')?R_IO_READ|R_IO_WRITE:0);
|
||||
switch (input[1]) {
|
||||
case 'b': // "oob" : reopen with bin info
|
||||
r_core_file_reopen (core, input+2, 0, 2);
|
||||
break;
|
||||
case 'n':
|
||||
r_core_file_reopen (core, input+2, 0, 0);
|
||||
break;
|
||||
case '+':
|
||||
r_core_file_reopen (core, input+2, R_IO_READ | R_IO_WRITE, 1);
|
||||
break;
|
||||
case 0: // "oo"
|
||||
r_core_file_reopen (core, input+2, 0, 1);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
{
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "oo[-] [arg]", " # map opened files",
|
||||
"oo", "", "reopen current file",
|
||||
"oob", "", "reopen loading rbin info",
|
||||
"oon", "", "reopen without loading rbin info",
|
||||
"oo+", "", "reopen in read-write",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
// memleak? lose all settings wtf
|
||||
|
@ -11,7 +11,7 @@ static int r_core_file_do_load_for_io_plugin (RCore *r, ut64 baseaddr, ut64 load
|
||||
|
||||
|
||||
// TODO: add support for args
|
||||
R_API int r_core_file_reopen(RCore *core, const char *args, int perm) {
|
||||
R_API int r_core_file_reopen(RCore *core, const char *args, int perm, int loadbin) {
|
||||
int isdebug = r_config_get_i (core->config, "cfg.debug");
|
||||
char *path;
|
||||
ut64 ofrom = 0, baddr = 0; // XXX ? check file->map ?
|
||||
@ -68,7 +68,11 @@ R_API int r_core_file_reopen(RCore *core, const char *args, int perm) {
|
||||
// when the new memory maps are created.
|
||||
file = r_core_file_open (core, path, perm, baddr);
|
||||
if (file) {
|
||||
int had_rbin_info = 0;
|
||||
ofile->map->from = ofrom;
|
||||
if (r_bin_file_delete (core->bin, ofile->desc->fd)) {
|
||||
had_rbin_info = 1;
|
||||
}
|
||||
r_core_file_close (core, ofile);
|
||||
r_core_file_set_by_file (core, file);
|
||||
r_core_file_set_by_fd (core, file->desc->fd);
|
||||
@ -78,9 +82,11 @@ R_API int r_core_file_reopen(RCore *core, const char *args, int perm) {
|
||||
eprintf ("File %s reopened in %s mode\n", path,
|
||||
(perm&R_IO_WRITE)? "read-write": "read-only");
|
||||
|
||||
ret = r_core_bin_load (core, obinfilepath, baddr);
|
||||
if (!ret) {
|
||||
eprintf ("Error: Failed to reload rbin for: %s", path);
|
||||
if (loadbin && (loadbin==2 || had_rbin_info)) {
|
||||
ret = r_core_bin_load (core, obinfilepath, baddr);
|
||||
if (!ret) {
|
||||
eprintf ("Error: Failed to reload rbin for: %s", path);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -213,7 +213,7 @@ R_API int r_core_visual_xrefs_X (RCore *core);
|
||||
|
||||
R_API int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback cb);
|
||||
R_API int r_core_serve(RCore *core, RIODesc *fd);
|
||||
R_API int r_core_file_reopen(RCore *core, const char *args, int perm);
|
||||
R_API int r_core_file_reopen(RCore *core, const char *args, int perm, int binload);
|
||||
R_API RCoreFile * r_core_file_find_by_fd(RCore* core, ut64 fd);
|
||||
R_API RCoreFile * r_core_file_find_by_name (RCore * core, const char * name);
|
||||
R_API RCoreFile * r_core_file_cur (RCore *r);
|
||||
|
@ -143,8 +143,6 @@ static int r_io_def_mmap_read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
|
||||
RIOMMapFileObj *mmo = NULL;
|
||||
if (!fd || !fd->data || !buf) {
|
||||
// in this case we fallback reopening in raw mode
|
||||
eprintf ("MAJOR FAILURE fOR %p %p\n", fd, fd->data);
|
||||
asm("int3");
|
||||
return -1;
|
||||
}
|
||||
if (io->off==UT64_MAX) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user