bool test_r_io_pcache (void) { RIO *io = r_io_new (); ut8 buf[8]; int fd = r_io_fd_open (io, "malloc://3", R_PERM_RW, 0); r_io_map_add (io, fd, R_PERM_RW, 0LL, 0LL, 1); //8 r_io_map_add (io, fd, R_PERM_RW, 1, 1, 1); //= r_io_map_add (io, fd, R_PERM_RW, 1, 2, 1); //= r_io_map_add (io, fd, R_PERM_RW, 1, 3, 1); //= r_io_map_add (io, fd, R_PERM_RW, 1, 4, 1); //= r_io_map_add (io, fd, R_PERM_RW, 1, 5, 1); //= r_io_map_add (io, fd, R_PERM_RW, 2, 6, 1); //D io->p_cache = 2; io->va = true; r_io_fd_write_at (io, fd, 0, (const ut8*)"8=D", 3); r_io_read_at (io, 0x0, buf, 8); mu_assert_streq ((const char *)buf, "", "pcache read happened, but it shouldn't"); io->p_cache = 1; r_io_read_at (io, 0x0, buf, 8); mu_assert_streq ((const char *)buf, "8=====D", "expected an ascii-pn from pcache"); r_io_fd_write_at (io, fd, 0, (const ut8*)"XXX", 3); r_io_read_at (io, 0x0, buf, 8); mu_assert_streq ((const char *)buf, "8=====D", "expected an ascii-pn from pcache"); io->p_cache = 0; r_io_read_at (io, 0x0, buf, 8); mu_assert_streq ((const char *)buf, "XXXXXXX", "expected censorship of the ascii-pn"); r_io_free (io); mu_end; }
static int al_fd_write_at_wrap (RIO *io, int fd, ut64 addr, ut8 *buf, int len, RIOMap *map, void *user) { RIOAccessLog *log = (RIOAccessLog *)user; RIOAccessLogElement *ale = R_NEW0 (RIOAccessLogElement); int rlen = r_io_fd_write_at (io, fd, addr, buf, len); if (ale) { ale->expect_len = len; ale->len = rlen; ale->buf_idx = (int)(size_t)(buf - log->buf); ale->flags = map->flags; ale->fd = fd; ale->mapid = map->id; ale->paddr = addr; ale->vaddr = map->itv.addr + (addr - map->delta); r_list_append (log->log, ale); } else { log->allocation_failed = true; } return rlen; }
static int fd_write_at_wrap (RIO *io, int fd, ut64 addr, ut8 *buf, int len, RIOMap *map, void *user) { return r_io_fd_write_at (io, fd, addr, buf, len); }