34 bool ret =
true, wrap = !prefix_mode && vaddr +
len < vaddr;
35 #define CMP(addr, part) ((addr) < rz_itv_end(((RzSkylineItem *)(part))->itv) - 1 ? -1 : (addr) > rz_itv_end(((RzSkylineItem *)(part))->itv) - 1 ? 1 \
61 if (addr < part->itv.addr) {
63 if (prefix_mode || len <= part->itv.addr - vaddr) {
75 if (((
map->perm & match_flg) == match_flg || io->
p_cache)) {
92 }
else if (prefix_mode) {
107 return prefix_mode ?
addr - vaddr : ret;
213 rz_list_foreach (desc_list,
iter,
desc) {
216 desc->plugin = plugin;
365 for (
i = 0;
i <
len;
i++) {
429 rz_list_foreach (
maps,
iter, current_map) {
431 if (current_map->
itv.
size == fd_size) {
454 #define IO_EXTEND_BLOCK_SZ 256
468 if (
addr > cur_size) {
493 remaining = remaining > sz ? remaining - sz : 0;
506 #undef IO_EXTEND_BLOCK_SZ
536 return pa -
map->delta +
map->itv.addr;
587 bnd->ptrace = rz_io_ptrace;
588 bnd->ptrace_func = rz_io_ptrace_func;
591 bnd->get_w32dbg_wrap = rz_io_get_w32dbg_wrap;
601 if (!shiftsize || (
end -
start) <= shiftsize) {
658 if (!io->ptrace_wrap) {
660 if (!io->ptrace_wrap) {
668 return io->ptrace_wrap;
685 RZ_API pid_t rz_io_ptrace_fork(
RzIO *io,
void (*child_callback)(
void *),
void *child_callback_user) {
696 child_callback(child_callback_user);
702 RZ_API void *rz_io_ptrace_func(
RzIO *io,
void *(*func)(
void *),
void *user) {
715 RZ_API struct w32dbg_wrap_instance_t *rz_io_get_w32dbg_wrap(
RzIO *io) {
716 if (!io->priv_w32dbg_wrap) {
717 io->priv_w32dbg_wrap = (
struct w32dbg_wrap_instance_t *)
w32dbg_wrap_new();
719 return io->priv_w32dbg_wrap;
738 #if RZ_IO_USE_PTRACE_WRAP
739 if (io->ptrace_wrap) {
741 free(io->ptrace_wrap);
static RzList * maps(RzBinFile *bf)
static static sync static getppid static getegid const char static filename request
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
size_t map(int syms, int left, int len)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API int rz_io_pwrite_at(RzIO *io, ut64 paddr, const ut8 *buf, int len)
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
RZ_API RzIODesc * rz_io_open_nomap(RzIO *io, const char *uri, int perm, int mode)
RZ_API ut64 rz_io_seek(RzIO *io, ut64 offset, int whence)
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API RzList * rz_io_open_many(RzIO *io, const char *uri, int perm, int mode)
#define IO_EXTEND_BLOCK_SZ
RZ_API bool rz_io_extend_at(RzIO *io, ut64 addr, ut64 size)
Extend the RzIODesc at addr by inserting size 0 bytes.
RZ_API bool rz_io_shift(RzIO *io, ut64 start, ut64 end, st64 move)
RZ_API bool rz_io_resize(RzIO *io, ut64 newsize)
RZ_API bool rz_io_vread_at_mapped(RzIO *io, ut64 vaddr, ut8 *buf, int len)
RZ_API void rz_io_free(RzIO *io)
RZ_API bool rz_io_set_write_mask(RzIO *io, const ut8 *mask, int len)
Set a mask that is used on all following write operations.
RZ_API ut64 rz_io_size(RzIO *io)
RZ_API ut64 rz_io_v2p(RzIO *io, ut64 va)
static int fd_read_at_wrap(RzIO *io, int fd, ut64 addr, ut8 *buf, int len, RzIOMap *map, void *user)
RZ_API RzIODesc * rz_io_open_buffer(RzIO *io, RzBuffer *b, int perm, int mode)
RZ_API bool rz_io_reopen(RzIO *io, int fd, int perm, int mode)
RZ_API RzIODesc * rz_io_open_at(RzIO *io, const char *uri, int perm, int mode, ut64 at, RZ_NULLABLE RZ_OUT RzIOMap **map)
Open a file and directly map it at the given offset.
static int fd_write_at_wrap(RzIO *io, int fd, ut64 addr, ut8 *buf, int len, RzIOMap *map, void *user)
RZ_API void rz_io_bind(RzIO *io, RzIOBind *bnd)
RZ_API bool rz_io_is_listener(RzIO *io)
RZ_API int rz_io_close_all(RzIO *io)
static bool rz_io_vwrite_at(RzIO *io, ut64 vaddr, const ut8 *buf, int len)
RZ_API bool rz_io_read_at_mapped(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API ut64 rz_io_p2v(RzIO *io, ut64 pa)
RZ_API int rz_io_fini(RzIO *io)
int(* cbOnIterMap)(RzIO *io, int fd, ut64 addr, ut8 *buf, int len, RzIOMap *map, void *user)
RZ_API bool rz_io_close(RzIO *io)
RZ_API bool rz_io_read(RzIO *io, ut8 *buf, int len)
RZ_API RzIO * rz_io_init(RzIO *io)
RZ_API RzIODesc * rz_io_open(RzIO *io, const char *uri, int perm, int mode)
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, int len)
RZ_API int rz_io_nread_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API bool rz_io_write(RzIO *io, const ut8 *buf, int len)
RZ_API RzIO * rz_io_new(void)
static st64 on_map_skyline(RzIO *io, ut64 vaddr, ut8 *buf, int len, int match_flg, cbOnIterMap op, bool prefix_mode)
RzIOMap * io_map_new(RzIO *io, int fd, int perm, ut64 delta, ut64 addr, ut64 size)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid ptrace
void * ptrace_wrap_func(ptrace_wrap_instance *inst, ptrace_wrap_func_func func, void *user)
void ptrace_wrap_instance_stop(ptrace_wrap_instance *inst)
pid_t ptrace_wrap_fork(ptrace_wrap_instance *inst, void(*child_callback)(void *), void *child_callback_user)
long ptrace_wrap(ptrace_wrap_instance *inst, ptrace_wrap_ptrace_request request, pid_t pid, void *addr, void *data)
int ptrace_wrap_instance_start(ptrace_wrap_instance *inst)
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_DEPRECATE RZ_API RZ_BORROW ut8 * rz_buf_data(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *size)
Return a borrowed array of bytes representing the buffer data.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
RZ_API void rz_event_free(RzEvent *ev)
RZ_API RzEvent * rz_event_new(void *user)
RZ_API bool rz_io_plugin_init(RzIO *io)
RZ_API bool rz_io_fd_resize(RzIO *io, int fd, ut64 newsize)
RZ_API bool rz_io_fd_is_dbg(RzIO *io, int fd)
RZ_API ut64 rz_io_fd_size(RzIO *io, int fd)
RZ_API void rz_io_cache_init(RzIO *io)
RZ_API const char * rz_io_fd_get_name(RzIO *io, int fd)
RZ_IPI bool rz_io_desc_init(RzIO *io)
RZ_API bool rz_io_addr_is_mapped(RzIO *io, ut64 vaddr)
RZ_API void rz_io_map_init(RzIO *io)
RZ_API bool rz_io_cache_read(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API int rz_io_desc_write(RzIODesc *desc, const ut8 *buf, int count)
RZ_API ut64 rz_io_desc_seek(RzIODesc *desc, ut64 offset, int whence)
RZ_API int rz_io_fd_open(RzIO *io, const char *uri, int flags, int mode)
RZ_API bool rz_io_desc_add(RzIO *io, RzIODesc *desc)
RZ_API bool rz_io_map_remap_fd(RzIO *io, int fd, ut64 addr)
RZ_API bool rz_io_cache_write(RzIO *io, ut64 addr, const ut8 *buf, int len)
RZ_API ut64 rz_io_desc_size(RzIODesc *desc)
RZ_API bool rz_io_desc_exchange(RzIO *io, int fd, int fdx)
RZ_API ut8 * rz_io_fd_get_buf(RzIO *io, int fd, RZ_OUT RZ_NONNULL ut64 *size)
Returns the underlying buffer of the file descriptor.
RZ_API int rz_io_fd_read(RzIO *io, int fd, ut8 *buf, int len)
RZ_API bool rz_io_desc_resize(RzIODesc *desc, ut64 newsize)
RZ_API int rz_io_desc_read_at(RzIODesc *desc, ut64 addr, ut8 *buf, int len)
RZ_API int rz_io_fd_read_at(RzIO *io, int fd, ut64 addr, ut8 *buf, int len)
RZ_API RzIOMap * rz_io_map_get_paddr(RzIO *io, ut64 paddr)
RZ_API void rz_io_map_reset(RzIO *io)
RZ_API RzIOMap * rz_io_map_get(RzIO *io, ut64 addr)
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
RZ_API RzList * rz_io_map_get_for_fd(RzIO *io, int fd)
RZ_API void rz_io_cache_fini(RzIO *io)
RZ_API int rz_io_desc_write_at(RzIODesc *desc, ut64 addr, const ut8 *buf, int len)
RZ_API bool rz_io_map_resize(RzIO *io, ut32 id, ut64 newsize)
RZ_IPI bool rz_io_desc_fini(RzIO *io)
RZ_API int rz_io_fd_write_at(RzIO *io, int fd, ut64 addr, const ut8 *buf, int len)
RZ_API bool rz_io_desc_del(RzIO *io, int fd)
RZ_API bool rz_io_is_valid_offset(RzIO *io, ut64 offset, int hasperm)
RZ_API int rz_io_fd_write(RzIO *io, int fd, const ut8 *buf, int len)
RZ_API int rz_io_fd_get_current(RzIO *io)
RZ_API ut64 rz_io_fd_seek(RzIO *io, int fd, ut64 addr, int whence)
RZ_API void rz_io_desc_cache_fini_all(RzIO *io)
RZ_API bool rz_io_use_fd(RzIO *io, int fd)
RZ_API RzIOMap * rz_io_map_new(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
RZ_API RzIOMap * rz_io_map_add(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
RZ_API void rz_io_map_fini(RzIO *io)
RZ_API bool rz_io_fd_close(RzIO *io, int fd)
RZ_API RzIOPlugin * rz_io_plugin_resolve(RzIO *io, const char *filename, bool many)
RZ_API bool rz_io_desc_close(RzIODesc *desc)
RZ_API RzIODesc * rz_io_desc_open(RzIO *io, const char *uri, int flags, int mode)
static ut64 rz_itv_end(RzInterval itv)
RZ_API void * rz_mem_dup(const void *s, int l)
static st64 rz_num_abs(st64 num)
static void rz_skyline_init(RzSkyline *skyline)
#define RZ_STR_ISNOTEMPTY(x)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API int rz_sys_fork(void)
#define UT64_ADD_OVFCHK(x, y)
#define rz_vector_lower_bound(vec, x, i, cmp)
static void * rz_vector_index_ptr(RzVector *vec, size_t index)
static size_t rz_vector_len(const RzVector *vec)
RzIOIsValidOff is_valid_offset
RzIOAddrIsMapped addr_is_mapped
RzIOGetCurrentFd fd_get_current
RzIOFdGetName fd_get_name
RzIOFdWriteAt fd_write_at
RzIOMapGetPaddr map_get_paddr
struct rz_io_plugin_t * plugin
int(* listener)(RzIODesc *io)
int(* close)(RzIODesc *desc)
char *(* system)(RzIO *io, RzIODesc *fd, const char *)
RzList *(* open_many)(RzIO *io, const char *, int perm, int mode)
struct rz_io_desc_t * desc
W32DbgWInst * w32dbg_wrap_new(void)
void w32dbg_wrap_free(W32DbgWInst *inst)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]