From 86d2c31c37df9c5df29df2fa44996d1bcfca29e5 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 23 Sep 2017 02:23:26 +0200 Subject: [PATCH] omm works without args now --- libr/core/cmd_open.c | 8 ++++++-- libr/io/desc.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libr/core/cmd_open.c b/libr/core/cmd_open.c index 21ab38e069..db9969c552 100644 --- a/libr/core/cmd_open.c +++ b/libr/core/cmd_open.c @@ -80,7 +80,7 @@ static const char *help_msg_om[] = { "om", " [fd]", "list all defined IO maps for a specific fd", "om", "-mapid", "remove the map with corresponding id", "om", " fd vaddr [size] [paddr] [name]", "create new io map", - "omm"," fd", "create default map for given fd. (omm `oq`)", + "omm"," [fd]", "create default map for given fd. (omm `oq`)", "om.", "", "show map, that is mapped to current offset", "omn", " mapid [name]", "set/delete name for map with mapid", "omf", " [mapid] rwx", "change flags/perms for current/given map", @@ -663,8 +663,12 @@ static void cmd_open_map(RCore *core, const char *input) { break; case 'm': // "omm" { - ut64 fd = r_num_math (core->num, input + 3); + ut64 fd = input[3]? r_num_math (core->num, input + 3): UT64_MAX; RIODesc *desc = r_io_desc_get (core->io, fd); + if (!desc) { + fd = r_io_fd_get_current (core->io); + desc = r_io_desc_get (core->io, fd); + } if (desc) { ut64 size = r_io_desc_size (desc); map = r_io_map_add (core->io, fd, desc->flags, 0, 0, size, true); diff --git a/libr/io/desc.c b/libr/io/desc.c index fefe4b6f8d..6a3b46a949 100644 --- a/libr/io/desc.c +++ b/libr/io/desc.c @@ -209,7 +209,7 @@ R_API bool r_io_desc_resize(RIODesc *desc, ut64 newsize) { return false; } -R_API bool r_io_desc_is_blockdevice (RIODesc *desc) { +R_API bool r_io_desc_is_blockdevice(RIODesc *desc) { if (!desc || !desc->plugin || !desc->plugin->is_blockdevice) { return false; }