Enable io-bank support in r_io_map_new ##io

This commit is contained in:
condret 2021-10-09 23:44:07 +02:00
parent 814ebb9f68
commit 87a38708e0
2 changed files with 13 additions and 9 deletions

View File

@ -180,7 +180,7 @@ R_API RIODesc* r_io_open_at(RIO* io, const char* uri, int perm, int mode, ut64 a
// second map
if (size && ((UT64_MAX - size + 1) < at)) {
// split map into 2 maps if only 1 big map results into interger overflow
io_map_new (io, desc->fd, desc->perm, UT64_MAX - at + 1, 0LL, size - (UT64_MAX - at) - 1);
r_io_map_new (io, desc->fd, desc->perm, UT64_MAX - at + 1, 0LL, size - (UT64_MAX - at) - 1);
// someone pls take a look at this confusing stuff
size = UT64_MAX - at + 1;
}

View File

@ -24,7 +24,7 @@ static void io_map_calculate_skyline(RIO *io) {
}
}
RIOMap* io_map_new(RIO* io, int fd, int perm, ut64 delta, ut64 addr, ut64 size) {
R_API RIOMap *r_io_map_new(RIO* io, int fd, int perm, ut64 delta, ut64 addr, ut64 size) {
r_return_val_if_fail (io && io->map_ids, NULL);
if (!size) {
return NULL;
@ -39,7 +39,7 @@ RIOMap* io_map_new(RIO* io, int fd, int perm, ut64 delta, ut64 addr, ut64 size)
map->delta = delta;
map->ts = io->mts++;
if ((UT64_MAX - size + 1) < addr) {
io_map_new (io, fd, perm, delta - addr, 0LL, size + addr);
r_io_map_new (io, fd, perm, delta - addr, 0LL, size + addr);
size = -(st64)addr;
}
// RIOMap describes an interval of addresses
@ -49,14 +49,18 @@ RIOMap* io_map_new(RIO* io, int fd, int perm, ut64 delta, ut64 addr, ut64 size)
map->delta = delta;
// new map lives on the top, being top the list's tail
r_pvector_push (&io->maps, map);
r_skyline_add (&io->map_skyline, map->itv, map);
if (io->use_banks) {
if (!r_io_bank_map_add_top (io, io->bank, map->id)) {
r_id_pool_kick_id (io->map_ids, map->id);
free (map);
return NULL;
}
} else {
r_skyline_add (&io->map_skyline, map->itv, map);
}
return map;
}
R_API RIOMap *r_io_map_new(RIO *io, int fd, int perm, ut64 delta, ut64 addr, ut64 size) {
return io_map_new (io, fd, perm, delta, addr, size);
}
R_API bool r_io_map_remap(RIO *io, ut32 id, ut64 addr) {
RIOMap *map = r_io_map_get (io, id);
if (map) {
@ -139,7 +143,7 @@ R_API RIOMap *r_io_map_add(RIO *io, int fd, int perm, ut64 delta, ut64 addr, ut6
RIODesc* desc = r_io_desc_get (io, fd);
if (desc) {
//a map cannot have higher permissions than the desc belonging to it
return io_map_new (io, fd, (perm & desc->perm) | (perm & R_PERM_X),
return r_io_map_new (io, fd, (perm & desc->perm) | (perm & R_PERM_X),
delta, addr, size);
}
return NULL;