Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jan 9, 2025
1 parent 613318a commit c9aa2ce
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
19 changes: 18 additions & 1 deletion libr/core/cmd_open.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,13 @@ static void cmd_omf(RCore *core, int argc, char *argv[]) {
const int id = r_num_math (core->num, argv[0]);
RIOMap *map = r_io_map_get (core->io, id);
if (map) {
if (argc > 2) {
bool res = r_io_map_setattr_fromstring (map, argv[2]);
if (!res) {
R_LOG_ERROR ("Invalid meta type string");
break;
}
}
int nperm = r_str_rwx (argv[1]);
if (nperm < 0) {
R_LOG_ERROR ("Invalid permission string");
Expand Down Expand Up @@ -1264,7 +1271,17 @@ static void cmd_open_map(RCore *core, const char *input) {
}
break;
case '?':
r_core_cmd_help (core, help_msg_om);
r_core_cmd_help_match (core, help_msg_om, "omf");
break;
case 0:
{
RIOMap *map = r_io_map_get_at (core->io, core->offset);
if (map) {
char *s = r_io_map_getattr (map);
r_cons_println (s);
free (s);
}
}
break;
default:
r_core_return_invalid_command (core, "omf", input[2]);
Expand Down
4 changes: 2 additions & 2 deletions libr/include/r_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ typedef enum {
#define R_IO_MAP_META_FLAG_LAST 16
typedef enum {
R_IO_MAP_META_FLAG_PAGED, // anything can be non-paged.. must be bitfield
R_IO_MAP_META_TYPE_PRIVATE, // private memory
R_IO_MAP_META_FLAG_PRIVATE, // private memory
R_IO_MAP_META_FLAG_PERSISTENT, // non volatile
R_IO_MAP_META_FLAG_ASLR, // randomizable
R_IO_MAP_META_TYPE_SWAP, // swappage to disk
R_IO_MAP_META_FLAG_SWAP, // swappage to disk
R_IO_MAP_META_FLAG_DEP, // same as W^X
R_IO_MAP_META_FLAG_ENCLAVE, // protected by a secure enclave
R_IO_MAP_META_FLAG_COMPRESSED, // compressed memory
Expand Down
9 changes: 4 additions & 5 deletions libr/io/io_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ static const char* metatypename[R_IO_MAP_META_TYPE_LAST] = {
[R_IO_MAP_META_TYPE_BSS] = "bss",
[R_IO_MAP_META_TYPE_SHARED] = "shared",
[R_IO_MAP_META_TYPE_KERNEL] = "kernel",
[R_IO_MAP_META_TYPE_SWAP] = "swap",
[R_IO_MAP_META_TYPE_GUARD] = "guard",
[R_IO_MAP_META_TYPE_NULL] = "null",
[R_IO_MAP_META_TYPE_GPU] = "gpu",
Expand All @@ -790,10 +789,10 @@ static const char *metaflagname[16] = {
};

R_API bool r_io_map_setattr_fromstring(RIOMap *map, const char *s) {
ut32 mapflag = 0;
int i;
int i, maptype;
for (maptype = 0; maptype < R_IO_MAP_META_TYPE_LAST; maptype++) {
if (strstr (s, metatypename[maptype])) {
ut32 mapflag = 0;
for (i = 0; i < R_IO_MAP_META_FLAG_LAST; i++) {
if (strstr (s, metaflagname[i])) {
mapflag |= (1 << i);
Expand Down Expand Up @@ -823,10 +822,10 @@ R_API char *r_io_map_getattr(RIOMap *map) {
RStrBuf *sb = r_strbuf_new ("");
ut32 maptype = map->meta & 0xffff;
ut32 mapflag = (map->meta > 16) & 0xffff;
if (map->type >= R_IO_MAP_META_TYPE_LAST) {
if (maptype >= R_IO_MAP_META_TYPE_LAST) {
return false;
}
if (flags >= R_IO_MAP_META_FLAG_LAST) {
if (mapflag >= R_IO_MAP_META_FLAG_LAST) {
return false;
}
r_strbuf_append (sb, metatypename[maptype]);
Expand Down

0 comments on commit c9aa2ce

Please sign in to comment.