15 #define RZ_IO_SEEK_SET 0
16 #define RZ_IO_SEEK_CUR 1
17 #define RZ_IO_SEEK_END 2
19 #define rz_io_map_get_from(map) map->itv.addr
20 #define rz_io_map_get_to(map) (rz_itv_size(map->itv) ? rz_itv_end(map->itv) - 1 : 0)
25 #include <sys/types.h>
27 #if DEBUGGER && HAVE_PTRACE
28 #include <sys/ptrace.h>
32 #if (defined(__GLIBC__) && defined(__linux__))
34 typedef void *rz_ptrace_data_t;
35 #define RZ_PTRACE_NODATA NULL
38 typedef int rz_ptrace_request_t;
39 typedef void *rz_ptrace_data_t;
40 #define RZ_PTRACE_NODATA NULL
41 #elif __APPLE__ || __OpenBSD__ || __NetBSD__ || __FreeBSD__ || __DragonFly__
42 typedef int rz_ptrace_request_t;
43 typedef int rz_ptrace_data_t;
44 #define RZ_PTRACE_NODATA 0
46 typedef int rz_ptrace_request_t;
47 typedef void *rz_ptrace_data_t;
48 #define RZ_PTRACE_NODATA NULL
87 struct w32dbg_wrap_instance_t *priv_w32dbg_wrap;
169 #define RZ_IO_DESC_CACHE_SIZE (sizeof(ut64) * 8)
213 typedef const char *(*RzIOFdGetName)(
RzIO *
io,
int fd);
224 typedef void *(*RzIOPtraceFuncFn)(
RzIO *
io,
void *(*func)(
void *),
void *user);
227 typedef struct w32dbg_wrap_instance_t *(*RzIOGetW32DbgWrap)(
RzIO *io);
266 RzIOPtraceFuncFn ptrace_func;
269 RzIOGetW32DbgWrap get_w32dbg_wrap;
344 #define rz_io_bind_init(x) memset(&x, 0, sizeof(x))
429 #define rz_io_range_new() RZ_NEW0(RzIORange)
430 #define rz_io_range_free(x) free(x)
440 RZ_API pid_t rz_io_ptrace_fork(
RzIO *io,
void (*child_callback)(
void *),
void *child_callback_user);
441 RZ_API void *rz_io_ptrace_func(
RzIO *io,
void *(*func)(
void *),
void *user);
445 RZ_API struct w32dbg_wrap_instance_t *rz_io_get_w32dbg_wrap(
RzIO *io);
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 count
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
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 long
size_t map(int syms, int left, int len)
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
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
long ptrace_wrap(ptrace_wrap_instance *inst, ptrace_wrap_ptrace_request request, pid_t pid, void *addr, void *data)
RZ_API RzIODesc * rz_io_open(RzIO *io, const char *uri, int flags, int mode)
RZ_API int rz_io_plugin_write(RzIODesc *desc, const ut8 *buf, int len)
RZ_API bool rz_io_plugin_init(RzIO *io)
RZ_API RzIOMap * rz_io_map_resolve(RzIO *io, ut32 id)
RZ_API bool rz_io_fd_resize(RzIO *io, int fd, ut64 newsize)
struct rz_event_io_map_del_t RzEventIOMapDel
struct rz_io_bind_t RzIOBind
struct rz_io_desc_cache_t RzIODescCache
int(* RzIOFdReadAt)(RzIO *io, int fd, ut64 addr, ut8 *buf, int len)
RZ_API int rz_io_pwrite_at(RzIO *io, ut64 paddr, const ut8 *buf, int len)
RZ_API bool rz_io_fd_is_dbg(RzIO *io, int fd)
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
RZ_API void rz_io_map_cleanup(RzIO *io)
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)
RzIOPlugin rz_io_plugin_tcp
RZ_API int rz_io_cache_invalidate(RzIO *io, ut64 from, ut64 to)
RZ_IPI bool rz_io_desc_init(RzIO *io)
RzIOPlugin rz_io_plugin_procpid
RZ_API bool rz_io_fd_is_chardevice(RzIO *io, int fd)
RZ_API ut64 rz_io_seek(RzIO *io, ut64 offset, int whence)
RzIODesc *(* RzIOOpen)(RzIO *io, const char *uri, int flags, int mode)
RZ_API bool rz_io_cache_at(RzIO *io, ut64 addr)
bool(* RzIOFdResize)(RzIO *io, int fd, ut64 newsize)
RzIODesc *(* RzIODescGet)(RzIO *io, int fd)
RZ_API bool rz_io_addr_is_mapped(RzIO *io, ut64 vaddr)
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API bool rz_io_map_exists_for_id(RzIO *io, ut32 id)
RZ_API RzIODesc * rz_io_desc_open_plugin(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode)
RzIOPlugin rz_io_plugin_null
struct rz_event_io_write_t RzEventIOWrite
RZ_API void rz_io_cache_reset(RzIO *io, int set)
char *(* RzIOSystem)(RzIO *io, const char *cmd)
RZ_API void rz_io_desc_free(RzIODesc *desc)
RzIOPlugin rz_io_plugin_gprobe
RZ_API void rz_io_map_init(RzIO *io)
RZ_API bool rz_io_fd_get_base(RzIO *io, int fd, ut64 *base)
RzIOPlugin rz_io_plugin_gdb
int(* RzIOGetCurrentFd)(RzIO *io)
int(* RzIOFdWrite)(RzIO *io, int fd, const ut8 *buf, int len)
RZ_API bool rz_io_cache_read(RzIO *io, ut64 addr, ut8 *buf, int len)
RzIOPlugin rz_io_plugin_bochs
RzIOPlugin rz_io_plugin_gzip
RZ_API int rz_io_fd_get_tid(RzIO *io, int fd)
bool(* RzIOClose)(RzIO *io, int fd)
RzIOPlugin rz_io_plugin_w32dbg
RZ_API bool rz_io_desc_is_blockdevice(RzIODesc *desc)
RZ_API RzList * rz_io_open_many(RzIO *io, const char *uri, int flags, int mode)
RZ_API bool rz_io_map_del_for_fd(RzIO *io, int fd)
RZ_API int rz_io_desc_write(RzIODesc *desc, const ut8 *buf, int count)
RZ_API bool rz_io_desc_cache_commit(RzIODesc *desc)
RZ_API ut64 rz_io_desc_seek(RzIODesc *desc, ut64 offset, int whence)
RZ_API bool rz_io_map_del(RzIO *io, ut32 id)
RZ_LIB_VERSION_HEADER(rz_io)
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 int rz_io_fd_open(RzIO *io, const char *uri, int flags, int mode)
RZ_API bool rz_io_shift(RzIO *io, ut64 start, ut64 end, st64 move)
RZ_API bool rz_io_resize(RzIO *io, ut64 newsize)
RzIOPlugin rz_io_plugin_ihex
ut64(* RzIOV2P)(RzIO *io, ut64 va)
RZ_API bool rz_io_map_exists(RzIO *io, RzIOMap *map)
RzIOPlugin rz_io_plugin_sparse
RZ_API bool rz_io_desc_add(RzIO *io, RzIODesc *desc)
RZ_API void rz_io_map_del_name(RzIOMap *map)
RZ_API bool rz_io_map_remap_fd(RzIO *io, int fd, ut64 addr)
RzIOPlugin rz_io_plugin_shm
bool(* RzIOWriteAt)(RzIO *io, ut64 addr, const ut8 *buf, int len)
RZ_API bool rz_io_cache_write(RzIO *io, ut64 addr, const ut8 *buf, int len)
bool(* RzIOFdIsDbg)(RzIO *io, int fd)
RZ_API bool rz_io_map_depriorize(RzIO *io, ut32 id)
RZ_API bool rz_io_vread_at_mapped(RzIO *io, ut64 vaddr, ut8 *buf, int len)
RzIOPlugin rz_io_plugin_srec
RZ_API RzIODesc * rz_io_open_at(RzIO *io, const char *uri, int flags, int mode, ut64 at, RZ_NULLABLE RZ_OUT RzIOMap **map)
Open a file and directly map it at the given offset.
RZ_API ut64 rz_io_desc_size(RzIODesc *desc)
RZ_API ut64 rz_io_map_next_available(RzIO *io, ut64 addr, ut64 size, ut64 load_align)
RzIOPlugin rz_io_plugin_self
RZ_API void rz_io_desc_cache_fini(RzIODesc *desc)
RZ_API bool rz_io_desc_exchange(RzIO *io, int fd, int fdx)
bool(* RzIOFdClose)(RzIO *io, int fd)
RZ_API void rz_io_free(RzIO *io)
ut64(* RzIOP2V)(RzIO *io, ut64 pa)
RZ_API int rz_io_desc_get_tid(RzIODesc *desc)
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 RzIODesc * rz_io_desc_new(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode, void *data)
RZ_API bool rz_io_map_priorize(RzIO *io, ut32 id)
RZ_API ut64 rz_io_map_next_address(RzIO *io, ut64 addr)
RzIOPlugin rz_io_plugin_zip
RZ_API int rz_io_desc_cache_write(RzIODesc *desc, ut64 paddr, const ut8 *buf, int len)
RZ_API ut64 rz_io_size(RzIO *io)
RZ_API bool rz_io_fd_is_blockdevice(RzIO *io, int fd)
RzIOPlugin rz_io_plugin_http
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 ut64 rz_io_v2p(RzIO *io, ut64 va)
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_desc_cache_read(RzIODesc *desc, ut64 paddr, ut8 *buf, int len)
RzIOPlugin rz_io_plugin_rzk
RzIOMap *(* RzIOMapGetPaddr)(RzIO *io, ut64 paddr)
RZ_API bool rz_io_read_i(RzIO *io, ut64 addr, ut64 *val, int size, bool endian)
RZ_API int rz_io_fd_read_at(RzIO *io, int fd, ut64 addr, ut8 *buf, int len)
const char *(* RzIOFdGetName)(RzIO *io, int fd)
RZ_API RzIOMap * rz_io_map_get_paddr(RzIO *io, ut64 paddr)
struct rz_event_io_desc_close_t RzEventIODescClose
struct rz_io_cache_t RzIOCache
RZ_API void rz_io_map_reset(RzIO *io)
RzIOPlugin rz_io_plugin_bfdbg
RZ_API RzIOMap * rz_io_map_add_batch(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
RZ_API RzIOMap * rz_io_map_get(RzIO *io, ut64 addr)
RZ_API bool rz_io_map_priorize_for_fd(RzIO *io, int fd)
RZ_API RzList * rz_io_desc_cache_list(RzIODesc *desc)
RZ_API int rz_io_desc_read(RzIODesc *desc, ut8 *buf, int count)
RZ_API bool rz_io_map_remap(RzIO *io, ut32 id, ut64 addr)
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
bool(* RzIOAddrIsMapped)(RzIO *io, ut64 addr)
RZ_API int rz_io_desc_get_pid(RzIODesc *desc)
RZ_API RzList * rz_io_map_get_for_fd(RzIO *io, int fd)
RzIOPlugin rz_io_plugin_rzpipe
RzIOPlugin rz_io_plugin_w32
RZ_API void rz_io_bind(RzIO *io, RzIOBind *bnd)
RZ_API int rz_io_plugin_read(RzIODesc *desc, ut8 *buf, int len)
ut64(* RzIODescSize)(RzIODesc *desc)
RZ_API bool rz_io_desc_is_chardevice(RzIODesc *desc)
RzIOPlugin rz_io_plugin_dmp
RZ_API bool rz_io_is_listener(RzIO *io)
RzIOMap *(* RzIOMapGet)(RzIO *io, ut64 addr)
RzIOPlugin rz_io_plugin_default
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_API void rz_io_update(RzIO *io)
RzIOPlugin rz_io_plugin_ptrace
RZ_API int rz_io_close_all(RzIO *io)
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 bool rz_io_map_is_mapped(RzIO *io, ut64 addr)
RZ_IPI bool rz_io_desc_fini(RzIO *io)
bool(* RzIODescUse)(RzIO *io, int fd)
RZ_API int rz_io_fini(RzIO *io)
RZ_API int rz_io_plugin_read_at(RzIODesc *desc, ut64 addr, ut8 *buf, int len)
RZ_API int rz_io_fd_write_at(RzIO *io, int fd, ut64 addr, const ut8 *buf, int len)
int(* RzIOFdWriteAt)(RzIO *io, int fd, ut64 addr, const ut8 *buf, int len)
ut8 *(* RzIOFdGetBuf)(RzIO *io, int fd, ut64 *size)
RZ_API bool rz_io_desc_del(RzIO *io, int fd)
bool(* RzIOReadAt)(RzIO *io, ut64 addr, ut8 *buf, int len)
ut64(* RzIOFdSeek)(RzIO *io, int fd, ut64 addr, int whence)
ut64(* RzIOFdSize)(RzIO *io, int fd)
RZ_API RZ_BORROW RzPVector * rz_io_maps(RzIO *io)
Returns the pointer to vector containing maps list.
RZ_API bool rz_io_reopen(RzIO *io, int fd, int flags, int mode)
RzIOPlugin rz_io_plugin_windbg
RZ_API bool rz_io_close(RzIO *io)
RzIOPlugin rz_io_plugin_rap
bool(* RzIOIsValidOff)(RzIO *io, ut64 addr, int hasperm)
RZ_API bool rz_io_read(RzIO *io, ut8 *buf, int len)
struct rz_io_desc_t RzIODesc
RZ_API RzIO * rz_io_init(RzIO *io)
RzIODesc *(* RzIOOpenAt)(RzIO *io, const char *uri, int flags, int mode, ut64 at, RZ_NULLABLE RZ_OUT RzIOMap **map)
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)
RzIOMap *(* RzIOMapAdd)(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
RzIOPlugin rz_io_plugin_malloc
RZ_API int rz_io_fd_get_current(RzIO *io)
RZ_API RzIODesc * rz_io_open_buffer(RzIO *io, RzBuffer *b, int flags, int mode)
RZ_API RzIOPlugin * rz_io_plugin_get_default(RzIO *io, const char *filename, bool many)
RzIOPlugin rz_io_plugin_winedbg
RzIOPlugin rz_io_plugin_mach
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
RZ_API RzIODesc * rz_io_open_nomap(RzIO *io, const char *uri, int flags, int mode)
RZ_API int rz_io_fd_get_pid(RzIO *io, int fd)
RZ_API ut64 rz_io_fd_seek(RzIO *io, int fd, ut64 addr, int whence)
RZ_API int rz_io_fd_get_highest(RzIO *io)
RZ_API void rz_io_cache_commit(RzIO *io, ut64 from, ut64 to)
RZ_API void rz_io_desc_cache_fini_all(RzIO *io)
RZ_API bool rz_io_use_fd(RzIO *io, int fd)
RzIOPlugin rz_io_plugin_winkd
RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, int len)
RZ_API void rz_io_desc_cache_cleanup(RzIODesc *desc)
RzList *(* RzIOFdGetMap)(RzIO *io, int fd)
int(* RzIOFdOpen)(RzIO *io, const char *uri, int flags, int mode)
RZ_API bool rz_io_desc_cache_init(RzIODesc *desc)
bool(* RzIOFdRemap)(RzIO *io, int fd, ut64 addr)
RzIOPlugin rz_io_plugin_qnx
RZ_API int rz_io_nread_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API RzIOMap * rz_io_map_new(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
RZ_API bool rz_io_desc_is_dbg(RzIODesc *desc)
RZ_API void rz_io_map_set_name(RzIOMap *map, const char *name)
RZ_API int rz_io_fd_get_prev(RzIO *io, int fd)
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)
RzIOPlugin rz_io_plugin_fd
int(* RzIOFdRead)(RzIO *io, int fd, ut8 *buf, int len)
RZ_API bool rz_io_write(RzIO *io, const ut8 *buf, int len)
RZ_API ut64 rz_io_map_location(RzIO *io, ut64 size)
Returns a memory location that can hold enough bytes without overlapping.
struct rz_io_map_t RzIOMap
RZ_API bool rz_io_fd_close(RzIO *io, int fd)
RzIOPlugin rz_io_plugin_debug
RZ_API int rz_io_plugin_write_at(RzIODesc *desc, ut64 addr, const ut8 *buf, int len)
RZ_API bool rz_io_write_i(RzIO *io, ut64 addr, ut64 *val, int size, bool endian)
RZ_API RzIOPlugin * rz_io_plugin_resolve(RzIO *io, const char *filename, bool many)
RzIOPlugin rz_io_plugin_ar
RZ_API int rz_io_fd_get_lowest(RzIO *io)
RZ_API RzIO * rz_io_new(void)
#define RZ_IO_DESC_CACHE_SIZE
RzIOPlugin rz_io_plugin_rzweb
RZ_API bool rz_io_plugin_add(RzIO *io, RZ_BORROW RzIOPlugin *plugin)
struct rz_io_plugin_t RzIOPlugin
RZ_API int rz_io_fd_get_next(RzIO *io, int fd)
RZ_API bool rz_io_desc_close(RzIODesc *desc)
RZ_API bool rz_io_desc_get_base(RzIODesc *desc, ut64 *base)
RZ_API RzIODesc * rz_io_desc_open(RzIO *io, const char *uri, int flags, int mode)
RZ_API ut8 * rz_io_desc_get_buf(RzIODesc *desc, RZ_OUT RZ_NONNULL ut64 *size)
Returns the underlying buffer of the io descriptor.
int(* PrintfCallback)(const char *str,...) RZ_PRINTF_CHECK(1
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
static struct sockaddr static addrlen static backlog const void static flags void flags
RzIOIsValidOff is_valid_offset
RzIOAddrIsMapped addr_is_mapped
RzIOGetCurrentFd fd_get_current
RzIOFdGetName fd_get_name
RzIOFdWriteAt fd_write_at
RzIOMapGetPaddr map_get_paddr
ut8 cdata[RZ_IO_DESC_CACHE_SIZE]
struct rz_io_plugin_t * plugin
void * user
Uninterpreted data to be injected from outside.
int(* read)(RzIO *io, RzIODesc *fd, ut8 *buf, int count)
int(* gettid)(RzIODesc *desc)
bool(* getbase)(RzIODesc *desc, ut64 *base)
int(* listener)(RzIODesc *io)
bool(* resize)(RzIO *io, RzIODesc *fd, ut64 size)
bool(* is_blockdevice)(RzIODesc *desc)
int(* create)(RzIO *io, const char *file, int mode, int type)
int(* close)(RzIODesc *desc)
int(* write)(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
int(* getpid)(RzIODesc *desc)
bool(* check)(RzIO *io, const char *, bool many)
bool(* is_chardevice)(RzIODesc *desc)
bool(* accept)(RzIO *io, RzIODesc *desc, int fd)
ut64(* lseek)(RzIO *io, RzIODesc *fd, ut64 offset, int whence)
struct rz_io_desc_t * desc
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]